Skip to content

Commit dda9c9b

Browse files
DawidWesierski4gregkh
authored andcommitted
ice: Fix ice VF reset during iavf initialization
[ Upstream commit 7255355 ] Fix the current implementation that causes ice_trigger_vf_reset() to start resetting the VF even when the VF-NIC is still initializing. When we reset NIC with ice driver it can interfere with iavf-vf initialization e.g. during consecutive resets induced by ice iavf ice | | |<-----------------| | ice resets vf iavf | reset | start | |<-----------------| | ice resets vf | causing iavf | initialization | error | | iavf reset end This leads to a series of -53 errors (failed to init adminq) from the IAVF. Change the state of the vf_state field to be not active when the IAVF is still initializing. Make sure to wait until receiving the message on the message box to ensure that the vf is ready and initializded. In simple terms we use the ACTIVE flag to make sure that the ice driver knows if the iavf is ready for another reset iavf ice | | | | |<------------- ice resets vf iavf vf_state != ACTIVE reset | start | | | | | iavf | reset-------> vf_state == ACTIVE end ice resets vf | | | | Fixes: c54d209 ("ice: Wait for VF to be reset/ready before configuration") Signed-off-by: Dawid Wesierski <dawidx.wesierski@intel.com> Signed-off-by: Kamil Maziarz <kamil.maziarz@intel.com> Acked-by: Jacob Keller <Jacob.e.keller@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f181d79 commit dda9c9b

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

drivers/net/ethernet/intel/ice/ice_sriov.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena)
12401240
if (!vf)
12411241
return -EINVAL;
12421242

1243-
ret = ice_check_vf_ready_for_cfg(vf);
1243+
ret = ice_check_vf_ready_for_reset(vf);
12441244
if (ret)
12451245
goto out_put_vf;
12461246

@@ -1355,7 +1355,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
13551355
goto out_put_vf;
13561356
}
13571357

1358-
ret = ice_check_vf_ready_for_cfg(vf);
1358+
ret = ice_check_vf_ready_for_reset(vf);
13591359
if (ret)
13601360
goto out_put_vf;
13611361

@@ -1409,7 +1409,7 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)
14091409
return -EOPNOTSUPP;
14101410
}
14111411

1412-
ret = ice_check_vf_ready_for_cfg(vf);
1412+
ret = ice_check_vf_ready_for_reset(vf);
14131413
if (ret)
14141414
goto out_put_vf;
14151415

@@ -1722,7 +1722,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
17221722
if (!vf)
17231723
return -EINVAL;
17241724

1725-
ret = ice_check_vf_ready_for_cfg(vf);
1725+
ret = ice_check_vf_ready_for_reset(vf);
17261726
if (ret)
17271727
goto out_put_vf;
17281728

drivers/net/ethernet/intel/ice/ice_vf_lib.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ int ice_check_vf_ready_for_cfg(struct ice_vf *vf)
185185
return 0;
186186
}
187187

188+
/**
189+
* ice_check_vf_ready_for_reset - check if VF is ready to be reset
190+
* @vf: VF to check if it's ready to be reset
191+
*
192+
* The purpose of this function is to ensure that the VF is not in reset,
193+
* disabled, and is both initialized and active, thus enabling us to safely
194+
* initialize another reset.
195+
*/
196+
int ice_check_vf_ready_for_reset(struct ice_vf *vf)
197+
{
198+
int ret;
199+
200+
ret = ice_check_vf_ready_for_cfg(vf);
201+
if (!ret && !test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
202+
ret = -EAGAIN;
203+
204+
return ret;
205+
}
206+
188207
/**
189208
* ice_trigger_vf_reset - Reset a VF on HW
190209
* @vf: pointer to the VF structure

drivers/net/ethernet/intel/ice/ice_vf_lib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ u16 ice_get_num_vfs(struct ice_pf *pf);
214214
struct ice_vsi *ice_get_vf_vsi(struct ice_vf *vf);
215215
bool ice_is_vf_disabled(struct ice_vf *vf);
216216
int ice_check_vf_ready_for_cfg(struct ice_vf *vf);
217+
int ice_check_vf_ready_for_reset(struct ice_vf *vf);
217218
void ice_set_vf_state_dis(struct ice_vf *vf);
218219
bool ice_is_any_vf_in_unicast_promisc(struct ice_pf *pf);
219220
void

drivers/net/ethernet/intel/ice/ice_virtchnl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,7 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)
37223722
ice_vc_notify_vf_link_state(vf);
37233723
break;
37243724
case VIRTCHNL_OP_RESET_VF:
3725+
clear_bit(ICE_VF_STATE_ACTIVE, vf->vf_states);
37253726
ops->reset_vf(vf);
37263727
break;
37273728
case VIRTCHNL_OP_ADD_ETH_ADDR:

0 commit comments

Comments
 (0)