From patchwork Fri May 25 18:42:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136978 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3943266lji; Fri, 25 May 2018 11:44:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqL+XbRCf10wRbyUsWrn4bOGig0b5vd2tOo1XVJBm//cEsuyWSUfaReZLUP6BUwwQk6+iT2 X-Received: by 2002:a63:be01:: with SMTP id l1-v6mr2908322pgf.382.1527273897966; Fri, 25 May 2018 11:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273897; cv=none; d=google.com; s=arc-20160816; b=YUokhTgtAkaqjxCuYIZKLJApGwsCsIurzlXCkgV/R0R1hjkC2xKPVhv9zTnzoXg+B1 X3KAv72t4fIT3sOsZSQpI6/l28VN9qeUPCvFhcP9Yx/yy5hzlMgs2kHZhBsYfAWQNeYR jQjzSUaxLjKIqZRK2xeo5CKoQixSKBPB1I/oBHt45Bqx5NCTqDft/ChPwcGZq7zaHQVW hTuCldoHnwkl4tZcAcmEo13miIJEIUS7BxYncCEnQq3WkH676Z236cludgXSv0yMglXs g0QkqsXdUXsPx4i8qI6JCP6PMVndoV4Mtydh6T5x24SMP3eAPmXkjO4Gk5SQXwR92pHT WGJg== 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 5-v6si24142171pfi.285.2018.05.25.11.44.57; Fri, 25 May 2018 11:44:57 -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 S968006AbeEYSoy (ORCPT + 30 others); Fri, 25 May 2018 14:44:54 -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 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(-) -- 2.7.4 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", From patchwork Fri May 25 18:42:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136988 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3946315lji; Fri, 25 May 2018 11:48:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoy+8UFS/WkKZNoF/7hWs+TQiD0PB27rSbtYHOhJu/G8bv686C8g8eJtrS36SswjX4p7XOX X-Received: by 2002:a17:902:7e06:: with SMTP id b6-v6mr3730577plm.151.1527274114403; Fri, 25 May 2018 11:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527274114; cv=none; d=google.com; s=arc-20160816; b=fpmTzGf0v3IFYSIsLIKNQlXBdFnNdGYB+oWr9VV4naHFgImCn+sNChgw1bl+Vc6hn+ Sp79jYrj0Si6uWy9FdDt842u1LE2Fwll2OB2fSr115i6aVtPCXne3//UVf6/q+Bc07TX TPbhQMlLKtJcQA2mUU5iD+gGou4YhEgRUzQTxSLLaCbji9WuOtAa3HPMUmhqBXJNqeAC OIcz2wnKwKrrfAl/k+t08fGUfWbL8+HXXd+nKOyc20pV/pAVnPx9s/LyzrNx+UEpUeRA MSx8VrTb18OP4zSdmvewvLVxxRtxWCe/zodvMET9iQ4JrySPFbn1N/jYqwX2Q0R7fe8u KBig== 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=7azRa8ixGTohyUdnXaxWErNWwxCkNYNe6OepxwcdM7w=; b=oP1+wyL0W1UMN2GBbhSk7Uiw/BE0JK02UZoVupKx6RyO6iHCW+9fo4WJIJAPVETdTK nwslAgP3driVlkpCumenn7PBQUuJer9g+j4+/LLT6TRDcgtHSch8P0F22HgJoYq2vn6L snFch33887QEm028XMrF+NVonPj13IVNkUsRtNZ7dIK6iR2vmEJ52LGbfPzQQo7RHT9q UgoCbf+FXdXI+0zA3xWo4xFvm2422ljiPjynVH9E9BFCYUDmldKEm9QzqM/HNAAF7Nms 0abPLzEC/QAynLeAvV2kCWvkjNLDweERZYQl0oU8h81JH7RaEZEAAecI5URUrSl2XDBO mhKg== 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 m1-v6si24171847pfe.79.2018.05.25.11.48.34; Fri, 25 May 2018 11:48:34 -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 S967767AbeEYSol (ORCPT + 30 others); Fri, 25 May 2018 14:44:41 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:34813 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S967453AbeEYSoj (ORCPT ); Fri, 25 May 2018 14:44:39 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B1EA8A1DE4EF8; Sat, 26 May 2018 02:44:36 +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:28 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 02/12] net: hns3: Add support for tx_accept_tag2 and tx_accept_untag2 config Date: Fri, 25 May 2018 19:42:57 +0100 Message-ID: <20180525184307.36288-3-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 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 HNS3 Hardware can support up to two VLAN tags in transmit leg, the PPP module can handle the packets based on the tag1 and tag2 config. This patch adds support for tag2 config for vlan handling Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 7 ++++-- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 26 +++++++++++++++++----- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 6 +++-- 3 files changed, 29 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index ee3cbac..3fa08f7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -704,11 +704,14 @@ struct hclge_vlan_filter_vf_cfg_cmd { u8 vf_bitmap[16]; }; -#define HCLGE_ACCEPT_TAG_B 0 -#define HCLGE_ACCEPT_UNTAG_B 1 +#define HCLGE_ACCEPT_TAG1_B 0 +#define HCLGE_ACCEPT_UNTAG1_B 1 #define HCLGE_PORT_INS_TAG1_EN_B 2 #define HCLGE_PORT_INS_TAG2_EN_B 3 #define HCLGE_CFG_NIC_ROCE_SEL_B 4 +#define HCLGE_ACCEPT_TAG2_B 5 +#define HCLGE_ACCEPT_UNTAG2_B 6 + struct hclge_vport_vtag_tx_cfg_cmd { u8 vport_vlan_cfg; u8 vf_offset; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2f0bbb6..c0b8d5a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -4687,10 +4687,14 @@ static int hclge_set_vlan_tx_offload_cfg(struct hclge_vport *vport) req = (struct hclge_vport_vtag_tx_cfg_cmd *)desc.data; req->def_vlan_tag1 = cpu_to_le16(vcfg->default_tag1); req->def_vlan_tag2 = cpu_to_le16(vcfg->default_tag2); - hnae_set_bit(req->vport_vlan_cfg, HCLGE_ACCEPT_TAG_B, - vcfg->accept_tag ? 1 : 0); - hnae_set_bit(req->vport_vlan_cfg, HCLGE_ACCEPT_UNTAG_B, - vcfg->accept_untag ? 1 : 0); + hnae_set_bit(req->vport_vlan_cfg, HCLGE_ACCEPT_TAG1_B, + vcfg->accept_tag1 ? 1 : 0); + hnae_set_bit(req->vport_vlan_cfg, HCLGE_ACCEPT_UNTAG1_B, + vcfg->accept_untag1 ? 1 : 0); + hnae_set_bit(req->vport_vlan_cfg, HCLGE_ACCEPT_TAG2_B, + vcfg->accept_tag2 ? 1 : 0); + hnae_set_bit(req->vport_vlan_cfg, HCLGE_ACCEPT_UNTAG2_B, + vcfg->accept_untag2 ? 1 : 0); hnae_set_bit(req->vport_vlan_cfg, HCLGE_PORT_INS_TAG1_EN_B, vcfg->insert_tag1_en ? 1 : 0); hnae_set_bit(req->vport_vlan_cfg, HCLGE_PORT_INS_TAG2_EN_B, @@ -4814,8 +4818,18 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev) for (i = 0; i < hdev->num_alloc_vport; i++) { vport = &hdev->vport[i]; - vport->txvlan_cfg.accept_tag = true; - vport->txvlan_cfg.accept_untag = true; + vport->txvlan_cfg.accept_tag1 = true; + vport->txvlan_cfg.accept_untag1 = true; + + /* accept_tag2 and accept_untag2 are not supported on + * pdev revision(0x20), new revision support them. The + * value of this two fields will not return error when driver + * send command to fireware in revision(0x20). + * This two fields can not configured by user. + */ + vport->txvlan_cfg.accept_tag2 = true; + vport->txvlan_cfg.accept_untag2 = true; + vport->txvlan_cfg.insert_tag1_en = false; vport->txvlan_cfg.insert_tag2_en = false; vport->txvlan_cfg.default_tag1 = 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 93177d9..677f1e4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -570,8 +570,10 @@ struct hclge_dev { /* VPort level vlan tag configuration for TX direction */ struct hclge_tx_vtag_cfg { - bool accept_tag; /* Whether accept tagged packet from host */ - bool accept_untag; /* Whether accept untagged packet from host */ + bool accept_tag1; /* Whether accept tag1 packet from host */ + bool accept_untag1; /* Whether accept untag1 packet from host */ + bool accept_tag2; + bool accept_untag2; bool insert_tag1_en; /* Whether insert inner vlan tag */ bool insert_tag2_en; /* Whether insert outer vlan tag */ u16 default_tag1; /* The default inner vlan tag to insert */ From patchwork Fri May 25 18:42:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136975 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3943091lji; Fri, 25 May 2018 11:44:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq3HoQXSgNenZzoJo8Dy98+l34tZuuh8yuzng1jv4r+zfQhP01mrGe9OCEd9GaxPbS2jh30 X-Received: by 2002:a63:2bc4:: with SMTP id r187-v6mr2894264pgr.231.1527273884511; Fri, 25 May 2018 11:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273884; cv=none; d=google.com; s=arc-20160816; b=LJnKdl+o9Wvh0IJUSWvdIVGiVb8Uki0vNWMdRqLqhipq7yNVJs0YSk9We7VYThHkhr E0/3dEToqSktIvwT/5t5B0xeFnP5YB9rTo3K6bemXlDrJE1h6obf6EnMssSL63wf/pwt ngtoF7OEo9DzMpImNY91nfYcsx7XrFHOuyjVqOv/EOJlBWrsxXC5uU1kYqMbplMwVPbQ TgvzPwx7KThGkm1C0GtrTFRCLk2oxHCG9e/6FJ3H7RNf7agMKF5WMzRu/0PTRikrUKl2 FDZUwWoo74S14XdHFXHsbRYYn7O+5mRfHZQyjWKdp2NLVNAIV9baq3fA2Zm7e9/t5Id7 tr8A== 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=DE0idHVZO3bUMMZvhBUdALsDyijXCxwb5UAy2aWdzag=; b=a8YrSFKXZx/Yg0cu7op7xksysqC1cEO3s+8mDOP5ts5Zo+EahiyfgJ1zioad3DIsGr maRnjUJr2Bf+FhZ5MJqWMkdyPcsc4OJoQeXVhSON4nHACeWhh+k3zWGxX6w9bsnYdFeW yJGK7XvdUgDzSI1Q75j67uhXlTltsxwqFkDwzrIakB8wewhRu92ztqZXzBc7e5J6MHXr awPuFKQ0gefCDN6foyCyJc/4raowtqhHahmhr0ic1+LULTUTWCLFPXdpQPNrZ5ILJtFo BF/qo+Bs8fUeTTCfe+FakAqJ4l2SRxxS6O8hZbeEkg0ZyOjldqfuGMYNlyYuk/AH7WR8 7sXA== 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 a15-v6si25064827pll.412.2018.05.25.11.44.44; Fri, 25 May 2018 11:44:44 -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 S967816AbeEYSom (ORCPT + 30 others); Fri, 25 May 2018 14:44:42 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:34814 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S967598AbeEYSok (ORCPT ); Fri, 25 May 2018 14:44:40 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C0CAB65589842; Sat, 26 May 2018 02:44:36 +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:30 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 03/12] net: hns3: Add STRP_TAGP field support for hardware revision 0x21 Date: Fri, 25 May 2018 19:42:58 +0100 Message-ID: <20180525184307.36288-4-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 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 Hardware Revision(0x21) Buffer Descriptor adds a field STRP_TAGP for vlan stripped processed indication. STRP_TAGP field has 2 bits, bit 0 is stripped indication of the vlan tag in outer vlan tag field, bit 1 is stripped indication of the vlan tag in inner vlan tag field. For each bit, 0 indicates the tag is not stripped and 1 indicates the tag is stripped. This patch adds STRP_TAGP support for revision(0x21), and does not change the revision(0x20) action. Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 42 ++++++++++++++++++++++--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 ++ 2 files changed, 40 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index ae8d749..1bcb676 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2066,6 +2066,39 @@ static void hns3_rx_skb(struct hns3_enet_ring *ring, struct sk_buff *skb) napi_gro_receive(&ring->tqp_vector->napi, skb); } +static u16 hns3_parse_vlan_tag(struct hns3_enet_ring *ring, + struct hns3_desc *desc, u32 l234info) +{ + struct pci_dev *pdev = ring->tqp->handle->pdev; + u16 vlan_tag; + + if (pdev->revision == 0x20) { + 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); + + return vlan_tag; + } + +#define HNS3_STRP_OUTER_VLAN 0x1 +#define HNS3_STRP_INNER_VLAN 0x2 + + switch (hnae_get_field(l234info, HNS3_RXD_STRP_TAGP_M, + HNS3_RXD_STRP_TAGP_S)) { + case HNS3_STRP_OUTER_VLAN: + vlan_tag = le16_to_cpu(desc->rx.ot_vlan_tag); + break; + case HNS3_STRP_INNER_VLAN: + vlan_tag = le16_to_cpu(desc->rx.vlan_tag); + break; + default: + vlan_tag = 0; + break; + } + + return vlan_tag; +} + static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, struct sk_buff **out_skb, int *out_bnum) { @@ -2155,6 +2188,9 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, } *out_bnum = bnum; + + l234info = le32_to_cpu(desc->rx.l234_info); + /* 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. @@ -2162,17 +2198,13 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, 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); + vlan_tag = hns3_parse_vlan_tag(ring, desc, l234info); 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", ((u64 *)desc)[0], ((u64 *)desc)[1]); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 5b40f5a..38e91ca 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -104,6 +104,9 @@ enum hns3_nic_state { #define HNS3_RXD_L4ID_S 8 #define HNS3_RXD_L4ID_M (0xf << HNS3_RXD_L4ID_S) #define HNS3_RXD_FRAG_B 12 +#define HNS3_RXD_STRP_TAGP_S 13 +#define HNS3_RXD_STRP_TAGP_M (0x3 << HNS3_RXD_STRP_TAGP_S) + #define HNS3_RXD_L2E_B 16 #define HNS3_RXD_L3E_B 17 #define HNS3_RXD_L4E_B 18 From patchwork Fri May 25 18:42:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136987 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3945845lji; Fri, 25 May 2018 11:48:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqGBJ66wNVOxKp1YSUkxMfccdprUWWKFHeeUuR8kC0OE5yrZEe/NSHufcHq3DUTv8xAFf9A X-Received: by 2002:a17:902:8a87:: with SMTP id p7-v6mr3722596plo.278.1527274080339; Fri, 25 May 2018 11:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527274080; cv=none; d=google.com; s=arc-20160816; b=uiNdFcavZRNnSsPowV4OFiM7QNZKflc9DkkA90qJAkmuOWX7PHNya5tKUaQ6kpqdUw cITsu2AoUojRbJhd5qpk/edRwqqGfObI5YGrFk0CbtwfGcQ7M4NezL+K9GHJ6ZC0COQL Za1pOS4Y4yneZTmdhsbK/udyD5mfdNbREQuGI/0vfVKQINl6/2ahfUYwpl2grdCLQE+z dlNfhN3fUXduWbMqqY/BnBPbDQZmwHc1EkzbyYi3YLLbQq4hWZm29UGgbHvTQT5NG7AH 67/N2tzv2IrhraDz4+jeuO5qh433j1Nk9rk1bJmQVEKwL0etr4vK0J4rkx5JDox8i8Cy qCyQ== 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=uIzjB3iqGdDMgZbTzUqnCXHilHN2OyxbasM3dSHAdD0=; b=SIk5FUwqGLjYzX2t+usuNsLYi4GlDtOP4Q4neXRPwyo2TzIJTUpbmo0FWtSKO3EwC9 2vqV/M0SCdh7kRkN4JQ/0wwfreUP0e3Jtzt900PvQ7ILvrXKGc0CN0++KhyoQxHtiOsx xSoR8gSmZ6eG862JxTr6NCz+pmlK0o6QCkfSugHR5oqPooSa0oM+mABZue3zNS8JPEzL YnnaouPPR+AGYkxJSWYuG6IIpvhAdCC664H3h/QDvBV5GxX3X99oxloHji+epPLZJtjb oqyPhe7xpSZuJWeypTCay5QhxumSluAVDV7HQCFXnfrFsV4J+5xF6Sa3iTvRa4uHhrCP 8OTA== 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 e7-v6si10293792pgc.78.2018.05.25.11.48.00; Fri, 25 May 2018 11:48:00 -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 S967887AbeEYSos (ORCPT + 30 others); Fri, 25 May 2018 14:44:48 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60871 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S967830AbeEYSop (ORCPT ); Fri, 25 May 2018 14:44:45 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A1BED2941338; Sat, 26 May 2018 02:44:41 +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:33 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 04/12] net: hns3: Add support to enable TX/RX promisc mode for H/W rev(0x21) Date: Fri, 25 May 2018 19:42:59 +0100 Message-ID: <20180525184307.36288-5-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 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 HCLGE_PROMISC_TX_EN_B and HCLGE_PROMISC_RX_EN_B are not supported on pdev revision(0x20), new revision(0x21) supports them. Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 2 ++ drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index 3fa08f7..e9be6aa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -484,6 +484,8 @@ struct hclge_promisc_param { u8 enable; }; +#define HCLGE_PROMISC_TX_EN_B BIT(4) +#define HCLGE_PROMISC_RX_EN_B BIT(5) #define HCLGE_PROMISC_EN_B 1 #define HCLGE_PROMISC_EN_ALL 0x7 #define HCLGE_PROMISC_EN_UC 0x1 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index c0b8d5a..8ad8f62 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3586,7 +3586,14 @@ int hclge_cmd_set_promisc_mode(struct hclge_dev *hdev, req = (struct hclge_promisc_cfg_cmd *)desc.data; req->vf_id = param->vf_id; - req->flag = (param->enable << HCLGE_PROMISC_EN_B); + + /* HCLGE_PROMISC_TX_EN_B and HCLGE_PROMISC_RX_EN_B are not supported on + * pdev revision(0x20), new revision support them. The + * value of this two fields will not return error when driver + * send command to fireware in revision(0x20). + */ + req->flag = (param->enable << HCLGE_PROMISC_EN_B) | + HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B; ret = hclge_cmd_send(&hdev->hw, &desc, 1); if (ret) { From patchwork Fri May 25 18:43:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136976 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3943188lji; Fri, 25 May 2018 11:44:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq6TUmieaU2J+GzuRsRaPRG9ycqByvAg9kTICZdlbg+NDCNvuR4Du+HNk7hivOaTyvtJSpq X-Received: by 2002:a65:4188:: with SMTP id a8-v6mr2915534pgq.118.1527273892518; Fri, 25 May 2018 11:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273892; cv=none; d=google.com; s=arc-20160816; b=bOgOooM2zF7qlPqc3Kf7LLaTPN3nvtRLE/V7nd5iKLDLQyc+mEhyVTR9/a+kSpvPxg vSyPbBILwhRLvlUvAvoWyufyqkX+vbksCfS6DdWvzzBrNlXNfJ2IYHltnJ8qTkySi6aG DWQiAhxkOU0ENo9KApcrwlFqts5jnTcNpj6uMRzpUWaYxGxKPd/niG1oEEDUDlx4Gbk1 5YIZebAdaY9/TimzrHK3dfFzOhQSKAlJKD3Bq5wpGJ0SUQraRfddtc1OdRirJUQiJGHZ UQFoydZ9hg4SOy4SVT3dbYcytwG2O8wngI0b1T8mN3PWT2Real+BfUhVPRvdFgJDWRbF YFDQ== 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=RkIJFJfs4jZVYbV0LpA1As+SfboaDavS1JHha53TQqA=; b=nXML85uOuw7+VmS2gdVWYRr/8ydxEM03Tn+51BTd9r1Qjtdu6c9FPNMfU7xFTE+Q1/ q8Ua9coB2pBN7LtZjsqVr0ImRBW4StcqAOcyElaBDL8v9fXayJ8E0ERiFRJlmGY2XXii pQO89sW88Cw6A0/WXl0jIdsWPp5Djzj4TV52Q2U+5ek4z0r369AjULSTQRm/LFa1NXlj UnNVFEAdHaX3vzB4oiy8LbzyAjvxxChHcWSH1kNpTpeAcxYYblNYD+Tyr5PsWIsrilDf P/M54u3RtTnOVwLLb+jlTMOM/b0ggKSFkfl7WuWyIF7aNMpaeu0nqzrfOXyGbiMXLJFW GOXg== 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 a15-v6si25064827pll.412.2018.05.25.11.44.52; Fri, 25 May 2018 11:44:52 -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 S967946AbeEYSou (ORCPT + 30 others); Fri, 25 May 2018 14:44:50 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60872 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S967824AbeEYSop (ORCPT ); Fri, 25 May 2018 14:44:45 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9335AEF4F6BF5; Sat, 26 May 2018 02:44:41 +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:36 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH net-next 05/12] net: hns3: Fix for PF mailbox receving unknown message Date: Fri, 25 May 2018 19:43:00 +0100 Message-ID: <20180525184307.36288-6-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 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: Xi Wang Before the firmware updates the crq's tail pointer, if the PF driver reads the data in the crq, the data may be incomplete at this time, which will lead to the driver read an unknown message. This patch fixes it by checking if crq is not empty before reading the message. Fixes: c1a81619d73a ("net: hns3: Add mailbox interrupt handling to PF driver") Signed-off-by: Xi Wang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index b6ae26b..31f3d9a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -382,6 +382,13 @@ static void hclge_reset_vf(struct hclge_vport *vport, hclge_func_reset_cmd(hdev, mbx_req->mbx_src_vfid); } +static bool hclge_cmd_crq_empty(struct hclge_hw *hw) +{ + u32 tail = hclge_read_dev(hw, HCLGE_NIC_CRQ_TAIL_REG); + + return tail == hw->cmq.crq.next_to_use; +} + void hclge_mbx_handler(struct hclge_dev *hdev) { struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq; @@ -390,12 +397,23 @@ void hclge_mbx_handler(struct hclge_dev *hdev) struct hclge_desc *desc; int ret, flag; - flag = le16_to_cpu(crq->desc[crq->next_to_use].flag); /* handle all the mailbox requests in the queue */ - while (hnae_get_bit(flag, HCLGE_CMDQ_RX_OUTVLD_B)) { + while (!hclge_cmd_crq_empty(&hdev->hw)) { desc = &crq->desc[crq->next_to_use]; req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data; + flag = le16_to_cpu(crq->desc[crq->next_to_use].flag); + if (unlikely(!hnae_get_bit(flag, HCLGE_CMDQ_RX_OUTVLD_B))) { + dev_warn(&hdev->pdev->dev, + "dropped invalid mailbox message, code = %d\n", + req->msg[0]); + + /* dropping/not processing this invalid message */ + crq->desc[crq->next_to_use].flag = 0; + hclge_mbx_ring_ptr_move_crq(crq); + continue; + } + vport = &hdev->vport[req->mbx_src_vfid]; switch (req->msg[0]) { @@ -470,7 +488,6 @@ void hclge_mbx_handler(struct hclge_dev *hdev) } crq->desc[crq->next_to_use].flag = 0; hclge_mbx_ring_ptr_move_crq(crq); - flag = le16_to_cpu(crq->desc[crq->next_to_use].flag); } /* Write back CMDQ_RQ header pointer, M7 need this pointer */ From patchwork Fri May 25 18:43:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136980 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3943525lji; Fri, 25 May 2018 11:45:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrwnSJmGResBvQo9rpOqBoBmWNYqG12nUGNVgL93yDD96VMmWyWiJVDc5ZrNkxh0MEwOeok X-Received: by 2002:a17:902:a5:: with SMTP id a34-v6mr3772889pla.58.1527273914276; Fri, 25 May 2018 11:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273914; cv=none; d=google.com; s=arc-20160816; b=L4DmjjCGS68yxDRDfo/wq4RsZiDLPSwyNhwy8fV8gb8/yjr/11U2wxEyigF9A/Px7a 37fQt2FYP66MbHSEIH3wE9yXvTJH1otMJbtprv5Bvw7jYkPz0Ln5kVhog1U6VhHLRjlk 6AuaY7lOZrY40ZXLxRBSWY0kV1yKcC9ptPXOS4L7+loBWtCEu7pBtAp7NH0FbR0k/BcW Fmq58HAKSXKxSJXrvBvgKjG4GIm2Av97XDs5UlLc7l/J8uKY9822WrsCtK8mPA+htDvh siuAUzBw4Icn6gDWJj8slH3DAp6VsmlYagiWohXA9HZ6FYJItTd18EIz+6LkMW4wYmv+ U7bg== 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=MMRSrcdqgRlBEMsvcXa07GNnnNX+ATy5ET5pMJjmnug=; b=MudMci66qUaQhig57hNPOI9Q5FJ6gV2ZAqGo7shog3vAtThJKxDxdYqJqMPa60mtmV WRoyhxk3xqzJlp+3oQIRF4Rdn708U0aBIPCAnqy9kt9WCtc0UOE0T1xQ/aQke/oxr+fz BJP21S0wh8j1h50MzG18olQEhTMJ3YGGe/a0SqD6uonKHo1SRK0q7cMAuV4quoDl1TNu /Ytvai6JJO2fliDFxspWTjsghPoC3jXc1TQRKScIt9rJG/Rg+S3Skmj46aznD7m9lNco Xt0EncqjqtViBcc+gptcYOrLClfMhw46RIMDoFkER8SQHSsNg9SdwjTZAP+lXf06+ZRM HYcA== 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 p2-v6si2101279pls.551.2018.05.25.11.45.13; Fri, 25 May 2018 11:45:14 -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 S968111AbeEYSpJ (ORCPT + 30 others); Fri, 25 May 2018 14:45:09 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8142 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S968030AbeEYSo7 (ORCPT ); Fri, 25 May 2018 14:44:59 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 09F319878A204; Sat, 26 May 2018 02:44:46 +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:39 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 06/12] net: hns3: Fixes the state to indicate client-type initialization Date: Fri, 25 May 2018 19:43:01 +0100 Message-ID: <20180525184307.36288-7-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 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 HNAE3 module supports kernel nic driver, user nic driver and roce driver, and there are 3 client types. Driver uses one bit(HNAE3_CLIENT_INITED_B) to indicate the client initialization state, it will cause confusion for 3 client types. This patch fixes it by use 3 bits to indicate the initialization state. Fixes: 38caee9d3ee8 ("net: hns3: Add support of the HNAE3 framework") Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 49 +++++++++++++++++++++++++++-- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 4 ++- 2 files changed, 49 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 63d7dbf..9d79dad 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -36,6 +36,49 @@ static bool hnae3_client_match(enum hnae3_client_type client_type, return false; } +static void hnae3_set_client_init_flag(struct hnae3_client *client, + struct hnae3_ae_dev *ae_dev, int inited) +{ + switch (client->type) { + case HNAE3_CLIENT_KNIC: + hnae_set_bit(ae_dev->flag, HNAE3_KNIC_CLIENT_INITED_B, inited); + break; + case HNAE3_CLIENT_UNIC: + hnae_set_bit(ae_dev->flag, HNAE3_UNIC_CLIENT_INITED_B, inited); + break; + case HNAE3_CLIENT_ROCE: + hnae_set_bit(ae_dev->flag, HNAE3_ROCE_CLIENT_INITED_B, inited); + break; + default: + break; + } +} + +static int hnae3_get_client_init_flag(struct hnae3_client *client, + struct hnae3_ae_dev *ae_dev) +{ + int inited = 0; + + switch (client->type) { + case HNAE3_CLIENT_KNIC: + inited = hnae_get_bit(ae_dev->flag, + HNAE3_KNIC_CLIENT_INITED_B); + break; + case HNAE3_CLIENT_UNIC: + inited = hnae_get_bit(ae_dev->flag, + HNAE3_UNIC_CLIENT_INITED_B); + break; + case HNAE3_CLIENT_ROCE: + inited = hnae_get_bit(ae_dev->flag, + HNAE3_ROCE_CLIENT_INITED_B); + break; + default: + break; + } + + return inited; +} + static int hnae3_match_n_instantiate(struct hnae3_client *client, struct hnae3_ae_dev *ae_dev, bool is_reg) { @@ -56,14 +99,14 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client, return ret; } - hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 1); + hnae3_set_client_init_flag(client, ae_dev, 1); return 0; } - if (hnae_get_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B)) { + if (hnae3_get_client_init_flag(client, ae_dev)) { ae_dev->ops->uninit_client_instance(client, ae_dev); - hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 0); + hnae3_set_client_init_flag(client, ae_dev, 0); } return 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 45c571e..f250c59 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -54,7 +54,9 @@ #define HNAE3_DEV_INITED_B 0x0 #define HNAE3_DEV_SUPPORT_ROCE_B 0x1 #define HNAE3_DEV_SUPPORT_DCB_B 0x2 -#define HNAE3_CLIENT_INITED_B 0x3 +#define HNAE3_KNIC_CLIENT_INITED_B 0x3 +#define HNAE3_UNIC_CLIENT_INITED_B 0x4 +#define HNAE3_ROCE_CLIENT_INITED_B 0x5 #define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\ BIT(HNAE3_DEV_SUPPORT_ROCE_B)) From patchwork Fri May 25 18:43:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136986 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3945128lji; Fri, 25 May 2018 11:47:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrvQDMAZTVC1LQEVQWzuMvE+USjAgTMvcm0J7hPGeeFFIok9WF88kj2OUwqP6sFHSE08eAa X-Received: by 2002:a65:6101:: with SMTP id z1-v6mr2919979pgu.23.1527274022943; Fri, 25 May 2018 11:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527274022; cv=none; d=google.com; s=arc-20160816; b=niDk7CGR31CIOuOm/HSs18X/z7OXwP70CoE3q1OIYy1qvlfkZBJSWAuwicZDnLjHTD /sfbN3kmL28RcBUVJRgW2nzCF+eSI+lBZQ1jvK57QCgL3DV0b7WQjWMEySglFtP4Uc+U ZhwEm+JEoj/rfb/oKuufYuUWgcC0wFIDEmqTpjtu3bMsI0peUOC65j1Pq44S4Mz483Cp nRrVMT9jMqxgrEnh5LQ91vuDu2eA/3LN/nCEGMGeH4mcjAAlkW/xh/vzUecmk6kCV0LD 6g7QW0Z0aDG5zYtrpq9JsUBI5H3Qj3Z8jKbRJgc7tsryXMpuhEXVtl33El7t5g2oPor8 6HKg== 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=FEs8LJ/YQSJ4qexuWpSO9vtywiuVuk+EtqtIbtA/AKs=; b=1AorymJ2KL5f8dFPH1Q2Cuntgg0FKNxOafylpLuZKAYdZ+FwQIlLMcJdBwq6un/Cyo bh0ZdhjSnANmdA/gLyAasrFt5CDnqMYYNqZhM+fajEi+/siqDI9G6ZGWy6cXgvUIka5I cRI7LO5q/+OH6QE6OVFBozelae2vK1dWnMYQG74LINPXiaTDsx4r4uLOtJyKB54geg9d Ox6fFL4seD528pz+LMvRTs7F93WaIh5xFZsmv9vht9WritH34SoTlgsS1H3oyeBot06u 36omAd6jPcKVfxJ8SQzrru+GeJX3CVkemh0/wz1a5xsrf6s26exI0F+cnDR8NFxuo1qb OeRw== 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 p16-v6si19149091pgv.255.2018.05.25.11.47.02; Fri, 25 May 2018 11:47:02 -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 S968046AbeEYSo6 (ORCPT + 30 others); Fri, 25 May 2018 14:44:58 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60913 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S967992AbeEYSoy (ORCPT ); Fri, 25 May 2018 14:44:54 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C146E6DC2FB76; Sat, 26 May 2018 02:44:51 +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:42 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 07/12] net: hns3: Fixes the init of the VALID BD info in the descriptor Date: Fri, 25 May 2018 19:43:02 +0100 Message-ID: <20180525184307.36288-8-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 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: Fuyun Liang RX Buffer Descriptor contains a VALID bit which indicates if the BD is valid and has some data. This field is set by HNS3 hardware to intimate the driver of some valid data present in the BD. nd should be reset by the driver when BD is being used again. In the existing code this bit was not being (re-)initialized properly and hence was causing problems. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 1bcb676..d1ef104 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1819,6 +1819,7 @@ static void hns3_replace_buffer(struct hns3_enet_ring *ring, int i, hns3_unmap_buffer(ring, &ring->desc_cb[i]); ring->desc_cb[i] = *res_cb; ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma); + ring->desc[i].rx.bd_base_info = 0; } static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i) @@ -1826,6 +1827,7 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i) ring->desc_cb[i].reuse_flag = 0; ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma + ring->desc_cb[i].page_offset); + ring->desc[i].rx.bd_base_info = 0; } static void hns3_nic_reclaim_one_desc(struct hns3_enet_ring *ring, int *bytes, From patchwork Fri May 25 18:43:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136979 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3943341lji; Fri, 25 May 2018 11:45:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrtwKfzQrHfZkrGt9IJqyTKJ9xImXfFlwWAQLN5ODTi5zdd+192KhWrPENzfhtFqbKUWjCb X-Received: by 2002:a17:902:7283:: with SMTP id d3-v6mr3822853pll.192.1527273902551; Fri, 25 May 2018 11:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273902; cv=none; d=google.com; s=arc-20160816; b=ovIIXd+6azHQdhgpp3W1B7dVYYBLj9Cgxop7iQRyvjRKHffIvDRY8SfNbjmeEV9u97 jhut2Ns+Xyis/EafaZUyAfYxuEnOzv+ty74EMdHsdHMxEE0+7uVE4/Ra2TlPZI3XSHnk 2kIVvCcXhDrg8UAPKEYcbhq/UWM9vn32mjq6mjwwHbHHqZcyM8Q2DXB6lnNXed+73lHl jbmKlotFsf6LQmvaZb/IVcDCqEmAZmrp3RipygW+uDvyPFJyzO2ZW8iTCAgLL94QocK0 Q7EoAx8NOveRk/h540gz57b3ZsoUmjgxQ9csoE7AtSd8OAdfsb5rt8fsJ1gUeORIJp6i PzTw== 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=uJyrVHDa5n8Mwj01A9YPk9lzu1gcbBG36wdBdYLjeb0=; b=GAvMGculL5RocJwUajk1B8OeIWNtqdyuQLwRA5Z9x047F3hgM6p+o7o22lKqCbBxyK QkmEcEHafc61TWfwBXA9Pw5mMrOawNFaBDe+udrd6wRgFgGUf3fo6eVuR+SaW+gtwLNq wHmvVyQZk5crQVqZ3wfhHIO85IZ+xvTMXVWgRCXRYFV335MCN+gLOc6X+yH8p5mkAHlj 0uvGfwFmUz/Z8H/yXuFrpe/FvajJEJCu3bMP3A8MapOISlTq7liNffiLNGd9JJtP6z3X 1Z34AjblIQJNJdmst1xtuvR9VLjrnbATeHLY/P8V4o+nYRkdFalTWdmFioHto4SI+cAR E9yQ== 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 5-v6si24142171pfi.285.2018.05.25.11.45.02; Fri, 25 May 2018 11:45:02 -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 S968077AbeEYSpA (ORCPT + 30 others); Fri, 25 May 2018 14:45:00 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60905 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S967835AbeEYSoy (ORCPT ); Fri, 25 May 2018 14:44:54 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B3AC85737ED4B; Sat, 26 May 2018 02:44:51 +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:45 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 08/12] net: hns3: Removes unnecessary check when clearing TX/RX rings Date: Fri, 25 May 2018 19:43:03 +0100 Message-ID: <20180525184307.36288-9-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 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: Fuyun Liang Our code will ensure that hns3_clear_tx_ring is not used to cleared RX rings and hns3_clear_rx_ring is not used to cleared TX rings. So the ring type check is unnecessary. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index d1ef104..4c13c52 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3217,9 +3217,6 @@ static void hns3_recover_hw_addr(struct net_device *ndev) static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) { - if (!HNAE3_IS_TX_RING(ring)) - return; - while (ring->next_to_clean != ring->next_to_use) { hns3_free_buffer_detach(ring, ring->next_to_clean); ring_ptr_move_fw(ring, next_to_clean); @@ -3228,9 +3225,6 @@ static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) static void hns3_clear_rx_ring(struct hns3_enet_ring *ring) { - if (HNAE3_IS_TX_RING(ring)) - return; - while (ring->next_to_use != ring->next_to_clean) { /* When a buffer is not reused, it's memory has been * freed in hns3_handle_rx_bd or will be freed by From patchwork Fri May 25 18:43:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136983 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3944034lji; Fri, 25 May 2018 11:45:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpMd1NlYrt1PuICuSHfsKgUnwhvb5t2ZSBXkaWcpvZE63D/oU08BO77fZNB++JRoJ2lVodj X-Received: by 2002:a65:48c9:: with SMTP id o9-v6mr2974284pgs.106.1527273949940; Fri, 25 May 2018 11:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273949; cv=none; d=google.com; s=arc-20160816; b=veJRUNJzubog68HHgLDPNTCKdpf9CcmREpbiQyLpT3ciTo8XdrBAN+RwMt7KP71uwR XCP28YH+nqWhUk1THVNDWeLKCkDAfJWJsZ6OYZTX7r2O1wOdbZAX1JD1Bo7wsenNIciL RHMMWiwfJXTKEmGeGKEk/HLZfRZUovHEUhhAOyZKpQkJyotP1q08cG7kIX9d/AM0rxQw xN987/pU6gvXCg6lMhLh6FUw8nZkes6Su2rCUHXGI4hQm8lj41Dg/S52dEB+vBX3seZc u1U6joi0szCXp7E0JDFlR0CVkgN3sLuGOS0mU12E/GSGlxI+20Nr8jSOf5q2B2+swyMf rwNg== 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=9ms9+6djoLifB+m5bDgbcD2qq1WNc6heLvYY4/ZwN2w=; b=FjtE1rs4WZeGm+O30WzGLfYcq0MxGSa4w3KN2PHXMM2+gscg7umPPCVThKsL5gbV4Y IyleOPYtV+cWfTr1oLzzXSzV+oz2pUML8SjHhTnPpiuy9YDep4IbTL6Fakx19qxYrFgR sosM1uqTk6dgW4NFf5FW/yeDeigcAHmngE9MQA14el/CILJLmsZiV8Hgks9U7WWZVP+J wFLh5Ha8hchINLJc7jeycS2ZpyB8xkjJGHyTgsm8bud0rFfeLcSmNYvn6Ut5P04OVSy4 iyk9SQEDYsVkxQRXX6Vj2FmPjEbN/fbCQk4iQlcw53Zolt8c2hvN6jg7NScuzjl2DV7v 8H7A== 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 e2-v6si24891311pfm.220.2018.05.25.11.45.49; Fri, 25 May 2018 11:45:49 -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 S968183AbeEYSpQ (ORCPT + 30 others); Fri, 25 May 2018 14:45:16 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7745 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S968088AbeEYSpJ (ORCPT ); Fri, 25 May 2018 14:45:09 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 18851C3A836FB; Sat, 26 May 2018 02:44:56 +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:48 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 09/12] net: hns3: Clear TX/RX rings when stopping port & un-initializing client Date: Fri, 25 May 2018 19:43:04 +0100 Message-ID: <20180525184307.36288-10-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 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: Fuyun Liang When we down the port, some packets are left in TX/RX buffer. When we up the port again, these old packets are forwarded to protocol stack or are sent to internet. It will make some problem. TX/RX buffer should be cleared when stopping port. This patch adds some function to ensure the buffer is clean when port is started. We should clear the rings when clients are being un-initialized as well. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 115 +++++++++++++++++++-- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 4 + 3 files changed, 110 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 4c13c52..0529012 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -25,6 +25,9 @@ #include "hnae3.h" #include "hns3_enet.h" +static void hns3_clear_all_ring(struct hnae3_handle *h); +static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h); + static const char hns3_driver_name[] = "hns3"; const char hns3_driver_version[] = VERMAGIC_STRING; static const char hns3_driver_string[] = @@ -273,6 +276,10 @@ static int hns3_nic_net_up(struct net_device *netdev) int i, j; int ret; + ret = hns3_nic_reset_all_ring(h); + if (ret) + return ret; + /* get irq resource for all vectors */ ret = hns3_nic_init_irq(priv); if (ret) { @@ -333,17 +340,19 @@ static void hns3_nic_net_down(struct net_device *netdev) if (test_and_set_bit(HNS3_NIC_STATE_DOWN, &priv->state)) return; + /* disable vectors */ + for (i = 0; i < priv->vector_num; i++) + hns3_vector_disable(&priv->tqp_vector[i]); + /* stop ae_dev */ ops = priv->ae_handle->ae_algo->ops; if (ops->stop) ops->stop(priv->ae_handle); - /* disable vectors */ - for (i = 0; i < priv->vector_num; i++) - hns3_vector_disable(&priv->tqp_vector[i]); - /* free irq resources */ hns3_nic_uninit_irq(priv); + + hns3_clear_all_ring(priv->ae_handle); } static int hns3_nic_net_stop(struct net_device *netdev) @@ -2939,8 +2948,6 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv) goto out_when_alloc_ring_memory; } - hns3_init_ring_hw(priv->ring_data[i].ring); - u64_stats_init(&priv->ring_data[i].ring->syncp); } @@ -3102,6 +3109,8 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset) if (netdev->reg_state != NETREG_UNINITIALIZED) unregister_netdev(netdev); + hns3_force_clear_all_rx_ring(handle); + ret = hns3_nic_uninit_vector_data(priv); if (ret) netdev_err(netdev, "uninit vector error\n"); @@ -3218,12 +3227,46 @@ static void hns3_recover_hw_addr(struct net_device *ndev) static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) { while (ring->next_to_clean != ring->next_to_use) { + ring->desc[ring->next_to_clean].tx.bdtp_fe_sc_vld_ra_ri = 0; hns3_free_buffer_detach(ring, ring->next_to_clean); ring_ptr_move_fw(ring, next_to_clean); } } -static void hns3_clear_rx_ring(struct hns3_enet_ring *ring) +static int hns3_clear_rx_ring(struct hns3_enet_ring *ring) +{ + struct hns3_desc_cb res_cbs; + int ret; + + while (ring->next_to_use != ring->next_to_clean) { + /* When a buffer is not reused, it's memory has been + * freed in hns3_handle_rx_bd or will be freed by + * stack, so we need to replace the buffer here. + */ + if (!ring->desc_cb[ring->next_to_use].reuse_flag) { + ret = hns3_reserve_buffer_map(ring, &res_cbs); + if (ret) { + u64_stats_update_begin(&ring->syncp); + ring->stats.sw_err_cnt++; + u64_stats_update_end(&ring->syncp); + /* if alloc new buffer fail, exit directly + * and reclear in up flow. + */ + netdev_warn(ring->tqp->handle->kinfo.netdev, + "reserve buffer map failed, ret = %d\n", + ret); + return ret; + } + hns3_replace_buffer(ring, ring->next_to_use, + &res_cbs); + } + ring_ptr_move_fw(ring, next_to_use); + } + + return 0; +} + +static void hns3_force_clear_rx_ring(struct hns3_enet_ring *ring) { while (ring->next_to_use != ring->next_to_clean) { /* When a buffer is not reused, it's memory has been @@ -3240,6 +3283,19 @@ static void hns3_clear_rx_ring(struct hns3_enet_ring *ring) } } +static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h) +{ + struct net_device *ndev = h->kinfo.netdev; + struct hns3_nic_priv *priv = netdev_priv(ndev); + struct hns3_enet_ring *ring; + u32 i; + + for (i = 0; i < h->kinfo.num_tqps; i++) { + ring = priv->ring_data[i + h->kinfo.num_tqps].ring; + hns3_force_clear_rx_ring(ring); + } +} + static void hns3_clear_all_ring(struct hnae3_handle *h) { struct net_device *ndev = h->kinfo.netdev; @@ -3257,10 +3313,51 @@ static void hns3_clear_all_ring(struct hnae3_handle *h) netdev_tx_reset_queue(dev_queue); ring = priv->ring_data[i + h->kinfo.num_tqps].ring; + /* Continue to clear other rings even if clearing some + * rings failed. + */ hns3_clear_rx_ring(ring); } } +int hns3_nic_reset_all_ring(struct hnae3_handle *h) +{ + struct net_device *ndev = h->kinfo.netdev; + struct hns3_nic_priv *priv = netdev_priv(ndev); + struct hns3_enet_ring *rx_ring; + int i, j; + int ret; + + for (i = 0; i < h->kinfo.num_tqps; i++) { + h->ae_algo->ops->reset_queue(h, i); + hns3_init_ring_hw(priv->ring_data[i].ring); + + /* We need to clear tx ring here because self test will + * use the ring and will not run down before up + */ + hns3_clear_tx_ring(priv->ring_data[i].ring); + priv->ring_data[i].ring->next_to_clean = 0; + priv->ring_data[i].ring->next_to_use = 0; + + rx_ring = priv->ring_data[i + h->kinfo.num_tqps].ring; + hns3_init_ring_hw(rx_ring); + ret = hns3_clear_rx_ring(rx_ring); + if (ret) + return ret; + + /* We can not know the hardware head and tail when this + * function is called in reset flow, so we reuse all desc. + */ + for (j = 0; j < rx_ring->desc_num; j++) + hns3_reuse_buffer(rx_ring, j); + + rx_ring->next_to_clean = 0; + rx_ring->next_to_use = 0; + } + + return 0; +} + static int hns3_reset_notify_down_enet(struct hnae3_handle *handle) { struct hnae3_knic_private_info *kinfo = &handle->kinfo; @@ -3330,7 +3427,7 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle) struct hns3_nic_priv *priv = netdev_priv(netdev); int ret; - hns3_clear_all_ring(handle); + hns3_force_clear_all_rx_ring(handle); ret = hns3_nic_uninit_vector_data(priv); if (ret) { @@ -3466,8 +3563,6 @@ int hns3_set_channels(struct net_device *netdev, if (if_running) hns3_nic_net_stop(netdev); - hns3_clear_all_ring(h); - ret = hns3_nic_uninit_vector_data(priv); if (ret) { dev_err(&netdev->dev, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 38e91ca..3b083d5a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -625,6 +625,7 @@ int hns3_set_channels(struct net_device *netdev, bool hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget); int hns3_init_all_ring(struct hns3_nic_priv *priv); int hns3_uninit_all_ring(struct hns3_nic_priv *priv); +int hns3_nic_reset_all_ring(struct hnae3_handle *h); netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev); int hns3_clean_rx_ring( struct hns3_enet_ring *ring, int budget, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index c16bb6c..8f8cc24 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -108,6 +108,10 @@ static int hns3_lp_up(struct net_device *ndev, enum hnae3_loop loop_mode) if (!h->ae_algo->ops->start) return -EOPNOTSUPP; + ret = hns3_nic_reset_all_ring(h); + if (ret) + return ret; + ret = h->ae_algo->ops->start(h); if (ret) { netdev_err(ndev, From patchwork Fri May 25 18:43:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136985 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3944539lji; Fri, 25 May 2018 11:46:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqGb2WbNzlgtnwZGuqtOrl83TEjmZA3KQfsyoU/3tzCiCbj08o4iC7lNwcYOyma2Z1JarCE X-Received: by 2002:a62:7682:: with SMTP id r124-v6mr3725473pfc.80.1527273981545; Fri, 25 May 2018 11:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273981; cv=none; d=google.com; s=arc-20160816; b=YRE4p55EXg6VJnRkRpekghOHyAQm/h1xbS3usvnzva36oNbTZEX/WZydPIkElXQ5WT JjA5oldTmlWhe72SChEkXSr1Th3AdcrwbQk1yOUxfz0lsxVFGsAq6n0XQi/yXbN2SIof 5+xJvuQZqk4pyQf95M/o636s4b++Ecg+nqe8cp+XqUl0bqtQebh4eyrG1/XbHQLJt6Oj qWrSN4MGwHALw/b8cPsqr1mfZ3RTbZRDpMidErEfjmUKjbviHH1WpkWFmZU2w5HGMjc1 D8hHUWYpaUr0JmcSbCIM1zrmCiL8BzThfmmSWyE4D4k8/dGqcSpZclRvlOQCaSM17Ei4 dbXw== 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=OF0nneHNW07PT2OzKBiC5+nvCL4S78BpjssT6wvRWh0=; b=bOyIB+FLtBG7JcTUZl94seJX7gFsVbAyX8HIGPzPNMDs3JtN2JfOow/DrCR6vKOREp VhK5FQcg3vNtqNn7Q9enRSrWsrFfHDvPti7SZJUC5sFteoCzZno6UiOupGI+luBTXgj9 4E69lR5QeRPEGGTdgmcN7U4Z3Qsdh+D0a2gwTjlWq/BkRwYRiVB2jBpiQDeDuatPx4I5 BbxCEvCMhQRnr382HcDB7yPWxS1OcCesZpjqVRO41sjxN3UpEuX9SKYILiW+5Cef+fDW 0TFRLrx/ivk3aV7bHM532vZVZ4NamWq/h3EZ+eIUqh5AoS6En7oDayB4GBZANv4LDYpi WOAg== 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 p16-v6si19149091pgv.255.2018.05.25.11.46.21; Fri, 25 May 2018 11:46:21 -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 S968145AbeEYSpN (ORCPT + 30 others); Fri, 25 May 2018 14:45:13 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7746 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S968084AbeEYSpJ (ORCPT ); Fri, 25 May 2018 14:45:09 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 284BBFB8A0945; Sat, 26 May 2018 02:44:56 +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:51 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH net-next 10/12] net: hns3: Remove unused led control code Date: Fri, 25 May 2018 19:43:05 +0100 Message-ID: <20180525184307.36288-11-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 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: Jian Shen In the previous implementation of led control for fibre port , parses the port speed configuration, checks the link status and traffic status per second, and updates the blink status of link led, traffic led and speed led. Now, the firmware takes responsibility to handle the led, the dirver just needs to deal with locate command. So the codes for link led, traffic led and speed led are useless now. This patch removes these redundant codes. Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 1 - .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 109 --------------------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 - 3 files changed, 112 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index e9be6aa..de2f6f1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -115,7 +115,6 @@ enum hclge_opcode_type { HCLGE_OPC_QUERY_LINK_STATUS = 0x0307, HCLGE_OPC_CONFIG_MAX_FRM_SIZE = 0x0308, HCLGE_OPC_CONFIG_SPEED_DUP = 0x0309, - HCLGE_OPC_STATS_MAC_TRAFFIC = 0x0314, /* MACSEC command */ /* PFC/Pause CMD*/ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 8ad8f62..20988aa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -39,7 +39,6 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev, static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu); static int hclge_init_vlan_config(struct hclge_dev *hdev); static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev); -static int hclge_update_led_status(struct hclge_dev *hdev); static struct hnae3_ae_algo ae_algo; @@ -504,38 +503,6 @@ static int hclge_32_bit_update_stats(struct hclge_dev *hdev) return 0; } -static int hclge_mac_get_traffic_stats(struct hclge_dev *hdev) -{ - struct hclge_mac_stats *mac_stats = &hdev->hw_stats.mac_stats; - struct hclge_desc desc; - __le64 *desc_data; - int ret; - - /* for fiber port, need to query the total rx/tx packets statstics, - * used for data transferring checking. - */ - if (hdev->hw.mac.media_type != HNAE3_MEDIA_TYPE_FIBER) - return 0; - - if (test_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state)) - return 0; - - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_STATS_MAC_TRAFFIC, true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, - "Get MAC total pkt stats fail, ret = %d\n", ret); - - return ret; - } - - desc_data = (__le64 *)(&desc.data[0]); - mac_stats->mac_tx_total_pkt_num += le64_to_cpu(*desc_data++); - mac_stats->mac_rx_total_pkt_num += le64_to_cpu(*desc_data); - - return 0; -} - static int hclge_mac_update_stats(struct hclge_dev *hdev) { #define HCLGE_MAC_CMD_NUM 21 @@ -2916,20 +2883,13 @@ static void hclge_service_task(struct work_struct *work) struct hclge_dev *hdev = container_of(work, struct hclge_dev, service_task); - /* The total rx/tx packets statstics are wanted to be updated - * per second. Both hclge_update_stats_for_all() and - * hclge_mac_get_traffic_stats() can do it. - */ if (hdev->hw_stats.stats_timer >= HCLGE_STATS_TIMER_INTERVAL) { hclge_update_stats_for_all(hdev); hdev->hw_stats.stats_timer = 0; - } else { - hclge_mac_get_traffic_stats(hdev); } hclge_update_speed_duplex(hdev); hclge_update_link_status(hdev); - hclge_update_led_status(hdev); hclge_service_complete(hdev); } @@ -6100,75 +6060,6 @@ static int hclge_set_led_id(struct hnae3_handle *handle, return ret; } -enum hclge_led_port_speed { - HCLGE_SPEED_LED_FOR_1G, - HCLGE_SPEED_LED_FOR_10G, - HCLGE_SPEED_LED_FOR_25G, - HCLGE_SPEED_LED_FOR_40G, - HCLGE_SPEED_LED_FOR_50G, - HCLGE_SPEED_LED_FOR_100G, -}; - -static u8 hclge_led_get_speed_status(u32 speed) -{ - u8 speed_led; - - switch (speed) { - case HCLGE_MAC_SPEED_1G: - speed_led = HCLGE_SPEED_LED_FOR_1G; - break; - case HCLGE_MAC_SPEED_10G: - speed_led = HCLGE_SPEED_LED_FOR_10G; - break; - case HCLGE_MAC_SPEED_25G: - speed_led = HCLGE_SPEED_LED_FOR_25G; - break; - case HCLGE_MAC_SPEED_40G: - speed_led = HCLGE_SPEED_LED_FOR_40G; - break; - case HCLGE_MAC_SPEED_50G: - speed_led = HCLGE_SPEED_LED_FOR_50G; - break; - case HCLGE_MAC_SPEED_100G: - speed_led = HCLGE_SPEED_LED_FOR_100G; - break; - default: - speed_led = HCLGE_LED_NO_CHANGE; - } - - return speed_led; -} - -static int hclge_update_led_status(struct hclge_dev *hdev) -{ - u8 port_speed_status, link_status, activity_status; - u64 rx_pkts, tx_pkts; - - if (hdev->hw.mac.media_type != HNAE3_MEDIA_TYPE_FIBER) - return 0; - - port_speed_status = hclge_led_get_speed_status(hdev->hw.mac.speed); - - rx_pkts = hdev->hw_stats.mac_stats.mac_rx_total_pkt_num; - tx_pkts = hdev->hw_stats.mac_stats.mac_tx_total_pkt_num; - if (rx_pkts != hdev->rx_pkts_for_led || - tx_pkts != hdev->tx_pkts_for_led) - activity_status = HCLGE_LED_ON; - else - activity_status = HCLGE_LED_OFF; - hdev->rx_pkts_for_led = rx_pkts; - hdev->tx_pkts_for_led = tx_pkts; - - if (hdev->hw.mac.link) - link_status = HCLGE_LED_ON; - else - link_status = HCLGE_LED_OFF; - - return hclge_set_led_status_sfp(hdev, port_speed_status, - activity_status, link_status, - HCLGE_LED_NO_CHANGE); -} - static void hclge_get_link_mode(struct hnae3_handle *handle, unsigned long *supported, unsigned long *advertising) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 677f1e4..7fcabde 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -563,8 +563,6 @@ struct hclge_dev { struct hclge_vlan_type_cfg vlan_type_cfg; - u64 rx_pkts_for_led; - u64 tx_pkts_for_led; unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)]; }; From patchwork Fri May 25 18:43:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136984 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3944136lji; Fri, 25 May 2018 11:45:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr4YKO+xeEB4irljTBz5rMVj5olj0gELw/7JxrIFSFPBx9+Kz+pDvi75qCFWM+iXGNmOK5q X-Received: by 2002:a62:b2d0:: with SMTP id z77-v6mr3715576pfl.122.1527273956893; Fri, 25 May 2018 11:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273956; cv=none; d=google.com; s=arc-20160816; b=l+K6rpSikGmpnHQvrB/WpZdSI28AUdI907O6yPZ2Shbl6SgQDWqQWzkqliSlttv4d9 0ZOIPJJuAMDP9SaJdfvdC4XePN3+3Nct5JM5pRWxZguJsBTEOWD0oaA9rtOwGzVPKT/2 LOKj47S/VrmULqeuBO05sgyxb06rVUa+ax53DESxDII5Lhhm4r61zCZnGoG1amqiN0S8 pjVvXje94raydiJwYIknC/ZbL+O1t4tdjDQAHS1/nB5kXMIQ7w1ebUrJ4jlFiRC0ibaY rwTf5PRLVK0z9hfkPLoHkAgtOa6QPJKhwm3FtGhrArFFemf0t2oLKebLFEFfgd4GbsFu /f3A== 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=b6/z9JDaMTA5FmoPdZflqq13174DJuCQAikK0+wrOxY=; b=WDxGYoUibq4R31mgJH6AYZuM8rec6ViW5zBinU3ZIYRXlVM3wjVZ4CsAEIdKBFmrxW tL0JzfXi83DimscrhNT1ZXDhZpdtNp9ccjZFRWkD4/o4dTCa9hW0bR7HDa+P7u2Dtl6K 6UTWa3fMPhG4DkXrQlbLTO/dPvnl2b+9ThYvzY3/KRQh99rSj4Ph+93tQuWQpKn0UVC/ 9j9opTT+vQCQ2P9zRn+BhUa4WeyoSrzcNYdJ9nS1lGSXazsmcm3GPZwVRJLqBYGSggU3 bmhc7mvCKsS72LJ+48kv60APsBfVJPl/clfPZEOSUKYLhQ3z7/ydwgGgZLlG2LrUinZ0 r8cg== 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 b37-v6si24273645plb.377.2018.05.25.11.45.56; Fri, 25 May 2018 11:45:56 -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 S968271AbeEYSpy (ORCPT + 30 others); Fri, 25 May 2018 14:45:54 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8143 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S968165AbeEYSpO (ORCPT ); Fri, 25 May 2018 14:45:14 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 482CD9167E35B; Sat, 26 May 2018 02:45:01 +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:53 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH net-next 11/12] net: hns3: Adds support for led locate command for copper port Date: Fri, 25 May 2018 19:43:06 +0100 Message-ID: <20180525184307.36288-12-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 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: Jian Shen Firmware now supports control of all leds. Existing HNS3 driver code only supported led locate command over SFP Fibre ports. But now it is also supported over copper port. This patch removes existing not needed code for the led locate command and updates the led control command between driver and firmware. Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 12 ++------ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 35 +++------------------- 2 files changed, 6 insertions(+), 41 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index de2f6f1..d9aaa76 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -817,21 +817,13 @@ struct hclge_reset_cmd { #define HCLGE_NIC_CMQ_DESC_NUM 1024 #define HCLGE_NIC_CMQ_DESC_NUM_S 3 -#define HCLGE_LED_PORT_SPEED_STATE_S 0 -#define HCLGE_LED_PORT_SPEED_STATE_M GENMASK(5, 0) -#define HCLGE_LED_ACTIVITY_STATE_S 0 -#define HCLGE_LED_ACTIVITY_STATE_M GENMASK(1, 0) -#define HCLGE_LED_LINK_STATE_S 0 -#define HCLGE_LED_LINK_STATE_M GENMASK(1, 0) #define HCLGE_LED_LOCATE_STATE_S 0 #define HCLGE_LED_LOCATE_STATE_M GENMASK(1, 0) struct hclge_set_led_state_cmd { - u8 port_speed_led_config; - u8 link_led_config; - u8 activity_led_config; + u8 rsv1[3]; u8 locate_led_config; - u8 rsv[20]; + u8 rsv2[20]; }; int hclge_cmd_init(struct hclge_dev *hdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 20988aa..6916685 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5991,9 +5991,7 @@ static void hclge_get_regs(struct hnae3_handle *handle, u32 *version, "Get 64 bit register failed, ret = %d.\n", ret); } -static int hclge_set_led_status_sfp(struct hclge_dev *hdev, u8 speed_led_status, - u8 act_led_status, u8 link_led_status, - u8 locate_led_status) +static int hclge_set_led_status(struct hclge_dev *hdev, u8 locate_led_status) { struct hclge_set_led_state_cmd *req; struct hclge_desc desc; @@ -6002,12 +6000,6 @@ static int hclge_set_led_status_sfp(struct hclge_dev *hdev, u8 speed_led_status, hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_LED_STATUS_CFG, false); req = (struct hclge_set_led_state_cmd *)desc.data; - hnae_set_field(req->port_speed_led_config, HCLGE_LED_PORT_SPEED_STATE_M, - HCLGE_LED_PORT_SPEED_STATE_S, speed_led_status); - hnae_set_field(req->link_led_config, HCLGE_LED_ACTIVITY_STATE_M, - HCLGE_LED_ACTIVITY_STATE_S, act_led_status); - hnae_set_field(req->activity_led_config, HCLGE_LED_LINK_STATE_M, - HCLGE_LED_LINK_STATE_S, link_led_status); hnae_set_field(req->locate_led_config, HCLGE_LED_LOCATE_STATE_M, HCLGE_LED_LOCATE_STATE_S, locate_led_status); @@ -6028,36 +6020,17 @@ enum hclge_led_status { static int hclge_set_led_id(struct hnae3_handle *handle, enum ethtool_phys_id_state status) { -#define BLINK_FREQUENCY 2 struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; - struct phy_device *phydev = hdev->hw.mac.phydev; - int ret = 0; - - if (phydev || hdev->hw.mac.media_type != HNAE3_MEDIA_TYPE_FIBER) - return -EOPNOTSUPP; switch (status) { case ETHTOOL_ID_ACTIVE: - ret = hclge_set_led_status_sfp(hdev, - HCLGE_LED_NO_CHANGE, - HCLGE_LED_NO_CHANGE, - HCLGE_LED_NO_CHANGE, - HCLGE_LED_ON); - break; + return hclge_set_led_status(hdev, HCLGE_LED_ON); case ETHTOOL_ID_INACTIVE: - ret = hclge_set_led_status_sfp(hdev, - HCLGE_LED_NO_CHANGE, - HCLGE_LED_NO_CHANGE, - HCLGE_LED_NO_CHANGE, - HCLGE_LED_OFF); - break; + return hclge_set_led_status(hdev, HCLGE_LED_OFF); default: - ret = -EINVAL; - break; + return -EINVAL; } - - return ret; } static void hclge_get_link_mode(struct hnae3_handle *handle, From patchwork Fri May 25 18:43:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 136981 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3943611lji; Fri, 25 May 2018 11:45:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZptphk1vWH00yzaAChVj+WRjKz3knhtUERK0CjyKG87biSUcZoVdOT2e3GcI07KKls8wCvN X-Received: by 2002:a62:d11d:: with SMTP id z29-v6mr3650752pfg.246.1527273919518; Fri, 25 May 2018 11:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527273919; cv=none; d=google.com; s=arc-20160816; b=hraMtYfH8K56OWYXMY/MHb4JiWg+yk+5r4+CanLNiaNnnMOp1rywuPuUgab5gwPgZ0 fK04iI7Zt7SHrYRy5ByZPNFEcnM5HsJ8SBaUXfSXSMmsJCGjcpLCiWKv5nMWwsSQb/S2 JWS6olxd7O9zaI9pGBJLX2eeDCDBPgMvMVxs6Atq1y6Cua+XAIr5uU7tQF0ILC2sDGMk A6E4ecMjuWL8uDDiNKR34TekpMtec0M9LCdooLS14ZGN+uozbtvKbVmPnVf7/cOyo9K6 wxxRSfCUXec6fUHm5OGYfpa0FOV+/3aYocA78bH1e47S1jb9Mn11DcV7577vTGAlcsqh i9ww== 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=aUmy2vCjOCsf+MDjP4N+6cii8gAxxzYxq3cuzJwO8Tw=; b=aehjMTvSYbsdc3YLNw+tXI7PBpYw1kz160+HMeRT2sOlV5g7wOq927hhVxwerFKp2p xqTbQ8UvhRttPsBCFaC/Xx1P00uyXAXXowEKBb4v89h0/gfUe6sbWfZLtc7v7UzjWYfv +prkH4LVwU8Hq9vJMJmWbqJO4cKKs/anXcRNAVHZjtLFNNvxiWjp9fj/2OcZUPt88DYp 4z3ppmuSdnDDfmsVistN7jQ9OfRPRn6azwNQVIaZ0a/WoatlWFZpMHaqS6OCIIsSnrDM hrER+SAEMnVdnVlzJUZYKfUJfs0ya9IfyX3FQGjvZbtxn2GaqVNGluI/L3MY897XrvYL aFzg== 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 p2-v6si2101279pls.551.2018.05.25.11.45.19; Fri, 25 May 2018 11:45:19 -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 S968211AbeEYSpR (ORCPT + 30 others); Fri, 25 May 2018 14:45:17 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8144 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S968166AbeEYSpO (ORCPT ); Fri, 25 May 2018 14:45:14 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 567E0D52F7DD1; Sat, 26 May 2018 02:45:01 +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:57 +0800 From: Salil Mehta To: CC: , , , , , , , Lijun Ou , Zhou Wang Subject: [PATCH net-next 12/12] net: hns3: Fixes initalization of RoCE handle and makes it conditional Date: Fri, 25 May 2018 19:43:07 +0100 Message-ID: <20180525184307.36288-13-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 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: Lijun Ou When register a RoCE client with hnae3vf device, it needs to judge the device whether support RoCE vf function. Otherwise, it will lead to calltrace when RoCE is not support vf function and remove roce device. The calltrace as follows: [ 93.156614] Unable to handle kernel NULL pointer dereference at virtual address 00000015 [ 93.278784] Call trace: [ 93.278788] hnae3_match_n_instantiate+0x24/0xd8 [hnae3] [ 93.278790] hnae3_register_client+0xcc/0x150 [hnae3] [ 93.278801] hns_roce_hw_v2_init+0x18/0x1000 [hns_roce_hw_v2] [ 93.278805] do_one_initcall+0x58/0x160 [ 93.278807] do_init_module+0x64/0x1d8 [ 93.278809] load_module+0x135c/0x15c8 [ 93.278811] SyS_finit_module+0x100/0x118 [ 93.278816] __sys_trace_return+0x0/0x4 [ 93.278827] Code: aa0003f5 12001c56 aa1e03e0 d503201f (b9402660) Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support") Reported-by: Xinwei Kong Reported-by: Zhou Wang Signed-off-by: Lijun Ou Signed-off-by: Zhou Wang Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 2b0e329..266cdcb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1500,10 +1500,12 @@ static int hclgevf_init_instance(struct hclgevf_dev *hdev, return ret; break; case HNAE3_CLIENT_ROCE: - hdev->roce_client = client; - hdev->roce.client = client; + if (hnae3_dev_roce_supported(hdev)) { + hdev->roce_client = client; + hdev->roce.client = client; + } - if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) { + if (hdev->roce_client && hdev->nic_client) { ret = hclgevf_init_roce_base_info(hdev); if (ret) return ret;