Skip to contentSkip to conversation

Hirschmann Hellcreek DSA driver

PATCH Superseded Kurt Kanzenbach 3 participants 15 messages Sep 4, 2020 – Sep 7, 2020

Subsystems (5)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Kurt Kanzenbach

author maintainer
#0 lore raw

v5 cover Hirschmann Hellcreek DSA driver

Hi,

this series adds a DSA driver for the Hirschmann Hellcreek TSN switch IP. Characteristics of that IP:

* Full duplex Ethernet interface at 100/1000 Mbps on three ports
* IEEE 802.1Q-compliant Ethernet Switch
* IEEE 802.1Qbv Time-Aware scheduling support
* IEEE 1588 and IEEE 802.1AS support

That IP is used e.g. in

https://www.arrow.com/en/campaigns/arrow-kairos

Due to the hardware setup the switch driver is implemented using DSA. A special tagging protocol is leveraged. Furthermore, this driver supports PTP and hardware timestamping.

This work is part of the AccessTSN project: https://www.accesstsn.com/

The previous versions can be found here:

* https://lkml.kernel.org/netdev/[email protected]/
* https://lkml.kernel.org/netdev/[email protected]/
* https://lkml.kernel.org/netdev/[email protected]/
* https://lkml.kernel.org/netdev/[email protected]/
* https://lkml.kernel.org/netdev/[email protected]/

Changes since v4:

* Fix W=1 compiler warnings (kernel test robot)
* Add tags

Changes since v3:

* Drop TAPRIO support (David Miller)
=> Switch to mutexes due to the lack of hrtimers
* Use more specific compatible strings and add platform data (Andrew Lunn)
* Fix Kconfig ordering (Andrew Lunn)

Changes since v2:

* Make it compile by getting all requirements merged first (Jakub Kicinski, David Miller)
* Use "tsn" for TSN register set (Rob Herring)
* Fix DT binding issues (Rob Herring)

Changes since v1:

* Code simplifications (Florian Fainelli, Vladimir Oltean)
* Fix issues with hellcreek.yaml bindings (Florian Fainelli)
* Clear reserved field in ptp v2 event messages (Richard Cochran)
* Make use of generic ptp parsing function (Richard Cochran, Vladimir Oltean)
* Fix Kconfig (Florian Fainelli)
* Add tags (Florian Fainelli, Rob Herring, Richard Cochran)

Changes since RFC ordered by reviewers:

* Andrew Lunn
* Use dev_dbg for debug messages
* Get rid of __ function names where possible
* Use reverse xmas tree variable ordering
* Remove redundant/useless checks
* Improve comments e.g. for PTP
* Fix Kconfig ordering
* Make LED handling more generic and provide info via DT
* Setup advertisement of PHYs according to hardware
* Drop debugfs patch
* Jakub Kicinski
* Fix compiler warnings
* Florian Fainelli
* Switch to YAML DT bindings
* Richard Cochran
* Fix typo
* Add missing NULL checks

Kamil Alkhouri (2):
net: dsa: hellcreek: Add PTP clock support
net: dsa: hellcreek: Add support for hardware timestamping

Kurt Kanzenbach (5):
net: dsa: Add tag handling for Hirschmann Hellcreek switches
net: dsa: Add DSA driver for Hirschmann Hellcreek switches
net: dsa: hellcreek: Add PTP status LEDs
dt-bindings: Add vendor prefix for Hirschmann
dt-bindings: net: dsa: Add documentation for Hellcreek switches

 .../bindings/net/dsa/hellcreek.yaml           |  127 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |    2 +
 drivers/net/dsa/Kconfig                       |    2 +
 drivers/net/dsa/Makefile                      |    1 +
 drivers/net/dsa/hirschmann/Kconfig            |    9 +
 drivers/net/dsa/hirschmann/Makefile           |    5 +
 drivers/net/dsa/hirschmann/hellcreek.c        | 1262 +++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek.h        |  282 ++++
 .../net/dsa/hirschmann/hellcreek_hwtstamp.c   |  479 +++++++
 .../net/dsa/hirschmann/hellcreek_hwtstamp.h   |   58 +
 drivers/net/dsa/hirschmann/hellcreek_ptp.c    |  452 ++++++
 drivers/net/dsa/hirschmann/hellcreek_ptp.h    |   76 +
 .../platform_data/hirschmann-hellcreek.h      |   22 +
 include/net/dsa.h                             |    2 +
 net/dsa/Kconfig                               |    6 +
 net/dsa/Makefile                              |    1 +
 net/dsa/tag_hellcreek.c                       |  101 ++
 17 files changed, 2887 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.yaml
 create mode 100644 drivers/net/dsa/hirschmann/Kconfig
 create mode 100644 drivers/net/dsa/hirschmann/Makefile
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek.c
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek.h
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_ptp.c
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_ptp.h
 create mode 100644 include/linux/platform_data/hirschmann-hellcreek.h
 create mode 100644 net/dsa/tag_hellcreek.c
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH v5 1/7 net: dsa: Add tag handling for Hirschmann Hellcreek switches

The Hirschmann Hellcreek TSN switches have a special tagging protocol for frames exchanged between the CPU port and the master interface. The format is a one byte trailer indicating the destination or origin port.

It's quite similar to the Micrel KSZ tagging. That's why the implementation is based on that code.

---
 include/net/dsa.h       |   2 +
 net/dsa/Kconfig         |   6 +++
 net/dsa/Makefile        |   1 +
 net/dsa/tag_hellcreek.c | 101 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 110 insertions(+)
 create mode 100644 net/dsa/tag_hellcreek.c
include/net/dsa.h +2 -0
index 75c8fac82017..5cf710580a28 100644
@@ -45,6 +45,7 @@ struct phylink_link_state;
 #define DSA_TAG_PROTO_OCELOT_VALUE		15
 #define DSA_TAG_PROTO_AR9331_VALUE		16
 #define DSA_TAG_PROTO_RTL4_A_VALUE		17
+#define DSA_TAG_PROTO_HELLCREEK_VALUE		18
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -65,6 +66,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_OCELOT		= DSA_TAG_PROTO_OCELOT_VALUE,
 	DSA_TAG_PROTO_AR9331		= DSA_TAG_PROTO_AR9331_VALUE,
 	DSA_TAG_PROTO_RTL4_A		= DSA_TAG_PROTO_RTL4_A_VALUE,
