git: 07f780cb7f8e - main - mlx5: propagate the DEVX uid through SRQ create and destroy
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 07 Jul 2026 11:30:11 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=07f780cb7f8eab1aa6e84d3ed6785144d0d3cc47
commit 07f780cb7f8eab1aa6e84d3ed6785144d0d3cc47
Author: Ariel Ehrenberg <aehrenberg@nvidia.com>
AuthorDate: 2026-06-15 19:00:47 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-07 11:25:49 +0000
mlx5: propagate the DEVX uid through SRQ create and destroy
The SRQ command builders never stamped the owning DEVX uid into the
firmware CREATE_SRQ/CREATE_RMP/CREATE_XRC_SRQ commands, so a basic SRQ
was always created with uid 0. Every modern libmlx5 context runs with a
DEVX uid, and the QPs that reference the SRQ carry that uid, so firmware
rejected CREATE_QP with "bad resource": a uid-owned QP may not reference
a uid-0 SRQ.
Reviewed by: kib
Tested by: Wafa Hamzah <wafah@nvidia.com>
Sponsored by: Nvidia networking
MFC after: 1 month
---
sys/dev/mlx5/driver.h | 1 +
sys/dev/mlx5/mlx5_core/mlx5_srq.c | 30 +++++++++++++++++++++++++++---
sys/dev/mlx5/mlx5_ifc.h | 2 +-
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/sys/dev/mlx5/driver.h b/sys/dev/mlx5/driver.h
index ba6714c5c7b6..f5a73bec0776 100644
--- a/sys/dev/mlx5/driver.h
+++ b/sys/dev/mlx5/driver.h
@@ -481,6 +481,7 @@ struct mlx5_sq_bfreg {
struct mlx5_core_srq {
struct mlx5_core_rsc_common common; /* must be first */
u32 srqn;
+ u16 uid;
int max;
size_t max_gs;
size_t max_avail_gather;
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_srq.c b/sys/dev/mlx5/mlx5_core/mlx5_srq.c
index 7318a5b2c3c8..cd705ae6de88 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_srq.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_srq.c
@@ -166,7 +166,10 @@ static int create_rmp_cmd(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
set_wq(wq, in);
memcpy(MLX5_ADDR_OF(rmpc, rmpc, wq.pas), in->pas, pas_size);
+ MLX5_SET(create_rmp_in, create_in, uid, in->uid);
err = mlx5_core_create_rmp(dev, create_in, inlen, &srq->srqn);
+ if (!err)
+ srq->uid = in->uid;
kvfree(create_in);
return err;
@@ -175,7 +178,14 @@ static int create_rmp_cmd(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
static int destroy_rmp_cmd(struct mlx5_core_dev *dev,
struct mlx5_core_srq *srq)
{
- return mlx5_core_destroy_rmp(dev, srq->srqn);
+ u32 in[MLX5_ST_SZ_DW(destroy_rmp_in)] = {0};
+ u32 out[MLX5_ST_SZ_DW(destroy_rmp_out)] = {0};
+
+ MLX5_SET(destroy_rmp_in, in, opcode, MLX5_CMD_OP_DESTROY_RMP);
+ MLX5_SET(destroy_rmp_in, in, rmpn, srq->srqn);
+ MLX5_SET(destroy_rmp_in, in, uid, srq->uid);
+
+ return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
}
static int query_rmp_cmd(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
@@ -232,7 +242,10 @@ static int create_xrc_srq_cmd(struct mlx5_core_dev *dev,
MLX5_SET(xrc_srqc, xrc_srqc, user_index, in->user_index);
memcpy(pas, in->pas, pas_size);
+ MLX5_SET(create_xrc_srq_in, create_in, uid, in->uid);
err = mlx5_core_create_xsrq(dev, create_in, inlen, &srq->srqn);
+ if (!err)
+ srq->uid = in->uid;
if (err)
goto out;
@@ -244,7 +257,14 @@ out:
static int destroy_xrc_srq_cmd(struct mlx5_core_dev *dev,
struct mlx5_core_srq *srq)
{
- return mlx5_core_destroy_xsrq(dev, srq->srqn);
+ u32 in[MLX5_ST_SZ_DW(destroy_xrc_srq_in)] = {0};
+ u32 out[MLX5_ST_SZ_DW(destroy_xrc_srq_out)] = {0};
+
+ MLX5_SET(destroy_xrc_srq_in, in, opcode, MLX5_CMD_OP_DESTROY_XRC_SRQ);
+ MLX5_SET(destroy_xrc_srq_in, in, xrc_srqn, srq->srqn);
+ MLX5_SET(destroy_xrc_srq_in, in, uid, srq->uid);
+
+ return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
}
static int query_xrc_srq_cmd(struct mlx5_core_dev *dev,
@@ -304,10 +324,13 @@ static int create_srq_cmd(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
memcpy(pas, in->pas, pas_size);
MLX5_SET(create_srq_in, create_in, opcode, MLX5_CMD_OP_CREATE_SRQ);
+ MLX5_SET(create_srq_in, create_in, uid, in->uid);
err = mlx5_cmd_exec(dev, create_in, inlen, create_out, sizeof(create_out));
kvfree(create_in);
- if (!err)
+ if (!err) {
srq->srqn = MLX5_GET(create_srq_out, create_out, srqn);
+ srq->uid = in->uid;
+ }
return err;
}
@@ -320,6 +343,7 @@ static int destroy_srq_cmd(struct mlx5_core_dev *dev,
MLX5_SET(destroy_srq_in, srq_in, opcode, MLX5_CMD_OP_DESTROY_SRQ);
MLX5_SET(destroy_srq_in, srq_in, srqn, srq->srqn);
+ MLX5_SET(destroy_srq_in, srq_in, uid, srq->uid);
return mlx5_cmd_exec(dev, srq_in, sizeof(srq_in), srq_out, sizeof(srq_out));
}
diff --git a/sys/dev/mlx5/mlx5_ifc.h b/sys/dev/mlx5/mlx5_ifc.h
index 952f51d3c3f7..1906b670f013 100644
--- a/sys/dev/mlx5/mlx5_ifc.h
+++ b/sys/dev/mlx5/mlx5_ifc.h
@@ -7212,7 +7212,7 @@ struct mlx5_ifc_destroy_rmp_out_bits {
struct mlx5_ifc_destroy_rmp_in_bits {
u8 opcode[0x10];
- u8 reserved_0[0x10];
+ u8 uid[0x10];
u8 reserved_1[0x10];
u8 op_mod[0x10];