🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17002

Re: [PATCH V1 rdma-next 11/24] RDMA/mlx5: Introduce per-CQ poll_one hook in mlx5_ib_cq

#17002
From: Leon Romanovsky
Date: Mon, 16 Nov 2026 09:01
78 lines
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
> 
Technical Details
Message-ID: <20261116090141.GC11319@unreal>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364122-linux-kernel-netdev=dewy.ru
References: <20261110134320.34408-1-yishaih@nvidia.com> <20261110134320.34408-12-yishaih@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364122-linux-kernel-netdev=dewy.ru
From: leon@kernel.org (Leon Romanovsky)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH V1 rdma-next 11/24] RDMA/mlx5: Introduce per-CQ poll_one
 hook in mlx5_ib_cq
Date: Mon, 16 Nov 2026 11:01:41 +0200
Organization: Usenet Network
Message-ID: <20261116090141.GC11319@unreal>
References: <20261110134320.34408-1-yishaih@nvidia.com>
 <20261110134320.34408-12-yishaih@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2016002"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:SLMSo8GNydwxcU0u2ab1Rjpzd6k= sha256:k0AyUfZKfWrdNqB5jkTgt22QPAB+v3Q6F2whM8otexU=
	sha1:V449PEamrwImxGoWAun+xgcv1BQ= sha256:5tujPd7tFJneo+QktXUWB4rEY5qW7fHBV+i4q1DL1CM=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 62B9C114B68; Mon, 16 Nov 2026 12:02:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id JU7Yi2cpgUTB;
	Mon, 16 Nov 2026 12:02:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-364122-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C0FDC114B16; Mon, 16 Nov 2026 12:02:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 9C0D731C77; Mon, 16 Nov 2026 09:01:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794819706;
	b=wCs2Q0cTn5RzPBPAaV9P0nouCg14MsFtUlP9b+qxB8y2GTCY8pJ+3mBr4bztKEfIPw6D
	 NHx3N3J2oAt62dmJw3/RPM+ng4Ij7vaUb8kGXtkHKQZHQgqOwtVNQoHRiIywuy16PPCqD
	 WcQN2o12igWB1OrzbZSUj9CXIPeDmGNNYNJmGkMHJYBZWoEunF4II3SLZUuSpJywZ7t0Q
	 4ILvO1Ptji2f/pl4i2ckeunSysOxoecj1ZFDTS1G37+ymMGo6rt+rtlS3Vob+K5RK1JKE
	 B/MlcKPnjc3ZKbHdlEpFwCf7CmmbEo4G49mdURWk0sn6TXSTWLeL1/KWgh7LNUoAdZg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794819706;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=INWogzm8PidxyjUr/FFx7LS/Jeuuu1yeGh+jYBpFEF4=;
	b=1bhfFVTreaJynlwPjqJyqjzpROq/b6hqngs5zpFljtlnF65IC3J1K/jFo6VJ0OV1sqGD
	 ZE47fhq0VVRgHvsTPR5H1QAX+2KlfVxMBF8yxSd7KhEd0MMx2FfcOJiGlRztuMJkzISKB
	 bICtlf0b8yA2re+unJvSVN7MtQUfPItBeDUA05ObVi5MBEg55lwmIBVVXjVddZOlsl0lJ
	 AbstnKaIXfWCdHV/gW8ZM6jIZUSR2onx58qSn6qqxsoPKI3EtlNOVFEEAqjlUQG/4m94V
	 V2i/Nb1kh/4Khw7w4FFUzfwXpDg5kzYyz/7hiUsxV5phjrhSoNpuDTq8LHdiZ4WSTPw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K7kbq3xV;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4143A606A335;
	Mon, 16 Nov 2026 09:01:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K7kbq3xV
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794819705;
	b=E9e++MVUYPOj8P9HQH2thBMFUtOcpzHyYL6qHb5jwwwbhlBg8upAyUi4KpXG0EG/A5le
	 LE45CpVnoy5JIHb25foXDLGfvhoT8CmAWkzPHB86e6SRt3l96UZ9Voi3F5okhAhj2KcX0
	 qSa9QSckDXs5DK5+UsBHJvyXEmufGzc+pYscHNW1rT8Ddu1JZ/8r+kVfNDQj/P74MLzUK
	 QEIVKvJ5K4t5Z3aqsdxcreUB/ZipDVkhsdo6klO4KImnr2yOY8BfLsj1SqP4dH/ahf4B/
	 qAYbArQBTI28atf/pakgIGOS2B/lFZ+V2JUZCDYMEZUARH4gCpNzYts+eFhZJjd68Jw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794819705;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=INWogzm8PidxyjUr/FFx7LS/Jeuuu1yeGh+jYBpFEF4=;
	b=g7dwV132zYIjpw8PEF1PcmsDMqDbDbFf99Xn5OhCsQ7xpZd/n0LkpeTCXMrdP9sx00QV
	 hxLmsi2KmU5x7fOJcc6l307nwJuDhgAboRGGEqqrWeAze05fvH0M+MP3YoU9+e9OWXXVK
	 gnKGLcxfTNfPzbKjk8SBpQ5Ka3MSX7ItSUUUlvYRRiRBiEWBSpftn99u83ln3Fm1qoEmK
	 AxT/LjV9J0NrkxwRuYw6rI1Wi0b+DBJoVcXxCAG0jLgYYBUcPjgjv2CrYfXMrHVxDLhXU
	 MD22mniZjfDyRkPKlHV+P8VR/13vQIkL/99YyPG7me7mdm/40/ebqKQTeeM0phaPGQg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K7kbq3xV;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60557606A31C;
	Mon, 16 Nov 2026 09:01:45 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BB451F000C4;
	Mon, 16 Nov 2026 09:01:44 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794819705;
	bh=INWogzm8PidxyjUr/FFx7LS/Jeuuu1yeGh+jYBpFEF4=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=K7kbq3xVTbeXNgqE/m00Dbp5Pibd2rcnbtPD1z5d/ZOE75zzcL++Z/tI4Hia9fvYe
	 l5dzJnRf7a3gSqnTFcHpT7QA4xFeQ7RALAJnfr1jIQ7ZkXVXhgoiO11+y34aBZV6im
	 HKN6p8Yc9EEXAirgGxTrzMp9kG31uGJLYNFhpjJGjmzONwEucqhrL0lOZzN2G1b/fb
	 4cWZLzViAtSGplkqx/+jrfnWXhSrY6pbFST1GsAp5vgrLsTpD/cTI8N9/dhzP1asUS
	 lRyp8JpLcuwOYlN7DqvJd7iqc0iIEIw/IjrPPw1WIDjyKvho2XE6yPrP+ukMMZeO/Y
	 UVCz8/a+4Y4Hg==
X-Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com,
	kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org,
	davem@davemloft.net, andrew+netdev@lunn.ch, dtatulea@nvidia.com,
	moshe@nvidia.com, maorg@nvidia.com
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261110134320.34408-12-yishaih@nvidia.com>