xref: /illumos-gate/usr/src/uts/common/sys/ib/clients/daplt/daplt_if.h (revision 9e39c5ba00a55fa05777cc94b148296af305e135)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_DAPL_IF_H_
28 #define	_DAPL_IF_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* change this "version" everytime the interface changes */
35 #define	DAPL_IF_VERSION			(0x05302007)
36 
37 #define	DAPL_IOC			(0x0da9 << 16)
38 #define	DAPL_TYPE_IA			(DAPL_IOC | 0x11 << 8)
39 #define	DAPL_TYPE_EVD			(DAPL_IOC | 0x12 << 8)
40 #define	DAPL_TYPE_EP			(DAPL_IOC | 0x13 << 8)
41 #define	DAPL_TYPE_MR			(DAPL_IOC | 0x14 << 8)
42 #define	DAPL_TYPE_PD			(DAPL_IOC | 0x15 << 8)
43 #define	DAPL_TYPE_SP			(DAPL_IOC | 0x16 << 8)
44 #define	DAPL_TYPE_CNO			(DAPL_IOC | 0x17 << 8)
45 #define	DAPL_TYPE_MW			(DAPL_IOC | 0x18 << 8)
46 #define	DAPL_TYPE_MISC			(DAPL_IOC | 0x19 << 8)
47 #define	DAPL_TYPE_SRQ			(DAPL_IOC | 0x1a << 8)
48 #define	DAPL_TYPE_NONE			(DAPL_IOC | 0x1f << 8)
49 #define	DAPL_TYPE_MASK			(0xffffff00)
50 
51 /* NONE */
52 #define	DAPL_IA_CREATE			(DAPL_TYPE_NONE | 0x01)
53 
54 /* MISC */
55 #define	DAPL_CR_ACCEPT			(DAPL_TYPE_MISC | 0x01)
56 #define	DAPL_CR_REJECT			(DAPL_TYPE_MISC | 0x02)
57 #define	DAPL_IA_QUERY			(DAPL_TYPE_MISC | 0x03)
58 #define	DAPL_CR_HANDOFF			(DAPL_TYPE_MISC | 0x04)
59 
60 /* EP */
61 #define	DAPL_EP_CREATE			(DAPL_TYPE_EP | 0x01)
62 #define	DAPL_EP_FREE			(DAPL_TYPE_EP | 0x02)
63 #define	DAPL_EP_CONNECT			(DAPL_TYPE_EP | 0x03)
64 #define	DAPL_EP_MODIFY			(DAPL_TYPE_EP | 0x04)
65 #define	DAPL_EP_DISCONNECT		(DAPL_TYPE_EP | 0x05)
66 #define	DAPL_EP_REINIT			(DAPL_TYPE_EP | 0x06)
67 
68 /* EVD */
69 #define	DAPL_EVD_CREATE			(DAPL_TYPE_EVD | 0x01)
70 #define	DAPL_CQ_RESIZE			(DAPL_TYPE_EVD | 0x02)
71 #define	DAPL_EVD_FREE			(DAPL_TYPE_EVD | 0x03)
72 #define	DAPL_EVENT_POLL			(DAPL_TYPE_EVD | 0x04)
73 #define	DAPL_EVENT_WAKEUP		(DAPL_TYPE_EVD | 0x05)
74 #define	DAPL_EVD_MODIFY_CNO		(DAPL_TYPE_EVD | 0x06)
75 
76 /* MR */
77 #define	DAPL_MR_REGISTER		(DAPL_TYPE_MR | 0x01)
78 #define	DAPL_MR_REGISTER_LMR		(DAPL_TYPE_MR | 0x02)
79 #define	DAPL_MR_REGISTER_SHARED		(DAPL_TYPE_MR | 0x03)
80 #define	DAPL_MR_DEREGISTER		(DAPL_TYPE_MR | 0x04)
81 #define	DAPL_MR_SYNC			(DAPL_TYPE_MR | 0x05)
82 
83 /* MW */
84 #define	DAPL_MW_ALLOC			(DAPL_TYPE_MW | 0x01)
85 #define	DAPL_MW_FREE			(DAPL_TYPE_MW | 0x02)
86 
87 /* CNO */
88 #define	DAPL_CNO_ALLOC			(DAPL_TYPE_CNO | 0x01)
89 #define	DAPL_CNO_FREE			(DAPL_TYPE_CNO | 0x02)
90 #define	DAPL_CNO_WAIT			(DAPL_TYPE_CNO | 0x03)
91 
92 /* PD */
93 #define	DAPL_PD_ALLOC			(DAPL_TYPE_PD | 0x01)
94 #define	DAPL_PD_FREE			(DAPL_TYPE_PD | 0x02)
95 
96 /* SP */
97 #define	DAPL_SERVICE_REGISTER		(DAPL_TYPE_SP | 0x01)
98 #define	DAPL_SERVICE_DEREGISTER		(DAPL_TYPE_SP | 0x02)
99 
100 /* SRQ */
101 #define	DAPL_SRQ_CREATE			(DAPL_TYPE_SRQ	| 0x01)
102 #define	DAPL_SRQ_FREE			(DAPL_TYPE_SRQ	| 0x02)
103 #define	DAPL_SRQ_RESIZE			(DAPL_TYPE_SRQ	| 0x03)
104 
105 /*
106  * Drivers name and minor name.
107  */
108 #define	DAPLKA_DRV_NAME		"daplt"
109 #define	DAPLKA_MINOR_NAME	"daplt"
110 #define	DAPLKA_DEFAULT_PATH	"/devices/ib/daplt@0:daplt"
111 #define	DAPLKA_DRIVER_MINOR	0
112 
113 /*
114  * Upper limit on number of events that can be polled per event_poll ioctl
115  * Since we allocate memory in kernel there needs to be an upper bound.
116  */
117 #define	DAPL_EVD_MAX_EVENTS	16384
118 /*
119  * Number of events that we generally poll for in event_poll.
120  */
121 #define	NUM_EVENTS_PER_POLL	16
122 
123 /* duplicated from dat.h */
124 #ifndef _DAT_H_
125 typedef enum dat_evd_flags {
126 	DAT_EVD_SOFTWARE_FLAG	= 0x01,
127 	DAT_EVD_CR_FLAG		= 0x10,
128 	DAT_EVD_DTO_FLAG	= 0x20,
129 	DAT_EVD_CONNECTION_FLAG	= 0x40,
130 	DAT_EVD_RMR_BIND_FLAG	= 0x80,
131 	DAT_EVD_ASYNC_FLAG	= 0x100,
132 	/* DAT events only, no software events */
133 	DAT_EVD_DEFAULT_FLAG	= 0x1F0
134 } DAT_EVD_FLAGS;
135 #endif /* _DAT_H_ */
136 
137 #define	DAPL_MAX_PRIVATE_DATA_SIZE	IBT_MAX_PRIV_DATA_SZ
138 #define	DAPL_ATS_NBYTES			16	/* SA record data length */
139 
140 /*
141  * All structures defined herein are used for ioctls. On amd64,
142  * use pack(4) to make structures match the x86 alignment rules.
143  */
144 
145 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
146 #pragma pack(4)
147 #endif
148 
149 /*
150  *				      Byte     Offset
151  * uDAPL client's private data		64	00
152  * Base Sockets Direct Header (BSDH)	 4	64
153  * Extended Header				68
154  *  Hello Message (HH)			24
155  *
156  *   bits	32-24		23-16		15-8	7-0
157  * bytes
158  * 00-63	uDAPL client's private data
159  * 64-67	MID             client_msg_len	checksum
160  * 68-72	MajV MinV       IPV 		rsvd1
161  * 73-75	rsvd2				LocalPort
162  * 76-79	SrcIP(127-96)
163  * 80-83	SrcIP(95-64)
164  * 84-87	SrcIP(63-32)
165  * 88-92	SrcIP(31-00)
166  *
167  */
168 typedef union dapl_ia_addr_s {
169 	struct {
170 		uint32_t	iad_pad[3];
171 		struct in_addr	iad_v4data;
172 	} iad_v4_s;			/* IPv4 format */
173 	in6_addr_t	iad_v6data;	/* IPv6 format */
174 	uint8_t		iad_sadata[DAPL_ATS_NBYTES]; /* SA format */
175 	uint32_t	iad_src;	/* alignment */
176 } dapl_ia_addr_t;
177 #define	iad_v4		iad_v4_s.iad_v4data
178 #define	iad_v4pad	iad_v4_s.iad_pad
179 #define	iad_v6		iad_v6data
180 #define	iad_sa		iad_sadata
181 
182 typedef struct dapl_hello_msg {
183 	uint16_t	hi_checksum;	/* checksum */
184 	uint8_t		hi_clen;	/* client private data len */
185 	uint8_t		hi_mid;		/* command - not use */
186 	uint16_t	hi_rsvd1;
187 	uint8_t		hi_ipv;		/* IP family ipv4 or ipv6 */
188 	uint8_t		hi_vers;	/* hello message version number */
189 	in_port_t	hi_port;	/* IP port number */
190 	uint16_t	hi_rsvd2;
191 	dapl_ia_addr_t	_hi_ipaddr;	/* IP address */
192 } DAPL_HELLO_MSG;
193 /* different views of the address field */
194 #define	hi_v4ipaddr	_hi_ipaddr.iad_v4	/* IPv4 */
195 #define	hi_v4pad	_hi_ipaddr.iad_v4pad
196 #define	hi_v6ipaddr	_hi_ipaddr.iad_v6	/* IPv6 */
197 #define	hi_saaddr	_hi_ipaddr.iad_sa	/* 16 bytes SA record */
198 
199 #define	DAPL_CHECKSUM		0xbeef		/* use as magic number */
200 #define	DAPL_HELLO_MSG_VERS	0x10		/* major 1 minor 0 */
201 /* DAPL_PRIVATE used to pass private data in a connection */
202 #define	DAPL_CONSUMER_MAX_PRIVATE_DATA_SIZE	64
203 typedef struct dapl_private {
204 	unsigned char private_data[DAPL_CONSUMER_MAX_PRIVATE_DATA_SIZE];
205 	DAPL_HELLO_MSG hello_msg;
206 } DAPL_PRIVATE;
207 
208 /* EP ioctl interfaces */
209 
210 /*
211  * Definitions used by DAPL for HCA specific "data out" information.  This
212  * data is opaque to daplt, and is consumed by HCA specific code in the
213  * userland library.
214  *
215  * The sizes (in units of uint64_t) need to be big enough for all HCAs
216  * supported.  Although 16 is large enough, since we never want to have
217  * to change our interface version just because we undersized this, we
218  * have chosen 24.
219  */
220 #define	DAPL_CQ_DATA_OUT_SIZE	24
221 #define	DAPL_QP_DATA_OUT_SIZE	24
222 #define	DAPL_SRQ_DATA_OUT_SIZE	24
223 
224 typedef uint64_t dapl_cq_data_out_t[DAPL_QP_DATA_OUT_SIZE];
225 typedef uint64_t dapl_qp_data_out_t[DAPL_CQ_DATA_OUT_SIZE];
226 typedef uint64_t dapl_srq_data_out_t[DAPL_SRQ_DATA_OUT_SIZE];
227 
228 /*
229  * Channel sizes struct, copy of ibt_chan_sizes_t so that it can work
230  * fine for both 32/64 bit library
231  */
232 typedef struct dapl_chan_sizes_s {
233 	uint_t	dcs_sq;		/* SendQ size. */
234 	uint_t	dcs_rq;		/* ReceiveQ size. */
235 	uint_t	dcs_sq_sgl;	/* Max SGL elements in a SQ WR. */
236 	uint_t	dcs_rq_sgl;	/* Max SGL elements in a RQ Wr. */
237 } dapl_chan_sizes_t;
238 
239 /*
240  * EP create ioctl message structure
241  */
242 typedef struct dapl_ep_create_s {
243 	uint64_t		ep_hkey;	  /* hash key of the EP */
244 	uint64_t		ep_pd_hkey;	  /* PD hash key */
245 	uint64_t		ep_rcv_evd_hkey;  /* Recv evd hash key */
246 	uint64_t		ep_snd_evd_hkey;  /* Send evd hash key */
247 	uint64_t		ep_conn_evd_hkey; /* Conn evd hash key */
248 	uint64_t		ep_srq_hkey;	  /* SRQ hash key	*/
249 	uint32_t		ep_srq_attached;  /* EP with SRQ - 1 or 0 */
250 	uint64_t		ep_cookie;	  /* Userland EP pointer */
251 	dapl_chan_sizes_t	ep_ch_sizes;	  /* Requested RC params */
252 	dapl_chan_sizes_t	ep_ch_real_sizes; /* Allocated RC params */
253 	dapl_qp_data_out_t	ep_qp_data_out;
254 } dapl_ep_create_t;
255 
256 /*
257  * Modify is not yet completely implemented
258  */
259 typedef struct dapl_ep_modify_s {
260 	uint64_t		epm_hkey;
261 	ibt_cep_modify_flags_t	epm_flags;
262 	uint8_t			epm_rdma_ra_out;
263 	uint8_t			epm_rdma_ra_in;
264 } dapl_ep_modify_t;
265 
266 /*
267  * EP Connect ioctl message
268  */
269 typedef struct dapl_ep_connect_s {
270 	uint64_t		epc_hkey;	/* EP hash key		*/
271 	ib_gid_t		epc_dgid;	/* destination gid	*/
272 	uint64_t		epc_sid;	/* service id		*/
273 	uint64_t		epc_timeout;	/* timeout		*/
274 	uint32_t		epc_priv_sz;	/* private data size	*/
275 	dapl_ia_addr_t		epc_raddr_sadata; /* remote addr in SA format */
276 	uchar_t			epc_priv[DAPL_MAX_PRIVATE_DATA_SIZE];
277 } dapl_ep_connect_t;
278 
279 typedef struct dapl_ep_disconnect_s {
280 	uint64_t		epd_hkey;	/* EP hash key */
281 } dapl_ep_disconnect_t;
282 
283 /*
284  * EP reinit ioctl called to recycle the RC
285  */
286 typedef struct dapl_ep_reinit_s {
287 	uint64_t		epri_hkey;	 /* EP hash key */
288 	uint64_t		epri_map_offset; /* Mapping offset of new QP */
289 	uint64_t		epri_map_len;	 /* Map len of new QP	*/
290 	uint32_t		epri_qpnum;	 /* QPnum of the new QP */
291 	uint32_t		epri_rq_offset;  /* New RecvQ offset in buf */
292 	uint32_t		epri_rq_desc_addr; /* New RecvQ kernel addr */
293 	uint32_t		epri_rq_numwqe;
294 	uint32_t		epri_rq_wqesz;
295 	uint32_t		epri_sq_offset;  /* New SendQ offset in buf */
296 	uint32_t		epri_sq_desc_addr; /* New SendQ kernel addr */
297 	uint32_t		epri_sq_numwqe;
298 	uint32_t		epri_sq_wqesz;
299 } dapl_ep_reinit_t;
300 
301 typedef struct dapl_ep_free_s {
302 	uint64_t		epf_hkey;	/* EP hash key */
303 } dapl_ep_free_t;
304 
305 /* EVD ioctl interfaces */
306 
307 /*
308  * EVD create ioctl
309  */
310 typedef struct dapl_evd_create_s {
311 	uint64_t		evd_hkey;	/* EVD hash key */
312 	DAT_EVD_FLAGS		evd_flags;	/* EVD streams flag */
313 	uint64_t		evd_cookie;	/* userland EVD pointer */
314 	uint64_t		evd_cno_hkey;	/* CNO hash key */
315 	uint32_t		evd_cq_size;	/* Requested CQ Size */
316 	uint32_t		evd_cq_real_size;  /* Allocated CQ size */
317 	dapl_cq_data_out_t	evd_cq_data_out;
318 } dapl_evd_create_t;
319 
320 /*
321  * If an EVD has a CQ this ioctl message is used to resize the CQ
322  */
323 typedef struct dapl_cq_resize_s {
324 	uint64_t		cqr_evd_hkey;	  /* EVD hash key */
325 	uint32_t		cqr_cq_new_size;  /* New requested CQ size */
326 	uint32_t		cqr_cq_real_size; /* Allocated CQ size */
327 	dapl_cq_data_out_t	cqr_cq_data_out;
328 } dapl_cq_resize_t;
329 
330 /*
331  * Event type used while returning events from the kernel
332  */
333 typedef enum {
334 	/* event family for the Async events */
335 	DAPL_ASYNC_EVENTS = 0x01,
336 	/* event family for events posted by the PASSIVE side cm_handler */
337 	DAPL_CR_EVENTS = 0x02,
338 	/* event family for events posted by the PASSIVE side cm_handler */
339 	DAPL_PASSIVE_CONNECTION_EVENTS = 0x04,
340 	/* event family for events posted by the ACTIVE side cm_handler */
341 	DAPL_ACTIVE_CONNECTION_EVENTS = 0x08
342 } dapl_event_family_t;
343 
344 /*
345  * Async event structure
346  */
347 typedef struct dapl_ib_async_event_s {
348 	ibt_async_code_t	ibae_type;
349 	ib_guid_t		ibae_hca_guid; /* HCA node GUID */
350 	uint64_t		ibae_cookie; /* ep or cq pointer */
351 	uint8_t			ibae_port; /* HCA Port num unaffiliated evnt */
352 } dapl_ib_async_event_t;
353 
354 /*
355  * CM events definitions used to translate IBTF CM events to DAPL CM events
356  */
357 typedef enum {
358 	/* IBT_CM_EVENT_CONN_EST */
359 	DAPL_IB_CME_CONNECTED = 1,
360 	/* IBT_CM_EVENT_CONN_CLOSED */
361 	DAPL_IB_CME_DISCONNECTED,
362 	/* IBT_CM_EVENT_REQ_RCV */
363 	DAPL_IB_CME_CONNECTION_REQUEST_PENDING,
364 	DAPL_IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA,
365 	/* IBT_CM_EVENT_FAILURE */
366 	DAPL_IB_CME_DESTINATION_REJECT,
367 	DAPL_IB_CME_DESTINATION_REJECT_PRIVATE_DATA,
368 	/* Currently not mapped to IBTF CM events */
369 	DAPL_IB_CME_DESTINATION_UNREACHABLE,
370 	DAPL_IB_CME_TOO_MANY_CONNECTION_REQUESTS,
371 	DAPL_IB_CME_LOCAL_FAILURE,
372 	DAPL_IB_CME_TIMED_OUT,
373 	DAPL_IB_CME_DISCONNECTED_ON_LINK_DOWN,
374 	/*
375 	 * Not really a CM event but library uses CM events as reject reasons
376 	 * so to avoid any overlaps, make it part of this enum
377 	 */
378 	DAPL_IB_CM_REJ_REASON_CONSUMER_REJ
379 } dapl_ib_cm_event_type_t;
380 
381 /*
382  * CM event structure
383  */
384 typedef struct dapl_ib_cm_event_s {
385 	dapl_ib_cm_event_type_t	ibce_event;
386 	/* Userland PSP ptr for CR, EP ptr for CONNECTION */
387 	uint64_t		ibce_cookie;
388 	/* Unique CR cookie: tmstamp + Index in the connection pending table */
389 	uint64_t		ibce_psep_cookie;
390 	uint32_t		ibce_priv_data_size;
391 	uchar_t			ibce_priv_data_ptr[DAPL_MAX_PRIVATE_DATA_SIZE];
392 } dapl_ib_cm_event_t;
393 
394 /*
395  * Kernel Events structure used for returning CM or Async events
396  */
397 typedef struct dapl_ib_event_s {
398 	dapl_event_family_t	ibe_ev_family;
399 	union {
400 		dapl_ib_async_event_t	ibe_async; /* Async event */
401 		dapl_ib_cm_event_t	ibe_ce;	   /* CM event    */
402 	} ev_data;
403 #define	ibe_async	ev_data.ibe_async
404 #define	ibe_ce		ev_data.ibe_ce
405 } dapl_ib_event_t;
406 
407 /*
408  * Event poll ioctl message
409  */
410 typedef struct dapl_event_poll_s {
411 	uint64_t		evp_evd_hkey;  /* EVD hash key		*/
412 	uint64_t		evp_timeout;   /* Timeout value		*/
413 	uint_t			evp_threshold; /* Threshold passed in	*/
414 	dapl_ib_event_t		*evp_ep;    /* array of events to be filled */
415 	uint_t			evp_num_ev; /* array sz, possbly > threshold */
416 	uint_t			evp_num_polled; /* number of elements filled */
417 } dapl_event_poll_t;
418 
419 /*
420  * Event poll ioctl message
421  */
422 typedef struct dapl_event_poll32_s {
423 	uint64_t		evp_evd_hkey;  /* EVD hash key		*/
424 	uint64_t		evp_timeout;   /* Timeout value		*/
425 	uint_t			evp_threshold; /* Threshold passed in	*/
426 	caddr32_t		evp_ep;    /* array of events to be filled */
427 	uint_t			evp_num_ev; /* array sz, possbly > threshold */
428 	uint_t			evp_num_polled; /* number of elements filled */
429 } dapl_event_poll32_t;
430 
431 /*
432  * EVD hash key to wakeup
433  */
434 typedef struct dapl_event_wakeup_s {
435 	uint64_t		evw_hkey;	/* EVD hash key */
436 } dapl_event_wakeup_t;
437 
438 /*
439  * modify EVD to CNO association
440  */
441 typedef struct dapl_evd_modify_cno_s {
442 	uint64_t		evmc_hkey;	/* EVD hash key */
443 	uint64_t		evmc_cno_hkey;	/* new CNO hash key */
444 } dapl_evd_modify_cno_t;
445 
446 
447 /*
448  * EVD hash key to free
449  */
450 typedef struct dapl_evd_free_s {
451 	uint64_t		evf_hkey;	/* EVD hash key */
452 } dapl_evd_free_t;
453 
454 /* MR ioctl interfaces */
455 
456 /*
457  * MR register ioctl message
458  */
459 typedef struct dapl_mr_register_s {
460 	uint64_t		mr_hkey;    /* MR hash key		 */
461 	uint64_t		mr_pd_hkey; /* PD hash key		 */
462 	ib_vaddr_t		mr_vaddr; /* Virtual address to register */
463 	ib_memlen_t		mr_len;	  /* Length of region to register */
464 	ibt_mr_flags_t		mr_flags;
465 	ibt_lkey_t		mr_lkey;  /* Lkey returned from mr_register */
466 	ibt_rkey_t		mr_rkey;  /* Rkey returned from mr_register */
467 } dapl_mr_register_t;
468 
469 /*
470  * Shared MR cookie
471  */
472 typedef union dapl_mr_cookie_u {
473 	uint64_t		mc_uint_arr[5];
474 	uchar_t			mc_byte_arr[40];
475 } dapl_mr_cookie_t;
476 
477 /*
478  * Shared MR register ioctl message
479  */
480 typedef struct dapl_mr_register_shared_s {
481 	uint64_t		mrs_hkey;    /* MR hash key		 */
482 	uint64_t		mrs_pd_hkey; /* PD hash key		 */
483 	ib_vaddr_t		mrs_vaddr; /* Virtual address to register */
484 	ib_memlen_t		mrs_len;   /* Length of region to register */
485 	ibt_mr_flags_t		mrs_flags;
486 	ibt_lkey_t		mrs_lkey;  /* Lkey returned from mr_register */
487 	ibt_rkey_t		mrs_rkey;  /* Rkey returned from mr_register */
488 	dapl_mr_cookie_t	mrs_shm_cookie; /* shared mem cookie */
489 } dapl_mr_register_shared_t;
490 
491 /*
492  * MR based MR register ioctl message
493  */
494 typedef struct dapl_mr_register_lmr_s {
495 	uint64_t		mrl_hkey; /* MR hash key */
496 	uint64_t		mrl_orig_hkey; /* hash key of Original MR */
497 	ibt_mr_flags_t		mrl_flags;
498 	ibt_lkey_t		mrl_lkey; /* Lkey returned from mr_register */
499 	ibt_rkey_t		mrl_rkey; /* Rkey returned from mr_register */
500 } dapl_mr_register_lmr_t;
501 
502 /*
503  * MR deregister ioctl message
504  */
505 typedef struct dapl_mr_deregister_s {
506 	uint64_t		mrd_hkey; /* MR hash key */
507 } dapl_mr_deregister_t;
508 
509 /*
510  * MR RDMA sync ioctl message
511  */
512 
513 #define	DAPL_MR_PER_SYNC 16
514 #define	DAPL_MR_SYNC_RDMA_RD 0
515 #define	DAPL_MR_SYNC_RDMA_WR 1
516 
517 typedef struct dapl_mr_sync_vec_s {
518 	uint64_t	mrsv_hkey;	/* MR hash key */
519 	uint64_t	mrsv_va;	/* MR sync virtual addr */
520 	uint64_t	mrsv_len;	/* MR sync length */
521 } dapl_mr_sync_vec_t;
522 
523 typedef struct dapl_mr_sync_s {
524 	uint32_t		mrs_flags;	/* MR sync direction */
525 	uint64_t		mrs_numseg;	/* number of MR's */
526 	dapl_mr_sync_vec_t 	mrs_vec[DAPL_MR_PER_SYNC]; /* sync elements */
527 } dapl_mr_sync_t;
528 
529 /* IA ioctl interfaces */
530 
531 /*
532  * IA create ioctl message
533  */
534 typedef struct dapl_ia_create_s {
535 	uint32_t		ia_version; /* ioctl interface version	*/
536 	ib_guid_t		ia_guid;    /* HCA guid			*/
537 	uint32_t		ia_port;    /* port number		*/
538 	uint32_t		ia_pkey;    /* pkey of the ibd instance */
539 	uint32_t		ia_resnum;  /* resource num in resrc table */
540 	uint8_t			ia_sadata[DAPL_ATS_NBYTES]; /* SA data record */
541 } dapl_ia_create_t;
542 
543 /*
544  * This structure is pretty much a copy of ibt_hca_attr_t but only
545  * relevant fields are present and the data types are such that
546  * its safe to use it in both in 32 and 64 bit libraries
547  * For detailed description refer to ibt_hca_attr_t in ibtl_types.h
548  */
549 typedef struct dapl_hca_attr_s {
550 	uint32_t	dhca_vendor_id:24;
551 	uint16_t	dhca_device_id;
552 	uint32_t	dhca_version_id;
553 	uint_t		dhca_max_chans;
554 	uint_t		dhca_max_chan_sz;
555 	uint_t		dhca_max_sgl;
556 	uint_t		dhca_max_cq;
557 	uint_t		dhca_max_cq_sz;
558 	uint_t		dhca_max_memr;
559 	ib_memlen_t	dhca_max_memr_len;
560 	uint_t		dhca_max_mem_win;
561 	uint8_t		dhca_max_rdma_in_chan;
562 	uint8_t		dhca_max_rdma_out_chan;
563 	uint16_t	dhca_max_partitions;
564 	uint8_t		dhca_nports;
565 	ib_guid_t	dhca_node_guid;
566 	uint_t		dhca_max_pd;
567 	uint_t		dhca_max_srqs;
568 	uint_t		dhca_max_srqs_sz;
569 	uint_t		dhca_max_srq_sgl;
570 } dapl_hca_attr_t;
571 
572 /*
573  * IA query ioctl message
574  */
575 typedef struct dapl_ia_query_s {
576 	dapl_hca_attr_t		hca_attr;
577 } dapl_ia_query_t;
578 
579 #define	DAPL_MAX_IA	64
580 /*
581  * IA enum ioctl message
582  */
583 typedef struct dapl_ia_enum_s {
584 	uint32_t		ia_count;	/* number of IAs */
585 	uint16_t		ia_devnum[DAPL_MAX_IA]; /* devnum of IAs */
586 } dapl_ia_enum_t;
587 
588 /* PD ioctl interfaces */
589 
590 typedef struct dapl_pd_alloc_s {
591 	uint64_t		pda_hkey;
592 } dapl_pd_alloc_t;
593 
594 typedef struct dapl_pd_free_s {
595 	uint64_t		pdf_hkey;
596 } dapl_pd_free_t;
597 
598 /* MW ioctl interfaces */
599 
600 typedef struct dapl_mw_alloc_s {
601 	uint64_t		mw_pd_hkey;
602 	uint64_t		mw_hkey;
603 	ibt_rkey_t		mw_rkey;
604 } dapl_mw_alloc_t;
605 
606 typedef struct dapl_mw_free_s {
607 	uint64_t		mw_hkey;
608 } dapl_mw_free_t;
609 
610 /* Passive Side ioctl interfaces */
611 
612 /*
613  * Service register ioctl message
614  */
615 typedef struct dapl_service_register_s {
616 	ib_svc_id_t		sr_sid;		/* Requested service id */
617 	uint64_t		sr_evd_hkey;	/* CR EVD hash key	*/
618 	uint64_t		sr_sp_hkey;	/* SP hash key		*/
619 	uint64_t		sr_sp_cookie;	/* Userland xSP ptr	*/
620 	ib_svc_id_t		sr_retsid;	/* Returned service id  */
621 } dapl_service_register_t;
622 
623 /*
624  * Service deregister ioctl message
625  */
626 typedef struct dapl_service_deregister_s {
627 	uint64_t		sdr_sp_hkey;
628 } dapl_service_deregister_t;
629 
630 /*
631  * Connection request accept ioctl message
632  */
633 typedef struct dapl_cr_accept_s {
634 	uint64_t	cra_sp_hkey;	/* xSP hash key */
635 	uint64_t	cra_ep_hkey;	/* EP hash key */
636 	uint64_t	cra_bkl_cookie;	/* CR timestamp + SP backlog index */
637 	uint32_t	cra_priv_sz;	/* private data and size */
638 	uchar_t		cra_priv[DAPL_MAX_PRIVATE_DATA_SIZE];
639 } dapl_cr_accept_t;
640 
641 /*
642  * Connection request reject ioctl message
643  */
644 typedef struct dapl_cr_reject_s {
645 	uint64_t	crr_sp_hkey;	/* xSP hash key */
646 	uint64_t	crr_bkl_cookie;  /* CR timestamp + SP backlog index */
647 	int		crr_reason;	/* Reason for rejecting the CR */
648 } dapl_cr_reject_t;
649 
650 /*
651  * Connection request handoff ioctl message
652  */
653 typedef struct dapl_cr_handoff_s {
654 	uint64_t	crh_sp_hkey;	/* xSP hash key */
655 	uint64_t	crh_bkl_cookie;  /* CR timestamp + SP backlog index */
656 	ib_svc_id_t	crh_conn_qual;  /* Service id of destination SP */
657 } dapl_cr_handoff_t;
658 
659 /* CNO ioctl interfaces */
660 
661 /*
662  * CNO alloc ioctl message
663  */
664 typedef struct dapl_cno_alloc_s {
665 	uint64_t	cno_hkey;	/* CNO hash key */
666 } dapl_cno_alloc_t;
667 
668 /*
669  * CNO free ioctl message
670  */
671 typedef struct dapl_cno_free_s {
672 	uint64_t	cnf_hkey;	/* CNO hash key */
673 } dapl_cno_free_t;
674 
675 /*
676  * CNO wait ioctl message
677  */
678 typedef struct dapl_cno_wait_s {
679 	uint64_t	cnw_hkey;	/* CNO hash key */
680 	uint64_t	cnw_timeout;	/* CNO timeout */
681 	uint64_t	cnw_evd_cookie;
682 } dapl_cno_wait_t;
683 
684 /*
685  * SRQ related structures
686  */
687 typedef struct dapl_srq_sizes_s {
688 	uint_t	srqs_sz;
689 	uint_t	srqs_sgl;
690 } dapl_srq_sizes_t;
691 
692 /*
693  * SRQ create ioctl message
694  */
695 typedef struct dapl_srq_create_s {
696 	uint64_t		srqc_pd_hkey;	/* hash key of the assoc PD */
697 	dapl_srq_sizes_t	srqc_sizes;	/* Requested SRQ params	*/
698 	uint64_t		srqc_hkey;	/* hash key of allocated SRQ */
699 	dapl_srq_sizes_t	srqc_real_sizes; /* Allocated SRQ params */
700 	dapl_srq_data_out_t	srqc_data_out;
701 } dapl_srq_create_t;
702 
703 /*
704  * SRQ resize ioctl message
705  */
706 typedef struct dapl_srq_resize_s {
707 	uint64_t		srqr_hkey;	/* hash key of the SRQ */
708 	uint32_t		srqr_new_size;	/* New SRQ size		*/
709 	uint32_t		srqr_real_size; /* Actual SRQ size	*/
710 	dapl_srq_data_out_t	srqr_data_out;
711 } dapl_srq_resize_t;
712 
713 /*
714  * SRQ free ioctl message
715  */
716 typedef struct dapl_srq_free_s {
717 	uint64_t	srqf_hkey; /* hash key of the SRQ being freed */
718 } dapl_srq_free_t;
719 
720 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
721 #pragma pack()
722 #endif
723 
724 #ifdef __cplusplus
725 }
726 #endif
727 
728 #endif	/* _DAPL_IF_H_ */
729