+	DSA_TAG_PROTO_HELLCREEK		= DSA_TAG_PROTO_HELLCREEK_VALUE,
 };
 
 struct packet_type;
net/dsa/Kconfig +6 -0
index 1f9b9b11008c..d975614f7dd6 100644
@@ -56,6 +56,12 @@ config NET_DSA_TAG_BRCM_PREPEND
 	  Broadcom switches which places the tag before the Ethernet header
 	  (prepended).
 
+config NET_DSA_TAG_HELLCREEK
+	tristate "Tag driver for Hirschmann Hellcreek TSN switches"
+	help
+	  Say Y or M if you want to enable support for tagging frames
+	  for the Hirschmann Hellcreek TSN switches.
+
 config NET_DSA_TAG_GSWIP
 	tristate "Tag driver for Lantiq / Intel GSWIP switches"
 	help
net/dsa/Makefile +1 -0
index 4f47b2025ff5..e25d5457964a 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o
 obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
 obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
 obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o
+obj-$(CONFIG_NET_DSA_TAG_HELLCREEK) += tag_hellcreek.o
 obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o
 obj-$(CONFIG_NET_DSA_TAG_RTL4_A) += tag_rtl4_a.o
 obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o
net/dsa/tag_hellcreek.c new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
2.20.1
author maintainer
#2 lore raw

PATCH v5 2/7 net: dsa: Add DSA driver for Hirschmann Hellcreek switches

In reply to Kurt Kanzenbach

Add a basic DSA driver for Hirschmann Hellcreek switches. Those switches are implementing features needed for Time Sensitive Networking (TSN) such as support for the Time Precision Protocol and various shapers like the Time Aware Shaper.

This driver includes basic support for networking:

* VLAN handling
* FDB handling
* Port statistics
* STP
* Phylink

---
 drivers/net/dsa/Kconfig                       |    2 +
 drivers/net/dsa/Makefile                      |    1 +
 drivers/net/dsa/hirschmann/Kconfig            |    8 +
 drivers/net/dsa/hirschmann/Makefile           |    2 +
 drivers/net/dsa/hirschmann/hellcreek.c        | 1176 +++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek.h        |  245 ++++
 .../platform_data/hirschmann-hellcreek.h      |   22 +
 7 files changed, 1456 insertions(+)
 create mode 100644 drivers/net/dsa/hirschmann/Kconfig
 create mode 100644 drivers/net/dsa/hirschmann/Makefile
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek.c
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek.h
 create mode 100644 include/linux/platform_data/hirschmann-hellcreek.h
drivers/net/dsa/Kconfig +2 -0
index 468b3c4273c5..07e17088b2b7 100644
@@ -24,6 +24,8 @@ config NET_DSA_LOOP
 	  This enables support for a fake mock-up switch chip which
 	  exercises the DSA APIs.
 
+source "drivers/net/dsa/hirschmann/Kconfig"
+
 config NET_DSA_LANTIQ_GSWIP
 	tristate "Lantiq / Intel GSWIP"
 	depends on HAS_IOMEM && NET_DSA
drivers/net/dsa/Makefile +1 -0
index 4a943ccc2ca4..a84adb140a04 100644
@@ -18,6 +18,7 @@ obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o
 obj-y				+= b53/
+obj-y				+= hirschmann/
 obj-y				+= microchip/
 obj-y				+= mv88e6xxx/
 obj-y				+= ocelot/
drivers/net/dsa/hirschmann/Kconfig new file +8 -0
new file mode 100644
index 000000000000..7d189cb936e3
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+config NET_DSA_HIRSCHMANN_HELLCREEK
+	tristate "Hirschmann Hellcreek TSN Switch support"
+	depends on HAS_IOMEM
+	depends on NET_DSA
+	select NET_DSA_TAG_HELLCREEK
+	help
+	  This driver adds support for Hirschmann Hellcreek TSN switches.
drivers/net/dsa/hirschmann/Makefile new file +2 -0
new file mode 100644
index 000000000000..0e12e149e40f
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_NET_DSA_HIRSCHMANN_HELLCREEK)	+= hellcreek.o
drivers/net/dsa/hirschmann/hellcreek.c new file +1176 -0

1,176 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek.h new file +245 -0

245 lines not on this page · raw message

include/linux/platform_data/hirschmann-hellcreek.h new file +22 -0
new file mode 100644
index 000000000000..fa2b1adb877f
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: (GPL-2.0 or MIT) */
+/*
+ * Hirschmann Hellcreek TSN switch platform data.
+ *
+ * Copyright (C) 2020 Linutronix GmbH
+ * Author Kurt Kanzenbach <[email protected]>
+ */
+
+#ifndef _HIRSCHMANN_HELLCREEK_H_
+#define _HIRSCHMANN_HELLCREEK_H_
+
+#include <linux/types.h>
+
+struct hellcreek_platform_data {
+	int num_ports;
+	int is_100_mbits;
+	int qbv_support;
+	int qbv_on_cpu;
+	u16 module_id;
+};
+
+#endif /* _HIRSCHMANN_HELLCREEK_H_ */
Signature · 1 line
2.20.1
maintainer
#3 lore raw

Re: [PATCH v5 2/7] net: dsa: Add DSA driver for Hirschmann Hellcreek switches

Quoted 14 lines · Kurt Kanzenbach

Add a basic DSA driver for Hirschmann Hellcreek switches. Those switches are implementing features needed for Time Sensitive Networking (TSN) such as support for the Time Precision Protocol and various shapers like the Time Aware Shaper.

This driver includes basic support for networking:

* VLAN handling
* FDB handling
* Port statistics
* STP
* Phylink

---

drivers/net/dsa/hirschmann/hellcreek.c line 801

Quoted 7 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +7 -0
+
+/* Default setup for DSA:
+ *  VLAN 2: CPU and Port 1 egress untagged.
+ *  VLAN 3: CPU and Port 2 egress untagged.
+ */
+static int hellcreek_setup_vlan_membership(struct dsa_switch *ds, int port,
+					   bool enabled)

If you use VLAN 2 and 3 for port separation, then how does the driver deal with the following:

ip link add link swp1 name swp1.100 type vlan id 100 ip link add link swp2 name swp2.100 type vlan id 100

In this case, frames with VLAN 100 shouldn't leak from one port to the other, will they?

Quoted 55 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +55 -0
+{
+	int upstream = dsa_upstream_port(ds, port);
+	struct switchdev_obj_port_vlan vlan = {
+		.vid_begin = port,
+		.vid_end = port,
+	};
+	int err = 0;
+
+	/* The CPU port is implicitly configured by
+	 * configuring the front-panel ports
+	 */
+	if (!dsa_is_user_port(ds, port))
+		return 0;
+
+	/* Apply vid to port as egress untagged and port vlan id */
+	vlan.flags = BRIDGE_VLAN_INFO_UNTAGGED | BRIDGE_VLAN_INFO_PVID;
+	if (enabled)
+		hellcreek_vlan_add(ds, port, &vlan);
+	else
+		err = hellcreek_vlan_del(ds, port, &vlan);
+	if (err) {
+		dev_err(ds->dev, "Failed to apply VID %d to port %d: %d\n",
+			port, port, err);
+		return err;
+	}
+
+	/* Apply vid to cpu port as well */
+	vlan.flags = BRIDGE_VLAN_INFO_UNTAGGED;
+	if (enabled)
+		hellcreek_vlan_add(ds, upstream, &vlan);
+	else
+		err = hellcreek_vlan_del(ds, upstream, &vlan);
+	if (err) {
+		dev_err(ds->dev, "Failed to apply VID %d to port %d: %d\n",
+			port, port, err);
+		return err;
+	}
+
+	return 0;
+}
+
+static void hellcreek_setup_ingressflt(struct hellcreek *hellcreek, int port,
+				       bool enable)
+{
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	u16 ptcfg;
+
+	mutex_lock(&hellcreek->reg_lock);
+
+	ptcfg = hellcreek_port->ptcfg;
+
+	if (enable)
+		ptcfg |= HR_PTCFG_INGRESSFLT;
+	else
+		ptcfg &= ~HR_PTCFG_INGRESSFLT;

drivers/net/dsa/hirschmann/hellcreek.c line 866

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+
+	hellcreek_select_port(hellcreek, port);
+	hellcreek_write(hellcreek, ptcfg, HR_PTCFG);
+	hellcreek_port->ptcfg = ptcfg;
+
+	mutex_unlock(&hellcreek->reg_lock);
+}
+
+static int hellcreek_vlan_filtering(struct dsa_switch *ds, int port,
+				    bool vlan_filtering)

I remember asking in Message-ID: <20200716082935.snokd33kn52ixk5h@skbuf> whether it would be possible for you to set ds->configure_vlan_while_not_filtering = true during hellcreek_setup. Did anything unexpected happen while trying that?

Quoted 15 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +15 -0
+{
+	struct hellcreek *hellcreek = ds->priv;
+
+	dev_dbg(hellcreek->dev, "%s VLAN filtering on port %d\n",
+		vlan_filtering ? "Enable" : "Disable", port);
+
+	/* Configure port to drop packages with not known vids */
+	hellcreek_setup_ingressflt(hellcreek, port, vlan_filtering);
+
+	/* Drop DSA vlan membership config. The user can now do it. */
+	hellcreek_setup_vlan_membership(ds, port, !vlan_filtering);
+
+	return 0;
+}
+
author maintainer
#4 lore raw

Re: [PATCH v5 2/7] net: dsa: Add DSA driver for Hirschmann Hellcreek switches

Quoted 26 lines · Vladimir Oltean
Quoted 14 lines · Kurt Kanzenbach

Add a basic DSA driver for Hirschmann Hellcreek switches. Those switches are implementing features needed for Time Sensitive Networking (TSN) such as support for the Time Precision Protocol and various shapers like the Time Aware Shaper.

This driver includes basic support for networking:

* VLAN handling
* FDB handling
* Port statistics
* STP
* Phylink

---

drivers/net/dsa/hirschmann/hellcreek.c line 801

Quoted 7 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +7 -0
+
+/* Default setup for DSA:
+ *  VLAN 2: CPU and Port 1 egress untagged.
+ *  VLAN 3: CPU and Port 2 egress untagged.
+ */
+static int hellcreek_setup_vlan_membership(struct dsa_switch *ds, int port,
+					   bool enabled)

If you use VLAN 2 and 3 for port separation, then how does the driver deal with the following:

Quoted 5 lines

ip link add link swp1 name swp1.100 type vlan id 100 ip link add link swp2 name swp2.100 type vlan id 100

In this case, frames with VLAN 100 shouldn't leak from one port to the other, will they?

Well, that depends on whether hellcreek_vlan_add() is called for creating that vlan interfaces. In general: As soon as both ports are members of the same vlan that traffic is switched.

Quoted 63 lines
Quoted 63 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +62 -0
+{
+	int upstream = dsa_upstream_port(ds, port);
+	struct switchdev_obj_port_vlan vlan = {
+		.vid_begin = port,
+		.vid_end = port,
+	};
+	int err = 0;
+
+	/* The CPU port is implicitly configured by
+	 * configuring the front-panel ports
+	 */
+	if (!dsa_is_user_port(ds, port))
+		return 0;
+
+	/* Apply vid to port as egress untagged and port vlan id */
+	vlan.flags = BRIDGE_VLAN_INFO_UNTAGGED | BRIDGE_VLAN_INFO_PVID;
+	if (enabled)
+		hellcreek_vlan_add(ds, port, &vlan);
+	else
+		err = hellcreek_vlan_del(ds, port, &vlan);
+	if (err) {
+		dev_err(ds->dev, "Failed to apply VID %d to port %d: %d\n",
+			port, port, err);
+		return err;
+	}
+
+	/* Apply vid to cpu port as well */
+	vlan.flags = BRIDGE_VLAN_INFO_UNTAGGED;
+	if (enabled)
+		hellcreek_vlan_add(ds, upstream, &vlan);
+	else
+		err = hellcreek_vlan_del(ds, upstream, &vlan);
+	if (err) {
+		dev_err(ds->dev, "Failed to apply VID %d to port %d: %d\n",
+			port, port, err);
+		return err;
+	}
+
+	return 0;
+}
+
+static void hellcreek_setup_ingressflt(struct hellcreek *hellcreek, int port,
+				       bool enable)
+{
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	u16 ptcfg;
+
+	mutex_lock(&hellcreek->reg_lock);
+
+	ptcfg = hellcreek_port->ptcfg;
+
+	if (enable)
+		ptcfg |= HR_PTCFG_INGRESSFLT;
+	else
+		ptcfg &= ~HR_PTCFG_INGRESSFLT;
+
+	hellcreek_select_port(hellcreek, port);
+	hellcreek_write(hellcreek, ptcfg, HR_PTCFG);
+	hellcreek_port->ptcfg = ptcfg;
+
+	mutex_unlock(&hellcreek->reg_lock);
+}
Quoted 8 lines

