kernel: mtk_eth_soc: fix tx vlan tag for llc packets
authorFelix Fietkau <[email protected]>
Sun, 31 Aug 2025 18:28:52 +0000 (20:28 +0200)
committerFelix Fietkau <[email protected]>
Sun, 31 Aug 2025 18:29:45 +0000 (20:29 +0200)
When sending llc packets with vlan tx offload, the hardware fails to
actually add the tag. Deal with this by fixing it up in software.

Fixes: https://github.com/openwrt/openwrt/issues/19916
Reported-by: Thibaut VARENE <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
target/linux/generic/hack-6.12/730-net-ethernet-mtk_eth_soc-add-hw-dump-for-forced-rese.patch
target/linux/generic/hack-6.6/730-net-ethernet-mtk_eth_soc-add-hw-dump-for-forced-rese.patch
target/linux/generic/pending-6.12/742-net-ethernet-mtk_eth_soc-fix-tx-vlan-tag-for-llc-pac.patch [new file with mode: 0644]
target/linux/generic/pending-6.6/742-net-ethernet-mtk_eth_soc-fix-tx-vlan-tag-for-llc-pac.patch [new file with mode: 0644]

index c4bf08b594b9e9fa6b9a468bf341e82b43bc3985..ffc21ee2ff7345b9c3d2a521429a0ca6eb14b0c7 100644 (file)
@@ -37,7 +37,7 @@ Signed-off-by: Bo-Cun Chen <[email protected]>
                .glo_cfg        = 0x4604,
                .rst_idx        = 0x4608,
                .delay_irq      = 0x460c,
-@@ -3901,6 +3904,56 @@ static void mtk_set_mcr_max_rx(struct mt
+@@ -3909,6 +3912,56 @@ static void mtk_set_mcr_max_rx(struct mt
                mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
  }
  
@@ -94,7 +94,7 @@ Signed-off-by: Bo-Cun Chen <[email protected]>
  static void mtk_hw_reset(struct mtk_eth *eth)
  {
        u32 val;
-@@ -4380,6 +4433,8 @@ static void mtk_pending_work(struct work
+@@ -4388,6 +4441,8 @@ static void mtk_pending_work(struct work
        rtnl_lock();
        set_bit(MTK_RESETTING, &eth->state);
  
index 95a6aa8cb82b41680a488b96bc2a495fef187b80..25d824bce67f811298af28623479abc46cc9f2db 100644 (file)
@@ -37,7 +37,7 @@ Signed-off-by: Bo-Cun Chen <[email protected]>
                .glo_cfg        = 0x4604,
                .rst_idx        = 0x4608,
                .delay_irq      = 0x460c,
-@@ -3899,6 +3902,56 @@ static void mtk_set_mcr_max_rx(struct mt
+@@ -3907,6 +3910,56 @@ static void mtk_set_mcr_max_rx(struct mt
                mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
  }
  
@@ -94,7 +94,7 @@ Signed-off-by: Bo-Cun Chen <[email protected]>
  static void mtk_hw_reset(struct mtk_eth *eth)
  {
        u32 val;
-@@ -4374,6 +4427,8 @@ static void mtk_pending_work(struct work
+@@ -4382,6 +4435,8 @@ static void mtk_pending_work(struct work
        rtnl_lock();
        set_bit(MTK_RESETTING, &eth->state);
  
diff --git a/target/linux/generic/pending-6.12/742-net-ethernet-mtk_eth_soc-fix-tx-vlan-tag-for-llc-pac.patch b/target/linux/generic/pending-6.12/742-net-ethernet-mtk_eth_soc-fix-tx-vlan-tag-for-llc-pac.patch
new file mode 100644 (file)
index 0000000..20a6a29
--- /dev/null
@@ -0,0 +1,39 @@
+From: Felix Fietkau <[email protected]>
+Date: Sun, 31 Aug 2025 20:05:13 +0200
+Subject: [PATCH] net: ethernet: mtk_eth_soc: fix tx vlan tag for llc packets
+
+When sending llc packets with vlan tx offload, the hardware fails to
+actually add the tag. Deal with this by fixing it up in software.
+
+Fixes: 656e705243fd ("net-next: mediatek: add support for MT7623 ethernet")
+Reported-by: Thibaut VARENE <[email protected]>
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+
+--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+@@ -1778,6 +1778,13 @@ static netdev_tx_t mtk_start_xmit(struct
+       bool gso = false;
+       int tx_num;
++      if (skb_vlan_tag_present(skb) &&
++          !eth_proto_is_802_3(eth_hdr(skb)->h_proto)) {
++              skb = __vlan_hwaccel_push_inside(skb);
++              if (!skb)
++                      goto dropped;
++      }
++
+       /* normally we can rely on the stack not calling this more than once,
+        * however we have 2 queues running on the same ring so we need to lock
+        * the ring access
+@@ -1841,8 +1848,9 @@ static netdev_tx_t mtk_start_xmit(struct
+ drop:
+       spin_unlock(&eth->page_lock);
+-      stats->tx_dropped++;
+       dev_kfree_skb_any(skb);
++dropped:
++      stats->tx_dropped++;
+       return NETDEV_TX_OK;
+ }
diff --git a/target/linux/generic/pending-6.6/742-net-ethernet-mtk_eth_soc-fix-tx-vlan-tag-for-llc-pac.patch b/target/linux/generic/pending-6.6/742-net-ethernet-mtk_eth_soc-fix-tx-vlan-tag-for-llc-pac.patch
new file mode 100644 (file)
index 0000000..7e90a79
--- /dev/null
@@ -0,0 +1,39 @@
+From: Felix Fietkau <[email protected]>
+Date: Sun, 31 Aug 2025 20:05:13 +0200
+Subject: [PATCH] net: ethernet: mtk_eth_soc: fix tx vlan tag for llc packets
+
+When sending llc packets with vlan tx offload, the hardware fails to
+actually add the tag. Deal with this by fixing it up in software.
+
+Fixes: 656e705243fd ("net-next: mediatek: add support for MT7623 ethernet")
+Reported-by: Thibaut VARENE <[email protected]>
+Signed-off-by: Felix Fietkau <[email protected]>
+---
+
+--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+@@ -1773,6 +1773,13 @@ static netdev_tx_t mtk_start_xmit(struct
+       bool gso = false;
+       int tx_num;
++      if (skb_vlan_tag_present(skb) &&
++          !eth_proto_is_802_3(eth_hdr(skb)->h_proto)) {
++              skb = __vlan_hwaccel_push_inside(skb);
++              if (!skb)
++                      goto dropped;
++      }
++
+       /* normally we can rely on the stack not calling this more than once,
+        * however we have 2 queues running on the same ring so we need to lock
+        * the ring access
+@@ -1836,8 +1843,9 @@ static netdev_tx_t mtk_start_xmit(struct
+ drop:
+       spin_unlock(&eth->page_lock);
+-      stats->tx_dropped++;
+       dev_kfree_skb_any(skb);
++dropped:
++      stats->tx_dropped++;
+       return NETDEV_TX_OK;
+ }