Introduce DSA Ethernet switch class and Felix driver
Subsystems (5)
Vladimir Oltean
maintainerv4 cover Introduce DSA Ethernet switch class and Felix driver
From: Vladimir Oltean <[email protected]>
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
This patch set introduces a DSA class in U-Boot to support drivers of DSA 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.
In the sandbox environment, the DSA sandbox driver, the switch ports and master eth interface look like this:
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
[...]
eth 4 [ + ] eth_sandbox |-- dsa-test-eth dsa 0 [ + ] dsa_sandbox |-- dsa-test eth 5 [ + ] dsa-port | |-- lan0 eth 6 [ + ] dsa-port | `-- lan1
=> setenv ethact lan1
=> ping 1.2.3.5
Using lan1 device
host 1.2.3.5 is alive
=>
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/from 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
NOTE:
This patchset is a major rework of the dsa-class code since the last
submission from May 5th:
https://patchwork.ozlabs.org/project/uboot/cover/1588700588-8587-1-git-send-email-claudiu.manoil at nxp.com/ The basic concepts and data path operation (tagging) in the DSA class
code remain the same as in the initial patchset from Alex, however the
external API has been changed significantly (simplified), the driver
model integration has been improved to the point that the DSA class
code no longer needs to allocate extra memory internally (via malloc),
reduced memory footprint, internal state data moved from the external
API and internalized, cleaner external API, internal code reworked,
completely reworked DSA sandbox driver and unit tests for better coverage
and to integrate better with the eth sandbox driver and tests, etc.
v4:
- Implemented the TODO for having a phy_device on the CPU port.
- Enabled CONFIG_PHY_FIXED which is a new dependency of CONFIG_DM_DSA.
v3:
- Removed all infrastructure associated with dsa_foreach_port, which is no longer needed.
- Only inherit the DSA master's MAC address if the environment does not already have a specific MAC address that should be used for the DSA port.
- Be compatible with the new "ethernet-ports" container name which has been introduced in the Linux kernel as commit 85e05d263ed2 ("net: dsa:
of: Allow ethernet-ports as encapsulating node") in v5.9.
- Fixed the felix driver not getting its ports initialized, due to dsa_foreach_port() being actually unusable when called from the probe function of the DSA udevice - the eth port udevices are _not_ yet probed at that point. We are now initializing all ports from the .port_enable() callback of each eth udevice.
- Deleted the unit tests associated with the infrastructure for dsa_foreach_port, since that function no longer exists.
- Enabled the config options for the Kontron LS1028A board too.
v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB dts to minimize impact on other boards (and for improved flexibility).
Alex Marginean (3):
drivers: net: Add Felix DSA switch driver
arm: dts: ls1028a: Add Ethernet switch node and dependencies
configs: ls1028a: Enable the Ethernet switch driver in defconfig
Claudiu Manoil (2):
net: Introduce DSA class for Ethernet switches
sandbox: Add a DSA sandbox driver and unit test
Vladimir Oltean (2):
net: phy: fixed: support speeds of 2500 and 10000
net: phy: introduce fixed_phy_create for DSA CPU ports
arch/Kconfig | 1 + arch/arm/dts/fsl-ls1028a-rdb.dts | 64 +++ arch/arm/dts/fsl-ls1028a.dtsi | 56 ++- arch/sandbox/dts/test.dts | 48 ++ configs/kontron_sl28_defconfig | 3 + 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 | 24 + drivers/net/Makefile | 1 + drivers/net/dsa_sandbox.c | 179 +++++++ 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 | 414 ++++++++++++++++ drivers/net/phy/fixed.c | 3 +- drivers/net/phy/phy.c | 31 ++ include/configs/sandbox.h | 2 + include/dm/uclass-id.h | 1 + include/net.h | 6 + include/net/dsa.h | 165 +++++++ include/phy.h | 21 + net/Makefile | 1 + net/dsa-uclass.c | 478 +++++++++++++++++++ test/dm/Makefile | 1 + test/dm/dsa.c | 82 ++++ test/dm/eth.c | 10 +- 28 files changed, 1610 insertions(+), 7 deletions(-) create mode 100644 drivers/net/dsa_sandbox.c create mode 100644 drivers/net/mscc_eswitch/felix_switch.c create mode 100644 include/net/dsa.h create mode 100644 net/dsa-uclass.c create mode 100644 test/dm/dsa.c
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v4 1/7 net: phy: fixed: support speeds of 2500 and 10000
From: Vladimir Oltean <[email protected]>
Unlike the Linux fixed PHY driver, the one in U-Boot does not attempt to emulate the clause 22 register set of a gigabit copper PHY driver through the swphy framework. Therefore, the limitation of being unable to support speeds higher than gigabit in fixed-link does not apply to the U-Boot fixed PHY driver. This makes the fixed-link U-Boot implementation more similar to the one from phylink, which can work with any valid link speed.
---
Changes in v4:
Patch is new.
drivers/net/phy/fixed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/phy/fixed.c +2 -1
@@ -23,7 +23,8 @@ int fixedphy_probe(struct phy_device *phydev)/* check for mandatory properties within fixed-link node */ val =fdt_getprop_u32_default_node (gd->fdt_blob, ofnode,0 ,"speed" ,0 ); -if (val !=SPEED_10 && val !=SPEED_100 && val !=SPEED_1000 ) { +if (val !=SPEED_10 && val !=SPEED_100 && val !=SPEED_1000 && + val !=SPEED_2500 && val !=SPEED_10000 ) {printf ("ERROR: no/invalid speed given in fixed-link node!" );return -EINVAL ; }
Signature · 1 line
2.25.1
PATCH v4 1/7 net: phy: fixed: support speeds of 2500 and 10000
Quoted 21 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Monday, January 25, 2021 2:24 PM
To: Tom Rini <[email protected]>; Joe Hershberger <[email protected]>; Simon Glass <[email protected]>; Bin Meng <[email protected]>; u-boot at lists.denx.de
Cc: Michael Walle <[email protected]>; Alexandru Marginean <[email protected]>; Claudiu Manoil <[email protected]>
Subject: [PATCH v4 1/7] net: phy: fixed: support speeds of 2500 and 10000From: Vladimir Oltean <[email protected]>
Unlike the Linux fixed PHY driver, the one in U-Boot does not attempt to emulate the clause 22 register set of a gigabit copper PHY driver through the swphy framework. Therefore, the limitation of being unable to support speeds higher than gigabit in fixed-link does not apply to the U-Boot fixed PHY driver. This makes the fixed-link U-Boot implementation more similar to the one from phylink, which can work with any valid link speed.
Quoted 1 line
Signed-off-by Vladimir Oltean <[email protected]>
PATCH v4 1/7 net: phy: fixed: support speeds of 2500 and 10000
In reply to Vladimir OlteanQuoted 10 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Unlike the Linux fixed PHY driver, the one in U-Boot does not attempt to emulate the clause 22 register set of a gigabit copper PHY driver through the swphy framework. Therefore, the limitation of being unable to support speeds higher than gigabit in fixed-link does not apply to the U-Boot fixed PHY driver. This makes the fixed-link U-Boot implementation more similar to the one from phylink, which can work with any valid link speed.
Quoted 2 lines
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Claudiu Manoil <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/2b6f4c8d/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 2/7 net: phy: introduce fixed_phy_create for DSA CPU ports
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The DSA (Distributed Switch Architecture) implementation has made a design decision when it got introduced to the Linux kernel in 2008. That was to hide away from the user the CPU-facing Ethernet MAC, since it does not make sense to register it as a struct net_device (UCLASS_ETH udevice for U-Boot), because that would never be beneficial for a user:
they would not be able to use it for traffic, since conceptually, a packet delivered to the CPU port should loop back into the system.
Nonetheless, DSA has had numerous growing pains due to the lack of a struct net_device for the CPU port, but so far it has overcome them. It is unlikely at this stage of maturity that this aspect of it will change.
We would like U-Boot to present the same information as Linux, to be at parity in terms of number of interfaces, so that ethNaddr environment variables could directly be associated between U-Boot and Linux. Therefore, we would implicitly like U-Boot to hide the CPU port from the user as well.
But the paradox is that DSA still needs a struct phy_device to inform the driver of the parameters of the link that it should configure the CPU port to. The problem is that the phy_device is typically returned via a call to phy_connect, which needs an udevice to attach the PHY to, and to search its ofnode for the 'fixed-link' property. But we don't have an udevice to present for the CPU port.
Since 99% of DSA setups are MAC-to-MAC connections between the switch and the host Ethernet controller, the struct phy_device is going to be a fixed PHY. This simplifies things quite a bit. In U-Boot, a fixed PHY does not need an MDIO bus, and does not need an attached dev either. Basically, the phy_connect call doesn't do any connection, it just creates the fixed PHY.
The proposal of this patch is to introduce a new fixed_phy_create function which will take a single argument: the ofnode that holds this:
port at 4 {
reg = <4>;
phy-mode = "internal";
fixed-link {
speed = <2500>;
full-duplex;
};
};and probe a fixed PHY driver using the information from this ofnode. DSA will probably be the only user of this function.
---
Changes in v4:
Patch is new.
drivers/net/phy/phy.c | 31 +++++++++++++++++++++++++++++++ include/phy.h | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+)
drivers/net/phy/phy.c +31 -0
@@ -973,6 +973,37 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,#endif #ifdef CONFIG_PHY_FIXED +/** +* fixed_phy_create() - create an unconnected fixed-link pseudo-PHY device +* @node: OF node for the container of the fixed-link node +* +* Description: Creates a struct phy_device based on a fixed-link of_node +* description. Can be used without phy_connect by drivers which do not expose +* a UCLASS_ETH udevice. +*/ +struct phy_device *fixed_phy_create (ofnode node) +{ +phy_interface_t interface =PHY_INTERFACE_MODE_NONE ; +const char *if_str; +ofnode subnode; + + if_str =ofnode_read_string (node,"phy-mode" ); +if (!if_str) { + if_str =ofnode_read_string (node,"phy-interface-type" ); + } +if (if_str) { + interface =phy_get_interface_by_name (if_str); + } + + subnode =ofnode_find_subnode (node,"fixed-link" ); +if (!ofnode_valid (subnode)) { +return NULL ; + } + +return phy_device_create (NULL ,ofnode_to_offset (subnode),PHY_FIXED_ID , + false, interface); +} +#ifdef CONFIG_DM_ETH static struct phy_device *phy_connect_fixed(struct mii_dev *bus, struct udevice *dev,
include/phy.h +21 -0
@@ -402,6 +402,27 @@ int phy_reset(struct phy_device *phydev);struct phy_device *phy_find_by_mask (struct mii_dev *bus,unsigned phy_mask,phy_interface_t interface); +#ifdef CONFIG_PHY_FIXED + +/** +* fixed_phy_create() - create an unconnected fixed-link pseudo-PHY device +* @node: OF node for the container of the fixed-link node +* +* Description: Creates a struct phy_device based on a fixed-link of_node +* description. Can be used without phy_connect by drivers which do not expose +* a UCLASS_ETH udevice. +*/ +struct phy_device *fixed_phy_create (ofnode node); + +#else + +static inline struct phy_device *fixed_phy_create (ofnode node) +{ +return NULL ; +} + +#endif +#ifdef CONFIG_DM_ETH /**
Signature · 1 line
2.25.1
PATCH v4 2/7 net: phy: introduce fixed_phy_create for DSA CPU ports
Quoted 60 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Monday, January 25, 2021 2:24 PM
To: Tom Rini <[email protected]>; Joe Hershberger <[email protected]>; Simon Glass <[email protected]>; Bin Meng <[email protected]>; u-boot at lists.denx.de
Cc: Michael Walle <[email protected]>; Alexandru Marginean <[email protected]>; Claudiu Manoil <[email protected]>
Subject: [PATCH v4 2/7] net: phy: introducefixed_phy_createfor DSA CPU portsFrom: Vladimir Oltean <[email protected]>
The DSA (Distributed Switch Architecture) implementation has made a design decision when it got introduced to the Linux kernel in 2008. That was to hide away from the user the CPU-facing Ethernet MAC, since it does not make sense to register it as a struct
net_device(UCLASS_ETHudevice for U-Boot), because that would never be beneficial for a user:
they would not be able to use it for traffic, since conceptually, a packet delivered to the CPU port should loop back into the system.Nonetheless, DSA has had numerous growing pains due to the lack of a struct
net_devicefor the CPU port, but so far it has overcome them. It is unlikely at this stage of maturity that this aspect of it will change.We would like U-Boot to present the same information as Linux, to be at parity in terms of number of interfaces, so that ethNaddr environment variables could directly be associated between U-Boot and Linux. Therefore, we would implicitly like U-Boot to hide the CPU port from the user as well.
But the paradox is that DSA still needs a struct
phy_deviceto inform the driver of the parameters of the link that it should configure the CPU port to. The problem is that thephy_deviceis typically returned via a call tophy_connect, which needs an udevice to attach the PHY to, and to search its ofnode for the 'fixed-link' property. But we don't have an udevice to present for the CPU port.Since 99% of DSA setups are MAC-to-MAC connections between the switch and the host Ethernet controller, the struct
phy_deviceis going to be a fixed PHY. This simplifies things quite a bit. In U-Boot, a fixed PHY does not need an MDIO bus, and does not need an attached dev either. Basically, thephy_connectcall doesn't do any connection, it just creates the fixed PHY.The proposal of this patch is to introduce a new
fixed_phy_createfunction which will take a single argument: the ofnode that holds this:port at 4 { reg = <4>; phy-mode = "internal"; fixed-link { speed = <2500>; full-duplex; }; };
Quoted 4 lines
and probe a fixed PHY driver using the information from this ofnode. DSA will probably be the only user of this function.
Signed-off-by Vladimir Oltean <[email protected]>
PATCH v4 2/7 net: phy: introduce fixed_phy_create for DSA CPU ports
In reply to Vladimir OlteanQuoted 48 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
The DSA (Distributed Switch Architecture) implementation has made a design decision when it got introduced to the Linux kernel in 2008. That was to hide away from the user the CPU-facing Ethernet MAC, since it does not make sense to register it as a struct
net_device(UCLASS_ETHudevice for U-Boot), because that would never be beneficial for a user:
they would not be able to use it for traffic, since conceptually, a packet delivered to the CPU port should loop back into the system.Nonetheless, DSA has had numerous growing pains due to the lack of a struct
net_devicefor the CPU port, but so far it has overcome them. It is unlikely at this stage of maturity that this aspect of it will change.We would like U-Boot to present the same information as Linux, to be at parity in terms of number of interfaces, so that ethNaddr environment variables could directly be associated between U-Boot and Linux. Therefore, we would implicitly like U-Boot to hide the CPU port from the user as well.
But the paradox is that DSA still needs a struct
phy_deviceto inform the driver of the parameters of the link that it should configure the CPU port to. The problem is that thephy_deviceis typically returned via a call tophy_connect, which needs an udevice to attach the PHY to, and to search its ofnode for the 'fixed-link' property. But we don't have an udevice to present for the CPU port.Since 99% of DSA setups are MAC-to-MAC connections between the switch and the host Ethernet controller, the struct
phy_deviceis going to be a fixed PHY. This simplifies things quite a bit. In U-Boot, a fixed PHY does not need an MDIO bus, and does not need an attached dev either. Basically, thephy_connectcall doesn't do any connection, it just creates the fixed PHY.The proposal of this patch is to introduce a new
fixed_phy_createfunction which will take a single argument: the ofnode that holds this:port at 4 { reg = <4>; phy-mode = "internal"; fixed-link { speed = <2500>; full-duplex; }; };
Quoted 5 lines
and probe a fixed PHY driver using the information from this ofnode. DSA will probably be the only user of this function.
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Claudiu Manoil <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/0fc5c9ea/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 3/7 net: Introduce DSA class for Ethernet switches
In reply to Vladimir OlteanFrom: Claudiu Manoil <[email protected]>
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.
---
v4:
- Implemented the TODO for having a phy_device on the CPU port.
v3:
- Removed all infrastructure associated with dsa_foreach_port, which is no longer needed.
- Only inherit the DSA master's MAC address if the environment does not already have a specific MAC address that should be used for the DSA port.
- Be compatible with the new "ethernet-ports" container name which has been introduced in the Linux kernel as commit 85e05d263ed2 ("net: dsa:
of: Allow ethernet-ports as encapsulating node") in v5.9.
v2: none
drivers/net/Kconfig | 15 ++ include/dm/uclass-id.h | 1 + include/net.h | 6 + include/net/dsa.h | 165 ++++++++++++++ net/Makefile | 1 + net/dsa-uclass.c | 478 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 666 insertions(+) create mode 100644 include/net/dsa.h create mode 100644 net/dsa-uclass.c
drivers/net/Kconfig +15 -0
@@ -37,6 +37,21 @@ 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 + depends on PHY_FIXED + 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 the "master" Ethernet interface in DSA terminology. + This is currently implemented in net/dsa-uclass.c, refer to + include/net/dsa.h for API details. + config MDIO_SANDBOX depends on DM_MDIO && SANDBOX default y
include/dm/uclass-id.h +1 -0
@@ -46,6 +46,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_ETH_PHY, /* Ethernet PHY device */
include/net.h +6 -0
@@ -499,7 +499,13 @@ struct icmp_hdr {* maximum packet size and multiple of 32 bytes = 1536 */ #define PKTSIZE 1522 +#ifndef CONFIG_DM_DSA #define PKTSIZE_ALIGN 1536 +#else +/* Maximum DSA tagging overhead (headroom and/or tailroom) */ +#define DSA_MAX_OVR 256 +#define PKTSIZE_ALIGN (1536 + DSA_MAX_OVR) +#endif /* * Maximum receive ring size; that is, the number of packets
include/net/dsa.h new file +165 -0
165 lines not on this page · raw message
net/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_NET) += arp.o obj-$(CONFIG_CMD_BOOTP) += bootp.o obj-$(CONFIG_CMD_CDP) += cdp.o obj-$(CONFIG_CMD_DNS) += dns.o +obj-$(CONFIG_DM_DSA) += dsa-uclass.o ifdef CONFIG_DM_ETH obj-$(CONFIG_NET) += eth-uclass.o else
net/dsa-uclass.c new file +478 -0
478 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 3/7 net: Introduce DSA class for Ethernet switches
Quoted 10 lines · Vladimir Oltean
From: Claudiu Manoil <[email protected]>
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 4 lines
Signed-off-by Alex Marginean <[email protected]>Signed-off-by Claudiu Manoil <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/57440c4a/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
In reply to Vladimir OlteanFrom: Claudiu Manoil <[email protected]>
The DSA sandbox driver is used for unit testing the DSA class code. It implements a simple 2 port switch plus 1 CPU port, and uses a very simple tag to identify the ports.
The DSA sandbox device is connected via CPU port to a regular Ethernet sandbox device, called 'dsa-test-eth, managed by the existing eth sandbox driver. The 'dsa-test-eth' is not intended for testing the eth class code however, but it is used to emulate traffic through the 'lan0' and 'lan1' front pannel switch ports. To achieve this the dsa sandbox driver registers a tx handler for the 'dsa-test-eth' device. The switch ports, labeled as 'lan0' and 'lan1', are also registered as eth devices by the dsa class code this time. So pinging through these switch ports is as easy as:
=> setenv ethact lan0
=> ping 1.2.3.5
Unit tests for the dsa class code were also added. The 'dsa_probe' test exercises most API functions from dsa.h. The 'dsa' unit test simply exercises ARP/ICMP traffic through the two switch ports, including tag injection and extraction, with the help of the dsa sandbox driver.
I took care to minimize the impact on the existing eth unit tests, though some adjustments needed to be made with the addition of extra eth interfaces used by the dsa unit tests. The additional eth interfaces also require MAC addresses, these have been added to the sandbox default environment.
---
v4: none.
v3:
- deleted the unit tests associated with the infrastructure for dsa_foreach_port, since that function no longer exists.
- added fixed-link and phy-mode to lan0 from the sandbox device tree. We don't support ports that don't have a PHY and are not fixed-link either.
v2: none
arch/Kconfig | 1 + arch/sandbox/dts/test.dts | 48 ++++++++++ drivers/net/Kconfig | 9 ++ drivers/net/Makefile | 1 + drivers/net/dsa_sandbox.c | 179 ++++++++++++++++++++++++++++++++++++++ include/configs/sandbox.h | 2 + test/dm/Makefile | 1 + test/dm/dsa.c | 82 +++++++++++++++++ test/dm/eth.c | 10 +-- 9 files changed, 328 insertions(+), 5 deletions(-) create mode 100644 drivers/net/dsa_sandbox.c create mode 100644 test/dm/dsa.c
arch/Kconfig +1 -0
@@ -160,6 +160,7 @@ config SANDBOX imply CMD_CLONE imply SILENT_CONSOLE imply BOOTARGS_SUBST + imply DM_DSA config SH bool "SuperH architecture"
arch/sandbox/dts/test.dts +48 -0
61 lines not on this page · raw message
drivers/net/Kconfig +9 -0
@@ -78,6 +78,15 @@ config DM_ETH_PHY help Enable driver model for Ethernet Generic PHY . +config DSA_SANDBOX + depends on DM_DSA && SANDBOX + default y + bool "Sandbox: Mocked DSA driver" + help + This driver implements a dummy DSA switch connected to a dummy sandbox + Ethernet device used as DSA master, to test DSA class code, including + exported DSA API and datapath processing of Ethernet traffic. + menuconfig NETDEVICES bool "Network device support" depends on NET
drivers/net/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o obj-$(CONFIG_ETH_DESIGNWARE_S700) += dwmac_s700.o obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o obj-$(CONFIG_DNET) += dnet.o +obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o obj-$(CONFIG_DM_ETH_PHY) += eth-phy-uclass.o obj-$(CONFIG_E1000) += e1000.o obj-$(CONFIG_E1000_SPI) += e1000_spi.o
drivers/net/dsa_sandbox.c new file +179 -0
179 lines not on this page · raw message
include/configs/sandbox.h +2 -0
@@ -93,7 +93,9 @@#endif #define SANDBOX_ETH_SETTINGS "ethaddr=00:00:11:22:33:44\0" \ + "eth2addr=00:00:11:22:33:48\0" \ "eth3addr=00:00:11:22:33:45\0" \ + "eth4addr=00:00:11:22:33:48\0" \ "eth5addr=00:00:11:22:33:46\0" \ "eth6addr=00:00:11:22:33:47\0" \ "ipaddr=1.2.3.4\0"
test/dm/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_DM_BOOTCOUNT) += bootcount.o obj-$(CONFIG_CLK) += clk.o clk_ccf.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o +obj-$(CONFIG_DM_DSA) += dsa.o obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_FIRMWARE) += firmware.o obj-$(CONFIG_DM_GPIO) += gpio.o
test/dm/dsa.c new file +82 -0
82 lines not on this page · raw message
test/dm/eth.c +5 -5
@@ -53,8 +53,8 @@ static int dm_test_eth_alias(struct unit_test_state *uts)ut_assertok (net_loop (PING ));ut_asserteq_str ("eth at 10004000" ,env_get ("ethact" )); -/* Expected to fail since eth2 is not defined in the device tree */ -env_set ("ethact" ,"eth2" ); +/* Expected to fail since eth1 is not defined in the device tree */ +env_set ("ethact" ,"eth1" );ut_assertok (net_loop (PING ));ut_asserteq_str ("eth at 10002000" ,env_get ("ethact" ));
@@ -227,7 +227,7 @@ static int _dm_test_net_retry(struct unit_test_state *uts)* the active device should be eth0 */ sandbox_eth_disable_response (1 , true); -env_set ("ethact" ,"eth at 10004000" ); +env_set ("ethact" ,"lan1" );env_set ("netretry" ,"yes" );sandbox_eth_skip_timeout ();ut_assertok (net_loop (PING ));
@@ -237,11 +237,11 @@ static int _dm_test_net_retry(struct unit_test_state *uts)* eth1 is disabled and netretry is no, so the ping should fail and the * active device should be eth1 */ -env_set ("ethact" ,"eth at 10004000" ); +env_set ("ethact" ,"lan1" );env_set ("netretry" ,"no" );sandbox_eth_skip_timeout ();ut_asserteq (-ENONET ,net_loop (PING )); -ut_asserteq_str ("eth at 10004000" ,env_get ("ethact" )); +ut_asserteq_str ("lan1" ,env_get ("ethact" ));return 0 ; }
Signature · 1 line
2.25.1
PATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Quoted 28 lines · Vladimir Oltean
From: Claudiu Manoil <[email protected]>
The DSA sandbox driver is used for unit testing the DSA class code. It implements a simple 2 port switch plus 1 CPU port, and uses a very simple tag to identify the ports.
The DSA sandbox device is connected via CPU port to a regular Ethernet sandbox device, called 'dsa-test-eth, managed by the existing eth sandbox driver. The 'dsa-test-eth' is not intended for testing the eth class code however, but it is used to emulate traffic through the 'lan0' and 'lan1' front pannel switch ports. To achieve this the dsa sandbox driver registers a tx handler for the 'dsa-test-eth' device. The switch ports, labeled as 'lan0' and 'lan1', are also registered as eth devices by the dsa class code this time. So pinging through these switch ports is as easy as:
=> setenv ethact lan0
=> ping 1.2.3.5Unit tests for the dsa class code were also added. The '
dsa_probe' test exercises most API functions fromdsa.h. The 'dsa' unit test simply exercises ARP/ICMP traffic through the two switch ports, including tag injection and extraction, with the help of the dsa sandbox driver.
I took care to minimize the impact on the existing eth unit tests, though some adjustments needed to be made with the addition of extra eth interfaces used by the dsa unit tests. The additional eth interfaces also require MAC addresses, these have been added to the sandbox default environment.
Quoted 4 lines
Signed-off-by Alex Marginean <[email protected]>Signed-off-by Claudiu Manoil <[email protected]>Reviewed-by Simon Glass <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660
Note that I'm still reviewing the rest of the series right now.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/18d5c6ad/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.
PATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Quoted 11 lines · Vladimir Oltean
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.
I'm about to push the rest of the series, so you can rebase on master shortly, thanks! Or should I hold off as this exposed problems in the rest of your series?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/d019734e/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Quoted 9 lines · Tom Rini
Quoted 8 lines · Vladimir Oltean
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
Quoted 7 lines
Quoted 3 lines
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.I'm about to push the rest of the series, so you can rebase on master shortly, thanks! Or should I hold off as this exposed problems in the rest of your series?
Sorry, I missed your reply earlier. I just sent out a new version which should be sandbox-clean and which also makes the fixed PHY driver compatible with live OF, since that's what the problem was, essentially.
PATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Am 2021-02-16 22:21, schrieb Vladimir Oltean:
Quoted 14 lines · Tom Rini
Quoted 13 lines · Vladimir Oltean
Quoted 11 lines
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.
Quoted 8 lines
Quoted 3 lines
I'm about to push the rest of the series, so you can rebase on master shortly, thanks! Or should I hold off as this exposed problems in the rest of your series?
Sorry, I missed your reply earlier. I just sent out a new version which should be sandbox-clean and which also makes the fixed PHY driver compatible with live OF, since that's what the problem was, essentially.
If this series is merged, I'd just send a follow up for the kontron sl28 board device tree, which also uses DSA. Originally, this it wasn't possible to include the patch in this series, because there was still the base device tree for this board variant pending in u-boot.
So if possible, I'd welcome it if it can be merged after this series.
-michael
PATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Quoted 23 lines · Michael Walle
Am 2021-02-16 22:21, schrieb Vladimir Oltean:
Quoted 14 lines · Tom Rini
Quoted 13 lines · Vladimir Oltean
Quoted 11 lines
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.Quoted 7 lines
Quoted 3 lines
I'm about to push the rest of the series, so you can rebase on master shortly, thanks! Or should I hold off as this exposed problems in the rest of your series?
Sorry, I missed your reply earlier. I just sent out a new version which should be sandbox-clean and which also makes the fixed PHY driver compatible with live OF, since that's what the problem was, essentially.
Quoted 6 lines
If this series is merged, I'd just send a follow up for the kontron sl28 board device tree, which also uses DSA. Originally, this it wasn't possible to include the patch in this series, because there was still the base device tree for this board variant pending in u-boot.
So if possible, I'd welcome it if it can be merged after this series.
OK, so I guess there's a small amount of follow-up to finish enabling it as I see, today with v4:kontron_sl28 : all +9467 bss +2560 data +568 rodata +675 spl/u-boot-spl:all +18 spl/u-boot-spl:rodata +18 text +5664
when building and it's on just a few layerscape platforms so I assumed it was enabling everything.
And, I'm inclined to go with reposting just a follow-up that fixes / enables sandbox and livetree as I would like to both:
- Not delay the whole thing further
- Not merge other changes immediately after they're posted[*]
Signature · 11 lines
Tom [*]: Yes, I did this literally yesterday, but for a security series I had seen prior, so a special case I don't like either, but... anyhow. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/aeb97ea2/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Quoted 43 lines · Tom Rini
Quoted 23 lines · Michael Walle
Am 2021-02-16 22:21, schrieb Vladimir Oltean:
Quoted 14 lines · Tom Rini
Quoted 13 lines · Vladimir Oltean
Quoted 11 lines
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.Quoted 7 lines
Quoted 3 lines
I'm about to push the rest of the series, so you can rebase on master shortly, thanks! Or should I hold off as this exposed problems in the rest of your series?
Sorry, I missed your reply earlier. I just sent out a new version which should be sandbox-clean and which also makes the fixed PHY driver compatible with live OF, since that's what the problem was, essentially.
Quoted 6 lines
If this series is merged, I'd just send a follow up for the kontron sl28 board device tree, which also uses DSA. Originally, this it wasn't possible to include the patch in this series, because there was still the base device tree for this board variant pending in u-boot.
So if possible, I'd welcome it if it can be merged after this series.
OK, so I guess there's a small amount of follow-up to finish enabling it as I see, today with v4:
kontron_sl28: all +9467 bss +2560 data +568 rodata +675 spl/u-boot-spl:all +18 spl/u-boot-spl:rodata +18 text +5664when building and it's on just a few layerscape platforms so I assumed it was enabling everything.
And, I'm inclined to go with reposting just a follow-up that fixes / enables sandbox and livetree as I would like to both:
- Not delay the whole thing further
- Not merge other changes immediately after they're posted[*]
Quoted 5 lines
--
Tom[*]: Yes, I did this literally yesterday, but for a security series I had seen prior, so a special case I don't like either, but... anyhow.
Tom, if you want to merge v4 sans the sandbox support instead of v5, I'm okay with that. I can easily send out the v5 changes in a follow-up series.
PATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Quoted 44 lines · Vladimir Oltean
Quoted 43 lines · Tom Rini
Quoted 23 lines · Michael Walle
Am 2021-02-16 22:21, schrieb Vladimir Oltean:
Quoted 14 lines · Tom Rini
Quoted 13 lines · Vladimir Oltean
Quoted 11 lines
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.Quoted 7 lines
Quoted 3 lines
I'm about to push the rest of the series, so you can rebase on master shortly, thanks! Or should I hold off as this exposed problems in the rest of your series?
Sorry, I missed your reply earlier. I just sent out a new version which should be sandbox-clean and which also makes the fixed PHY driver compatible with live OF, since that's what the problem was, essentially.
Quoted 6 lines
If this series is merged, I'd just send a follow up for the kontron sl28 board device tree, which also uses DSA. Originally, this it wasn't possible to include the patch in this series, because there was still the base device tree for this board variant pending in u-boot.
So if possible, I'd welcome it if it can be merged after this series.
OK, so I guess there's a small amount of follow-up to finish enabling it as I see, today with v4:
kontron_sl28: all +9467 bss +2560 data +568 rodata +675 spl/u-boot-spl:all +18 spl/u-boot-spl:rodata +18 text +5664when building and it's on just a few layerscape platforms so I assumed it was enabling everything.
And, I'm inclined to go with reposting just a follow-up that fixes / enables sandbox and livetree as I would like to both:
- Not delay the whole thing further
- Not merge other changes immediately after they're posted[*]
Quoted 8 lines
Quoted 5 lines
--
Tom[*]: Yes, I did this literally yesterday, but for a security series I had seen prior, so a special case I don't like either, but... anyhow.
Tom, if you want to merge v4 sans the sandbox support instead of v5, I'm okay with that. I can easily send out the v5 changes in a follow-up series.
Thanks! Pushing stuff now..
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/8fd021b0/attachment.sig>
PATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
In reply to Tom RiniAm 2021-02-16 22:38, schrieb Tom Rini:
Quoted 30 lines · Michael Walle
Quoted 29 lines
Am 2021-02-16 22:21, schrieb Vladimir Oltean:
Quoted 14 lines · Tom Rini
Quoted 13 lines · Vladimir Oltean
Quoted 11 lines
Hi Tom,
Quoted 4 lines · Tom Rini
This test does not pass for me. This can be seen at:
https://gitlab.denx.de/u-boot/u-boot/-/jobs/223660Note that I'm still reviewing the rest of the series right now.
You're right, thanks for letting me know.
I've fixed this in my tree [ by adding two more patches :-/ ], let me know if you have any other feedback, otherwise I'm going to resend soon.Quoted 7 lines
Quoted 3 lines
I'm about to push the rest of the series, so you can rebase on master shortly, thanks! Or should I hold off as this exposed problems in the rest of your series?
Sorry, I missed your reply earlier. I just sent out a new version which should be sandbox-clean and which also makes the fixed PHY driver compatible with live OF, since that's what the problem was, essentially.
If this series is merged, I'd just send a follow up for the kontron sl28
board device tree, which also uses DSA. Originally, this it wasn't possible to include the patch in this series, because there was still the base device tree for this board variant pending in u-boot.
Quoted 7 lines
Quoted 1 line
So if possible, I'd welcome it if it can be merged after this series.
OK, so I guess there's a small amount of follow-up to finish enabling it
as I see, today with v4:kontron_sl28: all +9467 bss +2560 data +568 rodata +675
spl/u-boot-spl:all +18 spl/u-boot-spl:rodata +18 text +5664
The support was already enabled, but the device tree for this partitcular variant was still missing when this patchset was posted. Therefore, it couldn't be enabled.
commit b463010be067ba4b8ef9b7b80919f592a0f83bfb
Author: Michael Walle <[email protected]> Date: Fri Jan 8 00:08:58 2021 +0100
board: sl28: add network variant 2 support
Although this variant has two external network ports, they are not
(yet)
supported by the bootloader because they are connected via an
internal
network switch. Otherwise its the same as the other variants.
So the only thing which is missing is device tree fragment.
Quoted 7 lines
when building and it's on just a few layerscape platforms so I assumed it was enabling everything.
And, I'm inclined to go with reposting just a follow-up that fixes / enables sandbox and livetree as I would like to both:
- Not delay the whole thing further
- Not merge other changes immediately after they're posted[*]
I just tried it again on my board and there seems still to be something broken :( I just don't have time right now. Would it be OK, to delay this until tomorrow?
-michael
PATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Am 2021-02-16 22:58, schrieb Michael Walle:
Quoted 3 lines
I just tried it again on my board and there seems still to be something broken :( I just don't have time right now. Would it be OK, to delay this until tomorrow?
Please disregard this nonsense. Its all working.
-michael
Vladimir Oltean
maintainerPATCH v4 4/7 sandbox: Add a DSA sandbox driver and unit test
Quoted 6 lines · Michael Walle
Am 2021-02-16 22:58, schrieb Michael Walle:
Quoted 3 lines
I just tried it again on my board and there seems still to be something broken :( I just don't have time right now. Would it be OK, to delay this until tomorrow?
Please disregard this nonsense. Its all working.
Don't worry. I've done and said so many stupid things in the past week I couldn't even keep track, and if I didn't feel bad for them, neither should you :D
I have the follow-up patches for the sandbox prepared, is it okay if I send them tonight? They can marinate for as long as necessary.
Vladimir Oltean
maintainerPATCH v4 5/7 drivers: net: Add Felix DSA switch driver
In reply to Vladimir OlteanFrom: Alex Marginean <[email protected]>
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.
---
v4: none
v3: dsa_foreach_port() does not work when called from the probe function
of the DSA udevice, because the eth port udevices are _not_ yet probed at that point. To fix this, we are now initializing all ports from the .port_enable() callback of each eth udevice.
v2: none
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 | 414 ++++++++++++++++++++++++ 4 files changed, 428 insertions(+) create mode 100644 drivers/net/mscc_eswitch/felix_switch.c
drivers/net/fsl_enetc.h +5 -0
@@ -201,6 +201,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 the + NXP LS1028A 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 +414 -0
414 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 5/7 drivers: net: Add Felix DSA switch driver
Quoted 11 lines · Vladimir Oltean
From: Alex Marginean <[email protected]>
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.
Signed-off-by Alex Marginean <[email protected]>Signed-off-by Claudiu Manoil <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/5fcc452a/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 6/7 arm: dts: ls1028a: Add Ethernet switch node and dependencies
In reply to Vladimir OlteanFrom: Alex Marginean <[email protected]>
The definition follows the DSA binding in kernel and describes the switch, its ports and PHYs. The switch node has the same structure as in Linux and this patch enables it (and relevant ports) for the LS1028A RDB board.
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is not used in U-Boot and was disabled. Ethernet port aliases were also added to better manage the multitude of ports available now.
---
v4: none.
v3: Added a comment denoting the PHY model present on the RDB.
v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB DTS to minimize impact on other boards (and for improved flexibility).
arch/arm/dts/fsl-ls1028a-rdb.dts | 64 ++++++++++++++++++++++++++++++++ arch/arm/dts/fsl-ls1028a.dtsi | 56 +++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-)
arch/arm/dts/fsl-ls1028a-rdb.dts +64 -0
@@ -15,6 +15,12 @@ compatible = "fsl,ls1028a-rdb", "fsl,ls1028a"; aliases { spi0 = &fspi; + eth0 = &enetc0; + eth1 = &enetc2; + eth2 = &mscc_felix_port0; + eth3 = &mscc_felix_port1; + eth4 = &mscc_felix_port2; + eth5 = &mscc_felix_port3; }; };
@@ -131,9 +137,67 @@ phy-handle = <&rdb_phy0>; }; +&enetc2 { + status = "okay"; +}; + +&mscc_felix { + status = "okay"; +}; + +&mscc_felix_port0 { + label = "swp0"; + phy-handle = <&sw_phy0>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port1 { + label = "swp1"; + phy-handle = <&sw_phy1>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port2 { + label = "swp2"; + phy-handle = <&sw_phy2>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port3 { + label = "swp3"; + phy-handle = <&sw_phy3>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port4 { + ethernet = <&enetc2>; + status = "okay"; +}; + &mdio0 { status = "okay"; rdb_phy0: phy at 2 { reg = <2>; }; + + /* VSC8514 QSGMII PHY */ + 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 +55 -1
64 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 6/7 arm: dts: ls1028a: Add Ethernet switch node and dependencies
Am 2021-01-25 13:23, schrieb Vladimir Oltean:
Quoted 8 lines
From: Alex Marginean <[email protected]>
The definition follows the DSA binding in kernel and describes the switch,
its ports and PHYs. The switch node has the same structure as in Linux and this patch enables it (and relevant ports) for the LS1028A RDB board.
Quoted 8 lines
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is
not used in U-Boot and was disabled. Ethernet port aliases were also added to better manage the multitude of ports available now.Signed-off-by Alex Marginean <[email protected]>Signed-off-by Claudiu Manoil <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>
You don't seem to like my review tag :p
Quoted 169 lines
---
v4: none.v3: Added a comment denoting the PHY model present on the RDB.
v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB DTS to minimize impact on other boards (and for improved flexibility).
arch/arm/dts/fsl-ls1028a-rdb.dts | 64 ++++++++++++++++++++++++++++++++ arch/arm/dts/fsl-ls1028a.dtsi | 56 +++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-)arch/arm/dts/fsl-ls1028a-rdb.dts +64
-0@@ -15,6 +15,12 @@ compatible = "fsl,ls1028a-rdb", "fsl,ls1028a"; aliases { spi0 = &fspi; + eth0 = &enetc0; + eth1 = &enetc2; + eth2 = &mscc_felix_port0; + eth3 = &mscc_felix_port1; + eth4 = &mscc_felix_port2; + eth5 = &mscc_felix_port3; }; };@@ -131,9 +137,67 @@ phy-handle = <&rdb_phy0>; }; +&enetc2 { + status = "okay"; +}; + +&mscc_felix { + status = "okay"; +}; + +&mscc_felix_port0 { + label = "swp0"; + phy-handle = <&sw_phy0>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port1 { + label = "swp1"; + phy-handle = <&sw_phy1>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port2 { + label = "swp2"; + phy-handle = <&sw_phy2>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port3 { + label = "swp3"; + phy-handle = <&sw_phy3>; + phy-mode = "qsgmii"; + status = "okay"; +}; + +&mscc_felix_port4 { + ethernet = <&enetc2>; + status = "okay"; +}; + &mdio0 { status = "okay"; rdb_phy0: phy at 2 { reg = <2>; }; + + /* VSC8514 QSGMII PHY */ + 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 +55
-1@@ -151,9 +151,63 @@ reg = <0x000300 0 0 0 0>; status = "disabled"; }; + + mscc_felix: pci at 0,5 { + reg = <0x000500 0 0 0 0>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + mscc_felix_port0: port at 0 { + reg = <0>; + status = "disabled"; + }; + + mscc_felix_port1: port at 1 { + reg = <1>; + status = "disabled"; + }; + + mscc_felix_port2: port at 2 { + reg = <2>; + status = "disabled"; + }; + + mscc_felix_port3: port at 3 { + reg = <3>; + status = "disabled"; + }; + + mscc_felix_port4: port at 4 { + reg = <4>; + phy-mode = "internal"; + status = "disabled"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; + + mscc_felix_port5: port at 5 { + reg = <5>; + phy-mode = "internal"; + status = "disabled"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + + }; + }; + }; + enetc6: pci at 0,6 { reg = <0x000600 0 0 0 0>; - status = "okay"; + status = "disabled"; phy-mode = "internal"; }; };
Signature · 1 line
-michael
PATCH v4 6/7 arm: dts: ls1028a: Add Ethernet switch node and dependencies
In reply to Vladimir OlteanQuoted 6 lines · Vladimir Oltean
From: Alex Marginean <[email protected]>
The definition follows the DSA binding in kernel and describes the switch, its ports and PHYs. The switch node has the same structure as in Linux and this patch enables it (and relevant ports) for the LS1028A RDB board.
Quoted 8 lines
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is not used in U-Boot and was disabled. Ethernet port aliases were also added to better manage the multitude of ports available now.
Signed-off-by Alex Marginean <[email protected]>Signed-off-by Claudiu Manoil <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Michael Walle <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/6fbefb3d/attachment.sig>
Vladimir Oltean
maintainerPATCH v4 7/7 configs: ls1028a: Enable the Ethernet switch driver in defconfig
In reply to Vladimir OlteanFrom: Alex Marginean <[email protected]>
The switch driver for LS1028A Ethernet switch is now compiled in for the NXP LS1028A reference design boards and for the Kontron SMARC-sAL28.
---
v4: enabled CONFIG_PHY_FIXED which is a new dependency of CONFIG_DM_DSA
v3: enable the config options for the Kontron board too.
v2: none
configs/kontron_sl28_defconfig | 3 +++ configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 3 +++ configs/ls1028aqds_tfa_defconfig | 3 +++ configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 3 +++ configs/ls1028ardb_tfa_defconfig | 3 +++ 5 files changed, 15 insertions(+)
configs/kontron_sl28_defconfig +3 -0
@@ -82,6 +82,9 @@ CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_FSL_ENETC=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y
configs/ls1028aqds_tfa_SECURE_BOOT_defconfig +3 -0
@@ -61,6 +61,9 @@ CONFIG_DM_MDIO_MUX=y CONFIG_E1000=y CONFIG_FSL_ENETC=y CONFIG_MDIO_MUX_I2CREG=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y
configs/ls1028aqds_tfa_defconfig +3 -0
@@ -67,6 +67,9 @@ CONFIG_DM_MDIO_MUX=y CONFIG_E1000=y CONFIG_FSL_ENETC=y CONFIG_MDIO_MUX_I2CREG=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y
configs/ls1028ardb_tfa_SECURE_BOOT_defconfig +3 -0
@@ -58,6 +58,9 @@ CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_FSL_ENETC=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y
configs/ls1028ardb_tfa_defconfig +3 -0
@@ -64,6 +64,9 @@ CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_FSL_ENETC=y +CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y +CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y
Signature · 1 line
2.25.1
PATCH v4 7/7 configs: ls1028a: Enable the Ethernet switch driver in defconfig
Quoted 9 lines · Vladimir Oltean
From: Alex Marginean <[email protected]>
The switch driver for LS1028A Ethernet switch is now compiled in for the NXP LS1028A reference design boards and for the Kontron SMARC-sAL28.
Signed-off-by Alex Marginean <[email protected]>Signed-off-by Claudiu Manoil <[email protected]>Signed-off-by Vladimir Oltean <[email protected]>Acked-by Michael Walle <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210216/8124de3a/attachment.sig>
v4 cover Introduce DSA Ethernet switch class and Felix driver
In reply to Vladimir OlteanAm 2021-01-25 13:23, schrieb Vladimir Oltean:
Quoted 123 lines
From: Vladimir Oltean <[email protected]>
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.txtThis patch set introduces a DSA class in U-Boot to support drivers of DSA
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.
In the sandbox environment, the DSA sandbox driver, the switch ports and
master eth interface look like this:
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
[...]eth 4 [ + ] eth_sandbox |-- dsa-test-eth dsa 0 [ + ] dsa_sandbox |-- dsa-test eth 5 [ + ] dsa-port | |-- lan0 eth 6 [ + ] dsa-port | `-- lan1=> setenv ethact lan1
=> ping 1.2.3.5
Using lan1 device
host 1.2.3.5 is alive
=>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/from 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 <--> swp3NOTE:
This patchset is a major rework of the dsa-class code since the last
submission from May 5th:
https://patchwork.ozlabs.org/project/uboot/cover/1588700588-8587-1-git-send-email-claudiu.manoil at nxp.com/ The basic concepts and data path operation (tagging) in the DSA class
code remain the same as in the initial patchset from Alex, however the
external API has been changed significantly (simplified), the driver
model integration has been improved to the point that the DSA class
code no longer needs to allocate extra memory internally (via malloc),
reduced memory footprint, internal state data moved from the external
API and internalized, cleaner external API, internal code reworked,
completely reworked DSA sandbox driver and unit tests for better
coverage
and to integrate better with the eth sandbox driver and tests, etc.v4:
- Implemented the TODO for having aphy_deviceon the CPU port.
- EnabledCONFIG_PHY_FIXEDwhich is a new dependency ofCONFIG_DM_DSA.v3:
- Removed all infrastructure associated withdsa_foreach_port, which is no longer needed.
- Only inherit the DSA master's MAC address if the environment does not already have a specific MAC address that should be used for the DSA port.
- Be compatible with the new "ethernet-ports" container name which has been introduced in the Linux kernel as commit85e05d263ed2("net:
dsa:
of: Allow ethernet-ports as encapsulating node") in v5.9.
- Fixed the felix driver not getting its ports initialized, due todsa_foreach_port()being actually unusable when called from the probe function of the DSA udevice - the eth port udevices are _not_ yet probed at that point. We are now initializing all ports from the .port_enable() callback of each eth udevice.
- Deleted the unit tests associated with the infrastructure fordsa_foreach_port, since that function no longer exists.
- Enabled the config options for the Kontron LS1028A board too.v2: Switch node structure defined in dtsi now consistent with the Linux switch node definition. Moved aliases from dtsi to the RDB dts to minimize impact on other boards (and for improved flexibility).
Alex Marginean (3):
drivers: net: Add Felix DSA switch driver
arm: dts: ls1028a: Add Ethernet switch node and dependencies
configs: ls1028a: Enable the Ethernet switch driver in defconfig
Quoted 7 lines
Claudiu Manoil (2):
net: Introduce DSA class for Ethernet switches
sandbox: Add a DSA sandbox driver and unit testVladimir Oltean (2):
net: phy: fixed: support speeds of 2500 and 10000
net: phy: introducefixed_phy_createfor DSA CPU ports
Works now. Tested on Kontron sl28 var2 with two switch ports routed to two SGMII lanes.
Thanks,
-michael
Vladimir Oltean
maintainerv4 cover Introduce DSA Ethernet switch class and Felix driver
Quoted 4 lines · Michael Walle
Works now. Tested on Kontron sl28 var2 with two switch ports routed to two SGMII lanes.
Thanks for the patience!