DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] net/iavf: fix reset VF doesn't notify PF to reset
@ 2020-11-05  8:32 Steve Yang
  2020-11-06  2:58 ` Xing, Beilei
  2020-11-09  6:51 ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
  0 siblings, 2 replies; 12+ messages in thread
From: Steve Yang @ 2020-11-05  8:32 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, jingjing.wu, Steve Yang

When VF closed, the VF should notify PF to close/reset relative
resources from PF side.

Check the VF RSS offload flag and ignore relative operation when
iavf hash uninit to avoid reset/close error.

Fixes: 22b123a36d07 ("net/avf: initialize PMD")

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/common/iavf/iavf_prototype.h |  1 +
 drivers/common/iavf/version.map      |  1 +
 drivers/net/iavf/iavf_ethdev.c       | 48 +++++++++++++++++++++++++++-
 drivers/net/iavf/iavf_hash.c         |  9 ++++--
 4 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/drivers/common/iavf/iavf_prototype.h b/drivers/common/iavf/iavf_prototype.h
index f34e77db0f..3998d26dc0 100644
--- a/drivers/common/iavf/iavf_prototype.h
+++ b/drivers/common/iavf/iavf_prototype.h
@@ -83,6 +83,7 @@ void iavf_destroy_spinlock(struct iavf_spinlock *sp);
 __rte_internal
 void iavf_vf_parse_hw_config(struct iavf_hw *hw,
 			     struct virtchnl_vf_resource *msg);
+__rte_internal
 enum iavf_status iavf_vf_reset(struct iavf_hw *hw);
 __rte_internal
 enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
diff --git a/drivers/common/iavf/version.map b/drivers/common/iavf/version.map
index e0f117197c..6c1427cca4 100644
--- a/drivers/common/iavf/version.map
+++ b/drivers/common/iavf/version.map
@@ -7,6 +7,7 @@ INTERNAL {
 	iavf_set_mac_type;
 	iavf_shutdown_adminq;
 	iavf_vf_parse_hw_config;
+	iavf_vf_reset;
 
 	local: *;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 7e3c26a94e..e2498a184e 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1780,6 +1780,34 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)
 	}
 }
 
+static int
+iavf_reset_vf(struct iavf_hw *hw)
+{
+	int ret;
+	if (iavf_vf_reset(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "Reset VF NIC failed");
+		return -1;
+	}
+	/**
+	 * After issuing vf reset command to pf, pf won't necessarily
+	 * reset vf, it depends on what state it exactly is. If it's not
+	 * initialized yet, it won't have vf reset since it's in a certain
+	 * state. If not, it will try to reset. Even vf is reset, pf will
+	 * set I40E_VFGEN_RSTAT to COMPLETE first, then wait 10ms and set
+	 * it to ACTIVE. In this duration, vf may not catch the moment that
+	 * COMPLETE is set. So, for vf, we'll try to wait a long time.
+	 */
+	rte_delay_ms(200);
+
+	ret = iavf_check_vf_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "VF is still resetting");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 iavf_init_vf(struct rte_eth_dev *dev)
 {
@@ -1814,6 +1842,24 @@ iavf_init_vf(struct rte_eth_dev *dev)
 		goto err;
 	}
 
+	/* Reset VF and wait until it's complete */
+	if (iavf_reset_vf(hw)) {
+		PMD_INIT_LOG(ERR, "reset NIC failed");
+		goto err_aq;
+	}
+
+	/* VF reset, shutdown admin queue and initialize again */
+	if (iavf_shutdown_adminq(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "iavf_shutdown_adminq failed");
+		goto err;
+	}
+
+	iavf_init_adminq_parameter(hw);
+	if (iavf_init_adminq(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "init_adminq failed");
+		goto err;
+	}
+
 	vf->aq_resp = rte_zmalloc("vf_aq_resp", IAVF_AQ_BUF_SZ, 0);
 	if (!vf->aq_resp) {
 		PMD_INIT_LOG(ERR, "unable to allocate vf_aq_resp memory");
@@ -2050,7 +2096,7 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
-
+	iavf_reset_vf(hw);
 	/*
 	 * disable promiscuous mode before reset vf
 	 * it is a workaround solution when work with kernel driver
diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index 8a5a6bb5a4..d3e9218f75 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -1093,10 +1093,13 @@ iavf_hash_uninit(struct iavf_adapter *ad)
 	if (vf->vf_reset)
 		return;
 
-	if (iavf_hash_default_set(ad, false))
-		PMD_DRV_LOG(ERR, "fail to delete default RSS");
+	if (vf->vf_res &&
+	    vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF) {
+		if (iavf_hash_default_set(ad, false))
+			PMD_DRV_LOG(ERR, "fail to delete default RSS");
 
-	iavf_unregister_parser(&iavf_hash_parser, ad);
+		iavf_unregister_parser(&iavf_hash_parser, ad);
+	}
 }
 
 static void
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH v1] net/iavf: fix reset VF doesn't notify PF to reset
  2020-11-05  8:32 [dpdk-dev] [PATCH v1] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
@ 2020-11-06  2:58 ` Xing, Beilei
  2020-11-09  6:51 ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
  1 sibling, 0 replies; 12+ messages in thread
