blob: a76a784772a607bc13b669fe32777ed9bfdd2956 [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From 0f2e84b06686745694f276c4aae6cf9d132a56af Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:30 +0800
4Subject: [PATCH]
5 [networking][999-2712-net-ethernet-mtk_eth_soc-add-mtk-dsa-tag-rx-offload.patch]
6
7---
8 net/dsa/tag_mtk.c | 32 +++++++++++++++++++-------------
9 1 file changed, 19 insertions(+), 13 deletions(-)
10
11diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c
12index edc505e07..c386fdc90 100644
13--- a/net/dsa/tag_mtk.c
14+++ b/net/dsa/tag_mtk.c
15@@ -80,22 +80,28 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
developerfd40db22021-04-29 10:08:25 +080016 bool is_multicast_skb = is_multicast_ether_addr(dest) &&
17 !is_broadcast_ether_addr(dest);
18
19- if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
20- return NULL;
21+ if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) {
22+ hdr = ntohs(skb->vlan_proto);
23+ skb->vlan_proto = 0;
24+ skb->vlan_tci = 0;
25+ } else {
26+ if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
27+ return NULL;
28
29- /* The MTK header is added by the switch between src addr
30- * and ethertype at this point, skb->data points to 2 bytes
31- * after src addr so header should be 2 bytes right before.
32- */
33- phdr = (__be16 *)(skb->data - 2);
34- hdr = ntohs(*phdr);
35+ /* The MTK header is added by the switch between src addr
36+ * and ethertype at this point, skb->data points to 2 bytes
37+ * after src addr so header should be 2 bytes right before.
38+ */
39+ phdr = (__be16 *)(skb->data - 2);
40+ hdr = ntohs(*phdr);
41
42- /* Remove MTK tag and recalculate checksum. */
43- skb_pull_rcsum(skb, MTK_HDR_LEN);
44+ /* Remove MTK tag and recalculate checksum. */
45+ skb_pull_rcsum(skb, MTK_HDR_LEN);
46
47- memmove(skb->data - ETH_HLEN,
48- skb->data - ETH_HLEN - MTK_HDR_LEN,
49- 2 * ETH_ALEN);
50+ memmove(skb->data - ETH_HLEN,
51+ skb->data - ETH_HLEN - MTK_HDR_LEN,
52+ 2 * ETH_ALEN);
53+ }
54
55 /* Get source port information */
56 port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK);
developer5d148cb2023-06-02 13:08:11 +080057--
582.34.1
59