Skip to contentSkip to conversation

Introduce DSA Ethernet switch class and Felix driver

PATCH Superseded Alex Marginean 3 participants 13 messages Nov 22, 2019 – Nov 24, 2019

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Introduce DSA Ethernet switch class and Felix driver

DSA stands for Distributed Switch Architecture and it is a subsystem introduced in the Linux kernel to support switches that:
- have an Ethernet link up to the CPU
- use some form of tagging to identify the source/destination port for Rx/Tx
- may be cascaded in tree-like structures.

DSA is described in depth here:
https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt

From the doc:

	Summarized, this is basically how DSA looks like from a network device
	perspective:


		    |---------------------------
		    | CPU network device (eth0)|
		    ----------------------------
		    | <tag added by switch     |
		    |                          |
		    |                          |
		    |        tag added by CPU> |
		|--------------------------------------------|
		| Switch driver				     |
		|--------------------------------------------|
		    ||        ||         ||
		|-------|  |-------|  |-------|
		| sw0p0 |  | sw0p1 |  | sw0p2 |
		|-------|  |-------|  |-------|

This patch set introduces a DSA class in U-Boot to support drivers of such switches. DSA drivers have to implement the following ops:
- enable/disable of switch ports,
- insert a tag in frames being transmitted, used by the switch to select the egress port,
- parse a tag in frames being received, used for Rx traffic.

DSA class code deals with presentation of switch ports as Ethernet interfaces, deals with the master Ethernet device for I/O and helps with parsing of the DT assuming the structure follows the DSA kernel binding.

Support for switch cascading is not included yet.

This patch set also introduces a driver for the Ethernet switch integrated into NXP LS1028A, called Felix. The switch has 4 front panel ports, I/O to/fom it is done though an ENETC Ethernet interface and meta-data is carried between the switch and the driver though an additional header pre-pended to the original frame.
Network commands like tftp can be used on these front panel ports. The ports are disabled unless used so they do not cause issues on network topologies that include loops.