From: Xing, Beilei @ 2020-11-06  2:58 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming, Wu, Jingjing, Yang, SteveX



> -----Original Message-----
> From: Steve Yang <stevex.yang@intel.com>
> Sent: Thursday, November 5, 2020 4:32 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Yang, SteveX
> <stevex.yang@intel.com>
> Subject: [PATCH v1] net/iavf: fix reset VF doesn't notify PF to reset
> 
> When VF closed, the VF should notify PF to close/reset relative resources from
> PF side.
> 
> Check the VF RSS offload flag and ignore relative operation when iavf hash
> uninit to avoid reset/close error.

Seems there're 2 bug fix in the patch, it's better to split.
Is the fix ported from i40evf?
For vf_reset, I think there's another patch needed backport: commit 0eaa1f8c75311b96d269a0195b80e80d6c27e83c

> 
> Fixes: 22b123a36d07 ("net/avf: initialize PMD")
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>
> ---
>  drivers/common/iavf/iavf_prototype.h |  1 +
>  drivers/common/iavf/version.map      |  1 +
>  drivers/net/iavf/iavf_ethdev.c       | 48 +++++++++++++++++++++++++++-
>  drivers/net/iavf/iavf_hash.c         |  9 ++++--
>  4 files changed, 55 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/common/iavf/iavf_prototype.h
> b/drivers/common/iavf/iavf_prototype.h
> index f34e77db0f..3998d26dc0 100644
> --- a/drivers/common/iavf/iavf_prototype.h
> +++ b/drivers/common/iavf/iavf_prototype.h
> @@ -83,6 +83,7 @@ void iavf_destroy_spinlock(struct iavf_spinlock *sp);
> __rte_internal  void iavf_vf_parse_hw_config(struct iavf_hw *hw,
>  			     struct virtchnl_vf_resource *msg);
> +__rte_internal
>  enum iavf_status iavf_vf_reset(struct iavf_hw *hw);  __rte_internal  enum
> iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw, diff --git
> a/drivers/common/iavf/version.map b/drivers/common/iavf/version.map
> index e0f117197c..6c1427cca4 100644
> --- a/drivers/common/iavf/version.map
> +++ b/drivers/common/iavf/version.map
> @@ -7,6 +7,7 @@ INTERNAL {
>  	iavf_set_mac_type;
>  	iavf_shutdown_adminq;
>  	iavf_vf_parse_hw_config;
> +	iavf_vf_reset;
> 
>  	local: *;
>  };
> diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
> index 7e3c26a94e..e2498a184e 100644
> --- a/drivers/net/iavf/iavf_ethdev.c
> +++ b/drivers/net/iavf/iavf_ethdev.c
> @@ -1780,6 +1780,34 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)
>  	}
>  }
> 
> +static int
> +iavf_reset_vf(struct iavf_hw *hw)
> +{
> +	int ret;
> +	if (iavf_vf_reset(hw) != IAVF_SUCCESS) {
> +		PMD_INIT_LOG(ERR, "Reset VF NIC failed");
> +		return -1;
> +	}
> +	/**
> +	 * After issuing vf reset command to pf, pf won't necessarily
> +	 * reset vf, it depends on what state it exactly is. If it's not
> +	 * initialized yet, it won't have vf reset since it's in a certain
> +	 * state. If not, it will try to reset. Even vf is reset, pf will
> +	 * set I40E_VFGEN_RSTAT to COMPLETE first, then wait 10ms and set
> +	 * it to ACTIVE. In this duration, vf may not catch the moment that
> +	 * COMPLETE is set. So, for vf, we'll try to wait a long time.
> +	 */
> +	rte_delay_ms(200);
> +
> +	ret = iavf_check_vf_reset_done(hw);
> +	if (ret) {
> +		PMD_INIT_LOG(ERR, "VF is still resetting");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int
>  iavf_init_vf(struct rte_eth_dev *dev)
>  {
> @@ -1814,6 +1842,24 @@ iavf_init_vf(struct rte_eth_dev *dev)
>  		goto err;
>  	}
> 
> +	/* Reset VF and wait until it's complete */
> +	if (iavf_reset_vf(hw)) {
> +		PMD_INIT_LOG(ERR, "reset NIC failed");
> +		goto err_aq;
> +	}
> +
> +	/* VF reset, shutdown admin queue and initialize again */
> +	if (iavf_shutdown_adminq(hw) != IAVF_SUCCESS) {
> +		PMD_INIT_LOG(ERR, "iavf_shutdown_adminq failed");
> +		goto err;
> +	}
> +
> +	iavf_init_adminq_parameter(hw);
> +	if (iavf_init_adminq(hw) != IAVF_SUCCESS) {
> +		PMD_INIT_LOG(ERR, "init_adminq failed");
> +		goto err;
> +	}
> +
>  	vf->aq_resp = rte_zmalloc("vf_aq_resp", IAVF_AQ_BUF_SZ, 0);
>  	if (!vf->aq_resp) {
>  		PMD_INIT_LOG(ERR, "unable to allocate vf_aq_resp memory");
> @@ -2050,7 +2096,7 @@ iavf_dev_close(struct rte_eth_dev *dev)
> 
>  	iavf_flow_flush(dev, NULL);
>  	iavf_flow_uninit(adapter);
> -
> +	iavf_reset_vf(hw);
>  	/*
>  	 * disable promiscuous mode before reset vf
>  	 * it is a workaround solution when work with kernel driver diff --git
> a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c index
> 8a5a6bb5a4..d3e9218f75 100644
> --- a/drivers/net/iavf/iavf_hash.c
> +++ b/drivers/net/iavf/iavf_hash.c
> @@ -1093,10 +1093,13 @@ iavf_hash_uninit(struct iavf_adapter *ad)
>  	if (vf->vf_reset)
>  		return;
> 
> -	if (iavf_hash_default_set(ad, false))
> -		PMD_DRV_LOG(ERR, "fail to delete default RSS");
> +	if (vf->vf_res &&
> +	    vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF) {
> +		if (iavf_hash_default_set(ad, false))
> +			PMD_DRV_LOG(ERR, "fail to delete default RSS");
> 
> -	iavf_unregister_parser(&iavf_hash_parser, ad);
> +		iavf_unregister_parser(&iavf_hash_parser, ad);
> +	}
>  }
> 
>  static void
> --
> 2.17.1


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

* [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf
  2020-11-05  8:32 [dpdk-dev] [PATCH v1] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
  2020-11-06  2:58 ` Xing, Beilei
@ 2020-11-09  6:51 ` Steve Yang
  2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
                     ` (2 more replies)
  1 sibling, 3 replies; 12+ messages in thread
From: Steve Yang @ 2020-11-09  6:51 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, jingjing.wu, Steve Yang

When VF closed, the VF should notify PF to close/reset relative
resources from PF side.

Check the VF RSS offload flag and ignore relative operation when
iavf hash uninit to avoid reset/close error.

---
v2:
 * split to 2 patches;
 * added patch backport: commit 0eaa1f8c75

Steve Yang (2):
  net/iavf: fix reset VF doesn't notify PF to reset
  net/iavf: fix the RSS error when VF port closed

 drivers/common/iavf/iavf_prototype.h |  1 +
 drivers/common/iavf/version.map      |  1 +
 drivers/net/iavf/iavf_ethdev.c       | 57 ++++++++++++++++++++++++++--
 drivers/net/iavf/iavf_hash.c         |  9 +++--
 4 files changed, 62 insertions(+), 6 deletions(-)

-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset
  2020-11-09  6:51 ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
@ 2020-11-09  6:51   ` Steve Yang
  2020-11-10  5:56     ` Xing, Beilei
  2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
  2020-11-13  0:46   ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
  2 siblings, 1 reply; 12+ messages in thread
From: Steve Yang @ 2020-11-09  6:51 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, jingjing.wu, Steve Yang

When VF closed, the VF should notify PF to close/reset relative
resources from PF side.

Fixes: 22b123a36d07 ("net/avf: initialize PMD")

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/common/iavf/iavf_prototype.h |  1 +
 drivers/common/iavf/version.map      |  1 +
 drivers/net/iavf/iavf_ethdev.c       | 57 ++++++++++++++++++++++++++--
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/common/iavf/iavf_prototype.h b/drivers/common/iavf/iavf_prototype.h
index f34e77db0f..3998d26dc0 100644
--- a/drivers/common/iavf/iavf_prototype.h
+++ b/drivers/common/iavf/iavf_prototype.h
@@ -83,6 +83,7 @@ void iavf_destroy_spinlock(struct iavf_spinlock *sp);
 __rte_internal
 void iavf_vf_parse_hw_config(struct iavf_hw *hw,
 			     struct virtchnl_vf_resource *msg);
+__rte_internal
 enum iavf_status iavf_vf_reset(struct iavf_hw *hw);
 __rte_internal
 enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
diff --git a/drivers/common/iavf/version.map b/drivers/common/iavf/version.map
index e0f117197c..6c1427cca4 100644
--- a/drivers/common/iavf/version.map
+++ b/drivers/common/iavf/version.map
@@ -7,6 +7,7 @@ INTERNAL {
 	iavf_set_mac_type;
 	iavf_shutdown_adminq;
 	iavf_vf_parse_hw_config;
+	iavf_vf_reset;
 
 	local: *;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 7e3c26a94e..510adc5f6b 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1417,8 +1417,10 @@ iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 }
 
 static int
-iavf_check_vf_reset_done(struct iavf_hw *hw)
+iavf_check_vf_reset_done(struct rte_eth_dev *dev)
 {
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	int i, reset;
 
 	for (i = 0; i < IAVF_RESET_WAIT_CNT; i++) {
@@ -1434,6 +1436,7 @@ iavf_check_vf_reset_done(struct iavf_hw *hw)
 	if (i >= IAVF_RESET_WAIT_CNT)
 		return -1;
 
+	vf->vf_reset = false;
 	return 0;
 }
 
@@ -1780,6 +1783,36 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)
 	}
 }
 
+static int
+iavf_reset_vf(struct rte_eth_dev *dev)
+{
+	struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int ret;
+
+	if (iavf_vf_reset(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "Reset VF NIC failed");
+		return -1;
+	}
+	/**
+	 * After issuing vf reset command to pf, pf won't necessarily
+	 * reset vf, it depends on what state it exactly is. If it's not
+	 * initialized yet, it won't have vf reset since it's in a certain
+	 * state. If not, it will try to reset. Even vf is reset, pf will
+	 * set I40E_VFGEN_RSTAT to COMPLETE first, then wait 10ms and set
+	 * it to ACTIVE. In this duration, vf may not catch the moment that
+	 * COMPLETE is set. So, for vf, we'll try to wait a long time.
+	 */
+	rte_delay_ms(200);
+
+	ret = iavf_check_vf_reset_done(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "VF is still resetting");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 iavf_init_vf(struct rte_eth_dev *dev)
 {
@@ -1801,7 +1834,7 @@ iavf_init_vf(struct rte_eth_dev *dev)
 		goto err;
 	}
 
-	err = iavf_check_vf_reset_done(hw);
+	err = iavf_check_vf_reset_done(dev);
 	if (err) {
 		PMD_INIT_LOG(ERR, "VF is still resetting");
 		goto err;
@@ -1814,6 +1847,24 @@ iavf_init_vf(struct rte_eth_dev *dev)
 		goto err;
 	}
 
+	/* Reset VF and wait until it's complete */
+	if (iavf_reset_vf(dev)) {
+		PMD_INIT_LOG(ERR, "reset NIC failed");
+		goto err_aq;
+	}
+
+	/* VF reset, shutdown admin queue and initialize again */
+	if (iavf_shutdown_adminq(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "iavf_shutdown_adminq failed");
+		goto err;
+	}
+
+	iavf_init_adminq_parameter(hw);
+	if (iavf_init_adminq(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "init_adminq failed");
+		goto err;
+	}
+
 	vf->aq_resp = rte_zmalloc("vf_aq_resp", IAVF_AQ_BUF_SZ, 0);
 	if (!vf->aq_resp) {
 		PMD_INIT_LOG(ERR, "unable to allocate vf_aq_resp memory");
@@ -2050,7 +2101,7 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
-
+	iavf_reset_vf(dev);
 	/*
 	 * disable promiscuous mode before reset vf
 	 * it is a workaround solution when work with kernel driver
-- 
2.17.1


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

* [dpdk-dev] [PATCH v2 2/2] net/iavf: fix the RSS error when VF port closed
  2020-11-09  6:51 ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
  2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
@ 2020-11-09  6:51   ` Steve Yang
  2020-11-12 11:47     ` Zhang, Qi Z
  2020-11-13  0:46   ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
  2 siblings, 1 reply; 12+ messages in thread
From: Steve Yang @ 2020-11-09  6:51 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, jingjing.wu, Steve Yang

Check the VF RSS offload flag and ignore relative operation when
iavf hash uninit to avoid reset/close error.

Fixes: 7be10c3004be ("net/iavf: add RSS configuration for VF")

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/net/iavf/iavf_hash.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index 8a5a6bb5a4..d3e9218f75 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -1093,10 +1093,13 @@ iavf_hash_uninit(struct iavf_adapter *ad)
 	if (vf->vf_reset)
 		return;
 
-	if (iavf_hash_default_set(ad, false))
-		PMD_DRV_LOG(ERR, "fail to delete default RSS");
+	if (vf->vf_res &&
+	    vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF) {
+		if (iavf_hash_default_set(ad, false))
+			PMD_DRV_LOG(ERR, "fail to delete default RSS");
 
-	iavf_unregister_parser(&iavf_hash_parser, ad);
+		iavf_unregister_parser(&iavf_hash_parser, ad);
+	}
 }
 
 static void
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset
  2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
@ 2020-11-10  5:56     ` Xing, Beilei
  0 siblings, 0 replies; 12+ messages in thread
From: Xing, Beilei @ 2020-11-10  5:56 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming, Wu, Jingjing, Yang, SteveX



> -----Original Message-----
> From: Steve Yang <stevex.yang@intel.com>
> Sent: Monday, November 9, 2020 2:52 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Yang, SteveX
> <stevex.yang@intel.com>
> Subject: [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset
> 
> When VF closed, the VF should notify PF to close/reset relative resources from
> PF side.

The commit log and title should be refined since this patch includes ' notify PF to reset '
and 'clear VF reset flag', right?
If it's hard to summarize, it's better to split.

> 
> Fixes: 22b123a36d07 ("net/avf: initialize PMD")
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>

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

* Re: [dpdk-dev] [PATCH v2 2/2] net/iavf: fix the RSS error when VF port closed
  2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
@ 2020-11-12 11:47     ` Zhang, Qi Z
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang, Qi Z @ 2020-11-12 11:47 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming, Xing, Beilei, Wu, Jingjing, Yang, SteveX



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Steve Yang
> Sent: Monday, November 9, 2020 2:52 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Yang, SteveX
> <stevex.yang@intel.com>
> Subject: [dpdk-dev] [PATCH v2 2/2] net/iavf: fix the RSS error when VF port
> closed
> 
> Check the VF RSS offload flag and ignore relative operation when iavf hash
> uninit to avoid reset/close error.
> 
> Fixes: 7be10c3004be ("net/iavf: add RSS configuration for VF")
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>
> ---
>  drivers/net/iavf/iavf_hash.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c index
> 8a5a6bb5a4..d3e9218f75 100644
> --- a/drivers/net/iavf/iavf_hash.c
> +++ b/drivers/net/iavf/iavf_hash.c
> @@ -1093,10 +1093,13 @@ iavf_hash_uninit(struct iavf_adapter *ad)
>  	if (vf->vf_reset)
>  		return;
> 
> -	if (iavf_hash_default_set(ad, false))
> -		PMD_DRV_LOG(ERR, "fail to delete default RSS");
> +	if (vf->vf_res &&
> +	    vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF) {
> +		if (iavf_hash_default_set(ad, false))
> +			PMD_DRV_LOG(ERR, "fail to delete default RSS");

Better to follow the same pattern in ice_hash_init, return immediate when check something wrong.

> 
> -	iavf_unregister_parser(&iavf_hash_parser, ad);
> +		iavf_unregister_parser(&iavf_hash_parser, ad);
> +	}
>  }
> 
>  static void
> --
> 2.17.1


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

* [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf
  2020-11-09  6:51 ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
  2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
  2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
@ 2020-11-13  0:46   ` Steve Yang
  2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
  2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
  2 siblings, 2 replies; 12+ messages in thread
From: Steve Yang @ 2020-11-13  0:46 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, jingjing.wu, qi.z.zhang, Steve Yang

When VF closed, the VF should notify PF to close/reset relative
resources from PF side.

Check the VF RSS offload flag and ignore relative operation when
iavf hash uninit to avoid reset/close error.

---
v3:
 * changed code pattern for 'ice_hash_uninit'.
v2:
 * split to 2 patches;
 * added patch backport: commit 0eaa1f8c75

Steve Yang (2):
  net/iavf: fix reset VF doesn't notify PF to reset
  net/iavf: fix the RSS error when VF port closed

 drivers/common/iavf/iavf_prototype.h |  1 +
 drivers/common/iavf/version.map      |  1 +
 drivers/net/iavf/iavf_ethdev.c       | 57 ++++++++++++++++++++++++++--
 drivers/net/iavf/iavf_hash.c         |  6 +++
 4 files changed, 62 insertions(+), 3 deletions(-)

-- 
2.17.1


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

* [dpdk-dev] [PATCH v3 1/2] net/iavf: fix reset VF doesn't notify PF to reset
  2020-11-13  0:46   ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
@ 2020-11-13  0:46     ` Steve Yang
  2020-11-13  7:45       ` Xing, Beilei
  2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
  1 sibling, 1 reply; 12+ messages in thread
From: Steve Yang @ 2020-11-13  0:46 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, jingjing.wu, qi.z.zhang, Steve Yang

When VF closed, the VF should notify PF to close/reset relative
resources from PF side.

Fixes: 22b123a36d07 ("net/avf: initialize PMD")

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/common/iavf/iavf_prototype.h |  1 +
 drivers/common/iavf/version.map      |  1 +
 drivers/net/iavf/iavf_ethdev.c       | 57 ++++++++++++++++++++++++++--
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/common/iavf/iavf_prototype.h b/drivers/common/iavf/iavf_prototype.h
index f34e77db0f..3998d26dc0 100644
--- a/drivers/common/iavf/iavf_prototype.h
+++ b/drivers/common/iavf/iavf_prototype.h
@@ -83,6 +83,7 @@ void iavf_destroy_spinlock(struct iavf_spinlock *sp);
 __rte_internal
 void iavf_vf_parse_hw_config(struct iavf_hw *hw,
 			     struct virtchnl_vf_resource *msg);
+__rte_internal
 enum iavf_status iavf_vf_reset(struct iavf_hw *hw);
 __rte_internal
 enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
diff --git a/drivers/common/iavf/version.map b/drivers/common/iavf/version.map
index e0f117197c..6c1427cca4 100644
--- a/drivers/common/iavf/version.map
+++ b/drivers/common/iavf/version.map
@@ -7,6 +7,7 @@ INTERNAL {
 	iavf_set_mac_type;
 	iavf_shutdown_adminq;
 	iavf_vf_parse_hw_config;
+	iavf_vf_reset;
 
 	local: *;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 7e3c26a94e..510adc5f6b 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1417,8 +1417,10 @@ iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 }
 
 static int
-iavf_check_vf_reset_done(struct iavf_hw *hw)
+iavf_check_vf_reset_done(struct rte_eth_dev *dev)
 {
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	int i, reset;
 
 	for (i = 0; i < IAVF_RESET_WAIT_CNT; i++) {
@@ -1434,6 +1436,7 @@ iavf_check_vf_reset_done(struct iavf_hw *hw)
 	if (i >= IAVF_RESET_WAIT_CNT)
 		return -1;
 
+	vf->vf_reset = false;
 	return 0;
 }
 
@@ -1780,6 +1783,36 @@ iavf_init_proto_xtr(struct rte_eth_dev *dev)
 	}
 }
 
+static int
+iavf_reset_vf(struct rte_eth_dev *dev)
+{
+	struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int ret;
+
+	if (iavf_vf_reset(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "Reset VF NIC failed");
+		return -1;
+	}
+	/**
+	 * After issuing vf reset command to pf, pf won't necessarily
+	 * reset vf, it depends on what state it exactly is. If it's not
+	 * initialized yet, it won't have vf reset since it's in a certain
+	 * state. If not, it will try to reset. Even vf is reset, pf will
+	 * set I40E_VFGEN_RSTAT to COMPLETE first, then wait 10ms and set
+	 * it to ACTIVE. In this duration, vf may not catch the moment that
+	 * COMPLETE is set. So, for vf, we'll try to wait a long time.
+	 */
+	rte_delay_ms(200);
+
+	ret = iavf_check_vf_reset_done(dev);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "VF is still resetting");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 iavf_init_vf(struct rte_eth_dev *dev)
 {
@@ -1801,7 +1834,7 @@ iavf_init_vf(struct rte_eth_dev *dev)
 		goto err;
 	}
 
-	err = iavf_check_vf_reset_done(hw);
+	err = iavf_check_vf_reset_done(dev);
 	if (err) {
 		PMD_INIT_LOG(ERR, "VF is still resetting");
 		goto err;
@@ -1814,6 +1847,24 @@ iavf_init_vf(struct rte_eth_dev *dev)
 		goto err;
 	}
 
+	/* Reset VF and wait until it's complete */
+	if (iavf_reset_vf(dev)) {
+		PMD_INIT_LOG(ERR, "reset NIC failed");
+		goto err_aq;
+	}
+
+	/* VF reset, shutdown admin queue and initialize again */
+	if (iavf_shutdown_adminq(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "iavf_shutdown_adminq failed");
+		goto err;
+	}
+
+	iavf_init_adminq_parameter(hw);
+	if (iavf_init_adminq(hw) != IAVF_SUCCESS) {
+		PMD_INIT_LOG(ERR, "init_adminq failed");
+		goto err;
+	}
+
 	vf->aq_resp = rte_zmalloc("vf_aq_resp", IAVF_AQ_BUF_SZ, 0);
 	if (!vf->aq_resp) {
 		PMD_INIT_LOG(ERR, "unable to allocate vf_aq_resp memory");
@@ -2050,7 +2101,7 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
-
+	iavf_reset_vf(dev);
 	/*
 	 * disable promiscuous mode before reset vf
 	 * it is a workaround solution when work with kernel driver
-- 
2.17.1


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

* [dpdk-dev] [PATCH v3 2/2] net/iavf: fix the RSS error when VF port closed
  2020-11-13  0:46   ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
  2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
@ 2020-11-13  0:46     ` Steve Yang
  2020-11-13  5:38       ` Zhang, Qi Z
  1 sibling, 1 reply; 12+ messages in thread
From: Steve Yang @ 2020-11-13  0:46 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, beilei.xing, jingjing.wu, qi.z.zhang, Steve Yang

Check the VF RSS offload flag and ignore relative operation when
iavf hash uninit to avoid reset/close error.

Fixes: 7be10c3004be ("net/iavf: add RSS configuration for VF")

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/net/iavf/iavf_hash.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index 8a5a6bb5a4..c4c73e6644 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -1093,6 +1093,12 @@ iavf_hash_uninit(struct iavf_adapter *ad)
 	if (vf->vf_reset)
 		return;
 
+	if (!vf->vf_res)
+		return;
+
+	if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF))
+		return;
+
 	if (iavf_hash_default_set(ad, false))
 		PMD_DRV_LOG(ERR, "fail to delete default RSS");
 
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH v3 2/2] net/iavf: fix the RSS error when VF port closed
  2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
@ 2020-11-13  5:38       ` Zhang, Qi Z
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang, Qi Z @ 2020-11-13  5:38 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming, Xing, Beilei, Wu, Jingjing, Yang, SteveX



> -----Original Message-----
> From: Steve Yang <stevex.yang@intel.com>
> Sent: Friday, November 13, 2020 8:47 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v3 2/2] net/iavf: fix the RSS error when VF port closed
> 
> Check the VF RSS offload flag and ignore relative operation when iavf hash
> uninit to avoid reset/close error.
> 
> Fixes: 7be10c3004be ("net/iavf: add RSS configuration for VF")
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi

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

* Re: [dpdk-dev] [PATCH v3 1/2] net/iavf: fix reset VF doesn't notify PF to reset
  2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
@ 2020-11-13  7:45       ` Xing, Beilei
  0 siblings, 0 replies; 12+ messages in thread
From: Xing, Beilei @ 2020-11-13  7:45 UTC (permalink / raw)
  To: Yang, SteveX, dev; +Cc: Yang, Qiming, Wu, Jingjing, Zhang, Qi Z, Yang, SteveX



> -----Original Message-----
> From: Steve Yang <stevex.yang@intel.com>
> Sent: Friday, November 13, 2020 8:47 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v3 1/2] net/iavf: fix reset VF doesn't notify PF to reset
> 
> When VF closed, the VF should notify PF to close/reset relative resources from
> PF side.
> 
> Fixes: 22b123a36d07 ("net/avf: initialize PMD")
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>

No need this patch since there'll be PCI reset during VF init/close.
So nack it.

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

end of thread, other threads:[~2020-11-13  7:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05  8:32 [dpdk-dev] [PATCH v1] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
2020-11-06  2:58 ` Xing, Beilei
2020-11-09  6:51 ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
2020-11-10  5:56     ` Xing, Beilei
2020-11-09  6:51   ` [dpdk-dev] [PATCH v2 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
2020-11-12 11:47     ` Zhang, Qi Z
2020-11-13  0:46   ` [dpdk-dev] [PATCH v2 0/2] net/iavf: backported bug fixes from i40evf to iavf Steve Yang
2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 1/2] net/iavf: fix reset VF doesn't notify PF to reset Steve Yang
2020-11-13  7:45       ` Xing, Beilei
2020-11-13  0:46     ` [dpdk-dev] [PATCH v3 2/2] net/iavf: fix the RSS error when VF port closed Steve Yang
2020-11-13  5:38       ` Zhang, Qi Z

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git