xref: /titanic_41/usr/src/lib/udapl/libdat/include/dat/udat.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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 (c) 2002-2004, Network Appliance, Inc. All rights reserved.
24  */
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 
32 #ifndef _UDAT_H_
33 #define	_UDAT_H_
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 /*
38  *
39  * HEADER: udat.h
40  *
41  * PURPOSE: defines the user DAT API
42  *
43  * Description: Header file for "uDAPL: User Direct Access Programming
44  *              Library, Version: 1.2"
45  *
46  * Mapping rules:
47  *      All global symbols are prepended with "DAT_" or "dat_"
48  *      All DAT objects have an 'api' tag which, such as 'ep' or 'lmr'
49  *      The method table is in the provider definition structure.
50  *
51  *
52  */
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #include <dat/udat_config.h>
59 
60 #include <dat/dat_platform_specific.h>
61 
62 typedef enum dat_mem_type
63 {
64 	/* Shared between udat and kdat */
65 	DAT_MEM_TYPE_VIRTUAL		= 0x00,
66 	DAT_MEM_TYPE_LMR		= 0x01,
67 	/* udat specific */
68 	DAT_MEM_TYPE_SHARED_VIRTUAL	= 0x02
69 } DAT_MEM_TYPE;
70 
71 /* dat handle types */
72 typedef enum dat_handle_type
73 {
74 	DAT_HANDLE_TYPE_CR,
75 	DAT_HANDLE_TYPE_EP,
76 	DAT_HANDLE_TYPE_EVD,
77 	DAT_HANDLE_TYPE_IA,
78 	DAT_HANDLE_TYPE_LMR,
79 	DAT_HANDLE_TYPE_PSP,
80 	DAT_HANDLE_TYPE_PZ,
81 	DAT_HANDLE_TYPE_RMR,
82 	DAT_HANDLE_TYPE_RSP,
83 	DAT_HANDLE_TYPE_CNO,
84 	DAT_HANDLE_TYPE_SRQ
85 } DAT_HANDLE_TYPE;
86 
87 /*
88  * EVD state consists of 3 orthogonal substates. One for
89  * enabled/disabled, one for waitable/unwaitable, and one
90  * for configuration. Within each substates the values are
91  * mutually exclusive.
92  */
93 typedef enum dat_evd_state
94 {
95 	DAT_EVD_STATE_ENABLED 		= 0x01,
96 	DAT_EVD_STATE_DISABLED 		= 0x02,
97 	DAT_EVD_STATE_WAITABLE 		= 0x04,
98 	DAT_EVD_STATE_UNWAITABLE 	= 0x08,
99 	DAT_EVD_STATE_CONFIG_NOTIFY 	= 0x10,
100 	DAT_EVD_STATE_CONFIG_SOLICITED 	= 0x20,
101 	DAT_EVD_STATE_CONFIG_THRESHOLD 	= 0x30
102 } DAT_EVD_STATE;
103 
104 typedef enum dat_evd_param_mask
105 {
106 	DAT_EVD_FIELD_IA_HANDLE    	= 0x01,
107 	DAT_EVD_FIELD_EVD_QLEN		= 0x02,
108 	DAT_EVD_FIELD_EVD_STATE    	= 0x04,
109 	DAT_EVD_FIELD_CNO		= 0x08,
110 	DAT_EVD_FIELD_EVD_FLAGS		= 0x10,
111 
112 	DAT_EVD_FIELD_ALL		= 0x1F
113 } DAT_EVD_PARAM_MASK;
114 
115 typedef DAT_UINT64 DAT_PROVIDER_ATTR_MASK;
116 
117 #include <dat/dat.h>
118 
119 typedef DAT_HANDLE	DAT_CNO_HANDLE;
120 
121 struct dat_evd_param
122 {
123 	DAT_IA_HANDLE		ia_handle;
124 	DAT_COUNT		evd_qlen;
125 	DAT_EVD_STATE		evd_state;
126 	DAT_CNO_HANDLE		cno_handle;
127 	DAT_EVD_FLAGS		evd_flags;
128 };
129 
130 #define	DAT_LMR_COOKIE_SIZE 40 /* size of DAT_LMR_COOKIE in bytes */
131 typedef char (* DAT_LMR_COOKIE)[DAT_LMR_COOKIE_SIZE];
132 
133 /* Format for OS wait proxy agent function */
134 
135 typedef void (*DAT_AGENT_FUNC)(
136 	DAT_PVOID,	/* instance data   */
137 	DAT_EVD_HANDLE  /* Event Dispatcher*/);
138 
139 /* Definition */
140 
141 typedef struct dat_os_wait_proxy_agent
142 {
143 	DAT_PVOID instance_data;
144 	DAT_AGENT_FUNC proxy_agent_func;
145 } DAT_OS_WAIT_PROXY_AGENT;
146 
147 /* Define NULL Proxy agent */
148 
149 #define	DAT_OS_WAIT_PROXY_AGENT_NULL \
150 	(DAT_OS_WAIT_PROXY_AGENT) { \
151 	(DAT_PVOID) NULL, \
152 	(DAT_AGENT_FUNC) NULL }
153 
154 
155 /* Flags */
156 
157 /*
158  * The value specified by the uDAPL Consumer for dat_ia_open to indicate
159  * that not async EVD should be created for the opening instance of an IA.
160  * The same IA have been open before that has the only async EVD to
161  * handle async errors for all open instances of the IA.
162  */
163 
164 #define	DAT_EVD_ASYNC_EXISTS (DAT_EVD_HANDLE) 0x1
165 
166 /*
167  * The value return by the dat_ia_query for the case when there is no
168  * async EVD for the IA instance. Consumer had specified the value of
169  * DAT_EVD_ASYNC_EXISTS for the async_evd_handle for dat_ia_open.
170  */
171 
172 #define	DAT_EVD_OUT_OF_SCOPE (DAT_EVD_HANDLE) 0x2
173 
174 /*
175  * Memory types
176  *
177  * Specifing memory type for LMR create. A consumer must use a single
178  * value when registering memory. The union of any of these
179  * flags is used in the provider parameters to indicate what memory
180  * type provider supports for LMR memory creation.
181  */
182 
183 
184 
185 /* For udapl only */
186 
187 typedef struct dat_shared_memory
188 {
189 	DAT_PVOID		virtual_address;
190 	DAT_LMR_COOKIE		shared_memory_id;
191 } DAT_SHARED_MEMORY;
192 
193 typedef union dat_region_description
194 {
195 	DAT_PVOID		for_va;
196 	DAT_LMR_HANDLE		for_lmr_handle;
197 	DAT_SHARED_MEMORY	for_shared_memory;	/* For udapl only */
198 } DAT_REGION_DESCRIPTION;
199 
200 /* LMR Arguments */
201 
202 struct dat_lmr_param
203 {
204 	DAT_IA_HANDLE		ia_handle;
205 	DAT_MEM_TYPE		mem_type;
206 	DAT_REGION_DESCRIPTION	region_desc;
207 	DAT_VLEN		length;
208 	DAT_PZ_HANDLE		pz_handle;
209 	DAT_MEM_PRIV_FLAGS	mem_priv;
210 	DAT_LMR_CONTEXT		lmr_context;
211 	DAT_RMR_CONTEXT		rmr_context;
212 	DAT_VLEN		registered_size;
213 	DAT_VADDR		registered_address;
214 };
215 
216 
217 typedef struct dat_cno_param
218 {
219 	DAT_IA_HANDLE		ia_handle;
220 	DAT_OS_WAIT_PROXY_AGENT	agent;
221 } DAT_CNO_PARAM;
222 
223 typedef enum dat_cno_param_mask
224 {
225 	DAT_CNO_FIELD_IA_HANDLE	= 0x1,
226 	DAT_CNO_FIELD_AGENT	= 0x2,
227 
228 	DAT_CNO_FIELD_ALL	= 0x3
229 } DAT_CNO_PARAM_MASK;
230 
231 
232 /* General Provider attributes. udat specific. */
233 typedef enum dat_pz_support
234 {
235 	DAT_PZ_UNIQUE,
236 	DAT_PZ_SAME,
237 	DAT_PZ_SHAREABLE
238 } DAT_PZ_SUPPORT;
239 
240 /*
241  * Provider should support merging of all event stream types. Provider
242  * attribute specify support for merging different event stream types.
243  * It is a 2D binary matrix where each row and column represents an event
244  * stream type. Each binary entry is 1 if the event streams of its raw
245  * and column can fed the same EVD, and 0 otherwise. The order of event
246  * streams in row and column is the same as in the definition of
247  * DAT_EVD_FLAGS: index 0 - Software Event, 1- Connection Request,
248  * 2 - DTO Completion, 3 - Connection event, 4 - RMR Bind Completion,
249  * 5 - Asynchronous event. By definition each diagonal entry is 1.
250  * Consumer allocates an array for it and passes it IN as a pointer
251  * for the array that Provider fills. Provider must fill the array
252  * that Consumer passes.
253  */
254 
255 struct dat_provider_attr
256 {
257 	char				provider_name[DAT_NAME_MAX_LENGTH];
258 	DAT_UINT32			provider_version_major;
259 	DAT_UINT32			provider_version_minor;
260 	DAT_UINT32			dapl_version_major;
261 	DAT_UINT32			dapl_version_minor;
262 	DAT_MEM_TYPE			lmr_mem_types_supported;
263 	DAT_IOV_OWNERSHIP		iov_ownership_on_return;
264 	DAT_QOS				dat_qos_supported;
265 	DAT_COMPLETION_FLAGS		completion_flags_supported;
266 	DAT_BOOLEAN			is_thread_safe;
267 	DAT_COUNT			max_private_data_size;
268 	DAT_BOOLEAN			supports_multipath;
269 	DAT_EP_CREATOR_FOR_PSP		ep_creator;
270 	DAT_PZ_SUPPORT			pz_support;
271 	DAT_UINT32			optimal_buffer_alignment;
272 	const DAT_BOOLEAN		evd_stream_merging_supported[6][6];
273 	DAT_BOOLEAN			srq_supported;
274 	DAT_COUNT			srq_watermarks_supported;
275 	DAT_BOOLEAN			srq_ep_pz_difference_supported;
276 	DAT_COUNT			srq_info_supported;
277 	DAT_COUNT			ep_recv_info_supported;
278 	DAT_BOOLEAN			lmr_sync_req;
279 	DAT_BOOLEAN			dto_async_return_guaranteed;
280 	DAT_BOOLEAN			rdma_write_for_rdma_read_req;
281 	DAT_COUNT			num_provider_specific_attr;
282 	DAT_NAMED_ATTR *		provider_specific_attr;
283 };
284 
285 #define	DAT_PROVIDER_FIELD_PROVIDER_NAME		UINT64_C(0x0000001)
286 #define	DAT_PROVIDER_FIELD_PROVIDER_VERSION_MAJOR	UINT64_C(0x0000002)
287 #define	DAT_PROVIDER_FIELD_PROVIDER_VERSION_MINOR	UINT64_C(0x0000004)
288 #define	DAT_PROVIDER_FIELD_DAPL_VERSION_MAJOR		UINT64_C(0x0000008)
289 #define	DAT_PROVIDER_FIELD_DAPL_VERSION_MINOR		UINT64_C(0x0000010)
290 #define	DAT_PROVIDER_FIELD_LMR_MEM_TYPE_SUPPORTED	UINT64_C(0x0000020)
291 #define	DAT_PROVIDER_FIELD_IOV_OWNERSHIP		UINT64_C(0x0000040)
292 #define	DAT_PROVIDER_FIELD_DAT_QOS_SUPPORTED		UINT64_C(0x0000080)
293 #define	DAT_PROVIDER_FIELD_COMPLETION_FLAGS_SUPPORTED	UINT64_C(0x0000100)
294 #define	DAT_PROVIDER_FIELD_IS_THREAD_SAFE		UINT64_C(0x0000200)
295 #define	DAT_PROVIDER_FIELD_MAX_PRIVATE_DATA_SIZE	UINT64_C(0x0000400)
296 #define	DAT_PROVIDER_FIELD_SUPPORTS_MULTIPATH		UINT64_C(0x0000800)
297 #define	DAT_PROVIDER_FIELD_EP_CREATOR			UINT64_C(0x0001000)
298 #define	DAT_PROVIDER_FIELD_PZ_SUPPORT			UINT64_C(0x0002000)
299 #define	DAT_PROVIDER_FIELD_OPTIMAL_BUFFER_ALIGNMENT	UINT64_C(0x0004000)
300 #define	DAT_PROVIDER_FIELD_EVD_STREAM_MERGING_SUPPORTED	UINT64_C(0x0008000)
301 #define	DAT_PROVIDER_FIELD_SRQ_SUPPORTED		UINT64_C(0x0010000)
302 #define	DAT_PROVIDER_FIELD_SRQ_WATERMARKS_SUPPORTED	UINT64_C(0x0020000)
303 #define	DAT_PROVIDER_FIELD_SRQ_EP_PZ_DIFFERENCE_SUPPORTED \
304 							UINT64_C(0x0040000)
305 #define	DAT_PROVIDER_FIELD_SRQ_INFO_SUPPORTED		UINT64_C(0x0080000)
306 #define	DAT_PROVIDER_FIELD_EP_RECV_INFO_SUPPORTED	UINT64_C(0x0100000)
307 #define	DAT_PROVIDER_FIELD_LMR_SYNC_REQ			UINT64_C(0x0200000)
308 #define	DAT_PROVIDER_FIELD_DTO_ASYNC_RETURN_GUARANTEED	UINT64_C(0x0400000)
309 #define	DAT_PROVIDER_FIELD_RDMA_WRITE_FOR_RDMA_READ_REQ	UINT64_C(0x0800000)
310 #define	DAT_PROVIDER_FIELD_NUM_PROVIDER_SPECIFIC_ATTR	UINT64_C(0x1000000)
311 #define	DAT_PROVIDER_FIELD_PROVIDER_SPECIFIC_ATTR	UINT64_C(0x2000000)
312 
313 #define	DAT_PROVIDER_FIELD_ALL				UINT64_C(0x3FFFFFF)
314 #define	DAT_PROVIDER_FIELD_NONE				UINT64_C(0x0)
315 
316 #include <dat/udat_vendor_specific.h>
317 
318 /* ************************************************************************ */
319 
320 /*
321  * User DAT functions definitions.
322  */
323 
324 
325 extern DAT_RETURN dat_lmr_create(
326 	IN	DAT_IA_HANDLE,		/* ia_handle		*/
327 	IN	DAT_MEM_TYPE,		/* mem_type		*/
328 	IN	DAT_REGION_DESCRIPTION,	/* region_description   */
329 	IN	DAT_VLEN,		/* length		*/
330 	IN	DAT_PZ_HANDLE,		/* pz_handle		*/
331 	IN	DAT_MEM_PRIV_FLAGS,	/* privileges		*/
332 	OUT	DAT_LMR_HANDLE *,	/* lmr_handle		*/
333 	OUT	DAT_LMR_CONTEXT *,	/* lmr_context		*/
334 	OUT	DAT_RMR_CONTEXT *,	/* rmr_context		*/
335 	OUT	DAT_VLEN *,		/* registered_length	*/
336 	OUT	DAT_VADDR *);		/* registered_address   */
337 
338 /* Event Functions */
339 
340 extern DAT_RETURN dat_evd_create(
341 	IN	DAT_IA_HANDLE,		/* ia_handle		*/
342 	IN	DAT_COUNT,		/* evd_min_qlen		*/
343 	IN	DAT_CNO_HANDLE,		/* cno_handle		*/
344 	IN	DAT_EVD_FLAGS,		/* evd_flags		*/
345 	OUT	DAT_EVD_HANDLE *);	/* evd_handle		*/
346 
347 extern DAT_RETURN dat_evd_modify_cno(
348 	IN	DAT_EVD_HANDLE,		/* evd_handle		*/
349 	IN	DAT_CNO_HANDLE);	/* cno_handle		*/
350 
351 extern DAT_RETURN dat_cno_create(
352 	IN	DAT_IA_HANDLE,		/* ia_handle		*/
353 	IN	DAT_OS_WAIT_PROXY_AGENT,	/* agent		*/
354 	OUT	DAT_CNO_HANDLE *);	/* cno_handle		*/
355 
356 extern DAT_RETURN dat_cno_modify_agent(
357 	IN	DAT_CNO_HANDLE,			/* cno_handle		*/
358 	IN	DAT_OS_WAIT_PROXY_AGENT);	/* agent		*/
359 
360 extern DAT_RETURN dat_cno_query(
361 	IN	DAT_CNO_HANDLE,		/* cno_handle		*/
362 	IN	DAT_CNO_PARAM_MASK,	/* cno_param_mask	*/
363 	OUT	DAT_CNO_PARAM *);	/* cno_param		*/
364 
365 extern DAT_RETURN dat_cno_free(
366 	IN DAT_CNO_HANDLE);		/* cno_handle		*/
367 
368 extern DAT_RETURN dat_cno_wait(
369 	IN	DAT_CNO_HANDLE,		/* cno_handle		*/
370 	IN	DAT_TIMEOUT,		/* timeout		*/
371 	OUT	DAT_EVD_HANDLE *);	/* evd_handle		*/
372 
373 extern DAT_RETURN dat_evd_enable(
374 	IN	DAT_EVD_HANDLE);	/* evd_handle		*/
375 
376 extern DAT_RETURN dat_evd_wait(
377 	IN	DAT_EVD_HANDLE,		/* evd_handle		*/
378 	IN	DAT_TIMEOUT,		/* Timeout		*/
379 	IN	DAT_COUNT,		/* Threshold		*/
380 	OUT	DAT_EVENT *,		/* event		*/
381 	OUT	DAT_COUNT *);		/* N more events	*/
382 
383 extern DAT_RETURN dat_evd_disable(
384 	IN	DAT_EVD_HANDLE);	/* evd_handle		*/
385 
386 extern DAT_RETURN dat_evd_set_unwaitable(
387 	IN DAT_EVD_HANDLE);		/* evd_handle */
388 
389 extern DAT_RETURN dat_evd_clear_unwaitable(
390 	IN DAT_EVD_HANDLE); /* evd_handle */
391 
392 #ifdef __cplusplus
393 }
394 #endif
395 
396 #endif /* _UDAT_H_ */
397