Felix as seen on LS1028A RDB:
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
......

 dsa           0  [ + ]   felix-switch          |   |-- felix-switch
 eth           4  [ + ]   dsa-port              |   |   |-- swp0
 eth           5  [ + ]   dsa-port              |   |   |-- swp1
 eth           6  [ + ]   dsa-port              |   |   |-- swp2
 eth           7  [ + ]   dsa-port              |   |   `-- swp3

=> mdio list
......
10 - Vitesse VSC8514 <--> swp0
11 - Vitesse VSC8514 <--> swp1
12 - Vitesse VSC8514 <--> swp2
13 - Vitesse VSC8514 <--> swp3

=> tftp 80000000 test
Using swp2 device
TFTP from server 192.168.100.1; our IP address is 192.168.100.100 Filename 'test'.
Load address: 0x80000000
Loading: #################################################################

         #################################################################
         ########################################################
         6.8 MiB/s

done
Bytes transferred = 949880 (e7e78 hex)

This patch set replaces this previous submission of the Felix driver:
https://patchwork.ozlabs.org/project/uboot/list/?series=143126&state=*
and depends on:
https://patchwork.ozlabs.org/project/uboot/list/?series=142858
https://patchwork.ozlabs.org/project/uboot/list/?series=142879

Alex Marginean (6):
net: introduce DSA class for Ethernet switches
drivers: net: add a DSA sandbox driver
test: dm: add a simple unit test for DSA class
drivers: net: add Felix DSA switch driver
arm: dts: ls1028a: adds Ethernet switch node and its dependencies
configs: ls1028a: enable the Ethernet switch driver in defconfig

 arch/Kconfig                                 |   1 +
 arch/arm/dts/fsl-ls1028a-rdb.dts             |  36 ++
 arch/arm/dts/fsl-ls1028a.dtsi                |  41 +-
 arch/sandbox/dts/test.dts                    |  49 ++
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig |   3 +-
 configs/ls1028aqds_tfa_defconfig             |   3 +-
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig |   3 +-
 configs/ls1028ardb_tfa_defconfig             |   3 +-
 drivers/net/Kconfig                          |  21 +
 drivers/net/Makefile                         |   1 +
 drivers/net/dsa_sandbox.c                    | 272 +++++++++++
 drivers/net/fsl_enetc.h                      |   5 +
 drivers/net/mscc_eswitch/Kconfig             |   8 +
 drivers/net/mscc_eswitch/Makefile            |   1 +
 drivers/net/mscc_eswitch/felix_switch.c      | 453 +++++++++++++++++++
 include/configs/sandbox.h                    |   4 +
 include/dm/uclass-id.h                       |   1 +
 include/dsa.h                                | 132 ++++++
 net/Makefile                                 |   1 +
 net/dsa-uclass.c                             | 369 +++++++++++++++
 test/dm/Makefile                             |   1 +
 test/dm/dsa.c                                |  58 +++
 test/dm/test-fdt.c                           |   2 +-
 23 files changed, 1462 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/dsa_sandbox.c
 create mode 100644 drivers/net/mscc_eswitch/felix_switch.c
 create mode 100644 include/dsa.h
 create mode 100644 net/dsa-uclass.c
 create mode 100644 test/dm/dsa.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/6 net: introduce DSA class for Ethernet switches

DSA stands for Distributed Switch Architecture and it covers switches that are connected to the CPU through an Ethernet link and generally use frame tags to pass information about the source/destination ports to/from CPU. Front panel ports are presented as regular ethernet devices in U-Boot and they are expected to support the typical networking commands. DSA switches may be cascaded, DSA class code does not currently support this.

---
 drivers/net/Kconfig    |  13 ++
 include/dm/uclass-id.h |   1 +
 include/dsa.h          | 132 +++++++++++++++
 net/Makefile           |   1 +
 net/dsa-uclass.c       | 369 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 516 insertions(+)
 create mode 100644 include/dsa.h
 create mode 100644 net/dsa-uclass.c
drivers/net/Kconfig +13 -0
index 4182897d89..a4157cb122 100644
@@ -37,6 +37,19 @@ config DM_MDIO_MUX
 	  This is currently implemented in net/mdio-mux-uclass.c
 	  Look in include/miiphy.h for details.
 
+config DM_DSA
+	bool "Enable Driver Model for DSA switches"
+	depends on DM_ETH && DM_MDIO
+	help
+	  Enable Driver Model for DSA switches
+
+	  Adds UCLASS_DSA class supporting switches that follow the Distributed
+	  Switch Architecture (DSA).  These switches rely on the presence of a
+	  management switch port connected to an Ethernet controller capable of
+	  receiving frames from the switch.  This host Ethernet controller is
+	  called "master" and "cpu" in DSA terminology.
+	  This is currently implemented in net/dsa-uclass.c
+
 config MDIO_SANDBOX
 	depends on DM_MDIO && SANDBOX
 	default y
include/dm/uclass-id.h +1 -0
index 0c563d898b..8f37a91488 100644
@@ -42,6 +42,7 @@ enum uclass_id {
 	UCLASS_DISPLAY,		/* Display (e.g. DisplayPort, HDMI) */
 	UCLASS_DSI_HOST,	/* Display Serial Interface host */
 	UCLASS_DMA,		/* Direct Memory Access */
+	UCLASS_DSA,		/* Distributed (Ethernet) Switch Architecture */
 	UCLASS_EFI,		/* EFI managed devices */
 	UCLASS_ETH,		/* Ethernet device */
 	UCLASS_FIRMWARE,	/* Firmware */
include/dsa.h new file +132 -0

132 lines not on this page · raw message

net/Makefile +1 -0
index 2a700c8401..fac8c8beb9 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_CMD_SNTP) += sntp.o
 obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
 obj-$(CONFIG_UDP_FUNCTION_FASTBOOT)  += fastboot.o
 obj-$(CONFIG_CMD_WOL)  += wol.o
+obj-$(CONFIG_DM_DSA)   += dsa-uclass.o
 
 # Disable this warning as it is triggered by:
 # sprintf(buf, index ? "foo%d" : "foo", index)
net/dsa-uclass.c new file +369 -0

369 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/6 drivers: net: add a DSA sandbox driver

In reply to Alex Marginean

The DSA sandbox driver is used for DSA unit testing. It implements a simple 4 port switch that uses a very simple tag to identify the ports. The DSA driver comes paired with an Ethernet driver that loops packets back and can selectively filter traffic on DSA switch ports.

---
 drivers/net/Kconfig       |   8 ++
 drivers/net/Makefile      |   1 +
 drivers/net/dsa_sandbox.c | 272 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 281 insertions(+)
 create mode 100644 drivers/net/dsa_sandbox.c
drivers/net/Kconfig +8 -0
index a4157cb122..ac420cb474 100644
@@ -70,6 +70,14 @@ config MDIO_MUX_SANDBOX
 
 	  This driver is used for testing in test/dm/mdio.c
 
+config DSA_SANDBOX
+	depends on DM_DSA && SANDBOX
+	default y
+	bool "Sandbox: Mocked DSA driver"
+	help
+	  This driver implements a dummy switch and a dummy Ethernet device used
+	  to test DSA class code.
+
 menuconfig NETDEVICES
 	bool "Network device support"
 	depends on NET
drivers/net/Makefile +1 -0
index 30991834ec..8be49f6335 100644
@@ -82,3 +82,4 @@ obj-y += mscc_eswitch/
 obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o
 obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.o
 obj-$(CONFIG_FSL_ENETC) += fsl_enetc.o fsl_enetc_mdio.o
+obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o
drivers/net/dsa_sandbox.c new file +272 -0

272 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/6 test: dm: add a simple unit test for DSA class

In reply to Alex Marginean

The test pings the local IP address though different ports of a sandbox DSA device. Port traffic is filtered and the test verifies that ping works only on enabled ports.
The additional interfaces require MAC addresses, these have been added to sandbox default environment.

---
 arch/Kconfig              |  1 +
 arch/sandbox/dts/test.dts | 49 +++++++++++++++++++++++++++++++++
 include/configs/sandbox.h |  4 +++
 test/dm/Makefile          |  1 +
 test/dm/dsa.c             | 58 +++++++++++++++++++++++++++++++++++++++
 test/dm/test-fdt.c        |  2 +-
 6 files changed, 114 insertions(+), 1 deletion(-)
 create mode 100644 test/dm/dsa.c
arch/Kconfig +1 -0
index 141e48bc43..70907d69a1 100644
@@ -133,6 +133,7 @@ config SANDBOX
 	imply PHYLIB
 	imply DM_MDIO
 	imply DM_MDIO_MUX
+	imply DM_DSA
 
 config SH
 	bool "SuperH architecture"
arch/sandbox/dts/test.dts +49 -0

61 lines not on this page · raw message

include/configs/sandbox.h +4 -0
index 5d75021ed6..a586a93415 100644
@@ -102,6 +102,10 @@
 					"eth1addr=00:00:11:22:33:45\0" \
 					"eth3addr=00:00:11:22:33:46\0" \
 					"eth5addr=00:00:11:22:33:47\0" \
+					"eth8addr=00:00:11:22:33:48\0" \
+					"eth9addr=00:00:11:22:33:49\0" \
+					"eth10addr=00:00:11:22:33:4a\0" \
+					"eth11addr=00:00:11:22:33:4b\0" \
 					"ipaddr=1.2.3.4\0"
 
 #define MEM_LAYOUT_ENV_SETTINGS \
test/dm/Makefile +1 -0
index 0c2fd5cb5e..69e9feed91 100644
@@ -65,4 +65,5 @@ obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o
 obj-$(CONFIG_DMA) += dma.o
 obj-$(CONFIG_DM_MDIO) += mdio.o
 obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o
+obj-$(CONFIG_DM_DSA) += dsa.o
 endif
test/dm/dsa.c new file +58 -0

58 lines not on this page · raw message

test/dm/test-fdt.c +1 -1
index 1fb8b5c248..0d7dd053e2 100644
@@ -224,7 +224,7 @@ static int dm_test_alias_highest_id(struct unit_test_state *uts)
 	int ret;
 
 	ret = dev_read_alias_highest_id("eth");
-	ut_asserteq(5, ret);
+	ut_asserteq(11, ret);
 
 	ret = dev_read_alias_highest_id("gpio");
 	ut_asserteq(2, ret);
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/6 drivers: net: add Felix DSA switch driver

In reply to Alex Marginean

This driver is used for the Ethernet switch integrated into LS1028A NXP. Felix on LS1028A has 4 front panel ports and two internal ports, I/O to/from the switch is done through an ENETC Ethernet interface. The 4 front panel ports are available as Ethernet interfaces and can be used with the typical network commands like tftp.

---
 drivers/net/fsl_enetc.h                 |   5 +
 drivers/net/mscc_eswitch/Kconfig        |   8 +
 drivers/net/mscc_eswitch/Makefile       |   1 +
 drivers/net/mscc_eswitch/felix_switch.c | 453 ++++++++++++++++++++++++
 4 files changed, 467 insertions(+)
 create mode 100644 drivers/net/mscc_eswitch/felix_switch.c
drivers/net/fsl_enetc.h +5 -0
index 9a36cdad80..29e7781b5e 100644
@@ -200,6 +200,11 @@ struct enetc_priv {
 /* PCS replicator block for USXGMII */
 #define ENETC_PCS_DEVAD_REPL		0x1f
 
+#define ENETC_PCS_REPL_LINK_TIMER_1	0x12
+#define  ENETC_PCS_REPL_LINK_TIMER_1_DEF	0x0003
+#define ENETC_PCS_REPL_LINK_TIMER_2	0x13
+#define  ENETC_PCS_REPL_LINK_TIMER_2_DEF	0x06a0
+
 /* ENETC external MDIO registers */
 #define ENETC_MDIO_BASE		0x1c00
 #define ENETC_MDIO_CFG		0x00
drivers/net/mscc_eswitch/Kconfig +8 -0
index 80dd22f98b..11fb08edaa 100644
@@ -36,3 +36,11 @@ config MSCC_SERVAL_SWITCH
 	select PHYLIB
 	help
 	  This driver supports the Serval network switch device.
+
+config MSCC_FELIX_SWITCH
+	bool "Felix switch driver"
+	depends on DM_DSA && DM_PCI
+	select FSL_ENETC
+	help
+	  This driver supports the Ethernet switch integrated in LS1028A NXP
+	  SoC.
drivers/net/mscc_eswitch/Makefile +1 -0
index d583fe9fc4..22342ed114 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_MSCC_LUTON_SWITCH) += luton_switch.o mscc_xfer.o mscc_mac_table.o m
 obj-$(CONFIG_MSCC_JR2_SWITCH) += jr2_switch.o mscc_xfer.o mscc_miim.o
 obj-$(CONFIG_MSCC_SERVALT_SWITCH) += servalt_switch.o mscc_xfer.o mscc_miim.o
 obj-$(CONFIG_MSCC_SERVAL_SWITCH) += serval_switch.o mscc_xfer.o mscc_mac_table.o mscc_miim.o
+obj-$(CONFIG_MSCC_FELIX_SWITCH) += felix_switch.o
drivers/net/mscc_eswitch/felix_switch.c new file +453 -0

453 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

PATCH 4/6 drivers: net: add Felix DSA switch driver

Am 2019-11-22 02:36, schrieb Alex Marginean:

Quoted 463 lines

This driver is used for the Ethernet switch integrated into LS1028A NXP.
Felix on LS1028A has 4 front panel ports and two internal ports, I/O to/from the switch is done through an ENETC Ethernet interface. The 4 front panel ports are available as Ethernet interfaces and can be used with the typical network commands like tftp.

---
 drivers/net/fsl_enetc.h                 |   5 +
 drivers/net/mscc_eswitch/Kconfig        |   8 +
 drivers/net/mscc_eswitch/Makefile       |   1 +
 drivers/net/mscc_eswitch/felix_switch.c | 453 ++++++++++++++++++++++++
 4 files changed, 467 insertions(+)
 create mode 100644 drivers/net/mscc_eswitch/felix_switch.c
drivers/net/fsl_enetc.h +5 -0
index 9a36cdad80..29e7781b5e 100644
@@ -200,6 +200,11 @@ struct enetc_priv {
 /* PCS replicator block for USXGMII */
 #define ENETC_PCS_DEVAD_REPL		0x1f
 
+#define ENETC_PCS_REPL_LINK_TIMER_1	0x12
+#define  ENETC_PCS_REPL_LINK_TIMER_1_DEF	0x0003
+#define ENETC_PCS_REPL_LINK_TIMER_2	0x13
+#define  ENETC_PCS_REPL_LINK_TIMER_2_DEF	0x06a0
+
 /* ENETC external MDIO registers */
 #define ENETC_MDIO_BASE		0x1c00
 #define ENETC_MDIO_CFG		0x00
drivers/net/mscc_eswitch/Kconfig +8 -0
index 80dd22f98b..11fb08edaa 100644
@@ -36,3 +36,11 @@ config MSCC_SERVAL_SWITCH
 	select PHYLIB
 	help
 	  This driver supports the Serval network switch device.
+
+config MSCC_FELIX_SWITCH
+	bool "Felix switch driver"
+	depends on DM_DSA && DM_PCI
+	select FSL_ENETC
+	help
+	  This driver supports the Ethernet switch integrated in LS1028A NXP
+	  SoC.
drivers/net/mscc_eswitch/Makefile +0 -0
index d583fe9fc4..22342ed114 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_MSCC_LUTON_SWITCH) += luton_switch.o

mscc_xfer.o mscc_mac_table.o m
obj-$(CONFIG_MSCC_JR2_SWITCH) += jr2_switch.o mscc_xfer.o mscc_miim.o obj-$(CONFIG_MSCC_SERVALT_SWITCH) += servalt_switch.o mscc_xfer.o
mscc_miim.o
obj-$(CONFIG_MSCC_SERVAL_SWITCH) += serval_switch.o mscc_xfer.o
mscc_mac_table.o mscc_miim.o

drivers/net/mscc_eswitch/Makefile +1 -0
+obj-$(CONFIG_MSCC_FELIX_SWITCH) += felix_switch.o
drivers/net/mscc_eswitch/felix_switch.c new file +8 -0
new file mode 100644
index 0000000000..8df0e8e4b7
@@ -0,0 +1,453 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Felix Ethernet switch driver
+ * Copyright 2018-2019 NXP
+ */
+
+/*
+ * This driver is used for the Ethernet switch integrated into LS1028A 

NXP.
+ * Felix switch is derived from Microsemi Ocelot but there are several NXP
+ * adaptations that makes the two U-Boot drivers largely incompatible.
+ *
+ * Felix on LS1028A has 4 front panel ports and two internal ports, connected
+ * to ENETC interfaces. We're using one of the ENETC interfaces to push traffic
+ * into the switch. Injection/extraction headers are used to identify
+ * egress/ingress ports in the switch for Tx/Rx.
+ */

drivers/net/mscc_eswitch/felix_switch.c new file +13 -0
+
+#include <common.h>
+#include <dsa.h>
+#include <asm/io.h>
+#include <pci.h>
+#include <miiphy.h>
+
+/* defines especially around PCS are reused from enetc */
+#include "../fsl_enetc.h"
+
+#define PCI_DEVICE_ID_FELIX_ETHSW	0xEEF0
+
+/* Felix has in fact 6 ports, but we don't use the last internal one 

*/

drivers/net/mscc_eswitch/felix_switch.c new file +17 -0
+#define FELIX_PORT_COUNT		5
+/* Front panel port mask */
+#define FELIX_FP_PORT_MASK		0xf
+
+/* Register map for BAR4 */
+#define FELIX_SYS			0x010000
+#define FELIX_ES0			0x040000
+#define FELIX_IS1			0x050000
+#define FELIX_IS2			0x060000
+#define FELIX_GMII(port)		(0x100000 + (port) * 0x10000)
+#define FELIX_QSYS			0x200000
+
+#define FELIX_SYS_SYSTEM		(FELIX_SYS + 0x00000E00)
+#define  FELIX_SYS_SYSTEM_EN		BIT(0)
+#define FELIX_SYS_RAM_CTRL		(FELIX_SYS + 0x00000F24)
+#define  FELIX_SYS_RAM_CTRL_INIT	BIT(1)
+#define FELIX_SYS_SYSTEM_PORT_MODE(a)	(FELIX_SYS_SYSTEM + 0xC + (a) * 

4)

drivers/net/mscc_eswitch/felix_switch.c new file +17 -0
+#define  FELIX_SYS_SYSTEM_PORT_MODE_CPU	0x0000001e
+
+#define FELIX_ES0_TCAM_CTRL		(FELIX_ES0 + 0x000003C0)
+#define  FELIX_ES0_TCAM_CTRL_EN		BIT(0)
+#define FELIX_IS1_TCAM_CTRL		(FELIX_IS1 + 0x000003C0)
+#define  FELIX_IS1_TCAM_CTRL_EN		BIT(0)
+#define FELIX_IS2_TCAM_CTRL		(FELIX_IS2 + 0x000003C0)
+#define  FELIX_IS2_TCAM_CTRL_EN		BIT(0)
+
+#define FELIX_GMII_CLOCK_CFG(port)	(FELIX_GMII(port) + 0x00000000)
+#define  FELIX_GMII_CLOCK_CFG_LINK_1G	1
+#define  FELIX_GMII_CLOCK_CFG_LINK_100M	2
+#define  FELIX_GMII_CLOCK_CFG_LINK_10M	3
+#define FELIX_GMII_MAC_ENA_CFG(port)	(FELIX_GMII(port) + 0x0000001C)
+#define  FELIX_GMII_MAX_ENA_CFG_TX	BIT(0)
+#define  FELIX_GMII_MAX_ENA_CFG_RX	BIT(4)
+#define FELIX_GMII_MAC_IFG_CFG(port)	(FELIX_GMII(port) + 0x0000001C + 

0x14)

drivers/net/mscc_eswitch/felix_switch.c new file +29 -0
+#define  FELIX_GMII_MAC_IFG_CFG_DEF	0x515
+
+#define FELIX_QSYS_SYSTEM		(FELIX_QSYS + 0x0000F460)
+#define FELIX_QSYS_SYSTEM_SW_PORT_MODE(a)	\
+					(FELIX_QSYS_SYSTEM + 0x20 + (a) * 4)
+#define  FELIX_QSYS_SYSTEM_SW_PORT_ENA		BIT(14)
+#define  FELIX_QSYS_SYSTEM_SW_PORT_LOSSY	BIT(9)
+#define  FELIX_QSYS_SYSTEM_SW_PORT_SCH(a)	(((a) & 0x3800) << 11)
+#define FELIX_QSYS_SYSTEM_EXT_CPU_CFG	(FELIX_QSYS_SYSTEM + 0x80)
+#define  FELIX_QSYS_SYSTEM_EXT_CPU_PORT(a)	(((a) & 0xf) << 8 | 0xff)
+
+/* internal MDIO in BAR0 */
+#define FELIX_PM_IMDIO_BASE		0x8030
+
+/* Serdes block on LS1028A */
+#define FELIX_SERDES_BASE		0x1ea0000L
+#define FELIX_SERDES_LNATECR0(lane)	(FELIX_SERDES_BASE + 0x818 + \
+					 (lane) * 0x40)
+#define  FELIX_SERDES_LNATECR0_ADPT_EQ	0x00003000
+#define FELIX_SERDES_SGMIICR1(lane)	(FELIX_SERDES_BASE + 0x1804 + \
+					 (lane) * 0x10)
+#define  FELIX_SERDES_SGMIICR1_SGPCS	BIT(11)
+#define  FELIX_SERDES_SGMIICR1_MDEV(a)	(((a) & 0x1f) << 27)
+
+#define FELIX_PCS_CTRL			0
+#define  FELIX_PCS_CTRL_RST		BIT(15)
+
+/*
+ * The long prefix format used here contains two dummy MAC addresses, 

a magic
+ * value in place of a VLAN tag followed by the extraction/injection header and
+ * the original L2 frame. Out of all this we only use the port ID.
+ */

drivers/net/mscc_eswitch/felix_switch.c new file +5 -0
+
+#define FELIX_DSA_TAG_LEN		sizeof(struct felix_dsa_tag)
+#define FELIX_DSA_TAG_MAGIC		0x0a008088
+#define FELIX_DSA_TAG_INJ_PORT		7
+#define  FELIX_DSA_TAG_INJ_PORT_SET(a)	(0x1 << ((a) & 

FELIX_FP_PORT_MASK))

drivers/net/mscc_eswitch/felix_switch.c new file +18 -0
+#define FELIX_DSA_TAG_EXT_PORT		10
+#define  FELIX_DSA_TAG_EXT_PORT_GET(a)	((a) >> 3)
+
+struct felix_dsa_tag {
+	uchar d_mac[6];
+	uchar s_mac[6];
+	u32   magic;
+	uchar meta[16];
+};
+
+struct felix_priv {
+	void *regs_base;
+	void *imdio_base;
+	struct mii_dev imdio;
+	struct udevice *port[FELIX_PORT_COUNT];
+};
+
+/* MDIO wrappers, we're using these to drive internal MDIO to get to 

serdes */
+static int felix_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)

drivers/net/mscc_eswitch/felix_switch.c new file +8 -0
+{
+	struct enetc_mdio_priv priv;
+
+	priv.regs_base = bus->priv;
+	return enetc_mdio_read_priv(&priv, addr, devad, reg);
+}
+
+static int felix_mdio_write(struct mii_dev *bus, int addr, int devad, 

int reg,

drivers/net/mscc_eswitch/felix_switch.c new file +10 -0
+			    u16 val)
+{
+	struct enetc_mdio_priv priv;
+
+	priv.regs_base = bus->priv;
+	return enetc_mdio_write_priv(&priv, addr, devad, reg, val);
+}
+
+/* set up serdes for SGMII */
+static int felix_init_sgmii(struct udevice *dev, int port, int 

if_type)

drivers/net/mscc_eswitch/felix_switch.c new file +17 -0
+{
+	struct felix_priv *priv = dev_get_priv(dev);
+	bool is2500 = false;
+	u16 reg;
+
+	/* set up PCS lane address */
+	out_le32(FELIX_SERDES_SGMIICR1(port), FELIX_SERDES_SGMIICR1_SGPCS |
+		 FELIX_SERDES_SGMIICR1_MDEV(port));
+
+	if (!priv->imdio.priv)
+		return 0;
+
+	if (if_type == PHY_INTERFACE_MODE_SGMII_2500)
+		is2500 = true;
+
+	/*
+	 * Set to SGMII mode, for 1Gbps enable AN, for 2.5Gbps set fixed 

speed.

drivers/net/mscc_eswitch/felix_switch.c new file +1 -0
+	 * Although fixed speed is 1Gbps, we could be running at 2.5Gbps 

based

drivers/net/mscc_eswitch/felix_switch.c new file +1 -0
+	 * on PLL configuration.  Setting 1G for 2.5G here is counter 

intuitive

drivers/net/mscc_eswitch/felix_switch.c new file +4 -0
+	 * but intentional.
+	 */
+	reg = ENETC_PCS_IF_MODE_SGMII;
+	reg |= is2500 ? ENETC_PCS_IF_MODE_SPEED_1G : 

ENETC_PCS_IF_MODE_SGMII_AN;

drivers/net/mscc_eswitch/felix_switch.c new file +115 -0
+	felix_mdio_write(&priv->imdio, port, MDIO_DEVAD_NONE,
+			 ENETC_PCS_IF_MODE, reg);
+
+	/* Dev ability - SGMII */
+	felix_mdio_write(&priv->imdio, port, MDIO_DEVAD_NONE,
+			 ENETC_PCS_DEV_ABILITY, ENETC_PCS_DEV_ABILITY_SGMII);
+
+	/* Adjust link timer for SGMII */
+	felix_mdio_write(&priv->imdio, port, MDIO_DEVAD_NONE,
+			 ENETC_PCS_LINK_TIMER1, ENETC_PCS_LINK_TIMER1_VAL);
+	felix_mdio_write(&priv->imdio, port, MDIO_DEVAD_NONE,
+			 ENETC_PCS_LINK_TIMER2, ENETC_PCS_LINK_TIMER2_VAL);
+
+	reg = ENETC_PCS_CR_DEF_VAL;
+	reg |= is2500 ? ENETC_PCS_CR_RST : ENETC_PCS_CR_RESET_AN;
+	/* restart PCS AN */
+	felix_mdio_write(&priv->imdio, port, MDIO_DEVAD_NONE,
+			 ENETC_PCS_CR, reg);
+
+	return 0;
+}
+
+/* set up MAC and serdes for (Q)SXGMII */
+static int felix_init_sxgmii(struct udevice *dev, int port)
+{
+	struct felix_priv *priv = dev_get_priv(dev);
+	int to = 1000;
+
+	/* set up transit equalization control on serdes lane */
+	out_le32(FELIX_SERDES_LNATECR0(1), FELIX_SERDES_LNATECR0_ADPT_EQ);
+
+	if (!priv->imdio.priv)
+		return 0;
+
+	/*reset lane */
+	felix_mdio_write(&priv->imdio, port, MDIO_MMD_PCS, FELIX_PCS_CTRL,
+			 FELIX_PCS_CTRL_RST);
+	while (felix_mdio_read(&priv->imdio, port, MDIO_MMD_PCS,
+			       FELIX_PCS_CTRL) & FELIX_PCS_CTRL_RST &&
+			--to) {
+		mdelay(10);
+	}
+	if (felix_mdio_read(&priv->imdio, port, MDIO_MMD_PCS,
+			    FELIX_PCS_CTRL) & FELIX_PCS_CTRL_RST)
+		dev_dbg(port, "PCS reset time-out\n");
+
+	/* Dev ability - SXGMII */
+	felix_mdio_write(&priv->imdio, port, ENETC_PCS_DEVAD_REPL,
+			 ENETC_PCS_DEV_ABILITY, ENETC_PCS_DEV_ABILITY_SXGMII);
+
+	/* Restart PCS AN */
+	felix_mdio_write(&priv->imdio, port, ENETC_PCS_DEVAD_REPL,
+			 ENETC_PCS_CR,
+			 ENETC_PCS_CR_RST | ENETC_PCS_CR_RESET_AN);
+	felix_mdio_write(&priv->imdio, port, ENETC_PCS_DEVAD_REPL,
+			 ENETC_PCS_REPL_LINK_TIMER_1,
+			 ENETC_PCS_REPL_LINK_TIMER_1_DEF);
+	felix_mdio_write(&priv->imdio, port, ENETC_PCS_DEVAD_REPL,
+			 ENETC_PCS_REPL_LINK_TIMER_2,
+			 ENETC_PCS_REPL_LINK_TIMER_2_DEF);
+
+	return 0;
+}
+
+/* Apply protocol specific configuration to MAC, serdes as needed */
+static void felix_start_pcs(struct udevice *dev, int port)
+{
+	struct dsa_perdev_platdata *platdata = dev->platdata;
+	struct felix_priv *priv = dev_get_priv(dev);
+	const char *if_str;
+	int if_type;
+
+	if_type = PHY_INTERFACE_MODE_NONE;
+
+	priv->imdio.read = felix_mdio_read;
+	priv->imdio.write = felix_mdio_write;
+	priv->imdio.priv = priv->imdio_base + FELIX_PM_IMDIO_BASE;
+	strncpy(priv->imdio.name, dev->name, MDIO_NAME_LEN);
+
+	if_str = ofnode_read_string(platdata->port[port].node, "phy-mode");
+	if (if_str)
+		if_type = phy_get_interface_by_name(if_str);
+	else
+		dev_dbg(port,
+			"phy-mode property not found, defaulting to NONE\n");
+	if (if_type < 0)
+		if_type = PHY_INTERFACE_MODE_NONE;
+
+	switch (if_type) {
+	case PHY_INTERFACE_MODE_SGMII:
+	case PHY_INTERFACE_MODE_SGMII_2500:
+	case PHY_INTERFACE_MODE_QSGMII:
+		felix_init_sgmii(dev, port, if_type);
+		break;
+	case PHY_INTERFACE_MODE_XGMII:
+	case PHY_INTERFACE_MODE_XFI:
+	case PHY_INTERFACE_MODE_USXGMII:
+		felix_init_sxgmii(dev, port);
+		break;
+	}
+}
+
+void felix_init(struct udevice *dev)
+{
+	struct dsa_perdev_platdata *platdata = dev->platdata;
+	struct felix_priv *priv = dev_get_priv(dev);
+	int supported, to = 100, port;
+	void *base = priv->regs_base;
+	struct phy_device *phy;
+
+	dev_dbg(dev, "trying to set up L2 switch\n");
+
+	/* Init core memories */
+	out_le32(base + FELIX_SYS_RAM_CTRL, FELIX_SYS_RAM_CTRL_INIT);
+	while (in_le32(base + FELIX_SYS_RAM_CTRL) & FELIX_SYS_RAM_CTRL_INIT 

&&

drivers/net/mscc_eswitch/felix_switch.c new file +100 -0
+	       --to)
+		udelay(10);
+	if (in_le32(base + FELIX_SYS_RAM_CTRL) & FELIX_SYS_RAM_CTRL_INIT)
+		dev_dbg(dev, "Time-out waiting for switch memories\n");
+
+	/* Start switch core, set up ES0, IS1, IS2 */
+	out_le32(base + FELIX_SYS_SYSTEM, FELIX_SYS_SYSTEM_EN);
+	out_le32(base + FELIX_ES0_TCAM_CTRL, FELIX_ES0_TCAM_CTRL_EN);
+	out_le32(base + FELIX_IS1_TCAM_CTRL, FELIX_IS1_TCAM_CTRL_EN);
+	out_le32(base + FELIX_IS2_TCAM_CTRL, FELIX_IS2_TCAM_CTRL_EN);
+	udelay(20);
+
+	supported = PHY_GBIT_FEATURES | SUPPORTED_2500baseX_Full;
+
+	for (port = 0; port < FELIX_PORT_COUNT; port++) {
+		/* Set up MAC registers */
+		out_le32(base + FELIX_GMII_CLOCK_CFG(port),
+			 FELIX_GMII_CLOCK_CFG_LINK_1G);
+
+		out_le32(base + FELIX_GMII_MAC_IFG_CFG(port),
+			 FELIX_GMII_MAC_IFG_CFG_DEF);
+
+		felix_start_pcs(dev, port);
+
+		phy = platdata->port[port].phy;
+		if (phy) {
+			phy->supported &= supported;
+			phy->advertising &= supported;
+			phy_config(phy);
+		}
+	}
+
+	/* set up CPU port */
+	out_le32(base + FELIX_QSYS_SYSTEM_EXT_CPU_CFG,
+		 FELIX_QSYS_SYSTEM_EXT_CPU_PORT(platdata->cpu_port));
+	out_le32(base + FELIX_SYS_SYSTEM_PORT_MODE(platdata->cpu_port),
+		 FELIX_SYS_SYSTEM_PORT_MODE_CPU);
+}
+
+static int felix_bind(struct udevice *dev)
+{
+	struct dsa_perdev_platdata *pdata = dev->platdata;
+
+	pdata->num_ports = FELIX_PORT_COUNT;
+	pdata->headroom = FELIX_DSA_TAG_LEN;
+
+	return 0;
+}
+
+/*
+ * Probe Felix:
+ * - enable the PCI function
+ * - map BAR 4
+ * - init switch core and port registers
+ */
+static int felix_probe(struct udevice *dev)
+{
+	struct felix_priv *priv = dev_get_priv(dev);
+
+	if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) {
+		dev_dbg(dev, "switch disabled\n");
+		return -ENODEV;
+	}
+
+	priv->imdio_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, 0);
+	if (!priv->imdio_base) {
+		dev_dbg(dev, "failed to map BAR0\n");
+		return -EINVAL;
+	}
+
+	priv->regs_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_4, 0);
+	if (!priv->regs_base) {
+		dev_dbg(dev, "failed to map BAR4\n");
+		return -EINVAL;
+	}
+
+	/* register internal MDIO for debug */
+	if (!miiphy_get_dev_by_name(dev->name)) {
+		struct mii_dev *mii_bus;
+
+		mii_bus = mdio_alloc();
+		mii_bus->read = felix_mdio_read;
+		mii_bus->write = felix_mdio_write;
+		mii_bus->priv = priv->imdio_base + FELIX_PM_IMDIO_BASE;
+		strncpy(mii_bus->name, dev->name, MDIO_NAME_LEN);
+		mdio_register(mii_bus);
+	}
+
+	dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY);
+
+	/* set up registers */
+	felix_init(dev);
+
+	return 0;
+}
+
+static int felix_port_enable(struct udevice *dev, int port,
+			     struct phy_device *phy)
+{
+	struct felix_priv *priv = dev_get_priv(dev);

drivers/net/mscc_eswitch/felix_switch.c line 385

Quoted 10 lines
drivers/net/mscc_eswitch/felix_switch.c new file +10 -0
+	void *base = priv->regs_base;
+
+	out_le32(base + FELIX_GMII_MAC_ENA_CFG(port),
+		 FELIX_GMII_MAX_ENA_CFG_TX | FELIX_GMII_MAX_ENA_CFG_RX);
+
+	out_le32(base + FELIX_QSYS_SYSTEM_SW_PORT_MODE(port),
+		 FELIX_QSYS_SYSTEM_SW_PORT_ENA |
+		 FELIX_QSYS_SYSTEM_SW_PORT_LOSSY |
+		 FELIX_QSYS_SYSTEM_SW_PORT_SCH(1));
+

if (phy)

Quoted 71 lines
drivers/net/mscc_eswitch/felix_switch.c new file +24 -0
+	phy_startup(phy);
+	return 0;
+}
+
+static void felix_port_disable(struct udevice *dev, int port,
+			       struct phy_device *phy)
+{
+	struct felix_priv *priv = dev_get_priv(dev);
+	void *base = priv->regs_base;
+
+	out_le32(base + FELIX_GMII_MAC_ENA_CFG(port), 0);
+
+	out_le32(base + FELIX_QSYS_SYSTEM_SW_PORT_MODE(port),
+		 FELIX_QSYS_SYSTEM_SW_PORT_LOSSY |
+		 FELIX_QSYS_SYSTEM_SW_PORT_SCH(1));
+
+	/*
+	 * we don't call phy_shutdown here to avoind waiting next time we use
+	 * the port, but the downside is that remote side will think we're
+	 * actively processing traffic although we are not.
+	 */
+}
+
+static int felix_xmit(struct udevice *dev, int port, void *packet, int 

length)

drivers/net/mscc_eswitch/felix_switch.c new file +10 -0
+{
+	struct felix_dsa_tag *tag = packet;
+
+	tag->magic = FELIX_DSA_TAG_MAGIC;
+	tag->meta[FELIX_DSA_TAG_INJ_PORT] = FELIX_DSA_TAG_INJ_PORT_SET(port);
+
+	return 0;
+}
+
+static int felix_rcv(struct udevice *dev, int *port, void *packet, int 

length)

drivers/net/mscc_eswitch/felix_switch.c new file +7 -0
+{
+	struct felix_dsa_tag *tag = packet;
+
+	if (tag->magic != FELIX_DSA_TAG_MAGIC)
+		return -EINVAL;
+
+	*port = 

FELIX_DSA_TAG_EXT_PORT_GET(tag->meta[FELIX_DSA_TAG_EXT_PORT]);

drivers/net/mscc_eswitch/felix_switch.c new file +27 -0
+
+	return 0;
+}
+
+static const struct dsa_ops felix_dsa_ops = {
+	.port_enable  = felix_port_enable,
+	.port_disable = felix_port_disable,
+	.xmit         = felix_xmit,
+	.rcv          = felix_rcv,
+};
+
+U_BOOT_DRIVER(felix_ethsw) = {
+	.name	= "felix-switch",
+	.id	= UCLASS_DSA,
+	.bind	= felix_bind,
+	.probe	= felix_probe,
+	.ops    = &felix_dsa_ops,
+	.priv_auto_alloc_size = sizeof(struct felix_priv),
+	.platdata_auto_alloc_size = sizeof(struct eth_pdata),
+};
+
+static struct pci_device_id felix_ethsw_ids[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_FELIX_ETHSW) },
+	{}
+};
+
+U_BOOT_PCI_DEVICE(felix_ethsw, felix_ethsw_ids);
#6 lore raw

PATCH 5/6 arm: dts: ls1028a: adds Ethernet switch node and its dependencies

In reply to Alex Marginean

The definition follows the DSA binding in kernel and describes the switch, its ports and PHYs.
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028, it is not used in U-Boot and was disabled.

---
 arch/arm/dts/fsl-ls1028a-rdb.dts | 36 ++++++++++++++++++++++++++++
 arch/arm/dts/fsl-ls1028a.dtsi    | 41 +++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 1 deletion(-)
arch/arm/dts/fsl-ls1028a-rdb.dts +36 -0
index 3d5e8ade21..700fc067a4 100644
@@ -114,9 +114,45 @@
 	phy-handle = <&rdb_phy0>;
 };
 
+&ethsw_ports {
+	port at 0 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy0>;
+	};
+	port at 1 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy1>;
+	};
+	port at 2 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy2>;
+	};
+	port at 3 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy3>;
+	};
+};
+
 &mdio0 {
 	status = "okay";
 	rdb_phy0: phy at 2 {
 		reg = <2>;
 	};
+
+	sw_phy0: phy at 10 {
+		reg = <0x10>;
+	};
+	sw_phy1: phy at 11 {
+		reg = <0x11>;
+	};
+	sw_phy2: phy at 12 {
+		reg = <0x12>;
+	};
+	sw_phy3: phy at 13 {
+		reg = <0x13>;
+	};
 };
arch/arm/dts/fsl-ls1028a.dtsi +40 -1

49 lines not on this page · raw message

Signature · 1 line
2.17.1
#7 lore raw

PATCH 5/6 arm: dts: ls1028a: adds Ethernet switch node and its dependencies

Am 2019-11-22 02:36, schrieb Alex Marginean:

Quoted 5 lines

The definition follows the DSA binding in kernel and describes the switch,
its ports and PHYs.
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028, it is

nitpicking.. LS1028A

Quoted 1 line

not used in U-Boot and was disabled.

it should be checked that the connected enetc port should be enabled. otherwise this driver goes awry.

[snip]

#8 lore raw

PATCH 5/6 arm: dts: ls1028a: adds Ethernet switch node and its dependencies

Hi Michael,

Quoted 6 lines · Michael Walle

Am 2019-11-22 02:36, schrieb Alex Marginean:

Quoted 4 lines

The definition follows the DSA binding in kernel and describes the switch,
its ports and PHYs.
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028, it is

Quoted 7 lines

nitpicking.. LS1028A

Quoted 1 line

not used in U-Boot and was disabled.

it should be checked that the connected enetc port should be enabled. otherwise this driver goes awry.

On LS1028A if mater Eth is disabled (ENETC PF2) there is a crash, I assume that's what you bumped into. From the looks of it that's caused by a hardware issue. For others reading this, the issue is making PCI PF5 (the switch) unable to use its internal MDIO registers if PF2 (master Eth) is disabled.
I don't think I want to have switch driver code check on the ENETC functions, this should end up in a SoC erratum with the recommendation to have PF2 enabled when using the switch.

On other platforms having a master Eth disabled means traffic through the switch won't work, but should not crash U-Boot either, uclass code seems to be fine in that regard.

Thanks for the review and for the comments, I'll send a v2 for this series.

Alex

Quoted 6 lines

[snip]
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#9 lore raw

PATCH 5/6 arm: dts: ls1028a: adds Ethernet switch node and its dependencies

In reply to Alex Marginean

Hi,

sorry for the second mail. I've missed something. See below.

Am 2019-11-22 02:36, schrieb Alex Marginean:

Quoted 70 lines

The definition follows the DSA binding in kernel and describes the switch,
its ports and PHYs.
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028, it is
not used in U-Boot and was disabled.

---
 arch/arm/dts/fsl-ls1028a-rdb.dts | 36 ++++++++++++++++++++++++++++
 arch/arm/dts/fsl-ls1028a.dtsi    | 41 +++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 1 deletion(-)
arch/arm/dts/fsl-ls1028a-rdb.dts +36 -0
index 3d5e8ade21..700fc067a4 100644
@@ -114,9 +114,45 @@
 	phy-handle = <&rdb_phy0>;
 };
 
+&ethsw_ports {
+	port at 0 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy0>;
+	};
+	port at 1 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy1>;
+	};
+	port at 2 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy2>;
+	};
+	port at 3 {
+		status = "okay";
+		phy-mode = "qsgmii";
+		phy-handle = <&sw_phy3>;
+	};
+};
+
 &mdio0 {
 	status = "okay";
 	rdb_phy0: phy at 2 {
 		reg = <2>;
 	};
+
+	sw_phy0: phy at 10 {
+		reg = <0x10>;
+	};
+	sw_phy1: phy at 11 {
+		reg = <0x11>;
+	};
+	sw_phy2: phy at 12 {
+		reg = <0x12>;
+	};
+	sw_phy3: phy at 13 {
+		reg = <0x13>;
+	};
 };
arch/arm/dts/fsl-ls1028a.dtsi +0 -0
index 43a154e8e7..a442fba4d0 100644

arch/arm/dts/fsl-ls1028a.dtsi line 144

Quoted 9 lines
arch/arm/dts/fsl-ls1028a.dtsi +6 -0
@@ -136,9 +136,48 @@
 			reg = <0x000300 0 0 0 0>;
 			status = "disabled";
 		};
+		ethsw: pci at 0,5 {
+			#address-cells=<0>;
+			#size-cells=<1>;
+			reg = <0x000500 0 0 0 0>;
+
+			ethsw_ports: ports {

#address-cells=<1>;
#size-cells=<0>;

Quoted 40 lines
arch/arm/dts/fsl-ls1028a.dtsi +34 -1
+				port at 0 {
+					reg = <0>;
+					status = "disabled";
+					label = "swp0";
+				};
+				port at 1 {
+					reg = <1>;
+					status = "disabled";
+					label = "swp1";
+				};
+				port at 2 {
+					reg = <2>;
+					status = "disabled";
+					label = "swp2";
+				};
+				port at 3 {
+					reg = <3>;
+					status = "disabled";
+					label = "swp3";
+				};
+				port at 4 {
+					reg = <4>;
+					phy-mode = "internal";
+					status = "okay";
+					ethernet = <&enetc2>;
+				};
+				port at 5 {
+					reg = <5>;
+					phy-mode = "internal";
+					status = "disabled";
+				};
+			};
+		};
 		enetc6: pci at 0,6 {
 			reg = <0x000600 0 0 0 0>;
-			status = "okay";
+			status = "disabled";
 			phy-mode = "internal";
 		};
 	};
#10 lore raw

PATCH 6/6 configs: ls1028a: enable the Ethernet switch driver in defconfig

In reply to Alex Marginean

The switch driver for LS1028A Ethernet switch is now compiled in for both LS1028A boards.

---
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 3 ++-
 configs/ls1028aqds_tfa_defconfig             | 3 ++-
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 3 ++-
 configs/ls1028ardb_tfa_defconfig             | 3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)
configs/ls1028aqds_tfa_SECURE_BOOT_defconfig +2 -1
index 713a088e42..931c78ab46 100644
@@ -49,8 +49,9 @@ CONFIG_PHY_ATHEROS=y
 CONFIG_PHY_VITESSE=y
 CONFIG_DM_ETH=y
 CONFIG_DM_MDIO=y
+CONFIG_DM_DSA=y
 CONFIG_E1000=y
-CONFIG_FSL_ENETC=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
configs/ls1028aqds_tfa_defconfig +2 -1
index b5eb872148..ad5c783e16 100644
@@ -52,8 +52,9 @@ CONFIG_PHY_ATHEROS=y
 CONFIG_PHY_VITESSE=y
 CONFIG_DM_ETH=y
 CONFIG_DM_MDIO=y
+CONFIG_DM_DSA=y
 CONFIG_E1000=y
-CONFIG_FSL_ENETC=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
configs/ls1028ardb_tfa_SECURE_BOOT_defconfig +2 -1
index dc07a0a4d7..e30fb96344 100644
@@ -48,9 +48,10 @@ CONFIG_PHY_ATHEROS=y
 CONFIG_PHY_VITESSE=y
 CONFIG_DM_ETH=y
 CONFIG_DM_MDIO=y
+CONFIG_DM_DSA=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
-CONFIG_FSL_ENETC=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
configs/ls1028ardb_tfa_defconfig +2 -1
index 644c5ac6bb..87e4fdd18e 100644
@@ -52,9 +52,10 @@ CONFIG_PHY_ATHEROS=y
 CONFIG_PHY_VITESSE=y
 CONFIG_DM_ETH=y
 CONFIG_DM_MDIO=y
+CONFIG_DM_DSA=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
-CONFIG_FSL_ENETC=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
Signature · 1 line
2.17.1
#11 lore raw

cover Introduce DSA Ethernet switch class and Felix driver

In reply to Alex Marginean
Quoted 129 lines · Alex Marginean

DSA stands for Distributed Switch Architecture and it is a subsystem introduced in the Linux kernel to support switches that:
- have an Ethernet link up to the CPU
- use some form of tagging to identify the source/destination port for Rx/Tx
- may be cascaded in tree-like structures.

DSA is described in depth here:
https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt

From the doc:

        Summarized, this is basically how DSA looks like from a network device
        perspective:


                    |---------------------------
                    | CPU network device (eth0)|
                    ----------------------------
                    | <tag added by switch     |
                    |                          |
                    |                          |
                    |        tag added by CPU> |
                |--------------------------------------------|
                | Switch driver                              |
                |--------------------------------------------|
                    ||        ||         ||
                |-------|  |-------|  |-------|
                | sw0p0 |  | sw0p1 |  | sw0p2 |
                |-------|  |-------|  |-------|

This patch set introduces a DSA class in U-Boot to support drivers of such switches. DSA drivers have to implement the following ops:
- enable/disable of switch ports,
- insert a tag in frames being transmitted, used by the switch to select the egress port,
- parse a tag in frames being received, used for Rx traffic.

DSA class code deals with presentation of switch ports as Ethernet interfaces, deals with the master Ethernet device for I/O and helps with parsing of the DT assuming the structure follows the DSA kernel binding.

Support for switch cascading is not included yet.

This patch set also introduces a driver for the Ethernet switch integrated into NXP LS1028A, called Felix. The switch has 4 front panel ports, I/O to/fom it is done though an ENETC Ethernet interface and meta-data is carried between the switch and the driver though an additional header pre-pended to the original frame.
Network commands like tftp can be used on these front panel ports. The ports are disabled unless used so they do not cause issues on network topologies that include loops.

Felix as seen on LS1028A RDB:
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
......

 dsa           0  [ + ]   felix-switch          |   |-- felix-switch
 eth           4  [ + ]   dsa-port              |   |   |-- swp0
 eth           5  [ + ]   dsa-port              |   |   |-- swp1
 eth           6  [ + ]   dsa-port              |   |   |-- swp2
 eth           7  [ + ]   dsa-port              |   |   `-- swp3

