* [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support
@ 2026-01-30 10:23 Tomas Hlavacek
2026-02-03 4:20 ` patchwork-bot+netdevbpf
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Tomas Hlavacek @ 2026-01-30 10:23 UTC (permalink / raw)
To: netdev
Cc: linux-riscv, spacemit, davem, edumazet, kuba, pabeni, dlan,
wangruikang, stable, Tomas Hlavacek
The driver never programs the MAC frame size and jabber registers,
causing the hardware to reject frames larger than the default 1518
bytes even when larger DMA buffers are allocated.
Program MAC_MAXIMUM_FRAME_SIZE, MAC_TRANSMIT_JABBER_SIZE, and
MAC_RECEIVE_JABBER_SIZE based on the configured MTU. Also fix the
maximum buffer size from 4096 to 4095, since the descriptor buffer
size field is only 12 bits. Account for double VLAN tags in frame
size calculations.
Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
Cc: stable@vger.kernel.org
Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com>
---
v3:
- Set all three frame/jabber registers, fix 12-bit buffer size field
overflow, use actual frame size with VLAN headroom consistently.
v2: https://lore.kernel.org/netdev/20260126171449.83288-1-tmshlvck@gmail.com/
- Added Fixes tag and Cc stable.
v1: https://lore.kernel.org/netdev/20260126135919.77168-1-tmshlvck@gmail.com/
---
drivers/net/ethernet/spacemit/k1_emac.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/spacemit/k1_emac.c b/drivers/net/ethernet/spacemit/k1_emac.c
index 220eb5ce7583..cd6879d7434c 100644
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@ -12,6 +12,7 @@
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
+#include <linux/if_vlan.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
@@ -38,7 +39,7 @@
#define EMAC_DEFAULT_BUFSIZE 1536
#define EMAC_RX_BUF_2K 2048
-#define EMAC_RX_BUF_4K 4096
+#define EMAC_RX_BUF_MAX FIELD_MAX(RX_DESC_1_BUFFER_SIZE_1_MASK)
/* Tuning parameters from SpacemiT */
#define EMAC_TX_FRAMES 64
@@ -202,8 +203,7 @@ static void emac_init_hw(struct emac_priv *priv)
{
/* Destination address for 802.3x Ethernet flow control */
u8 fc_dest_addr[ETH_ALEN] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01 };
-
- u32 rxirq = 0, dma = 0;
+ u32 rxirq = 0, dma = 0, frame_sz;
regmap_set_bits(priv->regmap_apmu,
priv->regmap_apmu_offset + APMU_EMAC_CTRL_REG,
@@ -228,6 +228,15 @@ static void emac_init_hw(struct emac_priv *priv)
DEFAULT_TX_THRESHOLD);
emac_wr(priv, MAC_RECEIVE_PACKET_START_THRESHOLD, DEFAULT_RX_THRESHOLD);
+ /* Set maximum frame size and jabber size based on configured MTU,
+ * accounting for Ethernet header, double VLAN tags, and FCS.
+ */
+ frame_sz = priv->ndev->mtu + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN;
+
+ emac_wr(priv, MAC_MAXIMUM_FRAME_SIZE, frame_sz);
+ emac_wr(priv, MAC_TRANSMIT_JABBER_SIZE, frame_sz);
+ emac_wr(priv, MAC_RECEIVE_JABBER_SIZE, frame_sz);
+
/* Configure flow control (enabled in emac_adjust_link() later) */
emac_set_mac_addr_reg(priv, fc_dest_addr, MAC_FC_SOURCE_ADDRESS_HIGH);
emac_wr(priv, MAC_FC_PAUSE_HIGH_THRESHOLD, DEFAULT_FC_FIFO_HIGH);
@@ -924,14 +933,14 @@ static int emac_change_mtu(struct net_device *ndev, int mtu)
return -EBUSY;
}
- frame_len = mtu + ETH_HLEN + ETH_FCS_LEN;
+ frame_len = mtu + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN;
if (frame_len <= EMAC_DEFAULT_BUFSIZE)
priv->dma_buf_sz = EMAC_DEFAULT_BUFSIZE;
else if (frame_len <= EMAC_RX_BUF_2K)
priv->dma_buf_sz = EMAC_RX_BUF_2K;
else
- priv->dma_buf_sz = EMAC_RX_BUF_4K;
+ priv->dma_buf_sz = EMAC_RX_BUF_MAX;
ndev->mtu = mtu;
@@ -2005,7 +2014,7 @@ static int emac_probe(struct platform_device *pdev)
ndev->hw_features = NETIF_F_SG;
ndev->features |= ndev->hw_features;
- ndev->max_mtu = EMAC_RX_BUF_4K - (ETH_HLEN + ETH_FCS_LEN);
+ ndev->max_mtu = EMAC_RX_BUF_MAX - (ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN);
ndev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
priv = netdev_priv(ndev);
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support
2026-01-30 10:23 [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support Tomas Hlavacek
@ 2026-02-03 4:20 ` patchwork-bot+netdevbpf
2026-02-03 9:39 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge Matthieu Baerts
2026-02-20 4:11 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support patchwork-bot+linux-riscv
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-03 4:20 UTC (permalink / raw)
To: Tomas Hlavacek
Cc: netdev, linux-riscv, spacemit, davem, edumazet, kuba, pabeni,
dlan, wangruikang, stable
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 30 Jan 2026 11:23:01 +0100 you wrote:
> The driver never programs the MAC frame size and jabber registers,
> causing the hardware to reject frames larger than the default 1518
> bytes even when larger DMA buffers are allocated.
>
> Program MAC_MAXIMUM_FRAME_SIZE, MAC_TRANSMIT_JABBER_SIZE, and
> MAC_RECEIVE_JABBER_SIZE based on the configured MTU. Also fix the
> maximum buffer size from 4096 to 4095, since the descriptor buffer
> size field is only 12 bits. Account for double VLAN tags in frame
> size calculations.
>
> [...]
Here is the summary with links:
- [net,v3] net: spacemit: k1-emac: fix jumbo frame support
https://git.kernel.org/netdev/net/c/3125fc170169
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge
2026-01-30 10:23 [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support Tomas Hlavacek
2026-02-03 4:20 ` patchwork-bot+netdevbpf
@ 2026-02-03 9:39 ` Matthieu Baerts
2026-02-03 10:25 ` Vivian Wang
2026-02-03 18:22 ` Tomas Hlavacek
2026-02-20 4:11 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support patchwork-bot+linux-riscv
2 siblings, 2 replies; 6+ messages in thread
From: Matthieu Baerts @ 2026-02-03 9:39 UTC (permalink / raw)
To: Tomas Hlavacek, netdev
Cc: linux-riscv, spacemit, davem, edumazet, kuba, pabeni, dlan,
wangruikang, stable, Mark Brown
[-- Attachment #1: Type: text/plain, Size: 1790 bytes --]
Hello,
+cc: Mark for Linux Next
On 30/01/2026 11:23, Tomas Hlavacek wrote:
> The driver never programs the MAC frame size and jabber registers,
> causing the hardware to reject frames larger than the default 1518
> bytes even when larger DMA buffers are allocated.
>
> Program MAC_MAXIMUM_FRAME_SIZE, MAC_TRANSMIT_JABBER_SIZE, and
> MAC_RECEIVE_JABBER_SIZE based on the configured MTU. Also fix the
> maximum buffer size from 4096 to 4095, since the descriptor buffer
> size field is only 12 bits. Account for double VLAN tags in frame
> size calculations.
FYI, we got a small conflict when merging 'net' in 'net-next' in the
MPTCP tree due to this patch applied in 'net':
3125fc170169 ("net: spacemit: k1-emac: fix jumbo frame support")
and this one from 'net-next':
f66086798f91 ("net: spacemit: Remove broken flow control support")
----- Generic Message -----
The best is to avoid conflicts between 'net' and 'net-next' trees but if
they cannot be avoided when preparing patches, a note about how to fix
them is much appreciated.
The conflict has been resolved on our side [1] and the resolution we
suggest is attached to this email. Please report any issues linked to
this conflict resolution as it might be used by others. If you worked on
the mentioned patches, don't hesitate to ACK this conflict resolution.
---------------------------
Regarding this conflict, both commits modified independent code from the
same context: code related to the flow control has been removed, and the
one to frame/jabber size has been added.
Rerere cache is available in [2].
Cheers,
Matt
1: https://github.com/multipath-tcp/mptcp_net-next/commit/286ef2be604b
2: https://github.com/multipath-tcp/mptcp-upstream-rr-cache/commit/45e15
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
[-- Attachment #2: 286ef2be604bcb5d4ec28bb2d194865f61a52088.patch --]
[-- Type: text/x-patch, Size: 1565 bytes --]
diff --cc drivers/net/ethernet/spacemit/k1_emac.c
index 40c9504b7444,b49c4708bf9e..dab0772c5b9d
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@@ -193,7 -201,9 +194,7 @@@ static void emac_reset_hw(struct emac_p
static void emac_init_hw(struct emac_priv *priv)
{
- u32 rxirq = 0, dma = 0;
- /* Destination address for 802.3x Ethernet flow control */
- u8 fc_dest_addr[ETH_ALEN] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01 };
+ u32 rxirq = 0, dma = 0, frame_sz;
regmap_set_bits(priv->regmap_apmu,
priv->regmap_apmu_offset + APMU_EMAC_CTRL_REG,
@@@ -218,6 -228,21 +219,15 @@@
DEFAULT_TX_THRESHOLD);
emac_wr(priv, MAC_RECEIVE_PACKET_START_THRESHOLD, DEFAULT_RX_THRESHOLD);
+ /* Set maximum frame size and jabber size based on configured MTU,
+ * accounting for Ethernet header, double VLAN tags, and FCS.
+ */
+ frame_sz = priv->ndev->mtu + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN;
+
+ emac_wr(priv, MAC_MAXIMUM_FRAME_SIZE, frame_sz);
+ emac_wr(priv, MAC_TRANSMIT_JABBER_SIZE, frame_sz);
+ emac_wr(priv, MAC_RECEIVE_JABBER_SIZE, frame_sz);
+
- /* Configure flow control (enabled in emac_adjust_link() later) */
- emac_set_mac_addr_reg(priv, fc_dest_addr, MAC_FC_SOURCE_ADDRESS_HIGH);
- emac_wr(priv, MAC_FC_PAUSE_HIGH_THRESHOLD, DEFAULT_FC_FIFO_HIGH);
- emac_wr(priv, MAC_FC_HIGH_PAUSE_TIME, DEFAULT_FC_PAUSE_TIME);
- emac_wr(priv, MAC_FC_PAUSE_LOW_THRESHOLD, 0);
-
/* RX IRQ mitigation */
rxirq = FIELD_PREP(MREGBIT_RECEIVE_IRQ_FRAME_COUNTER_MASK,
EMAC_RX_FRAMES);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge
2026-02-03 9:39 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge Matthieu Baerts
@ 2026-02-03 10:25 ` Vivian Wang
2026-02-03 18:22 ` Tomas Hlavacek
1 sibling, 0 replies; 6+ messages in thread
From: Vivian Wang @ 2026-02-03 10:25 UTC (permalink / raw)
To: Matthieu Baerts, Tomas Hlavacek, netdev
Cc: linux-riscv, spacemit, davem, edumazet, kuba, pabeni, dlan,
stable, Mark Brown
Hi Matthieu and Mark,
On 2/3/26 17:39, Matthieu Baerts wrote:
> [...]
>
> The conflict has been resolved on our side [1] and the resolution we
> suggest is attached to this email. Please report any issues linked to
> this conflict resolution as it might be used by others. If you worked on
> the mentioned patches, don't hesitate to ACK this conflict resolution.
> ---------------------------
Your merge is correct. Thanks for handling it.
Vivian "dramforever" Wang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge
2026-02-03 9:39 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge Matthieu Baerts
2026-02-03 10:25 ` Vivian Wang
@ 2026-02-03 18:22 ` Tomas Hlavacek
1 sibling, 0 replies; 6+ messages in thread
From: Tomas Hlavacek @ 2026-02-03 18:22 UTC (permalink / raw)
To: Matthieu Baerts
Cc: netdev, linux-riscv, spacemit, davem, edumazet, kuba, pabeni,
dlan, wangruikang, stable, Mark Brown
Dear Matthieu,
On Tue, Feb 3, 2026 at 10:39 AM Matthieu Baerts <matttbe@kernel.org> wrote:
[...]
> The conflict has been resolved on our side [1] and the resolution we
> suggest is attached to this email. Please report any issues linked to
> this conflict resolution as it might be used by others. If you worked on
> the mentioned patches, don't hesitate to ACK this conflict resolution.
It looks good to me. Thank you!
Tomas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support
2026-01-30 10:23 [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support Tomas Hlavacek
2026-02-03 4:20 ` patchwork-bot+netdevbpf
2026-02-03 9:39 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge Matthieu Baerts
@ 2026-02-20 4:11 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-02-20 4:11 UTC (permalink / raw)
To: Tomas Hlavacek
Cc: linux-riscv, netdev, spacemit, davem, edumazet, kuba, pabeni,
dlan, wangruikang, stable
Hello:
This patch was applied to riscv/linux.git (fixes)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 30 Jan 2026 11:23:01 +0100 you wrote:
> The driver never programs the MAC frame size and jabber registers,
> causing the hardware to reject frames larger than the default 1518
> bytes even when larger DMA buffers are allocated.
>
> Program MAC_MAXIMUM_FRAME_SIZE, MAC_TRANSMIT_JABBER_SIZE, and
> MAC_RECEIVE_JABBER_SIZE based on the configured MTU. Also fix the
> maximum buffer size from 4096 to 4095, since the descriptor buffer
> size field is only 12 bits. Account for double VLAN tags in frame
> size calculations.
>
> [...]
Here is the summary with links:
- [net,v3] net: spacemit: k1-emac: fix jumbo frame support
https://git.kernel.org/riscv/c/3125fc170169
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-20 4:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-30 10:23 [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support Tomas Hlavacek
2026-02-03 4:20 ` patchwork-bot+netdevbpf
2026-02-03 9:39 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support: manual merge Matthieu Baerts
2026-02-03 10:25 ` Vivian Wang
2026-02-03 18:22 ` Tomas Hlavacek
2026-02-20 4:11 ` [PATCH net v3] net: spacemit: k1-emac: fix jumbo frame support patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox