Commit a31ad3b0 authored by Michael Wang's avatar Michael Wang Committed by Doug Ledford

IB/Verbs: Use management helper rdma_cap_ib_mcast()

Introduce helper rdma_cap_ib_mcast() to help us check if the port of an
IB device support Infiniband Multicast.
Signed-off-by: default avatarMichael Wang <yun.wang@profitbricks.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Tested-by: default avatarIra Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarSean Hefty <sean.hefty@intel.com>
Reviewed-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: default avatarDoug Ledford <dledford@redhat.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent fe53ba2f
...@@ -1014,7 +1014,7 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv) ...@@ -1014,7 +1014,7 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
mc = container_of(id_priv->mc_list.next, mc = container_of(id_priv->mc_list.next,
struct cma_multicast, list); struct cma_multicast, list);
list_del(&mc->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)) { id_priv->id.port_num)) {
ib_sa_free_multicast(mc->multicast.ib); ib_sa_free_multicast(mc->multicast.ib);
kfree(mc); kfree(mc);
...@@ -3328,7 +3328,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, ...@@ -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)) { if (rdma_protocol_iboe(id->device, id->port_num)) {
kref_init(&mc->mcref); kref_init(&mc->mcref);
ret = cma_iboe_join_multicast(id_priv, mc); 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); ret = cma_join_ib_multicast(id_priv, mc);
else else
ret = -ENOSYS; ret = -ENOSYS;
...@@ -3362,7 +3362,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) ...@@ -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); 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); ib_sa_free_multicast(mc->multicast.ib);
kfree(mc); kfree(mc);
} else if (rdma_protocol_iboe(id->device, id->port_num)) } else if (rdma_protocol_iboe(id->device, id->port_num))
......
...@@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler, ...@@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
int index; int index;
dev = container_of(handler, struct mcast_device, event_handler); 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; return;
index = event->element.port_num - dev->start_port; index = event->element.port_num - dev->start_port;
...@@ -820,7 +820,7 @@ static void mcast_add_one(struct ib_device *device) ...@@ -820,7 +820,7 @@ static void mcast_add_one(struct ib_device *device)
} }
for (i = 0; i <= dev->end_port - dev->start_port; i++) { 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; continue;
port = &dev->port[i]; port = &dev->port[i];
port->dev = dev; port->dev = dev;
...@@ -858,7 +858,7 @@ static void mcast_remove_one(struct ib_device *device) ...@@ -858,7 +858,7 @@ static void mcast_remove_one(struct ib_device *device)
flush_workqueue(mcast_wq); flush_workqueue(mcast_wq);
for (i = 0; i <= dev->end_port - dev->start_port; i++) { 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]; port = &dev->port[i];
deref_port(port); deref_port(port);
wait_for_completion(&port->comp); wait_for_completion(&port->comp);
......
...@@ -1849,6 +1849,21 @@ static inline bool rdma_cap_ib_sa(struct ib_device *device, u8 port_num) ...@@ -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); 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, int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid); u8 port_num, int index, union ib_gid *gid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment