[ofa-general] Re: [PATCH - diags] Added support to query the GUID table entries
Hal Rosenstock
halr at voltaire.com
Wed Mar 14 06:45:38 PDT 2007
Hi Dotan,
On Wed, 2007-03-14 at 06:25, Dotan Barak wrote:
> Added support to query the GUID table entries.
Thanks. One comment below:
> Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>
>
> ---
>
> Index: gen2_devel_user/src/userspace/management/diags/src/smpquery.c
> ===================================================================
> --- gen2_devel_user.orig/src/userspace/management/diags/src/smpquery.c 2007-03-12 18:05:09.000000000 +0200
> +++ gen2_devel_user/src/userspace/management/diags/src/smpquery.c 2007-03-12 18:09:52.000000000 +0200
> @@ -44,6 +44,9 @@
> #include <getopt.h>
> #include <netinet/in.h>
>
> +#define __STDC_FORMAT_MACROS
> +#include <inttypes.h>
> +
> #define __BUILD_VERSION_TAG__ 1.2
> #include <common.h>
> #include <umad.h>
> @@ -65,7 +68,7 @@ typedef struct match_rec {
> } match_rec_t;
>
> static op_fn_t node_desc, node_info, port_info, switch_info, pkey_table,
> - sl2vl_table, vlarb_table;
> + sl2vl_table, vlarb_table, guid_info;
>
> static const match_rec_t match_tbl[] = {
> { "nodeinfo", node_info },
> @@ -75,6 +78,7 @@ static const match_rec_t match_tbl[] = {
> { "pkeys", pkey_table, 1 },
> { "sl2vl", sl2vl_table, 1 },
> { "vlarb", vlarb_table, 1 },
> + { "guid", guid_info, 1 },
> {0}
> };
>
> @@ -341,6 +345,51 @@ vlarb_table(ib_portid_t *dest, char **ar
> return ret;
> }
>
> +static char *
> +guid_info(ib_portid_t *dest, char **argv, int argc)
> +{
> + uint8_t data[IB_SMP_DATA_SIZE];
> + uint32_t i, j, k;
> + uint64_t *p;
> + uint mod;
> + int n, phy_ports;
> + int portnum = 0;
> +
> + if (argc > 0)
> + portnum = strtol(argv[0], 0, 0);
> +
> + /* Get the guid capacity */
> + if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
> + return "node info query failed";
> +
> + mad_decode_field(data, IB_NODE_NPORTS_F, &phy_ports);
> + if (portnum > phy_ports)
> + return "invalid port number";
> + if (!smp_query(data, dest, IB_ATTR_PORT_INFO, 0, 0))
> + return "port info failed";
Port number does not affect GUIDInfo and in fact the query for PortInfo
here is using port 0 so portnum is not needed, right ?
-- Hal
> + mad_decode_field(data, IB_PORT_GUID_CAP_F, &n);
> +
> + for (i = 0; i < (n + 7) / 8; i++) {
> + mod = i;
> + if (!smp_query(data, dest, IB_ATTR_GUID_INFO, mod, 0))
> + return "guid info query failed";
> + if (i + 1 == (n + 7) / 8)
> + k = ((n + 1 - i * 8) / 2) * 2;
> + else
> + k = 8;
> + p = (uint64_t *) data;
> + for (j = 0; j < k; j += 2, p += 2) {
> + printf("%4u: 0x%016"PRIx64" 0x%016"PRIx64"\n",
> + (i * 8) + j,
> + ntohll(p[0]), ntohll(p[1]));
> + }
> + }
> + printf("%d guids capacity for this port\n", n);
> +
> + return 0;
> +}
> +
> static op_fn_t *
> match_op(char *name)
> {
> Index: gen2_devel_user/src/userspace/management/libibmad/include/infiniband/mad.h
> ===================================================================
> --- gen2_devel_user.orig/src/userspace/management/libibmad/include/infiniband/mad.h 2007-02-26 16:01:55.000000000 +0200
> +++ gen2_devel_user/src/userspace/management/libibmad/include/infiniband/mad.h 2007-03-12 18:12:11.000000000 +0200
> @@ -118,6 +118,7 @@ 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,
>
>
More information about the general
mailing list