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