Skip to contentSkip to conversation

net/ice: fix LLDP forward

PATCH Superseded Wang Ying A 4 participants 7 messages Jul 26, 2019 – Jul 29, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: fix LLDP forward

The patch fix the issue that lldp packet can't be forwarded to host.

Fixes 59d151de6673 ("net/ice: stop LLDP by default")
---
 drivers/net/ice/ice_ethdev.c | 46 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +45 -1
index 08fc9ec..37bea2b 100644
@@ -1385,6 +1385,44 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	return ret;
 }
 
+#define ICE_ETHERTYPE_LLDP              0x88CC
+/** ice_cfg_sw_lldp - Config switch rules for LLDP packet handling
+ * @vsi: the VSI being configured
+ * @tx: bool to determine Tx or Rx rule
+ * @create: bool to determine create or remove Rule
+ */
+static enum ice_status
+ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create)
+{
+	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_fltr_list_entry *list = NULL;
+	struct LIST_HEAD_TYPE tmp_add_list;
+	enum ice_status status;
+	list = (struct ice_fltr_list_entry *)ice_malloc(hw, sizeof(*list));
+	if (!list)
+		return ICE_ERR_NO_MEMORY;
+	list->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
+	list->fltr_info.vsi_handle = vsi->idx;
+	list->fltr_info.l_data.ethertype_mac.ethertype = ICE_ETHERTYPE_LLDP;
+	if (tx) {
+		list->fltr_info.fltr_act = ICE_DROP_PACKET;
+		list->fltr_info.flag = ICE_FLTR_TX;
+		list->fltr_info.src_id = ICE_SRC_ID_VSI;
+	} else {
+		list->fltr_info.fltr_act = ICE_FWD_TO_VSI;
+		list->fltr_info.flag = ICE_FLTR_RX;
+		list->fltr_info.src_id = ICE_SRC_ID_LPORT;
+	}
+	INIT_LIST_HEAD(&tmp_add_list);
+	LIST_ADD(&list->list_entry, &tmp_add_list);
+	if (create)
+		status = ice_add_eth_mac(hw, &tmp_add_list);
+	else
+		status = ice_remove_eth_mac(hw, &tmp_add_list);
+	ice_free(hw, list);
+	return status;
+}
+
 static int
 ice_dev_init(struct rte_eth_dev *dev)
 {
@@ -1492,7 +1530,13 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	ret = ice_aq_stop_lldp(hw, TRUE, FALSE, NULL);
 	if (ret != ICE_SUCCESS)
 		PMD_INIT_LOG(DEBUG, "lldp has already stopped\n");
-
+	ret = ice_init_dcb(hw, true);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to init DCB\n");
+	/* Forward LLDP packets to default VSI */
+	ret = ice_cfg_sw_lldp(vsi, false, true);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to cfg lldp\n");
 	/* register callback func to eal lib */
 	rte_intr_callback_register(intr_handle,
 				   ice_interrupt_handler, dev);
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 net/ice: fix LLDP forward

The patch fix the issue that lldp packet can't be forwarded to host.

Fixes 59d151de6673 ("net/ice: stop LLDP by default")

---
---
V2: Remove redundant macro definiton and function argument;
Modify the function name, variables and comments to avoid similarities with kernel code.
---

 drivers/net/ice/ice_ethdev.c | 42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +41 -1
index 08fc9ec..9550aed 100644
@@ -1385,6 +1385,40 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* Forward LLDP packets to default VSI by set switch rules*/
+static int
+ice_vsi_config_sw_lldp(struct ice_vsi *vsi,  bool on)
+{
+	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_fltr_list_entry *s_list_itr = NULL;
+	struct LIST_HEAD_TYPE list_head;
+	int ret = 0;
+
+	INIT_LIST_HEAD(&list_head);
+
+	s_list_itr = (struct ice_fltr_list_entry *)
+			ice_malloc(hw, sizeof(*s_list_itr));
+	if (!s_list_itr) {
+		ret = -ENOMEM;
+		goto DONE;
+	}
+	s_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
+	s_list_itr->fltr_info.vsi_handle = vsi->idx;
+	s_list_itr->fltr_info.l_data.ethertype_mac.ethertype =
+			RTE_ETHER_TYPE_LLDP;
+	s_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
+	s_list_itr->fltr_info.flag = ICE_FLTR_RX;
+	s_list_itr->fltr_info.src_id = ICE_SRC_ID_LPORT;
+	LIST_ADD(&s_list_itr->list_entry, &list_head);
+	if (on)
+		ret = ice_add_eth_mac(hw, &list_head);
+	else
+		ret = ice_remove_eth_mac(hw, &list_head);
+DONE:
+	rte_free(s_list_itr);
+	return ret;
+}
+
 static int
 ice_dev_init(struct rte_eth_dev *dev)
 {
@@ -1492,7 +1526,13 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	ret = ice_aq_stop_lldp(hw, TRUE, FALSE, NULL);
 	if (ret != ICE_SUCCESS)
 		PMD_INIT_LOG(DEBUG, "lldp has already stopped\n");
-
+	ret = ice_init_dcb(hw, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to init DCB\n");
+	/* Forward LLDP packets to default VSI */
+	ret = ice_vsi_config_sw_lldp(vsi, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to cfg lldp\n");
 	/* register callback func to eal lib */
 	rte_intr_callback_register(intr_handle,
 				   ice_interrupt_handler, dev);
Signature · 1 line
1.8.3.1
#2 lore raw

Hi, Ying

Quoted 30 lines

-----Original Message-----
From: Wang, Ying A
Sent: Thursday, July 25, 2019 4:36 PM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yang, Qiming <[email protected]>; Wang, Ying A <[email protected]>; [email protected]
Subject: [PATCH v2] net/ice: fix LLDP forward

The patch fix the issue that lldp packet can't be forwarded to host.

Fixes 59d151de6673 ("net/ice: stop LLDP by default")

---
---
V2: Remove redundant macro definiton and function argument;
Modify the function name, variables and comments to avoid similarities with kernel code.
---

 drivers/net/ice/ice_ethdev.c | 42
+++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c index renamed from drivers/net/ice/ice_ethdev.c +0 -0

08fc9ec..9550aed 100644

drivers/net/ice/ice_ethdev.c static int ice_parse_devargs(struct rte_eth_dev · line 1390

Quoted 6 lines
drivers/net/ice/ice_ethdev.c +2 -0
@@ -1385,6 +1385,40 @@ static int ice_parse_devargs(struct rte_eth_dev
 *dev)
 	return ret;
 }
 
+/* Forward LLDP packets to default VSI by set switch rules*/ static int
+ice_vsi_config_sw_lldp(struct ice_vsi *vsi,  bool on) {

Have this line's format anything wrong?
And why don't we ask ND to deliver ice_cfg_sw_lldp in share code?

Quoted 51 lines
drivers/net/ice/ice_ethdev.c +37 -1
+	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_fltr_list_entry *s_list_itr = NULL;
+	struct LIST_HEAD_TYPE list_head;
+	int ret = 0;
+
+	INIT_LIST_HEAD(&list_head);
+
+	s_list_itr = (struct ice_fltr_list_entry *)
+			ice_malloc(hw, sizeof(*s_list_itr));
+	if (!s_list_itr) {
+		ret = -ENOMEM;
+		goto DONE;
+	}
+	s_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
+	s_list_itr->fltr_info.vsi_handle = vsi->idx;
+	s_list_itr->fltr_info.l_data.ethertype_mac.ethertype =
+			RTE_ETHER_TYPE_LLDP;
+	s_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
+	s_list_itr->fltr_info.flag = ICE_FLTR_RX;
+	s_list_itr->fltr_info.src_id = ICE_SRC_ID_LPORT;
+	LIST_ADD(&s_list_itr->list_entry, &list_head);
+	if (on)
+		ret = ice_add_eth_mac(hw, &list_head);
+	else
+		ret = ice_remove_eth_mac(hw, &list_head);
+DONE:
+	rte_free(s_list_itr);
+	return ret;
+}
+
 static int
 ice_dev_init(struct rte_eth_dev *dev)
 {
@@ -1492,7 +1526,13 @@ static int ice_parse_devargs(struct rte_eth_dev
 *dev)
 	ret = ice_aq_stop_lldp(hw, TRUE, FALSE, NULL);
 	if (ret != ICE_SUCCESS)
 		PMD_INIT_LOG(DEBUG, "lldp has already stopped\n");
-
+	ret = ice_init_dcb(hw, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to init DCB\n");
+	/* Forward LLDP packets to default VSI */
+	ret = ice_vsi_config_sw_lldp(vsi, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to cfg lldp\n");
 	/* register callback func to eal lib */
 	rte_intr_callback_register(intr_handle,

ice_interrupt_handler, dev);
--
1.8.3.1

#3 lore raw
In reply to Wang Ying A
Quoted 30 lines · Wang Ying A

The patch fix the issue that lldp packet can't be forwarded to host.

Fixes 59d151de6673 ("net/ice: stop LLDP by default")

---
---
V2: Remove redundant macro definiton and function argument;
Modify the function name, variables and comments to avoid similarities with kernel code.
---

drivers/net/ice/ice_ethdev.c | 42 +++++++++++++++++++++++++++++++++++++++++-

1 file changed, 41 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +6 -0
index 08fc9ec..9550aed 100644
@@ -1385,6 +1385,40 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* Forward LLDP packets to default VSI by set switch rules*/
+static int
+ice_vsi_config_sw_lldp(struct ice_vsi *vsi,  bool on)
+{
+	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_fltr_list_entry *s_list_itr = NULL;

drivers/net/ice/ice_ethdev.c static int ice_parse_devargs(struct rte_eth_dev *dev) · line 1403

Quoted 10 lines
drivers/net/ice/ice_ethdev.c +10 -0
+	struct LIST_HEAD_TYPE list_head;
+	int ret = 0;
+
+	INIT_LIST_HEAD(&list_head);
+
+	s_list_itr = (struct ice_fltr_list_entry *)
+			ice_malloc(hw, sizeof(*s_list_itr));
+	if (!s_list_itr) {
+		ret = -ENOMEM;
+		goto DONE;

Here ice_malloc has failed, so you don't need to goto DONE to free it, you can just return -ENOMEM here.

Thanks,
Xiaolong

Quoted 39 lines
drivers/net/ice/ice_ethdev.c +18 -0
+	}
+	s_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
+	s_list_itr->fltr_info.vsi_handle = vsi->idx;
+	s_list_itr->fltr_info.l_data.ethertype_mac.ethertype =
+			RTE_ETHER_TYPE_LLDP;
+	s_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
+	s_list_itr->fltr_info.flag = ICE_FLTR_RX;
+	s_list_itr->fltr_info.src_id = ICE_SRC_ID_LPORT;
+	LIST_ADD(&s_list_itr->list_entry, &list_head);
+	if (on)
+		ret = ice_add_eth_mac(hw, &list_head);
+	else
+		ret = ice_remove_eth_mac(hw, &list_head);
+DONE:
+	rte_free(s_list_itr);
+	return ret;
+}
+

static int
ice_dev_init(struct rte_eth_dev *dev)
{

drivers/net/ice/ice_ethdev.c +7 -1
@@ -1492,7 +1526,13 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	ret = ice_aq_stop_lldp(hw, TRUE, FALSE, NULL);
 	if (ret != ICE_SUCCESS)
 		PMD_INIT_LOG(DEBUG, "lldp has already stopped\n");
-
+	ret = ice_init_dcb(hw, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to init DCB\n");
+	/* Forward LLDP packets to default VSI */
+	ret = ice_vsi_config_sw_lldp(vsi, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to cfg lldp\n");
 	/* register callback func to eal lib */
 	rte_intr_callback_register(intr_handle,
 				   ice_interrupt_handler, dev);
Signature · 1 line
1.8.3.1
#4 lore raw
Quoted 55 lines

-----Original Message-----
From: Ye, Xiaolong
Sent: Saturday, July 27, 2019 11:31 AM
To: Wang, Ying A <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/ice: fix LLDP forward

drivers/net/ice/ice_ethdev.c static int ice_parse_devargs(struct rte_eth_dev

Quoted 22 lines · Wang Ying A

The patch fix the issue that lldp packet can't be forwarded to host.

Fixes 59d151de6673 ("net/ice: stop LLDP by default")

---
---
V2: Remove redundant macro definiton and function argument;
Modify the function name, variables and comments to avoid similarities with kernel code.
---

drivers/net/ice/ice_ethdev.c | 42
+++++++++++++++++++++++++++++++++++++++++-

1 file changed, 41 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/ice/ice_ethdev.c index 08fc9ec..9550aed 100644

drivers/net/ice/ice_ethdev.c +0 -0
@@ -1385,6 +1385,40 @@ static int ice_parse_devargs(struct rte_eth_dev

*dev)

Quoted 7 lines
drivers/net/ice/ice_ethdev.c +4 -0
 	return ret;
 }
 
+/* Forward LLDP packets to default VSI by set switch rules*/ static
+int ice_vsi_config_sw_lldp(struct ice_vsi *vsi,  bool on) {
+	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_fltr_list_entry *s_list_itr = NULL;

drivers/net/ice/ice_ethdev.c static int ice_parse_devargs(struct rte_eth_dev *dev) · line 1403

Quoted 10 lines
drivers/net/ice/ice_ethdev.c +10 -0
+	struct LIST_HEAD_TYPE list_head;
+	int ret = 0;
+
+	INIT_LIST_HEAD(&list_head);
+
+	s_list_itr = (struct ice_fltr_list_entry *)
+			ice_malloc(hw, sizeof(*s_list_itr));
+	if (!s_list_itr) {
+		ret = -ENOMEM;
+		goto DONE;

Here ice_malloc has failed, so you don't need to goto DONE to free it, you can just return -ENOMEM here.

Quoted 3 lines

Thanks,
Xiaolong

OK, will fix it in V3.

Thanks
Ying

Quoted 40 lines

drivers/net/ice/ice_ethdev.c static int ice_parse_devargs(struct rte_eth_dev

Quoted 22 lines
drivers/net/ice/ice_ethdev.c +18 -0
+	}
+	s_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
+	s_list_itr->fltr_info.vsi_handle = vsi->idx;
+	s_list_itr->fltr_info.l_data.ethertype_mac.ethertype =
+			RTE_ETHER_TYPE_LLDP;
+	s_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
+	s_list_itr->fltr_info.flag = ICE_FLTR_RX;
+	s_list_itr->fltr_info.src_id = ICE_SRC_ID_LPORT;
+	LIST_ADD(&s_list_itr->list_entry, &list_head);
+	if (on)
+		ret = ice_add_eth_mac(hw, &list_head);
+	else
+		ret = ice_remove_eth_mac(hw, &list_head);
+DONE:
+	rte_free(s_list_itr);
+	return ret;
+}
+

static int
ice_dev_init(struct rte_eth_dev *dev)
{

drivers/net/ice/ice_ethdev.c +0 -0
@@ -1492,7 +1526,13 @@ static int ice_parse_devargs(struct rte_eth_dev

*dev)

Quoted 17 lines
drivers/net/ice/ice_ethdev.c +7 -2
 	ret = ice_aq_stop_lldp(hw, TRUE, FALSE, NULL);
 	if (ret != ICE_SUCCESS)
 		PMD_INIT_LOG(DEBUG, "lldp has already stopped\n");
-
+	ret = ice_init_dcb(hw, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to init DCB\n");
+	/* Forward LLDP packets to default VSI */
+	ret = ice_vsi_config_sw_lldp(vsi, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to cfg lldp\n");
 	/* register callback func to eal lib */
 	rte_intr_callback_register(intr_handle,
 				   ice_interrupt_handler, dev);
--

1.8.3.1

#5 lore raw

PATCH v3 1/1 net/ice: fix LLDP forward

In reply to Wang Ying A

The patch fix the issue that lldp packet can't be forwarded to host.

Fixes 59d151de6673 ("net/ice: stop LLDP by default")

---
---
V2: Remove redundant macro definiton and rewrite
ice_vsi_config_sw_lldp function.
v3: Fix improper memory free issue.

---
 drivers/net/ice/ice_ethdev.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +39 -1
index 08fc9ec..ea4555a 100644
@@ -1385,6 +1385,38 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* Forward LLDP packets to default VSI by set switch rules */
+static int
+ice_vsi_config_sw_lldp(struct ice_vsi *vsi,  bool on)
+{
+	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_fltr_list_entry *s_list_itr = NULL;
+	struct LIST_HEAD_TYPE list_head;
+	int ret = 0;
+
+	INIT_LIST_HEAD(&list_head);
+
+	s_list_itr = (struct ice_fltr_list_entry *)
+			ice_malloc(hw, sizeof(*s_list_itr));
+	if (!s_list_itr)
+		return -ENOMEM;
+	s_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
+	s_list_itr->fltr_info.vsi_handle = vsi->idx;
+	s_list_itr->fltr_info.l_data.ethertype_mac.ethertype =
+			RTE_ETHER_TYPE_LLDP;
+	s_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
+	s_list_itr->fltr_info.flag = ICE_FLTR_RX;
+	s_list_itr->fltr_info.src_id = ICE_SRC_ID_LPORT;
+	LIST_ADD(&s_list_itr->list_entry, &list_head);
+	if (on)
+		ret = ice_add_eth_mac(hw, &list_head);
+	else
+		ret = ice_remove_eth_mac(hw, &list_head);
+
+	rte_free(s_list_itr);
+	return ret;
+}
+
 static int
 ice_dev_init(struct rte_eth_dev *dev)
 {
@@ -1492,7 +1524,13 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 	ret = ice_aq_stop_lldp(hw, TRUE, FALSE, NULL);
 	if (ret != ICE_SUCCESS)
 		PMD_INIT_LOG(DEBUG, "lldp has already stopped\n");
-
+	ret = ice_init_dcb(hw, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to init DCB\n");
+	/* Forward LLDP packets to default VSI */
+	ret = ice_vsi_config_sw_lldp(vsi, TRUE);
+	if (ret != ICE_SUCCESS)
+		PMD_INIT_LOG(DEBUG, "Failed to cfg lldp\n");
 	/* register callback func to eal lib */
 	rte_intr_callback_register(intr_handle,
 				   ice_interrupt_handler, dev);
Signature · 1 line
1.8.3.1
Acked-by on v3 1/1 Applied
#6 lore raw
Quoted 11 lines

-----Original Message-----
From: Wang, Ying A
Sent: Monday, July 29, 2019 4:42 AM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Ye, Xiaolong <[email protected]>; Yang, Qiming <[email protected]>; Wang, Ying A <[email protected]>; [email protected]
Subject: [PATCH v3] net/ice: fix LLDP forward

Quoted 6 lines

The patch fix the issue that lldp packet can't be forwarded to host.

Fixes 59d151de6673 ("net/ice: stop LLDP by default")

Applied to dpdk-next-net-intel.

Thanks
Qi