Skip to content

Commit 877b7e6

Browse files
lczapnikanguy11
authored andcommitted
i40e: fix validation of VF state in get resources
VF state I40E_VF_STATE_ACTIVE is not the only state in which VF is actually active so it should not be used to determine if a VF is allowed to obtain resources. Use I40E_VF_STATE_RESOURCES_LOADED that is set only in i40e_vc_get_vf_resources_msg() and cleared during reset. Fixes: 61125b8 ("i40e: Fix failed opcode appearing if handling messages from VF") Cc: [email protected] Signed-off-by: Lukasz Czapnik <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> Signed-off-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 9739d58 commit 877b7e6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,7 @@ static void i40e_trigger_vf_reset(struct i40e_vf *vf, bool flr)
14641464
* functions that may still be running at this point.
14651465
*/
14661466
clear_bit(I40E_VF_STATE_INIT, &vf->vf_states);
1467+
clear_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states);
14671468

14681469
/* In the case of a VFLR, the HW has already reset the VF and we
14691470
* just need to clean up, so don't hit the VFRTRIG register.
@@ -2130,7 +2131,10 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
21302131
size_t len = 0;
21312132
int ret;
21322133

2133-
if (!i40e_sync_vf_state(vf, I40E_VF_STATE_INIT)) {
2134+
i40e_sync_vf_state(vf, I40E_VF_STATE_INIT);
2135+
2136+
if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) ||
2137+
test_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states)) {
21342138
aq_ret = -EINVAL;
21352139
goto err;
21362140
}
@@ -2233,6 +2237,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
22332237
vf->default_lan_addr.addr);
22342238
}
22352239
set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
2240+
set_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states);
22362241

22372242
err:
22382243
/* send the response back to the VF */

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ enum i40e_vf_states {
4141
I40E_VF_STATE_MC_PROMISC,
4242
I40E_VF_STATE_UC_PROMISC,
4343
I40E_VF_STATE_PRE_ENABLE,
44-
I40E_VF_STATE_RESETTING
44+
I40E_VF_STATE_RESETTING,
45+
I40E_VF_STATE_RESOURCES_LOADED,
4546
};
4647

4748
/* VF capabilities */

0 commit comments

Comments
 (0)