]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sif: ipd: Fix incorrect calculation of ipd from static rate
authorWei Lin Guay <wei.lin.guay@oracle.com>
Tue, 30 Aug 2016 20:17:01 +0000 (22:17 +0200)
committerKnut Omang <knut.omang@oracle.com>
Fri, 9 Sep 2016 10:32:00 +0000 (12:32 +0200)
Orabug: 24449061

The ipd is calculated wrongly because it compares the active speed enum
with the value return from ib_rate_to_mult. Thus, this patch converts the
PSIF Active speed enum to a multiple of the base rate of SDR (2.5 Gbps).

Signed-off-by: Wei Lin Guay <wei.lin.guay@oracle.com>
Reviewed-by: Knut Omang <knut.omang@oracle.com>
drivers/infiniband/hw/sif/sif_defs.c
drivers/infiniband/hw/sif/sif_defs.h
drivers/infiniband/hw/sif/sif_query.c

index f68a7a38753e09bf6b95bd751ca20fb8dbd0839f..ed95ee69f76649134497f70b62b0d7775042b8fb 100644 (file)
@@ -456,6 +456,29 @@ enum ib_mtu sif2ib_path_mtu(enum psif_path_mtu mtu)
        }
 }
 
+/* psif_port_speed to mult - convert the IB speed definition to a
+ * multiple of the base rate of 2.5 Gbps. E.g, PSIF_SPEED_EDR will
+ * be converted to 10, as 25 Gbps is 10 * 2.5 Gbps.
+ */
+const int psif_port_speed_to_mult(enum psif_port_speed speed)
+{
+       switch (speed) {
+       default:
+       case PSIF_PORT_SPEED_FIELD_MAX:
+       case PSIF_SPEED_SDR:
+               return 1;
+       case PSIF_SPEED_DDR:
+               return 2;
+       case PSIF_SPEED_QDR:
+               return 4;
+       case PSIF_SPEED_FDR10:
+               return 4;
+       case PSIF_SPEED_FDR:
+               return 5;
+       case PSIF_SPEED_EDR:
+               return 10;
+       }
+}
 
 /* TBD: IB datastructure dump functions - remove/replace? */
 
index 3c1975e823c214877d8c03b99d5659db31a23d49..e027cc6fde802581d894a3813a2e3fae1bed285d 100644 (file)
@@ -67,6 +67,7 @@ enum psif_migration ib2sif_mig_state(enum ib_mig_state mstate);
 enum ib_mtu sif2ib_path_mtu(enum psif_path_mtu mtu);
 enum psif_path_mtu ib2sif_path_mtu(enum ib_mtu mtu);
 enum kernel_ulp_type sif_find_kernel_ulp_caller(void);
+const int psif_port_speed_to_mult(enum psif_port_speed speed);
 
 /* TBD: IB datastructure dump functions - remove/replace? */
 const char *ib_event2str(enum ib_event_type e);
index 2f18fe81b95e99d8e0cd2e8575d8b7d45837f102..4e0a103a4891e7e1d4c2aca1fdb0a3a431a61760 100644 (file)
@@ -162,6 +162,7 @@ int sif_calc_ipd(struct sif_dev      *sdev, u8 port, enum ib_rate static_rate, u8 *i
        int path = ib_rate_to_mult(static_rate);
        int link;
        u8 active_speed = sdev->port[port - 1].active_speed;
+       int active_mult = psif_port_speed_to_mult((enum psif_port_speed)active_speed);
        u8 active_width = sdev->port[port - 1].active_width;
 
        if (static_rate == IB_RATE_PORT_CURRENT) {
@@ -180,8 +181,8 @@ int sif_calc_ipd(struct sif_dev      *sdev, u8 port, enum ib_rate static_rate, u8 *i
                return -EDEADLK;
        }
 
-       /* 2^active_width * active_speed */
-       link = (1 << active_width)*active_speed;
+       /* 2^active_width * mult SDR of active speed */
+       link = (1 << active_width)*active_mult;
 
        if (path >= link)
                *ipd = 0;