=> mdio list
......
10 - Vitesse VSC8514 <--> swp0
11 - Vitesse VSC8514 <--> swp1
12 - Vitesse VSC8514 <--> swp2
13 - Vitesse VSC8514 <--> swp3

=> tftp 80000000 test
Using swp2 device
TFTP from server 192.168.100.1; our IP address is 192.168.100.100 Filename 'test'.
Load address: 0x80000000
Loading: #################################################################

         #################################################################
         ########################################################
         6.8 MiB/s

done
Bytes transferred = 949880 (e7e78 hex)

This patch set replaces this previous submission of the Felix driver:
https://patchwork.ozlabs.org/project/uboot/list/?series=143126&state=*
and depends on:
https://patchwork.ozlabs.org/project/uboot/list/?series=142858
https://patchwork.ozlabs.org/project/uboot/list/?series=142879

Alex Marginean (6):
net: introduce DSA class for Ethernet switches
drivers: net: add a DSA sandbox driver
test: dm: add a simple unit test for DSA class
drivers: net: add Felix DSA switch driver
arm: dts: ls1028a: adds Ethernet switch node and its dependencies
configs: ls1028a: enable the Ethernet switch driver in defconfig

 arch/Kconfig                                 |   1 +
 arch/arm/dts/fsl-ls1028a-rdb.dts             |  36 ++
 arch/arm/dts/fsl-ls1028a.dtsi                |  41 +-
 arch/sandbox/dts/test.dts                    |  49 ++
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig |   3 +-
 configs/ls1028aqds_tfa_defconfig             |   3 +-
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig |   3 +-
 configs/ls1028ardb_tfa_defconfig             |   3 +-
 drivers/net/Kconfig                          |  21 +
 drivers/net/Makefile                         |   1 +
 drivers/net/dsa_sandbox.c                    | 272 +++++++++++
 drivers/net/fsl_enetc.h                      |   5 +
 drivers/net/mscc_eswitch/Kconfig             |   8 +
 drivers/net/mscc_eswitch/Makefile            |   1 +
 drivers/net/mscc_eswitch/felix_switch.c      | 453 +++++++++++++++++++
 include/configs/sandbox.h                    |   4 +
 include/dm/uclass-id.h                       |   1 +
 include/dsa.h                                | 132 ++++++
 net/Makefile                                 |   1 +
 net/dsa-uclass.c                             | 369 +++++++++++++++
 test/dm/Makefile                             |   1 +
 test/dm/dsa.c                                |  58 +++
 test/dm/test-fdt.c                           |   2 +-
 23 files changed, 1462 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/dsa_sandbox.c
 create mode 100644 drivers/net/mscc_eswitch/felix_switch.c
 create mode 100644 include/dsa.h
 create mode 100644 net/dsa-uclass.c
 create mode 100644 test/dm/dsa.c
