netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2-next] rdma: Add print of link CapabilityMask2 flags
@ 2018-12-23 11:24 Leon Romanovsky
  2018-12-27 23:42 ` David Ahern
  0 siblings, 1 reply; 2+ messages in thread
From: Leon Romanovsky @ 2018-12-23 11:24 UTC (permalink / raw)
  To: David Ahern
  Cc: Michael Guralnik, netdev, RDMA mailing list, Stephen Hemminger,
	Leon Romanovsky

From: Michael Guralnik <michaelgur@mellanox.com>

CapabilityMask2 is defined in IBTA spec as a member of PortInfo.
Add translation to string of new CapabilityMask2 expansion of link caps.

The flags are concatenated to current caps print as seen in this example
printing EXT_INFO flag:

root@server-22 $ rdma -d link
1/1: mlx5_0/1: subnet_prefix fe80:0000:0000:0000 lid 2 sm_lid 2 lmc 0
	state ACTIVE physical_state LINK_UP
caps: <SM, TRAP, SL_MAP, SYS_IMAGE_GUID, CABLE_INFO, EXTENDED_SPEEDS,
	CAP_MASK2, CM, DEVICE_MGMT, VENDOR_CLASS, CAP_MASK_NOTICE,
	CLIENT_REG, OTHER_LOCAL_CHANGES, MULT_PKER_TRAP, EXT_INFO>

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 rdma/link.c | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/rdma/link.c b/rdma/link.c
index 7a6d4b7e..c064be62 100644
--- a/rdma/link.c
+++ b/rdma/link.c
@@ -19,7 +19,7 @@ static int link_help(struct rd *rd)

 static const char *caps_to_str(uint32_t idx)
 {
-#define RDMA_PORT_FLAGS(x) \
+#define RDMA_PORT_FLAGS_LOW(x) \
 	x(RESERVED, 0) \
 	x(SM, 1) \
 	x(NOTICE, 2) \
@@ -53,13 +53,39 @@ static const char *caps_to_str(uint32_t idx)
 	x(MULT_FDB, 30) \
 	x(HIERARCHY_INFO, 31)

-	enum { RDMA_PORT_FLAGS(RDMA_BITMAP_ENUM) };
+#define RDMA_PORT_FLAGS_HIGH(x) \
+	x(SET_NODE_DESC, 0) \
+	x(EXT_INFO, 1) \
+	x(VIRT, 2) \
+	x(SWITCH_POR_STATE_TABLE, 3) \
+	x(LINK_WIDTH_2X, 4) \
+	x(LINK_SPEED_HDR, 5)
+
+	/*
+	 * Separation below is needed to allow compilation of rdmatool
+	 * on 32bits systems. On such systems, C-enum is limited to be
+	 * int and can't hold more than 32 bits.
+	 */
+	enum { RDMA_PORT_FLAGS_LOW(RDMA_BITMAP_ENUM) };
+	enum { RDMA_PORT_FLAGS_HIGH(RDMA_BITMAP_ENUM) };

 	static const char * const
-		rdma_port_names[] = { RDMA_PORT_FLAGS(RDMA_BITMAP_NAMES) };
-	#undef RDMA_PORT_FLAGS
+		rdma_port_names_low[] = { RDMA_PORT_FLAGS_LOW(RDMA_BITMAP_NAMES) };
+	static const char * const
+		rdma_port_names_high[] = { RDMA_PORT_FLAGS_HIGH(RDMA_BITMAP_NAMES) };
+	uint32_t high_idx;
+	#undef RDMA_PORT_FLAGS_LOW
+	#undef RDMA_PORT_FLAGS_HIGH
+
+	if (idx < ARRAY_SIZE(rdma_port_names_low) && rdma_port_names_low[idx])
+		return rdma_port_names_low[idx];

-	return rdma_port_names[idx];
+	high_idx = idx - ARRAY_SIZE(rdma_port_names_low);
+	if (high_idx < ARRAY_SIZE(rdma_port_names_high) &&
+	    rdma_port_names_high[high_idx])
+		return rdma_port_names_high[high_idx];
+
+	return "UNKNOWN";
 }

 static void link_print_caps(struct rd *rd, struct nlattr **tb)

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

* Re: [PATCH iproute2-next] rdma: Add print of link CapabilityMask2 flags
  2018-12-23 11:24 [PATCH iproute2-next] rdma: Add print of link CapabilityMask2 flags Leon Romanovsky
@ 2018-12-27 23:42 ` David Ahern
  0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2018-12-27 23:42 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Michael Guralnik, netdev, RDMA mailing list, Stephen Hemminger,
	Leon Romanovsky

On 12/23/18 6:24 AM, Leon Romanovsky wrote:
> From: Michael Guralnik <michaelgur@mellanox.com>
> 
> CapabilityMask2 is defined in IBTA spec as a member of PortInfo.
> Add translation to string of new CapabilityMask2 expansion of link caps.
> 
> The flags are concatenated to current caps print as seen in this example
> printing EXT_INFO flag:
> 
> root@server-22 $ rdma -d link
> 1/1: mlx5_0/1: subnet_prefix fe80:0000:0000:0000 lid 2 sm_lid 2 lmc 0
> 	state ACTIVE physical_state LINK_UP
> caps: <SM, TRAP, SL_MAP, SYS_IMAGE_GUID, CABLE_INFO, EXTENDED_SPEEDS,
> 	CAP_MASK2, CM, DEVICE_MGMT, VENDOR_CLASS, CAP_MASK_NOTICE,
> 	CLIENT_REG, OTHER_LOCAL_CHANGES, MULT_PKER_TRAP, EXT_INFO>
> 
> Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  rdma/link.c | 36 +++++++++++++++++++++++++++++++-----
>  1 file changed, 31 insertions(+), 5 deletions(-)
> 

applied to iproute2-next. Thanks

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

end of thread, other threads:[~2018-12-27 23:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-23 11:24 [PATCH iproute2-next] rdma: Add print of link CapabilityMask2 flags Leon Romanovsky
2018-12-27 23:42 ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).