net/iavf: delay VF reset command

Message ID 20240909110356.23757-1-bruce.richardson@intel.com (mailing list archive)
State Accepted
Delegated to: Bruce Richardson
Headers
Series net/iavf: delay VF reset command |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Bruce Richardson Sept. 9, 2024, 11:03 a.m. UTC
Commit 0f9ec0cbd2a9 ("net/iavf: fix VF reset when using DCF"),
introduced a VF-reset adminq call into the reset sequence for iavf.
However, that call was very early in the sequence before other adminq
commands had been sent.

To delay the VF reset, we can put the message sending in the "dev_close"
function, right before the adminq is shut down, and thereby guaranteeing
that we won't have any subsequent issues with adminq messages.

In the process of making this change, we can also use the iavf_vf_reset
function from common/iavf, rather than hard-coding the message sending
lower-level calls in the net driver.

Fixes: e74e1bb6280d ("net/iavf: enable port reset")
Fixes: 0f9ec0cbd2a9 ("net/iavf: fix VF reset when using DCF")
Cc: kaiwenx.deng@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/iavf/iavf_prototype.h |  1 +
 drivers/common/iavf/version.map      |  1 +
 drivers/net/iavf/iavf_ethdev.c       | 12 +-----------
 3 files changed, 3 insertions(+), 11 deletions(-)
  

Comments

Bruce Richardson Sept. 17, 2024, 2:31 p.m. UTC | #1
On Mon, Sep 09, 2024 at 12:03:56PM +0100, Bruce Richardson wrote:
> Commit 0f9ec0cbd2a9 ("net/iavf: fix VF reset when using DCF"),
> introduced a VF-reset adminq call into the reset sequence for iavf.
> However, that call was very early in the sequence before other adminq
> commands had been sent.
> 
> To delay the VF reset, we can put the message sending in the "dev_close"
> function, right before the adminq is shut down, and thereby guaranteeing
> that we won't have any subsequent issues with adminq messages.
> 
> In the process of making this change, we can also use the iavf_vf_reset
> function from common/iavf, rather than hard-coding the message sending
> lower-level calls in the net driver.
> 
> Fixes: e74e1bb6280d ("net/iavf: enable port reset")
> Fixes: 0f9ec0cbd2a9 ("net/iavf: fix VF reset when using DCF")
> Cc: kaiwenx.deng@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
Tested-by: Hongbo Li <hongbox.li@intel.com>

Applied to dpdk-next-net-intel.
  
David Marchand Sept. 20, 2024, 11:01 a.m. UTC | #2
On Mon, Sep 9, 2024 at 1:04 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> Commit 0f9ec0cbd2a9 ("net/iavf: fix VF reset when using DCF"),
> introduced a VF-reset adminq call into the reset sequence for iavf.
> However, that call was very early in the sequence before other adminq
> commands had been sent.
>
> To delay the VF reset, we can put the message sending in the "dev_close"
> function, right before the adminq is shut down, and thereby guaranteeing
> that we won't have any subsequent issues with adminq messages.
>
> In the process of making this change, we can also use the iavf_vf_reset
> function from common/iavf, rather than hard-coding the message sending
> lower-level calls in the net driver.
>
> Fixes: e74e1bb6280d ("net/iavf: enable port reset")
> Fixes: 0f9ec0cbd2a9 ("net/iavf: fix VF reset when using DCF")
> Cc: kaiwenx.deng@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

I see this patch is already merged, but as I was investigating iavf
internals, I remembered this patch and relooked at it.

Sending a reset request to the PF while closing the device seems saner to me.
It also aligns the DPDK iavf driver behavior to the Linux kernel iavf driver.

Reviewed-by: David Marchand <david.marchand@redhat.com>

Thanks Bruce.
  

Patch

diff --git a/drivers/common/iavf/iavf_prototype.h b/drivers/common/iavf/iavf_prototype.h
index ba78ec5169..7c43a817bb 100644
--- a/drivers/common/iavf/iavf_prototype.h
+++ b/drivers/common/iavf/iavf_prototype.h
@@ -79,6 +79,7 @@  STATIC INLINE struct iavf_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype)
 __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 44276dcf38..11036bc179 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2962,6 +2962,7 @@  iavf_dev_close(struct rte_eth_dev *dev)
 	if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
 		iavf_config_promisc(adapter, false, false);
 
+	iavf_vf_reset(hw);
 	iavf_shutdown_adminq(hw);
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
 		/* disable uio intr before callback unregister */
@@ -3041,17 +3042,6 @@  iavf_dev_reset(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
-
-	if (!vf->in_reset_recovery) {
-		ret = iavf_aq_send_msg_to_pf(hw, VIRTCHNL_OP_RESET_VF,
-						IAVF_SUCCESS, NULL, 0, NULL);
-		if (ret) {
-			PMD_DRV_LOG(ERR, "fail to send cmd VIRTCHNL_OP_RESET_VF");
-			return ret;
-		}
-	}
-
 	/*
 	 * Check whether the VF reset has been done and inform application,
 	 * to avoid calling the virtual channel command, which may cause