Quoted 7 lines

--
2.17.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

CC ing the Linux DSA maintainers, who are probably interested in this.

Thanks,
-Vladimir

#12 lore raw

cover Introduce DSA Ethernet switch class and Felix driver

In reply to Alex Marginean

Am 2019-11-22 02:36, schrieb Alex Marginean:

Quoted 133 lines

DSA stands for Distributed Switch Architecture and it is a subsystem introduced
in the Linux kernel to support switches that:
- have an Ethernet link up to the CPU
- use some form of tagging to identify the source/destination port for Rx/Tx
- may be cascaded in tree-like structures.

DSA is described in depth here:
https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt

From the doc:

	Summarized, this is basically how DSA looks like from a network device
	perspective:


		    |---------------------------
		    | CPU network device (eth0)|
		    ----------------------------
		    | <tag added by switch     |
		    |                          |
		    |                          |
		    |        tag added by CPU> |
		|--------------------------------------------|
		| Switch driver				     |
		|--------------------------------------------|
		    ||        ||         ||
		|-------|  |-------|  |-------|
		| sw0p0 |  | sw0p1 |  | sw0p2 |
		|-------|  |-------|  |-------|

This patch set introduces a DSA class in U-Boot to support drivers of such
switches. DSA drivers have to implement the following ops:
- enable/disable of switch ports,
- insert a tag in frames being transmitted, used by the switch to select the
egress port,
- parse a tag in frames being received, used for Rx traffic.

