TSN API

TSN is grouped into three basic key component categories required for complete real-time communication. Multiple specifications fall under these three categories.

  • Time Synchronization i.e. 802.1AS(gPTP)
  • Scheduling and traffic shaping - i.e 802.1Qav, 802.1Qbv, 802.1Qbu/802.3br, 802.1CB and 802.1Qci.
  • Selection of communication paths, reservation and fault tolerance - i.e SRP (802.1Qat) and 802.1Qcc are key standards that define the system configuration of TSN networks.
Standards Support on Orin Software and Hardware
802.1AS YES

802.1 Qbu + 802.3br

(egress path)

YES

802.1 Qbv

(egress path)

YES

802.1 Qav (CBS)

(egress path)

YES
IEEE 802.1Qat (SRP) NO

This document provides sample application code for reference along with documenting the ioctl interface, which can be used to write customized applications to validate TSN specifications for Linux and QNX operating systems. Sample applications are used to configure end-to-end connections between two Ethernet interfaces

Terminology

TC - Traffic class value from 0 to 7.

GCL - gate control list, this is reliant to 802.1Qbv Specification

RQ - Frame Preemption Residue Queue. The Rx queue number to which the residual

preemption frames must be forwarded. Preemption frames that are tagged and pass the SA/DA/VLAN filtering are routed and All other frames are treated as residual frames and are routed to the queue number mentioned in this field. The Queue-0 is used as a default queue for express frames, so this field cannot be programmed to a value 0.

APP - application

OS - Operating system

DUT - Target device

Linux OS

This section is explaining how to use driver provided private IOCTL for configuring hardware in Linux OS.

Using IOCTL Interfaces

/* include */
#include "ether_export.h"

static int open_socket(char *ifname)
{
        int sockfd;

        sockfd = socket(PF_INET, SOCK_STREAM, 0);
        return sockfd;
}

static void close_socket(int sockfd)
{
        close(sockfd);
}

int main(int argc, char *argv[])
{

int sockfd;
static char *if_name;
struct ifreq ifr;
struct ifr_data_struct data;
struct osi_est_config cfg;

sockfd = open_socket(argv[1]);
if_name = strdup(argv[1]);

/* Update all fields of osi_est_config from user input  for example..*/
cfg.en_dis = atoi(argv1);
            cfg.btr[0] = atoi(argv2);
            cfg.btr[1] = atoi(argv3);
            cfg.btr_offset[0] = atoi(argv4);
            cfg.btr_offset[1] = atoi(argv5);
            cfg.ctr[0] = strtol(argv6, NULL, 16);
            cfg.ctr[1] = strtol(argv7, NULL, 16);

data.cmd = ETHER_EST_CFG;
data.ptr = &cfg;
strcpy(ifr.ifr_ifrn.ifrn_name, ifname);
ifr.ifr_ifru.ifru_data = &data;

 ret = ioctl(sockfd, DWC_ETH_QOS_PRV_IOCTL, &ifr);
if (ret < 0)
                printf("IOCTL Error in %s()\n",__func__);
        else
                printf("Configured successfully\n");
close_socket(sockfd);
Return ret;
}

IOCTL Supported Commands

/**
 * @addtogroup private IOCTL related info
 *
 * @brief MACRO are defined for driver supported
 * private IOCTLs. These IOCTLs can be called using
 * SIOCDEVPRIVATE custom ioctl command.
 * @{
 */
/** Line speed */
#define EQOS_GET_CONNECTED_SPEED        25
/** To set HW AVB configuration from user application */
#define ETHER_AVB_ALGORITHM             27
/** To get current configuration in HW */
#define ETHER_GET_AVB_ALGORITHM         46
/** To configure EST(802.1 bv) in HW */
#define ETHER_CONFIG_EST                49
/** For configure FPE (802.1 bu + 803.2 br) in HW */
#define ETHER_CONFIG_FPE                50
/** @} */

Data Structures

Data structure heater files are in the drive-linux/include folder.

Sample Applications

The sample applications use development utility code and should not be used for production.

802.1Qbu + 802.3br

IEEE 802.1 Qbu stops the transmission of long, non-critical frames to prioritize time-sensitive traffic, addressing the problem of transmission hogging. A major challenge for the timely transfer of critical messages is the presence of legacy traffic sharing the same network. Once a packet travels down a wire, it will block the wire from other packets until the end of the packet is reached.

To counter this issue, IEEE defined two standards- IEEE 802.1Qbu and IEEE802.3br, to support preemption. These standards, which build upon the TAS feature in 802.1Qbv, allow devices to preempt the transmission of non-TSN Ethernet frames (often legacy traffic) to prioritize high priority frames, while allowing the remainder of the interrupted frame to be sent later.

