diff mbox

RDMA/libibverbs: Display proper speed for RoCE devices

Message ID 4b5b3757-bfbe-49a6-aa12-3267a11187d0@CMEXHTCAS2.ad.emulex.com (mailing list archive)
State Rejected
Headers show

Commit Message

Devesh Sharma Jan. 22, 2014, 11:49 a.m. UTC
From: Devesh Sharma <devesh.sharma@emulex.com>

currently ibv_devinfo -v display active_width. However, on RoCE link_width
is not defined. Therefore adding checks on link_layer while displaying
active_link_speed and active_link_width.
Also adding check on link_layer while displaying LID, SM_LID and LMC.

Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com>
---
 examples/devinfo.c |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/examples/devinfo.c b/examples/devinfo.c
index ff078e4..85c8c0a 100644
--- a/examples/devinfo.c
+++ b/examples/devinfo.c
@@ -149,6 +149,17 @@  static const char *speed_str(uint8_t speed)
 	}
 }
 
+static const char *roce_speed_str (uint8_t speed)
+{
+	switch (speed) {
+	case 1: return "2.5 Gbps";
+	case 2: return "5.0 Gbps";
+	case 4: return "10.0 Gbps";
+	case 8: return "40.0 Gbps";
+	default: return "invalid speed";
+	}
+}
+
 static const char *vl_str(uint8_t vl_num)
 {
 	switch (vl_num) {
@@ -305,9 +316,13 @@  static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
 		       mtu_str(port_attr.max_mtu), port_attr.max_mtu);
 		printf("\t\t\tactive_mtu:\t\t%s (%d)\n",
 		       mtu_str(port_attr.active_mtu), port_attr.active_mtu);
-		printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid);
-		printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid);
-		printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc);
+
+		if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
+			printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid);
+			printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid);
+			printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc);
+		}
+
 		printf("\t\t\tlink_layer:\t\t%s\n",
 					link_layer_str(port_attr.link_layer));
 
@@ -323,10 +338,17 @@  static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
 			printf("\t\t\tgid_tbl_len:\t\t%d\n", port_attr.gid_tbl_len);
 			printf("\t\t\tsubnet_timeout:\t\t%d\n", port_attr.subnet_timeout);
 			printf("\t\t\tinit_type_reply:\t%d\n", port_attr.init_type_reply);
-			printf("\t\t\tactive_width:\t\t%sX (%d)\n",
-			       width_str(port_attr.active_width), port_attr.active_width);
-			printf("\t\t\tactive_speed:\t\t%s (%d)\n",
-			       speed_str(port_attr.active_speed), port_attr.active_speed);
+
+			if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
+				printf("\t\t\tactive_width:\t\t%sX (%d)\n",
+			               width_str(port_attr.active_width), port_attr.active_width);
+				printf("\t\t\tactive_speed:\t\t%s (%d)\n",
+			               speed_str(port_attr.active_speed), port_attr.active_speed);
+			} else {
+				printf("\t\t\tactive_speed:\t\t%s (%d)\n",
+                                       roce_speed_str(port_attr.active_speed * port_attr.active_width),
+                                       port_attr.active_speed * port_attr.active_width);
+			}
 			if (ib_dev->transport_type == IBV_TRANSPORT_IB)
 				printf("\t\t\tphys_state:\t\t%s (%d)\n",
 				       port_phy_state_str(port_attr.phys_state), port_attr.phys_state);