Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Leon Romanovsky
Mon, 16 Nov 2026 09:01
Re: [PATCH V1 rdma-next 11/24] RDMA/mlx5: Introduce per-CQ poll_one hook in mlx5_ib_cq
Author: Leon Romanovsky
Date: Mon, 16 Nov 2026 09:01
Date: Mon, 16 Nov 2026 09:01
78 lines
10841 bytes
10841 bytes
On Tue, Nov 10, 2026 at 03:43:07PM +0200, Yishai Hadas wrote:
> Add a poll_one function pointer to struct mlx5_ib_cq and initialize it
> to mlx5_poll_one in both mlx5_ib_create_cq() (kernel-ULP CQs) and
> mlx5_ib_create_user_cq() (uverbs CQs, the path used by both the
> modern ioctl-based and legacy write-based CQ creation commands).
> mlx5_ib_poll_cq() is updated to dispatch through the pointer instead
> of calling mlx5_poll_one() directly.
>
> This is a pure refactor with no behaviour change.
That is only partially true. mlx5_ib_poll_cq() is on the data path, and this
change adds indirection to a path that is already full of likely()/unlikely()
annotations.
Thanks
> The indirection allows a specialised poll_one implementation to be installed on a
> specific CQ, which a follow-up patch uses to verify the UMR CQ against
> a hostile NIC.
>
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> ---
> drivers/infiniband/hw/mlx5/cq.c | 9 ++++++++-
> drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 ++
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
> index 55ffd7d4de51..11c1153747c2 100644
> --- a/drivers/infiniband/hw/mlx5/cq.c
> +++ b/drivers/infiniband/hw/mlx5/cq.c
> @@ -633,7 +633,7 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
> soft_polled = poll_soft_wc(cq, num_entries, wc, false);
>
> for (npolled = 0; npolled < num_entries - soft_polled; npolled++) {
> - if (mlx5_poll_one(cq, &cur_qp, wc + soft_polled + npolled))
> + if (cq->poll_one(cq, &cur_qp, wc + soft_polled + npolled))
> break;
> }
>
> @@ -1010,6 +1010,8 @@ int mlx5_ib_create_user_cq(struct ib_cq *ibcq,
>
> cq->mcq.comp = mlx5_add_cq_to_tasklet;
> cq->mcq.tasklet_ctx.comp = mlx5_ib_cq_comp;
> + /* Set before the CQ is created, see mlx5_ib_create_cq() */
> + cq->poll_one = mlx5_poll_one;
>
> err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen, out, sizeof(out));
> if (err)
> @@ -1093,6 +1095,11 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
> MLX5_SET64(cqc, cqc, dbr_addr, cq->db.dma);
>
> cq->mcq.comp = mlx5_ib_cq_comp;
> + /*
> + * Set before mlx5_core_create_cq(). No real CQE can arrive before a
> + * QP uses the CQ, but a forged one can make mlx5_ib_poll_cq() call it.
> + */
> + cq->poll_one = mlx5_poll_one;
>
> err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen, out,
> sizeof(out));
> diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> index 980b41800df5..4833f42b3fd1 100644
> --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
> +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> @@ -592,6 +592,8 @@ struct mlx5_ib_cq {
> enum ib_cq_notify_flags notify_flags;
> struct work_struct notify_work;
> u16 private_flags; /* Use mlx5_ib_cq_pr_flags */
> + int (*poll_one)(struct mlx5_ib_cq *cq, struct mlx5_ib_qp **cur_qp,
> + struct ib_wc *wc);
> };
>
> struct mlx5_ib_wc {
> --
> 2.18.1
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads