* INLINE functions for initializing and accessing I/O data channels
*/
-#define NUMSIGNALS(x, q) \
- (((struct spar_io_channel_protocol *)(x))->q.MaxSignalSlots)
#define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64))
#define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64))
-#define IO_CHANNEL_SIZE(x) COVER(SIZEOF_PROTOCOL + \
- (NUMSIGNALS(x, cmd_q) + \
- NUMSIGNALS(x, rsp_q)) * SIZEOF_CMDRSP, 4096)
#define MIN_IO_CHANNEL_SIZE COVER(SIZEOF_PROTOCOL + \
2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096)
-#ifdef __GNUC__
-/* These defines should only ever be used in service partitons */
-/* because they rely on the size of uiscmdrsp */
-#define QSLOTSFROMBYTES(bytes) (((bytes-SIZEOF_PROTOCOL)/2)/SIZEOF_CMDRSP)
-#define QSIZEFROMBYTES(bytes) (QSLOTSFROMBYTES(bytes)*SIZEOF_CMDRSP)
-#define SignalQInit(x) \
- do { \
- x->cmd_q.size = QSIZEFROMBYTES(x->channel_header.size); \
- x->cmd_q.sig_base_offset = SIZEOF_PROTOCOL - \
- offsetof(struct spar_io_channel_protocol, cmd_q);\
- x->cmd_q.signal_size = SIZEOF_CMDRSP; \
- x->cmd_q.max_slots = \
- QSLOTSFROMBYTES(x->channel_header.size); \
- x->cmd_q.max_signals = x->cmd_q.max_slots - 1; \
- x->rsp_q.size = QSIZEFROMBYTES(x->channel_header.size); \
- x->rsp_q.sig_base_offset = \
- (SIZEOF_PROTOCOL + x->cmd_q.size) - \
- offsetof(struct spar_io_channel_protocol, rsp_q);\
- x->rsp_q.signal_size = SIZEOF_CMDRSP; \
- x->rsp_q.max_slots = \
- QSLOTSFROMBYTES(x->channel_header.size); \
- x->rsp_q.max_signals = x->rsp_q.max_slots - 1; \
- x->channel_header.ch_space_offset = \
- offsetof(struct spar_io_channel_protocol, cmd_q);\
- } while (0)
-
-#define INIT_CLIENTSTRING(chan, type, clientStr, clientStrLen) \
- do { \
- if (clientStr) { \
- chan->channel_header.cli_str_offset = \
- offsetof(type, client_string); \
- memcpy(chan->client_string, clientStr, \
- MINNUM(clientStrLen, \
- (u32)(MAX_CLIENTSTRING_LEN - 1))); \
- chan->client_string[MINNUM(clientStrLen, \
- (u32)(MAX_CLIENTSTRING_LEN \
- - 1))] \
- = '\0'; \
- } \
- else \
- if (clientStrLen > 0) \
- return 0; \
- } while (0)
-
-#define ULTRA_IO_CHANNEL_SERVER_READY(x, chanId, logCtx) \
- ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, CHANNELSRV_READY, \
- logCtx)
-
-#define ULTRA_IO_CHANNEL_SERVER_NOTREADY(x, chanId, logCtx) \
- ULTRA_CHANNEL_SERVER_TRANSITION(x, chanId, SrvState, \
- CHANNELSRV_UNINITIALIZED, logCtx)
-
-static inline int ULTRA_VHBA_init_channel(struct spar_io_channel_protocol *x,
- struct vhba_wwnn *wwnn,
- struct vhba_config_max *max,
- unsigned char *clientStr,
- u32 clientStrLen, u64 bytes) {
- memset(x, 0, sizeof(struct spar_io_channel_protocol));
- x->channel_header.version_id = ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID;
- x->channel_header.signature = ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE;
- x->channel_header.srv_state = CHANNELSRV_UNINITIALIZED;
- x->channel_header.header_size = sizeof(x->channel_header);
- x->channel_header.size = COVER(bytes, 4096);
- x->channel_header.chtype = spar_vhba_channel_protocol_uuid;
- x->channel_header.zone_uuid = NULL_UUID_LE;
- x->vhba.wwnn = *wwnn;
- x->vhba.max = *max;
- INIT_CLIENTSTRING(x, struct spar_io_channel_protocol, clientStr,
- clientStrLen);
- SignalQInit(x);
- if ((x->cmd_q.max_slots > MAX_NUMSIGNALS) ||
- (x->rsp_q.max_slots > MAX_NUMSIGNALS)) {
- return 0;
- }
- if ((x->cmd_q.max_slots < MIN_NUMSIGNALS) ||
- (x->rsp_q.max_slots < MIN_NUMSIGNALS)) {
- return 0;
- }
- return 1;
-}
-
-static inline void ULTRA_VHBA_set_max(struct spar_io_channel_protocol *x,
- struct vhba_config_max *max) {
- x->vhba.max = *max;
-}
-
-static inline int ULTRA_VNIC_init_channel(struct spar_io_channel_protocol *x,
- unsigned char *macaddr,
- u32 num_rcv_bufs, u32 mtu,
- uuid_le zoneGuid,
- unsigned char *clientStr,
- u32 clientStrLen,
- u64 bytes) {
- memset(x, 0, sizeof(struct spar_io_channel_protocol));
- x->channel_header.version_id = ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID;
- x->channel_header.signature = ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE;
- x->channel_header.srv_state = CHANNELSRV_UNINITIALIZED;
- x->channel_header.header_size = sizeof(x->channel_header);
- x->channel_header.size = COVER(bytes, 4096);
- x->channel_header.chtype = spar_vnic_channel_protocol_uuid;
- x->channel_header.zone_uuid = NULL_UUID_LE;
- memcpy(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN);
- x->vnic.num_rcv_bufs = num_rcv_bufs;
- x->vnic.mtu = mtu;
- x->vnic.zone_uuid = zoneGuid;
- INIT_CLIENTSTRING(x, struct spar_io_channel_protocol, clientStr,
- clientStrLen);
- SignalQInit(x);
- if ((x->cmd_q.max_slots > MAX_NUMSIGNALS) ||
- (x->rsp_q.max_slots > MAX_NUMSIGNALS)) {
- return 0;
- }
- if ((x->cmd_q.max_slots < MIN_NUMSIGNALS) ||
- (x->rsp_q.max_slots < MIN_NUMSIGNALS)) {
- return 0;
- }
- return 1;
-}
-
-#endif /* __GNUC__ */
/*
* INLINE function for expanding a guest's pfn-off-size into multiple 4K page