| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2021,2022 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. |
| 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 | # For testing the hardware platform use a different schedule: The Profinet spec |
| 35 | # allows to utililze up to 90% for real time streams. In order to test the XDP |
| 36 | # performance use 75/25 split. Keep 25% for RTA, PTP, LLDP, DCP and UDP traffic. |
| 37 | # |
| 38 | ENTRY1_NS=$(echo "$CYCLETIME_NS * 12.5 / 100" | bc) # TSN High |
| 39 | ENTRY2_NS=$(echo "$CYCLETIME_NS * 12.5 / 100" | bc) # TSN Low |
| 40 | ENTRY3_NS=$(echo "$CYCLETIME_NS * 25 / 100" | bc) # RTC |
| 41 | ENTRY4_NS=$(echo "$CYCLETIME_NS * 50 / 100" | bc) # Everything else |
| 42 | |
| 43 | # |
| 44 | # Tx Assignment with Qbv and full hardware offload. |
| 45 | # |
| 46 | # PCP 6 - Queue 0 - TSN High |
| 47 | # PCP 5 - Queue 1 - TSN Low |
| 48 | # PCP 4 - Queue 2 - RTC |
| 49 | # PCP 3/2/1/7 - Queue 3 - RTA / LLDP / DCP / PTP / UDP |
| 50 | # |
| 51 | tc qdisc replace dev ${INTERFACE} handle 100 parent root taprio num_tc 4 \ |
| 52 | map 3 3 3 3 3 2 1 0 3 3 3 3 3 3 3 3 \ |
| 53 | queues 1@0 1@1 1@2 1@3 \ |
| 54 | base-time ${BASETIME} \ |
| 55 | sched-entry S 0x01 ${ENTRY1_NS} \ |
| 56 | sched-entry S 0x02 ${ENTRY2_NS} \ |
| 57 | sched-entry S 0x04 ${ENTRY3_NS} \ |
| 58 | sched-entry S 0xf8 ${ENTRY4_NS} \ |
| 59 | flags 0x02 |
| 60 | |
| 61 | # |
| 62 | # Rx Queues Assignment. |
| 63 | # |
| 64 | # Rx Q 3 - All Traffic |
| 65 | # Rx Q 2 - RTC |
| 66 | # Rx Q 1 - TSN Low |
| 67 | # Rx Q 0 - TSN High |
| 68 | # |
| 69 | RXQUEUES=(3 0 1 2 3 3 3 3 3 3) |
| 70 | igc_rx_queues_assign "${INTERFACE}" RXQUEUES |
| 71 | |
| 72 | igc_end "${INTERFACE}" |
| 73 | |
| 74 | setup_irqs "${INTERFACE}" |
| 75 | |
| 76 | exit 0 |