linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
@ 2020-05-21 11:38 Huazhong Tan
  2020-05-21 11:38 ` [PATCH V2 net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Huazhong Tan @ 2020-05-21 11:38 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.

Change log:
V1->V2: modifies [patch 1]'s commit log, suggested by Jakub Kicinski.

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] 9+ messages in thread

* [PATCH V2 net-next 1/2] net: hns3: adds support for dynamic VLAN mode
  2020-05-21 11:38 [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Huazhong Tan
@ 2020-05-21 11:38 ` Huazhong Tan
  2020-05-21 11:38 ` [PATCH V2 net-next 2/2] net: hns3: add support for 'QoS' in port based VLAN configuration Huazhong Tan
  2020-05-21 19:17 ` [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Jakub Kicinski
  2 siblings, 0 replies; 9+ messages in thread
From: Huazhong Tan @ 2020-05-21 11:38 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 a new VLAN mode called dynamic mode for it.
So there are two VLAN modes supported in HNS3 driver: default
VLAN mode and dynamic VLAN mode, chosen by firmware.

For default VLAN mode, both port VLAN filter and VF VLAN filter
are enabled.

For dynamic VLAN mode, port VLAN filter is always disabled, and
VF VLAN filter is keep disable until a non-zero VLAN ID being
used for the function.

Furthermore, in original implement the port VLAN filter and VF
VLAN filter is enabled when user disable promisc mode. Now for
dynamic VLAN mode, it should also take account of whether a
non-zero VLAN ID used.

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] 9+ messages in thread

