IB/Verbs: Use management helper rdma_cap_ib_mcast()
authorMichael Wang <yun.wang@profitbricks.com>
Tue, 5 May 2015 12:50:37 +0000 (14:50 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 18 May 2015 17:35:05 +0000 (13:35 -0400)
Introduce helper rdma_cap_ib_mcast() to help us check if the port of an
IB device support Infiniband Multicast.

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/cma.c
drivers/infiniband/core/multicast.c
include/rdma/ib_verbs.h

index 6d65460..78becc7 100644 (file)
@@ -1014,7 +1014,7 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
                mc = container_of(id_priv->mc_list.next,
                                  struct cma_multicast, list);
                list_del(&mc->list);
-               if (rdma_protocol_ib(id_priv->cma_dev->device,
+               if (rdma_cap_ib_mcast(id_priv->cma_dev->device,
                                      id_priv->id.port_num)) {
                        ib_sa_free_multicast(mc->multicast.ib);
                        kfree(mc);
@@ -3328,7 +3328,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
        if (rdma_protocol_iboe(id->device, id->port_num)) {
                kref_init(&mc->mcref);
                ret = cma_iboe_join_multicast(id_priv, mc);
-       } else if (rdma_protocol_ib(id->device, id->port_num))
+       } else if (rdma_cap_ib_mcast(id->device, id->port_num))
                ret = cma_join_ib_multicast(id_priv, mc);
        else
                ret = -ENOSYS;
@@ -3362,7 +3362,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
 
                        BUG_ON(id_priv->cma_dev->device != id->device);
 
-                       if (rdma_protocol_ib(id->device, id->port_num)) {
+                       if (rdma_cap_ib_mcast(id->device, id->port_num)) {
                                ib_sa_free_multicast(mc->multicast.ib);
                                kfree(mc);
                        } else if (rdma_protocol_iboe(id->device, id->port_num))
index b57ed03..605f20a 100644 (file)
@@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
        int index;
 
        dev = container_of(handler, struct mcast_device, event_handler);
-       if (WARN_ON(!rdma_protocol_ib(dev->device, event->element.port_num)))
+       if (WARN_ON(!rdma_cap_ib_mcast(dev->device, event->element.port_num)))
                return;
 
        index = event->element.port_num - dev->start_port;
@@ -820,7 +820,7 @@ static void mcast_add_one(struct ib_device *device)
        }
 
        for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-               if (!rdma_protocol_ib(device, dev->start_port + i))
+               if (!rdma_cap_ib_mcast(device, dev->start_port + i))
                        continue;
                port = &dev->port[i];
                port->dev = dev;
@@ -858,7 +858,7 @@ static void mcast_remove_one(struct ib_device *device)
        flush_workqueue(mcast_wq);
 
        for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-               if (rdma_protocol_ib(device, dev->start_port + i)) {
+               if (rdma_cap_ib_mcast(device, dev->start_port + i)) {
                        port = &dev->port[i];
                        deref_port(port);
                        wait_for_completion(&port->comp);
index c3a561e..6bbbc86 100644 (file)
@@ -1849,6 +1849,21 @@ static inline bool rdma_cap_ib_sa(struct ib_device *device, u8 port_num)
        return rdma_protocol_ib(device, port_num);
 }
 
+/**
+ * rdma_cap_ib_mcast - Check if the port of device has the capability Infiniband
+ * Multicast.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return false when port of the device don't support Infiniband
+ * Multicast.
+ */
+static inline bool rdma_cap_ib_mcast(struct ib_device *device, u8 port_num)
+{
+       return rdma_cap_ib_sa(device, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
                 u8 port_num, int index, union ib_gid *gid);