[PATCH net-next 11/15] net: Add netif_rxq_has_xdp_only_mp()
From: Björn Töpel
Date: Tue Nov 24 2026 - 07:59:33 EST
A driver lays out an RX queue before it creates the page pools of that
queue, so it cannot ask a pool whether a memory provider backs it, and
a layout that depends on the provider has nothing to read.
Tell the driver from the queue. Return whether the provider of an RX
queue is XDP-only, which the next patch uses to keep an mlx5 queue
from waiting for buffers that its socket has not lent yet.
Page pools of a queue are created under the instance lock, which the
caller holds as well, so the answer agrees with the pools of that
queue. A queue index past the device's RX queues has no provider.
Signed-off-by: Björn Töpel <bjorn@xxxxxxxxxx>
---
include/net/netdev_queues.h | 1 +
net/core/netdev_rx_queue.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index c5335e935b7d..813388778797 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -235,6 +235,7 @@ void netdev_queue_config(struct net_device *dev, int rxq,
struct netdev_queue_config *qcfg);
bool netif_rxq_has_unreadable_mp(struct net_device *dev, unsigned int rxq_idx);
+bool netif_rxq_has_xdp_only_mp(struct net_device *dev, unsigned int rxq_idx);
/**
* DOC: Lockless queue stopping / waking helpers.
diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c
index 2e10201fc0c0..212f1b9415b3 100644
--- a/net/core/netdev_rx_queue.c
+++ b/net/core/netdev_rx_queue.c
@@ -94,6 +94,31 @@ bool netif_rxq_has_unreadable_mp(struct net_device *dev, unsigned int rxq_idx)
}
EXPORT_SYMBOL(netif_rxq_has_unreadable_mp);
+/**
+ * netif_rxq_has_xdp_only_mp() - whether an XDP-only provider backs an RX queue
+ * @dev: device of the queue
+ * @rxq_idx: RX queue of @dev itself, not of a lease
+ *
+ * The page pools of the queue that allow it take the provider, see
+ * %PP_FLAG_ALLOW_XDP_ONLY_NETMEM. They are created under the instance lock,
+ * which the caller holds, so they agree with the answer.
+ *
+ * Return: true if the queue has a provider with %MP_XDP_ONLY.
+ */
+bool netif_rxq_has_xdp_only_mp(struct net_device *dev, unsigned int rxq_idx)
+{
+ const struct memory_provider_ops *ops;
+
+ netdev_assert_locked(dev);
+
+ if (rxq_idx >= dev->real_num_rx_queues)
+ return false;
+
+ ops = __netif_get_rx_queue(dev, rxq_idx)->mp_params.mp_ops;
+ return ops && ops->flags & MP_XDP_ONLY;
+}
+EXPORT_SYMBOL(netif_rxq_has_xdp_only_mp);
+
bool netif_rxq_has_mp(struct net_device *dev, unsigned int rxq_idx)
{
if (rxq_idx < dev->real_num_rx_queues)
--
2.56.1