drivers/net/dsa/hirschmann/hellcreek.c line 866

Quoted 3 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +3 -0
+
+static int hellcreek_vlan_filtering(struct dsa_switch *ds, int port,
+				    bool vlan_filtering)

I remember asking in Message-ID: <20200716082935.snokd33kn52ixk5h@skbuf> whether it would be possible for you to set ds->configure_vlan_while_not_filtering = true during hellcreek_setup. Did anything unexpected happen while trying that?

No, that comment got lost.

So looking at the flag: Does it mean the driver can receive vlan configurations when a bridge without vlan filtering is used? That might be problematic as this driver uses vlans for the port separation by default. This is undone when vlan filtering is set to 1 meaning vlan configurations can be received without any problems.

Thanks,
Kurt

maintainer
#5 lore raw

Re: [PATCH v5 2/7] net: dsa: Add DSA driver for Hirschmann Hellcreek switches

Quoted 3 lines · Kurt Kanzenbach

Well, that depends on whether hellcreek_vlan_add() is called for creating that vlan interfaces. In general: As soon as both ports are members of the same vlan that traffic is switched.

That's indeed what I would expect.
Not only that, but with your pvid-based setup, you only ensure port separation for untagged traffic anyway. I don't think you even need to call hellcreek_vlan_add() for VID 100 to be switched between ports, because your .port_vlan_filtering callback does not in fact disable VLAN awareness, it just configures the ports to not drop unknown VLANs. So, arguably, VLAN classification is still performed. An untagged packet is classified to the PVID, a tagged packet is classified to the VID in the packet. So tagged packets bypass the separation.

So, I think that's not ok. I think the only proper way to solve this is to inform the IP designers that VLANs are no substitute for a port forwarding matrix (a lookup table that answers the question "can port i forward to port j"). Switch ports that are individually addressable by the network stack are a fundamental assumption of the switchdev framework.

Quoted 5 lines
Quoted 4 lines

I remember asking in Message-ID: <20200716082935.snokd33kn52ixk5h@skbuf> whether it would be possible for you to set ds->configure_vlan_while_not_filtering = true during hellcreek_setup. Did anything unexpected happen while trying that?

Quoted 7 lines

No, that comment got lost.

So looking at the flag: Does it mean the driver can receive vlan configurations when a bridge without vlan filtering is used? That might be problematic as this driver uses vlans for the port separation by default. This is undone when vlan filtering is set to 1 meaning vlan configurations can be received without any problems.

Yes.
Generally speaking, the old DSA behavior is something that we're trying to get rid of, once all drivers set the option to true. So a new driver should not rely on it even if it needs something like that. If you need caching of VLANs installed by the bridge and/or by the 8021q module, then you can add those to a list, and restore them in the .port_vlan_filtering callback by yourself. You can look at how sja1105 does that.

Thanks,
-Vladimir

author maintainer
#6 lore raw

Re: [PATCH v5 2/7] net: dsa: Add DSA driver for Hirschmann Hellcreek switches

Quoted 8 lines · Vladimir Oltean
Quoted 3 lines · Kurt Kanzenbach

Well, that depends on whether hellcreek_vlan_add() is called for creating that vlan interfaces. In general: As soon as both ports are members of the same vlan that traffic is switched.

That's indeed what I would expect.
Not only that, but with your pvid-based setup, you only ensure port separation for untagged traffic anyway.

Why? Tagged traffic is dropped unless the vlan is configured somehow. By default, I've configured vlan 2 and 3 to reflect the port separation for DSA. At reset the ports aren't members of any vlan.

We could also skip the initial VLAN configuration completely. At the end of the day it's a TSN switch and the user will setup the vlan configuration anyway.

Quoted 8 lines

I don't think you even need to call hellcreek_vlan_add() for VID 100 to be switched between ports, because your .port_vlan_filtering callback does not in fact disable VLAN awareness, it just configures the ports to not drop unknown VLANs. So, arguably, VLAN classification is still performed. An untagged packet is classified to the PVID, a tagged packet is classified to the VID in the packet. So tagged packets bypass the separation.

Quoted 6 lines

So, I think that's not ok. I think the only proper way to solve this is to inform the IP designers that VLANs are no substitute for a port forwarding matrix (a lookup table that answers the question "can port i forward to port j"). Switch ports that are individually addressable by the network stack are a fundamental assumption of the switchdev framework.

As I said before, there is no port forwarding matrix. There are only vlans and the fdb. There's also a global flag for setting vlan unaware mode and a port option for vlan tag required. That's it. I guess, we have to deal with it somehow.

Quoted 14 lines
Quoted 6 lines
Quoted 5 lines

I remember asking in Message-ID: <20200716082935.snokd33kn52ixk5h@skbuf> whether it would be possible for you to set ds->configure_vlan_while_not_filtering = true during hellcreek_setup. Did anything unexpected happen while trying that?

Quoted 7 lines

No, that comment got lost.

So looking at the flag: Does it mean the driver can receive vlan configurations when a bridge without vlan filtering is used? That might be problematic as this driver uses vlans for the port separation by default. This is undone when vlan filtering is set to 1 meaning vlan configurations can be received without any problems.

Quoted 4 lines

Yes.
Generally speaking, the old DSA behavior is something that we're trying to get rid of, once all drivers set the option to true. So a new driver should not rely on it even if it needs something like that.

