ds_impl.h revision beba1dd881728e806abb8621851ae851da168a08
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DS_IMPL_H
#define _DS_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* The Domain Services Protocol
*
* The DS protocol is divided into two parts. The first is fixed and
* must remain exactly the same for *all* versions of the DS protocol.
* The only messages supported by the fixed portion of the protocol are
* to negotiate a version to use for the rest of the protocol.
*/
/*
* Domain Services Header
*/
typedef struct ds_hdr {
} ds_hdr_t;
/*
* DS Fixed Message Types
*/
/*
* DS Fixed Initialization Messages
*/
typedef struct ds_init_req {
typedef struct ds_init_ack {
typedef struct ds_init_nack {
/*
* DS Message Types for Version 1.0
*/
/* result codes */
/*
* Service Register Messages
*/
typedef struct ds_reg_req {
} ds_reg_req_t;
typedef struct ds_reg_ack {
} ds_reg_ack_t;
typedef struct ds_reg_nack {
/*
* Service Unregister Messages
*/
typedef struct ds_unreg_req {
typedef struct ds_unreg_ack {
typedef struct ds_unreg_nack {
/*
* Data Transfer Messages
*/
typedef struct ds_data_handle {
typedef struct ds_data_nack {
/*
* Message Processing Utilities
*/
/*
* Domain Service Port
*
* A DS port is a logical representation of an LDC dedicated to
* communication between DS endpoints. The ds_port_t maintains state
* associated with a connection to a remote endpoint. This includes
* the state of the port, the LDC state, the current version of the
* DS protocol in use on the port, and other port properties.
*
* Locking: The port is protected by a single mutex. It must be held
* while the port structure is being accessed and also when data is
* being read or written using the port
*/
typedef enum {
DS_PORT_FREE, /* port structure not in use */
DS_PORT_INIT, /* port structure created */
DS_PORT_LDC_INIT, /* ldc successfully initialized */
DS_PORT_INIT_REQ, /* initialization handshake sent */
DS_PORT_READY /* init handshake completed */
typedef struct ds_ldc {
} ds_ldc_t;
typedef uint64_t ds_domain_hdl_t;
/* port flags */
typedef struct ds_port {
char *domain_name; /* LDOMs domain name assoc. with port */
} ds_port_t;
/*
* A DS portset is a bitmap that represents a collection of DS
* ports. Each bit represent a particular port id. We need
* to allocate for the max. number of domains supported,
* plus a small number (e.g. for the SP connection).
*/
#define DS_EXTRA_PORTS 16
extern ds_portset_t ds_nullport;
/* DS SP Port ID */
extern uint64_t ds_sp_port_id;
sizeof (set)) == 0)
sizeof (set1)))
/*
* A DS event consists of a buffer on a port. We explictly use a link to
*/
typedef struct ds_event {
char *buf;
} ds_event_t;
/*
* LDC Information
*/
#define DS_STREAM_MTU 4096
/*
* Machine Description Constants
*/
#define DS_MD_ROOT_NAME "domain-services"
#define DS_MD_PORT_NAME "domain-services-port"
#define DS_MD_CHAN_NAME "channel-endpoint"
/*
* DS Services
*
* A DS Service is a mapping between a DS capability and a client
* of the DS framework that provides that capability. It includes
* information on the state of the service, the currently negotiated
* version of the capability specific protocol, the port that is
* currently in use by the capability, etc.
*/
typedef enum {
DS_SVC_INVAL, /* svc structure uninitialized */
DS_SVC_FREE, /* svc structure not in use */
DS_SVC_INACTIVE, /* svc not registered */
DS_SVC_REG_PENDING, /* register message sent */
DS_SVC_ACTIVE, /* register message acknowledged */
DS_SVC_UNREG_PENDING /* unregister is pending */
/* ds_svc flags bits */
typedef struct ds_svc {
int fixed; /* is svc fixed to port */
void *drv_psp; /* driver per svc ptr */
} ds_svc_t;
typedef struct ds_svcs {
} ds_svcs_t;
#ifndef DS_MAXSVCS_INIT
#define DS_MAXSVCS_INIT 32
#endif
/*
* A service handle is a 64 bit value with three pieces of information
* encoded in it. The upper 32 bits is the index into the table of
* a particular service structure. Bit 31 indicates whether the handle
* represents a service privider or service client. The lower 31 bits is
* a counter that is incremented each time a service structure is reused.
*/
#define DS_IDX_SHIFT 32
#define DS_COUNT_MASK 0x7fffffffull
#define DS_HDL_ISCLIENT_BIT 0x80000000ull
#define DS_INVALID_INSTANCE (-1)
extern boolean_t ds_enabled;
/*
* DS Message Logging
*
* The DS framework logs all incoming and outgoing messages to a
* ring buffer. This provides the ability to reconstruct a trace
* of DS activity for use in debugging. In addition to the message
* data, each log entry contains a timestamp and the destination
* of the message. The destination is based on the port number the
* message passed through (port number + 1). The sign of the dest
* field distinguishes incoming messages from outgoing messages.
* Incoming messages have a negative destination field.
*/
typedef struct ds_log_entry {
void *data; /* the data itself */
/*
* DS Log Limits:
*
* The size of the log is controlled by two limits. The first is
* a soft limit that is configurable by the user (via the global
* variable ds_log_sz). When this limit is exceeded, each new
* message that is added to the log replaces the oldest message.
*
* The second is a hard limit that is calculated based on the soft
* limit (DS_LOG_LIMIT). It is defined to be ~3% above the soft limit.
* Once this limit is exceeded, a thread is scheduled to delete old
* messages until the size of the log is below the soft limit.
*/
/*
* DS Log Memory Usage:
*
* The log free list is initialized from a pre-allocated pool of entry
* structures (the global ds_log_entry_pool). The number of entries
* in the pool (DS_LOG_NPOOL) is the number of entries that would
* take up half the default size of the log.
*
* As messages are added to the log, entry structures are pulled from
* the free list. If the free list is empty, memory is allocated for
* the entry. When entries are removed from the log, they are placed
* on the free list. Allocated memory is only deallocated when the
* entire log is destroyed.
*/
sizeof (ds_log_entry_t))
/* VBSC code compatability related defines */
/* VBSC debug print needs newline, Solaris cmn_err doesn't */
#define DS_EOL
/*
* Results of checking version array with ds_vers_isvalid()
*/
typedef enum {
/* System specific interfaces */
/* vlds cb access to svc structure */
/* initialization functions */
void ds_common_init(void);
/* message sending functions */
/* walker functions */
/* service utilities */
ds_svc_t *ds_alloc_svc(void);
int is_client);
/* port utilities */
/* misc utilities */
/* log functions */
/* vlds driver interfaces to ds module */
void ds_unreg_all(int instance);
/* ds_ucap_init flags */
/*
* Error buffer size for ds_errno_to_str
*/
#define DS_EBUFSIZE 80
/*
* Debugging Features
*/
#ifdef DEBUG
#define DS_DBG_BASIC 0x001
#define DS_DBG_FLAG_LDC 0x002
#define DS_DBG_FLAG_LOG 0x004
#define DS_DBG_DUMP_LDC_MSG 0x008
#define DS_DBG_FLAG_MD 0x010
#define DS_DBG_FLAG_USR 0x020
#define DS_DBG_FLAG_VLDS 0x040
#define DS_DBG_FLAG_PRCL 0x080
#define DS_DBG_FLAG_RCVQ 0x100
#define DS_DBG_FLAG_LOOP 0x200
#else /* DEBUG */
#define DS_DBG_LDC DS_DBG
#define DS_DBG_LOG DS_DBG
#define DS_DBG_USR DS_DBG
#define DS_DBG_VLDS DS_DBG
#define DS_DBG_PRCL DS_DBG
#define DS_DBG_RCVQ DS_DBG
#define DS_DBG_LOOP DS_DBG
#define DS_BADHDL1 NULL
#define DS_BADHDL2 NULL
#endif /* DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _DS_IMPL_H */