netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: hns3: adds two VLAN feature
@ 2020-05-20  1:20 Huazhong Tan
  2020-05-20  1:20 ` [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
  2020-05-20  1:20 ` [PATCH net-next 2/2] net: hns3: add support for 'QOS' in port based VLAN configuration Huazhong Tan
  0 siblings, 2 replies; 7+ messages in thread
From: Huazhong Tan @ 2020-05-20  1:20 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm, kuba,
	Huazhong Tan

This patchset adds two new VLAN feature.

[patch 1] adds a new dynamic VLAN mode.
[patch 2] adds support for 'QOS' field to PVID.

GuoJia Liao (2):
  net: hns3: adds support for dynamic VLAN mode
  net: hns3: add support for 'QOS' in port based VLAN configuration

 drivers/net/ethernet/hisilicon/hns3/hnae3.h        |   5 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c    |   3 +
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |   6 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |   2 +
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 151 ++++++++++++++++-----
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h    |  25 +++-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c |  10 +-
 7 files changed, 155 insertions(+), 47 deletions(-)

-- 
2.7.4


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

* [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode
  2020-05-20  1:20 [PATCH net-next 0/2] net: hns3: adds two VLAN feature Huazhong Tan
@ 2020-05-20  1:20 ` Huazhong Tan
  2020-05-20 21:06   ` Jakub Kicinski
  2020-05-20  1:20 ` [PATCH net-next 2/2] net: hns3: add support for 'QOS' in port based VLAN configuration Huazhong Tan
  1 sibling, 1 reply; 7+ messages in thread
From: Huazhong Tan @ 2020-05-20  1:20 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm, kuba,
	GuoJia Liao, Huazhong Tan

From: GuoJia Liao <liaoguojia@huawei.com>

There is a scenario which needs vNICs enable the VLAN filter
in access port, while disable the VLAN filter in trunk port.
Access port and trunk port can switch according to the user's
configuration.

This patch adds support for the dynamic VLAN mode. then the
HNS3 driver can support two VLAN modes: default VLAN mode and
dynamic VLAN mode. User can switch the mode through the
configuration file.

In default VLAN mode, port based VLAN filter and VF VLAN
filter should always be enabled.

In dynamic VLAN mode, port based VLAN filter is disabled, and
VF VLAN filter is disabled defaultly, and should be enabled
when there is a non-zero VLAN ID. In addition, VF VLAN filter
is enabled if PVID is enabled for vNIC.

When enable promisc, VLAN filter should be disabled. When disable
promisc, VLAN filter's status depends on the value of
'vport->vf_vlan_en', which is used to record the VF VLAN filter
status.

In default VLAN mode, 'vport->vf_vlan_en' always be 'true', so
VF VLAN filter will set to be enabled after disabling promisc.

In dynamic VLAN mode, 'vport->vf_vlan_en' lies on whether there
is a non-zero VLAN ID.

Signed-off-by: GuoJia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h        |   5 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c    |   3 +
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |   6 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |   2 +
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 121 +++++++++++++++++----
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h    |  21 ++++
 6 files changed, 132 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 7506cab..e5973d6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -643,9 +643,12 @@ struct hnae3_unic_private_info {
 #define HNAE3_BPE		BIT(2)	/* broadcast promisc enable */
 #define HNAE3_OVERFLOW_UPE	BIT(3)	/* unicast mac vlan overflow */
 #define HNAE3_OVERFLOW_MPE	BIT(4)	/* multicast mac vlan overflow */
-#define HNAE3_VLAN_FLTR		BIT(5)	/* enable vlan filter */
+#define HNAE3_VLAN_FLTR		BIT(5)	/* enable vlan filter by promisc mode */
+#define HNAE3_VF_VLAN_EN	BIT(6)	/* enable vf vlan filter by vlan used */
 #define HNAE3_UPE		(HNAE3_USER_UPE | HNAE3_OVERFLOW_UPE)
 #define HNAE3_MPE		(HNAE3_USER_MPE | HNAE3_OVERFLOW_MPE)
+#define HNAE3_OVERFLOW_UMPE	(HNAE3_OVERFLOW_UPE | HNAE3_OVERFLOW_MPE)
+#define HNAE3_VLAN_FLTR_EN	(HNAE3_VLAN_FLTR | HNAE3_VF_VLAN_EN)
 
 struct hnae3_handle {
 	struct hnae3_client *client;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 9fe40c7..80b07ee 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -584,6 +584,7 @@ static int hns3_nic_mc_unsync(struct net_device *netdev,
 
 static u8 hns3_get_netdev_flags(struct net_device *netdev)
 {
+	struct hnae3_handle *h = hns3_get_handle(netdev);
 	u8 flags = 0;
 
 	if (netdev->flags & IFF_PROMISC) {
@@ -594,6 +595,8 @@ static u8 hns3_get_netdev_flags(struct net_device *netdev)
 			flags |= HNAE3_USER_MPE;
 	}
 
+	flags |= (h->netdev_flags & HNAE3_VF_VLAN_EN);
+
 	return flags;
 }
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 6b1545f..10dfdfd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -106,7 +106,8 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en)
 	} else {
 		/* recover promisc mode before loopback test */
 		hns3_request_update_promisc_mode(h);
-		vlan_filter_enable = ndev->flags & IFF_PROMISC ? false : true;
+		vlan_filter_enable = (h->netdev_flags & HNAE3_VLAN_FLTR_EN) ?
+				      false : true;
 		hns3_enable_vlan_filter(ndev, vlan_filter_enable);
 	}
 
@@ -386,7 +387,8 @@ static void hns3_self_test(struct net_device *ndev,
 
 #if IS_ENABLED(CONFIG_VLAN_8021Q)
 	if (dis_vlan_filter)
-		h->ae_algo->ops->enable_vlan_filter(h, true);
+		h->ae_algo->ops->enable_vlan_filter(h,
+					h->netdev_flags & HNAE3_VLAN_FLTR_EN);
 #endif
 
 	if (if_running)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index e3bab8f..85aa879 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -491,6 +491,8 @@ struct hclge_pf_res_cmd {
 #define HCLGE_CFG_RSS_SIZE_M	GENMASK(31, 24)
 #define HCLGE_CFG_SPEED_ABILITY_S	0
 #define HCLGE_CFG_SPEED_ABILITY_M	GENMASK(7, 0)
+#define HCLGE_CFG_VLAN_MODE_S		8
+#define HCLGE_CFG_VLAN_MODE_M		GENMASK(9, 8)
 #define HCLGE_CFG_UMV_TBL_SPACE_S	16
 #define HCLGE_CFG_UMV_TBL_SPACE_M	GENMASK(31, 16)
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index b796d3f..bdacda4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -71,6 +71,7 @@ static int hclge_set_default_loopback(struct hclge_dev *hdev);
 static void hclge_sync_mac_table(struct hclge_dev *hdev);
 static void hclge_restore_hw_table(struct hclge_dev *hdev);
 static void hclge_sync_promisc_mode(struct hclge_dev *hdev);
+static int hclge_vf_vlan_filter_switch(struct hclge_vport *vport);
 
 static struct hnae3_ae_algo ae_algo;
 
@@ -1281,6 +1282,11 @@ static void hclge_parse_cfg(struct hclge_cfg *cfg, struct hclge_desc *desc)
 	cfg->speed_ability = hnae3_get_field(__le32_to_cpu(req->param[1]),
 					     HCLGE_CFG_SPEED_ABILITY_M,
 					     HCLGE_CFG_SPEED_ABILITY_S);
+
+	cfg->vlan_mode_sel = hnae3_get_field(__le32_to_cpu(req->param[1]),
+					     HCLGE_CFG_VLAN_MODE_M,
+					     HCLGE_CFG_VLAN_MODE_S);
+
 	cfg->umv_space = hnae3_get_field(__le32_to_cpu(req->param[1]),
 					 HCLGE_CFG_UMV_TBL_SPACE_M,
 					 HCLGE_CFG_UMV_TBL_SPACE_S);
@@ -1379,6 +1385,7 @@ static int hclge_configure(struct hclge_dev *hdev)
 	hdev->tc_max = cfg.tc_num;
 	hdev->tm_info.hw_pfc_map = 0;
 	hdev->wanted_umv_size = cfg.umv_space;
+	hdev->vlan_mode = cfg.vlan_mode_sel;
 
 	if (hnae3_dev_fd_supported(hdev)) {
 		hdev->fd_en = true;
@@ -8233,6 +8240,11 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
 	struct hclge_desc desc;
 	int ret;
 
+	/* bypass port vlan filter when dynamic vlan mode on */
+	if (vlan_type == HCLGE_FILTER_TYPE_PORT &&
+	    hdev->vlan_mode == HCLGE_VLAN_DYNAMIC_MODE)
+		return 0;
+
 	/* read current vlan filter parameter */
 	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_VLAN_FILTER_CTRL, true);
 	req = (struct hclge_vlan_filter_ctrl_cmd *)desc.data;
@@ -8259,18 +8271,6 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
 	return ret;
 }
 
-#define HCLGE_FILTER_TYPE_VF		0
-#define HCLGE_FILTER_TYPE_PORT		1
-#define HCLGE_FILTER_FE_EGRESS_V1_B	BIT(0)
-#define HCLGE_FILTER_FE_NIC_INGRESS_B	BIT(0)
-#define HCLGE_FILTER_FE_NIC_EGRESS_B	BIT(1)
-#define HCLGE_FILTER_FE_ROCE_INGRESS_B	BIT(2)
-#define HCLGE_FILTER_FE_ROCE_EGRESS_B	BIT(3)
-#define HCLGE_FILTER_FE_EGRESS		(HCLGE_FILTER_FE_NIC_EGRESS_B \
-					| HCLGE_FILTER_FE_ROCE_EGRESS_B)
-#define HCLGE_FILTER_FE_INGRESS		(HCLGE_FILTER_FE_NIC_INGRESS_B \
-					| HCLGE_FILTER_FE_ROCE_INGRESS_B)
-
 static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable)
 {
 	struct hclge_vport *vport = hclge_get_vport(handle);
@@ -8451,6 +8451,10 @@ static int hclge_set_vlan_filter_hw(struct hclge_dev *hdev, __be16 proto,
 		return -EINVAL;
 	}
 
+	/* bypass port vlan filter when dynamic vlan mode on */
+	if (hdev->vlan_mode == HCLGE_VLAN_DYNAMIC_MODE)
+		return 0;
+
 	for_each_set_bit(vport_idx, hdev->vlan_table[vlan_id], HCLGE_VPORT_NUM)
 		vport_num++;
 
@@ -8640,6 +8644,12 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
 		/* for revision 0x21, vf vlan filter is per function */
 		for (i = 0; i < hdev->num_alloc_vport; i++) {
 			vport = &hdev->vport[i];
+			vport->vf_vlan_en =
+				hdev->vlan_mode == HCLGE_VLAN_DEFAULT_MODE;
+
+			if (!vport->vf_vlan_en)
+				continue;
+
 			ret = hclge_set_vlan_filter_ctrl(hdev,
 							 HCLGE_FILTER_TYPE_VF,
 							 HCLGE_FILTER_FE_EGRESS,
@@ -8818,6 +8828,8 @@ void hclge_restore_vport_vlan_table(struct hclge_vport *vport)
 			break;
 		vlan->hd_tbl_status = true;
 	}
+
+	hclge_vf_vlan_filter_switch(vport);
 }
 
 /* For global reset and imp reset, hardware will clear the mac table,
@@ -8881,6 +8893,56 @@ int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
 	return hclge_set_vlan_rx_offload_cfg(vport);
 }
 
+static bool hclge_has_vlan_used(struct hclge_dev *hdev, u16 vport_id)
+{
+#define VLAN_CHECK_START_ID	1
+
+	u16 vlan_id;
+
+	/* if set as vlan default mode, vf vlan filter always on */
+	if (hdev->vlan_mode == HCLGE_VLAN_DEFAULT_MODE)
+		return true;
+
+	/* check all vlan tag in vf vlan table except 0 */
+	for (vlan_id = VLAN_CHECK_START_ID; vlan_id < VLAN_N_VID; vlan_id++)
+		if (test_bit(vport_id, hdev->vlan_table[vlan_id]))
+			return true;
+
+	return false;
+}
+
+static int hclge_vf_vlan_filter_switch(struct hclge_vport *vport)
+{
+	struct hnae3_handle *nic = &vport->nic;
+	struct hclge_dev *hdev = vport->back;
+	bool filter_en;
+	int ret;
+
+	filter_en = hclge_has_vlan_used(hdev, vport->vport_id) ||
+		vport->port_base_vlan_cfg.state != HNAE3_PORT_BASE_VLAN_DISABLE;
+
+	if (filter_en == vport->vf_vlan_en)
+		return 0;
+
+	ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
+					 HCLGE_FILTER_FE_EGRESS,
+					 filter_en, vport->vport_id);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"failed to %s vport%u vf vlan filter, ret = %d.\n",
+			filter_en ? "enable" : "disable", vport->vport_id, ret);
+		return ret;
+	}
+
+	vport->vf_vlan_en = filter_en;
+	if (filter_en)
+		nic->netdev_flags |= HNAE3_VF_VLAN_EN;
+	else
+		nic->netdev_flags &= ~HNAE3_VF_VLAN_EN;
+
+	return 0;
+}
+
 static int hclge_update_vlan_filter_entries(struct hclge_vport *vport,
 					    u16 port_base_vlan_state,
 					    struct hclge_vlan_info *new_info,
@@ -8921,6 +8983,9 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
 	if (ret)
 		return ret;
 
+	if (old_vlan_info->vlan_tag == vlan_info->vlan_tag)
+		goto update;
+
 	if (state == HNAE3_PORT_BASE_VLAN_MODIFY) {
 		/* add new VLAN tag */
 		ret = hclge_set_vlan_filter_hw(hdev,
@@ -8948,19 +9013,18 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
 	if (ret)
 		return ret;
 
-	/* update state only when disable/enable port based VLAN */
+update:
 	vport->port_base_vlan_cfg.state = state;
 	if (state == HNAE3_PORT_BASE_VLAN_DISABLE)
 		nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_DISABLE;
 	else
 		nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
 
-update:
 	vport->port_base_vlan_cfg.vlan_info.vlan_tag = vlan_info->vlan_tag;
 	vport->port_base_vlan_cfg.vlan_info.qos = vlan_info->qos;
 	vport->port_base_vlan_cfg.vlan_info.vlan_proto = vlan_info->vlan_proto;
 
-	return 0;
+	return hclge_vf_vlan_filter_switch(vport);
 }
 
 static u16 hclge_get_port_base_vlan_state(struct hclge_vport *vport,
@@ -8970,15 +9034,16 @@ static u16 hclge_get_port_base_vlan_state(struct hclge_vport *vport,
 	if (state == HNAE3_PORT_BASE_VLAN_DISABLE) {
 		if (!vlan)
 			return HNAE3_PORT_BASE_VLAN_NOCHANGE;
-		else
-			return HNAE3_PORT_BASE_VLAN_ENABLE;
+
+		return HNAE3_PORT_BASE_VLAN_ENABLE;
 	} else {
 		if (!vlan)
 			return HNAE3_PORT_BASE_VLAN_DISABLE;
-		else if (vport->port_base_vlan_cfg.vlan_info.vlan_tag == vlan)
+
+		if (vport->port_base_vlan_cfg.vlan_info.vlan_tag == vlan)
 			return HNAE3_PORT_BASE_VLAN_NOCHANGE;
-		else
-			return HNAE3_PORT_BASE_VLAN_MODIFY;
+
+		return HNAE3_PORT_BASE_VLAN_MODIFY;
 	}
 }
 
@@ -9090,7 +9155,14 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
 		 */
 		set_bit(vlan_id, vport->vlan_del_fail_bmap);
 	}
-	return ret;
+
+	if (ret) {
+		dev_info(&hdev->pdev->dev, "failed to set vf vlan, ret = %d!\n",
+			 ret);
+		return ret;
+	}
+
+	return hclge_vf_vlan_filter_switch(vport);
 }
 
 static void hclge_sync_vlan_filter(struct hclge_dev *hdev)
@@ -11104,6 +11176,7 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev)
 	struct hclge_vport *vport = &hdev->vport[0];
 	struct hnae3_handle *handle = &vport->nic;
 	u8 tmp_flags = 0;
+	u32 filter_en;
 	int ret;
 
 	if (vport->last_promisc_flags != vport->overflow_promisc_flags) {
@@ -11117,8 +11190,10 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev)
 					     tmp_flags & HNAE3_MPE);
 		if (!ret) {
 			clear_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state);
-			hclge_enable_vlan_filter(handle,
-						 tmp_flags & HNAE3_VLAN_FLTR);
+
+			filter_en = hclge_has_vlan_used(hdev, 0) ?
+							HNAE3_VLAN_FLTR : 0;
+			hclge_enable_vlan_filter(handle, tmp_flags & filter_en);
 		}
 	}
 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 913c4f6..1a1a88a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -202,6 +202,18 @@ enum HLCGE_PORT_TYPE {
 #define HCLGE_SUPPORT_GE \
 	(HCLGE_SUPPORT_1G_BIT | HCLGE_SUPPORT_100M_BIT | HCLGE_SUPPORT_10M_BIT)
 
+#define HCLGE_FILTER_TYPE_VF		0
+#define HCLGE_FILTER_TYPE_PORT		1
+#define HCLGE_FILTER_FE_EGRESS_V1_B	BIT(0)
+#define HCLGE_FILTER_FE_NIC_INGRESS_B	BIT(0)
+#define HCLGE_FILTER_FE_NIC_EGRESS_B	BIT(1)
+#define HCLGE_FILTER_FE_ROCE_INGRESS_B	BIT(2)
+#define HCLGE_FILTER_FE_ROCE_EGRESS_B	BIT(3)
+#define HCLGE_FILTER_FE_EGRESS		(HCLGE_FILTER_FE_NIC_EGRESS_B \
+					| HCLGE_FILTER_FE_ROCE_EGRESS_B)
+#define HCLGE_FILTER_FE_INGRESS		(HCLGE_FILTER_FE_NIC_INGRESS_B \
+					| HCLGE_FILTER_FE_ROCE_INGRESS_B)
+
 enum HCLGE_DEV_STATE {
 	HCLGE_STATE_REINITING,
 	HCLGE_STATE_DOWN,
@@ -310,6 +322,11 @@ enum hclge_fc_mode {
 	HCLGE_FC_DEFAULT
 };
 
+enum hclge_vlan_mode_sel {
+	HCLGE_VLAN_DEFAULT_MODE,
+	HCLGE_VLAN_DYNAMIC_MODE
+};
+
 enum hclge_link_fail_code {
 	HCLGE_LF_NORMAL,
 	HCLGE_LF_REF_CLOCK_LOST,
@@ -347,6 +364,7 @@ struct hclge_cfg {
 	u8 default_speed;
 	u32 numa_node_map;
 	u8 speed_ability;
+	u8 vlan_mode_sel;
 	u16 umv_space;
 };
 
@@ -824,6 +842,8 @@ struct hclge_dev {
 	enum HCLGE_FD_ACTIVE_RULE_TYPE fd_active_type;
 	u8 fd_en;
 
+	u8 vlan_mode;
+
 	u16 wanted_umv_size;
 	/* max available unicast mac vlan space */
 	u16 max_umv_size;
@@ -914,6 +934,7 @@ struct hclge_vport {
 	u32 bw_limit;		/* VSI BW Limit (0 = disabled) */
 	u8  dwrr;
 
+	bool vf_vlan_en;
 	unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)];
 	struct hclge_port_base_vlan_config port_base_vlan_cfg;
 	struct hclge_tx_vtag_cfg  txvlan_cfg;
-- 
2.7.4


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

* [PATCH net-next 2/2] net: hns3: add support for 'QOS' in port based VLAN configuration
  2020-05-20  1:20 [PATCH net-next 0/2] net: hns3: adds two VLAN feature Huazhong Tan
  2020-05-20  1:20 ` [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
@ 2020-05-20  1:20 ` Huazhong Tan
  1 sibling, 0 replies; 7+ messages in thread
From: Huazhong Tan @ 2020-05-20  1:20 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm, kuba,
	GuoJia Liao, Huazhong Tan

From: GuoJia Liao <liaoguojia@huawei.com>

This patch adds support for 'QOS' in port based VLAN configuration.

Signed-off-by: GuoJia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 32 ++++++++++++----------
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h    |  4 +--
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 10 +++----
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index bdacda4..936e3bc 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -8546,7 +8546,7 @@ static int hclge_set_vlan_rx_offload_cfg(struct hclge_vport *vport)
 
 static int hclge_vlan_offload_cfg(struct hclge_vport *vport,
 				  u16 port_base_vlan_state,
-				  u16 vlan_tag)
+				  u16 vlan_tag, u8 qos)
 {
 	int ret;
 
@@ -8557,7 +8557,8 @@ static int hclge_vlan_offload_cfg(struct hclge_vport *vport,
 	} else {
 		vport->txvlan_cfg.accept_tag1 = false;
 		vport->txvlan_cfg.insert_tag1_en = true;
-		vport->txvlan_cfg.default_tag1 = vlan_tag;
+		vport->txvlan_cfg.default_tag1 = (qos << VLAN_PRIO_SHIFT) |
+						 vlan_tag;
 	}
 
 	vport->txvlan_cfg.accept_untag1 = true;
@@ -8687,13 +8688,15 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
 
 	for (i = 0; i < hdev->num_alloc_vport; i++) {
 		u16 vlan_tag;
+		u8 qos;
 
 		vport = &hdev->vport[i];
 		vlan_tag = vport->port_base_vlan_cfg.vlan_info.vlan_tag;
+		qos = vport->port_base_vlan_cfg.vlan_info.qos;
 
 		ret = hclge_vlan_offload_cfg(vport,
 					     vport->port_base_vlan_cfg.state,
-					     vlan_tag);
+					     vlan_tag, qos);
 		if (ret)
 			return ret;
 	}
@@ -8979,7 +8982,8 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
 
 	old_vlan_info = &vport->port_base_vlan_cfg.vlan_info;
 
-	ret = hclge_vlan_offload_cfg(vport, state, vlan_info->vlan_tag);
+	ret = hclge_vlan_offload_cfg(vport, state, vlan_info->vlan_tag,
+				     vlan_info->qos);
 	if (ret)
 		return ret;
 
@@ -9029,18 +9033,19 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
 
 static u16 hclge_get_port_base_vlan_state(struct hclge_vport *vport,
 					  enum hnae3_port_base_vlan_state state,
-					  u16 vlan)
+					  u16 vlan, u8 qos)
 {
 	if (state == HNAE3_PORT_BASE_VLAN_DISABLE) {
-		if (!vlan)
+		if (!vlan && !qos)
 			return HNAE3_PORT_BASE_VLAN_NOCHANGE;
 
 		return HNAE3_PORT_BASE_VLAN_ENABLE;
 	} else {
-		if (!vlan)
+		if (!vlan && !qos)
 			return HNAE3_PORT_BASE_VLAN_DISABLE;
 
-		if (vport->port_base_vlan_cfg.vlan_info.vlan_tag == vlan)
+		if (vport->port_base_vlan_cfg.vlan_info.vlan_tag == vlan &&
+		    vport->port_base_vlan_cfg.vlan_info.qos == qos)
 			return HNAE3_PORT_BASE_VLAN_NOCHANGE;
 
 		return HNAE3_PORT_BASE_VLAN_MODIFY;
@@ -9054,7 +9059,6 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
 	struct hclge_dev *hdev = vport->back;
 	struct hclge_vlan_info vlan_info;
 	u16 state;
-	int ret;
 
 	if (hdev->pdev->revision == 0x20)
 		return -EOPNOTSUPP;
@@ -9071,7 +9075,7 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
 
 	state = hclge_get_port_base_vlan_state(vport,
 					       vport->port_base_vlan_cfg.state,
-					       vlan);
+					       vlan, qos);
 	if (state == HNAE3_PORT_BASE_VLAN_NOCHANGE)
 		return 0;
 
@@ -9083,11 +9087,9 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
 		return hclge_update_port_base_vlan_cfg(vport, state,
 						       &vlan_info);
 	} else {
-		ret = hclge_push_vf_port_base_vlan_info(&hdev->vport[0],
-							vport->vport_id, state,
-							vlan, qos,
-							ntohs(proto));
-		return ret;
+		return hclge_push_vf_port_base_vlan_info(&hdev->vport[0],
+							 vport->vport_id,
+							 state, &vlan_info);
 	}
 }
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 1a1a88a..2d69f98 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -1026,8 +1026,8 @@ void hclge_restore_vport_vlan_table(struct hclge_vport *vport);
 int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
 				    struct hclge_vlan_info *vlan_info);
 int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
-				      u16 state, u16 vlan_tag, u16 qos,
-				      u16 vlan_proto);
+				      u16 state,
+				      struct hclge_vlan_info *vlan_info);
 void hclge_task_schedule(struct hclge_dev *hdev, unsigned long delay_time);
 int hclge_query_bd_num_cmd_send(struct hclge_dev *hdev,
 				struct hclge_desc *desc);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
index 0874ae4..b85c9b9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
@@ -319,17 +319,17 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport,
 }
 
 int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
-				      u16 state, u16 vlan_tag, u16 qos,
-				      u16 vlan_proto)
+				      u16 state,
+				      struct hclge_vlan_info *vlan_info)
 {
 #define MSG_DATA_SIZE	8
 
 	u8 msg_data[MSG_DATA_SIZE];
 
 	memcpy(&msg_data[0], &state, sizeof(u16));
-	memcpy(&msg_data[2], &vlan_proto, sizeof(u16));
-	memcpy(&msg_data[4], &qos, sizeof(u16));
-	memcpy(&msg_data[6], &vlan_tag, sizeof(u16));
+	memcpy(&msg_data[2], &vlan_info->vlan_proto, sizeof(u16));
+	memcpy(&msg_data[4], &vlan_info->qos, sizeof(u16));
+	memcpy(&msg_data[6], &vlan_info->vlan_tag, sizeof(u16));
 
 	return hclge_send_mbx_msg(vport, msg_data, sizeof(msg_data),
 				  HCLGE_MBX_PUSH_VLAN_INFO, vfid);
-- 
2.7.4


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

* Re: [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode
  2020-05-20  1:20 ` [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
@ 2020-05-20 21:06   ` Jakub Kicinski
  2020-05-21  1:33     ` tanhuazhong
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2020-05-20 21:06 UTC (permalink / raw)
  To: Huazhong Tan
  Cc: davem, netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm,
	GuoJia Liao

On Wed, 20 May 2020 09:20:12 +0800 Huazhong Tan wrote:
> From: GuoJia Liao <liaoguojia@huawei.com>
> 
> There is a scenario which needs vNICs enable the VLAN filter
> in access port, while disable the VLAN filter in trunk port.
> Access port and trunk port can switch according to the user's
> configuration.
> 
> This patch adds support for the dynamic VLAN mode. then the
> HNS3 driver can support two VLAN modes: default VLAN mode and
> dynamic VLAN mode. User can switch the mode through the
> configuration file.

What configuration file? Sounds like you're reimplementing trusted 
VFs (ndo_set_vf_trust).

> In default VLAN mode, port based VLAN filter and VF VLAN
> filter should always be enabled.
> 
> In dynamic VLAN mode, port based VLAN filter is disabled, and
> VF VLAN filter is disabled defaultly, and should be enabled
> when there is a non-zero VLAN ID. In addition, VF VLAN filter
> is enabled if PVID is enabled for vNIC.
> 
> When enable promisc, VLAN filter should be disabled. When disable
> promisc, VLAN filter's status depends on the value of
> 'vport->vf_vlan_en', which is used to record the VF VLAN filter
> status.
> 
> In default VLAN mode, 'vport->vf_vlan_en' always be 'true', so
> VF VLAN filter will set to be enabled after disabling promisc.
> 
> In dynamic VLAN mode, 'vport->vf_vlan_en' lies on whether there
> is a non-zero VLAN ID.
> 
> Signed-off-by: GuoJia Liao <liaoguojia@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>

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

* Re: [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode
  2020-05-20 21:06   ` Jakub Kicinski
@ 2020-05-21  1:33     ` tanhuazhong
  2020-05-21  1:36       ` Jakub Kicinski
  0 siblings, 1 reply; 7+ messages in thread
From: tanhuazhong @ 2020-05-21  1:33 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm,
	GuoJia Liao



On 2020/5/21 5:06, Jakub Kicinski wrote:
> On Wed, 20 May 2020 09:20:12 +0800 Huazhong Tan wrote:
>> From: GuoJia Liao <liaoguojia@huawei.com>
>>
>> There is a scenario which needs vNICs enable the VLAN filter
>> in access port, while disable the VLAN filter in trunk port.
>> Access port and trunk port can switch according to the user's
>> configuration.
>>
>> This patch adds support for the dynamic VLAN mode. then the
>> HNS3 driver can support two VLAN modes: default VLAN mode and
>> dynamic VLAN mode. User can switch the mode through the
>> configuration file.
> 
> What configuration file? Sounds like you're reimplementing trusted
> VFs (ndo_set_vf_trust).
> 

Hi, Jakub.

Maybe this configuration file here is a little misleading,
this VLAN mode is decided by the firmware, the driver will
query the VLAN mode from firmware during  intializing.

I will modified this description in V2. BTW, is there any
other suggestion about this patch?

Thanks:)


>> In default VLAN mode, port based VLAN filter and VF VLAN
>> filter should always be enabled.
>>
>> In dynamic VLAN mode, port based VLAN filter is disabled, and
>> VF VLAN filter is disabled defaultly, and should be enabled
>> when there is a non-zero VLAN ID. In addition, VF VLAN filter
>> is enabled if PVID is enabled for vNIC.
>>
>> When enable promisc, VLAN filter should be disabled. When disable
>> promisc, VLAN filter's status depends on the value of
>> 'vport->vf_vlan_en', which is used to record the VF VLAN filter
>> status.
>>
>> In default VLAN mode, 'vport->vf_vlan_en' always be 'true', so
>> VF VLAN filter will set to be enabled after disabling promisc.
>>
>> In dynamic VLAN mode, 'vport->vf_vlan_en' lies on whether there
>> is a non-zero VLAN ID.
>>
>> Signed-off-by: GuoJia Liao <liaoguojia@huawei.com>
>> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> 
> .
> 


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

* Re: [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode
  2020-05-21  1:33     ` tanhuazhong
@ 2020-05-21  1:36       ` Jakub Kicinski
  2020-05-21  2:26         ` tanhuazhong
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2020-05-21  1:36 UTC (permalink / raw)
  To: tanhuazhong
  Cc: davem, netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm,
	GuoJia Liao

On Thu, 21 May 2020 09:33:14 +0800 tanhuazhong wrote:
> On 2020/5/21 5:06, Jakub Kicinski wrote:
> > On Wed, 20 May 2020 09:20:12 +0800 Huazhong Tan wrote:  
> >> From: GuoJia Liao <liaoguojia@huawei.com>
> >>
> >> There is a scenario which needs vNICs enable the VLAN filter
> >> in access port, while disable the VLAN filter in trunk port.
> >> Access port and trunk port can switch according to the user's
> >> configuration.
> >>
> >> This patch adds support for the dynamic VLAN mode. then the
> >> HNS3 driver can support two VLAN modes: default VLAN mode and
> >> dynamic VLAN mode. User can switch the mode through the
> >> configuration file.  
> > 
> > What configuration file? Sounds like you're reimplementing trusted
> > VFs (ndo_set_vf_trust).
> >   
> 
> Hi, Jakub.
> 
> Maybe this configuration file here is a little misleading,
> this VLAN mode is decided by the firmware, the driver will
> query the VLAN mode from firmware during  intializing.

And the FW got that configuration from?

> I will modified this description in V2. BTW, is there any
> other suggestion about this patch?

The other suggestion was to trusted vf. What's the difference between
trusted VF and "dynamic VLAN mode"?

> >> In default VLAN mode, port based VLAN filter and VF VLAN
> >> filter should always be enabled.
> >>
> >> In dynamic VLAN mode, port based VLAN filter is disabled, and
> >> VF VLAN filter is disabled defaultly, and should be enabled
> >> when there is a non-zero VLAN ID. In addition, VF VLAN filter
> >> is enabled if PVID is enabled for vNIC.
> >>
> >> When enable promisc, VLAN filter should be disabled. When disable
> >> promisc, VLAN filter's status depends on the value of
> >> 'vport->vf_vlan_en', which is used to record the VF VLAN filter
> >> status.
> >>
> >> In default VLAN mode, 'vport->vf_vlan_en' always be 'true', so
> >> VF VLAN filter will set to be enabled after disabling promisc.
> >>
> >> In dynamic VLAN mode, 'vport->vf_vlan_en' lies on whether there
> >> is a non-zero VLAN ID.
> >>
> >> Signed-off-by: GuoJia Liao <liaoguojia@huawei.com>
> >> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>  


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

* Re: [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode
  2020-05-21  1:36       ` Jakub Kicinski
@ 2020-05-21  2:26         ` tanhuazhong
  0 siblings, 0 replies; 7+ messages in thread
From: tanhuazhong @ 2020-05-21  2:26 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm,
	GuoJia Liao



On 2020/5/21 9:36, Jakub Kicinski wrote:
> On Thu, 21 May 2020 09:33:14 +0800 tanhuazhong wrote:
>> On 2020/5/21 5:06, Jakub Kicinski wrote:
>>> On Wed, 20 May 2020 09:20:12 +0800 Huazhong Tan wrote:
>>>> From: GuoJia Liao <liaoguojia@huawei.com>
>>>>
>>>> There is a scenario which needs vNICs enable the VLAN filter
>>>> in access port, while disable the VLAN filter in trunk port.
>>>> Access port and trunk port can switch according to the user's
>>>> configuration.
>>>>
>>>> This patch adds support for the dynamic VLAN mode. then the
>>>> HNS3 driver can support two VLAN modes: default VLAN mode and
>>>> dynamic VLAN mode. User can switch the mode through the
>>>> configuration file.
>>>
>>> What configuration file? Sounds like you're reimplementing trusted
>>> VFs (ndo_set_vf_trust).
>>>    
>>
>> Hi, Jakub.
>>
>> Maybe this configuration file here is a little misleading,
>> this VLAN mode is decided by the firmware, the driver will
>> query the VLAN mode from firmware during  intializing.
> 
> And the FW got that configuration from?
> 

It depends on the user's demand, the user can choose the firmware
which supports the default VLAN mode or the dynamic VLAN mode.

>> I will modified this description in V2. BTW, is there any
>> other suggestion about this patch?
> 
> The other suggestion was to trusted vf. What's the difference between
> trusted VF and "dynamic VLAN mode"?
> 

Trust VF is not related to dynamic VLAN mode. So far it's only
be used for privilege checking for the VF promisc. And dynamic
VLAN mode is designed to adapt specified scenario which want
enable/disable VLAN filter base on VLAN used.

Thanks.

>>>> In default VLAN mode, port based VLAN filter and VF VLAN
>>>> filter should always be enabled.
>>>>
>>>> In dynamic VLAN mode, port based VLAN filter is disabled, and
>>>> VF VLAN filter is disabled defaultly, and should be enabled
>>>> when there is a non-zero VLAN ID. In addition, VF VLAN filter
>>>> is enabled if PVID is enabled for vNIC.
>>>>
>>>> When enable promisc, VLAN filter should be disabled. When disable
>>>> promisc, VLAN filter's status depends on the value of
>>>> 'vport->vf_vlan_en', which is used to record the VF VLAN filter
>>>> status.
>>>>
>>>> In default VLAN mode, 'vport->vf_vlan_en' always be 'true', so
>>>> VF VLAN filter will set to be enabled after disabling promisc.
>>>>
>>>> In dynamic VLAN mode, 'vport->vf_vlan_en' lies on whether there
>>>> is a non-zero VLAN ID.
>>>>
>>>> Signed-off-by: GuoJia Liao <liaoguojia@huawei.com>
>>>> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> 
> 
> .
> 


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

end of thread, other threads:[~2020-05-21  2:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20  1:20 [PATCH net-next 0/2] net: hns3: adds two VLAN feature Huazhong Tan
2020-05-20  1:20 ` [PATCH net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
2020-05-20 21:06   ` Jakub Kicinski
2020-05-21  1:33     ` tanhuazhong
2020-05-21  1:36       ` Jakub Kicinski
2020-05-21  2:26         ` tanhuazhong
2020-05-20  1:20 ` [PATCH net-next 2/2] net: hns3: add support for 'QOS' in port based VLAN configuration Huazhong Tan

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