Skip to contentSkip to conversation

Hirschmann Hellcreek DSA driver

RFC PATCH In review Kurt Kanzenbach 6 participants 42 messages Jun 18, 2020 – Jun 26, 2020

Subsystems (5)
lore
Share & tools
lore

Kurt Kanzenbach

author maintainer
#0 lore raw

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, hardware timestamping and TAPRIO offloading.

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

If there are any objections let me know.

Thanks,
Kurt

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

Kurt Kanzenbach (7):
net: dsa: Add tag handling for Hirschmann Hellcreek switches
net: dsa: Add DSA driver for Hirschmann Hellcreek switches
net: dsa: hellcreek: Add TAPRIO offloading support
net: dsa: hellcreek: Add debugging mechanisms
net: dsa: hellcreek: Add PTP status LEDs
dt-bindings: Add vendor prefix for Hirschmann
dt-bindings: net: dsa: Add documentation for Hellcreek switches

 .../devicetree/bindings/net/dsa/hellcreek.txt |   72 +
 .../devicetree/bindings/vendor-prefixes.yaml  |    2 +
 drivers/net/dsa/Kconfig                       |    2 +
 drivers/net/dsa/Makefile                      |    1 +
 drivers/net/dsa/hirschmann/Kconfig            |    7 +
 drivers/net/dsa/hirschmann/Makefile           |    5 +
 drivers/net/dsa/hirschmann/hellcreek.c        | 1751 +++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek.h        |  302 +++
 .../net/dsa/hirschmann/hellcreek_hwtstamp.c   |  492 +++++
 .../net/dsa/hirschmann/hellcreek_hwtstamp.h   |   58 +
 drivers/net/dsa/hirschmann/hellcreek_ptp.c    |  369 ++++
 drivers/net/dsa/hirschmann/hellcreek_ptp.h    |   76 +
 include/net/dsa.h                             |    2 +
 net/dsa/Kconfig                               |    6 +
 net/dsa/Makefile                              |    1 +
 net/dsa/tag_hellcreek.c                       |  101 +
 16 files changed, 3247 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.txt
 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 net/dsa/tag_hellcreek.c
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

RFC PATCH 1/9 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 50389772c597..2784c4851d92 100644
@@ -44,6 +44,7 @@ struct phylink_link_state;
 #define DSA_TAG_PROTO_KSZ8795_VALUE		14
 #define DSA_TAG_PROTO_OCELOT_VALUE		15
 #define DSA_TAG_PROTO_AR9331_VALUE		16
+#define DSA_TAG_PROTO_HELLCREEK_VALUE		17
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -63,6 +64,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_KSZ8795		= DSA_TAG_PROTO_KSZ8795_VALUE,
 	DSA_TAG_PROTO_OCELOT		= DSA_TAG_PROTO_OCELOT_VALUE,
 	DSA_TAG_PROTO_AR9331		= DSA_TAG_PROTO_AR9331_VALUE,
+	DSA_TAG_PROTO_HELLCREEK		= DSA_TAG_PROTO_HELLCREEK_VALUE,
 };
 
 struct packet_type;
net/dsa/Kconfig +6 -0
index d5bc6ac599ef..edc0c3ab6a4e 100644
@@ -121,4 +121,10 @@ config NET_DSA_TAG_TRAILER
 	  Say Y or M if you want to enable support for tagging frames at
 	  with a trailed. e.g. Marvell 88E6060.
 
+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.
+
 endif
net/dsa/Makefile +1 -0
index 108486cfdeef..ed72f4ea899b 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_LAN9303) += tag_lan9303.o
 obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
net/dsa/tag_hellcreek.c new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#2 lore raw

Re: [RFC PATCH 1/9] net: dsa: Add tag handling for Hirschmann Hellcreek switches

Quoted 41 lines · Kurt Kanzenbach

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 50389772c597..2784c4851d92 100644
@@ -44,6 +44,7 @@ struct phylink_link_state;
 #define DSA_TAG_PROTO_KSZ8795_VALUE		14
 #define DSA_TAG_PROTO_OCELOT_VALUE		15
 #define DSA_TAG_PROTO_AR9331_VALUE		16
+#define DSA_TAG_PROTO_HELLCREEK_VALUE		17
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -63,6 +64,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_KSZ8795		= DSA_TAG_PROTO_KSZ8795_VALUE,
 	DSA_TAG_PROTO_OCELOT		= DSA_TAG_PROTO_OCELOT_VALUE,
 	DSA_TAG_PROTO_AR9331		= DSA_TAG_PROTO_AR9331_VALUE,
+	DSA_TAG_PROTO_HELLCREEK		= DSA_TAG_PROTO_HELLCREEK_VALUE,
 };
 
 struct packet_type;
net/dsa/Kconfig +0 -0
index d5bc6ac599ef..edc0c3ab6a4e 100644

net/dsa/Kconfig config NET_DSA_TAG_TRAILER · line 129

Quoted 9 lines
net/dsa/Kconfig +6 -0
@@ -121,4 +121,10 @@ config NET_DSA_TAG_TRAILER
 	  Say Y or M if you want to enable support for tagging frames at
 	  with a trailed. e.g. Marvell 88E6060.
 
+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.
+

Hi Kurt

This file is roughly in alphabetic order based on the tristate string. Please move this before "Tag driver for Lantiq / Intel GSWIP switches" to keep with the sorting.

Otherwise this looks good.

Andrew

author maintainer
#3 lore raw

RFC PATCH 2/9 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

---
 drivers/net/dsa/Kconfig                |    2 +
 drivers/net/dsa/Makefile               |    1 +
 drivers/net/dsa/hirschmann/Kconfig     |    7 +
 drivers/net/dsa/hirschmann/Makefile    |    2 +
 drivers/net/dsa/hirschmann/hellcreek.c | 1173 ++++++++++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek.h |  244 +++++
 6 files changed, 1429 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
drivers/net/dsa/Kconfig +2 -0
index d0024cb30a7b..d52195e7115b 100644
@@ -58,6 +58,8 @@ source "drivers/net/dsa/qca/Kconfig"
 
 source "drivers/net/dsa/sja1105/Kconfig"
 
+source "drivers/net/dsa/hirschmann/Kconfig"
+
 config NET_DSA_QCA8K
 	tristate "Qualcomm Atheros QCA8K Ethernet switch family support"
 	depends on NET_DSA
drivers/net/dsa/Makefile +1 -0
index 4a943ccc2ca4..a707ccc3a940 100644
@@ -23,3 +23,4 @@ obj-y				+= mv88e6xxx/
 obj-y				+= ocelot/
 obj-y				+= qca/
 obj-y				+= sja1105/
+obj-y				+= hirschmann/
drivers/net/dsa/hirschmann/Kconfig new file +7 -0
new file mode 100644
index 000000000000..714414d8f50f
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+config NET_DSA_HIRSCHMANN_HELLCREEK
+	tristate "Hirschmann Hellcreek TSN Switch support"
+	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 +1173 -0

1,173 lines not on this page · raw message

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

244 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#4 lore raw

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

Quoted 1 line

+static void __hellcreek_select_port(struct hellcreek *hellcreek, int port)

Hi Kurt

In general, please can you drop all these __ prefixes. They are useful when you have for example hellcreek_select_port() takes a lock and then calls _hellcreek_select_port(), but here, there is no need for them.

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

Quoted 5 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +5 -0
+static int hellcreek_detect(struct hellcreek *hellcreek)
+{
+	u8 tgd_maj, tgd_min;
+	u16 id, rel_low, rel_high, date_low, date_high, tgd_ver;
+	u32 rel, date;

Reverse Christmas tree please. Here and everywhere else.

Quoted 24 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +23 -0
+
+	id	  = hellcreek_read(hellcreek, HR_MODID_C);
+	rel_low	  = hellcreek_read(hellcreek, HR_REL_L_C);
+	rel_high  = hellcreek_read(hellcreek, HR_REL_H_C);
+	date_low  = hellcreek_read(hellcreek, HR_BLD_L_C);
+	date_high = hellcreek_read(hellcreek, HR_BLD_H_C);
+	tgd_ver   = hellcreek_read(hellcreek, TR_TGDVER);
+
+	if (id != HELLCREEK_MODULE_ID)
+		return -ENODEV;
+
+	rel	= rel_low | (rel_high << 16);
+	date	= date_low | (date_high << 16);
+	tgd_maj = (tgd_ver & TR_TGDVER_REV_MAJ_MASK) >> TR_TGDVER_REV_MAJ_SHIFT;
+	tgd_min = (tgd_ver & TR_TGDVER_REV_MIN_MASK) >> TR_TGDVER_REV_MIN_SHIFT;
+
+	dev_info(hellcreek->dev, "Module ID=%02x Release=%04x Date=%04x TGD Version=%02x.%02x\n",
+		 id, rel, date, tgd_maj, tgd_min);
+
+	return 0;
+}
 
+static int hellcreek_port_enable(struct dsa_switch *ds, int port,
+				 struct phy_device *phy)

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

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	unsigned long flags;
+	u16 val;
+
+	if (port >= NUM_PORTS)
+		return -EINVAL;
+
+	dev_info(hellcreek->dev, "Enable port %d\n", port);

dev_dbg().

+

Review

Quoted 1 line
(quoted diff) +1 -0
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);

I've not seen any interrupt handling code in the driver, and there is no mention of an interrupt in the DT binding. Do you really need _irqsave spin locks?

Quoted 11 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +11 -0
+
+	__hellcreek_select_port(hellcreek, port);
+	val = hellcreek_port->ptcfg;
+	val |= HR_PTCFG_ADMIN_EN;
+	hellcreek_write(hellcreek, val, HR_PTCFG);
+	hellcreek_port->ptcfg = val;
+
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+
+	return 0;
+}

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

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+
+static void hellcreek_port_disable(struct dsa_switch *ds, int port)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	unsigned long flags;
+	u16 val;
+
+	if (port >= NUM_PORTS)
+		return;

I don't think this test is actually needed, here or in any of the other callbacks. If it does happen, it means we have a core bug we should fix.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	dev_info(hellcreek->dev, "Disable port %d\n", port);

dev_dbg()

Quoted 25 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +24 -0
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);
+
+	__hellcreek_select_port(hellcreek, port);
+	val = hellcreek_port->ptcfg;
+	val &= ~HR_PTCFG_ADMIN_EN;
+	hellcreek_write(hellcreek, val, HR_PTCFG);
+	hellcreek_port->ptcfg = val;
+
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+}
+
 
+static void hellcreek_get_ethtool_stats(struct dsa_switch *ds, int port,
+					uint64_t *data)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	unsigned long flags;
+	int i;
+
+	if (port >= NUM_PORTS)
+		return;
+
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);
+	for (i = 0; i < ARRAY_SIZE(hellcreek_counter); ++i) {

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

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+		const struct hellcreek_counter *counter = &hellcreek_counter[i];
+		u8 offset = counter->offset + port * 64;
+		u16 high, low;
+		u64 value = 0;
+
+		__hellcreek_select_counter(hellcreek, offset);
+
+		high  = hellcreek_read(hellcreek, HR_CRDH);
+		low   = hellcreek_read(hellcreek, HR_CRDL);
+		value = (high << 16) | low;

Is there some sort of snapshot happening here? Or do you need to read high again, to make sure it has not incremented when low was being read?

Quoted 4 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +4 -0
+
+		hellcreek_port->counter_values[i] += value;
+		data[i] = hellcreek_port->counter_values[i];
+	}

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

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+}
+
+static int hellcreek_vlan_prepare(struct dsa_switch *ds, int port,
+				  const struct switchdev_obj_port_vlan *vlan)
+{
+	struct hellcreek *hellcreek = ds->priv;
+
+	/* Nothing todo */
+	dev_info(hellcreek->dev, "VLAN prepare for port %d\n", port);

dev_dbg()

Quoted 5 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +4 -0
+
+	return 0;
+}
+
 

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

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+static void hellcreek_vlan_add(struct dsa_switch *ds, int port,
+			       const struct switchdev_obj_port_vlan *vlan)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
+	bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
+	unsigned long flags;
+	u16 vid;
+
+	if (port >= NUM_PORTS || vlan->vid_end >= 4096)

