Skip to content

Commit

Permalink
Add+Fix software padding processing in Ethernet Tx path.
Browse files Browse the repository at this point in the history
Add software padding processing in Ethernet Tx path.

It's found that too-short packets would lead to
switch Tx CRC error, followed by switch output
queue stuck issue. So Ethernet driver should check
if the packet is too short and conduct software
padding when necessary.

If without this patch, switch might encounter output
queue stuck issue.

Change-Id: Ibd94cbf3be0530d2b9ee61477b0362d099c47d8e
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7109899

Fix software padding processing in Ethernet Tx path.

It's found that 20bytes(LLC), 28bytes, and 36bytes(PPP LCP Configuration
Ack) packets with additional 4bytes special tag for dsa driver would lead
to switch Tx CRC error, followed by switch output queue stuck issue.
Therefore, Ethernet driver check skb->len <= 40(36bytes PPP LCP + 4bytes
special tag) and conduct software padding.

Moreover, skb linearization should be checked again after conduct
software padding.

If without this patch, users might encounter problems when establishing
a PPPoE tunnel.

Change-Id: Id28fa3870dc9e905207d95634fe5cd692f363761
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9129634

frank-w: changed condition to MTK_MIN_TX_LENGTH
  • Loading branch information
developer authored and frank-w committed Feb 2, 2025
1 parent 5fed8aa commit afa4017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,14 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
int queue = skb_get_queue_mapping(skb);
int k = 0;

if (skb->len <= MTK_MIN_TX_LENGTH) {
if (skb_put_padto(skb, MTK_MIN_TX_LENGTH))
return -ENOMEM;

txd_info.last = !skb_is_nonlinear(skb);
txd_info.size = skb_headlen(skb);
}

txq = netdev_get_tx_queue(dev, queue);
itxd = ring->next_free;
itxd_pdma = qdma_to_pdma(ring, itxd);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define MTK_MAX_RX_LENGTH_2K 2048
#define MTK_TX_DMA_BUF_LEN 0x3fff
#define MTK_TX_DMA_BUF_LEN_V2 0xffff
#define MTK_MIN_TX_LENGTH 60
#define MTK_QDMA_RING_SIZE 2048
#define MTK_DMA_SIZE(x) (SZ_##x)
#define MTK_FQ_DMA_HEAD 32
Expand Down

0 comments on commit afa4017

Please sign in to comment.