mpnic: add NAPI buffer depletion check
Subsystems (3)
cover mpnic: add NAPI buffer depletion check
This series provides a buffer depletion check to unwedge Rx processing when page pool allocations have failed. Patch 4 has a more detailed description of the events that lead to the wedge, but the high level idea is that when page pool allocations fail, the buffer descriptor ring can run low, and when that happens the device will drop Rx packets and not raise interrupts, which causes the NAPI event loop not to be scheduled, so new buffers are not posted.
There are three setup patches for the depletion check:
Patch 1: convert writes to BDQ ring head and tail to WRITE_ONCE(), so the depletion check, which is not synchronized with the NAPI event loop, can READ_ONCE() those same fields.
Patch 2: introduce the driver level service task that runs once per second while the netif is running.
Patch 3: set the minimum Rx buffers needed per packet based on page size and max MTU.
With those in place, we have everything we need to watch the buffer ring head and tail positions from the service task, compare posted buffers to programmed Rx drop thresholds, and then force mpnic_poll() to run if needed.
---
Daniel Zahka (4):
eth: mpnic: use WRITE_ONCE() for BDQ head and tail updates
eth: mpnic: add a service task
eth: mpnic: set Rx buffer minimums using page size and mtu
eth: mpnic: add a NAPI depletion check
drivers/net/ethernet/meta/mpnic/mpnic.h | 3 +++ drivers/net/ethernet/meta/mpnic/mpnic_init.c | 13 ++++++--- drivers/net/ethernet/meta/mpnic/mpnic_netdev.c | 3 +++ drivers/net/ethernet/meta/mpnic/mpnic_pci.c | 21 +++++++++++++++ drivers/net/ethernet/meta/mpnic/mpnic_txrx.c | 37 +++++++++++++++++++++++--- drivers/net/ethernet/meta/mpnic/mpnic_txrx.h | 7 +++++ 6 files changed, 77 insertions(+), 7 deletions(-)
---
base-commit: eb0c18404c8943356f4aa164e5db9067b79ea93c
change-id: 20260929-linux-mpnic-428998421ffc
Best regards,
Signature · 1 line
Daniel Zahka <[email protected]>
PATCH 1/4 eth: mpnic: use WRITE_ONCE() for BDQ head and tail updates
Convert writes to BDQ ring head and tail in the NAPI path to WRITE_ONCE(), so that a buffer NAPI depletion check task later in the series can READ_ONCE() those fields from a workqueue outside of NAPI. The remaining writers in mpnic_enable_bdq() and mpnic_clean_bdq() run with NAPI disabled and the instance lock, so don't bother converting them. The NAPI depletion check later in the series will run under the instance lock.
--- drivers/net/ethernet/meta/mpnic/mpnic_txrx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c +3 -3
@@ -384,7 +384,7 @@ static unsigned int __mpnic_fill_bdq(struct mpnic_ring *bdq)static void __mpnic_bdq_commit_tail (struct mpnic_ring *bdq,unsigned int tail) {if (bdq->tail != tail) { - bdq->tail = tail; +WRITE_ONCE (bdq->tail, tail);writeq (tail, bdq->doorbell); }
@@ -483,7 +483,7 @@ mpnic_pkt_prepare(u64 rcd, struct mpnic_rcq_state *state, pg_start =mpnic_hdr_pg_start (pg_off); page =mpnic_page_pool_get (&state->hdr, &qt->sub0, pg_idx); - qt->sub0.head = (pg_idx +1 ) & qt->sub0.size_mask; +WRITE_ONCE (qt->sub0.head, (pg_idx +1 ) & qt->sub0.size_mask);/* Short-cut the end calculation if the page is fully consumed */ pg_end = fin ?page_size (page) :mpnic_hdr_pg_end (pg_off, len);
@@ -513,7 +513,7 @@ mpnic_add_rx_frag(u64 rcd, struct mpnic_rcq_state *state,struct page *page; page =mpnic_page_pool_get (&state->payld, &qt->sub1, pg_idx); - qt->sub1.head = (pg_idx +1 ) & qt->sub1.size_mask; +WRITE_ONCE (qt->sub1.head, (pg_idx +1 ) & qt->sub1.size_mask); truesz = (fin ?page_size (page) :ALIGN (pg_off + len,128 )) - pg_off;
Signature · 1 line
2.52.0
PATCH 2/4 eth: mpnic: add a service task
In reply to Daniel ZahkaAdd a service task that runs while the netdevice is running. For now, the service task does nothing besides conditionally reschedule itself.
--- drivers/net/ethernet/meta/mpnic/mpnic.h | 3 +++ drivers/net/ethernet/meta/mpnic/mpnic_netdev.c | 3 +++ drivers/net/ethernet/meta/mpnic/mpnic_pci.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+)
drivers/net/ethernet/meta/mpnic/mpnic.h +3 -0
@@ -7,6 +7,7 @@#include <linux/interrupt.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/types.h> +#include <linux/workqueue.h> #include "mpnic_csr.h"
@@ -27,6 +28,8 @@ struct mpnic_dev {u32 __iomem *uc_addr0; +struct delayed_work service_task; +u16 num_irqs;u64 dsn;
drivers/net/ethernet/meta/mpnic/mpnic_netdev.c +3 -0
@@ -35,6 +35,8 @@ static int mpnic_open(struct net_device *netdev)netif_tx_wake_all_queues (netdev);netif_carrier_on (netdev); +schedule_delayed_work (&mpn->mpd->service_task,HZ ); +return 0 ; err_free_resources:
@@ -48,6 +50,7 @@ static int mpnic_stop(struct net_device *netdev) {struct mpnic_net *mpn =netdev_priv (netdev); +cancel_delayed_work (&mpn->mpd->service_task);netif_carrier_off (netdev);mpnic_napi_disable (mpn);
drivers/net/ethernet/meta/mpnic/mpnic_pci.c +17 -0
@@ -53,6 +53,20 @@ u64 mpnic_rd64(struct mpnic_dev *mpd, u32 reg)return ~0ULL ; } +static void mpnic_service_task (struct work_struct *work) +{ +struct mpnic_dev *mpd =container_of (to_delayed_work (work), + struct mpnic_dev, service_task); +struct net_device *netdev = mpd->netdev; + +netdev_lock (netdev); + +if (netif_running (netdev)) +schedule_delayed_work (&mpd->service_task,HZ ); + +netdev_unlock (netdev); +} +static struct mpnic_dev *mpnic_alloc (struct pci_dev *pdev) {struct mpnic_dev *mpd;
@@ -69,6 +83,8 @@ static struct mpnic_dev *mpnic_alloc(struct pci_dev *pdev) mpd->readrq =pcie_get_readrq (pdev); mpd->relaxed_ord =pcie_relaxed_ordering_enabled (pdev); +INIT_DELAYED_WORK (&mpd->service_task, mpnic_service_task); +return mpd; }
@@ -162,6 +178,7 @@ static void mpnic_remove(struct pci_dev *pdev)struct mpnic_dev *mpd =pci_get_drvdata (pdev);unregister_netdev (mpd->netdev); +cancel_delayed_work_sync (&mpd->service_task);mpnic_netdev_free (mpd);mpnic_free_irqs (mpd);kfree (mpd);
Signature · 1 line
2.52.0
PATCH 3/4 eth: mpnic: set Rx buffer minimums using page size and mtu
In reply to Daniel ZahkaSet buffer based drop thresholds in the Rx path based on page size and the max MTU supported. The device will drop packets if it does not have at least the minimum number of completely unused buffer descriptors available.
These thresholds are currently set to 17 BDs for both HPQ and PPQ. These are overly conservative. With our current max MTU of 9742B, the settings we should target are:
4KiB page size: 1 HPQ, 3 PPQ
64KiB page size: 1 HPQ, 1 PPQ
The HPQ and PPQ rings are always given PAGE_SIZE sized buffers.
The RDE_CTL register encodes the thresholds as one less than the number of BDs needed.
--- drivers/net/ethernet/meta/mpnic/mpnic_init.c | 13 +++++++++---- drivers/net/ethernet/meta/mpnic/mpnic_txrx.h | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-)
drivers/net/ethernet/meta/mpnic/mpnic_init.c +9 -4
@@ -10,6 +10,7 @@#include <linux/sizes.h> #include "mpnic.h" +#include "mpnic_txrx.h" #define MPNIC_MEM_INIT_POLL_US 500#define MPNIC_MEM_INIT_TO_US 5000
@@ -272,10 +273,14 @@ static void mpnic_rxglb_init(struct mpnic_dev *mpd)* the per-queue prefetch FIFO. */ mpnic_wr64 (mpd,MPNIC_RDE_CTL , -FIELD_PREP (MPNIC_RDE_CTL_HPQ_DROP_THRESHOLD ,16 ) | -FIELD_PREP (MPNIC_RDE_CTL_PPQ_DROP_THRESHOLD ,16 ) | -FIELD_PREP (MPNIC_RDE_CTL_HPQ_LOCAL_DROP_THRESHOLD ,16 ) | -FIELD_PREP (MPNIC_RDE_CTL_PPQ_LOCAL_DROP_THRESHOLD ,16 )); +FIELD_PREP (MPNIC_RDE_CTL_HPQ_DROP_THRESHOLD , +MPNIC_RX_HPQ_DROP_THRS -1 ) | +FIELD_PREP (MPNIC_RDE_CTL_PPQ_DROP_THRESHOLD , +MPNIC_RX_PPQ_DROP_THRS -1 ) | +FIELD_PREP (MPNIC_RDE_CTL_HPQ_LOCAL_DROP_THRESHOLD , +MPNIC_RX_HPQ_DROP_THRS -1 ) | +FIELD_PREP (MPNIC_RDE_CTL_PPQ_LOCAL_DROP_THRESHOLD , +MPNIC_RX_PPQ_DROP_THRS -1 ));/* Receive side coalescing is not supported yet */ mpnic_wr64(mpd, MPNIC_RSC_GLOBAL_CONF,
drivers/net/ethernet/meta/mpnic/mpnic_txrx.h +6 -0
@@ -58,6 +58,12 @@ struct mpnic_net;#define MPNIC_MAX_JUMBO_FRAME_SIZE 9742 +#define MPNIC_RX_HPQ_DROP_THRS \ + DIV_ROUND_UP(MPNIC_RX_HROOM + MPNIC_RX_MAX_HDR + MPNIC_RX_TROOM, \ + PAGE_SIZE) +#define MPNIC_RX_PPQ_DROP_THRS \ + DIV_ROUND_UP(MPNIC_MAX_JUMBO_FRAME_SIZE, PAGE_SIZE) +/* The page a buffer descriptor queue is currently handing out. Records * how many of the references taken on it are still unused. */
Signature · 1 line
2.52.0
Re: [PATCH net-next 3/4] eth: mpnic: set Rx buffer minimums using page size and mtu
Quoted 7 lines · Daniel Zahka
Set buffer based drop thresholds in the Rx path based on page size and the max MTU supported. The device will drop packets if it does not have at least the minimum number of completely unused buffer descriptors available.
These thresholds are currently set to 17 BDs for both HPQ and PPQ. These
nit: if there is a v2, it would be helpful for review if terms like PPQ/HPQ were expanded here.
Quoted 70 lines
are overly conservative. With our current max MTU of 9742B, the settings we should target are:
4KiB page size: 1 HPQ, 3 PPQ
64KiB page size: 1 HPQ, 1 PPQThe HPQ and PPQ rings are always given
PAGE_SIZEsized buffers.The
RDE_CTLregister encodes the thresholds as one less than the number of BDs needed.Signed-off-by Daniel Zahka <[email protected]>--- drivers/net/ethernet/meta/mpnic/mpnic_init.c | 13 +++++++++---- drivers/net/ethernet/meta/mpnic/mpnic_txrx.h | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-)drivers/net/ethernet/meta/mpnic/mpnic_init.c +9
-4@@ -10,6 +10,7 @@#include <linux/sizes.h> #include "mpnic.h" +#include "mpnic_txrx.h" #define MPNIC_MEM_INIT_POLL_US 500#define MPNIC_MEM_INIT_TO_US 5000@@ -272,10 +273,14 @@ static void mpnic_rxglb_init(struct mpnic_dev *mpd)* the per-queue prefetch FIFO. */ mpnic_wr64 (mpd,MPNIC_RDE_CTL , -FIELD_PREP (MPNIC_RDE_CTL_HPQ_DROP_THRESHOLD ,16 ) | -FIELD_PREP (MPNIC_RDE_CTL_PPQ_DROP_THRESHOLD ,16 ) | -FIELD_PREP (MPNIC_RDE_CTL_HPQ_LOCAL_DROP_THRESHOLD ,16 ) | -FIELD_PREP (MPNIC_RDE_CTL_PPQ_LOCAL_DROP_THRESHOLD ,16 )); +FIELD_PREP (MPNIC_RDE_CTL_HPQ_DROP_THRESHOLD , +MPNIC_RX_HPQ_DROP_THRS -1 ) | +FIELD_PREP (MPNIC_RDE_CTL_PPQ_DROP_THRESHOLD , +MPNIC_RX_PPQ_DROP_THRS -1 ) | +FIELD_PREP (MPNIC_RDE_CTL_HPQ_LOCAL_DROP_THRESHOLD , +MPNIC_RX_HPQ_DROP_THRS -1 ) | +FIELD_PREP (MPNIC_RDE_CTL_PPQ_LOCAL_DROP_THRESHOLD , +MPNIC_RX_PPQ_DROP_THRS -1 ));/* Receive side coalescing is not supported yet */ mpnic_wr64(mpd, MPNIC_RSC_GLOBAL_CONF,drivers/net/ethernet/meta/mpnic/mpnic_txrx.h +6
-1@@ -58,6 +58,12 @@ struct mpnic_net;#define MPNIC_MAX_JUMBO_FRAME_SIZE 9742 +#define MPNIC_RX_HPQ_DROP_THRS \ + DIV_ROUND_UP(MPNIC_RX_HROOM + MPNIC_RX_MAX_HDR + MPNIC_RX_TROOM, \ + PAGE_SIZE) +#define MPNIC_RX_PPQ_DROP_THRS \ + DIV_ROUND_UP(MPNIC_MAX_JUMBO_FRAME_SIZE, PAGE_SIZE) +/* The page a buffer descriptor queue is currently handing out. Records * how many of the references taken on it are still unused. */ --2.52.0
Re: [PATCH net-next 3/4] eth: mpnic: set Rx buffer minimums using page size and mtu
Quoted 7 lines · Harshitha Ramamurthy
Quoted 6 lines · Daniel Zahka
Set buffer based drop thresholds in the Rx path based on page size and the max MTU supported. The device will drop packets if it does not have at least the minimum number of completely unused buffer descriptors available.
Quoted 5 lines
Quoted 1 line
These thresholds are currently set to 17 BDs for both HPQ and PPQ. These
nit: if there is a v2, it would be helpful for review if terms like PPQ/HPQ were expanded here.
Thanks for taking a look. The acronyms are:
HPQ: header page queue
PPQ: payload page queue
PATCH 4/4 eth: mpnic: add a NAPI depletion check
In reply to Daniel ZahkaThe 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.
--- 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(+)
drivers/net/ethernet/meta/mpnic/mpnic_pci.c +4 -0
@@ -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 );
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c +31 -0
@@ -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); +}
drivers/net/ethernet/meta/mpnic/mpnic_txrx.h +1 -0
@@ -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);
Signature · 1 line
2.52.0
Re: [PATCH net-next 4/4] eth: mpnic: add a NAPI depletion check
Quoted 72 lines · Daniel Zahka
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_pollwill 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 schedulingmpnic_poll(), and a false negative signal will result in a retry, where ifmpnic_poll()has truly not been running, should then report accurately whether or not posted Rx buffers are low.Signed-off-by Daniel Zahka <[email protected]>--- 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(+)drivers/net/ethernet/meta/mpnic/mpnic_pci.c +4
-0@@ -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 );drivers/net/ethernet/meta/mpnic/mpnic_txrx.c +9
-0@@ -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) +{
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c void mpnic_napi_enable(struct mpnic_net *mpn) · line 1414
Quoted 10 lines
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c +10
-0+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 +*/
Curious how the "+ 1 BD of extra safety margin" was decided. I understand the "+ 1 BD held by RDE as a spare" is because of HW behaviour but wondering about the extra buffer descriptor - if it came from testing or guarding against something specific.
Quoted 29 lines
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c +12
-0+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); +}drivers/net/ethernet/meta/mpnic/mpnic_txrx.h +1
-1@@ -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
Re: [PATCH net-next 4/4] eth: mpnic: add a NAPI depletion check
Quoted 1 line · Harshitha Ramamurthy
On Thu, Oct 1, 2026 at 9:41 AM Daniel Zahka <[email protected]> wrote:
[...]
Quoted 18 lines
+void
mpnic_napi_depletion_check(struct mpnic_net *mpn)drivers/net/ethernet/meta/mpnic/mpnic_txrx.c void mpnic_napi_enable(struct mpnic_net *mpn) · line 1414
Quoted 11 lines
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c +11
-0+{ +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 +*/ Curious how the "+ 1 BD of extra safety margin" was decided. I understand the "+ 1 BD held by RDE as a spare" is because of HW behaviour but wondering about the extra buffer descriptor - if it came from testing or guarding against something specific.
The extra +1 isn't strictly necessary. The real lower bound is MPNIC_RX_HPQ_DROP_THRS + 1, which was derived from the design of the device and our napi poll implementation. I added an extra BD count because the actual bound doesn't matter as long as its conservative. Perhaps that's a bit superstitious.
Quoted 29 lines
Quoted 29 lines
drivers/net/ethernet/meta/mpnic/mpnic_txrx.c +12
-0+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); +}drivers/net/ethernet/meta/mpnic/mpnic_txrx.h +1
-1@@ -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
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Quoted 17 lines · netdev-bot+sinfo
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
Quoted 8 lines
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
This is not a fix. See:
https://lore.kernel.org/netdev/[email protected]/
Quoted 26 lines · Daniel Zahka
This series provides a buffer depletion check to unwedge Rx processing when page pool allocations have failed. Patch 4 has a more detailed description of the events that lead to the wedge, but the high level idea is that when page pool allocations fail, the buffer descriptor ring can run low, and when that happens the device will drop Rx packets and not raise interrupts, which causes the NAPI event loop not to be scheduled, so new buffers are not posted.
There are three setup patches for the depletion check:
Patch 1: convert writes to BDQ ring head and tail to
WRITE_ONCE(), so the depletion check, which is not synchronized with the NAPI event loop, canREAD_ONCE()those same fields.Patch 2: introduce the driver level service task that runs once per second while the netif is running.
Patch 3: set the minimum Rx buffers needed per packet based on page size and max MTU.
With those in place, we have everything we need to watch the buffer ring head and tail positions from the service task, compare posted buffers to programmed Rx drop thresholds, and then force
mpnic_poll()to run if needed.
Quoted 7 lines
Signed-off-by Daniel Zahka <[email protected]>---
Daniel Zahka (4):
eth: mpnic: useWRITE_ONCE()for BDQ head and tail updates
eth: mpnic: add a service task
eth: mpnic: set Rx buffer minimums using page size and mtu
eth: mpnic: add a NAPI depletion check
For the series:
Quoted 17 lines
drivers/net/ethernet/meta/mpnic/mpnic.h | 3 +++ drivers/net/ethernet/meta/mpnic/mpnic_init.c | 13 ++++++--- drivers/net/ethernet/meta/mpnic/mpnic_netdev.c | 3 +++ drivers/net/ethernet/meta/mpnic/mpnic_pci.c | 21 +++++++++++++++ drivers/net/ethernet/meta/mpnic/mpnic_txrx.c | 37 +++++++++++++++++++++++--- drivers/net/ethernet/meta/mpnic/mpnic_txrx.h | 7 +++++ 6 files changed, 77 insertions(+), 7 deletions(-)---
base-commit:eb0c18404c8943356f4aa164e5db9067b79ea93c
change-id: 20260929-linux-mpnic-428998421ffcBest regards,
--
Daniel Zahka <[email protected]>
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 01 Oct 2026 09:38:57 -0700 you wrote:
This series provides a buffer depletion check to unwedge Rx processing when page pool allocations have failed. Patch 4 has a more detailed description of the events that lead to the wedge, but the high level idea is that when page pool allocations fail, the buffer descriptor ring can run low, and when that happens the device will drop Rx packets and not raise interrupts, which causes the NAPI event loop not to be scheduled, so new buffers are not posted.
[...]
Here is the summary with links:
- [net-next,1/4] eth: mpnic: use WRITE_ONCE() for BDQ head and tail updates
https://git.kernel.org/netdev/net-next/c/0de04d82b63c - [net-next,2/4] eth: mpnic: add a service task https://git.kernel.org/netdev/net-next/c/d990f86c796b - [net-next,3/4] eth: mpnic: set Rx buffer minimums using page size and mtu https://git.kernel.org/netdev/net-next/c/9e072eda51ca - [net-next,4/4] eth: mpnic: add a NAPI depletion check https://git.kernel.org/netdev/net-next/c/56f2178ff7f6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html