Commit 877b7e6f authored by Lukasz Czapnik's avatar Lukasz Czapnik Committed by Tony Nguyen
Browse files

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: 61125b8b ("i40e: Fix failed opcode appearing if handling messages from VF")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarLukasz Czapnik <lukasz.czapnik@intel.com>
Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Tested-by: default avatarRafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 9739d583
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1464,6 +1464,7 @@ static void i40e_trigger_vf_reset(struct i40e_vf *vf, bool flr)
	 * functions that may still be running at this point.
	 */
	clear_bit(I40E_VF_STATE_INIT, &vf->vf_states);
	clear_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states);

	/* In the case of a VFLR, the HW has already reset the VF and we
	 * 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)
	size_t len = 0;
	int ret;

	if (!i40e_sync_vf_state(vf, I40E_VF_STATE_INIT)) {
	i40e_sync_vf_state(vf, I40E_VF_STATE_INIT);

	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) ||
	    test_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states)) {
		aq_ret = -EINVAL;
		goto err;
	}
@@ -2233,6 +2237,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
				vf->default_lan_addr.addr);
	}
	set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
	set_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states);

err:
	/* send the response back to the VF */
+2 −1
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ enum i40e_vf_states {
	I40E_VF_STATE_MC_PROMISC,
	I40E_VF_STATE_UC_PROMISC,
	I40E_VF_STATE_PRE_ENABLE,
	I40E_VF_STATE_RESETTING
	I40E_VF_STATE_RESETTING,
	I40E_VF_STATE_RESOURCES_LOADED,
};

/* VF capabilities */