From: Shiyang He <shiyangx.he@intel.com>
To: dev@dpdk.org
Cc: yidingx.zhou@intel.com, Shiyang He <shiyangx.he@intel.com>,
Jingjing Wu <jingjing.wu@intel.com>,
Beilei Xing <beilei.xing@intel.com>
Subject: [PATCH v2] net/iavf: fix vf startup coredump
Date: Tue, 2 Jan 2024 09:27:59 +0000 [thread overview]
Message-ID: <20240102092759.8712-1-shiyangx.he@intel.com> (raw)
In-Reply-To: <20231204140940.3166836-1-shiyangx.he@intel.com>
When the vf starts to request multiple queues, the pf sends a reset
command to the vf. During the reset process, adminq sends an abnormal
message to pf for an unknown reason, and the resource request fails
resulting in a coredump.
This patch fixes the issue by checking the reset state before resetting.
v2: fix windows compilation errors
Signed-off-by: Shiyang He <shiyangx.he@intel.com>
---
drivers/net/iavf/iavf.h | 3 ++-
drivers/net/iavf/iavf_ethdev.c | 48 +++++++++++++++++++++++++++-------
2 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..cdf60bd833 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -19,6 +19,7 @@
#define IAVF_AQ_LEN 32
#define IAVF_AQ_BUF_SZ 4096
#define IAVF_RESET_WAIT_CNT 500
+#define IAVF_RESET_DETECTED_CNT 500
#define IAVF_BUF_SIZE_MIN 1024
#define IAVF_FRAME_SIZE_MAX 9728
#define IAVF_QUEUE_BASE_ADDR_UNIT 128
@@ -511,5 +512,5 @@ int iavf_flow_sub_check(struct iavf_adapter *adapter,
struct iavf_fsub_conf *filter);
void iavf_dev_watchdog_enable(struct iavf_adapter *adapter);
void iavf_dev_watchdog_disable(struct iavf_adapter *adapter);
-int iavf_handle_hw_reset(struct rte_eth_dev *dev);
+void iavf_handle_hw_reset(struct rte_eth_dev *dev);
#endif /* _IAVF_ETHDEV_H_ */
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..06b18f2758 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1086,9 +1086,6 @@ iavf_dev_stop(struct rte_eth_dev *dev)
PMD_INIT_FUNC_TRACE();
- if (vf->vf_reset)
- return 0;
-
if (adapter->closed)
return -1;
@@ -2949,7 +2946,6 @@ iavf_dev_reset(struct rte_eth_dev *dev)
{
int ret;
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);
/*
* Check whether the VF reset has been done and inform application,
@@ -2961,7 +2957,6 @@ iavf_dev_reset(struct rte_eth_dev *dev)
PMD_DRV_LOG(ERR, "Wait too long for reset done!\n");
return ret;
}
- vf->vf_reset = false;
PMD_DRV_LOG(DEBUG, "Start dev_reset ...\n");
ret = iavf_dev_uninit(dev);
@@ -2971,15 +2966,47 @@ iavf_dev_reset(struct rte_eth_dev *dev)
return iavf_dev_init(dev);
}
+static inline bool
+iavf_is_reset(struct iavf_hw *hw)
+{
+ return !(IAVF_READ_REG(hw, IAVF_VF_ARQLEN1) &
+ IAVF_VF_ARQLEN1_ARQENABLE_MASK);
+}
+
+static bool
+iavf_is_reset_detected(struct iavf_adapter *adapter)
+{
+ struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
+ int i;
+
+ /* poll until we see the reset actually happen */
+ for (i = 0; i < IAVF_RESET_DETECTED_CNT; i++) {
+ if (iavf_is_reset(hw))
+ return true;
+ rte_delay_ms(20);
+ }
+
+ return false;
+}
+
/*
* Handle hardware reset
*/
-int
+void
iavf_handle_hw_reset(struct rte_eth_dev *dev)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+ struct iavf_adapter *adapter = dev->data->dev_private;
int ret;
+ if (!dev->data->dev_started)
+ return;
+
+ if (!iavf_is_reset_detected(adapter)) {
+ PMD_DRV_LOG(DEBUG, "reset not start\n");
+ return;
+ }
+
vf->in_reset_recovery = true;
ret = iavf_dev_reset(dev);
@@ -2997,15 +3024,16 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev)
ret = iavf_dev_start(dev);
if (ret)
goto error;
- dev->data->dev_started = 1;
+ dev->data->dev_started = 1;
vf->in_reset_recovery = false;
- return 0;
+
+ return;
error:
- PMD_DRV_LOG(DEBUG, "RESET recover with error code=%d\n", ret);
vf->in_reset_recovery = false;
- return ret;
+ iavf_uninit_vf(dev);
+ PMD_DRV_LOG(DEBUG, "failed to reset port %d\n", dev->data->port_id);
}
static int
--
2.34.1
next prev parent reply other threads:[~2024-01-02 2:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 14:09 [PATCH] " Shiyang He
2024-01-02 9:27 ` Shiyang He [this message]
2024-01-03 10:42 ` [PATCH v3] net/iavf: fix VF " Shiyang He
2024-01-03 10:07 ` Zhang, Qi Z
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240102092759.8712-1-shiyangx.he@intel.com \
--to=shiyangx.he@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
--cc=yidingx.zhou@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).