Syntax
.nvether_sample_app <interface name> fpe <TC preemption mask> <RQ>

Parameters

  • TC preemption mask> - preemption- bit corresponding to TC should have value 1 else express/default bit value 0.
  • RQ - Residual/default queue for unfiltered preemptable packets.This value can be any enabled Rx queue except rx queue 0.

Stats: ethtool -S <interface name>

  • mmc_tx_fpe_frag_cnt - Tx fragment count
  • mmc_tx_fpe_hold_req_cnt - Tx set-hold count
  • mmc_rx_packet_reass_err_cnt - Rx reassembly error
  • mmc_rx_packet_smd_err_cnt - Rx SMD error
  • mmc_rx_packet_asm_ok_cnt - Rx assembly ok
  • mmc_rx_fpe_fragment_cnt - Rx fragment count.
Note:
  • Rx Queue 0 can not be RQ
  • Please use ethtool -S <interface name> to get stats related to FPE
  • Use the primary interface i.e eqos_0, mgbe2_0, etc. for configuration
  • FPE and MACSEC don’t coexist incase of MGBE HW due to HW limitation.
  • FPE is configured when peer device supports FPE and responds to verify packet(SMD-V).

Example

  • To set preemption for TC 1 and TC 2 - (bit value representation rep 0x6), and RQ 2
    • nvether_sample_app <interface name> fpe 0x6 2
  • To disable TX preemption
    • nvether_sample_app <interface name> fpe 0x0 2

802.1Qbv

Traffic scheduling allows for different traffic classes to coexist with competing priorities on the same network. IEEE 802.1Qbv and IEEE 802.1Qbu work together to help manage this coexistence. IEEE 802.1 Qbv and IEEE 802.1Qbu can prioritize different traffic classes and enable time-sensitive data.

Devices/systems with IEEE 802.1Qbv can prioritize TSN Ethernet frames on a schedule, while non-TSN Ethernet frames to be transmitted on a best-effort basis around the TSN frames. The 802.1Qbv standard defines up to eight queues per port for forwarding traffic where each frame is assigned to a queue based on a QoS priority. To control the flow of queued traffic to a TSN enabled switch, this standard defines a time-aware shaper (TAS) mechanism that moderates queue traffic, preventing delays during scheduled transmission. Put simply, a gate in front of each queue opens at a specific point in time for time-sensitive traffic over standard (non-TSN) Ethernet packets. PTP should be initialized to make TSN working on DUT.

Syntax

nvether_sample_app <interface name> est <enable/disable> <base-time> <base-time offset>
 <cycle time> <number of GCL entry> <GCL-entries>

Parameters

  • enable - 1 and disable - 0
  • base-time <nsec> <sec> put 0 0 if not sure - Value in decimal. If both values are 0 Driver will get PTP current time from MAC HW registers and add the base time offset into it.
  • base-time offset <nsec> <sec> - Value decimal. This offset is given to start a new GCL from base time value + offset.
  • cycle time <nsec> <sec> - Value in HEX. - ONE GCL full cycle time.
  • number of GCL entry max index 255 - value in decimal
  • GCL entries
    • [0x<8 bit gate mask> <24 bit interval - value in ns>]
    • [0x<8 bit gate mask> <24 bit interval - value in ns>]
    • :
    • :
    • [0x<8 bit gate mask> <24 bit interval in ns>]
Note:
  • When EST and FPE are enabled, bit 0 of the gate mask represents set-and-hold. In this case preemption is enabled for TC 0.
  • When only EST is enabled, all bits of the gate mask represent open-and-close. In this case all TC are expressed TC.
  • Disable tx flow control, such as ethtool -A <interface name> tx off rx off autoneg off
  • Use the primary interface, such as eqos_0, mgbe2_0 to configuration

Stats: ethtool -S <interface name>

  • const_gate_ctr_err - CGCE error count
  • head_of_line_blk_sch - Head of line block due to scheduling count
  • hlbs_q[0] - Head of line block due to scheduling count for TC 0
  • hlbs_q[1] - Head of line block due to scheduling count for TC 1
  • hlbs_q[2] - Head of line block due to scheduling count for TC 2
  • hlbs_q[3] - Head of line block due to scheduling count for TC 3
  • Hlbs_q[4] - Head of line block due to scheduling count for TC 4
  • hlbs_q[5] - Head of line block due to scheduling count for TC 5
  • hlbs_q[6] - Head of line block due to scheduling count for TC 6
  • hlbs_q[7] - Head of line block due to scheduling count for TC 7
  • head_of_line_blk_frm - Head of line block due to size count
  • hlbf_q[0] - Head of line block due to size count for TC0
  • hlbf_q[1] - Head of line block due to size count for TC1
  • hlbf_q[2] - Head of line block due to size count for TC2
  • hlbf_q[3] - Head of line block due to size count for TC3
  • hlbf_q[4] - Head of line block due to size count for TC4
  • hlbf_q[5] - Head of line block due to size count for TC5
  • hlbf_q[6] - Head of line block due to size count for TC6
  • hlbf_q[7] - Head of line block due to size count for TC7
  • base_time_reg_err - Base time wrongly programmed in the past.
  • sw_own_list_complete - GCL switch happens successfully. This will increase this counter by 1.

