Introduce DSA Ethernet switch class and Felix driver
Subsystems (3)
v2 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/sdone
Bytes transferred = 949880 (e7e78 hex)
Changes in v2:
- Don't use NULL PHY in Felix driver
- guard dsa.h with #ifndef __DSA__H__, somehow I missed that in v1
- added a TODO for setting master Eth in promiscuous mode
- Minor fixes in patch descriptions, API comments
- Added address/size-cells to LS1028A DT ports node
This patch set replaces v1:
https://patchwork.ozlabs.org/project/uboot/list/?series=144448
and depends on:
https://patchwork.ozlabs.org/project/uboot/list/?series=144907
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 | 44 +- 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 | 454 +++++++++++++++++++ include/configs/sandbox.h | 4 + include/dm/uclass-id.h | 1 + include/dsa.h | 140 ++++++ 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, 1474 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
PATCH v2 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 | 140 ++++++++++++++++ net/Makefile | 1 + net/dsa-uclass.c | 369 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 524 insertions(+) create mode 100644 include/dsa.h create mode 100644 net/dsa-uclass.c
drivers/net/Kconfig +13 -0
@@ -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
@@ -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 +140 -0
140 lines not on this page · raw message
net/Makefile +1 -0
@@ -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
PATCH v2 1/6 net: introduce DSA class for Ethernet switches
Hi Alex,
Quoted 8 lines · Alex Marginean
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.
Is it expected to eventually retrofit the other switch drivers that we have in U-Boot to use this?
Quoted 6 lines
Signed-off-by Alex Marginean <[email protected]>--- drivers/net/Kconfig | 13 ++ include/dm/uclass-id.h | 1 + include/dsa.h | 140 ++++++++++++++++
Please use include/net/dsa.h
Quoted 75 lines
net/Makefile | 1 + net/dsa-uclass.c | 369 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 524 insertions(+) create mode 100644 include/dsa.h create mode 100644 net/dsa-uclass.cdrivers/net/Kconfig +13
-0@@ -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 yinclude/dm/uclass-id.h +1
-0@@ -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 +27
-0@@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2019 NXP +*/ + +#ifndef __DSA_H__ +#define __DSA_H__ + +#include <common.h> +#include <dm.h> +#include <phy.h> + +/** +* DSA stands for Distributed Switch Architecture and it is infrastructure +* intended to support drivers for Switches that rely on an intermediary +* Ethernet device for I/O. These switches may support cascading allowing +* them to be arranged as a tree. +* DSA is documented in detail in the Linux kernel documentation under +* Documentation/networking/dsa/dsa.txt +* The network layout of such a switch is shown below: +* +* |--------------------------- +* | CPU network device (eth0)| +* ---------------------------- +* | <tag added by switch | +* | | +* | |
include/dsa.h line 37
Quoted 10 lines
include/dsa.h new file +10
-0+* | tag added by CPU> | +* |--------------------------------------------| +* | Switch driver | +* |--------------------------------------------| +* || || || +* |-------| |-------| |-------| +* | sw0p0 | | sw0p1 | | sw0p2 | +* |-------| |-------| |-------| +* +* In U-Boot the intent is to allow acces to front panel ports (shown at the
acces -> access
include/dsa.h line 39
Quoted 2 lines
include/dsa.h new file +2
-0+* bottom of the picture) though the master Ethernet port (eth0 in the picture). +* Front panel ports are presented as regular ethernet devices in U-Boot and
ethernet -> Ethernet
include/dsa.h line 51
Quoted 12 lines
include/dsa.h new file +12
-0+* they are expected to support the typical networking commands. +* In general DSA switches require the use of tags, extra headers added both by +* software on Tx and by the switch on Rx. These tags carry at a minimum port +* information and switch information for cascaded set-ups. +* In U-Boot these tags are inserted and parsed by the DSA switch driver, the +* class code helps with headroom/tailroom for the extra headers. +* +* TODO: +* - handle switch cascading, for now U-Boot only supports stand-alone switches. +* - put master Eth in promisc mode, this isn't needed right now but will be +* sooner or later. +*
Drop empty line
Quoted 89 lines
include/dsa.h new file +89
-0+*/ + +#define DSA_PORT_NAME_LENGTH 16 + +/* Maximum number of ports each DSA device can have */ +#define DSA_MAX_PORTS 12 +/* Used to size internal buffers, no support for jumbo yet */ +#define DSA_MAX_FRAME_SIZE 2048 + +/** +* struct dsa_ops - DSA operations +* +* @port_enable: Initialize a switch port for I/O +* @port_disable: Disable a port +* @xmit: Insert the DSA tag for transmission +* DSA drivers receive a copy of the packet with headroom and +* tailroom reserved and set to 0. +* Packet points to headroom and length is updated to include +* both headroom and tailroom +* @rcv: Process the DSA tag on reception +* Packet and length describe the frame as received from master +* including any additional headers +*/ +struct dsa_ops { +int (*port_enable)(struct udevice *dev,int port, +struct phy_device *phy); +void (*port_disable)(struct udevice *dev,int port, +struct phy_device *phy); +int (*xmit)(struct udevice *dev,int port,void *packet,int length); +int (*rcv)(struct udevice *dev,int *port,void *packet,int length); +}; + +#define dsa_get_ops (dev) ((struct dsa_ops *)(dev)->driver->ops) + +/** +* struct dsa_port_platdata - DSA port platform data +* +* @dev : Port u-device +* Uclass code sets this field for all ports +* @phy: PHY device associated with this port +* Uclass code sets this field for all ports except CPU port, based on +* DT information. It may be NULL. +* @node: Port DT node, if any. Uclass code sets this field. +* @index: Port index in the DSA switch, set by class code. +* @name: Name of the port Eth device. If a label property is present in the +* port DT node, it is used as name. Drivers can use custom names by +* populating this field, otherwise class code generates a default. +*/ +struct dsa_port_platdata { +struct udevice *dev; +struct phy_device *phy; +ofnode node; +int index; +char name[DSA_PORT_NAME_LENGTH ]; +}; + +/** +* struct dsa_perdev_platdata - Per-device platform data for DSA DM +* +* @num_ports: Number of ports the device has, must be <= DSA_MAX_PORTS +* All DSA drivers must set this at _bind +* @headroom: Size, in bytes, of headroom needed for the DSA tag +* All DSA drivers must set this at _bind or _probe +* @tailroom: Size, in bytes, of tailroom needed for the DSA tag +* DSA class code allocates headroom and tailroom on Tx before +* calling DSA driver xmit function +* All DSA drivers must set this at _bind or _probe +* @master_node: DT node of the master Ethernet. DT is optional so this may be +* null. +* @master_dev: Ethernet device to be used as master. Uclass code sets this +* based on DT information if present, otherwise drivers must set +* this field in _probe. +* @cpu_port: Index of switch port linked to master Ethernet. +* Uclass code sets this based on DT information if present, +* otherwise drivers must set this field in _bind. +* @port: per-port data +*/ +struct dsa_perdev_platdata { +int num_ports; +int headroom; +int tailroom; + +ofnode master_node; +struct udevice *master_dev; +int cpu_port; +struct dsa_port_platdata port[DSA_MAX_PORTS ]; +}; + +#endif /* __DSA_H__ */
[...]
PATCH v2 1/6 net: introduce DSA class for Ethernet switches
Hi Joe,
Quoted 13 lines · Joe Hershberger
Hi Alex,
Quoted 8 lines · Alex Marginean
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.
Quoted 2 lines
Is it expected to eventually retrofit the other switch drivers that we have in U-Boot to use this?
For now I would like to at least make sure that the uclass code allows that to happen. Longer term yes, it would be nice to get existing drivers converted. This is applicable to switches that rely on a master Eth device for I/O. The list should include switches that use DSA in kernel, of course:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/dsa
Some of these are under PHYs in U-Boot right now (like b53, mv88exxx), hooked up to the master Eth. This works, but comes with limitations, like this in b53 driver:
* The configuration determines which PHY ports to activate using the
* CONFIG_B53_PHY_PORTS bitmask. Set bit N will active port N and so on.
Having these drivers converted should come with some benefits:
- their DT nodes would be in sync with the kernel DSA bindings,
- users would have some run-time control over the switch ports used for I/O,
- driving PHYs of front panel ports comes more naturally with these ports being registered as eth devices.
There are other switches which don't fall under DSA, those that present some sort of direct I/O interface to the CPU and don't rely on a master Eth device. These switched may not follow DSA bindings, since they are not technically DSA. For them we could either have a more generic Eth switch class or just let the drivers register the switch device or the ports on the switch as Eth devices.
I'll send a v3 with fixes for the comments below.
Thanks!
Alex
Quoted 213 lines
Quoted 6 lines
Signed-off-by Alex Marginean <[email protected]>--- drivers/net/Kconfig | 13 ++ include/dm/uclass-id.h | 1 + include/dsa.h | 140 ++++++++++++++++Please use
include/net/dsa.hQuoted 75 lines
net/Makefile | 1 + net/dsa-uclass.c | 369 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 524 insertions(+)create mode 100644
include/dsa.h
create mode 100644net/dsa-uclass.cdrivers/net/Kconfig +13
-0@@ -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 yinclude/dm/uclass-id.h +1
-0@@ -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 +27
-0@@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2019 NXP +*/ + +#ifndef __DSA_H__ +#define __DSA_H__ + +#include <common.h> +#include <dm.h> +#include <phy.h> + +/** +* DSA stands for Distributed Switch Architecture and it is infrastructure +* intended to support drivers for Switches that rely on an intermediary +* Ethernet device for I/O. These switches may support cascading allowing +* them to be arranged as a tree. +* DSA is documented in detail in the Linux kernel documentation under +* Documentation/networking/dsa/dsa.txt +* The network layout of such a switch is shown below: +* +* |--------------------------- +* | CPU network device (eth0)| +* ---------------------------- +* | <tag added by switch | +* | | +* | | include/dsa.h line 37
Quoted 10 lines
include/dsa.h new file +10
-0+* | tag added by CPU> | +* |--------------------------------------------| +* | Switch driver | +* |--------------------------------------------| +* || || || +* |-------| |-------| |-------| +* | sw0p0 | | sw0p1 | | sw0p2 | +* |-------| |-------| |-------| +* +* In U-Boot the intent is to allow acces to front panel ports (shown at the acces -> access
include/dsa.h line 39
Quoted 2 lines
include/dsa.h new file +2
-0+* bottom of the picture) though the master Ethernet port (eth0 in the picture). +* Front panel ports are presented as regular ethernet devices in U-Boot and ethernet -> Ethernet
include/dsa.h line 51
Quoted 12 lines
include/dsa.h new file +12
-0+* they are expected to support the typical networking commands. +* In general DSA switches require the use of tags, extra headers added both by +* software on Tx and by the switch on Rx. These tags carry at a minimum port +* information and switch information for cascaded set-ups. +* In U-Boot these tags are inserted and parsed by the DSA switch driver, the +* class code helps with headroom/tailroom for the extra headers. +* +* TODO: +* - handle switch cascading, for now U-Boot only supports stand-alone switches. +* - put master Eth in promisc mode, this isn't needed right now but will be +* sooner or later. +* Drop empty line
Quoted 79 lines
include/dsa.h new file +79
-0+*/ + +#define DSA_PORT_NAME_LENGTH 16 + +/* Maximum number of ports each DSA device can have */ +#define DSA_MAX_PORTS 12 +/* Used to size internal buffers, no support for jumbo yet */ +#define DSA_MAX_FRAME_SIZE 2048 + +/** +* struct dsa_ops - DSA operations +* +* @port_enable: Initialize a switch port for I/O +* @port_disable: Disable a port +* @xmit: Insert the DSA tag for transmission +* DSA drivers receive a copy of the packet with headroom and +* tailroom reserved and set to 0. +* Packet points to headroom and length is updated to include +* both headroom and tailroom +* @rcv: Process the DSA tag on reception +* Packet and length describe the frame as received from master +* including any additional headers +*/ +struct dsa_ops { +int (*port_enable)(struct udevice *dev,int port, +struct phy_device *phy); +void (*port_disable)(struct udevice *dev,int port, +struct phy_device *phy); +int (*xmit)(struct udevice *dev,int port,void *packet,int length); +int (*rcv)(struct udevice *dev,int *port,void *packet,int length); +}; + +#define dsa_get_ops (dev) ((struct dsa_ops *)(dev)->driver->ops) + +/** +* struct dsa_port_platdata - DSA port platform data +* +* @dev : Port u-device +* Uclass code sets this field for all ports +* @phy: PHY device associated with this port +* Uclass code sets this field for all ports except CPU port, based on +* DT information. It may be NULL. +* @node: Port DT node, if any. Uclass code sets this field. +* @index: Port index in the DSA switch, set by class code. +* @name: Name of the port Eth device. If a label property is present in the +* port DT node, it is used as name. Drivers can use custom names by +* populating this field, otherwise class code generates a default. +*/ +struct dsa_port_platdata { +struct udevice *dev; +struct phy_device *phy; +ofnode node; +int index; +char name[DSA_PORT_NAME_LENGTH ]; +}; + +/** +* struct dsa_perdev_platdata - Per-device platform data for DSA DM +* +* @num_ports: Number of ports the device has, must be <= DSA_MAX_PORTS +* All DSA drivers must set this at _bind +* @headroom: Size, in bytes, of headroom needed for the DSA tag +* All DSA drivers must set this at _bind or _probe +* @tailroom: Size, in bytes, of tailroom needed for the DSA tag +* DSA class code allocates headroom and tailroom on Tx before +* calling DSA driver xmit function +* All DSA drivers must set this at _bind or _probe +* @master_node: DT node of the master Ethernet. DT is optional so this may be +* null. +* @master_dev: Ethernet device to be used as master. Uclass code sets this +* based on DT information if present, otherwise drivers must set +* this field in _probe. +* @cpu_port: Index of switch port linked to master Ethernet. +* Uclass code sets this based on DT information if present, +* otherwise drivers must set this field in _bind. +* @port: per-port data +*/ +struct dsa_perdev_platdata { +int num_ports;include/dsa.h line 140
Quoted 10 lines
include/dsa.h new file +10
-0+int headroom; +int tailroom; + +ofnode master_node; +struct udevice *master_dev; +int cpu_port; + struct dsa_port_platdata port[DSA_MAX_PORTS]; +}; + +#endif /* __DSA_H__ */ [...]
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v2 1/6 net: introduce DSA class for Ethernet switches
Quoted 42 lines · Alexandru Marginean
Hi Joe,
Quoted 16 lines · Joe Hershberger
Hi Alex,
Quoted 11 lines · Alex Marginean
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.Quoted 2 lines
Is it expected to eventually retrofit the other switch drivers that we have in U-Boot to use this?
For now I would like to at least make sure that the uclass code allows that to happen. Longer term yes, it would be nice to get existing drivers converted. This is applicable to switches that rely on a master Eth device for I/O. The list should include switches that use DSA in kernel, of course:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/dsaSome of these are under PHYs in U-Boot right now (like b53, mv88exxx), hooked up to the master Eth. This works, but comes with limitations, like this in b53 driver:
* The configuration determines which PHY ports to activate using the
*CONFIG_B53_PHY_PORTSbitmask. Set bit N will active port N and so on. Having these drivers converted should come with some benefits:
- their DT nodes would be in sync with the kernel DSA bindings,
- users would have some run-time control over the switch ports used for I/O,
- driving PHYs of front panel ports comes more naturally with these ports being registered as eth devices.
Quoted 6 lines
There are other switches which don't fall under DSA, those that present some sort of direct I/O interface to the CPU and don't rely on a master Eth device. These switched may not follow DSA bindings, since they are not technically DSA. For them we could either have a more generic Eth switch class or just let the drivers register the switch device or the ports on the switch as Eth devices.
The Device Tree binding for DSA is actually fairly generic within the 'ports' container node, if you omit the ethernet phandle, this still allows you to describe a multi-port Ethernet switch with the data path being contained solely within the switch node and not spread across a DSA master and a discrete switch. At least, this could be a starting point.
Signature · 1 line
Florian
PATCH v2 1/6 net: introduce DSA class for Ethernet switches
Quoted 52 lines · Florian Fainelli
Quoted 42 lines · Alexandru Marginean
Hi Joe,
Quoted 16 lines · Joe Hershberger
Hi Alex,
Quoted 11 lines · Alex Marginean
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.Quoted 2 lines
Is it expected to eventually retrofit the other switch drivers that we have in U-Boot to use this?
For now I would like to at least make sure that the uclass code allows that to happen. Longer term yes, it would be nice to get existing drivers converted. This is applicable to switches that rely on a master Eth device for I/O. The list should include switches that use DSA in kernel, of course:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/dsaSome of these are under PHYs in U-Boot right now (like b53, mv88exxx), hooked up to the master Eth. This works, but comes with limitations, like this in b53 driver:
* The configuration determines which PHY ports to activate using the
*CONFIG_B53_PHY_PORTSbitmask. Set bit N will active port N and so on.
Having these drivers converted should come with some benefits:
- their DT nodes would be in sync with the kernel DSA bindings,
- users would have some run-time control over the switch ports used for I/O,
- driving PHYs of front panel ports comes more naturally with these ports being registered as eth devices.Quoted 6 lines
There are other switches which don't fall under DSA, those that present some sort of direct I/O interface to the CPU and don't rely on a master Eth device. These switched may not follow DSA bindings, since they are not technically DSA. For them we could either have a more generic Eth switch class or just let the drivers register the switch device or the ports on the switch as Eth devices.
Quoted 6 lines
The Device Tree binding for DSA is actually fairly generic within the 'ports' container node, if you omit the ethernet phandle, this still allows you to describe a multi-port Ethernet switch with the data path being contained solely within the switch node and not spread across a DSA master and a discrete switch. At least, this could be a starting point.
It is, I don't disagree with that. My argument is DSA-like binding isn't enforced in kernel tree for non-DSA switches (is it?) and allowing U-Boot to use existing kernel DTs for non-DSA switches is a good thing.
Binding aside I still think DSA should be a class of its own in U-Boot. There are differences in the API between DSA ports and Eth devices and DSA uclass has the code dealing with master Eth, which is useless for non-DSA. I think this way the code and the interface to the drivers is simpler and more clear.
Alex
PATCH v2 2/6 drivers: net: add a DSA sandbox driver
In reply to Alex MargineanThe 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
@@ -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
@@ -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
PATCH v2 3/6 test: dm: add a simple unit test for DSA class
In reply to Alex MargineanThe 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 4/6 drivers: net: add Felix DSA switch driver
In reply to Alex MargineanThis 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 | 454 ++++++++++++++++++++++++ 4 files changed, 468 insertions(+) create mode 100644 drivers/net/mscc_eswitch/felix_switch.c
drivers/net/fsl_enetc.h +5 -0
@@ -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
@@ -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
@@ -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 +454 -0
454 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 5/6 arm: dts: ls1028a: adds Ethernet switch node and its dependencies
In reply to Alex MargineanThe 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 LS1028A, it is not used in U-Boot and was disabled.
--- arch/arm/dts/fsl-ls1028a-rdb.dts | 36 ++++++++++++++++++++++++++ arch/arm/dts/fsl-ls1028a.dtsi | 44 +++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-)
arch/arm/dts/fsl-ls1028a-rdb.dts +36 -0
@@ -114,9 +114,45 @@ phy-handle = <&rdb_phy0>; }; +ðsw_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 +43 -1
52 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 6/6 configs: ls1028a: enable the Ethernet switch driver in defconfig
In reply to Alex MargineanThe 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
@@ -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
@@ -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
@@ -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
@@ -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