From patchwork Wed Nov 8 05:44:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 10047689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7EA960381 for ; Wed, 8 Nov 2017 05:45:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A61382A433 for ; Wed, 8 Nov 2017 05:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98B032A437; Wed, 8 Nov 2017 05:45:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF7B32A433 for ; Wed, 8 Nov 2017 05:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753084AbdKHFpK (ORCPT ); Wed, 8 Nov 2017 00:45:10 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:45694 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbdKHFpJ (ORCPT ); Wed, 8 Nov 2017 00:45:09 -0500 Received: by mail-qk0-f196.google.com with SMTP id c16so1992524qke.2 for ; Tue, 07 Nov 2017 21:45:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=UegPNjWG0Zgeo8GpdI1f6M7BHMgq2tIaevAwbRKfPtY=; b=YF6rbMb3kheAUgSrsz9TtwCaqq0DphBEB5ZTDH8Mfkbe11HzoYp1qlAOZJu3dr9xuA Y3HYTiolz2FXL8DFpuhEd0T3BaMuVIewnJMM8Py34gaQafoKEu2S09hEbVBd4Jv0+ouI wty+jjtID2zU5PU4lB2d/NEc1vTonXA/nE+4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UegPNjWG0Zgeo8GpdI1f6M7BHMgq2tIaevAwbRKfPtY=; b=h/GB9e5JwaCm273LeqLv32mEWXSVWRTEIJGqEMXtDYO1ULrDU6DFqWhgdZV8Lctl4p e360rAWfnXaTNuJT6i/iI+LrXtn0zbzJm4wEbFa+YXCGiJrtp++5tGLioQpSxPK8btpF Ts9k03XkmfiG+hHuPJYrn11AhNiMXE2/2uyVkxfqdwdPaDs6fAErbfFSeVzkxTO7CaX5 yckZ0uz8tdMOIrb0tM25rT3uCCbHu6MPNY8BYYFVK87EecgSZwHo8jfsQtgodmqprl3g Aj8EwgKAkueMbe48i3cLs3fiDnOuBjM0+LJ4kqnrUf1ZvD+v/HRiWdEsu98k9y1hn1gM GSCw== X-Gm-Message-State: AJaThX7DTJ5aMU1wF3Na8HPOdM+FvtjWoriTPhMMRc3ngJX8O0Tx4ewl IDjngLb4cLgwA8TkBAFOpOMt+Q== X-Google-Smtp-Source: ABhQp+Rl3QuSoPufX5s2DZ/NyCZ0Wh2+JcagxDsNsKli6AcPIokGJuGVrNZne4TRz5GzKidfQf4J0g== X-Received: by 10.55.44.3 with SMTP id s3mr1838618qkh.122.1510119909112; Tue, 07 Nov 2017 21:45:09 -0800 (PST) Received: from neo00-el73.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id s76sm2142524qkl.81.2017.11.07.21.45.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 21:45:08 -0800 (PST) From: Devesh Sharma To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, parav@mellanox.com, leon@kernel.org, Devesh Sharma Subject: [PATCH] RDMA/bnxt_re: report vlan_id and sl in qp1 recv completion Date: Wed, 8 Nov 2017 00:44:53 -0500 Message-Id: <1510119893-24676-1-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In a real RoCE v2 network it is possible to have two Sections of network have same IP hence same gid. However those may have different vlans. During connection resolution it is important to report the actual vlan on which the MAD packet was received instead of relying on other means to resolve vlan-id. ib_find_gid_index should not be used to resolve the vlan-id using sgid of the local system where the packet was received. Our device has the capability to report the actual VLAN-ID in the GSI qp completions. Since we have the capability our driver should move away from resolving the vlan-id with the help of SGID at the destination port. Signed-off-by: Devesh Sharma Reported-by: Parav Pandit --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 33 ++++++++++++++++++++++++++++++++ drivers/infiniband/hw/bnxt_re/qplib_fp.c | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index ebcdfb4..558d786 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -2771,6 +2771,32 @@ static void bnxt_re_process_res_rawqp1_wc(struct ib_wc *wc, wc->wc_flags |= IB_WC_GRH; } +static bool bnxt_re_is_vlan_pkt(struct bnxt_qplib_cqe *orig_cqe, + u16 *vid, u8 *sl) +{ + u32 metadata; + u16 tpid; + bool ret = false; + + metadata = orig_cqe->raweth_qp1_metadata; + if (orig_cqe->raweth_qp1_flags2 & + CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_VLAN) { + tpid = ((metadata & + CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_MASK) >> + CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_SFT); + if (tpid == ETH_P_8021Q) { + *vid = metadata & + CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_MASK; + *sl = (metadata & + CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_MASK) >> + CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_SFT; + ret = true; + } + } + + return ret; +} + static void bnxt_re_process_res_rc_wc(struct ib_wc *wc, struct bnxt_qplib_cqe *cqe) { @@ -2796,6 +2822,8 @@ static void bnxt_re_process_res_shadow_qp_wc(struct bnxt_re_qp *qp, struct bnxt_qplib_cqe *orig_cqe = NULL; struct bnxt_re_sqp_entries *sqp_entry = NULL; int nw_type; + u16 vlan_id; + u8 sl; tbl_idx = cqe->wr_id; @@ -2810,6 +2838,11 @@ static void bnxt_re_process_res_shadow_qp_wc(struct bnxt_re_qp *qp, wc->ex.imm_data = orig_cqe->immdata; wc->src_qp = orig_cqe->src_qp; memcpy(wc->smac, orig_cqe->smac, ETH_ALEN); + if (bnxt_re_is_vlan_pkt(orig_cqe, &vlan_id, &sl)) { + wc->vlan_id = vlan_id; + wc->sl = sl; + wc->wc_flags |= IB_WC_WITH_VLAN; + } wc->port_num = 1; wc->vendor_err = orig_cqe->status; diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index a82044d..8962621 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c @@ -2236,6 +2236,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq, cqe->raweth_qp1_flags = le16_to_cpu(hwcqe->raweth_qp1_flags); cqe->raweth_qp1_flags2 = le32_to_cpu(hwcqe->raweth_qp1_flags2); + cqe->raweth_qp1_metadata = le32_to_cpu(hwcqe->raweth_qp1_metadata); rq = &qp->rq; if (wr_id_idx > rq->hwq.max_elements) {