From patchwork Thu Dec 25 01:00:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 5537911 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CDC49F1CD for ; Wed, 24 Dec 2014 08:33:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9C7420155 for ; Wed, 24 Dec 2014 08:33:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7B84201B9 for ; Wed, 24 Dec 2014 08:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751638AbaLXIdm (ORCPT ); Wed, 24 Dec 2014 03:33:42 -0500 Received: from cmexedge2.emulex.com ([138.239.224.100]:32962 "EHLO CMEXEDGE2.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751589AbaLXIdl (ORCPT ); Wed, 24 Dec 2014 03:33:41 -0500 Received: from CMEXHTCAS1.ad.emulex.com (138.239.115.217) by CMEXEDGE2.ext.emulex.com (138.239.224.100) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 24 Dec 2014 00:33:42 -0800 Received: from codebrowse.emulex.com (10.192.207.129) by smtp.emulex.com (138.239.115.207) with Microsoft SMTP Server id 14.3.174.1; Wed, 24 Dec 2014 00:33:37 -0800 From: Somnath Kotur To: CC: , Devesh Sharma , Somnath Kotur Subject: [PATCH 6/6] RDMA/ocrdma: introducing a function to check RoCE-v2 support Date: Thu, 25 Dec 2014 06:30:18 +0530 X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Message-ID: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_12_24, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Devesh Sharma 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 Signed-off-by: Somnath Kotur --- 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 --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;