Skip to content

Commit 86197ad

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: set Tx topology every time new repr is added
It is needed to track correct Tx topology. Update it every time new representor is created or remove node in case of removing corresponding representor. Still clear all node when removing switchdev mode as part of Tx topology isn't related only to representors. Also clear ::rate_note value to prevent skipping this node next time Tx topology is created. Reviewed-by: Piotr Raczynski <piotr.raczynski@intel.com> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Reviewed-by: Jacob Keller <jacob.e.keller@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 292e015 commit 86197ad

File tree

4 files changed

+59
-7
lines changed

4 files changed

+59
-7
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node
810810
struct ice_vf *vf;
811811
int i;
812812

813+
if (node->rate_node)
814+
/* already added, skip to the next */
815+
goto traverse_children;
816+
813817
if (node->parent == tc_node) {
814818
/* create root node */
815819
rate_node = devl_rate_node_create(devlink, node, node->name, NULL);
@@ -831,6 +835,7 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node
831835
if (rate_node && !IS_ERR(rate_node))
832836
node->rate_node = rate_node;
833837

838+
traverse_children:
834839
for (i = 0; i < node->num_children; i++)
835840
ice_traverse_tx_tree(devlink, node->children[i], tc_node, pf);
836841
}
@@ -861,6 +866,30 @@ int ice_devlink_rate_init_tx_topology(struct devlink *devlink, struct ice_vsi *v
861866
return 0;
862867
}
863868

869+
static void ice_clear_rate_nodes(struct ice_sched_node *node)
870+
{
871+
node->rate_node = NULL;
872+
873+
for (int i = 0; i < node->num_children; i++)
874+
ice_clear_rate_nodes(node->children[i]);
875+
}
876+
877+
/**
878+
* ice_devlink_rate_clear_tx_topology - clear node->rate_node
879+
* @vsi: main vsi struct
880+
*
881+
* Clear rate_node to cleanup creation of Tx topology.
882+
*
883+
*/
884+
void ice_devlink_rate_clear_tx_topology(struct ice_vsi *vsi)
885+
{
886+
struct ice_port_info *pi = vsi->port_info;
887+
888+
mutex_lock(&pi->sched_lock);
889+
ice_clear_rate_nodes(pi->root->children[0]);
890+
mutex_unlock(&pi->sched_lock);
891+
}
892+
864893
/**
865894
* ice_set_object_tx_share - sets node scheduling parameter
866895
* @pi: devlink struct instance

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ void ice_devlink_destroy_regions(struct ice_pf *pf);
2020

2121
int ice_devlink_rate_init_tx_topology(struct devlink *devlink, struct ice_vsi *vsi);
2222
void ice_tear_down_devlink_rate_tree(struct ice_pf *pf);
23+
void ice_devlink_rate_clear_tx_topology(struct ice_vsi *vsi);
2324

2425
#endif /* _ICE_DEVLINK_H_ */

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,22 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
519519
static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
520520
{
521521
struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
522+
struct devlink *devlink = priv_to_devlink(pf);
522523

523524
ice_eswitch_napi_disable(&pf->eswitch.reprs);
524525
ice_eswitch_br_offloads_deinit(pf);
525526
ice_eswitch_release_env(pf);
526527
ice_eswitch_release_reprs(pf);
527528
ice_vsi_release(ctrl_vsi);
528529
ice_repr_rem_from_all_vfs(pf);
530+
531+
/* since all port representors are destroyed, there is
532+
* no point in keeping the nodes
533+
*/
534+
ice_devlink_rate_clear_tx_topology(ice_get_main_vsi(pf));
535+
devl_lock(devlink);
536+
devl_rate_nodes_destroy(devlink);
537+
devl_unlock(devlink);
529538
}
530539

531540
/**

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@ ice_repr_reg_netdev(struct net_device *netdev)
278278
return register_netdev(netdev);
279279
}
280280

281+
static void ice_repr_remove_node(struct devlink_port *devlink_port)
282+
{
283+
devl_lock(devlink_port->devlink);
284+
devl_rate_leaf_destroy(devlink_port);
285+
devl_unlock(devlink_port->devlink);
286+
}
287+
281288
/**
282289
* ice_repr_rem - remove representor from VF
283290
* @reprs: xarray storing representors
@@ -298,6 +305,7 @@ static void ice_repr_rem_vf(struct ice_vf *vf)
298305
if (!repr)
299306
return;
300307

308+
ice_repr_remove_node(&repr->vf->devlink_port);
301309
unregister_netdev(repr->netdev);
302310
ice_repr_rem(&vf->pf->eswitch.reprs, repr);
303311
ice_devlink_destroy_vf_port(vf);
@@ -310,22 +318,26 @@ static void ice_repr_rem_vf(struct ice_vf *vf)
310318
*/
311319
void ice_repr_rem_from_all_vfs(struct ice_pf *pf)
312320
{
313-
struct devlink *devlink;
314321
struct ice_vf *vf;
315322
unsigned int bkt;
316323

317324
lockdep_assert_held(&pf->vfs.table_lock);
318325

319326
ice_for_each_vf(pf, bkt, vf)
320327
ice_repr_rem_vf(vf);
328+
}
329+
330+
static void ice_repr_set_tx_topology(struct ice_pf *pf)
331+
{
332+
struct devlink *devlink;
333+
334+
/* only export if ADQ and DCB disabled and eswitch enabled*/
335+
if (ice_is_adq_active(pf) || ice_is_dcb_active(pf) ||
336+
!ice_is_switchdev_running(pf))
337+
return;
321338

322-
/* since all port representors are destroyed, there is
323-
* no point in keeping the nodes
324-
*/
325339
devlink = priv_to_devlink(pf);
326-
devl_lock(devlink);
327-
devl_rate_nodes_destroy(devlink);
328-
devl_unlock(devlink);
340+
ice_devlink_rate_init_tx_topology(devlink, ice_get_main_vsi(pf));
329341
}
330342

331343
/**
@@ -415,6 +427,7 @@ static struct ice_repr *ice_repr_add_vf(struct ice_vf *vf)
415427
goto err_netdev;
416428

417429
ice_virtchnl_set_repr_ops(vf);
430+
ice_repr_set_tx_topology(vf->pf);
418431

419432
return repr;
420433

0 commit comments

Comments
 (0)