| 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 | # Split traffic between TSN streams, real time and everything else. |
| 35 | # |
| 36 | ENTRY1_NS="50000" # TSN High |
| 37 | ENTRY2_NS="50000" # TSN Low |
| 38 | ENTRY3_NS="100000" # RTC |
| 39 | ENTRY4_NS="800000" # RTA and everything else |
| 40 | |
| 41 | # |
| 42 | # Tx Assignment with Qbv and full hardware offload. |
| 43 | # |
| 44 | # PCP 6 - Tx Q 0 - TSN High |
| 45 | # PCP 5 - Tx Q 1 - TSN Low |
| 46 | # PCP 4 - Tx Q 2 - RTC |
| 47 | # PCP 3/X - Tx Q 3 - RTA and Everything else |
| 48 | # |
| 49 | tc qdisc replace dev ${INTERFACE} handle 100 parent root taprio num_tc 4 \ |
| 50 | map 3 3 3 3 3 2 1 0 3 3 3 3 3 3 3 3 \ |
| 51 | queues 1@0 1@1 1@2 1@3 \ |
| 52 | base-time ${BASETIME} \ |
| 53 | sched-entry S 0x01 ${ENTRY1_NS} \ |
| 54 | sched-entry S 0x02 ${ENTRY2_NS} \ |
| 55 | sched-entry S 0x04 ${ENTRY3_NS} \ |
| 56 | sched-entry S 0x08 ${ENTRY4_NS} \ |
| 57 | flags 0x02 |
| 58 | |
| 59 | # |
| 60 | # Enable Tx launch time support for TC 0 and TC 1. |
| 61 | # |
| 62 | tc qdisc replace dev ${INTERFACE} parent 100:1 etf \ |
| 63 | clockid CLOCK_TAI \ |
| 64 | delta 500000 \ |
| 65 | offload |
| 66 | |
| 67 | tc qdisc replace dev ${INTERFACE} parent 100:2 etf \ |
| 68 | clockid CLOCK_TAI \ |
| 69 | delta 500000 \ |
| 70 | offload |
| 71 | |
| 72 | # |
| 73 | # Rx Queues Assignment. |
| 74 | # |
| 75 | # Rx Q 3 - All Traffic |
| 76 | # Rx Q 2 - RTC |
| 77 | # Rx Q 1 - TSN Low |
| 78 | # Rx Q 0 - TSN High |
| 79 | # |
| 80 | RXQUEUES=(3 0 1 2 3 3 3 3 3 3) |
| 81 | igc_rx_queues_assign "${INTERFACE}" RXQUEUES |
| 82 | |
| 83 | igc_end "${INTERFACE}" |
| 84 | |
| 85 | setup_irqs "${INTERFACE}" |
| 86 | |
| 87 | exit 0 |