summaryrefslogtreecommitdiffstats
path: root/recipes-networking/dpdk/files/run-ptest
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2014-06-26 11:48:23 (GMT)
committerAdrian Dudau <adrian.dudau@enea.com>2014-06-26 11:48:23 (GMT)
commit1b6242fc583a6b871304fb995af6dc211b58f69b (patch)
treeb5d434d90dedae24792906aa304897c23a134386 /recipes-networking/dpdk/files/run-ptest
downloadmeta-ip-daisy-enea.tar.gz
initial commit for Enea Linux 4.0daisy-enea
Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'recipes-networking/dpdk/files/run-ptest')
-rw-r--r--recipes-networking/dpdk/files/run-ptest195
1 files changed, 195 insertions, 0 deletions
diff --git a/recipes-networking/dpdk/files/run-ptest b/recipes-networking/dpdk/files/run-ptest
new file mode 100644
index 0000000..76fd407
--- /dev/null
+++ b/recipes-networking/dpdk/files/run-ptest
@@ -0,0 +1,195 @@
1#!/bin/sh
2
3export RTE_SDK=/opt/dpdk
4export RTE_TARGET=x86_64-default-linuxapp-gcc
5export RTE_ARCH=x86_64
6RTE_SRC=/usr/src/dpdk
7HUGE_PAGES_MEM=2097152 #[1024 * 2048kB]
8
9#check hugetlbfs mount
10echo -n "Mounting hugepages..."
11mount | grep "nodev on /mnt/huge type hugetlbfs"
12if [ $? -ne 0 ]; then
13 mkdir -p /mnt/huge
14 mount -t hugetlbfs nodev /mnt/huge
15fi
16echo "OK!"
17
18#increase hugepages for all nodes
19echo -n "Allocating hugepages..."
20#get hugepages sizes
21hp_sz=`cat /proc/meminfo | grep Hugepagesize | sed -r "s/Hugepagesize:[^0-9]*([0-9]+) kB/\1/"`
22#calculate huge pages number to get the equivalent of 1024 pages of 2MB
23huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}`
24#get hugepages no
25hp=0
26#Find out if this is a NUMA machine
27ls /sys/devices/system/node/node* > /dev/null 2>&1
28if [ $? -ne 0 ]; then
29 hp=`cat /proc/sys/vm/nr_hugepages`
30 hptest=`expr $hp + $huge_pages_no`
31 echo $hptest > /proc/sys/vm/nr_hugepages
32else
33 hparray=()
34 nodes=`ls /sys/devices/system/node | grep node | wc -l`
35 for (( i=0; $i<$nodes; i++ ))
36 do
37 hp=`cat /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages`
38 hptest=`expr $hp + $huge_pages_no`
39 echo $hptest > /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages
40 hparray+=("$hp")
41 done
42fi
43echo "OK!"
44echo "Allocated ${huge_pages_no} x ${hp_sz}kB"
45
46#run l2fwd loopback test
47DEVS=("I350" "82599")
48PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py
49IGB_UIO=${RTE_SDK}/${RTE_TARGET}/kmod/igb_uio.ko
50RTE_KNI=${RTE_SDK}/${RTE_TARGET}/kmod/rte_kni.ko
51
52rmmod rte_kni > /dev/null 2>&1
53rmmod igb_uio > /dev/null 2>&1
54modprobe uio && insmod ${IGB_UIO}
55
56#insert igb_uio, needed by some dpdk tests
57if [ $? -ne 0 ]; then
58 echo "FAIL: uio/igb_uio load"
59 DEVS=()
60else
61 echo "PASS: uio/igb_uio load"
62fi
63
64#insert rte_kni driver in loopback mode, needed by KNI tests
65insmod ${RTE_KNI} lo_mode=lo_mode_fifo
66
67if [ $? -ne 0 ]; then
68 echo "FAIL: rte_kni load"
69 DEVS=()
70else
71 echo "PASS: rte_kni load"
72fi
73
74#bind devices to igb_uio, needed by some dpdk tests
75drvarray=()
76pciarray=()
77for dev in ${DEVS[@]}
78do
79 DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1`
80 if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then
81 continue
82 fi
83
84 DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"`
85 DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"`
86 DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"`
87 DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"`
88
89 echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)"
90
91 if [ ! -z ${DEV_ETH} ]; then
92 ifconfig ${DEV_ETH} down
93 fi
94
95 ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR}
96 drvarray+=("${DEV_DRV}")
97 pciarray+=("${DEV_PCI_ADDR}")
98done
99
100#run dpdk tests
101python ${RTE_SRC}/app/test/autotest.py ./test ${RTE_TARGET}
102
103#bind devices to initial drivers
104for ((i=0;i<${#pciarray[@]};i++));
105do
106 echo "${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}"
107 ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}
108done
109
110for dev in ${DEVS[@]}
111do
112 DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1`
113 if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then
114 echo "SKIP: l2fwd-lpbk ($dev)"
115 continue
116 fi
117
118 DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"`
119 DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"`
120 DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"`
121 DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"`
122
123 echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)"
124
125 if [ ! -z ${DEV_ETH} ]; then
126 ifconfig ${DEV_ETH} down
127 fi
128
129 ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR}
130
131 ./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 &
132 APP_PID=$!
133 sleep 20
134 kill $APP_PID
135
136 DEV_SENT=`cat ${DEV_PCI_ADDR}.log|grep "Packets sent:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
137 DEV_RECV=`cat ${DEV_PCI_ADDR}.log|grep "Packets received:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
138 DEV_DROP=`cat ${DEV_PCI_ADDR}.log|grep "Packets dropped:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"`
139
140
141 echo "Results: sent $DEV_SENT, received $DEV_RECV, dropped $DEV_DROP"
142
143 STATUS=0
144
145 case "$dev" in
146 "I350")
147 if [ ${DEV_SENT} -lt 13000000 ]; then
148 STATUS=1
149 fi
150 ;;
151 "82599")
152 if [ ${DEV_SENT} -lt 110000000 ]; then
153 STATUS=1
154 fi
155 ;;
156 esac
157
158 if [ ${STATUS} -ne 0 ]; then
159 echo "FAIL: l2fwd-lpbk (low throughput)"
160 fi
161
162 if [ ${STATUS} -eq 0 ] && { [ ${DEV_DROP} -ne 0 ] || [ ${DEV_SENT} -ne ${DEV_RECV} ]; } then
163 echo "FAIL: l2fwd-lpbk (dropped packets)"
164 STATUS=1
165 fi
166
167 if [ ${STATUS} -eq 0 ]; then
168 echo "PASS: l2fwd-lpbk ($dev)"
169 fi
170
171 ${PCI_UTIL} --bind=${DEV_DRV} ${DEV_PCI_ADDR}
172done
173
174if [ ! -z ${DEVS} ]; then
175 rmmod rte_kni > /dev/null 2>&1
176 rmmod igb_uio > /dev/null 2>&1
177 rmmod uio > /dev/null 2>&1
178fi
179
180echo -n "Freeing hugepages..."
181#Find out if this is a NUMA machine
182ls /sys/devices/system/node/node* > /dev/null 2>&1
183if [ $? -ne 0 ]; then
184 echo $hp > /proc/sys/vm/nr_hugepages
185else
186 i=0
187 for hp in ${hparray[@]}
188 do
189 echo $hp > "/sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages"
190 ((i++))
191 done
192fi
193echo "OK!"
194rm -rf /mnt/huge/*
195