Skip to content

Commit 336ffdf

Browse files
plappermaulrobimarko
authored andcommitted
realtek: dsa: convert trailer tag hack into separate module
DSA tagging currently works with a tuned trailer tagging. That means: - realtek target uses tag_trailer for tagging - there is a patch for the trailer tagger to write the target port not as a bitfield but as an integer Make the tagging independent from upstream and hacky patches by providing a new downstream driver. This can be aligned easier for future development. Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: openwrt/openwrt#21815 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent fb5aa04 commit 336ffdf

11 files changed

Lines changed: 135 additions & 69 deletions

File tree

target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
config NET_DSA_RTL83XX
33
tristate "Realtek RTL838x/RTL839x switch support"
44
depends on MACH_REALTEK_RTL
5-
select NET_DSA_TAG_TRAILER
5+
select NET_DSA_TAG_RTL_OTTO
66
help
77
This driver adds support for Realtek RTL83xx series switching.
88

target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static enum dsa_tag_protocol rtldsa_get_tag_protocol(struct dsa_switch *ds,
428428
/* The switch does not tag the frames, instead internally the header
429429
* structure for each packet is tagged accordingly.
430430
*/
431-
return DSA_TAG_PROTO_TRAILER;
431+
return DSA_TAG_PROTO_RTL_OTTO;
432432
}
433433

