xref: /titanic_51/usr/src/lib/udapl/libdat/include/dat/dat_error.h (revision 03494a9880d80f834bec10a1e8f0a2f8f7c97bf4)
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  * Copyright (c) 2002-2004, Network Appliance, Inc. All rights reserved.
23  */
24 
25 /*
26  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 #ifndef _DAT_ERROR_H_
31 #define	_DAT_ERROR_H_
32 
33 /*
34  *
35  * HEADER: dat_error.h
36  *
37  * PURPOSE: DAT return codes
38  *
39  * Description: Header file for "uDAPL: User Direct Access Programming
40  *		Library, Version: 1.2"
41  *
42  * Mapping rules:
43  *		Error types are compound types, as mapped out below.
44  *
45  *
46  */
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /*
53  *
54  * All return codes are actually a 3-way tuple:
55  *
56  * type: DAT_RETURN_CLASS DAT_RETURN_TYPE DAT_RETURN_SUBTYPE
57  * bits: 31-30 29-16           15-0
58  *
59  * +----------------------------------------------------------------------+
60  * |3130 | 29282726252423222120191817 | 1615141312111009080706054003020100|
61  * |CLAS | DAT_TYPE_STATUS            | SUBTYPE_STATUS                    |
62  * +----------------------------------------------------------------------+
63  */
64 
65 /*
66  * Class Bits
67  */
68 #define	DAT_CLASS_ERROR   0x80000000
69 #define	DAT_CLASS_WARNING 0x40000000
70 #define	DAT_CLASS_SUCCESS 0x00000000
71 
72 /*
73  * DAT Error bits
74  */
75 #define	DAT_TYPE_MASK    0x3fff0000   /* mask for DAT_TYPE_STATUS bits    */
76 #define	DAT_SUBTYPE_MASK 0x0000FFFF   /* mask for DAT_SUBTYPE_STATUS bits */
77 
78 /*
79  * Determining the success of an operation is best done with a macro;
80  * each of these returns a boolean value.
81  */
82 #define	DAT_IS_WARNING(status)  ((DAT_UINT32)(status) & DAT_CLASS_WARNING)
83 
84 #define	DAT_GET_TYPE(status)    ((DAT_UINT32)(status) & DAT_TYPE_MASK)
85 #define	DAT_GET_SUBTYPE(status) ((DAT_UINT32)(status) & DAT_SUBTYPE_MASK)
86 
87 /*
88  * DAT return types. The ERROR bit is enabled for these definitions
89  */
90 typedef enum dat_return_type
91 {
92 	/* The operation was successful.				*/
93 	DAT_SUCCESS					= 0x000000,
94 
95 	/*
96 	 * The operation was aborted because IA was closed or EVD was
97 	 * destroyed.
98 	 */
99 	DAT_ABORT					= 0x00010000,
100 
101 	/* The specified Connection Qualifier was in use.		*/
102 	DAT_CONN_QUAL_IN_USE				= 0x00020000,
103 
104 	/* The operation failed due to resource limitations.		*/
105 	DAT_INSUFFICIENT_RESOURCES			= 0x00030000,
106 
107 	/*
108 	 * Provider internal error. This error can be returned by any
109 	 * operation when the Provider have detected an internal error.
110 	 * This error does no mask any error causes by Consumer.
111 	 */
112 	DAT_INTERNAL_ERROR				= 0x00040000,
113 
114 	/* One of the DAT handles was invalid.				*/
115 	DAT_INVALID_HANDLE				= 0x00050000,
116 
117 	/* One of the parameters was invalid.				*/
118 	DAT_INVALID_PARAMETER				= 0x00060000,
119 
120 	/*
121 	 * One of the parameters was invalid for this operation. There
122 	 * are Event Streams associated with the Event Dispatcher feeding
123 	 * it.
124 	 */
125 	DAT_INVALID_STATE				= 0x00070000,
126 
127 	/*
128 	 * The size of the receiving buffer is too small for sending
129 	 * buffer data.  The size of the local buffer is too small for
130 	 * the data of the remote buffer.
131 	 */
132 	DAT_LENGTH_ERROR				= 0x00080000,
133 
134 	/* The requested Model was not supported by the Provider.	*/
135 	DAT_MODEL_NOT_SUPPORTED				= 0x00090000,
136 
137 	/*
138 	 * The provider name or specified attributes are not found in
139 	 * the registry.
140 	 */
141 
142 	DAT_PROVIDER_NOT_FOUND				= 0x000A0000,
143 
144 	/*
145 	 * Protection violation for local or remote memory
146 	 * access. Protection Zone mismatch between an LMR of one of the
147 	 * local_iov segments and the local Endpoint.
148 	 */
149 	DAT_PRIVILEGES_VIOLATION			= 0x000B0000,
150 
151 	/*
152 	 * Privileges violation for local or re-mote memory access. One
153 	 * of the LMRs used in local_iov was either invalid or did not
154 	 * have the local read privileges.
155 	 */
156 	DAT_PROTECTION_VIOLATION			= 0x000C0000,
157 
158 	/* The operation timed out without a notification.		*/
159 	DAT_QUEUE_EMPTY					= 0x000D0000,
160 
161 	/* The Event Dispatcher queue is full.				*/
162 	DAT_QUEUE_FULL					= 0x000E0000,
163 
164 	/* The operation timed out. UDAPL ONLY				*/
165 	DAT_TIMEOUT_EXPIRED				= 0x000F0000,
166 
167 	/* The provider name was already registered			*/
168 	DAT_PROVIDER_ALREADY_REGISTERED			= 0x00100000,
169 
170 	/* The provider is "in-use" and cannot be closed at this time	*/
171 	DAT_PROVIDER_IN_USE				= 0x00110000,
172 
173 	/* The requested remote address is not valid or not reachable	*/
174 	DAT_INVALID_ADDRESS				= 0x00120000,
175 
176 	/* [Unix only] dat_evd_wait or dat_cno_wait has been interrupted. */
177 	DAT_INTERRUPTED_CALL				= 0x00130000,
178 
179 	/* No Connection Qualifiers are available 			*/
180 	DAT_CONN_QUAL_UNAVAILABLE			= 0x00140000,
181 
182 	/* Provider does not support the operation yet.			*/
183 	DAT_NOT_IMPLEMENTED				= 0x0FFF0000
184 
185 } DAT_RETURN_TYPE;
186 
187 typedef	DAT_UINT32 DAT_RETURN;
188 
189 /* Backwared compatibility with DAT 1.0					*/
190 #define	DAT_NAME_NOT_FOUND DAT_PROVIDER_NOT_FOUND
191 
192 /*
193  * DAT_RETURN_SUBTYPE listing
194  */
195 
196 typedef enum dat_return_subtype
197 {
198 	/* First element is no subtype */
199 	DAT_NO_SUBTYPE,
200 	/* ABORT sub types						*/
201 	/* call was interrupted by a signal, or otherwise		*/
202 	DAT_SUB_INTERRUPTED,
203 
204 	/* DAT_CONN_QUAL_IN_USE has no subtypes				*/
205 
206 	/* INSUFFICIENT_RESOURCES subtypes				*/
207 	DAT_RESOURCE_MEMORY,
208 	DAT_RESOURCE_DEVICE,
209 	DAT_RESOURCE_TEP, /* transport endpoint, e.g. QP */
210 	DAT_RESOURCE_TEVD, /* transport EVD, e.g. CQ */
211 	DAT_RESOURCE_PROTECTION_DOMAIN,
212 	DAT_RESOURCE_MEMORY_REGION, /* HCA memory for LMR or RMR */
213 	DAT_RESOURCE_ERROR_HANDLER,
214 	DAT_RESOURCE_CREDITS, /* e.g outstanding RDMA Read credit as target */
215 	DAT_RESOURCE_SRQ,
216 
217 	/* DAT_INTERNAL_ERROR has no subtypes				*/
218 
219 	/* INVALID_HANDLE subtypes					*/
220 	DAT_INVALID_HANDLE_IA,
221 	DAT_INVALID_HANDLE_EP,
222 	DAT_INVALID_HANDLE_LMR,
223 	DAT_INVALID_HANDLE_RMR,
224 	DAT_INVALID_HANDLE_PZ,
225 	DAT_INVALID_HANDLE_PSP,
226 	DAT_INVALID_HANDLE_RSP,
227 	DAT_INVALID_HANDLE_CR,
228 	DAT_INVALID_HANDLE_CNO,
229 	DAT_INVALID_HANDLE_EVD_CR,
230 	DAT_INVALID_HANDLE_EVD_REQUEST,
231 	DAT_INVALID_HANDLE_EVD_RECV,
232 	DAT_INVALID_HANDLE_EVD_CONN,
233 	DAT_INVALID_HANDLE_EVD_ASYNC,
234 	DAT_INVALID_HANDLE_SRQ,
235 	DAT_INVALID_HANDLE1,
236 	DAT_INVALID_HANDLE2,
237 	DAT_INVALID_HANDLE3,
238 	DAT_INVALID_HANDLE4,
239 	DAT_INVALID_HANDLE5,
240 	DAT_INVALID_HANDLE6,
241 	DAT_INVALID_HANDLE7,
242 	DAT_INVALID_HANDLE8,
243 	DAT_INVALID_HANDLE9,
244 	DAT_INVALID_HANDLE10,
245 
246 	/* DAT_INVALID_PARAMETER subtypes				*/
247 	DAT_INVALID_ARG1,
248 	DAT_INVALID_ARG2,
249 	DAT_INVALID_ARG3,
250 	DAT_INVALID_ARG4,
251 	DAT_INVALID_ARG5,
252 	DAT_INVALID_ARG6,
253 	DAT_INVALID_ARG7,
254 	DAT_INVALID_ARG8,
255 	DAT_INVALID_ARG9,
256 	DAT_INVALID_ARG10,
257 
258 	/* DAT_INVALID_EP_STATE subtypes */
259 	DAT_INVALID_STATE_EP_UNCONNECTED,
260 	DAT_INVALID_STATE_EP_ACTCONNPENDING,
261 	DAT_INVALID_STATE_EP_PASSCONNPENDING,
262 	DAT_INVALID_STATE_EP_TENTCONNPENDING,
263 	DAT_INVALID_STATE_EP_CONNECTED,
264 	DAT_INVALID_STATE_EP_DISCONNECTED,
265 	DAT_INVALID_STATE_EP_RESERVED,
266 	DAT_INVALID_STATE_EP_COMPLPENDING,
267 	DAT_INVALID_STATE_EP_DISCPENDING,
268 	DAT_INVALID_STATE_EP_PROVIDERCONTROL,
269 	DAT_INVALID_STATE_EP_NOTREADY,
270 	DAT_INVALID_STATE_EP_RECV_WATERMARK,
271 	DAT_INVALID_STATE_EP_PZ,
272 	DAT_INVALID_STATE_EP_EVD_REQUEST,
273 	DAT_INVALID_STATE_EP_EVD_RECV,
274 	DAT_INVALID_STATE_EP_EVD_CONNECT,
275 	DAT_INVALID_STATE_EP_UNCONFIGURED,
276 	DAT_INVALID_STATE_EP_UNCONFRESERVED,
277 	DAT_INVALID_STATE_EP_UNCONFPASSIVE,
278 	DAT_INVALID_STATE_EP_UNCONFTENTATIVE,
279 
280 	DAT_INVALID_STATE_CNO_IN_USE,
281 	DAT_INVALID_STATE_CNO_DEAD,
282 
283 	/*
284 	 * EVD states. Enabled/Disabled, Waitable/Unwaitable,
285 	 * and Notify/Solicited/Threshold are 3 orthogonal
286 	 * bands of EVD state.The Threshold one is uDAPL specific.
287 	 */
288 	DAT_INVALID_STATE_EVD_OPEN,
289 	/*
290 	 * EVD can be either in enabled or disabled but not both
291 	 * or neither at the same time
292 	 */
293 	DAT_INVALID_STATE_EVD_ENABLED,
294 	DAT_INVALID_STATE_EVD_DISABLED,
295 	/*
296 	 * EVD can be either in waitable or unwaitable but not
297 	 * both or neither at the same time
298 	 */
299 	DAT_INVALID_STATE_EVD_WAITABLE,
300 	DAT_INVALID_STATE_EVD_UNWAITABLE,
301 	/* Do not release an EVD if it is in use			*/
302 	DAT_INVALID_STATE_EVD_IN_USE,
303 
304 	/*
305 	 * EVD can be either in notify or solicited or threshold
306 	 * but not any pair, or all, or none at the same time.
307 	 * The threshold one is for uDAPL only
308 	 */
309 	DAT_INVALID_STATE_EVD_CONFIG_NOTIFY,
310 	DAT_INVALID_STATE_EVD_CONFIG_SOLICITED,
311 	DAT_INVALID_STATE_EVD_CONFIG_THRESHOLD,
312 	DAT_INVALID_STATE_EVD_WAITER,
313 	DAT_INVALID_STATE_EVD_ASYNC, /* Async EVD required */
314 	DAT_INVALID_STATE_IA_IN_USE,
315 	DAT_INVALID_STATE_LMR_IN_USE,
316 	DAT_INVALID_STATE_LMR_FREE,
317 	DAT_INVALID_STATE_PZ_IN_USE,
318 	DAT_INVALID_STATE_PZ_FREE,
319 
320 	/* DAT_INVALID_STATE_SRQ subtypes */
321 	DAT_INVALID_STATE_SRQ_OPERATIONAL,
322 	DAT_INVALID_STATE_SRQ_ERROR,
323 	DAT_INVALID_STATE_SRQ_IN_USE,
324 
325 	/* DAT_LENGTH_ERROR has no subtypes				*/
326 	/* DAT_MODEL_NOT_SUPPORTED has no subtypes			*/
327 
328 	/* DAT_PRIVILEGES_VIOLATION subtypes				*/
329 	DAT_PRIVILEGES_READ,
330 	DAT_PRIVILEGES_WRITE,
331 	DAT_PRIVILEGES_RDMA_READ,
332 	DAT_PRIVILEGES_RDMA_WRITE,
333 
334 	/* DAT_PROTECTION_VIOLATION subtypes				*/
335 	DAT_PROTECTION_READ,
336 	DAT_PROTECTION_WRITE,
337 	DAT_PROTECTION_RDMA_READ,
338 	DAT_PROTECTION_RDMA_WRITE,
339 
340 	/* DAT_QUEUE_EMPTY has no subtypes				*/
341 	/* DAT_QUEUE_FULL has no subtypes				*/
342 	/* DAT_TIMEOUT_EXPIRED has no subtypes				*/
343 	/* DAT_PROVIDER_ALREADY_REGISTERED has no subtypes		*/
344 	/* DAT_PROVIDER_IN_USE has no subtypes				*/
345 
346 	/* DAT_INVALID_ADDRESS subtypes					*/
347 	/*
348 	 * Unsupported addresses - those that are not Malformed,
349 	 * but are incorrect for use in DAT (regardless of local
350 	 * routing capabilities): IPv6 Multicast Addresses (ff/8)
351 	 * IPv4 Broadcast/Multicast Addresses
352 	 */
353 	DAT_INVALID_ADDRESS_UNSUPPORTED,
354 	/*
355 	 * Unreachable addresses - A Provider may know that certain
356 	 * addresses are unreachable immediately. One examples would
357 	 * be an IPv6 addresses on an IPv4-only system. This may also
358 	 * be returned if it is known that there is no route to the
359 	 * host. A Provider is not obligated to check for this
360 	 * condition.
361 	 */
362 	DAT_INVALID_ADDRESS_UNREACHABLE,
363 	/*
364 	 * Malformed addresses -- these cannot be valid in any context.
365 	 * Those listed in RFC1884 section 2.3 as "Reserved" or
366 	 * "Unassigned".
367 	 */
368 	DAT_INVALID_ADDRESS_MALFORMED,
369 
370 	/* DAT_INTERRUPTED_CALL has no subtypes				*/
371 	/* DAT_CONN_QUAL_UNAVAILABLE has no subtypes			*/
372 
373 	/* DAT_PROVIDER_NOT_FOUND subtypes. Erratta to the 1.1 spec	*/
374 	DAT_NAME_NOT_REGISTERED,
375 	DAT_MAJOR_NOT_FOUND,
376 	DAT_MINOR_NOT_FOUND,
377 	DAT_THREAD_SAFETY_NOT_FOUND,
378 
379 	/* DAT_INVALID_PARAMETER Sun specific */
380 	DAT_INVALID_RO_COOKIE
381 
382 } DAT_RETURN_SUBTYPE;
383 
384 #ifdef __cplusplus
385 }
386 #endif
387 
388 #endif /* _DAT_ERROR_H_ */
389