rockchip: add Radxa CM3 IO board support
[openwrt/staging/jow.git] / target / linux / rockchip / armv8 / base-files / etc / hotplug.d / net / 40-net-smp-affinity
1 #!/bin/sh
2
3 [ "$ACTION" = add ] || exit
4
5 get_device_irq() {
6 local device="$1"
7 local line
8 local seconds="0"
9
10 # wait up to 10 seconds for the irq/device to appear
11 while [ "${seconds}" -le 10 ]; do
12 line=$(grep -E -m 1 "${device}\$" /proc/interrupts) && break
13 seconds="$(( seconds + 2 ))"
14 sleep 2
15 done
16 echo ${line} | sed 's/:.*//'
17 }
18
19 set_interface_core() {
20 local core_mask="$1"
21 local interface="$2"
22 local device="$3"
23
24 [ -z "${device}" ] && device="$interface"
25
26 local irq=$(get_device_irq "$device")
27
28 echo "${core_mask}" > /proc/irq/${irq}/smp_affinity
29 }
30
31 case "$(board_name)" in
32 friendlyarm,nanopi-r2c|\
33 friendlyarm,nanopi-r2c-plus|\
34 friendlyarm,nanopi-r2s|\
35 radxa,cm3-io|\
36 xunlong,orangepi-r1-plus|\
37 xunlong,orangepi-r1-plus-lts)
38 set_interface_core 2 "eth0"
39 set_interface_core 4 "eth1" "xhci-hcd:usb[0-9]+"
40 ;;
41 friendlyarm,nanopi-r4s|\
42 friendlyarm,nanopi-r4s-enterprise)
43 set_interface_core 10 "eth0"
44 set_interface_core 20 "eth1"
45 ;;
46 friendlyarm,nanopi-r5c)
47 set_interface_core 2 "eth0"
48 set_interface_core 4 "eth1"
49 ;;
50 friendlyarm,nanopi-r5s)
51 set_interface_core 2 "eth0"
52 set_interface_core 4 "eth1"
53 set_interface_core 8 "eth2"
54 ;;
55 esac
56