[openib-general] [libmthca] patch to devinfo: Added a print of the IB ports rate values

Dotan Barak dotanb at mellanox.co.il
Tue Jul 25 08:03:46 PDT 2006


attached in the patch of this issue (until i'll fix my mail client)

thanks
Dotan
-------------- next part --------------
Added a print of the IB ports rate values.

Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>

Index: latest/src/userspace/libibverbs/examples/devinfo.c
===================================================================
--- latest.orig/src/userspace/libibverbs/examples/devinfo.c	2006-07-25 08:02:39.000000000 +0300
+++ latest/src/userspace/libibverbs/examples/devinfo.c	2006-07-25 17:05:35.000000000 +0300
@@ -104,36 +104,36 @@ static const char *atomic_cap_str(enum i
 	}
 }
 
-static const char *mtu_str(enum ibv_mtu max_mtu)
+static int mtu_num(enum ibv_mtu max_mtu)
 {
 	switch (max_mtu) {
-	case IBV_MTU_256:  return "256";
-	case IBV_MTU_512:  return "512";
-	case IBV_MTU_1024: return "1024";
-	case IBV_MTU_2048: return "2048";
-	case IBV_MTU_4096: return "4096";
-	default:           return "invalid MTU";
+	case IBV_MTU_256:  return 256;
+	case IBV_MTU_512:  return 512;
+	case IBV_MTU_1024: return 1024;
+	case IBV_MTU_2048: return 2048;
+	case IBV_MTU_4096: return 4096;
+	default:           return -1;
 	}
 }
 
-static const char *width_str(uint8_t width)
+static int width_num(uint8_t width)
 {
 	switch (width) {
-	case 1:  return "1";
-	case 2:  return "4";
-	case 4:  return "8";
-	case 8:  return "12";
-	default: return "invalid width";
+	case 1:  return 1;
+	case 2:  return 4;
+	case 4:  return 8;
+	case 8:  return 12;
+	default: return -1;
 	}
 }
 
-static const char *speed_str(uint8_t speed)
+static double speed_num(uint8_t speed)
 {
 	switch (speed) {
-	case 1:  return "2.5 Gbps";
-	case 2:  return "5.0 Gbps";
-	case 4:  return "10.0 Gbps";
-	default: return "invalid speed";
+	case 1:  return 2.5;
+	case 2:  return 5.0;
+	case 4:  return 10.0;
+	default: return -1;
 	}
 }
 
@@ -257,10 +257,10 @@ static int print_hca_cap(struct ibv_devi
 		printf("\t\tport:\t%d\n", port);
 		printf("\t\t\tstate:\t\t\t%s (%d)\n",
 		       port_state_str(port_attr.state), port_attr.state);
-		printf("\t\t\tmax_mtu:\t\t%s (%d)\n",
-		       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\tmax_mtu:\t\t%d (%d)\n",
+		       mtu_num(port_attr.max_mtu), port_attr.max_mtu);
+		printf("\t\t\tactive_mtu:\t\t%d (%d)\n",
+		       mtu_num(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);
@@ -276,10 +276,12 @@ static int print_hca_cap(struct ibv_devi
 			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);
+			printf("\t\t\tactive_width:\t\t%dX (%d)\n",
+			       width_num(port_attr.active_width), port_attr.active_width);
+			printf("\t\t\tactive_speed:\t\t%.1lf Gbps (%d)\n",
+			       speed_num(port_attr.active_speed), port_attr.active_speed);
+			printf("\t\t\trate:\t\t\t%.1lf\n",
+			       width_num(port_attr.active_width) * speed_num(port_attr.active_speed));
 			printf("\t\t\tphys_state:\t\t%s (%d)\n",
 			       port_phy_state_str(port_attr.phys_state), port_attr.phys_state);
 


More information about the general mailing list