* [PATCH RFC] IB/verbs: introduce rdma_transport_is_ib() to check transport type
@ 2015-03-19 13:44 Michael Wang
2015-03-19 17:02 ` Hefty, Sean
0 siblings, 1 reply; 3+ messages in thread
From: Michael Wang @ 2015-03-19 13:44 UTC (permalink / raw)
To: Roland Dreier, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Or Gerlitz, Ira Weiny, Moni Shoua, Tatyana Nikolova, Steve Wise,
Yan Burman, Jack Morgenstein, Bart Van Assche, Yann Droneaud,
David S. Miller, Alex Estrin, Doug Ledford, Eric Dumazet,
Erez Shitrit, Haggai Eran, Sagi Grimberg, Shachar Raindel,
Eli Cohen, Matan Barak, Mike Marciniszyn
We have plenty of places where we don't care what exactly the
transport type is, but only care if it's IB type.
This patch introduce rdma_transport_is_ib() as shortcuts to check
whether an 'ib_device' is infiniband transport type, which help us to
save some code.
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
drivers/infiniband/core/cm.c | 2 +-
drivers/infiniband/core/cma.c | 15 +++++++--------
drivers/infiniband/core/mad.c | 4 ++--
drivers/infiniband/core/multicast.c | 2 +-
drivers/infiniband/core/sa_query.c | 2 +-
drivers/infiniband/core/ucm.c | 3 +--
drivers/infiniband/core/user_mad.c | 2 +-
drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++--
include/rdma/ib_verbs.h | 5 +++++
9 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index e28a494..2c72e9e 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3762,7 +3762,7 @@ static void cm_add_one(struct ib_device *ib_device)
int ret;
u8 i;
- if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(ib_device))
return;
cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index d570030..cc2b261 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -375,7 +375,7 @@ static int cma_acquire_dev(struct rdma_id_private
*id_priv,
listen_id_priv->id.port_num) == dev_ll) {
cma_dev = listen_id_priv->cma_dev;
port = listen_id_priv->id.port_num;
- if (rdma_node_get_transport(cma_dev->device->node_type) ==
RDMA_TRANSPORT_IB &&
+ if (rdma_transport_is_ib(cma_dev->device) &&
rdma_port_get_link_layer(cma_dev->device, port) ==
IB_LINK_LAYER_ETHERNET)
ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
&found_port, NULL);
@@ -395,7 +395,7 @@ static int cma_acquire_dev(struct rdma_id_private
*id_priv,
listen_id_priv->id.port_num == port)
continue;
if (rdma_port_get_link_layer(cma_dev->device, port) ==
dev_ll) {
- if (rdma_node_get_transport(cma_dev->device->node_type)
== RDMA_TRANSPORT_IB &&
+ if (rdma_transport_is_ib(cma_dev->device) &&
rdma_port_get_link_layer(cma_dev->device, port) ==
IB_LINK_LAYER_ETHERNET)
ret = ib_find_cached_gid(cma_dev->device,
&iboe_gid, &found_port, NULL);
else
@@ -435,7 +435,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_node_get_transport(cur_dev->device->node_type) !=
RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(cur_dev->device))
continue;
for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
@@ -633,8 +633,7 @@ static int cma_modify_qp_rtr(struct rdma_id_private
*id_priv,
if (ret)
goto out;
- if (rdma_node_get_transport(id_priv->cma_dev->device->node_type)
- == RDMA_TRANSPORT_IB &&
+ if (rdma_transport_is_ib(id_priv->cma_dev->device) &&
rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
== IB_LINK_LAYER_ETHERNET) {
ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
@@ -1626,7 +1625,7 @@ static void cma_listen_on_dev(struct
rdma_id_private *id_priv,
int ret;
if (cma_family(id_priv) == AF_IB &&
- rdma_node_get_transport(cma_dev->device->node_type) !=
RDMA_TRANSPORT_IB)
+ !rdma_transport_is_ib(cma_dev->device))
return;
id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps,
@@ -2028,7 +2027,7 @@ static int cma_bind_loopback(struct
rdma_id_private *id_priv)
mutex_lock(&lock);
list_for_each_entry(cur_dev, &dev_list, list) {
if (cma_family(id_priv) == AF_IB &&
- rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB)
+ !rdma_transport_is_ib(cur_dev->device))
continue;
if (!cma_dev)
@@ -3405,7 +3404,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id,
struct sockaddr *addr)
ib_detach_mcast(id->qp,
&mc->multicast.ib->rec.mgid,
be16_to_cpu(mc->multicast.ib->rec.mlid));
- if
(rdma_node_get_transport(id_priv->cma_dev->device->node_type) ==
RDMA_TRANSPORT_IB) {
+ if (rdma_transport_is_ib(id_priv->cma_dev->device)) {
switch (rdma_port_get_link_layer(id->device,
id->port_num)) {
case IB_LINK_LAYER_INFINIBAND:
ib_sa_free_multicast(mc->multicast.ib);
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 74c30f4..dd51b37 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_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(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_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(device))
return;
if (device->node_type == RDMA_NODE_IB_SWITCH) {
diff --git a/drivers/infiniband/core/multicast.c
b/drivers/infiniband/core/multicast.c
index fa17b55..bdda79f 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -808,7 +808,7 @@ static void mcast_add_one(struct ib_device *device)
int i;
int count = 0;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(device))
return;
dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
diff --git a/drivers/infiniband/core/sa_query.c
b/drivers/infiniband/core/sa_query.c
index c38f030..ce82861 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -1154,7 +1154,7 @@ static void ib_sa_add_one(struct ib_device *device)
struct ib_sa_device *sa_dev;
int s, e, i;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(device))
return;
if (device->node_type == RDMA_NODE_IB_SWITCH)
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index f2f6393..ddbe0b4 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -1253,8 +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_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!device->alloc_ucontext || !rdma_transport_is_ib(device))
return;
ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
diff --git a/drivers/infiniband/core/user_mad.c
b/drivers/infiniband/core/user_mad.c
index 928cdd2..28a8b30 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_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(device))
return;
if (device->node_type == RDMA_NODE_IB_SWITCH)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c
b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 58b5aa3..6afb30f 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1655,7 +1655,7 @@ static void ipoib_add_one(struct ib_device *device)
struct ipoib_dev_priv *priv;
int s, e, p;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(device))
return;
dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
@@ -1690,7 +1690,7 @@ static void ipoib_remove_one(struct ib_device *device)
struct ipoib_dev_priv *priv, *tmp;
struct list_head *dev_list;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_transport_is_ib(device))
return;
dev_list = ib_get_client_data(device, &ipoib_client);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 65994a1..f6a04b5 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1743,6 +1743,11 @@ int ib_query_port(struct ib_device *device,
enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
u8 port_num);
+static inline int rdma_transport_is_ib(struct ib_device *device)
+{
+ return rdma_node_get_transport(device->node_type) == RDMA_TRANSPORT_IB;
+}
+
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-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH RFC] IB/verbs: introduce rdma_transport_is_ib() to check transport type
2015-03-19 13:44 [PATCH RFC] IB/verbs: introduce rdma_transport_is_ib() to check transport type Michael Wang
@ 2015-03-19 17:02 ` Hefty, Sean
2015-03-19 17:29 ` Michael Wang
0 siblings, 1 reply; 3+ messages in thread
From: Hefty, Sean @ 2015-03-19 17:02 UTC (permalink / raw)
To: Michael Wang, Roland Dreier, Hal Rosenstock,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Or Gerlitz, Weiny, Ira, Moni Shoua, Nikolova, Tatyana E,
Steve Wise, Yan Burman, Jack Morgenstein, Bart Van Assche,
Yann Droneaud, David S. Miller, Estrin, Alex, Doug Ledford,
Eric Dumazet, Erez Shitrit, Haggai Eran, Sagi Grimberg,
Shachar Raindel, Eli Cohen, Matan Barak, Marciniszyn, Mike
> We have plenty of places where we don't care what exactly the
> transport type is, but only care if it's IB type.
>
> This patch introduce rdma_transport_is_ib() as shortcuts to check
> whether an 'ib_device' is infiniband transport type, which help us to
> save some code.
In most of these places, the check that we want is whether IB management is used. The transport check is an indirect way of checking for that, and I believe we should use a more direct method of checking for the functionality that's actually desired.
Please see the following thread that is related to these changes:
http://www.spinics.net/lists/linux-rdma/msg23484.html
- Sean
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] IB/verbs: introduce rdma_transport_is_ib() to check transport type
2015-03-19 17:02 ` Hefty, Sean
@ 2015-03-19 17:29 ` Michael Wang
0 siblings, 0 replies; 3+ messages in thread
From: Michael Wang @ 2015-03-19 17:29 UTC (permalink / raw)
To: Hefty, Sean, Roland Dreier, Hal Rosenstock,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Or Gerlitz, Weiny, Ira, Moni Shoua, Nikolova, Tatyana E,
Steve Wise, Yan Burman, Jack Morgenstein, Bart Van Assche,
Yann Droneaud, David S. Miller, Estrin, Alex, Doug Ledford,
Eric Dumazet, Erez Shitrit, Haggai Eran, Sagi Grimberg,
Shachar Raindel, Eli Cohen, Matan Barak, Marciniszyn, Mike
Hi, Sean
Thanks for point it out for me :-)
I'll try to follow the conversation to understand what
really needs to be done, see if I could do some
contribution on it.
Regards,
Michael Wang
On 03/19/2015 06:02 PM, Hefty, Sean wrote:
>> We have plenty of places where we don't care what exactly the
>> transport type is, but only care if it's IB type.
>>
>> This patch introduce rdma_transport_is_ib() as shortcuts to check
>> whether an 'ib_device' is infiniband transport type, which help us to
>> save some code.
> In most of these places, the check that we want is whether IB management is used. The transport check is an indirect way of checking for that, and I believe we should use a more direct method of checking for the functionality that's actually desired.
>
> Please see the following thread that is related to these changes:
>
> http://www.spinics.net/lists/linux-rdma/msg23484.html
>
> - Sean
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-19 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-19 13:44 [PATCH RFC] IB/verbs: introduce rdma_transport_is_ib() to check transport type Michael Wang
2015-03-19 17:02 ` Hefty, Sean
2015-03-19 17:29 ` Michael Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).