diff options
author | Jacob Keller <jacob.e.keller@intel.com> | 2022-02-17 00:37:35 +0300 |
---|---|---|
committer | Tony Nguyen <anthony.l.nguyen@intel.com> | 2022-03-03 19:46:48 +0300 |
commit | c4c2c7db64e19f815956c750c461d67867f1cdaf (patch) | |
tree | 92576f915f28ce29fedd020190728d379a1d4c1c /drivers/net/ethernet/intel/ice/ice_lib.c | |
parent | 19281e866808840d2de3f79a929c361b54b017d9 (diff) | |
download | linux-c4c2c7db64e19f815956c750c461d67867f1cdaf.tar.xz |
ice: convert ice_for_each_vf to include VF entry iterator
The ice_for_each_vf macro is intended to be used to loop over all VFs.
The current implementation relies on an iterator that is the index into
the VF array in the PF structure. This forces all users to perform a
look up themselves.
This abstraction forces a lot of duplicate work on callers and leaks the
interface implementation to the caller. Replace this with an
implementation that includes the VF pointer the primary iterator. This
version simplifies callers which just want to iterate over every VF, as
they no longer need to perform their own lookup.
The "i" iterator value is replaced with a new unsigned int "bkt"
parameter, as this will match the necessary interface for replacing
the VF array with a hash table. For now, the bkt is the VF ID, but in
the future it will simply be the hash bucket index. Document that it
should not be treated as a VF ID.
This change aims to simplify switching from the array to a hash table. I
considered alternative implementations such as an xarray but decided
that the hash table was the simplest and most suitable implementation. I
also looked at methods to hide the bkt iterator entirely, but I couldn't
come up with a feasible solution that worked for hash table iterators.
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_lib.c')
-rw-r--r-- | drivers/net/ethernet/intel/ice/ice_lib.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 5af36311a404..54ee85e7004f 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -433,13 +433,14 @@ static irqreturn_t ice_eswitch_msix_clean_rings(int __always_unused irq, void *d { struct ice_q_vector *q_vector = (struct ice_q_vector *)data; struct ice_pf *pf = q_vector->vsi->back; - int i; + struct ice_vf *vf; + unsigned int bkt; if (!q_vector->tx.tx_ring && !q_vector->rx.rx_ring) return IRQ_HANDLED; - ice_for_each_vf(pf, i) - napi_schedule(&pf->vf[i].repr->q_vector->napi); + ice_for_each_vf(pf, bkt, vf) + napi_schedule(&vf->repr->q_vector->napi); return IRQ_HANDLED; } @@ -1342,11 +1343,10 @@ ice_get_res(struct ice_pf *pf, struct ice_res_tracker *res, u16 needed, u16 id) */ static int ice_get_vf_ctrl_res(struct ice_pf *pf, struct ice_vsi *vsi) { - int i; - - ice_for_each_vf(pf, i) { - struct ice_vf *vf = &pf->vf[i]; + struct ice_vf *vf; + unsigned int bkt; + ice_for_each_vf(pf, bkt, vf) { if (vf != vsi->vf && vf->ctrl_vsi_idx != ICE_NO_VSI) return pf->vsi[vf->ctrl_vsi_idx]->base_vector; } @@ -2891,11 +2891,10 @@ void ice_napi_del(struct ice_vsi *vsi) */ static void ice_free_vf_ctrl_res(struct ice_pf *pf, struct ice_vsi *vsi) { - int i; - - ice_for_each_vf(pf, i) { - struct ice_vf *vf = &pf->vf[i]; + struct ice_vf *vf; + unsigned int bkt; + ice_for_each_vf(pf, bkt, vf) { if (vf != vsi->vf && vf->ctrl_vsi_idx != ICE_NO_VSI) return; } |