kernel: import accepted MediaTek Ethernet patches
[openwrt/staging/aparcar.git] / target / linux / generic / pending-5.15 / 734-net-ethernet-mtk_eth_soc-ppe-fix-L2-offloading-with-.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 27 Dec 2022 15:02:51 +0100
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: ppe: fix L2 offloading with DSA
4 untagging offload enabled
5
6 Check for skb metadata in order to detect the case where the DSA header is not
7 present.
8
9 Fixes: 2d7605a72906 ("net: ethernet: mtk_eth_soc: enable hardware DSA untagging")
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
14 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 @@ -1998,9 +1998,6 @@ static int mtk_poll_rx(struct napi_struc
16 skb_checksum_none_assert(skb);
17 skb->protocol = eth_type_trans(skb, netdev);
18
19 - if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
20 - mtk_ppe_check_skb(eth->ppe[0], skb, hash);
21 -
22 /* When using VLAN untagging in combination with DSA, the
23 * hardware treats the MTK special tag as a VLAN and untags it.
24 */
25 @@ -2013,6 +2010,9 @@ static int mtk_poll_rx(struct napi_struc
26 skb_dst_set_noref(skb, &eth->dsa_meta[port]->dst);
27 }
28
29 + if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
30 + mtk_ppe_check_skb(eth->ppe[0], skb, hash);
31 +
32 skb_record_rx_queue(skb, 0);
33 napi_gro_receive(napi, skb);
34
35 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
36 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
37 @@ -8,6 +8,7 @@
38 #include <linux/platform_device.h>
39 #include <linux/if_ether.h>
40 #include <linux/if_vlan.h>
41 +#include <net/dst_metadata.h>
42 #include <net/dsa.h>
43 #include "mtk_eth_soc.h"
44 #include "mtk_ppe.h"
45 @@ -755,7 +756,9 @@ void __mtk_ppe_check_skb(struct mtk_ppe
46 skb->dev->dsa_ptr->tag_ops->proto != DSA_TAG_PROTO_MTK)
47 goto out;
48
49 - tag += 4;
50 + if (!skb_metadata_dst(skb))
51 + tag += 4;
52 +
53 if (get_unaligned_be16(tag) != ETH_P_8021Q)
54 break;
55