| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2024 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 testing XDP busy polling. |
| 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="8000000" # default: 8ms |
| 25 | [ -z $BASETIME ] && BASETIME=$(date '+%s000000000' -d '-30 sec') # default: now - 30s |
| 26 | |
| 27 | load_kernel_modules |
| 28 | |
| 29 | napi_defer_hard_irqs "${INTERFACE}" "${CYCLETIME_NS}" |
| 30 | |
| 31 | igc_start "${INTERFACE}" |
| 32 | |
| 33 | # |
| 34 | # Split traffic between TSN streams, priority and everything else. |
| 35 | # |
| 36 | ENTRY1_NS=$(echo "$CYCLETIME_NS * 50 / 100" | bc) # RTC |
| 37 | ENTRY2_NS=$(echo "$CYCLETIME_NS * 25 / 100" | bc) # TSN Streams / Prio |
| 38 | ENTRY3_NS=$(echo "$CYCLETIME_NS * 25 / 100" | bc) # Everything else |
| 39 | |
| 40 | # |
| 41 | # Tx Assignment with Qbv and full hardware offload. |
| 42 | # |
| 43 | # PCP 4 - Rx Q 0 - RTC |
| 44 | # PCP 6/5 - Rx Q 1 - TSN Streams / Prio |
| 45 | # PCP X - Rx Q 2 - Everything else |
| 46 | # |
| 47 | tc qdisc replace dev ${INTERFACE} handle 100 parent root taprio num_tc 3 \ |
| 48 | map 2 2 2 2 2 2 1 0 2 2 2 2 2 2 2 2 \ |
| 49 | queues 1@0 1@1 2@2 \ |
| 50 | base-time ${BASETIME} \ |
| 51 | sched-entry S 0x01 ${ENTRY1_NS} \ |
| 52 | sched-entry S 0x02 ${ENTRY2_NS} \ |
| 53 | sched-entry S 0x04 ${ENTRY3_NS} \ |
| 54 | flags 0x02 |
| 55 | |
| 56 | # |
| 57 | # Rx Queues Assignment. |
| 58 | # |
| 59 | # PCP 4 - Rx Q 0 - RTC |
| 60 | # PCP 6/5 - Rx Q 1 - TSN Streams / Prio |
| 61 | # PCP X - Rx Q 2 - Everything else |
| 62 | # |
| 63 | RXQUEUES=(2 1 1 0 2 2 2 2 1 1) |
| 64 | igc_rx_queues_assign "${INTERFACE}" RXQUEUES |
| 65 | |
| 66 | igc_end "${INTERFACE}" |
| 67 | |
| 68 | setup_irqs "${INTERFACE}" |
| 69 | |
| 70 | exit 0 |