Skip to content

Commit 498bd79

Browse files
cjubranPaolo Abeni
authored andcommitted
net/mlx5: Introduce hierarchy level tracking on scheduling nodes
Add a `level` field to `mlx5_esw_sched_node` to track the hierarchy depth of each scheduling node. This allows enforcement of the scheduling depth constraints based on `log_esw_max_sched_depth`. Modify `esw_qos_node_set_parent()` and `__esw_qos_alloc_node()` to correctly assign hierarchy levels. Ensure that nodes inherit their parent’s level incrementally. Signed-off-by: Carolina Jubran <cjubran@nvidia.com> Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://patch.msgid.link/1741642016-44918-3-git-send-email-tariqt@nvidia.com Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent b407b4b commit 498bd79

File tree

1 file changed

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

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,30 @@ struct mlx5_esw_sched_node {
9090
struct list_head children;
9191
/* Valid only if this node is associated with a vport. */
9292
struct mlx5_vport *vport;
93+
/* Level in the hierarchy. The root node level is 1. */
94+
u8 level;
9395
};
9496

97+
static void esw_qos_node_attach_to_parent(struct mlx5_esw_sched_node *node)
98+
{
99+
if (!node->parent) {
100+
/* Root children are assigned a depth level of 2. */
101+
node->level = 2;
102+
list_add_tail(&node->entry, &node->esw->qos.domain->nodes);
103+
} else {
104+
node->level = node->parent->level + 1;
105+
list_add_tail(&node->entry, &node->parent->children);
106+
}
107+
}
108+
95109
static void
96110
esw_qos_node_set_parent(struct mlx5_esw_sched_node *node, struct mlx5_esw_sched_node *parent)
97111
{
98112
list_del_init(&node->entry);
99113
node->parent = parent;
100114
list_add_tail(&node->entry, &parent->children);
101115
node->esw = parent->esw;
116+
node->level = parent->level + 1;
102117
}
103118

104119
void mlx5_esw_qos_vport_qos_free(struct mlx5_vport *vport)
@@ -358,7 +373,6 @@ static struct mlx5_esw_sched_node *
358373
__esw_qos_alloc_node(struct mlx5_eswitch *esw, u32 tsar_ix, enum sched_node_type type,
359374
struct mlx5_esw_sched_node *parent)
360375
{
361-
struct list_head *parent_children;
362376
struct mlx5_esw_sched_node *node;
363377

364378
node = kzalloc(sizeof(*node), GFP_KERNEL);
@@ -370,8 +384,7 @@ __esw_qos_alloc_node(struct mlx5_eswitch *esw, u32 tsar_ix, enum sched_node_type
370384
node->type = type;
371385
node->parent = parent;
372386
INIT_LIST_HEAD(&node->children);
373-
parent_children = parent ? &parent->children : &esw->qos.domain->nodes;
374-
list_add_tail(&node->entry, parent_children);
387+
esw_qos_node_attach_to_parent(node);
375388

376389
return node;
377390
}

0 commit comments

Comments
 (0)