linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: hinic: Add support for configuration of rx-vlan-filter by ethtool
@ 2022-10-31  7:47 Cai Huoqing
  2022-11-02  4:40 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Cai Huoqing @ 2022-10-31  7:47 UTC (permalink / raw)
  To: kuba
  Cc: Cai Huoqing, David S. Miller, Eric Dumazet, Paolo Abeni, Qiao Ma,
	Zhengchao Shao, Christophe JAILLET, Gustavo A. R. Silva, netdev,
	linux-kernel

When ethtool config rx-vlan-filter: 'ethtool -K ethx rx-vlan-filter on/off'
to turn on/off the vlan filter, the driver will send control command to firmware,
then set to hardware in this patch.

Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev>
---
 .../net/ethernet/huawei/hinic/hinic_main.c    | 10 ++++++
 .../net/ethernet/huawei/hinic/hinic_port.c    | 33 +++++++++++++++++++
 .../net/ethernet/huawei/hinic/hinic_port.h    | 12 +++++++
 3 files changed, 55 insertions(+)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
index 9d4d795e1081..28729b49af95 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
@@ -1092,6 +1092,16 @@ static int set_features(struct hinic_dev *nic_dev,
 		}
 	}
 
+	if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
+		ret = hinic_set_vlan_fliter(nic_dev,
+					    !!(features &
+					       NETIF_F_HW_VLAN_CTAG_FILTER));
+		if (ret) {
+			err = ret;
+			failed_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
+		}
+	}
+
 	if (err) {
 		nic_dev->netdev->features = features ^ failed_features;
 		return -EIO;
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c
index 0a39c3dffa9a..9406237c461e 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_port.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c
@@ -447,6 +447,39 @@ int hinic_set_rx_vlan_offload(struct hinic_dev *nic_dev, u8 en)
 	return 0;
 }
 
+int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en)
+{
+	struct hinic_hwdev *hwdev = nic_dev->hwdev;
+	struct hinic_hwif *hwif = hwdev->hwif;
+	struct pci_dev *pdev = hwif->pdev;
+	struct hinic_vlan_filter vlan_filter;
+	u16 out_size = sizeof(vlan_filter);
+	int err;
+
+	if (!hwdev)
+		return -EINVAL;
+
+	vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
+	vlan_filter.enable = en;
+
+	err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_VLAN_FILTER,
+				 &vlan_filter, sizeof(vlan_filter),
+				 &vlan_filter, &out_size);
+	if (vlan_filter.status == HINIC_MGMT_CMD_UNSUPPORTED) {
+		err = HINIC_MGMT_CMD_UNSUPPORTED;
+	} else if ((err == HINIC_MBOX_VF_CMD_ERROR) &&
+			   HINIC_IS_VF(hwif)) {
+		err = HINIC_MGMT_CMD_UNSUPPORTED;
+	} else if (err || !out_size || vlan_filter.status) {
+		dev_err(&pdev->dev,
+			"Failed to set vlan fliter, err: %d, status: 0x%x, out size: 0x%x\n",
+			err, vlan_filter.status, out_size);
+		err = -EINVAL;
+	}
+
+	return err;
+}
+
 int hinic_set_max_qnum(struct hinic_dev *nic_dev, u8 num_rqs)
 {
 	struct hinic_hwdev *hwdev = nic_dev->hwdev;
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.h b/drivers/net/ethernet/huawei/hinic/hinic_port.h
index c9ae3d4dc547..c8694ac7c702 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_port.h
+++ b/drivers/net/ethernet/huawei/hinic/hinic_port.h
@@ -351,6 +351,16 @@ struct hinic_vlan_cfg {
 	u8      rsvd1[5];
 };
 
+struct hinic_vlan_filter {
+	u8	status;
+	u8	version;
+	u8	rsvd0[6];
+
+	u16	func_idx;
+	u8	rsvd1[2];
+	u32	enable;
+};
+
 struct hinic_rss_template_mgmt {
 	u8	status;
 	u8	version;
@@ -831,6 +841,8 @@ int hinic_get_vport_stats(struct hinic_dev *nic_dev,
 
 int hinic_set_rx_vlan_offload(struct hinic_dev *nic_dev, u8 en);
 
+int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en);
+
 int hinic_get_mgmt_version(struct hinic_dev *nic_dev, u8 *mgmt_ver);
 
 int hinic_set_link_settings(struct hinic_hwdev *hwdev,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: hinic: Add support for configuration of rx-vlan-filter by ethtool
  2022-10-31  7:47 [PATCH net-next] net: hinic: Add support for configuration of rx-vlan-filter by ethtool Cai Huoqing
@ 2022-11-02  4:40 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2022-11-02  4:40 UTC (permalink / raw)
  To: Cai Huoqing
  Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Qiao Ma,
	Zhengchao Shao, Christophe JAILLET, Gustavo A. R. Silva, netdev,
	linux-kernel

On Mon, 31 Oct 2022 15:47:03 +0800 Cai Huoqing wrote:
> When ethtool config rx-vlan-filter: 'ethtool -K ethx rx-vlan-filter on/off'
> to turn on/off the vlan filter, the driver will send control command to firmware,
> then set to hardware in this patch.

This patch depends on a definition added in your other set.
Please repost once that gets merged, otherwise it doesn't build.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-02  4:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31  7:47 [PATCH net-next] net: hinic: Add support for configuration of rx-vlan-filter by ethtool Cai Huoqing
2022-11-02  4:40 ` Jakub Kicinski

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).