Skip to content

Commit 2f436f1

Browse files
cjubrankuba-moo
authored andcommitted
net/mlx5e: HTB, Fix inconsistencies with QoS SQs number
When creating a new HTB class while the interface is down, the variable that follows the number of QoS SQs (htb_max_qos_sqs) may not be consistent with the number of HTB classes. Previously, we compared these two values to ensure that the node_qid is lower than the number of QoS SQs, and we allocated stats for that SQ when they are equal. Change the check to compare the node_qid with the current number of leaf nodes and fix the checking conditions to ensure allocation of stats_list and stats for each node. Fixes: 214baf2 ("net/mlx5e: Support HTB offload") Signed-off-by: Carolina Jubran <cjubran@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://lore.kernel.org/r/20240409190820.227554-9-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ecb8294 commit 2f436f1

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core/en

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,25 @@ int mlx5e_open_qos_sq(struct mlx5e_priv *priv, struct mlx5e_channels *chs,
8383

8484
txq_ix = mlx5e_qid_from_qos(chs, node_qid);
8585

86-
WARN_ON(node_qid > priv->htb_max_qos_sqs);
87-
if (node_qid == priv->htb_max_qos_sqs) {
88-
struct mlx5e_sq_stats *stats, **stats_list = NULL;
89-
90-
if (priv->htb_max_qos_sqs == 0) {
91-
stats_list = kvcalloc(mlx5e_qos_max_leaf_nodes(priv->mdev),
92-
sizeof(*stats_list),
93-
GFP_KERNEL);
94-
if (!stats_list)
95-
return -ENOMEM;
96-
}
86+
WARN_ON(node_qid >= mlx5e_htb_cur_leaf_nodes(priv->htb));
87+
if (!priv->htb_qos_sq_stats) {
88+
struct mlx5e_sq_stats **stats_list;
89+
90+
stats_list = kvcalloc(mlx5e_qos_max_leaf_nodes(priv->mdev),
91+
sizeof(*stats_list), GFP_KERNEL);
92+
if (!stats_list)
93+
return -ENOMEM;
94+
95+
WRITE_ONCE(priv->htb_qos_sq_stats, stats_list);
96+
}
97+
98+
if (!priv->htb_qos_sq_stats[node_qid]) {
99+
struct mlx5e_sq_stats *stats;
100+
97101
stats = kzalloc(sizeof(*stats), GFP_KERNEL);
98-
if (!stats) {
99-
kvfree(stats_list);
102+
if (!stats)
100103
return -ENOMEM;
101-
}
102-
if (stats_list)
103-
WRITE_ONCE(priv->htb_qos_sq_stats, stats_list);
104+
104105
WRITE_ONCE(priv->htb_qos_sq_stats[node_qid], stats);
105106
/* Order htb_max_qos_sqs increment after writing the array pointer.
106107
* Pairs with smp_load_acquire in en_stats.c.

0 commit comments

Comments
 (0)