blob: 0dcb79f3f58a95954590d806ee18774af4d1d2c9 (
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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
#! /bin/bash
prog=dpdk_intel
config=/etc/ixgbe.conf
quit()
{
QUIT=$1
}
#
# Creates hugepage filesystem.
#
create_mnt_huge()
{
echo "Creating /mnt/huge and mounting as hugetlbfs"
mkdir -p /mnt/huge
grep -s '/mnt/huge' /proc/mounts > /dev/null
if [ $? -ne 0 ] ; then
mount -t hugetlbfs nodev /mnt/huge
fi
}
#
# Removes hugepage filesystem.
#
remove_mnt_huge()
{
echo "Unmounting /mnt/huge and removing directory"
grep -s '/mnt/huge' /proc/mounts > /dev/null
if [ $? -eq 0 ] ; then
umount /mnt/huge
fi
if [ -d /mnt/huge ] ; then
rm -R /mnt/huge
fi
}
#
# Unloads igb_uio.ko.
#
remove_igb_uio_module()
{
echo "Unloading any existing DPDK UIO module"
/sbin/lsmod | grep -s igb_uio > /dev/null
if [ $? -eq 0 ] ; then
/sbin/rmmod igb_uio
fi
}
#
# Loads new igb_uio.ko (and uio module if needed).
#
load_igb_uio_module()
{
if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
echo " To fix, please try to rebuild target."
return
fi
remove_igb_uio_module
/sbin/lsmod | grep -s uio > /dev/null
if [ $? -ne 0 ] ; then
modinfo uio > /dev/null
if [ $? -eq 0 ]; then
echo "Loading uio module"
/sbin/modprobe uio
fi
fi
# UIO may be compiled into kernel, so it may not be an error if it can't
# be loaded.
echo "Loading DPDK UIO module"
/sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko
if [ $? -ne 0 ] ; then
echo "## ERROR: Could not load kmod/igb_uio.ko."
quit
fi
}
#
# Unloads the rte_kni.ko module.
#
remove_kni_module()
{
echo "Unloading any existing DPDK KNI module"
/sbin/lsmod | grep -s rte_kni > /dev/null
if [ $? -eq 0 ] ; then
/sbin/rmmod rte_kni
fi
}
#
# Loads the rte_kni.ko module.
#
load_kni_module()
{
# Check that the KNI module is already built.
if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko ];then
echo "## ERROR: Target does not have the DPDK KNI Module."
echo " To fix, please try to rebuild target."
return
fi
# Unload existing version if present.
remove_kni_module
# Now try load the KNI module.
echo "Loading DPDK KNI module"
/sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko
if [ $? -ne 0 ] ; then
echo "## ERROR: Could not load kmod/rte_kni.ko."
quit
fi
}
#
# Removes all reserved hugepages.
#
clear_huge_pages()
{
echo > .echo_tmp
for d in /sys/devices/system/node/node? ; do
echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
done
echo "Removing currently reserved hugepages"
sh .echo_tmp
rm -f .echo_tmp
remove_mnt_huge
}
#
# Creates hugepages.
#
set_non_numa_pages()
{
clear_huge_pages
echo "echo $HUGEPAGE_MEM > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp
echo "Reserving hugepages"
sh .echo_tmp
rm -f .echo_tmp
create_mnt_huge
}
#
# Creates hugepages on specific NUMA nodes.
#
set_numa_pages()
{
clear_huge_pages
echo ""
echo " Input the number of 2MB pages for each node"
echo " Example: to have 128MB of hugepages available per node,"
echo " enter '64' to reserve 64 * 2MB pages on each node"
echo > .echo_tmp
for d in /sys/devices/system/node/node? ; do
node=$(basename $d)
echo -n "Number of pages for $node: "
read Pages
echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
done
echo "Reserving hugepages"
sh .echo_tmp
rm -f .echo_tmp
create_mnt_huge
}
#
# Uses dpdk_nic_bind.py to move devices to work with igb_uio
#
bind_nics_to_igb_uio()
{
oldIFS=$IFS
IFS=,
for PCI_PATH in $IXGBE_UIO; do
${RTE_SDK}/tools/dpdk_nic_bind.py -b igb_uio $PCI_PATH
done
IFS=$oldIFS
}
#
# Uses dpdk_nic_bind.py to move devices to work with kernel drivers again
#
unbind_nics()
{
oldIFS=$IFS
IFS=,
for PCI_PATH in $IXGBE_UIO; do
sudo ${RTE_SDK}/tools/dpdk_nic_bind.py -b ixgbe $PCI_PATH
done
IFS=$oldIFS
}
load_config_file()
{
if [ ! -f $config ] ; then
echo "Loading Configure file $config error"
exit 3
fi
source $config
}
start()
{
echo -n $"Starting $prog: "
load_config_file
load_igb_uio_module
bind_nics_to_igb_uio
set_non_numa_pages
return 0
}
stop()
{
echo -n $"Stopping $prog: "
load_config_file
clear_huge_pages
unbind_nics
remove_igb_uio_module
return 0
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=2
esac
exit $RETVAL
|