On Wed, 11 Mar 2026 00:26:47 +0100
Vincent Jardin <[email protected]> wrote:

> Add mlx5_txq_rate_limit structure and alloc/free helpers for
> per-queue data-rate packet pacing. Each Tx queue can now hold
> its own PP (Packet Pacing) index allocated via mlx5dv_pp_alloc()
> with MLX5_DATA_RATE mode.
> 
> mlx5_txq_alloc_pp_rate_limit() converts Mbps to kbps for the PRM
> rate_limit field and allocates a dedicated PP index from the HW
> rate table. mlx5_txq_free_pp_rate_limit() releases it.
> 
> The existing Clock Queue path (sh->txpp.pp / sh->txpp.pp_id) is
> untouched — it uses MLX5_WQE_RATE for per-packet scheduling,
> while per-queue rate limiting uses MLX5_DATA_RATE.
> 
> PP index cleanup is added to mlx5_txq_release() to prevent leaks
> when queues are destroyed.
> 
> Supported hardware:
> - ConnectX-6 Dx: per-SQ rate via packet_pacing_rate_limit_index
> - ConnectX-7/8: same mechanism, plus wait-on-time coexistence
> - BlueField-2/3: same PP allocation support
> 
> Not supported:
> - ConnectX-5: packet_pacing exists but MLX5_DATA_RATE mode may
>   not be available on all firmware versions
> - ConnectX-4 Lx and earlier: no packet_pacing capability
> 
> Signed-off-by: Vincent Jardin <[email protected]>

For better type safety, void * pointers should be avoided.
In this patch, struct mlx5_txq_rate_limit stores the PP context as void *pp.
This opaque pointer hides the type and makes the code harder for static 
analysis.

Use the actual type (struct mlx5dv_pp *) behind the HAVE_MLX5DV_PP_ALLOC guard
so the cast at ((struct mlx5dv_pp *)(rl->pp))->index becomes a direct member 
access.

Minor nit:
The line break in the dv_alloc_pp call hurts readability — the function call, 
its arguments, and the NULL check would be clearer on fewer lines:


rl->pp = mlx5_glue->dv_alloc_pp(sh->cdev->ctx, sizeof(pp), &pp, 0);
if (rl->pp == NULL) {

Reply via email to