Skip to content

Commit 000773c

Browse files
jacob-kelleranguy11
authored andcommitted
ice: factor VF variables to separate structure
We maintain a number of values for VFs within the ice_pf structure. This includes the VF table, the number of allocated VFs, the maximum number of supported SR-IOV VFs, the number of queue pairs per VF, the number of MSI-X vectors per VF, and a bitmap of the VFs with detected MDD events. We're about to add a few more variables to this list. Clean this up first by extracting these members out into a new ice_vfs structure defined in ice_virtchnl_pf.h 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>
1 parent c4c2c7d commit 000773c

File tree

7 files changed

+83
-68
lines changed

7 files changed

+83
-68
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,7 @@ struct ice_pf {
528528
struct ice_vsi **vsi; /* VSIs created by the driver */
529529
struct ice_sw *first_sw; /* first switch created by firmware */
530530
u16 eswitch_mode; /* current mode of eswitch */
531-
/* Virtchnl/SR-IOV config info */
532-
struct ice_vf *vf;
533-
u16 num_alloc_vfs; /* actual number of VFs allocated */
534-
u16 num_vfs_supported; /* num VFs supported for this PF */
535-
u16 num_qps_per_vf;
536-
u16 num_msix_per_vf;
537-
/* used to ratelimit the MDD event logging */
538-
unsigned long last_printed_mdd_jiffies;
539-
DECLARE_BITMAP(malvfs, ICE_MAX_VF_COUNT);
531+
struct ice_vfs vfs;
540532
DECLARE_BITMAP(features, ICE_F_MAX);
541533
DECLARE_BITMAP(state, ICE_STATE_NBITS);
542534
DECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS);

drivers/net/ethernet/intel/ice/ice_eswitch.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,20 @@ static void ice_eswitch_remap_rings_to_vectors(struct ice_pf *pf)
176176
int q_id;
177177

178178
ice_for_each_txq(vsi, q_id) {
179-
struct ice_repr *repr = pf->vf[q_id].repr;
180-
struct ice_q_vector *q_vector = repr->q_vector;
181-
struct ice_tx_ring *tx_ring = vsi->tx_rings[q_id];
182-
struct ice_rx_ring *rx_ring = vsi->rx_rings[q_id];
179+
struct ice_q_vector *q_vector;
180+
struct ice_tx_ring *tx_ring;
181+
struct ice_rx_ring *rx_ring;
182+
struct ice_repr *repr;
183+
struct ice_vf *vf;
184+
185+
if (WARN_ON(q_id >= pf->vfs.num_alloc))
186+
continue;
187+
188+
vf = &pf->vfs.table[q_id];
189+
repr = vf->repr;
190+
q_vector = repr->q_vector;
191+
tx_ring = vsi->tx_rings[q_id];
192+
rx_ring = vsi->rx_rings[q_id];
183193

184194
q_vector->vsi = vsi;
185195
q_vector->reg_idx = vsi->q_vectors[0]->reg_idx;
@@ -525,7 +535,7 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
525535
if (pf->eswitch_mode == mode)
526536
return 0;
527537

528-
if (pf->num_alloc_vfs) {
538+
if (pf->vfs.num_alloc) {
529539
dev_info(ice_pf_to_dev(pf), "Changing eswitch mode is allowed only if there is no VFs created");
530540
NL_SET_ERR_MSG_MOD(extack, "Changing eswitch mode is allowed only if there is no VFs created");
531541
return -EOPNOTSUPP;

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
12971297
}
12981298

12991299
if (test_bit(ICE_FLAG_VF_VLAN_PRUNING, change_flags) &&
1300-
pf->num_alloc_vfs) {
1300+
pf->vfs.num_alloc) {
13011301
dev_err(dev, "vf-vlan-pruning: VLAN pruning cannot be changed while VFs are active.\n");
13021302
/* toggle bit back to previous state */
13031303
change_bit(ICE_FLAG_VF_VLAN_PRUNING, pf->flags);

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,21 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, struct ice_vf *vf)
215215
/* The number of queues for ctrl VSI is equal to number of VFs.
216216
* Each ring is associated to the corresponding VF_PR netdev.
217217
*/
218-
vsi->alloc_txq = pf->num_alloc_vfs;
219-
vsi->alloc_rxq = pf->num_alloc_vfs;
218+
vsi->alloc_txq = pf->vfs.num_alloc;
219+
vsi->alloc_rxq = pf->vfs.num_alloc;
220220
vsi->num_q_vectors = 1;
221221
break;
222222
case ICE_VSI_VF:
223223
if (vf->num_req_qs)
224224
vf->num_vf_qs = vf->num_req_qs;
225225
vsi->alloc_txq = vf->num_vf_qs;
226226
vsi->alloc_rxq = vf->num_vf_qs;
227-
/* pf->num_msix_per_vf includes (VF miscellaneous vector +
227+
/* pf->vfs.num_msix_per includes (VF miscellaneous vector +
228228
* data queue interrupts). Since vsi->num_q_vectors is number
229229
* of queues vectors, subtract 1 (ICE_NONQ_VECS_VF) from the
230230
* original vector count
231231
*/
232-
vsi->num_q_vectors = pf->num_msix_per_vf - ICE_NONQ_VECS_VF;
232+
vsi->num_q_vectors = pf->vfs.num_msix_per - ICE_NONQ_VECS_VF;
233233
break;
234234
case ICE_VSI_CTRL:
235235
vsi->alloc_txq = 1;

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3712,7 +3712,7 @@ static void ice_set_pf_caps(struct ice_pf *pf)
37123712
clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags);
37133713
if (func_caps->common_cap.sr_iov_1_1) {
37143714
set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags);
3715-
pf->num_vfs_supported = min_t(int, func_caps->num_allocd_vfs,
3715+
pf->vfs.num_supported = min_t(int, func_caps->num_allocd_vfs,
37163716
ICE_MAX_VF_COUNT);
37173717
}
37183718
clear_bit(ICE_FLAG_RSS_ENA, pf->flags);

0 commit comments

Comments
 (0)