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.
/* 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,
--- /dev/null
+// 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);
--- /dev/null
+From: Markus Stockhausen <markus.stockhausen@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@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;
+++ /dev/null
-From 2b88563ee5aafd9571d965b7f2093a0f58d98a31 Mon Sep 17 00:00:00 2001
-From: John Crispin <john@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@biot.com>
-Submitted-by: Birger Koblitz <mail@birger-koblitz.de>
-Submitted-by: Sander Vanheule <sander@svanheule.net>
-Submitted-by: Bjørn Mork <bjorn@mork.no>
-Submitted-by: John Crispin <john@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;
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
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
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
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
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
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