linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Li <lipeng321@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linuxarm@huawei.com>, <salil.mehta@huawei.com>,
	<lipeng321@huawei.com>
Subject: [PATCH net-next 01/20] net: hns3: Add ethtool interface for vlan filter
Date: Fri, 5 Jan 2018 18:18:05 +0800	[thread overview]
Message-ID: <1515147504-86802-2-git-send-email-lipeng321@huawei.com> (raw)
In-Reply-To: <1515147504-86802-1-git-send-email-lipeng321@huawei.com>

From: Jian Shen <shenjian15@huawei.com>

This patch adds vlan filter enable switch to
support ethtool -K ethX rx-vlan-filter on/off.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h             |  3 +++
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c         | 11 ++++++++++-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 ++++++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 82e9a80..adec88d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -274,6 +274,8 @@ struct hnae3_ae_dev {
  *   Get firmware version
  * get_mdix_mode()
  *   Get media typr of phy
+ * enable_vlan_filter()
+ *   Enable vlan filter
  * set_vlan_filter()
  *   Set vlan filter config of Ports
  * set_vf_vlan_filter()
@@ -382,6 +384,7 @@ struct hnae3_ae_ops {
 	void (*get_mdix_mode)(struct hnae3_handle *handle,
 			      u8 *tp_mdix_ctrl, u8 *tp_mdix);
 
+	void (*enable_vlan_filter)(struct hnae3_handle *handle, bool enable);
 	int (*set_vlan_filter)(struct hnae3_handle *handle, __be16 proto,
 			       u16 vlan_id, bool is_kill);
 	int (*set_vf_vlan_filter)(struct hnae3_handle *handle, int vfid,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 320ae88..8e37689 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1101,6 +1101,11 @@ static int hns3_nic_set_features(struct net_device *netdev,
 		priv->ops.maybe_stop_tx = hns3_nic_maybe_stop_tx;
 	}
 
+	if (features & NETIF_F_HW_VLAN_CTAG_FILTER)
+		h->ae_algo->ops->enable_vlan_filter(h, true);
+	else
+		h->ae_algo->ops->enable_vlan_filter(h, false);
+
 	changed = netdev->features ^ features;
 	if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
 		if (features & NETIF_F_HW_VLAN_CTAG_RX)
@@ -1549,6 +1554,8 @@ static void hns3_remove(struct pci_dev *pdev)
 /* set default feature to hns3 */
 static void hns3_set_default_feature(struct net_device *netdev)
 {
+	struct hnae3_handle *h = hns3_get_handle(netdev);
+
 	netdev->priv_flags |= IFF_UNICAST_FLT;
 
 	netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
@@ -1577,12 +1584,14 @@ static void hns3_set_default_feature(struct net_device *netdev)
 		NETIF_F_GSO_UDP_TUNNEL_CSUM;
 
 	netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-		NETIF_F_HW_VLAN_CTAG_FILTER |
 		NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
 		NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
 		NETIF_F_GRO | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_GRE |
 		NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL |
 		NETIF_F_GSO_UDP_TUNNEL_CSUM;
+
+	if (!(h->flags & HNAE3_SUPPORT_VF))
+		netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 }
 
 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 0874acf..93fe870 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4241,6 +4241,17 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
 	return 0;
 }
 
+#define HCLGE_FILTER_TYPE_VF		0
+#define HCLGE_FILTER_TYPE_PORT		1
+
+static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable)
+{
+	struct hclge_vport *vport = hclge_get_vport(handle);
+	struct hclge_dev *hdev = vport->back;
+
+	hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, enable);
+}
+
 int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid,
 			     bool is_kill, u16 vlan, u8 qos, __be16 proto)
 {
@@ -4469,8 +4480,6 @@ static int hclge_set_vlan_protocol_type(struct hclge_dev *hdev)
 
 static int hclge_init_vlan_config(struct hclge_dev *hdev)
 {
-#define HCLGE_FILTER_TYPE_VF		0
-#define HCLGE_FILTER_TYPE_PORT		1
 #define HCLGE_DEF_VLAN_TYPE		0x8100
 
 	struct hnae3_handle *handle;
@@ -5482,6 +5491,7 @@ static int hclge_set_channels(struct hnae3_handle *handle, u32 new_tqps_num)
 	.get_sset_count = hclge_get_sset_count,
 	.get_fw_version = hclge_get_fw_version,
 	.get_mdix_mode = hclge_get_mdix_mode,
+	.enable_vlan_filter = hclge_enable_vlan_filter,
 	.set_vlan_filter = hclge_set_port_vlan_filter,
 	.set_vf_vlan_filter = hclge_set_vf_vlan_filter,
 	.enable_hw_strip_rxvtag = hclge_en_hw_strip_rxvtag,
-- 
1.9.1

  reply	other threads:[~2018-01-05 10:01 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
2018-01-05 10:18 ` Peng Li [this message]
2018-01-05 10:18 ` [PATCH net-next 02/20] net: hns3: Disable VFs change rxvlan offload status Peng Li
2018-01-05 10:18 ` [PATCH net-next 03/20] net: hns3: Unify the strings display of packet statistics Peng Li
2018-01-05 10:18 ` [PATCH net-next 04/20] net: hns3: Fix spelling errors Peng Li
2018-01-05 10:18 ` [PATCH net-next 05/20] net: hns3: Remove repeat statistic of rx_errors Peng Li
2018-01-05 10:18 ` [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics Peng Li
2018-01-05 14:54   ` Andrew Lunn
2018-01-06  6:23     ` lipeng (Y)
2018-01-06 15:49       ` Andrew Lunn
2018-01-05 10:18 ` [PATCH net-next 07/20] net: hns3: Mask the packet statistics query when NIC is down Peng Li
2018-01-05 10:18 ` [PATCH net-next 08/20] net: hns3: Fix an error of total drop packet statistics Peng Li
2018-01-05 10:18 ` [PATCH net-next 09/20] net: hns3: Fix a loop index error of tqp statistics query Peng Li
2018-01-05 10:18 ` [PATCH net-next 10/20] net: hns3: Fix an error macro definition of HNS3_TQP_STAT Peng Li
2018-01-05 10:18 ` [PATCH net-next 11/20] net: hns3: Remove a useless member of struct hns3_stats Peng Li
2018-01-05 10:18 ` [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev Peng Li
2018-01-08 20:04   ` Jakub Kicinski
2018-01-09  1:39     ` David Miller
2018-01-09  1:46       ` Jakub Kicinski
2018-01-09  1:50         ` Jakub Kicinski
2018-01-09  1:54           ` David Miller
2018-01-09  2:48             ` lipeng (Y)
2018-01-09  3:06               ` David Miller
2018-01-09  3:27                 ` lipeng (Y)
2018-01-05 10:18 ` [PATCH net-next 13/20] net: hns3: Fix a response data read error of tqp statistics query Peng Li
2018-01-05 10:18 ` [PATCH net-next 14/20] net: hns3: fix for updating fc_mode_last_time Peng Li
2018-01-05 10:18 ` [PATCH net-next 15/20] net: hns3: fix for setting MTU Peng Li
2018-01-05 10:18 ` [PATCH net-next 16/20] net: hns3: fix for changing MTU Peng Li
2018-01-05 10:18 ` [PATCH net-next 17/20] net: hns3: add MTU initialization for hardware Peng Li
2018-01-05 10:18 ` [PATCH net-next 18/20] net: hns3: fix for not setting pause parameters Peng Li
2018-01-05 10:18 ` [PATCH net-next 19/20] net: hns3: remove redundant semicolon Peng Li
2018-01-05 10:18 ` [PATCH net-next 20/20] net: hns3: Add more packet size statisctics Peng Li
2018-01-08 19:08 ` [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515147504-86802-2-git-send-email-lipeng321@huawei.com \
    --to=lipeng321@huawei.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=salil.mehta@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).