* [PATCH V2 net-next 2/2] net: hns3: add support for 'QoS' in port based VLAN configuration
  2020-05-21 11:38 [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Huazhong Tan
  2020-05-21 11:38 ` [PATCH V2 net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
@ 2020-05-21 11:38 ` Huazhong Tan
  2020-05-21 19:17 ` [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Jakub Kicinski
  2 siblings, 0 replies; 9+ messages in thread
From: Huazhong Tan @ 2020-05-21 11:38 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] 9+ messages in thread

* Re: [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
  2020-05-21 11:38 [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Huazhong Tan
  2020-05-21 11:38 ` [PATCH V2 net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
  2020-05-21 11:38 ` [PATCH V2 net-next 2/2] net: hns3: add support for 'QoS' in port based VLAN configuration Huazhong Tan
@ 2020-05-21 19:17 ` Jakub Kicinski
  2020-05-21 21:37   ` David Miller
  2 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2020-05-21 19:17 UTC (permalink / raw)
  To: Huazhong Tan
  Cc: davem, netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm

On Thu, 21 May 2020 19:38:23 +0800 Huazhong Tan wrote:
> This patchset adds two new VLAN feature.
> 
> [patch 1] adds a new dynamic VLAN mode.
> [patch 2] adds support for 'QoS' field to PVID.
> 
> Change log:
> V1->V2: modifies [patch 1]'s commit log, suggested by Jakub Kicinski.

I don't like the idea that FW is choosing the driver behavior in a way
that's not observable via standard Linux APIs. This is the second time
a feature like that posted for a driver this week, and we should
discourage it.

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

* Re: [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
  2020-05-21 19:17 ` [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Jakub Kicinski
@ 2020-05-21 21:37   ` David Miller
  2020-05-22  9:35     ` tanhuazhong
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2020-05-21 21:37 UTC (permalink / raw)
  To: kuba
  Cc: tanhuazhong, netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm

From: Jakub Kicinski <kuba@kernel.org>
Date: Thu, 21 May 2020 12:17:07 -0700

> On Thu, 21 May 2020 19:38:23 +0800 Huazhong Tan wrote:
>> This patchset adds two new VLAN feature.
>> 
>> [patch 1] adds a new dynamic VLAN mode.
>> [patch 2] adds support for 'QoS' field to PVID.
>> 
>> Change log:
>> V1->V2: modifies [patch 1]'s commit log, suggested by Jakub Kicinski.
> 
> I don't like the idea that FW is choosing the driver behavior in a way
> that's not observable via standard Linux APIs. This is the second time
> a feature like that posted for a driver this week, and we should
> discourage it.

Agreed, this is an unacceptable approach to driver features.

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

* Re: [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
  2020-05-21 21:37   ` David Miller
@ 2020-05-22  9:35     ` tanhuazhong
  2020-05-27  2:31       ` tanhuazhong
  0 siblings, 1 reply; 9+ messages in thread
From: tanhuazhong @ 2020-05-22  9:35 UTC (permalink / raw)
  To: David Miller, kuba
  Cc: netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm



On 2020/5/22 5:37, David Miller wrote:
> From: Jakub Kicinski <kuba@kernel.org>
> Date: Thu, 21 May 2020 12:17:07 -0700
> 
>> On Thu, 21 May 2020 19:38:23 +0800 Huazhong Tan wrote:
>>> This patchset adds two new VLAN feature.
>>>
>>> [patch 1] adds a new dynamic VLAN mode.
>>> [patch 2] adds support for 'QoS' field to PVID.
>>>
>>> Change log:
>>> V1->V2: modifies [patch 1]'s commit log, suggested by Jakub Kicinski.
>>
>> I don't like the idea that FW is choosing the driver behavior in a way
>> that's not observable via standard Linux APIs. This is the second time
>> a feature like that posted for a driver this week, and we should
>> discourage it.
> 
> Agreed, this is an unacceptable approach to driver features.
> 

Hi, Jakub & David.

As decribed in patch #1, there is a scenario which needs the dynamic
mode(port VLAN filter is always disabled, andVF VLAN filter is keep
disable until a non-zero VLAN ID being used for the function).

Is this mode selection provided through "ethtool --set-priv-flags"
more acceptable? Or is there any other better suggestion for this?

Thanks.

> .
> 


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

* Re: [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
  2020-05-22  9:35     ` tanhuazhong
@ 2020-05-27  2:31       ` tanhuazhong
  2020-05-27 19:30         ` Jakub Kicinski
  0 siblings, 1 reply; 9+ messages in thread
From: tanhuazhong @ 2020-05-27  2:31 UTC (permalink / raw)
  To: David Miller, kuba
  Cc: netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm



On 2020/5/22 17:35, tanhuazhong wrote:
> 
> 
> On 2020/5/22 5:37, David Miller wrote:
>> From: Jakub Kicinski <kuba@kernel.org>
>> Date: Thu, 21 May 2020 12:17:07 -0700
>>
>>> On Thu, 21 May 2020 19:38:23 +0800 Huazhong Tan wrote:
>>>> This patchset adds two new VLAN feature.
>>>>
>>>> [patch 1] adds a new dynamic VLAN mode.
>>>> [patch 2] adds support for 'QoS' field to PVID.
>>>>
>>>> Change log:
>>>> V1->V2: modifies [patch 1]'s commit log, suggested by Jakub Kicinski.
>>>
>>> I don't like the idea that FW is choosing the driver behavior in a way
>>> that's not observable via standard Linux APIs. This is the second time
>>> a feature like that posted for a driver this week, and we should
>>> discourage it.
>>
>> Agreed, this is an unacceptable approach to driver features.
>>
> 
> Hi, Jakub & David.
> 
> As decribed in patch #1, there is a scenario which needs the dynamic
> mode(port VLAN filter is always disabled, andVF VLAN filter is keep
> disable until a non-zero VLAN ID being used for the function).
> 
> Is this mode selection provided through "ethtool --set-priv-flags"
> more acceptable? Or is there any other better suggestion for this?
> 
> Thanks.
> 

Hi, Jakub & David.

For patch#1, is it acceptable adding "ethtool --get-priv-flags"
to query the VLAN. If yes, I will send a RFC for it.

Best Regards.
Thanks.

>> .
>>


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

* Re: [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
  2020-05-27  2:31       ` tanhuazhong
@ 2020-05-27 19:30         ` Jakub Kicinski
  2020-05-28 23:46           ` Salil Mehta
  0 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2020-05-27 19:30 UTC (permalink / raw)
  To: tanhuazhong
  Cc: David Miller, netdev, linux-kernel, salil.mehta, yisen.zhuang, linuxarm

On Wed, 27 May 2020 10:31:59 +0800 tanhuazhong wrote:
> Hi, Jakub & David.
> 
> For patch#1, is it acceptable adding "ethtool --get-priv-flags"
> to query the VLAN. If yes, I will send a RFC for it.

The recommended way of implementing vfs with advanced vlan
configurations is via "switchdev mode" & representors.

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

* RE: [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
  2020-05-27 19:30         ` Jakub Kicinski
@ 2020-05-28 23:46           ` Salil Mehta
  0 siblings, 0 replies; 9+ messages in thread
From: Salil Mehta @ 2020-05-28 23:46 UTC (permalink / raw)
  To: Jakub Kicinski, tanhuazhong
  Cc: David Miller, netdev, linux-kernel, Zhuangyuzeng (Yisen), Linuxarm

Hi Jakub/David,

> From: Jakub Kicinski [mailto:kuba@kernel.org]
> Sent: Wednesday, May 27, 2020 8:31 PM
> To: tanhuazhong <tanhuazhong@huawei.com>
> Cc: David Miller <davem@davemloft.net>; netdev@vger.kernel.org;
> linux-kernel@vger.kernel.org; Salil Mehta <salil.mehta@huawei.com>;
> Zhuangyuzeng (Yisen) <yisen.zhuang@huawei.com>; Linuxarm <linuxarm@huawei.com>
> Subject: Re: [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature
> 
> On Wed, 27 May 2020 10:31:59 +0800 tanhuazhong wrote:
> > Hi, Jakub & David.
> >
> > For patch#1, is it acceptable adding "ethtool --get-priv-flags"
> > to query the VLAN. If yes, I will send a RFC for it.
> 
> The recommended way of implementing vfs with advanced vlan
> configurations is via "switchdev mode" & representors.

AFAIK, switchdev ops only facilitates the standard abstract
interface to any underlying standard or proprietary hardware
which could be ASIC, eswitch etc. Therefore, standard tools
like ip, bridge or even stacks like FRR etc. could be used
while leveraging the below hardware forwarding.

Not sure how will switchdev ops will be of help here?


Just curious how does Mellanox supports Hybrid port mode?

In general, 
We can have port being configured as Access/Trunk ports.

Access port = Only untagged packets are sent or are expected.
                RX'ed Tagged packets are dropped.
Trunk Port  = Only Tagged packet are received or sent and any
                Untagged packets received are dropped.

Mellanox also support Hybrid mode in Onyx platform:

Hybrid - packets are sent tagged or untagged, the port
expects both tagged and untagged packets. This mode is
a combination of Access and Trunk modes. There is an
option to configure multiple VLANs on the hybrid port.
PVID is configured on the port for untagged ingress
packets.

First two configuration are easy to realize using the
standard Linux configuration tools like ip/bridge but
not sure about the hybrid? also, why do we even need
to create a bridge to realize any of above port modes?

Note: HNS hardware does not have eswitch support.


Salil.


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

end of thread, other threads:[~2020-05-28 23:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 11:38 [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Huazhong Tan
2020-05-21 11:38 ` [PATCH V2 net-next 1/2] net: hns3: adds support for dynamic VLAN mode Huazhong Tan
2020-05-21 11:38 ` [PATCH V2 net-next 2/2] net: hns3: add support for 'QoS' in port based VLAN configuration Huazhong Tan
2020-05-21 19:17 ` [PATCH V2 net-next 0/2] net: hns3: adds two VLAN feature Jakub Kicinski
2020-05-21 21:37   ` David Miller
2020-05-22  9:35     ` tanhuazhong
2020-05-27  2:31       ` tanhuazhong
2020-05-27 19:30         ` Jakub Kicinski
2020-05-28 23:46           ` Salil Mehta

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