Time Sensitive Networking (TSN) is a collection of Ethernet standards defined by IEEE 802.1Q that enables deterministic messaging over standard Ethernet networks. With TSN, Ethernet frames are not limited to Internet Protocol, so it can carry the payload of any industrial application.
Enable TSN support
To add TSN support and tools to your system, add the feature to your project’s conf/local.conf
file:
# TSN
DISTRO_FEATURES:append = " tsn"
Rebuild your image, for example:
$ bitbake dey-image-qt
Deploy the resulting images to the device.
Kernel configuration
You can manage the Ethernet driver and PHY device support through the following kernel configuration options:
-
802.1 Time-Sensitive Networking support (
CONFIG_TSN
) -
ENETC PF driver (
CONFIG_FSL_ENETC
) -
ENETC hardware Time-sensitive Network support (
CONFIG_FSL_ENETC_QOS
)
These options are enabled as built-in on the default ConnectCore 93 kernel configuration file.
IEEE 802.1 Standard configuration
The Linux ecosystem supports several TSN features such as Credit-Based Shaper (formerly Qav), Enhancements for Scheduled Traffic (EST, former Qbv), Generalized Precision Time Protocol (gPTP), and Audio/Video Transport Protocol (AVTP). You can manage the different TSN standards through the following kernel configuration options:
-
Hardware Multiqueue-aware Multi Band Queuing (MULTIQ) (
CONFIG_NET_SCH_MULTIQ
) -
Credit Based Shaper (CBS) (
CONFIG_NET_SCH_CBS
) -
Earliest TxTime First (ETF) (
CONFIG_NET_SCH_ETF
) -
Time Aware Priority (taprio) Scheduler (
CONFIG_NET_SCH_TAPRIO
) -
Multi-queue priority scheduler (MQPRIO) (
CONFIG_NET_SCH_MQPRIO
) -
Elementary classification (BASIC) (
CONFIG_NET_CLS_BASIC
) -
Flower classifier (
CONFIG_NET_CLS_FLOWER
) -
Generic actions (
CONFIG_NET_ACT_GACT
) -
Redirecting and Mirroring (
CONFIG_NET_ACT_MIRRED
) -
Frame gate entry list control tc action (
CONFIG_NET_ACT_GATE
)
These options are not enabled in the default defconfig, but they are added via a config fragment when you enable TSN support in your Digi Embedded Yocto project.
Many more configuration options are available. You must include or exclude options based on your final application. |
Kernel driver
The drivers for the i.MX93 TSN Ethernet support are located at:
File | Description |
---|---|
ENETC PF driver |
|
ENETC hardware Time-sensitive Network |
Device tree bindings and customization
The i.MX93 Ethernet interface device tree binding is documented at Documentation/devicetree/bindings/net/snps,dwmac.yaml
.
The Ethernet interface is defined in the i.MX93 CPU and ConnectCore 93 Development Kit device tree files.
Enable remaining EQoS driver Ethernet queues
All five queues are required for TSN support. Digi provides a pre-compiled device tree overlay to enable these remaining queues that are necessary for TSN support, and that are otherwise disabled on the default device tree. To apply this overlay, run the following command in U-Boot:
=> setenv overlays ccimx9-dvk_eqos-tsn.dtbo,${overlays}
=> saveenv
TSN user space
TSN user space tools
After enabling TSN support, Digi Embedded Yocto includes several tools into the rootfs to configure the TSN connection on the target. The following tools are available in user space.
-
ptp4l: Daemon that synchronizes the PTP Hardware Clock (PHC) from the NIC.
-
phc2sys: Daemon that synchronizes the PHC and the system clock.
-
pmc: Utility tool to configure ptp4l in run-time.
-
tc: Traffic Control (TC) subsystem that helps police, classify, shape, and schedule network traffic and manages packet content.
TSN user space usage
The test consists on two devices connected through a direct cable or through a TSN switch, one acting as master and the other as slave.a The test consists of two devices—one acting as master and the other as slave—connected through a direct cable or through a TSN switch.
-
Check hardware timestamp support
# ethtool -T eth0 | grep PTP PTP Hardware Clock: 0
-
Set up server script (
server.sh
)#!/bin/sh echo "[SERVER] Configuring PTP Server on eth0" tc qdisc del dev eth0 root 2>/dev/null tc qdisc add dev eth0 root handle 100 taprio \ num_tc 1 map 0 queues 1@0 \ base-time 0 \ sched-entry S 01 1000000 \ flags 0x2 ptp4l -i eth0 -f /etc/linuxptp/ptp4l.conf -m -s
-
Set up client script (
client.sh
)#!/bin/sh echo "[CLIENT] Configuring PTP Client on eth0" tc qdisc del dev eth0 root 2>/dev/null tc qdisc add dev eth0 root handle 100 taprio \ num_tc 1 map 0 queues 1@0 \ base-time 0 \ sched-entry S 01 1000000 \ flags 0x2 ptp4l -i eth0 -f /etc/linuxptp/ptp4l.conf -m & sleep 2 phc2sys -s eth0 -c CLOCK_REALTIME -O 0 -m
-
Run on the server side
# chmod +x server.sh # ./server.sh [SERVER] Configuring PTP Server on eth0 [ 312.614080] imx-dwmac 428a0000.ethernet eth0: disabled FPE [ 312.619629] imx-dwmac 428a0000.ethernet eth0: stop FPE handshake [ 312.631960] imx-dwmac 428a0000.ethernet eth0: configured EST [ 312.637630] imx-dwmac 428a0000.ethernet eth0: EST: SWOL has been switched Warning: sch_taprio: Size table not specified, frame length estimations may be inaccurate. ptp4l[312.643]: selected /dev/ptp0 as PTP clock ptp4l[312.645]: port 1 (eth0): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[312.645]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[312.645]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[319.566]: selected local clock 0004f3.fffe.73330a as best master ptp4l[322.792]: port 1 (eth0): new foreign master 0004f3.fffe.290020-1 ptp4l[326.792]: selected best master clock 0004f3.fffe.290020 ptp4l[326.792]: port 1 (eth0): LISTENING to UNCALIBRATED on RS_SLAVE ptp4l[328.791]: master offset 408 s0 freq -3411 path delay 3018 ptp4l[329.791]: master offset 389 s2 freq -3430 path delay 3053 ptp4l[329.792]: port 1 (eth0): UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[330.792]: master offset 202 s2 freq -3228 path delay 3088
-
Run on the client side
# chmod +x client.sh # ./client.sh [CLIENT] Configuring PTP Client on eth0 [ 154.821990] imx-dwmac 428a0000.ethernet eth0: disabled FPE [ 154.827502] imx-dwmac 428a0000.ethernet eth0: stop FPE handshake [ 154.839492] imx-dwmac 428a0000.ethernet eth0: configured EST [ 154.839769] imx-dwmac 428a0000.ethernet eth0: EST: SWOL has been switched Warning: sch_taprio: Size table not specified, frame length estimations may be inaccurate. ptp4l[154.851]: selected /dev/ptp0 as PTP clock ptp4l[154.852]: port 1 (eth0): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[154.853]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[154.853]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE phc2sys[157.855]: CLOCK_REALTIME phc offset 147 s0 freq -27 delay 583 phc2sys[158.855]: CLOCK_REALTIME phc offset 164 s2 freq -10 delay 583 phc2sys[159.856]: CLOCK_REALTIME phc offset 206 s2 freq +196 delay 583 phc2sys[160.856]: CLOCK_REALTIME phc offset -21 s2 freq +31 delay 583 phc2sys[161.856]: CLOCK_REALTIME phc offset -43 s2 freq +3 delay 583 ptp4l[162.164]: port 1 (eth0): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ptp4l[162.165]: selected local clock 0004f3.fffe.290020 as best master ptp4l[162.165]: port 1 (eth0): assuming the grand master role phc2sys[162.856]: CLOCK_REALTIME phc offset -35 s2 freq -2 delay 583
-
Optionally validate TSN Qdisc (on either board)
# tc qdisc show dev eth0 qdisc taprio 100: root tc 1 map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues offset 0 count 1 flags 0x2 base-time 0 cycle-time 1000000 cycle-time-extension 0 index 0 cmd S gatemask 0x1 interval 1000000 max-sdu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fp E E E E E E E E E E E E E E E E qdisc pfifo 0: parent 100:1 refcnt 2 limit 1000p