Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3796525imm; Fri, 25 May 2018 11:48:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqb5QaET8wKoiste+3gD7NkmfsnihA+QWAaWb+BFlBd3XrhK/m4aMve71EYOmwRC/z9OyG/ X-Received: by 2002:a17:902:b087:: with SMTP id p7-v6mr3736420plr.227.1527274104725; Fri, 25 May 2018 11:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527274104; cv=none; d=google.com; s=arc-20160816; b=LP1prFom5p5szBZW1o7sClny3VxzV0wPCDuQgVRaR08lMHEa5a5A4lrbz2DBmUL+rJ 4o4TMZzQZOp88sjDJ50evKauhzV0fOkA/qXftN/7xLYa13gNgWtdljB3ITPyBgOV0W5X 2mPA//qFd56YRBGjfoWK28QGmlBz15Ywy/9WeDimYJVVUs2h6G25TdFBZzCyWJ6KSTiU gn1jIv4l/bhIRXGZ3rPbZfo+uerF6NiGhI6EygfbqWMAj1sFo7xXAzKQHQdZzhh8zpIV tYJ6eJ+tijfXpjVW2zLA3hlGe1w6nBbtO1cFotup1RupEL0eSJE6WbHnzDngk77tRDM7 WkXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=AdL++1gM5emjmAcwGDAMYU6BHWtab2Kb7JAWOzEVWLY=; b=zWngPj6nqnWi6Io9xvuKIC+2nzNgDNMkwY4t1hIcWS6PbTJko7qoGtlOkdQuSEBrAP Fvla35VwJEmfhqeFTgMCJEKXoXIG+J/UdZFkUnmuOYtm8zoSdP0r5ncUcYoM2Au/RVts UdZAwgd32ZOhdab1aJIvbWuYMbhLDaIBTdC8Y0LBWZ9McXo32MB4JiH6/ERx4yJg+Auq XZbOH2MaW7mO5nRwMRWMkIe4Y4ugU2X0LCGX4E1PM/oLdBRH5No0Qk3x0CjkEmirViu4 G+yOiPiuW5DOWR9pQoJ6e86pT3NMJPmc8iSt0k40JZzo8u5spPPGSSEdzj9LTxRfzwbl 4AAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f39-v6si24010822plb.572.2018.05.25.11.48.09; Fri, 25 May 2018 11:48:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968002AbeEYSox (ORCPT + 99 others); Fri, 25 May 2018 14:44:53 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8141 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967820AbeEYSoo (ORCPT ); Fri, 25 May 2018 14:44:44 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DAA906759C475; Sat, 26 May 2018 02:44:30 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Sat, 26 May 2018 02:44:25 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 01/12] net: hns3: Updates RX packet info fetch in case of multi BD Date: Fri, 25 May 2018 19:42:56 +0100 Message-ID: <20180525184307.36288-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180525184307.36288-1-salil.mehta@huawei.com> References: <20180525184307.36288-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Li In the latest revision of the hardware, if a packet is spanning across multiple BDs then only VLD bit and current data size info is valid in each BD, and rest of the information is only valid in the last BD of the packet. In such case we should make sure we are fetching RX packet size from the first descriptor and information like VLAN should be fetched from last BD. Signed-off-by: Peng Li Reviewed-by: Yisen Zhuang Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index cac5195..ae8d749 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2085,9 +2085,8 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, prefetch(desc); - length = le16_to_cpu(desc->rx.pkt_len); + length = le16_to_cpu(desc->rx.size); bd_base_info = le32_to_cpu(desc->rx.bd_base_info); - l234info = le32_to_cpu(desc->rx.l234_info); /* Check valid BD */ if (!hnae_get_bit(bd_base_info, HNS3_RXD_VLD_B)) @@ -2121,22 +2120,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, prefetchw(skb->data); - /* Based on hw strategy, the tag offloaded will be stored at - * ot_vlan_tag in two layer tag case, and stored at vlan_tag - * in one layer tag case. - */ - if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) { - u16 vlan_tag; - - vlan_tag = le16_to_cpu(desc->rx.ot_vlan_tag); - if (!(vlan_tag & VLAN_VID_MASK)) - vlan_tag = le16_to_cpu(desc->rx.vlan_tag); - if (vlan_tag & VLAN_VID_MASK) - __vlan_hwaccel_put_tag(skb, - htons(ETH_P_8021Q), - vlan_tag); - } - bnum = 1; if (length <= HNS3_RX_HEAD_SIZE) { memcpy(__skb_put(skb, length), va, ALIGN(length, sizeof(long))); @@ -2172,6 +2155,23 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, } *out_bnum = bnum; + /* Based on hw strategy, the tag offloaded will be stored at + * ot_vlan_tag in two layer tag case, and stored at vlan_tag + * in one layer tag case. + */ + if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) { + u16 vlan_tag; + + vlan_tag = le16_to_cpu(desc->rx.ot_vlan_tag); + if (!(vlan_tag & VLAN_VID_MASK)) + vlan_tag = le16_to_cpu(desc->rx.vlan_tag); + if (vlan_tag & VLAN_VID_MASK) + __vlan_hwaccel_put_tag(skb, + htons(ETH_P_8021Q), + vlan_tag); + } + + l234info = le32_to_cpu(desc->rx.l234_info); if (unlikely(!hnae_get_bit(bd_base_info, HNS3_RXD_VLD_B))) { netdev_err(netdev, "no valid bd,%016llx,%016llx\n", -- 2.7.4