Commit 3a3b311e authored by Karen Sornek's avatar Karen Sornek Committed by Tony Nguyen

i40e: Fix warning message and call stack during rmmod i40e driver

Restore part of reset functionality used when reset is called
from the VF to reset itself. Without this fix warning message
is displayed when VF is being removed via sysfs.

Fix the crash of the VF during reset by ensuring
that the PF receives the reset message successfully.
Refactor code to use one function instead of two.

Fixes: 5c3c48ac ("i40e: implement virtual device interface")
Signed-off-by: default avatarGrzegorz Szczurek <grzegorzx.szczurek@intel.com>
Signed-off-by: default avatarKaren Sornek <karen.sornek@intel.com>
Tested-by: default avatarTony Brelinski <tony.brelinski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 9e0a603c
...@@ -183,17 +183,18 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf) ...@@ -183,17 +183,18 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf)
/***********************misc routines*****************************/ /***********************misc routines*****************************/
/** /**
* i40e_vc_disable_vf * i40e_vc_reset_vf
* @vf: pointer to the VF info * @vf: pointer to the VF info
* * @notify_vf: notify vf about reset or not
* Disable the VF through a SW reset. * Reset VF handler.
**/ **/
static inline void i40e_vc_disable_vf(struct i40e_vf *vf) static void i40e_vc_reset_vf(struct i40e_vf *vf, bool notify_vf)
{ {
struct i40e_pf *pf = vf->pf; struct i40e_pf *pf = vf->pf;
int i; int i;
i40e_vc_notify_vf_reset(vf); if (notify_vf)
i40e_vc_notify_vf_reset(vf);
/* We want to ensure that an actual reset occurs initiated after this /* We want to ensure that an actual reset occurs initiated after this
* function was called. However, we do not want to wait forever, so * function was called. However, we do not want to wait forever, so
...@@ -211,9 +212,14 @@ static inline void i40e_vc_disable_vf(struct i40e_vf *vf) ...@@ -211,9 +212,14 @@ static inline void i40e_vc_disable_vf(struct i40e_vf *vf)
usleep_range(10000, 20000); usleep_range(10000, 20000);
} }
dev_warn(&vf->pf->pdev->dev, if (notify_vf)
"Failed to initiate reset for VF %d after 200 milliseconds\n", dev_warn(&vf->pf->pdev->dev,
vf->vf_id); "Failed to initiate reset for VF %d after 200 milliseconds\n",
vf->vf_id);
else
dev_dbg(&vf->pf->pdev->dev,
"Failed to initiate reset for VF %d after 200 milliseconds\n",
vf->vf_id);
} }
/** /**
...@@ -2108,20 +2114,6 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg) ...@@ -2108,20 +2114,6 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
return ret; return ret;
} }
/**
* i40e_vc_reset_vf_msg
* @vf: pointer to the VF info
*
* called from the VF to reset itself,
* unlike other virtchnl messages, PF driver
* doesn't send the response back to the VF
**/
static void i40e_vc_reset_vf_msg(struct i40e_vf *vf)
{
if (test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
i40e_reset_vf(vf, false);
}
/** /**
* i40e_vc_config_promiscuous_mode_msg * i40e_vc_config_promiscuous_mode_msg
* @vf: pointer to the VF info * @vf: pointer to the VF info
...@@ -2617,8 +2609,7 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg) ...@@ -2617,8 +2609,7 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg)
} else { } else {
/* successful request */ /* successful request */
vf->num_req_queues = req_pairs; vf->num_req_queues = req_pairs;
i40e_vc_notify_vf_reset(vf); i40e_vc_reset_vf(vf, true);
i40e_reset_vf(vf, false);
return 0; return 0;
} }
...@@ -3813,8 +3804,7 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg) ...@@ -3813,8 +3804,7 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)
vf->num_req_queues = 0; vf->num_req_queues = 0;
/* reset the VF in order to allocate resources */ /* reset the VF in order to allocate resources */
i40e_vc_notify_vf_reset(vf); i40e_vc_reset_vf(vf, true);
i40e_reset_vf(vf, false);
return I40E_SUCCESS; return I40E_SUCCESS;
...@@ -3854,8 +3844,7 @@ static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg) ...@@ -3854,8 +3844,7 @@ static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg)
} }
/* reset the VF in order to allocate resources */ /* reset the VF in order to allocate resources */
i40e_vc_notify_vf_reset(vf); i40e_vc_reset_vf(vf, true);
i40e_reset_vf(vf, false);
return I40E_SUCCESS; return I40E_SUCCESS;
...@@ -3917,7 +3906,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode, ...@@ -3917,7 +3906,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
i40e_vc_notify_vf_link_state(vf); i40e_vc_notify_vf_link_state(vf);
break; break;
case VIRTCHNL_OP_RESET_VF: case VIRTCHNL_OP_RESET_VF:
i40e_vc_reset_vf_msg(vf); i40e_vc_reset_vf(vf, false);
ret = 0; ret = 0;
break; break;
case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
...@@ -4171,7 +4160,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) ...@@ -4171,7 +4160,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
/* Force the VF interface down so it has to bring up with new MAC /* Force the VF interface down so it has to bring up with new MAC
* address * address
*/ */
i40e_vc_disable_vf(vf); i40e_vc_reset_vf(vf, true);
dev_info(&pf->pdev->dev, "Bring down and up the VF interface to make this change effective.\n"); dev_info(&pf->pdev->dev, "Bring down and up the VF interface to make this change effective.\n");
error_param: error_param:
...@@ -4235,7 +4224,7 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id, ...@@ -4235,7 +4224,7 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
/* duplicate request, so just return success */ /* duplicate request, so just return success */
goto error_pvid; goto error_pvid;
i40e_vc_disable_vf(vf); i40e_vc_reset_vf(vf, true);
/* During reset the VF got a new VSI, so refresh a pointer. */ /* During reset the VF got a new VSI, so refresh a pointer. */
vsi = pf->vsi[vf->lan_vsi_idx]; vsi = pf->vsi[vf->lan_vsi_idx];
/* Locked once because multiple functions below iterate list */ /* Locked once because multiple functions below iterate list */
...@@ -4613,7 +4602,7 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting) ...@@ -4613,7 +4602,7 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)
goto out; goto out;
vf->trusted = setting; vf->trusted = setting;
i40e_vc_disable_vf(vf); i40e_vc_reset_vf(vf, true);
dev_info(&pf->pdev->dev, "VF %u is now %strusted\n", dev_info(&pf->pdev->dev, "VF %u is now %strusted\n",
vf_id, setting ? "" : "un"); vf_id, setting ? "" : "un");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment