From patchwork Wed Nov 8 07:48:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 10047899 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 883F86032D for ; Wed, 8 Nov 2017 07:49:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7918A293CB for ; Wed, 8 Nov 2017 07:49:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D5272A4F3; Wed, 8 Nov 2017 07:49:06 +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 7E6EF293CB for ; Wed, 8 Nov 2017 07:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751084AbdKHHtB (ORCPT ); Wed, 8 Nov 2017 02:49:01 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:44640 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750832AbdKHHs6 (ORCPT ); Wed, 8 Nov 2017 02:48:58 -0500 Received: by mail-qk0-f195.google.com with SMTP id v137so2261613qkb.1 for ; Tue, 07 Nov 2017 23:48:58 -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=pJXfZjLPXHh4hnuVcI9MsfKVhjmiMXjrBGuq99Q2yOY=; b=Deb+OpojrOjfkkF8lMIqJZqs2v9ew8rm7QhsOP0TmRlrBm/zakN9gaoOl2IZJjhKfo vNs3hneD0yfwSICJ4nqB0+i+wDawxy0GZBmea0tDWDCfW1I14UZqDTwMslDl0OqpoM2u RzS4m6p5QAmM6S6Ui5oqkNfQb4bhKMlV8mcyE= 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=pJXfZjLPXHh4hnuVcI9MsfKVhjmiMXjrBGuq99Q2yOY=; b=EDYJgP3Yye2pQO5qgDm1N2J8dH1/DxquiJ/8Dt33uYL6th6WutiwG4ljjEPul6Mja9 wj6e3lysJRXn5e3xN8bSbFrspW6jkCqFITJH7yj2xq3oVtL0cXVd9gkHaYEkfT2UAwxx oRwfV3/ERgjkb4YoxtnR5asSsIGbBYXICAyYRvGfydohWyvPlyjQNQvmxAtlUjbLVTJ4 tIbocP/6qfPDP1PGCXX4lwdSX+6INbqeOQ91DQy7oemjBmNC1un4zfRertu0wSkt0Tb8 xcjn3PY1NllLOymcSfrwwAOY16tiFkVSnMy+Br7PcpRP8iGE9UNqsgST2iGk8/yNZ5RW UNJg== X-Gm-Message-State: AJaThX5Ovv0bsUByDYMUh5av45FLYDZMNbURyR/NPbBkQkMCNPz61n2d LWOdShQFWJ5XwwmuYGBXo3NbpQ== X-Google-Smtp-Source: ABhQp+RI1pDTtuo7q7PmK3uDnS2Bg19PjC+Jksxj9iYow6I02oz67LH8I/I06Qn0VZD8mRW7nPazgg== X-Received: by 10.55.217.149 with SMTP id q21mr2151982qkl.102.1510127337691; Tue, 07 Nov 2017 23:48:57 -0800 (PST) Received: from neo00-el73.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id c16sm2289419qtd.57.2017.11.07.23.48.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 23:48:56 -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 v1] RDMA/bnxt_re: report vlan_id and sl in qp1 recv completion Date: Wed, 8 Nov 2017 02:48:45 -0500 Message-Id: <1510127325-26879-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 | 35 +++++++++++++++++++++++++++++++- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index ebcdfb4..bdb6435 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) +{ + bool ret = false; + u32 metadata; + u16 tpid; + + 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) { @@ -2790,12 +2816,14 @@ static void bnxt_re_process_res_shadow_qp_wc(struct bnxt_re_qp *qp, struct ib_wc *wc, struct bnxt_qplib_cqe *cqe) { - u32 tbl_idx; struct bnxt_re_dev *rdev = qp->rdev; struct bnxt_re_qp *qp1_qp = NULL; struct bnxt_qplib_cqe *orig_cqe = NULL; struct bnxt_re_sqp_entries *sqp_entry = NULL; int nw_type; + u32 tbl_idx; + 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) {