27299f17deae1dd94d13970419a41ce0d5574597
[openwrt/openwrt.git] / target / linux / realtek / patches-5.10 / 701-net-dsa-add-rtl838x-support-for-tag-trailer.patch
1 From 2b88563ee5aafd9571d965b7f2093a0f58d98a31 Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Thu, 26 Nov 2020 12:02:21 +0100
4 Subject: net: dsa: Add rtl838x support for tag trailer
5
6 * rename the target to realtek
7 * add refactored DSA driver
8 * add latest gpio driver
9 * lots of arch cleanups
10 * new irq driver
11 * additional boards
12
13 Submitted-by: Bert Vermeulen <bert@biot.com>
14 Submitted-by: Birger Koblitz <mail@birger-koblitz.de>
15 Submitted-by: Sander Vanheule <sander@svanheule.net>
16 Submitted-by: Bjørn Mork <bjorn@mork.no>
17 Submitted-by: John Crispin <john@phrozen.org>
18 ---
19 net/dsa/tag_trailer.c | 16 +++++++++++++-
20 1 file changed, 17 insertions(+), 1 deletion(-)
21
22 --- a/net/dsa/tag_trailer.c
23 +++ b/net/dsa/tag_trailer.c
24 @@ -17,7 +17,12 @@ static struct sk_buff *trailer_xmit(stru
25
26 trailer = skb_put(skb, 4);
27 trailer[0] = 0x80;
28 +
29 +#ifdef CONFIG_NET_DSA_RTL83XX
30 + trailer[1] = dp->index;
31 +#else
32 trailer[1] = 1 << dp->index;
33 +#endif /* CONFIG_NET_DSA_RTL838X */
34 trailer[2] = 0x10;
35 trailer[3] = 0x00;
36
37 @@ -34,12 +39,23 @@ static struct sk_buff *trailer_rcv(struc
38 return NULL;
39
40 trailer = skb_tail_pointer(skb) - 4;
41 +
42 +#ifdef CONFIG_NET_DSA_RTL83XX
43 + if (trailer[0] != 0x80 || (trailer[1] & 0x80) != 0x00 ||
44 + (trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
45 + return NULL;
46 +
47 + if (trailer[1] & 0x40)
48 + skb->offload_fwd_mark = 1;
49 +
50 + source_port = trailer[1] & 0x3f;
51 +#else
52 if (trailer[0] != 0x80 || (trailer[1] & 0xf8) != 0x00 ||
53 (trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
54 return NULL;
55
56 source_port = trailer[1] & 7;
57 -
58 +#endif
59 skb->dev = dsa_master_find_slave(dev, 0, source_port);
60 if (!skb->dev)
61 return NULL;