IB: Use central enum for speed instead of hard-coded values
authorOr Gerlitz <ogerlitz@mellanox.com>
Tue, 28 Feb 2012 16:49:50 +0000 (18:49 +0200)
committerRoland Dreier <roland@purestorage.com>
Mon, 5 Mar 2012 17:25:16 +0000 (09:25 -0800)
The kernel IB stack uses one enumeration for IB speed, which wasn't
explicitly specified in the verbs header file.  Add that enum, and use
it all over the code.

The IB speed/width notation is also used by iWARP and IBoE HW drivers,
which use the convention of rate = speed * width to advertise their
port link rate.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/core/sysfs.c
drivers/infiniband/hw/amso1100/c2_provider.c
drivers/infiniband/hw/cxgb3/iwch_provider.c
drivers/infiniband/hw/cxgb4/provider.c
drivers/infiniband/hw/ehca/ehca_hca.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/nes/nes_verbs.c
include/rdma/ib_verbs.h

index a860b6ddbb61e1e4eb435b958f1d0979a51b109b..83b720ef6c3497eec02327e62a930a1c6d478667 100644 (file)
@@ -187,27 +187,26 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
                return ret;
 
        switch (attr.active_speed) {
-       case 1:
-               /* SDR */
+       case IB_SPEED_SDR:
                rate = 25;
                break;
-       case 2:
+       case IB_SPEED_DDR:
                speed = " DDR";
                rate = 50;
                break;
-       case 4:
+       case IB_SPEED_QDR:
                speed = " QDR";
                rate = 100;
                break;
-       case 8:
+       case IB_SPEED_FDR10:
                speed = " FDR10";
                rate = 100;
                break;
-       case 16:
+       case IB_SPEED_FDR:
                speed = " FDR";
                rate = 140;
                break;
-       case 32:
+       case IB_SPEED_EDR:
                speed = " EDR";
                rate = 250;
                break;
index 12f923d64e42d075a68edd778fb0c9246919eca5..07eb3a8067d84a7a0d625364089c9294101c8c42 100644 (file)
@@ -94,7 +94,7 @@ static int c2_query_port(struct ib_device *ibdev,
        props->pkey_tbl_len = 1;
        props->qkey_viol_cntr = 0;
        props->active_width = 1;
-       props->active_speed = 1;
+       props->active_speed = IB_SPEED_SDR;
 
        return 0;
 }
index 37c224fc3ad9b8f31e0886507fc43f543ee547b0..0bdf09aa6f4213466cda00994ed7a4d833981670 100644 (file)
@@ -1227,7 +1227,7 @@ static int iwch_query_port(struct ib_device *ibdev,
        props->gid_tbl_len = 1;
        props->pkey_tbl_len = 1;
        props->active_width = 2;
-       props->active_speed = 2;
+       props->active_speed = IB_SPEED_DDR;
        props->max_msg_sz = -1;
 
        return 0;
index 247fe706e7fae810b3272a866a6e21065d5caf43..be1c18f44400494e3bc2f68ead22a68208a58013 100644 (file)
@@ -329,7 +329,7 @@ static int c4iw_query_port(struct ib_device *ibdev, u8 port,
        props->gid_tbl_len = 1;
        props->pkey_tbl_len = 1;
        props->active_width = 2;
-       props->active_speed = 2;
+       props->active_speed = IB_SPEED_DDR;
        props->max_msg_sz = -1;
 
        return 0;
index 73edc3668663a2cb8f2b987db1c8945016df4714..9ed4d2588304a2029e4d401aaee28e8cddd3403e 100644 (file)
@@ -233,7 +233,7 @@ int ehca_query_port(struct ib_device *ibdev,
                props->phys_state      = 5;
                props->state           = rblock->state;
                props->active_width    = IB_WIDTH_12X;
-               props->active_speed    = 0x1;
+               props->active_speed    = IB_SPEED_SDR;
        }
 
 query_port1:
index 7b445df6a667be9a595ae1f8ed9449e6419ce16a..6ff6bdf28a3abcb90e7817a53626d4c3d46bd453 100644 (file)
@@ -215,16 +215,16 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 
                switch (ext_active_speed) {
                case 1:
-                       props->active_speed = 16; /* FDR */
+                       props->active_speed = IB_SPEED_FDR;
                        break;
                case 2:
-                       props->active_speed = 32; /* EDR */
+                       props->active_speed = IB_SPEED_EDR;
                        break;
                }
        }
 
        /* If reported active speed is QDR, check if is FDR-10 */
-       if (props->active_speed == 4) {
+       if (props->active_speed == IB_SPEED_QDR) {
                if (to_mdev(ibdev)->dev->caps.ext_port_cap[port] &
                    MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO) {
                        init_query_mad(in_mad);
@@ -238,7 +238,7 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
 
                        /* Checking LinkSpeedActive for FDR-10 */
                        if (out_mad->data[15] & 0x1)
-                               props->active_speed = 8;
+                               props->active_speed = IB_SPEED_FDR10;
                }
        }
 
@@ -259,7 +259,7 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
        enum ib_mtu tmp;
 
        props->active_width     = IB_WIDTH_1X;
-       props->active_speed     = 4;
+       props->active_speed     = IB_SPEED_QDR;
        props->port_cap_flags   = IB_PORT_CM_SUP;
        props->gid_tbl_len      = to_mdev(ibdev)->dev->caps.gid_table_len[port];
        props->max_msg_sz       = to_mdev(ibdev)->dev->caps.max_msg_sz;
index 0927b5cc65d33ac36850a1396c23e1b046b54f6b..8b8812de4b5c881486ed265f31d411f2427ac97b 100644 (file)
@@ -597,7 +597,7 @@ static int nes_query_port(struct ib_device *ibdev, u8 port, struct ib_port_attr
        props->pkey_tbl_len = 1;
        props->qkey_viol_cntr = 0;
        props->active_width = IB_WIDTH_4X;
-       props->active_speed = 1;
+       props->active_speed = IB_SPEED_SDR;
        props->max_msg_sz = 0x80000000;
 
        return 0;
index bf5daafe8ecc09ca4d846906ed76c6599cdd1a53..ff22a73e0937fa4a0500143cceee1ad1ceb156e5 100644 (file)
@@ -239,6 +239,15 @@ static inline int ib_width_enum_to_int(enum ib_port_width width)
        }
 }
 
+enum ib_port_speed {
+       IB_SPEED_SDR    = 1,
+       IB_SPEED_DDR    = 2,
+       IB_SPEED_QDR    = 4,
+       IB_SPEED_FDR10  = 8,
+       IB_SPEED_FDR    = 16,
+       IB_SPEED_EDR    = 32
+};
+
 struct ib_protocol_stats {
        /* TBD... */
 };