File: umad_str.c

package info (click to toggle)
rdma-core 33.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,844 kB
  • sloc: ansic: 145,804; python: 5,688; sh: 2,761; perl: 1,465; makefile: 73
file content (352 lines) | stat: -rw-r--r-- 10,111 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/*
 * Copyright (c) 2004, 2005, 2010 Intel Corporation.  All rights reserved.
 * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved.
 * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

#include <endian.h>
#include <stdio.h>
#include <infiniband/umad.h>
#include <infiniband/umad_types.h>
#include <infiniband/umad_sm.h>
#include <infiniband/umad_sa.h>
#include <infiniband/umad_cm.h>
#include "umad_str.h"

const char * umad_class_str(uint8_t mgmt_class)
{
	switch (mgmt_class) {
		case UMAD_CLASS_SUBN_LID_ROUTED:
		case UMAD_CLASS_SUBN_DIRECTED_ROUTE:
			return("Subn");
		case UMAD_CLASS_SUBN_ADM:
			return("SubnAdm");
		case UMAD_CLASS_PERF_MGMT:
			return("Perf");
		case UMAD_CLASS_BM:
			return("BM");
		case UMAD_CLASS_DEVICE_MGMT:
			return("DevMgt");
		case UMAD_CLASS_CM:
			return("ComMgt");
		case UMAD_CLASS_SNMP:
			return("SNMP");
		case UMAD_CLASS_DEVICE_ADM:
			return("DevAdm");
		case UMAD_CLASS_BOOT_MGMT:
			return("BootMgt");
		case UMAD_CLASS_BIS:
			return("BIS");
		case UMAD_CLASS_CONG_MGMT:
			return("CongestionManagment");
		default:
			break;
	}

	if ((UMAD_CLASS_VENDOR_RANGE1_START <= mgmt_class
		&& mgmt_class <= UMAD_CLASS_VENDOR_RANGE1_END)
	    || (UMAD_CLASS_VENDOR_RANGE2_START <= mgmt_class
		&& mgmt_class <= UMAD_CLASS_VENDOR_RANGE2_END))
		return("Vendor");

	if (UMAD_CLASS_APPLICATION_START <= mgmt_class
	    && mgmt_class <= UMAD_CLASS_APPLICATION_END) {
		return("Application");
	}
	return ("<unknown>");
}

static const char * umad_common_method_str(uint8_t method)
{
	switch(method) {
		case UMAD_METHOD_GET:
			return ("Get");
		case UMAD_METHOD_SET:
			return ("Set");
		case UMAD_METHOD_GET_RESP:
			return ("GetResp");
		case UMAD_METHOD_SEND:
			return ("Send");
		case UMAD_METHOD_TRAP:
			return ("Trap");
		case UMAD_METHOD_REPORT:
			return ("Report");
		case UMAD_METHOD_REPORT_RESP:
			return ("ReportResp");
		case UMAD_METHOD_TRAP_REPRESS:
			return ("TrapRepress");
		default:
			return ("<unknown");
	}
}

static const char * umad_sa_method_str(uint8_t method)
{
	switch(method) {
		case UMAD_SA_METHOD_GET_TABLE:
			return ("GetTable");
		case UMAD_SA_METHOD_GET_TABLE_RESP:
			return ("GetTableResp");
		case UMAD_SA_METHOD_DELETE:
			return ("Delete");
		case UMAD_SA_METHOD_DELETE_RESP:
			return ("DeleteResp");
		case UMAD_SA_METHOD_GET_MULTI:
			return ("GetMulti");
		case UMAD_SA_METHOD_GET_MULTI_RESP:
			return ("GetMultiResp");
		case UMAD_SA_METHOD_GET_TRACE_TABLE:
			return ("GetTraceTable");
		default:
			return (umad_common_method_str(method));
	}
}

const char * umad_method_str(uint8_t mgmt_class, uint8_t method)
{
	if (mgmt_class == UMAD_CLASS_SUBN_ADM)
		return(umad_sa_method_str(method));

	return (umad_common_method_str(method));
}

const char * umad_common_mad_status_str(__be16 _status)
{
	uint16_t status = be16toh(_status);

	if (status & UMAD_STATUS_BUSY)
		return ("Busy");

	if (status & UMAD_STATUS_REDIRECT)
		return ("Redirection required");

	switch(status & UMAD_STATUS_INVALID_FIELD_MASK) {
		case UMAD_STATUS_BAD_VERSION:
			return ("Bad Version");
		case UMAD_STATUS_METHOD_NOT_SUPPORTED:
			return ("Method not supported");
		case UMAD_STATUS_ATTR_NOT_SUPPORTED:
			return ("Method/Attribute combo not supported");
		case UMAD_STATUS_INVALID_ATTR_VALUE:
			return ("Invalid attribute/modifier field");
	}
	return ("Success");
}

const char * umad_sa_mad_status_str(__be16 _status)
{
	uint16_t status = be16toh(_status);
	switch((status & UMAD_STATUS_CLASS_MASK) >> 8) {
		case UMAD_SA_STATUS_SUCCESS:
			return ("Success");
		case UMAD_SA_STATUS_NO_RESOURCES:
			return ("No Resources");
		case UMAD_SA_STATUS_REQ_INVALID:
			return ("Request Invalid");
		case UMAD_SA_STATUS_NO_RECORDS:
			return ("No Records");
		case UMAD_SA_STATUS_TOO_MANY_RECORDS:
			return ("Too Many Records");
		case UMAD_SA_STATUS_INVALID_GID:
			return ("Invalid GID");
		case UMAD_SA_STATUS_INSUF_COMPS:
			return ("Insufficient Components");
		case UMAD_SA_STATUS_REQ_DENIED:
			return ("Request Denied");
		case UMAD_SA_STATUS_PRI_SUGGESTED:
			return ("Priority Suggested");
	}
	return ("Undefined Error");
}

static const char *umad_common_attr_str(__be16 attr_id)
{
	switch(be16toh(attr_id)) {
		case UMAD_ATTR_CLASS_PORT_INFO:
			return "Class Port Info";
		case UMAD_ATTR_NOTICE:
			return "Notice";
		case UMAD_ATTR_INFORM_INFO:
			return "Inform Info";
		default:
			return "<unknown>";
	}
}

static const char * umad_sm_attr_str(__be16 attr_id)
{
	switch(be16toh(attr_id)) {
		case UMAD_SM_ATTR_NODE_DESC:
			return ("NodeDescription");
		case UMAD_SM_ATTR_NODE_INFO:
			return ("NodeInfo");
		case UMAD_SM_ATTR_SWITCH_INFO:
			return ("SwitchInfo");
		case UMAD_SM_ATTR_GUID_INFO:
			return ("GUIDInfo");
		case UMAD_SM_ATTR_PORT_INFO:
			return ("PortInfo");
		case UMAD_SM_ATTR_PKEY_TABLE:
			return ("P_KeyTable");
		case UMAD_SM_ATTR_SLVL_TABLE:
			return ("SLtoVLMappingTable");
		case UMAD_SM_ATTR_VL_ARB_TABLE:
			return ("VLArbitrationTable");
		case UMAD_SM_ATTR_LINEAR_FT:
			return ("LinearForwardingTable");
		case UMAD_SM_ATTR_RANDOM_FT:
			return ("RandomForwardingTable");
		case UMAD_SM_ATTR_MCAST_FT:
			return ("MulticastForwardingTable");
		case UMAD_SM_ATTR_SM_INFO:
			return ("SMInfo");
		case UMAD_SM_ATTR_VENDOR_DIAG:
			return ("VendorDiag");
		case UMAD_SM_ATTR_LED_INFO:
			return ("LedInfo");
		case UMAD_SM_ATTR_LINK_SPD_WIDTH_TABLE:
			return ("LinkSpeedWidthPairsTable");
		case UMAD_SM_ATTR_VENDOR_MADS_TABLE:
			return ("VendorSpecificMadsTable");
		case UMAD_SM_ATTR_HIERARCHY_INFO:
			return ("HierarchyInfo");
		case UMAD_SM_ATTR_CABLE_INFO:
			return ("CableInfo");
		case UMAD_SM_ATTR_PORT_INFO_EXT:
			return ("PortInfoExtended");
		default:
			return (umad_common_attr_str(attr_id));
	}
}

static const char * umad_sa_attr_str(__be16 attr_id)
{
	switch(be16toh(attr_id)) {
		case UMAD_SA_ATTR_NODE_REC:
			return ("NodeRecord");
		case UMAD_SA_ATTR_PORT_INFO_REC:
			return ("PortInfoRecord");
		case UMAD_SA_ATTR_SLVL_REC:
			return ("SLtoVLMappingTableRecord");
		case UMAD_SA_ATTR_SWITCH_INFO_REC:
			return ("SwitchInfoRecord");
		case UMAD_SA_ATTR_LINEAR_FT_REC:
			return ("LinearForwardingTableRecord");
		case UMAD_SA_ATTR_RANDOM_FT_REC:
			return ("RandomForwardingTableRecord");
		case UMAD_SA_ATTR_MCAST_FT_REC:
			return ("MulticastForwardingTableRecord");
		case UMAD_SA_ATTR_SM_INFO_REC:
			return ("SMInfoRecord");
		case UMAD_SA_ATTR_INFORM_INFO_REC:
			return ("InformInfoRecord");
		case UMAD_SA_ATTR_LINK_REC:
			return ("LinkRecord");
		case UMAD_SA_ATTR_GUID_INFO_REC:
			return ("GuidInfoRecord");
		case UMAD_SA_ATTR_SERVICE_REC:
			return ("ServiceRecord");
		case UMAD_SA_ATTR_PKEY_TABLE_REC:
			return ("P_KeyTableRecord");
		case UMAD_SA_ATTR_PATH_REC:
			return ("PathRecord");
		case UMAD_SA_ATTR_VL_ARB_REC:
			return ("VLArbitrationTableRecord");
		case UMAD_SA_ATTR_MCMEMBER_REC:
			return ("MCMemberRecord");
		case UMAD_SA_ATTR_TRACE_REC:
			return ("TraceRecord");
		case UMAD_SA_ATTR_MULTI_PATH_REC:
			return ("MultiPathRecord");
		case UMAD_SA_ATTR_SERVICE_ASSOC_REC:
			return ("ServiceAssociationRecord");
		case UMAD_SA_ATTR_LINK_SPD_WIDTH_TABLE_REC:
			return ("LinkSpeedWidthPairsTableRecord");
		case UMAD_SA_ATTR_HIERARCHY_INFO_REC:
			return ("HierarchyInfoRecord");
		case UMAD_SA_ATTR_CABLE_INFO_REC:
			return ("CableInfoRecord");
		case UMAD_SA_ATTR_PORT_INFO_EXT_REC:
			return ("PortInfoExtendedRecord");
		default:
			return (umad_common_attr_str(attr_id));
	}
}

static const char * umad_cm_attr_str(__be16 attr_id)
{
	switch(be16toh(attr_id)) {
		case UMAD_CM_ATTR_REQ:
			return "ConnectRequest";
		case UMAD_CM_ATTR_MRA:
			return "MsgRcptAck";
		case UMAD_CM_ATTR_REJ:
			return "ConnectReject";
		case UMAD_CM_ATTR_REP:
			return "ConnectReply";
		case UMAD_CM_ATTR_RTU:
			return "ReadyToUse";
		case UMAD_CM_ATTR_DREQ:
			return "DisconnectRequest";
		case UMAD_CM_ATTR_DREP:
			return "DisconnectReply";
		case UMAD_CM_ATTR_SIDR_REQ:
			return "ServiceIDResReq";
		case UMAD_CM_ATTR_SIDR_REP:
			return "ServiceIDResReqResp";
		case UMAD_CM_ATTR_LAP:
			return "LoadAlternatePath";
		case UMAD_CM_ATTR_APR:
			return "AlternatePathResponse";
		case UMAD_CM_ATTR_SAP:
			return "SuggestAlternatePath";
		case UMAD_CM_ATTR_SPR:
			return "SuggestPathResponse";
		default:
			return (umad_common_attr_str(attr_id));
	}
}

const char * umad_attribute_str(uint8_t mgmt_class, __be16 attr_id)
{
	switch (mgmt_class) {
		case UMAD_CLASS_SUBN_LID_ROUTED:
		case UMAD_CLASS_SUBN_DIRECTED_ROUTE:
			return(umad_sm_attr_str(attr_id));
		case UMAD_CLASS_SUBN_ADM:
			return(umad_sa_attr_str(attr_id));
		case UMAD_CLASS_CM:
			return(umad_cm_attr_str(attr_id));
	}

	return (umad_common_attr_str(attr_id));
}