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));
251 static const char * umad_sa_attr_str(__be16 attr_id)
253 switch(be16toh(attr_id)) {
254 case UMAD_SA_ATTR_NODE_REC:
255 return ("NodeRecord");
256 case UMAD_SA_ATTR_PORT_INFO_REC:
257 return ("PortInfoRecord");
258 case UMAD_SA_ATTR_SLVL_REC:
259 return ("SLtoVLMappingTableRecord");
260 case UMAD_SA_ATTR_SWITCH_INFO_REC:
261 return ("SwitchInfoRecord");
262 case UMAD_SA_ATTR_LINEAR_FT_REC:
263 return ("LinearForwardingTableRecord");
264 case UMAD_SA_ATTR_RANDOM_FT_REC:
265 return ("RandomForwardingTableRecord");
266 case UMAD_SA_ATTR_MCAST_FT_REC:
267 return ("MulticastForwardingTableRecord");
268 case UMAD_SA_ATTR_SM_INFO_REC:
269 return ("SMInfoRecord");
270 case UMAD_SA_ATTR_INFORM_INFO_REC:
271 return ("InformInfoRecord");
272 case UMAD_SA_ATTR_LINK_REC:
273 return ("LinkRecord");
274 case UMAD_SA_ATTR_GUID_INFO_REC:
275 return ("GuidInfoRecord");
276 case UMAD_SA_ATTR_SERVICE_REC:
277 return ("ServiceRecord");
278 case UMAD_SA_ATTR_PKEY_TABLE_REC:
279 return ("P_KeyTableRecord");
280 case UMAD_SA_ATTR_PATH_REC:
281 return ("PathRecord");
282 case UMAD_SA_ATTR_VL_ARB_REC:
283 return ("VLArbitrationTableRecord");
284 case UMAD_SA_ATTR_MCMEMBER_REC:
285 return ("MCMemberRecord");
286 case UMAD_SA_ATTR_TRACE_REC:
287 return ("TraceRecord");
288 case UMAD_SA_ATTR_MULTI_PATH_REC:
289 return ("MultiPathRecord");
290 case UMAD_SA_ATTR_SERVICE_ASSOC_REC:
291 return ("ServiceAssociationRecord");
292 case UMAD_SA_ATTR_LINK_SPD_WIDTH_TABLE_REC:
293 return ("LinkSpeedWidthPairsTableRecord");
294 case UMAD_SA_ATTR_HIERARCHY_INFO_REC:
295 return ("HierarchyInfoRecord");
296 case UMAD_SA_ATTR_CABLE_INFO_REC:
297 return ("CableInfoRecord");
298 case UMAD_SA_ATTR_PORT_INFO_EXT_REC:
299 return ("PortInfoExtendedRecord");
301 return (umad_common_attr_str(attr_id));
305 static const char * umad_cm_attr_str(__be16 attr_id)
307 switch(be16toh(attr_id)) {
308 case UMAD_CM_ATTR_REQ:
309 return "ConnectRequest";
310 case UMAD_CM_ATTR_MRA:
312 case UMAD_CM_ATTR_REJ:
313 return "ConnectReject";
314 case UMAD_CM_ATTR_REP:
315 return "ConnectReply";
316 case UMAD_CM_ATTR_RTU:
318 case UMAD_CM_ATTR_DREQ:
319 return "DisconnectRequest";
320 case UMAD_CM_ATTR_DREP:
321 return "DisconnectReply";
322 case UMAD_CM_ATTR_SIDR_REQ:
323 return "ServiceIDResReq";
324 case UMAD_CM_ATTR_SIDR_REP:
325 return "ServiceIDResReqResp";
326 case UMAD_CM_ATTR_LAP:
327 return "LoadAlternatePath";
328 case UMAD_CM_ATTR_APR:
329 return "AlternatePathResponse";
330 case UMAD_CM_ATTR_SAP:
331 return "SuggestAlternatePath";
332 case UMAD_CM_ATTR_SPR:
333 return "SuggestPathResponse";
335 return (umad_common_attr_str(attr_id));
339 const char * umad_attribute_str(uint8_t mgmt_class, __be16 attr_id)
341 switch (mgmt_class) {
342 case UMAD_CLASS_SUBN_LID_ROUTED:
343 case UMAD_CLASS_SUBN_DIRECTED_ROUTE:
344 return(umad_sm_attr_str(attr_id));
345 case UMAD_CLASS_SUBN_ADM:
346 return(umad_sa_attr_str(attr_id));
348 return(umad_cm_attr_str(attr_id));
351 return (umad_common_attr_str(attr_id));