]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ofed/libibverbs/src/enum_strs.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ofed / libibverbs / src / enum_strs.c
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         };
43
44         if (node_type < IBV_NODE_CA || node_type > IBV_NODE_RNIC)
45                 return "unknown";
46
47         return node_type_str[node_type];
48 }
49
50 const char *ibv_port_state_str(enum ibv_port_state port_state)
51 {
52         static const char *const port_state_str[] = {
53                 [IBV_PORT_NOP]          = "no state change (NOP)",
54                 [IBV_PORT_DOWN]         = "down",
55                 [IBV_PORT_INIT]         = "init",
56                 [IBV_PORT_ARMED]        = "armed",
57                 [IBV_PORT_ACTIVE]       = "active",
58                 [IBV_PORT_ACTIVE_DEFER] = "active defer"
59         };
60
61         if (port_state < IBV_PORT_NOP || port_state > IBV_PORT_ACTIVE_DEFER)
62                 return "unknown";
63
64         return port_state_str[port_state];
65 }
66
67 const char *ibv_event_type_str(enum ibv_event_type event)
68 {
69         static const char *const event_type_str[] = {
70                 [IBV_EVENT_CQ_ERR]              = "CQ error",
71                 [IBV_EVENT_QP_FATAL]            = "local work queue catastrophic error",
72                 [IBV_EVENT_QP_REQ_ERR]          = "invalid request local work queue error",
73                 [IBV_EVENT_QP_ACCESS_ERR]       = "local access violation work queue error",
74                 [IBV_EVENT_COMM_EST]            = "communication established",
75                 [IBV_EVENT_SQ_DRAINED]          = "send queue drained",
76                 [IBV_EVENT_PATH_MIG]            = "path migrated",
77                 [IBV_EVENT_PATH_MIG_ERR]        = "path migration request error",
78                 [IBV_EVENT_DEVICE_FATAL]        = "local catastrophic error",
79                 [IBV_EVENT_PORT_ACTIVE]         = "port active",
80                 [IBV_EVENT_PORT_ERR]            = "port error",
81                 [IBV_EVENT_LID_CHANGE]          = "LID change",
82                 [IBV_EVENT_PKEY_CHANGE]         = "P_Key change",
83                 [IBV_EVENT_SM_CHANGE]           = "SM change",
84                 [IBV_EVENT_SRQ_ERR]             = "SRQ catastrophic error",
85                 [IBV_EVENT_SRQ_LIMIT_REACHED]   = "SRQ limit reached",
86                 [IBV_EVENT_QP_LAST_WQE_REACHED] = "last WQE reached",
87                 [IBV_EVENT_CLIENT_REREGISTER]   = "client reregistration",
88         };
89
90         if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_CLIENT_REREGISTER)
91                 return "unknown";
92
93         return event_type_str[event];
94 }
95
96 const char *ibv_wc_status_str(enum ibv_wc_status status)
97 {
98         static const char *const wc_status_str[] = {
99                 [IBV_WC_SUCCESS]                = "success",
100                 [IBV_WC_LOC_LEN_ERR]            = "local length error",
101                 [IBV_WC_LOC_QP_OP_ERR]          = "local QP operation error",
102                 [IBV_WC_LOC_EEC_OP_ERR]         = "local EE context operation error",
103                 [IBV_WC_LOC_PROT_ERR]           = "local protection error",
104                 [IBV_WC_WR_FLUSH_ERR]           = "Work Request Flushed Error",
105                 [IBV_WC_MW_BIND_ERR]            = "memory management operation error",
106                 [IBV_WC_BAD_RESP_ERR]           = "bad response error",
107                 [IBV_WC_LOC_ACCESS_ERR]         = "local access error",
108                 [IBV_WC_REM_INV_REQ_ERR]        = "remote invalid request error",
109                 [IBV_WC_REM_ACCESS_ERR]         = "remote access error",
110                 [IBV_WC_REM_OP_ERR]             = "remote operation error",
111                 [IBV_WC_RETRY_EXC_ERR]          = "transport retry counter exceeded",
112                 [IBV_WC_RNR_RETRY_EXC_ERR]      = "RNR retry counter exceeded",
113                 [IBV_WC_LOC_RDD_VIOL_ERR]       = "local RDD violation error",
114                 [IBV_WC_REM_INV_RD_REQ_ERR]     = "remote invalid RD request",
115                 [IBV_WC_REM_ABORT_ERR]          = "aborted error",
116                 [IBV_WC_INV_EECN_ERR]           = "invalid EE context number",
117                 [IBV_WC_INV_EEC_STATE_ERR]      = "invalid EE context state",
118                 [IBV_WC_FATAL_ERR]              = "fatal error",
119                 [IBV_WC_RESP_TIMEOUT_ERR]       = "response timeout error",
120                 [IBV_WC_GENERAL_ERR]            = "general error"
121         };
122
123         if (status < IBV_WC_SUCCESS || status > IBV_WC_GENERAL_ERR)
124                 return "unknown";
125
126         return wc_status_str[status];
127 }