summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_repr.c
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2022-02-16 13:37:28 -0800
committerTony Nguyen <anthony.l.nguyen@intel.com>2022-03-03 08:46:47 -0800
commitdf830543d63c9a8e4594d92c0c1ffb48c240947f (patch)
tree14b673292aa45c7f8053c8a81a9fdd454be49543 /drivers/net/ethernet/intel/ice/ice_repr.c
parent25bf4df4d18b4546a5821d77b5fac149a3a4961f (diff)
downloadlinux-stable-df830543d63c9a8e4594d92c0c1ffb48c240947f.tar.gz
linux-stable-df830543d63c9a8e4594d92c0c1ffb48c240947f.tar.bz2
linux-stable-df830543d63c9a8e4594d92c0c1ffb48c240947f.zip
ice: refactor unwind cleanup in eswitch mode
The code for supporting eswitch mode and port representors on VFs uses an unwind based cleanup flow when handling errors. These flows are used to cleanup and get everything back to the state prior to attempting to switch from legacy to representor mode or back. The unwind iterations make sense, but complicate a plan to refactor the VF array structure. In the future we won't have a clean method of reversing an iteration of the VFs. Instead, we can change the cleanup flow to just iterate over all VF structures and clean up appropriately. First notice that ice_repr_add_for_all_vfs and ice_repr_rem_from_all_vfs have an additional step of re-assigning the VC ops. There is no good reason to do this outside of ice_repr_add and ice_repr_rem. It can simply be done as the last step of these functions. Second, make sure ice_repr_rem is safe to call on a VF which does not have a representor. Check if vf->repr is NULL first and exit early if so. Move ice_repr_rem_from_all_vfs above ice_repr_add_for_all_vfs so that we can call it from the cleanup function. In ice_eswitch.c, replace the unwind iteration with a call to ice_eswitch_release_reprs. This will go through all of the VFs and revert the VF back to the standard model without the eswitch mode. To make this safe, ensure this function checks whether or not the represent or has been moved. Rely on the metadata destination in vf->repr->dst. This must be NULL if the representor has not been moved to eswitch mode. Ensure that we always re-assign this value back to NULL after freeing it, and move the ice_eswitch_release_reprs so that it can be called from the setup function. With these changes, eswitch cleanup no longer uses an unwind flow that is problematic for the planned VF data structure change. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_repr.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_repr.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c b/drivers/net/ethernet/intel/ice/ice_repr.c
index dcc310e29300..787f51c8ddb2 100644
--- a/drivers/net/ethernet/intel/ice/ice_repr.c
+++ b/drivers/net/ethernet/intel/ice/ice_repr.c
@@ -284,6 +284,8 @@ static int ice_repr_add(struct ice_vf *vf)
devlink_port_type_eth_set(&vf->devlink_port, repr->netdev);
+ ice_vc_change_ops_to_repr(&vf->vc_ops);
+
return 0;
err_netdev:
@@ -311,6 +313,9 @@ err_alloc_rule:
*/
static void ice_repr_rem(struct ice_vf *vf)
{
+ if (!vf->repr)
+ return;
+
ice_devlink_destroy_vf_port(vf);
kfree(vf->repr->q_vector);
vf->repr->q_vector = NULL;
@@ -323,54 +328,48 @@ static void ice_repr_rem(struct ice_vf *vf)
#endif
kfree(vf->repr);
vf->repr = NULL;
+
+ ice_vc_set_dflt_vf_ops(&vf->vc_ops);
}
/**
- * ice_repr_add_for_all_vfs - add port representor for all VFs
+ * ice_repr_rem_from_all_vfs - remove port representor for all VFs
* @pf: pointer to PF structure
*/
-int ice_repr_add_for_all_vfs(struct ice_pf *pf)
+void ice_repr_rem_from_all_vfs(struct ice_pf *pf)
{
- int err;
int i;
ice_for_each_vf(pf, i) {
struct ice_vf *vf = &pf->vf[i];
- err = ice_repr_add(vf);
- if (err)
- goto err;
-
- ice_vc_change_ops_to_repr(&vf->vc_ops);
- }
-
- return 0;
-
-err:
- for (i = i - 1; i >= 0; i--) {
- struct ice_vf *vf = &pf->vf[i];
-
ice_repr_rem(vf);
- ice_vc_set_dflt_vf_ops(&vf->vc_ops);
}
-
- return err;
}
/**
- * ice_repr_rem_from_all_vfs - remove port representor for all VFs
+ * ice_repr_add_for_all_vfs - add port representor for all VFs
* @pf: pointer to PF structure
*/
-void ice_repr_rem_from_all_vfs(struct ice_pf *pf)
+int ice_repr_add_for_all_vfs(struct ice_pf *pf)
{
+ int err;
int i;
ice_for_each_vf(pf, i) {
struct ice_vf *vf = &pf->vf[i];
- ice_repr_rem(vf);
- ice_vc_set_dflt_vf_ops(&vf->vc_ops);
+ err = ice_repr_add(vf);
+ if (err)
+ goto err;
}
+
+ return 0;
+
+err:
+ ice_repr_rem_from_all_vfs(pf);
+
+ return err;
}
/**