summaryrefslogtreecommitdiffstats
path: root/target/linux/rockchip/armv8/base-files/etc/hotplug.d/net/40-net-smp-affinity
blob: 360b34ba9120a90c9aa4bbb12f2bca1ab26755bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/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 -E -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
friendlyarm,nanopi-r2c|\
friendlyarm,nanopi-r2c-plus|\
friendlyarm,nanopi-r2s|\
radxa,cm3-io|\
xunlong,orangepi-r1-plus|\
xunlong,orangepi-r1-plus-lts)
	set_interface_core 2 "eth0"
	set_interface_core 4 "eth1" "xhci-hcd:usb[0-9]+"
	;;
friendlyarm,nanopi-r4s|\
friendlyarm,nanopi-r4s-enterprise)
	set_interface_core 10 "eth0"
	set_interface_core 20 "eth1"
	;;
friendlyarm,nanopi-r5c)
	set_interface_core 2 "eth0"
	set_interface_core 4 "eth1"
	;;
friendlyarm,nanopi-r5s)
	set_interface_core 2 "eth0"
	set_interface_core 4 "eth1"
	set_interface_core 8 "eth2"
	;;
esac