2 * Copyright (c) 2004, 2005, 2010 Intel Corporation. All rights reserved.
3 * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved.
4 * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 #include <infiniband/endian.h>
38 #include <infiniband/umad.h>
39 #include <infiniband/umad_types.h>
40 #include <infiniband/umad_sm.h>
41 #include <infiniband/umad_sa.h>
42 #include <infiniband/umad_cm.h>
45 const char * umad_class_str(uint8_t mgmt_class)
48 case UMAD_CLASS_SUBN_LID_ROUTED:
49 case UMAD_CLASS_SUBN_DIRECTED_ROUTE:
51 case UMAD_CLASS_SUBN_ADM:
53 case UMAD_CLASS_PERF_MGMT:
57 case UMAD_CLASS_DEVICE_MGMT:
63 case UMAD_CLASS_DEVICE_ADM:
65 case UMAD_CLASS_BOOT_MGMT:
69 case UMAD_CLASS_CONG_MGMT:
70 return("CongestionManagment");
75 if ((UMAD_CLASS_VENDOR_RANGE1_START <= mgmt_class
76 && mgmt_class <= UMAD_CLASS_VENDOR_RANGE1_END)
77 || (UMAD_CLASS_VENDOR_RANGE2_START <= mgmt_class
78 && mgmt_class <= UMAD_CLASS_VENDOR_RANGE2_END))
81 if (UMAD_CLASS_APPLICATION_START <= mgmt_class
82 && mgmt_class <= UMAD_CLASS_APPLICATION_END) {
83 return("Application");
88 static const char * umad_common_method_str(uint8_t method)
95 case UMAD_METHOD_GET_RESP:
97 case UMAD_METHOD_SEND:
99 case UMAD_METHOD_TRAP:
101 case UMAD_METHOD_REPORT:
103 case UMAD_METHOD_REPORT_RESP:
104 return ("ReportResp");
105 case UMAD_METHOD_TRAP_REPRESS:
106 return ("TrapRepress");
112 static const char * umad_sa_method_str(uint8_t method)
115 case UMAD_SA_METHOD_GET_TABLE:
117 case UMAD_SA_METHOD_GET_TABLE_RESP:
118 return ("GetTableResp");
119 case UMAD_SA_METHOD_DELETE:
121 case UMAD_SA_METHOD_DELETE_RESP:
122 return ("DeleteResp");
123 case UMAD_SA_METHOD_GET_MULTI:
125 case UMAD_SA_METHOD_GET_MULTI_RESP:
126 return ("GetMultiResp");
127 case UMAD_SA_METHOD_GET_TRACE_TABLE:
128 return ("GetTraceTable");
130 return (umad_common_method_str(method));
134 const char * umad_method_str(uint8_t mgmt_class, uint8_t method)
136 if (mgmt_class == UMAD_CLASS_SUBN_ADM)
137 return(umad_sa_method_str(method));
139 return (umad_common_method_str(method));
142 const char * umad_common_mad_status_str(__be16 _status)
144 uint16_t status = be16toh(_status);
146 if (status & UMAD_STATUS_BUSY)
149 if (status & UMAD_STATUS_REDIRECT)
150 return ("Redirection required");
152 switch(status & UMAD_STATUS_INVALID_FIELD_MASK) {
153 case UMAD_STATUS_BAD_VERSION:
154 return ("Bad Version");
155 case UMAD_STATUS_METHOD_NOT_SUPPORTED:
156 return ("Method not supported");
157 case UMAD_STATUS_ATTR_NOT_SUPPORTED:
158 return ("Method/Attribute combo not supported");
159 case UMAD_STATUS_INVALID_ATTR_VALUE:
160 return ("Invalid attribute/modifier field");
165 const char * umad_sa_mad_status_str(__be16 _status)
167 uint16_t status = be16toh(_status);
168 switch((status & UMAD_STATUS_CLASS_MASK) >> 8) {
169 case UMAD_SA_STATUS_SUCCESS:
171 case UMAD_SA_STATUS_NO_RESOURCES:
172 return ("No Resources");
173 case UMAD_SA_STATUS_REQ_INVALID:
174 return ("Request Invalid");
175 case UMAD_SA_STATUS_NO_RECORDS:
176 return ("No Records");
177 case UMAD_SA_STATUS_TOO_MANY_RECORDS:
178 return ("Too Many Records");
179 case UMAD_SA_STATUS_INVALID_GID:
180 return ("Invalid GID");
181 case UMAD_SA_STATUS_INSUF_COMPS:
182 return ("Insufficient Components");
183 case UMAD_SA_STATUS_REQ_DENIED:
184 return ("Request Denied");
185 case UMAD_SA_STATUS_PRI_SUGGESTED:
186 return ("Priority Suggested");
188 return ("Undefined Error");
191 static const char *umad_common_attr_str(__be16 attr_id)
193 switch(be16toh(attr_id)) {
194 case UMAD_ATTR_CLASS_PORT_INFO:
195 return "Class Port Info";
196 case UMAD_ATTR_NOTICE:
198 case UMAD_ATTR_INFORM_INFO:
199 return "Inform Info";
205 static const char * umad_sm_attr_str(__be16 attr_id)
207 switch(be16toh(attr_id)) {
208 case UMAD_SM_ATTR_NODE_DESC:
209 return ("NodeDescription");
210 case UMAD_SM_ATTR_NODE_INFO:
212 case UMAD_SM_ATTR_SWITCH_INFO:
213 return ("SwitchInfo");
214 case UMAD_SM_ATTR_GUID_INFO:
216 case UMAD_SM_ATTR_PORT_INFO:
218 case UMAD_SM_ATTR_PKEY_TABLE:
219 return ("P_KeyTable");
220 case UMAD_SM_ATTR_SLVL_TABLE:
221 return ("SLtoVLMappingTable");
222 case UMAD_SM_ATTR_VL_ARB_TABLE:
223 return ("VLArbitrationTable");
224 case UMAD_SM_ATTR_LINEAR_FT:
225 return ("LinearForwardingTable");
226 case UMAD_SM_ATTR_RANDOM_FT:
227 return ("RandomForwardingTable");
228 case UMAD_SM_ATTR_MCAST_FT:
229 return ("MulticastForwardingTable");
230 case UMAD_SM_ATTR_SM_INFO:
232 case UMAD_SM_ATTR_VENDOR_DIAG:
233 return ("VendorDiag");
234 case UMAD_SM_ATTR_LED_INFO:
236 case UMAD_SM_ATTR_LINK_SPD_WIDTH_TABLE:
237 return ("LinkSpeedWidthPairsTable");
238 case UMAD_SM_ATTR_VENDOR_MADS_TABLE:
239 return ("VendorSpecificMadsTable");
240 case UMAD_SM_ATTR_HIERARCHY_INFO:
241 return ("HierarchyInfo");
242 case UMAD_SM_ATTR_CABLE_INFO:
243 return ("CableInfo");
244 case UMAD_SM_ATTR_PORT_INFO_EXT:
245 return ("PortInfoExtended");
247 return (umad_common_attr_str(attr_id));
249 return ("<unknown>");
252 static const char * umad_sa_attr_str(__be16 attr_id)
254 switch(be16toh(attr_id)) {
255 case UMAD_SA_ATTR_NODE_REC:
256 return ("NodeRecord");
257 case UMAD_SA_ATTR_PORT_INFO_REC:
258 return ("PortInfoRecord");
259 case UMAD_SA_ATTR_SLVL_REC:
260 return ("SLtoVLMappingTableRecord");
261 case UMAD_SA_ATTR_SWITCH_INFO_REC:
262 return ("SwitchInfoRecord");
263 case UMAD_SA_ATTR_LINEAR_FT_REC:
264 return ("LinearForwardingTableRecord");
265 case UMAD_SA_ATTR_RANDOM_FT_REC:
266 return ("RandomForwardingTableRecord");
267 case UMAD_SA_ATTR_MCAST_FT_REC:
268 return ("MulticastForwardingTableRecord");
269 case UMAD_SA_ATTR_SM_INFO_REC:
270 return ("SMInfoRecord");
271 case UMAD_SA_ATTR_INFORM_INFO_REC:
272 return ("InformInfoRecord");
273 case UMAD_SA_ATTR_LINK_REC:
274 return ("LinkRecord");
275 case UMAD_SA_ATTR_GUID_INFO_REC:
276 return ("GuidInfoRecord");
277 case UMAD_SA_ATTR_SERVICE_REC:
278 return ("ServiceRecord");
279 case UMAD_SA_ATTR_PKEY_TABLE_REC:
280 return ("P_KeyTableRecord");
281 case UMAD_SA_ATTR_PATH_REC:
282 return ("PathRecord");
283 case UMAD_SA_ATTR_VL_ARB_REC:
284 return ("VLArbitrationTableRecord");
285 case UMAD_SA_ATTR_MCMEMBER_REC:
286 return ("MCMemberRecord");
287 case UMAD_SA_ATTR_TRACE_REC:
288 return ("TraceRecord");
289 case UMAD_SA_ATTR_MULTI_PATH_REC:
290 return ("MultiPathRecord");
291 case UMAD_SA_ATTR_SERVICE_ASSOC_REC:
292 return ("ServiceAssociationRecord");
293 case UMAD_SA_ATTR_LINK_SPD_WIDTH_TABLE_REC:
294 return ("LinkSpeedWidthPairsTableRecord");
295 case UMAD_SA_ATTR_HIERARCHY_INFO_REC:
296 return ("HierarchyInfoRecord");
297 case UMAD_SA_ATTR_CABLE_INFO_REC:
298 return ("CableInfoRecord");
299 case UMAD_SA_ATTR_PORT_INFO_EXT_REC:
300 return ("PortInfoExtendedRecord");
302 return (umad_common_attr_str(attr_id));
304 return ("<unknown>");
307 static const char * umad_cm_attr_str(__be16 attr_id)
309 switch(be16toh(attr_id)) {
310 case UMAD_CM_ATTR_REQ:
311 return "ConnectRequest";
312 case UMAD_CM_ATTR_MRA:
314 case UMAD_CM_ATTR_REJ:
315 return "ConnectReject";
316 case UMAD_CM_ATTR_REP:
317 return "ConnectReply";
318 case UMAD_CM_ATTR_RTU:
320 case UMAD_CM_ATTR_DREQ:
321 return "DisconnectRequest";
322 case UMAD_CM_ATTR_DREP:
323 return "DisconnectReply";
324 case UMAD_CM_ATTR_SIDR_REQ:
325 return "ServiceIDResReq";
326 case UMAD_CM_ATTR_SIDR_REP:
327 return "ServiceIDResReqResp";
328 case UMAD_CM_ATTR_LAP:
329 return "LoadAlternatePath";
330 case UMAD_CM_ATTR_APR:
331 return "AlternatePathResponse";
332 case UMAD_CM_ATTR_SAP:
333 return "SuggestAlternatePath";
334 case UMAD_CM_ATTR_SPR:
335 return "SuggestPathResponse";
337 return (umad_common_attr_str(attr_id));
339 return ("<unknown>");
342 const char * umad_attribute_str(uint8_t mgmt_class, __be16 attr_id)
344 switch (mgmt_class) {
345 case UMAD_CLASS_SUBN_LID_ROUTED:
346 case UMAD_CLASS_SUBN_DIRECTED_ROUTE:
347 return(umad_sm_attr_str(attr_id));
348 case UMAD_CLASS_SUBN_ADM:
349 return(umad_sa_attr_str(attr_id));
351 return(umad_cm_attr_str(attr_id));
354 return (umad_common_attr_str(attr_id));