lede/target/linux/rockchip/armv8/base-files/etc/hotplug.d/net/40-net-smp-affinity
Ronny Kotzschmar 628ef82714 rockchip: reliably distribute net interrupts
On the NanoPI R4S it takes an average of 3..5 seconds for the network devices
to appear in '/proc/interrupts'.
Wait up to 10 seconds to ensure that the distribution of the interrupts
really happens.

Signed-off-by: Ronny Kotzschmar <ro.ok@me.com>
2022-07-08 11:50:20 +08:00

48 lines
936 B
Bash

#!/bin/sh
[ "$ACTION" = add ] || exit
get_device_irq() {
local device="$1"
local line
local seconds="0"
# wait up to 10 seconds for the irq/device to appear
while [ "${seconds}" -le 10 ]; do
line=$(grep -m 1 "${device}\$" /proc/interrupts) && break
seconds="$(( seconds + 2 ))"
sleep 2
done
echo ${line} | sed 's/:.*//'
}
set_interface_core() {
local core_mask="$1"
local interface="$2"
local device="$3"
[ -z "${device}" ] && device="$interface"
local irq=$(get_device_irq "$device")
echo "${core_mask}" > /proc/irq/${irq}/smp_affinity
}
case "$(board_name)" in
embedfire,doornet1|\
friendlyarm,nanopi-r2c|\
friendlyarm,nanopi-r2s|\
xunlong,orangepi-r1-plus|\
xunlong,orangepi-r1-plus-lts)
set_interface_core 2 "eth0"
set_interface_core 4 "eth1" "xhci-hcd:usb3"
;;
embedfire,doornet2|\
friendlyarm,nanopi-r4s|\
sharevdi,guangmiao-g4c)
set_interface_core 10 "eth0"
set_interface_core 20 "eth1"
;;
esac