Example

  • Enable EST with cycle time 16,777,685 ns, 2 GCL entries where in 1st entry for TC0 open for 470 ns and in 2nd entry no gate open for 16,777,685 ns.
    • nvether_sample_app eth1 est 1 0 0 0 10 0x10001d5 0 2 0x10001d6 0xffffff
  • Example for FPE and EST enable with set-and-hold feature
    • Configure FPE as mentioned in 802.1Qbu + 802.3br
    • Configure EST with set-and-hold feature like for case “Enable EST with cycle time 16,777,685 ns, 2 GCL entries where in 1st entry for TC0 open for 470 ns with set-and-hold bit set and in 2nd entry no gate open for 16,777,215 ns”
      nvether_sample_app eth1 est 1 0 0 0 10 0x10001d5 0 2 0x30001d6 0xfffff

Check if the New GCL is Activated

GCL configuration and GCL activation are different. Note that programmed GCL is activated based on base time programmed. Check the results of ethtool -S <interface name> to check if the sw_own_list_complete value updated from the last value or if an error counter increased.

802.1Qav

Originally developed to meet the bandwidth requirements of audio/video streams while preserving bandwidth for best effort traffic, IEEE 802.1Qav, known as Forwarding and Queueing for Time-Sensitive Streams (FQTSS) and later integrated into 802.1Q, defines a credit-based traffic shaper for reserving bandwidth for A/V streams in a bridged network.

In bridges, reserved A/V stream traffic is prioritized over best effort traffic as long as sufficient credits are available to transmit the higher-priority A/V data. As with end stations sourcing stream data, the credit-based traffic shaper results in stream data distributed evenly across a bridged network over time

.

Syntax

nvether_sample_app  <interface name> avb <qinx> <algorithm_value> <bw> <credit_control> <tcinx>

Parameters

  • qinx - Tx Queue index
  • algorithm value
    • 0 - Default (strict priority for EQOS and EST for MGBE)
    • 1 - CBS (credit based shaper)
  • bw - Value in terms of percentage of bandwidth to be allocated (1-100)
  • credit_control
    • 0 - disabled credit_control. The credit accumulates even when there is no packet waiting in TC<n> and another TC is transmitting.
    • 1 - enabled credit_control. When there is no packet waiting in TC<n> and other TC is transmitting, no credit is accumulated.
  • tcinx - TC mapping for <qinx>
Note:
  • credit_control is applicable for cbs only. CBS configuration is per TC.
  • Use the primary interface, such as eqos_0, mgbe2_0 for configuration.

Example

    • Give 20 % bandwidth to TxQ/TC 2.
      nvether_sample_app <interface name> avb 2 1 20 1 2
    • Reset to default tx selection algorithm for TxQ/TC 2
      nvether_sample_app <interface name> avb 2 0 20 1 2

VLAN(802.1Q)

In Linux, to create VLAN and MAP the ingress and egress priority to SKB priority following Linux standard tools and utilities can be used. Example commands are as follows:

ip link add link eth0 name eth0.5 type vlan id 5
ip addr add 10.0.1.6/24 brd 10.0.1.255 dev eth0.5
ip link set dev eth0.5 up
 
ip link add link eth0 name eth0.5 type vlan id 5 egress 0:1 1:2 4:4

In the previous command, the internal skb prio 0 is mapped to VLAN prio 1, skb prio 1 to VLAN prio 2 and 4 to 4.

You can also use in built application vconfig such as vconfig set_egress_map [vlan-name] [skb_priority] [vlan_qos]

PTP (802.1AS) - 2 step PTP

Nodes in the TSN network communicate with each other in real time and need a shared understanding of time to agree on corrective actions, recognize each other’s state, and cooperate together.

The IEEE 802.1AS project created a profile of the IEEE 1588 PTP synchronization protocol for TSN. This profile will enable clock synchronization compatibility between different TSN devices. 802.1AS also addresses support for fault tolerance and multiple active synchronization masters.