All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] libibverbs: display gid type in ibv_devinfo
@ 2020-02-03 15:56 Devesh Sharma
  2020-02-03 16:08 ` Jason Gunthorpe
  2020-02-03 18:18 ` Gal Pressman
  0 siblings, 2 replies; 8+ messages in thread
From: Devesh Sharma @ 2020-02-03 15:56 UTC (permalink / raw)
  To: linux-rdma; +Cc: jgg, leon

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:0000:0000:0000:b226:28ff:fed3:b0f0, IB/RoCE v1
       GID[  1]:        fe80:0000:0000:0000:b226:28ff:fed3:b0f0, RoCE v2
       GID[  2]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, IB/RoCE v1
       GID[  3]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, RoCE v2
$
$

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 | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 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..5bf1a39 100644
--- a/libibverbs/examples/devinfo.c
+++ b/libibverbs/examples/devinfo.c
@@ -162,8 +162,18 @@ 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)
 {
+	enum ibv_gid_type type;
 	union ibv_gid gid;
 	int rc = 0;
 	int i;
@@ -175,8 +185,15 @@ static int print_all_port_gids(struct ibv_context *ctx, uint8_t port_num, int tb
 			       port_num, i);
 			return rc;
 		}
+
+		rc = ibv_query_gid_type(ctx, port_num, i, &type);
+		if (rc) {
+			rc = 0;
+			type = IBV_GID_TYPE_INVALID;
+		}
+
 		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",
+			printf("\t\t\tGID[%3d]:\t\t%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x, %s\n",
 			       i,
 			       gid.raw[ 0], gid.raw[ 1],
 			       gid.raw[ 2], gid.raw[ 3],
@@ -185,7 +202,8 @@ static int print_all_port_gids(struct ibv_context *ctx, uint8_t port_num, int tb
 			       gid.raw[ 8], gid.raw[ 9],
 			       gid.raw[10], gid.raw[11],
 			       gid.raw[12], gid.raw[13],
-			       gid.raw[14], gid.raw[15]);
+			       gid.raw[14], gid.raw[15],
+			       gid_type_str(type));
 	}
 	return rc;
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] libibverbs: display gid type in ibv_devinfo
  2020-02-03 15:56 [PATCH v4] libibverbs: display gid type in ibv_devinfo Devesh Sharma
@ 2020-02-03 16:08 ` Jason Gunthorpe
  2020-02-03 16:27   ` Devesh Sharma
  2020-02-03 18:18 ` Gal Pressman
  1 sibling, 1 reply; 8+ messages in thread
From: Jason Gunthorpe @ 2020-02-03 16:08 UTC (permalink / raw)
  To: Devesh Sharma; +Cc: linux-rdma, leon

On Mon, Feb 03, 2020 at 10:56:55AM -0500, Devesh Sharma wrote:
> 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:0000:0000:0000:b226:28ff:fed3:b0f0, IB/RoCE v1
>        GID[  1]:        fe80:0000:0000:0000:b226:28ff:fed3:b0f0, RoCE v2
>        GID[  2]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, IB/RoCE v1
>        GID[  3]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, RoCE v2

I think you should display the RoCEv2 GID in IPv6 notation, since it
isn't really a GID anyhmore. The IPv6 notation should automatically
show the IPv4 dotted quad

Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] libibverbs: display gid type in ibv_devinfo
  2020-02-03 16:08 ` Jason Gunthorpe
@ 2020-02-03 16:27   ` Devesh Sharma
  2020-02-03 16:50     ` Jason Gunthorpe
  0 siblings, 1 reply; 8+ messages in thread
From: Devesh Sharma @ 2020-02-03 16:27 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma, Leon Romanovsky

On Mon, Feb 3, 2020 at 9:38 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Mon, Feb 03, 2020 at 10:56:55AM -0500, Devesh Sharma wrote:
> > 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:0000:0000:0000:b226:28ff:fed3:b0f0, IB/RoCE v1
> >        GID[  1]:        fe80:0000:0000:0000:b226:28ff:fed3:b0f0, RoCE v2
> >        GID[  2]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, IB/RoCE v1
> >        GID[  3]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, RoCE v2
>
> I think you should display the RoCEv2 GID in IPv6 notation, since it
> isn't really a GID anyhmore. The IPv6 notation should automatically
> show the IPv4 dotted quad

There are many format specifiers, which one are you indicating? are
those supported in printf()?
>
> Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] libibverbs: display gid type in ibv_devinfo
  2020-02-03 16:27   ` Devesh Sharma
@ 2020-02-03 16:50     ` Jason Gunthorpe
  2020-02-03 17:52       ` Devesh Sharma
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Gunthorpe @ 2020-02-03 16:50 UTC (permalink / raw)
  To: Devesh Sharma; +Cc: linux-rdma, Leon Romanovsky

On Mon, Feb 03, 2020 at 09:57:39PM +0530, Devesh Sharma wrote:
> On Mon, Feb 3, 2020 at 9:38 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> >
> > On Mon, Feb 03, 2020 at 10:56:55AM -0500, Devesh Sharma wrote:
> > > 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:0000:0000:0000:b226:28ff:fed3:b0f0, IB/RoCE v1
> > >        GID[  1]:        fe80:0000:0000:0000:b226:28ff:fed3:b0f0, RoCE v2
> > >        GID[  2]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, IB/RoCE v1
> > >        GID[  3]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, RoCE v2
> >
> > I think you should display the RoCEv2 GID in IPv6 notation, since it
> > isn't really a GID anyhmore. The IPv6 notation should automatically
> > show the IPv4 dotted quad
> 
> There are many format specifiers, which one are you indicating? are
> those supported in printf()?

inet_ntop(AF_INET6)

Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] libibverbs: display gid type in ibv_devinfo
  2020-02-03 16:50     ` Jason Gunthorpe
