Re: [PATCH rdma-next v3 10/13] RDMA/core: queue pair attributes for unconnected transports

From: Michael Margolin

Date: Mon Nov 16 2026 - 09:54:46 EST


On Mon, Nov 09, 2026 at 08:00:43PM -0800, Eric Davis wrote:
> A queue pair on an unconnected transport is created with more than the
> connected attributes. A job key authorizing it to act within a job, the
> initiator identity it sends under, and the ordering guarantees the caller
> wants it to keep.
>
> The QP holds a reference to its job key for as long as it lives, so the
> job cannot go away underneath it.
>
> Signed-off-by: Eric Davis <eric.davis@xxxxxxxxxxxx>
> ---
> drivers/infiniband/core/uverbs_std_types_qp.c | 173 ++++++++++++++++++++++++++
> drivers/infiniband/core/verbs.c | 5 +
> include/rdma/ib_verbs.h | 14 +++
> include/uapi/rdma/ib_user_ioctl_cmds.h | 3 +
> 4 files changed, 195 insertions(+)
>
> diff --git a/drivers/infiniband/core/uverbs_std_types_qp.c b/drivers/infiniband/core/uverbs_std_types_qp.c
> index 249206d2992f..a1112083fb73 100644
> --- a/drivers/infiniband/core/uverbs_std_types_qp.c
> +++ b/drivers/infiniband/core/uverbs_std_types_qp.c
> @@ -79,6 +79,157 @@ static void set_caps(struct ib_qp_init_attr *attr,
> }
> }
>
> +/* A QP may relax what its type guarantees on this device, but not ask for
> + * more than the device advertises for it.
> + */
> +static int create_qp_semantics_check(struct ib_device *device,
> + const struct ib_qp_semantics *req)
> +{
> + struct ib_qp_semantics adv = {};
> + u32 m = req->comp_mask;
> + int ret;
> +
> + if (!device->ops.query_qp_semantics)
> + return -EOPNOTSUPP;
> +
> + ret = device->ops.query_qp_semantics(device, IB_QPT_RU, &adv);
> + if (ret)
> + return ret;
> +
> + if (m & ~adv.comp_mask)
> + return -EINVAL;
> +
> + if (((m & IB_UVERBS_QP_SEMANTICS_MASK_MSG_ORDER) &&
> + (req->msg_order & ~adv.msg_order)) ||
> + ((m & IB_UVERBS_QP_SEMANTICS_MASK_RAW) &&
> + req->max_rdma_raw_size > adv.max_rdma_raw_size) ||
> + ((m & IB_UVERBS_QP_SEMANTICS_MASK_WAR) &&
> + req->max_rdma_war_size > adv.max_rdma_war_size) ||
> + ((m & IB_UVERBS_QP_SEMANTICS_MASK_WAW) &&
> + req->max_rdma_waw_size > adv.max_rdma_waw_size) ||
> + ((m & IB_UVERBS_QP_SEMANTICS_MASK_PDU) &&
> + req->max_pdu > adv.max_pdu) ||
> + ((m & IB_UVERBS_QP_SEMANTICS_MASK_IMM) &&
> + req->imm_data_size > adv.imm_data_size) ||
> + ((m & IB_UVERBS_QP_SEMANTICS_MASK_USAGE) &&
> + (req->usage_flags & ~adv.usage_flags)))
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> +/* Process the optional creation attributes. A job to act within, a source
> + * identity, a set of ordering guarantees to ask for. They and the checks on
> + * a requested QP number belong to a reliable unconnected QP.
> + */
> +static int create_qp_opt_attrs(struct uverbs_attr_bundle *attrs,
> + struct ib_device *device, struct ib_pd *pd,
> + struct ib_qp_init_attr *attr,
> + struct ib_qp_semantics *sem)
> +{
> + struct ib_uverbs_qp_semantics usem = {};
> + struct ib_jkey *jkey;
> + bool has_semantics;
> + u32 m;
> + int ret;
> +
> + has_semantics = uverbs_attr_is_valid(attrs,
> + UVERBS_ATTR_CREATE_QP_SEMANTICS);
> +
> + if (attr->qp_type != IB_QPT_RU) {
> + if (has_semantics ||
> + uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_QP_SRC_ID) ||
> + uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_QP_JOB_KEY))
> + return -EOPNOTSUPP;
> +
> + return 0;
> + }
> +
> + if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_QP_SRC_ID)) {
> + ret = uverbs_copy_from(&attr->src_id, attrs,
> + UVERBS_ATTR_CREATE_QP_SRC_ID);
> + if (ret)
> + return ret;
> + }
> +
> + if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_QP_JOB_KEY)) {
> + jkey = uverbs_attr_get_obj(attrs,
> + UVERBS_ATTR_CREATE_QP_JOB_KEY);
> + if (IS_ERR(jkey))
> + return PTR_ERR(jkey);
> +
> + /* a key acts within the PD it was made on */
> + if (jkey->pd != pd)
> + return -EINVAL;
> +
> + attr->jkey = jkey;
> + }
> +
> + if (attr->create_flags & IB_QP_CREATE_SOURCE_QPN) {
> + if (attr->source_qpn & IB_UVERBS_QPN_UET_RESERVED_MASK)
> + return -EINVAL;
> +
> + /* a relative QP is named within a job, so it needs a key */
> + if (!(attr->source_qpn &
> + IB_UVERBS_QPN_UET_ABSOLUTE_ADDR_BIT) &&
> + !attr->jkey)
> + return -EINVAL;

On a device without jobs, these two checks together mean a caller can only choose a QPN that has
the absolute bit set. Is that rule meant for RU in general, or only for UET?

Michael