]> git.proxmox.com Git - mirror_ovs.git/blob - tests/pmd.at
tests: Fix race in MPLS translate.
[mirror_ovs.git] / tests / pmd.at
1 AT_BANNER([PMD])
2
3 m4_divert_push([PREPARE_TESTS])
4
5 # Given the output of `ovs-appctl dpif-netdev/pmd-rxq-show`, prints a list
6 # of every rxq (one per line) in the form:
7 # port_name rxq_id numa_id core_id
8 parse_pmd_rxq_show () {
9 awk '/pmd/ {numa=$4; core=substr($6, 1, length($6) - 1)} /\t/{for (i=4; i<=NF; i++) print $2, $i, numa, core}' | sort
10 }
11
12 # Given the output of `ovs-appctl dpctl/dump-flows`, prints a list of flows
13 # (one per line), with the pmd_id at the beginning of the line
14 #
15 flow_dump_prepend_pmd () {
16 awk '/flow-dump from non-dpdk/ {pmd_id=-1; next} /flow-dump from pmd/ {pmd_id=$7; next} {print pmd_id, $0}' | sort
17 }
18
19 m4_divert_pop([PREPARE_TESTS])
20
21 dnl CHECK_CPU_DISCOVERED([n_cpu])
22 dnl
23 dnl Waits until CPUs discovered and checks if number of discovered CPUs
24 dnl is greater or equal to 'n_cpu'. Without parameters checks that at
25 dnl least one CPU discovered.
26 m4_define([CHECK_CPU_DISCOVERED], [
27 PATTERN="Discovered [[0-9]]* NUMA nodes and [[0-9]]* CPU cores"
28 OVS_WAIT_UNTIL([grep "$PATTERN" ovs-vswitchd.log])
29 N_CPU=$(grep "$PATTERN" ovs-vswitchd.log | sed -e 's/.* \([[0-9]]*\) CPU cores/\1/')
30 if [[ -z "$1" ]]
31 then AT_CHECK([test "$N_CPU" -gt "0"])
32 else AT_SKIP_IF([test "$N_CPU" -lt "$1"])
33 fi
34 ])
35
36 dnl CHECK_PMD_THREADS_CREATED([n_threads], [numa_id], [+line])
37 dnl
38 dnl Whaits for creation of 'n_threads' or at least 1 thread if $1 not
39 dnl passed. Checking starts from line number 'line' in ovs-vswithd.log .
40 m4_define([CHECK_PMD_THREADS_CREATED], [
41 PATTERN="Created [[0-9]]* pmd threads on numa node $2"
42 line_st=$3
43 if [[ -z "$line_st" ]]
44 then
45 line_st="+0"
46 fi
47 OVS_WAIT_UNTIL([tail -n $line_st ovs-vswitchd.log | grep "$PATTERN"])
48 N_THREADS=$(tail -n $line_st ovs-vswitchd.log | grep "$PATTERN" | tail -1 | sed -e 's/.* \([[0-9]]*\) pmd .*/\1/')
49 if [[ -z "$1" ]]
50 then AT_CHECK([test "$N_THREADS" -gt 0])
51 else AT_CHECK([test "$N_THREADS" -eq "$1"])
52 fi
53 ])
54
55 m4_define([SED_NUMA_CORE_PATTERN], ["s/\(numa_id \)[[0-9]]*\( core_id \)[[0-9]]*:/\1<cleared>\2<cleared>:/"])
56 m4_define([DUMMY_NUMA], [--dummy-numa="0,0,0,0"])
57
58 AT_SETUP([PMD - creating a thread/add-port])
59 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy-pmd], [], [], [DUMMY_NUMA])
60
61 CHECK_CPU_DISCOVERED()
62 CHECK_PMD_THREADS_CREATED()
63
64 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
65 pmd thread numa_id <cleared> core_id <cleared>:
66 isolated : false
67 port: p0 queue-id: 0
68 ])
69
70 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
71 dummy@ovs-dummy: hit:0 missed:0
72 br0:
73 br0 65534/100: (dummy-internal)
74 p0 1/1: (dummy-pmd: configured_rx_queues=1, configured_tx_queues=<cleared>, requested_rx_queues=1, requested_tx_queues=<cleared>)
75 ])
76
77 OVS_VSWITCHD_STOP
78 AT_CLEANUP
79
80 AT_SETUP([PMD - multiqueue support])
81 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy-pmd], [], [], [DUMMY_NUMA])
82
83 CHECK_CPU_DISCOVERED()
84 CHECK_PMD_THREADS_CREATED()
85
86 AT_CHECK([ovs-vsctl set interface p0 options:n_rxq=8])
87
88 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
89 dummy@ovs-dummy: hit:0 missed:0
90 br0:
91 br0 65534/100: (dummy-internal)
92 p0 1/1: (dummy-pmd: configured_rx_queues=8, configured_tx_queues=<cleared>, requested_rx_queues=8, requested_tx_queues=<cleared>)
93 ])
94
95 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
96 pmd thread numa_id <cleared> core_id <cleared>:
97 isolated : false
98 port: p0 queue-id: 0 1 2 3 4 5 6 7
99 ])
100
101 OVS_VSWITCHD_STOP
102 AT_CLEANUP
103
104
105 AT_SETUP([PMD - pmd-cpu-mask/distribution of rx queues])
106 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy-pmd options:n_rxq=8],
107 [], [], [DUMMY_NUMA])
108
109 CHECK_CPU_DISCOVERED(2)
110 CHECK_PMD_THREADS_CREATED()
111
112 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
113 dummy@ovs-dummy: hit:0 missed:0
114 br0:
115 br0 65534/100: (dummy-internal)
116 p0 1/1: (dummy-pmd: configured_rx_queues=8, configured_tx_queues=<cleared>, requested_rx_queues=8, requested_tx_queues=<cleared>)
117 ])
118
119 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
120 pmd thread numa_id <cleared> core_id <cleared>:
121 isolated : false
122 port: p0 queue-id: 0 1 2 3 4 5 6 7
123 ])
124
125 TMP=$(cat ovs-vswitchd.log | wc -l | tr -d [[:blank:]])
126 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x3])
127 CHECK_PMD_THREADS_CREATED([2], [], [+$TMP])
128
129 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
130 pmd thread numa_id <cleared> core_id <cleared>:
131 isolated : false
132 port: p0 queue-id: 0 2 4 6
133 pmd thread numa_id <cleared> core_id <cleared>:
134 isolated : false
135 port: p0 queue-id: 1 3 5 7
136 ])
137
138 TMP=$(cat ovs-vswitchd.log | wc -l | tr -d [[:blank:]])
139 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x1])
140 CHECK_PMD_THREADS_CREATED([1], [], [+$TMP])
141
142 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], [0], [dnl
143 pmd thread numa_id <cleared> core_id <cleared>:
144 isolated : false
145 port: p0 queue-id: 0 1 2 3 4 5 6 7
146 ])
147
148 OVS_VSWITCHD_STOP
149 AT_CLEANUP
150
151
152 AT_SETUP([PMD - stats])
153 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 ofport_request=7 type=dummy-pmd options:n_rxq=4],
154 [], [], [DUMMY_NUMA])
155
156 CHECK_CPU_DISCOVERED()
157 CHECK_PMD_THREADS_CREATED()
158
159 AT_CHECK([ovs-appctl vlog/set dpif_netdev:dbg])
160 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
161
162 sleep 1
163
164 AT_CHECK([ovs-appctl dpif/show | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
165 dummy@ovs-dummy: hit:0 missed:0
166 br0:
167 br0 65534/100: (dummy-internal)
168 p0 7/1: (dummy-pmd: configured_rx_queues=4, configured_tx_queues=<cleared>, requested_rx_queues=4, requested_tx_queues=<cleared>)
169 ])
170
171 AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 5], [0], [dnl
172 pmd thread numa_id <cleared> core_id <cleared>:
173 emc hits:0
174 megaflow hits:0
175 avg. subtable lookups per hit:0.00
176 miss:0
177 lost:0
178 ])
179
180 ovs-appctl time/stop
181 ovs-appctl time/warp 100
182 (
183 for i in `seq 0 19`;
184 do
185 pkt="in_port(7),eth(src=50:54:00:00:00:77,dst=50:54:00:00:01:78),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)"
186 AT_CHECK([ovs-appctl netdev-dummy/receive p0 $pkt])
187 done
188 )
189 ovs-appctl time/warp 100
190
191 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
192 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),eth(src=50:54:00:00:00:77,dst=50:54:00:00:01:78),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
193 ])
194 AT_CHECK([cat ovs-vswitchd.log | filter_flow_install | strip_xout], [0], [dnl
195 recirc_id(0),in_port(1),eth(src=50:54:00:00:00:77,dst=50:54:00:00:01:78),eth_type(0x0800),ipv4(frag=no), actions: <del>
196 ])
197
198 AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 5], [0], [dnl
199 pmd thread numa_id <cleared> core_id <cleared>:
200 emc hits:19
201 megaflow hits:0
202 avg. subtable lookups per hit:0.00
203 miss:1
204 lost:0
205 ])
206
207 OVS_VSWITCHD_STOP
208 AT_CLEANUP
209
210 dnl Reconfigure the number of rx queues of a port, make sure that all the
211 dnl queues are polled by the datapath and try to send a couple of packets.
212 AT_SETUP([PMD - reconfigure n_rxq])
213 OVS_VSWITCHD_START(
214 [add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=2 -- \
215 add-port br0 p2 -- set Interface p2 type=dummy-pmd ofport_request=2
216 ], [], [], [--dummy-numa 0])
217 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
218
219 AT_CHECK([ovs-ofctl add-flow br0 action=controller])
220
221 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
222 p1 0 0 0
223 p1 1 0 0
224 p2 0 0 0
225 ])
226
227 AT_CAPTURE_FILE([ofctl_monitor.log])
228 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
229
230 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 1 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
231
232 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 2])
233 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
234
235 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
236 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
237 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
238 ])
239
240 AT_CHECK([ovs-vsctl set interface p1 options:n_rxq=4])
241
242 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
243 p1 0 0 0
244 p1 1 0 0
245 p1 2 0 0
246 p1 3 0 0
247 p2 0 0 0
248 ])
249
250 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
251
252 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 3 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
253
254 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 2])
255 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
256
257 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
258 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
259 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
260 ])
261
262 dnl Check resetting to default number of rx queues after removal from the db.
263 AT_CHECK([ovs-vsctl remove interface p1 options n_rxq])
264
265 AT_CHECK([ovs-appctl dpif/show | grep p1 | sed 's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
266 p1 1/1: (dummy-pmd: configured_rx_queues=1, configured_tx_queues=<cleared>, requested_rx_queues=1, requested_tx_queues=<cleared>)
267 ])
268
269 OVS_VSWITCHD_STOP
270 AT_CLEANUP
271
272 dnl There was a bug where OVS failed to create a ukey and install a megaflow
273 dnl if a packet with the exact same flow was received by two different pmd
274 dnl threads. This is a regression test for that bug.
275 AT_SETUP([PMD - same flow multiple threads])
276 OVS_VSWITCHD_START(
277 [add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=2 -- \
278 set Open_vSwitch . other_config:pmd-cpu-mask=3
279 ], [], [], [--dummy-numa 0,0])
280 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
281
282 AT_CHECK([ovs-ofctl add-flow br0 action=controller])
283
284 dnl Make sure that the queues are on different cores. There's no way to
285 dnl control which queue is on which thread, we just need to make sure that
286 dnl two threads (core_id) show up in pmd-rxq-show
287 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show | cut -f 4 -d ' ' | sort], [0], [dnl
288 0
289 1
290 ])
291
292 AT_CAPTURE_FILE([ofctl_monitor.log])
293 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
294
295 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
296
297 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 1 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
298
299 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 4])
300 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
301
302 dnl Make sure that both flows have been installed
303 AT_CHECK([ovs-appctl dpctl/dump-flows | flow_dump_prepend_pmd], [0], [dnl
304 0 recirc_id(0),in_port(1),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller))
305 1 recirc_id(0),in_port(1),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller))
306 ])
307
308 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
309 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
310 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
311 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
312 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
313 ])
314
315 OVS_VSWITCHD_STOP
316 AT_CLEANUP
317
318 AT_SETUP([PMD - change numa node])
319 OVS_VSWITCHD_START(
320 [add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=2 -- \
321 add-port br0 p2 -- set Interface p2 type=dummy-pmd ofport_request=2 options:n_rxq=2 -- \
322 set Open_vSwitch . other_config:pmd-cpu-mask=3
323 ], [], [], [--dummy-numa 0,1])
324 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
325
326 AT_CHECK([ovs-ofctl add-flow br0 action=controller])
327
328 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
329 p1 0 0 0
330 p1 1 0 0
331 p2 0 0 0
332 p2 1 0 0
333 ])
334
335 AT_CAPTURE_FILE([ofctl_monitor.log])
336 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
337
338 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
339
340 AT_CHECK([ovs-appctl netdev-dummy/receive p2 --qid 1 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
341
342 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 4])
343 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
344
345 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
346 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
347 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
348 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=2 (via action) data_len=42 (unbuffered)
349 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
350 ])
351
352 AT_CHECK([ovs-vsctl set Interface p2 options:numa_id=1])
353
354 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
355 p1 0 0 0
356 p1 1 0 0
357 p2 0 1 1
358 p2 1 1 1
359 ])
360
361 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
362
363 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 1 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
364
365 AT_CHECK([ovs-appctl netdev-dummy/receive p2 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
366
367 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 4])
368 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
369
370 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
371 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
372 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
373 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=2 (via action) data_len=42 (unbuffered)
374 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
375 ])
376
377 OVS_VSWITCHD_STOP
378 AT_CLEANUP
379
380 AT_SETUP([PMD - non pmd device])
381 OVS_VSWITCHD_START(
382 [add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=1 -- \
383 add-port br0 p2 -- set Interface p2 type=dummy ofport_request=2 -- \
384 set Interface br0 options:tx_pcap=br0.pcap -- \
385 set Open_vSwitch . other_config:pmd-cpu-mask=1
386 ], [], [], [--dummy-numa 0,0])
387 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
388
389 AT_CHECK([ovs-ofctl add-flow br0 actions=LOCAL])
390
391 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
392 p1 0 0 0
393 ])
394
395 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
396
397 AT_CHECK([ovs-appctl netdev-dummy/receive p2 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
398
399 OVS_WAIT_UNTIL([test `ovs-pcap br0.pcap | wc -l` -ge 2])
400
401 AT_CHECK([ovs-pcap br0.pcap], [0], [dnl
402 50540000000a50540000000908004500001c00000000400166df0a0000020a0000010800f7ff00000000
403 50540000000a50540000000908004500001c00000000400166df0a0000020a0000010800f7ff00000000
404 ])
405
406 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=2])
407
408 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
409 p1 0 0 1
410 ])
411
412 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
413
414 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
415
416 AT_CHECK([ovs-appctl netdev-dummy/receive p2 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
417
418 OVS_WAIT_UNTIL([test `ovs-pcap br0.pcap | wc -l` -ge 4])
419
420 AT_CHECK([ovs-pcap br0.pcap], [0], [dnl
421 50540000000a50540000000908004500001c00000000400166df0a0000020a0000010800f7ff00000000
422 50540000000a50540000000908004500001c00000000400166df0a0000020a0000010800f7ff00000000
423 50540000000a50540000000908004500001c00000000400166df0a0000020a0000010800f7ff00000000
424 50540000000a50540000000908004500001c00000000400166df0a0000020a0000010800f7ff00000000
425 ])
426
427 OVS_VSWITCHD_STOP
428 AT_CLEANUP
429
430 AT_SETUP([PMD - add remove ports])
431 OVS_VSWITCHD_START(
432 [], [], [], [--dummy-numa 0,0])
433 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
434
435 AT_CHECK([ovs-ofctl add-flow br0 actions=controller])
436
437 AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=1])
438
439 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
440 p1 0 0 0
441 ])
442
443 AT_CAPTURE_FILE([ofctl_monitor.log])
444 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
445
446 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
447
448 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 2])
449 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
450
451 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
452 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
453 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
454 ])
455
456 AT_CHECK([ovs-vsctl del-port br0 p1])
457 AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=1])
458
459 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
460
461 AT_CHECK([ovs-appctl netdev-dummy/receive p1 --qid 0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
462
463 OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 2])
464 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
465
466 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
467 NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
468 icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0 icmp_csum:f7ff
469 ])
470
471 OVS_VSWITCHD_STOP
472 AT_CLEANUP
473
474 AT_SETUP([PMD - rxq affinity])
475 OVS_VSWITCHD_START(
476 [], [], [], [--dummy-numa 0,0,0,0,0,0,0,0,0])
477 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
478
479 AT_CHECK([ovs-ofctl add-flow br0 actions=controller])
480
481 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0x1fe])
482
483 AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=4 other_config:pmd-rxq-affinity="0:3,1:7,2:2,3:8"])
484
485 dnl The rxqs should be on the requested cores.
486 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
487 p1 0 0 3
488 p1 1 0 7
489 p1 2 0 2
490 p1 3 0 8
491 ])
492
493 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6])
494
495 dnl We removed the cores requested by some queues from pmd-cpu-mask.
496 dnl Those queues will not be polled.
497 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
498 p1 2 0 2
499 ])
500
501 AT_CHECK([ovs-vsctl remove Interface p1 other_config pmd-rxq-affinity])
502
503 dnl We removed the rxq-affinity request. dpif-netdev should assign queues
504 dnl in a round robin fashion. We just make sure that every rxq is being
505 dnl polled again.
506 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show | cut -f 1,2 -d ' ' | sort], [0], [dnl
507 p1 0
508 p1 1
509 p1 2
510 p1 3
511 ])
512
513 AT_CHECK([ovs-vsctl set Interface p1 other_config:pmd-rxq-affinity='0:1'])
514
515 dnl We explicitly requested core 1 for queue 0. Core 1 becomes isolated and
516 dnl every other queue goes to core 2.
517 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
518 p1 0 0 1
519 p1 1 0 2
520 p1 2 0 2
521 p1 3 0 2
522 ])
523
524 OVS_VSWITCHD_STOP(["/dpif_netdev|WARN|There is no PMD thread on core/d"])
525 AT_CLEANUP
526
527 AT_SETUP([PMD - rxq affinity - NUMA])
528 OVS_VSWITCHD_START(
529 [], [], [], [--dummy-numa 0,0,0,1,1])
530 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
531
532 AT_CHECK([ovs-ofctl add-flow br0 actions=controller])
533
534 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=7e])
535
536 AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=2 options:numa_id=0 other_config:pmd-rxq-affinity="0:1,1:2"])
537
538 dnl The rxqs should be on the requested cores.
539 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
540 p1 0 0 1
541 p1 1 0 2
542 ])
543
544 AT_CHECK([ovs-vsctl set Interface p1 other_config:pmd-rxq-affinity="0:3,1:4"])
545
546 dnl We moved the queues to different numa node. Expecting threads on
547 dnl NUMA node 1 to be created.
548 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
549 p1 0 1 3
550 p1 1 1 4
551 ])
552
553 AT_CHECK([ovs-vsctl set Interface p1 other_config:pmd-rxq-affinity="0:3,1:1"])
554
555 dnl Queues splitted between NUMA nodes.
556 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
557 p1 0 1 3
558 p1 1 0 1
559 ])
560
561 AT_CHECK([ovs-vsctl remove Interface p1 other_config pmd-rxq-affinity])
562
563 dnl We removed the rxq-affinity request. dpif-netdev should assign queues
564 dnl in a round robin fashion. We just make sure that every rxq is being
565 dnl polled again.
566 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show | cut -f 1,2 -d ' ' | sort], [0], [dnl
567 p1 0
568 p1 1
569 ])
570
571 AT_CHECK([ovs-vsctl set Interface p1 other_config:pmd-rxq-affinity='0:3'])
572
573 dnl We explicitly requesting NUMA node 1 for queue 0.
574 dnl Queue 1 should be polled by thread from NUMA node 0.
575 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show | cut -f 1,2,3 -d ' '], [0], [dnl
576 p1 0 1
577 p1 1 0
578 ])
579
580 OVS_VSWITCHD_STOP
581 AT_CLEANUP
582
583 AT_SETUP([PMD - monitor threads])
584 OVS_VSWITCHD_START(
585 [], [], [], [--dummy-numa 0,0])
586 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
587
588 dnl The two devices are connected together externally using net.sock
589 AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1 options:n_rxq=1 options:pstream=punix:$OVS_RUNDIR/net.sock])
590 AT_CHECK([ovs-vsctl add-port br0 p2 -- set Interface p2 type=dummy-pmd ofport_request=2 options:n_rxq=1 options:stream=unix:$OVS_RUNDIR/net.sock])
591
592 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
593 p1 0 0 0
594 p2 0 0 0
595 ])
596
597 dnl Enable bfd with a very aggressive interval. This will make the monitor very
598 dnl busy, and uncover race conditions with the main thread.
599 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_rx=1 bfd:min_tx=1])
600 AT_CHECK([ovs-vsctl set Interface p2 bfd:enable=true bfd:min_rx=1 bfd:min_tx=1])
601
602 AT_CHECK([ovs-vsctl --timeout=10 wait-until Interface p1 bfd_status:forwarding=true \
603 -- wait-until Interface p2 bfd_status:forwarding=true])
604
605 dnl Trigger reconfiguration of the datapath
606 AT_CHECK([ovs-vsctl set Interface p1 options:n_rxq=2])
607 AT_CHECK([ovs-vsctl set Interface p2 options:n_rxq=2])
608
609 dnl Make sure that reconfiguration succeded
610 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | parse_pmd_rxq_show], [0], [dnl
611 p1 0 0 0
612 p1 1 0 0
613 p2 0 0 0
614 p2 1 0 0
615 ])
616
617 OVS_VSWITCHD_STOP
618 AT_CLEANUP
619
620 AT_SETUP([PMD - dpctl])
621 OVS_VSWITCHD_START(
622 [del-br br0], [], [], [--dummy-numa 0,0])
623 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
624
625 AT_CHECK([ovs-appctl dpctl/add-dp dummy@dp0])
626 AT_CHECK([ovs-appctl dpctl/add-if dummy@dp0 p1,type=dummy-pmd])
627 AT_CHECK([ovs-appctl dpctl/add-if dummy@dp0 p2,type=dummy])
628
629 AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show dp0 | parse_pmd_rxq_show], [0], [dnl
630 p1 0 0 0
631 ])
632
633 AT_CHECK([ovs-appctl dpctl/show dummy@dp0], [0], [dnl
634 dummy@dp0:
635 lookups: hit:0 missed:0 lost:0
636 flows: 0
637 port 0: dp0 (dummy-internal)
638 port 1: p1 (dummy-pmd: configured_rx_queues=1, configured_tx_queues=1, requested_rx_queues=1, requested_tx_queues=1)
639 port 2: p2 (dummy)
640 ])
641
642 AT_CHECK([ovs-appctl dpctl/add-flow dummy@dp0 'in_port(1),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x1234)' 2], [0], [dnl
643 ])
644
645 AT_CHECK([ovs-appctl dpctl/dump-flows dummy@dp0 | sort], [0], [dnl
646 flow-dump from non-dpdk interfaces:
647 flow-dump from pmd on cpu core: 0
648 recirc_id(0),in_port(1),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x1234), packets:0, bytes:0, used:never, actions:2
649 recirc_id(0),in_port(1),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x1234), packets:0, bytes:0, used:never, actions:2
650 ])
651
652 AT_CHECK([ovs-appctl dpctl/del-flow dummy@dp0 'in_port(1),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x1234)'], [0], [dnl
653 ])
654
655 AT_CHECK([ovs-appctl dpctl/dump-flows dummy@dp0], [0], [dnl
656 ])
657
658 AT_CHECK([ovs-appctl dpctl/del-dp dummy@dp0], [0], [dnl
659 ])
660
661 OVS_VSWITCHD_STOP
662 AT_CLEANUP