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 3/4] eth: mpnic: set Rx buffer minimums using page size and mtu
Date: Thu, 01 Oct 2026 09:39:00 -0700 [thread overview]
Message-ID: <20261001-linux-mpnic-v1-3-6422ee74233a@gmail.com> (raw)
In-Reply-To: <20261001-linux-mpnic-v1-0-6422ee74233a@gmail.com>
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
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.
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
---
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(-)
diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_init.c b/drivers/net/ethernet/meta/mpnic/mpnic_init.c
index 2daed458f5fc..ace4124158fb 100644
--- a/drivers/net/ethernet/meta/mpnic/mpnic_init.c
+++ b/drivers/net/ethernet/meta/mpnic/mpnic_init.c
@@ -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,
diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
index 834eb9bfffd1..9397010557eb 100644
--- a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
+++ b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
@@ -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
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 depletion check 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 ` Daniel Zahka [this message]
2026-10-01 16:39 ` [PATCH net-next 4/4] eth: mpnic: add a NAPI depletion check Daniel Zahka
2026-10-01 16:45 ` [PATCH net-next 0/4] mpnic: add NAPI buffer " 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-3-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®