From patchwork Mon Oct 1 11:46:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147888 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3803911lji; Mon, 1 Oct 2018 04:48:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV631Pu6Rmm766FKQ+wOdNmeEGWXz6qFiARPiRiGEZbaUAsXrf6+D/LE8miYKmFhz+JkHzGBX X-Received: by 2002:a63:5c63:: with SMTP id n35-v6mr5282699pgm.402.1538394526110; Mon, 01 Oct 2018 04:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538394526; cv=none; d=google.com; s=arc-20160816; b=BQOj3ArHd/71LOvy6bm7G+rYmvH/hYCCb77BlEGzRV25+7E2Z2titfqOsQbwIRSPM2 1CrR1sjM8xI/XVDu8CTMtZtgX/GnEC8YgWsaBatJecxHbcJf6g0SZPmBrYkwbe/NrBJf dO5rNyn/Q9Z3gqi+DTNtep1Yd0+6plQkn1tyT8OUWIXxiGCEcAYQZpZg2K91N0q7V1sH Ds/D5xJtxjkKj67UyS2zhEeRnVzNBh+EZo/8e4sHQw+9w1YsBIwJ19Dtu9M+qksZ4FuO 0RFfL9wq7TIF6VqV9hx9DfgsdL1ZmvLkz/x4xRJWfxzZv7p1dQ24sKfsV9uhctcv96J+ MmnQ== 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=sVfBlIZ5LZbdR+a7EXYLtYkwJlnc0P80BmBoZ9S2+uwHqejofouw0yBN6u9PDJu8rx HpR1+AHfAUf9bczXRQrIc0pO2ldMW4eUj/Edr5c2TpLOIKpCLFk5geEIyCCgCvennwmT lKdg/3HUj178THgKh9S+Laf2LQv5iGZHUBMnP8BWEpg7SjdlkFxqa0WCxKiQxereQQob qVOn7t9Szc0AQZ8rTbW4+Gbva1uzSns62HKRgwcwmVJUMmjFx+fsVXsa6leJVb0hlX+c bhgZn7a+Yc69lG1DojzhfzrlaXPL6iPtxsvPDrB6iAQtZ+RB+/w2Nr185eAnlYFRm3Ki 166A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 q4-v6si12263596pgj.417.2018.10.01.04.48.45; Mon, 01 Oct 2018 04:48:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729457AbeJAS0I (ORCPT + 10 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 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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(-) -- 2.7.4 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 = {