From: Daniel Zahka <daniel.zahka@gmail.com>
To: Alexander Duyck <alexanderduyck@fb.com>,
Jakub Kicinski <kuba@kernel.org>,
kernel-team@meta.com, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next 4/4] eth: mpnic: add a NAPI depletion check
Date: Thu, 01 Oct 2026 09:39:01 -0700 [thread overview]
Message-ID: <20261001-linux-mpnic-v1-4-6422ee74233a@gmail.com> (raw)
In-Reply-To: <20261001-linux-mpnic-v1-0-6422ee74233a@gmail.com>
The Rx path can wedge if page pool allocations fail in
__mpnic_fill_bdq(). The problematic sequence is: page pool allocations
fail, bdq rings are empty, device receives packet from the network, but
drops it for lack of buffer space and does not raise interrupt,
mpnic_poll() does not run, so page pool allocations are not retried.
To break out of this cycle, we can add a depletion check to our service
task. The depletion check checks if posted buffers are under a low
watermark, and raises a completion queue interrupt, so that mpnic_poll
will run on the corresponding napi vector.
A note about the lock free reads: We don't bother synchronizing the ring
head and tail reads with mpnic_poll(), because a false positive signal
would simply raise a spurious interrupt scheduling mpnic_poll(), and a
false negative signal will result in a retry, where if mpnic_poll() has
truly not been running, should then report accurately whether or not
posted Rx buffers are low.
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
---
drivers/net/ethernet/meta/mpnic/mpnic_pci.c | 4 ++++
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c | 31 ++++++++++++++++++++++++++++
drivers/net/ethernet/meta/mpnic/mpnic_txrx.h | 1 +
3 files changed, 36 insertions(+)
diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_pci.c b/drivers/net/ethernet/meta/mpnic/mpnic_pci.c
index 17eae5a9ba16..125fb26edf93 100644
--- a/drivers/net/ethernet/meta/mpnic/mpnic_pci.c
+++ b/drivers/net/ethernet/meta/mpnic/mpnic_pci.c
@@ -11,6 +11,7 @@
#include "mpnic.h"
#include "mpnic_netdev.h"
+#include "mpnic_txrx.h"
#define PCI_DEVICE_ID_META_MPNIC 0x0014
@@ -61,6 +62,9 @@ static void mpnic_service_task(struct work_struct *work)
netdev_lock(netdev);
+ if (netif_carrier_ok(netdev))
+ mpnic_napi_depletion_check(netdev_priv(netdev));
+
if (netif_running(netdev))
schedule_delayed_work(&mpd->service_task, HZ);
diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
index 49061c7316d5..5495e9a9aa65 100644
--- a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
+++ b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.c
@@ -55,6 +55,12 @@ static unsigned int mpnic_desc_unused(struct mpnic_ring *ring)
return (ring->head - ring->tail - 1) & ring->size_mask;
}
+static unsigned int mpnic_desc_used(struct mpnic_ring *ring)
+{
+ return (READ_ONCE(ring->tail) - READ_ONCE(ring->head)) &
+ ring->size_mask;
+}
+
static struct netdev_queue *mpnic_txring_txq(const struct net_device *dev,
const struct mpnic_ring *ring)
{
@@ -1393,3 +1399,28 @@ void mpnic_napi_enable(struct mpnic_net *mpn)
mpnic_wrfl(mpn->mpd);
}
+
+void mpnic_napi_depletion_check(struct mpnic_net *mpn)
+{
+ int i, j, t;
+
+ for (i = 0; i < mpn->num_napi; i++) {
+ struct mpnic_napi_vector *nv = mpn->napi[i];
+
+ for (t = nv->txt_count, j = 0; j < nv->rxt_count; j++, t++) {
+ /* Check if BDs posted covers a max sized frame
+ * + 1 BD held by RDE as a spare
+ * + 1 BD of extra safety margin
+ */
+ if (mpnic_desc_used(&nv->qt[t].sub0) <
+ MPNIC_RX_HPQ_DROP_THRS + 2 ||
+ mpnic_desc_used(&nv->qt[t].sub1) <
+ MPNIC_RX_PPQ_DROP_THRS + 2) {
+ mpnic_nv_irq_trigger(nv);
+ break;
+ }
+ }
+ }
+
+ mpnic_wrfl(mpn->mpd);
+}
diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
index 9397010557eb..767d87a36c35 100644
--- a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
+++ b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
@@ -148,6 +148,7 @@ int mpnic_set_netif_queues(struct mpnic_net *mpn);
void mpnic_reset_netif_queues(struct mpnic_net *mpn);
void mpnic_napi_enable(struct mpnic_net *mpn);
void mpnic_napi_disable(struct mpnic_net *mpn);
+void mpnic_napi_depletion_check(struct mpnic_net *mpn);
void mpnic_enable(struct mpnic_net *mpn);
void mpnic_disable(struct mpnic_net *mpn);
void mpnic_wait_all_queues_idle(struct mpnic_dev *mpd);
--
2.52.0
next prev parent reply other threads:[~2026-10-01 16:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 16:38 [PATCH net-next 0/4] mpnic: add NAPI buffer " Daniel Zahka
2026-10-01 16:38 ` [PATCH net-next 1/4] eth: mpnic: use WRITE_ONCE() for BDQ head and tail updates Daniel Zahka
2026-10-01 16:38 ` [PATCH net-next 2/4] eth: mpnic: add a service task Daniel Zahka
2026-10-01 16:39 ` [PATCH net-next 3/4] eth: mpnic: set Rx buffer minimums using page size and mtu Daniel Zahka
2026-10-01 16:39 ` Daniel Zahka [this message]
2026-10-01 16:45 ` [PATCH net-next 0/4] mpnic: add NAPI buffer depletion check netdev-bot+sinfo
2026-10-01 18:26 ` Daniel Zahka
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=20261001-linux-mpnic-v1-4-6422ee74233a@gmail.com \
--to=daniel.zahka@gmail.com \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®