[RFC PATCH 03/11] IB/Verbs: Use management helper has_mad() for mad-check

From: Michael Wang
Date: Fri Mar 27 2015 - 11:43:21 EST



Introduce helper has_mad() to help us check if an IB device support
Management Datagrams.

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/mad.c | 4 ++--
drivers/infiniband/core/user_mad.c | 2 +-
include/rdma/ib_verbs.h | 13 +++++++++++++
3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 23cf9e8..896b749 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -3057,7 +3057,7 @@ static void ib_mad_init_device(struct ib_device *device)
{
int start, end, i;

- if (!rdma_transport_is_ib(device))
+ if (!has_mad(device))
return;

if (device->node_type == RDMA_NODE_IB_SWITCH) {
@@ -3102,7 +3102,7 @@ static void ib_mad_remove_device(struct ib_device *device)
{
int i, num_ports, cur_port;

- if (!rdma_transport_is_ib(device))
+ if (!has_mad(device))
return;

if (device->node_type == RDMA_NODE_IB_SWITCH) {
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 28a8b30..31feec3 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1274,7 +1274,7 @@ static void ib_umad_add_one(struct ib_device *device)
struct ib_umad_device *umad_dev;
int s, e, i;

- if (!rdma_transport_is_ib(device))
+ if (!has_mad(device))
return;

if (device->node_type == RDMA_NODE_IB_SWITCH)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index ca6d6bc..7b2bfe8 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1783,6 +1783,19 @@ static inline int tech_iboe(struct ib_device *device, u8 port_num)
rdma_port_ll_is_eth(device, port_num);
}

+/**
+ * has_mad - Check if a device support Management Datagrams.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * Management Datagrams.
+ */
+static inline int has_mad(struct ib_device *device)
+{
+ return rdma_transport_is_ib(device);
+}
+
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/