From: Devesh Sharma <devesh.sharma@broadcom.com>
To: linux-rdma@vger.kernel.org
Cc: jgg@mellanox.com, leon@kernel.org
Subject: [PATCH v5] libibverbs: display gid type in ibv_devinfo
Date: Mon, 3 Feb 2020 12:52:04 -0500 [thread overview]
Message-ID: <1580752324-24742-1-git-send-email-devesh.sharma@broadcom.com> (raw)
It becomes difficult to make out from the output of ibv_devinfo
if a particular gid index is RoCE v2 or not.
Adding a string to the output of ibv_devinfo -v to display the
gid type at the end of gid.
The output would look something like below:
$ ibv_devinfo -v -d bnxt_re2
hca_id: bnxt_re2
transport: InfiniBand (0)
fw_ver: 216.0.220.0
node_guid: b226:28ff:fed3:b0f0
sys_image_guid: b226:28ff:fed3:b0f0
.
.
.
.
phys_state: LINK_UP (5)
GID[ 0]: fe80::b226:28ff:fed3:b0f0, IB/RoCE v1
GID[ 1]: fe80::b226:28ff:fed3:b0f0, RoCE v2
GID[ 2]: ::ffff:192.170.1.101, IB/RoCE v1
GID[ 3]: ::ffff:192.170.1.101, RoCE v2
$
$
Reviewed-by: Jason Gunthrope <jgg@ziepe.ca>
Reviewed-by: Leon Romanovsky <leon@kernel.org>
Reviewed-by: Gal Pressman <galpress@amazon.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
---
libibverbs/driver.h | 1 +
libibverbs/examples/devinfo.c | 35 ++++++++++++++++++++++++-----------
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/libibverbs/driver.h b/libibverbs/driver.h
index a0e6f89..fc0699d 100644
--- a/libibverbs/driver.h
+++ b/libibverbs/driver.h
@@ -84,6 +84,7 @@ enum verbs_qp_mask {
enum ibv_gid_type {
IBV_GID_TYPE_IB_ROCE_V1,
IBV_GID_TYPE_ROCE_V2,
+ IBV_GID_TYPE_INVALID
};
enum ibv_mr_type {
diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c
index bf53eac..568712c 100644
--- a/libibverbs/examples/devinfo.c
+++ b/libibverbs/examples/devinfo.c
@@ -40,6 +40,7 @@
#include <getopt.h>
#include <endian.h>
#include <inttypes.h>
+#include <arpa/inet.h>
#include <infiniband/verbs.h>
#include <infiniband/driver.h>
@@ -162,8 +163,19 @@ static const char *vl_str(uint8_t vl_num)
}
}
+static const char *gid_type_str(enum ibv_gid_type type)
+{
+ switch (type) {
+ case IBV_GID_TYPE_IB_ROCE_V1: return "IB/RoCE v1";
+ case IBV_GID_TYPE_ROCE_V2: return "RoCE v2";
+ default: return "Invalid gid type";
+ }
+}
+
static int print_all_port_gids(struct ibv_context *ctx, uint8_t port_num, int tbl_len)
{
+ char gid_str[INET6_ADDRSTRLEN] = {};
+ enum ibv_gid_type type;
union ibv_gid gid;
int rc = 0;
int i;
@@ -175,17 +187,18 @@ static int print_all_port_gids(struct ibv_context *ctx, uint8_t port_num, int tb
port_num, i);
return rc;
}
- if (!null_gid(&gid))
- printf("\t\t\tGID[%3d]:\t\t%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
- i,
- gid.raw[ 0], gid.raw[ 1],
- gid.raw[ 2], gid.raw[ 3],
- gid.raw[ 4], gid.raw[ 5],
- gid.raw[ 6], gid.raw[ 7],
- gid.raw[ 8], gid.raw[ 9],
- gid.raw[10], gid.raw[11],
- gid.raw[12], gid.raw[13],
- gid.raw[14], gid.raw[15]);
+
+ rc = ibv_query_gid_type(ctx, port_num, i, &type);
+ if (rc) {
+ rc = 0;
+ type = IBV_GID_TYPE_INVALID;
+ }
+
+ if (!null_gid(&gid)) {
+ inet_ntop(AF_INET6, gid.raw, gid_str, sizeof(gid_str));
+ printf("\t\t\tGID[%3d]:\t\t%s, %s\n", i, gid_str,
+ gid_type_str(type));
+ }
}
return rc;
}
--
1.8.3.1
next reply other threads:[~2020-02-03 17:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-03 17:52 Devesh Sharma [this message]
2020-02-03 17:53 ` [PATCH v5] libibverbs: display gid type in ibv_devinfo Jason Gunthorpe
2020-02-03 18:01 ` Devesh Sharma
2020-02-03 18:04 ` Jason Gunthorpe
2020-02-03 18:09 ` Devesh Sharma
2020-02-04 4:27 ` Parav Pandit
2020-02-04 5:08 ` Devesh Sharma
2020-02-04 7:17 ` Leon Romanovsky
2020-02-04 7:25 ` Parav Pandit
2020-02-04 8:44 ` Devesh Sharma
2020-02-04 8:50 ` Devesh Sharma
2020-02-03 19:46 ` Leon Romanovsky
2020-02-04 5:07 ` Devesh Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1580752324-24742-1-git-send-email-devesh.sharma@broadcom.com \
--to=devesh.sharma@broadcom.com \
--cc=jgg@mellanox.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox