diff options
author | Alan Swanson <reiver@improbability.net> | 2019-11-15 14:12:02 +0000 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2020-03-03 22:43:09 +0100 |
commit | 25cb5685c16b93147e2f120b5566d24d820f2c48 (patch) | |
tree | 6dc311e93640cf128cb9dfc09c40b60698fa0834 /package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering | |
parent | d3868f15f876507db54afacdef22a7059011a54e (diff) | |
download | upstream-25cb5685c16b93147e2f120b5566d24d820f2c48.tar.gz upstream-25cb5685c16b93147e2f120b5566d24d820f2c48.tar.bz2 upstream-25cb5685c16b93147e2f120b5566d24d820f2c48.zip |
netifd: rename 20-smp-tune to 20-smp-packet-steering
Rename the script to be more obvious that this is for
packet steering only.
Signed-off-by: Alan Swanson <reiver@improbability.net>
Diffstat (limited to 'package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering')
-rw-r--r-- | package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering new file mode 100644 index 0000000000..9d7aaae0ac --- /dev/null +++ b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering @@ -0,0 +1,62 @@ +#!/bin/sh +[ "$ACTION" = add ] || exit + +NPROCS="$(grep -c "^processor.*:" /proc/cpuinfo)" +[ "$NPROCS" -gt 1 ] || exit + +PROC_MASK="$(( (1 << $NPROCS) - 1 ))" + +find_irq_cpu() { + local dev="$1" + local match="$(grep -m 1 "$dev\$" /proc/interrupts)" + local cpu=0 + + [ -n "$match" ] && { + set -- $match + shift + for cur in `seq 1 $NPROCS`; do + [ "$1" -gt 0 ] && { + cpu=$(($cur - 1)) + break + } + shift + done + } + + echo "$cpu" +} + +set_hex_val() { + local file="$1" + local val="$2" + val="$(printf %x "$val")" + [ -n "$DEBUG" ] && echo "$file = $val" + echo "$val" > "$file" +} + +packet_steering="$(uci get "network.@globals[0].packet_steering")" +[ "$packet_steering" != 1 ] && exit 0 + +exec 512>/var/lock/smp_tune.lock +flock 512 || exit 1 + +for dev in /sys/class/net/*; do + [ -d "$dev" ] || continue + + # ignore virtual interfaces + [ -n "$(ls "${dev}/" | grep '^lower_')" ] && continue + [ -d "${dev}/device" ] || continue + + device="$(readlink "${dev}/device")" + device="$(basename "$device")" + irq_cpu="$(find_irq_cpu "$device")" + irq_cpu_mask="$((1 << $irq_cpu))" + + for q in ${dev}/queues/rx-*; do + set_hex_val "$q/rps_cpus" "$PROC_MASK" + done + + for q in ${dev}/queues/tx-*; do + set_hex_val "$q/xps_cpus" "$PROC_MASK" + done +done |