MLX5DV_SCHED_LEAF_CREATE(3)
πΈ mlx5dv_sched_node_create / mlx5dv_sched_leaf_create / modify / destroy π
okay bestie so this is a page out of the mlx5 Programmer's Manual and it's literally all about scheduling elements β creating them, modifying them, destroying them. six functions, one page, no cap. let's go β¨
β¨ NAME β¨
mlx5dv_sched_node_createβ creates a scheduling node element πmlx5dv_sched_leaf_createβ creates a scheduling leaf element πmlx5dv_sched_node_modifyβ modifies a node scheduling elementmlx5dv_sched_leaf_modifyβ modifies a leaf scheduling elementmlx5dv_sched_node_destroyβ destroys a node scheduling element πmlx5dv_sched_leaf_destroyβ destroys a leaf scheduling element π
π SYNOPSIS π
#include <infiniband/mlx5dv.h>
struct mlx5dv_sched_node *mlx5dv_sched_node_create(struct ibv_context *context,
struct mlx5dv_sched_attr *sched_attr);
struct mlx5dv_sched_leaf *mlx5dv_sched_leaf_create(struct ibv_context *context,
struct mlx5dv_sched_attr *sched_attr);
int mlx5dv_sched_node_modify(struct mlx5dv_sched_node *node,
struct mlx5dv_sched_attr *sched_attr);
int mlx5dv_sched_leaf_modify(struct mlx5dv_sched_leaf *leaf,
struct mlx5dv_sched_attr *sched_attr);
int mlx5dv_sched_node_destroy(struct mlx5dv_sched_node *node);
int mlx5dv_sched_leaf_destroy(struct mlx5dv_sched_leaf *leaf);
π¦ DESCRIPTION π¦
so the transmit scheduling element (SE) is the main character here β it's scheduling the transmission for all the nodes connected to it. by configuring the SE, QoS policies may be enforced between the competing entities (e.g. SQ, QP). it's giving traffic cop energy, honestly π
in each scheduling cycle, the SE schedules all ready-to-transmit entities. and the SE assures that weight for each entity is met β yes bestie, it keeps its promises. if an entity has reached its maximum allowed bandwidth within the scheduling cycle, it won't be scheduled till end of the scheduling cycle. and the unused transmission bandwidth will be distributed among the remaining entities, assuring the weight setting. sharing is caring fr fr π
the SEs are connected in a tree structure π³ the entity is connected to a leaf. one or more leaves can be connected to a SE node. one or more SE nodes can be connected to a SE node, until reaching the SE root. for each input on each node, user can assign the maximum bandwidth and the scheduling weight.
the SE APIs (mlx5dv_sched_*) allow access by verbs application to set the hierarchical SE tree to the device. and the ibv_qp shall be connected to a leaf β that part is not optional, it's a whole requirement π«Ά
π ARGUMENTS π
please see ibv_create_qp_ex(3) man page for context. iykyk, we're not re-explaining that one here.
the mlx5dv_sched_attr struct π
struct mlx5dv_sched_attr {
struct mlx5dv_sched_node *parent;
uint32_t flags;
uint32_t bw_share;
uint32_t max_avg_bw;
uint64_t comp_mask;
};
parentβ a node handler to the parent scheduling element which this scheduling element will be connected to. the root scheduling element doesn't have a parent (it's the root, it's built different, main character energy π).flagsβ specifying what attributes in the structure are valid:MLX5DV_SCHED_ELEM_ATTR_FLAGS_BW_SHAREforbw_shareMLX5DV_SCHED_ELEM_ATTR_FLAGS_MAX_AVG_BWformax_avg_bw
bw_shareβ the relative bandwidth share allocated for this element. this field has no units. the bandwidth is shared between all elements connected to the same parent element, relatively to theirbw_share. value of0indicates a device default Weight. and heads up β this field must be0for the root TSAR β οΈmax_avg_bwβ the maximal transmission rate allowed for the element, averaged over time. value is given in units of 1 Mbit/sec. value0x0indicates the rate is unlimited. this field must be0for the root TSAR β οΈcomp_maskβ reserved for future extension, must be0now. no exceptions, bestie πnode/leafβ for modify, destroy: the scheduling element to work on.sched_attrβ for create, modify: the attribute of the scheduling element to work on.
π NOTES π
okay so for example, if an application wants to create 2 QoS QP groups:
g1: 70% bandwidth share of this applicationg2: 30% bandwidth share of this application, with maximum average bandwidth limited to 4Gbps
pseudo code, and yes we're keeping every line of it β
struct mlx5dv_sched_node *root;
struct mlx5dv_sched_leaf *leaf_g1, *leaf_g2;
struct mlx5dv_sched_attr;
struct ibv_qp *qp1, qp2;
/* Create root node */
attr.comp_mask = 0;
attr.parent = NULL;
attr.flags = 0;
root = mlx5dv_sched_node_create(context, attr);
/* Create group1 */
attr.comp_mask = 0;
attr.parent = root;
attr.bw_share = 7;
attr.flags = MLX5DV_SCHED_ELEM_ATTR_FLAGS_BW_SHARE;
leaf_g1 = mlx5dv_sched_leaf_create(context, attr);
/* Create group2 */
attr.comp_mask = 0;
attr.parent = root;
attr.bw_share = 3;
attr.max_avg_bw = 4096;
attr.flags = MLX5DV_SCHED_ELEM_ATTR_FLAGS_BW_SHARE | MLX5DV_SCHED_ELEM_ATTR_FLAGS_MAX_AVG_BW;
leaf_g2 = mlx5dv_sched_leaf_create(context, attr);
foreach (qp1 in group1)
mlx5dv_modify_qp_sched_elem(qp1, leaf_g1, NULL);
foreach (qp2 in group2)
mlx5dv_modify_qp_sched_elem(qp2, leaf_g2, NULL);
π₯ RETURN VALUE π₯
upon success *mlx5dv_sched_node[/leaf]_create()* will return a new struct mlx5dv_sched_node[/leaf]. on error NULL will be returned and errno will be set π
upon success modify and destroy, 0 is returned or the value of errno on a failure.
π§ SEE ALSO π§
ibv_create_qp_ex(3), mlx5dv_modify_qp_sched_elem(3)
π AUTHOR π
- Mark Zhang <markzhang@nvidia.com>
- Ariel Almog <ariela@nvidia.com>
and that's the whole page bestie, you ate π β¨
this little icon came from the mlx5 source, dated 2020-9-3 β yes it's vintage, and yes it still slays π
π¦ where this page comes from
- alpine 3.24: rdma-core-doc 61.0-r0 Β· GPL-2.0-only OR BSD-2-Clause
- centos-stream 10: rdma-core-devel 62.0-3.el10 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- centos-stream 9: rdma-core-devel 61.0-3.el9 Β· GPLv2 or BSD
- ubuntu jammy: libibverbs-dev 39.0-1 Β· BSD-MIT OR GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms