aboutsummaryrefslogtreecommitdiff
path: root/contrib/ofed/libibmad
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2017-08-02 16:00:30 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2017-08-02 16:00:30 +0000
commitd6b92ffa990dc57d8a969a98e3ca4e25ba39cbb2 (patch)
tree8cca73c0fa75739adf10581b9e68d682f63048f3 /contrib/ofed/libibmad
parent434b6d2073f936acc361b1e343dd9615036e1cd9 (diff)
downloadsrc-d6b92ffa990dc57d8a969a98e3ca4e25ba39cbb2.tar.gz
src-d6b92ffa990dc57d8a969a98e3ca4e25ba39cbb2.zip
OFED user-space import and update for use with Linux-4.9 compatible RDMA
kernel APIs. List of sources used: 1) rdma-core was cloned from "https://github.com/linux-rdma/rdma-core.git" Top commit d65138ef93af30b3ea249f3a84aa6a24ba7f8a75 2) OpenSM was cloned from git://git.openfabrics.org/~halr/opensm.git Top commit 85f841cf209f791c89a075048a907020e924528d 3) libibmad was cloned from "git://git.openfabrics.org/~iraweiny/libibmad.git" Tag 1.3.13 with some additional patches from Mellanox. 4) infiniband-diags was cloned from "git://git.openfabrics.org/~iraweiny/infiniband-diags.git" Tag 1.6.7 with some additional patches from Mellanox. Added the required Makefiles for building and installing. Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/projects/bsd_rdma_4_9/; revision=321936
Diffstat (limited to 'contrib/ofed/libibmad')
-rw-r--r--contrib/ofed/libibmad/Makefile36
-rw-r--r--contrib/ofed/libibmad/bm.c107
-rw-r--r--contrib/ofed/libibmad/cc.c119
-rw-r--r--contrib/ofed/libibmad/config.h89
-rw-r--r--contrib/ofed/libibmad/dump.c1221
-rw-r--r--contrib/ofed/libibmad/fields.c1380
-rw-r--r--contrib/ofed/libibmad/gs.c133
-rw-r--r--contrib/ofed/libibmad/libibmad.map160
-rw-r--r--contrib/ofed/libibmad/mad.c211
-rw-r--r--contrib/ofed/libibmad/mad.h1843
-rw-r--r--contrib/ofed/libibmad/mad_internal.h52
-rw-r--r--contrib/ofed/libibmad/mad_osd.h50
-rw-r--r--contrib/ofed/libibmad/portid.c127
-rw-r--r--contrib/ofed/libibmad/register.c178
-rw-r--r--contrib/ofed/libibmad/resolve.c249
-rw-r--r--contrib/ofed/libibmad/rpc.c456
-rw-r--r--contrib/ofed/libibmad/sa.c192
-rw-r--r--contrib/ofed/libibmad/serv.c205
-rw-r--r--contrib/ofed/libibmad/smp.c150
-rw-r--r--contrib/ofed/libibmad/vendor.c112
20 files changed, 7070 insertions, 0 deletions
diff --git a/contrib/ofed/libibmad/Makefile b/contrib/ofed/libibmad/Makefile
new file mode 100644
index 000000000000..8860971ae4eb
--- /dev/null
+++ b/contrib/ofed/libibmad/Makefile
@@ -0,0 +1,36 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= ibmad
+SHLIB_MAJOR= 5
+MK_PROFILE= no
+
+SRCS= \
+bm.c \
+cc.c \
+dump.c \
+fields.c \
+gs.c \
+mad.c \
+portid.c \
+register.c \
+resolve.c \
+rpc.c \
+sa.c \
+serv.c \
+smp.c \
+vendor.c
+
+.if defined(TESTBUILD)
+LDFLAGS= -libumad
+.else
+LIBADD= ibumad
+.endif
+CFLAGS+= -DHAVE_CONFIG_H=1
+CFLAGS+= -I${.CURDIR}
+VERSION_MAP= ${.CURDIR}/libibmad.map
+
+.include <bsd.lib.mk>
+
diff --git a/contrib/ofed/libibmad/bm.c b/contrib/ofed/libibmad/bm.c
new file mode 100644
index 000000000000..318145120efc
--- /dev/null
+++ b/contrib/ofed/libibmad/bm.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+
+#include <infiniband/mad.h>
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+static inline int response_expected(int method)
+{
+ return method == IB_MAD_METHOD_GET ||
+ method == IB_MAD_METHOD_SET || method == IB_MAD_METHOD_TRAP;
+}
+
+uint8_t *bm_call_via(void *data, ib_portid_t * portid, ib_bm_call_t * call,
+ struct ibmad_port * srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ int resp_expected;
+ struct {
+ uint64_t bkey;
+ uint8_t reserved[32];
+ uint8_t data[IB_BM_DATA_SZ];
+ } bm_data;
+
+ DEBUG("route %s data %p", portid2str(portid), data);
+ if (portid->lid <= 0) {
+ IBWARN("only lid routes are supported");
+ return NULL;
+ }
+
+ resp_expected = response_expected(call->method);
+
+ rpc.mgtclass = IB_BOARD_MGMT_CLASS;
+
+ rpc.method = call->method;
+ rpc.attr.id = call->attrid;
+ rpc.attr.mod = call->mod;
+ rpc.timeout = resp_expected ? call->timeout : 0;
+ // send data and bkey
+ rpc.datasz = IB_BM_BKEY_AND_DATA_SZ;
+ rpc.dataoffs = IB_BM_BKEY_OFFS;
+
+ // copy data to a buffer which also includes the bkey
+ bm_data.bkey = htonll(call->bkey);
+ memset(bm_data.reserved, 0, sizeof(bm_data.reserved));
+ memcpy(bm_data.data, data, IB_BM_DATA_SZ);
+
+ DEBUG
+ ("method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d bkey 0x%08x%08x",
+ rpc.method, rpc.attr.id, rpc.attr.mod, rpc.datasz, rpc.dataoffs,
+ resp_expected, (int)(call->bkey >> 32), (int)call->bkey);
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ if (resp_expected) {
+ /* FIXME: no RMPP for now */
+ if (mad_rpc(srcport, &rpc, portid, &bm_data, &bm_data))
+ goto return_ok;
+ return NULL;
+ }
+
+ if (mad_send_via(&rpc, portid, 0, &bm_data, srcport) < 0)
+ return NULL;
+
+return_ok:
+ memcpy(data, bm_data.data, IB_BM_DATA_SZ);
+ return data;
+}
diff --git a/contrib/ofed/libibmad/cc.c b/contrib/ofed/libibmad/cc.c
new file mode 100644
index 000000000000..23340156d61c
--- /dev/null
+++ b/contrib/ofed/libibmad/cc.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011 Lawrence Livermore National Lab. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+void *cc_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey)
+{
+ ib_rpc_cc_t rpc = { 0 };
+ void *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ rpc.method = IB_MAD_METHOD_GET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ if (attrid == IB_CC_ATTR_CONGESTION_LOG) {
+ rpc.datasz = IB_CC_LOG_DATA_SZ;
+ rpc.dataoffs = IB_CC_LOG_DATA_OFFS;
+ }
+ else {
+ rpc.datasz = IB_CC_DATA_SZ;
+ rpc.dataoffs = IB_CC_DATA_OFFS;
+ }
+ rpc.mgtclass = IB_CC_CLASS;
+ rpc.cckey = cckey;
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, rcvbuf, rcvbuf);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+
+ return res;
+}
+
+void *cc_config_status_via(void *payload, void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey)
+{
+ ib_rpc_cc_t rpc = { 0 };
+ void *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ if (attrid == IB_CC_ATTR_CONGESTION_LOG) {
+ rpc.datasz = IB_CC_LOG_DATA_SZ;
+ rpc.dataoffs = IB_CC_LOG_DATA_OFFS;
+ }
+ else {
+ rpc.datasz = IB_CC_DATA_SZ;
+ rpc.dataoffs = IB_CC_DATA_OFFS;
+ }
+ rpc.mgtclass = IB_CC_CLASS;
+ rpc.cckey = cckey;
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, payload, rcvbuf);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+
+ return res;
+}
+
+
diff --git a/contrib/ofed/libibmad/config.h b/contrib/ofed/libibmad/config.h
new file mode 100644
index 000000000000..9333552edba2
--- /dev/null
+++ b/contrib/ofed/libibmad/config.h
@@ -0,0 +1,89 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `ibumad' library (-libumad). */
+#define HAVE_LIBIBUMAD 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "libibmad"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "linux-rdma@vger.kernel.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libibmad"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libibmad 1.3.13"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libibmad"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.3.13"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "1.3.13"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
diff --git a/contrib/ofed/libibmad/dump.c b/contrib/ofed/libibmad/dump.c
new file mode 100644
index 000000000000..00b9211662c5
--- /dev/null
+++ b/contrib/ofed/libibmad/dump.c
@@ -0,0 +1,1221 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/mad.h>
+
+void mad_dump_int(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ case 4:
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val);
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %d", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_uint(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ case 4:
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val);
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %u", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "0x%02x", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "0x%04x", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ snprintf(buf, bufsz, "0x%06x", *(uint32_t *) val & 0xffffff);
+ break;
+ case 4:
+ snprintf(buf, bufsz, "0x%08x", *(uint32_t *) val);
+ break;
+ case 5:
+ snprintf(buf, bufsz, "0x%010" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffULL);
+ break;
+ case 6:
+ snprintf(buf, bufsz, "0x%012" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffULL);
+ break;
+ case 7:
+ snprintf(buf, bufsz, "0x%014" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffffULL);
+ break;
+ case 8:
+ snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %d", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_rhex(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "%02x", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "%04x", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ snprintf(buf, bufsz, "%06x", *(uint32_t *) val & 0xffffff);
+ break;
+ case 4:
+ snprintf(buf, bufsz, "%08x", *(uint32_t *) val);
+ break;
+ case 5:
+ snprintf(buf, bufsz, "%010" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffULL);
+ break;
+ case 6:
+ snprintf(buf, bufsz, "%012" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffULL);
+ break;
+ case 7:
+ snprintf(buf, bufsz, "%014" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffffULL);
+ break;
+ case 8:
+ snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %d", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_linkwidth(char *buf, int bufsz, void *val, int valsz)
+{
+ int width = *(int *)val;
+
+ switch (width) {
+ case 1:
+ snprintf(buf, bufsz, "1X");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "4X");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "8X");
+ break;
+ case 8:
+ snprintf(buf, bufsz, "12X");
+ break;
+ case 16:
+ snprintf(buf, bufsz, "2X");
+ break;
+ default:
+ IBWARN("bad width %d", width);
+ snprintf(buf, bufsz, "undefined (%d)", width);
+ break;
+ }
+}
+
+static void dump_linkwidth(char *buf, int bufsz, int width)
+{
+ int n = 0;
+
+ if (width & 0x1)
+ n += snprintf(buf + n, bufsz - n, "1X or ");
+ if (n < bufsz && (width & 0x2))
+ n += snprintf(buf + n, bufsz - n, "4X or ");
+ if (n < bufsz && (width & 0x4))
+ n += snprintf(buf + n, bufsz - n, "8X or ");
+ if (n < bufsz && (width & 0x8))
+ n += snprintf(buf + n, bufsz - n, "12X or ");
+ if (n < bufsz && (width & 0x10))
+ n += snprintf(buf + n, bufsz - n, "2X or ");
+
+ if (n >= bufsz)
+ return;
+ else if (width == 0 || (width >> 5))
+ snprintf(buf + n, bufsz - n, "undefined (%d)", width);
+ else if (bufsz > 3)
+ buf[n - 4] = '\0';
+}
+
+void mad_dump_linkwidthsup(char *buf, int bufsz, void *val, int valsz)
+{
+ int width = *(int *)val;
+
+ dump_linkwidth(buf, bufsz, width);
+
+ switch (width) {
+ case 1:
+ case 3:
+ case 7:
+ case 11:
+ case 15:
+ case 17:
+ case 19:
+ case 23:
+ case 27:
+ case 31:
+ break;
+
+ default:
+ if (!(width >> 5))
+ snprintf(buf + strlen(buf), bufsz - strlen(buf),
+ " (IBA extension)");
+ break;
+ }
+}
+
+void mad_dump_linkwidthen(char *buf, int bufsz, void *val, int valsz)
+{
+ int width = *(int *)val;
+
+ dump_linkwidth(buf, bufsz, width);
+}
+
+void mad_dump_linkspeed(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ switch (speed) {
+ case 0:
+ snprintf(buf, bufsz, "Extended speed");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "2.5 Gbps");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "5.0 Gbps");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "10.0 Gbps");
+ break;
+ default:
+ snprintf(buf, bufsz, "undefined (%d)", speed);
+ break;
+ }
+}
+
+static void dump_linkspeed(char *buf, int bufsz, int speed)
+{
+ int n = 0;
+
+ if (speed & 0x1)
+ n += snprintf(buf + n, bufsz - n, "2.5 Gbps or ");
+ if (n < bufsz && (speed & 0x2))
+ n += snprintf(buf + n, bufsz - n, "5.0 Gbps or ");
+ if (n < bufsz && (speed & 0x4))
+ n += snprintf(buf + n, bufsz - n, "10.0 Gbps or ");
+
+ if (n >= bufsz)
+ return;
+ else if (speed == 0 || (speed >> 3)) {
+ n += snprintf(buf + n, bufsz - n, "undefined (%d)", speed);
+ if (n >= bufsz)
+ return;
+ } else if (bufsz > 3) {
+ buf[n - 4] = '\0';
+ n -= 4;
+ }
+
+ switch (speed) {
+ case 1:
+ case 3:
+ case 5:
+ case 7:
+ break;
+ default:
+ if (!(speed >> 3))
+ snprintf(buf + n, bufsz - n, " (IBA extension)");
+ break;
+ }
+}
+
+void mad_dump_linkspeedsup(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ dump_linkspeed(buf, bufsz, speed);
+}
+
+void mad_dump_linkspeeden(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ dump_linkspeed(buf, bufsz, speed);
+}
+
+void mad_dump_linkspeedext(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ switch (speed) {
+ case 0:
+ snprintf(buf, bufsz, "No Extended Speed");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "14.0625 Gbps");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "25.78125 Gbps");
+ break;
+ default:
+ snprintf(buf, bufsz, "undefined (%d)", speed);
+ break;
+ }
+}
+
+static void dump_linkspeedext(char *buf, int bufsz, int speed)
+{
+ int n = 0;
+
+ if (speed == 0) {
+ sprintf(buf, "%d", speed);
+ return;
+ }
+
+ if (speed & 0x1)
+ n += snprintf(buf + n, bufsz - n, "14.0625 Gbps or ");
+ if (n < bufsz && speed & 0x2)
+ n += snprintf(buf + n, bufsz - n, "25.78125 Gbps or ");
+ if (n >= bufsz) {
+ if (bufsz > 3)
+ buf[n - 4] = '\0';
+ return;
+ }
+
+ if (speed >> 2) {
+ n += snprintf(buf + n, bufsz - n, "undefined (%d)", speed);
+ return;
+ } else if (bufsz > 3)
+ buf[n - 4] = '\0';
+}
+
+void mad_dump_linkspeedextsup(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ dump_linkspeedext(buf, bufsz, speed);
+}
+
+void mad_dump_linkspeedexten(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ if (speed == 30) {
+ sprintf(buf, "%s", "Extended link speeds disabled");
+ return;
+ }
+ dump_linkspeedext(buf, bufsz, speed);
+}
+
+void mad_dump_portstate(char *buf, int bufsz, void *val, int valsz)
+{
+ int state = *(int *)val;
+
+ switch (state) {
+ case 0:
+ snprintf(buf, bufsz, "NoChange");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "Down");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Initialize");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "Armed");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "Active");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", state);
+ }
+}
+
+void mad_dump_linkdowndefstate(char *buf, int bufsz, void *val, int valsz)
+{
+ int state = *(int *)val;
+
+ switch (state) {
+ case 0:
+ snprintf(buf, bufsz, "NoChange");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "Sleep");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Polling");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", state);
+ break;
+ }
+}
+
+void mad_dump_physportstate(char *buf, int bufsz, void *val, int valsz)
+{
+ int state = *(int *)val;
+
+ switch (state) {
+ case 0:
+ snprintf(buf, bufsz, "NoChange");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "Sleep");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Polling");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "Disabled");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "PortConfigurationTraining");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "LinkUp");
+ break;
+ case 6:
+ snprintf(buf, bufsz, "LinkErrorRecovery");
+ break;
+ case 7:
+ snprintf(buf, bufsz, "PhyTest");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", state);
+ }
+}
+
+void mad_dump_mtu(char *buf, int bufsz, void *val, int valsz)
+{
+ int mtu = *(int *)val;
+
+ switch (mtu) {
+ case 1:
+ snprintf(buf, bufsz, "256");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "512");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "1024");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "2048");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "4096");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", mtu);
+ }
+}
+
+void mad_dump_vlcap(char *buf, int bufsz, void *val, int valsz)
+{
+ int vlcap = *(int *)val;
+
+ switch (vlcap) {
+ case 1:
+ snprintf(buf, bufsz, "VL0");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "VL0-1");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "VL0-3");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "VL0-7");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "VL0-14");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", vlcap);
+ }
+}
+
+void mad_dump_opervls(char *buf, int bufsz, void *val, int valsz)
+{
+ int opervls = *(int *)val;
+
+ switch (opervls) {
+ case 0:
+ snprintf(buf, bufsz, "No change");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "VL0");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "VL0-1");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "VL0-3");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "VL0-7");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "VL0-14");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", opervls);
+ }
+}
+
+void mad_dump_portcapmask(char *buf, int bufsz, void *val, int valsz)
+{
+ unsigned mask = *(unsigned *)val;
+ char *s = buf;
+
+ s += sprintf(s, "0x%x\n", mask);
+ if (mask & (1 << 1))
+ s += sprintf(s, "\t\t\t\tIsSM\n");
+ if (mask & (1 << 2))
+ s += sprintf(s, "\t\t\t\tIsNoticeSupported\n");
+ if (mask & (1 << 3))
+ s += sprintf(s, "\t\t\t\tIsTrapSupported\n");
+ if (mask & (1 << 4))
+ s += sprintf(s, "\t\t\t\tIsOptionalIPDSupported\n");
+ if (mask & (1 << 5))
+ s += sprintf(s, "\t\t\t\tIsAutomaticMigrationSupported\n");
+ if (mask & (1 << 6))
+ s += sprintf(s, "\t\t\t\tIsSLMappingSupported\n");
+ if (mask & (1 << 7))
+ s += sprintf(s, "\t\t\t\tIsMKeyNVRAM\n");
+ if (mask & (1 << 8))
+ s += sprintf(s, "\t\t\t\tIsPKeyNVRAM\n");
+ if (mask & (1 << 9))
+ s += sprintf(s, "\t\t\t\tIsLedInfoSupported\n");
+ if (mask & (1 << 10))
+ s += sprintf(s, "\t\t\t\tIsSMdisabled\n");
+ if (mask & (1 << 11))
+ s += sprintf(s, "\t\t\t\tIsSystemImageGUIDsupported\n");
+ if (mask & (1 << 12))
+ s += sprintf(s,
+ "\t\t\t\tIsPkeySwitchExternalPortTrapSupported\n");
+ if (mask & (1 << 14))
+ s += sprintf(s, "\t\t\t\tIsExtendedSpeedsSupported\n");
+ if (mask & (1 << 15))
+ s += sprintf(s, "\t\t\t\tIsCapabilityMask2Supported\n");
+ if (mask & (1 << 16))
+ s += sprintf(s, "\t\t\t\tIsCommunicatonManagementSupported\n");
+ if (mask & (1 << 17))
+ s += sprintf(s, "\t\t\t\tIsSNMPTunnelingSupported\n");
+ if (mask & (1 << 18))
+ s += sprintf(s, "\t\t\t\tIsReinitSupported\n");
+ if (mask & (1 << 19))
+ s += sprintf(s, "\t\t\t\tIsDeviceManagementSupported\n");
+ if (mask & (1 << 20))
+ s += sprintf(s, "\t\t\t\tIsVendorClassSupported\n");
+ if (mask & (1 << 21))
+ s += sprintf(s, "\t\t\t\tIsDRNoticeSupported\n");
+ if (mask & (1 << 22))
+ s += sprintf(s, "\t\t\t\tIsCapabilityMaskNoticeSupported\n");
+ if (mask & (1 << 23))
+ s += sprintf(s, "\t\t\t\tIsBootManagementSupported\n");
+ if (mask & (1 << 24))
+ s += sprintf(s, "\t\t\t\tIsLinkRoundTripLatencySupported\n");
+ if (mask & (1 << 25))
+ s += sprintf(s, "\t\t\t\tIsClientRegistrationSupported\n");
+ if (mask & (1 << 26))
+ s += sprintf(s, "\t\t\t\tIsOtherLocalChangesNoticeSupported\n");
+ if (mask & (1 << 27))
+ s += sprintf(s,
+ "\t\t\t\tIsLinkSpeedWidthPairsTableSupported\n");
+ if (mask & (1 << 28))
+ s += sprintf(s, "\t\t\t\tIsVendorSpecificMadsTableSupported\n");
+ if (mask & (1 << 29))
+ s += sprintf(s, "\t\t\t\tIsMcastPkeyTrapSuppressionSupported\n");
+ if (mask & (1 << 30))
+ s += sprintf(s, "\t\t\t\tIsMulticastFDBTopSupported\n");
+ if (mask & (1 << 31))
+ s += sprintf(s, "\t\t\t\tIsHierarchyInfoSupported\n");
+
+ if (s != buf)
+ *(--s) = 0;
+}
+
+void mad_dump_portcapmask2(char *buf, int bufsz, void *val, int valsz)
+{
+ int mask = *(int *)val;
+ char *s = buf;
+
+ s += sprintf(s, "0x%x\n", mask);
+ if (mask & (1 << 0))
+ s += sprintf(s, "\t\t\t\tIsSetNodeDescriptionSupported\n");
+ if (mask & (1 << 1))
+ s += sprintf(s, "\t\t\t\tIsPortInfoExtendedSupported\n");
+ if (mask & (1 << 2))
+ s += sprintf(s, "\t\t\t\tIsVirtualizationSupported\n");
+ if (mask & (1 << 3))
+ s += sprintf(s, "\t\t\t\tIsSwitchPortStateTableSupported\n");
+ if (mask & (1 << 4))
+ s += sprintf(s, "\t\t\t\tIsLinkWidth2xSupported\n");
+
+ if (s != buf)
+ *(--s) = 0;
+}
+
+void mad_dump_bitfield(char *buf, int bufsz, void *val, int valsz)
+{
+ snprintf(buf, bufsz, "0x%x", *(uint32_t *) val);
+}
+
+void mad_dump_array(char *buf, int bufsz, void *val, int valsz)
+{
+ uint8_t *p = val, *e;
+ char *s = buf;
+
+ if (bufsz < valsz * 2)
+ valsz = bufsz / 2;
+
+ for (p = val, e = p + valsz; p < e; p++, s += 2)
+ sprintf(s, "%02x", *p);
+}
+
+void mad_dump_string(char *buf, int bufsz, void *val, int valsz)
+{
+ if (bufsz < valsz)
+ valsz = bufsz;
+
+ snprintf(buf, valsz, "'%s'", (char *)val);
+}
+
+void mad_dump_node_type(char *buf, int bufsz, void *val, int valsz)
+{
+ int nodetype = *(int *)val;
+
+ switch (nodetype) {
+ case 1:
+ snprintf(buf, bufsz, "Channel Adapter");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Switch");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "Router");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)?", nodetype);
+ break;
+ }
+}
+
+#define IB_MAX_NUM_VLS 16
+#define IB_MAX_NUM_VLS_TO_U8 ((IB_MAX_NUM_VLS)/2)
+
+typedef struct _ib_slvl_table {
+ uint8_t vl_by_sl_num[IB_MAX_NUM_VLS_TO_U8];
+} ib_slvl_table_t;
+
+static inline void ib_slvl_get_i(ib_slvl_table_t * tbl, int i, uint8_t * vl)
+{
+ *vl = (tbl->vl_by_sl_num[i >> 1] >> ((!(i & 1)) << 2)) & 0xf;
+}
+
+#define IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK 32
+
+typedef struct _ib_vl_arb_table {
+ struct {
+ uint8_t res_vl;
+ uint8_t weight;
+ } vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK];
+} ib_vl_arb_table_t;
+
+static inline void ib_vl_arb_get_vl(uint8_t res_vl, uint8_t * const vl)
+{
+ *vl = res_vl & 0x0F;
+}
+
+void mad_dump_sltovl(char *buf, int bufsz, void *val, int valsz)
+{
+ ib_slvl_table_t *p_slvl_tbl = val;
+ uint8_t vl;
+ int i, n = 0;
+ n = snprintf(buf, bufsz, "|");
+ for (i = 0; i < 16; i++) {
+ ib_slvl_get_i(p_slvl_tbl, i, &vl);
+ n += snprintf(buf + n, bufsz - n, "%2u|", vl);
+ if (n >= bufsz)
+ break;
+ }
+ snprintf(buf + n, bufsz - n, "\n");
+}
+
+void mad_dump_vlarbitration(char *buf, int bufsz, void *val, int num)
+{
+ ib_vl_arb_table_t *p_vla_tbl = val;
+ int i, n;
+ uint8_t vl;
+
+ num /= sizeof(p_vla_tbl->vl_entry[0]);
+
+ n = snprintf(buf, bufsz, "\nVL : |");
+ if (n >= bufsz)
+ return;
+ for (i = 0; i < num; i++) {
+ ib_vl_arb_get_vl(p_vla_tbl->vl_entry[i].res_vl, &vl);
+ n += snprintf(buf + n, bufsz - n, "0x%-2X|", vl);
+ if (n >= bufsz)
+ return;
+ }
+
+ n += snprintf(buf + n, bufsz - n, "\nWEIGHT: |");
+ if (n >= bufsz)
+ return;
+ for (i = 0; i < num; i++) {
+ n += snprintf(buf + n, bufsz - n, "0x%-2X|",
+ p_vla_tbl->vl_entry[i].weight);
+ if (n >= bufsz)
+ return;
+ }
+
+ snprintf(buf + n, bufsz - n, "\n");
+}
+
+static int _dump_fields(char *buf, int bufsz, void *data, int start, int end)
+{
+ char val[64];
+ char *s = buf;
+ int n, field;
+
+ for (field = start; field < end && bufsz > 0; field++) {
+ mad_decode_field(data, field, val);
+ if (!mad_dump_field(field, s, bufsz-1, val))
+ return -1;
+ n = strlen(s);
+ s += n;
+ *s++ = '\n';
+ *s = 0;
+ n++;
+ bufsz -= n;
+ }
+
+ return (int)(s - buf);
+}
+
+void mad_dump_fields(char *buf, int bufsz, void *val, int valsz, int start,
+ int end)
+{
+ _dump_fields(buf, bufsz, val, start, end);
+}
+
+void mad_dump_nodedesc(char *buf, int bufsz, void *val, int valsz)
+{
+ strncpy(buf, val, bufsz);
+
+ if (valsz < bufsz)
+ buf[valsz] = 0;
+}
+
+void mad_dump_nodeinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_NODE_FIRST_F, IB_NODE_LAST_F);
+}
+
+void mad_dump_portinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PORT_FIRST_F, IB_PORT_LAST_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val,
+ IB_PORT_CAPMASK2_F, IB_PORT_LINK_SPEED_EXT_LAST_F);
+}
+
+void mad_dump_portstates(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PORT_STATE_F, IB_PORT_LINK_DOWN_DEF_F);
+}
+
+void mad_dump_switchinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_SW_FIRST_F, IB_SW_LAST_F);
+}
+
+void mad_dump_perfcounters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt, cnt2;
+
+ cnt = _dump_fields(buf, bufsz, val,
+ IB_PC_FIRST_F, IB_PC_VL15_DROPPED_F);
+ if (cnt < 0)
+ return;
+
+ cnt2 = _dump_fields(buf + cnt, bufsz - cnt, val,
+ IB_PC_QP1_DROP_F, IB_PC_QP1_DROP_F + 1);
+ if (cnt2 < 0)
+ return;
+
+ _dump_fields(buf + cnt + cnt2, bufsz - cnt - cnt2, val,
+ IB_PC_VL15_DROPPED_F, IB_PC_LAST_F);
+}
+
+void mad_dump_perfcounters_ext(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_FIRST_F, IB_PC_EXT_LAST_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val,
+ IB_PC_EXT_COUNTER_SELECT2_F, IB_PC_EXT_ERR_LAST_F);
+}
+
+void mad_dump_perfcounters_xmt_sl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_XMT_DATA_SL_FIRST_F,
+ IB_PC_XMT_DATA_SL_LAST_F);
+}
+
+void mad_dump_perfcounters_rcv_sl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_RCV_DATA_SL_FIRST_F,
+ IB_PC_RCV_DATA_SL_LAST_F);
+}
+
+void mad_dump_perfcounters_xmt_disc(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_XMT_INACT_DISC_F,
+ IB_PC_XMT_DISC_LAST_F);
+}
+
+void mad_dump_perfcounters_rcv_err(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_RCV_LOCAL_PHY_ERR_F,
+ IB_PC_RCV_ERR_LAST_F);
+}
+
+void mad_dump_portsamples_control(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PSC_OPCODE_F, IB_PSC_LAST_F);
+}
+
+void mad_dump_port_ext_speeds_counters_rsfec_active(char *buf, int bufsz,
+ void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PESC_RSFEC_PORT_SELECT_F,
+ IB_PESC_RSFEC_LAST_F);
+}
+
+void mad_dump_port_ext_speeds_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PESC_PORT_SELECT_F, IB_PESC_LAST_F);
+}
+
+void mad_dump_perfcounters_port_op_rcv_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_OP_RCV_COUNTERS_FIRST_F,
+ IB_PC_PORT_OP_RCV_COUNTERS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_flow_ctl_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_FLOW_CTL_COUNTERS_FIRST_F,
+ IB_PC_PORT_FLOW_CTL_COUNTERS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_op_packet(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_OP_PACKETS_FIRST_F,
+ IB_PC_PORT_VL_OP_PACKETS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_op_data(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_OP_DATA_FIRST_F,
+ IB_PC_PORT_VL_OP_DATA_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_xmit_flow_ctl_update_errors(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_xmit_wait_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_LAST_F);
+}
+
+void mad_dump_perfcounters_sw_port_vl_congestion(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_SW_PORT_VL_CONGESTION_FIRST_F,
+ IB_PC_SW_PORT_VL_CONGESTION_LAST_F);
+}
+
+void mad_dump_perfcounters_rcv_con_ctrl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_RCV_CON_CTRL_FIRST_F,
+ IB_PC_RCV_CON_CTRL_LAST_F);
+}
+
+
+void mad_dump_perfcounters_sl_rcv_fecn(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_SL_RCV_FECN_FIRST_F,
+ IB_PC_SL_RCV_FECN_LAST_F);
+}
+
+void mad_dump_perfcounters_sl_rcv_becn(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_SL_RCV_BECN_FIRST_F,
+ IB_PC_SL_RCV_BECN_LAST_F);
+}
+
+void mad_dump_perfcounters_xmit_con_ctrl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_XMIT_CON_CTRL_FIRST_F,
+ IB_PC_XMIT_CON_CTRL_LAST_F);
+}
+
+void mad_dump_perfcounters_vl_xmit_time_cong(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_VL_XMIT_TIME_CONG_FIRST_F,
+ IB_PC_VL_XMIT_TIME_CONG_LAST_F);
+}
+
+void mad_dump_mlnx_ext_port_info(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_MLNX_EXT_PORT_STATE_CHG_ENABLE_F,
+ IB_MLNX_EXT_PORT_LAST_F);
+}
+
+void mad_dump_portsamples_result(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PSR_TAG_F, IB_PSR_LAST_F);
+}
+
+void mad_dump_cc_congestioninfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_INFO_FIRST_F,
+ IB_CC_CONGESTION_INFO_LAST_F);
+}
+
+void mad_dump_cc_congestionkeyinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_KEY_INFO_FIRST_F,
+ IB_CC_CONGESTION_KEY_INFO_LAST_F);
+}
+
+void mad_dump_cc_congestionlog(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_FIRST_F,
+ IB_CC_CONGESTION_LOG_LAST_F);
+}
+
+void mad_dump_cc_congestionlogswitch(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_SWITCH_LAST_F);
+}
+
+void mad_dump_cc_congestionlogentryswitch(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_ENTRY_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_LAST_F);
+}
+
+void mad_dump_cc_congestionlogca(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_CA_LAST_F);
+}
+
+void mad_dump_cc_congestionlogentryca(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_ENTRY_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LAST_F);
+}
+
+void mad_dump_cc_switchcongestionsetting(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_SWITCH_CONGESTION_SETTING_FIRST_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_LAST_F);
+}
+
+void mad_dump_cc_switchportcongestionsettingelement(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_FIRST_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_LAST_F);
+}
+
+void mad_dump_cc_cacongestionsetting(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CA_CONGESTION_SETTING_FIRST_F,
+ IB_CC_CA_CONGESTION_SETTING_LAST_F);
+}
+
+void mad_dump_cc_cacongestionentry(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CA_CONGESTION_ENTRY_FIRST_F,
+ IB_CC_CA_CONGESTION_ENTRY_LAST_F);
+}
+
+void mad_dump_cc_congestioncontroltable(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_CONTROL_TABLE_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_LAST_F);
+}
+
+void mad_dump_cc_congestioncontroltableentry(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_LAST_F);
+}
+
+void mad_dump_cc_timestamp(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_TIMESTAMP_FIRST_F,
+ IB_CC_TIMESTAMP_LAST_F);
+}
+
+void mad_dump_classportinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ /* no FIRST_F and LAST_F for CPI field enums, must do a hack */
+ _dump_fields(buf, bufsz, val, IB_CPI_BASEVER_F, IB_CPI_TRAP_QKEY_F + 1);
+}
+
+void mad_dump_portmirror_route(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PMR_FIRST_F, IB_PMR_LAST_F);
+}
+
+void mad_dump_portmirror_filter(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PMF_FIRST_F, IB_PMF_LAST_F);
+}
+
+void mad_dump_portmirror_ports(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PMP_FIRST_F, IB_PMP_LAST_F);
+}
+
+void mad_dump_portinfo_ext(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PORT_EXT_CAPMASK_F,
+ IB_PORT_EXT_LAST_F);
+}
+
+void xdump(FILE * file, char *msg, void *p, int size)
+{
+#define HEX(x) ((x) < 10 ? '0' + (x) : 'a' + ((x) -10))
+ uint8_t *cp = p;
+ int i;
+
+ if (msg)
+ fputs(msg, file);
+
+ for (i = 0; i < size;) {
+ fputc(HEX(*cp >> 4), file);
+ fputc(HEX(*cp & 0xf), file);
+ if (++i >= size)
+ break;
+ fputc(HEX(cp[1] >> 4), file);
+ fputc(HEX(cp[1] & 0xf), file);
+ if ((++i) % 16)
+ fputc(' ', file);
+ else
+ fputc('\n', file);
+ cp += 2;
+ }
+ if (i % 16)
+ fputc('\n', file);
+}
diff --git a/contrib/ofed/libibmad/fields.c b/contrib/ofed/libibmad/fields.c
new file mode 100644
index 000000000000..45aa286377e2
--- /dev/null
+++ b/contrib/ofed/libibmad/fields.c
@@ -0,0 +1,1380 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009-2011 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/mad.h>
+
+/*
+ * BITSOFFS and BE_OFFS are required due the fact that the bit offsets are inconsistently
+ * encoded in the IB spec - IB headers are encoded such that the bit offsets
+ * are in big endian convention (BE_OFFS), while the SMI/GSI queries data fields bit
+ * offsets are specified using real bit offset (?!)
+ * The following macros normalize everything to big endian offsets.
+ */
+#define BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w)))), (w)
+#define BE_OFFS(o, w) (o), (w)
+#define BE_TO_BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w))))
+
+static const ib_field_t ib_mad_f[] = {
+ {0, 0}, /* IB_NO_FIELD - reserved as invalid */
+
+ {0, 64, "GidPrefix", mad_dump_rhex},
+ {64, 64, "GidGuid", mad_dump_rhex},
+
+ /*
+ * MAD: common MAD fields (IB spec 13.4.2)
+ * SMP: Subnet Management packets - lid routed (IB spec 14.2.1.1)
+ * DSMP: Subnet Management packets - direct route (IB spec 14.2.1.2)
+ * SA: Subnet Administration packets (IB spec 15.2.1.1)
+ */
+
+ /* first MAD word (0-3 bytes) */
+ {BE_OFFS(0, 7), "MadMethod", mad_dump_hex}, /* TODO: add dumper */
+ {BE_OFFS(7, 1), "MadIsResponse", mad_dump_uint}, /* TODO: add dumper */
+ {BE_OFFS(8, 8), "MadClassVersion", mad_dump_uint},
+ {BE_OFFS(16, 8), "MadMgmtClass", mad_dump_uint}, /* TODO: add dumper */
+ {BE_OFFS(24, 8), "MadBaseVersion", mad_dump_uint},
+
+ /* second MAD word (4-7 bytes) */
+ {BE_OFFS(48, 16), "MadStatus", mad_dump_hex}, /* TODO: add dumper */
+
+ /* DR SMP only */
+ {BE_OFFS(32, 8), "DrSmpHopCnt", mad_dump_uint},
+ {BE_OFFS(40, 8), "DrSmpHopPtr", mad_dump_uint},
+ {BE_OFFS(48, 15), "DrSmpStatus", mad_dump_hex}, /* TODO: add dumper */
+ {BE_OFFS(63, 1), "DrSmpDirection", mad_dump_uint}, /* TODO: add dumper */
+
+ /* words 3,4,5,6 (8-23 bytes) */
+ {64, 64, "MadTRID", mad_dump_hex},
+ {BE_OFFS(144, 16), "MadAttr", mad_dump_hex}, /* TODO: add dumper */
+ {160, 32, "MadModifier", mad_dump_hex}, /* TODO: add dumper */
+
+ /* word 7,8 (24-31 bytes) */
+ {192, 64, "MadMkey", mad_dump_hex},
+
+ /* word 9 (32-37 bytes) */
+ {BE_OFFS(256, 16), "DrSmpDLID", mad_dump_uint},
+ {BE_OFFS(272, 16), "DrSmpSLID", mad_dump_uint},
+
+ /* word 10,11 (36-43 bytes) */
+ {288, 64, "SaSMkey", mad_dump_hex},
+
+ /* word 12 (44-47 bytes) */
+ {BE_OFFS(46 * 8, 16), "SaAttrOffs", mad_dump_uint},
+
+ /* word 13,14 (48-55 bytes) */
+ {48 * 8, 64, "SaCompMask", mad_dump_hex},
+
+ /* word 13,14 (56-255 bytes) */
+ {56 * 8, (256 - 56) * 8, "SaData", mad_dump_hex},
+
+ /* bytes 64 - 127 */
+ {0, 0}, /* IB_SM_DATA_F - reserved as invalid */
+
+ /* bytes 64 - 256 */
+ {64 * 8, (256 - 64) * 8, "GsData", mad_dump_hex},
+
+ /* bytes 128 - 191 */
+ {1024, 512, "DrSmpPath", mad_dump_hex},
+
+ /* bytes 192 - 255 */
+ {1536, 512, "DrSmpRetPath", mad_dump_hex},
+
+ /*
+ * PortInfo fields
+ */
+ {0, 64, "Mkey", mad_dump_hex},
+ {64, 64, "GidPrefix", mad_dump_hex},
+ {BITSOFFS(128, 16), "Lid", mad_dump_uint},
+ {BITSOFFS(144, 16), "SMLid", mad_dump_uint},
+ {160, 32, "CapMask", mad_dump_portcapmask},
+ {BITSOFFS(192, 16), "DiagCode", mad_dump_hex},
+ {BITSOFFS(208, 16), "MkeyLeasePeriod", mad_dump_uint},
+ {BITSOFFS(224, 8), "LocalPort", mad_dump_uint},
+ {BITSOFFS(232, 8), "LinkWidthEnabled", mad_dump_linkwidthen},
+ {BITSOFFS(240, 8), "LinkWidthSupported", mad_dump_linkwidthsup},
+ {BITSOFFS(248, 8), "LinkWidthActive", mad_dump_linkwidth},
+ {BITSOFFS(256, 4), "LinkSpeedSupported", mad_dump_linkspeedsup},
+ {BITSOFFS(260, 4), "LinkState", mad_dump_portstate},
+ {BITSOFFS(264, 4), "PhysLinkState", mad_dump_physportstate},
+ {BITSOFFS(268, 4), "LinkDownDefState", mad_dump_linkdowndefstate},
+ {BITSOFFS(272, 2), "ProtectBits", mad_dump_uint},
+ {BITSOFFS(277, 3), "LMC", mad_dump_uint},
+ {BITSOFFS(280, 4), "LinkSpeedActive", mad_dump_linkspeed},
+ {BITSOFFS(284, 4), "LinkSpeedEnabled", mad_dump_linkspeeden},
+ {BITSOFFS(288, 4), "NeighborMTU", mad_dump_mtu},
+ {BITSOFFS(292, 4), "SMSL", mad_dump_uint},
+ {BITSOFFS(296, 4), "VLCap", mad_dump_vlcap},
+ {BITSOFFS(300, 4), "InitType", mad_dump_hex},
+ {BITSOFFS(304, 8), "VLHighLimit", mad_dump_uint},
+ {BITSOFFS(312, 8), "VLArbHighCap", mad_dump_uint},
+ {BITSOFFS(320, 8), "VLArbLowCap", mad_dump_uint},
+ {BITSOFFS(328, 4), "InitReply", mad_dump_hex},
+ {BITSOFFS(332, 4), "MtuCap", mad_dump_mtu},
+ {BITSOFFS(336, 3), "VLStallCount", mad_dump_uint},
+ {BITSOFFS(339, 5), "HoqLife", mad_dump_uint},
+ {BITSOFFS(344, 4), "OperVLs", mad_dump_opervls},
+ {BITSOFFS(348, 1), "PartEnforceInb", mad_dump_uint},
+ {BITSOFFS(349, 1), "PartEnforceOutb", mad_dump_uint},
+ {BITSOFFS(350, 1), "FilterRawInb", mad_dump_uint},
+ {BITSOFFS(351, 1), "FilterRawOutb", mad_dump_uint},
+ {BITSOFFS(352, 16), "MkeyViolations", mad_dump_uint},
+ {BITSOFFS(368, 16), "PkeyViolations", mad_dump_uint},
+ {BITSOFFS(384, 16), "QkeyViolations", mad_dump_uint},
+ {BITSOFFS(400, 8), "GuidCap", mad_dump_uint},
+ {BITSOFFS(408, 1), "ClientReregister", mad_dump_uint},
+ {BITSOFFS(409, 1), "McastPkeyTrapSuppressionEnabled", mad_dump_uint},
+ {BITSOFFS(411, 5), "SubnetTimeout", mad_dump_uint},
+ {BITSOFFS(419, 5), "RespTimeVal", mad_dump_uint},
+ {BITSOFFS(424, 4), "LocalPhysErr", mad_dump_uint},
+ {BITSOFFS(428, 4), "OverrunErr", mad_dump_uint},
+ {BITSOFFS(432, 16), "MaxCreditHint", mad_dump_uint},
+ {BITSOFFS(456, 24), "RoundTrip", mad_dump_uint},
+ {0, 0}, /* IB_PORT_LAST_F */
+
+ /*
+ * NodeInfo fields
+ */
+ {BITSOFFS(0, 8), "BaseVers", mad_dump_uint},
+ {BITSOFFS(8, 8), "ClassVers", mad_dump_uint},
+ {BITSOFFS(16, 8), "NodeType", mad_dump_node_type},
+ {BITSOFFS(24, 8), "NumPorts", mad_dump_uint},
+ {32, 64, "SystemGuid", mad_dump_hex},
+ {96, 64, "Guid", mad_dump_hex},
+ {160, 64, "PortGuid", mad_dump_hex},
+ {BITSOFFS(224, 16), "PartCap", mad_dump_uint},
+ {BITSOFFS(240, 16), "DevId", mad_dump_hex},
+ {256, 32, "Revision", mad_dump_hex},
+ {BITSOFFS(288, 8), "LocalPort", mad_dump_uint},
+ {BITSOFFS(296, 24), "VendorId", mad_dump_hex},
+ {0, 0}, /* IB_NODE_LAST_F */
+
+ /*
+ * SwitchInfo fields
+ */
+ {BITSOFFS(0, 16), "LinearFdbCap", mad_dump_uint},
+ {BITSOFFS(16, 16), "RandomFdbCap", mad_dump_uint},
+ {BITSOFFS(32, 16), "McastFdbCap", mad_dump_uint},
+ {BITSOFFS(48, 16), "LinearFdbTop", mad_dump_uint},
+ {BITSOFFS(64, 8), "DefPort", mad_dump_uint},
+ {BITSOFFS(72, 8), "DefMcastPrimPort", mad_dump_uint},
+ {BITSOFFS(80, 8), "DefMcastNotPrimPort", mad_dump_uint},
+ {BITSOFFS(88, 5), "LifeTime", mad_dump_uint},
+ {BITSOFFS(93, 1), "StateChange", mad_dump_uint},
+ {BITSOFFS(94, 2), "OptSLtoVLMapping", mad_dump_uint},
+ {BITSOFFS(96, 16), "LidsPerPort", mad_dump_uint},
+ {BITSOFFS(112, 16), "PartEnforceCap", mad_dump_uint},
+ {BITSOFFS(128, 1), "InboundPartEnf", mad_dump_uint},
+ {BITSOFFS(129, 1), "OutboundPartEnf", mad_dump_uint},
+ {BITSOFFS(130, 1), "FilterRawInbound", mad_dump_uint},
+ {BITSOFFS(131, 1), "FilterRawOutbound", mad_dump_uint},
+ {BITSOFFS(132, 1), "EnhancedPort0", mad_dump_uint},
+ {BITSOFFS(144, 16), "MulticastFDBTop", mad_dump_hex},
+ {0, 0}, /* IB_SW_LAST_F */
+
+ /*
+ * SwitchLinearForwardingTable fields
+ */
+ {0, 512, "LinearForwTbl", mad_dump_array},
+
+ /*
+ * SwitchMulticastForwardingTable fields
+ */
+ {0, 512, "MulticastForwTbl", mad_dump_array},
+
+ /*
+ * NodeDescription fields
+ */
+ {0, 64 * 8, "NodeDesc", mad_dump_string},
+
+ /*
+ * Notice/Trap fields
+ */
+ {BITSOFFS(0, 1), "NoticeIsGeneric", mad_dump_uint},
+ {BITSOFFS(1, 7), "NoticeType", mad_dump_uint},
+ {BITSOFFS(8, 24), "NoticeProducerType", mad_dump_node_type},
+ {BITSOFFS(32, 16), "NoticeTrapNumber", mad_dump_uint},
+ {BITSOFFS(48, 16), "NoticeIssuerLID", mad_dump_uint},
+ {BITSOFFS(64, 1), "NoticeToggle", mad_dump_uint},
+ {BITSOFFS(65, 15), "NoticeCount", mad_dump_uint},
+ {80, 432, "NoticeDataDetails", mad_dump_array},
+ {BITSOFFS(80, 16), "NoticeDataLID", mad_dump_uint},
+ {BITSOFFS(96, 16), "NoticeDataTrap144LID", mad_dump_uint},
+ {BITSOFFS(128, 32), "NoticeDataTrap144CapMask", mad_dump_uint},
+
+ /*
+ * Port counters
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex},
+ {BITSOFFS(32, 16), "SymbolErrorCounter", mad_dump_uint},
+ {BITSOFFS(48, 8), "LinkErrorRecoveryCounter", mad_dump_uint},
+ {BITSOFFS(56, 8), "LinkDownedCounter", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortRcvErrors", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortRcvRemotePhysicalErrors", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortRcvSwitchRelayErrors", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortXmitDiscards", mad_dump_uint},
+ {BITSOFFS(128, 8), "PortXmitConstraintErrors", mad_dump_uint},
+ {BITSOFFS(136, 8), "PortRcvConstraintErrors", mad_dump_uint},
+ {BITSOFFS(144, 8), "CounterSelect2", mad_dump_hex},
+ {BITSOFFS(152, 4), "LocalLinkIntegrityErrors", mad_dump_uint},
+ {BITSOFFS(156, 4), "ExcessiveBufferOverrunErrors", mad_dump_uint},
+ {BITSOFFS(176, 16), "VL15Dropped", mad_dump_uint},
+ {192, 32, "PortXmitData", mad_dump_uint},
+ {224, 32, "PortRcvData", mad_dump_uint},
+ {256, 32, "PortXmitPkts", mad_dump_uint},
+ {288, 32, "PortRcvPkts", mad_dump_uint},
+ {320, 32, "PortXmitWait", mad_dump_uint},
+ {0, 0}, /* IB_PC_LAST_F */
+
+ /*
+ * SMInfo
+ */
+ {0, 64, "SmInfoGuid", mad_dump_hex},
+ {64, 64, "SmInfoKey", mad_dump_hex},
+ {128, 32, "SmActivity", mad_dump_uint},
+ {BITSOFFS(160, 4), "SmPriority", mad_dump_uint},
+ {BITSOFFS(164, 4), "SmState", mad_dump_uint},
+
+ /*
+ * SA RMPP
+ */
+ {BE_OFFS(24 * 8 + 24, 8), "RmppVers", mad_dump_uint},
+ {BE_OFFS(24 * 8 + 16, 8), "RmppType", mad_dump_uint},
+ {BE_OFFS(24 * 8 + 11, 5), "RmppResp", mad_dump_uint},
+ {BE_OFFS(24 * 8 + 8, 3), "RmppFlags", mad_dump_hex},
+ {BE_OFFS(24 * 8 + 0, 8), "RmppStatus", mad_dump_hex},
+
+ /* data1 */
+ {28 * 8, 32, "RmppData1", mad_dump_hex},
+ {28 * 8, 32, "RmppSegNum", mad_dump_uint},
+ /* data2 */
+ {32 * 8, 32, "RmppData2", mad_dump_hex},
+ {32 * 8, 32, "RmppPayload", mad_dump_uint},
+ {32 * 8, 32, "RmppNewWin", mad_dump_uint},
+
+ /*
+ * SA Get Multi Path
+ */
+ {BITSOFFS(41, 7), "MultiPathNumPath", mad_dump_uint},
+ {BITSOFFS(120, 8), "MultiPathNumSrc", mad_dump_uint},
+ {BITSOFFS(128, 8), "MultiPathNumDest", mad_dump_uint},
+ {192, 128, "MultiPathGid", mad_dump_array},
+
+ /*
+ * SA Path rec
+ */
+ {64, 128, "PathRecDGid", mad_dump_array},
+ {192, 128, "PathRecSGid", mad_dump_array},
+ {BITSOFFS(320, 16), "PathRecDLid", mad_dump_uint},
+ {BITSOFFS(336, 16), "PathRecSLid", mad_dump_uint},
+ {BITSOFFS(393, 7), "PathRecNumPath", mad_dump_uint},
+ {BITSOFFS(428, 4), "PathRecSL", mad_dump_uint},
+
+ /*
+ * MC Member rec
+ */
+ {0, 128, "McastMemMGid", mad_dump_array},
+ {128, 128, "McastMemPortGid", mad_dump_array},
+ {256, 32, "McastMemQkey", mad_dump_hex},
+ {BITSOFFS(288, 16), "McastMemMLid", mad_dump_hex},
+ {BITSOFFS(352, 4), "McastMemSL", mad_dump_uint},
+ {BITSOFFS(306, 6), "McastMemMTU", mad_dump_uint},
+ {BITSOFFS(338, 6), "McastMemRate", mad_dump_uint},
+ {BITSOFFS(312, 8), "McastMemTClass", mad_dump_uint},
+ {BITSOFFS(320, 16), "McastMemPkey", mad_dump_uint},
+ {BITSOFFS(356, 20), "McastMemFlowLbl", mad_dump_uint},
+ {BITSOFFS(388, 4), "McastMemJoinState", mad_dump_uint},
+ {BITSOFFS(392, 1), "McastMemProxyJoin", mad_dump_uint},
+
+ /*
+ * Service record
+ */
+ {0, 64, "ServRecID", mad_dump_hex},
+ {64, 128, "ServRecGid", mad_dump_array},
+ {BITSOFFS(192, 16), "ServRecPkey", mad_dump_hex},
+ {224, 32, "ServRecLease", mad_dump_hex},
+ {256, 128, "ServRecKey", mad_dump_hex},
+ {384, 512, "ServRecName", mad_dump_string},
+ {896, 512, "ServRecData", mad_dump_array}, /* ATS for example */
+
+ /*
+ * ATS SM record - within SA_SR_DATA
+ */
+ {12 * 8, 32, "ATSNodeAddr", mad_dump_hex},
+ {BITSOFFS(16 * 8, 16), "ATSMagicKey", mad_dump_hex},
+ {BITSOFFS(18 * 8, 16), "ATSNodeType", mad_dump_hex},
+ {32 * 8, 32 * 8, "ATSNodeName", mad_dump_string},
+
+ /*
+ * SLTOVL MAPPING TABLE
+ */
+ {0, 64, "SLToVLMap", mad_dump_hex},
+
+ /*
+ * VL ARBITRATION TABLE
+ */
+ {0, 512, "VLArbTbl", mad_dump_array},
+
+ /*
+ * IB vendor classes range 2
+ */
+ {BE_OFFS(36 * 8, 24), "OUI", mad_dump_array},
+ {40 * 8, (256 - 40) * 8, "Vendor2Data", mad_dump_array},
+
+ /*
+ * Extended port counters
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex},
+ {64, 64, "PortXmitData", mad_dump_uint},
+ {128, 64, "PortRcvData", mad_dump_uint},
+ {192, 64, "PortXmitPkts", mad_dump_uint},
+ {256, 64, "PortRcvPkts", mad_dump_uint},
+ {320, 64, "PortUnicastXmitPkts", mad_dump_uint},
+ {384, 64, "PortUnicastRcvPkts", mad_dump_uint},
+ {448, 64, "PortMulticastXmitPkts", mad_dump_uint},
+ {512, 64, "PortMulticastRcvPkts", mad_dump_uint},
+ {0, 0}, /* IB_PC_EXT_LAST_F */
+
+ /*
+ * GUIDInfo fields
+ */
+ {0, 64, "GUID0", mad_dump_hex},
+
+ /*
+ * ClassPortInfo fields
+ */
+ {BITSOFFS(0, 8), "BaseVersion", mad_dump_uint},
+ {BITSOFFS(8, 8), "ClassVersion", mad_dump_uint},
+ {BITSOFFS(16, 16), "CapabilityMask", mad_dump_hex},
+ {BITSOFFS(32, 27), "CapabilityMask2", mad_dump_hex},
+ {BITSOFFS(59, 5), "RespTimeVal", mad_dump_uint},
+ {64, 128, "RedirectGID", mad_dump_array},
+ {BITSOFFS(192, 8), "RedirectTC", mad_dump_hex},
+ {BITSOFFS(200, 4), "RedirectSL", mad_dump_uint},
+ {BITSOFFS(204, 20), "RedirectFL", mad_dump_hex},
+ {BITSOFFS(224, 16), "RedirectLID", mad_dump_uint},
+ {BITSOFFS(240, 16), "RedirectPKey", mad_dump_hex},
+ {BITSOFFS(264, 24), "RedirectQP", mad_dump_hex},
+ {288, 32, "RedirectQKey", mad_dump_hex},
+ {320, 128, "TrapGID", mad_dump_array},
+ {BITSOFFS(448, 8), "TrapTC", mad_dump_hex},
+ {BITSOFFS(456, 4), "TrapSL", mad_dump_uint},
+ {BITSOFFS(460, 20), "TrapFL", mad_dump_hex},
+ {BITSOFFS(480, 16), "TrapLID", mad_dump_uint},
+ {BITSOFFS(496, 16), "TrapPKey", mad_dump_hex},
+ {BITSOFFS(512, 8), "TrapHL", mad_dump_uint},
+ {BITSOFFS(520, 24), "TrapQP", mad_dump_hex},
+ {544, 32, "TrapQKey", mad_dump_hex},
+
+ /*
+ * PortXmitDataSL fields
+ */
+ {32, 32, "XmtDataSL0", mad_dump_uint},
+ {64, 32, "XmtDataSL1", mad_dump_uint},
+ {96, 32, "XmtDataSL2", mad_dump_uint},
+ {128, 32, "XmtDataSL3", mad_dump_uint},
+ {160, 32, "XmtDataSL4", mad_dump_uint},
+ {192, 32, "XmtDataSL5", mad_dump_uint},
+ {224, 32, "XmtDataSL6", mad_dump_uint},
+ {256, 32, "XmtDataSL7", mad_dump_uint},
+ {288, 32, "XmtDataSL8", mad_dump_uint},
+ {320, 32, "XmtDataSL9", mad_dump_uint},
+ {352, 32, "XmtDataSL10", mad_dump_uint},
+ {384, 32, "XmtDataSL11", mad_dump_uint},
+ {416, 32, "XmtDataSL12", mad_dump_uint},
+ {448, 32, "XmtDataSL13", mad_dump_uint},
+ {480, 32, "XmtDataSL14", mad_dump_uint},
+ {512, 32, "XmtDataSL15", mad_dump_uint},
+ {0, 0}, /* IB_PC_XMT_DATA_SL_LAST_F */
+
+ /*
+ * PortRcvDataSL fields
+ */
+ {32, 32, "RcvDataSL0", mad_dump_uint},
+ {64, 32, "RcvDataSL1", mad_dump_uint},
+ {96, 32, "RcvDataSL2", mad_dump_uint},
+ {128, 32, "RcvDataSL3", mad_dump_uint},
+ {160, 32, "RcvDataSL4", mad_dump_uint},
+ {192, 32, "RcvDataSL5", mad_dump_uint},
+ {224, 32, "RcvDataSL6", mad_dump_uint},
+ {256, 32, "RcvDataSL7", mad_dump_uint},
+ {288, 32, "RcvDataSL8", mad_dump_uint},
+ {320, 32, "RcvDataSL9", mad_dump_uint},
+ {352, 32, "RcvDataSL10", mad_dump_uint},
+ {384, 32, "RcvDataSL11", mad_dump_uint},
+ {416, 32, "RcvDataSL12", mad_dump_uint},
+ {448, 32, "RcvDataSL13", mad_dump_uint},
+ {480, 32, "RcvDataSL14", mad_dump_uint},
+ {512, 32, "RcvDataSL15", mad_dump_uint},
+ {0, 0}, /* IB_PC_RCV_DATA_SL_LAST_F */
+
+ /*
+ * PortXmitDiscardDetails fields
+ */
+ {BITSOFFS(32, 16), "PortInactiveDiscards", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortNeighborMTUDiscards", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortSwLifetimeLimitDiscards", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortSwHOQLifetimeLimitDiscards", mad_dump_uint},
+ {0, 0}, /* IB_PC_XMT_DISC_LAST_F */
+
+ /*
+ * PortRcvErrorDetails fields
+ */
+ {BITSOFFS(32, 16), "PortLocalPhysicalErrors", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortMalformedPktErrors", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortBufferOverrunErrors", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortDLIDMappingErrors", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortVLMappingErrors", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortLoopingErrors", mad_dump_uint},
+ {0, 0}, /* IB_PC_RCV_ERR_LAST_F */
+
+ /*
+ * PortSamplesControl fields
+ */
+ {BITSOFFS(0, 8), "OpCode", mad_dump_hex},
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {BITSOFFS(16, 8), "Tick", mad_dump_hex},
+ {BITSOFFS(29, 3), "CounterWidth", mad_dump_uint},
+ {BITSOFFS(34, 3), "CounterMask0", mad_dump_hex},
+ {BITSOFFS(37, 27), "CounterMasks1to9", mad_dump_hex},
+ {BITSOFFS(65, 15), "CounterMasks10to14", mad_dump_hex},
+ {BITSOFFS(80, 8), "SampleMechanisms", mad_dump_uint},
+ {BITSOFFS(94, 2), "SampleStatus", mad_dump_uint},
+ {96, 64, "OptionMask", mad_dump_hex},
+ {160, 64, "VendorMask", mad_dump_hex},
+ {224, 32, "SampleStart", mad_dump_uint},
+ {256, 32, "SampleInterval", mad_dump_uint},
+ {BITSOFFS(288, 16), "Tag", mad_dump_hex},
+ {BITSOFFS(304, 16), "CounterSelect0", mad_dump_hex},
+ {BITSOFFS(320, 16), "CounterSelect1", mad_dump_hex},
+ {BITSOFFS(336, 16), "CounterSelect2", mad_dump_hex},
+ {BITSOFFS(352, 16), "CounterSelect3", mad_dump_hex},
+ {BITSOFFS(368, 16), "CounterSelect4", mad_dump_hex},
+ {BITSOFFS(384, 16), "CounterSelect5", mad_dump_hex},
+ {BITSOFFS(400, 16), "CounterSelect6", mad_dump_hex},
+ {BITSOFFS(416, 16), "CounterSelect7", mad_dump_hex},
+ {BITSOFFS(432, 16), "CounterSelect8", mad_dump_hex},
+ {BITSOFFS(448, 16), "CounterSelect9", mad_dump_hex},
+ {BITSOFFS(464, 16), "CounterSelect10", mad_dump_hex},
+ {BITSOFFS(480, 16), "CounterSelect11", mad_dump_hex},
+ {BITSOFFS(496, 16), "CounterSelect12", mad_dump_hex},
+ {BITSOFFS(512, 16), "CounterSelect13", mad_dump_hex},
+ {BITSOFFS(528, 16), "CounterSelect14", mad_dump_hex},
+ {576, 64, "SamplesOnlyOptionMask", mad_dump_hex},
+ {0, 0}, /* IB_PSC_LAST_F */
+
+ /* GUIDInfo fields */
+ {0, 64, "GUID0", mad_dump_hex},
+ {64, 64, "GUID1", mad_dump_hex},
+ {128, 64, "GUID2", mad_dump_hex},
+ {192, 64, "GUID3", mad_dump_hex},
+ {256, 64, "GUID4", mad_dump_hex},
+ {320, 64, "GUID5", mad_dump_hex},
+ {384, 64, "GUID6", mad_dump_hex},
+ {448, 64, "GUID7", mad_dump_hex},
+
+ /* GUID Info Record */
+ {BITSOFFS(0, 16), "Lid", mad_dump_uint},
+ {BITSOFFS(16, 8), "BlockNum", mad_dump_uint},
+ {64, 64, "Guid0", mad_dump_hex},
+ {128, 64, "Guid1", mad_dump_hex},
+ {192, 64, "Guid2", mad_dump_hex},
+ {256, 64, "Guid3", mad_dump_hex},
+ {320, 64, "Guid4", mad_dump_hex},
+ {384, 64, "Guid5", mad_dump_hex},
+ {448, 64, "Guid6", mad_dump_hex},
+ {512, 64, "Guid7", mad_dump_hex},
+
+ /*
+ * More PortInfo fields
+ */
+ {BITSOFFS(480, 16), "CapabilityMask2", mad_dump_portcapmask2},
+ {BITSOFFS(496, 4), "LinkSpeedExtActive", mad_dump_linkspeedext},
+ {BITSOFFS(500, 4), "LinkSpeedExtSupported", mad_dump_linkspeedextsup},
+ {BITSOFFS(507, 5), "LinkSpeedExtEnabled", mad_dump_linkspeedexten},
+ {0, 0}, /* IB_PORT_LINK_SPEED_EXT_LAST_F */
+
+ /*
+ * PortExtendedSpeedsCounters fields
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {64, 64, "CounterSelect", mad_dump_hex},
+ {BITSOFFS(128, 16), "SyncHeaderErrorCounter", mad_dump_uint},
+ {BITSOFFS(144, 16), "UnknownBlockCounter", mad_dump_uint},
+ {BITSOFFS(160, 16), "ErrorDetectionCounterLane0", mad_dump_uint},
+ {BITSOFFS(176, 16), "ErrorDetectionCounterLane1", mad_dump_uint},
+ {BITSOFFS(192, 16), "ErrorDetectionCounterLane2", mad_dump_uint},
+ {BITSOFFS(208, 16), "ErrorDetectionCounterLane3", mad_dump_uint},
+ {BITSOFFS(224, 16), "ErrorDetectionCounterLane4", mad_dump_uint},
+ {BITSOFFS(240, 16), "ErrorDetectionCounterLane5", mad_dump_uint},
+ {BITSOFFS(256, 16), "ErrorDetectionCounterLane6", mad_dump_uint},
+ {BITSOFFS(272, 16), "ErrorDetectionCounterLane7", mad_dump_uint},
+ {BITSOFFS(288, 16), "ErrorDetectionCounterLane8", mad_dump_uint},
+ {BITSOFFS(304, 16), "ErrorDetectionCounterLane9", mad_dump_uint},
+ {BITSOFFS(320, 16), "ErrorDetectionCounterLane10", mad_dump_uint},
+ {BITSOFFS(336, 16), "ErrorDetectionCounterLane11", mad_dump_uint},
+ {352, 32, "FECCorrectableBlockCtrLane0", mad_dump_uint},
+ {384, 32, "FECCorrectableBlockCtrLane1", mad_dump_uint},
+ {416, 32, "FECCorrectableBlockCtrLane2", mad_dump_uint},
+ {448, 32, "FECCorrectableBlockCtrLane3", mad_dump_uint},
+ {480, 32, "FECCorrectableBlockCtrLane4", mad_dump_uint},
+ {512, 32, "FECCorrectableBlockCtrLane5", mad_dump_uint},
+ {544, 32, "FECCorrectableBlockCtrLane6", mad_dump_uint},
+ {576, 32, "FECCorrectableBlockCtrLane7", mad_dump_uint},
+ {608, 32, "FECCorrectableBlockCtrLane8", mad_dump_uint},
+ {640, 32, "FECCorrectableBlockCtrLane9", mad_dump_uint},
+ {672, 32, "FECCorrectableBlockCtrLane10", mad_dump_uint},
+ {704, 32, "FECCorrectableBlockCtrLane11", mad_dump_uint},
+ {736, 32, "FECUncorrectableBlockCtrLane0", mad_dump_uint},
+ {768, 32, "FECUncorrectableBlockCtrLane1", mad_dump_uint},
+ {800, 32, "FECUncorrectableBlockCtrLane2", mad_dump_uint},
+ {832, 32, "FECUncorrectableBlockCtrLane3", mad_dump_uint},
+ {864, 32, "FECUncorrectableBlockCtrLane4", mad_dump_uint},
+ {896, 32, "FECUncorrectableBlockCtrLane5", mad_dump_uint},
+ {928, 32, "FECUncorrectableBlockCtrLane6", mad_dump_uint},
+ {960, 32, "FECUncorrectableBlockCtrLane7", mad_dump_uint},
+ {992, 32, "FECUncorrectableBlockCtrLane8", mad_dump_uint},
+ {1024, 32, "FECUncorrectableBlockCtrLane9", mad_dump_uint},
+ {1056, 32, "FECUncorrectableBlockCtrLane10", mad_dump_uint},
+ {1088, 32, "FECUncorrectableBlockCtrLane11", mad_dump_uint},
+ {0, 0}, /* IB_PESC_LAST_F */
+
+
+
+ /*
+ * PortOpRcvCounters fields
+ */
+ {32, 32, "PortOpRcvPkts", mad_dump_uint},
+ {64, 32, "PortOpRcvData", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_OP_RCV_COUNTERS_LAST_F */
+
+ /*
+ * PortFlowCtlCounters fields
+ */
+ {32, 32, "PortXmitFlowPkts", mad_dump_uint},
+ {64, 32, "PortRcvFlowPkts", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_FLOW_CTL_COUNTERS_LAST_F */
+
+ /*
+ * PortVLOpPackets fields
+ */
+ {BITSOFFS(32, 16), "PortVLOpPackets0", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortVLOpPackets1", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortVLOpPackets2", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortVLOpPackets3", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortVLOpPackets4", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortVLOpPackets5", mad_dump_uint},
+ {BITSOFFS(128, 16), "PortVLOpPackets6", mad_dump_uint},
+ {BITSOFFS(144, 16), "PortVLOpPackets7", mad_dump_uint},
+ {BITSOFFS(160, 16), "PortVLOpPackets8", mad_dump_uint},
+ {BITSOFFS(176, 16), "PortVLOpPackets9", mad_dump_uint},
+ {BITSOFFS(192, 16), "PortVLOpPackets10", mad_dump_uint},
+ {BITSOFFS(208, 16), "PortVLOpPackets11", mad_dump_uint},
+ {BITSOFFS(224, 16), "PortVLOpPackets12", mad_dump_uint},
+ {BITSOFFS(240, 16), "PortVLOpPackets13", mad_dump_uint},
+ {BITSOFFS(256, 16), "PortVLOpPackets14", mad_dump_uint},
+ {BITSOFFS(272, 16), "PortVLOpPackets15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_OP_PACKETS_LAST_F */
+
+ /*
+ * PortVLOpData fields
+ */
+ {32, 32, "PortVLOpData0", mad_dump_uint},
+ {64, 32, "PortVLOpData1", mad_dump_uint},
+ {96, 32, "PortVLOpData2", mad_dump_uint},
+ {128, 32, "PortVLOpData3", mad_dump_uint},
+ {160, 32, "PortVLOpData4", mad_dump_uint},
+ {192, 32, "PortVLOpData5", mad_dump_uint},
+ {224, 32, "PortVLOpData6", mad_dump_uint},
+ {256, 32, "PortVLOpData7", mad_dump_uint},
+ {288, 32, "PortVLOpData8", mad_dump_uint},
+ {320, 32, "PortVLOpData9", mad_dump_uint},
+ {352, 32, "PortVLOpData10", mad_dump_uint},
+ {384, 32, "PortVLOpData11", mad_dump_uint},
+ {416, 32, "PortVLOpData12", mad_dump_uint},
+ {448, 32, "PortVLOpData13", mad_dump_uint},
+ {480, 32, "PortVLOpData14", mad_dump_uint},
+ {512, 32, "PortVLOpData15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_OP_DATA_LAST_F */
+
+ /*
+ * PortVLXmitFlowCtlUpdateErrors fields
+ */
+ {BITSOFFS(32, 2), "PortVLXmitFlowCtlUpdateErrors0", mad_dump_uint},
+ {BITSOFFS(34, 2), "PortVLXmitFlowCtlUpdateErrors1", mad_dump_uint},
+ {BITSOFFS(36, 2), "PortVLXmitFlowCtlUpdateErrors2", mad_dump_uint},
+ {BITSOFFS(38, 2), "PortVLXmitFlowCtlUpdateErrors3", mad_dump_uint},
+ {BITSOFFS(40, 2), "PortVLXmitFlowCtlUpdateErrors4", mad_dump_uint},
+ {BITSOFFS(42, 2), "PortVLXmitFlowCtlUpdateErrors5", mad_dump_uint},
+ {BITSOFFS(44, 2), "PortVLXmitFlowCtlUpdateErrors6", mad_dump_uint},
+ {BITSOFFS(46, 2), "PortVLXmitFlowCtlUpdateErrors7", mad_dump_uint},
+ {BITSOFFS(48, 2), "PortVLXmitFlowCtlUpdateErrors8", mad_dump_uint},
+ {BITSOFFS(50, 2), "PortVLXmitFlowCtlUpdateErrors9", mad_dump_uint},
+ {BITSOFFS(52, 2), "PortVLXmitFlowCtlUpdateErrors10", mad_dump_uint},
+ {BITSOFFS(54, 2), "PortVLXmitFlowCtlUpdateErrors11", mad_dump_uint},
+ {BITSOFFS(56, 2), "PortVLXmitFlowCtlUpdateErrors12", mad_dump_uint},
+ {BITSOFFS(58, 2), "PortVLXmitFlowCtlUpdateErrors13", mad_dump_uint},
+ {BITSOFFS(60, 2), "PortVLXmitFlowCtlUpdateErrors14", mad_dump_uint},
+ {BITSOFFS(62, 2), "PortVLXmitFlowCtlUpdateErrors15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_LAST_F */
+
+ /*
+ * PortVLXmitWaitCounters fields
+ */
+ {BITSOFFS(32, 16), "PortVLXmitWait0", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortVLXmitWait1", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortVLXmitWait2", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortVLXmitWait3", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortVLXmitWait4", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortVLXmitWait5", mad_dump_uint},
+ {BITSOFFS(128, 16), "PortVLXmitWait6", mad_dump_uint},
+ {BITSOFFS(144, 16), "PortVLXmitWait7", mad_dump_uint},
+ {BITSOFFS(160, 16), "PortVLXmitWait8", mad_dump_uint},
+ {BITSOFFS(176, 16), "PortVLXmitWait9", mad_dump_uint},
+ {BITSOFFS(192, 16), "PortVLXmitWait10", mad_dump_uint},
+ {BITSOFFS(208, 16), "PortVLXmitWait11", mad_dump_uint},
+ {BITSOFFS(224, 16), "PortVLXmitWait12", mad_dump_uint},
+ {BITSOFFS(240, 16), "PortVLXmitWait13", mad_dump_uint},
+ {BITSOFFS(256, 16), "PortVLXmitWait14", mad_dump_uint},
+ {BITSOFFS(272, 16), "PortVLXmitWait15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_LAST_F */
+
+ /*
+ * SwPortVLCongestion fields
+ */
+ {BITSOFFS(32, 16), "SWPortVLCongestion0", mad_dump_uint},
+ {BITSOFFS(48, 16), "SWPortVLCongestion1", mad_dump_uint},
+ {BITSOFFS(64, 16), "SWPortVLCongestion2", mad_dump_uint},
+ {BITSOFFS(80, 16), "SWPortVLCongestion3", mad_dump_uint},
+ {BITSOFFS(96, 16), "SWPortVLCongestion4", mad_dump_uint},
+ {BITSOFFS(112, 16), "SWPortVLCongestion5", mad_dump_uint},
+ {BITSOFFS(128, 16), "SWPortVLCongestion6", mad_dump_uint},
+ {BITSOFFS(144, 16), "SWPortVLCongestion7", mad_dump_uint},
+ {BITSOFFS(160, 16), "SWPortVLCongestion8", mad_dump_uint},
+ {BITSOFFS(176, 16), "SWPortVLCongestion9", mad_dump_uint},
+ {BITSOFFS(192, 16), "SWPortVLCongestion10", mad_dump_uint},
+ {BITSOFFS(208, 16), "SWPortVLCongestion11", mad_dump_uint},
+ {BITSOFFS(224, 16), "SWPortVLCongestion12", mad_dump_uint},
+ {BITSOFFS(240, 16), "SWPortVLCongestion13", mad_dump_uint},
+ {BITSOFFS(256, 16), "SWPortVLCongestion14", mad_dump_uint},
+ {BITSOFFS(272, 16), "SWPortVLCongestion15", mad_dump_uint},
+ {0, 0}, /* IB_PC_SW_PORT_VL_CONGESTION_LAST_F */
+
+ /*
+ * PortRcvConCtrl fields
+ */
+ {32, 32, "PortPktRcvFECN", mad_dump_uint},
+ {64, 32, "PortPktRcvBECN", mad_dump_uint},
+ {0, 0}, /* IB_PC_RCV_CON_CTRL_LAST_F */
+
+ /*
+ * PortSLRcvFECN fields
+ */
+ {32, 32, "PortSLRcvFECN0", mad_dump_uint},
+ {64, 32, "PortSLRcvFECN1", mad_dump_uint},
+ {96, 32, "PortSLRcvFECN2", mad_dump_uint},
+ {128, 32, "PortSLRcvFECN3", mad_dump_uint},
+ {160, 32, "PortSLRcvFECN4", mad_dump_uint},
+ {192, 32, "PortSLRcvFECN5", mad_dump_uint},
+ {224, 32, "PortSLRcvFECN6", mad_dump_uint},
+ {256, 32, "PortSLRcvFECN7", mad_dump_uint},
+ {288, 32, "PortSLRcvFECN8", mad_dump_uint},
+ {320, 32, "PortSLRcvFECN9", mad_dump_uint},
+ {352, 32, "PortSLRcvFECN10", mad_dump_uint},
+ {384, 32, "PortSLRcvFECN11", mad_dump_uint},
+ {416, 32, "PortSLRcvFECN12", mad_dump_uint},
+ {448, 32, "PortSLRcvFECN13", mad_dump_uint},
+ {480, 32, "PortSLRcvFECN14", mad_dump_uint},
+ {512, 32, "PortSLRcvFECN15", mad_dump_uint},
+ {0, 0}, /* IB_PC_SL_RCV_FECN_LAST_F */
+
+ /*
+ * PortSLRcvBECN fields
+ */
+ {32, 32, "PortSLRcvBECN0", mad_dump_uint},
+ {64, 32, "PortSLRcvBECN1", mad_dump_uint},
+ {96, 32, "PortSLRcvBECN2", mad_dump_uint},
+ {128, 32, "PortSLRcvBECN3", mad_dump_uint},
+ {160, 32, "PortSLRcvBECN4", mad_dump_uint},
+ {192, 32, "PortSLRcvBECN5", mad_dump_uint},
+ {224, 32, "PortSLRcvBECN6", mad_dump_uint},
+ {256, 32, "PortSLRcvBECN7", mad_dump_uint},
+ {288, 32, "PortSLRcvBECN8", mad_dump_uint},
+ {320, 32, "PortSLRcvBECN9", mad_dump_uint},
+ {352, 32, "PortSLRcvBECN10", mad_dump_uint},
+ {384, 32, "PortSLRcvBECN11", mad_dump_uint},
+ {416, 32, "PortSLRcvBECN12", mad_dump_uint},
+ {448, 32, "PortSLRcvBECN13", mad_dump_uint},
+ {480, 32, "PortSLRcvBECN14", mad_dump_uint},
+ {512, 32, "PortSLRcvBECN15", mad_dump_uint},
+ {0, 0}, /* IB_PC_SL_RCV_BECN_LAST_F */
+
+ /*
+ * PortXmitConCtrl fields
+ */
+ {32, 32, "PortXmitTimeCong", mad_dump_uint},
+ {0, 0}, /* IB_PC_XMIT_CON_CTRL_LAST_F */
+
+ /*
+ * PortVLXmitTimeCong fields
+ */
+ {32, 32, "PortVLXmitTimeCong0", mad_dump_uint},
+ {64, 32, "PortVLXmitTimeCong1", mad_dump_uint},
+ {96, 32, "PortVLXmitTimeCong2", mad_dump_uint},
+ {128, 32, "PortVLXmitTimeCong3", mad_dump_uint},
+ {160, 32, "PortVLXmitTimeCong4", mad_dump_uint},
+ {192, 32, "PortVLXmitTimeCong5", mad_dump_uint},
+ {224, 32, "PortVLXmitTimeCong6", mad_dump_uint},
+ {256, 32, "PortVLXmitTimeCong7", mad_dump_uint},
+ {288, 32, "PortVLXmitTimeCong8", mad_dump_uint},
+ {320, 32, "PortVLXmitTimeCong9", mad_dump_uint},
+ {352, 32, "PortVLXmitTimeCong10", mad_dump_uint},
+ {384, 32, "PortVLXmitTimeCong11", mad_dump_uint},
+ {416, 32, "PortVLXmitTimeCong12", mad_dump_uint},
+ {448, 32, "PortVLXmitTimeCong13", mad_dump_uint},
+ {480, 32, "PortVLXmitTimeCong14", mad_dump_uint},
+ {0, 0}, /* IB_PC_VL_XMIT_TIME_CONG_LAST_F */
+
+ /*
+ * Mellanox ExtendedPortInfo fields
+ */
+ {BITSOFFS(24, 8), "StateChangeEnable", mad_dump_hex},
+ {BITSOFFS(56, 8), "LinkSpeedSupported", mad_dump_hex},
+ {BITSOFFS(88, 8), "LinkSpeedEnabled", mad_dump_hex},
+ {BITSOFFS(120, 8), "LinkSpeedActive", mad_dump_hex},
+ {0, 0}, /* IB_MLNX_EXT_PORT_LAST_F */
+
+ /*
+ * Congestion Control Mad fields
+ * bytes 24-31 of congestion control mad
+ */
+ {192, 64, "CC_Key", mad_dump_hex}, /* IB_CC_CCKEY_F */
+
+ /*
+ * CongestionInfo fields
+ */
+ {BITSOFFS(0, 16), "CongestionInfo", mad_dump_hex},
+ {BITSOFFS(16, 8), "ControlTableCap", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_INFO_LAST_F */
+
+ /*
+ * CongestionKeyInfo fields
+ */
+ {0, 64, "CC_Key", mad_dump_hex},
+ {BITSOFFS(64, 1), "CC_KeyProtectBit", mad_dump_uint},
+ {BITSOFFS(80, 16), "CC_KeyLeasePeriod", mad_dump_uint},
+ {BITSOFFS(96, 16), "CC_KeyViolations", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_KEY_INFO_LAST_F */
+
+ /*
+ * CongestionLog (common) fields
+ */
+ {BITSOFFS(0, 8), "LogType", mad_dump_uint},
+ {BITSOFFS(8, 8), "CongestionFlags", mad_dump_hex},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_LAST_F */
+
+ /*
+ * CongestionLog (Switch) fields
+ */
+ {BITSOFFS(16, 16), "LogEventsCounter", mad_dump_uint},
+ {32, 32, "CurrentTimeStamp", mad_dump_uint},
+ {64, 256, "PortMap", mad_dump_array},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_SWITCH_LAST_F */
+
+ /*
+ * CongestionLogEvent (Switch) fields
+ */
+ {BITSOFFS(0, 16), "SLID", mad_dump_uint},
+ {BITSOFFS(16, 16), "DLID", mad_dump_uint},
+ {BITSOFFS(32, 4), "SL", mad_dump_uint},
+ {64, 32, "Timestamp", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_ENTRY_SWITCH_LAST_F */
+
+ /*
+ * CongestionLog (CA) fields
+ */
+ {BITSOFFS(16, 16), "ThresholdEventCounter", mad_dump_uint},
+ {BITSOFFS(32, 16), "ThresholdCongestionEventMap", mad_dump_hex},
+ /* XXX: Q3/2010 errata lists offset 48, but that means field is not
+ * word aligned. Assume will be aligned to offset 64 later.
+ */
+ {BITSOFFS(64, 32), "CurrentTimeStamp", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_CA_LAST_F */
+
+ /*
+ * CongestionLogEvent (CA) fields
+ */
+ {BITSOFFS(0, 24), "Local_QP_CN_Entry", mad_dump_uint},
+ {BITSOFFS(24, 4), "SL_CN_Entry", mad_dump_uint},
+ {BITSOFFS(28, 4), "Service_Type_CN_Entry", mad_dump_hex},
+ {BITSOFFS(32, 24), "Remote_QP_Number_CN_Entry", mad_dump_uint},
+ {BITSOFFS(64, 16), "Local_LID_CN", mad_dump_uint},
+ {BITSOFFS(80, 16), "Remote_LID_CN_Entry", mad_dump_uint},
+ {BITSOFFS(96, 32), "Timestamp_CN_Entry", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_ENTRY_CA_LAST_F */
+
+ /*
+ * SwitchCongestionSetting fields
+ */
+ {0, 32, "Control_Map", mad_dump_hex},
+ {32, 256, "Victim_Mask", mad_dump_array},
+ {288, 256, "Credit_Mask", mad_dump_array},
+ {BITSOFFS(544, 4), "Threshold", mad_dump_hex},
+ {BITSOFFS(552, 8), "Packet_Size", mad_dump_uint},
+ {BITSOFFS(560, 4), "CS_Threshold", mad_dump_hex},
+ {BITSOFFS(576, 16), "CS_ReturnDelay", mad_dump_hex}, /* TODO: CCT dump */
+ {BITSOFFS(592, 16), "Marking_Rate", mad_dump_uint},
+ {0, 0}, /* IB_CC_SWITCH_CONGESTION_SETTING_LAST_F */
+
+ /*
+ * SwitchPortCongestionSettingElement fields
+ */
+ {BITSOFFS(0, 1), "Valid", mad_dump_uint},
+ {BITSOFFS(1, 1), "Control_Type", mad_dump_uint},
+ {BITSOFFS(4, 4), "Threshold", mad_dump_hex},
+ {BITSOFFS(8, 8), "Packet_Size", mad_dump_uint},
+ {BITSOFFS(16, 16), "Cong_Parm_Marking_Rate", mad_dump_uint},
+ {0, 0}, /* IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_LAST_F */
+
+ /*
+ * CACongestionSetting fields
+ */
+ {BITSOFFS(0, 16), "Port_Control", mad_dump_hex},
+ {BITSOFFS(16, 16), "Control_Map", mad_dump_hex},
+ {0, 0}, /* IB_CC_CA_CONGESTION_SETTING_LAST_F */
+
+ /*
+ * CACongestionEntry fields
+ */
+ {BITSOFFS(0, 16), "CCTI_Timer", mad_dump_uint},
+ {BITSOFFS(16, 8), "CCTI_Increase", mad_dump_uint},
+ {BITSOFFS(24, 8), "Trigger_Threshold", mad_dump_uint},
+ {BITSOFFS(32, 8), "CCTI_Min", mad_dump_uint},
+ {0, 0}, /* IB_CC_CA_CONGESTION_SETTING_ENTRY_LAST_F */
+
+ /*
+ * CongestionControlTable fields
+ */
+ {BITSOFFS(0, 16), "CCTI_Limit", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_CONTROL_TABLE_LAST_F */
+
+ /*
+ * CongestionControlTableEntry fields
+ */
+ {BITSOFFS(0, 2), "CCT_Shift", mad_dump_uint},
+ {BITSOFFS(2, 14), "CCT_Multiplier", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_LAST_F */
+
+ /*
+ * Timestamp fields
+ */
+ {0, 32, "Timestamp", mad_dump_uint},
+ {0, 0}, /* IB_CC_TIMESTAMP_LAST_F */
+
+ /* Node Record */
+ {BITSOFFS(0, 16), "Lid", mad_dump_uint},
+ {BITSOFFS(32, 8), "BaseVers", mad_dump_uint},
+ {BITSOFFS(40, 8), "ClassVers", mad_dump_uint},
+ {BITSOFFS(48, 8), "NodeType", mad_dump_node_type},
+ {BITSOFFS(56, 8), "NumPorts", mad_dump_uint},
+ {64, 64, "SystemGuid", mad_dump_hex},
+ {128, 64, "Guid", mad_dump_hex},
+ {192, 64, "PortGuid", mad_dump_hex},
+ {BITSOFFS(256, 16), "PartCap", mad_dump_uint},
+ {BITSOFFS(272, 16), "DevId", mad_dump_hex},
+ {288, 32, "Revision", mad_dump_hex},
+ {BITSOFFS(320, 8), "LocalPort", mad_dump_uint},
+ {BITSOFFS(328, 24), "VendorId", mad_dump_hex},
+ {352, 64 * 8, "NodeDesc", mad_dump_string},
+ {0, 0}, /* IB_SA_NR_LAST_F */
+
+ /*
+ * PortMirrorRoute fields
+ */
+ {BITSOFFS(0, 16), "EncapRawEthType", mad_dump_hex},
+ {BITSOFFS(20, 12), "MaxMirrorLen", mad_dump_hex},
+ {BITSOFFS(32, 3), "MT", mad_dump_hex},
+ {BITSOFFS(35, 1), "BF", mad_dump_hex},
+ {BITSOFFS(56, 8), "NMPort", mad_dump_hex},
+ {BITSOFFS(64, 4), "EncapLRHVL", mad_dump_hex},
+ {BITSOFFS(68, 4), "EncapLRHLVer", mad_dump_hex},
+ {BITSOFFS(72, 4), "EncapLRHSL", mad_dump_hex},
+ {BITSOFFS(78, 2), "EncapLRHLNH", mad_dump_hex},
+ {BITSOFFS(80, 16), "EncapLRHDLID", mad_dump_hex},
+ {BITSOFFS(101, 11), "EncapLRHLength", mad_dump_hex},
+ {BITSOFFS(112, 16), "EncapLRHSLID", mad_dump_hex},
+ {0, 0}, /* IB_PMR_LAST_F */
+
+ /*
+ * PortMirrorFilter fields
+ */
+ {0, 32, "MirrorFilter0", mad_dump_hex},
+ {32, 32, "MirrorFilter1", mad_dump_hex},
+ {64, 32, "MirrorMask0", mad_dump_hex},
+ {96, 32, "MirrorMask1", mad_dump_hex},
+ {128, 32, "MirrorMask2", mad_dump_hex},
+ {160, 32, "MirrorMask3", mad_dump_hex},
+ {BITSOFFS(192, 1), "B0", mad_dump_hex},
+ {BITSOFFS(196, 12), "MirrorMaskOffset0", mad_dump_hex},
+ {BITSOFFS(208, 1), "B1", mad_dump_hex},
+ {BITSOFFS(212, 12), "MirrorMaskOffset1", mad_dump_hex},
+ {BITSOFFS(224, 1), "B2", mad_dump_hex},
+ {BITSOFFS(228, 12), "MirrorMaskOffset2", mad_dump_hex},
+ {BITSOFFS(240, 1), "B3", mad_dump_hex},
+ {BITSOFFS(244, 12), "MirrorMaskOffset3", mad_dump_hex},
+ {0, 0}, /* IB_PMF_LAST_F */
+
+ /*
+ * PortMirrorPorts fields
+ */
+ {BITSOFFS(10, 2), "TQ1", mad_dump_hex},
+ {BITSOFFS(14, 2), "RQ1", mad_dump_hex},
+ {BITSOFFS(18, 2), "TQ2", mad_dump_hex},
+ {BITSOFFS(22, 2), "RQ2", mad_dump_hex},
+ {BITSOFFS(26, 2), "TQ3", mad_dump_hex},
+ {BITSOFFS(30, 2), "RQ3", mad_dump_hex},
+ {BITSOFFS(34, 2), "TQ4", mad_dump_hex},
+ {BITSOFFS(38, 2), "RQ4", mad_dump_hex},
+ {BITSOFFS(42, 2), "TQ5", mad_dump_hex},
+ {BITSOFFS(46, 2), "RQ5", mad_dump_hex},
+ {BITSOFFS(50, 2), "TQ6", mad_dump_hex},
+ {BITSOFFS(54, 2), "RQ6", mad_dump_hex},
+ {BITSOFFS(58, 2), "TQ7", mad_dump_hex},
+ {BITSOFFS(62, 2), "RQ7", mad_dump_hex},
+ {BITSOFFS(66, 2), "TQ8", mad_dump_hex},
+ {BITSOFFS(70, 2), "RQ8", mad_dump_hex},
+ {BITSOFFS(74, 2), "TQ9", mad_dump_hex},
+ {BITSOFFS(78, 2), "RQ9", mad_dump_hex},
+ {BITSOFFS(82, 2), "TQ10", mad_dump_hex},
+ {BITSOFFS(86, 2), "RQ10", mad_dump_hex},
+ {BITSOFFS(90, 2), "TQ11", mad_dump_hex},
+ {BITSOFFS(94, 2), "RQ11", mad_dump_hex},
+ {BITSOFFS(98, 2), "TQ12", mad_dump_hex},
+ {BITSOFFS(102, 2), "RQ12", mad_dump_hex},
+ {BITSOFFS(106, 2), "TQ13", mad_dump_hex},
+ {BITSOFFS(110, 2), "RQ13", mad_dump_hex},
+ {BITSOFFS(114, 2), "TQ14", mad_dump_hex},
+ {BITSOFFS(118, 2), "RQ14", mad_dump_hex},
+ {BITSOFFS(122, 2), "TQ15", mad_dump_hex},
+ {BITSOFFS(126, 2), "RQ15", mad_dump_hex},
+ {BITSOFFS(130, 2), "TQ16", mad_dump_hex},
+ {BITSOFFS(134, 2), "RQ16", mad_dump_hex},
+ {BITSOFFS(138, 2), "TQ17", mad_dump_hex},
+ {BITSOFFS(142, 2), "RQ17", mad_dump_hex},
+ {BITSOFFS(146, 2), "TQ18", mad_dump_hex},
+ {BITSOFFS(150, 2), "RQ18", mad_dump_hex},
+ {BITSOFFS(154, 2), "TQ19", mad_dump_hex},
+ {BITSOFFS(158, 2), "RQ19", mad_dump_hex},
+ {BITSOFFS(162, 2), "TQ20", mad_dump_hex},
+ {BITSOFFS(166, 2), "RQ20", mad_dump_hex},
+ {BITSOFFS(170, 2), "TQ21", mad_dump_hex},
+ {BITSOFFS(174, 2), "RQ21", mad_dump_hex},
+ {BITSOFFS(178, 2), "TQ22", mad_dump_hex},
+ {BITSOFFS(182, 2), "RQ22", mad_dump_hex},
+ {BITSOFFS(186, 2), "TQ23", mad_dump_hex},
+ {BITSOFFS(190, 2), "RQ23", mad_dump_hex},
+ {BITSOFFS(194, 2), "TQ24", mad_dump_hex},
+ {BITSOFFS(198, 2), "RQ24", mad_dump_hex},
+ {BITSOFFS(202, 2), "TQ25", mad_dump_hex},
+ {BITSOFFS(206, 2), "RQ25", mad_dump_hex},
+ {BITSOFFS(210, 2), "TQ26", mad_dump_hex},
+ {BITSOFFS(214, 2), "RQ26", mad_dump_hex},
+ {BITSOFFS(218, 2), "TQ27", mad_dump_hex},
+ {BITSOFFS(222, 2), "RQ27", mad_dump_hex},
+ {BITSOFFS(226, 2), "TQ28", mad_dump_hex},
+ {BITSOFFS(230, 2), "RQ28", mad_dump_hex},
+ {BITSOFFS(234, 2), "TQ29", mad_dump_hex},
+ {BITSOFFS(238, 2), "RQ29", mad_dump_hex},
+ {BITSOFFS(242, 2), "TQ30", mad_dump_hex},
+ {BITSOFFS(246, 2), "RQ30", mad_dump_hex},
+ {BITSOFFS(250, 2), "TQ31", mad_dump_hex},
+ {BITSOFFS(254, 2), "RQ31", mad_dump_hex},
+ {BITSOFFS(258, 2), "TQ32", mad_dump_hex},
+ {BITSOFFS(262, 2), "RQ32", mad_dump_hex},
+ {BITSOFFS(266, 2), "TQ33", mad_dump_hex},
+ {BITSOFFS(270, 2), "RQ33", mad_dump_hex},
+ {BITSOFFS(274, 2), "TQ34", mad_dump_hex},
+ {BITSOFFS(278, 2), "RQ34", mad_dump_hex},
+ {BITSOFFS(282, 2), "TQ35", mad_dump_hex},
+ {BITSOFFS(286, 2), "RQ35", mad_dump_hex},
+ {BITSOFFS(290, 2), "TQ36", mad_dump_hex},
+ {BITSOFFS(294, 2), "RQ36", mad_dump_hex},
+ {0, 0}, /* IB_FIELD_LAST_ */
+
+ /*
+ * PortSamplesResult fields
+ */
+ {BITSOFFS(0, 16), "Tag", mad_dump_hex},
+ {BITSOFFS(30, 2), "SampleStatus", mad_dump_hex},
+ {32, 32, "Counter0", mad_dump_uint},
+ {64, 32, "Counter1", mad_dump_uint},
+ {96, 32, "Counter2", mad_dump_uint},
+ {128, 32, "Counter3", mad_dump_uint},
+ {160, 32, "Counter4", mad_dump_uint},
+ {192, 32, "Counter5", mad_dump_uint},
+ {224, 32, "Counter6", mad_dump_uint},
+ {256, 32, "Counter7", mad_dump_uint},
+ {288, 32, "Counter8", mad_dump_uint},
+ {320, 32, "Counter9", mad_dump_uint},
+ {352, 32, "Counter10", mad_dump_uint},
+ {384, 32, "Counter11", mad_dump_uint},
+ {416, 32, "Counter12", mad_dump_uint},
+ {448, 32, "Counter13", mad_dump_uint},
+ {480, 32, "Counter14", mad_dump_uint},
+ {0, 0}, /* IB_PSR_LAST_F */
+
+ /*
+ * PortInfoExtended fields
+ */
+ {0, 32, "CapMask", mad_dump_hex},
+ {BITSOFFS(32, 16), "FECModeActive", mad_dump_uint},
+ {BITSOFFS(48, 16), "FDRFECModeSupported", mad_dump_uint},
+ {BITSOFFS(64, 16), "FDRFECModeEnabled", mad_dump_uint},
+ {BITSOFFS(80, 16), "EDRFECModeSupported", mad_dump_uint},
+ {BITSOFFS(96, 16), "EDRFECModeEnabled", mad_dump_uint},
+ {0, 0}, /* IB_PORT_EXT_LAST_F */
+
+ /*
+ * PortExtendedSpeedsCounters RSFEC Active fields
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {64, 64, "CounterSelect", mad_dump_hex},
+ {BITSOFFS(128, 16), "SyncHeaderErrorCounter", mad_dump_uint},
+ {BITSOFFS(144, 16), "UnknownBlockCounter", mad_dump_uint},
+ {352, 32, "FECCorrectableSymbolCtrLane0", mad_dump_uint},
+ {384, 32, "FECCorrectableSymbolCtrLane1", mad_dump_uint},
+ {416, 32, "FECCorrectableSymbolCtrLane2", mad_dump_uint},
+ {448, 32, "FECCorrectableSymbolCtrLane3", mad_dump_uint},
+ {480, 32, "FECCorrectableSymbolCtrLane4", mad_dump_uint},
+ {512, 32, "FECCorrectableSymbolCtrLane5", mad_dump_uint},
+ {544, 32, "FECCorrectableSymbolCtrLane6", mad_dump_uint},
+ {576, 32, "FECCorrectableSymbolCtrLane7", mad_dump_uint},
+ {608, 32, "FECCorrectableSymbolCtrLane8", mad_dump_uint},
+ {640, 32, "FECCorrectableSymbolCtrLane9", mad_dump_uint},
+ {672, 32, "FECCorrectableSymbolCtrLane10", mad_dump_uint},
+ {704, 32, "FECCorrectableSymbolCtrLane11", mad_dump_uint},
+ {1120, 32, "PortFECCorrectableBlockCtr", mad_dump_uint},
+ {1152, 32, "PortFECUncorrectableBlockCtr", mad_dump_uint},
+ {1184, 32, "PortFECCorrectedSymbolCtr", mad_dump_uint},
+ {0, 0}, /* IB_PESC_RSFEC_LAST_F */
+
+ /*
+ * More PortCountersExtended fields
+ */
+ {32, 32, "CounterSelect2", mad_dump_hex},
+ {576, 64, "SymbolErrorCounter", mad_dump_uint},
+ {640, 64, "LinkErrorRecoveryCounter", mad_dump_uint},
+ {704, 64, "LinkDownedCounter", mad_dump_uint},
+ {768, 64, "PortRcvErrors", mad_dump_uint},
+ {832, 64, "PortRcvRemotePhysicalErrors", mad_dump_uint},
+ {896, 64, "PortRcvSwitchRelayErrors", mad_dump_uint},
+ {960, 64, "PortXmitDiscards", mad_dump_uint},
+ {1024, 64, "PortXmitConstraintErrors", mad_dump_uint},
+ {1088, 64, "PortRcvConstraintErrors", mad_dump_uint},
+ {1152, 64, "LocalLinkIntegrityErrors", mad_dump_uint},
+ {1216, 64, "ExcessiveBufferOverrunErrors", mad_dump_uint},
+ {1280, 64, "VL15Dropped", mad_dump_uint},
+ {1344, 64, "PortXmitWait", mad_dump_uint},
+ {1408, 64, "QP1Dropped", mad_dump_uint},
+ {0, 0}, /* IB_PC_EXT_ERR_LAST_F */
+
+ /*
+ * Another PortCounters field
+ */
+ {160, 16, "QP1Dropped", mad_dump_uint},
+
+ {0, 0} /* IB_FIELD_LAST_ */
+};
+
+static void _set_field64(void *buf, int base_offs, const ib_field_t * f,
+ uint64_t val)
+{
+ uint64_t nval;
+
+ nval = htonll(val);
+ memcpy(((void *)(char *)buf + base_offs + f->bitoffs / 8),
+ (void *)&nval, sizeof(uint64_t));
+}
+
+static uint64_t _get_field64(void *buf, int base_offs, const ib_field_t * f)
+{
+ uint64_t val;
+ memcpy((void *)&val, (void *)((char *)buf + base_offs + f->bitoffs / 8),
+ sizeof(uint64_t));
+ return ntohll(val);
+}
+
+static void _set_field(void *buf, int base_offs, const ib_field_t * f,
+ uint32_t val)
+{
+ int prebits = (8 - (f->bitoffs & 7)) & 7;
+ int postbits = (f->bitoffs + f->bitlen) & 7;
+ int bytelen = f->bitlen / 8;
+ unsigned idx = base_offs + f->bitoffs / 8;
+ char *p = (char *)buf;
+
+ if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8) {
+ p[3 ^ idx] &= ~((((1 << f->bitlen) - 1)) << (f->bitoffs & 7));
+ p[3 ^ idx] |=
+ (val & ((1 << f->bitlen) - 1)) << (f->bitoffs & 7);
+ return;
+ }
+
+ if (prebits) { /* val lsb in byte msb */
+ p[3 ^ idx] &= (1 << (8 - prebits)) - 1;
+ p[3 ^ idx++] |= (val & ((1 << prebits) - 1)) << (8 - prebits);
+ val >>= prebits;
+ }
+
+ /* BIG endian byte order */
+ for (; bytelen--; val >>= 8)
+ p[3 ^ idx++] = val & 0xff;
+
+ if (postbits) { /* val msb in byte lsb */
+ p[3 ^ idx] &= ~((1 << postbits) - 1);
+ p[3 ^ idx] |= val;
+ }
+}
+
+static uint32_t _get_field(void *buf, int base_offs, const ib_field_t * f)
+{
+ int prebits = (8 - (f->bitoffs & 7)) & 7;
+ int postbits = (f->bitoffs + f->bitlen) & 7;
+ int bytelen = f->bitlen / 8;
+ unsigned idx = base_offs + f->bitoffs / 8;
+ uint8_t *p = (uint8_t *) buf;
+ uint32_t val = 0, v = 0, i;
+
+ if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8)
+ return (p[3 ^ idx] >> (f->bitoffs & 7)) & ((1 << f->bitlen) -
+ 1);
+
+ if (prebits) /* val lsb from byte msb */
+ v = p[3 ^ idx++] >> (8 - prebits);
+
+ if (postbits) { /* val msb from byte lsb */
+ i = base_offs + (f->bitoffs + f->bitlen) / 8;
+ val = (p[3 ^ i] & ((1 << postbits) - 1));
+ }
+
+ /* BIG endian byte order */
+ for (idx += bytelen - 1; bytelen--; idx--)
+ val = (val << 8) | p[3 ^ idx];
+
+ return (val << prebits) | v;
+}
+
+/* field must be byte aligned */
+static void _set_array(void *buf, int base_offs, const ib_field_t * f,
+ void *val)
+{
+ int bitoffs = f->bitoffs;
+
+ if (f->bitlen < 32)
+ bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen);
+
+ memcpy((uint8_t *) buf + base_offs + bitoffs / 8, val, f->bitlen / 8);
+}
+
+static void _get_array(void *buf, int base_offs, const ib_field_t * f,
+ void *val)
+{
+ int bitoffs = f->bitoffs;
+
+ if (f->bitlen < 32)
+ bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen);
+
+ memcpy(val, (uint8_t *) buf + base_offs + bitoffs / 8, f->bitlen / 8);
+}
+
+uint32_t mad_get_field(void *buf, int base_offs, enum MAD_FIELDS field)
+{
+ return _get_field(buf, base_offs, ib_mad_f + field);
+}
+
+void mad_set_field(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint32_t val)
+{
+ _set_field(buf, base_offs, ib_mad_f + field, val);
+}
+
+uint64_t mad_get_field64(void *buf, int base_offs, enum MAD_FIELDS field)
+{
+ return _get_field64(buf, base_offs, ib_mad_f + field);
+}
+
+void mad_set_field64(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint64_t val)
+{
+ _set_field64(buf, base_offs, ib_mad_f + field, val);
+}
+
+void mad_set_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val)
+{
+ _set_array(buf, base_offs, ib_mad_f + field, val);
+}
+
+void mad_get_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val)
+{
+ _get_array(buf, base_offs, ib_mad_f + field, val);
+}
+
+void mad_decode_field(uint8_t * buf, enum MAD_FIELDS field, void *val)
+{
+ const ib_field_t *f = ib_mad_f + field;
+
+ if (!field) {
+ *(int *)val = *(int *)buf;
+ return;
+ }
+ if (f->bitlen <= 32) {
+ *(uint32_t *) val = _get_field(buf, 0, f);
+ return;
+ }
+ if (f->bitlen == 64) {
+ *(uint64_t *) val = _get_field64(buf, 0, f);
+ return;
+ }
+ _get_array(buf, 0, f, val);
+}
+
+void mad_encode_field(uint8_t * buf, enum MAD_FIELDS field, void *val)
+{
+ const ib_field_t *f = ib_mad_f + field;
+
+ if (!field) {
+ *(int *)buf = *(int *)val;
+ return;
+ }
+ if (f->bitlen <= 32) {
+ _set_field(buf, 0, f, *(uint32_t *) val);
+ return;
+ }
+ if (f->bitlen == 64) {
+ _set_field64(buf, 0, f, *(uint64_t *) val);
+ return;
+ }
+ _set_array(buf, 0, f, val);
+}
+
+/************************/
+
+static char *_mad_dump_val(const ib_field_t * f, char *buf, int bufsz,
+ void *val)
+{
+ f->def_dump_fn(buf, bufsz, val, ALIGN(f->bitlen, 8) / 8);
+ buf[bufsz - 1] = 0;
+
+ return buf;
+}
+
+static char *_mad_dump_field(const ib_field_t * f, const char *name, char *buf,
+ int bufsz, void *val)
+{
+ char dots[128];
+ int l, n;
+
+ if (bufsz <= 32)
+ return NULL; /* buf too small */
+
+ if (!name)
+ name = f->name;
+
+ l = strlen(name);
+ if (l < 32) {
+ memset(dots, '.', 32 - l);
+ dots[32 - l] = 0;
+ }
+
+ n = snprintf(buf, bufsz, "%s:%s", name, dots);
+ _mad_dump_val(f, buf + n, bufsz - n, val);
+ buf[bufsz - 1] = 0;
+
+ return buf;
+}
+
+static int _mad_dump(ib_mad_dump_fn * fn, const char *name, void *val,
+ int valsz)
+{
+ ib_field_t f;
+ char buf[512];
+
+ f.def_dump_fn = fn;
+ f.bitlen = valsz * 8;
+
+ return printf("%s\n", _mad_dump_field(&f, name, buf, sizeof buf, val));
+}
+
+static int _mad_print_field(const ib_field_t * f, const char *name, void *val,
+ int valsz)
+{
+ return _mad_dump(f->def_dump_fn, name ? name : f->name, val,
+ valsz ? valsz : ALIGN(f->bitlen, 8) / 8);
+}
+
+int mad_print_field(enum MAD_FIELDS field, const char *name, void *val)
+{
+ if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
+ return -1;
+ return _mad_print_field(ib_mad_f + field, name, val, 0);
+}
+
+char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
+{
+ if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
+ return NULL;
+ return _mad_dump_field(ib_mad_f + field, 0, buf, bufsz, val);
+}
+
+char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
+{
+ if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
+ return NULL;
+ return _mad_dump_val(ib_mad_f + field, buf, bufsz, val);
+}
+
+const char *mad_field_name(enum MAD_FIELDS field)
+{
+ return (ib_mad_f[field].name);
+}
diff --git a/contrib/ofed/libibmad/gs.c b/contrib/ofed/libibmad/gs.c
new file mode 100644
index 000000000000..90db7e25e732
--- /dev/null
+++ b/contrib/ofed/libibmad/gs.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port,
+ unsigned timeout, unsigned id,
+ const struct ibmad_port * srcport)
+{
+ ib_rpc_v1_t rpc = { 0 };
+ ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
+ int lid = dest->lid;
+ void *p_ret;
+
+ DEBUG("lid %u port %d", lid, port);
+
+ if (lid == -1) {
+ IBWARN("only lid routed is supported");
+ return NULL;
+ }
+
+ rpc.mgtclass = IB_PERFORMANCE_CLASS | IB_MAD_RPC_VERSION1;
+ rpc.method = IB_MAD_METHOD_GET;
+ rpc.attr.id = id;
+
+ /* Same for attribute IDs */
+ mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
+ rpc.attr.mod = 0;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_PC_DATA_SZ;
+ rpc.dataoffs = IB_PC_DATA_OFFS;
+
+ if (!dest->qp)
+ dest->qp = 1;
+ if (!dest->qkey)
+ dest->qkey = IB_DEFAULT_QP1_QKEY;
+
+ p_ret = mad_rpc(srcport, rpcold, dest, rcvbuf, rcvbuf);
+ errno = rpc.error;
+ return p_ret;
+}
+
+uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest,
+ int port, unsigned mask, unsigned timeout,
+ unsigned id, const struct ibmad_port * srcport)
+{
+ ib_rpc_v1_t rpc = { 0 };
+ ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
+
+ int lid = dest->lid;
+ void *p_ret;
+
+ DEBUG("lid %u port %d mask 0x%x", lid, port, mask);
+
+ if (lid == -1) {
+ IBWARN("only lid routed is supported");
+ return NULL;
+ }
+
+ if (!mask)
+ mask = ~0;
+
+ rpc.mgtclass = IB_PERFORMANCE_CLASS | IB_MAD_RPC_VERSION1;
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = id;
+
+ memset(rcvbuf, 0, IB_MAD_SIZE);
+
+ /* Next 2 lines - same for attribute IDs */
+ mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
+ mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask);
+ mask = mask >> 16;
+ if (id == IB_GSI_PORT_COUNTERS_EXT)
+ mad_set_field(rcvbuf, 0, IB_PC_EXT_COUNTER_SELECT2_F, mask);
+ else
+ mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT2_F, mask);
+ rpc.attr.mod = 0;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_PC_DATA_SZ;
+ rpc.dataoffs = IB_PC_DATA_OFFS;
+ if (!dest->qp)
+ dest->qp = 1;
+ if (!dest->qkey)
+ dest->qkey = IB_DEFAULT_QP1_QKEY;
+
+ p_ret = mad_rpc(srcport, rpcold, dest, rcvbuf, rcvbuf);
+ errno = rpc.error;
+ return p_ret;
+}
diff --git a/contrib/ofed/libibmad/libibmad.map b/contrib/ofed/libibmad/libibmad.map
new file mode 100644
index 000000000000..2329ee05a121
--- /dev/null
+++ b/contrib/ofed/libibmad/libibmad.map
@@ -0,0 +1,160 @@
+IBMAD_1.3 {
+ global:
+ xdump;
+ mad_dump_field;
+ mad_dump_val;
+ mad_print_field;
+ mad_dump_array;
+ mad_dump_bitfield;
+ mad_dump_hex;
+ mad_dump_int;
+ mad_dump_linkdowndefstate;
+ mad_dump_linkspeed;
+ mad_dump_linkspeeden;
+ mad_dump_linkspeedsup;
+ mad_dump_linkspeedext;
+ mad_dump_linkspeedexten;
+ mad_dump_linkspeedextsup;
+ mad_dump_linkwidth;
+ mad_dump_linkwidthen;
+ mad_dump_linkwidthsup;
+ mad_dump_mlnx_ext_port_info;
+ mad_dump_portinfo_ext;
+ mad_dump_mtu;
+ mad_dump_node_type;
+ mad_dump_nodedesc;
+ mad_dump_nodeinfo;
+ mad_dump_opervls;
+ mad_dump_fields;
+ mad_dump_perfcounters;
+ mad_dump_perfcounters_ext;
+ mad_dump_perfcounters_xmt_sl;
+ mad_dump_perfcounters_rcv_sl;
+ mad_dump_perfcounters_xmt_disc;
+ mad_dump_perfcounters_rcv_err;
+ mad_dump_physportstate;
+ mad_dump_portcapmask;
+ mad_dump_portcapmask2;
+ mad_dump_portinfo;
+ mad_dump_portsamples_control;
+ mad_dump_portsamples_result;
+ mad_dump_perfcounters_port_op_rcv_counters;
+ mad_dump_perfcounters_port_flow_ctl_counters;
+ mad_dump_perfcounters_port_vl_op_packet;
+ mad_dump_perfcounters_port_vl_op_data;
+ mad_dump_perfcounters_port_vl_xmit_flow_ctl_update_errors;
+ mad_dump_perfcounters_port_vl_xmit_wait_counters;
+ mad_dump_perfcounters_sw_port_vl_congestion;
+ mad_dump_perfcounters_rcv_con_ctrl;
+ mad_dump_perfcounters_sl_rcv_fecn;
+ mad_dump_perfcounters_sl_rcv_becn;
+ mad_dump_perfcounters_xmit_con_ctrl;
+ mad_dump_perfcounters_vl_xmit_time_cong;
+ mad_dump_cc_congestioninfo;
+ mad_dump_cc_congestionkeyinfo;
+ mad_dump_cc_congestionlog;
+ mad_dump_cc_congestionlogswitch;
+ mad_dump_cc_congestionlogentryswitch;
+ mad_dump_cc_congestionlogca;
+ mad_dump_cc_congestionlogentryca;
+ mad_dump_cc_switchcongestionsetting;
+ mad_dump_cc_switchportcongestionsettingelement;
+ mad_dump_cc_cacongestionsetting;
+ mad_dump_cc_cacongestionentry;
+ mad_dump_cc_congestioncontroltable;
+ mad_dump_cc_congestioncontroltableentry;
+ mad_dump_cc_timestamp;
+ mad_dump_classportinfo;
+ mad_dump_portmirror_route;
+ mad_dump_portmirror_filter;
+ mad_dump_portmirror_ports;
+ mad_dump_portstates;
+ mad_dump_portstate;
+ mad_dump_rhex;
+ mad_dump_sltovl;
+ mad_dump_string;
+ mad_dump_switchinfo;
+ mad_dump_uint;
+ mad_dump_vlarbitration;
+ mad_dump_vlcap;
+ mad_get_field;
+ mad_set_field;
+ mad_get_field64;
+ mad_set_field64;
+ mad_get_array;
+ mad_set_array;
+ pma_query_via;
+ performance_reset_via;
+ mad_build_pkt;
+ mad_decode_field;
+ mad_encode;
+ mad_encode_field;
+ mad_trid;
+ portid2portnum;
+ portid2str;
+ str2drpath;
+ drpath2str;
+ mad_class_agent;
+ mad_register_client;
+ mad_register_server;
+ mad_register_client_via;
+ mad_register_server_via;
+ ib_resolve_portid_str;
+ ib_resolve_self;
+ ib_resolve_smlid;
+ ibdebug;
+ mad_rpc_open_port;
+ mad_rpc_close_port;
+ mad_rpc;
+ mad_rpc_rmpp;
+ mad_rpc_portid;
+ mad_rpc_class_agent;
+ mad_rpc_set_retries;
+ mad_rpc_set_timeout;
+ mad_get_timeout;
+ mad_get_retries;
+ madrpc;
+ madrpc_def_timeout;
+ madrpc_init;
+ madrpc_portid;
+ madrpc_rmpp;
+ madrpc_save_mad;
+ madrpc_set_retries;
+ madrpc_set_timeout;
+ madrpc_show_errors;
+ ib_path_query;
+ sa_call;
+ sa_rpc_call;
+ mad_alloc;
+ mad_free;
+ mad_receive;
+ mad_respond;
+ mad_receive_via;
+ mad_respond_via;
+ mad_send;
+ mad_send_via;
+ smp_query;
+ smp_set;
+ ib_vendor_call;
+ ib_vendor_call_via;
+ smp_query_via;
+ smp_query_status_via;
+ smp_set_via;
+ smp_set_status_via;
+ ib_path_query_via;
+ ib_resolve_smlid_via;
+ ib_resolve_guid_via;
+ ib_resolve_gid_via;
+ ib_resolve_portid_str_via;
+ ib_resolve_self_via;
+ mad_field_name;
+ bm_call_via;
+ mad_dump_port_ext_speeds_counters;
+ mad_dump_port_ext_speeds_counters_rsfec_active;
+ cc_query_status_via;
+ cc_config_status_via;
+ smp_mkey_get;
+ smp_mkey_set;
+ ib_node_query_via;
+ local: *;
+};
diff --git a/contrib/ofed/libibmad/mad.c b/contrib/ofed/libibmad/mad.c
new file mode 100644
index 000000000000..5deefa242527
--- /dev/null
+++ b/contrib/ofed/libibmad/mad.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+#define GET_IB_USERLAND_TID(tid) (tid & 0x00000000ffffffff)
+/*
+ * Generate the 64 bit MAD transaction ID. The upper 32 bits are reserved for
+ * use by the kernel. We clear the upper 32 bits here, but MADs received from
+ * the kernel may contain kernel specific data in these bits, consequently
+ * userland TID matching should only be done on the lower 32 bits.
+ */
+uint64_t mad_trid(void)
+{
+ static uint64_t trid;
+ uint64_t next;
+
+ if (!trid) {
+ srandom((int)time(0) * getpid());
+ trid = random();
+ }
+ next = ++trid;
+ next = GET_IB_USERLAND_TID(next);
+ return next;
+}
+
+int mad_get_timeout(const struct ibmad_port *srcport, int override_ms)
+{
+ return (override_ms ? override_ms :
+ srcport->timeout ? srcport->timeout : madrpc_timeout);
+}
+
+int mad_get_retries(const struct ibmad_port *srcport)
+{
+ return (srcport->retries ? srcport->retries : madrpc_retries);
+}
+
+void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath, void *data)
+{
+ int is_resp = rpc->method & IB_MAD_RESPONSE;
+ int mgtclass;
+
+ /* first word */
+ mad_set_field(buf, 0, IB_MAD_METHOD_F, rpc->method);
+ mad_set_field(buf, 0, IB_MAD_RESPONSE_F, is_resp ? 1 : 0);
+ mgtclass = rpc->mgtclass & 0xff;
+ if (mgtclass == IB_SA_CLASS || mgtclass == IB_CC_CLASS)
+ mad_set_field(buf, 0, IB_MAD_CLASSVER_F, 2);
+ else
+ mad_set_field(buf, 0, IB_MAD_CLASSVER_F, 1);
+ mad_set_field(buf, 0, IB_MAD_MGMTCLASS_F, rpc->mgtclass & 0xff);
+ mad_set_field(buf, 0, IB_MAD_BASEVER_F, 1);
+
+ /* second word */
+ if ((rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS) {
+ if (!drpath) {
+ IBWARN("encoding dr mad without drpath (null)");
+ errno = EINVAL;
+ return NULL;
+ }
+ if (drpath->cnt >= IB_SUBNET_PATH_HOPS_MAX) {
+ IBWARN("dr path with hop count %d", drpath->cnt);
+ errno = EINVAL;
+ return NULL;
+ }
+ mad_set_field(buf, 0, IB_DRSMP_HOPCNT_F, drpath->cnt);
+ mad_set_field(buf, 0, IB_DRSMP_HOPPTR_F,
+ is_resp ? drpath->cnt + 1 : 0x0);
+ mad_set_field(buf, 0, IB_DRSMP_STATUS_F, rpc->rstatus);
+ mad_set_field(buf, 0, IB_DRSMP_DIRECTION_F, is_resp ? 1 : 0); /* out */
+ } else
+ mad_set_field(buf, 0, IB_MAD_STATUS_F, rpc->rstatus);
+
+ /* words 3,4,5,6 */
+ if (!rpc->trid)
+ rpc->trid = mad_trid();
+
+ mad_set_field64(buf, 0, IB_MAD_TRID_F, rpc->trid);
+ mad_set_field(buf, 0, IB_MAD_ATTRID_F, rpc->attr.id);
+ mad_set_field(buf, 0, IB_MAD_ATTRMOD_F, rpc->attr.mod);
+
+ /* words 7,8 */
+ mad_set_field64(buf, 0, IB_MAD_MKEY_F, rpc->mkey);
+
+ if ((rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS) {
+ /* word 9 */
+ mad_set_field(buf, 0, IB_DRSMP_DRDLID_F,
+ drpath->drdlid ? drpath->drdlid : 0xffff);
+ mad_set_field(buf, 0, IB_DRSMP_DRSLID_F,
+ drpath->drslid ? drpath->drslid : 0xffff);
+
+ /* bytes 128 - 256 - by default should be zero due to memset */
+ if (is_resp)
+ mad_set_array(buf, 0, IB_DRSMP_RPATH_F, drpath->p);
+ else
+ mad_set_array(buf, 0, IB_DRSMP_PATH_F, drpath->p);
+ }
+
+ if ((rpc->mgtclass & 0xff) == IB_SA_CLASS)
+ mad_set_field64(buf, 0, IB_SA_COMPMASK_F, rpc->mask);
+
+ if ((rpc->mgtclass & 0xff) == IB_CC_CLASS) {
+ ib_rpc_cc_t *rpccc = (ib_rpc_cc_t *)rpc;
+ mad_set_field64(buf, 0, IB_CC_CCKEY_F, rpccc->cckey);
+ }
+
+ if (data)
+ memcpy((char *)buf + rpc->dataoffs, data, rpc->datasz);
+
+ /* vendor mads range 2 */
+ if (mad_is_vendor_range2(rpc->mgtclass & 0xff))
+ mad_set_field(buf, 0, IB_VEND2_OUI_F, rpc->oui);
+
+ return (uint8_t *) buf + IB_MAD_SIZE;
+}
+
+int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data)
+{
+ uint8_t *p, *mad;
+ int lid_routed = (rpc->mgtclass & 0xff) != IB_SMI_DIRECT_CLASS;
+ int is_smi = ((rpc->mgtclass & 0xff) == IB_SMI_CLASS ||
+ (rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS);
+ struct ib_mad_addr addr;
+
+ if (!is_smi)
+ umad_set_addr(umad, dport->lid, dport->qp, dport->sl,
+ dport->qkey);
+ else if (lid_routed)
+ umad_set_addr(umad, dport->lid, dport->qp, 0, 0);
+ else if ((dport->drpath.drslid != 0xffff) && (dport->lid > 0))
+ umad_set_addr(umad, dport->lid, 0, 0, 0);
+ else
+ umad_set_addr(umad, 0xffff, 0, 0, 0);
+
+ if (dport->grh_present && !is_smi) {
+ addr.grh_present = 1;
+ memcpy(addr.gid, dport->gid, 16);
+ addr.hop_limit = 0xff;
+ addr.traffic_class = 0;
+ addr.flow_label = 0;
+ umad_set_grh(umad, &addr);
+ } else
+ umad_set_grh(umad, 0);
+ umad_set_pkey(umad, is_smi ? 0 : dport->pkey_idx);
+
+ mad = umad_get_mad(umad);
+ p = mad_encode(mad, rpc, lid_routed ? 0 : &dport->drpath, data);
+ if (!p)
+ return -1;
+
+ if (!is_smi && rmpp) {
+ mad_set_field(mad, 0, IB_SA_RMPP_VERS_F, 1);
+ mad_set_field(mad, 0, IB_SA_RMPP_TYPE_F, rmpp->type);
+ mad_set_field(mad, 0, IB_SA_RMPP_RESP_F, 0x3f);
+ mad_set_field(mad, 0, IB_SA_RMPP_FLAGS_F, rmpp->flags);
+ mad_set_field(mad, 0, IB_SA_RMPP_STATUS_F, rmpp->status);
+ mad_set_field(mad, 0, IB_SA_RMPP_D1_F, rmpp->d1.u);
+ mad_set_field(mad, 0, IB_SA_RMPP_D2_F, rmpp->d2.u);
+ }
+
+ return ((int)(p - mad));
+}
diff --git a/contrib/ofed/libibmad/mad.h b/contrib/ofed/libibmad/mad.h
new file mode 100644
index 000000000000..706e09ff778e
--- /dev/null
+++ b/contrib/ofed/libibmad/mad.h
@@ -0,0 +1,1843 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009-2011 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.
+ *
+ */
+#ifndef _MAD_H_
+#define _MAD_H_
+
+#include <infiniband/mad_osd.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#define IB_MAD_RPC_VERSION_MASK 0x0f00
+#define IB_MAD_RPC_VERSION1 (1<<8)
+
+#define IB_SUBNET_PATH_HOPS_MAX 64
+#define IB_DEFAULT_SUBN_PREFIX 0xfe80000000000000ULL
+#define IB_DEFAULT_QP1_QKEY 0x80010000
+#define IB_MAD_SIZE 256
+#define IB_SMP_DATA_OFFS 64
+#define IB_SMP_DATA_SIZE 64
+#define IB_VENDOR_RANGE1_DATA_OFFS 24
+#define IB_VENDOR_RANGE1_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE1_DATA_OFFS)
+#define IB_VENDOR_RANGE2_DATA_OFFS 40
+#define IB_VENDOR_RANGE2_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE2_DATA_OFFS)
+#define IB_SA_DATA_SIZE 200
+#define IB_SA_DATA_OFFS 56
+#define IB_PC_DATA_OFFS 64
+#define IB_PC_DATA_SZ (IB_MAD_SIZE - IB_PC_DATA_OFFS)
+#define IB_SA_MCM_RECSZ 53
+#define IB_SA_PR_RECSZ 64
+#define IB_SA_NR_RECSZ 108
+#define IB_SA_GIR_RECSZ 72
+#define IB_BM_DATA_OFFS 64
+#define IB_BM_DATA_SZ (IB_MAD_SIZE - IB_BM_DATA_OFFS)
+#define IB_BM_BKEY_OFFS 24
+#define IB_BM_BKEY_AND_DATA_SZ (IB_MAD_SIZE - IB_BM_BKEY_OFFS)
+#define IB_CC_DATA_OFFS 64
+#define IB_CC_DATA_SZ (IB_MAD_SIZE - IB_CC_DATA_OFFS)
+#define IB_CC_LOG_DATA_OFFS 32
+#define IB_CC_LOG_DATA_SZ (IB_MAD_SIZE - IB_CC_LOG_DATA_OFFS)
+
+enum MAD_CLASSES {
+ IB_SMI_CLASS = 0x1,
+ IB_SMI_DIRECT_CLASS = 0x81,
+ IB_SA_CLASS = 0x3,
+ IB_PERFORMANCE_CLASS = 0x4,
+ IB_BOARD_MGMT_CLASS = 0x5,
+ IB_DEVICE_MGMT_CLASS = 0x6,
+ IB_CM_CLASS = 0x7,
+ IB_SNMP_CLASS = 0x8,
+ IB_VENDOR_RANGE1_START_CLASS = 0x9,
+ IB_VENDOR_RANGE1_END_CLASS = 0x0f,
+ IB_CC_CLASS = 0x21,
+ IB_VENDOR_RANGE2_START_CLASS = 0x30,
+ IB_VENDOR_RANGE2_END_CLASS = 0x4f,
+};
+
+enum MAD_METHODS {
+ IB_MAD_METHOD_GET = 0x1,
+ IB_MAD_METHOD_SET = 0x2,
+ IB_MAD_METHOD_GET_RESPONSE = 0x81,
+
+ IB_MAD_METHOD_SEND = 0x3,
+ IB_MAD_METHOD_TRAP = 0x5,
+ IB_MAD_METHOD_TRAP_REPRESS = 0x7,
+
+ IB_MAD_METHOD_REPORT = 0x6,
+ IB_MAD_METHOD_REPORT_RESPONSE = 0x86,
+ IB_MAD_METHOD_GET_TABLE = 0x12,
+ IB_MAD_METHOD_GET_TABLE_RESPONSE = 0x92,
+ IB_MAD_METHOD_GET_TRACE_TABLE = 0x13,
+ IB_MAD_METHOD_GET_TRACE_TABLE_RESPONSE = 0x93,
+ IB_MAD_METHOD_GETMULTI = 0x14,
+ IB_MAD_METHOD_GETMULTI_RESPONSE = 0x94,
+ IB_MAD_METHOD_DELETE = 0x15,
+ IB_MAD_METHOD_DELETE_RESPONSE = 0x95,
+
+ IB_MAD_RESPONSE = 0x80,
+};
+
+enum MAD_ATTR_ID {
+ CLASS_PORT_INFO = 0x1,
+ NOTICE = 0x2,
+ INFORM_INFO = 0x3,
+};
+
+enum MAD_STATUS {
+ IB_MAD_STS_OK = (0 << 2),
+ IB_MAD_STS_BUSY = (1 << 0),
+ IB_MAD_STS_REDIRECT = (1 << 1),
+ IB_MAD_STS_BAD_BASE_VER_OR_CLASS = (1 << 2),
+ IB_MAD_STS_METHOD_NOT_SUPPORTED = (2 << 2),
+ IB_MAD_STS_METHOD_ATTR_NOT_SUPPORTED = (3 << 2),
+ IB_MAD_STS_INV_ATTR_VALUE = (7 << 2),
+};
+
+enum SMI_ATTR_ID {
+ IB_ATTR_NODE_DESC = 0x10,
+ IB_ATTR_NODE_INFO = 0x11,
+ IB_ATTR_SWITCH_INFO = 0x12,
+ IB_ATTR_GUID_INFO = 0x14,
+ IB_ATTR_PORT_INFO = 0x15,
+ IB_ATTR_PKEY_TBL = 0x16,
+ IB_ATTR_SLVL_TABLE = 0x17,
+ IB_ATTR_VL_ARBITRATION = 0x18,
+ IB_ATTR_LINEARFORWTBL = 0x19,
+ IB_ATTR_MULTICASTFORWTBL = 0x1b,
+ IB_ATTR_LINKSPEEDWIDTHPAIRSTBL = 0x1c,
+ IB_ATTR_VENDORMADSTBL = 0x1d,
+ IB_ATTR_SMINFO = 0x20,
+ IB_ATTR_PORT_INFO_EXT = 0x33,
+ IB_ATTR_LAST,
+
+ IB_ATTR_MLNX_EXT_PORT_INFO = 0xff90,
+};
+
+enum SA_ATTR_ID {
+ IB_SA_ATTR_NOTICE = 0x02,
+ IB_SA_ATTR_INFORMINFO = 0x03,
+ IB_SA_ATTR_NODERECORD = 0x11,
+ IB_SA_ATTR_PORTINFORECORD = 0x12,
+ IB_SA_ATTR_SL2VLTABLERECORD = 0x13,
+ IB_SA_ATTR_SWITCHINFORECORD = 0x14,
+ IB_SA_ATTR_LFTRECORD = 0x15,
+ IB_SA_ATTR_RFTRECORD = 0x16,
+ IB_SA_ATTR_MFTRECORD = 0x17,
+ IB_SA_ATTR_SMINFORECORD = 0x18,
+ IB_SA_ATTR_LINKRECORD = 0x20,
+ IB_SA_ATTR_GUIDINFORECORD = 0x30,
+ IB_SA_ATTR_SERVICERECORD = 0x31,
+ IB_SA_ATTR_PKEYTABLERECORD = 0x33,
+ IB_SA_ATTR_PATHRECORD = 0x35,
+ IB_SA_ATTR_VLARBTABLERECORD = 0x36,
+ IB_SA_ATTR_MCRECORD = 0x38,
+ IB_SA_ATTR_MULTIPATH = 0x3a,
+ IB_SA_ATTR_INFORMINFORECORD = 0xf3,
+
+ IB_SA_ATTR_LAST
+};
+
+enum GSI_ATTR_ID {
+ IB_GSI_PORT_SAMPLES_CONTROL = 0x10,
+ IB_GSI_PORT_SAMPLES_RESULT = 0x11,
+ IB_GSI_PORT_COUNTERS = 0x12,
+ IB_GSI_PORT_RCV_ERROR_DETAILS = 0x15,
+ IB_GSI_PORT_XMIT_DISCARD_DETAILS = 0x16,
+ IB_GSI_PORT_PORT_OP_RCV_COUNTERS = 0x17,
+ IB_GSI_PORT_PORT_FLOW_CTL_COUNTERS = 0x18,
+ IB_GSI_PORT_PORT_VL_OP_PACKETS = 0x19,
+ IB_GSI_PORT_PORT_VL_OP_DATA = 0x1A,
+ IB_GSI_PORT_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS = 0x1B,
+ IB_GSI_PORT_PORT_VL_XMIT_WAIT_COUNTERS = 0x1C,
+ IB_GSI_PORT_COUNTERS_EXT = 0x1D,
+ IB_GSI_PORT_EXT_SPEEDS_COUNTERS = 0x1F,
+ IB_GSI_SW_PORT_VL_CONGESTION = 0x30,
+ IB_GSI_PORT_RCV_CON_CTRL = 0x31,
+ IB_GSI_PORT_SL_RCV_FECN = 0x32,
+ IB_GSI_PORT_SL_RCV_BECN = 0x33,
+ IB_GSI_PORT_XMIT_CON_CTRL = 0x34,
+ IB_GSI_PORT_VL_XMIT_TIME_CONG = 0x35,
+ IB_GSI_PORT_XMIT_DATA_SL = 0x36,
+ IB_GSI_PORT_RCV_DATA_SL = 0x37,
+ IB_GSI_ATTR_LAST
+};
+
+enum BM_ATTR_ID {
+ IB_BM_ATTR_BKEYINFO = 0x10,
+ IB_BM_ATTR_WRITE_VPD = 0x20,
+ IB_BM_ATTR_READ_VPD = 0x21,
+ IB_BM_ATTR_RESET_IBML = 0x22,
+ IB_BM_ATTR_SET_MODULE_PM_CONTROL = 0x23,
+ IB_BM_ATTR_GET_MODULE_PM_CONTROL = 0x24,
+ IB_BM_ATTR_SET_UNIT_PM_CONTROL = 0x25,
+ IB_BM_ATTR_GET_UNIT_PM_CONTROL = 0x26,
+ IB_BM_ATTR_SET_IOC_PM_CONTROL = 0x27,
+ IB_BM_ATTR_GET_IOC_PM_CONTROL = 0x28,
+ IB_BM_ATTR_SET_MODULE_STATE = 0x29,
+ IB_BM_ATTR_SET_MODULE_ATTENTION = 0x2A,
+ IB_BM_ATTR_GET_MODULE_STATUS = 0x2B,
+ IB_BM_ATTR_IB2IBML = 0x2C,
+ IB_BM_ATTR_IB2CME = 0x2D,
+ IB_BM_ATTR_IB2MME = 0x2E,
+ IB_BM_ATTR_OEM = 0x2F,
+
+ IB_BM_ATTR_LAST
+};
+
+enum CC_ATTRI_ID {
+ IB_CC_ATTR_CONGESTION_INFO = 0x11,
+ IB_CC_ATTR_CONGESTION_KEY_INFO = 0x12,
+ IB_CC_ATTR_CONGESTION_LOG = 0x13,
+ IB_CC_ATTR_SWITCH_CONGESTION_SETTING = 0x14,
+ IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING = 0x15,
+ IB_CC_ATTR_CA_CONGESTION_SETTING = 0x16,
+ IB_CC_ATTR_CONGESTION_CONTROL_TABLE = 0x17,
+ IB_CC_ATTR_TIMESTAMP = 0x18,
+};
+
+#define IB_VENDOR_OPENIB_PING_CLASS (IB_VENDOR_RANGE2_START_CLASS + 2)
+#define IB_VENDOR_OPENIB_SYSSTAT_CLASS (IB_VENDOR_RANGE2_START_CLASS + 3)
+#define IB_OPENIB_OUI (0x001405)
+
+typedef uint8_t ibmad_gid_t[16];
+#ifdef USE_DEPRECATED_IB_GID_T
+typedef ibmad_gid_t ib_gid_t __attribute__ ((deprecated));
+#endif
+
+typedef struct {
+ int cnt;
+ uint8_t p[IB_SUBNET_PATH_HOPS_MAX];
+ uint16_t drslid;
+ uint16_t drdlid;
+} ib_dr_path_t;
+
+typedef struct {
+ unsigned id;
+ unsigned mod;
+} ib_attr_t;
+
+typedef struct {
+ int mgtclass;
+ int method;
+ ib_attr_t attr;
+ uint32_t rstatus; /* return status */
+ int dataoffs;
+ int datasz;
+ uint64_t mkey;
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ uint64_t mask; /* for sa mads */
+ unsigned recsz; /* for sa mads (attribute offset) */
+ int timeout;
+ uint32_t oui; /* for vendor range 2 mads */
+} ib_rpc_t;
+
+typedef struct {
+ int mgtclass;
+ int method;
+ ib_attr_t attr;
+ uint32_t rstatus; /* return status */
+ int dataoffs;
+ int datasz;
+ uint64_t mkey;
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ uint64_t mask; /* for sa mads */
+ unsigned recsz; /* for sa mads (attribute offset) */
+ int timeout;
+ uint32_t oui; /* for vendor range 2 mads */
+ int error; /* errno */
+} ib_rpc_v1_t;
+
+typedef struct {
+ int mgtclass;
+ int method;
+ ib_attr_t attr;
+ uint32_t rstatus; /* return status */
+ int dataoffs;
+ int datasz;
+ uint64_t mkey;
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ uint64_t mask; /* for sa mads */
+ unsigned recsz; /* for sa mads (attribute offset) */
+ int timeout;
+ uint32_t oui; /* for vendor range 2 mads */
+ int error; /* errno */
+ uint64_t cckey;
+} ib_rpc_cc_t;
+
+typedef struct portid {
+ int lid; /* lid or 0 if directed route */
+ ib_dr_path_t drpath;
+ int grh_present; /* flag */
+ ibmad_gid_t gid;
+ uint32_t qp;
+ uint32_t qkey;
+ uint8_t sl;
+ unsigned pkey_idx;
+} ib_portid_t;
+
+typedef void (ib_mad_dump_fn) (char *buf, int bufsz, void *val, int valsz);
+
+#define IB_FIELD_NAME_LEN 32
+
+typedef struct ib_field {
+ int bitoffs;
+ int bitlen;
+ char name[IB_FIELD_NAME_LEN];
+ ib_mad_dump_fn *def_dump_fn;
+} ib_field_t;
+
+enum MAD_FIELDS {
+ IB_NO_FIELD,
+
+ IB_GID_PREFIX_F,
+ IB_GID_GUID_F,
+
+ /* first MAD word (0-3 bytes) */
+ IB_MAD_METHOD_F,
+ IB_MAD_RESPONSE_F,
+ IB_MAD_CLASSVER_F,
+ IB_MAD_MGMTCLASS_F,
+ IB_MAD_BASEVER_F,
+
+ /* second MAD word (4-7 bytes) */
+ IB_MAD_STATUS_F,
+
+ /* DRSMP only */
+ IB_DRSMP_HOPCNT_F,
+ IB_DRSMP_HOPPTR_F,
+ IB_DRSMP_STATUS_F,
+ IB_DRSMP_DIRECTION_F,
+
+ /* words 3,4,5,6 (8-23 bytes) */
+ IB_MAD_TRID_F,
+ IB_MAD_ATTRID_F,
+ IB_MAD_ATTRMOD_F,
+
+ /* word 7,8 (24-31 bytes) */
+ IB_MAD_MKEY_F,
+
+ /* word 9 (32-37 bytes) */
+ IB_DRSMP_DRDLID_F,
+ IB_DRSMP_DRSLID_F,
+
+ /* word 10,11 (36-43 bytes) */
+ IB_SA_MKEY_F,
+
+ /* word 12 (44-47 bytes) */
+ IB_SA_ATTROFFS_F,
+
+ /* word 13,14 (48-55 bytes) */
+ IB_SA_COMPMASK_F,
+
+ /* word 13,14 (56-255 bytes) */
+ IB_SA_DATA_F,
+
+ /* bytes 64 - 127 */
+ IB_SM_DATA_F,
+
+ /* bytes 64 - 256 */
+ IB_GS_DATA_F,
+
+ /* bytes 128 - 191 */
+ IB_DRSMP_PATH_F,
+
+ /* bytes 192 - 255 */
+ IB_DRSMP_RPATH_F,
+
+ /*
+ * PortInfo fields
+ */
+ IB_PORT_FIRST_F,
+ IB_PORT_MKEY_F = IB_PORT_FIRST_F,
+ IB_PORT_GID_PREFIX_F,
+ IB_PORT_LID_F,
+ IB_PORT_SMLID_F,
+ IB_PORT_CAPMASK_F,
+ IB_PORT_DIAG_F,
+ IB_PORT_MKEY_LEASE_F,
+ IB_PORT_LOCAL_PORT_F,
+ IB_PORT_LINK_WIDTH_ENABLED_F,
+ IB_PORT_LINK_WIDTH_SUPPORTED_F,
+ IB_PORT_LINK_WIDTH_ACTIVE_F,
+ IB_PORT_LINK_SPEED_SUPPORTED_F,
+ IB_PORT_STATE_F,
+ IB_PORT_PHYS_STATE_F,
+ IB_PORT_LINK_DOWN_DEF_F,
+ IB_PORT_MKEY_PROT_BITS_F,
+ IB_PORT_LMC_F,
+ IB_PORT_LINK_SPEED_ACTIVE_F,
+ IB_PORT_LINK_SPEED_ENABLED_F,
+ IB_PORT_NEIGHBOR_MTU_F,
+ IB_PORT_SMSL_F,
+ IB_PORT_VL_CAP_F,
+ IB_PORT_INIT_TYPE_F,
+ IB_PORT_VL_HIGH_LIMIT_F,
+ IB_PORT_VL_ARBITRATION_HIGH_CAP_F,
+ IB_PORT_VL_ARBITRATION_LOW_CAP_F,
+ IB_PORT_INIT_TYPE_REPLY_F,
+ IB_PORT_MTU_CAP_F,
+ IB_PORT_VL_STALL_COUNT_F,
+ IB_PORT_HOQ_LIFE_F,
+ IB_PORT_OPER_VLS_F,
+ IB_PORT_PART_EN_INB_F,
+ IB_PORT_PART_EN_OUTB_F,
+ IB_PORT_FILTER_RAW_INB_F,
+ IB_PORT_FILTER_RAW_OUTB_F,
+ IB_PORT_MKEY_VIOL_F,
+ IB_PORT_PKEY_VIOL_F,
+ IB_PORT_QKEY_VIOL_F,
+ IB_PORT_GUID_CAP_F,
+ IB_PORT_CLIENT_REREG_F,
+ IB_PORT_MCAST_PKEY_SUPR_ENAB_F,
+ IB_PORT_SUBN_TIMEOUT_F,
+ IB_PORT_RESP_TIME_VAL_F,
+ IB_PORT_LOCAL_PHYS_ERR_F,
+ IB_PORT_OVERRUN_ERR_F,
+ IB_PORT_MAX_CREDIT_HINT_F,
+ IB_PORT_LINK_ROUND_TRIP_F,
+ IB_PORT_LAST_F,
+
+ /*
+ * NodeInfo fields
+ */
+ IB_NODE_FIRST_F,
+ IB_NODE_BASE_VERS_F = IB_NODE_FIRST_F,
+ IB_NODE_CLASS_VERS_F,
+ IB_NODE_TYPE_F,
+ IB_NODE_NPORTS_F,
+ IB_NODE_SYSTEM_GUID_F,
+ IB_NODE_GUID_F,
+ IB_NODE_PORT_GUID_F,
+ IB_NODE_PARTITION_CAP_F,
+ IB_NODE_DEVID_F,
+ IB_NODE_REVISION_F,
+ IB_NODE_LOCAL_PORT_F,
+ IB_NODE_VENDORID_F,
+ IB_NODE_LAST_F,
+
+ /*
+ * SwitchInfo fields
+ */
+ IB_SW_FIRST_F,
+ IB_SW_LINEAR_FDB_CAP_F = IB_SW_FIRST_F,
+ IB_SW_RANDOM_FDB_CAP_F,
+ IB_SW_MCAST_FDB_CAP_F,
+ IB_SW_LINEAR_FDB_TOP_F,
+ IB_SW_DEF_PORT_F,
+ IB_SW_DEF_MCAST_PRIM_F,
+ IB_SW_DEF_MCAST_NOT_PRIM_F,
+ IB_SW_LIFE_TIME_F,
+ IB_SW_STATE_CHANGE_F,
+ IB_SW_OPT_SLTOVL_MAPPING_F,
+ IB_SW_LIDS_PER_PORT_F,
+ IB_SW_PARTITION_ENFORCE_CAP_F,
+ IB_SW_PARTITION_ENF_INB_F,
+ IB_SW_PARTITION_ENF_OUTB_F,
+ IB_SW_FILTER_RAW_INB_F,
+ IB_SW_FILTER_RAW_OUTB_F,
+ IB_SW_ENHANCED_PORT0_F,
+ IB_SW_MCAST_FDB_TOP_F,
+ IB_SW_LAST_F,
+
+ /*
+ * SwitchLinearForwardingTable fields
+ */
+ IB_LINEAR_FORW_TBL_F,
+
+ /*
+ * SwitchMulticastForwardingTable fields
+ */
+ IB_MULTICAST_FORW_TBL_F,
+
+ /*
+ * NodeDescription fields
+ */
+ IB_NODE_DESC_F,
+
+ /*
+ * Notice/Trap fields
+ */
+ IB_NOTICE_IS_GENERIC_F,
+ IB_NOTICE_TYPE_F,
+ IB_NOTICE_PRODUCER_F,
+ IB_NOTICE_TRAP_NUMBER_F,
+ IB_NOTICE_ISSUER_LID_F,
+ IB_NOTICE_TOGGLE_F,
+ IB_NOTICE_COUNT_F,
+ IB_NOTICE_DATA_DETAILS_F,
+ IB_NOTICE_DATA_LID_F,
+ IB_NOTICE_DATA_144_LID_F,
+ IB_NOTICE_DATA_144_CAPMASK_F,
+
+ /*
+ * GS Performance
+ */
+ IB_PC_FIRST_F,
+ IB_PC_PORT_SELECT_F = IB_PC_FIRST_F,
+ IB_PC_COUNTER_SELECT_F,
+ IB_PC_ERR_SYM_F,
+ IB_PC_LINK_RECOVERS_F,
+ IB_PC_LINK_DOWNED_F,
+ IB_PC_ERR_RCV_F,
+ IB_PC_ERR_PHYSRCV_F,
+ IB_PC_ERR_SWITCH_REL_F,
+ IB_PC_XMT_DISCARDS_F,
+ IB_PC_ERR_XMTCONSTR_F,
+ IB_PC_ERR_RCVCONSTR_F,
+ IB_PC_COUNTER_SELECT2_F,
+ IB_PC_ERR_LOCALINTEG_F,
+ IB_PC_ERR_EXCESS_OVR_F,
+ IB_PC_VL15_DROPPED_F,
+ IB_PC_XMT_BYTES_F,
+ IB_PC_RCV_BYTES_F,
+ IB_PC_XMT_PKTS_F,
+ IB_PC_RCV_PKTS_F,
+ IB_PC_XMT_WAIT_F,
+ IB_PC_LAST_F,
+
+ /*
+ * SMInfo
+ */
+ IB_SMINFO_GUID_F,
+ IB_SMINFO_KEY_F,
+ IB_SMINFO_ACT_F,
+ IB_SMINFO_PRIO_F,
+ IB_SMINFO_STATE_F,
+
+ /*
+ * SA RMPP
+ */
+ IB_SA_RMPP_VERS_F,
+ IB_SA_RMPP_TYPE_F,
+ IB_SA_RMPP_RESP_F,
+ IB_SA_RMPP_FLAGS_F,
+ IB_SA_RMPP_STATUS_F,
+
+ /* data1 */
+ IB_SA_RMPP_D1_F,
+ IB_SA_RMPP_SEGNUM_F,
+ /* data2 */
+ IB_SA_RMPP_D2_F,
+ IB_SA_RMPP_LEN_F, /* DATA: Payload len */
+ IB_SA_RMPP_NEWWIN_F, /* ACK: new window last */
+
+ /*
+ * SA Multi Path rec
+ */
+ IB_SA_MP_NPATH_F,
+ IB_SA_MP_NSRC_F,
+ IB_SA_MP_NDEST_F,
+ IB_SA_MP_GID0_F,
+
+ /*
+ * SA Path rec
+ */
+ IB_SA_PR_DGID_F,
+ IB_SA_PR_SGID_F,
+ IB_SA_PR_DLID_F,
+ IB_SA_PR_SLID_F,
+ IB_SA_PR_NPATH_F,
+ IB_SA_PR_SL_F,
+
+ /*
+ * MC Member rec
+ */
+ IB_SA_MCM_MGID_F,
+ IB_SA_MCM_PORTGID_F,
+ IB_SA_MCM_QKEY_F,
+ IB_SA_MCM_MLID_F,
+ IB_SA_MCM_SL_F,
+ IB_SA_MCM_MTU_F,
+ IB_SA_MCM_RATE_F,
+ IB_SA_MCM_TCLASS_F,
+ IB_SA_MCM_PKEY_F,
+ IB_SA_MCM_FLOW_LABEL_F,
+ IB_SA_MCM_JOIN_STATE_F,
+ IB_SA_MCM_PROXY_JOIN_F,
+
+ /*
+ * Service record
+ */
+ IB_SA_SR_ID_F,
+ IB_SA_SR_GID_F,
+ IB_SA_SR_PKEY_F,
+ IB_SA_SR_LEASE_F,
+ IB_SA_SR_KEY_F,
+ IB_SA_SR_NAME_F,
+ IB_SA_SR_DATA_F,
+
+ /*
+ * ATS SM record - within SA_SR_DATA
+ */
+ IB_ATS_SM_NODE_ADDR_F,
+ IB_ATS_SM_MAGIC_KEY_F,
+ IB_ATS_SM_NODE_TYPE_F,
+ IB_ATS_SM_NODE_NAME_F,
+
+ /*
+ * SLTOVL MAPPING TABLE
+ */
+ IB_SLTOVL_MAPPING_TABLE_F,
+
+ /*
+ * VL ARBITRATION TABLE
+ */
+ IB_VL_ARBITRATION_TABLE_F,
+
+ /*
+ * IB vendor class range 2
+ */
+ IB_VEND2_OUI_F,
+ IB_VEND2_DATA_F,
+
+ /*
+ * PortCountersExtended
+ */
+ IB_PC_EXT_FIRST_F,
+ IB_PC_EXT_PORT_SELECT_F = IB_PC_EXT_FIRST_F,
+ IB_PC_EXT_COUNTER_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F,
+ IB_PC_EXT_RCV_BYTES_F,
+ IB_PC_EXT_XMT_PKTS_F,
+ IB_PC_EXT_RCV_PKTS_F,
+ IB_PC_EXT_XMT_UPKTS_F,
+ IB_PC_EXT_RCV_UPKTS_F,
+ IB_PC_EXT_XMT_MPKTS_F,
+ IB_PC_EXT_RCV_MPKTS_F,
+ IB_PC_EXT_LAST_F,
+
+ /*
+ * GUIDInfo fields
+ */
+ IB_GUID_GUID0_F, /* Obsolete, kept for compatibility
+ Use IB_GI_GUID0_F going forward */
+
+ /*
+ * ClassPortInfo fields
+ */
+ IB_CPI_BASEVER_F,
+ IB_CPI_CLASSVER_F,
+ IB_CPI_CAPMASK_F,
+ IB_CPI_CAPMASK2_F,
+ IB_CPI_RESP_TIME_VALUE_F,
+ IB_CPI_REDIRECT_GID_F,
+ IB_CPI_REDIRECT_TC_F,
+ IB_CPI_REDIRECT_SL_F,
+ IB_CPI_REDIRECT_FL_F,
+ IB_CPI_REDIRECT_LID_F,
+ IB_CPI_REDIRECT_PKEY_F,
+ IB_CPI_REDIRECT_QP_F,
+ IB_CPI_REDIRECT_QKEY_F,
+ IB_CPI_TRAP_GID_F,
+ IB_CPI_TRAP_TC_F,
+ IB_CPI_TRAP_SL_F,
+ IB_CPI_TRAP_FL_F,
+ IB_CPI_TRAP_LID_F,
+ IB_CPI_TRAP_PKEY_F,
+ IB_CPI_TRAP_HL_F,
+ IB_CPI_TRAP_QP_F,
+ IB_CPI_TRAP_QKEY_F,
+
+ /*
+ * PortXmitDataSL fields
+ */
+ IB_PC_XMT_DATA_SL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_XMT_DATA_SL0_F = IB_PC_XMT_DATA_SL_FIRST_F,
+ IB_PC_XMT_DATA_SL1_F,
+ IB_PC_XMT_DATA_SL2_F,
+ IB_PC_XMT_DATA_SL3_F,
+ IB_PC_XMT_DATA_SL4_F,
+ IB_PC_XMT_DATA_SL5_F,
+ IB_PC_XMT_DATA_SL6_F,
+ IB_PC_XMT_DATA_SL7_F,
+ IB_PC_XMT_DATA_SL8_F,
+ IB_PC_XMT_DATA_SL9_F,
+ IB_PC_XMT_DATA_SL10_F,
+ IB_PC_XMT_DATA_SL11_F,
+ IB_PC_XMT_DATA_SL12_F,
+ IB_PC_XMT_DATA_SL13_F,
+ IB_PC_XMT_DATA_SL14_F,
+ IB_PC_XMT_DATA_SL15_F,
+ IB_PC_XMT_DATA_SL_LAST_F,
+
+ /*
+ * PortRcvDataSL fields
+ */
+ IB_PC_RCV_DATA_SL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_RCV_DATA_SL0_F = IB_PC_RCV_DATA_SL_FIRST_F,
+ IB_PC_RCV_DATA_SL1_F,
+ IB_PC_RCV_DATA_SL2_F,
+ IB_PC_RCV_DATA_SL3_F,
+ IB_PC_RCV_DATA_SL4_F,
+ IB_PC_RCV_DATA_SL5_F,
+ IB_PC_RCV_DATA_SL6_F,
+ IB_PC_RCV_DATA_SL7_F,
+ IB_PC_RCV_DATA_SL8_F,
+ IB_PC_RCV_DATA_SL9_F,
+ IB_PC_RCV_DATA_SL10_F,
+ IB_PC_RCV_DATA_SL11_F,
+ IB_PC_RCV_DATA_SL12_F,
+ IB_PC_RCV_DATA_SL13_F,
+ IB_PC_RCV_DATA_SL14_F,
+ IB_PC_RCV_DATA_SL15_F,
+ IB_PC_RCV_DATA_SL_LAST_F,
+
+ /*
+ * PortXmitDiscardDetails fields
+ */
+ /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_XMT_INACT_DISC_F,
+ IB_PC_XMT_NEIGH_MTU_DISC_F,
+ IB_PC_XMT_SW_LIFE_DISC_F,
+ IB_PC_XMT_SW_HOL_DISC_F,
+ IB_PC_XMT_DISC_LAST_F,
+
+ /*
+ * PortRcvErrorDetails fields
+ */
+ /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_RCV_LOCAL_PHY_ERR_F,
+ IB_PC_RCV_MALFORMED_PKT_ERR_F,
+ IB_PC_RCV_BUF_OVR_ERR_F,
+ IB_PC_RCV_DLID_MAP_ERR_F,
+ IB_PC_RCV_VL_MAP_ERR_F,
+ IB_PC_RCV_LOOPING_ERR_F,
+ IB_PC_RCV_ERR_LAST_F,
+
+ /*
+ * PortSamplesControl fields
+ */
+ IB_PSC_OPCODE_F,
+ IB_PSC_PORT_SELECT_F,
+ IB_PSC_TICK_F,
+ IB_PSC_COUNTER_WIDTH_F,
+ IB_PSC_COUNTER_MASK0_F,
+ IB_PSC_COUNTER_MASKS1TO9_F,
+ IB_PSC_COUNTER_MASKS10TO14_F,
+ IB_PSC_SAMPLE_MECHS_F,
+ IB_PSC_SAMPLE_STATUS_F,
+ IB_PSC_OPTION_MASK_F,
+ IB_PSC_VENDOR_MASK_F,
+ IB_PSC_SAMPLE_START_F,
+ IB_PSC_SAMPLE_INTVL_F,
+ IB_PSC_TAG_F,
+ IB_PSC_COUNTER_SEL0_F,
+ IB_PSC_COUNTER_SEL1_F,
+ IB_PSC_COUNTER_SEL2_F,
+ IB_PSC_COUNTER_SEL3_F,
+ IB_PSC_COUNTER_SEL4_F,
+ IB_PSC_COUNTER_SEL5_F,
+ IB_PSC_COUNTER_SEL6_F,
+ IB_PSC_COUNTER_SEL7_F,
+ IB_PSC_COUNTER_SEL8_F,
+ IB_PSC_COUNTER_SEL9_F,
+ IB_PSC_COUNTER_SEL10_F,
+ IB_PSC_COUNTER_SEL11_F,
+ IB_PSC_COUNTER_SEL12_F,
+ IB_PSC_COUNTER_SEL13_F,
+ IB_PSC_COUNTER_SEL14_F,
+ IB_PSC_SAMPLES_ONLY_OPT_MASK_F,
+ IB_PSC_LAST_F,
+
+ /*
+ * GUIDInfo fields
+ */
+ IB_GI_GUID0_F, /* a duplicate of IB_GUID_GUID0_F for backwards
+ compatibility */
+ IB_GI_GUID1_F,
+ IB_GI_GUID2_F,
+ IB_GI_GUID3_F,
+ IB_GI_GUID4_F,
+ IB_GI_GUID5_F,
+ IB_GI_GUID6_F,
+ IB_GI_GUID7_F,
+
+ /*
+ * GUID Info Record
+ */
+ IB_SA_GIR_LID_F,
+ IB_SA_GIR_BLOCKNUM_F,
+ IB_SA_GIR_GUID0_F,
+ IB_SA_GIR_GUID1_F,
+ IB_SA_GIR_GUID2_F,
+ IB_SA_GIR_GUID3_F,
+ IB_SA_GIR_GUID4_F,
+ IB_SA_GIR_GUID5_F,
+ IB_SA_GIR_GUID6_F,
+ IB_SA_GIR_GUID7_F,
+
+ /*
+ * More PortInfo fields
+ */
+ IB_PORT_CAPMASK2_F,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
+ IB_PORT_LINK_SPEED_EXT_ENABLED_F,
+ IB_PORT_LINK_SPEED_EXT_LAST_F,
+
+ /*
+ * PortExtendedSpeedsCounters fields
+ */
+ IB_PESC_PORT_SELECT_F,
+ IB_PESC_COUNTER_SELECT_F,
+ IB_PESC_SYNC_HDR_ERR_CTR_F,
+ IB_PESC_UNK_BLOCK_CTR_F,
+ IB_PESC_ERR_DET_CTR_LANE0_F,
+ IB_PESC_ERR_DET_CTR_LANE1_F,
+ IB_PESC_ERR_DET_CTR_LANE2_F,
+ IB_PESC_ERR_DET_CTR_LANE3_F,
+ IB_PESC_ERR_DET_CTR_LANE4_F,
+ IB_PESC_ERR_DET_CTR_LANE5_F,
+ IB_PESC_ERR_DET_CTR_LANE6_F,
+ IB_PESC_ERR_DET_CTR_LANE7_F,
+ IB_PESC_ERR_DET_CTR_LANE8_F,
+ IB_PESC_ERR_DET_CTR_LANE9_F,
+ IB_PESC_ERR_DET_CTR_LANE10_F,
+ IB_PESC_ERR_DET_CTR_LANE11_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE0_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE1_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE2_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE3_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE4_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE5_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE6_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE7_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE8_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE9_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE10_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE11_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE0_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE1_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE2_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE3_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE4_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE5_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE6_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE7_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE8_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE9_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE10_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE11_F,
+ IB_PESC_LAST_F,
+
+ /*
+ * PortOpRcvCounters fields
+ */
+ IB_PC_PORT_OP_RCV_COUNTERS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_OP_RCV_PKTS_F = IB_PC_PORT_OP_RCV_COUNTERS_FIRST_F,
+ IB_PC_PORT_OP_RCV_DATA_F,
+ IB_PC_PORT_OP_RCV_COUNTERS_LAST_F,
+
+ /*
+ * PortFlowCtlCounters fields
+ */
+ IB_PC_PORT_FLOW_CTL_COUNTERS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_XMIT_FLOW_PKTS_F = IB_PC_PORT_FLOW_CTL_COUNTERS_FIRST_F,
+ IB_PC_PORT_RCV_FLOW_PKTS_F,
+ IB_PC_PORT_FLOW_CTL_COUNTERS_LAST_F,
+
+ /*
+ * PortVLOpPackets fields
+ */
+ IB_PC_PORT_VL_OP_PACKETS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_OP_PACKETS0_F = IB_PC_PORT_VL_OP_PACKETS_FIRST_F,
+ IB_PC_PORT_VL_OP_PACKETS1_F,
+ IB_PC_PORT_VL_OP_PACKETS2_F,
+ IB_PC_PORT_VL_OP_PACKETS3_F,
+ IB_PC_PORT_VL_OP_PACKETS4_F,
+ IB_PC_PORT_VL_OP_PACKETS5_F,
+ IB_PC_PORT_VL_OP_PACKETS6_F,
+ IB_PC_PORT_VL_OP_PACKETS7_F,
+ IB_PC_PORT_VL_OP_PACKETS8_F,
+ IB_PC_PORT_VL_OP_PACKETS9_F,
+ IB_PC_PORT_VL_OP_PACKETS10_F,
+ IB_PC_PORT_VL_OP_PACKETS11_F,
+ IB_PC_PORT_VL_OP_PACKETS12_F,
+ IB_PC_PORT_VL_OP_PACKETS13_F,
+ IB_PC_PORT_VL_OP_PACKETS14_F,
+ IB_PC_PORT_VL_OP_PACKETS15_F,
+ IB_PC_PORT_VL_OP_PACKETS_LAST_F,
+
+ /*
+ * PortVLOpData fields
+ */
+ IB_PC_PORT_VL_OP_DATA_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_OP_DATA0_F = IB_PC_PORT_VL_OP_DATA_FIRST_F,
+ IB_PC_PORT_VL_OP_DATA1_F,
+ IB_PC_PORT_VL_OP_DATA2_F,
+ IB_PC_PORT_VL_OP_DATA3_F,
+ IB_PC_PORT_VL_OP_DATA4_F,
+ IB_PC_PORT_VL_OP_DATA5_F,
+ IB_PC_PORT_VL_OP_DATA6_F,
+ IB_PC_PORT_VL_OP_DATA7_F,
+ IB_PC_PORT_VL_OP_DATA8_F,
+ IB_PC_PORT_VL_OP_DATA9_F,
+ IB_PC_PORT_VL_OP_DATA10_F,
+ IB_PC_PORT_VL_OP_DATA11_F,
+ IB_PC_PORT_VL_OP_DATA12_F,
+ IB_PC_PORT_VL_OP_DATA13_F,
+ IB_PC_PORT_VL_OP_DATA14_F,
+ IB_PC_PORT_VL_OP_DATA15_F,
+ IB_PC_PORT_VL_OP_DATA_LAST_F,
+
+ /*
+ * PortVLXmitFlowCtlUpdateErrors fields
+ */
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS0_F = IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS1_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS2_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS3_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS4_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS5_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS6_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS7_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS8_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS9_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS10_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS11_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS12_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS13_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS14_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS15_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_LAST_F,
+
+ /*
+ * PortVLXmitWaitCounters fields
+ */
+ IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_XMIT_WAIT0_F = IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_WAIT1_F,
+ IB_PC_PORT_VL_XMIT_WAIT2_F,
+ IB_PC_PORT_VL_XMIT_WAIT3_F,
+ IB_PC_PORT_VL_XMIT_WAIT4_F,
+ IB_PC_PORT_VL_XMIT_WAIT5_F,
+ IB_PC_PORT_VL_XMIT_WAIT6_F,
+ IB_PC_PORT_VL_XMIT_WAIT7_F,
+ IB_PC_PORT_VL_XMIT_WAIT8_F,
+ IB_PC_PORT_VL_XMIT_WAIT9_F,
+ IB_PC_PORT_VL_XMIT_WAIT10_F,
+ IB_PC_PORT_VL_XMIT_WAIT11_F,
+ IB_PC_PORT_VL_XMIT_WAIT12_F,
+ IB_PC_PORT_VL_XMIT_WAIT13_F,
+ IB_PC_PORT_VL_XMIT_WAIT14_F,
+ IB_PC_PORT_VL_XMIT_WAIT15_F,
+ IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_LAST_F,
+
+ /*
+ * SwPortVLCongestion fields
+ */
+ IB_PC_SW_PORT_VL_CONGESTION_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_SW_PORT_VL_CONGESTION0_F = IB_PC_SW_PORT_VL_CONGESTION_FIRST_F,
+ IB_PC_SW_PORT_VL_CONGESTION1_F,
+ IB_PC_SW_PORT_VL_CONGESTION2_F,
+ IB_PC_SW_PORT_VL_CONGESTION3_F,
+ IB_PC_SW_PORT_VL_CONGESTION4_F,
+ IB_PC_SW_PORT_VL_CONGESTION5_F,
+ IB_PC_SW_PORT_VL_CONGESTION6_F,
+ IB_PC_SW_PORT_VL_CONGESTION7_F,
+ IB_PC_SW_PORT_VL_CONGESTION8_F,
+ IB_PC_SW_PORT_VL_CONGESTION9_F,
+ IB_PC_SW_PORT_VL_CONGESTION10_F,
+ IB_PC_SW_PORT_VL_CONGESTION11_F,
+ IB_PC_SW_PORT_VL_CONGESTION12_F,
+ IB_PC_SW_PORT_VL_CONGESTION13_F,
+ IB_PC_SW_PORT_VL_CONGESTION14_F,
+ IB_PC_SW_PORT_VL_CONGESTION15_F,
+ IB_PC_SW_PORT_VL_CONGESTION_LAST_F,
+
+ /*
+ * PortRcvConCtrl fields
+ */
+ IB_PC_RCV_CON_CTRL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_RCV_CON_CTRL_PKT_RCV_FECN_F = IB_PC_RCV_CON_CTRL_FIRST_F,
+ IB_PC_RCV_CON_CTRL_PKT_RCV_BECN_F,
+ IB_PC_RCV_CON_CTRL_LAST_F,
+
+ /*
+ * PortSLRcvFECN fields
+ */
+ IB_PC_SL_RCV_FECN_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_SL_RCV_FECN0_F = IB_PC_SL_RCV_FECN_FIRST_F,
+ IB_PC_SL_RCV_FECN1_F,
+ IB_PC_SL_RCV_FECN2_F,
+ IB_PC_SL_RCV_FECN3_F,
+ IB_PC_SL_RCV_FECN4_F,
+ IB_PC_SL_RCV_FECN5_F,
+ IB_PC_SL_RCV_FECN6_F,
+ IB_PC_SL_RCV_FECN7_F,
+ IB_PC_SL_RCV_FECN8_F,
+ IB_PC_SL_RCV_FECN9_F,
+ IB_PC_SL_RCV_FECN10_F,
+ IB_PC_SL_RCV_FECN11_F,
+ IB_PC_SL_RCV_FECN12_F,
+ IB_PC_SL_RCV_FECN13_F,
+ IB_PC_SL_RCV_FECN14_F,
+ IB_PC_SL_RCV_FECN15_F,
+ IB_PC_SL_RCV_FECN_LAST_F,
+
+ /*
+ * PortSLRcvBECN fields
+ */
+ IB_PC_SL_RCV_BECN_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_SL_RCV_BECN0_F = IB_PC_SL_RCV_BECN_FIRST_F,
+ IB_PC_SL_RCV_BECN1_F,
+ IB_PC_SL_RCV_BECN2_F,
+ IB_PC_SL_RCV_BECN3_F,
+ IB_PC_SL_RCV_BECN4_F,
+ IB_PC_SL_RCV_BECN5_F,
+ IB_PC_SL_RCV_BECN6_F,
+ IB_PC_SL_RCV_BECN7_F,
+ IB_PC_SL_RCV_BECN8_F,
+ IB_PC_SL_RCV_BECN9_F,
+ IB_PC_SL_RCV_BECN10_F,
+ IB_PC_SL_RCV_BECN11_F,
+ IB_PC_SL_RCV_BECN12_F,
+ IB_PC_SL_RCV_BECN13_F,
+ IB_PC_SL_RCV_BECN14_F,
+ IB_PC_SL_RCV_BECN15_F,
+ IB_PC_SL_RCV_BECN_LAST_F,
+
+ /*
+ * PortXmitConCtrl fields
+ */
+ IB_PC_XMIT_CON_CTRL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_XMIT_CON_CTRL_TIME_CONG_F = IB_PC_XMIT_CON_CTRL_FIRST_F,
+ IB_PC_XMIT_CON_CTRL_LAST_F,
+
+ /*
+ * PortVLXmitTimeCong fields
+ */
+ IB_PC_VL_XMIT_TIME_CONG_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_VL_XMIT_TIME_CONG0_F = IB_PC_VL_XMIT_TIME_CONG_FIRST_F,
+ IB_PC_VL_XMIT_TIME_CONG1_F,
+ IB_PC_VL_XMIT_TIME_CONG2_F,
+ IB_PC_VL_XMIT_TIME_CONG3_F,
+ IB_PC_VL_XMIT_TIME_CONG4_F,
+ IB_PC_VL_XMIT_TIME_CONG5_F,
+ IB_PC_VL_XMIT_TIME_CONG6_F,
+ IB_PC_VL_XMIT_TIME_CONG7_F,
+ IB_PC_VL_XMIT_TIME_CONG8_F,
+ IB_PC_VL_XMIT_TIME_CONG9_F,
+ IB_PC_VL_XMIT_TIME_CONG10_F,
+ IB_PC_VL_XMIT_TIME_CONG11_F,
+ IB_PC_VL_XMIT_TIME_CONG12_F,
+ IB_PC_VL_XMIT_TIME_CONG13_F,
+ IB_PC_VL_XMIT_TIME_CONG14_F,
+ IB_PC_VL_XMIT_TIME_CONG_LAST_F,
+
+ /*
+ * Mellanox ExtendedPortInfo fields
+ */
+ IB_MLNX_EXT_PORT_STATE_CHG_ENABLE_F,
+ IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F,
+ IB_MLNX_EXT_PORT_LAST_F,
+
+ /*
+ * Congestion Control Mad fields
+ * bytes 24-31 of congestion control mad
+ */
+ IB_CC_CCKEY_F,
+
+ /*
+ * CongestionInfo fields
+ */
+ IB_CC_CONGESTION_INFO_FIRST_F,
+ IB_CC_CONGESTION_INFO_F = IB_CC_CONGESTION_INFO_FIRST_F,
+ IB_CC_CONGESTION_INFO_CONTROL_TABLE_CAP_F,
+ IB_CC_CONGESTION_INFO_LAST_F,
+
+ /*
+ * CongestionKeyInfo fields
+ */
+ IB_CC_CONGESTION_KEY_INFO_FIRST_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_F = IB_CC_CONGESTION_KEY_INFO_FIRST_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_PROTECT_BIT_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_LEASE_PERIOD_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_VIOLATIONS_F,
+ IB_CC_CONGESTION_KEY_INFO_LAST_F,
+
+ /*
+ * CongestionLog (common) fields
+ */
+ IB_CC_CONGESTION_LOG_FIRST_F,
+ IB_CC_CONGESTION_LOG_LOGTYPE_F = IB_CC_CONGESTION_LOG_FIRST_F,
+ IB_CC_CONGESTION_LOG_CONGESTION_FLAGS_F,
+ IB_CC_CONGESTION_LOG_LAST_F,
+
+ /*
+ * CongestionLog (Switch) fields
+ */
+ IB_CC_CONGESTION_LOG_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_SWITCH_LOG_EVENTS_COUNTER_F = IB_CC_CONGESTION_LOG_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_SWITCH_CURRENT_TIME_STAMP_F,
+ IB_CC_CONGESTION_LOG_SWITCH_PORTMAP_F,
+ IB_CC_CONGESTION_LOG_SWITCH_LAST_F,
+
+ /*
+ * CongestionLogEvent (Switch) fields
+ */
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_SLID_F = IB_CC_CONGESTION_LOG_ENTRY_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_DLID_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_SL_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_TIMESTAMP_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_LAST_F,
+
+ /*
+ * CongestionLog (CA) fields
+ */
+ IB_CC_CONGESTION_LOG_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_CA_THRESHOLD_EVENT_COUNTER_F = IB_CC_CONGESTION_LOG_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_CA_THRESHOLD_CONGESTION_EVENT_MAP_F,
+ IB_CC_CONGESTION_LOG_CA_CURRENT_TIMESTAMP_F,
+ IB_CC_CONGESTION_LOG_CA_LAST_F,
+
+ /*
+ * CongestionLogEvent (CA) fields
+ */
+ IB_CC_CONGESTION_LOG_ENTRY_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LOCAL_QP_CN_ENTRY_F = IB_CC_CONGESTION_LOG_ENTRY_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_SL_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_SERVICE_TYPE_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_REMOTE_QP_NUMBER_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LOCAL_LID_CN_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_REMOTE_LID_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_TIMESTAMP_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LAST_F,
+
+ /*
+ * SwitchCongestionSetting fields
+ */
+ IB_CC_SWITCH_CONGESTION_SETTING_FIRST_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CONTROL_MAP_F = IB_CC_SWITCH_CONGESTION_SETTING_FIRST_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_VICTIM_MASK_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CREDIT_MASK_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_THRESHOLD_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_PACKET_SIZE_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CS_THRESHOLD_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CS_RETURN_DELAY_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_MARKING_RATE_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_LAST_F,
+
+ /*
+ * SwitchPortCongestionSettingElement fields
+ */
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_FIRST_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_VALID_F = IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_FIRST_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_CONTROL_TYPE_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_THRESHOLD_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_PACKET_SIZE_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_CONG_PARM_MARKING_RATE_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_LAST_F,
+
+ /*
+ * CACongestionSetting fields
+ */
+ IB_CC_CA_CONGESTION_SETTING_FIRST_F,
+ IB_CC_CA_CONGESTION_SETTING_PORT_CONTROL_F = IB_CC_CA_CONGESTION_SETTING_FIRST_F,
+ IB_CC_CA_CONGESTION_SETTING_CONTROL_MAP_F,
+ IB_CC_CA_CONGESTION_SETTING_LAST_F,
+
+ /*
+ * CACongestionEntry fields
+ */
+ IB_CC_CA_CONGESTION_ENTRY_FIRST_F,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_TIMER_F = IB_CC_CA_CONGESTION_ENTRY_FIRST_F,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_INCREASE_F,
+ IB_CC_CA_CONGESTION_ENTRY_TRIGGER_THRESHOLD_F,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_MIN_F,
+ IB_CC_CA_CONGESTION_ENTRY_LAST_F,
+
+ /*
+ * CongestionControlTable fields
+ */
+ IB_CC_CONGESTION_CONTROL_TABLE_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_CCTI_LIMIT_F = IB_CC_CONGESTION_CONTROL_TABLE_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_LAST_F,
+
+ /*
+ * CongestionControlTableEntry fields
+ */
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_CCT_SHIFT_F = IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_CCT_MULTIPLIER_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_LAST_F,
+
+ /*
+ * Timestamp fields
+ */
+ IB_CC_TIMESTAMP_FIRST_F,
+ IB_CC_TIMESTAMP_F = IB_CC_TIMESTAMP_FIRST_F,
+ IB_CC_TIMESTAMP_LAST_F,
+
+ /*
+ * Node Record
+ */
+ IB_SA_NR_FIRST_F,
+ IB_SA_NR_LID_F = IB_SA_NR_FIRST_F,
+ IB_SA_NR_BASEVER_F,
+ IB_SA_NR_CLASSVER_F,
+ IB_SA_NR_TYPE_F,
+ IB_SA_NR_NPORTS_F,
+ IB_SA_NR_SYSTEM_GUID_F,
+ IB_SA_NR_GUID_F,
+ IB_SA_NR_PORT_GUID_F,
+ IB_SA_NR_PARTITION_CAP_F,
+ IB_SA_NR_DEVID_F,
+ IB_SA_NR_REVISION_F,
+ IB_SA_NR_LOCAL_PORT_F,
+ IB_SA_NR_VENDORID_F,
+ IB_SA_NR_NODEDESC_F,
+ IB_SA_NR_LAST_F,
+
+ /*
+ * PortMirrorRoute fields
+ */
+ IB_PMR_FIRST_F,
+ IB_PMR_ENCAP_RAW_ETH_TYPE_F = IB_PMR_FIRST_F,
+ IB_PMR_MAX_MIRROR_LEN_F,
+ IB_PMR_MT_F,
+ IB_PMR_BF_F,
+ IB_PMR_NM_PORT_F,
+ IB_PMR_LRH_VL_F,
+ IB_PMR_LRH_LVER_F,
+ IB_PMR_LRH_SL_F,
+ IB_PMR_LRH_LNH_F,
+ IB_PMR_LRH_DLID_F,
+ IB_PMR_LRH_LEN_F,
+ IB_PMR_LRH_SLID_F,
+ IB_PMR_LAST_F,
+
+ /*
+ * PortMirrorFilter fields
+ */
+ IB_PMF_FIRST_F,
+ IB_PMF_MIRROR_FILTER0_F = IB_PMF_FIRST_F,
+ IB_PMF_MIRROR_FILTER1_F,
+ IB_PMF_MIRROR_MASK0_F,
+ IB_PMF_MIRROR_MASK1_F,
+ IB_PMF_MIRROR_MASK2_F,
+ IB_PMF_MIRROR_MASK3_F,
+ IB_PMF_B0_F,
+ IB_PMF_MIRROR_MASK_OFFS_0,
+ IB_PMF_B1_F,
+ IB_PMF_MIRROR_MASK_OFFS_1,
+ IB_PMF_B2_F,
+ IB_PMF_MIRROR_MASK_OFFS_2,
+ IB_PMF_B3_F,
+ IB_PMF_MIRROR_MASK_OFFS_3,
+ IB_PMF_LAST_F,
+
+ /*
+ * PortMirrorPorts fields
+ */
+ IB_PMP_FIRST_F,
+ IB_PMP_TQ_1_F = IB_PMP_FIRST_F,
+ IB_PMP_RQ_1_F,
+ IB_PMP_TQ_2_F,
+ IB_PMP_RQ_2_F,
+ IB_PMP_TQ_3_F,
+ IB_PMP_RQ_3_F,
+ IB_PMP_TQ_4_F,
+ IB_PMP_RQ_4_F,
+ IB_PMP_TQ_5_F,
+ IB_PMP_RQ_5_F,
+ IB_PMP_TQ_6_F,
+ IB_PMP_RQ_6_F,
+ IB_PMP_TQ_7_F,
+ IB_PMP_RQ_7_F,
+ IB_PMP_TQ_8_F,
+ IB_PMP_RQ_8_F,
+ IB_PMP_TQ_9_F,
+ IB_PMP_RQ_9_F,
+ IB_PMP_TQ_10_F,
+ IB_PMP_RQ_10_F,
+ IB_PMP_TQ_11_F,
+ IB_PMP_RQ_11_F,
+ IB_PMP_TQ_12_F,
+ IB_PMP_RQ_12_F,
+ IB_PMP_TQ_13_F,
+ IB_PMP_RQ_13_F,
+ IB_PMP_TQ_14_F,
+ IB_PMP_RQ_14_F,
+ IB_PMP_TQ_15_F,
+ IB_PMP_RQ_15_F,
+ IB_PMP_TQ_16_F,
+ IB_PMP_RQ_16_F,
+ IB_PMP_TQ_17_F,
+ IB_PMP_RQ_17_F,
+ IB_PMP_TQ_18_F,
+ IB_PMP_RQ_18_F,
+ IB_PMP_TQ_19_F,
+ IB_PMP_RQ_19_F,
+ IB_PMP_TQ_20_F,
+ IB_PMP_RQ_20_F,
+ IB_PMP_TQ_21_F,
+ IB_PMP_RQ_21_F,
+ IB_PMP_TQ_22_F,
+ IB_PMP_RQ_22_F,
+ IB_PMP_TQ_23_F,
+ IB_PMP_RQ_23_F,
+ IB_PMP_TQ_24_F,
+ IB_PMP_RQ_24_F,
+ IB_PMP_TQ_25_F,
+ IB_PMP_RQ_25_F,
+ IB_PMP_TQ_26_F,
+ IB_PMP_RQ_26_F,
+ IB_PMP_TQ_27_F,
+ IB_PMP_RQ_27_F,
+ IB_PMP_TQ_28_F,
+ IB_PMP_RQ_28_F,
+ IB_PMP_TQ_29_F,
+ IB_PMP_RQ_29_F,
+ IB_PMP_TQ_30_F,
+ IB_PMP_RQ_30_F,
+ IB_PMP_TQ_31_F,
+ IB_PMP_RQ_31_F,
+ IB_PMP_TQ_32_F,
+ IB_PMP_RQ_32_F,
+ IB_PMP_TQ_33_F,
+ IB_PMP_RQ_33_F,
+ IB_PMP_TQ_34_F,
+ IB_PMP_RQ_34_F,
+ IB_PMP_TQ_35_F,
+ IB_PMP_RQ_35_F,
+ IB_PMP_TQ_36_F,
+ IB_PMP_RQ_36_F,
+ IB_PMP_LAST_F,
+
+ /*
+ * PortSamplesResult fields
+ */
+ IB_PSR_TAG_F,
+ IB_PSR_SAMPLE_STATUS_F,
+ IB_PSR_COUNTER0_F,
+ IB_PSR_COUNTER1_F,
+ IB_PSR_COUNTER2_F,
+ IB_PSR_COUNTER3_F,
+ IB_PSR_COUNTER4_F,
+ IB_PSR_COUNTER5_F,
+ IB_PSR_COUNTER6_F,
+ IB_PSR_COUNTER7_F,
+ IB_PSR_COUNTER8_F,
+ IB_PSR_COUNTER9_F,
+ IB_PSR_COUNTER10_F,
+ IB_PSR_COUNTER11_F,
+ IB_PSR_COUNTER12_F,
+ IB_PSR_COUNTER13_F,
+ IB_PSR_COUNTER14_F,
+ IB_PSR_LAST_F,
+
+ /*
+ * PortInfoExtended fields
+ */
+ IB_PORT_EXT_FIRST_F,
+ IB_PORT_EXT_CAPMASK_F = IB_PORT_EXT_FIRST_F,
+ IB_PORT_EXT_FEC_MODE_ACTIVE_F,
+ IB_PORT_EXT_FDR_FEC_MODE_SUPPORTED_F,
+ IB_PORT_EXT_FDR_FEC_MODE_ENABLED_F,
+ IB_PORT_EXT_EDR_FEC_MODE_SUPPORTED_F,
+ IB_PORT_EXT_EDR_FEC_MODE_ENABLED_F,
+ IB_PORT_EXT_LAST_F,
+
+ /*
+ * PortExtendedSpeedsCounters RSFEC active fields
+ */
+ IB_PESC_RSFEC_PORT_SELECT_F,
+ IB_PESC_RSFEC_COUNTER_SELECT_F,
+ IB_PESC_RSFEC_SYNC_HDR_ERR_CTR_F,
+ IB_PESC_RSFEC_UNK_BLOCK_CTR_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE0_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE1_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE2_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE3_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE4_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE5_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE6_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE7_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE8_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE9_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE10_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE11_F,
+ IB_PESC_PORT_FEC_CORR_BLOCK_CTR_F,
+ IB_PESC_PORT_FEC_UNCORR_BLOCK_CTR_F,
+ IB_PESC_PORT_FEC_CORR_SYMBOL_CTR_F,
+ IB_PESC_RSFEC_LAST_F,
+
+ /*
+ * More PortCountersExtended fields
+ */
+ IB_PC_EXT_COUNTER_SELECT2_F,
+ IB_PC_EXT_ERR_SYM_F,
+ IB_PC_EXT_LINK_RECOVERS_F,
+ IB_PC_EXT_LINK_DOWNED_F,
+ IB_PC_EXT_ERR_RCV_F,
+ IB_PC_EXT_ERR_PHYSRCV_F,
+ IB_PC_EXT_ERR_SWITCH_REL_F,
+ IB_PC_EXT_XMT_DISCARDS_F,
+ IB_PC_EXT_ERR_XMTCONSTR_F,
+ IB_PC_EXT_ERR_RCVCONSTR_F,
+ IB_PC_EXT_ERR_LOCALINTEG_F,
+ IB_PC_EXT_ERR_EXCESS_OVR_F,
+ IB_PC_EXT_VL15_DROPPED_F,
+ IB_PC_EXT_XMT_WAIT_F,
+ IB_PC_EXT_QP1_DROP_F,
+ IB_PC_EXT_ERR_LAST_F,
+
+ /*
+ * Another PortCounters field
+ */
+ IB_PC_QP1_DROP_F,
+
+ IB_FIELD_LAST_ /* must be last */
+};
+
+/*
+ * SA RMPP section
+ */
+enum RMPP_TYPE_ENUM {
+ IB_RMPP_TYPE_NONE,
+ IB_RMPP_TYPE_DATA,
+ IB_RMPP_TYPE_ACK,
+ IB_RMPP_TYPE_STOP,
+ IB_RMPP_TYPE_ABORT,
+};
+
+enum RMPP_FLAGS_ENUM {
+ IB_RMPP_FLAG_ACTIVE = 1 << 0,
+ IB_RMPP_FLAG_FIRST = 1 << 1,
+ IB_RMPP_FLAG_LAST = 1 << 2,
+};
+
+typedef struct {
+ int type;
+ int flags;
+ int status;
+ union {
+ uint32_t u;
+ uint32_t segnum;
+ } d1;
+ union {
+ uint32_t u;
+ uint32_t len;
+ uint32_t newwin;
+ } d2;
+} ib_rmpp_hdr_t;
+
+enum SA_SIZES_ENUM {
+ SA_HEADER_SZ = 20,
+};
+
+typedef struct ib_sa_call {
+ unsigned attrid;
+ unsigned mod;
+ uint64_t mask;
+ unsigned method;
+
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ unsigned recsz; /* return field */
+ ib_rmpp_hdr_t rmpp;
+} ib_sa_call_t;
+
+typedef struct ib_vendor_call {
+ unsigned method;
+ unsigned mgmt_class;
+ unsigned attrid;
+ unsigned mod;
+ uint32_t oui;
+ unsigned timeout;
+ ib_rmpp_hdr_t rmpp;
+} ib_vendor_call_t;
+
+typedef struct ib_bm_call {
+ unsigned method;
+ unsigned attrid;
+ unsigned mod;
+ unsigned timeout;
+ uint64_t bkey;
+} ib_bm_call_t;
+
+#define IB_MIN_UCAST_LID 1
+#define IB_MAX_UCAST_LID (0xc000-1)
+#define IB_MIN_MCAST_LID 0xc000
+#define IB_MAX_MCAST_LID (0xffff-1)
+
+#define IB_LID_VALID(lid) ((lid) >= IB_MIN_UCAST_LID && lid <= IB_MAX_UCAST_LID)
+#define IB_MLID_VALID(lid) ((lid) >= IB_MIN_MCAST_LID && lid <= IB_MAX_MCAST_LID)
+
+#define MAD_DEF_RETRIES 3
+#define MAD_DEF_TIMEOUT_MS 1000
+
+enum MAD_DEST {
+ IB_DEST_LID,
+ IB_DEST_DRPATH,
+ IB_DEST_GUID,
+ IB_DEST_DRSLID,
+ IB_DEST_GID
+};
+
+enum MAD_NODE_TYPE {
+ IB_NODE_CA = 1,
+ IB_NODE_SWITCH,
+ IB_NODE_ROUTER,
+ NODE_RNIC,
+
+ IB_NODE_MAX = NODE_RNIC
+};
+
+/******************************************************************************/
+
+/* portid.c */
+MAD_EXPORT char *portid2str(ib_portid_t * portid);
+MAD_EXPORT int portid2portnum(ib_portid_t * portid);
+MAD_EXPORT int str2drpath(ib_dr_path_t * path, char *routepath, int drslid,
+ int drdlid);
+MAD_EXPORT char *drpath2str(ib_dr_path_t * path, char *dstr, size_t dstr_size);
+
+static inline int ib_portid_set(ib_portid_t * portid, int lid, int qp, int qkey)
+{
+ portid->lid = lid;
+ portid->qp = qp;
+ portid->qkey = qkey;
+ portid->grh_present = 0;
+
+ return 0;
+}
+
+/* fields.c */
+MAD_EXPORT uint32_t mad_get_field(void *buf, int base_offs,
+ enum MAD_FIELDS field);
+MAD_EXPORT void mad_set_field(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint32_t val);
+/* field must be byte aligned */
+MAD_EXPORT uint64_t mad_get_field64(void *buf, int base_offs,
+ enum MAD_FIELDS field);
+MAD_EXPORT void mad_set_field64(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint64_t val);
+MAD_EXPORT void mad_set_array(void *buf, int base_offs, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT void mad_get_array(void *buf, int base_offs, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT void mad_decode_field(uint8_t * buf, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT void mad_encode_field(uint8_t * buf, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT int mad_print_field(enum MAD_FIELDS field, const char *name,
+ void *val);
+MAD_EXPORT char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz,
+ void *val);
+MAD_EXPORT char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz,
+ void *val);
+MAD_EXPORT const char *mad_field_name(enum MAD_FIELDS field);
+
+/* mad.c */
+MAD_EXPORT void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath,
+ void *data);
+MAD_EXPORT uint64_t mad_trid(void);
+MAD_EXPORT int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data);
+
+/* New interface */
+MAD_EXPORT void madrpc_show_errors(int set);
+MAD_EXPORT int madrpc_set_retries(int retries);
+MAD_EXPORT int madrpc_set_timeout(int timeout);
+MAD_EXPORT struct ibmad_port *mad_rpc_open_port(char *dev_name, int dev_port,
+ int *mgmt_classes,
+ int num_classes);
+MAD_EXPORT void mad_rpc_close_port(struct ibmad_port *srcport);
+
+/*
+ * On redirection, the dport argument is updated with the redirection target,
+ * so subsequent MADs will not go through the redirection process again but
+ * reach the target directly.
+ */
+MAD_EXPORT void *mad_rpc(const struct ibmad_port *srcport, ib_rpc_t * rpc,
+ ib_portid_t * dport, void *payload, void *rcvdata);
+
+MAD_EXPORT void *mad_rpc_rmpp(const struct ibmad_port *srcport, ib_rpc_t * rpc,
+ ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data);
+MAD_EXPORT int mad_rpc_portid(struct ibmad_port *srcport);
+MAD_EXPORT void mad_rpc_set_retries(struct ibmad_port *port, int retries);
+MAD_EXPORT void mad_rpc_set_timeout(struct ibmad_port *port, int timeout);
+MAD_EXPORT int mad_rpc_class_agent(struct ibmad_port *srcport, int cls);
+
+MAD_EXPORT int mad_get_timeout(const struct ibmad_port *srcport,
+ int override_ms);
+MAD_EXPORT int mad_get_retries(const struct ibmad_port *srcport);
+
+/* register.c */
+MAD_EXPORT int mad_register_port_client(int port_id, int mgmt,
+ uint8_t rmpp_version);
+MAD_EXPORT int mad_register_client(int mgmt, uint8_t rmpp_version) DEPRECATED;
+MAD_EXPORT int mad_register_server(int mgmt, uint8_t rmpp_version,
+ long method_mask[16 / sizeof(long)],
+ uint32_t class_oui) DEPRECATED;
+/* register.c new interface */
+MAD_EXPORT int mad_register_client_via(int mgmt, uint8_t rmpp_version,
+ struct ibmad_port *srcport);
+MAD_EXPORT int mad_register_server_via(int mgmt, uint8_t rmpp_version,
+ long method_mask[16 / sizeof(long)],
+ uint32_t class_oui,
+ struct ibmad_port *srcport);
+MAD_EXPORT int mad_class_agent(int mgmt) DEPRECATED;
+
+/* serv.c */
+MAD_EXPORT int mad_send(ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data) DEPRECATED;
+MAD_EXPORT void *mad_receive(void *umad, int timeout) DEPRECATED;
+MAD_EXPORT int mad_respond(void *umad, ib_portid_t * portid, uint32_t rstatus)
+ DEPRECATED;
+
+/* serv.c new interface */
+MAD_EXPORT int mad_send_via(ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data,
+ struct ibmad_port *srcport);
+MAD_EXPORT void *mad_receive_via(void *umad, int timeout,
+ struct ibmad_port *srcport);
+MAD_EXPORT int mad_respond_via(void *umad, ib_portid_t * portid,
+ uint32_t rstatus, struct ibmad_port *srcport);
+MAD_EXPORT void *mad_alloc(void);
+MAD_EXPORT void mad_free(void *umad);
+
+/* vendor.c */
+MAD_EXPORT uint8_t *ib_vendor_call(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call) DEPRECATED;
+
+/* vendor.c new interface */
+MAD_EXPORT uint8_t *ib_vendor_call_via(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call,
+ struct ibmad_port *srcport);
+
+static inline int mad_is_vendor_range1(int mgmt)
+{
+ return mgmt >= 0x9 && mgmt <= 0xf;
+}
+
+static inline int mad_is_vendor_range2(int mgmt)
+{
+ return mgmt >= 0x30 && mgmt <= 0x4f;
+}
+
+/* rpc.c */
+MAD_EXPORT int madrpc_portid(void) DEPRECATED;
+void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata)
+ DEPRECATED;
+void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data) DEPRECATED;
+MAD_EXPORT void madrpc_init(char *dev_name, int dev_port, int *mgmt_classes,
+ int num_classes) DEPRECATED;
+void madrpc_save_mad(void *madbuf, int len) DEPRECATED;
+
+/* smp.c */
+MAD_EXPORT uint8_t *smp_query(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout) DEPRECATED;
+MAD_EXPORT uint8_t *smp_set(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout) DEPRECATED;
+
+/* smp.c new interface */
+MAD_EXPORT uint8_t *smp_query_via(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *smp_set_via(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *smp_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod,
+ unsigned timeout, int *rstatus,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *smp_set_status_via(void *data, ib_portid_t * portid,
+ unsigned attrid, unsigned mod,
+ unsigned timeout, int *rstatus,
+ const struct ibmad_port *srcport);
+MAD_EXPORT void smp_mkey_set(struct ibmad_port *srcport, uint64_t mkey);
+MAD_EXPORT uint64_t smp_mkey_get(const struct ibmad_port *srcport);
+
+/* cc.c */
+MAD_EXPORT void *cc_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey);
+
+MAD_EXPORT void *cc_config_status_via(void *payload, void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey);
+
+/* sa.c */
+uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa,
+ unsigned timeout) DEPRECATED;
+MAD_EXPORT int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid,
+ ib_portid_t * sm_id, void *buf) DEPRECATED;
+
+/* sa.c new interface */
+MAD_EXPORT uint8_t *sa_rpc_call(const struct ibmad_port *srcport, void *rcvbuf,
+ ib_portid_t * portid, ib_sa_call_t * sa,
+ unsigned timeout);
+MAD_EXPORT int ib_path_query_via(const struct ibmad_port *srcport,
+ ibmad_gid_t srcgid, ibmad_gid_t destgid,
+ ib_portid_t * sm_id, void *buf);
+ /* returns lid */
+MAD_EXPORT int ib_node_query_via(const struct ibmad_port *srcport,
+ uint64_t guid, ib_portid_t * sm_id,
+ void *buf);
+
+/* resolve.c */
+MAD_EXPORT int ib_resolve_smlid(ib_portid_t * sm_id, int timeout) DEPRECATED;
+MAD_EXPORT int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest, ib_portid_t * sm_id)
+ DEPRECATED;
+MAD_EXPORT int ib_resolve_self(ib_portid_t * portid, int *portnum,
+ ibmad_gid_t * gid) DEPRECATED;
+
+/* resolve.c new interface */
+MAD_EXPORT int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_gid_via(ib_portid_t * portid, ibmad_gid_t gid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest,
+ ib_portid_t * sm_id,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_self_via(ib_portid_t * portid, int *portnum,
+ ibmad_gid_t * gid,
+ const struct ibmad_port *srcport);
+
+/* gs.c new interface */
+MAD_EXPORT uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port,
+ unsigned timeout, unsigned id,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest,
+ int port, unsigned mask,
+ unsigned timeout, unsigned id,
+ const struct ibmad_port *srcport);
+
+/* bm.c */
+MAD_EXPORT uint8_t *bm_call_via(void *data, ib_portid_t * portid,
+ ib_bm_call_t * call,
+ struct ibmad_port *srcport);
+
+/* dump.c */
+MAD_EXPORT ib_mad_dump_fn
+ mad_dump_int, mad_dump_uint, mad_dump_hex, mad_dump_rhex,
+ mad_dump_bitfield, mad_dump_array, mad_dump_string,
+ mad_dump_linkwidth, mad_dump_linkwidthsup, mad_dump_linkwidthen,
+ mad_dump_linkdowndefstate,
+ mad_dump_linkspeed, mad_dump_linkspeedsup, mad_dump_linkspeeden,
+ mad_dump_linkspeedext, mad_dump_linkspeedextsup, mad_dump_linkspeedexten,
+ mad_dump_portstate, mad_dump_portstates,
+ mad_dump_physportstate, mad_dump_portcapmask, mad_dump_portcapmask2,
+ mad_dump_mtu, mad_dump_vlcap, mad_dump_opervls,
+ mad_dump_node_type, mad_dump_sltovl, mad_dump_vlarbitration,
+ mad_dump_nodedesc, mad_dump_nodeinfo, mad_dump_portinfo,
+ mad_dump_switchinfo, mad_dump_perfcounters, mad_dump_perfcounters_ext,
+ mad_dump_perfcounters_xmt_sl, mad_dump_perfcounters_rcv_sl,
+ mad_dump_perfcounters_xmt_disc, mad_dump_perfcounters_rcv_err,
+ mad_dump_portsamples_control, mad_dump_port_ext_speeds_counters,
+ mad_dump_perfcounters_port_op_rcv_counters, mad_dump_perfcounters_port_flow_ctl_counters,
+ mad_dump_perfcounters_port_vl_op_packet, mad_dump_perfcounters_port_vl_op_data,
+ mad_dump_perfcounters_port_vl_xmit_flow_ctl_update_errors, mad_dump_perfcounters_port_vl_xmit_wait_counters,
+ mad_dump_perfcounters_sw_port_vl_congestion, mad_dump_perfcounters_rcv_con_ctrl,
+ mad_dump_perfcounters_sl_rcv_fecn, mad_dump_perfcounters_sl_rcv_becn,
+ mad_dump_perfcounters_xmit_con_ctrl, mad_dump_perfcounters_vl_xmit_time_cong,
+ mad_dump_mlnx_ext_port_info, mad_dump_cc_congestioninfo, mad_dump_cc_congestionkeyinfo,
+ mad_dump_cc_congestionlog, mad_dump_cc_congestionlogswitch,
+ mad_dump_cc_congestionlogentryswitch, mad_dump_cc_congestionlogca,
+ mad_dump_cc_congestionlogentryca, mad_dump_cc_switchcongestionsetting,
+ mad_dump_cc_switchportcongestionsettingelement, mad_dump_cc_cacongestionsetting,
+ mad_dump_cc_cacongestionentry, mad_dump_cc_congestioncontroltable,
+ mad_dump_cc_congestioncontroltableentry, mad_dump_cc_timestamp,
+ mad_dump_classportinfo, mad_dump_portmirror_route,
+ mad_dump_portmirror_ports, mad_dump_portsamples_result,
+ mad_dump_portinfo_ext, mad_dump_port_ext_speeds_counters_rsfec_active;
+
+MAD_EXPORT void mad_dump_fields(char *buf, int bufsz, void *val, int valsz,
+ int start, int end);
+
+extern MAD_EXPORT int ibdebug;
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifndef ntohll
+#define ntohll bswap_64
+#endif
+#ifndef htonll
+#define htonll bswap_64
+#endif
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#ifndef ntohll
+#define ntohll(x) (x)
+#endif
+#ifndef htonll
+#define htonll(x) (x)
+#endif
+#endif /* __BYTE_ORDER == __BIG_ENDIAN */
+
+/* Misc. macros: */
+/** align value \a l to \a size (ceil) */
+#define ALIGN(l, size) (((l) + ((size) - 1)) / (size) * (size))
+
+/** printf style warning MACRO, includes name of function and pid */
+#define IBWARN(fmt, ...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
+
+#define IBDEBUG(fmt, ...) fprintf(stdout, "ibdebug: [%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
+
+#define IBVERBOSE(fmt, ...) fprintf(stdout, "[%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
+
+#define IBPANIC(fmt, ...) do { \
+ fprintf(stderr, "ibpanic: [%d] %s: " fmt ": %m\n", \
+ (int)getpid(), __func__, ## __VA_ARGS__); \
+ exit(-1); \
+} while(0)
+
+MAD_EXPORT void xdump(FILE * file, char *msg, void *p, int size);
+
+END_C_DECLS
+#endif /* _MAD_H_ */
diff --git a/contrib/ofed/libibmad/mad_internal.h b/contrib/ofed/libibmad/mad_internal.h
new file mode 100644
index 000000000000..f5522dbd06d2
--- /dev/null
+++ b/contrib/ofed/libibmad/mad_internal.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. 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.
+ *
+ */
+
+#ifndef _MAD_INTERNAL_H_
+#define _MAD_INTERNAL_H_
+
+#define MAX_CLASS 256
+
+struct ibmad_port {
+ int port_id; /* file descriptor returned by umad_open() */
+ int class_agents[MAX_CLASS]; /* class2agent mapper */
+ int timeout, retries;
+ uint64_t smp_mkey;
+ char ca_name[UMAD_CA_NAME_LEN];
+ int portnum;
+};
+
+extern struct ibmad_port *ibmp;
+extern int madrpc_timeout;
+extern int madrpc_retries;
+
+#endif /* _MAD_INTERNAL_H_ */
diff --git a/contrib/ofed/libibmad/mad_osd.h b/contrib/ofed/libibmad/mad_osd.h
new file mode 100644
index 000000000000..afca11dde998
--- /dev/null
+++ b/contrib/ofed/libibmad/mad_osd.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. 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.
+ *
+ */
+#ifndef _MAD_OSD_H_
+#define _MAD_OSD_H_
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <infiniband/byteswap.h>
+#include <inttypes.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+
+#define MAD_EXPORT
+#define DEPRECATED __attribute__ ((deprecated))
+
+#endif /* _MAD_OSD_H_ */
diff --git a/contrib/ofed/libibmad/portid.c b/contrib/ofed/libibmad/portid.c
new file mode 100644
index 000000000000..40754fe2e4f7
--- /dev/null
+++ b/contrib/ofed/libibmad/portid.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+
+#include <infiniband/mad.h>
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+int portid2portnum(ib_portid_t * portid)
+{
+ if (portid->lid > 0)
+ return -1;
+
+ if (portid->drpath.cnt == 0)
+ return 0;
+
+ return portid->drpath.p[(portid->drpath.cnt - 1)];
+}
+
+char *portid2str(ib_portid_t * portid)
+{
+ static char buf[1024] = "local";
+ int n = 0;
+
+ if (portid->lid > 0) {
+ n += sprintf(buf + n, "Lid %d", portid->lid);
+ if (portid->grh_present) {
+ char gid[sizeof
+ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
+ if (inet_ntop(AF_INET6, portid->gid, gid, sizeof(gid)))
+ n += sprintf(buf + n, " Gid %s", gid);
+ }
+ if (portid->drpath.cnt)
+ n += sprintf(buf + n, " ");
+ else
+ return buf;
+ }
+ n += sprintf(buf + n, "DR path ");
+ drpath2str(&(portid->drpath), buf + n, sizeof(buf) - n);
+
+ return buf;
+}
+
+int str2drpath(ib_dr_path_t * path, char *routepath, int drslid, int drdlid)
+{
+ char *s, *str;
+ char *tmp;
+
+ path->cnt = -1;
+
+ if (!routepath || !(tmp = strdup(routepath)))
+ goto Exit;
+
+ DEBUG("DR str: %s", routepath);
+
+ str = tmp;
+
+ while (str && *str) {
+ if ((s = strchr(str, ',')))
+ *s = 0;
+ path->p[++path->cnt] = (uint8_t) atoi(str);
+ if (!s)
+ break;
+ str = s + 1;
+ }
+ free(tmp);
+
+Exit:
+ path->drdlid = drdlid ? drdlid : 0xffff;
+ path->drslid = drslid ? drslid : 0xffff;
+
+ return path->cnt;
+}
+
+char *drpath2str(ib_dr_path_t * path, char *dstr, size_t dstr_size)
+{
+ int i = 0;
+ int rc = snprintf(dstr, dstr_size, "slid %u; dlid %u; %d",
+ path->drslid, path->drdlid, path->p[0]);
+ if (rc >= (int)dstr_size)
+ return dstr;
+ for (i = 1; i <= path->cnt; i++) {
+ rc += snprintf(dstr + rc, dstr_size - rc, ",%d", path->p[i]);
+ if (rc >= (int)dstr_size)
+ break;
+ }
+ return (dstr);
+}
diff --git a/contrib/ofed/libibmad/register.c b/contrib/ofed/libibmad/register.c
new file mode 100644
index 000000000000..1fdb64a7bd9e
--- /dev/null
+++ b/contrib/ofed/libibmad/register.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+static int mgmt_class_vers(int mgmt_class)
+{
+ if ((mgmt_class >= IB_VENDOR_RANGE1_START_CLASS &&
+ mgmt_class <= IB_VENDOR_RANGE1_END_CLASS) ||
+ (mgmt_class >= IB_VENDOR_RANGE2_START_CLASS &&
+ mgmt_class <= IB_VENDOR_RANGE2_END_CLASS))
+ return 1;
+
+ switch (mgmt_class) {
+ case IB_SMI_CLASS:
+ case IB_SMI_DIRECT_CLASS:
+ return 1;
+ case IB_SA_CLASS:
+ return 2;
+ case IB_PERFORMANCE_CLASS:
+ return 1;
+ case IB_DEVICE_MGMT_CLASS:
+ return 1;
+ case IB_CC_CLASS:
+ return 2;
+ case IB_BOARD_MGMT_CLASS:
+ return 1;
+ }
+
+ return 0;
+}
+
+int mad_class_agent(int mgmt)
+{
+ if (mgmt < 1 || mgmt >= MAX_CLASS)
+ return -1;
+ return ibmp->class_agents[mgmt];
+}
+
+int mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version)
+{
+ int vers, agent;
+
+ if ((vers = mgmt_class_vers(mgmt)) <= 0) {
+ DEBUG("Unknown class %d mgmt_class", mgmt);
+ return -1;
+ }
+
+ agent = umad_register(port_id, mgmt, vers, rmpp_version, 0);
+ if (agent < 0)
+ DEBUG("Can't register agent for class %d", mgmt);
+
+ return agent;
+}
+
+int mad_register_client(int mgmt, uint8_t rmpp_version)
+{
+ return mad_register_client_via(mgmt, rmpp_version, ibmp);
+}
+
+int mad_register_client_via(int mgmt, uint8_t rmpp_version,
+ struct ibmad_port *srcport)
+{
+ int agent;
+
+ if (!srcport)
+ return -1;
+
+ agent = mad_register_port_client(mad_rpc_portid(srcport), mgmt,
+ rmpp_version);
+ if (agent < 0)
+ return agent;
+
+ srcport->class_agents[mgmt] = agent;
+ return 0;
+}
+
+int mad_register_server(int mgmt, uint8_t rmpp_version,
+ long method_mask[], uint32_t class_oui)
+{
+ return mad_register_server_via(mgmt, rmpp_version, method_mask,
+ class_oui, ibmp);
+}
+
+int mad_register_server_via(int mgmt, uint8_t rmpp_version,
+ long method_mask[], uint32_t class_oui,
+ struct ibmad_port *srcport)
+{
+ long class_method_mask[16 / sizeof(long)];
+ uint8_t oui[3];
+ int agent, vers;
+
+ if (method_mask)
+ memcpy(class_method_mask, method_mask,
+ sizeof class_method_mask);
+ else
+ memset(class_method_mask, 0xff, sizeof(class_method_mask));
+
+ if (!srcport)
+ return -1;
+
+ if (srcport->class_agents[mgmt] >= 0) {
+ DEBUG("Class 0x%x already registered %d",
+ mgmt, srcport->class_agents[mgmt]);
+ return -1;
+ }
+ if ((vers = mgmt_class_vers(mgmt)) <= 0) {
+ DEBUG("Unknown class 0x%x mgmt_class", mgmt);
+ return -1;
+ }
+ if (mgmt >= IB_VENDOR_RANGE2_START_CLASS &&
+ mgmt <= IB_VENDOR_RANGE2_END_CLASS) {
+ oui[0] = (class_oui >> 16) & 0xff;
+ oui[1] = (class_oui >> 8) & 0xff;
+ oui[2] = class_oui & 0xff;
+ if ((agent =
+ umad_register_oui(srcport->port_id, mgmt, rmpp_version,
+ oui, class_method_mask)) < 0) {
+ DEBUG("Can't register agent for class %d", mgmt);
+ return -1;
+ }
+ } else
+ if ((agent =
+ umad_register(srcport->port_id, mgmt, vers, rmpp_version,
+ class_method_mask)) < 0) {
+ DEBUG("Can't register agent for class %d", mgmt);
+ return -1;
+ }
+
+ srcport->class_agents[mgmt] = agent;
+
+ return agent;
+}
diff --git a/contrib/ofed/libibmad/resolve.c b/contrib/ofed/libibmad/resolve.c
new file mode 100644
index 000000000000..1e4035744f7b
--- /dev/null
+++ b/contrib/ofed/libibmad/resolve.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport)
+{
+ umad_port_t port;
+ int ret;
+
+ memset(sm_id, 0, sizeof(*sm_id));
+
+ ret = umad_get_port(srcport->ca_name, srcport->portnum, &port);
+ if (ret)
+ return -1;
+
+ if (!IB_LID_VALID(port.sm_lid)) {
+ errno = ENXIO;
+ return -1;
+ }
+ sm_id->sl = port.sm_sl;
+
+ ret = ib_portid_set(sm_id, port.sm_lid, 0, 0);
+ umad_release_port(&port);
+ return ret;
+}
+
+int ib_resolve_smlid(ib_portid_t * sm_id, int timeout)
+{
+ return ib_resolve_smlid_via(sm_id, timeout, ibmp);
+}
+
+int ib_resolve_gid_via(ib_portid_t * portid, ibmad_gid_t gid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t sm_portid = { 0 };
+ char buf[IB_SA_DATA_SIZE] = { 0 };
+
+ if (!sm_id)
+ sm_id = &sm_portid;
+
+ if (!IB_LID_VALID(sm_id->lid)) {
+ if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
+ return -1;
+ }
+
+ if ((portid->lid =
+ ib_path_query_via(srcport, gid, gid, sm_id, buf)) < 0)
+ return -1;
+
+ return 0;
+}
+
+int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t sm_portid = { 0 };
+ uint8_t buf[IB_SA_DATA_SIZE] = { 0 };
+ uint64_t prefix;
+ ibmad_gid_t selfgid;
+ umad_port_t port;
+
+ if (!sm_id)
+ sm_id = &sm_portid;
+
+ if (!IB_LID_VALID(sm_id->lid)) {
+ if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
+ return -1;
+ }
+
+ if (umad_get_port(srcport->ca_name, srcport->portnum, &port))
+ return -1;
+
+ mad_set_field64(selfgid, 0, IB_GID_PREFIX_F, ntohll(port.gid_prefix));
+ mad_set_field64(selfgid, 0, IB_GID_GUID_F, ntohll(port.port_guid));
+ umad_release_port(&port);
+
+ memcpy(&prefix, portid->gid, sizeof(prefix));
+ if (!prefix)
+ mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F,
+ IB_DEFAULT_SUBN_PREFIX);
+ if (guid)
+ mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid);
+
+ if ((portid->lid =
+ ib_path_query_via(srcport, selfgid, portid->gid, sm_id, buf)) < 0)
+ return -1;
+
+ mad_decode_field(buf, IB_SA_PR_SL_F, &portid->sl);
+ return 0;
+}
+
+int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest_type, ib_portid_t * sm_id,
+ const struct ibmad_port *srcport)
+{
+ ibmad_gid_t gid;
+ uint64_t guid;
+ int lid;
+ char *routepath;
+ ib_portid_t selfportid = { 0 };
+ int selfport = 0;
+
+ memset(portid, 0, sizeof *portid);
+
+ switch (dest_type) {
+ case IB_DEST_LID:
+ lid = strtol(addr_str, 0, 0);
+ if (!IB_LID_VALID(lid)) {
+ errno = EINVAL;
+ return -1;
+ }
+ return ib_portid_set(portid, lid, 0, 0);
+
+ case IB_DEST_DRPATH:
+ if (str2drpath(&portid->drpath, addr_str, 0, 0) < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+
+ case IB_DEST_GUID:
+ if (!(guid = strtoull(addr_str, 0, 0))) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* keep guid in portid? */
+ return ib_resolve_guid_via(portid, &guid, sm_id, 0, srcport);
+
+ case IB_DEST_DRSLID:
+ lid = strtol(addr_str, &routepath, 0);
+ routepath++;
+ if (!IB_LID_VALID(lid)) {
+ errno = EINVAL;
+ return -1;
+ }
+ ib_portid_set(portid, lid, 0, 0);
+
+ /* handle DR parsing and set DrSLID to local lid */
+ if (ib_resolve_self_via(&selfportid, &selfport, 0, srcport) < 0)
+ return -1;
+ if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) <
+ 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+
+ case IB_DEST_GID:
+ if (inet_pton(AF_INET6, addr_str, &gid) <= 0)
+ return -1;
+ return ib_resolve_gid_via(portid, gid, sm_id, 0, srcport);
+ default:
+ IBWARN("bad dest_type %d", dest_type);
+ errno = EINVAL;
+ }
+
+ return -1;
+}
+
+int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest_type, ib_portid_t * sm_id)
+{
+ return ib_resolve_portid_str_via(portid, addr_str, dest_type,
+ sm_id, ibmp);
+}
+
+int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t self = { 0 };
+ uint8_t portinfo[64];
+ uint8_t nodeinfo[64];
+ uint64_t guid, prefix;
+
+ if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return -1;
+
+ if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport))
+ return -1;
+
+ mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
+ mad_decode_field(portinfo, IB_PORT_SMSL_F, &portid->sl);
+ mad_decode_field(portinfo, IB_PORT_GID_PREFIX_F, &prefix);
+ mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &guid);
+
+ if (portnum)
+ mad_decode_field(nodeinfo, IB_NODE_LOCAL_PORT_F, portnum);
+ if (gid) {
+ mad_encode_field(*gid, IB_GID_PREFIX_F, &prefix);
+ mad_encode_field(*gid, IB_GID_GUID_F, &guid);
+ }
+ return 0;
+}
+
+int ib_resolve_self(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid)
+{
+ return ib_resolve_self_via(portid, portnum, gid, ibmp);
+}
diff --git a/contrib/ofed/libibmad/rpc.c b/contrib/ofed/libibmad/rpc.c
new file mode 100644
index 000000000000..a7d29e3421a4
--- /dev/null
+++ b/contrib/ofed/libibmad/rpc.c
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+int ibdebug;
+
+static struct ibmad_port mad_port;
+struct ibmad_port *ibmp = &mad_port;
+
+static int iberrs;
+
+int madrpc_retries = MAD_DEF_RETRIES;
+int madrpc_timeout = MAD_DEF_TIMEOUT_MS;
+
+static void *save_mad;
+static int save_mad_len = 256;
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+#define ERRS(fmt, ...) do { \
+ if (iberrs || ibdebug) \
+ IBWARN(fmt, ## __VA_ARGS__); \
+} while (0)
+
+#define MAD_TID(mad) (*((uint64_t *)((char *)(mad) + 8)))
+
+void madrpc_show_errors(int set)
+{
+ iberrs = set;
+}
+
+void madrpc_save_mad(void *madbuf, int len)
+{
+ save_mad = madbuf;
+ save_mad_len = len;
+}
+
+int madrpc_set_retries(int retries)
+{
+ if (retries > 0)
+ madrpc_retries = retries;
+ return madrpc_retries;
+}
+
+int madrpc_set_timeout(int timeout)
+{
+ madrpc_timeout = timeout;
+ return 0;
+}
+
+void mad_rpc_set_retries(struct ibmad_port *port, int retries)
+{
+ port->retries = retries;
+}
+
+void mad_rpc_set_timeout(struct ibmad_port *port, int timeout)
+{
+ port->timeout = timeout;
+}
+
+int madrpc_def_timeout(void)
+{
+ return madrpc_timeout;
+}
+
+int madrpc_portid(void)
+{
+ return ibmp->port_id;
+}
+
+int mad_rpc_portid(struct ibmad_port *srcport)
+{
+ return srcport->port_id;
+}
+
+int mad_rpc_class_agent(struct ibmad_port *port, int class)
+{
+ if (class < 1 || class >= MAX_CLASS)
+ return -1;
+ return port->class_agents[class];
+}
+
+static int
+_do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
+ int timeout, int max_retries, int *p_error)
+{
+ uint32_t trid; /* only low 32 bits - see mad_trid() */
+ int retries;
+ int length, status;
+
+ if (ibdebug > 1) {
+ IBWARN(">>> sending: len %d pktsz %zu", len, umad_size() + len);
+ xdump(stderr, "send buf\n", sndbuf, umad_size() + len);
+ }
+
+ if (save_mad) {
+ memcpy(save_mad, umad_get_mad(sndbuf),
+ save_mad_len < len ? save_mad_len : len);
+ save_mad = 0;
+ }
+
+ if (max_retries <= 0) {
+ errno = EINVAL;
+ *p_error = EINVAL;
+ ERRS("max_retries %d <= 0", max_retries);
+ return -1;
+ }
+
+ trid =
+ (uint32_t) mad_get_field64(umad_get_mad(sndbuf), 0, IB_MAD_TRID_F);
+
+ for (retries = 0; retries < max_retries; retries++) {
+ if (retries)
+ ERRS("retry %d (timeout %d ms)", retries, timeout);
+
+ length = len;
+ if (umad_send(port_id, agentid, sndbuf, length, timeout, 0) < 0) {
+ IBWARN("send failed; %s", strerror(errno));
+ return -1;
+ }
+
+ /* Use same timeout on receive side just in case */
+ /* send packet is lost somewhere. */
+ do {
+ length = len;
+ if (umad_recv(port_id, rcvbuf, &length, timeout) < 0) {
+ IBWARN("recv failed: %s", strerror(errno));
+ return -1;
+ }
+
+ if (ibdebug > 2)
+ umad_addr_dump(umad_get_mad_addr(rcvbuf));
+ if (ibdebug > 1) {
+ IBWARN("rcv buf:");
+ xdump(stderr, "rcv buf\n", umad_get_mad(rcvbuf),
+ IB_MAD_SIZE);
+ }
+ } while ((uint32_t)
+ mad_get_field64(umad_get_mad(rcvbuf), 0,
+ IB_MAD_TRID_F) != trid);
+
+ status = umad_status(rcvbuf);
+ if (!status)
+ return length; /* done */
+ if (status == ENOMEM)
+ return length;
+ }
+
+ errno = status;
+ *p_error = ETIMEDOUT;
+ ERRS("timeout after %d retries, %d ms", retries, timeout * retries);
+ return -1;
+}
+
+static int redirect_port(ib_portid_t * port, uint8_t * mad)
+{
+ port->lid = mad_get_field(mad, 64, IB_CPI_REDIRECT_LID_F);
+ if (!port->lid) {
+ IBWARN("GID-based redirection is not supported");
+ return -1;
+ }
+
+ port->qp = mad_get_field(mad, 64, IB_CPI_REDIRECT_QP_F);
+ port->qkey = mad_get_field(mad, 64, IB_CPI_REDIRECT_QKEY_F);
+ port->sl = (uint8_t) mad_get_field(mad, 64, IB_CPI_REDIRECT_SL_F);
+
+ /* TODO: Reverse map redirection P_Key to P_Key index */
+
+ if (ibdebug)
+ IBWARN("redirected to lid %d, qp 0x%x, qkey 0x%x, sl 0x%x",
+ port->lid, port->qp, port->qkey, port->sl);
+
+ return 0;
+}
+
+void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc,
+ ib_portid_t * dport, void *payload, void *rcvdata)
+{
+ int status, len;
+ uint8_t sndbuf[1024], rcvbuf[1024], *mad;
+ ib_rpc_v1_t *rpcv1 = (ib_rpc_v1_t *)rpc;
+ int error = 0;
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = 0;
+ do {
+ len = 0;
+ memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);
+
+ if ((len = mad_build_pkt(sndbuf, rpc, dport, 0, payload)) < 0)
+ return NULL;
+
+ if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
+ port->class_agents[rpc->mgtclass & 0xff],
+ len, mad_get_timeout(port, rpc->timeout),
+ mad_get_retries(port), &error)) < 0) {
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) ==
+ IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+ IBWARN("_do_madrpc failed; dport (%s)",
+ portid2str(dport));
+ return NULL;
+ }
+
+ mad = umad_get_mad(rcvbuf);
+ status = mad_get_field(mad, 0, IB_DRSMP_STATUS_F);
+
+ /* check for exact match instead of only the redirect bit;
+ * that way, weird statuses cause an error, too */
+ if (status == IB_MAD_STS_REDIRECT) {
+ /* update dport for next request and retry */
+ /* bail if redirection fails */
+ if (redirect_port(dport, mad))
+ break;
+ } else
+ break;
+ } while (1);
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+ rpc->rstatus = status;
+
+ if (status != 0) {
+ ERRS("MAD completed with error status 0x%x; dport (%s)",
+ status, portid2str(dport));
+ errno = EIO;
+ return NULL;
+ }
+
+ if (ibdebug) {
+ IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
+ xdump(stderr, "mad data\n", mad + rpc->dataoffs, rpc->datasz);
+ }
+
+ if (rcvdata)
+ memcpy(rcvdata, mad + rpc->dataoffs, rpc->datasz);
+
+ return rcvdata;
+}
+
+void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc,
+ ib_portid_t * dport, ib_rmpp_hdr_t * rmpp, void *data)
+{
+ int status, len;
+ uint8_t sndbuf[1024], rcvbuf[1024], *mad;
+ ib_rpc_v1_t *rpcv1 = (ib_rpc_v1_t *)rpc;
+ int error = 0;
+
+ memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);
+
+ DEBUG("rmpp %p data %p", rmpp, data);
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = 0;
+ if ((len = mad_build_pkt(sndbuf, rpc, dport, rmpp, data)) < 0)
+ return NULL;
+
+ if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
+ port->class_agents[rpc->mgtclass & 0xff],
+ len, mad_get_timeout(port, rpc->timeout),
+ mad_get_retries(port), &error)) < 0) {
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+ IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
+ return NULL;
+ }
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+
+ mad = umad_get_mad(rcvbuf);
+
+ if ((status = mad_get_field(mad, 0, IB_MAD_STATUS_F)) != 0) {
+ ERRS("MAD completed with error status 0x%x; dport (%s)",
+ status, portid2str(dport));
+ errno = EIO;
+ return NULL;
+ }
+
+ if (ibdebug) {
+ IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
+ xdump(stderr, "rmpp mad data\n", mad + rpc->dataoffs,
+ rpc->datasz);
+ }
+
+ if (rmpp) {
+ rmpp->flags = mad_get_field(mad, 0, IB_SA_RMPP_FLAGS_F);
+ if ((rmpp->flags & 0x3) &&
+ mad_get_field(mad, 0, IB_SA_RMPP_VERS_F) != 1) {
+ IBWARN("bad rmpp version");
+ return NULL;
+ }
+ rmpp->type = mad_get_field(mad, 0, IB_SA_RMPP_TYPE_F);
+ rmpp->status = mad_get_field(mad, 0, IB_SA_RMPP_STATUS_F);
+ DEBUG("rmpp type %d status %d", rmpp->type, rmpp->status);
+ rmpp->d1.u = mad_get_field(mad, 0, IB_SA_RMPP_D1_F);
+ rmpp->d2.u = mad_get_field(mad, 0, IB_SA_RMPP_D2_F);
+ }
+
+ if (data)
+ memcpy(data, mad + rpc->dataoffs, rpc->datasz);
+
+ rpc->recsz = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
+
+ return data;
+}
+
+void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata)
+{
+ return mad_rpc(ibmp, rpc, dport, payload, rcvdata);
+}
+
+void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data)
+{
+ return mad_rpc_rmpp(ibmp, rpc, dport, rmpp, data);
+}
+
+void
+madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, int num_classes)
+{
+ int fd;
+
+ if (umad_init() < 0)
+ IBPANIC("can't init UMAD library");
+
+ if ((fd = umad_open_port(dev_name, dev_port)) < 0)
+ IBPANIC("can't open UMAD port (%s:%d)",
+ dev_name ? dev_name : "(nil)", dev_port);
+
+ if (num_classes >= MAX_CLASS)
+ IBPANIC("too many classes %d requested", num_classes);
+
+ ibmp->port_id = fd;
+ memset(ibmp->class_agents, 0xff, sizeof ibmp->class_agents);
+ while (num_classes--) {
+ uint8_t rmpp_version = 0;
+ int mgmt = *mgmt_classes++;
+
+ if (mgmt == IB_SA_CLASS)
+ rmpp_version = 1;
+ if (mad_register_client_via(mgmt, rmpp_version, ibmp) < 0)
+ IBPANIC("client_register for mgmt class %d failed",
+ mgmt);
+ }
+}
+
+struct ibmad_port *mad_rpc_open_port(char *dev_name, int dev_port,
+ int *mgmt_classes, int num_classes)
+{
+ struct ibmad_port *p;
+ int port_id;
+
+ if (num_classes >= MAX_CLASS) {
+ IBWARN("too many classes %d requested", num_classes);
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (umad_init() < 0) {
+ IBWARN("can't init UMAD library");
+ errno = ENODEV;
+ return NULL;
+ }
+
+ p = malloc(sizeof(*p));
+ if (!p) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ memset(p, 0, sizeof(*p));
+
+ if ((port_id = umad_open_port(dev_name, dev_port)) < 0) {
+ IBWARN("can't open UMAD port (%s:%d)", dev_name, dev_port);
+ if (!errno)
+ errno = EIO;
+ free(p);
+ return NULL;
+ }
+
+ p->port_id = port_id;
+ if (dev_name)
+ strncpy(p->ca_name, dev_name, sizeof p->ca_name - 1);
+ p->portnum = dev_port;
+
+ memset(p->class_agents, 0xff, sizeof p->class_agents);
+ while (num_classes--) {
+ uint8_t rmpp_version = 0;
+ int mgmt = *mgmt_classes++;
+
+ if (mgmt == IB_SA_CLASS)
+ rmpp_version = 1;
+ if (mgmt < 0 || mgmt >= MAX_CLASS ||
+ mad_register_client_via(mgmt, rmpp_version, p) < 0) {
+ IBWARN("client_register for mgmt %d failed", mgmt);
+ if (!errno)
+ errno = EINVAL;
+ umad_close_port(port_id);
+ free(p);
+ return NULL;
+ }
+ }
+
+ return p;
+}
+
+void mad_rpc_close_port(struct ibmad_port *port)
+{
+ umad_close_port(port->port_id);
+ free(port);
+}
diff --git a/contrib/ofed/libibmad/sa.c b/contrib/ofed/libibmad/sa.c
new file mode 100644
index 000000000000..9a9da2115939
--- /dev/null
+++ b/contrib/ofed/libibmad/sa.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+uint8_t *sa_rpc_call(const struct ibmad_port *ibmad_port, void *rcvbuf,
+ ib_portid_t * portid, ib_sa_call_t * sa, unsigned timeout)
+{
+ ib_rpc_t rpc = { 0 };
+ uint8_t *p;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", sa->attrid, sa->mod,
+ portid2str(portid));
+
+ if (portid->lid <= 0) {
+ IBWARN("only lid routes are supported");
+ return NULL;
+ }
+
+ rpc.mgtclass = IB_SA_CLASS;
+ rpc.method = sa->method;
+ rpc.attr.id = sa->attrid;
+ rpc.attr.mod = sa->mod;
+ rpc.mask = sa->mask;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_SA_DATA_SIZE;
+ rpc.dataoffs = IB_SA_DATA_OFFS;
+ rpc.trid = sa->trid;
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0 /*&sa->rmpp */ , rcvbuf); /* TODO: RMPP */
+
+ sa->recsz = rpc.recsz;
+
+ return p;
+}
+
+uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa,
+ unsigned timeout)
+{
+ return sa_rpc_call(ibmp, rcvbuf, portid, sa, timeout);
+}
+
+/* PathRecord */
+#define IB_PR_COMPMASK_DGID (1ull<<2)
+#define IB_PR_COMPMASK_SGID (1ull<<3)
+#define IB_PR_COMPMASK_DLID (1ull<<4)
+#define IB_PR_COMPMASK_SLID (1ull<<5)
+#define IB_PR_COMPMASK_RAWTRAFIC (1ull<<6)
+#define IB_PR_COMPMASK_RESV0 (1ull<<7)
+#define IB_PR_COMPMASK_FLOWLABEL (1ull<<8)
+#define IB_PR_COMPMASK_HOPLIMIT (1ull<<9)
+#define IB_PR_COMPMASK_TCLASS (1ull<<10)
+#define IB_PR_COMPMASK_REVERSIBLE (1ull<<11)
+#define IB_PR_COMPMASK_NUMBPATH (1ull<<12)
+#define IB_PR_COMPMASK_PKEY (1ull<<13)
+#define IB_PR_COMPMASK_RESV1 (1ull<<14)
+#define IB_PR_COMPMASK_SL (1ull<<15)
+#define IB_PR_COMPMASK_MTUSELEC (1ull<<16)
+#define IB_PR_COMPMASK_MTU (1ull<<17)
+#define IB_PR_COMPMASK_RATESELEC (1ull<<18)
+#define IB_PR_COMPMASK_RATE (1ull<<19)
+#define IB_PR_COMPMASK_PKTLIFETIMESELEC (1ull<<20)
+#define IB_PR_COMPMASK_PKTLIFETIME (1ull<<21)
+#define IB_PR_COMPMASK_PREFERENCE (1ull<<22)
+
+#define IB_PR_DEF_MASK (IB_PR_COMPMASK_DGID |\
+ IB_PR_COMPMASK_SGID)
+
+int ib_path_query_via(const struct ibmad_port *srcport, ibmad_gid_t srcgid,
+ ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf)
+{
+ ib_sa_call_t sa = { 0 };
+ uint8_t *p;
+ int dlid;
+
+ memset(&sa, 0, sizeof sa);
+ sa.method = IB_MAD_METHOD_GET;
+ sa.attrid = IB_SA_ATTR_PATHRECORD;
+ sa.mask = IB_PR_DEF_MASK;
+ sa.trid = mad_trid();
+
+ memset(buf, 0, IB_SA_PR_RECSZ);
+
+ mad_encode_field(buf, IB_SA_PR_DGID_F, destgid);
+ mad_encode_field(buf, IB_SA_PR_SGID_F, srcgid);
+
+ p = sa_rpc_call(srcport, buf, sm_id, &sa, 0);
+ if (!p) {
+ IBWARN("sa call path_query failed");
+ return -1;
+ }
+
+ mad_decode_field(p, IB_SA_PR_DLID_F, &dlid);
+ return dlid;
+}
+
+int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id,
+ void *buf)
+{
+ return ib_path_query_via(ibmp, srcgid, destgid, sm_id, buf);
+}
+
+/* NodeRecord */
+#define IB_NR_COMPMASK_LID (1ull<<0)
+#define IB_NR_COMPMASK_RESERVED1 (1ull<<1)
+#define IB_NR_COMPMASK_BASEVERSION (1ull<<2)
+#define IB_NR_COMPMASK_CLASSVERSION (1ull<<3)
+#define IB_NR_COMPMASK_NODETYPE (1ull<<4)
+#define IB_NR_COMPMASK_NUMPORTS (1ull<<5)
+#define IB_NR_COMPMASK_SYSIMAGEGUID (1ull<<6)
+#define IB_NR_COMPMASK_NODEGUID (1ull<<7)
+#define IB_NR_COMPMASK_PORTGUID (1ull<<8)
+#define IB_NR_COMPMASK_PARTCAP (1ull<<9)
+#define IB_NR_COMPMASK_DEVID (1ull<<10)
+#define IB_NR_COMPMASK_REV (1ull<<11)
+#define IB_NR_COMPMASK_PORTNUM (1ull<<12)
+#define IB_NR_COMPMASK_VENDID (1ull<<13)
+#define IB_NR_COMPMASK_NODEDESC (1ull<<14)
+
+#define IB_NR_DEF_MASK IB_NR_COMPMASK_PORTGUID
+
+int ib_node_query_via(const struct ibmad_port *srcport, uint64_t guid,
+ ib_portid_t * sm_id, void *buf)
+{
+ ib_sa_call_t sa = { 0 };
+ uint8_t *p;
+
+ memset(&sa, 0, sizeof sa);
+ sa.method = IB_MAD_METHOD_GET;
+ sa.attrid = IB_SA_ATTR_NODERECORD;
+ sa.mask = IB_NR_DEF_MASK;
+ sa.trid = mad_trid();
+
+ memset(buf, 0, IB_SA_NR_RECSZ);
+
+ mad_encode_field(buf, IB_SA_NR_PORT_GUID_F, &guid);
+
+ p = sa_rpc_call(srcport, buf, sm_id, &sa, 0);
+ if (!p) {
+ IBWARN("sa call node_query failed");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/contrib/ofed/libibmad/serv.c b/contrib/ofed/libibmad/serv.c
new file mode 100644
index 000000000000..26d6d13c5d06
--- /dev/null
+++ b/contrib/ofed/libibmad/serv.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+int mad_send(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data)
+{
+ return mad_send_via(rpc, dport, rmpp, data, ibmp);
+}
+
+int mad_send_via(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data, struct ibmad_port *srcport)
+{
+ uint8_t pktbuf[1024];
+ void *umad = pktbuf;
+
+ memset(pktbuf, 0, umad_size() + IB_MAD_SIZE);
+
+ DEBUG("rmpp %p data %p", rmpp, data);
+
+ if (mad_build_pkt(umad, rpc, dport, rmpp, data) < 0)
+ return -1;
+
+ if (ibdebug) {
+ IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
+ xdump(stderr, "mad send data\n",
+ (char *)umad_get_mad(umad) + rpc->dataoffs, rpc->datasz);
+ }
+
+ if (umad_send(srcport->port_id, srcport->class_agents[rpc->mgtclass & 0xff],
+ umad, IB_MAD_SIZE, mad_get_timeout(srcport, rpc->timeout),
+ 0) < 0) {
+ IBWARN("send failed; %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int mad_respond(void *umad, ib_portid_t * portid, uint32_t rstatus)
+{
+ return mad_respond_via(umad, portid, rstatus, ibmp);
+}
+
+int mad_respond_via(void *umad, ib_portid_t * portid, uint32_t rstatus,
+ struct ibmad_port *srcport)
+{
+ uint8_t *mad = umad_get_mad(umad);
+ ib_mad_addr_t *mad_addr;
+ ib_rpc_t rpc = { 0 };
+ ib_portid_t rport;
+ int is_smi;
+
+ if (!portid) {
+ if (!(mad_addr = umad_get_mad_addr(umad))) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(&rport, 0, sizeof(rport));
+
+ rport.lid = ntohs(mad_addr->lid);
+ rport.qp = ntohl(mad_addr->qpn);
+ rport.qkey = ntohl(mad_addr->qkey);
+ rport.sl = mad_addr->sl;
+
+ if (mad_addr->grh_present) {
+ rport.grh_present = 1;
+ memcpy(&rport.gid, &mad_addr->gid, sizeof(rport.gid));
+ }
+
+ portid = &rport;
+ }
+
+ DEBUG("dest %s", portid2str(portid));
+
+ rpc.mgtclass = mad_get_field(mad, 0, IB_MAD_MGMTCLASS_F);
+
+ rpc.method = mad_get_field(mad, 0, IB_MAD_METHOD_F);
+ if (rpc.method == IB_MAD_METHOD_SET)
+ rpc.method = IB_MAD_METHOD_GET;
+ if (rpc.method != IB_MAD_METHOD_SEND)
+ rpc.method |= IB_MAD_RESPONSE;
+
+ rpc.attr.id = mad_get_field(mad, 0, IB_MAD_ATTRID_F);
+ rpc.attr.mod = mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
+ if (rpc.mgtclass == IB_SA_CLASS)
+ rpc.recsz = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
+ if (mad_is_vendor_range2(rpc.mgtclass))
+ rpc.oui = mad_get_field(mad, 0, IB_VEND2_OUI_F);
+
+ rpc.trid = mad_get_field64(mad, 0, IB_MAD_TRID_F);
+ rpc.rstatus = rstatus;
+
+ /* cleared by default: timeout, datasz, dataoffs, mkey, mask */
+
+ is_smi = rpc.mgtclass == IB_SMI_CLASS ||
+ rpc.mgtclass == IB_SMI_DIRECT_CLASS;
+
+ if (is_smi)
+ portid->qp = 0;
+ else if (!portid->qp)
+ portid->qp = 1;
+
+ if (!portid->qkey && portid->qp == 1)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ DEBUG
+ ("qp 0x%x class 0x%x method %d attr 0x%x mod 0x%x datasz %d off %d qkey %x",
+ portid->qp, rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod,
+ rpc.datasz, rpc.dataoffs, portid->qkey);
+
+ if (mad_build_pkt(umad, &rpc, portid, 0, 0) < 0)
+ return -1;
+
+ if (ibdebug > 1)
+ xdump(stderr, "mad respond pkt\n", mad, IB_MAD_SIZE);
+
+ if (umad_send
+ (srcport->port_id, srcport->class_agents[rpc.mgtclass], umad,
+ IB_MAD_SIZE, mad_get_timeout(srcport, rpc.timeout), 0) < 0) {
+ DEBUG("send failed; %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+void *mad_receive(void *umad, int timeout)
+{
+ return mad_receive_via(umad, timeout, ibmp);
+}
+
+void *mad_receive_via(void *umad, int timeout, struct ibmad_port *srcport)
+{
+ void *mad = umad ? umad : umad_alloc(1, umad_size() + IB_MAD_SIZE);
+ int agent;
+ int length = IB_MAD_SIZE;
+
+ if ((agent = umad_recv(srcport->port_id, mad, &length,
+ mad_get_timeout(srcport, timeout))) < 0) {
+ if (!umad)
+ umad_free(mad);
+ DEBUG("recv failed: %s", strerror(errno));
+ return 0;
+ }
+
+ return mad;
+}
+
+void *mad_alloc(void)
+{
+ return umad_alloc(1, umad_size() + IB_MAD_SIZE);
+}
+
+void mad_free(void *umad)
+{
+ umad_free(umad);
+}
diff --git a/contrib/ofed/libibmad/smp.c b/contrib/ofed/libibmad/smp.c
new file mode 100644
index 000000000000..c5471e9d0f97
--- /dev/null
+++ b/contrib/ofed/libibmad/smp.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+void smp_mkey_set(struct ibmad_port *srcport, uint64_t mkey)
+{
+ srcport->smp_mkey = mkey;
+}
+
+uint64_t smp_mkey_get(const struct ibmad_port *srcport)
+{
+ return srcport->smp_mkey;
+}
+
+uint8_t *smp_set_status_via(void *data, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout, int *rstatus,
+ const struct ibmad_port *srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ uint8_t *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ if ((portid->lid <= 0) ||
+ (portid->drpath.drslid == 0xffff) ||
+ (portid->drpath.drdlid == 0xffff))
+ rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
+ else
+ rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
+
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_SMP_DATA_SIZE;
+ rpc.dataoffs = IB_SMP_DATA_OFFS;
+ rpc.mkey = srcport->smp_mkey;
+
+ portid->sl = 0;
+ portid->qp = 0;
+
+ res = mad_rpc(srcport, &rpc, portid, data, data);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+ return res;
+}
+
+uint8_t *smp_set_via(void *data, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port *srcport)
+{
+ return smp_set_status_via(data, portid, attrid, mod, timeout, NULL,
+ srcport);
+}
+
+uint8_t *smp_set(void *data, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout)
+{
+ return smp_set_via(data, portid, attrid, mod, timeout, ibmp);
+}
+
+uint8_t *smp_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ uint8_t *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ rpc.method = IB_MAD_METHOD_GET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_SMP_DATA_SIZE;
+ rpc.dataoffs = IB_SMP_DATA_OFFS;
+ rpc.mkey = srcport->smp_mkey;
+
+ if ((portid->lid <= 0) ||
+ (portid->drpath.drslid == 0xffff) ||
+ (portid->drpath.drdlid == 0xffff))
+ rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
+ else
+ rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
+
+ portid->sl = 0;
+ portid->qp = 0;
+
+ res = mad_rpc(srcport, &rpc, portid, rcvbuf, rcvbuf);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+ return res;
+}
+
+uint8_t *smp_query_via(void *rcvbuf, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port * srcport)
+{
+ return smp_query_status_via(rcvbuf, portid, attrid, mod, timeout, NULL,
+ srcport);
+}
+
+uint8_t *smp_query(void *rcvbuf, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout)
+{
+ return smp_query_via(rcvbuf, portid, attrid, mod, timeout, ibmp);
+}
diff --git a/contrib/ofed/libibmad/vendor.c b/contrib/ofed/libibmad/vendor.c
new file mode 100644
index 000000000000..20abf5cfc3d5
--- /dev/null
+++ b/contrib/ofed/libibmad/vendor.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 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.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+static inline int response_expected(int method)
+{
+ return method == IB_MAD_METHOD_GET ||
+ method == IB_MAD_METHOD_SET || method == IB_MAD_METHOD_TRAP;
+}
+
+uint8_t *ib_vendor_call(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call)
+{
+ return ib_vendor_call_via(data, portid, call, ibmp);
+}
+
+uint8_t *ib_vendor_call_via(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call,
+ struct ibmad_port * srcport)
+{
+ ib_rpc_v1_t rpc = { 0 };
+ ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
+ int range1 = 0, resp_expected;
+ void *p_ret;
+
+ DEBUG("route %s data %p", portid2str(portid), data);
+ if (portid->lid <= 0)
+ return NULL; /* no direct SMI */
+
+ if (!(range1 = mad_is_vendor_range1(call->mgmt_class)) &&
+ !(mad_is_vendor_range2(call->mgmt_class)))
+ return NULL;
+
+ resp_expected = response_expected(call->method);
+
+ rpc.mgtclass = call->mgmt_class | IB_MAD_RPC_VERSION1;
+
+ rpc.method = call->method;
+ rpc.attr.id = call->attrid;
+ rpc.attr.mod = call->mod;
+ rpc.timeout = resp_expected ? call->timeout : 0;
+ rpc.datasz =
+ range1 ? IB_VENDOR_RANGE1_DATA_SIZE : IB_VENDOR_RANGE2_DATA_SIZE;
+ rpc.dataoffs =
+ range1 ? IB_VENDOR_RANGE1_DATA_OFFS : IB_VENDOR_RANGE2_DATA_OFFS;
+
+ if (!range1)
+ rpc.oui = call->oui;
+
+ DEBUG
+ ("class 0x%x method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d",
+ rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod, rpc.datasz,
+ rpc.dataoffs, resp_expected);
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ if (resp_expected) {
+ p_ret = mad_rpc_rmpp(srcport, rpcold, portid, 0, data); /* FIXME: no RMPP for now */
+ errno = rpc.error;
+ return p_ret;
+ }
+
+ return mad_send_via(rpcold, portid, 0, data, srcport) < 0 ? 0 : data; /* FIXME: no RMPP for now */
+}