Skip to contentSkip to conversation

i40e: Fix VF failed to init adminq: -53

PATCH New Mateusz Palczewski 2 participants 2 messages Oct 27, 2021 – Nov 26, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i40e: Fix VF failed to init adminq: -53

From: Norbert Zulinski <[email protected]>

Fix the problem with init adminq in VF reset handler.
When the PF finished reinitialize VF resource set VFR_VFACTIVE bit in VF Reset Status register. It is sign for VF driver among others to shut down and reinitialize the admin queue. VF handle reset procedure is sampling this register to check every 10ms. PF driver give up to 20ms to VF reset procedure. For a single VF reset it is enoungh time to do it but in case request VF reset twice, the first VF reset can be not completely finished when PF requests it one more time.
Fixed by adding additional time for VF to finish reset procedure before sending next VF reset request by PF.

Fixes 5c3c48ac6bf5 ("i40e: implement virtual device interface")
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++++
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h | 2 ++
 2 files changed, 6 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +4 -0
index 5a488ce..ec0e52c 100644
@@ -172,6 +172,9 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf)
 	    !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
 		return;
 
+	if (ktime_get_ns() - vf->reset_timestamp < I40E_VF_RESET_TIME_MIN)
+		usleep_range(30000, 60000);
+
 	abs_vf_id = vf->vf_id + (int)vf->pf->hw.func_caps.vf_base_id;
 
 	pfe.event = VIRTCHNL_EVENT_RESET_IMPENDING;
@@ -1536,6 +1539,7 @@ bool i40e_reset_vf(struct i40e_vf *vf, bool flr)
 	i40e_cleanup_reset_vf(vf);
 
 	i40e_flush(hw);
+	vf->reset_timestamp = ktime_get_ns();
 	clear_bit(__I40E_VF_DISABLE, pf->state);
 
 	return true;
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h +2 -0
index 49575a6..0e7d555 100644
@@ -19,6 +19,7 @@
 #define I40E_MAX_VF_PROMISC_FLAGS	3
 
 #define I40E_VF_STATE_WAIT_COUNT	20
+#define I40E_VF_RESET_TIME_MIN		30000000	// time in nsec
 
 /* Various queue ctrls */
 enum i40e_queue_ctrl {
@@ -80,6 +81,7 @@ struct i40e_vf {
 	u16 port_vlan_id;
 	bool pf_set_mac;	/* The VMM admin set the VF MAC address */
 	bool trusted;
+	u64 reset_timestamp;
 
 	/* VSI indices - actual VSI pointers are maintained in the PF structure
 	 * When assigned, these will be non-zero, because VSI 0 is always
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 i40e: Fix VF failed to init adminq: -53

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Quoted 38 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Mateusz Palczewski
Sent: ?roda, 27 pa?dziernika 2021 14:05
To: intel-wired-lan at lists.osuosl.org
Cc: Palczewski, Mateusz <[email protected]>; Zulinski, NorbertX <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v1] i40e: Fix VF failed to init adminq: -53

From: Norbert Zulinski <[email protected]>

Fix the problem with init adminq in VF reset handler.
When the PF finished reinitialize VF resource set VFR_VFACTIVE bit in VF Reset Status register. It is sign for VF driver among others to shut down and reinitialize the admin queue. VF handle reset procedure is sampling this register to check every 10ms. PF driver give up to 20ms to VF reset procedure. For a single VF reset it is enoungh time to do it but in case request VF reset twice, the first VF reset can be not completely finished when PF requests it one more time.
Fixed by adding additional time for VF to finish reset procedure before sending next VF reset request by PF.

Fixes 5c3c48ac6bf5 ("i40e: implement virtual device interface")
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++++
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h | 2 ++
 2 files changed, 6 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -0
index 5a488ce..ec0e52c 100644