diff options
author | Jacob Keller <jacob.e.keller@intel.com> | 2022-02-16 13:37:37 -0800 |
---|---|---|
committer | Tony Nguyen <anthony.l.nguyen@intel.com> | 2022-03-03 10:54:33 -0800 |
commit | fb916db1f04f8c5f005fafcbe6ae01f40abd6aff (patch) | |
tree | ddf390284d5eb4344622f3edc9eb4a43d0e5bf9d /drivers/net/ethernet/intel/ice/ice_eswitch.c | |
parent | 000773c00f52f2a6084ec04c2efdc2a28ee29d9c (diff) |
ice: introduce VF accessor functions
Before we switch the VF data structure storage mechanism to a hash,
introduce new accessor functions to define the new interface.
* ice_get_vf_by_id is a function used to obtain a reference to a VF from
the table based on its VF ID
* ice_has_vfs is used to quickly check if any VFs are configured
* ice_get_num_vfs is used to get an exact count of how many VFs are
configured
We can drop the old ice_validate_vf_id function, since every caller was
just going to immediately access the VF table to get a reference
anyways. This way we simply use the single ice_get_vf_by_id to both
validate the VF ID is within range and that there exists a VF with that
ID.
This change enables us to more easily convert the codebase to the hash
table since most callers now properly use the interface.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_eswitch.c')
-rw-r--r-- | drivers/net/ethernet/intel/ice/ice_eswitch.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c index 7bcba782f74c..c27013afcadb 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c @@ -182,10 +182,10 @@ static void ice_eswitch_remap_rings_to_vectors(struct ice_pf *pf) struct ice_repr *repr; struct ice_vf *vf; - if (WARN_ON(q_id >= pf->vfs.num_alloc)) + vf = ice_get_vf_by_id(pf, q_id); + if (WARN_ON(!vf)) continue; - vf = &pf->vfs.table[q_id]; repr = vf->repr; q_vector = repr->q_vector; tx_ring = vsi->tx_rings[q_id]; @@ -535,7 +535,7 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode, if (pf->eswitch_mode == mode) return 0; - if (pf->vfs.num_alloc) { + if (ice_has_vfs(pf)) { dev_info(ice_pf_to_dev(pf), "Changing eswitch mode is allowed only if there is no VFs created"); NL_SET_ERR_MSG_MOD(extack, "Changing eswitch mode is allowed only if there is no VFs created"); return -EOPNOTSUPP; |