xref: /freebsd/contrib/ofed/libibverbs/enum_strs.c (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1 /*
2  * Copyright (c) 2008 Lawrence Livermore National Laboratory
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #include <infiniband/verbs.h>
34 
35 const char *ibv_node_type_str(enum ibv_node_type node_type)
36 {
37 	static const char *const node_type_str[] = {
38 		[IBV_NODE_CA]		= "InfiniBand channel adapter",
39 		[IBV_NODE_SWITCH]	= "InfiniBand switch",
40 		[IBV_NODE_ROUTER]	= "InfiniBand router",
41 		[IBV_NODE_RNIC]		= "iWARP NIC",
42 		[IBV_NODE_USNIC]	= "usNIC",
43 		[IBV_NODE_USNIC_UDP]	= "usNIC UDP",
44 	};
45 
46 	if (node_type < IBV_NODE_CA || node_type > IBV_NODE_USNIC_UDP)
47 		return "unknown";
48 
49 	return node_type_str[node_type];
50 }
51 
52 const char *ibv_port_state_str(enum ibv_port_state port_state)
53 {
54 	static const char *const port_state_str[] = {
55 		[IBV_PORT_NOP]		= "no state change (NOP)",
56 		[IBV_PORT_DOWN]		= "down",
57 		[IBV_PORT_INIT]		= "init",
58 		[IBV_PORT_ARMED]	= "armed",
59 		[IBV_PORT_ACTIVE]	= "active",
60 		[IBV_PORT_ACTIVE_DEFER]	= "active defer"
61 	};
62 
63 	if (port_state < IBV_PORT_NOP || port_state > IBV_PORT_ACTIVE_DEFER)
64 		return "unknown";
65 
66 	return port_state_str[port_state];
67 }
68 
69 const char *ibv_event_type_str(enum ibv_event_type event)
70 {
71 	static const char *const event_type_str[] = {
72 		[IBV_EVENT_CQ_ERR]		= "CQ error",
73 		[IBV_EVENT_QP_FATAL]		= "local work queue catastrophic error",
74 		[IBV_EVENT_QP_REQ_ERR]		= "invalid request local work queue error",
75 		[IBV_EVENT_QP_ACCESS_ERR]	= "local access violation work queue error",
76 		[IBV_EVENT_COMM_EST]		= "communication established",
77 		[IBV_EVENT_SQ_DRAINED]		= "send queue drained",
78 		[IBV_EVENT_PATH_MIG]		= "path migrated",
79 		[IBV_EVENT_PATH_MIG_ERR]	= "path migration request error",
80 		[IBV_EVENT_DEVICE_FATAL]	= "local catastrophic error",
81 		[IBV_EVENT_PORT_ACTIVE]		= "port active",
82 		[IBV_EVENT_PORT_ERR]		= "port error",
83 		[IBV_EVENT_LID_CHANGE]		= "LID change",
84 		[IBV_EVENT_PKEY_CHANGE]		= "P_Key change",
85 		[IBV_EVENT_SM_CHANGE]		= "SM change",
86 		[IBV_EVENT_SRQ_ERR]		= "SRQ catastrophic error",
87 		[IBV_EVENT_SRQ_LIMIT_REACHED]	= "SRQ limit reached",
88 		[IBV_EVENT_QP_LAST_WQE_REACHED]	= "last WQE reached",
89 		[IBV_EVENT_CLIENT_REREGISTER]	= "client reregistration",
90 		[IBV_EVENT_GID_CHANGE]		= "GID table change"
91 	};
92 
93 	if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_GID_CHANGE)
94 		return "unknown";
95 
96 	return event_type_str[event];
97 }
98 
99 const char *ibv_wc_status_str(enum ibv_wc_status status)
100 {
101 	static const char *const wc_status_str[] = {
102 		[IBV_WC_SUCCESS]		= "success",
103 		[IBV_WC_LOC_LEN_ERR]		= "local length error",
104 		[IBV_WC_LOC_QP_OP_ERR]		= "local QP operation error",
105 		[IBV_WC_LOC_EEC_OP_ERR]		= "local EE context operation error",
106 		[IBV_WC_LOC_PROT_ERR]		= "local protection error",
107 		[IBV_WC_WR_FLUSH_ERR]		= "Work Request Flushed Error",
108 		[IBV_WC_MW_BIND_ERR]		= "memory management operation error",
109 		[IBV_WC_BAD_RESP_ERR]		= "bad response error",
110 		[IBV_WC_LOC_ACCESS_ERR]		= "local access error",
111 		[IBV_WC_REM_INV_REQ_ERR]	= "remote invalid request error",
112 		[IBV_WC_REM_ACCESS_ERR]		= "remote access error",
113 		[IBV_WC_REM_OP_ERR]		= "remote operation error",
114 		[IBV_WC_RETRY_EXC_ERR]		= "transport retry counter exceeded",
115 		[IBV_WC_RNR_RETRY_EXC_ERR]	= "RNR retry counter exceeded",
116 		[IBV_WC_LOC_RDD_VIOL_ERR]	= "local RDD violation error",
117 		[IBV_WC_REM_INV_RD_REQ_ERR]	= "remote invalid RD request",
118 		[IBV_WC_REM_ABORT_ERR]		= "aborted error",
119 		[IBV_WC_INV_EECN_ERR]		= "invalid EE context number",
120 		[IBV_WC_INV_EEC_STATE_ERR]	= "invalid EE context state",
121 		[IBV_WC_FATAL_ERR]		= "fatal error",
122 		[IBV_WC_RESP_TIMEOUT_ERR]	= "response timeout error",
123 		[IBV_WC_GENERAL_ERR]		= "general error"
124 	};
125 
126 	if (status < IBV_WC_SUCCESS || status > IBV_WC_GENERAL_ERR)
127 		return "unknown";
128 
129 	return wc_status_str[status];
130 }
131