All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] rdma-core/libibverbs: display gid type in ibv_devinfo
@ 2020-02-03  5:47 Devesh Sharma
  2020-02-03  8:49 ` Leon Romanovsky
  2020-02-03  9:13 ` Gal Pressman
  0 siblings, 2 replies; 5+ messages in thread
From: Devesh Sharma @ 2020-02-03  5:47 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.

Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
---
 libibverbs/examples/devinfo.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c
index bf53eac..bbaed8c 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 0: return "IB/RoCE v1";
+	case 1: return "RoCE v2";
+	default: return "invalid value";
+	}
+}
+
 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 = 0x2;
+		}
+
 		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] 5+ messages in thread

* Re: [PATCH v3] rdma-core/libibverbs: display gid type in ibv_devinfo
  2020-02-03  5:47 [PATCH v3] rdma-core/libibverbs: display gid type in ibv_devinfo Devesh Sharma
@ 2020-02-03  8:49 ` Leon Romanovsky
  2020-02-03 14:59   ` Devesh Sharma
  2020-02-03  9:13 ` Gal Pressman
  1 sibling, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2020-02-03  8:49 UTC (permalink / raw)
  To: Devesh Sharma; +Cc: linux-rdma, jgg

On Mon, Feb 03, 2020 at 12:47:26AM -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.
>
> Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
> ---
>  libibverbs/examples/devinfo.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
>

It will be very helpful to add example of "ibv_devinfo -v"
to the commit message.

Thanks

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

* Re: [PATCH v3] rdma-core/libibverbs: display gid type in ibv_devinfo
  2020-02-03  5:47 [PATCH v3] rdma-core/libibverbs: display gid type in ibv_devinfo Devesh Sharma
  2020-02-03  8:49 ` Leon Romanovsky
@ 2020-02-03  9:13 ` Gal Pressman
  2020-02-03 15:00   ` Devesh Sharma
  1 sibling, 1 reply; 5+ messages in thread
From: Gal Pressman @ 2020-02-03  9:13 UTC (permalink / raw)
  To: Devesh Sharma; +Cc: linux-rdma, jgg, leon

On 03/02/2020 7:47, 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.
> 
> Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
> ---
>  libibverbs/examples/devinfo.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c
> index bf53eac..bbaed8c 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 0: return "IB/RoCE v1";
> +	case 1: return "RoCE v2";
> +	default: return "invalid value";
> +	}
> +}

Why hard code the enum values? Use IBV_GID_TYPE_IB_ROCE_V1 and IBV_GID_TYPE_ROCE_V2.

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

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

On Mon, Feb 3, 2020 at 2:20 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Mon, Feb 03, 2020 at 12:47:26AM -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.
> >
> > Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
> > ---
> >  libibverbs/examples/devinfo.c | 22 ++++++++++++++++++++--
> >  1 file changed, 20 insertions(+), 2 deletions(-)
> >
>
> It will be very helpful to add example of "ibv_devinfo -v"
> to the commit message.
Sure, adding it.
>
> Thanks

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

* Re: [PATCH v3] rdma-core/libibverbs: display gid type in ibv_devinfo
  2020-02-03  9:13 ` Gal Pressman
@ 2020-02-03 15:00   ` Devesh Sharma
  0 siblings, 0 replies; 5+ messages in thread
From: Devesh Sharma @ 2020-02-03 15:00 UTC (permalink / raw)
  To: Gal Pressman; +Cc: linux-rdma, Jason Gunthorpe, Leon Romanovsky

On Mon, Feb 3, 2020 at 2:43 PM Gal Pressman <galpress@amazon.com> wrote:
>
> On 03/02/2020 7:47, 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.
> >
> > Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
> > ---
> >  libibverbs/examples/devinfo.c | 22 ++++++++++++++++++++--
> >  1 file changed, 20 insertions(+), 2 deletions(-)
> >
> > diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c
> > index bf53eac..bbaed8c 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 0: return "IB/RoCE v1";
> > +     case 1: return "RoCE v2";
> > +     default: return "invalid value";
> > +     }
> > +}
>
> Why hard code the enum values? Use IBV_GID_TYPE_IB_ROCE_V1 and IBV_GID_TYPE_ROCE_V2.
Agree, changing it.

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03  5:47 [PATCH v3] rdma-core/libibverbs: display gid type in ibv_devinfo Devesh Sharma
2020-02-03  8:49 ` Leon Romanovsky
2020-02-03 14:59   ` Devesh Sharma
2020-02-03  9:13 ` Gal Pressman
2020-02-03 15:00   ` Devesh Sharma

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.