All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/11] IB/Verbs: IB Management Helpers
@ 2015-03-27 15:39 ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:39 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


There are plenty of lengthy code to check the transport type of IB device,
or the link layer type of it's port, but actually we are just speculating
whether a particular management is supported by the device/port.

Thus instead of inferring, we should have our own mechanism for
IB management capability/protocol checking, several proposals below.

This patch set is the pioneer which try to collecting all the cases where
a management helper applicable, and put all the speculating logical together,
in order to be easily integrated to the new querying mechanism in future.

TODO:
    The helper in patch 10 and 11 are still to be classified, that is
    cap_ib() and cap_eth().

    The name/description of each helper may not correct enough, those folks
    who are familiar with these particular parts, your suggestion would be
    invaluable ;-)

Proposals:
    Sean:
    https://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg23339.html
    Doug:
    https://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg23418.html
    Jason:
    https://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg23425.html

Michael Wang (11):
    [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
    [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
    [RFC PATCH 03/11] IB/Verbs: Use management helper has_mad() for mad-check
    [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
    [RFC PATCH 05/11] IB/Verbs: Use management helper has_cm() for cm-check
    [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa() for sa-check
    [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and cap_mcast() for mcast-check
    [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for iwarp-check
    [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and cap_ipoib() for ipoib-check
    [RFC PATCH 10/11] IB/Verbs: Use management helper cap_ib() for ib-check
    [RFC PATCH 11/11] IB/Verbs: Use management helper cap_eth() for eth-check

---
 drivers/infiniband/core/agent.c           |    6
 drivers/infiniband/core/cm.c              |    6
 drivers/infiniband/core/cma.c             |   79 ++++------
 drivers/infiniband/core/mad.c             |   18 +-
 drivers/infiniband/core/multicast.c       |   30 +---
 drivers/infiniband/core/sa_query.c        |   42 ++---
 drivers/infiniband/core/ucm.c             |    8 -
 drivers/infiniband/core/user_mad.c        |    6
 drivers/infiniband/core/verbs.c           |   14 -
 drivers/infiniband/hw/mlx4/ah.c           |    6
 drivers/infiniband/hw/mlx4/cq.c           |   10 -
 drivers/infiniband/hw/mlx4/mad.c          |   36 +---
 drivers/infiniband/hw/mlx4/main.c         |   23 +--
 drivers/infiniband/hw/mlx4/mlx4_ib.h      |    6
 drivers/infiniband/hw/mlx4/qp.c           |   57 ++-----
 drivers/infiniband/hw/mlx4/sysfs.c        |   16 --
 drivers/infiniband/ulp/ipoib/ipoib_main.c |   18 +-
 include/rdma/ib_verbs.h                   |  218 ++++++++++++++++++++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |    8 -
 19 files changed, 381 insertions(+), 226 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* [RFC PATCH 00/11] IB/Verbs: IB Management Helpers
@ 2015-03-27 15:39 ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:39 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


There are plenty of lengthy code to check the transport type of IB device,
or the link layer type of it's port, but actually we are just speculating
whether a particular management is supported by the device/port.

Thus instead of inferring, we should have our own mechanism for
IB management capability/protocol checking, several proposals below.

This patch set is the pioneer which try to collecting all the cases where
a management helper applicable, and put all the speculating logical together,
in order to be easily integrated to the new querying mechanism in future.

TODO:
    The helper in patch 10 and 11 are still to be classified, that is
    cap_ib() and cap_eth().

    The name/description of each helper may not correct enough, those folks
    who are familiar with these particular parts, your suggestion would be
    invaluable ;-)

Proposals:
    Sean:
    https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23339.html
    Doug:
    https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23418.html
    Jason:
    https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23425.html

Michael Wang (11):
    [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
    [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
    [RFC PATCH 03/11] IB/Verbs: Use management helper has_mad() for mad-check
    [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
    [RFC PATCH 05/11] IB/Verbs: Use management helper has_cm() for cm-check
    [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa() for sa-check
    [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and cap_mcast() for mcast-check
    [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for iwarp-check
    [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and cap_ipoib() for ipoib-check
    [RFC PATCH 10/11] IB/Verbs: Use management helper cap_ib() for ib-check
    [RFC PATCH 11/11] IB/Verbs: Use management helper cap_eth() for eth-check

---
 drivers/infiniband/core/agent.c           |    6
 drivers/infiniband/core/cm.c              |    6
 drivers/infiniband/core/cma.c             |   79 ++++------
 drivers/infiniband/core/mad.c             |   18 +-
 drivers/infiniband/core/multicast.c       |   30 +---
 drivers/infiniband/core/sa_query.c        |   42 ++---
 drivers/infiniband/core/ucm.c             |    8 -
 drivers/infiniband/core/user_mad.c        |    6
 drivers/infiniband/core/verbs.c           |   14 -
 drivers/infiniband/hw/mlx4/ah.c           |    6
 drivers/infiniband/hw/mlx4/cq.c           |   10 -
 drivers/infiniband/hw/mlx4/mad.c          |   36 +---
 drivers/infiniband/hw/mlx4/main.c         |   23 +--
 drivers/infiniband/hw/mlx4/mlx4_ib.h      |    6
 drivers/infiniband/hw/mlx4/qp.c           |   57 ++-----
 drivers/infiniband/hw/mlx4/sysfs.c        |   16 --
 drivers/infiniband/ulp/ipoib/ipoib_main.c |   18 +-
 include/rdma/ib_verbs.h                   |  218 ++++++++++++++++++++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |    8 -
 19 files changed, 381 insertions(+), 226 deletions(-)


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 00/11] IB/Verbs: IB Management Helpers
@ 2015-03-27 15:39 ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:39 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


There are plenty of lengthy code to check the transport type of IB device,
or the link layer type of it's port, but actually we are just speculating
whether a particular management is supported by the device/port.

Thus instead of inferring, we should have our own mechanism for
IB management capability/protocol checking, several proposals below.

This patch set is the pioneer which try to collecting all the cases where
a management helper applicable, and put all the speculating logical together,
in order to be easily integrated to the new querying mechanism in future.

TODO:
    The helper in patch 10 and 11 are still to be classified, that is
    cap_ib() and cap_eth().

    The name/description of each helper may not correct enough, those folks
    who are familiar with these particular parts, your suggestion would be
    invaluable ;-)

Proposals:
    Sean:
    https://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg23339.html
    Doug:
    https://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg23418.html
    Jason:
    https://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg23425.html

Michael Wang (11):
    [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
    [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
    [RFC PATCH 03/11] IB/Verbs: Use management helper has_mad() for mad-check
    [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
    [RFC PATCH 05/11] IB/Verbs: Use management helper has_cm() for cm-check
    [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa() for sa-check
    [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and cap_mcast() for mcast-check
    [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for iwarp-check
    [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and cap_ipoib() for ipoib-check
    [RFC PATCH 10/11] IB/Verbs: Use management helper cap_ib() for ib-check
    [RFC PATCH 11/11] IB/Verbs: Use management helper cap_eth() for eth-check

---
 drivers/infiniband/core/agent.c           |    6
 drivers/infiniband/core/cm.c              |    6
 drivers/infiniband/core/cma.c             |   79 ++++------
 drivers/infiniband/core/mad.c             |   18 +-
 drivers/infiniband/core/multicast.c       |   30 +---
 drivers/infiniband/core/sa_query.c        |   42 ++---
 drivers/infiniband/core/ucm.c             |    8 -
 drivers/infiniband/core/user_mad.c        |    6
 drivers/infiniband/core/verbs.c           |   14 -
 drivers/infiniband/hw/mlx4/ah.c           |    6
 drivers/infiniband/hw/mlx4/cq.c           |   10 -
 drivers/infiniband/hw/mlx4/mad.c          |   36 +---
 drivers/infiniband/hw/mlx4/main.c         |   23 +--
 drivers/infiniband/hw/mlx4/mlx4_ib.h      |    6
 drivers/infiniband/hw/mlx4/qp.c           |   57 ++-----
 drivers/infiniband/hw/mlx4/sysfs.c        |   16 --
 drivers/infiniband/ulp/ipoib/ipoib_main.c |   18 +-
 include/rdma/ib_verbs.h                   |  218 ++++++++++++++++++++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |    8 -
 19 files changed, 381 insertions(+), 226 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:40     ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:40 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


We have so much places to check transport type and link layer type, it's now
make sense to introduce some helpers in order to refine the lengthy code.

This patch will introduce helpers:
    rdma_transport_is_ib()
    rdma_transport_is_iwarp()
    rdma_port_ll_is_ib()
    rdma_port_ll_is_eth()
and use them to save some code for us.

Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 drivers/infiniband/core/agent.c           |  2 +-
 drivers/infiniband/core/cm.c              |  2 +-
 drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
 drivers/infiniband/core/mad.c             |  6 +++---
 drivers/infiniband/core/multicast.c       | 11 ++++-------
 drivers/infiniband/core/sa_query.c        | 14 +++++++-------
 drivers/infiniband/core/ucm.c             |  3 +--
 drivers/infiniband/core/user_mad.c        |  2 +-
 drivers/infiniband/core/verbs.c           |  5 ++---
 drivers/infiniband/hw/mlx4/ah.c           |  2 +-
 drivers/infiniband/hw/mlx4/cq.c           |  4 +---
 drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
 drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
 drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
 drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
 drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
 drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
 include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
 19 files changed, 79 insertions(+), 83 deletions(-)

diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index f6d2961..27f1bec 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
         goto error1;
     }
 
-    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
+    if (rdma_port_ll_is_ib(device, port_num)) {
         /* Obtain send only MAD agent for SMI QP */
         port_priv->agent[0] = ib_register_mad_agent(device, port_num,
                                 IB_QPT_SMI, NULL, 0,
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..668e955 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -375,8 +375,8 @@ 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 &&
-            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
+        if (rdma_transport_is_ib(cma_dev->device) &&
+            rdma_port_ll_is_eth(cma_dev->device, port))
             ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
                          &found_port, NULL);
         else
@@ -395,8 +395,8 @@ 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 &&
-                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
+                if (rdma_transport_is_ib(cma_dev->device) &&
+                    rdma_port_ll_is_eth(cma_dev->device, port))
                     ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
                 else
                     ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
@@ -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,10 +633,8 @@ 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 &&
-        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
-        == IB_LINK_LAYER_ETHERNET) {
+    if (rdma_transport_is_ib(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);
 
         if (ret)
@@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
     int ret;
     u16 pkey;
 
-    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
-        IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
         pkey = ib_addr_get_pkey(dev_addr);
     else
         pkey = 0xffff;
@@ -1626,7 +1623,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 +2025,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)
@@ -2060,7 +2057,7 @@ port_found:
         goto out;
 
     id_priv->id.route.addr.dev_addr.dev_type =
-        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
+        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
         ARPHRD_INFINIBAND : ARPHRD_ETHER;
 
     rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
@@ -3405,7 +3402,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..23cf9e8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
     init_mad_qp(port_priv, &port_priv->qp_info[1]);
 
     cq_size = mad_sendq_size + mad_recvq_size;
-    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
+    has_smi = rdma_port_ll_is_ib(device, port_num);
     if (has_smi)
         cq_size *= 2;
 
@@ -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..17573ff 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
     int index;
 
     dev = container_of(handler, struct mcast_device, event_handler);
-    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
-        IB_LINK_LAYER_INFINIBAND)
+    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
         return;
 
     index = event->element.port_num - dev->start_port;
@@ -808,7 +807,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,
@@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
     }
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
-            IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
             continue;
         port = &dev->port[i];
         port->dev = dev;
@@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
     flush_workqueue(mcast_wq);
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
-            IB_LINK_LAYER_INFINIBAND) {
+        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
             port = &dev->port[i];
             deref_port(port);
             wait_for_completion(&port->comp);
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index c38f030..d95d25f 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
         struct ib_sa_port *port =
             &sa_dev->port[event->element.port_num - sa_dev->start_port];
 
-        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
             return;
 
         spin_lock_irqsave(&port->ah_lock, flags);
@@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
     ah_attr->port_num = port_num;
     ah_attr->static_rate = rec->rate;
 
-    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
+    force_grh = rdma_port_ll_is_eth(device, port_num);
 
     if (rec->hop_limit > 1 || force_grh) {
         ah_attr->ah_flags = IB_AH_GRH;
@@ -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)
@@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
 
     for (i = 0; i <= e - s; ++i) {
         spin_lock_init(&sa_dev->port[i].ah_lock);
-        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, i + 1))
             continue;
 
         sa_dev->port[i].sm_ah    = NULL;
@@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
         goto err;
 
     for (i = 0; i <= e - s; ++i)
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
+        if (rdma_port_ll_is_ib(device, i + 1))
             update_sm_ah(&sa_dev->port[i].update_task);
 
     return;
 
 err:
     while (--i >= 0)
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
+        if (rdma_port_ll_is_ib(device, i + 1))
             ib_unregister_mad_agent(sa_dev->port[i].agent);
 
     kfree(sa_dev);
@@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
     flush_workqueue(ib_wq);
 
     for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
+        if (rdma_port_ll_is_ib(device, i + 1)) {
             ib_unregister_mad_agent(sa_dev->port[i].agent);
             if (sa_dev->port[i].sm_ah)
                 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
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/core/verbs.c b/drivers/infiniband/core/verbs.c
index f93eb8d..d8d015a 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
     u32 flow_class;
     u16 gid_index;
     int ret;
-    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
-            IB_LINK_LAYER_ETHERNET);
+    int is_eth = (rdma_port_ll_is_eth(device, port_num));
 
     memset(ah_attr, 0, sizeof *ah_attr);
     if (is_eth) {
@@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
     union ib_gid  sgid;
 
     if ((*qp_attr_mask & IB_QP_AV)  &&
-        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
+        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
         ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
                    qp_attr->ah_attr.grh.sgid_index, &sgid);
         if (ret)
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index 2d8c339..829eb60 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
     if (!ah)
         return ERR_PTR(-ENOMEM);
 
-    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
+    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
         if (!(ah_attr->ah_flags & IB_AH_GRH)) {
             ret = ERR_PTR(-EINVAL);
         } else {
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index cb63ecd..0417f03 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -789,9 +789,7 @@ repoll:
             break;
         }
 
-        is_eth = (rdma_port_get_link_layer(wc->qp->device,
-                          (*cur_qp)->port) ==
-              IB_LINK_LAYER_ETHERNET);
+        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
         if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
             if ((*cur_qp)->mlx4_ib_qp_type &
                 (MLX4_IB_QPT_PROXY_SMI_OWNER |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 82a7dd8..4736fc7 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
     int err;
     int slave;
     u8 *slave_id;
-    int is_eth = 0;
-
-    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
-        is_eth = 0;
-    else
-        is_eth = 1;
+    int is_eth = rdma_port_ll_is_eth(ibdev, port);
 
     if (is_eth) {
         if (!(wc->wc_flags & IB_WC_GRH)) {
@@ -1252,7 +1247,7 @@ out:
 
 static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
 {
-    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
         return slave;
     return mlx4_get_base_gid_ix(dev->dev, slave, port);
 }
@@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_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);
@@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
 
     ctx->state = DEMUX_PV_STATE_STARTING;
     /* have QP0 only if link layer is IB */
-    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
-        IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(ibdev, ctx->port))
         ctx->has_smi = 1;
 
     if (ctx->has_smi) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(ibdev, port))
         return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
     else
         return iboe_query_gid(ibdev, port, index, gid);
@@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
     int err = 0;
 
     for (i = 1; i <= ibdev->num_ports; ++i) {
-        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
-            IB_LINK_LAYER_ETHERNET) {
+        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
             err = reset_gid_table(ibdev, i);
             if (err)
                 goto out;
@@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
         if (p > ibdev->num_ports)
             return;
         if (mlx4_is_master(dev) &&
-            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
-            IB_LINK_LAYER_INFINIBAND) {
+            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
             mlx4_ib_invalidate_all_guid_record(ibdev, p);
         }
         ibev.event = IB_EVENT_PORT_ACTIVE;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 6eb743f..1befeb8 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
 {
     u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
 
-    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
+    if (rdma_port_ll_is_eth(ah->ibah.device, port))
         return true;
 
     return !!(ah->av.ib.g_slid & 0x80);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c880329..bd2f557 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
               u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
               struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
 {
-    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
-        IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
     int vidx;
     int smac_index;
     int err;
@@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 
     /* APM is not supported under RoCE */
     if (attr_mask & IB_QP_ALT_PATH &&
-        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
-        IB_LINK_LAYER_ETHERNET)
+        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
         return -ENOTSUPP;
 
     context = kzalloc(sizeof *context, GFP_KERNEL);
@@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
                 context->pri_path.fl = 0x80;
             context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
         }
-        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
-            IB_LINK_LAYER_ETHERNET) {
+        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
             if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
                 qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
                 context->pri_path.feup = 1 << 7; /* don't fsm */
@@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     }
 
     if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
-        int is_eth = rdma_port_get_link_layer(
-                &dev->ib_dev, qp->port) ==
-                IB_LINK_LAYER_ETHERNET;
+        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
         if (is_eth) {
             context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
             optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
@@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
     }
 
     if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
-        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
-         IB_LINK_LAYER_ETHERNET))
+        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
         goto out;
 
     if (attr_mask & IB_QP_PKEY_INDEX) {
@@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
     for (i = 0; i < wr->num_sge; ++i)
         send_size += wr->sg_list[i].length;
 
-    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
+    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
     is_grh = mlx4_ib_ah_grh_present(ah);
     if (is_eth) {
         if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
@@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
     if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
         return;
 
-    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
-        IB_LINK_LAYER_ETHERNET;
+    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
     if (is_eth)
         ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
         ((path->sched_queue & 4) << 1);
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index cb4c66e..d339b55 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
 
 static int add_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
-            IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
     int ret;
 
     /* do not display entries if eth transport, or if master */
@@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
 
 static void remove_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
-            IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
 
     if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
         return;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 58b5aa3..3341754 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);
@@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
     }
 
     for (p = s; p <= e; ++p) {
-        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, p))
             continue;
         dev = ipoib_add_port("ib%d", device, p);
         if (!IS_ERR(dev)) {
@@ -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..2bf9094 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1743,6 +1743,30 @@ 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;
+}
+
+static inline int rdma_transport_is_iwarp(struct ib_device *device)
+{
+    return rdma_node_get_transport(device->node_type)
+            == RDMA_TRANSPORT_IWARP;
+}
+
+static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_get_link_layer(device, port_num)
+            == IB_LINK_LAYER_INFINIBAND;
+}
+
+static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_get_link_layer(device, port_num)
+            == IB_LINK_LAYER_ETHERNET;
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index e011027..a7b5891 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
 
 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
 {
-    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
-         RDMA_TRANSPORT_IWARP)
+    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
         return 1;
     else
         return min_t(int, sge_count, xprt->sc_max_sge);
-- 
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	[flat|nested] 189+ messages in thread

* [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-27 15:40     ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:40 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


We have so much places to check transport type and link layer type, it's now
make sense to introduce some helpers in order to refine the lengthy code.

This patch will introduce helpers:
    rdma_transport_is_ib()
    rdma_transport_is_iwarp()
    rdma_port_ll_is_ib()
    rdma_port_ll_is_eth()
and use them to save some code for us.

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/agent.c           |  2 +-
 drivers/infiniband/core/cm.c              |  2 +-
 drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
 drivers/infiniband/core/mad.c             |  6 +++---
 drivers/infiniband/core/multicast.c       | 11 ++++-------
 drivers/infiniband/core/sa_query.c        | 14 +++++++-------
 drivers/infiniband/core/ucm.c             |  3 +--
 drivers/infiniband/core/user_mad.c        |  2 +-
 drivers/infiniband/core/verbs.c           |  5 ++---
 drivers/infiniband/hw/mlx4/ah.c           |  2 +-
 drivers/infiniband/hw/mlx4/cq.c           |  4 +---
 drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
 drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
 drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
 drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
 drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
 drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
 include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
 19 files changed, 79 insertions(+), 83 deletions(-)

diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index f6d2961..27f1bec 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
         goto error1;
     }
 
-    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
+    if (rdma_port_ll_is_ib(device, port_num)) {
         /* Obtain send only MAD agent for SMI QP */
         port_priv->agent[0] = ib_register_mad_agent(device, port_num,
                                 IB_QPT_SMI, NULL, 0,
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..668e955 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -375,8 +375,8 @@ 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 &&
-            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
+        if (rdma_transport_is_ib(cma_dev->device) &&
+            rdma_port_ll_is_eth(cma_dev->device, port))
             ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
                          &found_port, NULL);
         else
@@ -395,8 +395,8 @@ 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 &&
-                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
+                if (rdma_transport_is_ib(cma_dev->device) &&
+                    rdma_port_ll_is_eth(cma_dev->device, port))
                     ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
                 else
                     ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
@@ -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,10 +633,8 @@ 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 &&
-        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
-        == IB_LINK_LAYER_ETHERNET) {
+    if (rdma_transport_is_ib(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);
 
         if (ret)
@@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
     int ret;
     u16 pkey;
 
-    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
-        IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
         pkey = ib_addr_get_pkey(dev_addr);
     else
         pkey = 0xffff;
@@ -1626,7 +1623,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 +2025,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)
@@ -2060,7 +2057,7 @@ port_found:
         goto out;
 
     id_priv->id.route.addr.dev_addr.dev_type =
-        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
+        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
         ARPHRD_INFINIBAND : ARPHRD_ETHER;
 
     rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
@@ -3405,7 +3402,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..23cf9e8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
     init_mad_qp(port_priv, &port_priv->qp_info[1]);
 
     cq_size = mad_sendq_size + mad_recvq_size;
-    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
+    has_smi = rdma_port_ll_is_ib(device, port_num);
     if (has_smi)
         cq_size *= 2;
 
@@ -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..17573ff 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
     int index;
 
     dev = container_of(handler, struct mcast_device, event_handler);
-    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
-        IB_LINK_LAYER_INFINIBAND)
+    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
         return;
 
     index = event->element.port_num - dev->start_port;
@@ -808,7 +807,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,
@@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
     }
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
-            IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
             continue;
         port = &dev->port[i];
         port->dev = dev;
@@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
     flush_workqueue(mcast_wq);
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
-            IB_LINK_LAYER_INFINIBAND) {
+        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
             port = &dev->port[i];
             deref_port(port);
             wait_for_completion(&port->comp);
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index c38f030..d95d25f 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
         struct ib_sa_port *port =
             &sa_dev->port[event->element.port_num - sa_dev->start_port];
 
-        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
             return;
 
         spin_lock_irqsave(&port->ah_lock, flags);
@@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
     ah_attr->port_num = port_num;
     ah_attr->static_rate = rec->rate;
 
-    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
+    force_grh = rdma_port_ll_is_eth(device, port_num);
 
     if (rec->hop_limit > 1 || force_grh) {
         ah_attr->ah_flags = IB_AH_GRH;
@@ -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)
@@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
 
     for (i = 0; i <= e - s; ++i) {
         spin_lock_init(&sa_dev->port[i].ah_lock);
-        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, i + 1))
             continue;
 
         sa_dev->port[i].sm_ah    = NULL;
@@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
         goto err;
 
     for (i = 0; i <= e - s; ++i)
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
+        if (rdma_port_ll_is_ib(device, i + 1))
             update_sm_ah(&sa_dev->port[i].update_task);
 
     return;
 
 err:
     while (--i >= 0)
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
+        if (rdma_port_ll_is_ib(device, i + 1))
             ib_unregister_mad_agent(sa_dev->port[i].agent);
 
     kfree(sa_dev);
@@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
     flush_workqueue(ib_wq);
 
     for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
+        if (rdma_port_ll_is_ib(device, i + 1)) {
             ib_unregister_mad_agent(sa_dev->port[i].agent);
             if (sa_dev->port[i].sm_ah)
                 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
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/core/verbs.c b/drivers/infiniband/core/verbs.c
index f93eb8d..d8d015a 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
     u32 flow_class;
     u16 gid_index;
     int ret;
-    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
-            IB_LINK_LAYER_ETHERNET);
+    int is_eth = (rdma_port_ll_is_eth(device, port_num));
 
     memset(ah_attr, 0, sizeof *ah_attr);
     if (is_eth) {
@@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
     union ib_gid  sgid;
 
     if ((*qp_attr_mask & IB_QP_AV)  &&
-        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
+        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
         ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
                    qp_attr->ah_attr.grh.sgid_index, &sgid);
         if (ret)
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index 2d8c339..829eb60 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
     if (!ah)
         return ERR_PTR(-ENOMEM);
 
-    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
+    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
         if (!(ah_attr->ah_flags & IB_AH_GRH)) {
             ret = ERR_PTR(-EINVAL);
         } else {
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index cb63ecd..0417f03 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -789,9 +789,7 @@ repoll:
             break;
         }
 
-        is_eth = (rdma_port_get_link_layer(wc->qp->device,
-                          (*cur_qp)->port) ==
-              IB_LINK_LAYER_ETHERNET);
+        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
         if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
             if ((*cur_qp)->mlx4_ib_qp_type &
                 (MLX4_IB_QPT_PROXY_SMI_OWNER |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 82a7dd8..4736fc7 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
     int err;
     int slave;
     u8 *slave_id;
-    int is_eth = 0;
-
-    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
-        is_eth = 0;
-    else
-        is_eth = 1;
+    int is_eth = rdma_port_ll_is_eth(ibdev, port);
 
     if (is_eth) {
         if (!(wc->wc_flags & IB_WC_GRH)) {
@@ -1252,7 +1247,7 @@ out:
 
 static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
 {
-    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
         return slave;
     return mlx4_get_base_gid_ix(dev->dev, slave, port);
 }
@@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_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);
@@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
 
     ctx->state = DEMUX_PV_STATE_STARTING;
     /* have QP0 only if link layer is IB */
-    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
-        IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(ibdev, ctx->port))
         ctx->has_smi = 1;
 
     if (ctx->has_smi) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(ibdev, port))
         return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
     else
         return iboe_query_gid(ibdev, port, index, gid);
@@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
     int err = 0;
 
     for (i = 1; i <= ibdev->num_ports; ++i) {
-        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
-            IB_LINK_LAYER_ETHERNET) {
+        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
             err = reset_gid_table(ibdev, i);
             if (err)
                 goto out;
@@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
         if (p > ibdev->num_ports)
             return;
         if (mlx4_is_master(dev) &&
-            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
-            IB_LINK_LAYER_INFINIBAND) {
+            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
             mlx4_ib_invalidate_all_guid_record(ibdev, p);
         }
         ibev.event = IB_EVENT_PORT_ACTIVE;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 6eb743f..1befeb8 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
 {
     u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
 
-    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
+    if (rdma_port_ll_is_eth(ah->ibah.device, port))
         return true;
 
     return !!(ah->av.ib.g_slid & 0x80);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c880329..bd2f557 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
               u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
               struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
 {
-    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
-        IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
     int vidx;
     int smac_index;
     int err;
@@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 
     /* APM is not supported under RoCE */
     if (attr_mask & IB_QP_ALT_PATH &&
-        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
-        IB_LINK_LAYER_ETHERNET)
+        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
         return -ENOTSUPP;
 
     context = kzalloc(sizeof *context, GFP_KERNEL);
@@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
                 context->pri_path.fl = 0x80;
             context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
         }
-        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
-            IB_LINK_LAYER_ETHERNET) {
+        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
             if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
                 qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
                 context->pri_path.feup = 1 << 7; /* don't fsm */
@@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     }
 
     if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
-        int is_eth = rdma_port_get_link_layer(
-                &dev->ib_dev, qp->port) ==
-                IB_LINK_LAYER_ETHERNET;
+        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
         if (is_eth) {
             context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
             optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
@@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
     }
 
     if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
-        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
-         IB_LINK_LAYER_ETHERNET))
+        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
         goto out;
 
     if (attr_mask & IB_QP_PKEY_INDEX) {
@@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
     for (i = 0; i < wr->num_sge; ++i)
         send_size += wr->sg_list[i].length;
 
-    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
+    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
     is_grh = mlx4_ib_ah_grh_present(ah);
     if (is_eth) {
         if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
@@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
     if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
         return;
 
-    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
-        IB_LINK_LAYER_ETHERNET;
+    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
     if (is_eth)
         ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
         ((path->sched_queue & 4) << 1);
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index cb4c66e..d339b55 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
 
 static int add_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
-            IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
     int ret;
 
     /* do not display entries if eth transport, or if master */
@@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
 
 static void remove_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
-            IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
 
     if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
         return;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 58b5aa3..3341754 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);
@@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
     }
 
     for (p = s; p <= e; ++p) {
-        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, p))
             continue;
         dev = ipoib_add_port("ib%d", device, p);
         if (!IS_ERR(dev)) {
@@ -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..2bf9094 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1743,6 +1743,30 @@ 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;
+}
+
+static inline int rdma_transport_is_iwarp(struct ib_device *device)
+{
+    return rdma_node_get_transport(device->node_type)
+            == RDMA_TRANSPORT_IWARP;
+}
+
+static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_get_link_layer(device, port_num)
+            == IB_LINK_LAYER_INFINIBAND;
+}
+
+static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_get_link_layer(device, port_num)
+            == IB_LINK_LAYER_ETHERNET;
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index e011027..a7b5891 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
 
 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
 {
-    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
-         RDMA_TRANSPORT_IWARP)
+    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
         return 1;
     else
         return min_t(int, sge_count, xprt->sc_max_sge);
-- 
2.1.0


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-27 15:40     ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:40 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


We have so much places to check transport type and link layer type, it's now
make sense to introduce some helpers in order to refine the lengthy code.

This patch will introduce helpers:
    rdma_transport_is_ib()
    rdma_transport_is_iwarp()
    rdma_port_ll_is_ib()
    rdma_port_ll_is_eth()
and use them to save some code for us.

Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 drivers/infiniband/core/agent.c           |  2 +-
 drivers/infiniband/core/cm.c              |  2 +-
 drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
 drivers/infiniband/core/mad.c             |  6 +++---
 drivers/infiniband/core/multicast.c       | 11 ++++-------
 drivers/infiniband/core/sa_query.c        | 14 +++++++-------
 drivers/infiniband/core/ucm.c             |  3 +--
 drivers/infiniband/core/user_mad.c        |  2 +-
 drivers/infiniband/core/verbs.c           |  5 ++---
 drivers/infiniband/hw/mlx4/ah.c           |  2 +-
 drivers/infiniband/hw/mlx4/cq.c           |  4 +---
 drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
 drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
 drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
 drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
 drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
 drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
 include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
 19 files changed, 79 insertions(+), 83 deletions(-)

diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index f6d2961..27f1bec 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
         goto error1;
     }
 
-    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
+    if (rdma_port_ll_is_ib(device, port_num)) {
         /* Obtain send only MAD agent for SMI QP */
         port_priv->agent[0] = ib_register_mad_agent(device, port_num,
                                 IB_QPT_SMI, NULL, 0,
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..668e955 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -375,8 +375,8 @@ 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 &&
-            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
+        if (rdma_transport_is_ib(cma_dev->device) &&
+            rdma_port_ll_is_eth(cma_dev->device, port))
             ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
                          &found_port, NULL);
         else
@@ -395,8 +395,8 @@ 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 &&
-                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
+                if (rdma_transport_is_ib(cma_dev->device) &&
+                    rdma_port_ll_is_eth(cma_dev->device, port))
                     ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
                 else
                     ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
@@ -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,10 +633,8 @@ 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 &&
-        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
-        == IB_LINK_LAYER_ETHERNET) {
+    if (rdma_transport_is_ib(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);
 
         if (ret)
@@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
     int ret;
     u16 pkey;
 
-    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
-        IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
         pkey = ib_addr_get_pkey(dev_addr);
     else
         pkey = 0xffff;
@@ -1626,7 +1623,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 +2025,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)
@@ -2060,7 +2057,7 @@ port_found:
         goto out;
 
     id_priv->id.route.addr.dev_addr.dev_type =
-        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
+        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
         ARPHRD_INFINIBAND : ARPHRD_ETHER;
 
     rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
@@ -3405,7 +3402,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..23cf9e8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
     init_mad_qp(port_priv, &port_priv->qp_info[1]);
 
     cq_size = mad_sendq_size + mad_recvq_size;
-    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
+    has_smi = rdma_port_ll_is_ib(device, port_num);
     if (has_smi)
         cq_size *= 2;
 
@@ -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..17573ff 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
     int index;
 
     dev = container_of(handler, struct mcast_device, event_handler);
-    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
-        IB_LINK_LAYER_INFINIBAND)
+    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
         return;
 
     index = event->element.port_num - dev->start_port;
@@ -808,7 +807,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,
@@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
     }
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
-            IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
             continue;
         port = &dev->port[i];
         port->dev = dev;
@@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
     flush_workqueue(mcast_wq);
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
-            IB_LINK_LAYER_INFINIBAND) {
+        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
             port = &dev->port[i];
             deref_port(port);
             wait_for_completion(&port->comp);
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index c38f030..d95d25f 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
         struct ib_sa_port *port =
             &sa_dev->port[event->element.port_num - sa_dev->start_port];
 
-        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
             return;
 
         spin_lock_irqsave(&port->ah_lock, flags);
@@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
     ah_attr->port_num = port_num;
     ah_attr->static_rate = rec->rate;
 
-    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
+    force_grh = rdma_port_ll_is_eth(device, port_num);
 
     if (rec->hop_limit > 1 || force_grh) {
         ah_attr->ah_flags = IB_AH_GRH;
@@ -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)
@@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
 
     for (i = 0; i <= e - s; ++i) {
         spin_lock_init(&sa_dev->port[i].ah_lock);
-        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, i + 1))
             continue;
 
         sa_dev->port[i].sm_ah    = NULL;
@@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
         goto err;
 
     for (i = 0; i <= e - s; ++i)
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
+        if (rdma_port_ll_is_ib(device, i + 1))
             update_sm_ah(&sa_dev->port[i].update_task);
 
     return;
 
 err:
     while (--i >= 0)
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
+        if (rdma_port_ll_is_ib(device, i + 1))
             ib_unregister_mad_agent(sa_dev->port[i].agent);
 
     kfree(sa_dev);
@@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
     flush_workqueue(ib_wq);
 
     for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
-        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
+        if (rdma_port_ll_is_ib(device, i + 1)) {
             ib_unregister_mad_agent(sa_dev->port[i].agent);
             if (sa_dev->port[i].sm_ah)
                 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
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/core/verbs.c b/drivers/infiniband/core/verbs.c
index f93eb8d..d8d015a 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
     u32 flow_class;
     u16 gid_index;
     int ret;
-    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
-            IB_LINK_LAYER_ETHERNET);
+    int is_eth = (rdma_port_ll_is_eth(device, port_num));
 
     memset(ah_attr, 0, sizeof *ah_attr);
     if (is_eth) {
@@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
     union ib_gid  sgid;
 
     if ((*qp_attr_mask & IB_QP_AV)  &&
-        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
+        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
         ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
                    qp_attr->ah_attr.grh.sgid_index, &sgid);
         if (ret)
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index 2d8c339..829eb60 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
     if (!ah)
         return ERR_PTR(-ENOMEM);
 
-    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
+    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
         if (!(ah_attr->ah_flags & IB_AH_GRH)) {
             ret = ERR_PTR(-EINVAL);
         } else {
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index cb63ecd..0417f03 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -789,9 +789,7 @@ repoll:
             break;
         }
 
-        is_eth = (rdma_port_get_link_layer(wc->qp->device,
-                          (*cur_qp)->port) ==
-              IB_LINK_LAYER_ETHERNET);
+        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
         if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
             if ((*cur_qp)->mlx4_ib_qp_type &
                 (MLX4_IB_QPT_PROXY_SMI_OWNER |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 82a7dd8..4736fc7 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
     int err;
     int slave;
     u8 *slave_id;
-    int is_eth = 0;
-
-    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
-        is_eth = 0;
-    else
-        is_eth = 1;
+    int is_eth = rdma_port_ll_is_eth(ibdev, port);
 
     if (is_eth) {
         if (!(wc->wc_flags & IB_WC_GRH)) {
@@ -1252,7 +1247,7 @@ out:
 
 static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
 {
-    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
         return slave;
     return mlx4_get_base_gid_ix(dev->dev, slave, port);
 }
@@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_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);
@@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
 
     ctx->state = DEMUX_PV_STATE_STARTING;
     /* have QP0 only if link layer is IB */
-    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
-        IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(ibdev, ctx->port))
         ctx->has_smi = 1;
 
     if (ctx->has_smi) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
+    if (rdma_port_ll_is_ib(ibdev, port))
         return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
     else
         return iboe_query_gid(ibdev, port, index, gid);
@@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
     int err = 0;
 
     for (i = 1; i <= ibdev->num_ports; ++i) {
-        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
-            IB_LINK_LAYER_ETHERNET) {
+        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
             err = reset_gid_table(ibdev, i);
             if (err)
                 goto out;
@@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
         if (p > ibdev->num_ports)
             return;
         if (mlx4_is_master(dev) &&
-            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
-            IB_LINK_LAYER_INFINIBAND) {
+            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
             mlx4_ib_invalidate_all_guid_record(ibdev, p);
         }
         ibev.event = IB_EVENT_PORT_ACTIVE;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 6eb743f..1befeb8 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
 {
     u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
 
-    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
+    if (rdma_port_ll_is_eth(ah->ibah.device, port))
         return true;
 
     return !!(ah->av.ib.g_slid & 0x80);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index c880329..bd2f557 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
               u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
               struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
 {
-    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
-        IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
     int vidx;
     int smac_index;
     int err;
@@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 
     /* APM is not supported under RoCE */
     if (attr_mask & IB_QP_ALT_PATH &&
-        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
-        IB_LINK_LAYER_ETHERNET)
+        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
         return -ENOTSUPP;
 
     context = kzalloc(sizeof *context, GFP_KERNEL);
@@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
                 context->pri_path.fl = 0x80;
             context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
         }
-        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
-            IB_LINK_LAYER_ETHERNET) {
+        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
             if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
                 qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
                 context->pri_path.feup = 1 << 7; /* don't fsm */
@@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     }
 
     if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
-        int is_eth = rdma_port_get_link_layer(
-                &dev->ib_dev, qp->port) ==
-                IB_LINK_LAYER_ETHERNET;
+        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
         if (is_eth) {
             context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
             optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
@@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
     }
 
     if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
-        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
-         IB_LINK_LAYER_ETHERNET))
+        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
         goto out;
 
     if (attr_mask & IB_QP_PKEY_INDEX) {
@@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
     for (i = 0; i < wr->num_sge; ++i)
         send_size += wr->sg_list[i].length;
 
-    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
+    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
     is_grh = mlx4_ib_ah_grh_present(ah);
     if (is_eth) {
         if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
@@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
     if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
         return;
 
-    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
-        IB_LINK_LAYER_ETHERNET;
+    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
     if (is_eth)
         ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
         ((path->sched_queue & 4) << 1);
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index cb4c66e..d339b55 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
 
 static int add_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
-            IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
     int ret;
 
     /* do not display entries if eth transport, or if master */
@@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
 
 static void remove_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
-            IB_LINK_LAYER_ETHERNET;
+    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
 
     if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
         return;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 58b5aa3..3341754 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);
@@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
     }
 
     for (p = s; p <= e; ++p) {
-        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
+        if (!rdma_port_ll_is_ib(device, p))
             continue;
         dev = ipoib_add_port("ib%d", device, p);
         if (!IS_ERR(dev)) {
@@ -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..2bf9094 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1743,6 +1743,30 @@ 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;
+}
+
+static inline int rdma_transport_is_iwarp(struct ib_device *device)
+{
+    return rdma_node_get_transport(device->node_type)
+            == RDMA_TRANSPORT_IWARP;
+}
+
+static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_get_link_layer(device, port_num)
+            == IB_LINK_LAYER_INFINIBAND;
+}
+
+static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_get_link_layer(device, port_num)
+            == IB_LINK_LAYER_ETHERNET;
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index e011027..a7b5891 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
 
 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
 {
-    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
-         RDMA_TRANSPORT_IWARP)
+    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
         return 1;
     else
         return min_t(int, sge_count, xprt->sc_max_sge);
-- 
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	[flat|nested] 189+ messages in thread

* [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:42   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:42 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper tech_iboe() to help us check if the port of an IB
device is using RoCE/IBoE technology.

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/cma.c |  6 ++----
 include/rdma/ib_verbs.h       | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 668e955..280cfe3 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -375,8 +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_transport_is_ib(cma_dev->device) &&
-            rdma_port_ll_is_eth(cma_dev->device, port))
+        if (tech_iboe(cma_dev->device, port))
             ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
                          &found_port, NULL);
         else
@@ -395,8 +394,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_transport_is_ib(cma_dev->device) &&
-                    rdma_port_ll_is_eth(cma_dev->device, port))
+                if (tech_iboe(cma_dev->device, port))
                     ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
                 else
                     ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 2bf9094..ca6d6bc 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1767,6 +1767,22 @@ static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
             == IB_LINK_LAYER_ETHERNET;
 }
 
+/**
+ * tech_iboe - Check if the port of device using technology
+ * RoCE/IBoE.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device is not using technology
+ * RoCE/IBoE.
+ */
+static inline int tech_iboe(struct ib_device *device, u8 port_num)
+{
+    return rdma_transport_is_ib(device) &&
+            rdma_port_ll_is_eth(device, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
@ 2015-03-27 15:42   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:42 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


Introduce helper tech_iboe() to help us check if the port of an IB
device is using RoCE/IBoE technology.

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/cma.c |  6 ++----
 include/rdma/ib_verbs.h       | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 668e955..280cfe3 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -375,8 +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_transport_is_ib(cma_dev->device) &&
-            rdma_port_ll_is_eth(cma_dev->device, port))
+        if (tech_iboe(cma_dev->device, port))
             ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
                          &found_port, NULL);
         else
@@ -395,8 +394,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_transport_is_ib(cma_dev->device) &&
-                    rdma_port_ll_is_eth(cma_dev->device, port))
+                if (tech_iboe(cma_dev->device, port))
                     ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
                 else
                     ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 2bf9094..ca6d6bc 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1767,6 +1767,22 @@ static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
             == IB_LINK_LAYER_ETHERNET;
 }
 
+/**
+ * tech_iboe - Check if the port of device using technology
+ * RoCE/IBoE.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device is not using technology
+ * RoCE/IBoE.
+ */
+static inline int tech_iboe(struct ib_device *device, u8 port_num)
+{
+    return rdma_transport_is_ib(device) &&
+            rdma_port_ll_is_eth(device, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
-- 
2.1.0


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
@ 2015-03-27 15:42   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:42 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper tech_iboe() to help us check if the port of an IB
device is using RoCE/IBoE technology.

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/cma.c |  6 ++----
 include/rdma/ib_verbs.h       | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 668e955..280cfe3 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -375,8 +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_transport_is_ib(cma_dev->device) &&
-            rdma_port_ll_is_eth(cma_dev->device, port))
+        if (tech_iboe(cma_dev->device, port))
             ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
                          &found_port, NULL);
         else
@@ -395,8 +394,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_transport_is_ib(cma_dev->device) &&
-                    rdma_port_ll_is_eth(cma_dev->device, port))
+                if (tech_iboe(cma_dev->device, port))
                     ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
                 else
                     ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 2bf9094..ca6d6bc 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1767,6 +1767,22 @@ static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
             == IB_LINK_LAYER_ETHERNET;
 }
 
+/**
+ * tech_iboe - Check if the port of device using technology
+ * RoCE/IBoE.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device is not using technology
+ * RoCE/IBoE.
+ */
+static inline int tech_iboe(struct ib_device *device, u8 port_num)
+{
+    return rdma_transport_is_ib(device) &&
+            rdma_port_ll_is_eth(device, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 03/11] IB/Verbs: Use management helper has_mad() for mad-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:43   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:43 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


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

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/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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 03/11] IB/Verbs: Use management helper has_mad() for mad-check
@ 2015-03-27 15:43   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:43 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


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

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/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


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 03/11] IB/Verbs: Use management helper has_mad() for mad-check
@ 2015-03-27 15:43   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:43 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


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

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/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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:44   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:44 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper cap_smi() to help us check if the port of an
IB device support Subnet Management Interface.

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/agent.c  |  2 +-
 drivers/infiniband/core/mad.c    |  2 +-
 drivers/infiniband/hw/mlx4/mad.c |  2 +-
 include/rdma/ib_verbs.h          | 15 +++++++++++++++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index 27f1bec..187514a 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
         goto error1;
     }
 
-    if (rdma_port_ll_is_ib(device, port_num)) {
+    if (cap_smi(device, port_num)) {
         /* Obtain send only MAD agent for SMI QP */
         port_priv->agent[0] = ib_register_mad_agent(device, port_num,
                                 IB_QPT_SMI, NULL, 0,
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 896b749..c5d1ebb5b 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
     init_mad_qp(port_priv, &port_priv->qp_info[1]);
 
     cq_size = mad_sendq_size + mad_recvq_size;
-    has_smi = rdma_port_ll_is_ib(device, port_num);
+    has_smi = cap_smi(device, port_num);
     if (has_smi)
         cq_size *= 2;
 
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 4736fc7..09874d0 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1753,7 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
 
     ctx->state = DEMUX_PV_STATE_STARTING;
     /* have QP0 only if link layer is IB */
-    if (rdma_port_ll_is_ib(ibdev, ctx->port))
+    if (cap_smi(ibdev, ctx->port))
         ctx->has_smi = 1;
 
     if (ctx->has_smi) {
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 7b2bfe8..3d06178 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1796,6 +1796,21 @@ static inline int has_mad(struct ib_device *device)
     return rdma_transport_is_ib(device);
 }
 
+/**
+ * cap_smi - Check if the port of device has the capability
+ * Subnet Management Interface.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Subnet Management Interface.
+ */
+static inline int cap_smi(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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
@ 2015-03-27 15:44   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:44 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


Introduce helper cap_smi() to help us check if the port of an
IB device support Subnet Management Interface.

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/agent.c  |  2 +-
 drivers/infiniband/core/mad.c    |  2 +-
 drivers/infiniband/hw/mlx4/mad.c |  2 +-
 include/rdma/ib_verbs.h          | 15 +++++++++++++++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index 27f1bec..187514a 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
         goto error1;
     }
 
-    if (rdma_port_ll_is_ib(device, port_num)) {
+    if (cap_smi(device, port_num)) {
         /* Obtain send only MAD agent for SMI QP */
         port_priv->agent[0] = ib_register_mad_agent(device, port_num,
                                 IB_QPT_SMI, NULL, 0,
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 896b749..c5d1ebb5b 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
     init_mad_qp(port_priv, &port_priv->qp_info[1]);
 
     cq_size = mad_sendq_size + mad_recvq_size;
-    has_smi = rdma_port_ll_is_ib(device, port_num);
+    has_smi = cap_smi(device, port_num);
     if (has_smi)
         cq_size *= 2;
 
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 4736fc7..09874d0 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1753,7 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
 
     ctx->state = DEMUX_PV_STATE_STARTING;
     /* have QP0 only if link layer is IB */
-    if (rdma_port_ll_is_ib(ibdev, ctx->port))
+    if (cap_smi(ibdev, ctx->port))
         ctx->has_smi = 1;
 
     if (ctx->has_smi) {
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 7b2bfe8..3d06178 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1796,6 +1796,21 @@ static inline int has_mad(struct ib_device *device)
     return rdma_transport_is_ib(device);
 }
 
+/**
+ * cap_smi - Check if the port of device has the capability
+ * Subnet Management Interface.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Subnet Management Interface.
+ */
+static inline int cap_smi(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


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
@ 2015-03-27 15:44   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:44 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper cap_smi() to help us check if the port of an
IB device support Subnet Management Interface.

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/agent.c  |  2 +-
 drivers/infiniband/core/mad.c    |  2 +-
 drivers/infiniband/hw/mlx4/mad.c |  2 +-
 include/rdma/ib_verbs.h          | 15 +++++++++++++++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index 27f1bec..187514a 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
         goto error1;
     }
 
-    if (rdma_port_ll_is_ib(device, port_num)) {
+    if (cap_smi(device, port_num)) {
         /* Obtain send only MAD agent for SMI QP */
         port_priv->agent[0] = ib_register_mad_agent(device, port_num,
                                 IB_QPT_SMI, NULL, 0,
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 896b749..c5d1ebb5b 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
     init_mad_qp(port_priv, &port_priv->qp_info[1]);
 
     cq_size = mad_sendq_size + mad_recvq_size;
-    has_smi = rdma_port_ll_is_ib(device, port_num);
+    has_smi = cap_smi(device, port_num);
     if (has_smi)
         cq_size *= 2;
 
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 4736fc7..09874d0 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1753,7 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
 
     ctx->state = DEMUX_PV_STATE_STARTING;
     /* have QP0 only if link layer is IB */
-    if (rdma_port_ll_is_ib(ibdev, ctx->port))
+    if (cap_smi(ibdev, ctx->port))
         ctx->has_smi = 1;
 
     if (ctx->has_smi) {
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 7b2bfe8..3d06178 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1796,6 +1796,21 @@ static inline int has_mad(struct ib_device *device)
     return rdma_transport_is_ib(device);
 }
 
+/**
+ * cap_smi - Check if the port of device has the capability
+ * Subnet Management Interface.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Subnet Management Interface.
+ */
+static inline int cap_smi(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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 05/11] IB/Verbs: Use management helper has_cm() for cm-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:45   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:45 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


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(-)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 2c72e9e..5c1f01b 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_transport_is_ib(ib_device))
+    if (!has_cm(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 280cfe3..276fb76 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -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)
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index ddbe0b4..7084181 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -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);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3d06178..c0a63f8 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -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.
  *
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 05/11] IB/Verbs: Use management helper has_cm() for cm-check
@ 2015-03-27 15:45   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:45 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


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(-)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 2c72e9e..5c1f01b 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_transport_is_ib(ib_device))
+    if (!has_cm(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 280cfe3..276fb76 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -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)
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index ddbe0b4..7084181 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -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);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3d06178..c0a63f8 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -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.
  *
-- 
2.1.0


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 05/11] IB/Verbs: Use management helper has_cm() for cm-check
@ 2015-03-27 15:45   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:45 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


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(-)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 2c72e9e..5c1f01b 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_transport_is_ib(ib_device))
+    if (!has_cm(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 280cfe3..276fb76 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -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)
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index ddbe0b4..7084181 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -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);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3d06178..c0a63f8 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -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.
  *
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:46     ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:46 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_sa() and cap_sa() to help us check if an IB device
or it's port support Subnet Administrator.

Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 drivers/infiniband/core/sa_query.c | 12 ++++++------
 include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index d95d25f..89c27da 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
         struct ib_sa_port *port =
             &sa_dev->port[event->element.port_num - sa_dev->start_port];
 
-        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
+        if (!cap_sa(handler->device, port->port_num))
             return;
 
         spin_lock_irqsave(&port->ah_lock, flags);
@@ -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_transport_is_ib(device))
+    if (!has_sa(device))
         return;
 
     if (device->node_type == RDMA_NODE_IB_SWITCH)
@@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
 
     for (i = 0; i <= e - s; ++i) {
         spin_lock_init(&sa_dev->port[i].ah_lock);
-        if (!rdma_port_ll_is_ib(device, i + 1))
+        if (!cap_sa(device, i + 1))
             continue;
 
         sa_dev->port[i].sm_ah    = NULL;
@@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
         goto err;
 
     for (i = 0; i <= e - s; ++i)
-        if (rdma_port_ll_is_ib(device, i + 1))
+        if (cap_sa(device, i + 1))
             update_sm_ah(&sa_dev->port[i].update_task);
 
     return;
 
 err:
     while (--i >= 0)
-        if (rdma_port_ll_is_ib(device, i + 1))
+        if (cap_sa(device, i + 1))
             ib_unregister_mad_agent(sa_dev->port[i].agent);
 
     kfree(sa_dev);
@@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
     flush_workqueue(ib_wq);
 
     for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
-        if (rdma_port_ll_is_ib(device, i + 1)) {
+        if (cap_sa(device, i + 1)) {
             ib_unregister_mad_agent(sa_dev->port[i].agent);
             if (sa_dev->port[i].sm_ah)
                 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index c0a63f8..fa8ffa3 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
 }
 
 /**
+ * has_sa - Check if a device support Subnet Administrator.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * Subnet Administrator.
+ */
+static inline int has_sa(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_sa - Check if the port of device has the capability
+ * Subnet Administrator.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Subnet Administrator.
+ */
+static inline int cap_sa(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-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	[flat|nested] 189+ messages in thread

* [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 15:46     ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:46 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


Introduce helper has_sa() and cap_sa() to help us check if an IB device
or it's port support Subnet Administrator.

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/sa_query.c | 12 ++++++------
 include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index d95d25f..89c27da 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
         struct ib_sa_port *port =
             &sa_dev->port[event->element.port_num - sa_dev->start_port];
 
-        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
+        if (!cap_sa(handler->device, port->port_num))
             return;
 
         spin_lock_irqsave(&port->ah_lock, flags);
@@ -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_transport_is_ib(device))
+    if (!has_sa(device))
         return;
 
     if (device->node_type == RDMA_NODE_IB_SWITCH)
@@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
 
     for (i = 0; i <= e - s; ++i) {
         spin_lock_init(&sa_dev->port[i].ah_lock);
-        if (!rdma_port_ll_is_ib(device, i + 1))
+        if (!cap_sa(device, i + 1))
             continue;
 
         sa_dev->port[i].sm_ah    = NULL;
@@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
         goto err;
 
     for (i = 0; i <= e - s; ++i)
-        if (rdma_port_ll_is_ib(device, i + 1))
+        if (cap_sa(device, i + 1))
             update_sm_ah(&sa_dev->port[i].update_task);
 
     return;
 
 err:
     while (--i >= 0)
-        if (rdma_port_ll_is_ib(device, i + 1))
+        if (cap_sa(device, i + 1))
             ib_unregister_mad_agent(sa_dev->port[i].agent);
 
     kfree(sa_dev);
@@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
     flush_workqueue(ib_wq);
 
     for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
-        if (rdma_port_ll_is_ib(device, i + 1)) {
+        if (cap_sa(device, i + 1)) {
             ib_unregister_mad_agent(sa_dev->port[i].agent);
             if (sa_dev->port[i].sm_ah)
                 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index c0a63f8..fa8ffa3 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
 }
 
 /**
+ * has_sa - Check if a device support Subnet Administrator.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * Subnet Administrator.
+ */
+static inline int has_sa(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_sa - Check if the port of device has the capability
+ * Subnet Administrator.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Subnet Administrator.
+ */
+static inline int cap_sa(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


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 15:46     ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:46 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_sa() and cap_sa() to help us check if an IB device
or it's port support Subnet Administrator.

Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 drivers/infiniband/core/sa_query.c | 12 ++++++------
 include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index d95d25f..89c27da 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
         struct ib_sa_port *port =
             &sa_dev->port[event->element.port_num - sa_dev->start_port];
 
-        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
+        if (!cap_sa(handler->device, port->port_num))
             return;
 
         spin_lock_irqsave(&port->ah_lock, flags);
@@ -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_transport_is_ib(device))
+    if (!has_sa(device))
         return;
 
     if (device->node_type == RDMA_NODE_IB_SWITCH)
@@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
 
     for (i = 0; i <= e - s; ++i) {
         spin_lock_init(&sa_dev->port[i].ah_lock);
-        if (!rdma_port_ll_is_ib(device, i + 1))
+        if (!cap_sa(device, i + 1))
             continue;
 
         sa_dev->port[i].sm_ah    = NULL;
@@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
         goto err;
 
     for (i = 0; i <= e - s; ++i)
-        if (rdma_port_ll_is_ib(device, i + 1))
+        if (cap_sa(device, i + 1))
             update_sm_ah(&sa_dev->port[i].update_task);
 
     return;
 
 err:
     while (--i >= 0)
-        if (rdma_port_ll_is_ib(device, i + 1))
+        if (cap_sa(device, i + 1))
             ib_unregister_mad_agent(sa_dev->port[i].agent);
 
     kfree(sa_dev);
@@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
     flush_workqueue(ib_wq);
 
     for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
-        if (rdma_port_ll_is_ib(device, i + 1)) {
+        if (cap_sa(device, i + 1)) {
             ib_unregister_mad_agent(sa_dev->port[i].agent);
             if (sa_dev->port[i].sm_ah)
                 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index c0a63f8..fa8ffa3 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
 }
 
 /**
+ * has_sa - Check if a device support Subnet Administrator.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * Subnet Administrator.
+ */
+static inline int has_sa(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_sa - Check if the port of device has the capability
+ * Subnet Administrator.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Subnet Administrator.
+ */
+static inline int cap_sa(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-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	[flat|nested] 189+ messages in thread

* [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:46     ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:46 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_mcast() and cap_mcast() to help us check if an
IB device or it's port support Multicast.

Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 drivers/infiniband/core/cma.c       |  2 +-
 drivers/infiniband/core/multicast.c |  8 ++++----
 include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 276fb76..cbbc85b 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
+            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
index 17573ff..ffeaf27 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
     int index;
 
     dev = container_of(handler, struct mcast_device, event_handler);
-    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
+    if (!cap_mcast(dev->device, event->element.port_num))
         return;
 
     index = event->element.port_num - dev->start_port;
@@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
     int i;
     int count = 0;
 
-    if (!rdma_transport_is_ib(device))
+    if (!has_mcast(device))
         return;
 
     dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
@@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
     }
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
+        if (!cap_mcast(device, dev->start_port + i))
             continue;
         port = &dev->port[i];
         port->dev = dev;
@@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
     flush_workqueue(mcast_wq);
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
+        if (cap_mcast(device, dev->start_port + i)) {
             port = &dev->port[i];
             deref_port(port);
             wait_for_completion(&port->comp);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index fa8ffa3..e796104 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
 }
 
 /**
+ * has_mcast - Check if a device support Multicast.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * Multicast.
+ */
+static inline int has_mcast(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_mcast - Check if the port of device has the capability
+ * Multicast.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Multicast.
+ */
+static inline int cap_mcast(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-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	[flat|nested] 189+ messages in thread

* [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 15:46     ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:46 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


Introduce helper has_mcast() and cap_mcast() to help us check if an
IB device or it's port support Multicast.

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/cma.c       |  2 +-
 drivers/infiniband/core/multicast.c |  8 ++++----
 include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 276fb76..cbbc85b 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
+            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
index 17573ff..ffeaf27 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
     int index;
 
     dev = container_of(handler, struct mcast_device, event_handler);
-    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
+    if (!cap_mcast(dev->device, event->element.port_num))
         return;
 
     index = event->element.port_num - dev->start_port;
@@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
     int i;
     int count = 0;
 
-    if (!rdma_transport_is_ib(device))
+    if (!has_mcast(device))
         return;
 
     dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
@@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
     }
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
+        if (!cap_mcast(device, dev->start_port + i))
             continue;
         port = &dev->port[i];
         port->dev = dev;
@@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
     flush_workqueue(mcast_wq);
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
+        if (cap_mcast(device, dev->start_port + i)) {
             port = &dev->port[i];
             deref_port(port);
             wait_for_completion(&port->comp);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index fa8ffa3..e796104 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
 }
 
 /**
+ * has_mcast - Check if a device support Multicast.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * Multicast.
+ */
+static inline int has_mcast(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_mcast - Check if the port of device has the capability
+ * Multicast.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Multicast.
+ */
+static inline int cap_mcast(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


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 15:46     ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:46 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_mcast() and cap_mcast() to help us check if an
IB device or it's port support Multicast.

Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 drivers/infiniband/core/cma.c       |  2 +-
 drivers/infiniband/core/multicast.c |  8 ++++----
 include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 276fb76..cbbc85b 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
+            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
index 17573ff..ffeaf27 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
     int index;
 
     dev = container_of(handler, struct mcast_device, event_handler);
-    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
+    if (!cap_mcast(dev->device, event->element.port_num))
         return;
 
     index = event->element.port_num - dev->start_port;
@@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
     int i;
     int count = 0;
 
-    if (!rdma_transport_is_ib(device))
+    if (!has_mcast(device))
         return;
 
     dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
@@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
     }
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
+        if (!cap_mcast(device, dev->start_port + i))
             continue;
         port = &dev->port[i];
         port->dev = dev;
@@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
     flush_workqueue(mcast_wq);
 
     for (i = 0; i <= dev->end_port - dev->start_port; i++) {
-        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
+        if (cap_mcast(device, dev->start_port + i)) {
             port = &dev->port[i];
             deref_port(port);
             wait_for_completion(&port->comp);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index fa8ffa3..e796104 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
 }
 
 /**
+ * has_mcast - Check if a device support Multicast.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * Multicast.
+ */
+static inline int has_mcast(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_mcast - Check if the port of device has the capability
+ * Multicast.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * Multicast.
+ */
+static inline int cap_mcast(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-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	[flat|nested] 189+ messages in thread

* [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:47   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:47 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_iwarp() to help us check if an IB device
support IWARP protocol.

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>
---
 include/rdma/ib_verbs.h                 | 13 +++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e796104..0ef9cd7 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
 }
 
 /**
+ * has_iwarp - Check if a device support IWARP protocol.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * IWARP protocol.
+ */
+static inline int has_iwarp(struct ib_device *device)
+{
+    return rdma_transport_is_iwarp(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index a7b5891..48aeb5e 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
 
 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
 {
-    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
+    if (has_iwarp(xprt->sc_cm_id->device))
         return 1;
     else
         return min_t(int, sge_count, xprt->sc_max_sge);
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 15:47   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:47 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


Introduce helper has_iwarp() to help us check if an IB device
support IWARP protocol.

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>
---
 include/rdma/ib_verbs.h                 | 13 +++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e796104..0ef9cd7 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
 }
 
 /**
+ * has_iwarp - Check if a device support IWARP protocol.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * IWARP protocol.
+ */
+static inline int has_iwarp(struct ib_device *device)
+{
+    return rdma_transport_is_iwarp(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index a7b5891..48aeb5e 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
 
 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
 {
-    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
+    if (has_iwarp(xprt->sc_cm_id->device))
         return 1;
     else
         return min_t(int, sge_count, xprt->sc_max_sge);
-- 
2.1.0


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 15:47   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:47 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_iwarp() to help us check if an IB device
support IWARP protocol.

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>
---
 include/rdma/ib_verbs.h                 | 13 +++++++++++++
 net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e796104..0ef9cd7 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
 }
 
 /**
+ * has_iwarp - Check if a device support IWARP protocol.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * IWARP protocol.
+ */
+static inline int has_iwarp(struct ib_device *device)
+{
+    return rdma_transport_is_iwarp(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index a7b5891..48aeb5e 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
 
 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
 {
-    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
+    if (has_iwarp(xprt->sc_cm_id->device))
         return 1;
     else
         return min_t(int, sge_count, xprt->sc_max_sge);
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:48   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:48 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_ipoib() and cap_ipoib() to help us check if an
IB device or it's port support IP over Infiniband.

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/ulp/ipoib/ipoib_main.c |  6 +++---
 include/rdma/ib_verbs.h                   | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 3341754..fcd7558 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_transport_is_ib(device))
+    if (!has_ipoib(device))
         return;
 
     dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
@@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
     }
 
     for (p = s; p <= e; ++p) {
-        if (!rdma_port_ll_is_ib(device, p))
+        if (!cap_ipoib(device, p))
             continue;
         dev = ipoib_add_port("ib%d", device, p);
         if (!IS_ERR(dev)) {
@@ -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_transport_is_ib(device))
+    if (!has_ipoib(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 0ef9cd7..eead588 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1849,6 +1849,19 @@ static inline int has_iwarp(struct ib_device *device)
 }
 
 /**
+ * has_ipoib - Check if a device support IP over Infiniband.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * IP over Infiniband.
+ */
+static inline int has_ipoib(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1893,6 +1906,21 @@ static inline int cap_mcast(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_ipoib - Check if the port of device has the capability
+ * IP over Infiniband.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * IP over Infiniband.
+ */
+static inline int cap_ipoib(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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 15:48   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:48 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


Introduce helper has_ipoib() and cap_ipoib() to help us check if an
IB device or it's port support IP over Infiniband.

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/ulp/ipoib/ipoib_main.c |  6 +++---
 include/rdma/ib_verbs.h                   | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 3341754..fcd7558 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_transport_is_ib(device))
+    if (!has_ipoib(device))
         return;
 
     dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
@@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
     }
 
     for (p = s; p <= e; ++p) {
-        if (!rdma_port_ll_is_ib(device, p))
+        if (!cap_ipoib(device, p))
             continue;
         dev = ipoib_add_port("ib%d", device, p);
         if (!IS_ERR(dev)) {
@@ -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_transport_is_ib(device))
+    if (!has_ipoib(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 0ef9cd7..eead588 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1849,6 +1849,19 @@ static inline int has_iwarp(struct ib_device *device)
 }
 
 /**
+ * has_ipoib - Check if a device support IP over Infiniband.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * IP over Infiniband.
+ */
+static inline int has_ipoib(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1893,6 +1906,21 @@ static inline int cap_mcast(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_ipoib - Check if the port of device has the capability
+ * IP over Infiniband.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * IP over Infiniband.
+ */
+static inline int cap_ipoib(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


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 15:48   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:48 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


Introduce helper has_ipoib() and cap_ipoib() to help us check if an
IB device or it's port support IP over Infiniband.

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/ulp/ipoib/ipoib_main.c |  6 +++---
 include/rdma/ib_verbs.h                   | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 3341754..fcd7558 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_transport_is_ib(device))
+    if (!has_ipoib(device))
         return;
 
     dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
@@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
     }
 
     for (p = s; p <= e; ++p) {
-        if (!rdma_port_ll_is_ib(device, p))
+        if (!cap_ipoib(device, p))
             continue;
         dev = ipoib_add_port("ib%d", device, p);
         if (!IS_ERR(dev)) {
@@ -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_transport_is_ib(device))
+    if (!has_ipoib(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 0ef9cd7..eead588 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1849,6 +1849,19 @@ static inline int has_iwarp(struct ib_device *device)
 }
 
 /**
+ * has_ipoib - Check if a device support IP over Infiniband.
+ *
+ * @device: Device to be checked
+ *
+ * Return 0 when a device has none port to support
+ * IP over Infiniband.
+ */
+static inline int has_ipoib(struct ib_device *device)
+{
+    return rdma_transport_is_ib(device);
+}
+
+/**
  * cap_smi - Check if the port of device has the capability
  * Subnet Management Interface.
  *
@@ -1893,6 +1906,21 @@ static inline int cap_mcast(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * cap_ipoib - Check if the port of device has the capability
+ * IP over Infiniband.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support
+ * IP over Infiniband.
+ */
+static inline int cap_ipoib(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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 10/11] IB/Verbs: Use management helper cap_ib() for ib-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:49   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:49 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


TODO:
    We need to classify these check into the management helper.

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/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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 10/11] IB/Verbs: Use management helper cap_ib() for ib-check
@ 2015-03-27 15:49   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:49 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


TODO:
    We need to classify these check into the management helper.

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/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


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 10/11] IB/Verbs: Use management helper cap_ib() for ib-check
@ 2015-03-27 15:49   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:49 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


TODO:
    We need to classify these check into the management helper.

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/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

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 11/11] IB/Verbs: Use management helper cap_eth() for eth-check
  2015-03-27 15:39 ` Michael Wang
  (?)
@ 2015-03-27 15:49   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:49 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


TODO:
    We need to classify these check into the management helper.

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/cma.c        |  2 +-
 drivers/infiniband/core/sa_query.c   |  2 +-
 drivers/infiniband/core/verbs.c      |  4 ++--
 drivers/infiniband/hw/mlx4/ah.c      |  2 +-
 drivers/infiniband/hw/mlx4/cq.c      |  2 +-
 drivers/infiniband/hw/mlx4/mad.c     |  2 +-
 drivers/infiniband/hw/mlx4/main.c    |  2 +-
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  2 +-
 drivers/infiniband/hw/mlx4/qp.c      | 15 +++++++--------
 drivers/infiniband/hw/mlx4/sysfs.c   |  4 ++--
 include/rdma/ib_verbs.h              |  8 ++++++++
 11 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 1f68816..8b9386b6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -632,7 +632,7 @@ static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
         goto out;
 
     if (has_cm(id_priv->cma_dev->device) &&
-        rdma_port_ll_is_eth(id_priv->id.device, id_priv->id.port_num)) {
+        cap_eth(id_priv->id.device, id_priv->id.port_num)) {
         ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
 
         if (ret)
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 89c27da..7b32c47 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
     ah_attr->port_num = port_num;
     ah_attr->static_rate = rec->rate;
 
-    force_grh = rdma_port_ll_is_eth(device, port_num);
+    force_grh = cap_eth(device, port_num);
 
     if (rec->hop_limit > 1 || force_grh) {
         ah_attr->ah_flags = IB_AH_GRH;
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index d8d015a..4944460 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -198,7 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
     u32 flow_class;
     u16 gid_index;
     int ret;
-    int is_eth = (rdma_port_ll_is_eth(device, port_num));
+    int is_eth = cap_eth(device, port_num);
 
     memset(ah_attr, 0, sizeof *ah_attr);
     if (is_eth) {
@@ -870,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
     union ib_gid  sgid;
 
     if ((*qp_attr_mask & IB_QP_AV)  &&
-        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
+        (cap_eth(qp->device, qp_attr->ah_attr.port_num))) {
         ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
                    qp_attr->ah_attr.grh.sgid_index, &sgid);
         if (ret)
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index 829eb60..c314c2d 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
     if (!ah)
         return ERR_PTR(-ENOMEM);
 
-    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
+    if (cap_eth(pd->device, ah_attr->port_num)) {
         if (!(ah_attr->ah_flags & IB_AH_GRH)) {
             ret = ERR_PTR(-EINVAL);
         } else {
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 0417f03..01922a9 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -789,7 +789,7 @@ repoll:
             break;
         }
 
-        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
+        is_eth = cap_eth(wc->qp->device, (*cur_qp)->port);
         if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
             if ((*cur_qp)->mlx4_ib_qp_type &
                 (MLX4_IB_QPT_PROXY_SMI_OWNER |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 2a867fd..f544325 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -606,7 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
     int err;
     int slave;
     u8 *slave_id;
-    int is_eth = rdma_port_ll_is_eth(ibdev, port);
+    int is_eth = cap_eth(ibdev, port);
 
     if (is_eth) {
         if (!(wc->wc_flags & IB_WC_GRH)) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 1acc1c1..b007510 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1801,7 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
     int err = 0;
 
     for (i = 1; i <= ibdev->num_ports; ++i) {
-        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
+        if (cap_eth(&ibdev->ib_dev, i)) {
             err = reset_gid_table(ibdev, i);
             if (err)
                 goto out;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 1befeb8..6958ffc 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
 {
     u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
 
-    if (rdma_port_ll_is_eth(ah->ibah.device, port))
+    if (cap_eth(ah->ibah.device, port))
         return true;
 
     return !!(ah->av.ib.g_slid & 0x80);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index bd2f557..4d8172b 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1248,7 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
               u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
               struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
 {
-    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
+    int is_eth = cap_eth(&dev->ib_dev, port);
     int vidx;
     int smac_index;
     int err;
@@ -1431,8 +1431,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     int err = -EINVAL;
 
     /* APM is not supported under RoCE */
-    if (attr_mask & IB_QP_ALT_PATH &&
-        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
+    if (attr_mask & IB_QP_ALT_PATH && cap_eth(&dev->ib_dev, qp->port))
         return -ENOTSUPP;
 
     context = kzalloc(sizeof *context, GFP_KERNEL);
@@ -1662,7 +1661,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
                 context->pri_path.fl = 0x80;
             context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
         }
-        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
+        if (cap_eth(&dev->ib_dev, qp->port)) {
             if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
                 qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
                 context->pri_path.feup = 1 << 7; /* don't fsm */
@@ -1692,7 +1691,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     }
 
     if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
-        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
+        int is_eth = cap_eth(&dev->ib_dev, qp->port);
         if (is_eth) {
             context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
             optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
@@ -1922,7 +1921,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
     }
 
     if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
-        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
+        !cap_eth(&dev->ib_dev, attr->port_num))
         goto out;
 
     if (attr_mask & IB_QP_PKEY_INDEX) {
@@ -2126,7 +2125,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
     for (i = 0; i < wr->num_sge; ++i)
         send_size += wr->sg_list[i].length;
 
-    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
+    is_eth = cap_eth(sqp->qp.ibqp.device, sqp->qp.port);
     is_grh = mlx4_ib_ah_grh_present(ah);
     if (is_eth) {
         if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
@@ -3023,7 +3022,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
     if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
         return;
 
-    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
+    is_eth = cap_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
     if (is_eth)
         ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
         ((path->sched_queue & 4) << 1);
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index d339b55..83e0cf3 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -610,7 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
 
 static int add_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
+    int is_eth = cap_eth(&p->dev->ib_dev, p->port_num);
     int ret;
 
     /* do not display entries if eth transport, or if master */
@@ -644,7 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
 
 static void remove_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
+    int is_eth = cap_eth(&p->dev->ib_dev, p->port_num);
 
     if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
         return;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index deeaa52..e4a4b21 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1929,6 +1929,14 @@ static inline int cap_ib(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * TO BE CLASSIFIED
+ */
+static inline int cap_eth(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_ll_is_eth(device, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 11/11] IB/Verbs: Use management helper cap_eth() for eth-check
@ 2015-03-27 15:49   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:49 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn, Steve Wise,
	Tom Tucker, Chuck Lever, Michael Wang


TODO:
    We need to classify these check into the management helper.

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/cma.c        |  2 +-
 drivers/infiniband/core/sa_query.c   |  2 +-
 drivers/infiniband/core/verbs.c      |  4 ++--
 drivers/infiniband/hw/mlx4/ah.c      |  2 +-
 drivers/infiniband/hw/mlx4/cq.c      |  2 +-
 drivers/infiniband/hw/mlx4/mad.c     |  2 +-
 drivers/infiniband/hw/mlx4/main.c    |  2 +-
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  2 +-
 drivers/infiniband/hw/mlx4/qp.c      | 15 +++++++--------
 drivers/infiniband/hw/mlx4/sysfs.c   |  4 ++--
 include/rdma/ib_verbs.h              |  8 ++++++++
 11 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 1f68816..8b9386b6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -632,7 +632,7 @@ static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
         goto out;
 
     if (has_cm(id_priv->cma_dev->device) &&
-        rdma_port_ll_is_eth(id_priv->id.device, id_priv->id.port_num)) {
+        cap_eth(id_priv->id.device, id_priv->id.port_num)) {
         ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
 
         if (ret)
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 89c27da..7b32c47 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
     ah_attr->port_num = port_num;
     ah_attr->static_rate = rec->rate;
 
-    force_grh = rdma_port_ll_is_eth(device, port_num);
+    force_grh = cap_eth(device, port_num);
 
     if (rec->hop_limit > 1 || force_grh) {
         ah_attr->ah_flags = IB_AH_GRH;
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index d8d015a..4944460 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -198,7 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
     u32 flow_class;
     u16 gid_index;
     int ret;
-    int is_eth = (rdma_port_ll_is_eth(device, port_num));
+    int is_eth = cap_eth(device, port_num);
 
     memset(ah_attr, 0, sizeof *ah_attr);
     if (is_eth) {
@@ -870,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
     union ib_gid  sgid;
 
     if ((*qp_attr_mask & IB_QP_AV)  &&
-        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
+        (cap_eth(qp->device, qp_attr->ah_attr.port_num))) {
         ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
                    qp_attr->ah_attr.grh.sgid_index, &sgid);
         if (ret)
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index 829eb60..c314c2d 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
     if (!ah)
         return ERR_PTR(-ENOMEM);
 
-    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
+    if (cap_eth(pd->device, ah_attr->port_num)) {
         if (!(ah_attr->ah_flags & IB_AH_GRH)) {
             ret = ERR_PTR(-EINVAL);
         } else {
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 0417f03..01922a9 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -789,7 +789,7 @@ repoll:
             break;
         }
 
-        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
+        is_eth = cap_eth(wc->qp->device, (*cur_qp)->port);
         if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
             if ((*cur_qp)->mlx4_ib_qp_type &
                 (MLX4_IB_QPT_PROXY_SMI_OWNER |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 2a867fd..f544325 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -606,7 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
     int err;
     int slave;
     u8 *slave_id;
-    int is_eth = rdma_port_ll_is_eth(ibdev, port);
+    int is_eth = cap_eth(ibdev, port);
 
     if (is_eth) {
         if (!(wc->wc_flags & IB_WC_GRH)) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 1acc1c1..b007510 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1801,7 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
     int err = 0;
 
     for (i = 1; i <= ibdev->num_ports; ++i) {
-        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
+        if (cap_eth(&ibdev->ib_dev, i)) {
             err = reset_gid_table(ibdev, i);
             if (err)
                 goto out;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 1befeb8..6958ffc 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
 {
     u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
 
-    if (rdma_port_ll_is_eth(ah->ibah.device, port))
+    if (cap_eth(ah->ibah.device, port))
         return true;
 
     return !!(ah->av.ib.g_slid & 0x80);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index bd2f557..4d8172b 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1248,7 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
               u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
               struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
 {
-    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
+    int is_eth = cap_eth(&dev->ib_dev, port);
     int vidx;
     int smac_index;
     int err;
@@ -1431,8 +1431,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     int err = -EINVAL;
 
     /* APM is not supported under RoCE */
-    if (attr_mask & IB_QP_ALT_PATH &&
-        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
+    if (attr_mask & IB_QP_ALT_PATH && cap_eth(&dev->ib_dev, qp->port))
         return -ENOTSUPP;
 
     context = kzalloc(sizeof *context, GFP_KERNEL);
@@ -1662,7 +1661,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
                 context->pri_path.fl = 0x80;
             context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
         }
-        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
+        if (cap_eth(&dev->ib_dev, qp->port)) {
             if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
                 qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
                 context->pri_path.feup = 1 << 7; /* don't fsm */
@@ -1692,7 +1691,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     }
 
     if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
-        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
+        int is_eth = cap_eth(&dev->ib_dev, qp->port);
         if (is_eth) {
             context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
             optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
@@ -1922,7 +1921,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
     }
 
     if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
-        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
+        !cap_eth(&dev->ib_dev, attr->port_num))
         goto out;
 
     if (attr_mask & IB_QP_PKEY_INDEX) {
@@ -2126,7 +2125,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
     for (i = 0; i < wr->num_sge; ++i)
         send_size += wr->sg_list[i].length;
 
-    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
+    is_eth = cap_eth(sqp->qp.ibqp.device, sqp->qp.port);
     is_grh = mlx4_ib_ah_grh_present(ah);
     if (is_eth) {
         if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
@@ -3023,7 +3022,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
     if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
         return;
 
-    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
+    is_eth = cap_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
     if (is_eth)
         ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
         ((path->sched_queue & 4) << 1);
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index d339b55..83e0cf3 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -610,7 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
 
 static int add_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
+    int is_eth = cap_eth(&p->dev->ib_dev, p->port_num);
     int ret;
 
     /* do not display entries if eth transport, or if master */
@@ -644,7 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
 
 static void remove_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
+    int is_eth = cap_eth(&p->dev->ib_dev, p->port_num);
 
     if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
         return;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index deeaa52..e4a4b21 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1929,6 +1929,14 @@ static inline int cap_ib(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * TO BE CLASSIFIED
+ */
+static inline int cap_eth(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_ll_is_eth(device, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
-- 
2.1.0


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [RFC PATCH 11/11] IB/Verbs: Use management helper cap_eth() for eth-check
@ 2015-03-27 15:49   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 15:49 UTC (permalink / raw)
  To: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev
  Cc: J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford, Eric Dumazet, Erez Shitrit, Sagi Grimberg,
	Haggai Eran, Shachar Raindel, Mike Marciniszyn


TODO:
    We need to classify these check into the management helper.

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/cma.c        |  2 +-
 drivers/infiniband/core/sa_query.c   |  2 +-
 drivers/infiniband/core/verbs.c      |  4 ++--
 drivers/infiniband/hw/mlx4/ah.c      |  2 +-
 drivers/infiniband/hw/mlx4/cq.c      |  2 +-
 drivers/infiniband/hw/mlx4/mad.c     |  2 +-
 drivers/infiniband/hw/mlx4/main.c    |  2 +-
 drivers/infiniband/hw/mlx4/mlx4_ib.h |  2 +-
 drivers/infiniband/hw/mlx4/qp.c      | 15 +++++++--------
 drivers/infiniband/hw/mlx4/sysfs.c   |  4 ++--
 include/rdma/ib_verbs.h              |  8 ++++++++
 11 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 1f68816..8b9386b6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -632,7 +632,7 @@ static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
         goto out;
 
     if (has_cm(id_priv->cma_dev->device) &&
-        rdma_port_ll_is_eth(id_priv->id.device, id_priv->id.port_num)) {
+        cap_eth(id_priv->id.device, id_priv->id.port_num)) {
         ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
 
         if (ret)
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 89c27da..7b32c47 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
     ah_attr->port_num = port_num;
     ah_attr->static_rate = rec->rate;
 
-    force_grh = rdma_port_ll_is_eth(device, port_num);
+    force_grh = cap_eth(device, port_num);
 
     if (rec->hop_limit > 1 || force_grh) {
         ah_attr->ah_flags = IB_AH_GRH;
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index d8d015a..4944460 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -198,7 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
     u32 flow_class;
     u16 gid_index;
     int ret;
-    int is_eth = (rdma_port_ll_is_eth(device, port_num));
+    int is_eth = cap_eth(device, port_num);
 
     memset(ah_attr, 0, sizeof *ah_attr);
     if (is_eth) {
@@ -870,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
     union ib_gid  sgid;
 
     if ((*qp_attr_mask & IB_QP_AV)  &&
-        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
+        (cap_eth(qp->device, qp_attr->ah_attr.port_num))) {
         ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
                    qp_attr->ah_attr.grh.sgid_index, &sgid);
         if (ret)
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index 829eb60..c314c2d 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
     if (!ah)
         return ERR_PTR(-ENOMEM);
 
-    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
+    if (cap_eth(pd->device, ah_attr->port_num)) {
         if (!(ah_attr->ah_flags & IB_AH_GRH)) {
             ret = ERR_PTR(-EINVAL);
         } else {
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 0417f03..01922a9 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -789,7 +789,7 @@ repoll:
             break;
         }
 
-        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
+        is_eth = cap_eth(wc->qp->device, (*cur_qp)->port);
         if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
             if ((*cur_qp)->mlx4_ib_qp_type &
                 (MLX4_IB_QPT_PROXY_SMI_OWNER |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 2a867fd..f544325 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -606,7 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
     int err;
     int slave;
     u8 *slave_id;
-    int is_eth = rdma_port_ll_is_eth(ibdev, port);
+    int is_eth = cap_eth(ibdev, port);
 
     if (is_eth) {
         if (!(wc->wc_flags & IB_WC_GRH)) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 1acc1c1..b007510 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1801,7 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
     int err = 0;
 
     for (i = 1; i <= ibdev->num_ports; ++i) {
-        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
+        if (cap_eth(&ibdev->ib_dev, i)) {
             err = reset_gid_table(ibdev, i);
             if (err)
                 goto out;
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 1befeb8..6958ffc 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
 {
     u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
 
-    if (rdma_port_ll_is_eth(ah->ibah.device, port))
+    if (cap_eth(ah->ibah.device, port))
         return true;
 
     return !!(ah->av.ib.g_slid & 0x80);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index bd2f557..4d8172b 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1248,7 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
               u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
               struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
 {
-    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
+    int is_eth = cap_eth(&dev->ib_dev, port);
     int vidx;
     int smac_index;
     int err;
@@ -1431,8 +1431,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     int err = -EINVAL;
 
     /* APM is not supported under RoCE */
-    if (attr_mask & IB_QP_ALT_PATH &&
-        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
+    if (attr_mask & IB_QP_ALT_PATH && cap_eth(&dev->ib_dev, qp->port))
         return -ENOTSUPP;
 
     context = kzalloc(sizeof *context, GFP_KERNEL);
@@ -1662,7 +1661,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
                 context->pri_path.fl = 0x80;
             context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
         }
-        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
+        if (cap_eth(&dev->ib_dev, qp->port)) {
             if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
                 qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
                 context->pri_path.feup = 1 << 7; /* don't fsm */
@@ -1692,7 +1691,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
     }
 
     if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
-        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
+        int is_eth = cap_eth(&dev->ib_dev, qp->port);
         if (is_eth) {
             context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
             optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
@@ -1922,7 +1921,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
     }
 
     if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
-        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
+        !cap_eth(&dev->ib_dev, attr->port_num))
         goto out;
 
     if (attr_mask & IB_QP_PKEY_INDEX) {
@@ -2126,7 +2125,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
     for (i = 0; i < wr->num_sge; ++i)
         send_size += wr->sg_list[i].length;
 
-    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
+    is_eth = cap_eth(sqp->qp.ibqp.device, sqp->qp.port);
     is_grh = mlx4_ib_ah_grh_present(ah);
     if (is_eth) {
         if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
@@ -3023,7 +3022,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
     if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
         return;
 
-    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
+    is_eth = cap_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
     if (is_eth)
         ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
         ((path->sched_queue & 4) << 1);
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index d339b55..83e0cf3 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -610,7 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
 
 static int add_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
+    int is_eth = cap_eth(&p->dev->ib_dev, p->port_num);
     int ret;
 
     /* do not display entries if eth transport, or if master */
@@ -644,7 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
 
 static void remove_vf_smi_entries(struct mlx4_port *p)
 {
-    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
+    int is_eth = cap_eth(&p->dev->ib_dev, p->port_num);
 
     if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
         return;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index deeaa52..e4a4b21 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1929,6 +1929,14 @@ static inline int cap_ib(struct ib_device *device, u8 port_num)
     return rdma_port_ll_is_ib(device, port_num);
 }
 
+/**
+ * TO BE CLASSIFIED
+ */
+static inline int cap_eth(struct ib_device *device, u8 port_num)
+{
+    return rdma_port_ll_is_eth(device, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
          u8 port_num, int index, union ib_gid *gid);
 
-- 
2.1.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
  2015-03-27 15:48   ` Michael Wang
  (?)
@ 2015-03-27 16:06     ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:06 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:48:22PM +0100, Michael Wang wrote:

> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 3341754..fcd7558 100644
> +++ 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_transport_is_ib(device))
> +    if (!has_ipoib(device))
>          return;

This is a good example of a test that doesn't really make sense, IPoIB
is certainly a port specific attribute.

>      dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>      }
>  
>      for (p = s; p <= e; ++p) {
> -        if (!rdma_port_ll_is_ib(device, p))
> +        if (!cap_ipoib(device, p))
>              continue;

And down here we test every port.

The routine should just test every port and do nothing if no ports
need IPoIB.

>          dev = ipoib_add_port("ib%d", device, p);
>          if (!IS_ERR(dev)) {
> @@ -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_transport_is_ib(device))
> +    if (!has_ipoib(device))
>          return;

This test should be made redundant by having ib_get_client_data return
null if ipoib_add_one didn't do anything. Maybe that already happens?

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 16:06     ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:06 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 04:48:22PM +0100, Michael Wang wrote:

> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 3341754..fcd7558 100644
> +++ 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_transport_is_ib(device))
> +    if (!has_ipoib(device))
>          return;

This is a good example of a test that doesn't really make sense, IPoIB
is certainly a port specific attribute.

>      dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>      }
>  
>      for (p = s; p <= e; ++p) {
> -        if (!rdma_port_ll_is_ib(device, p))
> +        if (!cap_ipoib(device, p))
>              continue;

And down here we test every port.

The routine should just test every port and do nothing if no ports
need IPoIB.

>          dev = ipoib_add_port("ib%d", device, p);
>          if (!IS_ERR(dev)) {
> @@ -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_transport_is_ib(device))
> +    if (!has_ipoib(device))
>          return;

This test should be made redundant by having ib_get_client_data return
null if ipoib_add_one didn't do anything. Maybe that already happens?

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 16:06     ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:06 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:48:22PM +0100, Michael Wang wrote:

> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 3341754..fcd7558 100644
> +++ 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_transport_is_ib(device))
> +    if (!has_ipoib(device))
>          return;

This is a good example of a test that doesn't really make sense, IPoIB
is certainly a port specific attribute.

>      dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>      }
>  
>      for (p = s; p <= e; ++p) {
> -        if (!rdma_port_ll_is_ib(device, p))
> +        if (!cap_ipoib(device, p))
>              continue;

And down here we test every port.

The routine should just test every port and do nothing if no ports
need IPoIB.

>          dev = ipoib_add_port("ib%d", device, p);
>          if (!IS_ERR(dev)) {
> @@ -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_transport_is_ib(device))
> +    if (!has_ipoib(device))
>          return;

This test should be made redundant by having ib_get_client_data return
null if ipoib_add_one didn't do anything. Maybe that already happens?

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 15:47   ` Michael Wang
  (?)
@ 2015-03-27 16:13     ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:13 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> 
> Introduce helper has_iwarp() to help us check if an IB device
> support IWARP protocol.

Should probably be !has_rdma_read_sges()

True if the device can handle more than one SGE entry on a RDMA READ
work request.

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 16:13     ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:13 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> 
> Introduce helper has_iwarp() to help us check if an IB device
> support IWARP protocol.

Should probably be !has_rdma_read_sges()

True if the device can handle more than one SGE entry on a RDMA READ
work request.

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 16:13     ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:13 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> 
> Introduce helper has_iwarp() to help us check if an IB device
> support IWARP protocol.

Should probably be !has_rdma_read_sges()

True if the device can handle more than one SGE entry on a RDMA READ
work request.

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
  2015-03-27 16:06     ` Jason Gunthorpe
  (?)
@ 2015-03-27 16:15         ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 16:15 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On 03/27/2015 05:06 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:48:22PM +0100, Michael Wang wrote:
>
>> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> index 3341754..fcd7558 100644
>> +++ 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_transport_is_ib(device))
>> +    if (!has_ipoib(device))
>>          return;
> This is a good example of a test that doesn't really make sense, IPoIB
> is certainly a port specific attribute.
According to my understanding, seems like the logical is:

    if 'device have no port need ipoib initialization'
            return
>
>>      dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
>> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>>      }
>>  
>>      for (p = s; p <= e; ++p) {
>> -        if (!rdma_port_ll_is_ib(device, p))
>> +        if (!cap_ipoib(device, p))
>>              continue;
> And down here we test every port.
>
> The routine should just test every port and do nothing if no ports
> need IPoIB.
And here since there are some initial work to do, it iterate all the
port to find out which one need to be initialized.

>
>>          dev = ipoib_add_port("ib%d", device, p);
>>          if (!IS_ERR(dev)) {
>> @@ -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_transport_is_ib(device))
>> +    if (!has_ipoib(device))
>>          return;
> This test should be made redundant by having ib_get_client_data return
> null if ipoib_add_one didn't do anything. Maybe that already happens?
Here if we have done nothing when add a device, then nothing
need to be cleanup when remove it.

I'm not sure if it's a good idea, but seems like the idea is use twice
check on different level to save some cycles?

Regards,
Michael Wang
>
> Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 16:15         ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 16:15 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On 03/27/2015 05:06 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:48:22PM +0100, Michael Wang wrote:
>
>> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> index 3341754..fcd7558 100644
>> +++ 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_transport_is_ib(device))
>> +    if (!has_ipoib(device))
>>          return;
> This is a good example of a test that doesn't really make sense, IPoIB
> is certainly a port specific attribute.
According to my understanding, seems like the logical is:

    if 'device have no port need ipoib initialization'
            return
>
>>      dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
>> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>>      }
>>  
>>      for (p = s; p <= e; ++p) {
>> -        if (!rdma_port_ll_is_ib(device, p))
>> +        if (!cap_ipoib(device, p))
>>              continue;
> And down here we test every port.
>
> The routine should just test every port and do nothing if no ports
> need IPoIB.
And here since there are some initial work to do, it iterate all the
port to find out which one need to be initialized.

>
>>          dev = ipoib_add_port("ib%d", device, p);
>>          if (!IS_ERR(dev)) {
>> @@ -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_transport_is_ib(device))
>> +    if (!has_ipoib(device))
>>          return;
> This test should be made redundant by having ib_get_client_data return
> null if ipoib_add_one didn't do anything. Maybe that already happens?
Here if we have done nothing when add a device, then nothing
need to be cleanup when remove it.

I'm not sure if it's a good idea, but seems like the idea is use twice
check on different level to save some cycles?

Regards,
Michael Wang
>
> Jason


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 16:15         ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 16:15 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On 03/27/2015 05:06 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:48:22PM +0100, Michael Wang wrote:
>
>> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> index 3341754..fcd7558 100644
>> +++ 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_transport_is_ib(device))
>> +    if (!has_ipoib(device))
>>          return;
> This is a good example of a test that doesn't really make sense, IPoIB
> is certainly a port specific attribute.
According to my understanding, seems like the logical is:

    if 'device have no port need ipoib initialization'
            return
>
>>      dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
>> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>>      }
>>  
>>      for (p = s; p <= e; ++p) {
>> -        if (!rdma_port_ll_is_ib(device, p))
>> +        if (!cap_ipoib(device, p))
>>              continue;
> And down here we test every port.
>
> The routine should just test every port and do nothing if no ports
> need IPoIB.
And here since there are some initial work to do, it iterate all the
port to find out which one need to be initialized.

>
>>          dev = ipoib_add_port("ib%d", device, p);
>>          if (!IS_ERR(dev)) {
>> @@ -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_transport_is_ib(device))
>> +    if (!has_ipoib(device))
>>          return;
> This test should be made redundant by having ib_get_client_data return
> null if ipoib_add_one didn't do anything. Maybe that already happens?
Here if we have done nothing when add a device, then nothing
need to be cleanup when remove it.

I'm not sure if it's a good idea, but seems like the idea is use twice
check on different level to save some cycles?

Regards,
Michael Wang
>
> Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 16:13     ` Jason Gunthorpe
  (?)
@ 2015-03-27 16:17         ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 16:17 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On 03/27/2015 05:13 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
>> Introduce helper has_iwarp() to help us check if an IB device
>> support IWARP protocol.
> Should probably be !has_rdma_read_sges()
>
> True if the device can handle more than one SGE entry on a RDMA READ
> work request.
Sounds better :-) will change it in next version.

Regards,
Michael Wang

>
> Jason

--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 16:17         ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 16:17 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On 03/27/2015 05:13 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
>> Introduce helper has_iwarp() to help us check if an IB device
>> support IWARP protocol.
> Should probably be !has_rdma_read_sges()
>
> True if the device can handle more than one SGE entry on a RDMA READ
> work request.
Sounds better :-) will change it in next version.

Regards,
Michael Wang

>
> Jason


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 16:17         ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-27 16:17 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On 03/27/2015 05:13 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
>> Introduce helper has_iwarp() to help us check if an IB device
>> support IWARP protocol.
> Should probably be !has_rdma_read_sges()
>
> True if the device can handle more than one SGE entry on a RDMA READ
> work request.
Sounds better :-) will change it in next version.

Regards,
Michael Wang

>
> Jason

--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 15:46     ` Michael Wang
  (?)
@ 2015-03-27 16:28         ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:28 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
> 
> Introduce helper has_mcast() and cap_mcast() to help us check if an
> IB device or it's port support Multicast.
> 
> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
>  drivers/infiniband/core/cma.c       |  2 +-
>  drivers/infiniband/core/multicast.c |  8 ++++----
>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>  3 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 276fb76..cbbc85b 100644
> +++ b/drivers/infiniband/core/cma.c
> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> +            if (has_mcast(id_priv->cma_dev->device)) {

This might make more sense as cap_ib_multicast / cap_ip_multicast

>                  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/multicast.c b/drivers/infiniband/core/multicast.c
> index 17573ff..ffeaf27 100644
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> +    if (!cap_mcast(dev->device, event->element.port_num))
>          return;

These should probably be cap_ib_sa - that is what they are guarding
against.

But it seems redudent, since mcast_add_one will already not add a port that is
not IB, so mcast_event_handler is not callable. Something to do with
rocee/ib switching?

>      index = event->element.port_num - dev->start_port;
> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>      int i;
>      int count = 0;
>  
> -    if (!rdma_transport_is_ib(device))
> +    if (!has_mcast(device))
>          return;

Again, this seems redundant, every port is tested directly below, why
is this check needed?

Looking at this, I do wonder how a port can dynamically change between
rocee and IB.. If the link value changes then mcast_remove_one will
not be a perfect reversal of mcast_add_one. Bug?

It feels necessary to understand what happens when a port dynamically
switches to ethernet on mlx hardware to validate these patches :(

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 16:28         ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:28 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
> 
> Introduce helper has_mcast() and cap_mcast() to help us check if an
> IB device or it's port support Multicast.
> 
> 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/cma.c       |  2 +-
>  drivers/infiniband/core/multicast.c |  8 ++++----
>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>  3 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 276fb76..cbbc85b 100644
> +++ b/drivers/infiniband/core/cma.c
> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> +            if (has_mcast(id_priv->cma_dev->device)) {

This might make more sense as cap_ib_multicast / cap_ip_multicast

>                  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/multicast.c b/drivers/infiniband/core/multicast.c
> index 17573ff..ffeaf27 100644
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> +    if (!cap_mcast(dev->device, event->element.port_num))
>          return;

These should probably be cap_ib_sa - that is what they are guarding
against.

But it seems redudent, since mcast_add_one will already not add a port that is
not IB, so mcast_event_handler is not callable. Something to do with
rocee/ib switching?

>      index = event->element.port_num - dev->start_port;
> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>      int i;
>      int count = 0;
>  
> -    if (!rdma_transport_is_ib(device))
> +    if (!has_mcast(device))
>          return;

Again, this seems redundant, every port is tested directly below, why
is this check needed?

Looking at this, I do wonder how a port can dynamically change between
rocee and IB.. If the link value changes then mcast_remove_one will
not be a perfect reversal of mcast_add_one. Bug?

It feels necessary to understand what happens when a port dynamically
switches to ethernet on mlx hardware to validate these patches :(

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 16:28         ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:28 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
> 
> Introduce helper has_mcast() and cap_mcast() to help us check if an
> IB device or it's port support Multicast.
> 
> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
>  drivers/infiniband/core/cma.c       |  2 +-
>  drivers/infiniband/core/multicast.c |  8 ++++----
>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>  3 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 276fb76..cbbc85b 100644
> +++ b/drivers/infiniband/core/cma.c
> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> +            if (has_mcast(id_priv->cma_dev->device)) {

This might make more sense as cap_ib_multicast / cap_ip_multicast

>                  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/multicast.c b/drivers/infiniband/core/multicast.c
> index 17573ff..ffeaf27 100644
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> +    if (!cap_mcast(dev->device, event->element.port_num))
>          return;

These should probably be cap_ib_sa - that is what they are guarding
against.

But it seems redudent, since mcast_add_one will already not add a port that is
not IB, so mcast_event_handler is not callable. Something to do with
rocee/ib switching?

>      index = event->element.port_num - dev->start_port;
> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>      int i;
>      int count = 0;
>  
> -    if (!rdma_transport_is_ib(device))
> +    if (!has_mcast(device))
>          return;

Again, this seems redundant, every port is tested directly below, why
is this check needed?

Looking at this, I do wonder how a port can dynamically change between
rocee and IB.. If the link value changes then mcast_remove_one will
not be a perfect reversal of mcast_add_one. Bug?

It feels necessary to understand what happens when a port dynamically
switches to ethernet on mlx hardware to validate these patches :(

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
  2015-03-27 15:44   ` Michael Wang
  (?)
@ 2015-03-27 16:32       ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:32 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:44:43PM +0100, Michael Wang wrote:
> 
> Introduce helper cap_smi() to help us check if the port of an
> IB device support Subnet Management Interface.

This and most of the others should be qualified with 'cap_ib_smi'
since we already know we will need 'cap_opa_smi' someday

Jason
--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
@ 2015-03-27 16:32       ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:32 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 04:44:43PM +0100, Michael Wang wrote:
> 
> Introduce helper cap_smi() to help us check if the port of an
> IB device support Subnet Management Interface.

This and most of the others should be qualified with 'cap_ib_smi'
since we already know we will need 'cap_opa_smi' someday

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
@ 2015-03-27 16:32       ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:32 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 04:44:43PM +0100, Michael Wang wrote:
> 
> Introduce helper cap_smi() to help us check if the port of an
> IB device support Subnet Management Interface.

This and most of the others should be qualified with 'cap_ib_smi'
since we already know we will need 'cap_opa_smi' someday

Jason
--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
  2015-03-27 16:15         ` Michael Wang
  (?)
@ 2015-03-27 16:38           ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:38 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 05:15:42PM +0100, Michael Wang wrote:

> I'm not sure if it's a good idea, but seems like the idea is use twice
> check on different level to save some cycles?

That is what it looks like to me, right now. Which is why I'd drop
it. This isn't performance sensitive, make it simple.

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 16:38           ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:38 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 05:15:42PM +0100, Michael Wang wrote:

> I'm not sure if it's a good idea, but seems like the idea is use twice
> check on different level to save some cycles?

That is what it looks like to me, right now. Which is why I'd drop
it. This isn't performance sensitive, make it simple.

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 09/11] IB/Verbs: Use management helper has_ipoib() and, cap_ipoib() for ipoib-check
@ 2015-03-27 16:38           ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 16:38 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 05:15:42PM +0100, Michael Wang wrote:

> I'm not sure if it's a good idea, but seems like the idea is use twice
> check on different level to save some cycles?

That is what it looks like to me, right now. Which is why I'd drop
it. This isn't performance sensitive, make it simple.

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
  2015-03-27 15:46     ` Michael Wang
  (?)
@ 2015-03-27 16:47       ` ira.weiny
  -1 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 16:47 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford

On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
> 
> Introduce helper has_sa() and cap_sa() to help us check if an IB device
> or it's port support Subnet Administrator.

I think these 2 should be combined.  The question is if a port requires the use
of the SA depending on the network it is connected to.

Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
the other?  Do they show up as 2 devices?

Regardless I think we should define the SA access on a per port basis.

> 
> 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/sa_query.c | 12 ++++++------
>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index d95d25f..89c27da 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> +        if (!cap_sa(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -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_transport_is_ib(device))
> +    if (!has_sa(device))

The logic here should be:

if (no ports of this device need sa access)
	return;

So why not eliminate this check and allow the cap_sa(s) to handle the support?

-- Ira

>          return;
>  
>      if (device->node_type == RDMA_NODE_IB_SWITCH)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (!rdma_port_ll_is_ib(device, i + 1))
> +        if (!cap_sa(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_ll_is_ib(device, i + 1)) {
> +        if (cap_sa(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0a63f8..fa8ffa3 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>  }
>  
>  /**
> + * has_sa - Check if a device support Subnet Administrator.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Subnet Administrator.
> + */
> +static inline int has_sa(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_sa - Check if the port of device has the capability
> + * Subnet Administrator.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Subnet Administrator.
> + */
> +static inline int cap_sa(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
> 

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 16:47       ` ira.weiny
  0 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 16:47 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
> 
> Introduce helper has_sa() and cap_sa() to help us check if an IB device
> or it's port support Subnet Administrator.

I think these 2 should be combined.  The question is if a port requires the use
of the SA depending on the network it is connected to.

Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
the other?  Do they show up as 2 devices?

Regardless I think we should define the SA access on a per port basis.

> 
> 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/sa_query.c | 12 ++++++------
>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index d95d25f..89c27da 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> +        if (!cap_sa(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -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_transport_is_ib(device))
> +    if (!has_sa(device))

The logic here should be:

if (no ports of this device need sa access)
	return;

So why not eliminate this check and allow the cap_sa(s) to handle the support?

-- Ira

>          return;
>  
>      if (device->node_type == RDMA_NODE_IB_SWITCH)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (!rdma_port_ll_is_ib(device, i + 1))
> +        if (!cap_sa(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_ll_is_ib(device, i + 1)) {
> +        if (cap_sa(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0a63f8..fa8ffa3 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>  }
>  
>  /**
> + * has_sa - Check if a device support Subnet Administrator.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Subnet Administrator.
> + */
> +static inline int has_sa(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_sa - Check if the port of device has the capability
> + * Subnet Administrator.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Subnet Administrator.
> + */
> +static inline int cap_sa(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
> 

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 16:47       ` ira.weiny
  0 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 16:47 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford

On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
> 
> Introduce helper has_sa() and cap_sa() to help us check if an IB device
> or it's port support Subnet Administrator.

I think these 2 should be combined.  The question is if a port requires the use
of the SA depending on the network it is connected to.

Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
the other?  Do they show up as 2 devices?

Regardless I think we should define the SA access on a per port basis.

> 
> 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/sa_query.c | 12 ++++++------
>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index d95d25f..89c27da 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> +        if (!cap_sa(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -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_transport_is_ib(device))
> +    if (!has_sa(device))

The logic here should be:

if (no ports of this device need sa access)
	return;

So why not eliminate this check and allow the cap_sa(s) to handle the support?

-- Ira

>          return;
>  
>      if (device->node_type == RDMA_NODE_IB_SWITCH)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (!rdma_port_ll_is_ib(device, i + 1))
> +        if (!cap_sa(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_ll_is_ib(device, i + 1)) {
> +        if (cap_sa(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0a63f8..fa8ffa3 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>  }
>  
>  /**
> + * has_sa - Check if a device support Subnet Administrator.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Subnet Administrator.
> + */
> +static inline int has_sa(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_sa - Check if the port of device has the capability
> + * Subnet Administrator.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Subnet Administrator.
> + */
> +static inline int cap_sa(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
> 

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
  2015-03-27 16:32       ` Jason Gunthorpe
  (?)
@ 2015-03-27 16:59           ` Yun Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 16:59 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak

Make sense to me if opa smi will be handled differently, will be
changed in next version :-)

Regards,
Michael Wang

On Fri, Mar 27, 2015 at 5:32 PM, Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote:
> On Fri, Mar 27, 2015 at 04:44:43PM +0100, Michael Wang wrote:
>>
>> Introduce helper cap_smi() to help us check if the port of an
>> IB device support Subnet Management Interface.
>
> This and most of the others should be qualified with 'cap_ib_smi'
> since we already know we will need 'cap_opa_smi' someday
>
> Jason
--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
@ 2015-03-27 16:59           ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 16:59 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

Make sense to me if opa smi will be handled differently, will be
changed in next version :-)

Regards,
Michael Wang

On Fri, Mar 27, 2015 at 5:32 PM, Jason Gunthorpe
<jgunthorpe@obsidianresearch.com> wrote:
> On Fri, Mar 27, 2015 at 04:44:43PM +0100, Michael Wang wrote:
>>
>> Introduce helper cap_smi() to help us check if the port of an
>> IB device support Subnet Management Interface.
>
> This and most of the others should be qualified with 'cap_ib_smi'
> since we already know we will need 'cap_opa_smi' someday
>
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 04/11] IB/Verbs: Use management helper cap_smi() for smi-check
@ 2015-03-27 16:59           ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 16:59 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak

Make sense to me if opa smi will be handled differently, will be
changed in next version :-)

Regards,
Michael Wang

On Fri, Mar 27, 2015 at 5:32 PM, Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote:
> On Fri, Mar 27, 2015 at 04:44:43PM +0100, Michael Wang wrote:
>>
>> Introduce helper cap_smi() to help us check if the port of an
>> IB device support Subnet Management Interface.
>
> This and most of the others should be qualified with 'cap_ib_smi'
> since we already know we will need 'cap_opa_smi' someday
>
> Jason
--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 16:28         ` Jason Gunthorpe
  (?)
@ 2015-03-27 17:05           ` ira.weiny
  -1 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 17:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 10:28:20AM -0600, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_mcast() and cap_mcast() to help us check if an
> > IB device or it's port support Multicast.
> > 
> > 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/cma.c       |  2 +-
> >  drivers/infiniband/core/multicast.c |  8 ++++----
> >  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
> >  3 files changed, 33 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> > index 276fb76..cbbc85b 100644
> > +++ b/drivers/infiniband/core/cma.c
> > @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> > +            if (has_mcast(id_priv->cma_dev->device)) {
> 
> This might make more sense as cap_ib_multicast / cap_ip_multicast

Agreed.

> 
> >                  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/multicast.c b/drivers/infiniband/core/multicast.c
> > index 17573ff..ffeaf27 100644
> > +++ b/drivers/infiniband/core/multicast.c
> > @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
> >      int index;
> >  
> >      dev = container_of(handler, struct mcast_device, event_handler);
> > -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> > +    if (!cap_mcast(dev->device, event->element.port_num))
> >          return;
> 
> These should probably be cap_ib_sa - that is what they are guarding
> against.
> 
> But it seems redudent, since mcast_add_one will already not add a port that is
> not IB, so mcast_event_handler is not callable. Something to do with
> rocee/ib switching?

I'm not sure about this either.  This check seems to be necessary only on a
per-port level.  It does seem apparent that one can't go from Eth to IB.  What
happens if you go from IB to Eth on the port?

> 
> >      index = event->element.port_num - dev->start_port;
> > @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
> >      int i;
> >      int count = 0;
> >  
> > -    if (!rdma_transport_is_ib(device))
> > +    if (!has_mcast(device))
> >          return;
> 
> Again, this seems redundant, every port is tested directly below, why
> is this check needed?

Agreed.  Same as my comments about the SA support.  This is really only
needed on ports which need to register with the SA (or perhaps some future
entity) for Mcast support.

Also this is part of the ib_sa module and exports the function
ib_sa_join_multicast.  So that this point it is covered under the
cap_sa(device, port) call.

So the implementation of cap_mcast at this point is:

cap_mcast(device, port)
{
	return cap_sa(device,port);
}

> 
> Looking at this, I do wonder how a port can dynamically change between
> rocee and IB.. If the link value changes then mcast_remove_one will
> not be a perfect reversal of mcast_add_one. Bug?
> 
> It feels necessary to understand what happens when a port dynamically
> switches to ethernet on mlx hardware to validate these patches :(

Agreed.

:-(

-- Ira

> 
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:05           ` ira.weiny
  0 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 17:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 10:28:20AM -0600, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_mcast() and cap_mcast() to help us check if an
> > IB device or it's port support Multicast.
> > 
> > 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/cma.c       |  2 +-
> >  drivers/infiniband/core/multicast.c |  8 ++++----
> >  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
> >  3 files changed, 33 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> > index 276fb76..cbbc85b 100644
> > +++ b/drivers/infiniband/core/cma.c
> > @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> > +            if (has_mcast(id_priv->cma_dev->device)) {
> 
> This might make more sense as cap_ib_multicast / cap_ip_multicast

Agreed.

> 
> >                  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/multicast.c b/drivers/infiniband/core/multicast.c
> > index 17573ff..ffeaf27 100644
> > +++ b/drivers/infiniband/core/multicast.c
> > @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
> >      int index;
> >  
> >      dev = container_of(handler, struct mcast_device, event_handler);
> > -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> > +    if (!cap_mcast(dev->device, event->element.port_num))
> >          return;
> 
> These should probably be cap_ib_sa - that is what they are guarding
> against.
> 
> But it seems redudent, since mcast_add_one will already not add a port that is
> not IB, so mcast_event_handler is not callable. Something to do with
> rocee/ib switching?

I'm not sure about this either.  This check seems to be necessary only on a
per-port level.  It does seem apparent that one can't go from Eth to IB.  What
happens if you go from IB to Eth on the port?

> 
> >      index = event->element.port_num - dev->start_port;
> > @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
> >      int i;
> >      int count = 0;
> >  
> > -    if (!rdma_transport_is_ib(device))
> > +    if (!has_mcast(device))
> >          return;
> 
> Again, this seems redundant, every port is tested directly below, why
> is this check needed?

Agreed.  Same as my comments about the SA support.  This is really only
needed on ports which need to register with the SA (or perhaps some future
entity) for Mcast support.

Also this is part of the ib_sa module and exports the function
ib_sa_join_multicast.  So that this point it is covered under the
cap_sa(device, port) call.

So the implementation of cap_mcast at this point is:

cap_mcast(device, port)
{
	return cap_sa(device,port);
}

> 
> Looking at this, I do wonder how a port can dynamically change between
> rocee and IB.. If the link value changes then mcast_remove_one will
> not be a perfect reversal of mcast_add_one. Bug?
> 
> It feels necessary to understand what happens when a port dynamically
> switches to ethernet on mlx hardware to validate these patches :(

Agreed.

:-(

-- Ira

> 
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:05           ` ira.weiny
  0 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 17:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 10:28:20AM -0600, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_mcast() and cap_mcast() to help us check if an
> > IB device or it's port support Multicast.
> > 
> > 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/cma.c       |  2 +-
> >  drivers/infiniband/core/multicast.c |  8 ++++----
> >  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
> >  3 files changed, 33 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> > index 276fb76..cbbc85b 100644
> > +++ b/drivers/infiniband/core/cma.c
> > @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> > +            if (has_mcast(id_priv->cma_dev->device)) {
> 
> This might make more sense as cap_ib_multicast / cap_ip_multicast

Agreed.

> 
> >                  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/multicast.c b/drivers/infiniband/core/multicast.c
> > index 17573ff..ffeaf27 100644
> > +++ b/drivers/infiniband/core/multicast.c
> > @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
> >      int index;
> >  
> >      dev = container_of(handler, struct mcast_device, event_handler);
> > -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> > +    if (!cap_mcast(dev->device, event->element.port_num))
> >          return;
> 
> These should probably be cap_ib_sa - that is what they are guarding
> against.
> 
> But it seems redudent, since mcast_add_one will already not add a port that is
> not IB, so mcast_event_handler is not callable. Something to do with
> rocee/ib switching?

I'm not sure about this either.  This check seems to be necessary only on a
per-port level.  It does seem apparent that one can't go from Eth to IB.  What
happens if you go from IB to Eth on the port?

> 
> >      index = event->element.port_num - dev->start_port;
> > @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
> >      int i;
> >      int count = 0;
> >  
> > -    if (!rdma_transport_is_ib(device))
> > +    if (!has_mcast(device))
> >          return;
> 
> Again, this seems redundant, every port is tested directly below, why
> is this check needed?

Agreed.  Same as my comments about the SA support.  This is really only
needed on ports which need to register with the SA (or perhaps some future
entity) for Mcast support.

Also this is part of the ib_sa module and exports the function
ib_sa_join_multicast.  So that this point it is covered under the
cap_sa(device, port) call.

So the implementation of cap_mcast at this point is:

cap_mcast(device, port)
{
	return cap_sa(device,port);
}

> 
> Looking at this, I do wonder how a port can dynamically change between
> rocee and IB.. If the link value changes then mcast_remove_one will
> not be a perfect reversal of mcast_add_one. Bug?
> 
> It feels necessary to understand what happens when a port dynamically
> switches to ethernet on mlx hardware to validate these patches :(

Agreed.

:-(

-- Ira

> 
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
  2015-03-27 16:47       ` ira.weiny
  (?)
@ 2015-03-27 17:13         ` Yun Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:13 UTC (permalink / raw)
  To: ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak

On Fri, Mar 27, 2015 at 5:47 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
>>
>> Introduce helper has_sa() and cap_sa() to help us check if an IB device
>> or it's port support Subnet Administrator.
>
> I think these 2 should be combined.  The question is if a port requires the use
> of the SA depending on the network it is connected to.
>
> Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
> the other?  Do they show up as 2 devices?

I'm not sure about this... but sounds like your opinion is same to
Jason on ipoib stuff, I'll do more investigation on that part, if it's
just for optimization, then we should be able to eliminate has_xx()
stuff :-) after all, init/exit is not a hot path.

>
> Regardless I think we should define the SA access on a per port basis.
>
>>
>> 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/sa_query.c | 12 ++++++------
>>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>>  2 files changed, 34 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
>> index d95d25f..89c27da 100644
>> --- a/drivers/infiniband/core/sa_query.c
>> +++ b/drivers/infiniband/core/sa_query.c
>> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>>          struct ib_sa_port *port =
>>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>>
>> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>> +        if (!cap_sa(handler->device, port->port_num))
>>              return;
>>
>>          spin_lock_irqsave(&port->ah_lock, flags);
>> @@ -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_transport_is_ib(device))
>> +    if (!has_sa(device))
>
> The logic here should be:
>
> if (no ports of this device need sa access)
>         return;
>
> So why not eliminate this check and allow the cap_sa(s) to handle the support?

I'll check if we could merge this part to the following iteration :-)

Regards,
Michael Wang

>
> -- Ira
>
>>          return;
>>
>>      if (device->node_type == RDMA_NODE_IB_SWITCH)
>> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>>
>>      for (i = 0; i <= e - s; ++i) {
>>          spin_lock_init(&sa_dev->port[i].ah_lock);
>> -        if (!rdma_port_ll_is_ib(device, i + 1))
>> +        if (!cap_sa(device, i + 1))
>>              continue;
>>
>>          sa_dev->port[i].sm_ah    = NULL;
>> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>>          goto err;
>>
>>      for (i = 0; i <= e - s; ++i)
>> -        if (rdma_port_ll_is_ib(device, i + 1))
>> +        if (cap_sa(device, i + 1))
>>              update_sm_ah(&sa_dev->port[i].update_task);
>>
>>      return;
>>
>>  err:
>>      while (--i >= 0)
>> -        if (rdma_port_ll_is_ib(device, i + 1))
>> +        if (cap_sa(device, i + 1))
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>
>>      kfree(sa_dev);
>> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>>      flush_workqueue(ib_wq);
>>
>>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
>> -        if (rdma_port_ll_is_ib(device, i + 1)) {
>> +        if (cap_sa(device, i + 1)) {
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>              if (sa_dev->port[i].sm_ah)
>>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index c0a63f8..fa8ffa3 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>>  }
>>
>>  /**
>> + * has_sa - Check if a device support Subnet Administrator.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * Subnet Administrator.
>> + */
>> +static inline int has_sa(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_ib(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>>      return rdma_port_ll_is_ib(device, port_num);
>>  }
>>
>> +/**
>> + * cap_sa - Check if the port of device has the capability
>> + * Subnet Administrator.
>> + *
>> + * @device: Device to be checked
>> + * @port_num: Port number of the device
>> + *
>> + * Return 0 when port of the device don't support
>> + * Subnet Administrator.
>> + */
>> +static inline int cap_sa(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
>>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 17:13         ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:13 UTC (permalink / raw)
  To: ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 5:47 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
>>
>> Introduce helper has_sa() and cap_sa() to help us check if an IB device
>> or it's port support Subnet Administrator.
>
> I think these 2 should be combined.  The question is if a port requires the use
> of the SA depending on the network it is connected to.
>
> Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
> the other?  Do they show up as 2 devices?

I'm not sure about this... but sounds like your opinion is same to
Jason on ipoib stuff, I'll do more investigation on that part, if it's
just for optimization, then we should be able to eliminate has_xx()
stuff :-) after all, init/exit is not a hot path.

>
> Regardless I think we should define the SA access on a per port basis.
>
>>
>> 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/sa_query.c | 12 ++++++------
>>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>>  2 files changed, 34 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
>> index d95d25f..89c27da 100644
>> --- a/drivers/infiniband/core/sa_query.c
>> +++ b/drivers/infiniband/core/sa_query.c
>> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>>          struct ib_sa_port *port =
>>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>>
>> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>> +        if (!cap_sa(handler->device, port->port_num))
>>              return;
>>
>>          spin_lock_irqsave(&port->ah_lock, flags);
>> @@ -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_transport_is_ib(device))
>> +    if (!has_sa(device))
>
> The logic here should be:
>
> if (no ports of this device need sa access)
>         return;
>
> So why not eliminate this check and allow the cap_sa(s) to handle the support?

I'll check if we could merge this part to the following iteration :-)

Regards,
Michael Wang

>
> -- Ira
>
>>          return;
>>
>>      if (device->node_type == RDMA_NODE_IB_SWITCH)
>> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>>
>>      for (i = 0; i <= e - s; ++i) {
>>          spin_lock_init(&sa_dev->port[i].ah_lock);
>> -        if (!rdma_port_ll_is_ib(device, i + 1))
>> +        if (!cap_sa(device, i + 1))
>>              continue;
>>
>>          sa_dev->port[i].sm_ah    = NULL;
>> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>>          goto err;
>>
>>      for (i = 0; i <= e - s; ++i)
>> -        if (rdma_port_ll_is_ib(device, i + 1))
>> +        if (cap_sa(device, i + 1))
>>              update_sm_ah(&sa_dev->port[i].update_task);
>>
>>      return;
>>
>>  err:
>>      while (--i >= 0)
>> -        if (rdma_port_ll_is_ib(device, i + 1))
>> +        if (cap_sa(device, i + 1))
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>
>>      kfree(sa_dev);
>> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>>      flush_workqueue(ib_wq);
>>
>>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
>> -        if (rdma_port_ll_is_ib(device, i + 1)) {
>> +        if (cap_sa(device, i + 1)) {
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>              if (sa_dev->port[i].sm_ah)
>>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index c0a63f8..fa8ffa3 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>>  }
>>
>>  /**
>> + * has_sa - Check if a device support Subnet Administrator.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * Subnet Administrator.
>> + */
>> +static inline int has_sa(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_ib(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>>      return rdma_port_ll_is_ib(device, port_num);
>>  }
>>
>> +/**
>> + * cap_sa - Check if the port of device has the capability
>> + * Subnet Administrator.
>> + *
>> + * @device: Device to be checked
>> + * @port_num: Port number of the device
>> + *
>> + * Return 0 when port of the device don't support
>> + * Subnet Administrator.
>> + */
>> +static inline int cap_sa(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
>>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 17:13         ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:13 UTC (permalink / raw)
  To: ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 5:47 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
>>
>> Introduce helper has_sa() and cap_sa() to help us check if an IB device
>> or it's port support Subnet Administrator.
>
> I think these 2 should be combined.  The question is if a port requires the use
> of the SA depending on the network it is connected to.
>
> Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
> the other?  Do they show up as 2 devices?

I'm not sure about this... but sounds like your opinion is same to
Jason on ipoib stuff, I'll do more investigation on that part, if it's
just for optimization, then we should be able to eliminate has_xx()
stuff :-) after all, init/exit is not a hot path.

>
> Regardless I think we should define the SA access on a per port basis.
>
>>
>> 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/sa_query.c | 12 ++++++------
>>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>>  2 files changed, 34 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
>> index d95d25f..89c27da 100644
>> --- a/drivers/infiniband/core/sa_query.c
>> +++ b/drivers/infiniband/core/sa_query.c
>> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>>          struct ib_sa_port *port =
>>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>>
>> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>> +        if (!cap_sa(handler->device, port->port_num))
>>              return;
>>
>>          spin_lock_irqsave(&port->ah_lock, flags);
>> @@ -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_transport_is_ib(device))
>> +    if (!has_sa(device))
>
> The logic here should be:
>
> if (no ports of this device need sa access)
>         return;
>
> So why not eliminate this check and allow the cap_sa(s) to handle the support?

I'll check if we could merge this part to the following iteration :-)

Regards,
Michael Wang

>
> -- Ira
>
>>          return;
>>
>>      if (device->node_type == RDMA_NODE_IB_SWITCH)
>> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>>
>>      for (i = 0; i <= e - s; ++i) {
>>          spin_lock_init(&sa_dev->port[i].ah_lock);
>> -        if (!rdma_port_ll_is_ib(device, i + 1))
>> +        if (!cap_sa(device, i + 1))
>>              continue;
>>
>>          sa_dev->port[i].sm_ah    = NULL;
>> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>>          goto err;
>>
>>      for (i = 0; i <= e - s; ++i)
>> -        if (rdma_port_ll_is_ib(device, i + 1))
>> +        if (cap_sa(device, i + 1))
>>              update_sm_ah(&sa_dev->port[i].update_task);
>>
>>      return;
>>
>>  err:
>>      while (--i >= 0)
>> -        if (rdma_port_ll_is_ib(device, i + 1))
>> +        if (cap_sa(device, i + 1))
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>
>>      kfree(sa_dev);
>> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>>      flush_workqueue(ib_wq);
>>
>>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
>> -        if (rdma_port_ll_is_ib(device, i + 1)) {
>> +        if (cap_sa(device, i + 1)) {
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>              if (sa_dev->port[i].sm_ah)
>>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index c0a63f8..fa8ffa3 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>>  }
>>
>>  /**
>> + * has_sa - Check if a device support Subnet Administrator.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * Subnet Administrator.
>> + */
>> +static inline int has_sa(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_ib(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>>      return rdma_port_ll_is_ib(device, port_num);
>>  }
>>
>> +/**
>> + * cap_sa - Check if the port of device has the capability
>> + * Subnet Administrator.
>> + *
>> + * @device: Device to be checked
>> + * @port_num: Port number of the device
>> + *
>> + * Return 0 when port of the device don't support
>> + * Subnet Administrator.
>> + */
>> +static inline int cap_sa(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
>>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 16:13     ` Jason Gunthorpe
  (?)
@ 2015-03-27 17:16       ` ira.weiny
  -1 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 17:16 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_iwarp() to help us check if an IB device
> > support IWARP protocol.
> 
> Should probably be !has_rdma_read_sges()
> 
> True if the device can handle more than one SGE entry on a RDMA READ
> work request.

Isn't this value already provided by the query_device verb?

The verbs spec states the Query HCA contains the:

"Maximum number of scatter/gather entries per Work Request supported by the
HCA."

-- Ira

> 
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 17:16       ` ira.weiny
  0 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 17:16 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_iwarp() to help us check if an IB device
> > support IWARP protocol.
> 
> Should probably be !has_rdma_read_sges()
> 
> True if the device can handle more than one SGE entry on a RDMA READ
> work request.

Isn't this value already provided by the query_device verb?

The verbs spec states the Query HCA contains the:

"Maximum number of scatter/gather entries per Work Request supported by the
HCA."

-- Ira

> 
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 17:16       ` ira.weiny
  0 siblings, 0 replies; 189+ messages in thread
From: ira.weiny @ 2015-03-27 17:16 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_iwarp() to help us check if an IB device
> > support IWARP protocol.
> 
> Should probably be !has_rdma_read_sges()
> 
> True if the device can handle more than one SGE entry on a RDMA READ
> work request.

Isn't this value already provided by the query_device verb?

The verbs spec states the Query HCA contains the:

"Maximum number of scatter/gather entries per Work Request supported by the
HCA."

-- Ira

> 
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 17:16       ` ira.weiny
  (?)
@ 2015-03-27 17:29         ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:29 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 01:16:31PM -0400, ira.weiny wrote:
> On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
> > On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> > > 
> > > Introduce helper has_iwarp() to help us check if an IB device
> > > support IWARP protocol.
> > 
> > Should probably be !has_rdma_read_sges()
> > 
> > True if the device can handle more than one SGE entry on a RDMA READ
> > work request.
> 
> Isn't this value already provided by the query_device verb?
> 
> The verbs spec states the Query HCA contains the:
> 
> "Maximum number of scatter/gather entries per Work Request supported by the
> HCA."

http://www.spinics.net/lists/linux-rdma/msg22565.html

''Unlike IB, the iWARP protocol only allows 1 target/sink SGE in an
rdma read''

It is one of those annoying verbs is different on iWarp things.

So the max sge in the query_verbs must only apply to send/rdma write
on iWarp?

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 17:29         ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:29 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 01:16:31PM -0400, ira.weiny wrote:
> On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
> > On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> > > 
> > > Introduce helper has_iwarp() to help us check if an IB device
> > > support IWARP protocol.
> > 
> > Should probably be !has_rdma_read_sges()
> > 
> > True if the device can handle more than one SGE entry on a RDMA READ
> > work request.
> 
> Isn't this value already provided by the query_device verb?
> 
> The verbs spec states the Query HCA contains the:
> 
> "Maximum number of scatter/gather entries per Work Request supported by the
> HCA."

http://www.spinics.net/lists/linux-rdma/msg22565.html

''Unlike IB, the iWARP protocol only allows 1 target/sink SGE in an
rdma read''

It is one of those annoying verbs is different on iWarp things.

So the max sge in the query_verbs must only apply to send/rdma write
on iWarp?

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 17:29         ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:29 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 01:16:31PM -0400, ira.weiny wrote:
> On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
> > On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
> > > 
> > > Introduce helper has_iwarp() to help us check if an IB device
> > > support IWARP protocol.
> > 
> > Should probably be !has_rdma_read_sges()
> > 
> > True if the device can handle more than one SGE entry on a RDMA READ
> > work request.
> 
> Isn't this value already provided by the query_device verb?
> 
> The verbs spec states the Query HCA contains the:
> 
> "Maximum number of scatter/gather entries per Work Request supported by the
> HCA."

http://www.spinics.net/lists/linux-rdma/msg22565.html

''Unlike IB, the iWARP protocol only allows 1 target/sink SGE in an
rdma read''

It is one of those annoying verbs is different on iWarp things.

So the max sge in the query_verbs must only apply to send/rdma write
on iWarp?

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 17:05           ` ira.weiny
  (?)
@ 2015-03-27 17:31               ` Yun Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:31 UTC (permalink / raw)
  To: ira.weiny
  Cc: Jason Gunthorpe, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina

On Fri, Mar 27, 2015 at 6:05 PM, ira.weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> On Fri, Mar 27, 2015 at 10:28:20AM -0600, Jason Gunthorpe wrote:
>> On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
>> >
[snip]
>> > -            if (rdma_transport_is_ib(id_priv->cma_dev->device)) {
>> > +            if (has_mcast(id_priv->cma_dev->device)) {
>>
>> This might make more sense as cap_ib_multicast / cap_ip_multicast
>
> Agreed.
>

Will be changed in next version :-)

>>
>> >                  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/multicast.c b/drivers/infiniband/core/multicast.c
>> > index 17573ff..ffeaf27 100644
>> > +++ b/drivers/infiniband/core/multicast.c
>> > @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>> >      int index;
>> >
>> >      dev = container_of(handler, struct mcast_device, event_handler);
>> > -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>> > +    if (!cap_mcast(dev->device, event->element.port_num))
>> >          return;
>>
>> These should probably be cap_ib_sa - that is what they are guarding
>> against.
>>
>> But it seems redudent, since mcast_add_one will already not add a port that is
>> not IB, so mcast_event_handler is not callable. Something to do with
>> rocee/ib switching?
>
> I'm not sure about this either.  This check seems to be necessary only on a
> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
> happens if you go from IB to Eth on the port?

I also feel it's redundant at first glance, but just not sure if it
could be removed, lack of some knowledge :-P

>
>>
>> >      index = event->element.port_num - dev->start_port;
>> > @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>> >      int i;
>> >      int count = 0;
>> >
>> > -    if (!rdma_transport_is_ib(device))
>> > +    if (!has_mcast(device))
>> >          return;
>>
>> Again, this seems redundant, every port is tested directly below, why
>> is this check needed?
>
> Agreed.  Same as my comments about the SA support.  This is really only
> needed on ports which need to register with the SA (or perhaps some future
> entity) for Mcast support.

I will recheck all the logical around has_XX() see if we can get rid of them ;-)

>
> Also this is part of the ib_sa module and exports the function
> ib_sa_join_multicast.  So that this point it is covered under the
> cap_sa(device, port) call.
>
> So the implementation of cap_mcast at this point is:
>
> cap_mcast(device, port)
> {
>         return cap_sa(device,port);
> }
>

Sounds good :-) will be in next version.

>>
>> Looking at this, I do wonder how a port can dynamically change between
>> rocee and IB.. If the link value changes then mcast_remove_one will
>> not be a perfect reversal of mcast_add_one. Bug?
>>
>> It feels necessary to understand what happens when a port dynamically
>> switches to ethernet on mlx hardware to validate these patches :(
>
> Agreed.

Maybe we can temporarily reserve the old logical, and gradually solve
these problems?

Regards,
Michael Wang


>
> :-(
>
> -- Ira
>
>>
>> Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:31               ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:31 UTC (permalink / raw)
  To: ira.weiny
  Cc: Jason Gunthorpe, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 6:05 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Fri, Mar 27, 2015 at 10:28:20AM -0600, Jason Gunthorpe wrote:
>> On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
>> >
[snip]
>> > -            if (rdma_transport_is_ib(id_priv->cma_dev->device)) {
>> > +            if (has_mcast(id_priv->cma_dev->device)) {
>>
>> This might make more sense as cap_ib_multicast / cap_ip_multicast
>
> Agreed.
>

Will be changed in next version :-)

>>
>> >                  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/multicast.c b/drivers/infiniband/core/multicast.c
>> > index 17573ff..ffeaf27 100644
>> > +++ b/drivers/infiniband/core/multicast.c
>> > @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>> >      int index;
>> >
>> >      dev = container_of(handler, struct mcast_device, event_handler);
>> > -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>> > +    if (!cap_mcast(dev->device, event->element.port_num))
>> >          return;
>>
>> These should probably be cap_ib_sa - that is what they are guarding
>> against.
>>
>> But it seems redudent, since mcast_add_one will already not add a port that is
>> not IB, so mcast_event_handler is not callable. Something to do with
>> rocee/ib switching?
>
> I'm not sure about this either.  This check seems to be necessary only on a
> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
> happens if you go from IB to Eth on the port?

I also feel it's redundant at first glance, but just not sure if it
could be removed, lack of some knowledge :-P

>
>>
>> >      index = event->element.port_num - dev->start_port;
>> > @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>> >      int i;
>> >      int count = 0;
>> >
>> > -    if (!rdma_transport_is_ib(device))
>> > +    if (!has_mcast(device))
>> >          return;
>>
>> Again, this seems redundant, every port is tested directly below, why
>> is this check needed?
>
> Agreed.  Same as my comments about the SA support.  This is really only
> needed on ports which need to register with the SA (or perhaps some future
> entity) for Mcast support.

I will recheck all the logical around has_XX() see if we can get rid of them ;-)

>
> Also this is part of the ib_sa module and exports the function
> ib_sa_join_multicast.  So that this point it is covered under the
> cap_sa(device, port) call.
>
> So the implementation of cap_mcast at this point is:
>
> cap_mcast(device, port)
> {
>         return cap_sa(device,port);
> }
>

Sounds good :-) will be in next version.

>>
>> Looking at this, I do wonder how a port can dynamically change between
>> rocee and IB.. If the link value changes then mcast_remove_one will
>> not be a perfect reversal of mcast_add_one. Bug?
>>
>> It feels necessary to understand what happens when a port dynamically
>> switches to ethernet on mlx hardware to validate these patches :(
>
> Agreed.

Maybe we can temporarily reserve the old logical, and gradually solve
these problems?

Regards,
Michael Wang


>
> :-(
>
> -- Ira
>
>>
>> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:31               ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:31 UTC (permalink / raw)
  To: ira.weiny
  Cc: Jason Gunthorpe, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina

On Fri, Mar 27, 2015 at 6:05 PM, ira.weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> On Fri, Mar 27, 2015 at 10:28:20AM -0600, Jason Gunthorpe wrote:
>> On Fri, Mar 27, 2015 at 04:46:57PM +0100, Michael Wang wrote:
>> >
[snip]
>> > -            if (rdma_transport_is_ib(id_priv->cma_dev->device)) {
>> > +            if (has_mcast(id_priv->cma_dev->device)) {
>>
>> This might make more sense as cap_ib_multicast / cap_ip_multicast
>
> Agreed.
>

Will be changed in next version :-)

>>
>> >                  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/multicast.c b/drivers/infiniband/core/multicast.c
>> > index 17573ff..ffeaf27 100644
>> > +++ b/drivers/infiniband/core/multicast.c
>> > @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>> >      int index;
>> >
>> >      dev = container_of(handler, struct mcast_device, event_handler);
>> > -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>> > +    if (!cap_mcast(dev->device, event->element.port_num))
>> >          return;
>>
>> These should probably be cap_ib_sa - that is what they are guarding
>> against.
>>
>> But it seems redudent, since mcast_add_one will already not add a port that is
>> not IB, so mcast_event_handler is not callable. Something to do with
>> rocee/ib switching?
>
> I'm not sure about this either.  This check seems to be necessary only on a
> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
> happens if you go from IB to Eth on the port?

I also feel it's redundant at first glance, but just not sure if it
could be removed, lack of some knowledge :-P

>
>>
>> >      index = event->element.port_num - dev->start_port;
>> > @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>> >      int i;
>> >      int count = 0;
>> >
>> > -    if (!rdma_transport_is_ib(device))
>> > +    if (!has_mcast(device))
>> >          return;
>>
>> Again, this seems redundant, every port is tested directly below, why
>> is this check needed?
>
> Agreed.  Same as my comments about the SA support.  This is really only
> needed on ports which need to register with the SA (or perhaps some future
> entity) for Mcast support.

I will recheck all the logical around has_XX() see if we can get rid of them ;-)

>
> Also this is part of the ib_sa module and exports the function
> ib_sa_join_multicast.  So that this point it is covered under the
> cap_sa(device, port) call.
>
> So the implementation of cap_mcast at this point is:
>
> cap_mcast(device, port)
> {
>         return cap_sa(device,port);
> }
>

Sounds good :-) will be in next version.

>>
>> Looking at this, I do wonder how a port can dynamically change between
>> rocee and IB.. If the link value changes then mcast_remove_one will
>> not be a perfect reversal of mcast_add_one. Bug?
>>
>> It feels necessary to understand what happens when a port dynamically
>> switches to ethernet on mlx hardware to validate these patches :(
>
> Agreed.

Maybe we can temporarily reserve the old logical, and gradually solve
these problems?

Regards,
Michael Wang


>
> :-(
>
> -- Ira
>
>>
>> Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 17:16       ` ira.weiny
  (?)
@ 2015-03-27 17:35         ` Yun Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:35 UTC (permalink / raw)
  To: ira.weiny
  Cc: Jason Gunthorpe, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina

On Fri, Mar 27, 2015 at 6:16 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
>> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
>> >
>> > Introduce helper has_iwarp() to help us check if an IB device
>> > support IWARP protocol.
>>
>> Should probably be !has_rdma_read_sges()
>>
>> True if the device can handle more than one SGE entry on a RDMA READ
>> work request.
>
> Isn't this value already provided by the query_device verb?
>
> The verbs spec states the Query HCA contains the:
>
> "Maximum number of scatter/gather entries per Work Request supported by the
> HCA."

I'm not sure but may be query_device() is just too expensive for this path?
I need some investigation here too.

Regards,
Michael Wang

>
> -- Ira
>
>>
>> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 17:35         ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:35 UTC (permalink / raw)
  To: ira.weiny
  Cc: Jason Gunthorpe, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 6:16 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
>> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
>> >
>> > Introduce helper has_iwarp() to help us check if an IB device
>> > support IWARP protocol.
>>
>> Should probably be !has_rdma_read_sges()
>>
>> True if the device can handle more than one SGE entry on a RDMA READ
>> work request.
>
> Isn't this value already provided by the query_device verb?
>
> The verbs spec states the Query HCA contains the:
>
> "Maximum number of scatter/gather entries per Work Request supported by the
> HCA."

I'm not sure but may be query_device() is just too expensive for this path?
I need some investigation here too.

Regards,
Michael Wang

>
> -- Ira
>
>>
>> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-27 17:35         ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 17:35 UTC (permalink / raw)
  To: ira.weiny
  Cc: Jason Gunthorpe, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina

On Fri, Mar 27, 2015 at 6:16 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Fri, Mar 27, 2015 at 10:13:19AM -0600, Jason Gunthorpe wrote:
>> On Fri, Mar 27, 2015 at 04:47:36PM +0100, Michael Wang wrote:
>> >
>> > Introduce helper has_iwarp() to help us check if an IB device
>> > support IWARP protocol.
>>
>> Should probably be !has_rdma_read_sges()
>>
>> True if the device can handle more than one SGE entry on a RDMA READ
>> work request.
>
> Isn't this value already provided by the query_device verb?
>
> The verbs spec states the Query HCA contains the:
>
> "Maximum number of scatter/gather entries per Work Request supported by the
> HCA."

I'm not sure but may be query_device() is just too expensive for this path?
I need some investigation here too.

Regards,
Michael Wang

>
> -- Ira
>
>>
>> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 17:05           ` ira.weiny
  (?)
@ 2015-03-27 17:47               ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:47 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 01:05:08PM -0400, ira.weiny wrote:

> > But it seems redudent, since mcast_add_one will already not add a port that is
> > not IB, so mcast_event_handler is not callable. Something to do with
> > rocee/ib switching?
> 
> I'm not sure about this either.  This check seems to be necessary only on a
> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
> happens if you go from IB to Eth on the port?

Hmm... I see a mlx4_change_port_types which ultimately calls
ib_unregister_device, which suggests the port type doesn't change at
runtime (yay)

So maybe these checks really are redundant?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:47               ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:47 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 01:05:08PM -0400, ira.weiny wrote:

> > But it seems redudent, since mcast_add_one will already not add a port that is
> > not IB, so mcast_event_handler is not callable. Something to do with
> > rocee/ib switching?
> 
> I'm not sure about this either.  This check seems to be necessary only on a
> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
> happens if you go from IB to Eth on the port?

Hmm... I see a mlx4_change_port_types which ultimately calls
ib_unregister_device, which suggests the port type doesn't change at
runtime (yay)

So maybe these checks really are redundant?

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:47               ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:47 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On Fri, Mar 27, 2015 at 01:05:08PM -0400, ira.weiny wrote:

> > But it seems redudent, since mcast_add_one will already not add a port that is
> > not IB, so mcast_event_handler is not callable. Something to do with
> > rocee/ib switching?
> 
> I'm not sure about this either.  This check seems to be necessary only on a
> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
> happens if you go from IB to Eth on the port?

Hmm... I see a mlx4_change_port_types which ultimately calls
ib_unregister_device, which suggests the port type doesn't change at
runtime (yay)

So maybe these checks really are redundant?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 17:31               ` Yun Wang
  (?)
@ 2015-03-27 17:49                 ` Jason Gunthorpe
  -1 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:49 UTC (permalink / raw)
  To: Yun Wang
  Cc: ira.weiny, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina

On Fri, Mar 27, 2015 at 06:31:26PM +0100, Yun Wang wrote:

> Maybe we can temporarily reserve the old logical, and gradually solve
> these problems?

It is best to make behavioral changes in small patches, yes.

I think it is best to address these sorts of problems before trying to
tackle the driver interface side - that will avoid complexity.

ie how does a driver set has_ipoib? It isn't even a sensible question
when it is a per port capability.

Jason
--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:49                 ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:49 UTC (permalink / raw)
  To: Yun Wang
  Cc: ira.weiny, Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 06:31:26PM +0100, Yun Wang wrote:

> Maybe we can temporarily reserve the old logical, and gradually solve
> these problems?

It is best to make behavioral changes in small patches, yes.

I think it is best to address these sorts of problems before trying to
tackle the driver interface side - that will avoid complexity.

ie how does a driver set has_ipoib? It isn't even a sensible question
when it is a per port capability.

Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 17:49                 ` Jason Gunthorpe
  0 siblings, 0 replies; 189+ messages in thread
From: Jason Gunthorpe @ 2015-03-27 17:49 UTC (permalink / raw)
  To: Yun Wang
  Cc: ira.weiny, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak

On Fri, Mar 27, 2015 at 06:31:26PM +0100, Yun Wang wrote:

> Maybe we can temporarily reserve the old logical, and gradually solve
> these problems?

It is best to make behavioral changes in small patches, yes.

I think it is best to address these sorts of problems before trying to
tackle the driver interface side - that will avoid complexity.

ie how does a driver set has_ipoib? It isn't even a sensible question
when it is a per port capability.

Jason
--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 17:49                 ` Jason Gunthorpe
  (?)
@ 2015-03-27 18:09                   ` Yun Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 18:09 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: ira.weiny, Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina

On Fri, Mar 27, 2015 at 6:49 PM, Jason Gunthorpe
<jgunthorpe@obsidianresearch.com> wrote:
> On Fri, Mar 27, 2015 at 06:31:26PM +0100, Yun Wang wrote:
>
>> Maybe we can temporarily reserve the old logical, and gradually solve
>> these problems?
>
> It is best to make behavioral changes in small patches, yes.
>
> I think it is best to address these sorts of problems before trying to
> tackle the driver interface side - that will avoid complexity.
>
> ie how does a driver set has_ipoib? It isn't even a sensible question
> when it is a per port capability.

I used to imaging it would like:

init_device_mgmt_attributs(device)
{
    for_each_port(device)
        if (port support XX) {
            port.mgmt_attribute |= CAP_XX
             if !(device.mgmt_attribute & HAS_XX)
                 device.mgmt_attribute |= HAS_XX
        }
}

That is incase if a device got one port have some capability, the
device have it too, so has_XX() will check on device level that if it
has any port support XX, and cap_XX() to check on port level.

But if has_XX() is only for optimizing the init/exit path, then it
doesn't make sense to me any more...

Regards,
Michael Wang

>
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 18:09                   ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 18:09 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: ira.weiny, Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On Fri, Mar 27, 2015 at 6:49 PM, Jason Gunthorpe
<jgunthorpe@obsidianresearch.com> wrote:
> On Fri, Mar 27, 2015 at 06:31:26PM +0100, Yun Wang wrote:
>
>> Maybe we can temporarily reserve the old logical, and gradually solve
>> these problems?
>
> It is best to make behavioral changes in small patches, yes.
>
> I think it is best to address these sorts of problems before trying to
> tackle the driver interface side - that will avoid complexity.
>
> ie how does a driver set has_ipoib? It isn't even a sensible question
> when it is a per port capability.

I used to imaging it would like:

init_device_mgmt_attributs(device)
{
    for_each_port(device)
        if (port support XX) {
            port.mgmt_attribute |= CAP_XX
             if !(device.mgmt_attribute & HAS_XX)
                 device.mgmt_attribute |= HAS_XX
        }
}

That is incase if a device got one port have some capability, the
device have it too, so has_XX() will check on device level that if it
has any port support XX, and cap_XX() to check on port level.

But if has_XX() is only for optimizing the init/exit path, then it
doesn't make sense to me any more...

Regards,
Michael Wang

>
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-27 18:09                   ` Yun Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Yun Wang @ 2015-03-27 18:09 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: ira.weiny, Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak

On Fri, Mar 27, 2015 at 6:49 PM, Jason Gunthorpe
<jgunthorpe@obsidianresearch.com> wrote:
> On Fri, Mar 27, 2015 at 06:31:26PM +0100, Yun Wang wrote:
>
>> Maybe we can temporarily reserve the old logical, and gradually solve
>> these problems?
>
> It is best to make behavioral changes in small patches, yes.
>
> I think it is best to address these sorts of problems before trying to
> tackle the driver interface side - that will avoid complexity.
>
> ie how does a driver set has_ipoib? It isn't even a sensible question
> when it is a per port capability.

I used to imaging it would like:

init_device_mgmt_attributs(device)
{
    for_each_port(device)
        if (port support XX) {
            port.mgmt_attribute |= CAP_XX
             if !(device.mgmt_attribute & HAS_XX)
                 device.mgmt_attribute |= HAS_XX
        }
}

That is incase if a device got one port have some capability, the
device have it too, so has_XX() will check on device level that if it
has any port support XX, and cap_XX() to check on port level.

But if has_XX() is only for optimizing the init/exit path, then it
doesn't make sense to me any more...

Regards,
Michael Wang

>
> Jason

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
  2015-03-27 16:47       ` ira.weiny
  (?)
@ 2015-03-27 19:49         ` Doug Ledford
  -1 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-27 19:49 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 5948 bytes --]

On Fri, 2015-03-27 at 12:47 -0400, ira.weiny wrote:
> On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_sa() and cap_sa() to help us check if an IB device
> > or it's port support Subnet Administrator.
> 
> I think these 2 should be combined.  The question is if a port requires the use
> of the SA depending on the network it is connected to.
> 
> Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
> the other?

Yes.

>   Do they show up as 2 devices?

No.  They are two ports of the same device with different link layers.
See here:

hca_id:	mlx4_1
	transport:			InfiniBand (0)
	fw_ver:				2.31.5050
	node_guid:			f452:1403:007b:cba0
	sys_image_guid:			f452:1403:007b:cba3
	vendor_id:			0x02c9
	vendor_part_id:			4099
	hw_ver:				0x0
	board_id:			MT_1090120019
	phys_port_cnt:			2
		port:	1
			state:			PORT_ACTIVE (4)
			max_mtu:		2048 (4)
			active_mtu:		2048 (4)
			sm_lid:			2
			port_lid:		2
			port_lmc:		0x01
			link_layer:		InfiniBand

		port:	2
			state:			PORT_ACTIVE (4)
			max_mtu:		4096 (5)
			active_mtu:		4096 (5)
			sm_lid:			0
			port_lid:		0
			port_lmc:		0x00
			link_layer:		Ethernet



> Regardless I think we should define the SA access on a per port basis.

Yes.

> > 
> > 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/sa_query.c | 12 ++++++------
> >  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 34 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> > index d95d25f..89c27da 100644
> > --- a/drivers/infiniband/core/sa_query.c
> > +++ b/drivers/infiniband/core/sa_query.c
> > @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
> >          struct ib_sa_port *port =
> >              &sa_dev->port[event->element.port_num - sa_dev->start_port];
> >  
> > -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> > +        if (!cap_sa(handler->device, port->port_num))
> >              return;
> >  
> >          spin_lock_irqsave(&port->ah_lock, flags);
> > @@ -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_transport_is_ib(device))
> > +    if (!has_sa(device))
> 
> The logic here should be:
> 
> if (no ports of this device need sa access)
> 	return;
> 
> So why not eliminate this check and allow the cap_sa(s) to handle the support?
> 
> -- Ira
> 
> >          return;
> >  
> >      if (device->node_type == RDMA_NODE_IB_SWITCH)
> > @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
> >  
> >      for (i = 0; i <= e - s; ++i) {
> >          spin_lock_init(&sa_dev->port[i].ah_lock);
> > -        if (!rdma_port_ll_is_ib(device, i + 1))
> > +        if (!cap_sa(device, i + 1))
> >              continue;
> >  
> >          sa_dev->port[i].sm_ah    = NULL;
> > @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
> >          goto err;
> >  
> >      for (i = 0; i <= e - s; ++i)
> > -        if (rdma_port_ll_is_ib(device, i + 1))
> > +        if (cap_sa(device, i + 1))
> >              update_sm_ah(&sa_dev->port[i].update_task);
> >  
> >      return;
> >  
> >  err:
> >      while (--i >= 0)
> > -        if (rdma_port_ll_is_ib(device, i + 1))
> > +        if (cap_sa(device, i + 1))
> >              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >  
> >      kfree(sa_dev);
> > @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
> >      flush_workqueue(ib_wq);
> >  
> >      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> > -        if (rdma_port_ll_is_ib(device, i + 1)) {
> > +        if (cap_sa(device, i + 1)) {
> >              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >              if (sa_dev->port[i].sm_ah)
> >                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> > index c0a63f8..fa8ffa3 100644
> > --- a/include/rdma/ib_verbs.h
> > +++ b/include/rdma/ib_verbs.h
> > @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
> >  }
> >  
> >  /**
> > + * has_sa - Check if a device support Subnet Administrator.
> > + *
> > + * @device: Device to be checked
> > + *
> > + * Return 0 when a device has none port to support
> > + * Subnet Administrator.
> > + */
> > +static inline int has_sa(struct ib_device *device)
> > +{
> > +    return rdma_transport_is_ib(device);
> > +}
> > +
> > +/**
> >   * cap_smi - Check if the port of device has the capability
> >   * Subnet Management Interface.
> >   *
> > @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
> >      return rdma_port_ll_is_ib(device, port_num);
> >  }
> >  
> > +/**
> > + * cap_sa - Check if the port of device has the capability
> > + * Subnet Administrator.
> > + *
> > + * @device: Device to be checked
> > + * @port_num: Port number of the device
> > + *
> > + * Return 0 when port of the device don't support
> > + * Subnet Administrator.
> > + */
> > +static inline int cap_sa(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
> > 


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 19:49         ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-27 19:49 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

[-- Attachment #1: Type: text/plain, Size: 5948 bytes --]

On Fri, 2015-03-27 at 12:47 -0400, ira.weiny wrote:
> On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_sa() and cap_sa() to help us check if an IB device
> > or it's port support Subnet Administrator.
> 
> I think these 2 should be combined.  The question is if a port requires the use
> of the SA depending on the network it is connected to.
> 
> Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
> the other?

Yes.

>   Do they show up as 2 devices?

No.  They are two ports of the same device with different link layers.
See here:

hca_id:	mlx4_1
	transport:			InfiniBand (0)
	fw_ver:				2.31.5050
	node_guid:			f452:1403:007b:cba0
	sys_image_guid:			f452:1403:007b:cba3
	vendor_id:			0x02c9
	vendor_part_id:			4099
	hw_ver:				0x0
	board_id:			MT_1090120019
	phys_port_cnt:			2
		port:	1
			state:			PORT_ACTIVE (4)
			max_mtu:		2048 (4)
			active_mtu:		2048 (4)
			sm_lid:			2
			port_lid:		2
			port_lmc:		0x01
			link_layer:		InfiniBand

		port:	2
			state:			PORT_ACTIVE (4)
			max_mtu:		4096 (5)
			active_mtu:		4096 (5)
			sm_lid:			0
			port_lid:		0
			port_lmc:		0x00
			link_layer:		Ethernet



> Regardless I think we should define the SA access on a per port basis.

Yes.

> > 
> > 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/sa_query.c | 12 ++++++------
> >  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 34 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> > index d95d25f..89c27da 100644
> > --- a/drivers/infiniband/core/sa_query.c
> > +++ b/drivers/infiniband/core/sa_query.c
> > @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
> >          struct ib_sa_port *port =
> >              &sa_dev->port[event->element.port_num - sa_dev->start_port];
> >  
> > -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> > +        if (!cap_sa(handler->device, port->port_num))
> >              return;
> >  
> >          spin_lock_irqsave(&port->ah_lock, flags);
> > @@ -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_transport_is_ib(device))
> > +    if (!has_sa(device))
> 
> The logic here should be:
> 
> if (no ports of this device need sa access)
> 	return;
> 
> So why not eliminate this check and allow the cap_sa(s) to handle the support?
> 
> -- Ira
> 
> >          return;
> >  
> >      if (device->node_type == RDMA_NODE_IB_SWITCH)
> > @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
> >  
> >      for (i = 0; i <= e - s; ++i) {
> >          spin_lock_init(&sa_dev->port[i].ah_lock);
> > -        if (!rdma_port_ll_is_ib(device, i + 1))
> > +        if (!cap_sa(device, i + 1))
> >              continue;
> >  
> >          sa_dev->port[i].sm_ah    = NULL;
> > @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
> >          goto err;
> >  
> >      for (i = 0; i <= e - s; ++i)
> > -        if (rdma_port_ll_is_ib(device, i + 1))
> > +        if (cap_sa(device, i + 1))
> >              update_sm_ah(&sa_dev->port[i].update_task);
> >  
> >      return;
> >  
> >  err:
> >      while (--i >= 0)
> > -        if (rdma_port_ll_is_ib(device, i + 1))
> > +        if (cap_sa(device, i + 1))
> >              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >  
> >      kfree(sa_dev);
> > @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
> >      flush_workqueue(ib_wq);
> >  
> >      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> > -        if (rdma_port_ll_is_ib(device, i + 1)) {
> > +        if (cap_sa(device, i + 1)) {
> >              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >              if (sa_dev->port[i].sm_ah)
> >                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> > index c0a63f8..fa8ffa3 100644
> > --- a/include/rdma/ib_verbs.h
> > +++ b/include/rdma/ib_verbs.h
> > @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
> >  }
> >  
> >  /**
> > + * has_sa - Check if a device support Subnet Administrator.
> > + *
> > + * @device: Device to be checked
> > + *
> > + * Return 0 when a device has none port to support
> > + * Subnet Administrator.
> > + */
> > +static inline int has_sa(struct ib_device *device)
> > +{
> > +    return rdma_transport_is_ib(device);
> > +}
> > +
> > +/**
> >   * cap_smi - Check if the port of device has the capability
> >   * Subnet Management Interface.
> >   *
> > @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
> >      return rdma_port_ll_is_ib(device, port_num);
> >  }
> >  
> > +/**
> > + * cap_sa - Check if the port of device has the capability
> > + * Subnet Administrator.
> > + *
> > + * @device: Device to be checked
> > + * @port_num: Port number of the device
> > + *
> > + * Return 0 when port of the device don't support
> > + * Subnet Administrator.
> > + */
> > +static inline int cap_sa(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
> > 


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-27 19:49         ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-27 19:49 UTC (permalink / raw)
  To: ira.weiny
  Cc: Michael Wang, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma, linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 5948 bytes --]

On Fri, 2015-03-27 at 12:47 -0400, ira.weiny wrote:
> On Fri, Mar 27, 2015 at 04:46:11PM +0100, Michael Wang wrote:
> > 
> > Introduce helper has_sa() and cap_sa() to help us check if an IB device
> > or it's port support Subnet Administrator.
> 
> I think these 2 should be combined.  The question is if a port requires the use
> of the SA depending on the network it is connected to.
> 
> Aren't some dual port Mellanox cards capable of doing IB on 1 port and Eth on
> the other?

Yes.

>   Do they show up as 2 devices?

No.  They are two ports of the same device with different link layers.
See here:

hca_id:	mlx4_1
	transport:			InfiniBand (0)
	fw_ver:				2.31.5050
	node_guid:			f452:1403:007b:cba0
	sys_image_guid:			f452:1403:007b:cba3
	vendor_id:			0x02c9
	vendor_part_id:			4099
	hw_ver:				0x0
	board_id:			MT_1090120019
	phys_port_cnt:			2
		port:	1
			state:			PORT_ACTIVE (4)
			max_mtu:		2048 (4)
			active_mtu:		2048 (4)
			sm_lid:			2
			port_lid:		2
			port_lmc:		0x01
			link_layer:		InfiniBand

		port:	2
			state:			PORT_ACTIVE (4)
			max_mtu:		4096 (5)
			active_mtu:		4096 (5)
			sm_lid:			0
			port_lid:		0
			port_lmc:		0x00
			link_layer:		Ethernet



> Regardless I think we should define the SA access on a per port basis.

Yes.

> > 
> > 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/sa_query.c | 12 ++++++------
> >  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 34 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> > index d95d25f..89c27da 100644
> > --- a/drivers/infiniband/core/sa_query.c
> > +++ b/drivers/infiniband/core/sa_query.c
> > @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
> >          struct ib_sa_port *port =
> >              &sa_dev->port[event->element.port_num - sa_dev->start_port];
> >  
> > -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> > +        if (!cap_sa(handler->device, port->port_num))
> >              return;
> >  
> >          spin_lock_irqsave(&port->ah_lock, flags);
> > @@ -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_transport_is_ib(device))
> > +    if (!has_sa(device))
> 
> The logic here should be:
> 
> if (no ports of this device need sa access)
> 	return;
> 
> So why not eliminate this check and allow the cap_sa(s) to handle the support?
> 
> -- Ira
> 
> >          return;
> >  
> >      if (device->node_type == RDMA_NODE_IB_SWITCH)
> > @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
> >  
> >      for (i = 0; i <= e - s; ++i) {
> >          spin_lock_init(&sa_dev->port[i].ah_lock);
> > -        if (!rdma_port_ll_is_ib(device, i + 1))
> > +        if (!cap_sa(device, i + 1))
> >              continue;
> >  
> >          sa_dev->port[i].sm_ah    = NULL;
> > @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
> >          goto err;
> >  
> >      for (i = 0; i <= e - s; ++i)
> > -        if (rdma_port_ll_is_ib(device, i + 1))
> > +        if (cap_sa(device, i + 1))
> >              update_sm_ah(&sa_dev->port[i].update_task);
> >  
> >      return;
> >  
> >  err:
> >      while (--i >= 0)
> > -        if (rdma_port_ll_is_ib(device, i + 1))
> > +        if (cap_sa(device, i + 1))
> >              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >  
> >      kfree(sa_dev);
> > @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
> >      flush_workqueue(ib_wq);
> >  
> >      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> > -        if (rdma_port_ll_is_ib(device, i + 1)) {
> > +        if (cap_sa(device, i + 1)) {
> >              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >              if (sa_dev->port[i].sm_ah)
> >                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> > index c0a63f8..fa8ffa3 100644
> > --- a/include/rdma/ib_verbs.h
> > +++ b/include/rdma/ib_verbs.h
> > @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
> >  }
> >  
> >  /**
> > + * has_sa - Check if a device support Subnet Administrator.
> > + *
> > + * @device: Device to be checked
> > + *
> > + * Return 0 when a device has none port to support
> > + * Subnet Administrator.
> > + */
> > +static inline int has_sa(struct ib_device *device)
> > +{
> > +    return rdma_transport_is_ib(device);
> > +}
> > +
> > +/**
> >   * cap_smi - Check if the port of device has the capability
> >   * Subnet Management Interface.
> >   *
> > @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
> >      return rdma_port_ll_is_ib(device, port_num);
> >  }
> >  
> > +/**
> > + * cap_sa - Check if the port of device has the capability
> > + * Subnet Administrator.
> > + *
> > + * @device: Device to be checked
> > + * @port_num: Port number of the device
> > + *
> > + * Return 0 when port of the device don't support
> > + * Subnet Administrator.
> > + */
> > +static inline int cap_sa(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
> > 


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 17:47               ` Jason Gunthorpe
  (?)
@ 2015-03-30  8:30                   ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30  8:30 UTC (permalink / raw)
  To: Jason Gunthorpe, ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford



On 03/27/2015 06:47 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 01:05:08PM -0400, ira.weiny wrote:
>
>>> But it seems redudent, since mcast_add_one will already not add a port that is
>>> not IB, so mcast_event_handler is not callable. Something to do with
>>> rocee/ib switching?
>> I'm not sure about this either.  This check seems to be necessary only on a
>> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
>> happens if you go from IB to Eth on the port?
> Hmm... I see a mlx4_change_port_types which ultimately calls
> ib_unregister_device, which suggests the port type doesn't change at
> runtime (yay)
Yeah, seems like mlx4 will reinitialize the device when port link layer
changed.

I've take a look at other HW, they directly return a static type or
infer from transport type (I suppose this won't change dynamically).

Thus I also agreed check inside mcast_event_handler() is unnecessary,
maybe we can change that logical to WARN_ON(!cap_mcast()) ?

Regards,
Michael Wang

>
> So maybe these checks really are redundant?
>
> Jason

--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-30  8:30                   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30  8:30 UTC (permalink / raw)
  To: Jason Gunthorpe, ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever



On 03/27/2015 06:47 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 01:05:08PM -0400, ira.weiny wrote:
>
>>> But it seems redudent, since mcast_add_one will already not add a port that is
>>> not IB, so mcast_event_handler is not callable. Something to do with
>>> rocee/ib switching?
>> I'm not sure about this either.  This check seems to be necessary only on a
>> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
>> happens if you go from IB to Eth on the port?
> Hmm... I see a mlx4_change_port_types which ultimately calls
> ib_unregister_device, which suggests the port type doesn't change at
> runtime (yay)
Yeah, seems like mlx4 will reinitialize the device when port link layer
changed.

I've take a look at other HW, they directly return a static type or
infer from transport type (I suppose this won't change dynamically).

Thus I also agreed check inside mcast_event_handler() is unnecessary,
maybe we can change that logical to WARN_ON(!cap_mcast()) ?

Regards,
Michael Wang

>
> So maybe these checks really are redundant?
>
> Jason


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-30  8:30                   ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30  8:30 UTC (permalink / raw)
  To: Jason Gunthorpe, ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford



On 03/27/2015 06:47 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 01:05:08PM -0400, ira.weiny wrote:
>
>>> But it seems redudent, since mcast_add_one will already not add a port that is
>>> not IB, so mcast_event_handler is not callable. Something to do with
>>> rocee/ib switching?
>> I'm not sure about this either.  This check seems to be necessary only on a
>> per-port level.  It does seem apparent that one can't go from Eth to IB.  What
>> happens if you go from IB to Eth on the port?
> Hmm... I see a mlx4_change_port_types which ultimately calls
> ib_unregister_device, which suggests the port type doesn't change at
> runtime (yay)
Yeah, seems like mlx4 will reinitialize the device when port link layer
changed.

I've take a look at other HW, they directly return a static type or
infer from transport type (I suppose this won't change dynamically).

Thus I also agreed check inside mcast_event_handler() is unnecessary,
maybe we can change that logical to WARN_ON(!cap_mcast()) ?

Regards,
Michael Wang

>
> So maybe these checks really are redundant?
>
> Jason

--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 17:29         ` Jason Gunthorpe
  (?)
@ 2015-03-30 15:10             ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 15:10 UTC (permalink / raw)
  To: Jason Gunthorpe, ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford

On 03/27/2015 06:29 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 01:16:31PM -0400, ira.weiny wrote:
>> [snip]
> http://www.spinics.net/lists/linux-rdma/msg22565.html
>
> ''Unlike IB, the iWARP protocol only allows 1 target/sink SGE in an
> rdma read''
>
> It is one of those annoying verbs is different on iWarp things.
>
> So the max sge in the query_verbs must only apply to send/rdma write
> on iWarp?
I found that actually we don't have to touch this one which
only used by HW driver currently.

I think we can leave these scenes there in device driver, since
vendor could have different way to classify the usage of transfer
and link layer.

Our purpose is to introduce IB core management approach, which
may not be applicable on device level, maybe we can just pass them :-)

Regards,
Michael Wang


>
> Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-30 15:10             ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 15:10 UTC (permalink / raw)
  To: Jason Gunthorpe, ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Doug Ledford,
	Eric Dumazet, Erez Shitrit, Sagi Grimberg, Haggai Eran,
	Shachar Raindel, Mike Marciniszyn, Steve Wise, Tom Tucker,
	Chuck Lever

On 03/27/2015 06:29 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 01:16:31PM -0400, ira.weiny wrote:
>> [snip]
> http://www.spinics.net/lists/linux-rdma/msg22565.html
>
> ''Unlike IB, the iWARP protocol only allows 1 target/sink SGE in an
> rdma read''
>
> It is one of those annoying verbs is different on iWarp things.
>
> So the max sge in the query_verbs must only apply to send/rdma write
> on iWarp?
I found that actually we don't have to touch this one which
only used by HW driver currently.

I think we can leave these scenes there in device driver, since
vendor could have different way to classify the usage of transfer
and link layer.

Our purpose is to introduce IB core management approach, which
may not be applicable on device level, maybe we can just pass them :-)

Regards,
Michael Wang


>
> Jason


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-30 15:10             ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 15:10 UTC (permalink / raw)
  To: Jason Gunthorpe, ira.weiny
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin,
	Doug Ledford

On 03/27/2015 06:29 PM, Jason Gunthorpe wrote:
> On Fri, Mar 27, 2015 at 01:16:31PM -0400, ira.weiny wrote:
>> [snip]
> http://www.spinics.net/lists/linux-rdma/msg22565.html
>
> ''Unlike IB, the iWARP protocol only allows 1 target/sink SGE in an
> rdma read''
>
> It is one of those annoying verbs is different on iWarp things.
>
> So the max sge in the query_verbs must only apply to send/rdma write
> on iWarp?
I found that actually we don't have to touch this one which
only used by HW driver currently.

I think we can leave these scenes there in device driver, since
vendor could have different way to classify the usage of transfer
and link layer.

Our purpose is to introduce IB core management approach, which
may not be applicable on device level, maybe we can just pass them :-)

Regards,
Michael Wang


>
> Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
  2015-03-27 15:40     ` Michael Wang
  (?)
@ 2015-03-30 15:56       ` Doug Ledford
  -1 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 15:56 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 30195 bytes --]

On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
> We have so much places to check transport type and link layer type, it's now
> make sense to introduce some helpers in order to refine the lengthy code.
> 
> This patch will introduce helpers:
>     rdma_transport_is_ib()
>     rdma_transport_is_iwarp()
>     rdma_port_ll_is_ib()
>     rdma_port_ll_is_eth()
> and use them to save some code for us.

If the end result is to do something like I proposed, then why take this
intermediate step that just has to be backed out later?

In other words, if our end goal is to have

rdma_transport_is_ib()
rdma_transport_is_iwarp()
rdma_transport_is_roce()
rdma_transport_is_opa()

Then we should skip doing rdma_port_ll_is_*() as the answers to these
items would be implied by rdma_transport_is_roce() and such.

> 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/agent.c           |  2 +-
>  drivers/infiniband/core/cm.c              |  2 +-
>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
>  drivers/infiniband/core/mad.c             |  6 +++---
>  drivers/infiniband/core/multicast.c       | 11 ++++-------
>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
>  drivers/infiniband/core/ucm.c             |  3 +--
>  drivers/infiniband/core/user_mad.c        |  2 +-
>  drivers/infiniband/core/verbs.c           |  5 ++---
>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
>  19 files changed, 79 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> index f6d2961..27f1bec 100644
> --- a/drivers/infiniband/core/agent.c
> +++ b/drivers/infiniband/core/agent.c
> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
>          goto error1;
>      }
>  
> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
> +    if (rdma_port_ll_is_ib(device, port_num)) {
>          /* Obtain send only MAD agent for SMI QP */
>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>                                  IB_QPT_SMI, NULL, 0,
> 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..668e955 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -375,8 +375,8 @@ 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 &&
> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> +        if (rdma_transport_is_ib(cma_dev->device) &&
> +            rdma_port_ll_is_eth(cma_dev->device, port))
>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>                           &found_port, NULL);
>          else
> @@ -395,8 +395,8 @@ 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 &&
> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> +                if (rdma_transport_is_ib(cma_dev->device) &&
> +                    rdma_port_ll_is_eth(cma_dev->device, port))
>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>                  else
>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> @@ -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,10 +633,8 @@ 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 &&
> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
> -        == IB_LINK_LAYER_ETHERNET) {
> +    if (rdma_transport_is_ib(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);
>  
>          if (ret)
> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
>      int ret;
>      u16 pkey;
>  
> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
>          pkey = ib_addr_get_pkey(dev_addr);
>      else
>          pkey = 0xffff;
> @@ -1626,7 +1623,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 +2025,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)
> @@ -2060,7 +2057,7 @@ port_found:
>          goto out;
>  
>      id_priv->id.route.addr.dev_addr.dev_type =
> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
>  
>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
> @@ -3405,7 +3402,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..23cf9e8 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
>  
>      cq_size = mad_sendq_size + mad_recvq_size;
> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
> +    has_smi = rdma_port_ll_is_ib(device, port_num);
>      if (has_smi)
>          cq_size *= 2;
>  
> @@ -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..17573ff 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>          return;
>  
>      index = event->element.port_num - dev->start_port;
> @@ -808,7 +807,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,
> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>      }
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
> -            IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>              continue;
>          port = &dev->port[i];
>          port->dev = dev;
> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>      flush_workqueue(mcast_wq);
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
> -            IB_LINK_LAYER_INFINIBAND) {
> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>              port = &dev->port[i];
>              deref_port(port);
>              wait_for_completion(&port->comp);
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index c38f030..d95d25f 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
>      ah_attr->port_num = port_num;
>      ah_attr->static_rate = rec->rate;
>  
> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
> +    force_grh = rdma_port_ll_is_eth(device, port_num);
>  
>      if (rec->hop_limit > 1 || force_grh) {
>          ah_attr->ah_flags = IB_AH_GRH;
> @@ -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)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> +        if (rdma_port_ll_is_ib(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> +        if (rdma_port_ll_is_ib(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
> +        if (rdma_port_ll_is_ib(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
> index f93eb8d..d8d015a 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
>      u32 flow_class;
>      u16 gid_index;
>      int ret;
> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
> -            IB_LINK_LAYER_ETHERNET);
> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
>  
>      memset(ah_attr, 0, sizeof *ah_attr);
>      if (is_eth) {
> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
>      union ib_gid  sgid;
>  
>      if ((*qp_attr_mask & IB_QP_AV)  &&
> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
>          if (ret)
> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
> index 2d8c339..829eb60 100644
> --- a/drivers/infiniband/hw/mlx4/ah.c
> +++ b/drivers/infiniband/hw/mlx4/ah.c
> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
>      if (!ah)
>          return ERR_PTR(-ENOMEM);
>  
> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
>              ret = ERR_PTR(-EINVAL);
>          } else {
> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
> index cb63ecd..0417f03 100644
> --- a/drivers/infiniband/hw/mlx4/cq.c
> +++ b/drivers/infiniband/hw/mlx4/cq.c
> @@ -789,9 +789,7 @@ repoll:
>              break;
>          }
>  
> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
> -                          (*cur_qp)->port) ==
> -              IB_LINK_LAYER_ETHERNET);
> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
>              if ((*cur_qp)->mlx4_ib_qp_type &
>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 82a7dd8..4736fc7 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
>      int err;
>      int slave;
>      u8 *slave_id;
> -    int is_eth = 0;
> -
> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> -        is_eth = 0;
> -    else
> -        is_eth = 1;
> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
>  
>      if (is_eth) {
>          if (!(wc->wc_flags & IB_WC_GRH)) {
> @@ -1252,7 +1247,7 @@ out:
>  
>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
>  {
> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
>          return slave;
>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
>  }
> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_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);
> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
>  
>      ctx->state = DEMUX_PV_STATE_STARTING;
>      /* have QP0 only if link layer is IB */
> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
>          ctx->has_smi = 1;
>  
>      if (ctx->has_smi) {
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(ibdev, port))
>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
>      else
>          return iboe_query_gid(ibdev, port, index, gid);
> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
>      int err = 0;
>  
>      for (i = 1; i <= ibdev->num_ports; ++i) {
> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
> -            IB_LINK_LAYER_ETHERNET) {
> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
>              err = reset_gid_table(ibdev, i);
>              if (err)
>                  goto out;
> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
>          if (p > ibdev->num_ports)
>              return;
>          if (mlx4_is_master(dev) &&
> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
> -            IB_LINK_LAYER_INFINIBAND) {
> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
>          }
>          ibev.event = IB_EVENT_PORT_ACTIVE;
> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> index 6eb743f..1befeb8 100644
> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
>  {
>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
>  
> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
>          return true;
>  
>      return !!(ah->av.ib.g_slid & 0x80);
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index c880329..bd2f557 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
>  {
> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
> -        IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
>      int vidx;
>      int smac_index;
>      int err;
> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>  
>      /* APM is not supported under RoCE */
>      if (attr_mask & IB_QP_ALT_PATH &&
> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> -        IB_LINK_LAYER_ETHERNET)
> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
>          return -ENOTSUPP;
>  
>      context = kzalloc(sizeof *context, GFP_KERNEL);
> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>                  context->pri_path.fl = 0x80;
>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
>          }
> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> -            IB_LINK_LAYER_ETHERNET) {
> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
>                  context->pri_path.feup = 1 << 7; /* don't fsm */
> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>      }
>  
>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
> -        int is_eth = rdma_port_get_link_layer(
> -                &dev->ib_dev, qp->port) ==
> -                IB_LINK_LAYER_ETHERNET;
> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
>          if (is_eth) {
>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>      }
>  
>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
> -         IB_LINK_LAYER_ETHERNET))
> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
>          goto out;
>  
>      if (attr_mask & IB_QP_PKEY_INDEX) {
> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
>      for (i = 0; i < wr->num_sge; ++i)
>          send_size += wr->sg_list[i].length;
>  
> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
>      is_grh = mlx4_ib_ah_grh_present(ah);
>      if (is_eth) {
>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
>          return;
>  
> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
> -        IB_LINK_LAYER_ETHERNET;
> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
>      if (is_eth)
>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
>          ((path->sched_queue & 4) << 1);
> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
> index cb4c66e..d339b55 100644
> --- a/drivers/infiniband/hw/mlx4/sysfs.c
> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
>  
>  static int add_vf_smi_entries(struct mlx4_port *p)
>  {
> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> -            IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>      int ret;
>  
>      /* do not display entries if eth transport, or if master */
> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
>  
>  static void remove_vf_smi_entries(struct mlx4_port *p)
>  {
> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> -            IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>  
>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
>          return;
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 58b5aa3..3341754 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);
> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>      }
>  
>      for (p = s; p <= e; ++p) {
> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, p))
>              continue;
>          dev = ipoib_add_port("ib%d", device, p);
>          if (!IS_ERR(dev)) {
> @@ -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..2bf9094 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1743,6 +1743,30 @@ 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;
> +}
> +
> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
> +{
> +    return rdma_node_get_transport(device->node_type)
> +            == RDMA_TRANSPORT_IWARP;
> +}
> +
> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_port_get_link_layer(device, port_num)
> +            == IB_LINK_LAYER_INFINIBAND;
> +}
> +
> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_port_get_link_layer(device, port_num)
> +            == IB_LINK_LAYER_ETHERNET;
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>           u8 port_num, int index, union ib_gid *gid);
>  
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index e011027..a7b5891 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
> -         RDMA_TRANSPORT_IWARP)
> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>          return 1;
>      else
>          return min_t(int, sge_count, xprt->sc_max_sge);


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-30 15:56       ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 15:56 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

[-- Attachment #1: Type: text/plain, Size: 30195 bytes --]

On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
> We have so much places to check transport type and link layer type, it's now
> make sense to introduce some helpers in order to refine the lengthy code.
> 
> This patch will introduce helpers:
>     rdma_transport_is_ib()
>     rdma_transport_is_iwarp()
>     rdma_port_ll_is_ib()
>     rdma_port_ll_is_eth()
> and use them to save some code for us.

If the end result is to do something like I proposed, then why take this
intermediate step that just has to be backed out later?

In other words, if our end goal is to have

rdma_transport_is_ib()
rdma_transport_is_iwarp()
rdma_transport_is_roce()
rdma_transport_is_opa()

Then we should skip doing rdma_port_ll_is_*() as the answers to these
items would be implied by rdma_transport_is_roce() and such.

> 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/agent.c           |  2 +-
>  drivers/infiniband/core/cm.c              |  2 +-
>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
>  drivers/infiniband/core/mad.c             |  6 +++---
>  drivers/infiniband/core/multicast.c       | 11 ++++-------
>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
>  drivers/infiniband/core/ucm.c             |  3 +--
>  drivers/infiniband/core/user_mad.c        |  2 +-
>  drivers/infiniband/core/verbs.c           |  5 ++---
>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
>  19 files changed, 79 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> index f6d2961..27f1bec 100644
> --- a/drivers/infiniband/core/agent.c
> +++ b/drivers/infiniband/core/agent.c
> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
>          goto error1;
>      }
>  
> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
> +    if (rdma_port_ll_is_ib(device, port_num)) {
>          /* Obtain send only MAD agent for SMI QP */
>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>                                  IB_QPT_SMI, NULL, 0,
> 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..668e955 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -375,8 +375,8 @@ 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 &&
> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> +        if (rdma_transport_is_ib(cma_dev->device) &&
> +            rdma_port_ll_is_eth(cma_dev->device, port))
>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>                           &found_port, NULL);
>          else
> @@ -395,8 +395,8 @@ 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 &&
> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> +                if (rdma_transport_is_ib(cma_dev->device) &&
> +                    rdma_port_ll_is_eth(cma_dev->device, port))
>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>                  else
>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> @@ -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,10 +633,8 @@ 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 &&
> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
> -        == IB_LINK_LAYER_ETHERNET) {
> +    if (rdma_transport_is_ib(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);
>  
>          if (ret)
> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
>      int ret;
>      u16 pkey;
>  
> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
>          pkey = ib_addr_get_pkey(dev_addr);
>      else
>          pkey = 0xffff;
> @@ -1626,7 +1623,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 +2025,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)
> @@ -2060,7 +2057,7 @@ port_found:
>          goto out;
>  
>      id_priv->id.route.addr.dev_addr.dev_type =
> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
>  
>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
> @@ -3405,7 +3402,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..23cf9e8 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
>  
>      cq_size = mad_sendq_size + mad_recvq_size;
> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
> +    has_smi = rdma_port_ll_is_ib(device, port_num);
>      if (has_smi)
>          cq_size *= 2;
>  
> @@ -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..17573ff 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>          return;
>  
>      index = event->element.port_num - dev->start_port;
> @@ -808,7 +807,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,
> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>      }
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
> -            IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>              continue;
>          port = &dev->port[i];
>          port->dev = dev;
> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>      flush_workqueue(mcast_wq);
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
> -            IB_LINK_LAYER_INFINIBAND) {
> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>              port = &dev->port[i];
>              deref_port(port);
>              wait_for_completion(&port->comp);
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index c38f030..d95d25f 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
>      ah_attr->port_num = port_num;
>      ah_attr->static_rate = rec->rate;
>  
> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
> +    force_grh = rdma_port_ll_is_eth(device, port_num);
>  
>      if (rec->hop_limit > 1 || force_grh) {
>          ah_attr->ah_flags = IB_AH_GRH;
> @@ -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)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> +        if (rdma_port_ll_is_ib(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> +        if (rdma_port_ll_is_ib(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
> +        if (rdma_port_ll_is_ib(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
> index f93eb8d..d8d015a 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
>      u32 flow_class;
>      u16 gid_index;
>      int ret;
> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
> -            IB_LINK_LAYER_ETHERNET);
> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
>  
>      memset(ah_attr, 0, sizeof *ah_attr);
>      if (is_eth) {
> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
>      union ib_gid  sgid;
>  
>      if ((*qp_attr_mask & IB_QP_AV)  &&
> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
>          if (ret)
> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
> index 2d8c339..829eb60 100644
> --- a/drivers/infiniband/hw/mlx4/ah.c
> +++ b/drivers/infiniband/hw/mlx4/ah.c
> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
>      if (!ah)
>          return ERR_PTR(-ENOMEM);
>  
> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
>              ret = ERR_PTR(-EINVAL);
>          } else {
> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
> index cb63ecd..0417f03 100644
> --- a/drivers/infiniband/hw/mlx4/cq.c
> +++ b/drivers/infiniband/hw/mlx4/cq.c
> @@ -789,9 +789,7 @@ repoll:
>              break;
>          }
>  
> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
> -                          (*cur_qp)->port) ==
> -              IB_LINK_LAYER_ETHERNET);
> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
>              if ((*cur_qp)->mlx4_ib_qp_type &
>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 82a7dd8..4736fc7 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
>      int err;
>      int slave;
>      u8 *slave_id;
> -    int is_eth = 0;
> -
> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> -        is_eth = 0;
> -    else
> -        is_eth = 1;
> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
>  
>      if (is_eth) {
>          if (!(wc->wc_flags & IB_WC_GRH)) {
> @@ -1252,7 +1247,7 @@ out:
>  
>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
>  {
> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
>          return slave;
>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
>  }
> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_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);
> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
>  
>      ctx->state = DEMUX_PV_STATE_STARTING;
>      /* have QP0 only if link layer is IB */
> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
>          ctx->has_smi = 1;
>  
>      if (ctx->has_smi) {
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(ibdev, port))
>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
>      else
>          return iboe_query_gid(ibdev, port, index, gid);
> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
>      int err = 0;
>  
>      for (i = 1; i <= ibdev->num_ports; ++i) {
> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
> -            IB_LINK_LAYER_ETHERNET) {
> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
>              err = reset_gid_table(ibdev, i);
>              if (err)
>                  goto out;
> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
>          if (p > ibdev->num_ports)
>              return;
>          if (mlx4_is_master(dev) &&
> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
> -            IB_LINK_LAYER_INFINIBAND) {
> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
>          }
>          ibev.event = IB_EVENT_PORT_ACTIVE;
> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> index 6eb743f..1befeb8 100644
> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
>  {
>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
>  
> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
>          return true;
>  
>      return !!(ah->av.ib.g_slid & 0x80);
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index c880329..bd2f557 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
>  {
> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
> -        IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
>      int vidx;
>      int smac_index;
>      int err;
> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>  
>      /* APM is not supported under RoCE */
>      if (attr_mask & IB_QP_ALT_PATH &&
> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> -        IB_LINK_LAYER_ETHERNET)
> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
>          return -ENOTSUPP;
>  
>      context = kzalloc(sizeof *context, GFP_KERNEL);
> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>                  context->pri_path.fl = 0x80;
>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
>          }
> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> -            IB_LINK_LAYER_ETHERNET) {
> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
>                  context->pri_path.feup = 1 << 7; /* don't fsm */
> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>      }
>  
>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
> -        int is_eth = rdma_port_get_link_layer(
> -                &dev->ib_dev, qp->port) ==
> -                IB_LINK_LAYER_ETHERNET;
> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
>          if (is_eth) {
>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>      }
>  
>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
> -         IB_LINK_LAYER_ETHERNET))
> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
>          goto out;
>  
>      if (attr_mask & IB_QP_PKEY_INDEX) {
> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
>      for (i = 0; i < wr->num_sge; ++i)
>          send_size += wr->sg_list[i].length;
>  
> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
>      is_grh = mlx4_ib_ah_grh_present(ah);
>      if (is_eth) {
>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
>          return;
>  
> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
> -        IB_LINK_LAYER_ETHERNET;
> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
>      if (is_eth)
>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
>          ((path->sched_queue & 4) << 1);
> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
> index cb4c66e..d339b55 100644
> --- a/drivers/infiniband/hw/mlx4/sysfs.c
> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
>  
>  static int add_vf_smi_entries(struct mlx4_port *p)
>  {
> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> -            IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>      int ret;
>  
>      /* do not display entries if eth transport, or if master */
> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
>  
>  static void remove_vf_smi_entries(struct mlx4_port *p)
>  {
> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> -            IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>  
>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
>          return;
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 58b5aa3..3341754 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);
> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>      }
>  
>      for (p = s; p <= e; ++p) {
> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, p))
>              continue;
>          dev = ipoib_add_port("ib%d", device, p);
>          if (!IS_ERR(dev)) {
> @@ -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..2bf9094 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1743,6 +1743,30 @@ 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;
> +}
> +
> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
> +{
> +    return rdma_node_get_transport(device->node_type)
> +            == RDMA_TRANSPORT_IWARP;
> +}
> +
> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_port_get_link_layer(device, port_num)
> +            == IB_LINK_LAYER_INFINIBAND;
> +}
> +
> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_port_get_link_layer(device, port_num)
> +            == IB_LINK_LAYER_ETHERNET;
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>           u8 port_num, int index, union ib_gid *gid);
>  
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index e011027..a7b5891 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
> -         RDMA_TRANSPORT_IWARP)
> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>          return 1;
>      else
>          return min_t(int, sge_count, xprt->sc_max_sge);


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-30 15:56       ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 15:56 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 30195 bytes --]

On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
> We have so much places to check transport type and link layer type, it's now
> make sense to introduce some helpers in order to refine the lengthy code.
> 
> This patch will introduce helpers:
>     rdma_transport_is_ib()
>     rdma_transport_is_iwarp()
>     rdma_port_ll_is_ib()
>     rdma_port_ll_is_eth()
> and use them to save some code for us.

If the end result is to do something like I proposed, then why take this
intermediate step that just has to be backed out later?

In other words, if our end goal is to have

rdma_transport_is_ib()
rdma_transport_is_iwarp()
rdma_transport_is_roce()
rdma_transport_is_opa()

Then we should skip doing rdma_port_ll_is_*() as the answers to these
items would be implied by rdma_transport_is_roce() and such.

> 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/agent.c           |  2 +-
>  drivers/infiniband/core/cm.c              |  2 +-
>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
>  drivers/infiniband/core/mad.c             |  6 +++---
>  drivers/infiniband/core/multicast.c       | 11 ++++-------
>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
>  drivers/infiniband/core/ucm.c             |  3 +--
>  drivers/infiniband/core/user_mad.c        |  2 +-
>  drivers/infiniband/core/verbs.c           |  5 ++---
>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
>  19 files changed, 79 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> index f6d2961..27f1bec 100644
> --- a/drivers/infiniband/core/agent.c
> +++ b/drivers/infiniband/core/agent.c
> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
>          goto error1;
>      }
>  
> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
> +    if (rdma_port_ll_is_ib(device, port_num)) {
>          /* Obtain send only MAD agent for SMI QP */
>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>                                  IB_QPT_SMI, NULL, 0,
> 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..668e955 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -375,8 +375,8 @@ 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 &&
> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> +        if (rdma_transport_is_ib(cma_dev->device) &&
> +            rdma_port_ll_is_eth(cma_dev->device, port))
>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>                           &found_port, NULL);
>          else
> @@ -395,8 +395,8 @@ 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 &&
> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> +                if (rdma_transport_is_ib(cma_dev->device) &&
> +                    rdma_port_ll_is_eth(cma_dev->device, port))
>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>                  else
>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> @@ -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,10 +633,8 @@ 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 &&
> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
> -        == IB_LINK_LAYER_ETHERNET) {
> +    if (rdma_transport_is_ib(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);
>  
>          if (ret)
> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
>      int ret;
>      u16 pkey;
>  
> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
>          pkey = ib_addr_get_pkey(dev_addr);
>      else
>          pkey = 0xffff;
> @@ -1626,7 +1623,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 +2025,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)
> @@ -2060,7 +2057,7 @@ port_found:
>          goto out;
>  
>      id_priv->id.route.addr.dev_addr.dev_type =
> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
>  
>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
> @@ -3405,7 +3402,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..23cf9e8 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
>  
>      cq_size = mad_sendq_size + mad_recvq_size;
> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
> +    has_smi = rdma_port_ll_is_ib(device, port_num);
>      if (has_smi)
>          cq_size *= 2;
>  
> @@ -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..17573ff 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>          return;
>  
>      index = event->element.port_num - dev->start_port;
> @@ -808,7 +807,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,
> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>      }
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
> -            IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>              continue;
>          port = &dev->port[i];
>          port->dev = dev;
> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>      flush_workqueue(mcast_wq);
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
> -            IB_LINK_LAYER_INFINIBAND) {
> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>              port = &dev->port[i];
>              deref_port(port);
>              wait_for_completion(&port->comp);
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index c38f030..d95d25f 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
>      ah_attr->port_num = port_num;
>      ah_attr->static_rate = rec->rate;
>  
> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
> +    force_grh = rdma_port_ll_is_eth(device, port_num);
>  
>      if (rec->hop_limit > 1 || force_grh) {
>          ah_attr->ah_flags = IB_AH_GRH;
> @@ -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)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> +        if (rdma_port_ll_is_ib(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> +        if (rdma_port_ll_is_ib(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
> +        if (rdma_port_ll_is_ib(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
> index f93eb8d..d8d015a 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
>      u32 flow_class;
>      u16 gid_index;
>      int ret;
> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
> -            IB_LINK_LAYER_ETHERNET);
> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
>  
>      memset(ah_attr, 0, sizeof *ah_attr);
>      if (is_eth) {
> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
>      union ib_gid  sgid;
>  
>      if ((*qp_attr_mask & IB_QP_AV)  &&
> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
>          if (ret)
> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
> index 2d8c339..829eb60 100644
> --- a/drivers/infiniband/hw/mlx4/ah.c
> +++ b/drivers/infiniband/hw/mlx4/ah.c
> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
>      if (!ah)
>          return ERR_PTR(-ENOMEM);
>  
> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
>              ret = ERR_PTR(-EINVAL);
>          } else {
> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
> index cb63ecd..0417f03 100644
> --- a/drivers/infiniband/hw/mlx4/cq.c
> +++ b/drivers/infiniband/hw/mlx4/cq.c
> @@ -789,9 +789,7 @@ repoll:
>              break;
>          }
>  
> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
> -                          (*cur_qp)->port) ==
> -              IB_LINK_LAYER_ETHERNET);
> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
>              if ((*cur_qp)->mlx4_ib_qp_type &
>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 82a7dd8..4736fc7 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
>      int err;
>      int slave;
>      u8 *slave_id;
> -    int is_eth = 0;
> -
> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> -        is_eth = 0;
> -    else
> -        is_eth = 1;
> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
>  
>      if (is_eth) {
>          if (!(wc->wc_flags & IB_WC_GRH)) {
> @@ -1252,7 +1247,7 @@ out:
>  
>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
>  {
> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
>          return slave;
>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
>  }
> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_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);
> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
>  
>      ctx->state = DEMUX_PV_STATE_STARTING;
>      /* have QP0 only if link layer is IB */
> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
> -        IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
>          ctx->has_smi = 1;
>  
>      if (ctx->has_smi) {
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> +    if (rdma_port_ll_is_ib(ibdev, port))
>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
>      else
>          return iboe_query_gid(ibdev, port, index, gid);
> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
>      int err = 0;
>  
>      for (i = 1; i <= ibdev->num_ports; ++i) {
> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
> -            IB_LINK_LAYER_ETHERNET) {
> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
>              err = reset_gid_table(ibdev, i);
>              if (err)
>                  goto out;
> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
>          if (p > ibdev->num_ports)
>              return;
>          if (mlx4_is_master(dev) &&
> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
> -            IB_LINK_LAYER_INFINIBAND) {
> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
>          }
>          ibev.event = IB_EVENT_PORT_ACTIVE;
> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> index 6eb743f..1befeb8 100644
> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
>  {
>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
>  
> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
>          return true;
>  
>      return !!(ah->av.ib.g_slid & 0x80);
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index c880329..bd2f557 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
>  {
> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
> -        IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
>      int vidx;
>      int smac_index;
>      int err;
> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>  
>      /* APM is not supported under RoCE */
>      if (attr_mask & IB_QP_ALT_PATH &&
> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> -        IB_LINK_LAYER_ETHERNET)
> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
>          return -ENOTSUPP;
>  
>      context = kzalloc(sizeof *context, GFP_KERNEL);
> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>                  context->pri_path.fl = 0x80;
>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
>          }
> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> -            IB_LINK_LAYER_ETHERNET) {
> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
>                  context->pri_path.feup = 1 << 7; /* don't fsm */
> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>      }
>  
>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
> -        int is_eth = rdma_port_get_link_layer(
> -                &dev->ib_dev, qp->port) ==
> -                IB_LINK_LAYER_ETHERNET;
> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
>          if (is_eth) {
>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>      }
>  
>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
> -         IB_LINK_LAYER_ETHERNET))
> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
>          goto out;
>  
>      if (attr_mask & IB_QP_PKEY_INDEX) {
> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
>      for (i = 0; i < wr->num_sge; ++i)
>          send_size += wr->sg_list[i].length;
>  
> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
>      is_grh = mlx4_ib_ah_grh_present(ah);
>      if (is_eth) {
>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
>          return;
>  
> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
> -        IB_LINK_LAYER_ETHERNET;
> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
>      if (is_eth)
>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
>          ((path->sched_queue & 4) << 1);
> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
> index cb4c66e..d339b55 100644
> --- a/drivers/infiniband/hw/mlx4/sysfs.c
> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
>  
>  static int add_vf_smi_entries(struct mlx4_port *p)
>  {
> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> -            IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>      int ret;
>  
>      /* do not display entries if eth transport, or if master */
> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
>  
>  static void remove_vf_smi_entries(struct mlx4_port *p)
>  {
> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> -            IB_LINK_LAYER_ETHERNET;
> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>  
>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
>          return;
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 58b5aa3..3341754 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);
> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>      }
>  
>      for (p = s; p <= e; ++p) {
> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
> +        if (!rdma_port_ll_is_ib(device, p))
>              continue;
>          dev = ipoib_add_port("ib%d", device, p);
>          if (!IS_ERR(dev)) {
> @@ -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..2bf9094 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1743,6 +1743,30 @@ 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;
> +}
> +
> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
> +{
> +    return rdma_node_get_transport(device->node_type)
> +            == RDMA_TRANSPORT_IWARP;
> +}
> +
> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_port_get_link_layer(device, port_num)
> +            == IB_LINK_LAYER_INFINIBAND;
> +}
> +
> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_port_get_link_layer(device, port_num)
> +            == IB_LINK_LAYER_ETHERNET;
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>           u8 port_num, int index, union ib_gid *gid);
>  
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index e011027..a7b5891 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
> -         RDMA_TRANSPORT_IWARP)
> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>          return 1;
>      else
>          return min_t(int, sge_count, xprt->sc_max_sge);


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-27 15:46     ` Michael Wang
  (?)
@ 2015-03-30 16:11         ` Doug Ledford
  -1 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:11 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 5158 bytes --]

On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
> Introduce helper has_mcast() and cap_mcast() to help us check if an
> IB device or it's port support Multicast.

This probably needs reworded or rethought.  In truth, *all* rdma devices
are multicast capable.  *BUT*, IB/OPA devices require multicast
registration done the IB way (including for sendonly multicast sends),
while Ethernet devices do multicast the Ethernet way.  These tests are
really just for IB specific multicast registration and deregistration.
Call it has_mcast() and cap_mcast() is incorrect.

> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
> ---
>  drivers/infiniband/core/cma.c       |  2 +-
>  drivers/infiniband/core/multicast.c |  8 ++++----
>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>  3 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 276fb76..cbbc85b 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> +            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
> index 17573ff..ffeaf27 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> +    if (!cap_mcast(dev->device, event->element.port_num))
>          return;
>  
>      index = event->element.port_num - dev->start_port;
> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>      int i;
>      int count = 0;
>  
> -    if (!rdma_transport_is_ib(device))
> +    if (!has_mcast(device))
>          return;
>  
>      dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
> @@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>      }
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
> +        if (!cap_mcast(device, dev->start_port + i))
>              continue;
>          port = &dev->port[i];
>          port->dev = dev;
> @@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>      flush_workqueue(mcast_wq);
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
> +        if (cap_mcast(device, dev->start_port + i)) {
>              port = &dev->port[i];
>              deref_port(port);
>              wait_for_completion(&port->comp);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index fa8ffa3..e796104 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
>  }
>  
>  /**
> + * has_mcast - Check if a device support Multicast.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Multicast.
> + */
> +static inline int has_mcast(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_mcast - Check if the port of device has the capability
> + * Multicast.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Multicast.
> + */
> +static inline int cap_mcast(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);
>  


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-30 16:11         ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:11 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

[-- Attachment #1: Type: text/plain, Size: 4988 bytes --]

On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
> Introduce helper has_mcast() and cap_mcast() to help us check if an
> IB device or it's port support Multicast.

This probably needs reworded or rethought.  In truth, *all* rdma devices
are multicast capable.  *BUT*, IB/OPA devices require multicast
registration done the IB way (including for sendonly multicast sends),
while Ethernet devices do multicast the Ethernet way.  These tests are
really just for IB specific multicast registration and deregistration.
Call it has_mcast() and cap_mcast() is incorrect.

> 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/cma.c       |  2 +-
>  drivers/infiniband/core/multicast.c |  8 ++++----
>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>  3 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 276fb76..cbbc85b 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> +            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
> index 17573ff..ffeaf27 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> +    if (!cap_mcast(dev->device, event->element.port_num))
>          return;
>  
>      index = event->element.port_num - dev->start_port;
> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>      int i;
>      int count = 0;
>  
> -    if (!rdma_transport_is_ib(device))
> +    if (!has_mcast(device))
>          return;
>  
>      dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
> @@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>      }
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
> +        if (!cap_mcast(device, dev->start_port + i))
>              continue;
>          port = &dev->port[i];
>          port->dev = dev;
> @@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>      flush_workqueue(mcast_wq);
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
> +        if (cap_mcast(device, dev->start_port + i)) {
>              port = &dev->port[i];
>              deref_port(port);
>              wait_for_completion(&port->comp);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index fa8ffa3..e796104 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
>  }
>  
>  /**
> + * has_mcast - Check if a device support Multicast.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Multicast.
> + */
> +static inline int has_mcast(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_mcast - Check if the port of device has the capability
> + * Multicast.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Multicast.
> + */
> +static inline int cap_mcast(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);
>  


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-30 16:11         ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:11 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 5158 bytes --]

On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
> Introduce helper has_mcast() and cap_mcast() to help us check if an
> IB device or it's port support Multicast.

This probably needs reworded or rethought.  In truth, *all* rdma devices
are multicast capable.  *BUT*, IB/OPA devices require multicast
registration done the IB way (including for sendonly multicast sends),
while Ethernet devices do multicast the Ethernet way.  These tests are
really just for IB specific multicast registration and deregistration.
Call it has_mcast() and cap_mcast() is incorrect.

> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
> ---
>  drivers/infiniband/core/cma.c       |  2 +-
>  drivers/infiniband/core/multicast.c |  8 ++++----
>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>  3 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 276fb76..cbbc85b 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
> +            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
> index 17573ff..ffeaf27 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>      int index;
>  
>      dev = container_of(handler, struct mcast_device, event_handler);
> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> +    if (!cap_mcast(dev->device, event->element.port_num))
>          return;
>  
>      index = event->element.port_num - dev->start_port;
> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>      int i;
>      int count = 0;
>  
> -    if (!rdma_transport_is_ib(device))
> +    if (!has_mcast(device))
>          return;
>  
>      dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
> @@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>      }
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
> +        if (!cap_mcast(device, dev->start_port + i))
>              continue;
>          port = &dev->port[i];
>          port->dev = dev;
> @@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>      flush_workqueue(mcast_wq);
>  
>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> -        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
> +        if (cap_mcast(device, dev->start_port + i)) {
>              port = &dev->port[i];
>              deref_port(port);
>              wait_for_completion(&port->comp);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index fa8ffa3..e796104 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
>  }
>  
>  /**
> + * has_mcast - Check if a device support Multicast.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Multicast.
> + */
> +static inline int has_mcast(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_mcast - Check if the port of device has the capability
> + * Multicast.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Multicast.
> + */
> +static inline int cap_mcast(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);
>  


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-27 15:47   ` Michael Wang
  (?)
@ 2015-03-30 16:13     ` Doug Ledford
  -1 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:13 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]

On Fri, 2015-03-27 at 16:47 +0100, Michael Wang wrote:
> Introduce helper has_iwarp() to help us check if an IB device
> support IWARP protocol.

This is a needless redirection.  Just stick with the original
rdma_transport_is_iwarp().

> 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>
> ---
>  include/rdma/ib_verbs.h                 | 13 +++++++++++++
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index e796104..0ef9cd7 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
>  }
>  
>  /**
> + * has_iwarp - Check if a device support IWARP protocol.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * IWARP protocol.
> + */
> +static inline int has_iwarp(struct ib_device *device)
> +{
> +    return rdma_transport_is_iwarp(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index a7b5891..48aeb5e 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> -    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
> +    if (has_iwarp(xprt->sc_cm_id->device))
>          return 1;
>      else
>          return min_t(int, sge_count, xprt->sc_max_sge);


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-30 16:13     ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:13 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]

On Fri, 2015-03-27 at 16:47 +0100, Michael Wang wrote:
> Introduce helper has_iwarp() to help us check if an IB device
> support IWARP protocol.

This is a needless redirection.  Just stick with the original
rdma_transport_is_iwarp().

> 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>
> ---
>  include/rdma/ib_verbs.h                 | 13 +++++++++++++
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index e796104..0ef9cd7 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
>  }
>  
>  /**
> + * has_iwarp - Check if a device support IWARP protocol.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * IWARP protocol.
> + */
> +static inline int has_iwarp(struct ib_device *device)
> +{
> +    return rdma_transport_is_iwarp(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index a7b5891..48aeb5e 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> -    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
> +    if (has_iwarp(xprt->sc_cm_id->device))
>          return 1;
>      else
>          return min_t(int, sge_count, xprt->sc_max_sge);


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-30 16:13     ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:13 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]

On Fri, 2015-03-27 at 16:47 +0100, Michael Wang wrote:
> Introduce helper has_iwarp() to help us check if an IB device
> support IWARP protocol.

This is a needless redirection.  Just stick with the original
rdma_transport_is_iwarp().

> 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>
> ---
>  include/rdma/ib_verbs.h                 | 13 +++++++++++++
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index e796104..0ef9cd7 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
>  }
>  
>  /**
> + * has_iwarp - Check if a device support IWARP protocol.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * IWARP protocol.
> + */
> +static inline int has_iwarp(struct ib_device *device)
> +{
> +    return rdma_transport_is_iwarp(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index a7b5891..48aeb5e 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> -    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
> +    if (has_iwarp(xprt->sc_cm_id->device))
>          return 1;
>      else
>          return min_t(int, sge_count, xprt->sc_max_sge);


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
  2015-03-30 15:56       ` Doug Ledford
  (?)
@ 2015-03-30 16:14           ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:14 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

Hi, Doug

Thanks for the comments :-)

On 03/30/2015 05:56 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
>> We have so much places to check transport type and link layer type, it's now
>> make sense to introduce some helpers in order to refine the lengthy code.
>>
>> This patch will introduce helpers:
>>     rdma_transport_is_ib()
>>     rdma_transport_is_iwarp()
>>     rdma_port_ll_is_ib()
>>     rdma_port_ll_is_eth()
>> and use them to save some code for us.
> If the end result is to do something like I proposed, then why take this
> intermediate step that just has to be backed out later?

The problem is that I found there are still many places our new
mechanism may could not take care, especially inside device driver,
this is just try to collect the issues together as a basement so we can
gradually eliminate them.

Sure if finally we do capture all the cases, we can just get rid of
this one, but I guess it won't be that easy to directly jump into
next stage :-P

As I could imaging, after this reform, next stage could be introducing
the new mechanism without changing device driver, and the last
stage is to asking vendor adapt their code into the new mechanism.

>
> In other words, if our end goal is to have
>
> rdma_transport_is_ib()
> rdma_transport_is_iwarp()
> rdma_transport_is_roce()
> rdma_transport_is_opa()
>
> Then we should skip doing rdma_port_ll_is_*() as the answers to these
> items would be implied by rdma_transport_is_roce() and such.

Great if we achieved that ;-) but currently I just wondering maybe
these helpers can only cover part of the cases where we check
transport and link layer, there are still some cases we'll need the
very rough helper to save some code and make things clean~

Regards,
Michael Wang


>
>> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
>> ---
>>  drivers/infiniband/core/agent.c           |  2 +-
>>  drivers/infiniband/core/cm.c              |  2 +-
>>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
>>  drivers/infiniband/core/mad.c             |  6 +++---
>>  drivers/infiniband/core/multicast.c       | 11 ++++-------
>>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
>>  drivers/infiniband/core/ucm.c             |  3 +--
>>  drivers/infiniband/core/user_mad.c        |  2 +-
>>  drivers/infiniband/core/verbs.c           |  5 ++---
>>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
>>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
>>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
>>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
>>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
>>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
>>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
>>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
>>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
>>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
>>  19 files changed, 79 insertions(+), 83 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
>> index f6d2961..27f1bec 100644
>> --- a/drivers/infiniband/core/agent.c
>> +++ b/drivers/infiniband/core/agent.c
>> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
>>          goto error1;
>>      }
>>  
>> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
>> +    if (rdma_port_ll_is_ib(device, port_num)) {
>>          /* Obtain send only MAD agent for SMI QP */
>>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>>                                  IB_QPT_SMI, NULL, 0,
>> 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..668e955 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -375,8 +375,8 @@ 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 &&
>> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
>> +        if (rdma_transport_is_ib(cma_dev->device) &&
>> +            rdma_port_ll_is_eth(cma_dev->device, port))
>>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>>                           &found_port, NULL);
>>          else
>> @@ -395,8 +395,8 @@ 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 &&
>> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
>> +                if (rdma_transport_is_ib(cma_dev->device) &&
>> +                    rdma_port_ll_is_eth(cma_dev->device, port))
>>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>>                  else
>>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
>> @@ -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,10 +633,8 @@ 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 &&
>> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
>> -        == IB_LINK_LAYER_ETHERNET) {
>> +    if (rdma_transport_is_ib(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);
>>  
>>          if (ret)
>> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
>>      int ret;
>>      u16 pkey;
>>  
>> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
>>          pkey = ib_addr_get_pkey(dev_addr);
>>      else
>>          pkey = 0xffff;
>> @@ -1626,7 +1623,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 +2025,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)
>> @@ -2060,7 +2057,7 @@ port_found:
>>          goto out;
>>  
>>      id_priv->id.route.addr.dev_addr.dev_type =
>> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
>> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
>>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
>>  
>>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
>> @@ -3405,7 +3402,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..23cf9e8 100644
>> --- a/drivers/infiniband/core/mad.c
>> +++ b/drivers/infiniband/core/mad.c
>> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
>>  
>>      cq_size = mad_sendq_size + mad_recvq_size;
>> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
>> +    has_smi = rdma_port_ll_is_ib(device, port_num);
>>      if (has_smi)
>>          cq_size *= 2;
>>  
>> @@ -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..17573ff 100644
>> --- a/drivers/infiniband/core/multicast.c
>> +++ b/drivers/infiniband/core/multicast.c
>> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>>      int index;
>>  
>>      dev = container_of(handler, struct mcast_device, event_handler);
>> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>>          return;
>>  
>>      index = event->element.port_num - dev->start_port;
>> @@ -808,7 +807,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,
>> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>>      }
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
>> -            IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>>              continue;
>>          port = &dev->port[i];
>>          port->dev = dev;
>> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>>      flush_workqueue(mcast_wq);
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
>> -            IB_LINK_LAYER_INFINIBAND) {
>> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>>              port = &dev->port[i];
>>              deref_port(port);
>>              wait_for_completion(&port->comp);
>> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
>> index c38f030..d95d25f 100644
>> --- a/drivers/infiniband/core/sa_query.c
>> +++ b/drivers/infiniband/core/sa_query.c
>> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>>          struct ib_sa_port *port =
>>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>>  
>> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>>              return;
>>  
>>          spin_lock_irqsave(&port->ah_lock, flags);
>> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
>>      ah_attr->port_num = port_num;
>>      ah_attr->static_rate = rec->rate;
>>  
>> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
>> +    force_grh = rdma_port_ll_is_eth(device, port_num);
>>  
>>      if (rec->hop_limit > 1 || force_grh) {
>>          ah_attr->ah_flags = IB_AH_GRH;
>> @@ -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)
>> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>>  
>>      for (i = 0; i <= e - s; ++i) {
>>          spin_lock_init(&sa_dev->port[i].ah_lock);
>> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, i + 1))
>>              continue;
>>  
>>          sa_dev->port[i].sm_ah    = NULL;
>> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>>          goto err;
>>  
>>      for (i = 0; i <= e - s; ++i)
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
>> +        if (rdma_port_ll_is_ib(device, i + 1))
>>              update_sm_ah(&sa_dev->port[i].update_task);
>>  
>>      return;
>>  
>>  err:
>>      while (--i >= 0)
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
>> +        if (rdma_port_ll_is_ib(device, i + 1))
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>  
>>      kfree(sa_dev);
>> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>>      flush_workqueue(ib_wq);
>>  
>>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
>> +        if (rdma_port_ll_is_ib(device, i + 1)) {
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>              if (sa_dev->port[i].sm_ah)
>>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
>> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
>> index f93eb8d..d8d015a 100644
>> --- a/drivers/infiniband/core/verbs.c
>> +++ b/drivers/infiniband/core/verbs.c
>> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
>>      u32 flow_class;
>>      u16 gid_index;
>>      int ret;
>> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
>> -            IB_LINK_LAYER_ETHERNET);
>> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
>>  
>>      memset(ah_attr, 0, sizeof *ah_attr);
>>      if (is_eth) {
>> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
>>      union ib_gid  sgid;
>>  
>>      if ((*qp_attr_mask & IB_QP_AV)  &&
>> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
>> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
>>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
>>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
>>          if (ret)
>> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
>> index 2d8c339..829eb60 100644
>> --- a/drivers/infiniband/hw/mlx4/ah.c
>> +++ b/drivers/infiniband/hw/mlx4/ah.c
>> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
>>      if (!ah)
>>          return ERR_PTR(-ENOMEM);
>>  
>> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
>> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
>>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
>>              ret = ERR_PTR(-EINVAL);
>>          } else {
>> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
>> index cb63ecd..0417f03 100644
>> --- a/drivers/infiniband/hw/mlx4/cq.c
>> +++ b/drivers/infiniband/hw/mlx4/cq.c
>> @@ -789,9 +789,7 @@ repoll:
>>              break;
>>          }
>>  
>> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
>> -                          (*cur_qp)->port) ==
>> -              IB_LINK_LAYER_ETHERNET);
>> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
>>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
>>              if ((*cur_qp)->mlx4_ib_qp_type &
>>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
>> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
>> index 82a7dd8..4736fc7 100644
>> --- a/drivers/infiniband/hw/mlx4/mad.c
>> +++ b/drivers/infiniband/hw/mlx4/mad.c
>> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
>>      int err;
>>      int slave;
>>      u8 *slave_id;
>> -    int is_eth = 0;
>> -
>> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
>> -        is_eth = 0;
>> -    else
>> -        is_eth = 1;
>> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
>>  
>>      if (is_eth) {
>>          if (!(wc->wc_flags & IB_WC_GRH)) {
>> @@ -1252,7 +1247,7 @@ out:
>>  
>>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
>>  {
>> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
>>          return slave;
>>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
>>  }
>> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_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);
>> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
>>  
>>      ctx->state = DEMUX_PV_STATE_STARTING;
>>      /* have QP0 only if link layer is IB */
>> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
>>          ctx->has_smi = 1;
>>  
>>      if (ctx->has_smi) {
>> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
>> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(ibdev, port))
>>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
>>      else
>>          return iboe_query_gid(ibdev, port, index, gid);
>> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
>>      int err = 0;
>>  
>>      for (i = 1; i <= ibdev->num_ports; ++i) {
>> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
>> -            IB_LINK_LAYER_ETHERNET) {
>> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
>>              err = reset_gid_table(ibdev, i);
>>              if (err)
>>                  goto out;
>> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
>>          if (p > ibdev->num_ports)
>>              return;
>>          if (mlx4_is_master(dev) &&
>> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
>> -            IB_LINK_LAYER_INFINIBAND) {
>> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
>>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
>>          }
>>          ibev.event = IB_EVENT_PORT_ACTIVE;
>> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> index 6eb743f..1befeb8 100644
>> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
>>  {
>>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
>>  
>> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
>> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
>>          return true;
>>  
>>      return !!(ah->av.ib.g_slid & 0x80);
>> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
>> index c880329..bd2f557 100644
>> --- a/drivers/infiniband/hw/mlx4/qp.c
>> +++ b/drivers/infiniband/hw/mlx4/qp.c
>> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
>>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
>>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
>> -        IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
>>      int vidx;
>>      int smac_index;
>>      int err;
>> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>  
>>      /* APM is not supported under RoCE */
>>      if (attr_mask & IB_QP_ALT_PATH &&
>> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
>> -        IB_LINK_LAYER_ETHERNET)
>> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
>>          return -ENOTSUPP;
>>  
>>      context = kzalloc(sizeof *context, GFP_KERNEL);
>> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>                  context->pri_path.fl = 0x80;
>>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
>>          }
>> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
>> -            IB_LINK_LAYER_ETHERNET) {
>> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
>>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
>>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
>>                  context->pri_path.feup = 1 << 7; /* don't fsm */
>> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>      }
>>  
>>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
>> -        int is_eth = rdma_port_get_link_layer(
>> -                &dev->ib_dev, qp->port) ==
>> -                IB_LINK_LAYER_ETHERNET;
>> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
>>          if (is_eth) {
>>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
>>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
>> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>>      }
>>  
>>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
>> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
>> -         IB_LINK_LAYER_ETHERNET))
>> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
>>          goto out;
>>  
>>      if (attr_mask & IB_QP_PKEY_INDEX) {
>> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
>>      for (i = 0; i < wr->num_sge; ++i)
>>          send_size += wr->sg_list[i].length;
>>  
>> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
>> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
>>      is_grh = mlx4_ib_ah_grh_present(ah);
>>      if (is_eth) {
>>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
>> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
>>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
>>          return;
>>  
>> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
>> -        IB_LINK_LAYER_ETHERNET;
>> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
>>      if (is_eth)
>>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
>>          ((path->sched_queue & 4) << 1);
>> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
>> index cb4c66e..d339b55 100644
>> --- a/drivers/infiniband/hw/mlx4/sysfs.c
>> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
>> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
>>  
>>  static int add_vf_smi_entries(struct mlx4_port *p)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
>> -            IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>>      int ret;
>>  
>>      /* do not display entries if eth transport, or if master */
>> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
>>  
>>  static void remove_vf_smi_entries(struct mlx4_port *p)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
>> -            IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>>  
>>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
>>          return;
>> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> index 58b5aa3..3341754 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);
>> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>>      }
>>  
>>      for (p = s; p <= e; ++p) {
>> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, p))
>>              continue;
>>          dev = ipoib_add_port("ib%d", device, p);
>>          if (!IS_ERR(dev)) {
>> @@ -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..2bf9094 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1743,6 +1743,30 @@ 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;
>> +}
>> +
>> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
>> +{
>> +    return rdma_node_get_transport(device->node_type)
>> +            == RDMA_TRANSPORT_IWARP;
>> +}
>> +
>> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
>> +{
>> +    return rdma_port_get_link_layer(device, port_num)
>> +            == IB_LINK_LAYER_INFINIBAND;
>> +}
>> +
>> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
>> +{
>> +    return rdma_port_get_link_layer(device, port_num)
>> +            == IB_LINK_LAYER_ETHERNET;
>> +}
>> +
>>  int ib_query_gid(struct ib_device *device,
>>           u8 port_num, int index, union ib_gid *gid);
>>  
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> index e011027..a7b5891 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>>  
>>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>>  {
>> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
>> -         RDMA_TRANSPORT_IWARP)
>> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>>          return 1;
>>      else
>>          return min_t(int, sge_count, xprt->sc_max_sge);
>

--
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	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-30 16:14           ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:14 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

Hi, Doug

Thanks for the comments :-)

On 03/30/2015 05:56 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
>> We have so much places to check transport type and link layer type, it's now
>> make sense to introduce some helpers in order to refine the lengthy code.
>>
>> This patch will introduce helpers:
>>     rdma_transport_is_ib()
>>     rdma_transport_is_iwarp()
>>     rdma_port_ll_is_ib()
>>     rdma_port_ll_is_eth()
>> and use them to save some code for us.
> If the end result is to do something like I proposed, then why take this
> intermediate step that just has to be backed out later?

The problem is that I found there are still many places our new
mechanism may could not take care, especially inside device driver,
this is just try to collect the issues together as a basement so we can
gradually eliminate them.

Sure if finally we do capture all the cases, we can just get rid of
this one, but I guess it won't be that easy to directly jump into
next stage :-P

As I could imaging, after this reform, next stage could be introducing
the new mechanism without changing device driver, and the last
stage is to asking vendor adapt their code into the new mechanism.

>
> In other words, if our end goal is to have
>
> rdma_transport_is_ib()
> rdma_transport_is_iwarp()
> rdma_transport_is_roce()
> rdma_transport_is_opa()
>
> Then we should skip doing rdma_port_ll_is_*() as the answers to these
> items would be implied by rdma_transport_is_roce() and such.

Great if we achieved that ;-) but currently I just wondering maybe
these helpers can only cover part of the cases where we check
transport and link layer, there are still some cases we'll need the
very rough helper to save some code and make things clean~

Regards,
Michael Wang


>
>> 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/agent.c           |  2 +-
>>  drivers/infiniband/core/cm.c              |  2 +-
>>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
>>  drivers/infiniband/core/mad.c             |  6 +++---
>>  drivers/infiniband/core/multicast.c       | 11 ++++-------
>>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
>>  drivers/infiniband/core/ucm.c             |  3 +--
>>  drivers/infiniband/core/user_mad.c        |  2 +-
>>  drivers/infiniband/core/verbs.c           |  5 ++---
>>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
>>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
>>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
>>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
>>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
>>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
>>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
>>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
>>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
>>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
>>  19 files changed, 79 insertions(+), 83 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
>> index f6d2961..27f1bec 100644
>> --- a/drivers/infiniband/core/agent.c
>> +++ b/drivers/infiniband/core/agent.c
>> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
>>          goto error1;
>>      }
>>  
>> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
>> +    if (rdma_port_ll_is_ib(device, port_num)) {
>>          /* Obtain send only MAD agent for SMI QP */
>>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>>                                  IB_QPT_SMI, NULL, 0,
>> 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..668e955 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -375,8 +375,8 @@ 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 &&
>> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
>> +        if (rdma_transport_is_ib(cma_dev->device) &&
>> +            rdma_port_ll_is_eth(cma_dev->device, port))
>>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>>                           &found_port, NULL);
>>          else
>> @@ -395,8 +395,8 @@ 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 &&
>> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
>> +                if (rdma_transport_is_ib(cma_dev->device) &&
>> +                    rdma_port_ll_is_eth(cma_dev->device, port))
>>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>>                  else
>>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
>> @@ -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,10 +633,8 @@ 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 &&
>> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
>> -        == IB_LINK_LAYER_ETHERNET) {
>> +    if (rdma_transport_is_ib(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);
>>  
>>          if (ret)
>> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
>>      int ret;
>>      u16 pkey;
>>  
>> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
>>          pkey = ib_addr_get_pkey(dev_addr);
>>      else
>>          pkey = 0xffff;
>> @@ -1626,7 +1623,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 +2025,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)
>> @@ -2060,7 +2057,7 @@ port_found:
>>          goto out;
>>  
>>      id_priv->id.route.addr.dev_addr.dev_type =
>> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
>> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
>>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
>>  
>>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
>> @@ -3405,7 +3402,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..23cf9e8 100644
>> --- a/drivers/infiniband/core/mad.c
>> +++ b/drivers/infiniband/core/mad.c
>> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
>>  
>>      cq_size = mad_sendq_size + mad_recvq_size;
>> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
>> +    has_smi = rdma_port_ll_is_ib(device, port_num);
>>      if (has_smi)
>>          cq_size *= 2;
>>  
>> @@ -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..17573ff 100644
>> --- a/drivers/infiniband/core/multicast.c
>> +++ b/drivers/infiniband/core/multicast.c
>> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>>      int index;
>>  
>>      dev = container_of(handler, struct mcast_device, event_handler);
>> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>>          return;
>>  
>>      index = event->element.port_num - dev->start_port;
>> @@ -808,7 +807,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,
>> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>>      }
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
>> -            IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>>              continue;
>>          port = &dev->port[i];
>>          port->dev = dev;
>> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>>      flush_workqueue(mcast_wq);
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
>> -            IB_LINK_LAYER_INFINIBAND) {
>> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>>              port = &dev->port[i];
>>              deref_port(port);
>>              wait_for_completion(&port->comp);
>> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
>> index c38f030..d95d25f 100644
>> --- a/drivers/infiniband/core/sa_query.c
>> +++ b/drivers/infiniband/core/sa_query.c
>> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>>          struct ib_sa_port *port =
>>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>>  
>> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>>              return;
>>  
>>          spin_lock_irqsave(&port->ah_lock, flags);
>> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
>>      ah_attr->port_num = port_num;
>>      ah_attr->static_rate = rec->rate;
>>  
>> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
>> +    force_grh = rdma_port_ll_is_eth(device, port_num);
>>  
>>      if (rec->hop_limit > 1 || force_grh) {
>>          ah_attr->ah_flags = IB_AH_GRH;
>> @@ -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)
>> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>>  
>>      for (i = 0; i <= e - s; ++i) {
>>          spin_lock_init(&sa_dev->port[i].ah_lock);
>> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, i + 1))
>>              continue;
>>  
>>          sa_dev->port[i].sm_ah    = NULL;
>> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>>          goto err;
>>  
>>      for (i = 0; i <= e - s; ++i)
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
>> +        if (rdma_port_ll_is_ib(device, i + 1))
>>              update_sm_ah(&sa_dev->port[i].update_task);
>>  
>>      return;
>>  
>>  err:
>>      while (--i >= 0)
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
>> +        if (rdma_port_ll_is_ib(device, i + 1))
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>  
>>      kfree(sa_dev);
>> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>>      flush_workqueue(ib_wq);
>>  
>>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
>> +        if (rdma_port_ll_is_ib(device, i + 1)) {
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>              if (sa_dev->port[i].sm_ah)
>>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
>> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
>> index f93eb8d..d8d015a 100644
>> --- a/drivers/infiniband/core/verbs.c
>> +++ b/drivers/infiniband/core/verbs.c
>> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
>>      u32 flow_class;
>>      u16 gid_index;
>>      int ret;
>> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
>> -            IB_LINK_LAYER_ETHERNET);
>> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
>>  
>>      memset(ah_attr, 0, sizeof *ah_attr);
>>      if (is_eth) {
>> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
>>      union ib_gid  sgid;
>>  
>>      if ((*qp_attr_mask & IB_QP_AV)  &&
>> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
>> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
>>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
>>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
>>          if (ret)
>> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
>> index 2d8c339..829eb60 100644
>> --- a/drivers/infiniband/hw/mlx4/ah.c
>> +++ b/drivers/infiniband/hw/mlx4/ah.c
>> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
>>      if (!ah)
>>          return ERR_PTR(-ENOMEM);
>>  
>> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
>> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
>>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
>>              ret = ERR_PTR(-EINVAL);
>>          } else {
>> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
>> index cb63ecd..0417f03 100644
>> --- a/drivers/infiniband/hw/mlx4/cq.c
>> +++ b/drivers/infiniband/hw/mlx4/cq.c
>> @@ -789,9 +789,7 @@ repoll:
>>              break;
>>          }
>>  
>> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
>> -                          (*cur_qp)->port) ==
>> -              IB_LINK_LAYER_ETHERNET);
>> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
>>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
>>              if ((*cur_qp)->mlx4_ib_qp_type &
>>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
>> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
>> index 82a7dd8..4736fc7 100644
>> --- a/drivers/infiniband/hw/mlx4/mad.c
>> +++ b/drivers/infiniband/hw/mlx4/mad.c
>> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
>>      int err;
>>      int slave;
>>      u8 *slave_id;
>> -    int is_eth = 0;
>> -
>> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
>> -        is_eth = 0;
>> -    else
>> -        is_eth = 1;
>> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
>>  
>>      if (is_eth) {
>>          if (!(wc->wc_flags & IB_WC_GRH)) {
>> @@ -1252,7 +1247,7 @@ out:
>>  
>>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
>>  {
>> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
>>          return slave;
>>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
>>  }
>> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_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);
>> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
>>  
>>      ctx->state = DEMUX_PV_STATE_STARTING;
>>      /* have QP0 only if link layer is IB */
>> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
>>          ctx->has_smi = 1;
>>  
>>      if (ctx->has_smi) {
>> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
>> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(ibdev, port))
>>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
>>      else
>>          return iboe_query_gid(ibdev, port, index, gid);
>> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
>>      int err = 0;
>>  
>>      for (i = 1; i <= ibdev->num_ports; ++i) {
>> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
>> -            IB_LINK_LAYER_ETHERNET) {
>> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
>>              err = reset_gid_table(ibdev, i);
>>              if (err)
>>                  goto out;
>> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
>>          if (p > ibdev->num_ports)
>>              return;
>>          if (mlx4_is_master(dev) &&
>> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
>> -            IB_LINK_LAYER_INFINIBAND) {
>> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
>>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
>>          }
>>          ibev.event = IB_EVENT_PORT_ACTIVE;
>> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> index 6eb743f..1befeb8 100644
>> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
>>  {
>>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
>>  
>> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
>> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
>>          return true;
>>  
>>      return !!(ah->av.ib.g_slid & 0x80);
>> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
>> index c880329..bd2f557 100644
>> --- a/drivers/infiniband/hw/mlx4/qp.c
>> +++ b/drivers/infiniband/hw/mlx4/qp.c
>> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
>>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
>>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
>> -        IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
>>      int vidx;
>>      int smac_index;
>>      int err;
>> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>  
>>      /* APM is not supported under RoCE */
>>      if (attr_mask & IB_QP_ALT_PATH &&
>> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
>> -        IB_LINK_LAYER_ETHERNET)
>> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
>>          return -ENOTSUPP;
>>  
>>      context = kzalloc(sizeof *context, GFP_KERNEL);
>> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>                  context->pri_path.fl = 0x80;
>>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
>>          }
>> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
>> -            IB_LINK_LAYER_ETHERNET) {
>> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
>>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
>>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
>>                  context->pri_path.feup = 1 << 7; /* don't fsm */
>> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>      }
>>  
>>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
>> -        int is_eth = rdma_port_get_link_layer(
>> -                &dev->ib_dev, qp->port) ==
>> -                IB_LINK_LAYER_ETHERNET;
>> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
>>          if (is_eth) {
>>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
>>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
>> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>>      }
>>  
>>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
>> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
>> -         IB_LINK_LAYER_ETHERNET))
>> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
>>          goto out;
>>  
>>      if (attr_mask & IB_QP_PKEY_INDEX) {
>> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
>>      for (i = 0; i < wr->num_sge; ++i)
>>          send_size += wr->sg_list[i].length;
>>  
>> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
>> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
>>      is_grh = mlx4_ib_ah_grh_present(ah);
>>      if (is_eth) {
>>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
>> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
>>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
>>          return;
>>  
>> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
>> -        IB_LINK_LAYER_ETHERNET;
>> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
>>      if (is_eth)
>>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
>>          ((path->sched_queue & 4) << 1);
>> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
>> index cb4c66e..d339b55 100644
>> --- a/drivers/infiniband/hw/mlx4/sysfs.c
>> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
>> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
>>  
>>  static int add_vf_smi_entries(struct mlx4_port *p)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
>> -            IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>>      int ret;
>>  
>>      /* do not display entries if eth transport, or if master */
>> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
>>  
>>  static void remove_vf_smi_entries(struct mlx4_port *p)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
>> -            IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>>  
>>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
>>          return;
>> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> index 58b5aa3..3341754 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);
>> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>>      }
>>  
>>      for (p = s; p <= e; ++p) {
>> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, p))
>>              continue;
>>          dev = ipoib_add_port("ib%d", device, p);
>>          if (!IS_ERR(dev)) {
>> @@ -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..2bf9094 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1743,6 +1743,30 @@ 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;
>> +}
>> +
>> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
>> +{
>> +    return rdma_node_get_transport(device->node_type)
>> +            == RDMA_TRANSPORT_IWARP;
>> +}
>> +
>> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
>> +{
>> +    return rdma_port_get_link_layer(device, port_num)
>> +            == IB_LINK_LAYER_INFINIBAND;
>> +}
>> +
>> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
>> +{
>> +    return rdma_port_get_link_layer(device, port_num)
>> +            == IB_LINK_LAYER_ETHERNET;
>> +}
>> +
>>  int ib_query_gid(struct ib_device *device,
>>           u8 port_num, int index, union ib_gid *gid);
>>  
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> index e011027..a7b5891 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>>  
>>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>>  {
>> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
>> -         RDMA_TRANSPORT_IWARP)
>> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>>          return 1;
>>      else
>>          return min_t(int, sge_count, xprt->sc_max_sge);
>


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-30 16:14           ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:14 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

Hi, Doug

Thanks for the comments :-)

On 03/30/2015 05:56 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
>> We have so much places to check transport type and link layer type, it's now
>> make sense to introduce some helpers in order to refine the lengthy code.
>>
>> This patch will introduce helpers:
>>     rdma_transport_is_ib()
>>     rdma_transport_is_iwarp()
>>     rdma_port_ll_is_ib()
>>     rdma_port_ll_is_eth()
>> and use them to save some code for us.
> If the end result is to do something like I proposed, then why take this
> intermediate step that just has to be backed out later?

The problem is that I found there are still many places our new
mechanism may could not take care, especially inside device driver,
this is just try to collect the issues together as a basement so we can
gradually eliminate them.

Sure if finally we do capture all the cases, we can just get rid of
this one, but I guess it won't be that easy to directly jump into
next stage :-P

As I could imaging, after this reform, next stage could be introducing
the new mechanism without changing device driver, and the last
stage is to asking vendor adapt their code into the new mechanism.

>
> In other words, if our end goal is to have
>
> rdma_transport_is_ib()
> rdma_transport_is_iwarp()
> rdma_transport_is_roce()
> rdma_transport_is_opa()
>
> Then we should skip doing rdma_port_ll_is_*() as the answers to these
> items would be implied by rdma_transport_is_roce() and such.

Great if we achieved that ;-) but currently I just wondering maybe
these helpers can only cover part of the cases where we check
transport and link layer, there are still some cases we'll need the
very rough helper to save some code and make things clean~

Regards,
Michael Wang


>
>> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
>> ---
>>  drivers/infiniband/core/agent.c           |  2 +-
>>  drivers/infiniband/core/cm.c              |  2 +-
>>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
>>  drivers/infiniband/core/mad.c             |  6 +++---
>>  drivers/infiniband/core/multicast.c       | 11 ++++-------
>>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
>>  drivers/infiniband/core/ucm.c             |  3 +--
>>  drivers/infiniband/core/user_mad.c        |  2 +-
>>  drivers/infiniband/core/verbs.c           |  5 ++---
>>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
>>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
>>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
>>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
>>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
>>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
>>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
>>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
>>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
>>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
>>  19 files changed, 79 insertions(+), 83 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
>> index f6d2961..27f1bec 100644
>> --- a/drivers/infiniband/core/agent.c
>> +++ b/drivers/infiniband/core/agent.c
>> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
>>          goto error1;
>>      }
>>  
>> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
>> +    if (rdma_port_ll_is_ib(device, port_num)) {
>>          /* Obtain send only MAD agent for SMI QP */
>>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>>                                  IB_QPT_SMI, NULL, 0,
>> 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..668e955 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -375,8 +375,8 @@ 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 &&
>> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
>> +        if (rdma_transport_is_ib(cma_dev->device) &&
>> +            rdma_port_ll_is_eth(cma_dev->device, port))
>>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>>                           &found_port, NULL);
>>          else
>> @@ -395,8 +395,8 @@ 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 &&
>> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
>> +                if (rdma_transport_is_ib(cma_dev->device) &&
>> +                    rdma_port_ll_is_eth(cma_dev->device, port))
>>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>>                  else
>>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
>> @@ -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,10 +633,8 @@ 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 &&
>> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
>> -        == IB_LINK_LAYER_ETHERNET) {
>> +    if (rdma_transport_is_ib(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);
>>  
>>          if (ret)
>> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
>>      int ret;
>>      u16 pkey;
>>  
>> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
>>          pkey = ib_addr_get_pkey(dev_addr);
>>      else
>>          pkey = 0xffff;
>> @@ -1626,7 +1623,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 +2025,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)
>> @@ -2060,7 +2057,7 @@ port_found:
>>          goto out;
>>  
>>      id_priv->id.route.addr.dev_addr.dev_type =
>> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
>> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
>>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
>>  
>>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
>> @@ -3405,7 +3402,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..23cf9e8 100644
>> --- a/drivers/infiniband/core/mad.c
>> +++ b/drivers/infiniband/core/mad.c
>> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
>>  
>>      cq_size = mad_sendq_size + mad_recvq_size;
>> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
>> +    has_smi = rdma_port_ll_is_ib(device, port_num);
>>      if (has_smi)
>>          cq_size *= 2;
>>  
>> @@ -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..17573ff 100644
>> --- a/drivers/infiniband/core/multicast.c
>> +++ b/drivers/infiniband/core/multicast.c
>> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>>      int index;
>>  
>>      dev = container_of(handler, struct mcast_device, event_handler);
>> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>>          return;
>>  
>>      index = event->element.port_num - dev->start_port;
>> @@ -808,7 +807,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,
>> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>>      }
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
>> -            IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>>              continue;
>>          port = &dev->port[i];
>>          port->dev = dev;
>> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>>      flush_workqueue(mcast_wq);
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
>> -            IB_LINK_LAYER_INFINIBAND) {
>> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>>              port = &dev->port[i];
>>              deref_port(port);
>>              wait_for_completion(&port->comp);
>> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
>> index c38f030..d95d25f 100644
>> --- a/drivers/infiniband/core/sa_query.c
>> +++ b/drivers/infiniband/core/sa_query.c
>> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>>          struct ib_sa_port *port =
>>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>>  
>> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
>>              return;
>>  
>>          spin_lock_irqsave(&port->ah_lock, flags);
>> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
>>      ah_attr->port_num = port_num;
>>      ah_attr->static_rate = rec->rate;
>>  
>> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
>> +    force_grh = rdma_port_ll_is_eth(device, port_num);
>>  
>>      if (rec->hop_limit > 1 || force_grh) {
>>          ah_attr->ah_flags = IB_AH_GRH;
>> @@ -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)
>> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>>  
>>      for (i = 0; i <= e - s; ++i) {
>>          spin_lock_init(&sa_dev->port[i].ah_lock);
>> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, i + 1))
>>              continue;
>>  
>>          sa_dev->port[i].sm_ah    = NULL;
>> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>>          goto err;
>>  
>>      for (i = 0; i <= e - s; ++i)
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
>> +        if (rdma_port_ll_is_ib(device, i + 1))
>>              update_sm_ah(&sa_dev->port[i].update_task);
>>  
>>      return;
>>  
>>  err:
>>      while (--i >= 0)
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
>> +        if (rdma_port_ll_is_ib(device, i + 1))
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>  
>>      kfree(sa_dev);
>> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>>      flush_workqueue(ib_wq);
>>  
>>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
>> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
>> +        if (rdma_port_ll_is_ib(device, i + 1)) {
>>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>>              if (sa_dev->port[i].sm_ah)
>>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
>> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
>> index f93eb8d..d8d015a 100644
>> --- a/drivers/infiniband/core/verbs.c
>> +++ b/drivers/infiniband/core/verbs.c
>> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
>>      u32 flow_class;
>>      u16 gid_index;
>>      int ret;
>> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
>> -            IB_LINK_LAYER_ETHERNET);
>> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
>>  
>>      memset(ah_attr, 0, sizeof *ah_attr);
>>      if (is_eth) {
>> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
>>      union ib_gid  sgid;
>>  
>>      if ((*qp_attr_mask & IB_QP_AV)  &&
>> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
>> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
>>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
>>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
>>          if (ret)
>> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
>> index 2d8c339..829eb60 100644
>> --- a/drivers/infiniband/hw/mlx4/ah.c
>> +++ b/drivers/infiniband/hw/mlx4/ah.c
>> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
>>      if (!ah)
>>          return ERR_PTR(-ENOMEM);
>>  
>> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
>> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
>>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
>>              ret = ERR_PTR(-EINVAL);
>>          } else {
>> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
>> index cb63ecd..0417f03 100644
>> --- a/drivers/infiniband/hw/mlx4/cq.c
>> +++ b/drivers/infiniband/hw/mlx4/cq.c
>> @@ -789,9 +789,7 @@ repoll:
>>              break;
>>          }
>>  
>> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
>> -                          (*cur_qp)->port) ==
>> -              IB_LINK_LAYER_ETHERNET);
>> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
>>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
>>              if ((*cur_qp)->mlx4_ib_qp_type &
>>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
>> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
>> index 82a7dd8..4736fc7 100644
>> --- a/drivers/infiniband/hw/mlx4/mad.c
>> +++ b/drivers/infiniband/hw/mlx4/mad.c
>> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
>>      int err;
>>      int slave;
>>      u8 *slave_id;
>> -    int is_eth = 0;
>> -
>> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
>> -        is_eth = 0;
>> -    else
>> -        is_eth = 1;
>> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
>>  
>>      if (is_eth) {
>>          if (!(wc->wc_flags & IB_WC_GRH)) {
>> @@ -1252,7 +1247,7 @@ out:
>>  
>>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
>>  {
>> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
>>          return slave;
>>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
>>  }
>> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_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);
>> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
>>  
>>      ctx->state = DEMUX_PV_STATE_STARTING;
>>      /* have QP0 only if link layer is IB */
>> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
>> -        IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
>>          ctx->has_smi = 1;
>>  
>>      if (ctx->has_smi) {
>> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
>> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
>> +    if (rdma_port_ll_is_ib(ibdev, port))
>>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
>>      else
>>          return iboe_query_gid(ibdev, port, index, gid);
>> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
>>      int err = 0;
>>  
>>      for (i = 1; i <= ibdev->num_ports; ++i) {
>> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
>> -            IB_LINK_LAYER_ETHERNET) {
>> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
>>              err = reset_gid_table(ibdev, i);
>>              if (err)
>>                  goto out;
>> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
>>          if (p > ibdev->num_ports)
>>              return;
>>          if (mlx4_is_master(dev) &&
>> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
>> -            IB_LINK_LAYER_INFINIBAND) {
>> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
>>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
>>          }
>>          ibev.event = IB_EVENT_PORT_ACTIVE;
>> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> index 6eb743f..1befeb8 100644
>> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
>> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
>>  {
>>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
>>  
>> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
>> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
>>          return true;
>>  
>>      return !!(ah->av.ib.g_slid & 0x80);
>> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
>> index c880329..bd2f557 100644
>> --- a/drivers/infiniband/hw/mlx4/qp.c
>> +++ b/drivers/infiniband/hw/mlx4/qp.c
>> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
>>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
>>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
>> -        IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
>>      int vidx;
>>      int smac_index;
>>      int err;
>> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>  
>>      /* APM is not supported under RoCE */
>>      if (attr_mask & IB_QP_ALT_PATH &&
>> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
>> -        IB_LINK_LAYER_ETHERNET)
>> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
>>          return -ENOTSUPP;
>>  
>>      context = kzalloc(sizeof *context, GFP_KERNEL);
>> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>                  context->pri_path.fl = 0x80;
>>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
>>          }
>> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
>> -            IB_LINK_LAYER_ETHERNET) {
>> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
>>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
>>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
>>                  context->pri_path.feup = 1 << 7; /* don't fsm */
>> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
>>      }
>>  
>>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
>> -        int is_eth = rdma_port_get_link_layer(
>> -                &dev->ib_dev, qp->port) ==
>> -                IB_LINK_LAYER_ETHERNET;
>> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
>>          if (is_eth) {
>>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
>>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
>> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>>      }
>>  
>>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
>> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
>> -         IB_LINK_LAYER_ETHERNET))
>> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
>>          goto out;
>>  
>>      if (attr_mask & IB_QP_PKEY_INDEX) {
>> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
>>      for (i = 0; i < wr->num_sge; ++i)
>>          send_size += wr->sg_list[i].length;
>>  
>> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
>> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
>>      is_grh = mlx4_ib_ah_grh_present(ah);
>>      if (is_eth) {
>>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
>> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
>>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
>>          return;
>>  
>> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
>> -        IB_LINK_LAYER_ETHERNET;
>> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
>>      if (is_eth)
>>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
>>          ((path->sched_queue & 4) << 1);
>> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
>> index cb4c66e..d339b55 100644
>> --- a/drivers/infiniband/hw/mlx4/sysfs.c
>> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
>> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
>>  
>>  static int add_vf_smi_entries(struct mlx4_port *p)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
>> -            IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>>      int ret;
>>  
>>      /* do not display entries if eth transport, or if master */
>> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
>>  
>>  static void remove_vf_smi_entries(struct mlx4_port *p)
>>  {
>> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
>> -            IB_LINK_LAYER_ETHERNET;
>> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
>>  
>>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
>>          return;
>> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
>> index 58b5aa3..3341754 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);
>> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
>>      }
>>  
>>      for (p = s; p <= e; ++p) {
>> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
>> +        if (!rdma_port_ll_is_ib(device, p))
>>              continue;
>>          dev = ipoib_add_port("ib%d", device, p);
>>          if (!IS_ERR(dev)) {
>> @@ -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..2bf9094 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1743,6 +1743,30 @@ 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;
>> +}
>> +
>> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
>> +{
>> +    return rdma_node_get_transport(device->node_type)
>> +            == RDMA_TRANSPORT_IWARP;
>> +}
>> +
>> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
>> +{
>> +    return rdma_port_get_link_layer(device, port_num)
>> +            == IB_LINK_LAYER_INFINIBAND;
>> +}
>> +
>> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
>> +{
>> +    return rdma_port_get_link_layer(device, port_num)
>> +            == IB_LINK_LAYER_ETHERNET;
>> +}
>> +
>>  int ib_query_gid(struct ib_device *device,
>>           u8 port_num, int index, union ib_gid *gid);
>>  
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> index e011027..a7b5891 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>>  
>>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>>  {
>> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
>> -         RDMA_TRANSPORT_IWARP)
>> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>>          return 1;
>>      else
>>          return min_t(int, sge_count, xprt->sc_max_sge);
>

--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
  2015-03-27 15:46     ` Michael Wang
  (?)
@ 2015-03-30 16:16         ` Doug Ledford
  -1 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:16 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 4706 bytes --]

On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
> Introduce helper has_sa() and cap_sa() to help us check if an IB device
> or it's port support Subnet Administrator.

There's no functional reason to have both rdma_transport_is_ib and
rdma_port_ll_is_ib, just use one.  Then there is also no reason for both
has_sa and cap_sa.  Just use one.

> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
> ---
>  drivers/infiniband/core/sa_query.c | 12 ++++++------
>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index d95d25f..89c27da 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> +        if (!cap_sa(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -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_transport_is_ib(device))
> +    if (!has_sa(device))
>          return;
>  
>      if (device->node_type == RDMA_NODE_IB_SWITCH)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (!rdma_port_ll_is_ib(device, i + 1))
> +        if (!cap_sa(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_ll_is_ib(device, i + 1)) {
> +        if (cap_sa(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0a63f8..fa8ffa3 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>  }
>  
>  /**
> + * has_sa - Check if a device support Subnet Administrator.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Subnet Administrator.
> + */
> +static inline int has_sa(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_sa - Check if the port of device has the capability
> + * Subnet Administrator.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Subnet Administrator.
> + */
> +static inline int cap_sa(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);
>  


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-30 16:16         ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:16 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

[-- Attachment #1: Type: text/plain, Size: 4536 bytes --]

On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
> Introduce helper has_sa() and cap_sa() to help us check if an IB device
> or it's port support Subnet Administrator.

There's no functional reason to have both rdma_transport_is_ib and
rdma_port_ll_is_ib, just use one.  Then there is also no reason for both
has_sa and cap_sa.  Just use one.

> 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/sa_query.c | 12 ++++++------
>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index d95d25f..89c27da 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> +        if (!cap_sa(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -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_transport_is_ib(device))
> +    if (!has_sa(device))
>          return;
>  
>      if (device->node_type == RDMA_NODE_IB_SWITCH)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (!rdma_port_ll_is_ib(device, i + 1))
> +        if (!cap_sa(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_ll_is_ib(device, i + 1)) {
> +        if (cap_sa(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0a63f8..fa8ffa3 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>  }
>  
>  /**
> + * has_sa - Check if a device support Subnet Administrator.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Subnet Administrator.
> + */
> +static inline int has_sa(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_sa - Check if the port of device has the capability
> + * Subnet Administrator.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Subnet Administrator.
> + */
> +static inline int cap_sa(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);
>  


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 06/11] IB/Verbs: Use management helper has_sa() and cap_sa(), for sa-check
@ 2015-03-30 16:16         ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:16 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 4706 bytes --]

On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
> Introduce helper has_sa() and cap_sa() to help us check if an IB device
> or it's port support Subnet Administrator.

There's no functional reason to have both rdma_transport_is_ib and
rdma_port_ll_is_ib, just use one.  Then there is also no reason for both
has_sa and cap_sa.  Just use one.

> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
> ---
>  drivers/infiniband/core/sa_query.c | 12 ++++++------
>  include/rdma/ib_verbs.h            | 28 ++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index d95d25f..89c27da 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
>          struct ib_sa_port *port =
>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
>  
> -        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> +        if (!cap_sa(handler->device, port->port_num))
>              return;
>  
>          spin_lock_irqsave(&port->ah_lock, flags);
> @@ -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_transport_is_ib(device))
> +    if (!has_sa(device))
>          return;
>  
>      if (device->node_type == RDMA_NODE_IB_SWITCH)
> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>      for (i = 0; i <= e - s; ++i) {
>          spin_lock_init(&sa_dev->port[i].ah_lock);
> -        if (!rdma_port_ll_is_ib(device, i + 1))
> +        if (!cap_sa(device, i + 1))
>              continue;
>  
>          sa_dev->port[i].sm_ah    = NULL;
> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
>          goto err;
>  
>      for (i = 0; i <= e - s; ++i)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              update_sm_ah(&sa_dev->port[i].update_task);
>  
>      return;
>  
>  err:
>      while (--i >= 0)
> -        if (rdma_port_ll_is_ib(device, i + 1))
> +        if (cap_sa(device, i + 1))
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>  
>      kfree(sa_dev);
> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>      flush_workqueue(ib_wq);
>  
>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> -        if (rdma_port_ll_is_ib(device, i + 1)) {
> +        if (cap_sa(device, i + 1)) {
>              ib_unregister_mad_agent(sa_dev->port[i].agent);
>              if (sa_dev->port[i].sm_ah)
>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0a63f8..fa8ffa3 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1810,6 +1810,19 @@ static inline int has_cm(struct ib_device *device)
>  }
>  
>  /**
> + * has_sa - Check if a device support Subnet Administrator.
> + *
> + * @device: Device to be checked
> + *
> + * Return 0 when a device has none port to support
> + * Subnet Administrator.
> + */
> +static inline int has_sa(struct ib_device *device)
> +{
> +    return rdma_transport_is_ib(device);
> +}
> +
> +/**
>   * cap_smi - Check if the port of device has the capability
>   * Subnet Management Interface.
>   *
> @@ -1824,6 +1837,21 @@ static inline int cap_smi(struct ib_device *device, u8 port_num)
>      return rdma_port_ll_is_ib(device, port_num);
>  }
>  
> +/**
> + * cap_sa - Check if the port of device has the capability
> + * Subnet Administrator.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Subnet Administrator.
> + */
> +static inline int cap_sa(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);
>  


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
  2015-03-27 15:42   ` Michael Wang
  (?)
@ 2015-03-30 16:17     ` Doug Ledford
  -1 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:17 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 2992 bytes --]

On Fri, 2015-03-27 at 16:42 +0100, Michael Wang wrote:
> Introduce helper tech_iboe() to help us check if the port of an IB
> device is using RoCE/IBoE technology.

Just use rdma_transport_is_roce() instead.

> 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/cma.c |  6 ++----
>  include/rdma/ib_verbs.h       | 16 ++++++++++++++++
>  2 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 668e955..280cfe3 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -375,8 +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_transport_is_ib(cma_dev->device) &&
> -            rdma_port_ll_is_eth(cma_dev->device, port))
> +        if (tech_iboe(cma_dev->device, port))
>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>                           &found_port, NULL);
>          else
> @@ -395,8 +394,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_transport_is_ib(cma_dev->device) &&
> -                    rdma_port_ll_is_eth(cma_dev->device, port))
> +                if (tech_iboe(cma_dev->device, port))
>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>                  else
>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 2bf9094..ca6d6bc 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1767,6 +1767,22 @@ static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
>              == IB_LINK_LAYER_ETHERNET;
>  }
>  
> +/**
> + * tech_iboe - Check if the port of device using technology
> + * RoCE/IBoE.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device is not using technology
> + * RoCE/IBoE.
> + */
> +static inline int tech_iboe(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_transport_is_ib(device) &&
> +            rdma_port_ll_is_eth(device, port_num);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>           u8 port_num, int index, union ib_gid *gid);
>  


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
@ 2015-03-30 16:17     ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:17 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

[-- Attachment #1: Type: text/plain, Size: 2992 bytes --]

On Fri, 2015-03-27 at 16:42 +0100, Michael Wang wrote:
> Introduce helper tech_iboe() to help us check if the port of an IB
> device is using RoCE/IBoE technology.

Just use rdma_transport_is_roce() instead.

> 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/cma.c |  6 ++----
>  include/rdma/ib_verbs.h       | 16 ++++++++++++++++
>  2 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 668e955..280cfe3 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -375,8 +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_transport_is_ib(cma_dev->device) &&
> -            rdma_port_ll_is_eth(cma_dev->device, port))
> +        if (tech_iboe(cma_dev->device, port))
>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>                           &found_port, NULL);
>          else
> @@ -395,8 +394,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_transport_is_ib(cma_dev->device) &&
> -                    rdma_port_ll_is_eth(cma_dev->device, port))
> +                if (tech_iboe(cma_dev->device, port))
>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>                  else
>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 2bf9094..ca6d6bc 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1767,6 +1767,22 @@ static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
>              == IB_LINK_LAYER_ETHERNET;
>  }
>  
> +/**
> + * tech_iboe - Check if the port of device using technology
> + * RoCE/IBoE.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device is not using technology
> + * RoCE/IBoE.
> + */
> +static inline int tech_iboe(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_transport_is_ib(device) &&
> +            rdma_port_ll_is_eth(device, port_num);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>           u8 port_num, int index, union ib_gid *gid);
>  


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check
@ 2015-03-30 16:17     ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:17 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 2992 bytes --]

On Fri, 2015-03-27 at 16:42 +0100, Michael Wang wrote:
> Introduce helper tech_iboe() to help us check if the port of an IB
> device is using RoCE/IBoE technology.

Just use rdma_transport_is_roce() instead.

> 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/cma.c |  6 ++----
>  include/rdma/ib_verbs.h       | 16 ++++++++++++++++
>  2 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 668e955..280cfe3 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -375,8 +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_transport_is_ib(cma_dev->device) &&
> -            rdma_port_ll_is_eth(cma_dev->device, port))
> +        if (tech_iboe(cma_dev->device, port))
>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>                           &found_port, NULL);
>          else
> @@ -395,8 +394,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_transport_is_ib(cma_dev->device) &&
> -                    rdma_port_ll_is_eth(cma_dev->device, port))
> +                if (tech_iboe(cma_dev->device, port))
>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
>                  else
>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 2bf9094..ca6d6bc 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1767,6 +1767,22 @@ static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
>              == IB_LINK_LAYER_ETHERNET;
>  }
>  
> +/**
> + * tech_iboe - Check if the port of device using technology
> + * RoCE/IBoE.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device is not using technology
> + * RoCE/IBoE.
> + */
> +static inline int tech_iboe(struct ib_device *device, u8 port_num)
> +{
> +    return rdma_transport_is_ib(device) &&
> +            rdma_port_ll_is_eth(device, port_num);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>           u8 port_num, int index, union ib_gid *gid);
>  


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
  2015-03-30 16:11         ` Doug Ledford
  (?)
@ 2015-03-30 16:20           ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:20 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On 03/30/2015 06:11 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
>> Introduce helper has_mcast() and cap_mcast() to help us check if an
>> IB device or it's port support Multicast.
> This probably needs reworded or rethought.  In truth, *all* rdma devices
> are multicast capable.  *BUT*, IB/OPA devices require multicast
> registration done the IB way (including for sendonly multicast sends),
> while Ethernet devices do multicast the Ethernet way.  These tests are
> really just for IB specific multicast registration and deregistration.
> Call it has_mcast() and cap_mcast() is incorrect.

Thanks for the explanation :-)

Jason also mentioned we should use cap_ib_XX() instead, I'll use
that name then we can distinguish the management between
Eth and IB/OPA.

Regards,
Michael Wang


>
>> 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/cma.c       |  2 +-
>>  drivers/infiniband/core/multicast.c |  8 ++++----
>>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>>  3 files changed, 33 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>> index 276fb76..cbbc85b 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
>> +            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
>> index 17573ff..ffeaf27 100644
>> --- a/drivers/infiniband/core/multicast.c
>> +++ b/drivers/infiniband/core/multicast.c
>> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>>      int index;
>>  
>>      dev = container_of(handler, struct mcast_device, event_handler);
>> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>> +    if (!cap_mcast(dev->device, event->element.port_num))
>>          return;
>>  
>>      index = event->element.port_num - dev->start_port;
>> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>>      int i;
>>      int count = 0;
>>  
>> -    if (!rdma_transport_is_ib(device))
>> +    if (!has_mcast(device))
>>          return;
>>  
>>      dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
>> @@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>>      }
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>> +        if (!cap_mcast(device, dev->start_port + i))
>>              continue;
>>          port = &dev->port[i];
>>          port->dev = dev;
>> @@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>>      flush_workqueue(mcast_wq);
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>> +        if (cap_mcast(device, dev->start_port + i)) {
>>              port = &dev->port[i];
>>              deref_port(port);
>>              wait_for_completion(&port->comp);
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index fa8ffa3..e796104 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
>>  }
>>  
>>  /**
>> + * has_mcast - Check if a device support Multicast.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * Multicast.
>> + */
>> +static inline int has_mcast(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_ib(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> @@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
>>      return rdma_port_ll_is_ib(device, port_num);
>>  }
>>  
>> +/**
>> + * cap_mcast - Check if the port of device has the capability
>> + * Multicast.
>> + *
>> + * @device: Device to be checked
>> + * @port_num: Port number of the device
>> + *
>> + * Return 0 when port of the device don't support
>> + * Multicast.
>> + */
>> +static inline int cap_mcast(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);
>>  
>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-30 16:20           ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:20 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

On 03/30/2015 06:11 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
>> Introduce helper has_mcast() and cap_mcast() to help us check if an
>> IB device or it's port support Multicast.
> This probably needs reworded or rethought.  In truth, *all* rdma devices
> are multicast capable.  *BUT*, IB/OPA devices require multicast
> registration done the IB way (including for sendonly multicast sends),
> while Ethernet devices do multicast the Ethernet way.  These tests are
> really just for IB specific multicast registration and deregistration.
> Call it has_mcast() and cap_mcast() is incorrect.

Thanks for the explanation :-)

Jason also mentioned we should use cap_ib_XX() instead, I'll use
that name then we can distinguish the management between
Eth and IB/OPA.

Regards,
Michael Wang


>
>> 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/cma.c       |  2 +-
>>  drivers/infiniband/core/multicast.c |  8 ++++----
>>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>>  3 files changed, 33 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>> index 276fb76..cbbc85b 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
>> +            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
>> index 17573ff..ffeaf27 100644
>> --- a/drivers/infiniband/core/multicast.c
>> +++ b/drivers/infiniband/core/multicast.c
>> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>>      int index;
>>  
>>      dev = container_of(handler, struct mcast_device, event_handler);
>> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>> +    if (!cap_mcast(dev->device, event->element.port_num))
>>          return;
>>  
>>      index = event->element.port_num - dev->start_port;
>> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>>      int i;
>>      int count = 0;
>>  
>> -    if (!rdma_transport_is_ib(device))
>> +    if (!has_mcast(device))
>>          return;
>>  
>>      dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
>> @@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>>      }
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>> +        if (!cap_mcast(device, dev->start_port + i))
>>              continue;
>>          port = &dev->port[i];
>>          port->dev = dev;
>> @@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>>      flush_workqueue(mcast_wq);
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>> +        if (cap_mcast(device, dev->start_port + i)) {
>>              port = &dev->port[i];
>>              deref_port(port);
>>              wait_for_completion(&port->comp);
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index fa8ffa3..e796104 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
>>  }
>>  
>>  /**
>> + * has_mcast - Check if a device support Multicast.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * Multicast.
>> + */
>> +static inline int has_mcast(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_ib(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> @@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
>>      return rdma_port_ll_is_ib(device, port_num);
>>  }
>>  
>> +/**
>> + * cap_mcast - Check if the port of device has the capability
>> + * Multicast.
>> + *
>> + * @device: Device to be checked
>> + * @port_num: Port number of the device
>> + *
>> + * Return 0 when port of the device don't support
>> + * Multicast.
>> + */
>> +static inline int cap_mcast(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);
>>  
>


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check
@ 2015-03-30 16:20           ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:20 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

On 03/30/2015 06:11 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:46 +0100, Michael Wang wrote:
>> Introduce helper has_mcast() and cap_mcast() to help us check if an
>> IB device or it's port support Multicast.
> This probably needs reworded or rethought.  In truth, *all* rdma devices
> are multicast capable.  *BUT*, IB/OPA devices require multicast
> registration done the IB way (including for sendonly multicast sends),
> while Ethernet devices do multicast the Ethernet way.  These tests are
> really just for IB specific multicast registration and deregistration.
> Call it has_mcast() and cap_mcast() is incorrect.

Thanks for the explanation :-)

Jason also mentioned we should use cap_ib_XX() instead, I'll use
that name then we can distinguish the management between
Eth and IB/OPA.

Regards,
Michael Wang


>
>> 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/cma.c       |  2 +-
>>  drivers/infiniband/core/multicast.c |  8 ++++----
>>  include/rdma/ib_verbs.h             | 28 ++++++++++++++++++++++++++++
>>  3 files changed, 33 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>> index 276fb76..cbbc85b 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -3398,7 +3398,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_transport_is_ib(id_priv->cma_dev->device)) {
>> +            if (has_mcast(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/multicast.c b/drivers/infiniband/core/multicast.c
>> index 17573ff..ffeaf27 100644
>> --- a/drivers/infiniband/core/multicast.c
>> +++ b/drivers/infiniband/core/multicast.c
>> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
>>      int index;
>>  
>>      dev = container_of(handler, struct mcast_device, event_handler);
>> -    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
>> +    if (!cap_mcast(dev->device, event->element.port_num))
>>          return;
>>  
>>      index = event->element.port_num - dev->start_port;
>> @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device)
>>      int i;
>>      int count = 0;
>>  
>> -    if (!rdma_transport_is_ib(device))
>> +    if (!has_mcast(device))
>>          return;
>>  
>>      dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
>> @@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device)
>>      }
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
>> +        if (!cap_mcast(device, dev->start_port + i))
>>              continue;
>>          port = &dev->port[i];
>>          port->dev = dev;
>> @@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
>>      flush_workqueue(mcast_wq);
>>  
>>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
>> -        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
>> +        if (cap_mcast(device, dev->start_port + i)) {
>>              port = &dev->port[i];
>>              deref_port(port);
>>              wait_for_completion(&port->comp);
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index fa8ffa3..e796104 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device)
>>  }
>>  
>>  /**
>> + * has_mcast - Check if a device support Multicast.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * Multicast.
>> + */
>> +static inline int has_mcast(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_ib(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> @@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num)
>>      return rdma_port_ll_is_ib(device, port_num);
>>  }
>>  
>> +/**
>> + * cap_mcast - Check if the port of device has the capability
>> + * Multicast.
>> + *
>> + * @device: Device to be checked
>> + * @port_num: Port number of the device
>> + *
>> + * Return 0 when port of the device don't support
>> + * Multicast.
>> + */
>> +static inline int cap_mcast(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);
>>  
>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
  2015-03-30 16:13     ` Doug Ledford
  (?)
@ 2015-03-30 16:21         ` Michael Wang
  -1 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:21 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On 03/30/2015 06:13 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:47 +0100, Michael Wang wrote:
>> Introduce helper has_iwarp() to help us check if an IB device
>> support IWARP protocol.
> This is a needless redirection.  Just stick with the original
> rdma_transport_is_iwarp().

Agree, will leave it there :-)

Regards,
Michael Wang

>
>> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
>> ---
>>  include/rdma/ib_verbs.h                 | 13 +++++++++++++
>>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index e796104..0ef9cd7 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
>>  }
>>  
>>  /**
>> + * has_iwarp - Check if a device support IWARP protocol.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * IWARP protocol.
>> + */
>> +static inline int has_iwarp(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_iwarp(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> index a7b5891..48aeb5e 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> @@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>>  
>>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>>  {
>> -    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>> +    if (has_iwarp(xprt->sc_cm_id->device))
>>          return 1;
>>      else
>>          return min_t(int, sge_count, xprt->sc_max_sge);
>

--
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	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-30 16:21         ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:21 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

On 03/30/2015 06:13 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:47 +0100, Michael Wang wrote:
>> Introduce helper has_iwarp() to help us check if an IB device
>> support IWARP protocol.
> This is a needless redirection.  Just stick with the original
> rdma_transport_is_iwarp().

Agree, will leave it there :-)

Regards,
Michael Wang

>
>> 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>
>> ---
>>  include/rdma/ib_verbs.h                 | 13 +++++++++++++
>>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index e796104..0ef9cd7 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
>>  }
>>  
>>  /**
>> + * has_iwarp - Check if a device support IWARP protocol.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * IWARP protocol.
>> + */
>> +static inline int has_iwarp(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_iwarp(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> index a7b5891..48aeb5e 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> @@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>>  
>>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>>  {
>> -    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>> +    if (has_iwarp(xprt->sc_cm_id->device))
>>          return 1;
>>      else
>>          return min_t(int, sge_count, xprt->sc_max_sge);
>


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [RFC PATCH 08/11] IB/Verbs: Use management helper has_iwarp() for, iwarp-check
@ 2015-03-30 16:21         ` Michael Wang
  0 siblings, 0 replies; 189+ messages in thread
From: Michael Wang @ 2015-03-30 16:21 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	J. Bruce Fields, Trond Myklebust, David S. Miller, Or Gerlitz,
	Moni Shoua, PJ Waskiewicz, Tatyana Nikolova, Yan Burman,
	Jack Morgenstein, Bart Van Assche, Yann Droneaud, Colin Ian King,
	Majd Dibbiny, Jiri Kosina, Matan Barak, Alex Estrin

On 03/30/2015 06:13 PM, Doug Ledford wrote:
> On Fri, 2015-03-27 at 16:47 +0100, Michael Wang wrote:
>> Introduce helper has_iwarp() to help us check if an IB device
>> support IWARP protocol.
> This is a needless redirection.  Just stick with the original
> rdma_transport_is_iwarp().

Agree, will leave it there :-)

Regards,
Michael Wang

>
>> Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>> Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
>> ---
>>  include/rdma/ib_verbs.h                 | 13 +++++++++++++
>>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  2 +-
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
>> index e796104..0ef9cd7 100644
>> --- a/include/rdma/ib_verbs.h
>> +++ b/include/rdma/ib_verbs.h
>> @@ -1836,6 +1836,19 @@ static inline int has_mcast(struct ib_device *device)
>>  }
>>  
>>  /**
>> + * has_iwarp - Check if a device support IWARP protocol.
>> + *
>> + * @device: Device to be checked
>> + *
>> + * Return 0 when a device has none port to support
>> + * IWARP protocol.
>> + */
>> +static inline int has_iwarp(struct ib_device *device)
>> +{
>> +    return rdma_transport_is_iwarp(device);
>> +}
>> +
>> +/**
>>   * cap_smi - Check if the port of device has the capability
>>   * Subnet Management Interface.
>>   *
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> index a7b5891..48aeb5e 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> @@ -118,7 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>>  
>>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>>  {
>> -    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
>> +    if (has_iwarp(xprt->sc_cm_id->device))
>>          return 1;
>>      else
>>          return min_t(int, sge_count, xprt->sc_max_sge);
>

--
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	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
  2015-03-30 16:14           ` Michael Wang
  (?)
@ 2015-03-30 16:22             ` Doug Ledford
  -1 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:22 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 34043 bytes --]

On Mon, 2015-03-30 at 18:14 +0200, Michael Wang wrote:
> Hi, Doug
> 
> Thanks for the comments :-)
> 
> On 03/30/2015 05:56 PM, Doug Ledford wrote:
> > On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
> >> We have so much places to check transport type and link layer type, it's now
> >> make sense to introduce some helpers in order to refine the lengthy code.
> >>
> >> This patch will introduce helpers:
> >>     rdma_transport_is_ib()
> >>     rdma_transport_is_iwarp()
> >>     rdma_port_ll_is_ib()
> >>     rdma_port_ll_is_eth()
> >> and use them to save some code for us.
> > If the end result is to do something like I proposed, then why take this
> > intermediate step that just has to be backed out later?
> 
> The problem is that I found there are still many places our new
> mechanism may could not take care, especially inside device driver,
> this is just try to collect the issues together as a basement so we can
> gradually eliminate them.

There is no "gradually eliminate them" to the suggestion I made.
Remember, my suggestion was to remove the transport and link_layer items
from the port settings and replace it with just one transport item that
is a bitmask of the possible transport types.  This can not be done
gradually, it must be a complete change all at once as the two methods
of setting things are incompatible.  As there is only one out of tree
driver that I know of, lustre, we can give them the information they
need to make their driver work both before and after the change.

> Sure if finally we do capture all the cases, we can just get rid of
> this one, but I guess it won't be that easy to directly jump into
> next stage :-P
> 
> As I could imaging, after this reform, next stage could be introducing
> the new mechanism without changing device driver, and the last
> stage is to asking vendor adapt their code into the new mechanism.
> 
> >
> > In other words, if our end goal is to have
> >
> > rdma_transport_is_ib()
> > rdma_transport_is_iwarp()
> > rdma_transport_is_roce()
> > rdma_transport_is_opa()
> >
> > Then we should skip doing rdma_port_ll_is_*() as the answers to these
> > items would be implied by rdma_transport_is_roce() and such.
> 
> Great if we achieved that ;-) but currently I just wondering maybe
> these helpers can only cover part of the cases where we check
> transport and link layer, there are still some cases we'll need the
> very rough helper to save some code and make things clean~
> 
> Regards,
> Michael Wang
> 
> 
> >
> >> 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/agent.c           |  2 +-
> >>  drivers/infiniband/core/cm.c              |  2 +-
> >>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
> >>  drivers/infiniband/core/mad.c             |  6 +++---
> >>  drivers/infiniband/core/multicast.c       | 11 ++++-------
> >>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
> >>  drivers/infiniband/core/ucm.c             |  3 +--
> >>  drivers/infiniband/core/user_mad.c        |  2 +-
> >>  drivers/infiniband/core/verbs.c           |  5 ++---
> >>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
> >>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
> >>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
> >>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
> >>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
> >>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
> >>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
> >>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
> >>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
> >>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
> >>  19 files changed, 79 insertions(+), 83 deletions(-)
> >>
> >> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> >> index f6d2961..27f1bec 100644
> >> --- a/drivers/infiniband/core/agent.c
> >> +++ b/drivers/infiniband/core/agent.c
> >> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
> >>          goto error1;
> >>      }
> >>  
> >> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
> >> +    if (rdma_port_ll_is_ib(device, port_num)) {
> >>          /* Obtain send only MAD agent for SMI QP */
> >>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
> >>                                  IB_QPT_SMI, NULL, 0,
> >> 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..668e955 100644
> >> --- a/drivers/infiniband/core/cma.c
> >> +++ b/drivers/infiniband/core/cma.c
> >> @@ -375,8 +375,8 @@ 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 &&
> >> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> >> +        if (rdma_transport_is_ib(cma_dev->device) &&
> >> +            rdma_port_ll_is_eth(cma_dev->device, port))
> >>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
> >>                           &found_port, NULL);
> >>          else
> >> @@ -395,8 +395,8 @@ 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 &&
> >> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> >> +                if (rdma_transport_is_ib(cma_dev->device) &&
> >> +                    rdma_port_ll_is_eth(cma_dev->device, port))
> >>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
> >>                  else
> >>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> >> @@ -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,10 +633,8 @@ 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 &&
> >> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
> >> -        == IB_LINK_LAYER_ETHERNET) {
> >> +    if (rdma_transport_is_ib(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);
> >>  
> >>          if (ret)
> >> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
> >>      int ret;
> >>      u16 pkey;
> >>  
> >> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
> >>          pkey = ib_addr_get_pkey(dev_addr);
> >>      else
> >>          pkey = 0xffff;
> >> @@ -1626,7 +1623,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 +2025,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)
> >> @@ -2060,7 +2057,7 @@ port_found:
> >>          goto out;
> >>  
> >>      id_priv->id.route.addr.dev_addr.dev_type =
> >> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
> >> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
> >>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
> >>  
> >>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
> >> @@ -3405,7 +3402,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..23cf9e8 100644
> >> --- a/drivers/infiniband/core/mad.c
> >> +++ b/drivers/infiniband/core/mad.c
> >> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
> >>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
> >>  
> >>      cq_size = mad_sendq_size + mad_recvq_size;
> >> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
> >> +    has_smi = rdma_port_ll_is_ib(device, port_num);
> >>      if (has_smi)
> >>          cq_size *= 2;
> >>  
> >> @@ -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..17573ff 100644
> >> --- a/drivers/infiniband/core/multicast.c
> >> +++ b/drivers/infiniband/core/multicast.c
> >> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
> >>      int index;
> >>  
> >>      dev = container_of(handler, struct mcast_device, event_handler);
> >> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> >>          return;
> >>  
> >>      index = event->element.port_num - dev->start_port;
> >> @@ -808,7 +807,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,
> >> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
> >>      }
> >>  
> >>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> >> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
> >> -            IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
> >>              continue;
> >>          port = &dev->port[i];
> >>          port->dev = dev;
> >> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
> >>      flush_workqueue(mcast_wq);
> >>  
> >>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> >> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
> >> -            IB_LINK_LAYER_INFINIBAND) {
> >> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
> >>              port = &dev->port[i];
> >>              deref_port(port);
> >>              wait_for_completion(&port->comp);
> >> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> >> index c38f030..d95d25f 100644
> >> --- a/drivers/infiniband/core/sa_query.c
> >> +++ b/drivers/infiniband/core/sa_query.c
> >> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
> >>          struct ib_sa_port *port =
> >>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
> >>  
> >> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> >>              return;
> >>  
> >>          spin_lock_irqsave(&port->ah_lock, flags);
> >> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
> >>      ah_attr->port_num = port_num;
> >>      ah_attr->static_rate = rec->rate;
> >>  
> >> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
> >> +    force_grh = rdma_port_ll_is_eth(device, port_num);
> >>  
> >>      if (rec->hop_limit > 1 || force_grh) {
> >>          ah_attr->ah_flags = IB_AH_GRH;
> >> @@ -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)
> >> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
> >>  
> >>      for (i = 0; i <= e - s; ++i) {
> >>          spin_lock_init(&sa_dev->port[i].ah_lock);
> >> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, i + 1))
> >>              continue;
> >>  
> >>          sa_dev->port[i].sm_ah    = NULL;
> >> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
> >>          goto err;
> >>  
> >>      for (i = 0; i <= e - s; ++i)
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> >> +        if (rdma_port_ll_is_ib(device, i + 1))
> >>              update_sm_ah(&sa_dev->port[i].update_task);
> >>  
> >>      return;
> >>  
> >>  err:
> >>      while (--i >= 0)
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> >> +        if (rdma_port_ll_is_ib(device, i + 1))
> >>              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >>  
> >>      kfree(sa_dev);
> >> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
> >>      flush_workqueue(ib_wq);
> >>  
> >>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
> >> +        if (rdma_port_ll_is_ib(device, i + 1)) {
> >>              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >>              if (sa_dev->port[i].sm_ah)
> >>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> >> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
> >> index f93eb8d..d8d015a 100644
> >> --- a/drivers/infiniband/core/verbs.c
> >> +++ b/drivers/infiniband/core/verbs.c
> >> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
> >>      u32 flow_class;
> >>      u16 gid_index;
> >>      int ret;
> >> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
> >> -            IB_LINK_LAYER_ETHERNET);
> >> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
> >>  
> >>      memset(ah_attr, 0, sizeof *ah_attr);
> >>      if (is_eth) {
> >> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
> >>      union ib_gid  sgid;
> >>  
> >>      if ((*qp_attr_mask & IB_QP_AV)  &&
> >> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
> >> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
> >>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
> >>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
> >>          if (ret)
> >> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
> >> index 2d8c339..829eb60 100644
> >> --- a/drivers/infiniband/hw/mlx4/ah.c
> >> +++ b/drivers/infiniband/hw/mlx4/ah.c
> >> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
> >>      if (!ah)
> >>          return ERR_PTR(-ENOMEM);
> >>  
> >> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
> >> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
> >>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
> >>              ret = ERR_PTR(-EINVAL);
> >>          } else {
> >> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
> >> index cb63ecd..0417f03 100644
> >> --- a/drivers/infiniband/hw/mlx4/cq.c
> >> +++ b/drivers/infiniband/hw/mlx4/cq.c
> >> @@ -789,9 +789,7 @@ repoll:
> >>              break;
> >>          }
> >>  
> >> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
> >> -                          (*cur_qp)->port) ==
> >> -              IB_LINK_LAYER_ETHERNET);
> >> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
> >>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
> >>              if ((*cur_qp)->mlx4_ib_qp_type &
> >>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
> >> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> >> index 82a7dd8..4736fc7 100644
> >> --- a/drivers/infiniband/hw/mlx4/mad.c
> >> +++ b/drivers/infiniband/hw/mlx4/mad.c
> >> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
> >>      int err;
> >>      int slave;
> >>      u8 *slave_id;
> >> -    int is_eth = 0;
> >> -
> >> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> >> -        is_eth = 0;
> >> -    else
> >> -        is_eth = 1;
> >> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
> >>  
> >>      if (is_eth) {
> >>          if (!(wc->wc_flags & IB_WC_GRH)) {
> >> @@ -1252,7 +1247,7 @@ out:
> >>  
> >>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
> >>  {
> >> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
> >>          return slave;
> >>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
> >>  }
> >> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_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);
> >> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
> >>  
> >>      ctx->state = DEMUX_PV_STATE_STARTING;
> >>      /* have QP0 only if link layer is IB */
> >> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
> >>          ctx->has_smi = 1;
> >>  
> >>      if (ctx->has_smi) {
> >> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> >> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(ibdev, port))
> >>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
> >>      else
> >>          return iboe_query_gid(ibdev, port, index, gid);
> >> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
> >>      int err = 0;
> >>  
> >>      for (i = 1; i <= ibdev->num_ports; ++i) {
> >> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
> >> -            IB_LINK_LAYER_ETHERNET) {
> >> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
> >>              err = reset_gid_table(ibdev, i);
> >>              if (err)
> >>                  goto out;
> >> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
> >>          if (p > ibdev->num_ports)
> >>              return;
> >>          if (mlx4_is_master(dev) &&
> >> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
> >> -            IB_LINK_LAYER_INFINIBAND) {
> >> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
> >>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
> >>          }
> >>          ibev.event = IB_EVENT_PORT_ACTIVE;
> >> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> index 6eb743f..1befeb8 100644
> >> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
> >>  {
> >>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
> >>  
> >> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
> >> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
> >>          return true;
> >>  
> >>      return !!(ah->av.ib.g_slid & 0x80);
> >> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> >> index c880329..bd2f557 100644
> >> --- a/drivers/infiniband/hw/mlx4/qp.c
> >> +++ b/drivers/infiniband/hw/mlx4/qp.c
> >> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
> >>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
> >>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
> >>  {
> >> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
> >> -        IB_LINK_LAYER_ETHERNET;
> >> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
> >>      int vidx;
> >>      int smac_index;
> >>      int err;
> >> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>  
> >>      /* APM is not supported under RoCE */
> >>      if (attr_mask & IB_QP_ALT_PATH &&
> >> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> >> -        IB_LINK_LAYER_ETHERNET)
> >> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
> >>          return -ENOTSUPP;
> >>  
> >>      context = kzalloc(sizeof *context, GFP_KERNEL);
> >> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>                  context->pri_path.fl = 0x80;
> >>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
> >>          }
> >> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> >> -            IB_LINK_LAYER_ETHERNET) {
> >> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
> >>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
> >>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
> >>                  context->pri_path.feup = 1 << 7; /* don't fsm */
> >> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>      }
> >>  
> >>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
> >> -        int is_eth = rdma_port_get_link_layer(
> >> -                &dev->ib_dev, qp->port) ==
> >> -                IB_LINK_LAYER_ETHERNET;
> >> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
> >>          if (is_eth) {
> >>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
> >>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
> >> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
> >>      }
> >>  
> >>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
> >> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
> >> -         IB_LINK_LAYER_ETHERNET))
> >> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
> >>          goto out;
> >>  
> >>      if (attr_mask & IB_QP_PKEY_INDEX) {
> >> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
> >>      for (i = 0; i < wr->num_sge; ++i)
> >>          send_size += wr->sg_list[i].length;
> >>  
> >> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
> >> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
> >>      is_grh = mlx4_ib_ah_grh_present(ah);
> >>      if (is_eth) {
> >>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
> >> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
> >>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
> >>          return;
> >>  
> >> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
> >> -        IB_LINK_LAYER_ETHERNET;
> >> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
> >>      if (is_eth)
> >>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
> >>          ((path->sched_queue & 4) << 1);
> >> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
> >> index cb4c66e..d339b55 100644
> >> --- a/drivers/infiniband/hw/mlx4/sysfs.c
> >> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
> >> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
> >>  
> >>  static int add_vf_smi_entries(struct mlx4_port *p)
> >>  {
> >> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> >> -            IB_LINK_LAYER_ETHERNET;
> >> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
> >>      int ret;
> >>  
> >>      /* do not display entries if eth transport, or if master */
> >> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
> >>  
> >>  static void remove_vf_smi_entries(struct mlx4_port *p)
> >>  {
> >> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> >> -            IB_LINK_LAYER_ETHERNET;
> >> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
> >>  
> >>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
> >>          return;
> >> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> >> index 58b5aa3..3341754 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);
> >> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
> >>      }
> >>  
> >>      for (p = s; p <= e; ++p) {
> >> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, p))
> >>              continue;
> >>          dev = ipoib_add_port("ib%d", device, p);
> >>          if (!IS_ERR(dev)) {
> >> @@ -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..2bf9094 100644
> >> --- a/include/rdma/ib_verbs.h
> >> +++ b/include/rdma/ib_verbs.h
> >> @@ -1743,6 +1743,30 @@ 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;
> >> +}
> >> +
> >> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
> >> +{
> >> +    return rdma_node_get_transport(device->node_type)
> >> +            == RDMA_TRANSPORT_IWARP;
> >> +}
> >> +
> >> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
> >> +{
> >> +    return rdma_port_get_link_layer(device, port_num)
> >> +            == IB_LINK_LAYER_INFINIBAND;
> >> +}
> >> +
> >> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
> >> +{
> >> +    return rdma_port_get_link_layer(device, port_num)
> >> +            == IB_LINK_LAYER_ETHERNET;
> >> +}
> >> +
> >>  int ib_query_gid(struct ib_device *device,
> >>           u8 port_num, int index, union ib_gid *gid);
> >>  
> >> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> >> index e011027..a7b5891 100644
> >> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> >> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> >> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
> >>  
> >>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
> >>  {
> >> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
> >> -         RDMA_TRANSPORT_IWARP)
> >> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
> >>          return 1;
> >>      else
> >>          return min_t(int, sge_count, xprt->sc_max_sge);
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-30 16:22             ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:22 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin, Eric Dumazet,
	Erez Shitrit, Sagi Grimberg, Haggai Eran, Shachar Raindel,
	Mike Marciniszyn, Steve Wise, Tom Tucker, Chuck Lever

[-- Attachment #1: Type: text/plain, Size: 34043 bytes --]

On Mon, 2015-03-30 at 18:14 +0200, Michael Wang wrote:
> Hi, Doug
> 
> Thanks for the comments :-)
> 
> On 03/30/2015 05:56 PM, Doug Ledford wrote:
> > On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
> >> We have so much places to check transport type and link layer type, it's now
> >> make sense to introduce some helpers in order to refine the lengthy code.
> >>
> >> This patch will introduce helpers:
> >>     rdma_transport_is_ib()
> >>     rdma_transport_is_iwarp()
> >>     rdma_port_ll_is_ib()
> >>     rdma_port_ll_is_eth()
> >> and use them to save some code for us.
> > If the end result is to do something like I proposed, then why take this
> > intermediate step that just has to be backed out later?
> 
> The problem is that I found there are still many places our new
> mechanism may could not take care, especially inside device driver,
> this is just try to collect the issues together as a basement so we can
> gradually eliminate them.

There is no "gradually eliminate them" to the suggestion I made.
Remember, my suggestion was to remove the transport and link_layer items
from the port settings and replace it with just one transport item that
is a bitmask of the possible transport types.  This can not be done
gradually, it must be a complete change all at once as the two methods
of setting things are incompatible.  As there is only one out of tree
driver that I know of, lustre, we can give them the information they
need to make their driver work both before and after the change.

> Sure if finally we do capture all the cases, we can just get rid of
> this one, but I guess it won't be that easy to directly jump into
> next stage :-P
> 
> As I could imaging, after this reform, next stage could be introducing
> the new mechanism without changing device driver, and the last
> stage is to asking vendor adapt their code into the new mechanism.
> 
> >
> > In other words, if our end goal is to have
> >
> > rdma_transport_is_ib()
> > rdma_transport_is_iwarp()
> > rdma_transport_is_roce()
> > rdma_transport_is_opa()
> >
> > Then we should skip doing rdma_port_ll_is_*() as the answers to these
> > items would be implied by rdma_transport_is_roce() and such.
> 
> Great if we achieved that ;-) but currently I just wondering maybe
> these helpers can only cover part of the cases where we check
> transport and link layer, there are still some cases we'll need the
> very rough helper to save some code and make things clean~
> 
> Regards,
> Michael Wang
> 
> 
> >
> >> 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/agent.c           |  2 +-
> >>  drivers/infiniband/core/cm.c              |  2 +-
> >>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
> >>  drivers/infiniband/core/mad.c             |  6 +++---
> >>  drivers/infiniband/core/multicast.c       | 11 ++++-------
> >>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
> >>  drivers/infiniband/core/ucm.c             |  3 +--
> >>  drivers/infiniband/core/user_mad.c        |  2 +-
> >>  drivers/infiniband/core/verbs.c           |  5 ++---
> >>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
> >>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
> >>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
> >>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
> >>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
> >>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
> >>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
> >>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
> >>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
> >>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
> >>  19 files changed, 79 insertions(+), 83 deletions(-)
> >>
> >> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> >> index f6d2961..27f1bec 100644
> >> --- a/drivers/infiniband/core/agent.c
> >> +++ b/drivers/infiniband/core/agent.c
> >> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
> >>          goto error1;
> >>      }
> >>  
> >> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
> >> +    if (rdma_port_ll_is_ib(device, port_num)) {
> >>          /* Obtain send only MAD agent for SMI QP */
> >>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
> >>                                  IB_QPT_SMI, NULL, 0,
> >> 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..668e955 100644
> >> --- a/drivers/infiniband/core/cma.c
> >> +++ b/drivers/infiniband/core/cma.c
> >> @@ -375,8 +375,8 @@ 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 &&
> >> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> >> +        if (rdma_transport_is_ib(cma_dev->device) &&
> >> +            rdma_port_ll_is_eth(cma_dev->device, port))
> >>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
> >>                           &found_port, NULL);
> >>          else
> >> @@ -395,8 +395,8 @@ 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 &&
> >> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> >> +                if (rdma_transport_is_ib(cma_dev->device) &&
> >> +                    rdma_port_ll_is_eth(cma_dev->device, port))
> >>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
> >>                  else
> >>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> >> @@ -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,10 +633,8 @@ 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 &&
> >> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
> >> -        == IB_LINK_LAYER_ETHERNET) {
> >> +    if (rdma_transport_is_ib(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);
> >>  
> >>          if (ret)
> >> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
> >>      int ret;
> >>      u16 pkey;
> >>  
> >> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
> >>          pkey = ib_addr_get_pkey(dev_addr);
> >>      else
> >>          pkey = 0xffff;
> >> @@ -1626,7 +1623,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 +2025,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)
> >> @@ -2060,7 +2057,7 @@ port_found:
> >>          goto out;
> >>  
> >>      id_priv->id.route.addr.dev_addr.dev_type =
> >> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
> >> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
> >>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
> >>  
> >>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
> >> @@ -3405,7 +3402,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..23cf9e8 100644
> >> --- a/drivers/infiniband/core/mad.c
> >> +++ b/drivers/infiniband/core/mad.c
> >> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
> >>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
> >>  
> >>      cq_size = mad_sendq_size + mad_recvq_size;
> >> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
> >> +    has_smi = rdma_port_ll_is_ib(device, port_num);
> >>      if (has_smi)
> >>          cq_size *= 2;
> >>  
> >> @@ -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..17573ff 100644
> >> --- a/drivers/infiniband/core/multicast.c
> >> +++ b/drivers/infiniband/core/multicast.c
> >> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
> >>      int index;
> >>  
> >>      dev = container_of(handler, struct mcast_device, event_handler);
> >> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> >>          return;
> >>  
> >>      index = event->element.port_num - dev->start_port;
> >> @@ -808,7 +807,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,
> >> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
> >>      }
> >>  
> >>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> >> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
> >> -            IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
> >>              continue;
> >>          port = &dev->port[i];
> >>          port->dev = dev;
> >> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
> >>      flush_workqueue(mcast_wq);
> >>  
> >>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> >> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
> >> -            IB_LINK_LAYER_INFINIBAND) {
> >> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
> >>              port = &dev->port[i];
> >>              deref_port(port);
> >>              wait_for_completion(&port->comp);
> >> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> >> index c38f030..d95d25f 100644
> >> --- a/drivers/infiniband/core/sa_query.c
> >> +++ b/drivers/infiniband/core/sa_query.c
> >> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
> >>          struct ib_sa_port *port =
> >>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
> >>  
> >> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> >>              return;
> >>  
> >>          spin_lock_irqsave(&port->ah_lock, flags);
> >> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
> >>      ah_attr->port_num = port_num;
> >>      ah_attr->static_rate = rec->rate;
> >>  
> >> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
> >> +    force_grh = rdma_port_ll_is_eth(device, port_num);
> >>  
> >>      if (rec->hop_limit > 1 || force_grh) {
> >>          ah_attr->ah_flags = IB_AH_GRH;
> >> @@ -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)
> >> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
> >>  
> >>      for (i = 0; i <= e - s; ++i) {
> >>          spin_lock_init(&sa_dev->port[i].ah_lock);
> >> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, i + 1))
> >>              continue;
> >>  
> >>          sa_dev->port[i].sm_ah    = NULL;
> >> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
> >>          goto err;
> >>  
> >>      for (i = 0; i <= e - s; ++i)
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> >> +        if (rdma_port_ll_is_ib(device, i + 1))
> >>              update_sm_ah(&sa_dev->port[i].update_task);
> >>  
> >>      return;
> >>  
> >>  err:
> >>      while (--i >= 0)
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> >> +        if (rdma_port_ll_is_ib(device, i + 1))
> >>              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >>  
> >>      kfree(sa_dev);
> >> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
> >>      flush_workqueue(ib_wq);
> >>  
> >>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
> >> +        if (rdma_port_ll_is_ib(device, i + 1)) {
> >>              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >>              if (sa_dev->port[i].sm_ah)
> >>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> >> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
> >> index f93eb8d..d8d015a 100644
> >> --- a/drivers/infiniband/core/verbs.c
> >> +++ b/drivers/infiniband/core/verbs.c
> >> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
> >>      u32 flow_class;
> >>      u16 gid_index;
> >>      int ret;
> >> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
> >> -            IB_LINK_LAYER_ETHERNET);
> >> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
> >>  
> >>      memset(ah_attr, 0, sizeof *ah_attr);
> >>      if (is_eth) {
> >> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
> >>      union ib_gid  sgid;
> >>  
> >>      if ((*qp_attr_mask & IB_QP_AV)  &&
> >> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
> >> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
> >>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
> >>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
> >>          if (ret)
> >> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
> >> index 2d8c339..829eb60 100644
> >> --- a/drivers/infiniband/hw/mlx4/ah.c
> >> +++ b/drivers/infiniband/hw/mlx4/ah.c
> >> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
> >>      if (!ah)
> >>          return ERR_PTR(-ENOMEM);
> >>  
> >> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
> >> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
> >>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
> >>              ret = ERR_PTR(-EINVAL);
> >>          } else {
> >> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
> >> index cb63ecd..0417f03 100644
> >> --- a/drivers/infiniband/hw/mlx4/cq.c
> >> +++ b/drivers/infiniband/hw/mlx4/cq.c
> >> @@ -789,9 +789,7 @@ repoll:
> >>              break;
> >>          }
> >>  
> >> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
> >> -                          (*cur_qp)->port) ==
> >> -              IB_LINK_LAYER_ETHERNET);
> >> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
> >>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
> >>              if ((*cur_qp)->mlx4_ib_qp_type &
> >>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
> >> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> >> index 82a7dd8..4736fc7 100644
> >> --- a/drivers/infiniband/hw/mlx4/mad.c
> >> +++ b/drivers/infiniband/hw/mlx4/mad.c
> >> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
> >>      int err;
> >>      int slave;
> >>      u8 *slave_id;
> >> -    int is_eth = 0;
> >> -
> >> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> >> -        is_eth = 0;
> >> -    else
> >> -        is_eth = 1;
> >> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
> >>  
> >>      if (is_eth) {
> >>          if (!(wc->wc_flags & IB_WC_GRH)) {
> >> @@ -1252,7 +1247,7 @@ out:
> >>  
> >>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
> >>  {
> >> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
> >>          return slave;
> >>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
> >>  }
> >> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_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);
> >> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
> >>  
> >>      ctx->state = DEMUX_PV_STATE_STARTING;
> >>      /* have QP0 only if link layer is IB */
> >> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
> >>          ctx->has_smi = 1;
> >>  
> >>      if (ctx->has_smi) {
> >> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> >> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(ibdev, port))
> >>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
> >>      else
> >>          return iboe_query_gid(ibdev, port, index, gid);
> >> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
> >>      int err = 0;
> >>  
> >>      for (i = 1; i <= ibdev->num_ports; ++i) {
> >> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
> >> -            IB_LINK_LAYER_ETHERNET) {
> >> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
> >>              err = reset_gid_table(ibdev, i);
> >>              if (err)
> >>                  goto out;
> >> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
> >>          if (p > ibdev->num_ports)
> >>              return;
> >>          if (mlx4_is_master(dev) &&
> >> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
> >> -            IB_LINK_LAYER_INFINIBAND) {
> >> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
> >>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
> >>          }
> >>          ibev.event = IB_EVENT_PORT_ACTIVE;
> >> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> index 6eb743f..1befeb8 100644
> >> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
> >>  {
> >>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
> >>  
> >> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
> >> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
> >>          return true;
> >>  
> >>      return !!(ah->av.ib.g_slid & 0x80);
> >> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> >> index c880329..bd2f557 100644
> >> --- a/drivers/infiniband/hw/mlx4/qp.c
> >> +++ b/drivers/infiniband/hw/mlx4/qp.c
> >> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
> >>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
> >>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
> >>  {
> >> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
> >> -        IB_LINK_LAYER_ETHERNET;
> >> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
> >>      int vidx;
> >>      int smac_index;
> >>      int err;
> >> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>  
> >>      /* APM is not supported under RoCE */
> >>      if (attr_mask & IB_QP_ALT_PATH &&
> >> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> >> -        IB_LINK_LAYER_ETHERNET)
> >> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
> >>          return -ENOTSUPP;
> >>  
> >>      context = kzalloc(sizeof *context, GFP_KERNEL);
> >> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>                  context->pri_path.fl = 0x80;
> >>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
> >>          }
> >> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> >> -            IB_LINK_LAYER_ETHERNET) {
> >> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
> >>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
> >>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
> >>                  context->pri_path.feup = 1 << 7; /* don't fsm */
> >> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>      }
> >>  
> >>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
> >> -        int is_eth = rdma_port_get_link_layer(
> >> -                &dev->ib_dev, qp->port) ==
> >> -                IB_LINK_LAYER_ETHERNET;
> >> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
> >>          if (is_eth) {
> >>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
> >>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
> >> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
> >>      }
> >>  
> >>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
> >> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
> >> -         IB_LINK_LAYER_ETHERNET))
> >> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
> >>          goto out;
> >>  
> >>      if (attr_mask & IB_QP_PKEY_INDEX) {
> >> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
> >>      for (i = 0; i < wr->num_sge; ++i)
> >>          send_size += wr->sg_list[i].length;
> >>  
> >> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
> >> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
> >>      is_grh = mlx4_ib_ah_grh_present(ah);
> >>      if (is_eth) {
> >>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
> >> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
> >>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
> >>          return;
> >>  
> >> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
> >> -        IB_LINK_LAYER_ETHERNET;
> >> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
> >>      if (is_eth)
> >>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
> >>          ((path->sched_queue & 4) << 1);
> >> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
> >> index cb4c66e..d339b55 100644
> >> --- a/drivers/infiniband/hw/mlx4/sysfs.c
> >> +++ b/drivers/infiniband/hw/mlx4/sysfs.c
> >> @@ -610,8 +610,7 @@ static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
> >>  
> >>  static int add_vf_smi_entries(struct mlx4_port *p)
> >>  {
> >> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> >> -            IB_LINK_LAYER_ETHERNET;
> >> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
> >>      int ret;
> >>  
> >>      /* do not display entries if eth transport, or if master */
> >> @@ -645,8 +644,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
> >>  
> >>  static void remove_vf_smi_entries(struct mlx4_port *p)
> >>  {
> >> -    int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
> >> -            IB_LINK_LAYER_ETHERNET;
> >> +    int is_eth = rdma_port_ll_is_eth(&p->dev->ib_dev, p->port_num);
> >>  
> >>      if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
> >>          return;
> >> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> >> index 58b5aa3..3341754 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);
> >> @@ -1673,7 +1673,7 @@ static void ipoib_add_one(struct ib_device *device)
> >>      }
> >>  
> >>      for (p = s; p <= e; ++p) {
> >> -        if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, p))
> >>              continue;
> >>          dev = ipoib_add_port("ib%d", device, p);
> >>          if (!IS_ERR(dev)) {
> >> @@ -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..2bf9094 100644
> >> --- a/include/rdma/ib_verbs.h
> >> +++ b/include/rdma/ib_verbs.h
> >> @@ -1743,6 +1743,30 @@ 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;
> >> +}
> >> +
> >> +static inline int rdma_transport_is_iwarp(struct ib_device *device)
> >> +{
> >> +    return rdma_node_get_transport(device->node_type)
> >> +            == RDMA_TRANSPORT_IWARP;
> >> +}
> >> +
> >> +static inline int rdma_port_ll_is_ib(struct ib_device *device, u8 port_num)
> >> +{
> >> +    return rdma_port_get_link_layer(device, port_num)
> >> +            == IB_LINK_LAYER_INFINIBAND;
> >> +}
> >> +
> >> +static inline int rdma_port_ll_is_eth(struct ib_device *device, u8 port_num)
> >> +{
> >> +    return rdma_port_get_link_layer(device, port_num)
> >> +            == IB_LINK_LAYER_ETHERNET;
> >> +}
> >> +
> >>  int ib_query_gid(struct ib_device *device,
> >>           u8 port_num, int index, union ib_gid *gid);
> >>  
> >> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> >> index e011027..a7b5891 100644
> >> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> >> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> >> @@ -118,8 +118,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
> >>  
> >>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
> >>  {
> >> -    if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
> >> -         RDMA_TRANSPORT_IWARP)
> >> +    if (rdma_transport_is_iwarp(xprt->sc_cm_id->device))
> >>          return 1;
> >>      else
> >>          return min_t(int, sge_count, xprt->sc_max_sge);
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/11] IB/Verbs: Use helpers to check transport and link layer
@ 2015-03-30 16:22             ` Doug Ledford
  0 siblings, 0 replies; 189+ messages in thread
From: Doug Ledford @ 2015-03-30 16:22 UTC (permalink / raw)
  To: Michael Wang
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, Ira Weiny, linux-rdma,
	linux-kernel, linux-nfs, netdev, J. Bruce Fields,
	Trond Myklebust, David S. Miller, Or Gerlitz, Moni Shoua,
	PJ Waskiewicz, Tatyana Nikolova, Yan Burman, Jack Morgenstein,
	Bart Van Assche, Yann Droneaud, Colin Ian King, Majd Dibbiny,
	Jiri Kosina, Matan Barak, Alex Estrin

[-- Attachment #1: Type: text/plain, Size: 34043 bytes --]

On Mon, 2015-03-30 at 18:14 +0200, Michael Wang wrote:
> Hi, Doug
> 
> Thanks for the comments :-)
> 
> On 03/30/2015 05:56 PM, Doug Ledford wrote:
> > On Fri, 2015-03-27 at 16:40 +0100, Michael Wang wrote:
> >> We have so much places to check transport type and link layer type, it's now
> >> make sense to introduce some helpers in order to refine the lengthy code.
> >>
> >> This patch will introduce helpers:
> >>     rdma_transport_is_ib()
> >>     rdma_transport_is_iwarp()
> >>     rdma_port_ll_is_ib()
> >>     rdma_port_ll_is_eth()
> >> and use them to save some code for us.
> > If the end result is to do something like I proposed, then why take this
> > intermediate step that just has to be backed out later?
> 
> The problem is that I found there are still many places our new
> mechanism may could not take care, especially inside device driver,
> this is just try to collect the issues together as a basement so we can
> gradually eliminate them.

There is no "gradually eliminate them" to the suggestion I made.
Remember, my suggestion was to remove the transport and link_layer items
from the port settings and replace it with just one transport item that
is a bitmask of the possible transport types.  This can not be done
gradually, it must be a complete change all at once as the two methods
of setting things are incompatible.  As there is only one out of tree
driver that I know of, lustre, we can give them the information they
need to make their driver work both before and after the change.

> Sure if finally we do capture all the cases, we can just get rid of
> this one, but I guess it won't be that easy to directly jump into
> next stage :-P
> 
> As I could imaging, after this reform, next stage could be introducing
> the new mechanism without changing device driver, and the last
> stage is to asking vendor adapt their code into the new mechanism.
> 
> >
> > In other words, if our end goal is to have
> >
> > rdma_transport_is_ib()
> > rdma_transport_is_iwarp()
> > rdma_transport_is_roce()
> > rdma_transport_is_opa()
> >
> > Then we should skip doing rdma_port_ll_is_*() as the answers to these
> > items would be implied by rdma_transport_is_roce() and such.
> 
> Great if we achieved that ;-) but currently I just wondering maybe
> these helpers can only cover part of the cases where we check
> transport and link layer, there are still some cases we'll need the
> very rough helper to save some code and make things clean~
> 
> Regards,
> Michael Wang
> 
> 
> >
> >> 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/agent.c           |  2 +-
> >>  drivers/infiniband/core/cm.c              |  2 +-
> >>  drivers/infiniband/core/cma.c             | 27 ++++++++++++---------------
> >>  drivers/infiniband/core/mad.c             |  6 +++---
> >>  drivers/infiniband/core/multicast.c       | 11 ++++-------
> >>  drivers/infiniband/core/sa_query.c        | 14 +++++++-------
> >>  drivers/infiniband/core/ucm.c             |  3 +--
> >>  drivers/infiniband/core/user_mad.c        |  2 +-
> >>  drivers/infiniband/core/verbs.c           |  5 ++---
> >>  drivers/infiniband/hw/mlx4/ah.c           |  2 +-
> >>  drivers/infiniband/hw/mlx4/cq.c           |  4 +---
> >>  drivers/infiniband/hw/mlx4/mad.c          | 14 ++++----------
> >>  drivers/infiniband/hw/mlx4/main.c         |  8 +++-----
> >>  drivers/infiniband/hw/mlx4/mlx4_ib.h      |  2 +-
> >>  drivers/infiniband/hw/mlx4/qp.c           | 21 +++++++--------------
> >>  drivers/infiniband/hw/mlx4/sysfs.c        |  6 ++----
> >>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  6 +++---
> >>  include/rdma/ib_verbs.h                   | 24 ++++++++++++++++++++++++
> >>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c   |  3 +--
> >>  19 files changed, 79 insertions(+), 83 deletions(-)
> >>
> >> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> >> index f6d2961..27f1bec 100644
> >> --- a/drivers/infiniband/core/agent.c
> >> +++ b/drivers/infiniband/core/agent.c
> >> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
> >>          goto error1;
> >>      }
> >>  
> >> -    if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
> >> +    if (rdma_port_ll_is_ib(device, port_num)) {
> >>          /* Obtain send only MAD agent for SMI QP */
> >>          port_priv->agent[0] = ib_register_mad_agent(device, port_num,
> >>                                  IB_QPT_SMI, NULL, 0,
> >> 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..668e955 100644
> >> --- a/drivers/infiniband/core/cma.c
> >> +++ b/drivers/infiniband/core/cma.c
> >> @@ -375,8 +375,8 @@ 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 &&
> >> -            rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> >> +        if (rdma_transport_is_ib(cma_dev->device) &&
> >> +            rdma_port_ll_is_eth(cma_dev->device, port))
> >>              ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
> >>                           &found_port, NULL);
> >>          else
> >> @@ -395,8 +395,8 @@ 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 &&
> >> -                    rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
> >> +                if (rdma_transport_is_ib(cma_dev->device) &&
> >> +                    rdma_port_ll_is_eth(cma_dev->device, port))
> >>                      ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
> >>                  else
> >>                      ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> >> @@ -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,10 +633,8 @@ 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 &&
> >> -        rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
> >> -        == IB_LINK_LAYER_ETHERNET) {
> >> +    if (rdma_transport_is_ib(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);
> >>  
> >>          if (ret)
> >> @@ -700,8 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
> >>      int ret;
> >>      u16 pkey;
> >>  
> >> -    if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(id_priv->id.device, id_priv->id.port_num))
> >>          pkey = ib_addr_get_pkey(dev_addr);
> >>      else
> >>          pkey = 0xffff;
> >> @@ -1626,7 +1623,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 +2025,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)
> >> @@ -2060,7 +2057,7 @@ port_found:
> >>          goto out;
> >>  
> >>      id_priv->id.route.addr.dev_addr.dev_type =
> >> -        (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
> >> +        (rdma_port_ll_is_ib(cma_dev->device, p)) ?
> >>          ARPHRD_INFINIBAND : ARPHRD_ETHER;
> >>  
> >>      rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
> >> @@ -3405,7 +3402,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..23cf9e8 100644
> >> --- a/drivers/infiniband/core/mad.c
> >> +++ b/drivers/infiniband/core/mad.c
> >> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
> >>      init_mad_qp(port_priv, &port_priv->qp_info[1]);
> >>  
> >>      cq_size = mad_sendq_size + mad_recvq_size;
> >> -    has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
> >> +    has_smi = rdma_port_ll_is_ib(device, port_num);
> >>      if (has_smi)
> >>          cq_size *= 2;
> >>  
> >> @@ -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..17573ff 100644
> >> --- a/drivers/infiniband/core/multicast.c
> >> +++ b/drivers/infiniband/core/multicast.c
> >> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
> >>      int index;
> >>  
> >>      dev = container_of(handler, struct mcast_device, event_handler);
> >> -    if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (!rdma_port_ll_is_ib(dev->device, event->element.port_num))
> >>          return;
> >>  
> >>      index = event->element.port_num - dev->start_port;
> >> @@ -808,7 +807,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,
> >> @@ -824,8 +823,7 @@ static void mcast_add_one(struct ib_device *device)
> >>      }
> >>  
> >>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> >> -        if (rdma_port_get_link_layer(device, dev->start_port + i) !=
> >> -            IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, dev->start_port + i))
> >>              continue;
> >>          port = &dev->port[i];
> >>          port->dev = dev;
> >> @@ -863,8 +861,7 @@ static void mcast_remove_one(struct ib_device *device)
> >>      flush_workqueue(mcast_wq);
> >>  
> >>      for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> >> -        if (rdma_port_get_link_layer(device, dev->start_port + i) ==
> >> -            IB_LINK_LAYER_INFINIBAND) {
> >> +        if (rdma_port_ll_is_ib(device, dev->start_port + i)) {
> >>              port = &dev->port[i];
> >>              deref_port(port);
> >>              wait_for_completion(&port->comp);
> >> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> >> index c38f030..d95d25f 100644
> >> --- a/drivers/infiniband/core/sa_query.c
> >> +++ b/drivers/infiniband/core/sa_query.c
> >> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
> >>          struct ib_sa_port *port =
> >>              &sa_dev->port[event->element.port_num - sa_dev->start_port];
> >>  
> >> -        if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(handler->device, port->port_num))
> >>              return;
> >>  
> >>          spin_lock_irqsave(&port->ah_lock, flags);
> >> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
> >>      ah_attr->port_num = port_num;
> >>      ah_attr->static_rate = rec->rate;
> >>  
> >> -    force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
> >> +    force_grh = rdma_port_ll_is_eth(device, port_num);
> >>  
> >>      if (rec->hop_limit > 1 || force_grh) {
> >>          ah_attr->ah_flags = IB_AH_GRH;
> >> @@ -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)
> >> @@ -1175,7 +1175,7 @@ static void ib_sa_add_one(struct ib_device *device)
> >>  
> >>      for (i = 0; i <= e - s; ++i) {
> >>          spin_lock_init(&sa_dev->port[i].ah_lock);
> >> -        if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
> >> +        if (!rdma_port_ll_is_ib(device, i + 1))
> >>              continue;
> >>  
> >>          sa_dev->port[i].sm_ah    = NULL;
> >> @@ -1205,14 +1205,14 @@ static void ib_sa_add_one(struct ib_device *device)
> >>          goto err;
> >>  
> >>      for (i = 0; i <= e - s; ++i)
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> >> +        if (rdma_port_ll_is_ib(device, i + 1))
> >>              update_sm_ah(&sa_dev->port[i].update_task);
> >>  
> >>      return;
> >>  
> >>  err:
> >>      while (--i >= 0)
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
> >> +        if (rdma_port_ll_is_ib(device, i + 1))
> >>              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >>  
> >>      kfree(sa_dev);
> >> @@ -1233,7 +1233,7 @@ static void ib_sa_remove_one(struct ib_device *device)
> >>      flush_workqueue(ib_wq);
> >>  
> >>      for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> >> -        if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
> >> +        if (rdma_port_ll_is_ib(device, i + 1)) {
> >>              ib_unregister_mad_agent(sa_dev->port[i].agent);
> >>              if (sa_dev->port[i].sm_ah)
> >>                  kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
> >> 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/core/verbs.c b/drivers/infiniband/core/verbs.c
> >> index f93eb8d..d8d015a 100644
> >> --- a/drivers/infiniband/core/verbs.c
> >> +++ b/drivers/infiniband/core/verbs.c
> >> @@ -198,8 +198,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
> >>      u32 flow_class;
> >>      u16 gid_index;
> >>      int ret;
> >> -    int is_eth = (rdma_port_get_link_layer(device, port_num) ==
> >> -            IB_LINK_LAYER_ETHERNET);
> >> +    int is_eth = (rdma_port_ll_is_eth(device, port_num));
> >>  
> >>      memset(ah_attr, 0, sizeof *ah_attr);
> >>      if (is_eth) {
> >> @@ -871,7 +870,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
> >>      union ib_gid  sgid;
> >>  
> >>      if ((*qp_attr_mask & IB_QP_AV)  &&
> >> -        (rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
> >> +        (rdma_port_ll_is_eth(qp->device, qp_attr->ah_attr.port_num))) {
> >>          ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
> >>                     qp_attr->ah_attr.grh.sgid_index, &sgid);
> >>          if (ret)
> >> diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
> >> index 2d8c339..829eb60 100644
> >> --- a/drivers/infiniband/hw/mlx4/ah.c
> >> +++ b/drivers/infiniband/hw/mlx4/ah.c
> >> @@ -118,7 +118,7 @@ struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
> >>      if (!ah)
> >>          return ERR_PTR(-ENOMEM);
> >>  
> >> -    if (rdma_port_get_link_layer(pd->device, ah_attr->port_num) == IB_LINK_LAYER_ETHERNET) {
> >> +    if (rdma_port_ll_is_eth(pd->device, ah_attr->port_num)) {
> >>          if (!(ah_attr->ah_flags & IB_AH_GRH)) {
> >>              ret = ERR_PTR(-EINVAL);
> >>          } else {
> >> diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
> >> index cb63ecd..0417f03 100644
> >> --- a/drivers/infiniband/hw/mlx4/cq.c
> >> +++ b/drivers/infiniband/hw/mlx4/cq.c
> >> @@ -789,9 +789,7 @@ repoll:
> >>              break;
> >>          }
> >>  
> >> -        is_eth = (rdma_port_get_link_layer(wc->qp->device,
> >> -                          (*cur_qp)->port) ==
> >> -              IB_LINK_LAYER_ETHERNET);
> >> +        is_eth = (rdma_port_ll_is_eth(wc->qp->device, (*cur_qp)->port));
> >>          if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
> >>              if ((*cur_qp)->mlx4_ib_qp_type &
> >>                  (MLX4_IB_QPT_PROXY_SMI_OWNER |
> >> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> >> index 82a7dd8..4736fc7 100644
> >> --- a/drivers/infiniband/hw/mlx4/mad.c
> >> +++ b/drivers/infiniband/hw/mlx4/mad.c
> >> @@ -606,12 +606,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
> >>      int err;
> >>      int slave;
> >>      u8 *slave_id;
> >> -    int is_eth = 0;
> >> -
> >> -    if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> >> -        is_eth = 0;
> >> -    else
> >> -        is_eth = 1;
> >> +    int is_eth = rdma_port_ll_is_eth(ibdev, port);
> >>  
> >>      if (is_eth) {
> >>          if (!(wc->wc_flags & IB_WC_GRH)) {
> >> @@ -1252,7 +1247,7 @@ out:
> >>  
> >>  static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
> >>  {
> >> -    if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(&dev->ib_dev, port))
> >>          return slave;
> >>      return mlx4_get_base_gid_ix(dev->dev, slave, port);
> >>  }
> >> @@ -1260,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_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_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);
> >> @@ -1758,8 +1753,7 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
> >>  
> >>      ctx->state = DEMUX_PV_STATE_STARTING;
> >>      /* have QP0 only if link layer is IB */
> >> -    if (rdma_port_get_link_layer(ibdev, ctx->port) ==
> >> -        IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(ibdev, ctx->port))
> >>          ctx->has_smi = 1;
> >>  
> >>      if (ctx->has_smi) {
> >> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> >> index 0b280b1..f445f4c 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_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
> >> +    if (rdma_port_ll_is_ib(ibdev, port))
> >>          return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
> >>      else
> >>          return iboe_query_gid(ibdev, port, index, gid);
> >> @@ -1801,8 +1801,7 @@ static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
> >>      int err = 0;
> >>  
> >>      for (i = 1; i <= ibdev->num_ports; ++i) {
> >> -        if (rdma_port_get_link_layer(&ibdev->ib_dev, i) ==
> >> -            IB_LINK_LAYER_ETHERNET) {
> >> +        if (rdma_port_ll_is_eth(&ibdev->ib_dev, i)) {
> >>              err = reset_gid_table(ibdev, i);
> >>              if (err)
> >>                  goto out;
> >> @@ -2554,8 +2553,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
> >>          if (p > ibdev->num_ports)
> >>              return;
> >>          if (mlx4_is_master(dev) &&
> >> -            rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
> >> -            IB_LINK_LAYER_INFINIBAND) {
> >> +            rdma_port_ll_is_ib(&ibdev->ib_dev, p)) {
> >>              mlx4_ib_invalidate_all_guid_record(ibdev, p);
> >>          }
> >>          ibev.event = IB_EVENT_PORT_ACTIVE;
> >> diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> index 6eb743f..1befeb8 100644
> >> --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
> >> @@ -712,7 +712,7 @@ static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
> >>  {
> >>      u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
> >>  
> >> -    if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
> >> +    if (rdma_port_ll_is_eth(ah->ibah.device, port))
> >>          return true;
> >>  
> >>      return !!(ah->av.ib.g_slid & 0x80);
> >> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> >> index c880329..bd2f557 100644
> >> --- a/drivers/infiniband/hw/mlx4/qp.c
> >> +++ b/drivers/infiniband/hw/mlx4/qp.c
> >> @@ -1248,8 +1248,7 @@ static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
> >>                u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
> >>                struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
> >>  {
> >> -    int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
> >> -        IB_LINK_LAYER_ETHERNET;
> >> +    int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, port);
> >>      int vidx;
> >>      int smac_index;
> >>      int err;
> >> @@ -1433,8 +1432,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>  
> >>      /* APM is not supported under RoCE */
> >>      if (attr_mask & IB_QP_ALT_PATH &&
> >> -        rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> >> -        IB_LINK_LAYER_ETHERNET)
> >> +        rdma_port_ll_is_eth(&dev->ib_dev, qp->port))
> >>          return -ENOTSUPP;
> >>  
> >>      context = kzalloc(sizeof *context, GFP_KERNEL);
> >> @@ -1664,8 +1662,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>                  context->pri_path.fl = 0x80;
> >>              context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
> >>          }
> >> -        if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
> >> -            IB_LINK_LAYER_ETHERNET) {
> >> +        if (rdma_port_ll_is_eth(&dev->ib_dev, qp->port)) {
> >>              if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
> >>                  qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
> >>                  context->pri_path.feup = 1 << 7; /* don't fsm */
> >> @@ -1695,9 +1692,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
> >>      }
> >>  
> >>      if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
> >> -        int is_eth = rdma_port_get_link_layer(
> >> -                &dev->ib_dev, qp->port) ==
> >> -                IB_LINK_LAYER_ETHERNET;
> >> +        int is_eth = rdma_port_ll_is_eth(&dev->ib_dev, qp->port);
> >>          if (is_eth) {
> >>              context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
> >>              optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
> >> @@ -1927,8 +1922,7 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
> >>      }
> >>  
> >>      if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
> >> -        (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
> >> -         IB_LINK_LAYER_ETHERNET))
> >> +        !rdma_port_ll_is_eth(&dev->ib_dev, attr->port_num))
> >>          goto out;
> >>  
> >>      if (attr_mask & IB_QP_PKEY_INDEX) {
> >> @@ -2132,7 +2126,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
> >>      for (i = 0; i < wr->num_sge; ++i)
> >>          send_size += wr->sg_list[i].length;
> >>  
> >> -    is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
> >> +    is_eth = rdma_port_ll_is_eth(sqp->qp.ibqp.device, sqp->qp.port);
> >>      is_grh = mlx4_ib_ah_grh_present(ah);
> >>      if (is_eth) {
> >>          if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
> >> @@ -3029,8 +3023,7 @@ static void to_ib_ah_attr(struct mlx4_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
> >>      if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports)
> >>          return;
> >>  
> >> -    is_eth = rdma_port_get_link_layer(&ibdev->ib_dev, ib_ah_attr->port_num) ==
> >> -        IB_LINK_LAYER_ETHERNET;
> >> +    is_eth = rdma_port_ll_is_eth(&ibdev->ib_dev, ib_ah_attr->port_num);
> >>      if (is_eth)
> >>          ib_ah_attr->sl = ((path->sched_queue >> 3) & 0x7) |
> >>          ((path->sched_queue & 4) << 1);
> >> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
> >> index cb4c66e..d339b55 100644
> >> --- a/drivers/infiniband/hw/mlx4/sysfs.c
> >> +++ b/d