Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 ======================================
0004 Texas Instruments CPSW ethernet driver
0005 ======================================
0006 
0007 Multiqueue & CBS & MQPRIO
0008 =========================
0009 
0010 
0011 The cpsw has 3 CBS shapers for each external ports. This document
0012 describes MQPRIO and CBS Qdisc offload configuration for cpsw driver
0013 based on examples. It potentially can be used in audio video bridging
0014 (AVB) and time sensitive networking (TSN).
0015 
0016 The following examples were tested on AM572x EVM and BBB boards.
0017 
0018 Test setup
0019 ==========
0020 
0021 Under consideration two examples with AM572x EVM running cpsw driver
0022 in dual_emac mode.
0023 
0024 Several prerequisites:
0025 
0026 - TX queues must be rated starting from txq0 that has highest priority
0027 - Traffic classes are used starting from 0, that has highest priority
0028 - CBS shapers should be used with rated queues
0029 - The bandwidth for CBS shapers has to be set a little bit more then
0030   potential incoming rate, thus, rate of all incoming tx queues has
0031   to be a little less
0032 - Real rates can differ, due to discreetness
0033 - Map skb-priority to txq is not enough, also skb-priority to l2 prio
0034   map has to be created with ip or vconfig tool
0035 - Any l2/socket prio (0 - 7) for classes can be used, but for
0036   simplicity default values are used: 3 and 2
0037 - only 2 classes tested: A and B, but checked and can work with more,
0038   maximum allowed 4, but only for 3 rate can be set.
0039 
0040 Test setup for examples
0041 =======================
0042 
0043 ::
0044 
0045                                         +-------------------------------+
0046                                         |--+                            |
0047                                         |  |      Workstation0          |
0048                                         |E |  MAC 18:03:73:66:87:42     |
0049     +-----------------------------+  +--|t |                            |
0050     |                    | 1  | E |  |  |h |./tsn_listener -d \         |
0051     |  Target board:     | 0  | t |--+  |0 | 18:03:73:66:87:42 -i eth0 \|
0052     |  AM572x EVM        | 0  | h |     |  | -s 1500                    |
0053     |                    | 0  | 0 |     |--+                            |
0054     |  Only 2 classes:   |Mb  +---|     +-------------------------------+
0055     |  class A, class B  |        |
0056     |                    |    +---|     +-------------------------------+
0057     |                    | 1  | E |     |--+                            |
0058     |                    | 0  | t |     |  |      Workstation1          |
0059     |                    | 0  | h |--+  |E |  MAC 20:cf:30:85:7d:fd     |
0060     |                    |Mb  | 1 |  +--|t |                            |
0061     +-----------------------------+     |h |./tsn_listener -d \         |
0062                                         |0 | 20:cf:30:85:7d:fd -i eth0 \|
0063                                         |  | -s 1500                    |
0064                                         |--+                            |
0065                                         +-------------------------------+
0066 
0067 
0068 Example 1: One port tx AVB configuration scheme for target board
0069 ----------------------------------------------------------------
0070 
0071 (prints and scheme for AM572x evm, applicable for single port boards)
0072 
0073 - tc - traffic class
0074 - txq - transmit queue
0075 - p - priority
0076 - f - fifo (cpsw fifo)
0077 - S - shaper configured
0078 
0079 ::
0080 
0081     +------------------------------------------------------------------+ u
0082     | +---------------+  +---------------+  +------+ +------+          | s
0083     | |               |  |               |  |      | |      |          | e
0084     | | App 1         |  | App 2         |  | Apps | | Apps |          | r
0085     | | Class A       |  | Class B       |  | Rest | | Rest |          |
0086     | | Eth0          |  | Eth0          |  | Eth0 | | Eth1 |          | s
0087     | | VLAN100       |  | VLAN100       |  |   |  | |   |  |          | p
0088     | | 40 Mb/s       |  | 20 Mb/s       |  |   |  | |   |  |          | a
0089     | | SO_PRIORITY=3 |  | SO_PRIORITY=2 |  |   |  | |   |  |          | c
0090     | |   |           |  |   |           |  |   |  | |   |  |          | e
0091     | +---|-----------+  +---|-----------+  +---|--+ +---|--+          |
0092     +-----|------------------|------------------|--------|-------------+
0093         +-+     +------------+                  |        |
0094         |       |             +-----------------+     +--+
0095         |       |             |                       |
0096     +---|-------|-------------|-----------------------|----------------+
0097     | +----+ +----+ +----+ +----+                   +----+             |
0098     | | p3 | | p2 | | p1 | | p0 |                   | p0 |             | k
0099     | \    / \    / \    / \    /                   \    /             | e
0100     |  \  /   \  /   \  /   \  /                     \  /              | r
0101     |   \/     \/     \/     \/                       \/               | n
0102     |    |     |             |                        |                | e
0103     |    |     |       +-----+                        |                | l
0104     |    |     |       |                              |                |
0105     | +----+ +----+ +----+                          +----+             | s
0106     | |tc0 | |tc1 | |tc2 |                          |tc0 |             | p
0107     | \    / \    / \    /                          \    /             | a
0108     |  \  /   \  /   \  /                            \  /              | c
0109     |   \/     \/     \/                              \/               | e
0110     |   |      |       +-----+                        |                |
0111     |   |      |       |     |                        |                |
0112     |   |      |       |     |                        |                |
0113     |   |      |       |     |                        |                |
0114     | +----+ +----+ +----+ +----+                   +----+             |
0115     | |txq0| |txq1| |txq2| |txq3|                   |txq4|             |
0116     | \    / \    / \    / \    /                   \    /             |
0117     |  \  /   \  /   \  /   \  /                     \  /              |
0118     |   \/     \/     \/     \/                       \/               |
0119     | +-|------|------|------|--+                  +--|--------------+ |
0120     | | |      |      |      |  | Eth0.100         |  |     Eth1     | |
0121     +---|------|------|------|------------------------|----------------+
0122         |      |      |      |                        |
0123         p      p      p      p                        |
0124         3      2      0-1, 4-7  <- L2 priority        |
0125         |      |      |      |                        |
0126         |      |      |      |                        |
0127     +---|------|------|------|------------------------|----------------+
0128     |   |      |      |      |             |----------+                |
0129     | +----+ +----+ +----+ +----+       +----+                         |
0130     | |dma7| |dma6| |dma5| |dma4|       |dma3|                         |
0131     | \    / \    / \    / \    /       \    /                         | c
0132     |  \S /   \S /   \  /   \  /         \  /                          | p
0133     |   \/     \/     \/     \/           \/                           | s
0134     |   |      |      | +-----            |                            | w
0135     |   |      |      | |                 |                            |
0136     |   |      |      | |                 |                            | d
0137     | +----+ +----+ +----+p            p+----+                         | r
0138     | |    | |    | |    |o            o|    |                         | i
0139     | | f3 | | f2 | | f0 |r            r| f0 |                         | v
0140     | |tc0 | |tc1 | |tc2 |t            t|tc0 |                         | e
0141     | \CBS / \CBS / \CBS /1            2\CBS /                         | r
0142     |  \S /   \S /   \  /                \  /                          |
0143     |   \/     \/     \/                  \/                           |
0144     +------------------------------------------------------------------+
0145 
0146 
0147 1) ::
0148 
0149 
0150         // Add 4 tx queues, for interface Eth0, and 1 tx queue for Eth1
0151         $ ethtool -L eth0 rx 1 tx 5
0152         rx unmodified, ignoring
0153 
0154 2) ::
0155 
0156         // Check if num of queues is set correctly:
0157         $ ethtool -l eth0
0158         Channel parameters for eth0:
0159         Pre-set maximums:
0160         RX:             8
0161         TX:             8
0162         Other:          0
0163         Combined:       0
0164         Current hardware settings:
0165         RX:             1
0166         TX:             5
0167         Other:          0
0168         Combined:       0
0169 
0170 3) ::
0171 
0172         // TX queues must be rated starting from 0, so set bws for tx0 and tx1
0173         // Set rates 40 and 20 Mb/s appropriately.
0174         // Pay attention, real speed can differ a bit due to discreetness.
0175         // Leave last 2 tx queues not rated.
0176         $ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate
0177         $ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate
0178 
0179 4) ::
0180 
0181         // Check maximum rate of tx (cpdma) queues:
0182         $ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate
0183         40
0184         20
0185         0
0186         0
0187         0
0188 
0189 5) ::
0190 
0191         // Map skb->priority to traffic class:
0192         // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
0193         // Map traffic class to transmit queue:
0194         // tc0 -> txq0, tc1 -> txq1, tc2 -> (txq2, txq3)
0195         $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
0196         map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
0197 
0198 5a) ::
0199 
0200         // As two interface sharing same set of tx queues, assign all traffic
0201         // coming to interface Eth1 to separate queue in order to not mix it
0202         // with traffic from interface Eth0, so use separate txq to send
0203         // packets to Eth1, so all prio -> tc0 and tc0 -> txq4
0204         // Here hw 0, so here still default configuration for eth1 in hw
0205         $ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 1 \
0206         map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues 1@4 hw 0
0207 
0208 6) ::
0209 
0210         // Check classes settings
0211         $ tc -g class show dev eth0
0212         +---(100:ffe2) mqprio
0213         |    +---(100:3) mqprio
0214         |    +---(100:4) mqprio
0215         |
0216         +---(100:ffe1) mqprio
0217         |    +---(100:2) mqprio
0218         |
0219         +---(100:ffe0) mqprio
0220             +---(100:1) mqprio
0221 
0222         $ tc -g class show dev eth1
0223         +---(100:ffe0) mqprio
0224             +---(100:5) mqprio
0225 
0226 7) ::
0227 
0228         // Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc
0229         // Set it +1 Mb for reserve (important!)
0230         // here only idle slope is important, others arg are ignored
0231         // Pay attention, real speed can differ a bit due to discreetness
0232         $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1438 \
0233         hicredit 62 sendslope -959000 idleslope 41000 offload 1
0234         net eth0: set FIFO3 bw = 50
0235 
0236 8) ::
0237 
0238         // Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc:
0239         // Set it +1 Mb for reserve (important!)
0240         $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1468 \
0241         hicredit 65 sendslope -979000 idleslope 21000 offload 1
0242         net eth0: set FIFO2 bw = 30
0243 
0244 9) ::
0245 
0246         // Create vlan 100 to map sk->priority to vlan qos
0247         $ ip link add link eth0 name eth0.100 type vlan id 100
0248         8021q: 802.1Q VLAN Support v1.8
0249         8021q: adding VLAN 0 to HW filter on device eth0
0250         8021q: adding VLAN 0 to HW filter on device eth1
0251         net eth0: Adding vlanid 100 to vlan filter
0252 
0253 10) ::
0254 
0255         // Map skb->priority to L2 prio, 1 to 1
0256         $ ip link set eth0.100 type vlan \
0257         egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
0258 
0259 11) ::
0260 
0261         // Check egress map for vlan 100
0262         $ cat /proc/net/vlan/eth0.100
0263         [...]
0264         INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
0265         EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
0266 
0267 12) ::
0268 
0269         // Run your appropriate tools with socket option "SO_PRIORITY"
0270         // to 3 for class A and/or to 2 for class B
0271         // (I took at https://www.spinics.net/lists/netdev/msg460869.html)
0272         ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500&
0273         ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500&
0274 
0275 13) ::
0276 
0277         // run your listener on workstation (should be in same vlan)
0278         // (I took at https://www.spinics.net/lists/netdev/msg460869.html)
0279         ./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500
0280         Receiving data rate: 39012 kbps
0281         Receiving data rate: 39012 kbps
0282         Receiving data rate: 39012 kbps
0283         Receiving data rate: 39012 kbps
0284         Receiving data rate: 39012 kbps
0285         Receiving data rate: 39012 kbps
0286         Receiving data rate: 39012 kbps
0287         Receiving data rate: 39012 kbps
0288         Receiving data rate: 39012 kbps
0289         Receiving data rate: 39012 kbps
0290         Receiving data rate: 39012 kbps
0291         Receiving data rate: 39012 kbps
0292         Receiving data rate: 39000 kbps
0293 
0294 14) ::
0295 
0296         // Restore default configuration if needed
0297         $ ip link del eth0.100
0298         $ tc qdisc del dev eth1 root
0299         $ tc qdisc del dev eth0 root
0300         net eth0: Prev FIFO2 is shaped
0301         net eth0: set FIFO3 bw = 0
0302         net eth0: set FIFO2 bw = 0
0303         $ ethtool -L eth0 rx 1 tx 1
0304 
0305 Example 2: Two port tx AVB configuration scheme for target board
0306 ----------------------------------------------------------------
0307 
0308 (prints and scheme for AM572x evm, for dual emac boards only)
0309 
0310 ::
0311 
0312     +------------------------------------------------------------------+ u
0313     | +----------+  +----------+  +------+  +----------+  +----------+ | s
0314     | |          |  |          |  |      |  |          |  |          | | e
0315     | | App 1    |  | App 2    |  | Apps |  | App 3    |  | App 4    | | r
0316     | | Class A  |  | Class B  |  | Rest |  | Class B  |  | Class A  | |
0317     | | Eth0     |  | Eth0     |  |   |  |  | Eth1     |  | Eth1     | | s
0318     | | VLAN100  |  | VLAN100  |  |   |  |  | VLAN100  |  | VLAN100  | | p
0319     | | 40 Mb/s  |  | 20 Mb/s  |  |   |  |  | 10 Mb/s  |  | 30 Mb/s  | | a
0320     | | SO_PRI=3 |  | SO_PRI=2 |  |   |  |  | SO_PRI=3 |  | SO_PRI=2 | | c
0321     | |   |      |  |   |      |  |   |  |  |   |      |  |   |      | | e
0322     | +---|------+  +---|------+  +---|--+  +---|------+  +---|------+ |
0323     +-----|-------------|-------------|---------|-------------|--------+
0324         +-+     +-------+             |         +----------+  +----+
0325         |       |             +-------+------+             |       |
0326         |       |             |              |             |       |
0327     +---|-------|-------------|--------------|-------------|-------|---+
0328     | +----+ +----+ +----+ +----+          +----+ +----+ +----+ +----+ |
0329     | | p3 | | p2 | | p1 | | p0 |          | p0 | | p1 | | p2 | | p3 | | k
0330     | \    / \    / \    / \    /          \    / \    / \    / \    / | e
0331     |  \  /   \  /   \  /   \  /            \  /   \  /   \  /   \  /  | r
0332     |   \/     \/     \/     \/              \/     \/     \/     \/   | n
0333     |   |      |             |                |             |      |   | e
0334     |   |      |        +----+                +----+        |      |   | l
0335     |   |      |        |                          |        |      |   |
0336     | +----+ +----+ +----+                        +----+ +----+ +----+ | s
0337     | |tc0 | |tc1 | |tc2 |                        |tc2 | |tc1 | |tc0 | | p
0338     | \    / \    / \    /                        \    / \    / \    / | a
0339     |  \  /   \  /   \  /                          \  /   \  /   \  /  | c
0340     |   \/     \/     \/                            \/     \/     \/   | e
0341     |   |      |       +-----+                +-----+      |       |   |
0342     |   |      |       |     |                |     |      |       |   |
0343     |   |      |       |     |                |     |      |       |   |
0344     |   |      |       |     |    E      E    |     |      |       |   |
0345     | +----+ +----+ +----+ +----+ t      t +----+ +----+ +----+ +----+ |
0346     | |txq0| |txq1| |txq4| |txq5| h      h |txq6| |txq7| |txq3| |txq2| |
0347     | \    / \    / \    / \    / 0      1 \    / \    / \    / \    / |
0348     |  \  /   \  /   \  /   \  /  .      .  \  /   \  /   \  /   \  /  |
0349     |   \/     \/     \/     \/   1      1   \/     \/     \/     \/   |
0350     | +-|------|------|------|--+ 0      0 +-|------|------|------|--+ |
0351     | | |      |      |      |  | 0      0 | |      |      |      |  | |
0352     +---|------|------|------|---------------|------|------|------|----+
0353         |      |      |      |               |      |      |      |
0354         p      p      p      p               p      p      p      p
0355         3      2      0-1, 4-7   <-L2 pri->  0-1, 4-7      2      3
0356         |      |      |      |               |      |      |      |
0357         |      |      |      |               |      |      |      |
0358     +---|------|------|------|---------------|------|------|------|----+
0359     |   |      |      |      |               |      |      |      |    |
0360     | +----+ +----+ +----+ +----+          +----+ +----+ +----+ +----+ |
0361     | |dma7| |dma6| |dma3| |dma2|          |dma1| |dma0| |dma4| |dma5| |
0362     | \    / \    / \    / \    /          \    / \    / \    / \    / | c
0363     |  \S /   \S /   \  /   \  /            \  /   \  /   \S /   \S /  | p
0364     |   \/     \/     \/     \/              \/     \/     \/     \/   | s
0365     |   |      |      | +-----                |      |      |      |   | w
0366     |   |      |      | |                     +----+ |      |      |   |
0367     |   |      |      | |                          | |      |      |   | d
0368     | +----+ +----+ +----+p                      p+----+ +----+ +----+ | r
0369     | |    | |    | |    |o                      o|    | |    | |    | | i
0370     | | f3 | | f2 | | f0 |r        CPSW          r| f3 | | f2 | | f0 | | v
0371     | |tc0 | |tc1 | |tc2 |t                      t|tc0 | |tc1 | |tc2 | | e
0372     | \CBS / \CBS / \CBS /1                      2\CBS / \CBS / \CBS / | r
0373     |  \S /   \S /   \  /                          \S /   \S /   \  /  |
0374     |   \/     \/     \/                            \/     \/     \/   |
0375     +------------------------------------------------------------------+
0376     ========================================Eth==========================>
0377 
0378 1) ::
0379 
0380         // Add 8 tx queues, for interface Eth0, but they are common, so are accessed
0381         // by two interfaces Eth0 and Eth1.
0382         $ ethtool -L eth1 rx 1 tx 8
0383         rx unmodified, ignoring
0384 
0385 2) ::
0386 
0387         // Check if num of queues is set correctly:
0388         $ ethtool -l eth0
0389         Channel parameters for eth0:
0390         Pre-set maximums:
0391         RX:             8
0392         TX:             8
0393         Other:          0
0394         Combined:       0
0395         Current hardware settings:
0396         RX:             1
0397         TX:             8
0398         Other:          0
0399         Combined:       0
0400 
0401 3) ::
0402 
0403         // TX queues must be rated starting from 0, so set bws for tx0 and tx1 for Eth0
0404         // and for tx2 and tx3 for Eth1. That is, rates 40 and 20 Mb/s appropriately
0405         // for Eth0 and 30 and 10 Mb/s for Eth1.
0406         // Real speed can differ a bit due to discreetness
0407         // Leave last 4 tx queues as not rated
0408         $ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate
0409         $ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate
0410         $ echo 30 > /sys/class/net/eth1/queues/tx-2/tx_maxrate
0411         $ echo 10 > /sys/class/net/eth1/queues/tx-3/tx_maxrate
0412 
0413 4) ::
0414 
0415         // Check maximum rate of tx (cpdma) queues:
0416         $ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate
0417         40
0418         20
0419         30
0420         10
0421         0
0422         0
0423         0
0424         0
0425 
0426 5) ::
0427 
0428         // Map skb->priority to traffic class for Eth0:
0429         // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
0430         // Map traffic class to transmit queue:
0431         // tc0 -> txq0, tc1 -> txq1, tc2 -> (txq4, txq5)
0432         $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
0433         map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@4 hw 1
0434 
0435 6) ::
0436 
0437         // Check classes settings
0438         $ tc -g class show dev eth0
0439         +---(100:ffe2) mqprio
0440         |    +---(100:5) mqprio
0441         |    +---(100:6) mqprio
0442         |
0443         +---(100:ffe1) mqprio
0444         |    +---(100:2) mqprio
0445         |
0446         +---(100:ffe0) mqprio
0447             +---(100:1) mqprio
0448 
0449 7) ::
0450 
0451         // Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc for Eth0
0452         // here only idle slope is important, others ignored
0453         // Real speed can differ a bit due to discreetness
0454         $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1470 \
0455         hicredit 62 sendslope -959000 idleslope 41000 offload 1
0456         net eth0: set FIFO3 bw = 50
0457 
0458 8) ::
0459 
0460         // Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc for Eth0
0461         $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \
0462         hicredit 65 sendslope -979000 idleslope 21000 offload 1
0463         net eth0: set FIFO2 bw = 30
0464 
0465 9) ::
0466 
0467         // Create vlan 100 to map sk->priority to vlan qos for Eth0
0468         $ ip link add link eth0 name eth0.100 type vlan id 100
0469         net eth0: Adding vlanid 100 to vlan filter
0470 
0471 10) ::
0472 
0473         // Map skb->priority to L2 prio for Eth0.100, one to one
0474         $ ip link set eth0.100 type vlan \
0475         egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
0476 
0477 11) ::
0478 
0479         // Check egress map for vlan 100
0480         $ cat /proc/net/vlan/eth0.100
0481         [...]
0482         INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
0483         EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
0484 
0485 12) ::
0486 
0487         // Map skb->priority to traffic class for Eth1:
0488         // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
0489         // Map traffic class to transmit queue:
0490         // tc0 -> txq2, tc1 -> txq3, tc2 -> (txq6, txq7)
0491         $ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 3 \
0492         map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@2 1@3 2@6 hw 1
0493 
0494 13) ::
0495 
0496         // Check classes settings
0497         $ tc -g class show dev eth1
0498         +---(100:ffe2) mqprio
0499         |    +---(100:7) mqprio
0500         |    +---(100:8) mqprio
0501         |
0502         +---(100:ffe1) mqprio
0503         |    +---(100:4) mqprio
0504         |
0505         +---(100:ffe0) mqprio
0506             +---(100:3) mqprio
0507 
0508 14) ::
0509 
0510         // Set rate for class A - 31 Mbit (tc0, txq2) using CBS Qdisc for Eth1
0511         // here only idle slope is important, others ignored, but calculated
0512         // for interface speed - 100Mb for eth1 port.
0513         // Set it +1 Mb for reserve (important!)
0514         $ tc qdisc add dev eth1 parent 100:3 cbs locredit -1035 \
0515         hicredit 465 sendslope -69000 idleslope 31000 offload 1
0516         net eth1: set FIFO3 bw = 31
0517 
0518 15) ::
0519 
0520         // Set rate for class B - 11 Mbit (tc1, txq3) using CBS Qdisc for Eth1
0521         // Set it +1 Mb for reserve (important!)
0522         $ tc qdisc add dev eth1 parent 100:4 cbs locredit -1335 \
0523         hicredit 405 sendslope -89000 idleslope 11000 offload 1
0524         net eth1: set FIFO2 bw = 11
0525 
0526 16) ::
0527 
0528         // Create vlan 100 to map sk->priority to vlan qos for Eth1
0529         $ ip link add link eth1 name eth1.100 type vlan id 100
0530         net eth1: Adding vlanid 100 to vlan filter
0531 
0532 17) ::
0533 
0534         // Map skb->priority to L2 prio for Eth1.100, one to one
0535         $ ip link set eth1.100 type vlan \
0536         egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
0537 
0538 18) ::
0539 
0540         // Check egress map for vlan 100
0541         $ cat /proc/net/vlan/eth1.100
0542         [...]
0543         INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
0544         EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
0545 
0546 19) ::
0547 
0548         // Run appropriate tools with socket option "SO_PRIORITY" to 3
0549         // for class A and to 2 for class B. For both interfaces
0550         ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500&
0551         ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500&
0552         ./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p2 -s 1500&
0553         ./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p3 -s 1500&
0554 
0555 20) ::
0556 
0557         // run your listener on workstation (should be in same vlan)
0558         // (I took at https://www.spinics.net/lists/netdev/msg460869.html)
0559         ./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500
0560         Receiving data rate: 39012 kbps
0561         Receiving data rate: 39012 kbps
0562         Receiving data rate: 39012 kbps
0563         Receiving data rate: 39012 kbps
0564         Receiving data rate: 39012 kbps
0565         Receiving data rate: 39012 kbps
0566         Receiving data rate: 39012 kbps
0567         Receiving data rate: 39012 kbps
0568         Receiving data rate: 39012 kbps
0569         Receiving data rate: 39012 kbps
0570         Receiving data rate: 39012 kbps
0571         Receiving data rate: 39012 kbps
0572         Receiving data rate: 39000 kbps
0573 
0574 21) ::
0575 
0576         // Restore default configuration if needed
0577         $ ip link del eth1.100
0578         $ ip link del eth0.100
0579         $ tc qdisc del dev eth1 root
0580         net eth1: Prev FIFO2 is shaped
0581         net eth1: set FIFO3 bw = 0
0582         net eth1: set FIFO2 bw = 0
0583         $ tc qdisc del dev eth0 root
0584         net eth0: Prev FIFO2 is shaped
0585         net eth0: set FIFO3 bw = 0
0586         net eth0: set FIFO2 bw = 0
0587         $ ethtool -L eth0 rx 1 tx 1