Again, if vlan->vid_end >= 4096 is true, there is a core bug which needs fixing.

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

Quoted 6 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +6 -0
+		return;
+
+	dev_info(hellcreek->dev, "Add VLANs (%d -- %d) on port %d, %s, %s\n",
+		 vlan->vid_begin, vlan->vid_end, port,
+		 untagged ? "untagged" : "tagged",
+		 pvid ? "PVID" : "no PVID");

Please go thought the driver and consider all you dev_info() statements. Should they be dev_dbg()?

Andrew

author maintainer
#5 lore raw

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

Hi Andrew,

first off thank you for the review.

Quoted 8 lines · Andrew Lunn
Quoted 1 line

+static void __hellcreek_select_port(struct hellcreek *hellcreek, int port)

Hi Kurt

In general, please can you drop all these __ prefixes. They are useful when you have for example hellcreek_select_port() takes a lock and then calls _hellcreek_select_port(), but here, there is no need for them.

OK, sure.

Quoted 8 lines

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

Quoted 6 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +5 -0
+static int hellcreek_detect(struct hellcreek *hellcreek)
+{
+	u8 tgd_maj, tgd_min;
+	u16 id, rel_low, rel_high, date_low, date_high, tgd_ver;
+	u32 rel, date;

Reverse Christmas tree please. Here and everywhere else.

OK.

Quoted 23 lines
Quoted 22 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +21 -0
+
+	id	  = hellcreek_read(hellcreek, HR_MODID_C);
+	rel_low	  = hellcreek_read(hellcreek, HR_REL_L_C);
+	rel_high  = hellcreek_read(hellcreek, HR_REL_H_C);
+	date_low  = hellcreek_read(hellcreek, HR_BLD_L_C);
+	date_high = hellcreek_read(hellcreek, HR_BLD_H_C);
+	tgd_ver   = hellcreek_read(hellcreek, TR_TGDVER);
+
+	if (id != HELLCREEK_MODULE_ID)
+		return -ENODEV;
+
+	rel	= rel_low | (rel_high << 16);
+	date	= date_low | (date_high << 16);
+	tgd_maj = (tgd_ver & TR_TGDVER_REV_MAJ_MASK) >> TR_TGDVER_REV_MAJ_SHIFT;
+	tgd_min = (tgd_ver & TR_TGDVER_REV_MIN_MASK) >> TR_TGDVER_REV_MIN_SHIFT;
+
+	dev_info(hellcreek->dev, "Module ID=%02x Release=%04x Date=%04x TGD Version=%02x.%02x\n",
+		 id, rel, date, tgd_maj, tgd_min);
+
+	return 0;
+}
Quoted 14 lines

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

Quoted 12 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +12 -0
+static int hellcreek_port_enable(struct dsa_switch *ds, int port,
+				 struct phy_device *phy)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	unsigned long flags;
+	u16 val;
+
+	if (port >= NUM_PORTS)
+		return -EINVAL;
+
+	dev_info(hellcreek->dev, "Enable port %d\n", port);

dev_dbg().

These are debug messages. I'll change that in the complete code.

Quoted 7 lines

+

Review

Quoted 1 line
(quoted diff) +1 -0
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);

I've not seen any interrupt handling code in the driver, and there is no mention of an interrupt in the DT binding. Do you really need _irqsave spin locks?

Yes, I do. The TAPRIO offloading patch later adds hrtimers and that's why it's needed. However, in this particular patch it is not required, but I didn't want to change all spin lock calls later.

Quoted 18 lines
Quoted 18 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +17 -0
+
+	__hellcreek_select_port(hellcreek, port);
+	val = hellcreek_port->ptcfg;
+	val |= HR_PTCFG_ADMIN_EN;
+	hellcreek_write(hellcreek, val, HR_PTCFG);
+	hellcreek_port->ptcfg = val;
+
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+
+	return 0;
+}
+
+static void hellcreek_port_disable(struct dsa_switch *ds, int port)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	unsigned long flags;
Quoted 8 lines

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

Quoted 4 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +4 -0
+	u16 val;
+
+	if (port >= NUM_PORTS)
+		return;

I don't think this test is actually needed, here or in any of the other callbacks. If it does happen, it means we have a core bug we should fix.

Agreed.

Quoted 37 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+
+	dev_info(hellcreek->dev, "Disable port %d\n", port);

dev_dbg()

Quoted 31 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +30 -0
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);
+
+	__hellcreek_select_port(hellcreek, port);
+	val = hellcreek_port->ptcfg;
+	val &= ~HR_PTCFG_ADMIN_EN;
+	hellcreek_write(hellcreek, val, HR_PTCFG);
+	hellcreek_port->ptcfg = val;
+
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+}
+
 
+static void hellcreek_get_ethtool_stats(struct dsa_switch *ds, int port,
+					uint64_t *data)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	unsigned long flags;
+	int i;
+
+	if (port >= NUM_PORTS)
+		return;
+
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);
+	for (i = 0; i < ARRAY_SIZE(hellcreek_counter); ++i) {
+		const struct hellcreek_counter *counter = &hellcreek_counter[i];
+		u8 offset = counter->offset + port * 64;
+		u16 high, low;
+		u64 value = 0;
+
+		__hellcreek_select_counter(hellcreek, offset);
Quoted 8 lines

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

Quoted 4 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +4 -0
+
+		high  = hellcreek_read(hellcreek, HR_CRDH);
+		low   = hellcreek_read(hellcreek, HR_CRDL);
+		value = (high << 16) | low;

Is there some sort of snapshot happening here? Or do you need to read high again, to make sure it has not incremented when low was being read?

Yes, there is. When the counter is selected via __hellcreek_select_counter() both registers are locked. That's why there's no need to read high again. I'll add a comment for clarity.

Quoted 37 lines
Quoted 5 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +4 -0
+
+		hellcreek_port->counter_values[i] += value;
+		data[i] = hellcreek_port->counter_values[i];
+	}

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

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+}
+
+static int hellcreek_vlan_prepare(struct dsa_switch *ds, int port,
+				  const struct switchdev_obj_port_vlan *vlan)
+{
+	struct hellcreek *hellcreek = ds->priv;
+
+	/* Nothing todo */
+	dev_info(hellcreek->dev, "VLAN prepare for port %d\n", port);

dev_dbg()

Quoted 5 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +4 -0
+
+	return 0;
+}
+
 

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

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +10 -0
+static void hellcreek_vlan_add(struct dsa_switch *ds, int port,
+			       const struct switchdev_obj_port_vlan *vlan)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
+	bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
+	unsigned long flags;
+	u16 vid;
+
+	if (port >= NUM_PORTS || vlan->vid_end >= 4096)

Again, if vlan->vid_end >= 4096 is true, there is a core bug which needs fixing.

Quoted 9 lines

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

Quoted 6 lines
drivers/net/dsa/hirschmann/hellcreek.c new file +6 -0
+		return;
+
+	dev_info(hellcreek->dev, "Add VLANs (%d -- %d) on port %d, %s, %s\n",
+		 vlan->vid_begin, vlan->vid_end, port,
+		 untagged ? "untagged" : "tagged",
+		 pvid ? "PVID" : "no PVID");

Please go thought the driver and consider all you dev_info() statements. Should they be dev_dbg()?

I'll do.

Thanks,
Kurt

author maintainer
#6 lore raw

RFC PATCH 3/9 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/Makefile        |   4 +-
 drivers/net/dsa/hirschmann/hellcreek.c     |  72 ++++++
 drivers/net/dsa/hirschmann/hellcreek.h     |   7 +
 drivers/net/dsa/hirschmann/hellcreek_ptp.c | 279 +++++++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek_ptp.h |  69 +++++
 5 files changed, 430 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/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 +72 -0

117 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek.h +7 -0
index a08a10cb5ab7..2d4422fd2567 100644
@@ -234,10 +234,17 @@ struct hellcreek_fdb_entry {
 struct hellcreek {
 	struct device *dev;
 	struct dsa_switch *ds;
+	struct ptp_clock *ptp_clock;
+	struct ptp_clock_info ptp_clock_info;
 	struct hellcreek_port ports[4];
+	struct delayed_work overflow_work;
 	spinlock_t reg_lock;	/* Switch IP register lock */
+	spinlock_t 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 +279 -0

279 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
maintainer
#7 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

Quoted 19 lines · On Thu, 18 Jun 2020 08:40:23 +0200 Kurt Kanzenbach wrote:

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).

Quoted 5 lines

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.

Please make sure each patch in the series builds cleanly with the W=1 C=1 flags. Here we have:

../drivers/net/dsa/hirschmann/hellcreek_ptp.c: In function ‘__hellcreek_ptp_clock_read’:
../drivers/net/dsa/hirschmann/hellcreek_ptp.c:30:28: warning: variable ‘sech’ set but not used [-Wunused-but-set-variable]
30 | u16 nsl, nsh, secl, secm, sech;
| ^~~~
../drivers/net/dsa/hirschmann/hellcreek_ptp.c:30:22: warning: variable ‘secm’ set but not used [-Wunused-but-set-variable]
30 | u16 nsl, nsh, secl, secm, sech;
| ^~~~
../drivers/net/dsa/hirschmann/hellcreek_ptp.c:30:16: warning: variable ‘secl’ set but not used [-Wunused-but-set-variable]
30 | u16 nsl, nsh, secl, secm, sech;
| ^~~~

Next patch adds a few more.

author maintainer
#8 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

Hi Jakub,

Quoted 40 lines · Jakub Kicinski
Quoted 19 lines · On Thu, 18 Jun 2020 08:40:23 +0200 Kurt Kanzenbach wrote:

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).

Quoted 5 lines

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.

Please make sure each patch in the series builds cleanly with the W=1 C=1 flags. Here we have:

../drivers/net/dsa/hirschmann/hellcreek_ptp.c: In function ‘__hellcreek_ptp_clock_read’:
../drivers/net/dsa/hirschmann/hellcreek_ptp.c:30:28: warning: variable ‘sech’ set but not used [-Wunused-but-set-variable]
30 | u16 nsl, nsh, secl, secm, sech;
| ^~~~
../drivers/net/dsa/hirschmann/hellcreek_ptp.c:30:22: warning: variable ‘secm’ set but not used [-Wunused-but-set-variable]
30 | u16 nsl, nsh, secl, secm, sech;
| ^~~~
../drivers/net/dsa/hirschmann/hellcreek_ptp.c:30:16: warning: variable ‘secl’ set but not used [-Wunused-but-set-variable]
30 | u16 nsl, nsh, secl, secm, sech;
| ^~~~

Quoted 1 line

Next patch adds a few more.

Sorry, I did test with C=1 only. I'll fix it.

Thanks,
Kurt

maintainer
#9 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

