[RFC PATCH 10/11] IB/Verbs: Use management helper cap_ib() for ib-check
From: Michael Wang
Date: Fri Mar 27 2015 - 11:49:17 EST
TODO:
We need to classify these check into the management helper.
Cc: Jason Gunthorpe <jgunthorpe@xxxxxxxxxxxxxxxxxxxx>
Cc: Doug Ledford <dledford@xxxxxxxxxx>
Cc: Ira Weiny <ira.weiny@xxxxxxxxx>
Cc: Sean Hefty <sean.hefty@xxxxxxxxx>
Signed-off-by: Michael Wang <yun.wang@xxxxxxxxxxxxxxxx>
---
drivers/infiniband/core/cma.c | 5 ++---
drivers/infiniband/hw/mlx4/mad.c | 4 ++--
drivers/infiniband/hw/mlx4/main.c | 5 ++---
include/rdma/ib_verbs.h | 8 ++++++++
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index cbbc85b..1f68816 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -696,7 +696,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
int ret;
u16 pkey;
- if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
+ if (cap_ib(id_priv->id.device, id_priv->id.port_num))
pkey = ib_addr_get_pkey(dev_addr);
else
pkey = 0xffff;
@@ -2053,8 +2053,7 @@ port_found:
goto out;
id_priv->id.route.addr.dev_addr.dev_type =
- (rdma_port_ll_is_ib(cma_dev->device, p)) ?
- ARPHRD_INFINIBAND : ARPHRD_ETHER;
+ (cap_ib(cma_dev->device, p)) ? ARPHRD_INFINIBAND : ARPHRD_ETHER;
rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 09874d0..2a867fd 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1247,7 +1247,7 @@ out:
static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
{
- if (rdma_port_ll_is_ib(&dev->ib_dev, port))
+ if (cap_ib(&dev->ib_dev, port))
return slave;
return mlx4_get_base_gid_ix(dev->dev, slave, port);
}
@@ -1255,7 +1255,7 @@ static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
static void fill_in_real_sgid_index(struct mlx4_ib_dev *dev, int slave, int port,
struct ib_ah_attr *ah_attr)
{
- if (rdma_port_ll_is_ib(&dev->ib_dev, port))
+ if (cap_ib(&dev->ib_dev, port))
ah_attr->grh.sgid_index = slave;
else
ah_attr->grh.sgid_index += get_slave_base_gid_ix(dev, slave, port);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index f445f4c..1acc1c1 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -482,7 +482,7 @@ static int iboe_query_gid(struct ib_device *ibdev, u8 port, int index,
static int mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
union ib_gid *gid)
{
- if (rdma_port_ll_is_ib(ibdev, port))
+ if (cap_ib(ibdev, port))
return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
else
return iboe_query_gid(ibdev, port, index, gid);
@@ -2552,8 +2552,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
case MLX4_DEV_EVENT_PORT_UP:
if (p > ibdev->num_ports)
return;
- if (mlx4_is_master(dev) &&
- rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
+ if (mlx4_is_master(dev) && cap_ib(&ibdev->ib_dev, p)) {
mlx4_ib_invalidate_all_guid_record(ibdev, p);
}
ibev.event = IB_EVENT_PORT_ACTIVE;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index eead588..deeaa52 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1921,6 +1921,14 @@ static inline int cap_ipoib(struct ib_device *device, u8 port_num)
return rdma_port_ll_is_ib(device, port_num);
}
+/**
+ * TO BE CLASSIFIED
+ */
+static inline int cap_ib(struct ib_device *device, u8 port_num)
+{
+ return rdma_port_ll_is_ib(device, port_num);
+}
+
int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/