Skip to content

Commit 19b39ca

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: reserve number of CP queues
Rebuilding CP VSI each time the PR is created drastically increase the time of maximum VFs creation. Add function to reserve number of CP queues to deal with this problem. Use the same function to decrease number of queues in case of removing VFs. Assume that caller of ice_eswitch_reserve_cp_queues() will also call ice_eswitch_attach/detach() correct number of times. Still one by one PR adding is handy for VF resetting routine. Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent c9663f7 commit 19b39ca

File tree

4 files changed

+58
-7
lines changed

4 files changed

+58
-7
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ struct ice_eswitch {
528528
struct ice_esw_br_offloads *br_offloads;
529529
struct xarray reprs;
530530
bool is_running;
531+
/* struct to allow cp queues management optimization */
532+
struct {
533+
int to_reach;
534+
int value;
535+
bool is_reaching;
536+
} qs;
531537
};
532538

533539
struct ice_agg_node {

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

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void ice_eswitch_remap_rings_to_vectors(struct ice_eswitch *eswitch)
176176

177177
repr = xa_find(&eswitch->reprs, &repr_id, U32_MAX,
178178
XA_PRESENT);
179-
if (WARN_ON(!repr))
179+
if (!repr)
180180
break;
181181

182182
repr_id += 1;
@@ -455,6 +455,8 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
455455
return -ENODEV;
456456

457457
ctrl_vsi = pf->eswitch.control_vsi;
458+
/* cp VSI is createad with 1 queue as default */
459+
pf->eswitch.qs.value = 1;
458460
pf->eswitch.uplink_vsi = uplink_vsi;
459461

460462
if (ice_eswitch_setup_env(pf))
@@ -487,6 +489,7 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
487489
ice_vsi_release(ctrl_vsi);
488490

489491
pf->eswitch.is_running = false;
492+
pf->eswitch.qs.is_reaching = false;
490493
}
491494

492495
/**
@@ -615,15 +618,33 @@ static void
615618
ice_eswitch_cp_change_queues(struct ice_eswitch *eswitch, int change)
616619
{
617620
struct ice_vsi *cp = eswitch->control_vsi;
621+
int queues = 0;
622+
623+
if (eswitch->qs.is_reaching) {
624+
if (eswitch->qs.to_reach >= eswitch->qs.value + change) {
625+
queues = eswitch->qs.to_reach;
626+
eswitch->qs.is_reaching = false;
627+
} else {
628+
queues = 0;
629+
}
630+
} else if ((change > 0 && cp->alloc_txq <= eswitch->qs.value) ||
631+
change < 0) {
632+
queues = cp->alloc_txq + change;
633+
}
618634

619-
ice_vsi_close(cp);
635+
if (queues) {
636+
cp->req_txq = queues;
637+
cp->req_rxq = queues;
638+
ice_vsi_close(cp);
639+
ice_vsi_rebuild(cp, ICE_VSI_FLAG_NO_INIT);
640+
ice_vsi_open(cp);
641+
} else if (!change) {
642+
/* change == 0 means that VSI wasn't open, open it here */
643+
ice_vsi_open(cp);
644+
}
620645

621-
cp->req_txq = cp->alloc_txq + change;
622-
cp->req_rxq = cp->alloc_rxq + change;
623-
ice_vsi_rebuild(cp, ICE_VSI_FLAG_NO_INIT);
646+
eswitch->qs.value += change;
624647
ice_eswitch_remap_rings_to_vectors(eswitch);
625-
626-
ice_vsi_open(cp);
627648
}
628649

629650
int
@@ -641,6 +662,7 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf)
641662
if (err)
642663
return err;
643664
/* Control plane VSI is created with 1 queue as default */
665+
pf->eswitch.qs.to_reach -= 1;
644666
change = 0;
645667
}
646668

@@ -732,3 +754,19 @@ int ice_eswitch_rebuild(struct ice_pf *pf)
732754

733755
return 0;
734756
}
757+
758+
/**
759+
* ice_eswitch_reserve_cp_queues - reserve control plane VSI queues
760+
* @pf: pointer to PF structure
761+
* @change: how many more (or less) queues is needed
762+
*
763+
* Remember to call ice_eswitch_attach/detach() the "change" times.
764+
*/
765+
void ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change)
766+
{
767+
if (pf->eswitch.qs.value + change < 0)
768+
return;
769+
770+
pf->eswitch.qs.to_reach = pf->eswitch.qs.value + change;
771+
pf->eswitch.qs.is_reaching = true;
772+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void ice_eswitch_set_target_vsi(struct sk_buff *skb,
2626
struct ice_tx_offload_params *off);
2727
netdev_tx_t
2828
ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev);
29+
void ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change);
2930
#else /* CONFIG_ICE_SWITCHDEV */
3031
static inline void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) { }
3132

@@ -76,5 +77,8 @@ ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev)
7677
{
7778
return NETDEV_TX_BUSY;
7879
}
80+
81+
static inline void
82+
ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change) { }
7983
#endif /* CONFIG_ICE_SWITCHDEV */
8084
#endif /* _ICE_ESWITCH_H_ */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ void ice_free_vfs(struct ice_pf *pf)
172172
else
173173
dev_warn(dev, "VFs are assigned - not disabling SR-IOV\n");
174174

175+
ice_eswitch_reserve_cp_queues(pf, -ice_get_num_vfs(pf));
176+
175177
mutex_lock(&vfs->table_lock);
176178

177179
ice_for_each_vf(pf, bkt, vf) {
@@ -930,6 +932,7 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
930932
goto err_unroll_sriov;
931933
}
932934

935+
ice_eswitch_reserve_cp_queues(pf, num_vfs);
933936
ret = ice_start_vfs(pf);
934937
if (ret) {
935938
dev_err(dev, "Failed to start %d VFs, err %d\n", num_vfs, ret);

0 commit comments

Comments
 (0)