diff options
| author | Serge Semin <fancer.lancer@gmail.com> | 2025-08-22 13:39:14 +0300 |
|---|---|---|
| committer | Serge Semin <fancer.lancer@gmail.com> | 2026-08-13 20:31:43 +0300 |
| commit | 43b004020cf631086374654966117e81bf41b37a (patch) | |
| tree | 423aef772b4c4e6824552e7bc9628329243f6d10 | |
| parent | 7cec342ce65a02484b130e49e1903623ff6ac83a (diff) | |
| download | linux-43b004020cf631086374654966117e81bf41b37a.tar.gz linux-43b004020cf631086374654966117e81bf41b37a.zip | |
net: stmmac: Drop the power-of-2 Rx buffers size constraint
The recent commits fixing the Rx DMA-descriptors initialization for the DW
MAC100/GMAC switched the code to being agnostic from the power-of-2 Rx
buffers size. Instead they fully follow the HW databooks requirements the
buffers address and size to be properly aligned. The same has been
applicable for the DW QoS Ether, DW XGMAC/XLGMAC devices support from the
very initial commit adding them to the driver.
So let's drop the pre-defined set of the Rx buffers sizes and just use the
one MTU-based Rx buffer size instead. Not sure why hasn't this been done
from the very initial driver commit. Sigh...
Note this shall improve the driver performance as well since more buffers
will be able to fit the orderly allocated pages by the Page Pool means.
Thus less more data page-locality, less TLB misses, better CPU performance
in handling the incoming traffic.
Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.")
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
---
Not really a fix, but well...
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/common.h | 6 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 |
2 files changed, 5 insertions, 17 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 27665c7c5c25..95faae938b04 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -527,11 +527,7 @@ struct dma_features { u8 actphyif; }; -/* RX Buffer size must be multiple of 4/8/16 bytes */ -#define BUF_SIZE_16KiB 16368 -#define BUF_SIZE_8KiB 8188 -#define BUF_SIZE_4KiB 4096 -#define BUF_SIZE_2KiB 2048 +/* RX Buffer size alignment is of 4/8/16 bytes */ #define STMMAC_RX_BUF_ALIGN(x) ALIGN_DOWN(x, 16) #define STMMAC_RX_BUF_ADJUST(x) ALIGN(x, 16) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 0ec2cb760301..e4a16757346b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -258,8 +258,10 @@ static void stmmac_verify_args(void) { if (unlikely(watchdog < 0)) watchdog = TX_TIMEO; - if (unlikely((buf_sz < DEFAULT_BUFSIZE) || (buf_sz > BUF_SIZE_16KiB))) + + if (unlikely(buf_sz < DEFAULT_BUFSIZE || buf_sz > SZ_16K)) buf_sz = DEFAULT_BUFSIZE; + if (unlikely((pause < 0) || (pause > 0xffff))) pause = PAUSE_TIME; @@ -1594,16 +1596,6 @@ static unsigned int stmmac_get_bfsize(struct stmmac_priv *priv, int mtu) * the Ethernet header plus possible C/S-VLAN headers. */ buff_size = umax(mtu + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN, buf_sz); - if (buff_size >= BUF_SIZE_8KiB) - buff_size = BUF_SIZE_16KiB; - else if (buff_size >= BUF_SIZE_4KiB) - buff_size = BUF_SIZE_8KiB; - else if (buff_size >= BUF_SIZE_2KiB) - buff_size = BUF_SIZE_4KiB; - else if (buff_size > DEFAULT_BUFSIZE) - buff_size = BUF_SIZE_2KiB; - else - buff_size = DEFAULT_BUFSIZE; /* Make sure the buffer is bus-width aligned up to fit in all the DMA * writes and to avoid undefined behaviour (see notes in the databooks). @@ -6269,7 +6261,7 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) } /* If condition true, FIFO is too small or MTU too large */ - if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB)) + if ((txfifosz < new_mtu) || (new_mtu > XGMAC_JUMBO_LEN)) return -EINVAL; if (netif_running(dev)) { |