@ 2020-02-03 17:52       ` Devesh Sharma
  0 siblings, 0 replies; 8+ messages in thread
From: Devesh Sharma @ 2020-02-03 17:52 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma, Leon Romanovsky

On Mon, Feb 3, 2020 at 10:20 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Mon, Feb 03, 2020 at 09:57:39PM +0530, Devesh Sharma wrote:
> > On Mon, Feb 3, 2020 at 9:38 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> > >
> > > On Mon, Feb 03, 2020 at 10:56:55AM -0500, Devesh Sharma wrote:
> > > > 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:0000:0000:0000:b226:28ff:fed3:b0f0, IB/RoCE v1
> > > >        GID[  1]:        fe80:0000:0000:0000:b226:28ff:fed3:b0f0, RoCE v2
> > > >        GID[  2]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, IB/RoCE v1
> > > >        GID[  3]:        0000:0000:0000:0000:0000:ffff:c0aa:0165, RoCE v2
> > >
> > > I think you should display the RoCEv2 GID in IPv6 notation, since it
> > > isn't really a GID anyhmore. The IPv6 notation should automatically
> > > show the IPv4 dotted quad
> >
> > There are many format specifiers, which one are you indicating? are
> > those supported in printf()?
>
> inet_ntop(AF_INET6)
Done!
>
> Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] libibverbs: display gid type in ibv_devinfo
  2020-02-03 15:56 [PATCH v4] libibverbs: display gid type in ibv_devinfo Devesh Sharma
  2020-02-03 16:08 ` Jason Gunthorpe
@ 2020-02-03 18:18 ` Gal Pressman
  2020-02-03 18:23   ` Devesh Sharma
  1 sibling, 1 reply; 8+ messages in thread
From: Gal Pressman @ 2020-02-03 18:18 UTC (permalink / raw)
  To: Devesh Sharma; +Cc: linux-rdma, jgg, leon

On 03/02/2020 17:56, Devesh Sharma wrote:
> 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
>  };

I don't think that's right.
You're adding a new enum value to libibverbs, but it's not really
used/implemented there.
If devinfo needs an invalid GID value, make it local to that program.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] libibverbs: display gid type in ibv_devinfo
  2020-02-03 18:18 ` Gal Pressman
@ 2020-02-03 18:23   ` Devesh Sharma
  2020-02-03 19:44     ` Leon Romanovsky
  0 siblings, 1 reply; 8+ messages in thread
From: Devesh Sharma @ 2020-02-03 18:23 UTC (permalink / raw)
  To: Gal Pressman; +Cc: linux-rdma, Jason Gunthorpe, Leon Romanovsky

On Mon, Feb 3, 2020 at 11:48 PM Gal Pressman <galpress@amazon.com> wrote:
>
> On 03/02/2020 17:56, Devesh Sharma wrote:
> > 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
> >  };
>
> I don't think that's right.
> You're adding a new enum value to libibverbs, but it's not really
> used/implemented there.
> If devinfo needs an invalid GID value, make it local to that program.

the enum can be used by other applications too, if those are yet to be
coded in future. I thought its a good practice to put things at one
place once for all.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] libibverbs: display gid type in ibv_devinfo
  2020-02-03 18:23   ` Devesh Sharma
@ 2020-02-03 19:44     ` Leon Romanovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2020-02-03 19:44 UTC (permalink / raw)
  To: Devesh Sharma; +Cc: Gal Pressman, linux-rdma, Jason Gunthorpe

On Mon, Feb 03, 2020 at 11:53:47PM +0530, Devesh Sharma wrote:
> On Mon, Feb 3, 2020 at 11:48 PM Gal Pressman <galpress@amazon.com> wrote:
> >
> > On 03/02/2020 17:56, Devesh Sharma wrote:
> > > 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
> > >  };
> >
> > I don't think that's right.
> > You're adding a new enum value to libibverbs, but it's not really
> > used/implemented there.
> > If devinfo needs an invalid GID value, make it local to that program.
>
> the enum can be used by other applications too, if those are yet to be
> coded in future. I thought its a good practice to put things at one
> place once for all.

Yes, as long as IBV_GID_TYPE_INVALID can be returned by ibv_query_gid_type(),
but it doesn't.

Thanks

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-02-03 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 15:56 [PATCH v4] libibverbs: display gid type in ibv_devinfo Devesh Sharma
2020-02-03 16:08 ` Jason Gunthorpe
2020-02-03 16:27   ` Devesh Sharma
2020-02-03 16:50     ` Jason Gunthorpe
2020-02-03 17:52       ` Devesh Sharma
2020-02-03 18:18 ` Gal Pressman
2020-02-03 18:23   ` Devesh Sharma
2020-02-03 19:44     ` Leon Romanovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.