Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: networking: device drivers: convert ti/cpsw.txt to ReST

- add SPDX header;
- adjust titles and chapters, adding proper markups;
- mark code blocks and literals as such;
- adjust identation, whitespaces and blank lines where needed;
- add to networking/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mauro Carvalho Chehab and committed by
David S. Miller
6f22789d 8470f18e

+588 -541
+1
Documentation/networking/device_drivers/index.rst
··· 48 48 sb1000 49 49 smsc/smc9 50 50 ti/cpsw_switchdev 51 + ti/cpsw 51 52 52 53 .. only:: subproject and html 53 54
+587
Documentation/networking/device_drivers/ti/cpsw.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ====================================== 4 + Texas Instruments CPSW ethernet driver 5 + ====================================== 6 + 7 + Multiqueue & CBS & MQPRIO 8 + ========================= 9 + 10 + 11 + The cpsw has 3 CBS shapers for each external ports. This document 12 + describes MQPRIO and CBS Qdisc offload configuration for cpsw driver 13 + based on examples. It potentially can be used in audio video bridging 14 + (AVB) and time sensitive networking (TSN). 15 + 16 + The following examples were tested on AM572x EVM and BBB boards. 17 + 18 + Test setup 19 + ========== 20 + 21 + Under consideration two examples with AM572x EVM running cpsw driver 22 + in dual_emac mode. 23 + 24 + Several prerequisites: 25 + 26 + - TX queues must be rated starting from txq0 that has highest priority 27 + - Traffic classes are used starting from 0, that has highest priority 28 + - CBS shapers should be used with rated queues 29 + - The bandwidth for CBS shapers has to be set a little bit more then 30 + potential incoming rate, thus, rate of all incoming tx queues has 31 + to be a little less 32 + - Real rates can differ, due to discreetness 33 + - Map skb-priority to txq is not enough, also skb-priority to l2 prio 34 + map has to be created with ip or vconfig tool 35 + - Any l2/socket prio (0 - 7) for classes can be used, but for 36 + simplicity default values are used: 3 and 2 37 + - only 2 classes tested: A and B, but checked and can work with more, 38 + maximum allowed 4, but only for 3 rate can be set. 39 + 40 + Test setup for examples 41 + ======================= 42 + 43 + :: 44 + 45 + +-------------------------------+ 46 + |--+ | 47 + | | Workstation0 | 48 + |E | MAC 18:03:73:66:87:42 | 49 + +-----------------------------+ +--|t | | 50 + | | 1 | E | | |h |./tsn_listener -d \ | 51 + | Target board: | 0 | t |--+ |0 | 18:03:73:66:87:42 -i eth0 \| 52 + | AM572x EVM | 0 | h | | | -s 1500 | 53 + | | 0 | 0 | |--+ | 54 + | Only 2 classes: |Mb +---| +-------------------------------+ 55 + | class A, class B | | 56 + | | +---| +-------------------------------+ 57 + | | 1 | E | |--+ | 58 + | | 0 | t | | | Workstation1 | 59 + | | 0 | h |--+ |E | MAC 20:cf:30:85:7d:fd | 60 + | |Mb | 1 | +--|t | | 61 + +-----------------------------+ |h |./tsn_listener -d \ | 62 + |0 | 20:cf:30:85:7d:fd -i eth0 \| 63 + | | -s 1500 | 64 + |--+ | 65 + +-------------------------------+ 66 + 67 + 68 + Example 1: One port tx AVB configuration scheme for target board 69 + ---------------------------------------------------------------- 70 + 71 + (prints and scheme for AM572x evm, applicable for single port boards) 72 + 73 + - tc - traffic class 74 + - txq - transmit queue 75 + - p - priority 76 + - f - fifo (cpsw fifo) 77 + - S - shaper configured 78 + 79 + :: 80 + 81 + +------------------------------------------------------------------+ u 82 + | +---------------+ +---------------+ +------+ +------+ | s 83 + | | | | | | | | | | e 84 + | | App 1 | | App 2 | | Apps | | Apps | | r 85 + | | Class A | | Class B | | Rest | | Rest | | 86 + | | Eth0 | | Eth0 | | Eth0 | | Eth1 | | s 87 + | | VLAN100 | | VLAN100 | | | | | | | | p 88 + | | 40 Mb/s | | 20 Mb/s | | | | | | | | a 89 + | | SO_PRIORITY=3 | | SO_PRIORITY=2 | | | | | | | | c 90 + | | | | | | | | | | | | | | e 91 + | +---|-----------+ +---|-----------+ +---|--+ +---|--+ | 92 + +-----|------------------|------------------|--------|-------------+ 93 + +-+ +------------+ | | 94 + | | +-----------------+ +--+ 95 + | | | | 96 + +---|-------|-------------|-----------------------|----------------+ 97 + | +----+ +----+ +----+ +----+ +----+ | 98 + | | p3 | | p2 | | p1 | | p0 | | p0 | | k 99 + | \ / \ / \ / \ / \ / | e 100 + | \ / \ / \ / \ / \ / | r 101 + | \/ \/ \/ \/ \/ | n 102 + | | | | | | e 103 + | | | +-----+ | | l 104 + | | | | | | 105 + | +----+ +----+ +----+ +----+ | s 106 + | |tc0 | |tc1 | |tc2 | |tc0 | | p 107 + | \ / \ / \ / \ / | a 108 + | \ / \ / \ / \ / | c 109 + | \/ \/ \/ \/ | e 110 + | | | +-----+ | | 111 + | | | | | | | 112 + | | | | | | | 113 + | | | | | | | 114 + | +----+ +----+ +----+ +----+ +----+ | 115 + | |txq0| |txq1| |txq2| |txq3| |txq4| | 116 + | \ / \ / \ / \ / \ / | 117 + | \ / \ / \ / \ / \ / | 118 + | \/ \/ \/ \/ \/ | 119 + | +-|------|------|------|--+ +--|--------------+ | 120 + | | | | | | | Eth0.100 | | Eth1 | | 121 + +---|------|------|------|------------------------|----------------+ 122 + | | | | | 123 + p p p p | 124 + 3 2 0-1, 4-7 <- L2 priority | 125 + | | | | | 126 + | | | | | 127 + +---|------|------|------|------------------------|----------------+ 128 + | | | | | |----------+ | 129 + | +----+ +----+ +----+ +----+ +----+ | 130 + | |dma7| |dma6| |dma5| |dma4| |dma3| | 131 + | \ / \ / \ / \ / \ / | c 132 + | \S / \S / \ / \ / \ / | p 133 + | \/ \/ \/ \/ \/ | s 134 + | | | | +----- | | w 135 + | | | | | | | 136 + | | | | | | | d 137 + | +----+ +----+ +----+p p+----+ | r 138 + | | | | | | |o o| | | i 139 + | | f3 | | f2 | | f0 |r r| f0 | | v 140 + | |tc0 | |tc1 | |tc2 |t t|tc0 | | e 141 + | \CBS / \CBS / \CBS /1 2\CBS / | r 142 + | \S / \S / \ / \ / | 143 + | \/ \/ \/ \/ | 144 + +------------------------------------------------------------------+ 145 + 146 + 147 + 1) :: 148 + 149 + 150 + // Add 4 tx queues, for interface Eth0, and 1 tx queue for Eth1 151 + $ ethtool -L eth0 rx 1 tx 5 152 + rx unmodified, ignoring 153 + 154 + 2) :: 155 + 156 + // Check if num of queues is set correctly: 157 + $ ethtool -l eth0 158 + Channel parameters for eth0: 159 + Pre-set maximums: 160 + RX: 8 161 + TX: 8 162 + Other: 0 163 + Combined: 0 164 + Current hardware settings: 165 + RX: 1 166 + TX: 5 167 + Other: 0 168 + Combined: 0 169 + 170 + 3) :: 171 + 172 + // TX queues must be rated starting from 0, so set bws for tx0 and tx1 173 + // Set rates 40 and 20 Mb/s appropriately. 174 + // Pay attention, real speed can differ a bit due to discreetness. 175 + // Leave last 2 tx queues not rated. 176 + $ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate 177 + $ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate 178 + 179 + 4) :: 180 + 181 + // Check maximum rate of tx (cpdma) queues: 182 + $ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate 183 + 40 184 + 20 185 + 0 186 + 0 187 + 0 188 + 189 + 5) :: 190 + 191 + // Map skb->priority to traffic class: 192 + // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2 193 + // Map traffic class to transmit queue: 194 + // tc0 -> txq0, tc1 -> txq1, tc2 -> (txq2, txq3) 195 + $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \ 196 + 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 197 + 198 + 5a) :: 199 + 200 + // As two interface sharing same set of tx queues, assign all traffic 201 + // coming to interface Eth1 to separate queue in order to not mix it 202 + // with traffic from interface Eth0, so use separate txq to send 203 + // packets to Eth1, so all prio -> tc0 and tc0 -> txq4 204 + // Here hw 0, so here still default configuration for eth1 in hw 205 + $ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 1 \ 206 + map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues 1@4 hw 0 207 + 208 + 6) :: 209 + 210 + // Check classes settings 211 + $ tc -g class show dev eth0 212 + +---(100:ffe2) mqprio 213 + | +---(100:3) mqprio 214 + | +---(100:4) mqprio 215 + | 216 + +---(100:ffe1) mqprio 217 + | +---(100:2) mqprio 218 + | 219 + +---(100:ffe0) mqprio 220 + +---(100:1) mqprio 221 + 222 + $ tc -g class show dev eth1 223 + +---(100:ffe0) mqprio 224 + +---(100:5) mqprio 225 + 226 + 7) :: 227 + 228 + // Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc 229 + // Set it +1 Mb for reserve (important!) 230 + // here only idle slope is important, others arg are ignored 231 + // Pay attention, real speed can differ a bit due to discreetness 232 + $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1438 \ 233 + hicredit 62 sendslope -959000 idleslope 41000 offload 1 234 + net eth0: set FIFO3 bw = 50 235 + 236 + 8) :: 237 + 238 + // Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc: 239 + // Set it +1 Mb for reserve (important!) 240 + $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1468 \ 241 + hicredit 65 sendslope -979000 idleslope 21000 offload 1 242 + net eth0: set FIFO2 bw = 30 243 + 244 + 9) :: 245 + 246 + // Create vlan 100 to map sk->priority to vlan qos 247 + $ ip link add link eth0 name eth0.100 type vlan id 100 248 + 8021q: 802.1Q VLAN Support v1.8 249 + 8021q: adding VLAN 0 to HW filter on device eth0 250 + 8021q: adding VLAN 0 to HW filter on device eth1 251 + net eth0: Adding vlanid 100 to vlan filter 252 + 253 + 10) :: 254 + 255 + // Map skb->priority to L2 prio, 1 to 1 256 + $ ip link set eth0.100 type vlan \ 257 + egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 258 + 259 + 11) :: 260 + 261 + // Check egress map for vlan 100 262 + $ cat /proc/net/vlan/eth0.100 263 + [...] 264 + INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 265 + EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 266 + 267 + 12) :: 268 + 269 + // Run your appropriate tools with socket option "SO_PRIORITY" 270 + // to 3 for class A and/or to 2 for class B 271 + // (I took at https://www.spinics.net/lists/netdev/msg460869.html) 272 + ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500& 273 + ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500& 274 + 275 + 13) :: 276 + 277 + // run your listener on workstation (should be in same vlan) 278 + // (I took at https://www.spinics.net/lists/netdev/msg460869.html) 279 + ./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500 280 + Receiving data rate: 39012 kbps 281 + Receiving data rate: 39012 kbps 282 + Receiving data rate: 39012 kbps 283 + Receiving data rate: 39012 kbps 284 + Receiving data rate: 39012 kbps 285 + Receiving data rate: 39012 kbps 286 + Receiving data rate: 39012 kbps 287 + Receiving data rate: 39012 kbps 288 + Receiving data rate: 39012 kbps 289 + Receiving data rate: 39012 kbps 290 + Receiving data rate: 39012 kbps 291 + Receiving data rate: 39012 kbps 292 + Receiving data rate: 39000 kbps 293 + 294 + 14) :: 295 + 296 + // Restore default configuration if needed 297 + $ ip link del eth0.100 298 + $ tc qdisc del dev eth1 root 299 + $ tc qdisc del dev eth0 root 300 + net eth0: Prev FIFO2 is shaped 301 + net eth0: set FIFO3 bw = 0 302 + net eth0: set FIFO2 bw = 0 303 + $ ethtool -L eth0 rx 1 tx 1 304 + 305 + Example 2: Two port tx AVB configuration scheme for target board 306 + ---------------------------------------------------------------- 307 + 308 + (prints and scheme for AM572x evm, for dual emac boards only) 309 + 310 + :: 311 + 312 + +------------------------------------------------------------------+ u 313 + | +----------+ +----------+ +------+ +----------+ +----------+ | s 314 + | | | | | | | | | | | | e 315 + | | App 1 | | App 2 | | Apps | | App 3 | | App 4 | | r 316 + | | Class A | | Class B | | Rest | | Class B | | Class A | | 317 + | | Eth0 | | Eth0 | | | | | Eth1 | | Eth1 | | s 318 + | | VLAN100 | | VLAN100 | | | | | VLAN100 | | VLAN100 | | p 319 + | | 40 Mb/s | | 20 Mb/s | | | | | 10 Mb/s | | 30 Mb/s | | a 320 + | | SO_PRI=3 | | SO_PRI=2 | | | | | SO_PRI=3 | | SO_PRI=2 | | c 321 + | | | | | | | | | | | | | | | | | e 322 + | +---|------+ +---|------+ +---|--+ +---|------+ +---|------+ | 323 + +-----|-------------|-------------|---------|-------------|--------+ 324 + +-+ +-------+ | +----------+ +----+ 325 + | | +-------+------+ | | 326 + | | | | | | 327 + +---|-------|-------------|--------------|-------------|-------|---+ 328 + | +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ | 329 + | | p3 | | p2 | | p1 | | p0 | | p0 | | p1 | | p2 | | p3 | | k 330 + | \ / \ / \ / \ / \ / \ / \ / \ / | e 331 + | \ / \ / \ / \ / \ / \ / \ / \ / | r 332 + | \/ \/ \/ \/ \/ \/ \/ \/ | n 333 + | | | | | | | | e 334 + | | | +----+ +----+ | | | l 335 + | | | | | | | | 336 + | +----+ +----+ +----+ +----+ +----+ +----+ | s 337 + | |tc0 | |tc1 | |tc2 | |tc2 | |tc1 | |tc0 | | p 338 + | \ / \ / \ / \ / \ / \ / | a 339 + | \ / \ / \ / \ / \ / \ / | c 340 + | \/ \/ \/ \/ \/ \/ | e 341 + | | | +-----+ +-----+ | | | 342 + | | | | | | | | | | 343 + | | | | | | | | | | 344 + | | | | | E E | | | | | 345 + | +----+ +----+ +----+ +----+ t t +----+ +----+ +----+ +----+ | 346 + | |txq0| |txq1| |txq4| |txq5| h h |txq6| |txq7| |txq3| |txq2| | 347 + | \ / \ / \ / \ / 0 1 \ / \ / \ / \ / | 348 + | \ / \ / \ / \ / . . \ / \ / \ / \ / | 349 + | \/ \/ \/ \/ 1 1 \/ \/ \/ \/ | 350 + | +-|------|------|------|--+ 0 0 +-|------|------|------|--+ | 351 + | | | | | | | 0 0 | | | | | | | 352 + +---|------|------|------|---------------|------|------|------|----+ 353 + | | | | | | | | 354 + p p p p p p p p 355 + 3 2 0-1, 4-7 <-L2 pri-> 0-1, 4-7 2 3 356 + | | | | | | | | 357 + | | | | | | | | 358 + +---|------|------|------|---------------|------|------|------|----+ 359 + | | | | | | | | | | 360 + | +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ | 361 + | |dma7| |dma6| |dma3| |dma2| |dma1| |dma0| |dma4| |dma5| | 362 + | \ / \ / \ / \ / \ / \ / \ / \ / | c 363 + | \S / \S / \ / \ / \ / \ / \S / \S / | p 364 + | \/ \/ \/ \/ \/ \/ \/ \/ | s 365 + | | | | +----- | | | | | w 366 + | | | | | +----+ | | | | 367 + | | | | | | | | | | d 368 + | +----+ +----+ +----+p p+----+ +----+ +----+ | r 369 + | | | | | | |o o| | | | | | | i 370 + | | f3 | | f2 | | f0 |r CPSW r| f3 | | f2 | | f0 | | v 371 + | |tc0 | |tc1 | |tc2 |t t|tc0 | |tc1 | |tc2 | | e 372 + | \CBS / \CBS / \CBS /1 2\CBS / \CBS / \CBS / | r 373 + | \S / \S / \ / \S / \S / \ / | 374 + | \/ \/ \/ \/ \/ \/ | 375 + +------------------------------------------------------------------+ 376 + ========================================Eth==========================> 377 + 378 + 1) :: 379 + 380 + // Add 8 tx queues, for interface Eth0, but they are common, so are accessed 381 + // by two interfaces Eth0 and Eth1. 382 + $ ethtool -L eth1 rx 1 tx 8 383 + rx unmodified, ignoring 384 + 385 + 2) :: 386 + 387 + // Check if num of queues is set correctly: 388 + $ ethtool -l eth0 389 + Channel parameters for eth0: 390 + Pre-set maximums: 391 + RX: 8 392 + TX: 8 393 + Other: 0 394 + Combined: 0 395 + Current hardware settings: 396 + RX: 1 397 + TX: 8 398 + Other: 0 399 + Combined: 0 400 + 401 + 3) :: 402 + 403 + // TX queues must be rated starting from 0, so set bws for tx0 and tx1 for Eth0 404 + // and for tx2 and tx3 for Eth1. That is, rates 40 and 20 Mb/s appropriately 405 + // for Eth0 and 30 and 10 Mb/s for Eth1. 406 + // Real speed can differ a bit due to discreetness 407 + // Leave last 4 tx queues as not rated 408 + $ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate 409 + $ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate 410 + $ echo 30 > /sys/class/net/eth1/queues/tx-2/tx_maxrate 411 + $ echo 10 > /sys/class/net/eth1/queues/tx-3/tx_maxrate 412 + 413 + 4) :: 414 + 415 + // Check maximum rate of tx (cpdma) queues: 416 + $ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate 417 + 40 418 + 20 419 + 30 420 + 10 421 + 0 422 + 0 423 + 0 424 + 0 425 + 426 + 5) :: 427 + 428 + // Map skb->priority to traffic class for Eth0: 429 + // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2 430 + // Map traffic class to transmit queue: 431 + // tc0 -> txq0, tc1 -> txq1, tc2 -> (txq4, txq5) 432 + $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \ 433 + 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 434 + 435 + 6) :: 436 + 437 + // Check classes settings 438 + $ tc -g class show dev eth0 439 + +---(100:ffe2) mqprio 440 + | +---(100:5) mqprio 441 + | +---(100:6) mqprio 442 + | 443 + +---(100:ffe1) mqprio 444 + | +---(100:2) mqprio 445 + | 446 + +---(100:ffe0) mqprio 447 + +---(100:1) mqprio 448 + 449 + 7) :: 450 + 451 + // Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc for Eth0 452 + // here only idle slope is important, others ignored 453 + // Real speed can differ a bit due to discreetness 454 + $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1470 \ 455 + hicredit 62 sendslope -959000 idleslope 41000 offload 1 456 + net eth0: set FIFO3 bw = 50 457 + 458 + 8) :: 459 + 460 + // Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc for Eth0 461 + $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \ 462 + hicredit 65 sendslope -979000 idleslope 21000 offload 1 463 + net eth0: set FIFO2 bw = 30 464 + 465 + 9) :: 466 + 467 + // Create vlan 100 to map sk->priority to vlan qos for Eth0 468 + $ ip link add link eth0 name eth0.100 type vlan id 100 469 + net eth0: Adding vlanid 100 to vlan filter 470 + 471 + 10) :: 472 + 473 + // Map skb->priority to L2 prio for Eth0.100, one to one 474 + $ ip link set eth0.100 type vlan \ 475 + egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 476 + 477 + 11) :: 478 + 479 + // Check egress map for vlan 100 480 + $ cat /proc/net/vlan/eth0.100 481 + [...] 482 + INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 483 + EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 484 + 485 + 12) :: 486 + 487 + // Map skb->priority to traffic class for Eth1: 488 + // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2 489 + // Map traffic class to transmit queue: 490 + // tc0 -> txq2, tc1 -> txq3, tc2 -> (txq6, txq7) 491 + $ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 3 \ 492 + 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 493 + 494 + 13) :: 495 + 496 + // Check classes settings 497 + $ tc -g class show dev eth1 498 + +---(100:ffe2) mqprio 499 + | +---(100:7) mqprio 500 + | +---(100:8) mqprio 501 + | 502 + +---(100:ffe1) mqprio 503 + | +---(100:4) mqprio 504 + | 505 + +---(100:ffe0) mqprio 506 + +---(100:3) mqprio 507 + 508 + 14) :: 509 + 510 + // Set rate for class A - 31 Mbit (tc0, txq2) using CBS Qdisc for Eth1 511 + // here only idle slope is important, others ignored, but calculated 512 + // for interface speed - 100Mb for eth1 port. 513 + // Set it +1 Mb for reserve (important!) 514 + $ tc qdisc add dev eth1 parent 100:3 cbs locredit -1035 \ 515 + hicredit 465 sendslope -69000 idleslope 31000 offload 1 516 + net eth1: set FIFO3 bw = 31 517 + 518 + 15) :: 519 + 520 + // Set rate for class B - 11 Mbit (tc1, txq3) using CBS Qdisc for Eth1 521 + // Set it +1 Mb for reserve (important!) 522 + $ tc qdisc add dev eth1 parent 100:4 cbs locredit -1335 \ 523 + hicredit 405 sendslope -89000 idleslope 11000 offload 1 524 + net eth1: set FIFO2 bw = 11 525 + 526 + 16) :: 527 + 528 + // Create vlan 100 to map sk->priority to vlan qos for Eth1 529 + $ ip link add link eth1 name eth1.100 type vlan id 100 530 + net eth1: Adding vlanid 100 to vlan filter 531 + 532 + 17) :: 533 + 534 + // Map skb->priority to L2 prio for Eth1.100, one to one 535 + $ ip link set eth1.100 type vlan \ 536 + egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 537 + 538 + 18) :: 539 + 540 + // Check egress map for vlan 100 541 + $ cat /proc/net/vlan/eth1.100 542 + [...] 543 + INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 544 + EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 545 + 546 + 19) :: 547 + 548 + // Run appropriate tools with socket option "SO_PRIORITY" to 3 549 + // for class A and to 2 for class B. For both interfaces 550 + ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500& 551 + ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500& 552 + ./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p2 -s 1500& 553 + ./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p3 -s 1500& 554 + 555 + 20) :: 556 + 557 + // run your listener on workstation (should be in same vlan) 558 + // (I took at https://www.spinics.net/lists/netdev/msg460869.html) 559 + ./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500 560 + Receiving data rate: 39012 kbps 561 + Receiving data rate: 39012 kbps 562 + Receiving data rate: 39012 kbps 563 + Receiving data rate: 39012 kbps 564 + Receiving data rate: 39012 kbps 565 + Receiving data rate: 39012 kbps 566 + Receiving data rate: 39012 kbps 567 + Receiving data rate: 39012 kbps 568 + Receiving data rate: 39012 kbps 569 + Receiving data rate: 39012 kbps 570 + Receiving data rate: 39012 kbps 571 + Receiving data rate: 39012 kbps 572 + Receiving data rate: 39000 kbps 573 + 574 + 21) :: 575 + 576 + // Restore default configuration if needed 577 + $ ip link del eth1.100 578 + $ ip link del eth0.100 579 + $ tc qdisc del dev eth1 root 580 + net eth1: Prev FIFO2 is shaped 581 + net eth1: set FIFO3 bw = 0 582 + net eth1: set FIFO2 bw = 0 583 + $ tc qdisc del dev eth0 root 584 + net eth0: Prev FIFO2 is shaped 585 + net eth0: set FIFO3 bw = 0 586 + net eth0: set FIFO2 bw = 0 587 + $ ethtool -L eth0 rx 1 tx 1
-541
Documentation/networking/device_drivers/ti/cpsw.txt
··· 1 - * Texas Instruments CPSW ethernet driver 2 - 3 - Multiqueue & CBS & MQPRIO 4 - ===================================================================== 5 - ===================================================================== 6 - 7 - The cpsw has 3 CBS shapers for each external ports. This document 8 - describes MQPRIO and CBS Qdisc offload configuration for cpsw driver 9 - based on examples. It potentially can be used in audio video bridging 10 - (AVB) and time sensitive networking (TSN). 11 - 12 - The following examples were tested on AM572x EVM and BBB boards. 13 - 14 - Test setup 15 - ========== 16 - 17 - Under consideration two examples with AM572x EVM running cpsw driver 18 - in dual_emac mode. 19 - 20 - Several prerequisites: 21 - - TX queues must be rated starting from txq0 that has highest priority 22 - - Traffic classes are used starting from 0, that has highest priority 23 - - CBS shapers should be used with rated queues 24 - - The bandwidth for CBS shapers has to be set a little bit more then 25 - potential incoming rate, thus, rate of all incoming tx queues has 26 - to be a little less 27 - - Real rates can differ, due to discreetness 28 - - Map skb-priority to txq is not enough, also skb-priority to l2 prio 29 - map has to be created with ip or vconfig tool 30 - - Any l2/socket prio (0 - 7) for classes can be used, but for 31 - simplicity default values are used: 3 and 2 32 - - only 2 classes tested: A and B, but checked and can work with more, 33 - maximum allowed 4, but only for 3 rate can be set. 34 - 35 - Test setup for examples 36 - ======================= 37 - +-------------------------------+ 38 - |--+ | 39 - | | Workstation0 | 40 - |E | MAC 18:03:73:66:87:42 | 41 - +-----------------------------+ +--|t | | 42 - | | 1 | E | | |h |./tsn_listener -d \ | 43 - | Target board: | 0 | t |--+ |0 | 18:03:73:66:87:42 -i eth0 \| 44 - | AM572x EVM | 0 | h | | | -s 1500 | 45 - | | 0 | 0 | |--+ | 46 - | Only 2 classes: |Mb +---| +-------------------------------+ 47 - | class A, class B | | 48 - | | +---| +-------------------------------+ 49 - | | 1 | E | |--+ | 50 - | | 0 | t | | | Workstation1 | 51 - | | 0 | h |--+ |E | MAC 20:cf:30:85:7d:fd | 52 - | |Mb | 1 | +--|t | | 53 - +-----------------------------+ |h |./tsn_listener -d \ | 54 - |0 | 20:cf:30:85:7d:fd -i eth0 \| 55 - | | -s 1500 | 56 - |--+ | 57 - +-------------------------------+ 58 - 59 - ********************************************************************* 60 - ********************************************************************* 61 - ********************************************************************* 62 - Example 1: One port tx AVB configuration scheme for target board 63 - ---------------------------------------------------------------------- 64 - (prints and scheme for AM572x evm, applicable for single port boards) 65 - 66 - tc - traffic class 67 - txq - transmit queue 68 - p - priority 69 - f - fifo (cpsw fifo) 70 - S - shaper configured 71 - 72 - +------------------------------------------------------------------+ u 73 - | +---------------+ +---------------+ +------+ +------+ | s 74 - | | | | | | | | | | e 75 - | | App 1 | | App 2 | | Apps | | Apps | | r 76 - | | Class A | | Class B | | Rest | | Rest | | 77 - | | Eth0 | | Eth0 | | Eth0 | | Eth1 | | s 78 - | | VLAN100 | | VLAN100 | | | | | | | | p 79 - | | 40 Mb/s | | 20 Mb/s | | | | | | | | a 80 - | | SO_PRIORITY=3 | | SO_PRIORITY=2 | | | | | | | | c 81 - | | | | | | | | | | | | | | e 82 - | +---|-----------+ +---|-----------+ +---|--+ +---|--+ | 83 - +-----|------------------|------------------|--------|-------------+ 84 - +-+ +------------+ | | 85 - | | +-----------------+ +--+ 86 - | | | | 87 - +---|-------|-------------|-----------------------|----------------+ 88 - | +----+ +----+ +----+ +----+ +----+ | 89 - | | p3 | | p2 | | p1 | | p0 | | p0 | | k 90 - | \ / \ / \ / \ / \ / | e 91 - | \ / \ / \ / \ / \ / | r 92 - | \/ \/ \/ \/ \/ | n 93 - | | | | | | e 94 - | | | +-----+ | | l 95 - | | | | | | 96 - | +----+ +----+ +----+ +----+ | s 97 - | |tc0 | |tc1 | |tc2 | |tc0 | | p 98 - | \ / \ / \ / \ / | a 99 - | \ / \ / \ / \ / | c 100 - | \/ \/ \/ \/ | e 101 - | | | +-----+ | | 102 - | | | | | | | 103 - | | | | | | | 104 - | | | | | | | 105 - | +----+ +----+ +----+ +----+ +----+ | 106 - | |txq0| |txq1| |txq2| |txq3| |txq4| | 107 - | \ / \ / \ / \ / \ / | 108 - | \ / \ / \ / \ / \ / | 109 - | \/ \/ \/ \/ \/ | 110 - | +-|------|------|------|--+ +--|--------------+ | 111 - | | | | | | | Eth0.100 | | Eth1 | | 112 - +---|------|------|------|------------------------|----------------+ 113 - | | | | | 114 - p p p p | 115 - 3 2 0-1, 4-7 <- L2 priority | 116 - | | | | | 117 - | | | | | 118 - +---|------|------|------|------------------------|----------------+ 119 - | | | | | |----------+ | 120 - | +----+ +----+ +----+ +----+ +----+ | 121 - | |dma7| |dma6| |dma5| |dma4| |dma3| | 122 - | \ / \ / \ / \ / \ / | c 123 - | \S / \S / \ / \ / \ / | p 124 - | \/ \/ \/ \/ \/ | s 125 - | | | | +----- | | w 126 - | | | | | | | 127 - | | | | | | | d 128 - | +----+ +----+ +----+p p+----+ | r 129 - | | | | | | |o o| | | i 130 - | | f3 | | f2 | | f0 |r r| f0 | | v 131 - | |tc0 | |tc1 | |tc2 |t t|tc0 | | e 132 - | \CBS / \CBS / \CBS /1 2\CBS / | r 133 - | \S / \S / \ / \ / | 134 - | \/ \/ \/ \/ | 135 - +------------------------------------------------------------------+ 136 - ========================================Eth==========================> 137 - 138 - 1) 139 - // Add 4 tx queues, for interface Eth0, and 1 tx queue for Eth1 140 - $ ethtool -L eth0 rx 1 tx 5 141 - rx unmodified, ignoring 142 - 143 - 2) 144 - // Check if num of queues is set correctly: 145 - $ ethtool -l eth0 146 - Channel parameters for eth0: 147 - Pre-set maximums: 148 - RX: 8 149 - TX: 8 150 - Other: 0 151 - Combined: 0 152 - Current hardware settings: 153 - RX: 1 154 - TX: 5 155 - Other: 0 156 - Combined: 0 157 - 158 - 3) 159 - // TX queues must be rated starting from 0, so set bws for tx0 and tx1 160 - // Set rates 40 and 20 Mb/s appropriately. 161 - // Pay attention, real speed can differ a bit due to discreetness. 162 - // Leave last 2 tx queues not rated. 163 - $ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate 164 - $ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate 165 - 166 - 4) 167 - // Check maximum rate of tx (cpdma) queues: 168 - $ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate 169 - 40 170 - 20 171 - 0 172 - 0 173 - 0 174 - 175 - 5) 176 - // Map skb->priority to traffic class: 177 - // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2 178 - // Map traffic class to transmit queue: 179 - // tc0 -> txq0, tc1 -> txq1, tc2 -> (txq2, txq3) 180 - $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \ 181 - 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 182 - 183 - 5a) 184 - // As two interface sharing same set of tx queues, assign all traffic 185 - // coming to interface Eth1 to separate queue in order to not mix it 186 - // with traffic from interface Eth0, so use separate txq to send 187 - // packets to Eth1, so all prio -> tc0 and tc0 -> txq4 188 - // Here hw 0, so here still default configuration for eth1 in hw 189 - $ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 1 \ 190 - map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues 1@4 hw 0 191 - 192 - 6) 193 - // Check classes settings 194 - $ tc -g class show dev eth0 195 - +---(100:ffe2) mqprio 196 - | +---(100:3) mqprio 197 - | +---(100:4) mqprio 198 - | 199 - +---(100:ffe1) mqprio 200 - | +---(100:2) mqprio 201 - | 202 - +---(100:ffe0) mqprio 203 - +---(100:1) mqprio 204 - 205 - $ tc -g class show dev eth1 206 - +---(100:ffe0) mqprio 207 - +---(100:5) mqprio 208 - 209 - 7) 210 - // Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc 211 - // Set it +1 Mb for reserve (important!) 212 - // here only idle slope is important, others arg are ignored 213 - // Pay attention, real speed can differ a bit due to discreetness 214 - $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1438 \ 215 - hicredit 62 sendslope -959000 idleslope 41000 offload 1 216 - net eth0: set FIFO3 bw = 50 217 - 218 - 8) 219 - // Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc: 220 - // Set it +1 Mb for reserve (important!) 221 - $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1468 \ 222 - hicredit 65 sendslope -979000 idleslope 21000 offload 1 223 - net eth0: set FIFO2 bw = 30 224 - 225 - 9) 226 - // Create vlan 100 to map sk->priority to vlan qos 227 - $ ip link add link eth0 name eth0.100 type vlan id 100 228 - 8021q: 802.1Q VLAN Support v1.8 229 - 8021q: adding VLAN 0 to HW filter on device eth0 230 - 8021q: adding VLAN 0 to HW filter on device eth1 231 - net eth0: Adding vlanid 100 to vlan filter 232 - 233 - 10) 234 - // Map skb->priority to L2 prio, 1 to 1 235 - $ ip link set eth0.100 type vlan \ 236 - egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 237 - 238 - 11) 239 - // Check egress map for vlan 100 240 - $ cat /proc/net/vlan/eth0.100 241 - [...] 242 - INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 243 - EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 244 - 245 - 12) 246 - // Run your appropriate tools with socket option "SO_PRIORITY" 247 - // to 3 for class A and/or to 2 for class B 248 - // (I took at https://www.spinics.net/lists/netdev/msg460869.html) 249 - ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500& 250 - ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500& 251 - 252 - 13) 253 - // run your listener on workstation (should be in same vlan) 254 - // (I took at https://www.spinics.net/lists/netdev/msg460869.html) 255 - ./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500 256 - Receiving data rate: 39012 kbps 257 - Receiving data rate: 39012 kbps 258 - Receiving data rate: 39012 kbps 259 - Receiving data rate: 39012 kbps 260 - Receiving data rate: 39012 kbps 261 - Receiving data rate: 39012 kbps 262 - Receiving data rate: 39012 kbps 263 - Receiving data rate: 39012 kbps 264 - Receiving data rate: 39012 kbps 265 - Receiving data rate: 39012 kbps 266 - Receiving data rate: 39012 kbps 267 - Receiving data rate: 39012 kbps 268 - Receiving data rate: 39000 kbps 269 - 270 - 14) 271 - // Restore default configuration if needed 272 - $ ip link del eth0.100 273 - $ tc qdisc del dev eth1 root 274 - $ tc qdisc del dev eth0 root 275 - net eth0: Prev FIFO2 is shaped 276 - net eth0: set FIFO3 bw = 0 277 - net eth0: set FIFO2 bw = 0 278 - $ ethtool -L eth0 rx 1 tx 1 279 - 280 - ********************************************************************* 281 - ********************************************************************* 282 - ********************************************************************* 283 - Example 2: Two port tx AVB configuration scheme for target board 284 - ---------------------------------------------------------------------- 285 - (prints and scheme for AM572x evm, for dual emac boards only) 286 - 287 - +------------------------------------------------------------------+ u 288 - | +----------+ +----------+ +------+ +----------+ +----------+ | s 289 - | | | | | | | | | | | | e 290 - | | App 1 | | App 2 | | Apps | | App 3 | | App 4 | | r 291 - | | Class A | | Class B | | Rest | | Class B | | Class A | | 292 - | | Eth0 | | Eth0 | | | | | Eth1 | | Eth1 | | s 293 - | | VLAN100 | | VLAN100 | | | | | VLAN100 | | VLAN100 | | p 294 - | | 40 Mb/s | | 20 Mb/s | | | | | 10 Mb/s | | 30 Mb/s | | a 295 - | | SO_PRI=3 | | SO_PRI=2 | | | | | SO_PRI=3 | | SO_PRI=2 | | c 296 - | | | | | | | | | | | | | | | | | e 297 - | +---|------+ +---|------+ +---|--+ +---|------+ +---|------+ | 298 - +-----|-------------|-------------|---------|-------------|--------+ 299 - +-+ +-------+ | +----------+ +----+ 300 - | | +-------+------+ | | 301 - | | | | | | 302 - +---|-------|-------------|--------------|-------------|-------|---+ 303 - | +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ | 304 - | | p3 | | p2 | | p1 | | p0 | | p0 | | p1 | | p2 | | p3 | | k 305 - | \ / \ / \ / \ / \ / \ / \ / \ / | e 306 - | \ / \ / \ / \ / \ / \ / \ / \ / | r 307 - | \/ \/ \/ \/ \/ \/ \/ \/ | n 308 - | | | | | | | | e 309 - | | | +----+ +----+ | | | l 310 - | | | | | | | | 311 - | +----+ +----+ +----+ +----+ +----+ +----+ | s 312 - | |tc0 | |tc1 | |tc2 | |tc2 | |tc1 | |tc0 | | p 313 - | \ / \ / \ / \ / \ / \ / | a 314 - | \ / \ / \ / \ / \ / \ / | c 315 - | \/ \/ \/ \/ \/ \/ | e 316 - | | | +-----+ +-----+ | | | 317 - | | | | | | | | | | 318 - | | | | | | | | | | 319 - | | | | | E E | | | | | 320 - | +----+ +----+ +----+ +----+ t t +----+ +----+ +----+ +----+ | 321 - | |txq0| |txq1| |txq4| |txq5| h h |txq6| |txq7| |txq3| |txq2| | 322 - | \ / \ / \ / \ / 0 1 \ / \ / \ / \ / | 323 - | \ / \ / \ / \ / . . \ / \ / \ / \ / | 324 - | \/ \/ \/ \/ 1 1 \/ \/ \/ \/ | 325 - | +-|------|------|------|--+ 0 0 +-|------|------|------|--+ | 326 - | | | | | | | 0 0 | | | | | | | 327 - +---|------|------|------|---------------|------|------|------|----+ 328 - | | | | | | | | 329 - p p p p p p p p 330 - 3 2 0-1, 4-7 <-L2 pri-> 0-1, 4-7 2 3 331 - | | | | | | | | 332 - | | | | | | | | 333 - +---|------|------|------|---------------|------|------|------|----+ 334 - | | | | | | | | | | 335 - | +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ | 336 - | |dma7| |dma6| |dma3| |dma2| |dma1| |dma0| |dma4| |dma5| | 337 - | \ / \ / \ / \ / \ / \ / \ / \ / | c 338 - | \S / \S / \ / \ / \ / \ / \S / \S / | p 339 - | \/ \/ \/ \/ \/ \/ \/ \/ | s 340 - | | | | +----- | | | | | w 341 - | | | | | +----+ | | | | 342 - | | | | | | | | | | d 343 - | +----+ +----+ +----+p p+----+ +----+ +----+ | r 344 - | | | | | | |o o| | | | | | | i 345 - | | f3 | | f2 | | f0 |r CPSW r| f3 | | f2 | | f0 | | v 346 - | |tc0 | |tc1 | |tc2 |t t|tc0 | |tc1 | |tc2 | | e 347 - | \CBS / \CBS / \CBS /1 2\CBS / \CBS / \CBS / | r 348 - | \S / \S / \ / \S / \S / \ / | 349 - | \/ \/ \/ \/ \/ \/ | 350 - +------------------------------------------------------------------+ 351 - ========================================Eth==========================> 352 - 353 - 1) 354 - // Add 8 tx queues, for interface Eth0, but they are common, so are accessed 355 - // by two interfaces Eth0 and Eth1. 356 - $ ethtool -L eth1 rx 1 tx 8 357 - rx unmodified, ignoring 358 - 359 - 2) 360 - // Check if num of queues is set correctly: 361 - $ ethtool -l eth0 362 - Channel parameters for eth0: 363 - Pre-set maximums: 364 - RX: 8 365 - TX: 8 366 - Other: 0 367 - Combined: 0 368 - Current hardware settings: 369 - RX: 1 370 - TX: 8 371 - Other: 0 372 - Combined: 0 373 - 374 - 3) 375 - // TX queues must be rated starting from 0, so set bws for tx0 and tx1 for Eth0 376 - // and for tx2 and tx3 for Eth1. That is, rates 40 and 20 Mb/s appropriately 377 - // for Eth0 and 30 and 10 Mb/s for Eth1. 378 - // Real speed can differ a bit due to discreetness 379 - // Leave last 4 tx queues as not rated 380 - $ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate 381 - $ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate 382 - $ echo 30 > /sys/class/net/eth1/queues/tx-2/tx_maxrate 383 - $ echo 10 > /sys/class/net/eth1/queues/tx-3/tx_maxrate 384 - 385 - 4) 386 - // Check maximum rate of tx (cpdma) queues: 387 - $ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate 388 - 40 389 - 20 390 - 30 391 - 10 392 - 0 393 - 0 394 - 0 395 - 0 396 - 397 - 5) 398 - // Map skb->priority to traffic class for Eth0: 399 - // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2 400 - // Map traffic class to transmit queue: 401 - // tc0 -> txq0, tc1 -> txq1, tc2 -> (txq4, txq5) 402 - $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \ 403 - 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 404 - 405 - 6) 406 - // Check classes settings 407 - $ tc -g class show dev eth0 408 - +---(100:ffe2) mqprio 409 - | +---(100:5) mqprio 410 - | +---(100:6) mqprio 411 - | 412 - +---(100:ffe1) mqprio 413 - | +---(100:2) mqprio 414 - | 415 - +---(100:ffe0) mqprio 416 - +---(100:1) mqprio 417 - 418 - 7) 419 - // Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc for Eth0 420 - // here only idle slope is important, others ignored 421 - // Real speed can differ a bit due to discreetness 422 - $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1470 \ 423 - hicredit 62 sendslope -959000 idleslope 41000 offload 1 424 - net eth0: set FIFO3 bw = 50 425 - 426 - 8) 427 - // Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc for Eth0 428 - $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \ 429 - hicredit 65 sendslope -979000 idleslope 21000 offload 1 430 - net eth0: set FIFO2 bw = 30 431 - 432 - 9) 433 - // Create vlan 100 to map sk->priority to vlan qos for Eth0 434 - $ ip link add link eth0 name eth0.100 type vlan id 100 435 - net eth0: Adding vlanid 100 to vlan filter 436 - 437 - 10) 438 - // Map skb->priority to L2 prio for Eth0.100, one to one 439 - $ ip link set eth0.100 type vlan \ 440 - egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 441 - 442 - 11) 443 - // Check egress map for vlan 100 444 - $ cat /proc/net/vlan/eth0.100 445 - [...] 446 - INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 447 - EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 448 - 449 - 12) 450 - // Map skb->priority to traffic class for Eth1: 451 - // 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2 452 - // Map traffic class to transmit queue: 453 - // tc0 -> txq2, tc1 -> txq3, tc2 -> (txq6, txq7) 454 - $ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 3 \ 455 - 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 456 - 457 - 13) 458 - // Check classes settings 459 - $ tc -g class show dev eth1 460 - +---(100:ffe2) mqprio 461 - | +---(100:7) mqprio 462 - | +---(100:8) mqprio 463 - | 464 - +---(100:ffe1) mqprio 465 - | +---(100:4) mqprio 466 - | 467 - +---(100:ffe0) mqprio 468 - +---(100:3) mqprio 469 - 470 - 14) 471 - // Set rate for class A - 31 Mbit (tc0, txq2) using CBS Qdisc for Eth1 472 - // here only idle slope is important, others ignored, but calculated 473 - // for interface speed - 100Mb for eth1 port. 474 - // Set it +1 Mb for reserve (important!) 475 - $ tc qdisc add dev eth1 parent 100:3 cbs locredit -1035 \ 476 - hicredit 465 sendslope -69000 idleslope 31000 offload 1 477 - net eth1: set FIFO3 bw = 31 478 - 479 - 15) 480 - // Set rate for class B - 11 Mbit (tc1, txq3) using CBS Qdisc for Eth1 481 - // Set it +1 Mb for reserve (important!) 482 - $ tc qdisc add dev eth1 parent 100:4 cbs locredit -1335 \ 483 - hicredit 405 sendslope -89000 idleslope 11000 offload 1 484 - net eth1: set FIFO2 bw = 11 485 - 486 - 16) 487 - // Create vlan 100 to map sk->priority to vlan qos for Eth1 488 - $ ip link add link eth1 name eth1.100 type vlan id 100 489 - net eth1: Adding vlanid 100 to vlan filter 490 - 491 - 17) 492 - // Map skb->priority to L2 prio for Eth1.100, one to one 493 - $ ip link set eth1.100 type vlan \ 494 - egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 495 - 496 - 18) 497 - // Check egress map for vlan 100 498 - $ cat /proc/net/vlan/eth1.100 499 - [...] 500 - INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 501 - EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 502 - 503 - 19) 504 - // Run appropriate tools with socket option "SO_PRIORITY" to 3 505 - // for class A and to 2 for class B. For both interfaces 506 - ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500& 507 - ./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500& 508 - ./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p2 -s 1500& 509 - ./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p3 -s 1500& 510 - 511 - 20) 512 - // run your listener on workstation (should be in same vlan) 513 - // (I took at https://www.spinics.net/lists/netdev/msg460869.html) 514 - ./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500 515 - Receiving data rate: 39012 kbps 516 - Receiving data rate: 39012 kbps 517 - Receiving data rate: 39012 kbps 518 - Receiving data rate: 39012 kbps 519 - Receiving data rate: 39012 kbps 520 - Receiving data rate: 39012 kbps 521 - Receiving data rate: 39012 kbps 522 - Receiving data rate: 39012 kbps 523 - Receiving data rate: 39012 kbps 524 - Receiving data rate: 39012 kbps 525 - Receiving data rate: 39012 kbps 526 - Receiving data rate: 39012 kbps 527 - Receiving data rate: 39000 kbps 528 - 529 - 21) 530 - // Restore default configuration if needed 531 - $ ip link del eth1.100 532 - $ ip link del eth0.100 533 - $ tc qdisc del dev eth1 root 534 - net eth1: Prev FIFO2 is shaped 535 - net eth1: set FIFO3 bw = 0 536 - net eth1: set FIFO2 bw = 0 537 - $ tc qdisc del dev eth0 root 538 - net eth0: Prev FIFO2 is shaped 539 - net eth0: set FIFO3 bw = 0 540 - net eth0: set FIFO2 bw = 0 541 - $ ethtool -L eth0 rx 1 tx 1