From: Pavel Begunkov <asml.silence@gmail.com>
To: Dragos Tatulea <dtatulea@nvidia.com>,
almasrymina@google.com, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
tariqt@nvidia.com, cratiu@nvidia.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC net-next 1/4] net: Allow non parent devices to be used for ZC DMA
Date: Tue, 8 Jul 2025 12:06:29 +0100 [thread overview]
Message-ID: <32cb77d8-a4a5-4fc7-a427-d723e60efc59@gmail.com> (raw)
In-Reply-To: <20250702172433.1738947-2-dtatulea@nvidia.com>
On 7/2/25 18:24, Dragos Tatulea wrote:
> For zerocopy (io_uring, devmem), there is an assumption that the
> parent device can do DMA. However that is not always the case:
> for example mlx5 SF devices have an auxiliary device as a parent.
>
> This patch introduces the possibility for the driver to specify
> another DMA device to be used via the new dma_dev field. The field
> should be set before register_netdev().
>
> A new helper function is added to get the DMA device or return NULL.
> The callers can check for NULL and fail early if the device is
> not capable of DMA.
>
> Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
> ---
> include/linux/netdevice.h | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 5847c20994d3..83faa2314c30 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2550,6 +2550,9 @@ struct net_device {
>
> struct hwtstamp_provider __rcu *hwprov;
>
> + /* To be set by devices that can do DMA but not via parent. */
> + struct device *dma_dev;
> +
> u8 priv[] ____cacheline_aligned
> __counted_by(priv_len);
> } ____cacheline_aligned;
> @@ -5560,4 +5563,14 @@ extern struct net_device *blackhole_netdev;
> atomic_long_add((VAL), &(DEV)->stats.__##FIELD)
> #define DEV_STATS_READ(DEV, FIELD) atomic_long_read(&(DEV)->stats.__##FIELD)
>
> +static inline struct device *netdev_get_dma_dev(const struct net_device *dev)
> +{
> + struct device *dma_dev = dev->dma_dev ? dev->dma_dev : dev->dev.parent;
> +
> + if (!dma_dev->dma_mask)
dev->dev.parent is NULL for veth and I assume other virtual devices as well.
Mina, can you verify that devmem checks that? Seems like veth is rejected
by netdev_need_ops_lock() in netdev_nl_bind_rx_doit(), but IIRC per netdev
locking came after devmem got merged, and there are other virt devices that
might already be converted.
> + dma_dev = NULL;
> +
> + return dma_dev;
> +}
> +
> #endif /* _LINUX_NETDEVICE_H */
--
Pavel Begunkov
next prev parent reply other threads:[~2025-07-08 11:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 17:24 [RFC net-next 0/4] devmem/io_uring: Allow devices without parent PCI device Dragos Tatulea
2025-07-02 17:24 ` [RFC net-next 1/4] net: Allow non parent devices to be used for ZC DMA Dragos Tatulea
2025-07-02 18:32 ` Jakub Kicinski
2025-07-02 20:01 ` Dragos Tatulea
2025-07-02 20:53 ` Jakub Kicinski
2025-07-03 11:58 ` Parav Pandit
2025-07-04 13:11 ` Dragos Tatulea
2025-07-07 18:44 ` Mina Almasry
2025-07-07 21:35 ` Dragos Tatulea
2025-07-07 21:55 ` Mina Almasry
2025-07-08 8:52 ` Parav Pandit
2025-07-08 10:47 ` Pavel Begunkov
2025-07-08 14:23 ` Dragos Tatulea
2025-07-08 11:08 ` Pavel Begunkov
2025-07-08 14:26 ` Dragos Tatulea
2025-07-10 23:58 ` Jakub Kicinski
2025-07-11 2:52 ` Parav Pandit
2025-07-11 13:51 ` Jakub Kicinski
2025-07-08 11:06 ` Pavel Begunkov [this message]
2025-07-08 14:10 ` Mina Almasry
2025-07-08 15:25 ` Pavel Begunkov
2025-07-02 17:24 ` [RFC net-next 2/4] io_uring/zcrx: Use the new netdev_get_dma_dev() API Dragos Tatulea
2025-07-02 17:24 ` [RFC net-next 3/4] net: devmem: " Dragos Tatulea
2025-07-02 17:24 ` [RFC net-next 4/4] net/mlx5e: Enable HDS zerocopy flows for SFs Dragos Tatulea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32cb77d8-a4a5-4fc7-a427-d723e60efc59@gmail.com \
--to=asml.silence@gmail.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).