xref: /illumos-gate/usr/src/lib/udapl/libdat/common/dat_strerror.c (revision e7cbe64f7a72dae5cb44f100db60ca88f3313c65)
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-2003, Network Appliance, Inc. All rights reserved.
24  */
25 
26 /*
27  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 
34 /*
35  *
36  * MODULE: dat_strerror.c
37  *
38  * PURPOSE: Convert DAT_RETURN values to humman readable string
39  *
40  * $Id: dat_strerror.c,v 1.2 2003/08/06 14:40:29 jlentini Exp $
41  */
42 
43 #include <dat/udat.h>
44 
45 
46 /*
47  *
48  * Internal Function Declarations
49  *
50  */
51 
52 DAT_RETURN
53 dat_strerror_major(
54     IN  DAT_RETURN 		value,
55     OUT const char 		**message);
56 
57 DAT_RETURN
58 dat_strerror_minor(
59     IN  DAT_RETURN 		value,
60     OUT const char 		**message);
61 
62 
63 /*
64  *
65  * Internal Function Definitions
66  *
67  */
68 
69 DAT_RETURN
70 dat_strerror_major(
71     IN  DAT_RETURN 		value,
72     OUT const char 		**message)
73 {
74 	switch (DAT_GET_TYPE(value)) {
75 	case DAT_SUCCESS:
76 	{
77 		*message = "DAT_SUCCESS";
78 		return (DAT_SUCCESS);
79 	}
80 	case DAT_ABORT:
81 	{
82 		*message = "DAT_ABORT";
83 		return (DAT_SUCCESS);
84 	}
85 	case DAT_CONN_QUAL_IN_USE:
86 	{
87 		*message = "DAT_CONN_QUAL_IN_USE";
88 		return (DAT_SUCCESS);
89 	}
90 	case DAT_INSUFFICIENT_RESOURCES:
91 	{
92 		*message = "DAT_INSUFFICIENT_RESOURCES";
93 		return (DAT_SUCCESS);
94 	}
95 	case DAT_INTERNAL_ERROR:
96 	{
97 		*message = "DAT_INTERNAL_ERROR";
98 		return (DAT_SUCCESS);
99 	}
100 	case DAT_INVALID_HANDLE:
101 	{
102 		*message = "DAT_INVALID_HANDLE";
103 		return (DAT_SUCCESS);
104 	}
105 	case DAT_INVALID_PARAMETER:
106 	{
107 		*message = "DAT_INVALID_PARAMETER";
108 		return (DAT_SUCCESS);
109 	}
110 	case DAT_INVALID_STATE:
111 	{
112 		*message = "DAT_INVALID_STATE";
113 		return (DAT_SUCCESS);
114 	}
115 	case DAT_LENGTH_ERROR:
116 	{
117 		*message = "DAT_LENGTH_ERROR";
118 		return (DAT_SUCCESS);
119 	}
120 	case DAT_MODEL_NOT_SUPPORTED:
121 	{
122 		*message = "DAT_MODEL_NOT_SUPPORTED";
123 		return (DAT_SUCCESS);
124 	}
125 	case DAT_NAME_NOT_FOUND:
126 	{
127 		*message = "DAT_NAME_NOT_FOUND";
128 		return (DAT_SUCCESS);
129 	}
130 	case DAT_PRIVILEGES_VIOLATION:
131 	{
132 		*message = "DAT_PRIVILEGES_VIOLATION";
133 		return (DAT_SUCCESS);
134 	}
135 	case DAT_PROTECTION_VIOLATION:
136 	{
137 		*message = "DAT_PROTECTION_VIOLATION";
138 		return (DAT_SUCCESS);
139 	}
140 	case DAT_QUEUE_EMPTY:
141 	{
142 		*message = "DAT_QUEUE_EMPTY";
143 		return (DAT_SUCCESS);
144 	}
145 	case DAT_QUEUE_FULL:
146 	{
147 		*message = "DAT_QUEUE_FULL";
148 		return (DAT_SUCCESS);
149 	}
150 	case DAT_TIMEOUT_EXPIRED:
151 	{
152 		*message = "DAT_TIMEOUT_EXPIRED";
153 		return (DAT_SUCCESS);
154 	}
155 	case DAT_PROVIDER_ALREADY_REGISTERED:
156 	{
157 		*message = "DAT_PROVIDER_ALREADY_REGISTERED";
158 		return (DAT_SUCCESS);
159 	}
160 	case DAT_PROVIDER_IN_USE:
161 	{
162 		*message = "DAT_PROVIDER_IN_USE";
163 		return (DAT_SUCCESS);
164 	}
165 	case DAT_INVALID_ADDRESS:
166 	{
167 		*message = "DAT_INVALID_ADDRESS";
168 		return (DAT_SUCCESS);
169 	}
170 	case DAT_INTERRUPTED_CALL:
171 	{
172 		*message = "DAT_INTERRUPTED_CALL";
173 		return (DAT_SUCCESS);
174 	}
175 	case DAT_NOT_IMPLEMENTED:
176 	{
177 		*message = "DAT_NOT_IMPLEMENTED";
178 		return (DAT_SUCCESS);
179 	}
180 	default:
181 	{
182 		return (DAT_INVALID_PARAMETER);
183 	}
184 	}
185 }
186 
187 
188 DAT_RETURN
189 dat_strerror_minor(
190     IN  DAT_RETURN 		value,
191     OUT const char 		**message)
192 {
193 	switch (DAT_GET_SUBTYPE(value)) {
194 	case DAT_NO_SUBTYPE:
195 	{
196 		*message = "";
197 		return (DAT_SUCCESS);
198 	}
199 	case DAT_SUB_INTERRUPTED:
200 	{
201 		*message = "DAT_SUB_INTERRUPTED";
202 		return (DAT_SUCCESS);
203 	}
204 	case DAT_RESOURCE_MEMORY:
205 	{
206 		*message = "DAT_RESOURCE_MEMORY";
207 		return (DAT_SUCCESS);
208 	}
209 	case DAT_RESOURCE_DEVICE:
210 	{
211 		*message = "DAT_RESOURCE_DEVICE";
212 		return (DAT_SUCCESS);
213 	}
214 	case DAT_RESOURCE_TEP:
215 	{
216 		*message = "DAT_RESOURCE_TEP";
217 		return (DAT_SUCCESS);
218 	}
219 	case DAT_RESOURCE_TEVD:
220 	{
221 		*message = "DAT_RESOURCE_TEVD";
222 		return (DAT_SUCCESS);
223 	}
224 	case DAT_RESOURCE_PROTECTION_DOMAIN:
225 	{
226 		*message = "DAT_RESOURCE_PROTECTION_DOMAIN";
227 		return (DAT_SUCCESS);
228 	}
229 	case DAT_RESOURCE_MEMORY_REGION:
230 	{
231 		*message = "DAT_RESOURCE_MEMORY_REGION";
232 		return (DAT_SUCCESS);
233 	}
234 	case DAT_RESOURCE_ERROR_HANDLER:
235 	{
236 		*message = "DAT_RESOURCE_ERROR_HANDLER";
237 		return (DAT_SUCCESS);
238 	}
239 	case DAT_RESOURCE_CREDITS:
240 	{
241 		*message = "DAT_RESOURCE_CREDITS";
242 		return (DAT_SUCCESS);
243 	}
244 	case DAT_INVALID_HANDLE_IA:
245 	{
246 		*message = "DAT_INVALID_HANDLE_IA";
247 		return (DAT_SUCCESS);
248 	}
249 	case DAT_INVALID_HANDLE_EP:
250 	{
251 		*message = "DAT_INVALID_HANDLE_EP";
252 		return (DAT_SUCCESS);
253 	}
254 	case DAT_INVALID_HANDLE_LMR:
255 	{
256 		*message = "DAT_INVALID_HANDLE_LMR";
257 		return (DAT_SUCCESS);
258 	}
259 	case  DAT_INVALID_HANDLE_RMR:
260 	{
261 		*message = "DAT_INVALID_HANDLE_RMR";
262 		return (DAT_SUCCESS);
263 	}
264 	case DAT_INVALID_HANDLE_PZ:
265 	{
266 		*message = "DAT_INVALID_HANDLE_PZ";
267 		return (DAT_SUCCESS);
268 	}
269 	case DAT_INVALID_HANDLE_PSP:
270 	{
271 		*message = "DAT_INVALID_HANDLE_PSP";
272 		return (DAT_SUCCESS);
273 	}
274 	case DAT_INVALID_HANDLE_RSP:
275 	{
276 		*message = "DAT_INVALID_HANDLE_RSP";
277 		return (DAT_SUCCESS);
278 	}
279 	case DAT_INVALID_HANDLE_CR:
280 	{
281 		*message = "DAT_INVALID_HANDLE_CR";
282 		return (DAT_SUCCESS);
283 	}
284 	case DAT_INVALID_HANDLE_CNO:
285 	{
286 		*message = "DAT_INVALID_HANDLE_CNO";
287 		return (DAT_SUCCESS);
288 	}
289 	case DAT_INVALID_HANDLE_EVD_CR:
290 	{
291 		*message = "DAT_INVALID_HANDLE_EVD_CR";
292 		return (DAT_SUCCESS);
293 	}
294 	case DAT_INVALID_HANDLE_EVD_REQUEST:
295 	{
296 		*message = "DAT_INVALID_HANDLE_EVD_REQUEST";
297 		return (DAT_SUCCESS);
298 	}
299 	case DAT_INVALID_HANDLE_EVD_RECV:
300 	{
301 		*message = "DAT_INVALID_HANDLE_EVD_RECV";
302 		return (DAT_SUCCESS);
303 	}
304 	case DAT_INVALID_HANDLE_EVD_CONN:
305 	{
306 		*message = "DAT_INVALID_HANDLE_EVD_CONN";
307 		return (DAT_SUCCESS);
308 	}
309 	case DAT_INVALID_HANDLE_EVD_ASYNC:
310 	{
311 		*message = "DAT_INVALID_HANDLE_EVD_ASYNC";
312 		return (DAT_SUCCESS);
313 	}
314 	case DAT_INVALID_ARG1:
315 	{
316 		*message = "DAT_INVALID_ARG1";
317 		return (DAT_SUCCESS);
318 	}
319 	case DAT_INVALID_ARG2:
320 	{
321 		*message = "DAT_INVALID_ARG2";
322 		return (DAT_SUCCESS);
323 	}
324 	case DAT_INVALID_ARG3:
325 	{
326 		*message = "DAT_INVALID_ARG3";
327 		return (DAT_SUCCESS);
328 	}
329 	case DAT_INVALID_ARG4:
330 	{
331 		*message = "DAT_INVALID_ARG4";
332 		return (DAT_SUCCESS);
333 	}
334 	case DAT_INVALID_ARG5:
335 	{
336 		*message = "DAT_INVALID_ARG5";
337 		return (DAT_SUCCESS);
338 	}
339 	case DAT_INVALID_ARG6:
340 	{
341 		*message = "DAT_INVALID_ARG6";
342 		return (DAT_SUCCESS);
343 	}
344 	case DAT_INVALID_ARG7:
345 	{
346 		*message = "DAT_INVALID_ARG7";
347 		return (DAT_SUCCESS);
348 	}
349 	case DAT_INVALID_ARG8:
350 	{
351 		*message = "DAT_INVALID_ARG8";
352 		return (DAT_SUCCESS);
353 	}
354 	case DAT_INVALID_ARG9:
355 	{
356 		*message = "DAT_INVALID_ARG9";
357 		return (DAT_SUCCESS);
358 	}
359 	case DAT_INVALID_ARG10:
360 	{
361 		*message = "DAT_INVALID_ARG10";
362 		return (DAT_SUCCESS);
363 	}
364 	case DAT_INVALID_STATE_EP_UNCONNECTED:
365 	{
366 		*message = "DAT_INVALID_STATE_EP_UNCONNECTED";
367 		return (DAT_SUCCESS);
368 	}
369 	case DAT_INVALID_STATE_EP_ACTCONNPENDING:
370 	{
371 		*message = "DAT_INVALID_STATE_EP_ACTCONNPENDING";
372 		return (DAT_SUCCESS);
373 	}
374 	case DAT_INVALID_STATE_EP_PASSCONNPENDING:
375 	{
376 		*message = "DAT_INVALID_STATE_EP_PASSCONNPENDING";
377 		return (DAT_SUCCESS);
378 	}
379 	case DAT_INVALID_STATE_EP_TENTCONNPENDING:
380 	{
381 		*message = "DAT_INVALID_STATE_EP_TENTCONNPENDING";
382 		return (DAT_SUCCESS);
383 	}
384 	case DAT_INVALID_STATE_EP_CONNECTED:
385 	{
386 		*message = "DAT_INVALID_STATE_EP_CONNECTED";
387 		return (DAT_SUCCESS);
388 	}
389 	case DAT_INVALID_STATE_EP_DISCONNECTED:
390 	{
391 		*message = "DAT_INVALID_STATE_EP_DISCONNECTED";
392 		return (DAT_SUCCESS);
393 	}
394 	case DAT_INVALID_STATE_EP_RESERVED:
395 	{
396 		*message = "DAT_INVALID_STATE_EP_RESERVED";
397 		return (DAT_SUCCESS);
398 	}
399 	case DAT_INVALID_STATE_EP_COMPLPENDING:
400 	{
401 		*message = "DAT_INVALID_STATE_EP_COMPLPENDING";
402 		return (DAT_SUCCESS);
403 	}
404 	case DAT_INVALID_STATE_EP_DISCPENDING:
405 	{
406 		*message = "DAT_INVALID_STATE_EP_DISCPENDING";
407 		return (DAT_SUCCESS);
408 	}
409 	case DAT_INVALID_STATE_EP_PROVIDERCONTROL:
410 	{
411 		*message = "DAT_INVALID_STATE_EP_PROVIDERCONTROL";
412 		return (DAT_SUCCESS);
413 	}
414 	case DAT_INVALID_STATE_EP_NOTREADY:
415 	{
416 		*message = "DAT_INVALID_STATE_EP_NOTREADY";
417 		return (DAT_SUCCESS);
418 	}
419 	case DAT_INVALID_STATE_CNO_IN_USE:
420 	{
421 		*message = "DAT_INVALID_STATE_CNO_IN_USE";
422 		return (DAT_SUCCESS);
423 	}
424 	case DAT_INVALID_STATE_CNO_DEAD:
425 	{
426 		*message = "DAT_INVALID_STATE_CNO_DEAD";
427 		return (DAT_SUCCESS);
428 	}
429 	case DAT_INVALID_STATE_EVD_OPEN:
430 	{
431 		*message = "DAT_INVALID_STATE_EVD_OPEN";
432 		return (DAT_SUCCESS);
433 	}
434 	case DAT_INVALID_STATE_EVD_ENABLED:
435 	{
436 		*message = "DAT_INVALID_STATE_EVD_ENABLED";
437 		return (DAT_SUCCESS);
438 	}
439 	case DAT_INVALID_STATE_EVD_DISABLED:
440 	{
441 		*message = "DAT_INVALID_STATE_EVD_DISABLED";
442 		return (DAT_SUCCESS);
443 	}
444 	case DAT_INVALID_STATE_EVD_WAITABLE:
445 	{
446 		*message = "DAT_INVALID_STATE_EVD_WAITABLE";
447 		return (DAT_SUCCESS);
448 	}
449 	case DAT_INVALID_STATE_EVD_UNWAITABLE:
450 	{
451 		*message = "DAT_INVALID_STATE_EVD_UNWAITABLE";
452 		return (DAT_SUCCESS);
453 	}
454 	case DAT_INVALID_STATE_EVD_IN_USE:
455 	{
456 		*message = "DAT_INVALID_STATE_EVD_IN_USE";
457 		return (DAT_SUCCESS);
458 	}
459 	case DAT_INVALID_STATE_EVD_CONFIG_NOTIFY:
460 	{
461 		*message = "DAT_INVALID_STATE_EVD_CONFIG_NOTIFY";
462 		return (DAT_SUCCESS);
463 	}
464 	case DAT_INVALID_STATE_EVD_CONFIG_SOLICITED:
465 	{
466 		*message = "DAT_INVALID_STATE_EVD_CONFIG_SOLICITED";
467 		return (DAT_SUCCESS);
468 	}
469 	case DAT_INVALID_STATE_EVD_CONFIG_THRESHOLD:
470 	{
471 		*message = "DAT_INVALID_STATE_EVD_CONFIG_THRESHOLD";
472 		return (DAT_SUCCESS);
473 	}
474 	case DAT_INVALID_STATE_EVD_WAITER:
475 	{
476 		*message = "DAT_INVALID_STATE_EVD_WAITER";
477 		return (DAT_SUCCESS);
478 	}
479 	case DAT_INVALID_STATE_EVD_ASYNC:
480 	{
481 		*message = "DAT_INVALID_STATE_EVD_ASYNC";
482 		return (DAT_SUCCESS);
483 	}
484 	case DAT_INVALID_STATE_IA_IN_USE:
485 	{
486 		*message = "DAT_INVALID_STATE_IA_IN_USE";
487 		return (DAT_SUCCESS);
488 	}
489 	case DAT_INVALID_STATE_LMR_IN_USE:
490 	{
491 		*message = "DAT_INVALID_STATE_LMR_IN_USE";
492 		return (DAT_SUCCESS);
493 	}
494 	case DAT_INVALID_STATE_LMR_FREE:
495 	{
496 		*message = "DAT_INVALID_STATE_LMR_FREE";
497 		return (DAT_SUCCESS);
498 	}
499 	case DAT_INVALID_STATE_PZ_IN_USE:
500 	{
501 		*message = "DAT_INVALID_STATE_PZ_IN_USE";
502 		return (DAT_SUCCESS);
503 	}
504 	case DAT_INVALID_STATE_PZ_FREE:
505 	{
506 		*message = "DAT_INVALID_STATE_PZ_FREE";
507 		return (DAT_SUCCESS);
508 	}
509 	case DAT_PRIVILEGES_READ:
510 	{
511 		*message = "DAT_PRIVILEGES_READ";
512 		return (DAT_SUCCESS);
513 	}
514 	case DAT_PRIVILEGES_WRITE:
515 	{
516 		*message = "DAT_PRIVILEGES_WRITE";
517 		return (DAT_SUCCESS);
518 	}
519 	case DAT_PRIVILEGES_RDMA_READ:
520 	{
521 		*message = "DAT_PRIVILEGES_RDMA_READ";
522 		return (DAT_SUCCESS);
523 	}
524 	case DAT_PRIVILEGES_RDMA_WRITE:
525 	{
526 		*message = "DAT_PRIVILEGES_RDMA_WRITE";
527 		return (DAT_SUCCESS);
528 	}
529 	case DAT_PROTECTION_READ:
530 	{
531 		*message = "DAT_PROTECTION_READ";
532 		return (DAT_SUCCESS);
533 	}
534 	case DAT_PROTECTION_WRITE:
535 	{
536 		*message = "DAT_PROTECTION_WRITE";
537 		return (DAT_SUCCESS);
538 	}
539 	case DAT_PROTECTION_RDMA_READ:
540 	{
541 		*message = "DAT_PROTECTION_RDMA_READ";
542 		return (DAT_SUCCESS);
543 	}
544 	case DAT_PROTECTION_RDMA_WRITE:
545 	{
546 		*message = "DAT_PROTECTION_RDMA_WRITE";
547 		return (DAT_SUCCESS);
548 	}
549 	case DAT_INVALID_ADDRESS_UNSUPPORTED:
550 	{
551 		*message = "DAT_INVALID_ADDRESS_UNSUPPORTED";
552 		return (DAT_SUCCESS);
553 	}
554 	case DAT_INVALID_ADDRESS_UNREACHABLE:
555 	{
556 		*message = "DAT_INVALID_ADDRESS_UNREACHABLE";
557 		return (DAT_SUCCESS);
558 	}
559 	case DAT_INVALID_ADDRESS_MALFORMED:
560 	{
561 		*message = "DAT_INVALID_ADDRESS_MALFORMED";
562 		return (DAT_SUCCESS);
563 	}
564 	default:
565 	{
566 		return (DAT_INVALID_PARAMETER);
567 	}
568 	}
569 }
570 
571 
572 /*
573  *
574  * External Function Definitions
575  *
576  */
577 
578 DAT_RETURN
579 dat_strerror(
580 	IN  DAT_RETURN 		value,
581 	OUT const char 		**major_message,
582 	OUT const char		**minor_message)
583 {
584 	/*
585 	 * The DAT specification contains a note to implementers
586 	 * suggesting that the consumer's DAT_RETURN value be used
587 	 * as an index into a table of text strings. However,
588 	 * the DAT_RETURN values are not consecutive. Therefore this
589 	 * implementation does not follow the suggested implementation.
590 	 */
591 
592 	if (DAT_SUCCESS != dat_strerror_major(value, major_message)) {
593 		return (DAT_INVALID_PARAMETER);
594 	} else if (DAT_SUCCESS != dat_strerror_minor(value, minor_message)) {
595 		return (DAT_INVALID_PARAMETER);
596 	} else {
597 		return (DAT_SUCCESS);
598 	}
599 }
600