Skip to content

Commit e8f9735

Browse files
cjubrankuba-moo
authored andcommitted
net/mlx5e: Preserve tc-bw during parent changes
When changing parent of a node/leaf with tc-bw configured, the code saves and restores tc-bw values. However, it was reading the converted hardware bw_share values (where 0 becomes 1) instead of the original user values, causing incorrect tc-bw calculations after parent change. Store original tc-bw values in the node structure and use them directly for save/restore operations. Fixes: cf7e737 ("net/mlx5: Manage TC arbiter nodes and implement full support for tc-bw") Signed-off-by: Carolina Jubran <[email protected]> Reviewed-by: Cosmin Ratiu <[email protected]> Signed-off-by: Mark Bloch <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 330f0f6 commit e8f9735

File tree

1 file changed

+12
-12
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/esw

1 file changed

+12
-12
lines changed

drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct mlx5_esw_sched_node {
102102
u8 level;
103103
/* Valid only when this node represents a traffic class. */
104104
u8 tc;
105+
/* Valid only for a TC arbiter node or vport TC arbiter. */
106+
u32 tc_bw[DEVLINK_RATE_TCS_MAX];
105107
};
106108

107109
static void esw_qos_node_attach_to_parent(struct mlx5_esw_sched_node *node)
@@ -609,10 +611,7 @@ static void
609611
esw_qos_tc_arbiter_get_bw_shares(struct mlx5_esw_sched_node *tc_arbiter_node,
610612
u32 *tc_bw)
611613
{
612-
struct mlx5_esw_sched_node *vports_tc_node;
613-
614-
list_for_each_entry(vports_tc_node, &tc_arbiter_node->children, entry)
615-
tc_bw[vports_tc_node->tc] = vports_tc_node->bw_share;
614+
memcpy(tc_bw, tc_arbiter_node->tc_bw, sizeof(tc_arbiter_node->tc_bw));
616615
}
617616

618617
static void
@@ -629,6 +628,7 @@ esw_qos_set_tc_arbiter_bw_shares(struct mlx5_esw_sched_node *tc_arbiter_node,
629628
u8 tc = vports_tc_node->tc;
630629
u32 bw_share;
631630

631+
tc_arbiter_node->tc_bw[tc] = tc_bw[tc];
632632
bw_share = tc_bw[tc] * fw_max_bw_share;
633633
bw_share = esw_qos_calc_bw_share(bw_share, divider,
634634
fw_max_bw_share);
@@ -1060,6 +1060,7 @@ static void esw_qos_vport_disable(struct mlx5_vport *vport, struct netlink_ext_a
10601060
esw_qos_vport_tc_disable(vport, extack);
10611061

10621062
vport_node->bw_share = 0;
1063+
memset(vport_node->tc_bw, 0, sizeof(vport_node->tc_bw));
10631064
list_del_init(&vport_node->entry);
10641065
esw_qos_normalize_min_rate(vport_node->esw, vport_node->parent, extack);
10651066

@@ -1231,8 +1232,9 @@ static int esw_qos_vport_update(struct mlx5_vport *vport,
12311232
struct mlx5_esw_sched_node *parent,
12321233
struct netlink_ext_ack *extack)
12331234
{
1234-
struct mlx5_esw_sched_node *curr_parent = vport->qos.sched_node->parent;
1235-
enum sched_node_type curr_type = vport->qos.sched_node->type;
1235+
struct mlx5_esw_sched_node *vport_node = vport->qos.sched_node;
1236+
struct mlx5_esw_sched_node *curr_parent = vport_node->parent;
1237+
enum sched_node_type curr_type = vport_node->type;
12361238
u32 curr_tc_bw[DEVLINK_RATE_TCS_MAX] = {0};
12371239
int err;
12381240

@@ -1244,10 +1246,8 @@ static int esw_qos_vport_update(struct mlx5_vport *vport,
12441246
if (err)
12451247
return err;
12461248

1247-
if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type) {
1248-
esw_qos_tc_arbiter_get_bw_shares(vport->qos.sched_node,
1249-
curr_tc_bw);
1250-
}
1249+
if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type)
1250+
esw_qos_tc_arbiter_get_bw_shares(vport_node, curr_tc_bw);
12511251

12521252
esw_qos_vport_disable(vport, extack);
12531253

@@ -1258,8 +1258,8 @@ static int esw_qos_vport_update(struct mlx5_vport *vport,
12581258
}
12591259

12601260
if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type) {
1261-
esw_qos_set_tc_arbiter_bw_shares(vport->qos.sched_node,
1262-
curr_tc_bw, extack);
1261+
esw_qos_set_tc_arbiter_bw_shares(vport_node, curr_tc_bw,
1262+
extack);
12631263
}
12641264

12651265
return err;

0 commit comments

Comments
 (0)