xref: /onnv-gate/usr/src/uts/common/sys/ib/mgt/ibmf/ibmf_msg.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_IB_MGT_IBMF_IBMF_MSG_H
28*0Sstevel@tonic-gate #define	_SYS_IB_MGT_IBMF_IBMF_MSG_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef __cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #define	IBMF_MAD_SIZE			0x100
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate /*
39*0Sstevel@tonic-gate  * ibmf_addr definition
40*0Sstevel@tonic-gate  *	This is local address information.
41*0Sstevel@tonic-gate  *
42*0Sstevel@tonic-gate  *	When used in ibmf_msg_transport, local_lid refers to the (local) sender
43*0Sstevel@tonic-gate  *	and remote_lid/remote_qno refer to the destination (ie., receiver).
44*0Sstevel@tonic-gate  *	When used in async message callback, local_lid is the (local) receiver
45*0Sstevel@tonic-gate  *	and remote_lid/remote_qno refer to the (remote) source; ibmf fills
46*0Sstevel@tonic-gate  *	all fields of the addr_info_t when generating the receive callback.
47*0Sstevel@tonic-gate  *
48*0Sstevel@tonic-gate  *	Note that the sender and receiver may be on the same node/port.
49*0Sstevel@tonic-gate  */
50*0Sstevel@tonic-gate typedef struct _ibmf_addr_info {
51*0Sstevel@tonic-gate 	ib_lid_t		ia_local_lid;
52*0Sstevel@tonic-gate 	ib_lid_t		ia_remote_lid;
53*0Sstevel@tonic-gate 	ib_qpn_t		ia_remote_qno;
54*0Sstevel@tonic-gate 	ib_pkey_t		ia_p_key;
55*0Sstevel@tonic-gate 	ib_qkey_t		ia_q_key;
56*0Sstevel@tonic-gate 	uint8_t			ia_service_level:4;
57*0Sstevel@tonic-gate } ibmf_addr_info_t;
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate /*
60*0Sstevel@tonic-gate  * ibmf_global_addr_info_t
61*0Sstevel@tonic-gate  *	This has the global address information. This is filled in by the
62*0Sstevel@tonic-gate  *	client when sending the message and will be filled in by IBMF when
63*0Sstevel@tonic-gate  *	a message is received. ip_global_addr_valid is B_TRUE if global
64*0Sstevel@tonic-gate  *	address component of the message is valid (ip_global_addr_valid is
65*0Sstevel@tonic-gate  *	set by the client when sending packets and set by IBMF when packets
66*0Sstevel@tonic-gate  *	are received).
67*0Sstevel@tonic-gate  */
68*0Sstevel@tonic-gate typedef struct _ibmf_global_addr_info {
69*0Sstevel@tonic-gate 	ib_gid_t		ig_sender_gid;	/* gid of the sender */
70*0Sstevel@tonic-gate 	ib_gid_t		ig_recver_gid;	/* gid of the receiver */
71*0Sstevel@tonic-gate 	uint32_t		ig_flow_label;	/* pkt grouping */
72*0Sstevel@tonic-gate 	uint8_t			ig_tclass;	/* end-to-end service level */
73*0Sstevel@tonic-gate 	uint8_t			ig_hop_limit;	/* inter subnet hops */
74*0Sstevel@tonic-gate } ibmf_global_addr_info_t;
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate /*
77*0Sstevel@tonic-gate  * ibmf_msg_bufs_t
78*0Sstevel@tonic-gate  *	From the client's perspective, the message will consist of three
79*0Sstevel@tonic-gate  *	sections, the MAD header, the Management Class header, and the
80*0Sstevel@tonic-gate  *	data payload. IBMF will either assemble these sections into
81*0Sstevel@tonic-gate  *	a message or disassemble the incoming message into these sections.
82*0Sstevel@tonic-gate  *
83*0Sstevel@tonic-gate  *	The MAD header buffer is always 24 bytes in length.
84*0Sstevel@tonic-gate  *	It may be set to NULL only when the QP is configured for raw
85*0Sstevel@tonic-gate  *	UD traffic through the flags specified in ibmf_alloc_qp().
86*0Sstevel@tonic-gate  *
87*0Sstevel@tonic-gate  *	The class header buffer pointer may point to a buffer containing
88*0Sstevel@tonic-gate  *	the class specific header as defined by the IB Architecture
89*0Sstevel@tonic-gate  *	Specification, rev1.1. Note that the RMPP header should not be
90*0Sstevel@tonic-gate  *	included in the class header for classes that support RMPP.
91*0Sstevel@tonic-gate  *	For example, for the Subnet Administration (SA) class, the class
92*0Sstevel@tonic-gate  *	header starts at byte offset 36 in the MAD and is of length 20 bytes.
93*0Sstevel@tonic-gate  *
94*0Sstevel@tonic-gate  *	The data is provided in a buffer pointed to by im_bufs_cl_data,
95*0Sstevel@tonic-gate  *	with the data length provided in im_bufs_cl_data_len.
96*0Sstevel@tonic-gate  *
97*0Sstevel@tonic-gate  *	When sending a MAD message, the client may choose to not provide
98*0Sstevel@tonic-gate  *	a class header buffer in im_msgbufs_send.im_bufs_cl_hdr.
99*0Sstevel@tonic-gate  *	In this case, the im_msgbufs_send.im_bufs_cl_hdr must be NULL,
100*0Sstevel@tonic-gate  *	and IBMF will interpret this to imply that the class header
101*0Sstevel@tonic-gate  *	and data buffer are grouped together in the
102*0Sstevel@tonic-gate  *	im_msgbufs_send.im_bufs_cl_data buffer.
103*0Sstevel@tonic-gate  *
104*0Sstevel@tonic-gate  *	When sending a RAW UD packet over a non-special QP (i.e. not
105*0Sstevel@tonic-gate  *	IBMF_QP_HANDLE_DEFAULT), the entire packet must be provided
106*0Sstevel@tonic-gate  *	in a buffer pointed to by im_msgbufs_send.im_bufs_cl_data.
107*0Sstevel@tonic-gate  *	The im_msgbufs_send.im_bufs_mad_hdr and
108*0Sstevel@tonic-gate  *	im_msgbufs_send.im_bufs_cl_hdr pointers should be NULL.
109*0Sstevel@tonic-gate  *
110*0Sstevel@tonic-gate  *	The data contained in these buffers, MAD header, Management Class
111*0Sstevel@tonic-gate  *	header, and data payload buffers, must be in wire format which
112*0Sstevel@tonic-gate  *	is the big-endian format.
113*0Sstevel@tonic-gate  */
114*0Sstevel@tonic-gate typedef struct _ibmf_msg_bufs {
115*0Sstevel@tonic-gate 	ib_mad_hdr_t	*im_bufs_mad_hdr;	/* mad hdr (24 bytes) */
116*0Sstevel@tonic-gate 	void		*im_bufs_cl_hdr;	/* class hdr buffer ptr */
117*0Sstevel@tonic-gate 	size_t		im_bufs_cl_hdr_len;	/* class hdr buffer len ptr */
118*0Sstevel@tonic-gate 	void		*im_bufs_cl_data;	/* mad class data buf ptr */
119*0Sstevel@tonic-gate 	size_t		im_bufs_cl_data_len; 	/* mad class data len ptr */
120*0Sstevel@tonic-gate } ibmf_msg_bufs_t;
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate /*
123*0Sstevel@tonic-gate  * ibmf_msg definition
124*0Sstevel@tonic-gate  *	The IBMF client initializes various members of the msg while sending
125*0Sstevel@tonic-gate  *	the message. IBMF fills in the various members of the msg when a message
126*0Sstevel@tonic-gate  *	is received.
127*0Sstevel@tonic-gate  *	The im_msgbufs_send buffers must always be allocated and freed
128*0Sstevel@tonic-gate  *	by the client of ibmf. Message content passed from client to ibmf
129*0Sstevel@tonic-gate  *	must be through the im_msgbufs_send buffers.
130*0Sstevel@tonic-gate  *	The im_msgbufs_recv buffers must always be allocated and freed
131*0Sstevel@tonic-gate  *	by ibmf. Message content passed from ibmf to client
132*0Sstevel@tonic-gate  *	will always be through the im_msgbufs_recv buffers.
133*0Sstevel@tonic-gate  *
134*0Sstevel@tonic-gate  *	im_msg_status: contains the IBMF status (defined in ibmf.h) of
135*0Sstevel@tonic-gate  *	the transaction. This is the same as the return value of the
136*0Sstevel@tonic-gate  *	ibmf_msg_transport() call for a blocking transaction.
137*0Sstevel@tonic-gate  *
138*0Sstevel@tonic-gate  *	im_msg_flags:  must be set to IBMF_MSG_FLAGS_GLOBAL_ADDRESS by
139*0Sstevel@tonic-gate  *	the IBMF client if the send buffer contains a valid GRH, and by
140*0Sstevel@tonic-gate  *	IBMF if the receive buffer contains a valid GRH
141*0Sstevel@tonic-gate  *
142*0Sstevel@tonic-gate  *	Note on Host versus IB Wire format:
143*0Sstevel@tonic-gate  *	Any MAD data passed in the buffers pointed to by im_bufs_mad_hdr,
144*0Sstevel@tonic-gate  *	im_bufs_cl_hdr, and im_bufs_cl_data in im_msgbufs_send and
145*0Sstevel@tonic-gate  *	im_msgbufs_recv should be in IB wire format.
146*0Sstevel@tonic-gate  *	All other data in the ibmf_msg_t structure should be in host format,
147*0Sstevel@tonic-gate  *	including the data in im_local_addr and im_global_addr.
148*0Sstevel@tonic-gate  */
149*0Sstevel@tonic-gate typedef struct _ibmf_msg {
150*0Sstevel@tonic-gate 	ibmf_addr_info_t	im_local_addr;	/* local addressing info */
151*0Sstevel@tonic-gate 	ibmf_global_addr_info_t	im_global_addr;	/* global addressing info */
152*0Sstevel@tonic-gate 	int32_t			im_msg_status;	/* completion status */
153*0Sstevel@tonic-gate 	uint32_t		im_msg_flags;	/* flags */
154*0Sstevel@tonic-gate 	size_t			im_msg_sz_limit; /* max. message size */
155*0Sstevel@tonic-gate 	ibmf_msg_bufs_t		im_msgbufs_send; /* input data to ibmf */
156*0Sstevel@tonic-gate 	ibmf_msg_bufs_t		im_msgbufs_recv; /* output data from ibmf */
157*0Sstevel@tonic-gate } ibmf_msg_t;
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate #ifdef __cplusplus
160*0Sstevel@tonic-gate }
161*0Sstevel@tonic-gate #endif
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate #endif /* _SYS_IB_MGT_IBMF_IBMF_MSG_H */
164