DSA class code deals with presentation of switch ports as Ethernet interfaces,
deals with the master Ethernet device for I/O and helps with parsing of the DT
assuming the structure follows the DSA kernel binding.

Support for switch cascading is not included yet.

This patch set also introduces a driver for the Ethernet switch integrated into
NXP LS1028A, called Felix. The switch has 4 front panel ports, I/O to/fom it is
done though an ENETC Ethernet interface and meta-data is carried between the
switch and the driver though an additional header pre-pended to the original
frame.
Network commands like tftp can be used on these front panel ports. The ports
are disabled unless used so they do not cause issues on network topologies that
include loops.

Felix as seen on LS1028A RDB:
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
......

 dsa           0  [ + ]   felix-switch          |   |-- felix-switch
 eth           4  [ + ]   dsa-port              |   |   |-- swp0
 eth           5  [ + ]   dsa-port              |   |   |-- swp1
 eth           6  [ + ]   dsa-port              |   |   |-- swp2
 eth           7  [ + ]   dsa-port              |   |   `-- swp3

=> mdio list
......
10 - Vitesse VSC8514 <--> swp0 11 - Vitesse VSC8514 <--> swp1 12 - Vitesse VSC8514 <--> swp2 13 - Vitesse VSC8514 <--> swp3

=> tftp 80000000 test
Using swp2 device
TFTP from server 192.168.100.1; our IP address is 192.168.100.100 Filename 'test'.
Load address: 0x80000000
Loading:
#################################################################

#################################################################

         ########################################################
         6.8 MiB/s

done
Bytes transferred = 949880 (e7e78 hex)

This patch set replaces this previous submission of the Felix driver:
https://patchwork.ozlabs.org/project/uboot/list/?series=143126&state=*
and depends on:
https://patchwork.ozlabs.org/project/uboot/list/?series=142858
https://patchwork.ozlabs.org/project/uboot/list/?series=142879

Alex Marginean (6):
net: introduce DSA class for Ethernet switches
drivers: net: add a DSA sandbox driver
test: dm: add a simple unit test for DSA class
drivers: net: add Felix DSA switch driver
arm: dts: ls1028a: adds Ethernet switch node and its dependencies
configs: ls1028a: enable the Ethernet switch driver in defconfig

 arch/Kconfig                                 |   1 +
 arch/arm/dts/fsl-ls1028a-rdb.dts             |  36 ++
 arch/arm/dts/fsl-ls1028a.dtsi                |  41 +-
 arch/sandbox/dts/test.dts                    |  49 ++
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig |   3 +-
 configs/ls1028aqds_tfa_defconfig             |   3 +-
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig |   3 +-
 configs/ls1028ardb_tfa_defconfig             |   3 +-
 drivers/net/Kconfig                          |  21 +
 drivers/net/Makefile                         |   1 +
 drivers/net/dsa_sandbox.c                    | 272 +++++++++++
 drivers/net/fsl_enetc.h                      |   5 +
 drivers/net/mscc_eswitch/Kconfig             |   8 +
 drivers/net/mscc_eswitch/Makefile            |   1 +
 drivers/net/mscc_eswitch/felix_switch.c      | 453 +++++++++++++++++++
 include/configs/sandbox.h                    |   4 +
 include/dm/uclass-id.h                       |   1 +
 include/dsa.h                                | 132 ++++++
 net/Makefile                                 |   1 +
 net/dsa-uclass.c                             | 369 +++++++++++++++
 test/dm/Makefile                             |   1 +
Quoted 8 lines
 test/dm/dsa.c                                |  58 +++
 test/dm/test-fdt.c                           |   2 +-
 23 files changed, 1462 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/dsa_sandbox.c
 create mode 100644 drivers/net/mscc_eswitch/felix_switch.c
 create mode 100644 include/dsa.h
 create mode 100644 net/dsa-uclass.c
 create mode 100644 test/dm/dsa.c

For the patches affecting the real hardware: