All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, horms@kernel.org, almasrymina@google.com,
	michael.chan@broadcom.com, tariqt@nvidia.com,
	dtatulea@nvidia.com, hawk@kernel.org,
	ilias.apalodimas@linaro.org, alexanderduyck@fb.com,
	sdf@fomichev.me, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 11/15] net: page_pool: add helper to pre-check if PP will be unreadable
Date: Tue, 19 Aug 2025 19:57:00 -0700	[thread overview]
Message-ID: <20250820025704.166248-12-kuba@kernel.org> (raw)
In-Reply-To: <20250820025704.166248-1-kuba@kernel.org>

mlx5 pokes into the rxq state to check if the queue has a memory
provider, and therefore whether it may produce unreable mem.
Add a helper for doing this in the page pool API. fbnic will want
a similar thing (tho, for a slightly different reason).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 include/net/page_pool/helpers.h                   |  9 +++++++++
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 ++--------
 net/core/page_pool.c                              |  8 ++++++++
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h
index aa3719f28216..307c2436fa12 100644
--- a/include/net/page_pool/helpers.h
+++ b/include/net/page_pool/helpers.h
@@ -505,6 +505,15 @@ static inline void page_pool_nid_changed(struct page_pool *pool, int new_nid)
 		page_pool_update_nid(pool, new_nid);
 }
 
+bool __page_pool_rxq_wants_unreadable(struct net_device *dev, unsigned int qid);
+
+static inline bool
+page_pool_rxq_wants_unreadable(const struct page_pool_params *pp_params)
+{
+	return __page_pool_rxq_wants_unreadable(pp_params->netdev,
+						pp_params->queue_idx);
+}
+
 static inline bool page_pool_is_unreadable(struct page_pool *pool)
 {
 	return !!pool->mp_ops;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 21bb88c5d3dc..cee96ded300e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -42,6 +42,7 @@
 #include <net/netdev_lock.h>
 #include <net/netdev_queues.h>
 #include <net/netdev_rx_queue.h>
+#include <net/page_pool/helpers.h>
 #include <net/page_pool/types.h>
 #include <net/pkt_sched.h>
 #include <net/xdp_sock_drv.h>
@@ -777,13 +778,6 @@ static void mlx5e_rq_shampo_hd_info_free(struct mlx5e_rq *rq)
 	bitmap_free(rq->mpwqe.shampo->bitmap);
 }
 
-static bool mlx5_rq_needs_separate_hd_pool(struct mlx5e_rq *rq)
-{
-	struct netdev_rx_queue *rxq = __netif_get_rx_queue(rq->netdev, rq->ix);
-
-	return !!rxq->mp_params.mp_ops;
-}
-
 static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev,
 				struct mlx5e_params *params,
 				struct mlx5e_rq_param *rqp,
@@ -822,7 +816,7 @@ static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev,
 	hd_pool_size = (rq->mpwqe.shampo->hd_per_wqe * wq_size) /
 		MLX5E_SHAMPO_WQ_HEADER_PER_PAGE;
 
-	if (mlx5_rq_needs_separate_hd_pool(rq)) {
+	if (__page_pool_rxq_wants_unreadable(rq->netdev, rq->ix)) {
 		/* Separate page pool for shampo headers */
 		struct page_pool_params pp_params = { };
 
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 343a6cac21e3..9f087a6742c3 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -190,6 +190,14 @@ static void page_pool_struct_check(void)
 				    PAGE_POOL_FRAG_GROUP_ALIGN);
 }
 
+bool __page_pool_rxq_wants_unreadable(struct net_device *dev, unsigned int qid)
+{
+	struct netdev_rx_queue *rxq = __netif_get_rx_queue(dev, qid);
+
+	return !!rxq->mp_params.mp_ops;
+}
+EXPORT_SYMBOL(__page_pool_rxq_wants_unreadable);
+
 static int page_pool_init(struct page_pool *pool,
 			  const struct page_pool_params *params,
 			  int cpuid)
-- 
2.50.1


  parent reply	other threads:[~2025-08-20  2:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20  2:56 [PATCH net-next 00/15] eth: fbnic: support queue API and zero-copy Rx Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 01/15] net: page_pool: add page_pool_get() Jakub Kicinski
2025-08-20 10:35   ` Jesper Dangaard Brouer
2025-08-20 10:58   ` Dragos Tatulea
2025-08-20 23:11   ` Mina Almasry
2025-08-20  2:56 ` [PATCH net-next 02/15] eth: fbnic: move page pool pointer from NAPI to the ring struct Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 03/15] eth: fbnic: move xdp_rxq_info_reg() to resource alloc Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 04/15] eth: fbnic: move page pool alloc to fbnic_alloc_rx_qt_resources() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 05/15] eth: fbnic: use netmem_ref where applicable Jakub Kicinski
2025-08-20 23:22   ` Mina Almasry
2025-08-20  2:56 ` [PATCH net-next 06/15] eth: fbnic: request ops lock Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 07/15] eth: fbnic: split fbnic_disable() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 08/15] eth: fbnic: split fbnic_flush() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 09/15] eth: fbnic: split fbnic_enable() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 10/15] eth: fbnic: split fbnic_fill() Jakub Kicinski
2025-08-20  2:57 ` Jakub Kicinski [this message]
2025-08-20 11:30   ` [PATCH net-next 11/15] net: page_pool: add helper to pre-check if PP will be unreadable Dragos Tatulea
2025-08-20 14:52     ` Jakub Kicinski
2025-08-20 17:45       ` Dragos Tatulea
2025-08-20  2:57 ` [PATCH net-next 12/15] eth: fbnic: allocate unreadable page pool for the payloads Jakub Kicinski
2025-08-20 23:33   ` Mina Almasry
2025-08-21  0:45     ` Jakub Kicinski
2025-08-20  2:57 ` [PATCH net-next 13/15] eth: fbnic: defer page pool recycling activation to queue start Jakub Kicinski
2025-08-20  2:57 ` [PATCH net-next 14/15] eth: fbnic: don't pass NAPI into pp alloc Jakub Kicinski
2025-08-20  2:57 ` [PATCH net-next 15/15] eth: fbnic: support queue ops / zero-copy Rx Jakub Kicinski
2025-08-21  7:51 ` [PATCH net-next 00/15] eth: fbnic: support queue API and " Paolo Abeni
2025-08-21 14:28   ` Jakub Kicinski
2025-08-21 14:53     ` Taehee Yoo
2025-08-21 15:03       ` Jakub Kicinski
2025-08-21 15:22         ` Mina Almasry
2025-08-21 15:42           ` Jakub Kicinski
2025-08-21 15:02     ` Paolo Abeni
2025-08-21 15:20 ` patchwork-bot+netdevbpf

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=20250820025704.166248-12-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=alexanderduyck@fb.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.