diff mbox

[6/6] RDMA/ocrdma: introducing a function to check RoCE-v2 support

Message ID c1040ad6-3daa-4cce-9368-16f10d636952@CMEXHTCAS1.ad.emulex.com (mailing list archive)
State Rejected
Headers show

Commit Message

Somnath Kotur Dec. 25, 2014, 1 a.m. UTC
From: Devesh Sharma <devesh.sharma@emulex.com>

This patch replaces the checks for RoCE-v2 support with
an inline function to perform the same check for ease
of readability.

Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com>
Signed-off-by: Somnath Kotur <somnath.kotur@emulex.com>
---
 drivers/infiniband/hw/ocrdma/ocrdma.h       |    5 +++++
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |    3 +--
 drivers/infiniband/hw/ocrdma/ocrdma_main.c  |    6 ++----
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c |    6 ++----
 4 files changed, 10 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h
index 2c868d7..e3f9478 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma.h
@@ -577,4 +577,9 @@  static inline u8 ocrdma_is_enabled_and_synced(u32 state)
 		(state & OCRDMA_STATE_FLAG_SYNC);
 }
 
+static inline bool ocrdma_is_rocev2_supported(struct ocrdma_dev *dev)
+{
+	return (dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV4 ||
+		dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV6) ? true : false;
+}
 #endif
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 5b326dd..2560903 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -200,8 +200,7 @@  struct ib_ah *ocrdma_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr)
 		if (isvlan)
 			*ahid_addr |= (OCRDMA_AH_VLAN_VALID_MASK <<
 				       OCRDMA_AH_VLAN_VALID_SHIFT);
-		if (dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV4 ||
-		    dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV6)
+		if (ocrdma_is_rocev2_supported(dev))
 			*ahid_addr |= ((u32)ah->hdr_type &
 				       OCRDMA_AH_L3_TYPE_MASK) <<
 				       OCRDMA_AH_L3_TYPE_SHIFT;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
index 34e9c1d..1c3bc5c 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
@@ -220,8 +220,7 @@  static enum ib_port_type ocrdma_get_port_type(struct ib_device *device,
 {
 	struct ocrdma_dev *dev = get_ocrdma_dev(device);
 
-	return (dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV4 ||
-		dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV6) ?
+	return ocrdma_is_rocev2_supported(dev) ?
 		IB_PORT_TYPE_RoCEV2 : IB_PORT_TYPE_V1;
 }
 
@@ -339,8 +338,7 @@  static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
 {
 	int tblsz = OCRDMA_MAX_SGID;
 
-	if (dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV4 ||
-	    dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV6)
+	if (ocrdma_is_rocev2_supported(dev))
 		tblsz *= 2;
 
 	mutex_init(&dev->dev_lock);
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index e80e37f..ef8282f 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -191,8 +191,7 @@  int ocrdma_query_port(struct ib_device *ibdev,
 	    IB_PORT_CM_SUP |
 	    IB_PORT_REINIT_SUP |
 	    IB_PORT_DEVICE_MGMT_SUP | IB_PORT_VENDOR_CLASS_SUP | IB_PORT_IP_BASED_GIDS;
-	if (dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV4 ||
-	    dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV6)
+	if (ocrdma_is_rocev2_supported(dev))
 		props->port_cap_flags |= IB_PORT_RoCEV2_BASED_GIDS;
 
 	props->gid_tbl_len = dev->gid_tblsz;
@@ -2709,8 +2708,7 @@  static int ocrdma_update_ud_rcqe(struct ocrdma_dev *dev, struct ib_wc *ibwc,
 			  OCRDMA_CQE_UD_XFER_LEN_SHIFT) &
 			  OCRDMA_CQE_UD_XFER_LEN_MASK;
 
-	if (dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV4 ||
-	    dev->attr.roce_flags & OCRDMA_L3_TYPE_IPV6) {
+	if (ocrdma_is_rocev2_supported(dev)) {
 		hdr_type = (le32_to_cpu(cqe->ud.rxlen_pkey) >>
 			    OCRDMA_CQE_UD_L3TYPE_SHIFT) &
 			    OCRDMA_CQE_UD_L3TYPE_MASK;