434434
static void rtldsa_vlan_set_pvid(struct rtl838x_switch_priv *priv,
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/*
3+
* net/dsa/tag_trailer.c - Trailer tag format handling
4+
* Copyright (c) 2008-2009 Marvell Semiconductor
5+
*/
6+
7+
#include <linux/etherdevice.h>
8+
#include <linux/list.h>
9+
#include <linux/slab.h>
10+
11+
#include "tag.h"
12+
13+
#define RTL_OTTO_NAME "rtl_otto"
14+
15+
/*
16+
* TODO: This driver was copied over from trailer tagging. It will be developed
17+
* downstream in OpenWrt in conjunction with the Realtek Otto ethernet driver.
18+
* For now rely on the old trailer handling and keep everything as is.
19+
*/
20+
21+
static struct sk_buff *rtl_otto_xmit(struct sk_buff *skb, struct net_device *dev)
22+
{
23+
struct dsa_port *dp = dsa_user_to_port(dev);
24+
u8 *trailer;
25+
26+
trailer = skb_put(skb, 4);
27+
trailer[0] = 0x80;
28+
trailer[1] = dp->index;
29+
trailer[2] = 0x10;
30+
trailer[3] = 0x00;
31+
32+
return skb;
33+
}
34+
35+
static struct sk_buff *rtl_otto_rcv(struct sk_buff *skb, struct net_device *dev)
36+
{
37+
u8 *trailer;
38+
int source_port;
39+
40+
if (skb_linearize(skb))
41+
return NULL;
42+
43+
trailer = skb_tail_pointer(skb) - 4;
44+
45+
if (trailer[0] != 0x80 || (trailer[1] & 0x80) != 0x00 ||
46+
(trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
47+
return NULL;
48+
49+
if (trailer[1] & 0x40)
50+
skb->offload_fwd_mark = 1;
51+
52+
source_port = trailer[1] & 0x3f;
53+
54+
skb->dev = dsa_conduit_find_user(dev, 0, source_port);
55+
if (!skb->dev)
56+
return NULL;
57+
58+
if (pskb_trim_rcsum(skb, skb->len - 4))
59+
return NULL;
60+
61+
return skb;
62+
}
63+
64+
static const struct dsa_device_ops rtl_otto_netdev_ops = {
65+
.name = RTL_OTTO_NAME,
66+
.proto = DSA_TAG_PROTO_RTL_OTTO,
67+
.xmit = rtl_otto_xmit,
68+
.rcv = rtl_otto_rcv,
69+
.needed_tailroom = 4,
70+
};
71+
72+
MODULE_DESCRIPTION("DSA tag driver for Realtek Otto switches (RTL83xx/RTL93xx)");
73+
MODULE_LICENSE("GPL");
74+
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_RTL_OTTO, RTL_OTTO_NAME);
75+
76+
module_dsa_tag_driver(rtl_otto_netdev_ops);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From: Markus Stockhausen <markus.stockhausen@gmx.de>
2+
Date: Sun, 1 Feb 2026 10:40:52 +0100
3+
Subject: realtek: net: dsa: add suport for tag rtl-otto
4+
5+
This adds the rtl-otto tag feature for Realtek switches.
6+
7+
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
8+
9+
--- a/net/dsa/Makefile
10+
+++ b/net/dsa/Makefile
11+
@@ -35,6 +35,7 @@ obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca
12+
obj-$(CONFIG_NET_DSA_TAG_RTL4_A) += tag_rtl4_a.o
13+
obj-$(CONFIG_NET_DSA_TAG_RTL8_4) += tag_rtl8_4.o
14+
obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.o
15+
+obj-$(CONFIG_NET_DSA_TAG_RTL_OTTO) += tag_rtl_otto.o
16+
obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o
17+
obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
18+
obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o
19+
--- a/net/dsa/Kconfig
20+
+++ b/net/dsa/Kconfig
21+
@@ -163,6 +163,12 @@ config NET_DSA_TAG_LAN9303
22+
Say Y or M if you want to enable support for tagging frames for the
23+
SMSC/Microchip LAN9303 family of switches.
24+
25+
+config NET_DSA_TAG_RTL_OTTO
26+
+ tristate "Tag driver for Realtek Otto switches (RTL83xx/RTL93xx)"
27+
+ help
28+
+ Say Y or M if you want to enable support for tagging frames for the
29+
+ Realtek Otto family of switches.
30+
+
31+
config NET_DSA_TAG_SJA1105
32+
tristate "Tag driver for NXP SJA1105 switches"
33+
select PACKING
34+
--- a/include/net/dsa.h
35+
+++ b/include/net/dsa.h
36+
@@ -55,6 +55,7 @@ struct tc_action;
37+
#define DSA_TAG_PROTO_LAN937X_VALUE 27
38+
#define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28
39+
#define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29
40+
+#define DSA_TAG_PROTO_RTL_OTTO_VALUE 30
41+
42+
enum dsa_tag_protocol {
43+
DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE,
44+
@@ -87,6 +88,7 @@ enum dsa_tag_protocol {
45+
DSA_TAG_PROTO_RZN1_A5PSW = DSA_TAG_PROTO_RZN1_A5PSW_VALUE,
46+
DSA_TAG_PROTO_LAN937X = DSA_TAG_PROTO_LAN937X_VALUE,
47+
DSA_TAG_PROTO_VSC73XX_8021Q = DSA_TAG_PROTO_VSC73XX_8021Q_VALUE,
48+
+ DSA_TAG_PROTO_RTL_OTTO = DSA_TAG_PROTO_RTL_OTTO_VALUE,
49+
};
50+
51+
struct dsa_switch;

target/linux/realtek/patches-6.12/722-net-dsa-add-rtl838x-support-for-tag-trailer.patch

Lines changed: 0 additions & 61 deletions
This file was deleted.

target/linux/realtek/rtl838x/config-6.12

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ CONFIG_NET_DEVLINK=y
174174
CONFIG_NET_DSA=y
175175
CONFIG_NET_DSA_RTL83XX=y
176176
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
177-
CONFIG_NET_DSA_TAG_TRAILER=y
177+
CONFIG_NET_DSA_TAG_RTL_OTTO=y
178178
CONFIG_NET_EGRESS=y
179179
CONFIG_NET_INGRESS=y
180180
CONFIG_NET_RTL838X=y

target/linux/realtek/rtl839x/config-6.12

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ CONFIG_NET_DEVLINK=y
178178
CONFIG_NET_DSA=y
179179
CONFIG_NET_DSA_RTL83XX=y
180180
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
181-
CONFIG_NET_DSA_TAG_TRAILER=y
181+
CONFIG_NET_DSA_TAG_RTL_OTTO=y
182182
CONFIG_NET_EGRESS=y
183183
CONFIG_NET_FLOW_LIMIT=y
184184
CONFIG_NET_INGRESS=y

target/linux/realtek/rtl930x/config-6.12

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ CONFIG_NET_DEVLINK=y
160160
CONFIG_NET_DSA=y
161161
CONFIG_NET_DSA_RTL83XX=y
162162
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
163-
CONFIG_NET_DSA_TAG_TRAILER=y
163+
CONFIG_NET_DSA_TAG_RTL_OTTO=y
164164
CONFIG_NET_EGRESS=y
165165
CONFIG_NET_FLOW_LIMIT=y
166166
CONFIG_NET_INGRESS=y

target/linux/realtek/rtl930x_nand/config-6.12

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ CONFIG_NET_DEVLINK=y
166166
CONFIG_NET_DSA=y
167167
CONFIG_NET_DSA_RTL83XX=y
168168
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
169-
CONFIG_NET_DSA_TAG_TRAILER=y
169+
CONFIG_NET_DSA_TAG_RTL_OTTO=y
170170
CONFIG_NET_EGRESS=y
171171
CONFIG_NET_FLOW_LIMIT=y
172172
CONFIG_NET_INGRESS=y

target/linux/realtek/rtl931x/config-6.12

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ CONFIG_NET_DEVLINK=y
170170
CONFIG_NET_DSA=y
171171
CONFIG_NET_DSA_RTL83XX=y
172172
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
173-
CONFIG_NET_DSA_TAG_TRAILER=y
173+
CONFIG_NET_DSA_TAG_RTL_OTTO=y
174174
CONFIG_NET_EGRESS=y
175175
CONFIG_NET_FLOW_LIMIT=y
176176
CONFIG_NET_INGRESS=y

0 commit comments

Comments
 (0)