[v2] net/ice: fix LLDP forward

Message ID 1564097763-276974-1-git-send-email-ying.a.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/ice: fix LLDP forward |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Ying Wang July 25, 2019, 11:36 p.m. UTC
  The patch fix the issue that lldp packet can't be forwarded to host.

Fixes: 59d151de6673 ("net/ice: stop LLDP by default")
Cc: stable@dpdk.org

Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
---
---
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(-)
  

Comments

Qiming Yang July 26, 2019, 11:03 p.m. UTC | #1
Hi, Ying

> -----Original Message-----
> From: Wang, Ying A
> Sent: Thursday, July 25, 2019 4:36 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Wang, Ying A
> <ying.a.wang@intel.com>; stable@dpdk.org
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
> ---
> ---
> 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(-)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index
> 08fc9ec..9550aed 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -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?

> +	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
  
Xiaolong Ye July 27, 2019, 3:30 a.m. UTC | #2
On 07/26, Wang Ying A wrote:
>The patch fix the issue that lldp packet can't be forwarded to host.
>
>Fixes: 59d151de6673 ("net/ice: stop LLDP by default")
>Cc: stable@dpdk.org
>
>Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
>---
>---
>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(-)
>
>diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
>index 08fc9ec..9550aed 100644
>--- a/drivers/net/ice/ice_ethdev.c
>+++ b/drivers/net/ice/ice_ethdev.c
>@@ -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;

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

Thanks,
Xiaolong

>+	}
>+	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
>
  
Ying Wang July 29, 2019, 12:45 a.m. UTC | #3
> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Saturday, July 27, 2019 11:31 AM
> To: Wang, Ying A <ying.a.wang@intel.com>
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; dev@dpdk.org; Yang, Qiming
> <qiming.yang@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] net/ice: fix LLDP forward
> 
> On 07/26, Wang Ying A wrote:
> >The patch fix the issue that lldp packet can't be forwarded to host.
> >
> >Fixes: 59d151de6673 ("net/ice: stop LLDP by default")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Wang Ying A <ying.a.wang@intel.com>
> >---
> >---
> >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(-)
> >
> >diff --git a/drivers/net/ice/ice_ethdev.c
> >b/drivers/net/ice/ice_ethdev.c index 08fc9ec..9550aed 100644
> >--- a/drivers/net/ice/ice_ethdev.c
> >+++ b/drivers/net/ice/ice_ethdev.c
> >@@ -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;
> 
> Here ice_malloc has failed, so you don't need to goto DONE to free it, you can
> just return -ENOMEM here.
> 
> Thanks,
> Xiaolong
> 

OK, will fix it in V3.

Thanks
Ying


> >+	}
> >+	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
> >
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 08fc9ec..9550aed 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -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);