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