@@ -3762,7 +3762,7 @@ static void cm_add_one(struct ib_device *ib_device)
int ret;
u8 i;
- if (!rdma_transport_is_ib(ib_device))
+ if (!has_cm(ib_device))
return;
cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
@@ -433,7 +433,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
pkey = ntohs(addr->sib_pkey);
list_for_each_entry(cur_dev, &dev_list, list) {
- if (!rdma_transport_is_ib(cur_dev->device))
+ if (!has_cm(cur_dev->device))
continue;
for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
@@ -631,7 +631,7 @@ static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
if (ret)
goto out;
- if (rdma_transport_is_ib(id_priv->cma_dev->device) &&
+ if (has_cm(id_priv->cma_dev->device) &&
rdma_port_ll_is_eth(id_priv->id.device, id_priv->id.port_num)) {
ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
@@ -1620,8 +1620,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
struct rdma_cm_id *id;
int ret;
- if (cma_family(id_priv) == AF_IB &&
- !rdma_transport_is_ib(cma_dev->device))
+ if (cma_family(id_priv) == AF_IB && !has_cm(cma_dev->device))
return;
id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps,
@@ -2022,8 +2021,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
cma_dev = NULL;
mutex_lock(&lock);
list_for_each_entry(cur_dev, &dev_list, list) {
- if (cma_family(id_priv) == AF_IB &&
- !rdma_transport_is_ib(cur_dev->device))
+ if (cma_family(id_priv) == AF_IB && !has_cm(cur_dev->device))
continue;
if (!cma_dev)
@@ -1253,7 +1253,7 @@ static void ib_ucm_add_one(struct ib_device *device)
dev_t base;
struct ib_ucm_device *ucm_dev;
- if (!device->alloc_ucontext || !rdma_transport_is_ib(device))
+ if (!device->alloc_ucontext || !has_cm(device))
return;
ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
@@ -1797,6 +1797,19 @@ static inline int has_mad(struct ib_device *device)
}
/**
+ * has_cm - Check if a device support Communication Manager.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support Communication
+ * Manager.
+ */
+static inline int has_cm(struct ib_device *device)
+{
+ return rdma_transport_is_ib(device);
+}
+
+/**
* cap_smi - Check if the port of device has the capability
* Subnet Management Interface.
*
Introduce helper has_cm() to help us check if an IB device support Communication Manager. Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Cc: Doug Ledford <dledford@redhat.com> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Michael Wang <yun.wang@profitbricks.com> --- drivers/infiniband/core/cm.c | 2 +- drivers/infiniband/core/cma.c | 10 ++++------ drivers/infiniband/core/ucm.c | 2 +- include/rdma/ib_verbs.h | 13 +++++++++++++ 4 files changed, 19 insertions(+), 8 deletions(-)