| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2023-2025 Linutronix GmbH |
| 4 | # Author Kurt Kanzenbach <[email protected]> |
| 5 | # |
| 6 | # SPDX-License-Identifier: BSD-2-Clause |
| 7 | # |
| 8 | # Setup the Tx and Rx traffic flows for Intel i225 for profinet scenario. |
| 9 | # |
| 10 | |
| 11 | set -e |
| 12 | |
| 13 | source ../lib/common.sh |
| 14 | source ../lib/igc.sh |
| 15 | |
| 16 | # |
| 17 | # Command line arguments. |
| 18 | # |
| 19 | INTERFACE=$1 |
| 20 | CYCLETIME_NS=$2 |
| 21 | BASETIME=$3 |
| 22 | |
| 23 | [ -z $INTERFACE ] && INTERFACE="enp3s0" # default: enp3s0 |
| 24 | [ -z $CYCLETIME_NS ] && CYCLETIME_NS="1000000" # default: 1ms |
| 25 | [ -z $BASETIME ] && BASETIME=$(date '+%s000000000' -d '-30 sec') # default: now - 30s |
| 26 | |
| 27 | load_kernel_modules |
| 28 | |
| 29 | setup_threaded_napi "${INTERFACE}" |
| 30 | |
| 31 | igc_start "${INTERFACE}" |
| 32 | |
| 33 | # |
| 34 | # Setup egress classification: |
| 35 | # |
| 36 | # VLAN 100 -> TSN High from container #1 -> Time slot #0 |
| 37 | # VLAN 200 -> TSN High from container #2 -> Time slot #1 |
| 38 | # |
| 39 | tc qdisc add dev ${INTERFACE} clsact |
| 40 | tc filter add dev ${INTERFACE} egress protocol 802.1Q flower vlan_id 100 action skbedit priority 7 |
| 41 | tc filter add dev ${INTERFACE} egress protocol 802.1Q flower vlan_id 200 action skbedit priority 6 |
| 42 | |
| 43 | # |
| 44 | # Split traffic between TSN streams, real time and everything else. |
| 45 | # |
| 46 | ENTRY1_NS="64000" # TSN High #1 |
| 47 | ENTRY2_NS="64000" # TSN High #2 |
| 48 | ENTRY3_NS="172000" # Prio |
| 49 | ENTRY4_NS="700000" # Everything else |
| 50 | |
| 51 | # |
| 52 | # Tx Assignment with Qbv and full hardware offload. |
| 53 | # |
| 54 | # PCP 6 - Tx Q 0 - TSN High from container #1 |
| 55 | # PCP 5 - Tx Q 1 - TSN High from container #2 |
| 56 | # PCP 4 - Tx Q 2 - Prio |
| 57 | # PCP 3/X - Tx Q 3 - RTA and Everything else |
| 58 | # |
| 59 | tc qdisc replace dev ${INTERFACE} handle 100 parent root taprio num_tc 4 \ |
| 60 | map 3 3 3 3 3 2 1 0 3 3 3 3 3 3 3 3 \ |
| 61 | queues 1@0 1@1 1@2 1@3 \ |
| 62 | base-time ${BASETIME} \ |
| 63 | sched-entry S 0x01 ${ENTRY1_NS} \ |
| 64 | sched-entry S 0x02 ${ENTRY2_NS} \ |
| 65 | sched-entry S 0x04 ${ENTRY3_NS} \ |
| 66 | sched-entry S 0x08 ${ENTRY4_NS} \ |
| 67 | flags 0x02 |
| 68 | |
| 69 | # |
| 70 | # Rx Queues Assignment. |
| 71 | # |
| 72 | # Rx Q 3 - All Traffic |
| 73 | # Rx Q 2 - Prio |
| 74 | # Rx Q 1 - TSN High from container #2 |
| 75 | # Rx Q 0 - TSN High from container #1 |
| 76 | # |
| 77 | RXQUEUES=(3 0 1 2 3 3 3 3 3 3) |
| 78 | igc_rx_queues_assign "${INTERFACE}" RXQUEUES |
| 79 | |
| 80 | igc_end "${INTERFACE}" |
| 81 | |
| 82 | setup_irqs "${INTERFACE}" |
| 83 | |
| 84 | exit 0 |