blob: 76fd40745ebc88d9adb063ac5b1b4f11755e5bca (
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
|
#!/bin/sh
export RTE_SDK=/opt/dpdk
export RTE_TARGET=x86_64-default-linuxapp-gcc
export RTE_ARCH=x86_64
RTE_SRC=/usr/src/dpdk
HUGE_PAGES_MEM=2097152 #[1024 * 2048kB]
#check hugetlbfs mount
echo -n "Mounting hugepages..."
mount | grep "nodev on /mnt/huge type hugetlbfs"
if [ $? -ne 0 ]; then
mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
fi
echo "OK!"
#increase hugepages for all nodes
echo -n "Allocating hugepages..."
#get hugepages sizes
hp_sz=`cat /proc/meminfo | grep Hugepagesize | sed -r "s/Hugepagesize:[^0-9]*([0-9]+) kB/\1/"`
#calculate huge pages number to get the equivalent of 1024 pages of 2MB
huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}`
#get hugepages no
hp=0
#Find out if this is a NUMA machine
ls /sys/devices/system/node/node* > /dev/null 2>&1
if [ $? -ne 0 ]; then
hp=`cat /proc/sys/vm/nr_hugepages`
hptest=`expr $hp + $huge_pages_no`
echo $hptest > /proc/sys/vm/nr_hugepages
else
hparray=()
nodes=`ls /sys/devices/system/node | grep node | wc -l`
for (( i=0; $i<$nodes; i++ ))
do
hp=`cat /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages`
hptest=`expr $hp + $huge_pages_no`
echo $hptest > /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages
hparray+=("$hp")
done
fi
echo "OK!"
echo "Allocated ${huge_pages_no} x ${hp_sz}kB"
#run l2fwd loopback test
DEVS=("I350" "82599")
PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py
IGB_UIO=${RTE_SDK}/${RTE_TARGET}/kmod/igb_uio.ko
RTE_KNI=${RTE_SDK}/${RTE_TARGET}/kmod/rte_kni.ko
rmmod rte_kni > /dev/null 2>&1
rmmod igb_uio > /dev/null 2>&1
modprobe uio && insmod ${IGB_UIO}
#insert igb_uio, needed by some dpdk tests
if [ $? -ne 0 ]; then
echo "FAIL: uio/igb_uio load"
DEVS=()
else
echo "PASS: uio/igb_uio load"
fi
#insert rte_kni driver in loopback mode, needed by KNI tests
insmod ${RTE_KNI} lo_mode=lo_mode_fifo
if [ $? -ne 0 ]; then
echo "FAIL: rte_kni load"
DEVS=()
else
echo "PASS: rte_kni load"
fi
#bind devices to igb_uio, needed by some dpdk tests
drvarray=()
pciarray=()
for dev in ${DEVS[@]}
do
DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1`
if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then
continue
fi
DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"`
DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"`
DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"`
DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"`
echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)"
if [ ! -z ${DEV_ETH} ]; then
ifconfig ${DEV_ETH} down
fi
${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR}
drvarray+=("${DEV_DRV}")
pciarray+=("${DEV_PCI_ADDR}")
done
#run dpdk tests
python ${RTE_SRC}/app/test/autotest.py ./test ${RTE_TARGET}
#bind devices to initial drivers
for ((i=0;i<${#pciarray[@]};i++));
do
echo "${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}"
${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}
done
for dev in ${DEVS[@]}
do
DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1`
if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then
echo "SKIP: l2fwd-lpbk ($dev)"
continue
fi
DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"`
DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"`
DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"`
DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"`
echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)"
if [ ! -z ${DEV_ETH} ]; then
ifconfig ${DEV_ETH} down
fi
${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR}
./l2fwd-lpbk -c 0xff -n 2 --use-device=${DEV_PCI_ADDR} -- -p 0x1 -t 128 -s 64 -T 10 -l > ${DEV_PCI_ADDR}.log 2>&1 &
APP_PID=$!
sleep 20
kill $APP_PID
DEV_SENT=`cat ${DEV_PCI_ADDR}.log|grep "Packets sent:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
DEV_RECV=`cat ${DEV_PCI_ADDR}.log|grep "Packets received:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
DEV_DROP=`cat ${DEV_PCI_ADDR}.log|grep "Packets dropped:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
echo "Results: sent $DEV_SENT, received $DEV_RECV, dropped $DEV_DROP"
STATUS=0
case "$dev" in
"I350")
if [ ${DEV_SENT} -lt 13000000 ]; then
STATUS=1
fi
;;
"82599")
if [ ${DEV_SENT} -lt 110000000 ]; then
STATUS=1
fi
;;
esac
if [ ${STATUS} -ne 0 ]; then
echo "FAIL: l2fwd-lpbk (low throughput)"
fi
if [ ${STATUS} -eq 0 ] && { [ ${DEV_DROP} -ne 0 ] || [ ${DEV_SENT} -ne ${DEV_RECV} ]; } then
echo "FAIL: l2fwd-lpbk (dropped packets)"
STATUS=1
fi
if [ ${STATUS} -eq 0 ]; then
echo "PASS: l2fwd-lpbk ($dev)"
fi
${PCI_UTIL} --bind=${DEV_DRV} ${DEV_PCI_ADDR}
done
if [ ! -z ${DEVS} ]; then
rmmod rte_kni > /dev/null 2>&1
rmmod igb_uio > /dev/null 2>&1
rmmod uio > /dev/null 2>&1
fi
echo -n "Freeing hugepages..."
#Find out if this is a NUMA machine
ls /sys/devices/system/node/node* > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo $hp > /proc/sys/vm/nr_hugepages
else
i=0
for hp in ${hparray[@]}
do
echo $hp > "/sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages"
((i++))
done
fi
echo "OK!"
rm -rf /mnt/huge/*
|