]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/Verbs: Reform IB-core cm
authorMichael Wang <yun.wang@profitbricks.com>
Tue, 5 May 2015 12:50:21 +0000 (14:50 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 18 May 2015 17:35:04 +0000 (13:35 -0400)
Use raw management helpers to reform IB-core cm.

Signed-off-by: Michael Wang <yun.wang@profitbricks.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cm.c

index 0c1419105ff083ce40bb576e60f03911dee91270..cfcc7f45118540c9a25036a916796a6adde9022c 100644 (file)
@@ -3759,11 +3759,9 @@ static void cm_add_one(struct ib_device *ib_device)
        };
        unsigned long flags;
        int ret;
+       int count = 0;
        u8 i;
 
-       if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
-               return;
-
        cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
                         ib_device->phys_port_cnt, GFP_KERNEL);
        if (!cm_dev)
@@ -3782,6 +3780,9 @@ static void cm_add_one(struct ib_device *ib_device)
 
        set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
        for (i = 1; i <= ib_device->phys_port_cnt; i++) {
+               if (!rdma_ib_or_iboe(ib_device, i))
+                       continue;
+
                port = kzalloc(sizeof *port, GFP_KERNEL);
                if (!port)
                        goto error1;
@@ -3808,7 +3809,13 @@ static void cm_add_one(struct ib_device *ib_device)
                ret = ib_modify_port(ib_device, i, 0, &port_modify);
                if (ret)
                        goto error3;
+
+               count++;
        }
+
+       if (!count)
+               goto free;
+
        ib_set_client_data(ib_device, &cm_client, cm_dev);
 
        write_lock_irqsave(&cm.device_lock, flags);
@@ -3824,11 +3831,15 @@ error1:
        port_modify.set_port_cap_mask = 0;
        port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
        while (--i) {
+               if (!rdma_ib_or_iboe(ib_device, i))
+                       continue;
+
                port = cm_dev->port[i-1];
                ib_modify_port(ib_device, port->port_num, 0, &port_modify);
                ib_unregister_mad_agent(port->mad_agent);
                cm_remove_port_fs(port);
        }
+free:
        device_unregister(cm_dev->device);
        kfree(cm_dev);
 }
@@ -3852,6 +3863,9 @@ static void cm_remove_one(struct ib_device *ib_device)
        write_unlock_irqrestore(&cm.device_lock, flags);
 
        for (i = 1; i <= ib_device->phys_port_cnt; i++) {
+               if (!rdma_ib_or_iboe(ib_device, i))
+                       continue;
+
                port = cm_dev->port[i-1];
                ib_modify_port(ib_device, port->port_num, 0, &port_modify);
                ib_unregister_mad_agent(port->mad_agent);