1 /* 2 * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved. 3 * Copyright (c) 2009 HNR Consulting. All rights reserved. 4 * Copyright (c) 2009-2011 Mellanox Technologies LTD. All rights reserved. 5 * 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: 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer. 19 * 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. 24 * 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 32 * SOFTWARE. 33 * 34 */ 35 36 #if HAVE_CONFIG_H 37 # include <config.h> 38 #endif /* HAVE_CONFIG_H */ 39 40 #include <stdio.h> 41 #include <stdlib.h> 42 #include <string.h> 43 44 #include <infiniband/mad.h> 45 46 /* 47 * BITSOFFS and BE_OFFS are required due the fact that the bit offsets are inconsistently 48 * encoded in the IB spec - IB headers are encoded such that the bit offsets 49 * are in big endian convention (BE_OFFS), while the SMI/GSI queries data fields bit 50 * offsets are specified using real bit offset (?!) 51 * The following macros normalize everything to big endian offsets. 52 */ 53 #define BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w)))), (w) 54 #define BE_OFFS(o, w) (o), (w) 55 #define BE_TO_BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w)))) 56 57 static const ib_field_t ib_mad_f[] = { 58 {0, 0}, /* IB_NO_FIELD - reserved as invalid */ 59 60 {0, 64, "GidPrefix", mad_dump_rhex}, 61 {64, 64, "GidGuid", mad_dump_rhex}, 62 63 /* 64 * MAD: common MAD fields (IB spec 13.4.2) 65 * SMP: Subnet Management packets - lid routed (IB spec 14.2.1.1) 66 * DSMP: Subnet Management packets - direct route (IB spec 14.2.1.2) 67 * SA: Subnet Administration packets (IB spec 15.2.1.1) 68 */ 69 70 /* first MAD word (0-3 bytes) */ 71 {BE_OFFS(0, 7), "MadMethod", mad_dump_hex}, /* TODO: add dumper */ 72 {BE_OFFS(7, 1), "MadIsResponse", mad_dump_uint}, /* TODO: add dumper */ 73 {BE_OFFS(8, 8), "MadClassVersion", mad_dump_uint}, 74 {BE_OFFS(16, 8), "MadMgmtClass", mad_dump_uint}, /* TODO: add dumper */ 75 {BE_OFFS(24, 8), "MadBaseVersion", mad_dump_uint}, 76 77 /* second MAD word (4-7 bytes) */ 78 {BE_OFFS(48, 16), "MadStatus", mad_dump_hex}, /* TODO: add dumper */ 79 80 /* DR SMP only */ 81 {BE_OFFS(32, 8), "DrSmpHopCnt", mad_dump_uint}, 82 {BE_OFFS(40, 8), "DrSmpHopPtr", mad_dump_uint}, 83 {BE_OFFS(48, 15), "DrSmpStatus", mad_dump_hex}, /* TODO: add dumper */ 84 {BE_OFFS(63, 1), "DrSmpDirection", mad_dump_uint}, /* TODO: add dumper */ 85 86 /* words 3,4,5,6 (8-23 bytes) */ 87 {64, 64, "MadTRID", mad_dump_hex}, 88 {BE_OFFS(144, 16), "MadAttr", mad_dump_hex}, /* TODO: add dumper */ 89 {160, 32, "MadModifier", mad_dump_hex}, /* TODO: add dumper */ 90 91 /* word 7,8 (24-31 bytes) */ 92 {192, 64, "MadMkey", mad_dump_hex}, 93 94 /* word 9 (32-37 bytes) */ 95 {BE_OFFS(256, 16), "DrSmpDLID", mad_dump_uint}, 96 {BE_OFFS(272, 16), "DrSmpSLID", mad_dump_uint}, 97 98 /* word 10,11 (36-43 bytes) */ 99 {288, 64, "SaSMkey", mad_dump_hex}, 100 101 /* word 12 (44-47 bytes) */ 102 {BE_OFFS(46 * 8, 16), "SaAttrOffs", mad_dump_uint}, 103 104 /* word 13,14 (48-55 bytes) */ 105 {48 * 8, 64, "SaCompMask", mad_dump_hex}, 106 107 /* word 13,14 (56-255 bytes) */ 108 {56 * 8, (256 - 56) * 8, "SaData", mad_dump_hex}, 109 110 /* bytes 64 - 127 */ 111 {0, 0}, /* IB_SM_DATA_F - reserved as invalid */ 112 113 /* bytes 64 - 256 */ 114 {64 * 8, (256 - 64) * 8, "GsData", mad_dump_hex}, 115 116 /* bytes 128 - 191 */ 117 {1024, 512, "DrSmpPath", mad_dump_hex}, 118 119 /* bytes 192 - 255 */ 120 {1536, 512, "DrSmpRetPath", mad_dump_hex}, 121 122 /* 123 * PortInfo fields 124 */ 125 {0, 64, "Mkey", mad_dump_hex}, 126 {64, 64, "GidPrefix", mad_dump_hex}, 127 {BITSOFFS(128, 16), "Lid", mad_dump_uint}, 128 {BITSOFFS(144, 16), "SMLid", mad_dump_uint}, 129 {160, 32, "CapMask", mad_dump_portcapmask}, 130 {BITSOFFS(192, 16), "DiagCode", mad_dump_hex}, 131 {BITSOFFS(208, 16), "MkeyLeasePeriod", mad_dump_uint}, 132 {BITSOFFS(224, 8), "LocalPort", mad_dump_uint}, 133 {BITSOFFS(232, 8), "LinkWidthEnabled", mad_dump_linkwidthen}, 134 {BITSOFFS(240, 8), "LinkWidthSupported", mad_dump_linkwidthsup}, 135 {BITSOFFS(248, 8), "LinkWidthActive", mad_dump_linkwidth}, 136 {BITSOFFS(256, 4), "LinkSpeedSupported", mad_dump_linkspeedsup}, 137 {BITSOFFS(260, 4), "LinkState", mad_dump_portstate}, 138 {BITSOFFS(264, 4), "PhysLinkState", mad_dump_physportstate}, 139 {BITSOFFS(268, 4), "LinkDownDefState", mad_dump_linkdowndefstate}, 140 {BITSOFFS(272, 2), "ProtectBits", mad_dump_uint}, 141 {BITSOFFS(277, 3), "LMC", mad_dump_uint}, 142 {BITSOFFS(280, 4), "LinkSpeedActive", mad_dump_linkspeed}, 143 {BITSOFFS(284, 4), "LinkSpeedEnabled", mad_dump_linkspeeden}, 144 {BITSOFFS(288, 4), "NeighborMTU", mad_dump_mtu}, 145 {BITSOFFS(292, 4), "SMSL", mad_dump_uint}, 146 {BITSOFFS(296, 4), "VLCap", mad_dump_vlcap}, 147 {BITSOFFS(300, 4), "InitType", mad_dump_hex}, 148 {BITSOFFS(304, 8), "VLHighLimit", mad_dump_uint}, 149 {BITSOFFS(312, 8), "VLArbHighCap", mad_dump_uint}, 150 {BITSOFFS(320, 8), "VLArbLowCap", mad_dump_uint}, 151 {BITSOFFS(328, 4), "InitReply", mad_dump_hex}, 152 {BITSOFFS(332, 4), "MtuCap", mad_dump_mtu}, 153 {BITSOFFS(336, 3), "VLStallCount", mad_dump_uint}, 154 {BITSOFFS(339, 5), "HoqLife", mad_dump_uint}, 155 {BITSOFFS(344, 4), "OperVLs", mad_dump_opervls}, 156 {BITSOFFS(348, 1), "PartEnforceInb", mad_dump_uint}, 157 {BITSOFFS(349, 1), "PartEnforceOutb", mad_dump_uint}, 158 {BITSOFFS(350, 1), "FilterRawInb", mad_dump_uint}, 159 {BITSOFFS(351, 1), "FilterRawOutb", mad_dump_uint}, 160 {BITSOFFS(352, 16), "MkeyViolations", mad_dump_uint}, 161 {BITSOFFS(368, 16), "PkeyViolations", mad_dump_uint}, 162 {BITSOFFS(384, 16), "QkeyViolations", mad_dump_uint}, 163 {BITSOFFS(400, 8), "GuidCap", mad_dump_uint}, 164 {BITSOFFS(408, 1), "ClientReregister", mad_dump_uint}, 165 {BITSOFFS(409, 1), "McastPkeyTrapSuppressionEnabled", mad_dump_uint}, 166 {BITSOFFS(411, 5), "SubnetTimeout", mad_dump_uint}, 167 {BITSOFFS(419, 5), "RespTimeVal", mad_dump_uint}, 168 {BITSOFFS(424, 4), "LocalPhysErr", mad_dump_uint}, 169 {BITSOFFS(428, 4), "OverrunErr", mad_dump_uint}, 170 {BITSOFFS(432, 16), "MaxCreditHint", mad_dump_uint}, 171 {BITSOFFS(456, 24), "RoundTrip", mad_dump_uint}, 172 {0, 0}, /* IB_PORT_LAST_F */ 173 174 /* 175 * NodeInfo fields 176 */ 177 {BITSOFFS(0, 8), "BaseVers", mad_dump_uint}, 178 {BITSOFFS(8, 8), "ClassVers", mad_dump_uint}, 179 {BITSOFFS(16, 8), "NodeType", mad_dump_node_type}, 180 {BITSOFFS(24, 8), "NumPorts", mad_dump_uint}, 181 {32, 64, "SystemGuid", mad_dump_hex}, 182 {96, 64, "Guid", mad_dump_hex}, 183 {160, 64, "PortGuid", mad_dump_hex}, 184 {BITSOFFS(224, 16), "PartCap", mad_dump_uint}, 185 {BITSOFFS(240, 16), "DevId", mad_dump_hex}, 186 {256, 32, "Revision", mad_dump_hex}, 187 {BITSOFFS(288, 8), "LocalPort", mad_dump_uint}, 188 {BITSOFFS(296, 24), "VendorId", mad_dump_hex}, 189 {0, 0}, /* IB_NODE_LAST_F */ 190 191 /* 192 * SwitchInfo fields 193 */ 194 {BITSOFFS(0, 16), "LinearFdbCap", mad_dump_uint}, 195 {BITSOFFS(16, 16), "RandomFdbCap", mad_dump_uint}, 196 {BITSOFFS(32, 16), "McastFdbCap", mad_dump_uint}, 197 {BITSOFFS(48, 16), "LinearFdbTop", mad_dump_uint}, 198 {BITSOFFS(64, 8), "DefPort", mad_dump_uint}, 199 {BITSOFFS(72, 8), "DefMcastPrimPort", mad_dump_uint}, 200 {BITSOFFS(80, 8), "DefMcastNotPrimPort", mad_dump_uint}, 201 {BITSOFFS(88, 5), "LifeTime", mad_dump_uint}, 202 {BITSOFFS(93, 1), "StateChange", mad_dump_uint}, 203 {BITSOFFS(94, 2), "OptSLtoVLMapping", mad_dump_uint}, 204 {BITSOFFS(96, 16), "LidsPerPort", mad_dump_uint}, 205 {BITSOFFS(112, 16), "PartEnforceCap", mad_dump_uint}, 206 {BITSOFFS(128, 1), "InboundPartEnf", mad_dump_uint}, 207 {BITSOFFS(129, 1), "OutboundPartEnf", mad_dump_uint}, 208 {BITSOFFS(130, 1), "FilterRawInbound", mad_dump_uint}, 209 {BITSOFFS(131, 1), "FilterRawOutbound", mad_dump_uint}, 210 {BITSOFFS(132, 1), "EnhancedPort0", mad_dump_uint}, 211 {BITSOFFS(144, 16), "MulticastFDBTop", mad_dump_hex}, 212 {0, 0}, /* IB_SW_LAST_F */ 213 214 /* 215 * SwitchLinearForwardingTable fields 216 */ 217 {0, 512, "LinearForwTbl", mad_dump_array}, 218 219 /* 220 * SwitchMulticastForwardingTable fields 221 */ 222 {0, 512, "MulticastForwTbl", mad_dump_array}, 223 224 /* 225 * NodeDescription fields 226 */ 227 {0, 64 * 8, "NodeDesc", mad_dump_string}, 228 229 /* 230 * Notice/Trap fields 231 */ 232 {BITSOFFS(0, 1), "NoticeIsGeneric", mad_dump_uint}, 233 {BITSOFFS(1, 7), "NoticeType", mad_dump_uint}, 234 {BITSOFFS(8, 24), "NoticeProducerType", mad_dump_node_type}, 235 {BITSOFFS(32, 16), "NoticeTrapNumber", mad_dump_uint}, 236 {BITSOFFS(48, 16), "NoticeIssuerLID", mad_dump_uint}, 237 {BITSOFFS(64, 1), "NoticeToggle", mad_dump_uint}, 238 {BITSOFFS(65, 15), "NoticeCount", mad_dump_uint}, 239 {80, 432, "NoticeDataDetails", mad_dump_array}, 240 {BITSOFFS(80, 16), "NoticeDataLID", mad_dump_uint}, 241 {BITSOFFS(96, 16), "NoticeDataTrap144LID", mad_dump_uint}, 242 {BITSOFFS(128, 32), "NoticeDataTrap144CapMask", mad_dump_uint}, 243 244 /* 245 * Port counters 246 */ 247 {BITSOFFS(8, 8), "PortSelect", mad_dump_uint}, 248 {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex}, 249 {BITSOFFS(32, 16), "SymbolErrorCounter", mad_dump_uint}, 250 {BITSOFFS(48, 8), "LinkErrorRecoveryCounter", mad_dump_uint}, 251 {BITSOFFS(56, 8), "LinkDownedCounter", mad_dump_uint}, 252 {BITSOFFS(64, 16), "PortRcvErrors", mad_dump_uint}, 253 {BITSOFFS(80, 16), "PortRcvRemotePhysicalErrors", mad_dump_uint}, 254 {BITSOFFS(96, 16), "PortRcvSwitchRelayErrors", mad_dump_uint}, 255 {BITSOFFS(112, 16), "PortXmitDiscards", mad_dump_uint}, 256 {BITSOFFS(128, 8), "PortXmitConstraintErrors", mad_dump_uint}, 257 {BITSOFFS(136, 8), "PortRcvConstraintErrors", mad_dump_uint}, 258 {BITSOFFS(144, 8), "CounterSelect2", mad_dump_hex}, 259 {BITSOFFS(152, 4), "LocalLinkIntegrityErrors", mad_dump_uint}, 260 {BITSOFFS(156, 4), "ExcessiveBufferOverrunErrors", mad_dump_uint}, 261 {BITSOFFS(176, 16), "VL15Dropped", mad_dump_uint}, 262 {192, 32, "PortXmitData", mad_dump_uint}, 263 {224, 32, "PortRcvData", mad_dump_uint}, 264 {256, 32, "PortXmitPkts", mad_dump_uint}, 265 {288, 32, "PortRcvPkts", mad_dump_uint}, 266 {320, 32, "PortXmitWait", mad_dump_uint}, 267 {0, 0}, /* IB_PC_LAST_F */ 268 269 /* 270 * SMInfo 271 */ 272 {0, 64, "SmInfoGuid", mad_dump_hex}, 273 {64, 64, "SmInfoKey", mad_dump_hex}, 274 {128, 32, "SmActivity", mad_dump_uint}, 275 {BITSOFFS(160, 4), "SmPriority", mad_dump_uint}, 276 {BITSOFFS(164, 4), "SmState", mad_dump_uint}, 277 278 /* 279 * SA RMPP 280 */ 281 {BE_OFFS(24 * 8 + 24, 8), "RmppVers", mad_dump_uint}, 282 {BE_OFFS(24 * 8 + 16, 8), "RmppType", mad_dump_uint}, 283 {BE_OFFS(24 * 8 + 11, 5), "RmppResp", mad_dump_uint}, 284 {BE_OFFS(24 * 8 + 8, 3), "RmppFlags", mad_dump_hex}, 285 {BE_OFFS(24 * 8 + 0, 8), "RmppStatus", mad_dump_hex}, 286 287 /* data1 */ 288 {28 * 8, 32, "RmppData1", mad_dump_hex}, 289 {28 * 8, 32, "RmppSegNum", mad_dump_uint}, 290 /* data2 */ 291 {32 * 8, 32, "RmppData2", mad_dump_hex}, 292 {32 * 8, 32, "RmppPayload", mad_dump_uint}, 293 {32 * 8, 32, "RmppNewWin", mad_dump_uint}, 294 295 /* 296 * SA Get Multi Path 297 */ 298 {BITSOFFS(41, 7), "MultiPathNumPath", mad_dump_uint}, 299 {BITSOFFS(120, 8), "MultiPathNumSrc", mad_dump_uint}, 300 {BITSOFFS(128, 8), "MultiPathNumDest", mad_dump_uint}, 301 {192, 128, "MultiPathGid", mad_dump_array}, 302 303 /* 304 * SA Path rec 305 */ 306 {64, 128, "PathRecDGid", mad_dump_array}, 307 {192, 128, "PathRecSGid", mad_dump_array}, 308 {BITSOFFS(320, 16), "PathRecDLid", mad_dump_uint}, 309 {BITSOFFS(336, 16), "PathRecSLid", mad_dump_uint}, 310 {BITSOFFS(393, 7), "PathRecNumPath", mad_dump_uint}, 311 {BITSOFFS(428, 4), "PathRecSL", mad_dump_uint}, 312 313 /* 314 * MC Member rec 315 */ 316 {0, 128, "McastMemMGid", mad_dump_array}, 317 {128, 128, "McastMemPortGid", mad_dump_array}, 318 {256, 32, "McastMemQkey", mad_dump_hex}, 319 {BITSOFFS(288, 16), "McastMemMLid", mad_dump_hex}, 320 {BITSOFFS(352, 4), "McastMemSL", mad_dump_uint}, 321 {BITSOFFS(306, 6), "McastMemMTU", mad_dump_uint}, 322 {BITSOFFS(338, 6), "McastMemRate", mad_dump_uint}, 323 {BITSOFFS(312, 8), "McastMemTClass", mad_dump_uint}, 324 {BITSOFFS(320, 16), "McastMemPkey", mad_dump_uint}, 325 {BITSOFFS(356, 20), "McastMemFlowLbl", mad_dump_uint}, 326 {BITSOFFS(388, 4), "McastMemJoinState", mad_dump_uint}, 327 {BITSOFFS(392, 1), "McastMemProxyJoin", mad_dump_uint}, 328 329 /* 330 * Service record 331 */ 332 {0, 64, "ServRecID", mad_dump_hex}, 333 {64, 128, "ServRecGid", mad_dump_array}, 334 {BITSOFFS(192, 16), "ServRecPkey", mad_dump_hex}, 335 {224, 32, "ServRecLease", mad_dump_hex}, 336 {256, 128, "ServRecKey", mad_dump_hex}, 337 {384, 512, "ServRecName", mad_dump_string}, 338 {896, 512, "ServRecData", mad_dump_array}, /* ATS for example */ 339 340 /* 341 * ATS SM record - within SA_SR_DATA 342 */ 343 {12 * 8, 32, "ATSNodeAddr", mad_dump_hex}, 344 {BITSOFFS(16 * 8, 16), "ATSMagicKey", mad_dump_hex}, 345 {BITSOFFS(18 * 8, 16), "ATSNodeType", mad_dump_hex}, 346 {32 * 8, 32 * 8, "ATSNodeName", mad_dump_string}, 347 348 /* 349 * SLTOVL MAPPING TABLE 350 */ 351 {0, 64, "SLToVLMap", mad_dump_hex}, 352 353 /* 354 * VL ARBITRATION TABLE 355 */ 356 {0, 512, "VLArbTbl", mad_dump_array}, 357 358 /* 359 * IB vendor classes range 2 360 */ 361 {BE_OFFS(36 * 8, 24), "OUI", mad_dump_array}, 362 {40 * 8, (256 - 40) * 8, "Vendor2Data", mad_dump_array}, 363 364 /* 365 * Extended port counters 366 */ 367 {BITSOFFS(8, 8), "PortSelect", mad_dump_uint}, 368 {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex}, 369 {64, 64, "PortXmitData", mad_dump_uint}, 370 {128, 64, "PortRcvData", mad_dump_uint}, 371 {192, 64, "PortXmitPkts", mad_dump_uint}, 372 {256, 64, "PortRcvPkts", mad_dump_uint}, 373 {320, 64, "PortUnicastXmitPkts", mad_dump_uint}, 374 {384, 64, "PortUnicastRcvPkts", mad_dump_uint}, 375 {448, 64, "PortMulticastXmitPkts", mad_dump_uint}, 376 {512, 64, "PortMulticastRcvPkts", mad_dump_uint}, 377 {0, 0}, /* IB_PC_EXT_LAST_F */ 378 379 /* 380 * GUIDInfo fields 381 */ 382 {0, 64, "GUID0", mad_dump_hex}, 383 384 /* 385 * ClassPortInfo fields 386 */ 387 {BITSOFFS(0, 8), "BaseVersion", mad_dump_uint}, 388 {BITSOFFS(8, 8), "ClassVersion", mad_dump_uint}, 389 {BITSOFFS(16, 16), "CapabilityMask", mad_dump_hex}, 390 {BITSOFFS(32, 27), "CapabilityMask2", mad_dump_hex}, 391 {BITSOFFS(59, 5), "RespTimeVal", mad_dump_uint}, 392 {64, 128, "RedirectGID", mad_dump_array}, 393 {BITSOFFS(192, 8), "RedirectTC", mad_dump_hex}, 394 {BITSOFFS(200, 4), "RedirectSL", mad_dump_uint}, 395 {BITSOFFS(204, 20), "RedirectFL", mad_dump_hex}, 396 {BITSOFFS(224, 16), "RedirectLID", mad_dump_uint}, 397 {BITSOFFS(240, 16), "RedirectPKey", mad_dump_hex}, 398 {BITSOFFS(264, 24), "RedirectQP", mad_dump_hex}, 399 {288, 32, "RedirectQKey", mad_dump_hex}, 400 {320, 128, "TrapGID", mad_dump_array}, 401 {BITSOFFS(448, 8), "TrapTC", mad_dump_hex}, 402 {BITSOFFS(456, 4), "TrapSL", mad_dump_uint}, 403 {BITSOFFS(460, 20), "TrapFL", mad_dump_hex}, 404 {BITSOFFS(480, 16), "TrapLID", mad_dump_uint}, 405 {BITSOFFS(496, 16), "TrapPKey", mad_dump_hex}, 406 {BITSOFFS(512, 8), "TrapHL", mad_dump_uint}, 407 {BITSOFFS(520, 24), "TrapQP", mad_dump_hex}, 408 {544, 32, "TrapQKey", mad_dump_hex}, 409 410 /* 411 * PortXmitDataSL fields 412 */ 413 {32, 32, "XmtDataSL0", mad_dump_uint}, 414 {64, 32, "XmtDataSL1", mad_dump_uint}, 415 {96, 32, "XmtDataSL2", mad_dump_uint}, 416 {128, 32, "XmtDataSL3", mad_dump_uint}, 417 {160, 32, "XmtDataSL4", mad_dump_uint}, 418 {192, 32, "XmtDataSL5", mad_dump_uint}, 419 {224, 32, "XmtDataSL6", mad_dump_uint}, 420 {256, 32, "XmtDataSL7", mad_dump_uint}, 421 {288, 32, "XmtDataSL8", mad_dump_uint}, 422 {320, 32, "XmtDataSL9", mad_dump_uint}, 423 {352, 32, "XmtDataSL10", mad_dump_uint}, 424 {384, 32, "XmtDataSL11", mad_dump_uint}, 425 {416, 32, "XmtDataSL12", mad_dump_uint}, 426 {448, 32, "XmtDataSL13", mad_dump_uint}, 427 {480, 32, "XmtDataSL14", mad_dump_uint}, 428 {512, 32, "XmtDataSL15", mad_dump_uint}, 429 {0, 0}, /* IB_PC_XMT_DATA_SL_LAST_F */ 430 431 /* 432 * PortRcvDataSL fields 433 */ 434 {32, 32, "RcvDataSL0", mad_dump_uint}, 435 {64, 32, "RcvDataSL1", mad_dump_uint}, 436 {96, 32, "RcvDataSL2", mad_dump_uint}, 437 {128, 32, "RcvDataSL3", mad_dump_uint}, 438 {160, 32, "RcvDataSL4", mad_dump_uint}, 439 {192, 32, "RcvDataSL5", mad_dump_uint}, 440 {224, 32, "RcvDataSL6", mad_dump_uint}, 441 {256, 32, "RcvDataSL7", mad_dump_uint}, 442 {288, 32, "RcvDataSL8", mad_dump_uint}, 443 {320, 32, "RcvDataSL9", mad_dump_uint}, 444 {352, 32, "RcvDataSL10", mad_dump_uint}, 445 {384, 32, "RcvDataSL11", mad_dump_uint}, 446 {416, 32, "RcvDataSL12", mad_dump_uint}, 447 {448, 32, "RcvDataSL13", mad_dump_uint}, 448 {480, 32, "RcvDataSL14", mad_dump_uint}, 449 {512, 32, "RcvDataSL15", mad_dump_uint}, 450 {0, 0}, /* IB_PC_RCV_DATA_SL_LAST_F */ 451 452 /* 453 * PortXmitDiscardDetails fields 454 */ 455 {BITSOFFS(32, 16), "PortInactiveDiscards", mad_dump_uint}, 456 {BITSOFFS(48, 16), "PortNeighborMTUDiscards", mad_dump_uint}, 457 {BITSOFFS(64, 16), "PortSwLifetimeLimitDiscards", mad_dump_uint}, 458 {BITSOFFS(80, 16), "PortSwHOQLifetimeLimitDiscards", mad_dump_uint}, 459 {0, 0}, /* IB_PC_XMT_DISC_LAST_F */ 460 461 /* 462 * PortRcvErrorDetails fields 463 */ 464 {BITSOFFS(32, 16), "PortLocalPhysicalErrors", mad_dump_uint}, 465 {BITSOFFS(48, 16), "PortMalformedPktErrors", mad_dump_uint}, 466 {BITSOFFS(64, 16), "PortBufferOverrunErrors", mad_dump_uint}, 467 {BITSOFFS(80, 16), "PortDLIDMappingErrors", mad_dump_uint}, 468 {BITSOFFS(96, 16), "PortVLMappingErrors", mad_dump_uint}, 469 {BITSOFFS(112, 16), "PortLoopingErrors", mad_dump_uint}, 470 {0, 0}, /* IB_PC_RCV_ERR_LAST_F */ 471 472 /* 473 * PortSamplesControl fields 474 */ 475 {BITSOFFS(0, 8), "OpCode", mad_dump_hex}, 476 {BITSOFFS(8, 8), "PortSelect", mad_dump_uint}, 477 {BITSOFFS(16, 8), "Tick", mad_dump_hex}, 478 {BITSOFFS(29, 3), "CounterWidth", mad_dump_uint}, 479 {BITSOFFS(34, 3), "CounterMask0", mad_dump_hex}, 480 {BITSOFFS(37, 27), "CounterMasks1to9", mad_dump_hex}, 481 {BITSOFFS(65, 15), "CounterMasks10to14", mad_dump_hex}, 482 {BITSOFFS(80, 8), "SampleMechanisms", mad_dump_uint}, 483 {BITSOFFS(94, 2), "SampleStatus", mad_dump_uint}, 484 {96, 64, "OptionMask", mad_dump_hex}, 485 {160, 64, "VendorMask", mad_dump_hex}, 486 {224, 32, "SampleStart", mad_dump_uint}, 487 {256, 32, "SampleInterval", mad_dump_uint}, 488 {BITSOFFS(288, 16), "Tag", mad_dump_hex}, 489 {BITSOFFS(304, 16), "CounterSelect0", mad_dump_hex}, 490 {BITSOFFS(320, 16), "CounterSelect1", mad_dump_hex}, 491 {BITSOFFS(336, 16), "CounterSelect2", mad_dump_hex}, 492 {BITSOFFS(352, 16), "CounterSelect3", mad_dump_hex}, 493 {BITSOFFS(368, 16), "CounterSelect4", mad_dump_hex}, 494 {BITSOFFS(384, 16), "CounterSelect5", mad_dump_hex}, 495 {BITSOFFS(400, 16), "CounterSelect6", mad_dump_hex}, 496 {BITSOFFS(416, 16), "CounterSelect7", mad_dump_hex}, 497 {BITSOFFS(432, 16), "CounterSelect8", mad_dump_hex}, 498 {BITSOFFS(448, 16), "CounterSelect9", mad_dump_hex}, 499 {BITSOFFS(464, 16), "CounterSelect10", mad_dump_hex}, 500 {BITSOFFS(480, 16), "CounterSelect11", mad_dump_hex}, 501 {BITSOFFS(496, 16), "CounterSelect12", mad_dump_hex}, 502 {BITSOFFS(512, 16), "CounterSelect13", mad_dump_hex}, 503 {BITSOFFS(528, 16), "CounterSelect14", mad_dump_hex}, 504 {576, 64, "SamplesOnlyOptionMask", mad_dump_hex}, 505 {0, 0}, /* IB_PSC_LAST_F */ 506 507 /* GUIDInfo fields */ 508 {0, 64, "GUID0", mad_dump_hex}, 509 {64, 64, "GUID1", mad_dump_hex}, 510 {128, 64, "GUID2", mad_dump_hex}, 511 {192, 64, "GUID3", mad_dump_hex}, 512 {256, 64, "GUID4", mad_dump_hex}, 513 {320, 64, "GUID5", mad_dump_hex}, 514 {384, 64, "GUID6", mad_dump_hex}, 515 {448, 64, "GUID7", mad_dump_hex}, 516 517 /* GUID Info Record */ 518 {BITSOFFS(0, 16), "Lid", mad_dump_uint}, 519 {BITSOFFS(16, 8), "BlockNum", mad_dump_uint}, 520 {64, 64, "Guid0", mad_dump_hex}, 521 {128, 64, "Guid1", mad_dump_hex}, 522 {192, 64, "Guid2", mad_dump_hex}, 523 {256, 64, "Guid3", mad_dump_hex}, 524 {320, 64, "Guid4", mad_dump_hex}, 525 {384, 64, "Guid5", mad_dump_hex}, 526 {448, 64, "Guid6", mad_dump_hex}, 527 {512, 64, "Guid7", mad_dump_hex}, 528 529 /* 530 * More PortInfo fields 531 */ 532 {BITSOFFS(480, 16), "CapabilityMask2", mad_dump_portcapmask2}, 533 {BITSOFFS(496, 4), "LinkSpeedExtActive", mad_dump_linkspeedext}, 534 {BITSOFFS(500, 4), "LinkSpeedExtSupported", mad_dump_linkspeedextsup}, 535 {BITSOFFS(507, 5), "LinkSpeedExtEnabled", mad_dump_linkspeedexten}, 536 {0, 0}, /* IB_PORT_LINK_SPEED_EXT_LAST_F */ 537 538 /* 539 * PortExtendedSpeedsCounters fields 540 */ 541 {BITSOFFS(8, 8), "PortSelect", mad_dump_uint}, 542 {64, 64, "CounterSelect", mad_dump_hex}, 543 {BITSOFFS(128, 16), "SyncHeaderErrorCounter", mad_dump_uint}, 544 {BITSOFFS(144, 16), "UnknownBlockCounter", mad_dump_uint}, 545 {BITSOFFS(160, 16), "ErrorDetectionCounterLane0", mad_dump_uint}, 546 {BITSOFFS(176, 16), "ErrorDetectionCounterLane1", mad_dump_uint}, 547 {BITSOFFS(192, 16), "ErrorDetectionCounterLane2", mad_dump_uint}, 548 {BITSOFFS(208, 16), "ErrorDetectionCounterLane3", mad_dump_uint}, 549 {BITSOFFS(224, 16), "ErrorDetectionCounterLane4", mad_dump_uint}, 550 {BITSOFFS(240, 16), "ErrorDetectionCounterLane5", mad_dump_uint}, 551 {BITSOFFS(256, 16), "ErrorDetectionCounterLane6", mad_dump_uint}, 552 {BITSOFFS(272, 16), "ErrorDetectionCounterLane7", mad_dump_uint}, 553 {BITSOFFS(288, 16), "ErrorDetectionCounterLane8", mad_dump_uint}, 554 {BITSOFFS(304, 16), "ErrorDetectionCounterLane9", mad_dump_uint}, 555 {BITSOFFS(320, 16), "ErrorDetectionCounterLane10", mad_dump_uint}, 556 {BITSOFFS(336, 16), "ErrorDetectionCounterLane11", mad_dump_uint}, 557 {352, 32, "FECCorrectableBlockCtrLane0", mad_dump_uint}, 558 {384, 32, "FECCorrectableBlockCtrLane1", mad_dump_uint}, 559 {416, 32, "FECCorrectableBlockCtrLane2", mad_dump_uint}, 560 {448, 32, "FECCorrectableBlockCtrLane3", mad_dump_uint}, 561 {480, 32, "FECCorrectableBlockCtrLane4", mad_dump_uint}, 562 {512, 32, "FECCorrectableBlockCtrLane5", mad_dump_uint}, 563 {544, 32, "FECCorrectableBlockCtrLane6", mad_dump_uint}, 564 {576, 32, "FECCorrectableBlockCtrLane7", mad_dump_uint}, 565 {608, 32, "FECCorrectableBlockCtrLane8", mad_dump_uint}, 566 {640, 32, "FECCorrectableBlockCtrLane9", mad_dump_uint}, 567 {672, 32, "FECCorrectableBlockCtrLane10", mad_dump_uint}, 568 {704, 32, "FECCorrectableBlockCtrLane11", mad_dump_uint}, 569 {736, 32, "FECUncorrectableBlockCtrLane0", mad_dump_uint}, 570 {768, 32, "FECUncorrectableBlockCtrLane1", mad_dump_uint}, 571 {800, 32, "FECUncorrectableBlockCtrLane2", mad_dump_uint}, 572 {832, 32, "FECUncorrectableBlockCtrLane3", mad_dump_uint}, 573 {864, 32, "FECUncorrectableBlockCtrLane4", mad_dump_uint}, 574 {896, 32, "FECUncorrectableBlockCtrLane5", mad_dump_uint}, 575 {928, 32, "FECUncorrectableBlockCtrLane6", mad_dump_uint}, 576 {960, 32, "FECUncorrectableBlockCtrLane7", mad_dump_uint}, 577 {992, 32, "FECUncorrectableBlockCtrLane8", mad_dump_uint}, 578 {1024, 32, "FECUncorrectableBlockCtrLane9", mad_dump_uint}, 579 {1056, 32, "FECUncorrectableBlockCtrLane10", mad_dump_uint}, 580 {1088, 32, "FECUncorrectableBlockCtrLane11", mad_dump_uint}, 581 {0, 0}, /* IB_PESC_LAST_F */ 582 583 584 585 /* 586 * PortOpRcvCounters fields 587 */ 588 {32, 32, "PortOpRcvPkts", mad_dump_uint}, 589 {64, 32, "PortOpRcvData", mad_dump_uint}, 590 {0, 0}, /* IB_PC_PORT_OP_RCV_COUNTERS_LAST_F */ 591 592 /* 593 * PortFlowCtlCounters fields 594 */ 595 {32, 32, "PortXmitFlowPkts", mad_dump_uint}, 596 {64, 32, "PortRcvFlowPkts", mad_dump_uint}, 597 {0, 0}, /* IB_PC_PORT_FLOW_CTL_COUNTERS_LAST_F */ 598 599 /* 600 * PortVLOpPackets fields 601 */ 602 {BITSOFFS(32, 16), "PortVLOpPackets0", mad_dump_uint}, 603 {BITSOFFS(48, 16), "PortVLOpPackets1", mad_dump_uint}, 604 {BITSOFFS(64, 16), "PortVLOpPackets2", mad_dump_uint}, 605 {BITSOFFS(80, 16), "PortVLOpPackets3", mad_dump_uint}, 606 {BITSOFFS(96, 16), "PortVLOpPackets4", mad_dump_uint}, 607 {BITSOFFS(112, 16), "PortVLOpPackets5", mad_dump_uint}, 608 {BITSOFFS(128, 16), "PortVLOpPackets6", mad_dump_uint}, 609 {BITSOFFS(144, 16), "PortVLOpPackets7", mad_dump_uint}, 610 {BITSOFFS(160, 16), "PortVLOpPackets8", mad_dump_uint}, 611 {BITSOFFS(176, 16), "PortVLOpPackets9", mad_dump_uint}, 612 {BITSOFFS(192, 16), "PortVLOpPackets10", mad_dump_uint}, 613 {BITSOFFS(208, 16), "PortVLOpPackets11", mad_dump_uint}, 614 {BITSOFFS(224, 16), "PortVLOpPackets12", mad_dump_uint}, 615 {BITSOFFS(240, 16), "PortVLOpPackets13", mad_dump_uint}, 616 {BITSOFFS(256, 16), "PortVLOpPackets14", mad_dump_uint}, 617 {BITSOFFS(272, 16), "PortVLOpPackets15", mad_dump_uint}, 618 {0, 0}, /* IB_PC_PORT_VL_OP_PACKETS_LAST_F */ 619 620 /* 621 * PortVLOpData fields 622 */ 623 {32, 32, "PortVLOpData0", mad_dump_uint}, 624 {64, 32, "PortVLOpData1", mad_dump_uint}, 625 {96, 32, "PortVLOpData2", mad_dump_uint}, 626 {128, 32, "PortVLOpData3", mad_dump_uint}, 627 {160, 32, "PortVLOpData4", mad_dump_uint}, 628 {192, 32, "PortVLOpData5", mad_dump_uint}, 629 {224, 32, "PortVLOpData6", mad_dump_uint}, 630 {256, 32, "PortVLOpData7", mad_dump_uint}, 631 {288, 32, "PortVLOpData8", mad_dump_uint}, 632 {320, 32, "PortVLOpData9", mad_dump_uint}, 633 {352, 32, "PortVLOpData10", mad_dump_uint}, 634 {384, 32, "PortVLOpData11", mad_dump_uint}, 635 {416, 32, "PortVLOpData12", mad_dump_uint}, 636 {448, 32, "PortVLOpData13", mad_dump_uint}, 637 {480, 32, "PortVLOpData14", mad_dump_uint}, 638 {512, 32, "PortVLOpData15", mad_dump_uint}, 639 {0, 0}, /* IB_PC_PORT_VL_OP_DATA_LAST_F */ 640 641 /* 642 * PortVLXmitFlowCtlUpdateErrors fields 643 */ 644 {BITSOFFS(32, 2), "PortVLXmitFlowCtlUpdateErrors0", mad_dump_uint}, 645 {BITSOFFS(34, 2), "PortVLXmitFlowCtlUpdateErrors1", mad_dump_uint}, 646 {BITSOFFS(36, 2), "PortVLXmitFlowCtlUpdateErrors2", mad_dump_uint}, 647 {BITSOFFS(38, 2), "PortVLXmitFlowCtlUpdateErrors3", mad_dump_uint}, 648 {BITSOFFS(40, 2), "PortVLXmitFlowCtlUpdateErrors4", mad_dump_uint}, 649 {BITSOFFS(42, 2), "PortVLXmitFlowCtlUpdateErrors5", mad_dump_uint}, 650 {BITSOFFS(44, 2), "PortVLXmitFlowCtlUpdateErrors6", mad_dump_uint}, 651 {BITSOFFS(46, 2), "PortVLXmitFlowCtlUpdateErrors7", mad_dump_uint}, 652 {BITSOFFS(48, 2), "PortVLXmitFlowCtlUpdateErrors8", mad_dump_uint}, 653 {BITSOFFS(50, 2), "PortVLXmitFlowCtlUpdateErrors9", mad_dump_uint}, 654 {BITSOFFS(52, 2), "PortVLXmitFlowCtlUpdateErrors10", mad_dump_uint}, 655 {BITSOFFS(54, 2), "PortVLXmitFlowCtlUpdateErrors11", mad_dump_uint}, 656 {BITSOFFS(56, 2), "PortVLXmitFlowCtlUpdateErrors12", mad_dump_uint}, 657 {BITSOFFS(58, 2), "PortVLXmitFlowCtlUpdateErrors13", mad_dump_uint}, 658 {BITSOFFS(60, 2), "PortVLXmitFlowCtlUpdateErrors14", mad_dump_uint}, 659 {BITSOFFS(62, 2), "PortVLXmitFlowCtlUpdateErrors15", mad_dump_uint}, 660 {0, 0}, /* IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_LAST_F */ 661 662 /* 663 * PortVLXmitWaitCounters fields 664 */ 665 {BITSOFFS(32, 16), "PortVLXmitWait0", mad_dump_uint}, 666 {BITSOFFS(48, 16), "PortVLXmitWait1", mad_dump_uint}, 667 {BITSOFFS(64, 16), "PortVLXmitWait2", mad_dump_uint}, 668 {BITSOFFS(80, 16), "PortVLXmitWait3", mad_dump_uint}, 669 {BITSOFFS(96, 16), "PortVLXmitWait4", mad_dump_uint}, 670 {BITSOFFS(112, 16), "PortVLXmitWait5", mad_dump_uint}, 671 {BITSOFFS(128, 16), "PortVLXmitWait6", mad_dump_uint}, 672 {BITSOFFS(144, 16), "PortVLXmitWait7", mad_dump_uint}, 673 {BITSOFFS(160, 16), "PortVLXmitWait8", mad_dump_uint}, 674 {BITSOFFS(176, 16), "PortVLXmitWait9", mad_dump_uint}, 675 {BITSOFFS(192, 16), "PortVLXmitWait10", mad_dump_uint}, 676 {BITSOFFS(208, 16), "PortVLXmitWait11", mad_dump_uint}, 677 {BITSOFFS(224, 16), "PortVLXmitWait12", mad_dump_uint}, 678 {BITSOFFS(240, 16), "PortVLXmitWait13", mad_dump_uint}, 679 {BITSOFFS(256, 16), "PortVLXmitWait14", mad_dump_uint}, 680 {BITSOFFS(272, 16), "PortVLXmitWait15", mad_dump_uint}, 681 {0, 0}, /* IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_LAST_F */ 682 683 /* 684 * SwPortVLCongestion fields 685 */ 686 {BITSOFFS(32, 16), "SWPortVLCongestion0", mad_dump_uint}, 687 {BITSOFFS(48, 16), "SWPortVLCongestion1", mad_dump_uint}, 688 {BITSOFFS(64, 16), "SWPortVLCongestion2", mad_dump_uint}, 689 {BITSOFFS(80, 16), "SWPortVLCongestion3", mad_dump_uint}, 690 {BITSOFFS(96, 16), "SWPortVLCongestion4", mad_dump_uint}, 691 {BITSOFFS(112, 16), "SWPortVLCongestion5", mad_dump_uint}, 692 {BITSOFFS(128, 16), "SWPortVLCongestion6", mad_dump_uint}, 693 {BITSOFFS(144, 16), "SWPortVLCongestion7", mad_dump_uint}, 694 {BITSOFFS(160, 16), "SWPortVLCongestion8", mad_dump_uint}, 695 {BITSOFFS(176, 16), "SWPortVLCongestion9", mad_dump_uint}, 696 {BITSOFFS(192, 16), "SWPortVLCongestion10", mad_dump_uint}, 697 {BITSOFFS(208, 16), "SWPortVLCongestion11", mad_dump_uint}, 698 {BITSOFFS(224, 16), "SWPortVLCongestion12", mad_dump_uint}, 699 {BITSOFFS(240, 16), "SWPortVLCongestion13", mad_dump_uint}, 700 {BITSOFFS(256, 16), "SWPortVLCongestion14", mad_dump_uint}, 701 {BITSOFFS(272, 16), "SWPortVLCongestion15", mad_dump_uint}, 702 {0, 0}, /* IB_PC_SW_PORT_VL_CONGESTION_LAST_F */ 703 704 /* 705 * PortRcvConCtrl fields 706 */ 707 {32, 32, "PortPktRcvFECN", mad_dump_uint}, 708 {64, 32, "PortPktRcvBECN", mad_dump_uint}, 709 {0, 0}, /* IB_PC_RCV_CON_CTRL_LAST_F */ 710 711 /* 712 * PortSLRcvFECN fields 713 */ 714 {32, 32, "PortSLRcvFECN0", mad_dump_uint}, 715 {64, 32, "PortSLRcvFECN1", mad_dump_uint}, 716 {96, 32, "PortSLRcvFECN2", mad_dump_uint}, 717 {128, 32, "PortSLRcvFECN3", mad_dump_uint}, 718 {160, 32, "PortSLRcvFECN4", mad_dump_uint}, 719 {192, 32, "PortSLRcvFECN5", mad_dump_uint}, 720 {224, 32, "PortSLRcvFECN6", mad_dump_uint}, 721 {256, 32, "PortSLRcvFECN7", mad_dump_uint}, 722 {288, 32, "PortSLRcvFECN8", mad_dump_uint}, 723 {320, 32, "PortSLRcvFECN9", mad_dump_uint}, 724 {352, 32, "PortSLRcvFECN10", mad_dump_uint}, 725 {384, 32, "PortSLRcvFECN11", mad_dump_uint}, 726 {416, 32, "PortSLRcvFECN12", mad_dump_uint}, 727 {448, 32, "PortSLRcvFECN13", mad_dump_uint}, 728 {480, 32, "PortSLRcvFECN14", mad_dump_uint}, 729 {512, 32, "PortSLRcvFECN15", mad_dump_uint}, 730 {0, 0}, /* IB_PC_SL_RCV_FECN_LAST_F */ 731 732 /* 733 * PortSLRcvBECN fields 734 */ 735 {32, 32, "PortSLRcvBECN0", mad_dump_uint}, 736 {64, 32, "PortSLRcvBECN1", mad_dump_uint}, 737 {96, 32, "PortSLRcvBECN2", mad_dump_uint}, 738 {128, 32, "PortSLRcvBECN3", mad_dump_uint}, 739 {160, 32, "PortSLRcvBECN4", mad_dump_uint}, 740 {192, 32, "PortSLRcvBECN5", mad_dump_uint}, 741 {224, 32, "PortSLRcvBECN6", mad_dump_uint}, 742 {256, 32, "PortSLRcvBECN7", mad_dump_uint}, 743 {288, 32, "PortSLRcvBECN8", mad_dump_uint}, 744 {320, 32, "PortSLRcvBECN9", mad_dump_uint}, 745 {352, 32, "PortSLRcvBECN10", mad_dump_uint}, 746 {384, 32, "PortSLRcvBECN11", mad_dump_uint}, 747 {416, 32, "PortSLRcvBECN12", mad_dump_uint}, 748 {448, 32, "PortSLRcvBECN13", mad_dump_uint}, 749 {480, 32, "PortSLRcvBECN14", mad_dump_uint}, 750 {512, 32, "PortSLRcvBECN15", mad_dump_uint}, 751 {0, 0}, /* IB_PC_SL_RCV_BECN_LAST_F */ 752 753 /* 754 * PortXmitConCtrl fields 755 */ 756 {32, 32, "PortXmitTimeCong", mad_dump_uint}, 757 {0, 0}, /* IB_PC_XMIT_CON_CTRL_LAST_F */ 758 759 /* 760 * PortVLXmitTimeCong fields 761 */ 762 {32, 32, "PortVLXmitTimeCong0", mad_dump_uint}, 763 {64, 32, "PortVLXmitTimeCong1", mad_dump_uint}, 764 {96, 32, "PortVLXmitTimeCong2", mad_dump_uint}, 765 {128, 32, "PortVLXmitTimeCong3", mad_dump_uint}, 766 {160, 32, "PortVLXmitTimeCong4", mad_dump_uint}, 767 {192, 32, "PortVLXmitTimeCong5", mad_dump_uint}, 768 {224, 32, "PortVLXmitTimeCong6", mad_dump_uint}, 769 {256, 32, "PortVLXmitTimeCong7", mad_dump_uint}, 770 {288, 32, "PortVLXmitTimeCong8", mad_dump_uint}, 771 {320, 32, "PortVLXmitTimeCong9", mad_dump_uint}, 772 {352, 32, "PortVLXmitTimeCong10", mad_dump_uint}, 773 {384, 32, "PortVLXmitTimeCong11", mad_dump_uint}, 774 {416, 32, "PortVLXmitTimeCong12", mad_dump_uint}, 775 {448, 32, "PortVLXmitTimeCong13", mad_dump_uint}, 776 {480, 32, "PortVLXmitTimeCong14", mad_dump_uint}, 777 {0, 0}, /* IB_PC_VL_XMIT_TIME_CONG_LAST_F */ 778 779 /* 780 * Mellanox ExtendedPortInfo fields 781 */ 782 {BITSOFFS(24, 8), "StateChangeEnable", mad_dump_hex}, 783 {BITSOFFS(56, 8), "LinkSpeedSupported", mad_dump_hex}, 784 {BITSOFFS(88, 8), "LinkSpeedEnabled", mad_dump_hex}, 785 {BITSOFFS(120, 8), "LinkSpeedActive", mad_dump_hex}, 786 {0, 0}, /* IB_MLNX_EXT_PORT_LAST_F */ 787 788 /* 789 * Congestion Control Mad fields 790 * bytes 24-31 of congestion control mad 791 */ 792 {192, 64, "CC_Key", mad_dump_hex}, /* IB_CC_CCKEY_F */ 793 794 /* 795 * CongestionInfo fields 796 */ 797 {BITSOFFS(0, 16), "CongestionInfo", mad_dump_hex}, 798 {BITSOFFS(16, 8), "ControlTableCap", mad_dump_uint}, 799 {0, 0}, /* IB_CC_CONGESTION_INFO_LAST_F */ 800 801 /* 802 * CongestionKeyInfo fields 803 */ 804 {0, 64, "CC_Key", mad_dump_hex}, 805 {BITSOFFS(64, 1), "CC_KeyProtectBit", mad_dump_uint}, 806 {BITSOFFS(80, 16), "CC_KeyLeasePeriod", mad_dump_uint}, 807 {BITSOFFS(96, 16), "CC_KeyViolations", mad_dump_uint}, 808 {0, 0}, /* IB_CC_CONGESTION_KEY_INFO_LAST_F */ 809 810 /* 811 * CongestionLog (common) fields 812 */ 813 {BITSOFFS(0, 8), "LogType", mad_dump_uint}, 814 {BITSOFFS(8, 8), "CongestionFlags", mad_dump_hex}, 815 {0, 0}, /* IB_CC_CONGESTION_LOG_LAST_F */ 816 817 /* 818 * CongestionLog (Switch) fields 819 */ 820 {BITSOFFS(16, 16), "LogEventsCounter", mad_dump_uint}, 821 {32, 32, "CurrentTimeStamp", mad_dump_uint}, 822 {64, 256, "PortMap", mad_dump_array}, 823 {0, 0}, /* IB_CC_CONGESTION_LOG_SWITCH_LAST_F */ 824 825 /* 826 * CongestionLogEvent (Switch) fields 827 */ 828 {BITSOFFS(0, 16), "SLID", mad_dump_uint}, 829 {BITSOFFS(16, 16), "DLID", mad_dump_uint}, 830 {BITSOFFS(32, 4), "SL", mad_dump_uint}, 831 {64, 32, "Timestamp", mad_dump_uint}, 832 {0, 0}, /* IB_CC_CONGESTION_LOG_ENTRY_SWITCH_LAST_F */ 833 834 /* 835 * CongestionLog (CA) fields 836 */ 837 {BITSOFFS(16, 16), "ThresholdEventCounter", mad_dump_uint}, 838 {BITSOFFS(32, 16), "ThresholdCongestionEventMap", mad_dump_hex}, 839 /* XXX: Q3/2010 errata lists offset 48, but that means field is not 840 * word aligned. Assume will be aligned to offset 64 later. 841 */ 842 {BITSOFFS(64, 32), "CurrentTimeStamp", mad_dump_uint}, 843 {0, 0}, /* IB_CC_CONGESTION_LOG_CA_LAST_F */ 844 845 /* 846 * CongestionLogEvent (CA) fields 847 */ 848 {BITSOFFS(0, 24), "Local_QP_CN_Entry", mad_dump_uint}, 849 {BITSOFFS(24, 4), "SL_CN_Entry", mad_dump_uint}, 850 {BITSOFFS(28, 4), "Service_Type_CN_Entry", mad_dump_hex}, 851 {BITSOFFS(32, 24), "Remote_QP_Number_CN_Entry", mad_dump_uint}, 852 {BITSOFFS(64, 16), "Local_LID_CN", mad_dump_uint}, 853 {BITSOFFS(80, 16), "Remote_LID_CN_Entry", mad_dump_uint}, 854 {BITSOFFS(96, 32), "Timestamp_CN_Entry", mad_dump_uint}, 855 {0, 0}, /* IB_CC_CONGESTION_LOG_ENTRY_CA_LAST_F */ 856 857 /* 858 * SwitchCongestionSetting fields 859 */ 860 {0, 32, "Control_Map", mad_dump_hex}, 861 {32, 256, "Victim_Mask", mad_dump_array}, 862 {288, 256, "Credit_Mask", mad_dump_array}, 863 {BITSOFFS(544, 4), "Threshold", mad_dump_hex}, 864 {BITSOFFS(552, 8), "Packet_Size", mad_dump_uint}, 865 {BITSOFFS(560, 4), "CS_Threshold", mad_dump_hex}, 866 {BITSOFFS(576, 16), "CS_ReturnDelay", mad_dump_hex}, /* TODO: CCT dump */ 867 {BITSOFFS(592, 16), "Marking_Rate", mad_dump_uint}, 868 {0, 0}, /* IB_CC_SWITCH_CONGESTION_SETTING_LAST_F */ 869 870 /* 871 * SwitchPortCongestionSettingElement fields 872 */ 873 {BITSOFFS(0, 1), "Valid", mad_dump_uint}, 874 {BITSOFFS(1, 1), "Control_Type", mad_dump_uint}, 875 {BITSOFFS(4, 4), "Threshold", mad_dump_hex}, 876 {BITSOFFS(8, 8), "Packet_Size", mad_dump_uint}, 877 {BITSOFFS(16, 16), "Cong_Parm_Marking_Rate", mad_dump_uint}, 878 {0, 0}, /* IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_LAST_F */ 879 880 /* 881 * CACongestionSetting fields 882 */ 883 {BITSOFFS(0, 16), "Port_Control", mad_dump_hex}, 884 {BITSOFFS(16, 16), "Control_Map", mad_dump_hex}, 885 {0, 0}, /* IB_CC_CA_CONGESTION_SETTING_LAST_F */ 886 887 /* 888 * CACongestionEntry fields 889 */ 890 {BITSOFFS(0, 16), "CCTI_Timer", mad_dump_uint}, 891 {BITSOFFS(16, 8), "CCTI_Increase", mad_dump_uint}, 892 {BITSOFFS(24, 8), "Trigger_Threshold", mad_dump_uint}, 893 {BITSOFFS(32, 8), "CCTI_Min", mad_dump_uint}, 894 {0, 0}, /* IB_CC_CA_CONGESTION_SETTING_ENTRY_LAST_F */ 895 896 /* 897 * CongestionControlTable fields 898 */ 899 {BITSOFFS(0, 16), "CCTI_Limit", mad_dump_uint}, 900 {0, 0}, /* IB_CC_CONGESTION_CONTROL_TABLE_LAST_F */ 901 902 /* 903 * CongestionControlTableEntry fields 904 */ 905 {BITSOFFS(0, 2), "CCT_Shift", mad_dump_uint}, 906 {BITSOFFS(2, 14), "CCT_Multiplier", mad_dump_uint}, 907 {0, 0}, /* IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_LAST_F */ 908 909 /* 910 * Timestamp fields 911 */ 912 {0, 32, "Timestamp", mad_dump_uint}, 913 {0, 0}, /* IB_CC_TIMESTAMP_LAST_F */ 914 915 /* Node Record */ 916 {BITSOFFS(0, 16), "Lid", mad_dump_uint}, 917 {BITSOFFS(32, 8), "BaseVers", mad_dump_uint}, 918 {BITSOFFS(40, 8), "ClassVers", mad_dump_uint}, 919 {BITSOFFS(48, 8), "NodeType", mad_dump_node_type}, 920 {BITSOFFS(56, 8), "NumPorts", mad_dump_uint}, 921 {64, 64, "SystemGuid", mad_dump_hex}, 922 {128, 64, "Guid", mad_dump_hex}, 923 {192, 64, "PortGuid", mad_dump_hex}, 924 {BITSOFFS(256, 16), "PartCap", mad_dump_uint}, 925 {BITSOFFS(272, 16), "DevId", mad_dump_hex}, 926 {288, 32, "Revision", mad_dump_hex}, 927 {BITSOFFS(320, 8), "LocalPort", mad_dump_uint}, 928 {BITSOFFS(328, 24), "VendorId", mad_dump_hex}, 929 {352, 64 * 8, "NodeDesc", mad_dump_string}, 930 {0, 0}, /* IB_SA_NR_LAST_F */ 931 932 /* 933 * PortMirrorRoute fields 934 */ 935 {BITSOFFS(0, 16), "EncapRawEthType", mad_dump_hex}, 936 {BITSOFFS(20, 12), "MaxMirrorLen", mad_dump_hex}, 937 {BITSOFFS(32, 3), "MT", mad_dump_hex}, 938 {BITSOFFS(35, 1), "BF", mad_dump_hex}, 939 {BITSOFFS(56, 8), "NMPort", mad_dump_hex}, 940 {BITSOFFS(64, 4), "EncapLRHVL", mad_dump_hex}, 941 {BITSOFFS(68, 4), "EncapLRHLVer", mad_dump_hex}, 942 {BITSOFFS(72, 4), "EncapLRHSL", mad_dump_hex}, 943 {BITSOFFS(78, 2), "EncapLRHLNH", mad_dump_hex}, 944 {BITSOFFS(80, 16), "EncapLRHDLID", mad_dump_hex}, 945 {BITSOFFS(101, 11), "EncapLRHLength", mad_dump_hex}, 946 {BITSOFFS(112, 16), "EncapLRHSLID", mad_dump_hex}, 947 {0, 0}, /* IB_PMR_LAST_F */ 948 949 /* 950 * PortMirrorFilter fields 951 */ 952 {0, 32, "MirrorFilter0", mad_dump_hex}, 953 {32, 32, "MirrorFilter1", mad_dump_hex}, 954 {64, 32, "MirrorMask0", mad_dump_hex}, 955 {96, 32, "MirrorMask1", mad_dump_hex}, 956 {128, 32, "MirrorMask2", mad_dump_hex}, 957 {160, 32, "MirrorMask3", mad_dump_hex}, 958 {BITSOFFS(192, 1), "B0", mad_dump_hex}, 959 {BITSOFFS(196, 12), "MirrorMaskOffset0", mad_dump_hex}, 960 {BITSOFFS(208, 1), "B1", mad_dump_hex}, 961 {BITSOFFS(212, 12), "MirrorMaskOffset1", mad_dump_hex}, 962 {BITSOFFS(224, 1), "B2", mad_dump_hex}, 963 {BITSOFFS(228, 12), "MirrorMaskOffset2", mad_dump_hex}, 964 {BITSOFFS(240, 1), "B3", mad_dump_hex}, 965 {BITSOFFS(244, 12), "MirrorMaskOffset3", mad_dump_hex}, 966 {0, 0}, /* IB_PMF_LAST_F */ 967 968 /* 969 * PortMirrorPorts fields 970 */ 971 {BITSOFFS(10, 2), "TQ1", mad_dump_hex}, 972 {BITSOFFS(14, 2), "RQ1", mad_dump_hex}, 973 {BITSOFFS(18, 2), "TQ2", mad_dump_hex}, 974 {BITSOFFS(22, 2), "RQ2", mad_dump_hex}, 975 {BITSOFFS(26, 2), "TQ3", mad_dump_hex}, 976 {BITSOFFS(30, 2), "RQ3", mad_dump_hex}, 977 {BITSOFFS(34, 2), "TQ4", mad_dump_hex}, 978 {BITSOFFS(38, 2), "RQ4", mad_dump_hex}, 979 {BITSOFFS(42, 2), "TQ5", mad_dump_hex}, 980 {BITSOFFS(46, 2), "RQ5", mad_dump_hex}, 981 {BITSOFFS(50, 2), "TQ6", mad_dump_hex}, 982 {BITSOFFS(54, 2), "RQ6", mad_dump_hex}, 983 {BITSOFFS(58, 2), "TQ7", mad_dump_hex}, 984 {BITSOFFS(62, 2), "RQ7", mad_dump_hex}, 985 {BITSOFFS(66, 2), "TQ8", mad_dump_hex}, 986 {BITSOFFS(70, 2), "RQ8", mad_dump_hex}, 987 {BITSOFFS(74, 2), "TQ9", mad_dump_hex}, 988 {BITSOFFS(78, 2), "RQ9", mad_dump_hex}, 989 {BITSOFFS(82, 2), "TQ10", mad_dump_hex}, 990 {BITSOFFS(86, 2), "RQ10", mad_dump_hex}, 991 {BITSOFFS(90, 2), "TQ11", mad_dump_hex}, 992 {BITSOFFS(94, 2), "RQ11", mad_dump_hex}, 993 {BITSOFFS(98, 2), "TQ12", mad_dump_hex}, 994 {BITSOFFS(102, 2), "RQ12", mad_dump_hex}, 995 {BITSOFFS(106, 2), "TQ13", mad_dump_hex}, 996 {BITSOFFS(110, 2), "RQ13", mad_dump_hex}, 997 {BITSOFFS(114, 2), "TQ14", mad_dump_hex}, 998 {BITSOFFS(118, 2), "RQ14", mad_dump_hex}, 999 {BITSOFFS(122, 2), "TQ15", mad_dump_hex}, 1000 {BITSOFFS(126, 2), "RQ15", mad_dump_hex}, 1001 {BITSOFFS(130, 2), "TQ16", mad_dump_hex}, 1002 {BITSOFFS(134, 2), "RQ16", mad_dump_hex}, 1003 {BITSOFFS(138, 2), "TQ17", mad_dump_hex}, 1004 {BITSOFFS(142, 2), "RQ17", mad_dump_hex}, 1005 {BITSOFFS(146, 2), "TQ18", mad_dump_hex}, 1006 {BITSOFFS(150, 2), "RQ18", mad_dump_hex}, 1007 {BITSOFFS(154, 2), "TQ19", mad_dump_hex}, 1008 {BITSOFFS(158, 2), "RQ19", mad_dump_hex}, 1009 {BITSOFFS(162, 2), "TQ20", mad_dump_hex}, 1010 {BITSOFFS(166, 2), "RQ20", mad_dump_hex}, 1011 {BITSOFFS(170, 2), "TQ21", mad_dump_hex}, 1012 {BITSOFFS(174, 2), "RQ21", mad_dump_hex}, 1013 {BITSOFFS(178, 2), "TQ22", mad_dump_hex}, 1014 {BITSOFFS(182, 2), "RQ22", mad_dump_hex}, 1015 {BITSOFFS(186, 2), "TQ23", mad_dump_hex}, 1016 {BITSOFFS(190, 2), "RQ23", mad_dump_hex}, 1017 {BITSOFFS(194, 2), "TQ24", mad_dump_hex}, 1018 {BITSOFFS(198, 2), "RQ24", mad_dump_hex}, 1019 {BITSOFFS(202, 2), "TQ25", mad_dump_hex}, 1020 {BITSOFFS(206, 2), "RQ25", mad_dump_hex}, 1021 {BITSOFFS(210, 2), "TQ26", mad_dump_hex}, 1022 {BITSOFFS(214, 2), "RQ26", mad_dump_hex}, 1023 {BITSOFFS(218, 2), "TQ27", mad_dump_hex}, 1024 {BITSOFFS(222, 2), "RQ27", mad_dump_hex}, 1025 {BITSOFFS(226, 2), "TQ28", mad_dump_hex}, 1026 {BITSOFFS(230, 2), "RQ28", mad_dump_hex}, 1027 {BITSOFFS(234, 2), "TQ29", mad_dump_hex}, 1028 {BITSOFFS(238, 2), "RQ29", mad_dump_hex}, 1029 {BITSOFFS(242, 2), "TQ30", mad_dump_hex}, 1030 {BITSOFFS(246, 2), "RQ30", mad_dump_hex}, 1031 {BITSOFFS(250, 2), "TQ31", mad_dump_hex}, 1032 {BITSOFFS(254, 2), "RQ31", mad_dump_hex}, 1033 {BITSOFFS(258, 2), "TQ32", mad_dump_hex}, 1034 {BITSOFFS(262, 2), "RQ32", mad_dump_hex}, 1035 {BITSOFFS(266, 2), "TQ33", mad_dump_hex}, 1036 {BITSOFFS(270, 2), "RQ33", mad_dump_hex}, 1037 {BITSOFFS(274, 2), "TQ34", mad_dump_hex}, 1038 {BITSOFFS(278, 2), "RQ34", mad_dump_hex}, 1039 {BITSOFFS(282, 2), "TQ35", mad_dump_hex}, 1040 {BITSOFFS(286, 2), "RQ35", mad_dump_hex}, 1041 {BITSOFFS(290, 2), "TQ36", mad_dump_hex}, 1042 {BITSOFFS(294, 2), "RQ36", mad_dump_hex}, 1043 {0, 0}, /* IB_FIELD_LAST_ */ 1044 1045 /* 1046 * PortSamplesResult fields 1047 */ 1048 {BITSOFFS(0, 16), "Tag", mad_dump_hex}, 1049 {BITSOFFS(30, 2), "SampleStatus", mad_dump_hex}, 1050 {32, 32, "Counter0", mad_dump_uint}, 1051 {64, 32, "Counter1", mad_dump_uint}, 1052 {96, 32, "Counter2", mad_dump_uint}, 1053 {128, 32, "Counter3", mad_dump_uint}, 1054 {160, 32, "Counter4", mad_dump_uint}, 1055 {192, 32, "Counter5", mad_dump_uint}, 1056 {224, 32, "Counter6", mad_dump_uint}, 1057 {256, 32, "Counter7", mad_dump_uint}, 1058 {288, 32, "Counter8", mad_dump_uint}, 1059 {320, 32, "Counter9", mad_dump_uint}, 1060 {352, 32, "Counter10", mad_dump_uint}, 1061 {384, 32, "Counter11", mad_dump_uint}, 1062 {416, 32, "Counter12", mad_dump_uint}, 1063 {448, 32, "Counter13", mad_dump_uint}, 1064 {480, 32, "Counter14", mad_dump_uint}, 1065 {0, 0}, /* IB_PSR_LAST_F */ 1066 1067 /* 1068 * PortInfoExtended fields 1069 */ 1070 {0, 32, "CapMask", mad_dump_hex}, 1071 {BITSOFFS(32, 16), "FECModeActive", mad_dump_uint}, 1072 {BITSOFFS(48, 16), "FDRFECModeSupported", mad_dump_uint}, 1073 {BITSOFFS(64, 16), "FDRFECModeEnabled", mad_dump_uint}, 1074 {BITSOFFS(80, 16), "EDRFECModeSupported", mad_dump_uint}, 1075 {BITSOFFS(96, 16), "EDRFECModeEnabled", mad_dump_uint}, 1076 {0, 0}, /* IB_PORT_EXT_LAST_F */ 1077 1078 /* 1079 * PortExtendedSpeedsCounters RSFEC Active fields 1080 */ 1081 {BITSOFFS(8, 8), "PortSelect", mad_dump_uint}, 1082 {64, 64, "CounterSelect", mad_dump_hex}, 1083 {BITSOFFS(128, 16), "SyncHeaderErrorCounter", mad_dump_uint}, 1084 {BITSOFFS(144, 16), "UnknownBlockCounter", mad_dump_uint}, 1085 {352, 32, "FECCorrectableSymbolCtrLane0", mad_dump_uint}, 1086 {384, 32, "FECCorrectableSymbolCtrLane1", mad_dump_uint}, 1087 {416, 32, "FECCorrectableSymbolCtrLane2", mad_dump_uint}, 1088 {448, 32, "FECCorrectableSymbolCtrLane3", mad_dump_uint}, 1089 {480, 32, "FECCorrectableSymbolCtrLane4", mad_dump_uint}, 1090 {512, 32, "FECCorrectableSymbolCtrLane5", mad_dump_uint}, 1091 {544, 32, "FECCorrectableSymbolCtrLane6", mad_dump_uint}, 1092 {576, 32, "FECCorrectableSymbolCtrLane7", mad_dump_uint}, 1093 {608, 32, "FECCorrectableSymbolCtrLane8", mad_dump_uint}, 1094 {640, 32, "FECCorrectableSymbolCtrLane9", mad_dump_uint}, 1095 {672, 32, "FECCorrectableSymbolCtrLane10", mad_dump_uint}, 1096 {704, 32, "FECCorrectableSymbolCtrLane11", mad_dump_uint}, 1097 {1120, 32, "PortFECCorrectableBlockCtr", mad_dump_uint}, 1098 {1152, 32, "PortFECUncorrectableBlockCtr", mad_dump_uint}, 1099 {1184, 32, "PortFECCorrectedSymbolCtr", mad_dump_uint}, 1100 {0, 0}, /* IB_PESC_RSFEC_LAST_F */ 1101 1102 /* 1103 * More PortCountersExtended fields 1104 */ 1105 {32, 32, "CounterSelect2", mad_dump_hex}, 1106 {576, 64, "SymbolErrorCounter", mad_dump_uint}, 1107 {640, 64, "LinkErrorRecoveryCounter", mad_dump_uint}, 1108 {704, 64, "LinkDownedCounter", mad_dump_uint}, 1109 {768, 64, "PortRcvErrors", mad_dump_uint}, 1110 {832, 64, "PortRcvRemotePhysicalErrors", mad_dump_uint}, 1111 {896, 64, "PortRcvSwitchRelayErrors", mad_dump_uint}, 1112 {960, 64, "PortXmitDiscards", mad_dump_uint}, 1113 {1024, 64, "PortXmitConstraintErrors", mad_dump_uint}, 1114 {1088, 64, "PortRcvConstraintErrors", mad_dump_uint}, 1115 {1152, 64, "LocalLinkIntegrityErrors", mad_dump_uint}, 1116 {1216, 64, "ExcessiveBufferOverrunErrors", mad_dump_uint}, 1117 {1280, 64, "VL15Dropped", mad_dump_uint}, 1118 {1344, 64, "PortXmitWait", mad_dump_uint}, 1119 {1408, 64, "QP1Dropped", mad_dump_uint}, 1120 {0, 0}, /* IB_PC_EXT_ERR_LAST_F */ 1121 1122 /* 1123 * Another PortCounters field 1124 */ 1125 {160, 16, "QP1Dropped", mad_dump_uint}, 1126 1127 {0, 0} /* IB_FIELD_LAST_ */ 1128 }; 1129 1130 static void _set_field64(void *buf, int base_offs, const ib_field_t * f, 1131 uint64_t val) 1132 { 1133 uint64_t nval; 1134 1135 nval = htonll(val); 1136 memcpy(((void *)(char *)buf + base_offs + f->bitoffs / 8), 1137 (void *)&nval, sizeof(uint64_t)); 1138 } 1139 1140 static uint64_t _get_field64(void *buf, int base_offs, const ib_field_t * f) 1141 { 1142 uint64_t val; 1143 memcpy((void *)&val, (void *)((char *)buf + base_offs + f->bitoffs / 8), 1144 sizeof(uint64_t)); 1145 return ntohll(val); 1146 } 1147 1148 static void _set_field(void *buf, int base_offs, const ib_field_t * f, 1149 uint32_t val) 1150 { 1151 int prebits = (8 - (f->bitoffs & 7)) & 7; 1152 int postbits = (f->bitoffs + f->bitlen) & 7; 1153 int bytelen = f->bitlen / 8; 1154 unsigned idx = base_offs + f->bitoffs / 8; 1155 char *p = (char *)buf; 1156 1157 if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8) { 1158 p[3 ^ idx] &= ~((((1 << f->bitlen) - 1)) << (f->bitoffs & 7)); 1159 p[3 ^ idx] |= 1160 (val & ((1 << f->bitlen) - 1)) << (f->bitoffs & 7); 1161 return; 1162 } 1163 1164 if (prebits) { /* val lsb in byte msb */ 1165 p[3 ^ idx] &= (1 << (8 - prebits)) - 1; 1166 p[3 ^ idx++] |= (val & ((1 << prebits) - 1)) << (8 - prebits); 1167 val >>= prebits; 1168 } 1169 1170 /* BIG endian byte order */ 1171 for (; bytelen--; val >>= 8) 1172 p[3 ^ idx++] = val & 0xff; 1173 1174 if (postbits) { /* val msb in byte lsb */ 1175 p[3 ^ idx] &= ~((1 << postbits) - 1); 1176 p[3 ^ idx] |= val; 1177 } 1178 } 1179 1180 static uint32_t _get_field(void *buf, int base_offs, const ib_field_t * f) 1181 { 1182 int prebits = (8 - (f->bitoffs & 7)) & 7; 1183 int postbits = (f->bitoffs + f->bitlen) & 7; 1184 int bytelen = f->bitlen / 8; 1185 unsigned idx = base_offs + f->bitoffs / 8; 1186 uint8_t *p = (uint8_t *) buf; 1187 uint32_t val = 0, v = 0, i; 1188 1189 if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8) 1190 return (p[3 ^ idx] >> (f->bitoffs & 7)) & ((1 << f->bitlen) - 1191 1); 1192 1193 if (prebits) /* val lsb from byte msb */ 1194 v = p[3 ^ idx++] >> (8 - prebits); 1195 1196 if (postbits) { /* val msb from byte lsb */ 1197 i = base_offs + (f->bitoffs + f->bitlen) / 8; 1198 val = (p[3 ^ i] & ((1 << postbits) - 1)); 1199 } 1200 1201 /* BIG endian byte order */ 1202 for (idx += bytelen - 1; bytelen--; idx--) 1203 val = (val << 8) | p[3 ^ idx]; 1204 1205 return (val << prebits) | v; 1206 } 1207 1208 /* field must be byte aligned */ 1209 static void _set_array(void *buf, int base_offs, const ib_field_t * f, 1210 void *val) 1211 { 1212 int bitoffs = f->bitoffs; 1213 1214 if (f->bitlen < 32) 1215 bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen); 1216 1217 memcpy((uint8_t *) buf + base_offs + bitoffs / 8, val, f->bitlen / 8); 1218 } 1219 1220 static void _get_array(void *buf, int base_offs, const ib_field_t * f, 1221 void *val) 1222 { 1223 int bitoffs = f->bitoffs; 1224 1225 if (f->bitlen < 32) 1226 bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen); 1227 1228 memcpy(val, (uint8_t *) buf + base_offs + bitoffs / 8, f->bitlen / 8); 1229 } 1230 1231 uint32_t mad_get_field(void *buf, int base_offs, enum MAD_FIELDS field) 1232 { 1233 return _get_field(buf, base_offs, ib_mad_f + field); 1234 } 1235 1236 void mad_set_field(void *buf, int base_offs, enum MAD_FIELDS field, 1237 uint32_t val) 1238 { 1239 _set_field(buf, base_offs, ib_mad_f + field, val); 1240 } 1241 1242 uint64_t mad_get_field64(void *buf, int base_offs, enum MAD_FIELDS field) 1243 { 1244 return _get_field64(buf, base_offs, ib_mad_f + field); 1245 } 1246 1247 void mad_set_field64(void *buf, int base_offs, enum MAD_FIELDS field, 1248 uint64_t val) 1249 { 1250 _set_field64(buf, base_offs, ib_mad_f + field, val); 1251 } 1252 1253 void mad_set_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val) 1254 { 1255 _set_array(buf, base_offs, ib_mad_f + field, val); 1256 } 1257 1258 void mad_get_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val) 1259 { 1260 _get_array(buf, base_offs, ib_mad_f + field, val); 1261 } 1262 1263 void mad_decode_field(uint8_t * buf, enum MAD_FIELDS field, void *val) 1264 { 1265 const ib_field_t *f = ib_mad_f + field; 1266 1267 if (!field) { 1268 *(int *)val = *(int *)buf; 1269 return; 1270 } 1271 if (f->bitlen <= 32) { 1272 *(uint32_t *) val = _get_field(buf, 0, f); 1273 return; 1274 } 1275 if (f->bitlen == 64) { 1276 *(uint64_t *) val = _get_field64(buf, 0, f); 1277 return; 1278 } 1279 _get_array(buf, 0, f, val); 1280 } 1281 1282 void mad_encode_field(uint8_t * buf, enum MAD_FIELDS field, void *val) 1283 { 1284 const ib_field_t *f = ib_mad_f + field; 1285 1286 if (!field) { 1287 *(int *)buf = *(int *)val; 1288 return; 1289 } 1290 if (f->bitlen <= 32) { 1291 _set_field(buf, 0, f, *(uint32_t *) val); 1292 return; 1293 } 1294 if (f->bitlen == 64) { 1295 _set_field64(buf, 0, f, *(uint64_t *) val); 1296 return; 1297 } 1298 _set_array(buf, 0, f, val); 1299 } 1300 1301 /************************/ 1302 1303 static char *_mad_dump_val(const ib_field_t * f, char *buf, int bufsz, 1304 void *val) 1305 { 1306 f->def_dump_fn(buf, bufsz, val, ALIGN(f->bitlen, 8) / 8); 1307 buf[bufsz - 1] = 0; 1308 1309 return buf; 1310 } 1311 1312 static char *_mad_dump_field(const ib_field_t * f, const char *name, char *buf, 1313 int bufsz, void *val) 1314 { 1315 char dots[128]; 1316 int l, n; 1317 1318 if (bufsz <= 32) 1319 return NULL; /* buf too small */ 1320 1321 if (!name) 1322 name = f->name; 1323 1324 l = strlen(name); 1325 if (l < 32) { 1326 memset(dots, '.', 32 - l); 1327 dots[32 - l] = 0; 1328 } 1329 1330 n = snprintf(buf, bufsz, "%s:%s", name, dots); 1331 _mad_dump_val(f, buf + n, bufsz - n, val); 1332 buf[bufsz - 1] = 0; 1333 1334 return buf; 1335 } 1336 1337 static int _mad_dump(ib_mad_dump_fn * fn, const char *name, void *val, 1338 int valsz) 1339 { 1340 ib_field_t f; 1341 char buf[512]; 1342 1343 f.def_dump_fn = fn; 1344 f.bitlen = valsz * 8; 1345 1346 return printf("%s\n", _mad_dump_field(&f, name, buf, sizeof buf, val)); 1347 } 1348 1349 static int _mad_print_field(const ib_field_t * f, const char *name, void *val, 1350 int valsz) 1351 { 1352 return _mad_dump(f->def_dump_fn, name ? name : f->name, val, 1353 valsz ? valsz : ALIGN(f->bitlen, 8) / 8); 1354 } 1355 1356 int mad_print_field(enum MAD_FIELDS field, const char *name, void *val) 1357 { 1358 if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_) 1359 return -1; 1360 return _mad_print_field(ib_mad_f + field, name, val, 0); 1361 } 1362 1363 char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz, void *val) 1364 { 1365 if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_) 1366 return NULL; 1367 return _mad_dump_field(ib_mad_f + field, 0, buf, bufsz, val); 1368 } 1369 1370 char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz, void *val) 1371 { 1372 if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_) 1373 return NULL; 1374 return _mad_dump_val(ib_mad_f + field, buf, bufsz, val); 1375 } 1376 1377 const char *mad_field_name(enum MAD_FIELDS field) 1378 { 1379 return (ib_mad_f[field].name); 1380 } 1381