[PATCH 09/20] net: dsa: tag_xlnx_tsn: add skeleton tag protocol

Nagadheeraj Rottela <[email protected]>
Newsgroups org.kernel.vger.linux-devicetree,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <[email protected]>
The AMD/Xilinx TSN Endpoint Ethernet MAC IP does not insert an
in-band CPU tag on the wire. The EP MAC driver attaches a per-port
metadata_dst (METADATA_HW_PORT_MUX) on RX to carry the port
classification out of band. The tag protocol therefore has no tag
bytes to add or strip.

Add DSA_TAG_PROTO_XLNX_TSN and register NET_DSA_TAG_XLNX_TSN as a
no-op tag driver. A later patch adds the PTP TX intercept to reroute
PTP frames through the per-MAC PTP TX path.

Signed-off-by: Nagadheeraj Rottela <[email protected]>
---
 MAINTAINERS            |  1 +
 include/net/dsa.h      |  2 ++
 net/dsa/Kconfig        |  9 +++++++++
 net/dsa/Makefile       |  1 +
 net/dsa/tag_xlnx_tsn.c | 33 +++++++++++++++++++++++++++++++++
 5 files changed, 46 insertions(+)
 create mode 100644 net/dsa/tag_xlnx_tsn.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e5b95b3bfa21..6fbe83fb3953 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -29614,6 +29614,7 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml
 F:	drivers/net/ethernet/xilinx/tsn/
+F:	net/dsa/tag_xlnx_tsn.c
 
 XILINX UARTLITE SERIAL DRIVER
 M:	Peter Korsgaard <[email protected]>
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 6f7f5c17b532..f0cc5b49407a 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -60,6 +60,7 @@ struct tc_action;
 #define DSA_TAG_PROTO_MXL862_VALUE		32
 #define DSA_TAG_PROTO_NETC_VALUE		33
 #define DSA_TAG_PROTO_KSZ8463_VALUE		34
+#define DSA_TAG_PROTO_XLNX_TSN_VALUE		35
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -97,6 +98,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_MXL862		= DSA_TAG_PROTO_MXL862_VALUE,
 	DSA_TAG_PROTO_NETC		= DSA_TAG_PROTO_NETC_VALUE,
 	DSA_TAG_PROTO_KSZ8463		= DSA_TAG_PROTO_KSZ8463_VALUE,
+	DSA_TAG_PROTO_XLNX_TSN		= DSA_TAG_PROTO_XLNX_TSN_VALUE,
 };
 
 struct dsa_switch;
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index d5e725b90d78..8ca48ce46ec1 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -221,4 +221,13 @@ config NET_DSA_TAG_YT921X
 	  Say Y or M if you want to enable support for tagging frames for
 	  Motorcomm YT921x switches.
 
+config NET_DSA_TAG_XLNX_TSN
+	tristate "Tag driver for AMD/Xilinx TSN Endpoint Ethernet MAC"
+	help
+	  Say Y or M if you want to enable support for the AMD/Xilinx TSN
+	  Endpoint Ethernet MAC IP. The IP does not insert an in-band CPU
+	  tag; port classification is conveyed via metadata_dst attached on
+	  RX by the EP MAC driver, and PTP TX frames are intercepted in the
+	  xmit hook to be steered into the per-MAC PTP TX register window.
+
 endif
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index b8c2667cd14a..6ba6c3a95976 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.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
+obj-$(CONFIG_NET_DSA_TAG_XLNX_TSN) += tag_xlnx_tsn.o
 obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o
 obj-$(CONFIG_NET_DSA_TAG_YT921X) += tag_yt921x.o
 
diff --git a/net/dsa/tag_xlnx_tsn.c b/net/dsa/tag_xlnx_tsn.c
new file mode 100644
index 000000000000..de352aa3d9a8
--- /dev/null
+++ b/net/dsa/tag_xlnx_tsn.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * AMD/Xilinx TSN Endpoint Ethernet MAC tag protocol.
+ */
+
+#include "tag.h"
+
+#define XLNX_TSN_NAME	"xlnx_tsn"
+
+static struct sk_buff *xlnx_tsn_xmit(struct sk_buff *skb,
+				     struct net_device *dev)
+{
+	return skb;
+}
+
+static struct sk_buff *xlnx_tsn_rcv(struct sk_buff *skb,
+				    struct net_device *dev)
+{
+	kfree_skb(skb);
+	return NULL;
+}
+
+static const struct dsa_device_ops xlnx_tsn_netdev_ops = {
+	.name	= XLNX_TSN_NAME,
+	.proto	= DSA_TAG_PROTO_XLNX_TSN,
+	.xmit	= xlnx_tsn_xmit,
+	.rcv	= xlnx_tsn_rcv,
+};
+
+module_dsa_tag_driver(xlnx_tsn_netdev_ops);
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_XLNX_TSN, XLNX_TSN_NAME);
+MODULE_DESCRIPTION("DSA tag driver for AMD/Xilinx TSN Endpoint Ethernet MAC");
+MODULE_LICENSE("GPL");
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.