OK. when a new driver should set the flag, then I'll set it. So, all vlan requests programming requests should be "buffered" and executed when vlan filtering is enabled? What is it good for?

Thanks,
Kurt

maintainer
#7 lore raw

Re: [PATCH v5 2/7] net: dsa: Add DSA driver for Hirschmann Hellcreek switches

Quoted 6 lines · Kurt Kanzenbach
Quoted 5 lines · Vladimir Oltean
Quoted 3 lines · Kurt Kanzenbach

Well, that depends on whether hellcreek_vlan_add() is called for creating that vlan interfaces. In general: As soon as both ports are members of the same vlan that traffic is switched.

Quoted 8 lines
Quoted 3 lines

That's indeed what I would expect.
Not only that, but with your pvid-based setup, you only ensure port separation for untagged traffic anyway.

Why? Tagged traffic is dropped unless the vlan is configured somehow. By default, I've configured vlan 2 and 3 to reflect the port separation for DSA. At reset the ports aren't members of any vlan.

Wait, so what is the out-of-reset state of "ptcfg & HR_PTCFG_INGRESSFLT"? If it is filtering by default (and even if it isn't, but you can make it), then I suppose you can keep it like that, and try to model your ports something like this:

- force "ethtool -k swpN | grep rx-vlan-filter" to return "on (fixed)".
- enforce a check that in standalone mode, you can't have an 8021q upper interface with the same VLAN ID on more than 1 port at the same time. This will be the only way in which you can terminate VLAN traffic on standalone ports.

If you do this, I think you should be compliant with the stack.

Quoted 4 lines

We could also skip the initial VLAN configuration completely. At the end of the day it's a TSN switch and the user will setup the vlan configuration anyway.

Hmm, a driver is supposed to be use case agnostic.
I know people who are using a 5-port TSN switch (not this one) as a 1-port SGMII-to-RMII electrical adapter, with some hardware-accelerated shaping.
I think it would be good if you could maintain a sane mode of operation in standalone mode, it tends to come in as useful at times.

Quoted 15 lines
Quoted 8 lines

I don't think you even need to call hellcreek_vlan_add() for VID 100 to be switched between ports, because your .port_vlan_filtering callback does not in fact disable VLAN awareness, it just configures the ports to not drop unknown VLANs. So, arguably, VLAN classification is still performed. An untagged packet is classified to the PVID, a tagged packet is classified to the VID in the packet. So tagged packets bypass the separation.

Quoted 6 lines

So, I think that's not ok. I think the only proper way to solve this is to inform the IP designers that VLANs are no substitute for a port forwarding matrix (a lookup table that answers the question "can port i forward to port j"). Switch ports that are individually addressable by the network stack are a fundamental assumption of the switchdev framework.

Quoted 5 lines

As I said before, there is no port forwarding matrix. There are only vlans and the fdb. There's also a global flag for setting vlan unaware mode and a port option for vlan tag required. That's it. I guess, we have to deal with it somehow.

Yes, understood. But it's quite a strange omission.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines

I remember asking in Message-ID: <20200716082935.snokd33kn52ixk5h@skbuf> whether it would be possible for you to set ds->configure_vlan_while_not_filtering = true during hellcreek_setup. Did anything unexpected happen while trying that?

No, that comment got lost.

So looking at the flag: Does it mean the driver can receive vlan configurations when a bridge without vlan filtering is used? That might be problematic as this driver uses vlans for the port separation by default. This is undone when vlan filtering is set to 1 meaning vlan configurations can be received without any problems.

Quoted 8 lines
Quoted 4 lines

Yes.
Generally speaking, the old DSA behavior is something that we're trying to get rid of, once all drivers set the option to true. So a new driver should not rely on it even if it needs something like that.

OK. when a new driver should set the flag, then I'll set it. So, all vlan requests programming requests should be "buffered" and executed when vlan filtering is enabled? What is it good for?

It is good for correct functionality of the hardware, I don't get the question? If your driver makes private use of VLAN tags beyond what the upper layers ask for, then it should keep track of them. DSA has, in the past, ignored VLAN switchdev operations from the bridge when not in vlan_filtering mode, for unknown reasons. This is known to break some command sequences (see below), so the consensus at the time was to stop doing that, and introduce this temporary compatibility flag.

Some tests to make sure you're passing are:

1. Statically creating an 802.1Q bridge:

ip link add br0 type bridge vlan_filtering 1
ip link set swp1 master br0
ip link set swp2 master br0

2. Dynamically turning an 802.1D bridge into an 802.1Q bridge:

ip link add br0 type bridge
ip link set swp1 master br0
ip link set swp2 master br0
ip link set br0 type bridge vlan_filtering 1

# at this moment in time, if you don't have
# configure_vlan_while_not_filtering = true, then the VLAN tables of
# swp1 and swp2 will be missing the default_pvid (by default 1) of br0.

Thanks,
-Vladimir

author maintainer
#8 lore raw

Re: [PATCH v5 2/7] net: dsa: Add DSA driver for Hirschmann Hellcreek switches

Quoted 11 lines · Vladimir Oltean
Quoted 10 lines · Kurt Kanzenbach
Quoted 8 lines · Vladimir Oltean
Quoted 3 lines · Kurt Kanzenbach

Well, that depends on whether hellcreek_vlan_add() is called for creating that vlan interfaces. In general: As soon as both ports are members of the same vlan that traffic is switched.

That's indeed what I would expect.
Not only that, but with your pvid-based setup, you only ensure port separation for untagged traffic anyway.

Quoted 6 lines
Quoted 4 lines

Why? Tagged traffic is dropped unless the vlan is configured somehow. By default, I've configured vlan 2 and 3 to reflect the port separation for DSA. At reset the ports aren't members of any vlan.

Wait, so what is the out-of-reset state of "ptcfg & HR_PTCFG_INGRESSFLT"?

No, ingress filtering is not set by default. But, still the ports are by default not members of any vlan. So, I thought the traffic will be dropped as well. I'll check that.

Quoted 11 lines

If it is filtering by default (and even if it isn't, but you can make it), then I suppose you can keep it like that, and try to model your ports something like this:

- force "ethtool -k swpN | grep rx-vlan-filter" to return "on (fixed)".
- enforce a check that in standalone mode, you can't have an 8021q upper interface with the same VLAN ID on more than 1 port at the same time. This will be the only way in which you can terminate VLAN traffic on standalone ports.

If you do this, I think you should be compliant with the stack.

OK, great. I'll look into it.

Quoted 7 lines
Quoted 3 lines

OK. when a new driver should set the flag, then I'll set it. So, all vlan requests programming requests should be "buffered" and executed when vlan filtering is enabled? What is it good for?

It is good for correct functionality of the hardware, I don't get the question? If your driver makes private use of VLAN tags beyond what the upper layers ask for, then it should keep track of them.

OK.

Quoted 16 lines

DSA has, in the past, ignored VLAN switchdev operations from the bridge when not in vlan_filtering mode, for unknown reasons. This is known to break some command sequences (see below), so the consensus at the time was to stop doing that, and introduce this temporary compatibility flag.

Some tests to make sure you're passing are:

1. Statically creating an 802.1Q bridge:

ip link add br0 type bridge vlan_filtering 1
ip link set swp1 master br0
ip link set swp2 master br0

2. Dynamically turning an 802.1D bridge into an 802.1Q bridge:

Quoted 7 lines

ip link add br0 type bridge
ip link set swp1 master br0
ip link set swp2 master br0
ip link set br0 type bridge vlan_filtering 1

# at this moment in time, if you don't have
# configure_vlan_while_not_filtering = true, then the VLAN tables of
# swp1 and swp2 will be missing the default_pvid (by default 1) of br0.

Yes, OK. I've observed this behavior myself and was confused about it.

Thanks,
Kurt

#9 lore raw

Re: [PATCH v5 2/7] net: dsa: Add DSA driver for Hirschmann Hellcreek switches

In reply to Vladimir Oltean
Quoted 3 lines · Vladimir Oltean

So, I think that's not ok. I think the only proper way to solve this is to inform the IP designers that VLANs are no substitute for a port forwarding matrix

Somebody should tell TI that. (cpts anyone?)

Thanks,
Richard

author maintainer
#10 lore raw

PATCH v5 3/7 net: dsa: hellcreek: Add PTP clock support

In reply to Kurt Kanzenbach

From: Kamil Alkhouri <[email protected]>

The switch has internal PTP hardware clocks. Add support for it. There are three clocks:

* Synchronized
* Syntonized
* Free running

Currently the synchronized clock is exported to user space which is a good default for the beginning. The free running clock might be exported later e.g. for implementing 802.1AS-2011/2020 Time Aware Bridges (TAB). The switch also supports cross time stamping for that purpose.

The implementation adds support setting/getting the time as well as offset and frequency adjustments. However, the clock only holds a partial timeofday timestamp. This is why we track the seconds completely in software (see overflow work and last_ts).

Furthermore, add the PTP multicast addresses into the FDB to forward that packages only to the CPU port where they are processed by a PTP program.

---
 drivers/net/dsa/hirschmann/Kconfig         |   1 +
 drivers/net/dsa/hirschmann/Makefile        |   4 +-
 drivers/net/dsa/hirschmann/hellcreek.c     |  71 ++++++
 drivers/net/dsa/hirschmann/hellcreek.h     |   8 +
 drivers/net/dsa/hirschmann/hellcreek_ptp.c | 283 +++++++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek_ptp.h |  69 +++++
 6 files changed, 435 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_ptp.c
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_ptp.h
drivers/net/dsa/hirschmann/Kconfig +1 -0
index 7d189cb936e3..222dd35e2c9d 100644
@@ -3,6 +3,7 @@ config NET_DSA_HIRSCHMANN_HELLCREEK
 	tristate "Hirschmann Hellcreek TSN Switch support"
 	depends on HAS_IOMEM
 	depends on NET_DSA
+	depends on PTP_1588_CLOCK
 	select NET_DSA_TAG_HELLCREEK
 	help
 	  This driver adds support for Hirschmann Hellcreek TSN switches.
drivers/net/dsa/hirschmann/Makefile +3 -1
index 0e12e149e40f..39de02a03640 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_NET_DSA_HIRSCHMANN_HELLCREEK)	+= hellcreek.o
+obj-$(CONFIG_NET_DSA_HIRSCHMANN_HELLCREEK)	+= hellcreek_sw.o
+hellcreek_sw-objs := hellcreek.o
+hellcreek_sw-objs += hellcreek_ptp.o
drivers/net/dsa/hirschmann/hellcreek.c +71 -0

116 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek.h +8 -0
index 79e553e2e57d..8d872a08f9de 100644
@@ -16,6 +16,7 @@
 #include <linux/ptp_clock_kernel.h>
 #include <linux/timecounter.h>
 #include <linux/mutex.h>
+#include <linux/workqueue.h>
 #include <linux/platform_data/hirschmann-hellcreek.h>
 #include <net/dsa.h>
 
@@ -235,10 +236,17 @@ struct hellcreek {
 	const struct hellcreek_platform_data *pdata;
 	struct device *dev;
 	struct dsa_switch *ds;
+	struct ptp_clock *ptp_clock;
+	struct ptp_clock_info ptp_clock_info;
 	struct hellcreek_port *ports;
+	struct delayed_work overflow_work;
 	struct mutex reg_lock;	/* Switch IP register lock */
+	struct mutex ptp_lock;	/* PTP IP register lock */
 	void __iomem *base;
+	void __iomem *ptp_base;
 	u8 *vidmbrcfg;		/* vidmbrcfg shadow */
+	u64 seconds;		/* PTP seconds */
+	u64 last_ts;		/* Used for overflow detection */
 	size_t fdb_entries;
 };
 
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +283 -0

283 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek_ptp.h new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.20.1
author maintainer
#11 lore raw

PATCH v5 4/7 net: dsa: hellcreek: Add support for hardware timestamping

In reply to Kurt Kanzenbach

From: Kamil Alkhouri <[email protected]>

The switch has the ability to take hardware generated time stamps per port for PTPv2 event messages in Rx and Tx direction. That is useful for achieving needed time synchronization precision for TSN devices/switches. So add support for it.

There are two directions:

* RX

The switch has a single register per port to capture a timestamp. That mechanism is not used due to correlation problems. If the software processing is too slow and a PTPv2 event message is received before the previous one has been processed, false timestamps will be captured. Therefore, the switch can do "inline" timestamping which means it can insert the nanoseconds part of the timestamp directly into the PTPv2 event message. The reserved field (4 bytes) is leveraged for that. This might not be in accordance with (older) PTP standards, but is the only way to get reliable results.

* TX

In Tx direction there is no correlation problem, because the software and the driver has to ensure that only one event message is "on the fly". However, the switch provides also a mechanism to check whether a timestamp is lost. That can only happen when a timestamp is read and at this point another message is timestamped. So, that lost bit is checked just in case to indicate to the user that the driver or the software is somewhat buggy.

---
 drivers/net/dsa/hirschmann/Makefile           |   1 +
 drivers/net/dsa/hirschmann/hellcreek.c        |  15 +
 drivers/net/dsa/hirschmann/hellcreek.h        |  25 +
 .../net/dsa/hirschmann/hellcreek_hwtstamp.c   | 479 ++++++++++++++++++
 .../net/dsa/hirschmann/hellcreek_hwtstamp.h   |  58 +++
 drivers/net/dsa/hirschmann/hellcreek_ptp.c    |  48 +-
 drivers/net/dsa/hirschmann/hellcreek_ptp.h    |   4 +
 7 files changed, 616 insertions(+), 14 deletions(-)
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c
 create mode 100644 drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h
drivers/net/dsa/hirschmann/Makefile +1 -0
index 39de02a03640..f4075c2998b5 100644
@@ -2,3 +2,4 @@
 obj-$(CONFIG_NET_DSA_HIRSCHMANN_HELLCREEK)	+= hellcreek_sw.o
 hellcreek_sw-objs := hellcreek.o
 hellcreek_sw-objs += hellcreek_ptp.o
+hellcreek_sw-objs += hellcreek_hwtstamp.o
drivers/net/dsa/hirschmann/hellcreek.c +15 -0
index cda3cc61b102..2a0ff32ce34f 100644
@@ -25,6 +25,7 @@
 
 #include "hellcreek.h"
 #include "hellcreek_ptp.h"
+#include "hellcreek_hwtstamp.h"
 
 static const struct hellcreek_counter hellcreek_counter[] = {
 	{ 0x00, "RxFiltered", },
@@ -1087,6 +1088,11 @@ static const struct dsa_switch_ops hellcreek_ds_ops = {
 	.port_bridge_leave   = hellcreek_port_bridge_leave,
 	.port_stp_state_set  = hellcreek_port_stp_state_set,
 	.phylink_validate    = hellcreek_phylink_validate,
+	.port_hwtstamp_set   = hellcreek_port_hwtstamp_set,
+	.port_hwtstamp_get   = hellcreek_port_hwtstamp_get,
+	.port_txtstamp	     = hellcreek_port_txtstamp,
+	.port_rxtstamp	     = hellcreek_port_rxtstamp,
+	.get_ts_info	     = hellcreek_get_ts_info,
 };
 
 static int hellcreek_probe(struct platform_device *pdev)
@@ -1194,10 +1200,18 @@ static int hellcreek_probe(struct platform_device *pdev)
 		goto err_ptp_setup;
 	}
 
+	ret = hellcreek_hwtstamp_setup(hellcreek);
+	if (ret) {
+		dev_err(dev, "Failed to setup hardware timestamping!\n");
+		goto err_tstamp_setup;
+	}
+
 	platform_set_drvdata(pdev, hellcreek);
 
 	return 0;
 
+err_tstamp_setup:
+	hellcreek_ptp_free(hellcreek);
 err_ptp_setup:
 	dsa_unregister_switch(hellcreek->ds);
 
@@ -1208,6 +1222,7 @@ static int hellcreek_remove(struct platform_device *pdev)
 {
 	struct hellcreek *hellcreek = platform_get_drvdata(pdev);
 
+	hellcreek_hwtstamp_free(hellcreek);
 	hellcreek_ptp_free(hellcreek);
 	dsa_unregister_switch(hellcreek->ds);
 	platform_set_drvdata(pdev, NULL);
drivers/net/dsa/hirschmann/hellcreek.h +25 -0
index 8d872a08f9de..06cfaa0c5503 100644
@@ -213,11 +213,36 @@ struct hellcreek_counter {
 
 struct hellcreek;
 
+/* State flags for hellcreek_port_hwtstamp::state */
+enum {
+	HELLCREEK_HWTSTAMP_ENABLED,
+	HELLCREEK_HWTSTAMP_TX_IN_PROGRESS,
+};
+
+/* A structure to hold hardware timestamping information per port */
+struct hellcreek_port_hwtstamp {
+	/* Timestamping state */
+	unsigned long state;
+
+	/* Resources for receive timestamping */
+	struct sk_buff_head rx_queue; /* For synchronization messages */
+
+	/* Resources for transmit timestamping */
+	unsigned long tx_tstamp_start;
+	struct sk_buff *tx_skb;
+
+	/* Current timestamp configuration */
+	struct hwtstamp_config tstamp_config;
+};
+
 struct hellcreek_port {
 	struct hellcreek *hellcreek;
 	int port;
 	u16 ptcfg;		/* ptcfg shadow */
 	u64 *counter_values;
+
+	/* Per-port timestamping resources */
+	struct hellcreek_port_hwtstamp port_hwtstamp;
 };
 
 struct hellcreek_fdb_entry {
drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c new file +479 -0

479 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h new file +58 -0

58 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek_ptp.c +34 -14

71 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek_ptp.h +4 -0
index 2dd8aaa532d0..e0eca1f4a494 100644
@@ -59,6 +59,10 @@
 
 int hellcreek_ptp_setup(struct hellcreek *hellcreek);
 void hellcreek_ptp_free(struct hellcreek *hellcreek);
+u16 hellcreek_ptp_read(struct hellcreek *hellcreek, unsigned int offset);
+void hellcreek_ptp_write(struct hellcreek *hellcreek, u16 data,
+			 unsigned int offset);
+u64 hellcreek_ptp_gettime_seconds(struct hellcreek *hellcreek, u64 ns);
 
 #define ptp_to_hellcreek(ptp)					\
 	container_of(ptp, struct hellcreek, ptp_clock_info)
Signature · 1 line
2.20.1
author maintainer
#12 lore raw

PATCH v5 5/7 net: dsa: hellcreek: Add PTP status LEDs

In reply to Kurt Kanzenbach

The switch has two controllable I/Os which are usually connected to LEDs. This is useful to immediately visually see the PTP status.

These provide two signals:

* is_gm

This LED can be activated if the current device is the grand master in that PTP domain.

* sync_good

This LED can be activated if the current device is in sync with the network time.

Expose these via the LED framework to be controlled via user space e.g. linuxptp.

---
 drivers/net/dsa/hirschmann/hellcreek.h     |   4 +
 drivers/net/dsa/hirschmann/hellcreek_ptp.c | 149 +++++++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek_ptp.h |   3 +
 3 files changed, 156 insertions(+)
drivers/net/dsa/hirschmann/hellcreek.h +4 -0
index 06cfaa0c5503..d1d9b18c57b4 100644
@@ -17,6 +17,7 @@
 #include <linux/timecounter.h>
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
+#include <linux/leds.h>
 #include <linux/platform_data/hirschmann-hellcreek.h>
 #include <net/dsa.h>
 
@@ -265,6 +266,8 @@ struct hellcreek {
 	struct ptp_clock_info ptp_clock_info;
 	struct hellcreek_port *ports;
 	struct delayed_work overflow_work;
+	struct led_classdev led_is_gm;
+	struct led_classdev led_sync_good;
 	struct mutex reg_lock;	/* Switch IP register lock */
 	struct mutex ptp_lock;	/* PTP IP register lock */
 	void __iomem *base;
@@ -272,6 +275,7 @@ struct hellcreek {
 	u8 *vidmbrcfg;		/* vidmbrcfg shadow */
 	u64 seconds;		/* PTP seconds */
 	u64 last_ts;		/* Used for overflow detection */
+	u16 status_out;		/* ptp.status_out shadow */
 	size_t fdb_entries;
 };
 
drivers/net/dsa/hirschmann/hellcreek_ptp.c +149 -0

170 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek_ptp.h +3 -0
index e0eca1f4a494..0b51392c7e56 100644
@@ -70,4 +70,7 @@ u64 hellcreek_ptp_gettime_seconds(struct hellcreek *hellcreek, u64 ns);
 #define dw_overflow_to_hellcreek(dw)				\
 	container_of(dw, struct hellcreek, overflow_work)
 
+#define led_to_hellcreek(ldev, led)				\
+	container_of(ldev, struct hellcreek, led)
+
 #endif /* _HELLCREEK_PTP_H_ */
Signature · 1 line
2.20.1
author maintainer
#13 lore raw

PATCH v5 6/7 dt-bindings: Add vendor prefix for Hirschmann

In reply to Kurt Kanzenbach

Hirschmann is building devices for automation and networking. Add them to the vendor prefixes.

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 63996ab03521..6c4268b585cd 100644
@@ -433,6 +433,8 @@ patternProperties:
     description: HiDeep Inc.
   "^himax,.*":
     description: Himax Technologies, Inc.
+  "^hirschmann,.*":
+    description: Hirschmann Automation and Control GmbH
   "^hisilicon,.*":
     description: Hisilicon Limited.
   "^hit,.*":
Signature · 1 line
2.20.1
author maintainer
#14 lore raw

PATCH v5 7/7 dt-bindings: net: dsa: Add documentation for Hellcreek switches

In reply to Kurt Kanzenbach

Add basic documentation and example.

---
 .../bindings/net/dsa/hellcreek.yaml           | 127 ++++++++++++++++++
 1 file changed, 127 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.yaml
Documentation/devicetree/bindings/net/dsa/hellcreek.yaml new file +127 -0
new file mode 100644
index 000000000000..e26c5a2a360b
@@ -0,0 +1,127 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/dsa/hellcreek.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Hirschmann Hellcreek TSN Switch Device Tree Bindings
+
+allOf:
+  - $ref: dsa.yaml#
+
+maintainers:
+  - Andrew Lunn <[email protected]>
+  - Florian Fainelli <[email protected]>
+  - Vivien Didelot <[email protected]>
+  - Kurt Kanzenbach <[email protected]>
+
+description:
+  The Hellcreek TSN Switch IP is a 802.1Q Ethernet compliant switch. It supports
+  the Precision Time Protocol, Hardware Timestamping as well the Time Aware
+  Shaper.
+
+properties:
+  compatible:
+    items:
+      - const: hirschmann,hellcreek-de1soc-r1
+
+  reg:
+    description:
+      The physical base address and size of TSN and PTP memory base
+    minItems: 2
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: tsn
+      - const: ptp
+
+  leds:
+    type: object
+    properties:
+      '#address-cells':
+        const: 1
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      "^led@[01]$":
+          type: object
+          description: Hellcreek leds
+          $ref: ../../leds/common.yaml#
+
+          properties:
+            reg:
+              items:
+                - enum: [0, 1]
+              description: Led number
+
+            label: true
+
+            default-state: true
+
+          required:
+            - reg
+
+          additionalProperties: false
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - ethernet-ports
+  - leds
+
+unevaluatedProperties: false
+
+examples:
+  - |
+        switch0: switch@ff240000 {
+            compatible = "hirschmann,hellcreek-de1soc-r1";
+            reg = <0xff240000 0x1000>,
+                  <0xff250000 0x1000>;
+            reg-names = "tsn", "ptp";
+            dsa,member = <0 0>;
+
+            ethernet-ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                port@0 {
+                    reg = <0>;
+                    label = "cpu";
+                    ethernet = <&gmac0>;
+                };
+
+                port@2 {
+                    reg = <2>;
+                    label = "lan0";
+                    phy-handle = <&phy1>;
+                };
+
+                port@3 {
+                    reg = <3>;
+                    label = "lan1";
+                    phy-handle = <&phy2>;
+                };
+            };
+
+            leds {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                led@0 {
+                    reg = <0>;
+                    label = "sync_good";
+                    default-state = "on";
+                };
+
+                led@1 {
+                    reg = <1>;
+                    label = "is_gm";
+                    default-state = "off";
+                };
+            };
+        };
Signature · 1 line
2.20.1