[openwrt/openwrt] realtek: dsa: convert trailer tag hack into separate module
LEDE Commits
lede-commits at lists.infradead.org
Thu Feb 5 02:45:58 PST 2026
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/336ffdf631681c49169f5891baa7351dc81234a3
commit 336ffdf631681c49169f5891baa7351dc81234a3
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Sun Feb 1 11:11:51 2026 +0100
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 at gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21815
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../files-6.12/drivers/net/dsa/rtl83xx/Kconfig | 2 +-
.../files-6.12/drivers/net/dsa/rtl83xx/dsa.c | 2 +-
.../realtek/files-6.12/net/dsa/tag_rtl_otto.c | 76 ++++++++++++++++++++++
.../721-net-dsa-add-support-for-tag-rtl-otto.patch | 51 +++++++++++++++
...t-dsa-add-rtl838x-support-for-tag-trailer.patch | 61 -----------------
target/linux/realtek/rtl838x/config-6.12 | 2 +-
target/linux/realtek/rtl839x/config-6.12 | 2 +-
target/linux/realtek/rtl930x/config-6.12 | 2 +-
target/linux/realtek/rtl930x_nand/config-6.12 | 2 +-
target/linux/realtek/rtl931x/config-6.12 | 2 +-
target/linux/realtek/rtl931x_nand/config-6.12 | 2 +-
11 files changed, 135 insertions(+), 69 deletions(-)
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/Kconfig b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/Kconfig
index 97e6c8f428..5808ad11e0 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/Kconfig
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/Kconfig
@@ -2,7 +2,7 @@
config NET_DSA_RTL83XX
tristate "Realtek RTL838x/RTL839x switch support"
depends on MACH_REALTEK_RTL
- select NET_DSA_TAG_TRAILER
+ select NET_DSA_TAG_RTL_OTTO
help
This driver adds support for Realtek RTL83xx series switching.
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
index d33e0fa449..311e59e6f8 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
@@ -428,7 +428,7 @@ static enum dsa_tag_protocol rtldsa_get_tag_protocol(struct dsa_switch *ds,
/* The switch does not tag the frames, instead internally the header
* structure for each packet is tagged accordingly.
*/
- return DSA_TAG_PROTO_TRAILER;
+ return DSA_TAG_PROTO_RTL_OTTO;
}
static void rtldsa_vlan_set_pvid(struct rtl838x_switch_priv *priv,
diff --git a/target/linux/realtek/files-6.12/net/dsa/tag_rtl_otto.c b/target/linux/realtek/files-6.12/net/dsa/tag_rtl_otto.c
new file mode 100644
index 0000000000..08a9915584
--- /dev/null
+++ b/target/linux/realtek/files-6.12/net/dsa/tag_rtl_otto.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * net/dsa/tag_trailer.c - Trailer tag format handling
+ * Copyright (c) 2008-2009 Marvell Semiconductor
+ */
+
+#include <linux/etherdevice.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+
+#include "tag.h"
+
+#define RTL_OTTO_NAME "rtl_otto"
+
+/*
+ * TODO: This driver was copied over from trailer tagging. It will be developed
+ * downstream in OpenWrt in conjunction with the Realtek Otto ethernet driver.
+ * For now rely on the old trailer handling and keep everything as is.
+ */
+
+static struct sk_buff *rtl_otto_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct dsa_port *dp = dsa_user_to_port(dev);
+ u8 *trailer;
+
+ trailer = skb_put(skb, 4);
+ trailer[0] = 0x80;
+ trailer[1] = dp->index;
+ trailer[2] = 0x10;
+ trailer[3] = 0x00;
+
+ return skb;
+}
+
+static struct sk_buff *rtl_otto_rcv(struct sk_buff *skb, struct net_device *dev)
+{
+ u8 *trailer;
+ int source_port;
+
+ if (skb_linearize(skb))
+ return NULL;
+
+ trailer = skb_tail_pointer(skb) - 4;
+
+ if (trailer[0] != 0x80 || (trailer[1] & 0x80) != 0x00 ||
+ (trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
+ return NULL;
+
+ if (trailer[1] & 0x40)
+ skb->offload_fwd_mark = 1;
+
+ source_port = trailer[1] & 0x3f;
+
+ skb->dev = dsa_conduit_find_user(dev, 0, source_port);
+ if (!skb->dev)
+ return NULL;
+
+ if (pskb_trim_rcsum(skb, skb->len - 4))
+ return NULL;
+
+ return skb;
+}
+
+static const struct dsa_device_ops rtl_otto_netdev_ops = {
+ .name = RTL_OTTO_NAME,
+ .proto = DSA_TAG_PROTO_RTL_OTTO,
+ .xmit = rtl_otto_xmit,
+ .rcv = rtl_otto_rcv,
+ .needed_tailroom = 4,
+};
+
+MODULE_DESCRIPTION("DSA tag driver for Realtek Otto switches (RTL83xx/RTL93xx)");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_RTL_OTTO, RTL_OTTO_NAME);
+
+module_dsa_tag_driver(rtl_otto_netdev_ops);
diff --git a/target/linux/realtek/patches-6.12/721-net-dsa-add-support-for-tag-rtl-otto.patch b/target/linux/realtek/patches-6.12/721-net-dsa-add-support-for-tag-rtl-otto.patch
new file mode 100644
index 0000000000..7ad71228fc
--- /dev/null
+++ b/target/linux/realtek/patches-6.12/721-net-dsa-add-support-for-tag-rtl-otto.patch
@@ -0,0 +1,51 @@
+From: Markus Stockhausen <markus.stockhausen at gmx.de>
+Date: Sun, 1 Feb 2026 10:40:52 +0100
+Subject: realtek: net: dsa: add suport for tag rtl-otto
+
+This adds the rtl-otto tag feature for Realtek switches.
+
+Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
+
+--- a/net/dsa/Makefile
++++ b/net/dsa/Makefile
+@@ -35,6 +35,7 @@ obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca
+ obj-$(CONFIG_NET_DSA_TAG_RTL4_A) += tag_rtl4_a.o
+ obj-$(CONFIG_NET_DSA_TAG_RTL8_4) += tag_rtl8_4.o
+ obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.o
++obj-$(CONFIG_NET_DSA_TAG_RTL_OTTO) += tag_rtl_otto.o
+ obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o
+ obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
+ obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o
+--- a/net/dsa/Kconfig
++++ b/net/dsa/Kconfig
+@@ -163,6 +163,12 @@ config NET_DSA_TAG_LAN9303
+ Say Y or M if you want to enable support for tagging frames for the
+ SMSC/Microchip LAN9303 family of switches.
+
++config NET_DSA_TAG_RTL_OTTO
++ tristate "Tag driver for Realtek Otto switches (RTL83xx/RTL93xx)"
++ help
++ Say Y or M if you want to enable support for tagging frames for the
++ Realtek Otto family of switches.
++
+ config NET_DSA_TAG_SJA1105
+ tristate "Tag driver for NXP SJA1105 switches"
+ select PACKING
+--- a/include/net/dsa.h
++++ b/include/net/dsa.h
+@@ -55,6 +55,7 @@ struct tc_action;
+ #define DSA_TAG_PROTO_LAN937X_VALUE 27
+ #define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28
+ #define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29
++#define DSA_TAG_PROTO_RTL_OTTO_VALUE 30
+
+ enum dsa_tag_protocol {
+ DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE,
+@@ -87,6 +88,7 @@ enum dsa_tag_protocol {
+ DSA_TAG_PROTO_RZN1_A5PSW = DSA_TAG_PROTO_RZN1_A5PSW_VALUE,
+ DSA_TAG_PROTO_LAN937X = DSA_TAG_PROTO_LAN937X_VALUE,
+ DSA_TAG_PROTO_VSC73XX_8021Q = DSA_TAG_PROTO_VSC73XX_8021Q_VALUE,
++ DSA_TAG_PROTO_RTL_OTTO = DSA_TAG_PROTO_RTL_OTTO_VALUE,
+ };
+
+ struct dsa_switch;
diff --git a/target/linux/realtek/patches-6.12/722-net-dsa-add-rtl838x-support-for-tag-trailer.patch b/target/linux/realtek/patches-6.12/722-net-dsa-add-rtl838x-support-for-tag-trailer.patch
deleted file mode 100644
index 8f02f03b51..0000000000
--- a/target/linux/realtek/patches-6.12/722-net-dsa-add-rtl838x-support-for-tag-trailer.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From 2b88563ee5aafd9571d965b7f2093a0f58d98a31 Mon Sep 17 00:00:00 2001
-From: John Crispin <john at phrozen.org>
-Date: Thu, 26 Nov 2020 12:02:21 +0100
-Subject: net: dsa: Add rtl838x support for tag trailer
-
-* rename the target to realtek
-* add refactored DSA driver
-* add latest gpio driver
-* lots of arch cleanups
-* new irq driver
-* additional boards
-
-Submitted-by: Bert Vermeulen <bert at biot.com>
-Submitted-by: Birger Koblitz <mail at birger-koblitz.de>
-Submitted-by: Sander Vanheule <sander at svanheule.net>
-Submitted-by: Bjørn Mork <bjorn at mork.no>
-Submitted-by: John Crispin <john at phrozen.org>
----
- net/dsa/tag_trailer.c | 16 +++++++++++++-
- 1 file changed, 17 insertions(+), 1 deletion(-)
-
---- a/net/dsa/tag_trailer.c
-+++ b/net/dsa/tag_trailer.c
-@@ -19,7 +19,12 @@ static struct sk_buff *trailer_xmit(stru
-
- trailer = skb_put(skb, 4);
- trailer[0] = 0x80;
-+
-+#ifdef CONFIG_NET_DSA_RTL83XX
-+ trailer[1] = dp->index;
-+#else
- trailer[1] = 1 << dp->index;
-+#endif /* CONFIG_NET_DSA_RTL838X */
- trailer[2] = 0x10;
- trailer[3] = 0x00;
-
-@@ -35,12 +40,23 @@ static struct sk_buff *trailer_rcv(struc
- return NULL;
-
- trailer = skb_tail_pointer(skb) - 4;
-+
-+#ifdef CONFIG_NET_DSA_RTL83XX
-+ if (trailer[0] != 0x80 || (trailer[1] & 0x80) != 0x00 ||
-+ (trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
-+ return NULL;
-+
-+ if (trailer[1] & 0x40)
-+ skb->offload_fwd_mark = 1;
-+
-+ source_port = trailer[1] & 0x3f;
-+#else
- if (trailer[0] != 0x80 || (trailer[1] & 0xf8) != 0x00 ||
- (trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
- return NULL;
-
- source_port = trailer[1] & 7;
--
-+#endif
- skb->dev = dsa_conduit_find_user(dev, 0, source_port);
- if (!skb->dev)
- return NULL;
diff --git a/target/linux/realtek/rtl838x/config-6.12 b/target/linux/realtek/rtl838x/config-6.12
index fe55afc065..70b8598e17 100644
--- a/target/linux/realtek/rtl838x/config-6.12
+++ b/target/linux/realtek/rtl838x/config-6.12
@@ -174,7 +174,7 @@ CONFIG_NET_DEVLINK=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_RTL83XX=y
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
-CONFIG_NET_DSA_TAG_TRAILER=y
+CONFIG_NET_DSA_TAG_RTL_OTTO=y
CONFIG_NET_EGRESS=y
CONFIG_NET_INGRESS=y
CONFIG_NET_RTL838X=y
diff --git a/target/linux/realtek/rtl839x/config-6.12 b/target/linux/realtek/rtl839x/config-6.12
index b71f3f1702..2651a42d2e 100644
--- a/target/linux/realtek/rtl839x/config-6.12
+++ b/target/linux/realtek/rtl839x/config-6.12
@@ -178,7 +178,7 @@ CONFIG_NET_DEVLINK=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_RTL83XX=y
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
-CONFIG_NET_DSA_TAG_TRAILER=y
+CONFIG_NET_DSA_TAG_RTL_OTTO=y
CONFIG_NET_EGRESS=y
CONFIG_NET_FLOW_LIMIT=y
CONFIG_NET_INGRESS=y
diff --git a/target/linux/realtek/rtl930x/config-6.12 b/target/linux/realtek/rtl930x/config-6.12
index 02d1463659..ce58654015 100644
--- a/target/linux/realtek/rtl930x/config-6.12
+++ b/target/linux/realtek/rtl930x/config-6.12
@@ -160,7 +160,7 @@ CONFIG_NET_DEVLINK=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_RTL83XX=y
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
-CONFIG_NET_DSA_TAG_TRAILER=y
+CONFIG_NET_DSA_TAG_RTL_OTTO=y
CONFIG_NET_EGRESS=y
CONFIG_NET_FLOW_LIMIT=y
CONFIG_NET_INGRESS=y
diff --git a/target/linux/realtek/rtl930x_nand/config-6.12 b/target/linux/realtek/rtl930x_nand/config-6.12
index 4365107528..8cd4db24d7 100644
--- a/target/linux/realtek/rtl930x_nand/config-6.12
+++ b/target/linux/realtek/rtl930x_nand/config-6.12
@@ -166,7 +166,7 @@ CONFIG_NET_DEVLINK=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_RTL83XX=y
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
-CONFIG_NET_DSA_TAG_TRAILER=y
+CONFIG_NET_DSA_TAG_RTL_OTTO=y
CONFIG_NET_EGRESS=y
CONFIG_NET_FLOW_LIMIT=y
CONFIG_NET_INGRESS=y
diff --git a/target/linux/realtek/rtl931x/config-6.12 b/target/linux/realtek/rtl931x/config-6.12
index 622044c9eb..60f3a6067c 100644
--- a/target/linux/realtek/rtl931x/config-6.12
+++ b/target/linux/realtek/rtl931x/config-6.12
@@ -170,7 +170,7 @@ CONFIG_NET_DEVLINK=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_RTL83XX=y
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
-CONFIG_NET_DSA_TAG_TRAILER=y
+CONFIG_NET_DSA_TAG_RTL_OTTO=y
CONFIG_NET_EGRESS=y
CONFIG_NET_FLOW_LIMIT=y
CONFIG_NET_INGRESS=y
diff --git a/target/linux/realtek/rtl931x_nand/config-6.12 b/target/linux/realtek/rtl931x_nand/config-6.12
index 4357e0ee23..dfe46a968f 100644
--- a/target/linux/realtek/rtl931x_nand/config-6.12
+++ b/target/linux/realtek/rtl931x_nand/config-6.12
@@ -177,7 +177,7 @@ CONFIG_NET_DEVLINK=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_RTL83XX=y
# CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD is not set
-CONFIG_NET_DSA_TAG_TRAILER=y
+CONFIG_NET_DSA_TAG_RTL_OTTO=y
CONFIG_NET_EGRESS=y
CONFIG_NET_FLOW_LIMIT=y
CONFIG_NET_INGRESS=y
More information about the lede-commits
mailing list