diff mbox

[RFC,02/11] IB/Verbs: Use management helper tech_iboe() for iboe-check

Message ID 55157A4F.1090301@profitbricks.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Wang March 27, 2015, 3:42 p.m. UTC
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(-)

Comments

Doug Ledford March 30, 2015, 4:17 p.m. UTC | #1
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);
>
Michael Wang March 30, 2015, 4:23 p.m. UTC | #2
On 03/30/2015 06:17 PM, Doug Ledford wrote:
> 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.
Sounds good :-) will be in next version.

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

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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