This article gives information about the TTTech ® Ethernet switch. It also provides its composition and explains how to configure and use it.
The software part of the Ethernet switch control is provided through an external package (refer to X-LINUX-TSNSWCH to get more info).
Additional Acceleration Module (ACM) feature relying on the ethernet switch is also provided through an external package (refer to X-LINUX-ACM to get more info)
1. Framework purpose[edit | edit source]
An Ethernet switch is a Hardware device that connects devices on a local area network (LAN) and forwards data packets between them. It operates at the data link layer (layer 2) of the OSI model and uses MAC addresses to determine the destination of each packet. Ethernet switches can improve the network performance by reducing collisions and congestion, and they can also provide security features such as VLANs and port-based access control. Ethernet switches are more efficient in terms of CPU usage than Ethernet bridges. As hardware Ethernet switch is responsible for data forwarding, filtering, and prioritization, it reduces the workload on the CPU. As a result, the CPU can focus on other tasks, leading to improve network performance.
Ethernet switch can be used in many different use cases, as mentioned in How to use Ethernet switch section.
2. System overview[edit | edit source]
2.1. Component description[edit | edit source]
From user space to hardware
- Application (User space)
- There are a lot of applications using Ethernet: Internet browser, streaming applications, FTP applications etc.
- libtsn, ptp stack are used for TSN use cases
- acmlib for ACM use cases
- The main interface that is used between an application and the networking protocols is a socket [1]
- Ethernet tools (User space)
- A set of utilities is available to manage and maintain networks: ethtool, ping, route, ifconfig etc.
- Linux socket layer and networking protocols (Kernel space)
- The socket layer [2] is a uniform interface
- between the user process and the network protocol [3] stacks within the :kernel
- Linux networking core (Kernel space)
- The kernel network layer adapts the message with the transport protocol in use. The network subsystem of the Linux kernel is designed to be completely protocol independent.
- GMAC driver (Stmmac) (Kernel space)
- This is the driver for the MAC 10/100/1000 on-chip Ethernet controllers (Synopsys IP blocks).
- Documentation/networking/stmmac.txt[4]
- STM32 dwmac glue (Kernel space)
- This is the driver to configure RCC clocks and Sysconfig regarding board configuration.
- Documentation/networking/stmmac.txt[5]
- ETH Switch (Hardware)
- This is the Ethernet switch IP: Copyright TTTech Industrial Automation AG, 2021.
- Switch is composed of 2 parts: DeIP and ACM blocks
- DeIP:
- - Time synchronization (IEEE 802.1AS)
- IEEE 1588v2 profile for the synchronization of clocks in the network.
- Supports timing requirements for scheduled TSN networks
- - Forwarding and queuing enhancements for time-sensitive streams (IEEE802.1Qav)
- Time-sensitive streams define traffic shaping using priority classes, which is based
- on a simple form of "leaky bucket" credit-based fair queuing.
- 802.1Qav is designed to reduce buffering in receiving bridges and endpoints.
- - Time-aware scheduler for scheduled traffic (IEEE802.1Qbv)
- Provides guaranteed communication latency for time-critical traffic over standard Ethernet
- - Frame preemption (IEEE 802.1Qbu)
- Allows for optimal bandwidth utilization of nonscheduled background traffic sent
- in parallel with scheduled traffic
- - Redundancy (frame replication and elimination for reliability) (IEEE 802.1 CB)
- - Time synchronization (IEEE 802.1AS)
- ACM:
- - Acceleration Module IP (ACM IP) provides ultra-low latency cut-through between two external ports together with
- a frame processing on the fly (extraction and insertion of data). In normal use cases, ACM IP is used together with
- a TSN Ethernet switch
- ETH Switch (Software)
- Ethernet switch software support is provided through an dedicated expension package : X-LINUX-TSNSWCH.
- In kernel space, it consists in :
- STM32 deip glue (Kernel space) : This is the driver to configure RCC clocks and Sysconfig when switch is used.
- Switch driver (edge-lkm) (Kernel space) This is the driver to control switch (DeIP) and TSN application.
- STM32 deip glue (Kernel space) : This is the driver to configure RCC clocks and Sysconfig when switch is used.
- Acceleration Module feature ACM platform is provided through another dedicated expension package : X-LINUX-ACM
- In kernel space, it consists in :
- ACM driver (Kernel space) : This is the driver to control switch registers for ACM application.
- ACM driver (Kernel space) : This is the driver to control switch registers for ACM application.
- GMACx (Hardware)
- This is the Ethernet IP: GMAC [6]
- xMII portx (Hardware)
- The Ethernet PHY is connected to a media access controller (MAC). The MAC controls the data-link-layer portion of the OSI model.
- The media-independent interface (MII) defines the interface between the MAC and the PHY.
- Variations of the MII are available (RGMII, GMII, RMII, MII) that provide minimal pin count and varied data rates depending on system :requirements.
- The MDIO bus includes two signals:
- - MDC clock: driven by the MAC device to the PHY.
- - MDIO data: bidirectional, it is driven by the PHY to provide register data at the end of a read operation.
- The connector used by Ethernet phy is RJ45.
- ETH switch configuration only supports RGMII and RMII mode.
2.2. API description[edit | edit source]
The Ethernet API is documented in the Linux Kernel[7].
3. Configuration[edit | edit source]
3.1. Kernel configuration[edit | edit source]
The Ethernet API is activated by default in ST deliveries. Nevertheless, if a specific configuration is required, one can use Linux Menuconfig tool: Menuconfig or how to configure kernel and select:
For Network features:
Enable following configs in kernel when using Linux traffic control (tc):
Symbol: NET_SCH_MQPRIO [=y] && NET_SCH_CBS [=y] && NET_SCH_TAPRIO [=y]
[*] Networking support --->
Networking options --->
[*] QoS and/or fair queueing --->
<*> Credit Based Shaper (CBS)
<*> Time Aware Priority (taprio) Scheduler
<*> Multi-queue priority scheduler (MQPRIO)
[*] Actions --->
<*> Traffic Policing
<*> Generic actions
<*> Redirecting and Mirroring
<*> SKB Editing
<*> Vlan manipulation
<*> Frame gate entry list control tc action
3.2. Device tree configuration[edit | edit source]
DT bindings documentation deals with all required or optional device tree properties.
Detailed DT configuration for STM32 internal peripherals: Ethernet switch device tree configuration.
4. How to use Ethernet Switch[edit | edit source]
4.1. How to use the Ethernet Switch user space interface[edit | edit source]
Please see examples based on the following use cases:
- How to configure Ethernet switch: How to configure Ethernet switch
- How to configure TSN switch: How to configure TSN switch
5. How to trace and debug the framework[edit | edit source]
5.1. How to monitor[edit | edit source]
5.1.1. How to monitor PTP[edit | edit source]
deptp_tool can be used to have status of gPTP negotiation.
deptp_tool -t1 --get-port-dataset && deptp_tool -t2 --get-port-dataset source-clock-id 0a:8b:36:ff:fe:89:ef:01 source-port-num 1 clock-id 0a:8b:36:ff:fe:89:ef:01 port-num 1 port-state listening log-announce-interval 0 log-sync-interval -3 log-min-delay-req-interval 0 announce-receipt-timeout 3 version-number 18 delay-mechanism p2p log-min-pdelay-req-interval 0 peer-mean-path-delay-scaled 0 peer-mean-path-delay 0.000000 peer-mean-path-delay-ns 0 success source-clock-id 0a:8b:36:ff:fe:89:ef:01 source-port-num 2 clock-id 0a:8b:36:ff:fe:89:ef:01 port-num 2 port-state listening log-announce-interval 0 log-sync-interval -3 log-min-delay-req-interval 0 announce-receipt-timeout 3 version-number 18 delay-mechanism p2p log-min-pdelay-req-interval 0 peer-mean-path-delay-scaled 0 peer-mean-path-delay 0.000000 peer-mean-path-delay-ns 0 success
5.2. How to debug[edit | edit source]
5.2.1. Activating Switch debug messages[edit | edit source]
A detailed dynamic trace is available in How to use the kernel dynamic debug.
echo "file edge* +p" > /sys/kernel/debug/dynamic_debug/control
This command enables all the traces related to the Switch drivers at runtime.
A finer selection can be made by choosing only the files to trace.
Information |
Reminder: loglevel needs to be increased to 8 either by using boot arguments or by sending the dmesg -n 8 command from the console. |
6. Source code location[edit | edit source]
The source files are located inside the Linux kernel.
- Ethernet driver: dwmac-stm32.c[8]
- STM32 deip glue: stm32_deip.c Available in module from X-LINUX-TSNSWCH [9]
- Switch driver (edge-lkm): edge*.c Available in module from X-LINUX-TSNSWCH [10]
- ACM driver: main.c Available in module from X-LINUX-ACM [11]
7. References[edit | edit source]
- ↑ [1], Berkeley sockets
- ↑ [2], socket layer
- ↑ [3], Internet protocol
- ↑ https://www.kernel.org/doc/Documentation/networking/stmmac.txt, More information
- ↑ https://www.kernel.org/doc/Documentation/devicetree/bindings/net/stm32-dwmac.yaml, More information
- ↑ [4], DesignWare Ethernet GMAC IP
- ↑ Linux Networking and Network Devices APIs
- ↑ [5],dwmac-stm32.c
- ↑ [meta-st-stm32mp-tsn-swch/st.stm32-deip/stm32_deip.c
- ↑ [meta-st-stm32mp-tsn-swch/tsn_sw_base.edge-lkm
- ↑ [meta-st-stm32mp-tsn-acm/ngn.ngn-dd/acm/main.c