Re: [PATCH rdma-next v3 04/13] RDMA/core: add the reliable unconnected queue pair type

From: Michael Margolin

Date: Mon Nov 16 2026 - 09:41:26 EST


On Mon, Nov 09, 2026 at 08:00:37PM -0800, Eric Davis wrote:
> Add IB_QPT_RU and its userspace counterpart, together with the field
> layout of a reliable unconnected queue pair number used by UET.
>
> Such a number uses all 32 bits, unlike the 24-bit InfiniBand and RoCE
> one, so exempt it from the restrack assertion that no queue pair number
> sets the top byte.
>
> A relative number is named within a job, so pairs in two jobs may share
> one, but restrack keys a queue pair by its number alone. Until it keys
> them by more, refuse the second such pair with -EADDRINUSE rather than
> leave it untracked.
>
> The provider posts its work requests, so the write post_send and
> post_recv commands refuse such a queue pair.
>
> Signed-off-by: Eric Davis <eric.davis@xxxxxxxxxxxx>
> ---
> drivers/infiniband/core/restrack.c | 15 ++++++++++++++-
> drivers/infiniband/core/uverbs_cmd.c | 14 ++++++++++++++
> drivers/infiniband/core/verbs.c | 13 +++++++++++++
> include/rdma/ib_verbs.h | 1 +
> include/uapi/rdma/ib_user_ioctl_verbs.h | 21 +++++++++++++++++++++
> 5 files changed, 63 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
> index a8b838fdc7b5..a75af79adf2c 100644
> --- a/drivers/infiniband/core/restrack.c
> +++ b/drivers/infiniband/core/restrack.c
> @@ -241,7 +241,20 @@ void rdma_restrack_add(struct rdma_restrack_entry *res)
> /* Special case to ensure that LQPN points to right QP */
> struct ib_qp *qp = container_of(res, struct ib_qp, res);
>
> - WARN_ONCE(qp->qp_num >> 24 || qp->port >> 8,
> + /* An InfiniBand/RoCE QP number is 24 bits and the top byte is
> + * where the port is folded in for SMI and GSI. A reliable
> + * unconnected pair is an exception as its QP number is a
> + * full 32b wide, though of the top byte only the absolute bit
> + * may be set. An absolute number whose low bits are 0 or 1
> + * still conflicts SMI/GSI on port 128, which takes a device
> + * with both RU and MADs on that many ports. Two RU pairs in
> + * different jobs may also share a relative number, and
> + * create_qp() refuses the second.
> + */
> + WARN_ONCE(qp->port >> 8 ||
> + (qp->qp_type != IB_QPT_RU && qp->qp_num >> 24) ||
> + (qp->qp_type == IB_QPT_RU &&
> + qp->qp_num & IB_UVERBS_QPN_UET_RESERVED_MASK),

The QPN checks here, and the EADDRINUSE on a duplicate RU QPN, seem to exist only because restrack
keys QPs by their number. The nldev LQPN get and counter bind could find a QP by number and port
without that key. Would allocating QP IDs like other objects work? Duplicate RU QPNs would still
need some way to tell them apart in nldev, but that seems separate from the QPN layout.

Michael

> "QP number 0x%0X and port 0x%0X", qp->qp_num,
> qp->port);
> res->id = qp->qp_num;
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index ed55fbbdfc18..e4fdfa0d9548 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -2058,6 +2058,12 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs)
> goto out;
> }
>
> + /* reliable unconnected work requests are posted by the provider */
> + if (qp->qp_type == IB_QPT_RU) {
> + ret = -EOPNOTSUPP;
> + goto out_put;
> + }
> +
> is_ud = qp->qp_type == IB_QPT_UD;
> sg_ind = 0;
> last = NULL;
> @@ -2335,6 +2341,14 @@ static int ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs)
> goto out;
> }
>
> + /* reliable unconnected work requests are posted by the provider */
> + if (qp->qp_type == IB_QPT_RU) {
> + rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
> + UVERBS_LOOKUP_READ);
> + ret = -EOPNOTSUPP;
> + goto out;
> + }
> +
> resp.bad_wr = 0;
> ret = qp->device->ops.post_recv(qp->real_qp, wr, &bad_wr);
>
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index 1299125752d8..ccdb08284432 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -1333,10 +1333,23 @@ static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd,
> goto err_security;
>
> rdma_restrack_add(&qp->res);
> +
> + /* restrack keys a QP by its number alone, so an RU QP whose number
> + * another QP has, as one in another job may, is refused rather than
> + * left untracked
> + */
> + if (qp->qp_type == IB_QPT_RU && !qp->res.valid) {
> + ret = -EADDRINUSE;
> + goto err_track;
> + }
> +
> return qp;
>