]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
RDMA/ocrdma: Fix for displaying proper link speed
[karo-tx-linux.git] / drivers / infiniband / hw / ocrdma / ocrdma_verbs.c
index e934073e70524e8ab362a5789521e77265cf413d..f09a9403b6002d4dd69f54b62383f1db61833c51 100644 (file)
@@ -106,6 +106,45 @@ int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr)
        return 0;
 }
 
+static inline void get_link_speed_and_width(struct ocrdma_dev *dev,
+                                           u8 *ib_speed, u8 *ib_width)
+{
+       int status;
+       u8 speed;
+
+       status = ocrdma_mbx_get_link_speed(dev, &speed);
+       if (status)
+               speed = OCRDMA_PHYS_LINK_SPEED_ZERO;
+
+       switch (speed) {
+       case OCRDMA_PHYS_LINK_SPEED_1GBPS:
+               *ib_speed = IB_SPEED_SDR;
+               *ib_width = IB_WIDTH_1X;
+               break;
+
+       case OCRDMA_PHYS_LINK_SPEED_10GBPS:
+               *ib_speed = IB_SPEED_QDR;
+               *ib_width = IB_WIDTH_1X;
+               break;
+
+       case OCRDMA_PHYS_LINK_SPEED_20GBPS:
+               *ib_speed = IB_SPEED_DDR;
+               *ib_width = IB_WIDTH_4X;
+               break;
+
+       case OCRDMA_PHYS_LINK_SPEED_40GBPS:
+               *ib_speed = IB_SPEED_QDR;
+               *ib_width = IB_WIDTH_4X;
+               break;
+
+       default:
+               /* Unsupported */
+               *ib_speed = IB_SPEED_SDR;
+               *ib_width = IB_WIDTH_1X;
+       };
+}
+
+
 int ocrdma_query_port(struct ib_device *ibdev,
                      u8 port, struct ib_port_attr *props)
 {
@@ -142,8 +181,8 @@ int ocrdma_query_port(struct ib_device *ibdev,
        props->pkey_tbl_len = 1;
        props->bad_pkey_cntr = 0;
        props->qkey_viol_cntr = 0;
-       props->active_width = IB_WIDTH_1X;
-       props->active_speed = 4;
+       get_link_speed_and_width(dev, &props->active_speed,
+                                &props->active_width);
        props->max_msg_sz = 0x80000000;
        props->max_vl_num = 4;
        return 0;