blob: b00d665106c04d524fc0526e92b1b5ddff94d819 [file] [log] [blame]
developerc8e728e2022-05-19 10:39:32 +08001#!/bin/sh
2
3OPTIMIZED_FOR="$1"
4CPU_LIST=`cat /proc/interrupts | sed -n '1p'`
5NUM_OF_CPU=0; for i in $CPU_LIST; do NUM_OF_CPU=`expr $NUM_OF_CPU + 1`; done;
6DEFAULT_RPS=0
7
developere5e3d1b2023-02-02 15:26:12 +08008. /lib/functions.sh
9
developerc8e728e2022-05-19 10:39:32 +080010RPS_IF_LIST=""
11NUM_WIFI_CARD=0
12WIFI_RADIO1=0
13WIFI_RADIO2=0
14WIFI_RADIO3=0
developerb3f0c0e2022-07-12 11:44:31 +080015WED_ENABLE=0
developerc8e728e2022-05-19 10:39:32 +080016
developer5620ea52023-05-12 18:09:06 +080017WIFI_MODULE_LIST='mt7915e mt7996e'
18
developerc8e728e2022-05-19 10:39:32 +080019get_if_info()
20{
21 # try to get all wifi and eth net interface.
22 dbg2 "try to get all wifi and eth net interface."
23 NET_IF_LIST=`ls /sys/class/net`
24 for vif in $NET_IF_LIST;
25 do
developere5e3d1b2023-02-02 15:26:12 +080026 if [[ "$vif" == "eth"* ]] || \
27 [[ "$vif" == "lan"* ]] || [[ "$vif" == "wan"* ]] || \
28 [[ "$vif" == "wlan"* ]] || [[ "$vif" == "phy"* ]]; then
developerc8e728e2022-05-19 10:39:32 +080029 RPS_IF_LIST="$RPS_IF_LIST $vif"
30 fi
31 done;
32 dbg2 "RPS_IF_LIST = $RPS_IF_LIST"
33
34 # try to get wifi physical card num.
35 dbg2 "try to get wifi physical card num."
36 VIRTUAL_RADIO_LIST=`ls -l /sys/class/ieee80211/ | awk -F 'devices' '{print $2}' | awk -F 'phy' '{print $1}' | uniq`
37 for v in $VIRTUAL_RADIO_LIST;
38 do
39 NUM_WIFI_CARD=`expr $NUM_WIFI_CARD + 1`
40 dbg2 "physical raido $v"
41 if [[ $v == *"wmac"* ]]; then
42 WIFI_RADIO1=1
43 fi
developere5e3d1b2023-02-02 15:26:12 +080044
developerc8e728e2022-05-19 10:39:32 +080045 if [[ $v == *"wbsys"* ]]; then
developere5e3d1b2023-02-02 15:26:12 +080046 WIFI_RADIO1=1
47 fi
developerc8e728e2022-05-19 10:39:32 +080048
49 if [[ $v == *"pci0000"* ]]; then
50 WIFI_RADIO2=1
51 fi
52
53 if [[ $v == *"pci0001"* ]]; then
54 WIFI_RADIO3=1
55 fi
56 done;
57
developer5620ea52023-05-12 18:09:06 +080058
59 for v in $WIFI_MODULE_LIST;
developerb3f0c0e2022-07-12 11:44:31 +080060 do
developer5620ea52023-05-12 18:09:06 +080061 if [[ -f "/sys/module/$v/parameters/wed_enable" ]]; then
62 WED_ENABLE_LIST=`cat /sys/module/$v/parameters/wed_enable`
63 dbg2 "wed enable ori info $v $WED_ENABLE_LIST"
64 if [[ $WED_ENABLE_LIST == "Y" ]]; then
65 WED_ENABLE=1
66 fi
developerb3f0c0e2022-07-12 11:44:31 +080067 fi
68 done;
developerc8e728e2022-05-19 10:39:32 +080069 dbg2 "NUM_WIFI_CARD = $NUM_WIFI_CARD"
70 dbg2 "platform wifi enable = $WIFI_RADIO1"
71 dbg2 "pcie1 wifi enable = $WIFI_RADIO2"
72 dbg2 "pcie2 wifi enable = $WIFI_RADIO3"
developerb3f0c0e2022-07-12 11:44:31 +080073 dbg2 "WED enable = $WED_ENABLE"
developerc8e728e2022-05-19 10:39:32 +080074}
75
76# $1: CPU#
77# $2: irq list for added.
78CPU_AFFINITY_ADD()
79{
80 eval oval=\$CPU${1}_AFFINITY
81 eval CPU${1}_AFFINITY=\"\$CPU${1}_AFFINITY $2\"
82}
83
84# $1: CPU#
85# $2: Interface name for added.
86CPU_RPS_ADD()
87{
88 eval oval=\$CPU${1}_RPS
89 eval CPU${1}_RPS=\"\$CPU${1}_RPS $2\"
90 dbg2 "CPU${1}_RPS=\"\$CPU${1}_RPS $2\""
91}
92
developere5e3d1b2023-02-02 15:26:12 +080093MT7988()
94{
95 num_of_wifi=$1
96 DEFAULT_RPS=0
97
98 #Physical IRQ# setting
developerc2d0db22023-05-30 10:57:24 +080099 #Ethernet RSS feature enables 4 Rx rings
100 eth_irq_rx0=221
101 eth_irq_rx1=222
102 eth_irq_rx2=223
103 eth_irq_rx3=224
104 eth_irq_tx=229
developere5e3d1b2023-02-02 15:26:12 +0800105 wifi1_irq_pcie0=524288
106 wifi1_irq_pcie1=134742016
107 wifi2_irq_pcie0=
108 wifi2_irq_pcie1=
109
110 if [[ "$WED_ENABLE" -eq "1" ]]; then
111 dbg2 "WED_ENABLE ON irq/iptable setting"
112 #TCP Binding
113 iptables -D FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
114 iptables -I FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
115 ip6tables -D FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
116 ip6tables -I FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
117 #UDP Binding
118 iptables -D FORWARD -p udp -j FLOWOFFLOAD --hw
119 iptables -I FORWARD -p udp -j FLOWOFFLOAD --hw
120 ip6tables -D FORWARD -p udp -j FLOWOFFLOAD --hw
121 ip6tables -I FORWARD -p udp -j FLOWOFFLOAD --hw
developerfed736e2024-07-12 14:00:34 +0800122 #Multicast skip Binding
123 iptables -D FORWARD -m pkttype --pkt-type multicast -j ACCEPT
124 iptables -I FORWARD -m pkttype --pkt-type multicast -j ACCEPT
125 ip6tables -D FORWARD -m pkttype --pkt-type multicast -j ACCEPT
126 ip6tables -I FORWARD -m pkttype --pkt-type multicast -j ACCEPT
developere5e3d1b2023-02-02 15:26:12 +0800127
128 else
129 dbg2 "WED_ENABLE OFF irq/iptable seting"
130 fi
131
132 for vif in $NET_IF_LIST;
133 do
134 if [[ "$vif" == "wlan"* ]] || [[ "$vif" == "phy"* ]]; then
135 WIFI_IF_LIST="$WIFI_IF_LIST $vif"
136 fi
137 done;
138 dbg2 "$WIFI_IF_LIST = $WIFI_IF_LIST"
139 # Please update the CPU binding in each cases.
140 # CPU#_AFFINITY="add binding irq number here"
141 # CPU#_RPS="add binding interface name here"
142 if [ "$num_of_wifi" = "0" ]; then
developerc2d0db22023-05-30 10:57:24 +0800143 CPU0_AFFINITY="$eth_irq_rx0 $eth_irq_tx"
144 CPU1_AFFINITY="$eth_irq_rx1"
145 CPU2_AFFINITY="$eth_irq_rx2"
146 CPU3_AFFINITY="$eth_irq_rx3"
developere5e3d1b2023-02-02 15:26:12 +0800147
148 CPU0_RPS="$RPS_IF_LIST"
149 CPU1_RPS="$RPS_IF_LIST"
150 CPU2_RPS="$RPS_IF_LIST"
151 CPU3_RPS="$RPS_IF_LIST"
152 else
153 #we bound all wifi card to cpu0 and bound eth to cpu
154 CPU0_AFFINITY=""
155 CPU1_AFFINITY=""
developerc2d0db22023-05-30 10:57:24 +0800156 CPU2_AFFINITY="$eth_irq_rx0 $eth_irq_rx1 $eth_irq_tx"
157 CPU3_AFFINITY="$eth_irq_rx2 $eth_irq_rx3"
developere5e3d1b2023-02-02 15:26:12 +0800158
159 CPU0_RPS="$WIFI_IF_LIST"
160 CPU1_RPS="$WIFI_IF_LIST"
developer5c2bb1b2023-03-02 19:44:01 +0800161 CPU2_RPS=""
developere5e3d1b2023-02-02 15:26:12 +0800162 CPU3_RPS=""
163 fi
164 dbg2 "CPU0_AFFINITY = $CPU0_AFFINITY"
165 dbg2 "CPU1_AFFINITY = $CPU1_AFFINITY"
166 dbg2 "CPU2_AFFINITY = $CPU2_AFFINITY"
167 dbg2 "CPU3_AFFINITY = $CPU3_AFFINITY"
168}
169
developerc8e728e2022-05-19 10:39:32 +0800170MT7986()
171{
172 num_of_wifi=$1
173 DEFAULT_RPS=0
174
175 #Physical IRQ# setting
developer6a30f6f2023-10-16 10:58:43 +0800176 #Ethernet RSS feature enables 4 Rx rings
177 eth_irq_rx0=221
178 eth_irq_rx1=222
179 eth_irq_rx2=223
180 eth_irq_rx3=224
developerc2d0db22023-05-30 10:57:24 +0800181 eth_irq_tx=229
developerc8e728e2022-05-19 10:39:32 +0800182 wifi1_irq=
183 wifi2_irq=
184 wifi3_irq=
developerb3f0c0e2022-07-12 11:44:31 +0800185
186 if [[ "$WED_ENABLE" -eq "1" ]]; then
187 dbg2 "WED_ENABLE ON irq/iptable setting"
188 #TCP Binding
189 iptables -D FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
190 iptables -I FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
191 ip6tables -D FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
192 ip6tables -I FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
193 #UDP Binding
194 iptables -D FORWARD -p udp -j FLOWOFFLOAD --hw
195 iptables -I FORWARD -p udp -j FLOWOFFLOAD --hw
196 ip6tables -D FORWARD -p udp -j FLOWOFFLOAD --hw
197 ip6tables -I FORWARD -p udp -j FLOWOFFLOAD --hw
developerfed736e2024-07-12 14:00:34 +0800198 #Multicast skip Binding
199 iptables -D FORWARD -m pkttype --pkt-type multicast -j ACCEPT
200 iptables -I FORWARD -m pkttype --pkt-type multicast -j ACCEPT
201 ip6tables -D FORWARD -m pkttype --pkt-type multicast -j ACCEPT
202 ip6tables -I FORWARD -m pkttype --pkt-type multicast -j ACCEPT
developerb3f0c0e2022-07-12 11:44:31 +0800203
204 #AX6000 AX7800 - SOC
205 if [[ "$WIFI_RADIO1" -eq "1" ]]; then
206 wifi1_irq=238
207 fi
208 #AX7800 - PCIE0
209 if [[ "$WIFI_RADIO2" -eq "1" ]]; then
210 wifi2_irq=237
211 fi
212 #AX7800 - PCIE1
213 #if [[ "$WIFI_RADIO3" -eq "1" ]]; then
214 # wifi3_irq=239
215 #fi
216 else
217 dbg2 "WED_ENABLE OFF irq/iptable seting"
218 #AX6000 AX7800 - SOC
219 if [[ "$WIFI_RADIO1" -eq "1" ]]; then
220 wifi1_irq=245
221 fi
222 #AX7800 - PCIE0
223 if [[ "$WIFI_RADIO2" -eq "1" ]]; then
224 wifi2_irq=246
225 fi
226 #AX7800 - PCIE1
227 #if [[ "$WIFI_RADIO3" -eq "1" ]]; then
228 # wifi3_irq=247
229 #fi
developerc8e728e2022-05-19 10:39:32 +0800230 fi
developer7e37e612023-09-11 11:36:12 +0800231
232 for vif in $NET_IF_LIST;
233 do
developer6a30f6f2023-10-16 10:58:43 +0800234 if [[ "$vif" == "wlan"* ]] || [[ "$vif" == "phy"* ]]; then
235 WIFI_IF_LIST="$WIFI_IF_LIST $vif"
developer7e37e612023-09-11 11:36:12 +0800236 fi
237 done;
developer6a30f6f2023-10-16 10:58:43 +0800238 dbg2 "$WIFI_IF_LIST = $WIFI_IF_LIST"
developerc8e728e2022-05-19 10:39:32 +0800239 # Please update the CPU binding in each cases.
240 # CPU#_AFFINITY="add binding irq number here"
241 # CPU#_RPS="add binding interface name here"
242 if [ "$num_of_wifi" = "0" ]; then
developer6a30f6f2023-10-16 10:58:43 +0800243 CPU0_AFFINITY="$eth_irq_rx0"
244 CPU1_AFFINITY="$eth_irq_rx1 $eth_irq_tx"
245 CPU2_AFFINITY="$eth_irq_rx2"
246 CPU3_AFFINITY="$eth_irq_rx3"
developerc8e728e2022-05-19 10:39:32 +0800247
developer6a30f6f2023-10-16 10:58:43 +0800248 CPU0_RPS=""
249 CPU1_RPS=""
250 CPU2_RPS=""
251 CPU3_RPS=""
developerc8e728e2022-05-19 10:39:32 +0800252 else
253 #we bound all wifi card to cpu1 and bound eth to cpu0
developer6a30f6f2023-10-16 10:58:43 +0800254 CPU0_AFFINITY="$eth_irq_rx0"
255 CPU1_AFFINITY="$eth_irq_rx1 $eth_irq_tx"
256 CPU2_AFFINITY="$eth_irq_rx2 $wifi2_irq $wifi3_irq"
257 CPU3_AFFINITY="$eth_irq_rx3 $wifi1_irq"
developerc8e728e2022-05-19 10:39:32 +0800258
developer6a30f6f2023-10-16 10:58:43 +0800259 CPU0_RPS="$WIFI_IF_LIST"
260 CPU1_RPS="$WIFI_IF_LIST"
261 CPU2_RPS="$WIFI_IF_LIST"
262 CPU3_RPS="$WIFI_IF_LIST"
developerc8e728e2022-05-19 10:39:32 +0800263 fi
264 dbg2 "CPU0_AFFINITY = $CPU0_AFFINITY"
265 dbg2 "CPU1_AFFINITY = $CPU1_AFFINITY"
266 dbg2 "CPU2_AFFINITY = $CPU2_AFFINITY"
267 dbg2 "CPU3_AFFINITY = $CPU3_AFFINITY"
268}
269
270MT7981()
271{
272 num_of_wifi=$1
273 DEFAULT_RPS=0
274
275 #Physical IRQ# setting
developerc2d0db22023-05-30 10:57:24 +0800276 eth_irq_rx=221
277 eth_irq_tx=229
developerc8e728e2022-05-19 10:39:32 +0800278 wifi1_irq=
279 wifi2_irq=
280 wifi3_irq=
developer975badf2023-10-27 14:35:41 +0800281
developerc8e728e2022-05-19 10:39:32 +0800282 #AX3000
developer975badf2023-10-27 14:35:41 +0800283 if [[ "$WED_ENABLE" -eq "1" ]]; then
284 dbg2 "WED_ENABLE ON irq/iptable setting"
285 #TCP Binding
286 iptables -D FORWARD -p tcp -m conntrack --ctstate \
287 RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
288 iptables -I FORWARD -p tcp -m conntrack --ctstate \
289 RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
290 ip6tables -D FORWARD -p tcp -m conntrack --ctstate \
291 RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
292 ip6tables -I FORWARD -p tcp -m conntrack --ctstate \
293 RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
294 #UDP Binding
295 iptables -D FORWARD -p udp -j FLOWOFFLOAD --hw
296 iptables -I FORWARD -p udp -j FLOWOFFLOAD --hw
297 ip6tables -D FORWARD -p udp -j FLOWOFFLOAD --hw
298 ip6tables -I FORWARD -p udp -j FLOWOFFLOAD --hw
developerfed736e2024-07-12 14:00:34 +0800299 #Multicast skip Binding
300 iptables -D FORWARD -m pkttype --pkt-type multicast -j ACCEPT
301 iptables -I FORWARD -m pkttype --pkt-type multicast -j ACCEPT
302 ip6tables -D FORWARD -m pkttype --pkt-type multicast -j ACCEPT
303 ip6tables -I FORWARD -m pkttype --pkt-type multicast -j ACCEPT
developer975badf2023-10-27 14:35:41 +0800304
305 if [[ "$WIFI_RADIO1" -eq "1" ]]; then
306 wifi1_irq=237
307 fi
308 else
309 if [[ "$WIFI_RADIO1" -eq "1" ]]; then
310 wifi1_irq=245
311 fi
developerc8e728e2022-05-19 10:39:32 +0800312 fi
developer975badf2023-10-27 14:35:41 +0800313
developerc8e728e2022-05-19 10:39:32 +0800314 # Please update the CPU binding in each cases.
315 # CPU#_AFFINITY="add binding irq number here"
316 # CPU#_RPS="add binding interface name here"
317 if [ "$num_of_wifi" = "0" ]; then
developerc2d0db22023-05-30 10:57:24 +0800318 CPU0_AFFINITY="$eth_irq_rx"
319 CPU1_AFFINITY="$eth_irq_tx"
developerc8e728e2022-05-19 10:39:32 +0800320
321 CPU0_RPS="$RPS_IF_LIST"
322 CPU1_RPS="$RPS_IF_LIST"
323 else
324 #we bound all wifi card to cpu0 and bound eth to cpu1
325 CPU0_AFFINITY="$wifi1_irq $wifi2_irq $wifi3_irq"
developerc2d0db22023-05-30 10:57:24 +0800326 CPU1_AFFINITY="$eth_irq_rx $eth_irq_tx"
developerc8e728e2022-05-19 10:39:32 +0800327
328 CPU0_RPS="$RPS_IF_LIST"
329 CPU1_RPS="$RPS_IF_LIST"
330 fi
331 dbg2 "CPU0_AFFINITY = $CPU0_AFFINITY"
332 dbg2 "CPU1_AFFINITY = $CPU1_AFFINITY"
333}
334
335MT7622()
336{
337 num_of_wifi=$1
338 DEFAULT_RPS=0
339
340 #Physical IRQ# setting
341 eth0_irq=224
342 eth1_irq=225
343 wifi1_irq=
344 wifi2_irq=
345 wifi3_irq=
346 #AX1200 AX3200
347 if [[ "$WIFI_RADIO1" -eq "1" ]]; then
348 wifi1_irq=211
349 fi
350 #AX1800 AX3200
351 if [[ "$WIFI_RADIO2" -eq "1" ]]; then
352 wifi2_irq=214
353 fi
354 #AX3600
355 if [[ "$WIFI_RADIO3" -eq "1" ]]; then
356 wifi3_irq=215
357 fi
358
359 # Please update the CPU binding in each cases.
360 # CPU#_AFFINITY="add binding irq number here"
361 # CPU#_RPS="add binding interface name here"
362 if [ "$num_of_wifi" == "0" ]; then
363 CPU0_AFFINITY="$eth0_irq"
364 CPU1_AFFINITY="$eth1_irq"
365
366 CPU0_RPS="$RPS_IF_LIST"
367 CPU1_RPS="$RPS_IF_LIST"
368 else
369 #we bound all wifi card to cpu0 and bound eth to cpu1
370 CPU0_AFFINITY="$wifi1_irq $wifi2_irq $wifi3_irq"
371 CPU1_AFFINITY="$eth0_irq $eth1_irq"
372
373 CPU0_RPS="$RPS_IF_LIST"
374 CPU1_RPS="$RPS_IF_LIST"
375 fi
376
377 dbg2 "CPU0_AFFINITY = $CPU0_AFFINITY"
378 dbg2 "CPU1_AFFINITY = $CPU1_AFFINITY"
379}
380
381setup_model()
382{
developere5e3d1b2023-02-02 15:26:12 +0800383 board=$(board_name)
developerc8e728e2022-05-19 10:39:32 +0800384 num_of_wifi=$NUM_WIFI_CARD
385
developere5e3d1b2023-02-02 15:26:12 +0800386 if [[ $board == *"7988"* ]]; then
387 dbg "setup_model: MT7988 NUM_WIFI_CARD=$num_of_wifi"
388 MT7988 $num_of_wifi
389 elif [[ $board == *"7986"* ]]; then
developerc8e728e2022-05-19 10:39:32 +0800390 dbg "setup_model: MT7986 NUM_WIFI_CARD=$num_of_wifi"
391 MT7986 $num_of_wifi
392 elif [[ $board == *"7981"* ]]; then
393 dbg "setup_model: MT7981 NUM_WIFI_CARD=$num_of_wifi"
394 MT7981 $num_of_wifi
395 elif [[ $board == *"7622"* ]]; then
396 dbg "setup_model: MT7622 NUM_WIFI_CARD=$num_of_wifi"
397 MT7622 $num_of_wifi
developer33759cf2024-10-11 15:19:50 +0800398 elif [[ $board == *"bpi-r4"* ]]; then
399 dbg "setup_model: bpi-r4 NUM_WIFI_CARD=$num_of_wifi"
400 MT7988 $num_of_wifi
developerc8e728e2022-05-19 10:39:32 +0800401 fi
402}
403
404get_virtual_irq()
405{
406 PHY_POS=`expr $NUM_OF_CPU + 3` #physical irq # position in /proc/interrups may vary with the number of CPU up
407 target_phy_irq=$1
408 cat /proc/interrupts | sed 's/:/ /g'| awk '$1 ~ /^[0-9]+$/' | while read line
409 do
410 set -- $line
411 phy_irq=$(eval "echo \$$PHY_POS")
412 if [ $phy_irq == $target_phy_irq ]; then
413 echo $1
414 return
415 fi
416 done
417}
418
419set_rps_cpu_bitmap()
420{
421 dbg2 "# Scan binding interfaces of each cpu"
422 # suppose the value of interface_var is null or hex
423 num=0
424 while [ "$num" -lt "$NUM_OF_CPU" ];do
425 cpu_bit=$((2 ** $num))
426 eval rps_list=\$CPU${num}_RPS
427 dbg2 "# CPU$num: rps_list=$rps_list"
428 for i in $rps_list; do
429 var=${VAR_PREFIX}_${i//-/_}
430 eval ifval=\$$var
431 dbg2 "[var val before] \$$var=$ifval"
432 if [ -z "$ifval" ]; then
433 eval $var=$cpu_bit
434 else
435 eval $var=`expr $ifval + $cpu_bit`
436 fi
437 eval ifval=\$$var
438 dbg2 "[rps val after]$i=$ifval"
439 done
440 num=`expr $num + 1`
441 done
442}
443
444# $1: The default rps value. If rps of the interface is not setup, set $1 to it
445set_rps_cpus()
446{
447 dbg2 "# Setup rps of the interfaces, $RPS_IF_LIST."
448 for i in $RPS_IF_LIST; do
449 var=${VAR_PREFIX}_${i//-/_}
450 eval cpu_map=\$$var
451 if [ -d /sys/class/net/$i ]; then
452 if [ ! -z $cpu_map ]; then
453 cpu_map=`printf '%x' $cpu_map`
454 dbg "echo $cpu_map > /sys/class/net/$i/queues/rx-0/rps_cpus"
455 echo $cpu_map > /sys/class/net/$i/queues/rx-0/rps_cpus
456 elif [ ! -z $1 ]; then
457 dbg "echo $1 > /sys/class/net/$i/queues/rx-0/rps_cpus"
458 echo $1 > /sys/class/net/$i/queues/rx-0/rps_cpus
459 fi
460 fi
461 done
462}
463
464set_smp_affinity()
465{
466 dbg2 "# Setup affinity of each physical irq."
467 num=0
468 while [ "$num" -lt "$NUM_OF_CPU" ];do
469 eval smp_list=\$CPU${num}_AFFINITY
470 for i in $smp_list; do
471 cpu_bit=$((2 ** $num))
472 virq=$(get_virtual_irq $i)
473 #virq=$i
474 dbg2 "irq p2v $i --> $virq"
475 if [ ! -z $virq ]; then
476 dbg "echo $cpu_bit > /proc/irq/$virq/smp_affinity"
477 echo $cpu_bit > /proc/irq/$virq/smp_affinity
478 fi
479 done
480 num=`expr $num + 1`
481 done
482}
483
484if [ "$1" = "dbg" ]; then
485 DBG=1
486elif [ "$1" = "dbg2" ]; then
487 DBG=2
488else
489 DBG=0
490fi
491
492# Usage: dbg "the output string"
493dbg()
494{
495 if [ "$DBG" -ge "1" ]; then
496 echo -e $1
497 fi
498}
499
500# Usage: dbg2 "the output string"
501dbg2()
502{
503 if [ "$DBG" -ge "2" ]; then
504 echo -e $1
505 fi
506}
507
508dbg "# RPS and AFFINITY Setting"
509dbg "# NUM_OF_CPU=$NUM_OF_CPU"
510VAR_PREFIX="autogen"
511get_if_info
512setup_model
513set_rps_cpu_bitmap
514set_rps_cpus $DEFAULT_RPS
515set_smp_affinity
516#end of file