In reply to Kurt Kanzenbach
Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+static u64 __hellcreek_ptp_clock_read(struct hellcreek *hellcreek)
+{
+	u16 nsl, nsh, secl, secm, sech;
+
+	/* Take a snapshot */
+	hellcreek_ptp_write(hellcreek, PR_COMMAND_C_SS, PR_COMMAND_C);
+
+	/* The time of the day is saved as 96 bits. However, due to hardware
+	 * limitations the seconds are not or only partly kept in the PTP
+	 * core. That's why only the nanoseconds are used and the seconds are

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 47

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+	 * tracked in software. Anyway due to internal locking all five
+	 * registers should be read.
+	 */
+	sech = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secm = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secl = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsh  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsl  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+
+	return (u64)nsl | ((u64)nsh << 16);

Hi Kurt

What are the hardware limitations? There seems to be 48 bits for seconds? That allows for 8925104 years?

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 58

Quoted 9 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +9 -0
+static u64 __hellcreek_ptp_gettime(struct hellcreek *hellcreek)
+{
+	u64 ns;
+
+	ns = __hellcreek_ptp_clock_read(hellcreek);
+	if (ns < hellcreek->last_ts)
+		hellcreek->seconds++;
+	hellcreek->last_ts = ns;
+	ns += hellcreek->seconds * NSEC_PER_SEC;

So the assumption is, this gets called at least once per second. And if that does not happen, there is no recovery. The second is lost.

I'm just wondering if there is something more robust using what the hardware does provide, even if the hardware is not perfect.

Andrew

author maintainer
#10 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

Hi Andrew,

Quoted 23 lines · Andrew Lunn
Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+static u64 __hellcreek_ptp_clock_read(struct hellcreek *hellcreek)
+{
+	u16 nsl, nsh, secl, secm, sech;
+
+	/* Take a snapshot */
+	hellcreek_ptp_write(hellcreek, PR_COMMAND_C_SS, PR_COMMAND_C);
+
+	/* The time of the day is saved as 96 bits. However, due to hardware
+	 * limitations the seconds are not or only partly kept in the PTP
+	 * core. That's why only the nanoseconds are used and the seconds are

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 47

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+	 * tracked in software. Anyway due to internal locking all five
+	 * registers should be read.
+	 */
+	sech = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secm = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secl = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsh  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsl  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+
+	return (u64)nsl | ((u64)nsh << 16);

Hi Kurt

Quoted 2 lines

What are the hardware limitations? There seems to be 48 bits for seconds? That allows for 8925104 years?

In theory, yes. Due to hardware hardware considerations only a few or none of these bits are used for the seconds. The rest is zero. Meaning that the wraparound is not 8925104 years, but at e.g. 8 seconds when using 3 bits for the seconds.

I've discussed this the Hirschmann people and they suggested to use the nanoseconds only. That's what I did here.

Quoted 13 lines

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 58

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +9 -0
+static u64 __hellcreek_ptp_gettime(struct hellcreek *hellcreek)
+{
+	u64 ns;
+
+	ns = __hellcreek_ptp_clock_read(hellcreek);
+	if (ns < hellcreek->last_ts)
+		hellcreek->seconds++;
+	hellcreek->last_ts = ns;
+	ns += hellcreek->seconds * NSEC_PER_SEC;

So the assumption is, this gets called at least once per second. And if that does not happen, there is no recovery. The second is lost.

Yes, exactly. If a single overflow is missed, then the time is wrong.

Quoted 3 lines

I'm just wondering if there is something more robust using what the hardware does provide, even if the hardware is not perfect.

I don't think there's a more robust way to do this. The overflow period is a second which should be enough time to catch the overflow even if the system is loaded. We did long running tests for days and the mechanism worked fine. We could also consider to move the delayed work to a dedicated thread which could be run with real time (SCHED_FIFO) priority. But, I didn't see the need for it.

Thanks,
Kurt

maintainer
#11 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

Quoted 26 lines · Kurt Kanzenbach

Hi Andrew,

Quoted 23 lines · Andrew Lunn
Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+static u64 __hellcreek_ptp_clock_read(struct hellcreek *hellcreek)
+{
+	u16 nsl, nsh, secl, secm, sech;
+
+	/* Take a snapshot */
+	hellcreek_ptp_write(hellcreek, PR_COMMAND_C_SS, PR_COMMAND_C);
+
+	/* The time of the day is saved as 96 bits. However, due to hardware
+	 * limitations the seconds are not or only partly kept in the PTP
+	 * core. That's why only the nanoseconds are used and the seconds are

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 47

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+	 * tracked in software. Anyway due to internal locking all five
+	 * registers should be read.
+	 */
+	sech = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secm = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secl = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsh  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsl  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+
+	return (u64)nsl | ((u64)nsh << 16);

Hi Kurt

Quoted 7 lines
Quoted 2 lines

What are the hardware limitations? There seems to be 48 bits for seconds? That allows for 8925104 years?

In theory, yes. Due to hardware hardware considerations only a few or none of these bits are used for the seconds. The rest is zero. Meaning that the wraparound is not 8925104 years, but at e.g. 8 seconds when using 3 bits for the seconds.

Please add this to the comment.

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +4 -0
+static u64 __hellcreek_ptp_gettime(struct hellcreek *hellcreek)
+{
+	u64 ns;
+
Quoted 8 lines

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 58

Quoted 5 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +5 -0
+	ns = __hellcreek_ptp_clock_read(hellcreek);
+	if (ns < hellcreek->last_ts)
+		hellcreek->seconds++;
+	hellcreek->last_ts = ns;
+	ns += hellcreek->seconds * NSEC_PER_SEC;

So the assumption is, this gets called at least once per second. And if that does not happen, there is no recovery. The second is lost.

Yes, exactly. If a single overflow is missed, then the time is wrong.

Quoted 3 lines

I'm just wondering if there is something more robust using what the hardware does provide, even if the hardware is not perfect.

Quoted 6 lines

I don't think there's a more robust way to do this. The overflow period is a second which should be enough time to catch the overflow even if the system is loaded. We did long running tests for days and the mechanism worked fine. We could also consider to move the delayed work to a dedicated thread which could be run with real time (SCHED_FIFO) priority. But, I didn't see the need for it.

If the hardware does give you 3 working bits for the seconds, you could make use of that for a consistency check. If nothing else, you could do a

dev_err(dev, 'PTP time is FUBAR');

Andrew

author maintainer
#12 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

Quoted 30 lines · Andrew Lunn
Quoted 29 lines · Kurt Kanzenbach

Hi Andrew,

Quoted 25 lines · Andrew Lunn
Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+static u64 __hellcreek_ptp_clock_read(struct hellcreek *hellcreek)
+{
+	u16 nsl, nsh, secl, secm, sech;
+
+	/* Take a snapshot */
+	hellcreek_ptp_write(hellcreek, PR_COMMAND_C_SS, PR_COMMAND_C);
+
+	/* The time of the day is saved as 96 bits. However, due to hardware
+	 * limitations the seconds are not or only partly kept in the PTP
+	 * core. That's why only the nanoseconds are used and the seconds are

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 47

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +10 -0
+	 * tracked in software. Anyway due to internal locking all five
+	 * registers should be read.
+	 */
+	sech = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secm = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	secl = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsh  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+	nsl  = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C);
+
+	return (u64)nsl | ((u64)nsh << 16);

Hi Kurt

What are the hardware limitations? There seems to be 48 bits for seconds? That allows for 8925104 years?

Quoted 6 lines
Quoted 4 lines

In theory, yes. Due to hardware hardware considerations only a few or none of these bits are used for the seconds. The rest is zero. Meaning that the wraparound is not 8925104 years, but at e.g. 8 seconds when using 3 bits for the seconds.

Please add this to the comment.

I will, no problem.

Quoted 27 lines
Quoted 20 lines
Quoted 13 lines

drivers/net/dsa/hirschmann/hellcreek_ptp.c line 58

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek_ptp.c new file +9 -0
+static u64 __hellcreek_ptp_gettime(struct hellcreek *hellcreek)
+{
+	u64 ns;
+
+	ns = __hellcreek_ptp_clock_read(hellcreek);
+	if (ns < hellcreek->last_ts)
+		hellcreek->seconds++;
+	hellcreek->last_ts = ns;
+	ns += hellcreek->seconds * NSEC_PER_SEC;

So the assumption is, this gets called at least once per second. And if that does not happen, there is no recovery. The second is lost.

Yes, exactly. If a single overflow is missed, then the time is wrong.

Quoted 3 lines

I'm just wondering if there is something more robust using what the hardware does provide, even if the hardware is not perfect.

Quoted 6 lines

I don't think there's a more robust way to do this. The overflow period is a second which should be enough time to catch the overflow even if the system is loaded. We did long running tests for days and the mechanism worked fine. We could also consider to move the delayed work to a dedicated thread which could be run with real time (SCHED_FIFO) priority. But, I didn't see the need for it.

Quoted 5 lines

If the hardware does give you 3 working bits for the seconds, you could make use of that for a consistency check. If nothing else, you could do a

dev_err(dev, 'PTP time is FUBAR');

OK. I'll add a check for that.

Thanks,
Kurt

#13 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

In reply to Kurt Kanzenbach
Quoted 5 lines · Kurt Kanzenbach
drivers/net/dsa/hirschmann/hellcreek.h +0 -0
index a08a10cb5ab7..2d4422fd2567 100644

drivers/net/dsa/hirschmann/hellcreek.h struct hellcreek_fdb_entry { · line 242

Quoted 9 lines
drivers/net/dsa/hirschmann/hellcreek.h +4 -0
@@ -234,10 +234,17 @@ struct hellcreek_fdb_entry {
 struct hellcreek {
 	struct device *dev;
 	struct dsa_switch *ds;
+	struct ptp_clock *ptp_clock;
+	struct ptp_clock_info ptp_clock_info;
 	struct hellcreek_port ports[4];
+	struct delayed_work overflow_work;
 	spinlock_t reg_lock;	/* Switch IP register lock */
+	spinlock_t ptp_lock;	/* PTP IP register lock */

Why use a spin lock and not a mutex?

Quoted 5 lines
drivers/net/dsa/hirschmann/hellcreek.h +3 -0
 	void __iomem *base;
+	void __iomem *ptp_base;
 	u8 *vidmbrcfg;		/* vidmbrcfg shadow */
+	u64 seconds;		/* PTP seconds */
+	u64 last_ts;		/* Used for overflow detection */

drivers/net/dsa/hirschmann/hellcreek.h struct hellcreek_fdb_entry {

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.h +7 -0
 	size_t fdb_entries;
 };
 
+static int hellcreek_ptp_gettime(struct ptp_clock_info *ptp,
+				 struct timespec64 *ts)
+{
+	struct hellcreek *hellcreek = ptp_to_hellcreek(ptp);
+	u64 ns;
+
+	spin_lock(&hellcreek->ptp_lock);

Won't a mutex do here instead?

Quoted 6 lines
drivers/net/dsa/hirschmann/hellcreek.h +6 -0
+	ns = __hellcreek_ptp_gettime(hellcreek);
+	spin_unlock(&hellcreek->ptp_lock);
+
+	*ts = ns_to_timespec64(ns);
+
+	return 0;

drivers/net/dsa/hirschmann/hellcreek.h

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.h +9 -0
+}
 
+static int hellcreek_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+	struct hellcreek *hellcreek = ptp_to_hellcreek(ptp);
+	u16 negative = 0, counth, countl;
+	u32 count_val;
+
+	/* If the offset is larger than IP-Core slow offset resources. Don't
+	 * concider slow adjustment. Rather, add the offset directly to the

consider

Quoted 64 lines
drivers/net/dsa/hirschmann/hellcreek.h +63 -0
+	 * current time
+	 */
+	if (abs(delta) > MAX_SLOW_OFFSET_ADJ) {
+		struct timespec64 now, then = ns_to_timespec64(delta);
+
+		hellcreek_ptp_gettime(ptp, &now);
+		now = timespec64_add(now, then);
+		hellcreek_ptp_settime(ptp, &now);
+
+		return 0;
+	}
+
+	if (delta < 0) {
+		negative = 1;
+		delta = -delta;
+	}
+
+	/* 'count_val' does not exceed the maximum register size (2^30) */
+	count_val = div_s64(delta, MAX_NS_PER_STEP);
+
+	counth = (count_val & 0xffff0000) >> 16;
+	countl = count_val & 0xffff;
+
+	negative = (negative << 15) & 0x8000;
+
+	spin_lock(&hellcreek->ptp_lock);
+
+	/* Set offset write register */
+	hellcreek_ptp_write(hellcreek, negative, PR_CLOCK_OFFSET_C);
+	hellcreek_ptp_write(hellcreek, MAX_NS_PER_STEP, PR_CLOCK_OFFSET_C);
+	hellcreek_ptp_write(hellcreek, MIN_CLK_CYCLES_BETWEEN_STEPS,
+			    PR_CLOCK_OFFSET_C);
+	hellcreek_ptp_write(hellcreek, countl,  PR_CLOCK_OFFSET_C);
+	hellcreek_ptp_write(hellcreek, counth,  PR_CLOCK_OFFSET_C);
+
+	spin_unlock(&hellcreek->ptp_lock);
+
+	return 0;
+}
 
+int hellcreek_ptp_setup(struct hellcreek *hellcreek)
+{
+	u16 status;
+
+	/* Set up the overflow work */
+	INIT_DELAYED_WORK(&hellcreek->overflow_work,
+			  hellcreek_ptp_overflow_check);
+
+	/* Setup PTP clock */
+	hellcreek->ptp_clock_info.owner = THIS_MODULE;
+	snprintf(hellcreek->ptp_clock_info.name,
+		 sizeof(hellcreek->ptp_clock_info.name),
+		 dev_name(hellcreek->dev));
+
+	/* IP-Core can add up to 0.5 ns per 8 ns cycle, which means
+	 * accumulator_overflow_rate shall not exceed 62.5 MHz (which adjusts
+	 * the nominal frequency by 6.25%)
+	 */
+	hellcreek->ptp_clock_info.max_adj   = 62500000;
+	hellcreek->ptp_clock_info.n_alarm   = 0;
+	hellcreek->ptp_clock_info.n_pins    = 0;
+	hellcreek->ptp_clock_info.n_ext_ts  = 0;
+	hellcreek->ptp_clock_info.n_per_out = 0;
+	hellcreek->ptp_clock_info.pps	    = 0;

drivers/net/dsa/hirschmann/hellcreek.h

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.h +10 -0
+	hellcreek->ptp_clock_info.adjfine   = hellcreek_ptp_adjfine;
+	hellcreek->ptp_clock_info.adjtime   = hellcreek_ptp_adjtime;
+	hellcreek->ptp_clock_info.gettime64 = hellcreek_ptp_gettime;
+	hellcreek->ptp_clock_info.settime64 = hellcreek_ptp_settime;
+	hellcreek->ptp_clock_info.enable    = hellcreek_ptp_enable;
+
+	hellcreek->ptp_clock = ptp_clock_register(&hellcreek->ptp_clock_info,
+						  hellcreek->dev);
+	if (IS_ERR(hellcreek->ptp_clock))
+		return PTR_ERR(hellcreek->ptp_clock);

The ptp_clock_register() can also return NULL:

* Returns a valid pointer on success or PTR_ERR on failure. If PHC
* support is missing at the configuration level, this function
* returns NULL, and drivers are expected to gracefully handle that
* case separately.

Quoted 9 lines
drivers/net/dsa/hirschmann/hellcreek.h +9 -0
+
+	/* Enable the offset correction process, if no offset correction is
+	 * already taking place
+	 */
+	status = hellcreek_ptp_read(hellcreek, PR_CLOCK_STATUS_C);
+	if (!(status & PR_CLOCK_STATUS_C_OFS_ACT))
+		hellcreek_ptp_write(hellcreek,
+				    status | PR_CLOCK_STATUS_C_ENA_OFS,
+				    PR_CLOCK_STATUS_C);

drivers/net/dsa/hirschmann/hellcreek.h

Quoted 10 lines
drivers/net/dsa/hirschmann/hellcreek.h +10 -0
+
+	/* Enable the drift correction process */
+	hellcreek_ptp_write(hellcreek, status | PR_CLOCK_STATUS_C_ENA_DRIFT,
+			    PR_CLOCK_STATUS_C);
+
+	schedule_delayed_work(&hellcreek->overflow_work,
+			      HELLCREEK_OVERFLOW_PERIOD);
+
+	return 0;
+}

Thanks,
Richard

author maintainer
#14 lore raw

Re: [RFC PATCH 3/9] net: dsa: hellcreek: Add PTP clock support

Hi Richard,

Quoted 18 lines · Richard Cochran
Quoted 5 lines · Kurt Kanzenbach
drivers/net/dsa/hirschmann/hellcreek.h +0 -0
index a08a10cb5ab7..2d4422fd2567 100644

drivers/net/dsa/hirschmann/hellcreek.h struct hellcreek_fdb_entry { · line 242

Quoted 9 lines
drivers/net/dsa/hirschmann/hellcreek.h +4 -0
@@ -234,10 +234,17 @@ struct hellcreek_fdb_entry {
 struct hellcreek {
 	struct device *dev;
 	struct dsa_switch *ds;
+	struct ptp_clock *ptp_clock;
+	struct ptp_clock_info ptp_clock_info;
 	struct hellcreek_port ports[4];
+	struct delayed_work overflow_work;
 	spinlock_t reg_lock;	/* Switch IP register lock */
+	spinlock_t ptp_lock;	/* PTP IP register lock */

Why use a spin lock and not a mutex?

No particular reason. Mutex will also work.

Quoted 7 lines

drivers/net/dsa/hirschmann/hellcreek.h struct hellcreek_fdb_entry { · line 246

Quoted 4 lines
drivers/net/dsa/hirschmann/hellcreek.h +4 -0
+	hellcreek->ptp_clock = ptp_clock_register(&hellcreek->ptp_clock_info,
+						  hellcreek->dev);
+	if (IS_ERR(hellcreek->ptp_clock))
+		return PTR_ERR(hellcreek->ptp_clock);

The ptp_clock_register() can also return NULL:

Quoted 5 lines

* Returns a valid pointer on success or PTR_ERR on failure. If PHC
* support is missing at the configuration level, this function
* returns NULL, and drivers are expected to gracefully handle that
* case separately.

I see, thanks. I guess we could add the missing NULL checks to remove() and get_ts_info() to handle that case gracefully.

Thanks,
Kurt

author maintainer
#15 lore raw

RFC PATCH 4/9 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   | 492 ++++++++++++++++++
 .../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, 629 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 f6561bf97f56..138e72852b7d 100644
@@ -26,6 +26,7 @@
 
 #include "hellcreek.h"
 #include "hellcreek_ptp.h"
+#include "hellcreek_hwtstamp.h"
 
 static const struct hellcreek_counter hellcreek_counter[] = {
 	{ 0x00, "RxFiltered", },
@@ -1102,6 +1103,11 @@ static const struct dsa_switch_ops hellcreek_ds_ops = {
 	.port_bridge_join    = hellcreek_port_bridge_join,
 	.port_bridge_leave   = hellcreek_port_bridge_leave,
 	.port_stp_state_set  = hellcreek_port_stp_state_set,
+	.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)
@@ -1201,10 +1207,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);
 
@@ -1215,6 +1229,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 2d4422fd2567..1d3de72a48a5 100644
@@ -212,11 +212,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 +492 -0

492 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..169fafb3ab6a 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
#16 lore raw

RFC PATCH 5/9 net: dsa: hellcreek: Add TAPRIO offloading support

In reply to Kurt Kanzenbach

The switch has support for the 802.1Qbv Time Aware Shaper (TAS). Traffic schedules may be configured individually on each front port. Each port has eight egress queues. The traffic is mapped to a traffic class respectively via the PCP field of a VLAN tagged frame.

The TAPRIO Qdisc already implements that. Therefore, this interface can simply be reused. Add .port_setup_tc() accordingly.

The activation of a schedule on a port is split into two parts:

* Programming the necessary gate control list (GCL)
* Setup hrtimer for starting the schedule

The hardware supports starting a schedule up to eight seconds in the future. The TAPRIO interface provides an absolute base time. Therefore, hrtimers are leveraged.

---
 drivers/net/dsa/hirschmann/hellcreek.c | 290 +++++++++++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek.h |  21 ++
 2 files changed, 311 insertions(+)
drivers/net/dsa/hirschmann/hellcreek.c +290 -0
index 138e72852b7d..7e678b298f99 100644
@@ -22,7 +22,9 @@
 #include <linux/spinlock.h>
 #include <linux/delay.h>
 #include <linux/ktime.h>
+#include <linux/time.h>
 #include <net/dsa.h>
+#include <net/pkt_sched.h>
 
 #include "hellcreek.h"
 #include "hellcreek_ptp.h"
@@ -159,6 +161,15 @@ static void __hellcreek_select_vlan(struct hellcreek *hellcreek, int vid,
 	hellcreek_write(hellcreek, val, HR_VIDCFG);
 }
 
+static void __hellcreek_select_tgd(struct hellcreek *hellcreek, int port)
+{
+	u16 val = 0;
+
+	val |= port << TR_TGDSEL_TDGSEL_SHIFT;
+
+	hellcreek_write(hellcreek, val, TR_TGDSEL);
+}
+
 static int hellcreek_wait_until_ready(struct hellcreek *hellcreek)
 {
 	u16 val;
@@ -988,6 +999,24 @@ static void __hellcreek_setup_tc_identity_mapping(struct hellcreek *hellcreek)
 	}
 }
 
+static void __hellcreek_setup_tc_mapping(struct hellcreek *hellcreek,
+					 struct net_device *netdev)
+{
+	int i, j;
+
+	/* Setup mapping between traffic classes and port queues. */
+	for (i = 0; i < netdev_get_num_tc(netdev); ++i) {
+		for (j = 0; j < netdev->tc_to_txq[i].count; ++j) {
+			const int queue = j + netdev->tc_to_txq[i].offset;
+
+			__hellcreek_select_prio(hellcreek, i);
+			hellcreek_write(hellcreek,
+					queue << HR_PRTCCFG_PCP_TC_MAP_SHIFT,
+					HR_PRTCCFG);
+		}
+	}
+}
+
 static void hellcreek_setup_tc_identity_mapping(struct hellcreek *hellcreek)
 {
 	unsigned long flags;
@@ -1085,6 +1114,263 @@ static int hellcreek_setup(struct dsa_switch *ds)
 	return 0;
 }
 
+static void __hellcreek_setup_gcl(struct hellcreek *hellcreek, int port,
+				  const struct hellcreek_schedule *schedule)
+{
+	size_t i;
+
+	for (i = 1; i <= schedule->num_entries; ++i) {
+		const struct hellcreek_gcl_entry *cur, *initial, *next;
+		u16 data;
+		u8 gates;
+
+		cur	= &schedule->entries[i - 1];
+		initial = &schedule->entries[0];
+		next	= &schedule->entries[i];
+
+		if (i == schedule->num_entries)
+			gates = initial->gate_states ^
+				cur->gate_states;
+		else
+			gates = next->gate_states ^
+				cur->gate_states;
+
+		data = gates;
+		if (cur->overrun_ignore)
+			data |= TR_GCLDAT_GCLOVRI;
+
+		if (i == schedule->num_entries)
+			data |= TR_GCLDAT_GCLWRLAST;
+
+		/* Gates states */
+		hellcreek_write(hellcreek, data, TR_GCLDAT);
+
+		/* Time intervall */
+		hellcreek_write(hellcreek,
+				cur->interval & 0x0000ffff,
+				TR_GCLTIL);
+		hellcreek_write(hellcreek,
+				(cur->interval & 0xffff0000) >> 16,
+				TR_GCLTIH);
+
+		/* Commit entry */
+		data = ((i - 1) << TR_GCLCMD_GCLWRADR_SHIFT) |
+			(initial->gate_states <<
+			 TR_GCLCMD_INIT_GATE_STATES_SHIFT);
+		hellcreek_write(hellcreek, data, TR_GCLCMD);
+	}
+}
+
+static void __hellcreek_set_cycle_time(struct hellcreek *hellcreek,
+				       const struct hellcreek_schedule *schedule)
+{
+	u32 cycle_time = schedule->cycle_time;
+
+	hellcreek_write(hellcreek, cycle_time & 0x0000ffff, TR_CTWRL);
+	hellcreek_write(hellcreek, (cycle_time & 0xffff0000) >> 16, TR_CTWRH);
+}
+
+static void __hellcreek_start_schedule(struct hellcreek *hellcreek,
+				       ktime_t start_time)
+{
+	struct timespec64 ts = ktime_to_timespec64(start_time);
+
+	/* Start can be only 8 seconds in the future */
+	ts.tv_sec %= 8;
+
+	/* Start schedule at this point of time */
+	hellcreek_write(hellcreek, ts.tv_nsec & 0x0000ffff, TR_ESTWRL);
+	hellcreek_write(hellcreek, (ts.tv_nsec & 0xffff0000) >> 16, TR_ESTWRH);
+
+	/* Arm timer, set seconds and switch schedule */
+	hellcreek_write(hellcreek, TR_ESTCMD_ESTARM | TR_ESTCMD_ESTSWCFG |
+		     ((ts.tv_sec & TR_ESTCMD_ESTSEC_MASK) <<
+		      TR_ESTCMD_ESTSEC_SHIFT), TR_ESTCMD);
+}
+
+static struct hellcreek_schedule *hellcreek_taprio_to_schedule(
+	const struct tc_taprio_qopt_offload *taprio)
+{
+	struct hellcreek_schedule *schedule;
+	size_t i;
+
+	/* Allocate some memory first */
+	schedule = kzalloc(sizeof(*schedule), GFP_KERNEL);
+	if (!schedule)
+		return ERR_PTR(-ENOMEM);
+	schedule->entries = kcalloc(taprio->num_entries,
+				    sizeof(*schedule->entries),
+				    GFP_KERNEL);
+	if (!schedule->entries) {
+		kfree(schedule);
+		return ERR_PTR(-ENOMEM);
+	}
+
+	/* Construct hellcreek schedule */
+	schedule->num_entries = taprio->num_entries;
+	schedule->base_time   = taprio->base_time;
+
+	for (i = 0; i < taprio->num_entries; ++i) {
+		const struct tc_taprio_sched_entry *t = &taprio->entries[i];
+		struct hellcreek_gcl_entry *k = &schedule->entries[i];
+
+		k->interval	  = t->interval;
+		k->gate_states	  = t->gate_mask;
+		k->overrun_ignore = 0;
+
+		/* Update complete cycle time */
+		schedule->cycle_time += t->interval;
+	}
+
+	return schedule;
+}
+
+static enum hrtimer_restart hellcreek_set_schedule(struct hrtimer *timer)
+{
+	struct hellcreek_port *hellcreek_port =
+		hrtimer_to_hellcreek_port(timer);
+	struct hellcreek *hellcreek = hellcreek_port->hellcreek;
+	struct hellcreek_schedule *schedule;
+	unsigned long flags;
+
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);
+
+	/* First select port */
+	__hellcreek_select_tgd(hellcreek, hellcreek_port->port);
+
+	/* Set admin base time and switch schedule */
+	__hellcreek_start_schedule(hellcreek,
+				   hellcreek_port->current_schedule->base_time);
+
+	schedule = hellcreek_port->current_schedule;
+	hellcreek_port->current_schedule = NULL;
+
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+
+	dev_info(hellcreek->dev, "ARMed EST timer for port %d\n",
+		 hellcreek_port->port);
+
+	/* Free resources */
+	kfree(schedule->entries);
+	kfree(schedule);
+
+	return HRTIMER_NORESTART;
+}
+
+static int hellcreek_port_set_schedule(struct dsa_switch *ds, int port,
+				       const struct tc_taprio_qopt_offload *taprio)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	struct hellcreek_schedule *schedule;
+	struct net_device *netdev = dsa_to_port(ds, port)->slave;
+	unsigned long flags;
+	ktime_t start;
+	u16 ctrl;
+
+	/* Convert taprio data to hellcreek schedule */
+	schedule = hellcreek_taprio_to_schedule(taprio);
+	if (IS_ERR(schedule))
+		return PTR_ERR(schedule);
+
+	dev_info(hellcreek->dev, "Configure traffic schedule on port %d\n",
+		 port);
+
+	/* Cancel an in flight timer */
+	hrtimer_cancel(&hellcreek_port->cycle_start_timer);
+
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);
+
+	if (hellcreek_port->current_schedule) {
+		kfree(hellcreek_port->current_schedule->entries);
+		kfree(hellcreek_port->current_schedule);
+	}
+
+	hellcreek_port->current_schedule = schedule;
+
+	/* First select port */
+	__hellcreek_select_tgd(hellcreek, port);
+
+	/* Setup traffic class <-> queue mapping */
+	__hellcreek_setup_tc_mapping(hellcreek, netdev);
+
+	/* Enable gating and set the admin state to forward everything in the
+	 * mean time
+	 */
+	ctrl = (0xff << TR_TGDCTRL_ADMINGATESTATES_SHIFT) | TR_TGDCTRL_GATE_EN;
+	hellcreek_write(hellcreek, ctrl, TR_TGDCTRL);
+
+	/* Cancel pending schedule */
+	hellcreek_write(hellcreek, 0x00, TR_ESTCMD);
+
+	/* Setup a new schedule */
+	__hellcreek_setup_gcl(hellcreek, port, schedule);
+
+	/* Configure cycle time */
+	__hellcreek_set_cycle_time(hellcreek, schedule);
+
+	/* Setup timer for schedule switch: The IP core only allows to set a
+	 * cycle start timer 8 seconds in the future. This is why we setup the
+	 * hritmer to base_time - 5 seconds. Then, we have enough time to
+	 * activate IP core's EST timer.
+	 */
+	start = ktime_sub_ns(schedule->base_time, (u64)5 * NSEC_PER_SEC);
+	hrtimer_start_range_ns(&hellcreek_port->cycle_start_timer, start,
+			       NSEC_PER_SEC, HRTIMER_MODE_ABS);
+
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+
+	return 0;
+}
+
+static int hellcreek_port_del_schedule(struct dsa_switch *ds, int port)
+{
+	struct hellcreek *hellcreek = ds->priv;
+	struct hellcreek_port *hellcreek_port = &hellcreek->ports[port];
+	unsigned long flags;
+
+	dev_info(hellcreek->dev, "Remove traffic schedule on port %d\n", port);
+
+	/* First cancel timer */
+	hrtimer_cancel(&hellcreek_port->cycle_start_timer);
+
+	spin_lock_irqsave(&hellcreek->reg_lock, flags);
+
+	if (hellcreek_port->current_schedule) {
+		kfree(hellcreek_port->current_schedule->entries);
+		kfree(hellcreek_port->current_schedule);
+		hellcreek_port->current_schedule = NULL;
+	}
+
+	/* Then select port */
+	__hellcreek_select_tgd(hellcreek, port);
+
+	/* Revert tc mapping */
+	__hellcreek_setup_tc_identity_mapping(hellcreek);
+
+	/* Disable gating and return to regular switching flow */
+	hellcreek_write(hellcreek, 0xff << TR_TGDCTRL_ADMINGATESTATES_SHIFT,
+			TR_TGDCTRL);
+
+	spin_unlock_irqrestore(&hellcreek->reg_lock, flags);
+
+	return 0;
+}
+
+static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port,
+				   enum tc_setup_type type, void *type_data)
+{
+	const struct tc_taprio_qopt_offload *taprio = type_data;
+
+	if (type != TC_SETUP_QDISC_TAPRIO)
+		return -EOPNOTSUPP;
+
+	if (taprio->enable)
+		return hellcreek_port_set_schedule(ds, port, taprio);
+
+	return hellcreek_port_del_schedule(ds, port);
+}
+
 static const struct dsa_switch_ops hellcreek_ds_ops = {
 	.get_tag_protocol    = hellcreek_get_tag_protocol,
 	.setup		     = hellcreek_setup,
@@ -1107,6 +1393,7 @@ static const struct dsa_switch_ops hellcreek_ds_ops = {
 	.port_hwtstamp_get   = hellcreek_port_hwtstamp_get,
 	.port_txtstamp	     = hellcreek_port_txtstamp,
 	.port_rxtstamp	     = hellcreek_port_rxtstamp,
+	.port_setup_tc	     = hellcreek_port_setup_tc,
 	.get_ts_info	     = hellcreek_get_ts_info,
 };
 
@@ -1138,6 +1425,9 @@ static int hellcreek_probe(struct platform_device *pdev)
 		if (!port->counter_values)
 			return -ENOMEM;
 
+		hrtimer_init(&port->cycle_start_timer, CLOCK_TAI,
+			     HRTIMER_MODE_ABS);
+		port->cycle_start_timer.function = hellcreek_set_schedule;
 		port->hellcreek = hellcreek;
 		port->port	= i;
 	}
drivers/net/dsa/hirschmann/hellcreek.h +21 -0
index 1d3de72a48a5..d3d1a1144857 100644
@@ -16,6 +16,7 @@
 #include <linux/ptp_clock_kernel.h>
 #include <linux/timecounter.h>
 #include <linux/spinlock.h>
+#include <linux/hrtimer.h>
 #include <net/dsa.h>
 
 /* Ports:
@@ -210,6 +211,20 @@ struct hellcreek_counter {
 	const char *name;
 };
 
+struct hellcreek_gcl_entry {
+	u32 interval;
+	u8 gate_states;
+	bool overrun_ignore;
+};
+
+struct hellcreek_schedule {
+	struct hellcreek_gcl_entry *entries;
+	size_t num_entries;
+	ktime_t base_time;
+	u32 cycle_time;
+	int port;
+};
+
 struct hellcreek;
 
 /* State flags for hellcreek_port_hwtstamp::state */
@@ -236,6 +251,8 @@ struct hellcreek_port_hwtstamp {
 
 struct hellcreek_port {
 	struct hellcreek *hellcreek;
+	struct hellcreek_schedule *current_schedule;
+	struct hrtimer cycle_start_timer;
 	int port;
 	u16 ptcfg;		/* ptcfg shadow */
 	u64 *counter_values;
@@ -273,4 +290,8 @@ struct hellcreek {
 	size_t fdb_entries;
 };
 
+#define hrtimer_to_hellcreek_port(timer)		\
+	container_of(timer, struct hellcreek_port,	\
+		     cycle_start_timer)
+
 #endif /* _HELLCREEK_H_ */
Signature · 1 line
2.20.1
author maintainer
#17 lore raw

RFC PATCH 6/9 net: dsa: hellcreek: Add debugging mechanisms

In reply to Kurt Kanzenbach

The switch has registers which are useful for debugging issues:

* Trace registers

This can be helpful to trace why packets have been filtered or dropped or if there any other serious problems.

* Memory registers

These registers provide the current switch internal RAM utilization. Especially a unexpected workload with an not appropriate queue setup packets might be dropped due to memory exhaustion.

Expose that registers via debugfs.

---
 drivers/net/dsa/hirschmann/hellcreek.c | 207 ++++++++++++++++++++++++-
 drivers/net/dsa/hirschmann/hellcreek.h |   1 +
 2 files changed, 205 insertions(+), 3 deletions(-)
drivers/net/dsa/hirschmann/hellcreek.c +204 -3
index 7e678b298f99..a56df65ae486 100644
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/ktime.h>
 #include <linux/time.h>
+#include <linux/debugfs.h>
 #include <net/dsa.h>
 #include <net/pkt_sched.h>
 
@@ -1371,6 +1372,195 @@ static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port,
 	return hellcreek_port_del_schedule(ds, port);
 }
 
+static ssize_t hellcreek_dbg_swtrc_cfg_write(struct file *filp,
+					     const char __user *buffer,
+					     size_t count, loff_t *ppos)
+{
+	struct hellcreek *hellcreek = filp->private_data;
+	int ret;
+	u16 reg;
+
+	ret = kstrtou16_from_user(buffer, count, 16, &reg);
+	if (ret)
+		return ret;
+
+	hellcreek_write(hellcreek, reg, HR_SWTRC_CFG);
+
+	return count;
+}
+
+static ssize_t hellcreek_dbg_swtrc0_write(struct file *filp,
+					  const char __user *buffer,
+					  size_t count, loff_t *ppos)
+{
+	struct hellcreek *hellcreek = filp->private_data;
+	int ret;
+	u16 reg;
+
+	ret = kstrtou16_from_user(buffer, count, 16, &reg);
+	if (ret)
+		return ret;
+
+	hellcreek_write(hellcreek, reg, HR_SWTRC0);
+
+	return count;
+}
+
+static ssize_t hellcreek_dbg_swtrc1_write(struct file *filp,
+					  const char __user *buffer,
+					  size_t count, loff_t *ppos)
+{
+	struct hellcreek *hellcreek = filp->private_data;
+	int ret;
+	u16 reg;
+
+	ret = kstrtou16_from_user(buffer, count, 16, &reg);
+	if (ret)
+		return ret;
+
+	hellcreek_write(hellcreek, reg, HR_SWTRC1);
+
+	return count;
+}
+
+static ssize_t hellcreek_dbg_swtrc0_read(struct file *filp,
+					 char __user *buffer,
+					 size_t count, loff_t *ppos)
+{
+	struct hellcreek *hellcreek = filp->private_data;
+	char buf[32];
+	ssize_t desc = 0;
+	u16 reg;
+
+	reg = hellcreek_read(hellcreek, HR_SWTRC0);
+
+	desc += snprintf(buf, sizeof(buf), "0x%04x\n", reg);
+
+	return simple_read_from_buffer(buffer, count, ppos, buf, desc);
+}
+
+static ssize_t hellcreek_dbg_swtrc1_read(struct file *filp,
+					 char __user *buffer,
+					 size_t count, loff_t *ppos)
+{
+	struct hellcreek *hellcreek = filp->private_data;
+	char buf[32];
+	ssize_t desc = 0;
+	u16 reg;
+
+	reg = hellcreek_read(hellcreek, HR_SWTRC1);
+
+	desc += snprintf(buf, sizeof(buf), "0x%04x\n", reg);
+
+	return simple_read_from_buffer(buffer, count, ppos, buf, desc);
+}
+
+static ssize_t hellcreek_dbg_mfree_read(struct file *filp,
+					char __user *buffer,
+					size_t count, loff_t *ppos)
+{
+	struct hellcreek *hellcreek = filp->private_data;
+	char buf[32];
+	ssize_t desc = 0;
+	u16 reg;
+
+	reg = hellcreek_read(hellcreek, HR_MFREE);
+
+	desc += snprintf(buf, sizeof(buf), "0x%04x\n", reg);
+
+	return simple_read_from_buffer(buffer, count, ppos, buf, desc);
+}
+
+static ssize_t hellcreek_dbg_pfree_read(struct file *filp,
+					char __user *buffer,
+					size_t count, loff_t *ppos)
+{
+	struct hellcreek *hellcreek = filp->private_data;
+	char buf[32];
+	ssize_t desc = 0;
+	u16 reg;
+
+	reg = hellcreek_read(hellcreek, HR_PFREE);
+
+	desc += snprintf(buf, sizeof(buf), "0x%04x\n", reg);
+
+	return simple_read_from_buffer(buffer, count, ppos, buf, desc);
+}
+
+static const struct file_operations hellcreek_dbg_swtrc_cfg_fops = {
+	.owner = THIS_MODULE,
+	.open  = simple_open,
+	.write = hellcreek_dbg_swtrc_cfg_write,
+};
+
+static const struct file_operations hellcreek_dbg_swtrc0_fops = {
+	.owner = THIS_MODULE,
+	.open  = simple_open,
+	.read  = hellcreek_dbg_swtrc0_read,
+	.write = hellcreek_dbg_swtrc0_write,
+};
+
+static const struct file_operations hellcreek_dbg_swtrc1_fops = {
+	.owner = THIS_MODULE,
+	.open  = simple_open,
+	.read  = hellcreek_dbg_swtrc1_read,
+	.write = hellcreek_dbg_swtrc1_write,
+};
+
+static const struct file_operations hellcreek_dbg_pfree_fops = {
+	.owner = THIS_MODULE,
+	.open  = simple_open,
+	.read  = hellcreek_dbg_pfree_read,
+};
+
+static const struct file_operations hellcreek_dbg_mfree_fops = {
+	.owner = THIS_MODULE,
+	.open  = simple_open,
+	.read  = hellcreek_dbg_mfree_read,
+};
+
+static int hellcreek_debugfs_init(struct hellcreek *hellcreek)
+{
+	struct dentry *file;
+
+	hellcreek->debug_dir = debugfs_create_dir(dev_name(hellcreek->dev),
+						  NULL);
+	if (!hellcreek->debug_dir)
+		return -ENOMEM;
+
+	file = debugfs_create_file("swtrc_cfg", 0200, hellcreek->debug_dir,
+				   hellcreek, &hellcreek_dbg_swtrc_cfg_fops);
+	if (!file)
+		return -ENOMEM;
+
+	file = debugfs_create_file("swtrc0", 0600, hellcreek->debug_dir,
+				   hellcreek, &hellcreek_dbg_swtrc0_fops);
+	if (!file)
+		return -ENOMEM;
+
+	file = debugfs_create_file("swtrc1", 0600, hellcreek->debug_dir,
+				   hellcreek, &hellcreek_dbg_swtrc1_fops);
+	if (!file)
+		return -ENOMEM;
+
+	file = debugfs_create_file("pfree", 0400, hellcreek->debug_dir,
+				   hellcreek, &hellcreek_dbg_pfree_fops);
+	if (!file)
+		return -ENOMEM;
+
+	file = debugfs_create_file("mfree", 0400, hellcreek->debug_dir,
+				   hellcreek, &hellcreek_dbg_mfree_fops);
+	if (!file)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void hellcreek_debugfs_exit(struct hellcreek *hellcreek)
+{
+	debugfs_remove_recursive(hellcreek->debug_dir);
+}
+
 static const struct dsa_switch_ops hellcreek_ds_ops = {
 	.get_tag_protocol    = hellcreek_get_tag_protocol,
 	.setup		     = hellcreek_setup,
@@ -1475,9 +1665,17 @@ static int hellcreek_probe(struct platform_device *pdev)
 
 	hellcreek_feature_detect(hellcreek);
 
+	ret = hellcreek_debugfs_init(hellcreek);
+	if (ret) {
+		dev_err(dev, "Failed to initialize debugfs!\n");
+		goto err_debugfs;
+	}
+
 	hellcreek->ds = devm_kzalloc(dev, sizeof(*hellcreek->ds), GFP_KERNEL);
-	if (!hellcreek->ds)
-		return -ENOMEM;
+	if (!hellcreek->ds) {
+		ret = -ENOMEM;
+		goto err_debugfs;
+	}
 
 	hellcreek->ds->dev	     = dev;
 	hellcreek->ds->priv	     = hellcreek;
@@ -1488,7 +1686,7 @@ static int hellcreek_probe(struct platform_device *pdev)
 	ret = dsa_register_switch(hellcreek->ds);
 	if (ret) {
 		dev_err(dev, "Unable to register switch\n");
-		return ret;
+		goto err_debugfs;
 	}
 
 	ret = hellcreek_ptp_setup(hellcreek);
@@ -1511,6 +1709,8 @@ static int hellcreek_probe(struct platform_device *pdev)
 	hellcreek_ptp_free(hellcreek);
 err_ptp_setup:
 	dsa_unregister_switch(hellcreek->ds);
+err_debugfs:
+	hellcreek_debugfs_exit(hellcreek);
 
 	return ret;
 }
@@ -1519,6 +1719,7 @@ static int hellcreek_remove(struct platform_device *pdev)
 {
 	struct hellcreek *hellcreek = platform_get_drvdata(pdev);
 
+	hellcreek_debugfs_exit(hellcreek);
 	hellcreek_hwtstamp_free(hellcreek);
 	hellcreek_ptp_free(hellcreek);
 	dsa_unregister_switch(hellcreek->ds);
drivers/net/dsa/hirschmann/hellcreek.h +1 -0
index d3d1a1144857..59cc7b59ff2c 100644
@@ -280,6 +280,7 @@ struct hellcreek {
 	struct ptp_clock_info ptp_clock_info;
 	struct hellcreek_port ports[4];
 	struct delayed_work overflow_work;
+	struct dentry *debug_dir;
 	spinlock_t reg_lock;	/* Switch IP register lock */
 	spinlock_t ptp_lock;	/* PTP IP register lock */
 	void __iomem *base;
Signature · 1 line
2.20.1
maintainer
#18 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

Quoted 1 line · Kurt Kanzenbach

The switch has registers which are useful for debugging issues:

debugfs is not particularly likes. Please try to find other means where possible. Memory usage fits nicely into devlink. See mv88e6xxx which exports the ATU fill for example. Are trace registers counters?

drivers/net/dsa/hirschmann/hellcreek.c static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port, · line 1529

Quoted 8 lines
drivers/net/dsa/hirschmann/hellcreek.c +8 -0
+static int hellcreek_debugfs_init(struct hellcreek *hellcreek)
+{
+	struct dentry *file;
+
+	hellcreek->debug_dir = debugfs_create_dir(dev_name(hellcreek->dev),
+						  NULL);
+	if (!hellcreek->debug_dir)
+		return -ENOMEM;

Just a general comment. You should not check the return value from any debugfs call, since it is totally optional. It will also do the right thing if the previous call has failed. There are numerous emails from GregKH about this.

Andrew

author maintainer
#19 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

Hi Andrew,

Quoted 6 lines · Andrew Lunn
Quoted 1 line · Kurt Kanzenbach

The switch has registers which are useful for debugging issues:

debugfs is not particularly likes. Please try to find other means where possible. Memory usage fits nicely into devlink. See mv88e6xxx which exports the ATU fill for example.

OK, I'll have a look at devlink and the mv88e6xxx driver to see if that could be utilized.

Quoted 1 line

Are trace registers counters?

No. The trace registers provide bits for error conditions and if packets have been dropped e.g. because of full queues or FCS errors, and so on.

Quoted 14 lines

drivers/net/dsa/hirschmann/hellcreek.c static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port, · line 1529

Quoted 9 lines
drivers/net/dsa/hirschmann/hellcreek.c +8 -0
+static int hellcreek_debugfs_init(struct hellcreek *hellcreek)
+{
+	struct dentry *file;
+
+	hellcreek->debug_dir = debugfs_create_dir(dev_name(hellcreek->dev),
+						  NULL);
+	if (!hellcreek->debug_dir)
+		return -ENOMEM;

Just a general comment. You should not check the return value from any debugfs call, since it is totally optional. It will also do the right thing if the previous call has failed. There are numerous emails from GregKH about this.

OK.

Thanks,
Kurt

maintainer
#20 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

Quoted 4 lines
Quoted 1 line

Are trace registers counters?

No. The trace registers provide bits for error conditions and if packets have been dropped e.g. because of full queues or FCS errors, and so on.

Is there some documentation somewhere? A better understanding of what they can do might help figure out the correct API.

Andrew

author maintainer
#21 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

Quoted 7 lines · Andrew Lunn
Quoted 4 lines
Quoted 1 line

Are trace registers counters?

No. The trace registers provide bits for error conditions and if packets have been dropped e.g. because of full queues or FCS errors, and so on.

Is there some documentation somewhere? A better understanding of what they can do might help figure out the correct API.

No, not that I'm aware of.

Actually there are a few more debugging mechanisms and features which should be exposed somehow. Here's the list:

* Trace registers for the error conditions. This feature needs to be
configured for which ports should be traced
* Memory registers for indicating how many free page and meta pointers
are available (read-only)
* Limit registers for configuring:
* Maximum memory limit per port
* Reserved memory for critical traffic
* Background traffic rate
* Maximum queue depth
* Re-prioritization of packets based on the ether type (not mac address)
* Packet logging (-> retrieval of packet time stamps) based on port, traffic class and direction
* Queue tracking

What API would be useful for these mechanisms?

Thanks,
Kurt

maintainer
#22 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

Quoted 27 lines · Kurt Kanzenbach
Quoted 7 lines · Andrew Lunn
Quoted 4 lines
Quoted 1 line

Are trace registers counters?

No. The trace registers provide bits for error conditions and if packets have been dropped e.g. because of full queues or FCS errors, and so on.

Is there some documentation somewhere? A better understanding of what they can do might help figure out the correct API.

No, not that I'm aware of.

Actually there are a few more debugging mechanisms and features which should be exposed somehow. Here's the list:

* Trace registers for the error conditions. This feature needs to be
configured for which ports should be traced
* Memory registers for indicating how many free page and meta pointers
are available (read-only)
* Limit registers for configuring:
* Maximum memory limit per port
* Reserved memory for critical traffic
* Background traffic rate
* Maximum queue depth
* Re-prioritization of packets based on the ether type (not mac address)
* Packet logging (-> retrieval of packet time stamps) based on port, traffic class and direction
* Queue tracking

Quoted 1 line

What API would be useful for these mechanisms?

Hi Kurt

You should take a look at devlink. Many of these fit devlink resources. Use that where it fits. But you might end up with an out of tree debugfs patch for your own debugging work. We have something similar of mv88e6xxx.

Andrew

author maintainer
#23 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

Quoted 28 lines · Andrew Lunn
Quoted 27 lines · Kurt Kanzenbach
Quoted 7 lines · Andrew Lunn
Quoted 4 lines
Quoted 1 line

Are trace registers counters?

No. The trace registers provide bits for error conditions and if packets have been dropped e.g. because of full queues or FCS errors, and so on.

Is there some documentation somewhere? A better understanding of what they can do might help figure out the correct API.

No, not that I'm aware of.

Actually there are a few more debugging mechanisms and features which should be exposed somehow. Here's the list:

* Trace registers for the error conditions. This feature needs to be
configured for which ports should be traced
* Memory registers for indicating how many free page and meta pointers
are available (read-only)
* Limit registers for configuring:
* Maximum memory limit per port
* Reserved memory for critical traffic
* Background traffic rate
* Maximum queue depth
* Re-prioritization of packets based on the ether type (not mac address)
* Packet logging (-> retrieval of packet time stamps) based on port, traffic class and direction
* Queue tracking

Quoted 8 lines
Quoted 1 line

What API would be useful for these mechanisms?

Hi Kurt

You should take a look at devlink. Many of these fit devlink resources. Use that where it fits. But you might end up with an out of tree debugfs patch for your own debugging work. We have something similar of mv88e6xxx.

I see. Maybe I'll keep the debug stuff out of tree for now and will come back to it later.

Thanks,
Kurt

maintainer
#24 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

In reply to Kurt Kanzenbach

Hi Kurt,

Quoted 2 lines · Kurt Kanzenbach

* Re-prioritization of packets based on the ether type (not mac address)

This can be done by offloading a tc skbedit priority action, and a "protocol" key (even though I don't understand why you need to mention "not mac address".

Quoted 1 line

* Packet logging (-> retrieval of packet time stamps) based on port, traffic class and direction

What does this mean? tcpdump can give you this, for traffic destined to the CPU. Do you want to mirror/sample traffic to the CPU for debug?

Quoted 5 lines

What API would be useful for these mechanisms?

Thanks,
Kurt

Thanks,
-Vladimir

author maintainer
#25 lore raw

Re: [RFC PATCH 6/9] net: dsa: hellcreek: Add debugging mechanisms

Hi Vladimir,

Quoted 9 lines · Vladimir Oltean

Hi Kurt,

Quoted 2 lines · Kurt Kanzenbach

* Re-prioritization of packets based on the ether type (not mac address)

This can be done by offloading a tc skbedit priority action, and a "protocol" key (even though I don't understand why you need to mention "not mac address".

Thanks. That seems like it can be used. I did mention the mac address, because the switch has two ways of doing a re-prioritization either by fdb entries via mac addresses or by the high level inspection (HLI) based on the ether type.

Quoted 6 lines
Quoted 2 lines

* Packet logging (-> retrieval of packet time stamps) based on port, traffic class and direction

What does this mean? tcpdump can give you this, for traffic destined to the CPU. Do you want to mirror/sample traffic to the CPU for debug?

The switch can capture timestamps (nanoseconds) when packets have been transmitted or received on all ports. The timestamps are stored in a FIFO and can be retrieved later. As you said tcpdump only works for packets at the CPU port. This feature is useful for debugging latency issues for specific traffic flows.

Thanks,
Kurt

author maintainer
#26 lore raw

RFC PATCH 7/9 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 | 70 ++++++++++++++++++++++
 drivers/net/dsa/hirschmann/hellcreek_ptp.h |  3 +
 3 files changed, 77 insertions(+)
drivers/net/dsa/hirschmann/hellcreek.h +4 -0
index 59cc7b59ff2c..18e78d7e0a55 100644
@@ -17,6 +17,7 @@
 #include <linux/timecounter.h>
 #include <linux/spinlock.h>
 #include <linux/hrtimer.h>
+#include <linux/leds.h>
 #include <net/dsa.h>
 
 /* Ports:
@@ -281,6 +282,8 @@ struct hellcreek {
 	struct hellcreek_port ports[4];
 	struct delayed_work overflow_work;
 	struct dentry *debug_dir;
+	struct led_classdev led_is_gm;
+	struct led_classdev led_sync_good;
 	spinlock_t reg_lock;	/* Switch IP register lock */
 	spinlock_t ptp_lock;	/* PTP IP register lock */
 	void __iomem *base;
@@ -288,6 +291,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 +70 -0

88 lines not on this page · raw message

drivers/net/dsa/hirschmann/hellcreek_ptp.h +3 -0
index 169fafb3ab6a..42988291ba4c 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
maintainer
#27 lore raw

Re: [RFC PATCH 7/9] net: dsa: hellcreek: Add PTP status LEDs

Quoted 10 lines · 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.

Quoted 7 lines

* 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.

Hi Kurt

Is the hardware driving these signals at all? Or are these just suggested names in the documentation? It would not be an issue to have user space to configure them to use the heartbeat trigger, etc?

Andrew

author maintainer
#28 lore raw

Re: [RFC PATCH 7/9] net: dsa: hellcreek: Add PTP status LEDs

Hi Andrew,

Quoted 16 lines · Andrew Lunn
Quoted 15 lines · 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.

Quoted 8 lines
Quoted 2 lines

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

Hi Kurt

Is the hardware driving these signals at all? Or are these just suggested names in the documentation? It would not be an issue to have user space to configure them to use the heartbeat trigger, etc?

These are more like GPIOs. If a 1 is set into the register then the hardware drives the signal to high. The names are from the documentation:

* sync_good: This signal indicates that the switch is in sync
* is_gm: This signal indicates that the switch is the grand master

However, these signals have to be set by user space. Most likely these signals are connected to LEDs.

Thanks,
Kurt

maintainer
#29 lore raw

Re: [RFC PATCH 7/9] net: dsa: hellcreek: Add PTP status LEDs

Quoted 32 lines · Kurt Kanzenbach

Hi Andrew,

Quoted 16 lines · Andrew Lunn
Quoted 15 lines · 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.

Quoted 8 lines
Quoted 2 lines

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

Hi Kurt

Is the hardware driving these signals at all? Or are these just suggested names in the documentation? It would not be an issue to have user space to configure them to use the heartbeat trigger, etc?

These are more like GPIOs. If a 1 is set into the register then the hardware drives the signal to high. The names are from the documentation:

Quoted 5 lines

* sync_good: This signal indicates that the switch is in sync
* is_gm: This signal indicates that the switch is the grand master

However, these signals have to be set by user space. Most likely these signals are connected to LEDs.

Thanks

Since these are general purpose LEDs, you might want to look at

Documentation/devicetree/bindings/leds/common.yaml

and implement some of the common properties. The label should ideally correspond to the text on the case, not what the datasheet says. So getting it from DT is a good idea. Do Hirschmanns own cases use this text on there front plate?

Andrew

author maintainer
#30 lore raw

RFC PATCH 8/9 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 9aeab66be85f..279a10418ce8 100644
@@ -429,6 +429,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
#31 lore raw

RFC PATCH 9/9 dt-bindings: net: dsa: Add documentation for Hellcreek switches

In reply to Kurt Kanzenbach

Add basic documentation and example.

---
 .../devicetree/bindings/net/dsa/hellcreek.txt | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.txt
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +72 -0
new file mode 100644
index 000000000000..9ea6494dc554
@@ -0,0 +1,72 @@
+Hirschmann hellcreek switch driver
+==================================
+
+Required properties:
+
+- compatible:
+	Must be one of:
+	- "hirschmann,hellcreek"
+
+See Documentation/devicetree/bindings/net/dsa/dsa.txt for the list of standard
+DSA required and optional properties.
+
+Example
+-------
+
+Ethernet switch connected memory mapped to the host, CPU port wired to gmac0:
+
+soc {
+        switch0: switch@0xff240000 {
+                compatible = "hirschmann,hellcreek";
+                status = "okay";
+                reg = <0xff240000 0x1000   /* TSN base */
+                       0xff250000 0x1000>; /* PTP base */
+                dsa,member = <0 0>;
+
+                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>;
+                        };
+                };
+        };
+};
+
+&gmac0 {
+        status = "okay";
+        phy-mode = "mii";
+
+        fixed-link {
+                speed = <100>;
+                full-duplex;
+        };
+
+        mdio {
+                #address-cells = <1>;
+                #size-cells = <0>;
+                compatible = "snps,dwmac-mdio";
+
+                phy1: ethernet-phy@1 {
+                        reg = <1>;
+                };
+                phy2: ethernet-phy@2 {
+                        reg = <2>;
+                };
+        };
+};
Signature · 1 line
2.20.1
maintainer
#32 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Quoted 32 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +32 -0
+Ethernet switch connected memory mapped to the host, CPU port wired to gmac0:
+
+soc {
+        switch0: switch@0xff240000 {
+                compatible = "hirschmann,hellcreek";
+                status = "okay";
+                reg = <0xff240000 0x1000   /* TSN base */
+                       0xff250000 0x1000>; /* PTP base */
+                dsa,member = <0 0>;
+
+                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>;
+                        };
+                };

Documentation/devicetree/bindings/net/dsa/hellcreek.txt line 57

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +10 -0
+        };
+};
+
+&gmac0 {
+        status = "okay";
+        phy-mode = "mii";
+
+        fixed-link {
+                speed = <100>;
+                full-duplex;

Hi Kurt

The switch is 100/100Mbps right? The MAC is only Fast ethernet. Do you need some properties in the port@0 node to tell the switch to only use 100Mbps? I would expect it to default to 1G. Not looked at the code yet...

Andrew

author maintainer
#33 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Hi Andrew,

Quoted 45 lines · Andrew Lunn
Quoted 32 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +32 -0
+Ethernet switch connected memory mapped to the host, CPU port wired to gmac0:
+
+soc {
+        switch0: switch@0xff240000 {
+                compatible = "hirschmann,hellcreek";
+                status = "okay";
+                reg = <0xff240000 0x1000   /* TSN base */
+                       0xff250000 0x1000>; /* PTP base */
+                dsa,member = <0 0>;
+
+                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>;
+                        };
+                };

Documentation/devicetree/bindings/net/dsa/hellcreek.txt line 57

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +10 -0
+        };
+};
+
+&gmac0 {
+        status = "okay";
+        phy-mode = "mii";
+
+        fixed-link {
+                speed = <100>;
+                full-duplex;

Hi Kurt

Quoted 4 lines

The switch is 100/100Mbps right? The MAC is only Fast ethernet. Do you need some properties in the port@0 node to tell the switch to only use 100Mbps? I would expect it to default to 1G. Not looked at the code yet...

No, that is not needed. That is a hardware configuration and AFAIK cannot be changed at run time.

Thanks,
Kurt

maintainer
#34 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Quoted 7 lines
Quoted 4 lines

The switch is 100/100Mbps right? The MAC is only Fast ethernet. Do you need some properties in the port@0 node to tell the switch to only use 100Mbps? I would expect it to default to 1G. Not looked at the code yet...

No, that is not needed. That is a hardware configuration and AFAIK cannot be changed at run time.

I was wondering about that in general. I did not spot any code in the driver dealing with results from the PHY auto-neg. So you are saying the CPU is fixed speed, by strapping? But what about the other ports? Does the MAC need to know the PHY has negotiated 10Half, not 1G? Would that not make a difference to your TSN?

Andrew

author maintainer
#35 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 4 lines

The switch is 100/100Mbps right? The MAC is only Fast ethernet. Do you need some properties in the port@0 node to tell the switch to only use 100Mbps? I would expect it to default to 1G. Not looked at the code yet...

Quoted 8 lines
Quoted 2 lines

No, that is not needed. That is a hardware configuration and AFAIK cannot be changed at run time.

I was wondering about that in general. I did not spot any code in the driver dealing with results from the PHY auto-neg. So you are saying the CPU is fixed speed, by strapping? But what about the other ports? Does the MAC need to know the PHY has negotiated 10Half, not 1G? Would that not make a difference to your TSN?

Indeed, that does make a difference. I've checked with the vendor. The current version of the switch IP does not support configuring the speed etc. at run time. It is hard wired to 100 Mbit/s or 1000 Mbit/s for now. Later versions of the chip might support setting the speed etc. via configuration registers. As a result the PHYs at the front ports should be programmed to only advertise 100 Mbit/s or 1G depending on the hardware setup.

Thanks,
Kurt

maintainer
#36 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Quoted 15 lines · Kurt Kanzenbach
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 4 lines

The switch is 100/100Mbps right? The MAC is only Fast ethernet. Do you need some properties in the port@0 node to tell the switch to only use 100Mbps? I would expect it to default to 1G. Not looked at the code yet...

Quoted 8 lines
Quoted 2 lines

No, that is not needed. That is a hardware configuration and AFAIK cannot be changed at run time.

I was wondering about that in general. I did not spot any code in the driver dealing with results from the PHY auto-neg. So you are saying the CPU is fixed speed, by strapping? But what about the other ports? Does the MAC need to know the PHY has negotiated 10Half, not 1G? Would that not make a difference to your TSN?

Quoted 7 lines

Indeed, that does make a difference. I've checked with the vendor. The current version of the switch IP does not support configuring the speed etc. at run time. It is hard wired to 100 Mbit/s or 1000 Mbit/s for now. Later versions of the chip might support setting the speed etc. via configuration registers. As a result the PHYs at the front ports should be programmed to only advertise 100 Mbit/s or 1G depending on the hardware setup.

Hi Kurt

Are there registers which allow you to determine the strapping? There are phylib/phylink calls you can make to set the advertisement in the PHY. It would be good to do this in the DSA driver.

Andrew

author maintainer
#37 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Quoted 24 lines · Andrew Lunn
Quoted 15 lines · Kurt Kanzenbach
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 4 lines

The switch is 100/100Mbps right? The MAC is only Fast ethernet. Do you need some properties in the port@0 node to tell the switch to only use 100Mbps? I would expect it to default to 1G. Not looked at the code yet...

Quoted 8 lines
Quoted 2 lines

No, that is not needed. That is a hardware configuration and AFAIK cannot be changed at run time.

I was wondering about that in general. I did not spot any code in the driver dealing with results from the PHY auto-neg. So you are saying the CPU is fixed speed, by strapping? But what about the other ports? Does the MAC need to know the PHY has negotiated 10Half, not 1G? Would that not make a difference to your TSN?

Quoted 7 lines

Indeed, that does make a difference. I've checked with the vendor. The current version of the switch IP does not support configuring the speed etc. at run time. It is hard wired to 100 Mbit/s or 1000 Mbit/s for now. Later versions of the chip might support setting the speed etc. via configuration registers. As a result the PHYs at the front ports should be programmed to only advertise 100 Mbit/s or 1G depending on the hardware setup.

Quoted 3 lines

Hi Kurt

Are there registers which allow you to determine the strapping?

No, there are not.

Quoted 2 lines

There are phylib/phylink calls you can make to set the advertisement in the PHY. It would be good to do this in the DSA driver.

I will. All the chips currently available are configured to 100 Mbit/s. So, we can assume that for now.

Thanks,
Kurt

#38 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

In reply to Kurt Kanzenbach

Documentation/devicetree/bindings/net/dsa/hellcreek.txt

Quoted 13 lines · Kurt Kanzenbach

Add basic documentation and example.

---
 .../devicetree/bindings/net/dsa/hellcreek.txt | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.txt
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +0 -0
new file mode 100644
index 000000000000..9ea6494dc554

This should be a YAML binding and we should also convert the DSA binding to YAML one day.

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +9 -0
@@ -0,0 +1,72 @@
+Hirschmann hellcreek switch driver
+==================================
+
+Required properties:
+
+- compatible:
+	Must be one of:
+	- "hirschmann,hellcreek"
+

Documentation/devicetree/bindings/net/dsa/hellcreek.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +10 -0
+See Documentation/devicetree/bindings/net/dsa/dsa.txt for the list of standard
+DSA required and optional properties.
+
+Example
+-------
+
+Ethernet switch connected memory mapped to the host, CPU port wired to gmac0:
+
+soc {
+        switch0: switch@0xff240000 {

Please remove the leading 0x from the unit address.

Signature · 1 line
Florian
author maintainer
#39 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Hi Florian,

Quoted 9 lines · Florian Fainelli
Quoted 8 lines · Kurt Kanzenbach

Add basic documentation and example.

---
 .../devicetree/bindings/net/dsa/hellcreek.txt | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.txt
Quoted 8 lines

Documentation/devicetree/bindings/net/dsa/hellcreek.txt

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +0 -0
new file mode 100644
index 000000000000..9ea6494dc554

This should be a YAML binding and we should also convert the DSA binding to YAML one day.

OK.

Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +13 -0
@@ -0,0 +1,72 @@
+Hirschmann hellcreek switch driver
+==================================
+
+Required properties:
+
+- compatible:
+	Must be one of:
+	- "hirschmann,hellcreek"
+
+See Documentation/devicetree/bindings/net/dsa/dsa.txt for the list of standard
+DSA required and optional properties.
+
+Example
Quoted 8 lines

Documentation/devicetree/bindings/net/dsa/hellcreek.txt line 19

Quoted 6 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +6 -0
+-------
+
+Ethernet switch connected memory mapped to the host, CPU port wired to gmac0:
+
+soc {
+        switch0: switch@0xff240000 {

Please remove the leading 0x from the unit address.

Sure.

Thanks,
Kurt

author maintainer
#40 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Quoted 19 lines · Kurt Kanzenbach
Quoted 9 lines · Florian Fainelli
Quoted 8 lines · Kurt Kanzenbach

Add basic documentation and example.

---
 .../devicetree/bindings/net/dsa/hellcreek.txt | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.txt
Quoted 8 lines

Documentation/devicetree/bindings/net/dsa/hellcreek.txt

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +0 -0
new file mode 100644
index 000000000000..9ea6494dc554

This should be a YAML binding and we should also convert the DSA binding to YAML one day.

Quoted 1 line

OK.

I converted it into a YAML binding. Should I provide the dsa.yaml as well? Otherwise I have to define the DSA properties such as dsa,member in the hellcreek.yaml file.

Thanks,
Kurt

#41 lore raw

Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches

Quoted 20 lines · Kurt Kanzenbach
Quoted 19 lines · Kurt Kanzenbach
Quoted 17 lines · Florian Fainelli

Documentation/devicetree/bindings/net/dsa/hellcreek.txt

Quoted 13 lines · Kurt Kanzenbach

Add basic documentation and example.

---
 .../devicetree/bindings/net/dsa/hellcreek.txt | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/hellcreek.txt
Documentation/devicetree/bindings/net/dsa/hellcreek.txt new file +0 -0
new file mode 100644
index 000000000000..9ea6494dc554

This should be a YAML binding and we should also convert the DSA binding to YAML one day.

Quoted 5 lines
Quoted 1 line

OK.

I converted it into a YAML binding. Should I provide the dsa.yaml as well? Otherwise I have to define the DSA properties such as dsa,member in the hellcreek.yaml file.

If you have the generic DSA binding converted as YAML that would be highly welcome you can submit that separately from your patch series.

There are quite a few Device Tree sources in tree that can be used as a validation vector for dsa.yaml.

Signature · 1 line
Florian