Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3798235imm; Mon, 1 Oct 2018 04:49:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV61AO5O4gTizggyiR58hQax5Z/+CL6rrYH8wG8+F8XB9DhgdPQlB62mDlpHL4iTR0iJ0wp/6 X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr11360293pln.60.1538394563278; Mon, 01 Oct 2018 04:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538394563; cv=none; d=google.com; s=arc-20160816; b=bGA/PKN8sfSpLwJgbJohYpugr1I8vA0TGotuuqybKCTF7wmOsG3Im3SRpT+FDSCBz2 115CssYFauM3XNXpQbjCU8T14pikAb1Kbw6QJDXTK3bl8LmHFeDSdQGc9mWjdNEIwMjM hWcySe+WUBJrqWXEBXsZ3XphchgyEVnDkFGNQhzcxLPjzzbzuvYTJpiBm7taDjtG2vbJ l59RDodqicEs9CvYAr38eegwmV11pPUgu0hZcjphKoarwuYFEqhFHfzeZBU3GoeIpgO7 44UVIimAZ4iG/rTc0Tl6SANmaSkGd1aKgURZQ4S+JH+1yGL9OJ+fAG3Yet0uajrzP5vz Fc0Q== 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; bh=32f9Oae/bHp7mgwozFZ9lzIpMirGj00m9EqLcsfXHfw=; b=Vz9ezEG/EBxJpHYaMDvCUhcca4LuPAFpuN1Bq1JEv0bdPHmpl/wu2+SnrjEHar7p1T iMxp605OKahe3phDXenusQ099QZV/5aGEjqm0EwZBqCH3Ql2dhgVf8lof4n1NO1dfg7X BuRzRLUDSebYu1TrKXR/jPb69sTEaVQA4XJtGXVyi3SchEg+WvaQ7T4/RPhICwA7OnEo bqn0S6cndroJ933jAshlAdYEAg8M2x9qz/wqS+IdIFi4KGsZH4jfLHx0BTHcjuIcLjqJ Jw+MV+M7r5KNxcTb0cXpZHtkcw/tfkiQB4mPD7dNqitSIsrJvmjQUSeIFxcqUM9oBoYj GiuQ== 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 r3-v6si11234925pga.321.2018.10.01.04.49.08; Mon, 01 Oct 2018 04:49:23 -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 S1729446AbeJAS0I (ORCPT + 99 others); Mon, 1 Oct 2018 14:26:08 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13592 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729250AbeJAS0I (ORCPT ); Mon, 1 Oct 2018 14:26:08 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 17AA42E10E613; Mon, 1 Oct 2018 19:48:37 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.399.0; Mon, 1 Oct 2018 19:48:29 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH net-next 7/7] net: hns3: Add support for enable/disable flow director Date: Mon, 1 Oct 2018 12:46:47 +0100 Message-ID: <20181001114647.15504-8-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181001114647.15504-1-salil.mehta@huawei.com> References: <20181001114647.15504-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.202.226.54] 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 This patch adds switch for flow director with ethtool command Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 15 ++++++++++++++- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 13 +++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index e185d04..591ee2e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -430,6 +430,7 @@ struct hnae3_ae_ops { int (*get_fd_all_rules)(struct hnae3_handle *handle, struct ethtool_rxnfc *cmd, u32 *rule_locs); int (*restore_fd_rules)(struct hnae3_handle *handle); + void (*enable_fd)(struct hnae3_handle *handle, bool enable); }; struct hnae3_dcb_ops { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 96f07ca..c269256 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1285,6 +1285,13 @@ static int hns3_nic_set_features(struct net_device *netdev, return ret; } + if ((changed & NETIF_F_NTUPLE) && h->ae_algo->ops->enable_fd) { + if (features & NETIF_F_NTUPLE) + h->ae_algo->ops->enable_fd(h, true); + else + h->ae_algo->ops->enable_fd(h, false); + } + netdev->features = features; return 0; } @@ -1770,8 +1777,14 @@ static void hns3_set_default_feature(struct net_device *netdev) NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_SCTP_CRC; - if (pdev->revision != 0x20) + if (pdev->revision >= 0x21) { netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; + + if (!(h->flags & HNAE3_SUPPORT_VF)) { + netdev->hw_features |= NETIF_F_NTUPLE; + netdev->features |= NETIF_F_NTUPLE; + } + } } static int hns3_alloc_buffer(struct hns3_enet_ring *ring, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 00ec4db..0ce7ccb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -4597,6 +4597,18 @@ static int hclge_get_all_rules(struct hnae3_handle *handle, return 0; } +static void hclge_enable_fd(struct hnae3_handle *handle, bool enable) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_dev *hdev = vport->back; + + hdev->fd_cfg.fd_en = enable; + if (!enable) + hclge_del_all_fd_entries(handle, false); + else + hclge_restore_fd_entries(handle); +} + static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable) { struct hclge_desc desc; @@ -7341,6 +7353,7 @@ static const struct hnae3_ae_ops hclge_ops = { .get_fd_rule_info = hclge_get_fd_rule_info, .get_fd_all_rules = hclge_get_all_rules, .restore_fd_rules = hclge_restore_fd_entries, + .enable_fd = hclge_enable_fd, }; static struct hnae3_ae_algo ae_algo = { -- 2.7.4