-
Notifications
You must be signed in to change notification settings - Fork 2
/
my_set_4way_nic.sh
executable file
·90 lines (69 loc) · 1.53 KB
/
my_set_4way_nic.sh
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
bond_list="bond0 bond1"
rfc=16392
#param1: nic
set_xps_for_nic()
{
for fileRps in $(ls /sys/class/net/$1/queues/tx-*/xps_cpus)
do
echo 0003ff,f0003fff > $file
done
}
set_rps_for_sys()
{
cc=$(grep -c processor /proc/cpuinfo)
rsfe=$(($cc*$rfc))
sysctl -w net.core.rps_sock_flow_entries=$rsfe
}
#param1: nic
set_rps_for_nic()
{
for file in $(ls /sys/class/net/$1/queues/rx-*/rps_flow_cnt)
do
echo $rfc> $file
done
for file in $(ls /sys/class/net/$1/queues/rx-*/rps_cpus)
do
echo 0003ff,f0003fff > $file
done
}
#param1: nic
set_nic_bind_numa_node()
{
node=$(cat /sys/class/net/$1/device/numa_node)
if [ -n $node ];then
echo "bind $1 to node $node"
set_irq_affinity_bynode.sh $node $nic
fi
}
#param1: nic
set_nic_parameter()
{
ethtool -G $1 rx 8192 tx 1024
ethtool -G $1 rx 8192 tx 1024
ethtool -K $1 lro on
}
#param1: nic
set_nic_irq_to_cpu()
{
set_irq_affinity_cpulist.sh 0-13,28-41 $1
}
service iptables stop
service irqbalance stop
set_rps_for_sys
for bond in $bond_list
do
dmidecode -t system | grep -i huawei && cat /proc/net/bonding/$bond | awk '$0~/Slave Interface:/ {print $NF}' | while read nic
do
[[ -z $nic ]] && echo not found bond && exit 1
echo "the nic is $nic in the node-$node"
set_nic_bind_numa_node $nic
echo "nic parameter"
ethtool -K $bond lro on
set_nic_parameter $nic
echo "set rps..."
set_rps_for_nic $nic
echo "set xps..."
set_xps_for_nic $nic
done
done