xref: /linux/tools/testing/selftests/drivers/net/netdevsim/devlink.sh (revision ea68a3e9d14e9e0bf017d178fb4bd53b6deb1482)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4lib_dir=$(dirname $0)/../../../net/forwarding
5
6ALL_TESTS="fw_flash_test params_test regions_test reload_test \
7	   netns_reload_test resource_test dev_info_test \
8	   empty_reporter_test dummy_reporter_test rate_test"
9NUM_NETIFS=0
10source $lib_dir/lib.sh
11
12BUS_ADDR=10
13PORT_COUNT=4
14VF_COUNT=4
15DEV_NAME=netdevsim$BUS_ADDR
16SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV_NAME/net/
17DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV_NAME/
18DL_HANDLE=netdevsim/$DEV_NAME
19
20wait_for_devlink()
21{
22	"$@" | grep -q $DL_HANDLE
23}
24
25devlink_wait()
26{
27	local timeout=$1
28
29	busywait "$timeout" wait_for_devlink devlink dev
30}
31
32fw_flash_test()
33{
34	RET=0
35
36	devlink dev flash $DL_HANDLE file dummy
37	check_err $? "Failed to flash with status updates on"
38
39	devlink dev flash $DL_HANDLE file dummy component fw.mgmt
40	check_err $? "Failed to flash with component attribute"
41
42	devlink dev flash $DL_HANDLE file dummy overwrite settings
43	check_fail $? "Flash with overwrite settings should be rejected"
44
45	echo "1"> $DEBUGFS_DIR/fw_update_overwrite_mask
46	check_err $? "Failed to change allowed overwrite mask"
47
48	devlink dev flash $DL_HANDLE file dummy overwrite settings
49	check_err $? "Failed to flash with settings overwrite enabled"
50
51	devlink dev flash $DL_HANDLE file dummy overwrite identifiers
52	check_fail $? "Flash with overwrite settings should be identifiers"
53
54	echo "3"> $DEBUGFS_DIR/fw_update_overwrite_mask
55	check_err $? "Failed to change allowed overwrite mask"
56
57	devlink dev flash $DL_HANDLE file dummy overwrite identifiers overwrite settings
58	check_err $? "Failed to flash with settings and identifiers overwrite enabled"
59
60	echo "n"> $DEBUGFS_DIR/fw_update_status
61	check_err $? "Failed to disable status updates"
62
63	devlink dev flash $DL_HANDLE file dummy
64	check_err $? "Failed to flash with status updates off"
65
66	log_test "fw flash test"
67}
68
69param_get()
70{
71	local name=$1
72
73	cmd_jq "devlink dev param show $DL_HANDLE name $name -j" \
74	       '.[][][].values[] | select(.cmode == "driverinit").value'
75}
76
77param_set()
78{
79	local name=$1
80	local value=$2
81
82	devlink dev param set $DL_HANDLE name $name cmode driverinit value $value
83}
84
85check_value()
86{
87	local name=$1
88	local phase_name=$2
89	local expected_param_value=$3
90	local expected_debugfs_value=$4
91	local value
92
93	value=$(param_get $name)
94	check_err $? "Failed to get $name param value"
95	[ "$value" == "$expected_param_value" ]
96	check_err $? "Unexpected $phase_name $name param value"
97	value=$(<$DEBUGFS_DIR/$name)
98	check_err $? "Failed to get $name debugfs value"
99	[ "$value" == "$expected_debugfs_value" ]
100	check_err $? "Unexpected $phase_name $name debugfs value"
101}
102
103params_test()
104{
105	RET=0
106
107	local max_macs
108	local test1
109
110	check_value max_macs initial 32 32
111	check_value test1 initial true Y
112
113	param_set max_macs 16
114	check_err $? "Failed to set max_macs param value"
115	param_set test1 false
116	check_err $? "Failed to set test1 param value"
117
118	check_value max_macs post-set 16 32
119	check_value test1 post-set false Y
120
121	devlink dev reload $DL_HANDLE
122
123	check_value max_macs post-reload 16 16
124	check_value test1 post-reload false N
125
126	log_test "params test"
127}
128
129check_region_size()
130{
131	local name=$1
132	local size
133
134	size=$(devlink region show $DL_HANDLE/$name -j | jq -e -r '.[][].size')
135	check_err $? "Failed to get $name region size"
136	[ $size -eq 32768 ]
137	check_err $? "Invalid $name region size"
138}
139
140check_region_snapshot_count()
141{
142	local name=$1
143	local phase_name=$2
144	local expected_count=$3
145	local count
146
147	count=$(devlink region show $DL_HANDLE/$name -j | jq -e -r '.[][].snapshot | length')
148	[ $count -eq $expected_count ]
149	check_err $? "Unexpected $phase_name snapshot count"
150}
151
152regions_test()
153{
154	RET=0
155
156	local count
157
158	check_region_size dummy
159	check_region_snapshot_count dummy initial 0
160
161	echo ""> $DEBUGFS_DIR/take_snapshot
162	check_err $? "Failed to take first dummy region snapshot"
163	check_region_snapshot_count dummy post-first-snapshot 1
164
165	echo ""> $DEBUGFS_DIR/take_snapshot
166	check_err $? "Failed to take second dummy region snapshot"
167	check_region_snapshot_count dummy post-second-snapshot 2
168
169	echo ""> $DEBUGFS_DIR/take_snapshot
170	check_err $? "Failed to take third dummy region snapshot"
171	check_region_snapshot_count dummy post-third-snapshot 3
172
173	devlink region del $DL_HANDLE/dummy snapshot 1
174	check_err $? "Failed to delete first dummy region snapshot"
175
176	check_region_snapshot_count dummy post-first-delete 2
177
178	devlink region new $DL_HANDLE/dummy snapshot 25
179	check_err $? "Failed to create a new snapshot with id 25"
180
181	check_region_snapshot_count dummy post-first-request 3
182
183	devlink region dump $DL_HANDLE/dummy snapshot 25 >> /dev/null
184	check_err $? "Failed to dump snapshot with id 25"
185
186	devlink region read $DL_HANDLE/dummy snapshot 25 addr 0 len 1 >> /dev/null
187	check_err $? "Failed to read snapshot with id 25 (1 byte)"
188
189	devlink region read $DL_HANDLE/dummy snapshot 25 addr 128 len 128 >> /dev/null
190	check_err $? "Failed to read snapshot with id 25 (128 bytes)"
191
192	devlink region read $DL_HANDLE/dummy snapshot 25 addr 128 len $((1<<32)) >> /dev/null
193	check_err $? "Failed to read snapshot with id 25 (oversized)"
194
195	devlink region read $DL_HANDLE/dummy snapshot 25 addr $((1<<32)) len 128 >> /dev/null 2>&1
196	check_fail $? "Bad read of snapshot with id 25 did not fail"
197
198	devlink region del $DL_HANDLE/dummy snapshot 25
199	check_err $? "Failed to delete snapshot with id 25"
200
201	check_region_snapshot_count dummy post-second-delete 2
202
203	sid=$(devlink -j region new $DL_HANDLE/dummy | jq '.[][][][]')
204	check_err $? "Failed to create a new snapshot with id allocated by the kernel"
205
206	check_region_snapshot_count dummy post-first-request 3
207
208	devlink region dump $DL_HANDLE/dummy snapshot $sid >> /dev/null
209	check_err $? "Failed to dump a snapshot with id allocated by the kernel"
210
211	devlink region del $DL_HANDLE/dummy snapshot $sid
212	check_err $? "Failed to delete snapshot with id allocated by the kernel"
213
214	check_region_snapshot_count dummy post-first-request 2
215
216	log_test "regions test"
217}
218
219reload_test()
220{
221	RET=0
222
223	devlink dev reload $DL_HANDLE
224	check_err $? "Failed to reload"
225
226	echo "y"> $DEBUGFS_DIR/fail_reload
227	check_err $? "Failed to setup devlink reload to fail"
228
229	devlink dev reload $DL_HANDLE
230	check_fail $? "Unexpected success of devlink reload"
231
232	echo "n"> $DEBUGFS_DIR/fail_reload
233	check_err $? "Failed to setup devlink reload not to fail"
234
235	devlink dev reload $DL_HANDLE
236	check_err $? "Failed to reload after set not to fail"
237
238	echo "y"> $DEBUGFS_DIR/dont_allow_reload
239	check_err $? "Failed to forbid devlink reload"
240
241	devlink dev reload $DL_HANDLE
242	check_fail $? "Unexpected success of devlink reload"
243
244	echo "n"> $DEBUGFS_DIR/dont_allow_reload
245	check_err $? "Failed to re-enable devlink reload"
246
247	devlink dev reload $DL_HANDLE
248	check_err $? "Failed to reload after re-enable"
249
250	log_test "reload test"
251}
252
253netns_reload_test()
254{
255	RET=0
256
257	ip netns add testns1
258	check_err $? "Failed add netns \"testns1\""
259	ip netns add testns2
260	check_err $? "Failed add netns \"testns2\""
261
262	devlink dev reload $DL_HANDLE netns testns1
263	check_err $? "Failed to reload into netns \"testns1\""
264
265	devlink -N testns1 dev reload $DL_HANDLE netns testns2
266	check_err $? "Failed to reload from netns \"testns1\" into netns \"testns2\""
267
268	ip netns del testns2
269	ip netns del testns1
270
271	# Wait until netns async cleanup is done.
272	devlink_wait 2000
273
274	log_test "netns reload test"
275}
276
277DUMMYDEV="dummytest"
278
279res_val_get()
280{
281	local netns=$1
282	local parentname=$2
283	local name=$3
284	local type=$4
285
286	cmd_jq "devlink -N $netns resource show $DL_HANDLE -j" \
287	       ".[][][] | select(.name == \"$parentname\").resources[] \
288	        | select(.name == \"$name\").$type"
289}
290
291resource_test()
292{
293	RET=0
294
295	ip netns add testns1
296	check_err $? "Failed add netns \"testns1\""
297	ip netns add testns2
298	check_err $? "Failed add netns \"testns2\""
299
300	devlink dev reload $DL_HANDLE netns testns1
301	check_err $? "Failed to reload into netns \"testns1\""
302
303	# Create dummy dev to add the address and routes on.
304
305	ip -n testns1 link add name $DUMMYDEV type dummy
306	check_err $? "Failed create dummy device"
307	ip -n testns1 link set $DUMMYDEV up
308	check_err $? "Failed bring up dummy device"
309	ip -n testns1 a a 192.0.1.1/24 dev $DUMMYDEV
310	check_err $? "Failed add an IP address to dummy device"
311
312	local occ=$(res_val_get testns1 IPv4 fib occ)
313	local limit=$((occ+1))
314
315	# Set fib size limit to handle one another route only.
316
317	devlink -N testns1 resource set $DL_HANDLE path IPv4/fib size $limit
318	check_err $? "Failed to set IPv4/fib resource size"
319	local size_new=$(res_val_get testns1 IPv4 fib size_new)
320	[ "$size_new" -eq "$limit" ]
321	check_err $? "Unexpected \"size_new\" value (got $size_new, expected $limit)"
322
323	devlink -N testns1 dev reload $DL_HANDLE
324	check_err $? "Failed to reload"
325	local size=$(res_val_get testns1 IPv4 fib size)
326	[ "$size" -eq "$limit" ]
327	check_err $? "Unexpected \"size\" value (got $size, expected $limit)"
328
329	# Insert 2 routes, the first is going to be inserted,
330	# the second is expected to fail to be inserted.
331
332	ip -n testns1 r a 192.0.2.0/24 via 192.0.1.2
333	check_err $? "Failed to add route"
334
335	ip -n testns1 r a 192.0.3.0/24 via 192.0.1.2
336	check_fail $? "Unexpected successful route add over limit"
337
338	# Now create another dummy in second network namespace and
339	# insert two routes. That is over the limit of the netdevsim
340	# instance in the first namespace. Move the netdevsim instance
341	# into the second namespace and expect it to fail.
342
343	ip -n testns2 link add name $DUMMYDEV type dummy
344	check_err $? "Failed create dummy device"
345	ip -n testns2 link set $DUMMYDEV up
346	check_err $? "Failed bring up dummy device"
347	ip -n testns2 a a 192.0.1.1/24 dev $DUMMYDEV
348	check_err $? "Failed add an IP address to dummy device"
349	ip -n testns2 r a 192.0.2.0/24 via 192.0.1.2
350	check_err $? "Failed to add route"
351	ip -n testns2 r a 192.0.3.0/24 via 192.0.1.2
352	check_err $? "Failed to add route"
353
354	devlink -N testns1 dev reload $DL_HANDLE netns testns2
355	check_fail $? "Unexpected successful reload from netns \"testns1\" into netns \"testns2\""
356
357	devlink -N testns2 resource set $DL_HANDLE path IPv4/fib size ' -1'
358	check_err $? "Failed to reset IPv4/fib resource size"
359
360	devlink -N testns2 dev reload $DL_HANDLE netns 1
361	check_err $? "Failed to reload devlink back"
362
363	ip netns del testns2
364	ip netns del testns1
365
366	# Wait until netns async cleanup is done.
367	devlink_wait 2000
368
369	log_test "resource test"
370}
371
372info_get()
373{
374	local name=$1
375
376	cmd_jq "devlink dev info $DL_HANDLE -j" ".[][][\"$name\"]" "-e"
377}
378
379dev_info_test()
380{
381	RET=0
382
383	driver=$(info_get "driver")
384	check_err $? "Failed to get driver name"
385	[ "$driver" == "netdevsim" ]
386	check_err $? "Unexpected driver name $driver"
387
388	log_test "dev_info test"
389}
390
391empty_reporter_test()
392{
393	RET=0
394
395	devlink health show $DL_HANDLE reporter empty >/dev/null
396	check_err $? "Failed show empty reporter"
397
398	devlink health dump show $DL_HANDLE reporter empty >/dev/null
399	check_err $? "Failed show dump of empty reporter"
400
401	devlink health diagnose $DL_HANDLE reporter empty >/dev/null
402	check_err $? "Failed diagnose empty reporter"
403
404	devlink health recover $DL_HANDLE reporter empty
405	check_err $? "Failed recover empty reporter"
406
407	log_test "empty reporter test"
408}
409
410check_reporter_info()
411{
412	local name=$1
413	local expected_state=$2
414	local expected_error=$3
415	local expected_recover=$4
416	local expected_grace_period=$5
417	local expected_auto_recover=$6
418
419	local show=$(devlink health show $DL_HANDLE reporter $name -j | jq -e -r ".[][][]")
420	check_err $? "Failed show $name reporter"
421
422	local state=$(echo $show | jq -r ".state")
423	[ "$state" == "$expected_state" ]
424	check_err $? "Unexpected \"state\" value (got $state, expected $expected_state)"
425
426	local error=$(echo $show | jq -r ".error")
427	[ "$error" == "$expected_error" ]
428	check_err $? "Unexpected \"error\" value (got $error, expected $expected_error)"
429
430	local recover=`echo $show | jq -r ".recover"`
431	[ "$recover" == "$expected_recover" ]
432	check_err $? "Unexpected \"recover\" value (got $recover, expected $expected_recover)"
433
434	local grace_period=$(echo $show | jq -r ".grace_period")
435	check_err $? "Failed get $name reporter grace_period"
436	[ "$grace_period" == "$expected_grace_period" ]
437	check_err $? "Unexpected \"grace_period\" value (got $grace_period, expected $expected_grace_period)"
438
439	local auto_recover=$(echo $show | jq -r ".auto_recover")
440	[ "$auto_recover" == "$expected_auto_recover" ]
441	check_err $? "Unexpected \"auto_recover\" value (got $auto_recover, expected $expected_auto_recover)"
442}
443
444dummy_reporter_test()
445{
446	RET=0
447
448	check_reporter_info dummy healthy 0 0 0 true
449
450	devlink health set $DL_HANDLE reporter dummy auto_recover false
451	check_err $? "Failed to dummy reporter auto_recover option"
452
453	check_reporter_info dummy healthy 0 0 0 false
454
455	local BREAK_MSG="foo bar"
456	echo "$BREAK_MSG"> $DEBUGFS_DIR/health/break_health
457	check_err $? "Failed to break dummy reporter"
458
459	check_reporter_info dummy error 1 0 0 false
460
461	local dump=$(devlink health dump show $DL_HANDLE reporter dummy -j)
462	check_err $? "Failed show dump of dummy reporter"
463
464	local dump_break_msg=$(echo $dump | jq -r ".break_message")
465	[ "$dump_break_msg" == "$BREAK_MSG" ]
466	check_err $? "Unexpected dump break message value (got $dump_break_msg, expected $BREAK_MSG)"
467
468	devlink health dump clear $DL_HANDLE reporter dummy
469	check_err $? "Failed clear dump of dummy reporter"
470
471	devlink health recover $DL_HANDLE reporter dummy
472	check_err $? "Failed recover dummy reporter"
473
474	check_reporter_info dummy healthy 1 1 0 false
475
476	devlink health set $DL_HANDLE reporter dummy auto_recover true
477	check_err $? "Failed to dummy reporter auto_recover option"
478
479	check_reporter_info dummy healthy 1 1 0 true
480
481	echo "$BREAK_MSG"> $DEBUGFS_DIR/health/break_health
482	check_err $? "Failed to break dummy reporter"
483
484	check_reporter_info dummy healthy 2 2 0 true
485
486	local diagnose=$(devlink health diagnose $DL_HANDLE reporter dummy -j -p)
487	check_err $? "Failed show diagnose of dummy reporter"
488
489	local rcvrd_break_msg=$(echo $diagnose | jq -r ".recovered_break_message")
490	[ "$rcvrd_break_msg" == "$BREAK_MSG" ]
491	check_err $? "Unexpected recovered break message value (got $rcvrd_break_msg, expected $BREAK_MSG)"
492
493	devlink health set $DL_HANDLE reporter dummy grace_period 10
494	check_err $? "Failed to dummy reporter grace_period option"
495
496	check_reporter_info dummy healthy 2 2 10 true
497
498	echo "Y"> $DEBUGFS_DIR/health/fail_recover
499	check_err $? "Failed set dummy reporter recovery to fail"
500
501	echo "$BREAK_MSG"> $DEBUGFS_DIR/health/break_health
502	check_fail $? "Unexpected success of dummy reporter break"
503
504	check_reporter_info dummy error 3 2 10 true
505
506	devlink health recover $DL_HANDLE reporter dummy
507	check_fail $? "Unexpected success of dummy reporter recover"
508
509	echo "N"> $DEBUGFS_DIR/health/fail_recover
510	check_err $? "Failed set dummy reporter recovery to be successful"
511
512	devlink health recover $DL_HANDLE reporter dummy
513	check_err $? "Failed recover dummy reporter"
514
515	check_reporter_info dummy healthy 3 3 10 true
516
517	echo 8192 > $DEBUGFS_DIR/health/binary_len
518	check_err $? "Failed set dummy reporter binary len to 8192"
519
520	local dump=$(devlink health dump show $DL_HANDLE reporter dummy -j)
521	check_err $? "Failed show dump of dummy reporter"
522
523	devlink health dump clear $DL_HANDLE reporter dummy
524	check_err $? "Failed clear dump of dummy reporter"
525
526	log_test "dummy reporter test"
527}
528
529rate_leafs_get()
530{
531	local handle=$1
532
533	cmd_jq "devlink port function rate show -j" \
534	       '.[] | to_entries | .[] | select(.value.type == "leaf") | .key | select(contains("'$handle'"))'
535}
536
537rate_nodes_get()
538{
539	local handle=$1
540
541	cmd_jq "devlink port function rate show -j" \
542		'.[] | to_entries | .[] | select(.value.type == "node") | .key | select(contains("'$handle'"))'
543}
544
545rate_attr_set()
546{
547	local handle=$1
548	local name=$2
549	local value=$3
550	local units=$4
551
552	devlink port function rate set $handle $name $value$units
553}
554
555rate_attr_get()
556{
557	local handle=$1
558	local name=$2
559
560	cmd_jq "devlink port function rate show $handle -j" '.[][].'$name
561}
562
563rate_attr_tx_rate_check()
564{
565	local handle=$1
566	local name=$2
567	local rate=$3
568	local debug_file=$4
569
570	rate_attr_set $handle $name $rate mbit
571	check_err $? "Failed to set $name value"
572
573	local debug_value=$(cat $debug_file)
574	check_err $? "Failed to read $name value from debugfs"
575	[ "$debug_value" == "$rate" ]
576	check_err $? "Unexpected $name debug value $debug_value != $rate"
577
578	local api_value=$(( $(rate_attr_get $handle $name) * 8 / 1000000 ))
579	check_err $? "Failed to get $name attr value"
580	[ "$api_value" == "$rate" ]
581	check_err $? "Unexpected $name attr value $api_value != $rate"
582}
583
584rate_attr_parent_check()
585{
586	local handle=$1
587	local parent=$2
588	local debug_file=$3
589
590	rate_attr_set $handle parent $parent
591	check_err $? "Failed to set parent"
592
593	debug_value=$(cat $debug_file)
594	check_err $? "Failed to get parent debugfs value"
595	[ "$debug_value" == "$parent" ]
596	check_err $? "Unexpected parent debug value $debug_value != $parent"
597
598	api_value=$(rate_attr_get $r_obj parent)
599	check_err $? "Failed to get parent attr value"
600	[ "$api_value" == "$parent" ]
601	check_err $? "Unexpected parent attr value $api_value != $parent"
602}
603
604rate_node_add()
605{
606	local handle=$1
607
608	devlink port function rate add $handle
609}
610
611rate_node_del()
612{
613	local handle=$1
614
615	devlink port function rate del $handle
616}
617
618rate_test()
619{
620	RET=0
621
622	echo $VF_COUNT > /sys/bus/netdevsim/devices/$DEV_NAME/sriov_numvfs
623	devlink dev eswitch set $DL_HANDLE mode switchdev
624	local leafs=`rate_leafs_get $DL_HANDLE`
625	local num_leafs=`echo $leafs | wc -w`
626	[ "$num_leafs" == "$VF_COUNT" ]
627	check_err $? "Expected $VF_COUNT rate leafs but got $num_leafs"
628
629	rate=10
630	for r_obj in $leafs
631	do
632		rate_attr_tx_rate_check $r_obj tx_share $rate \
633			$DEBUGFS_DIR/ports/${r_obj##*/}/tx_share
634		rate=$(($rate+10))
635	done
636
637	rate=100
638	for r_obj in $leafs
639	do
640		rate_attr_tx_rate_check $r_obj tx_max $rate \
641			$DEBUGFS_DIR/ports/${r_obj##*/}/tx_max
642		rate=$(($rate+100))
643	done
644
645	local node1_name='group1'
646	local node1="$DL_HANDLE/$node1_name"
647	rate_node_add "$node1"
648	check_err $? "Failed to add node $node1"
649
650	local num_nodes=`rate_nodes_get $DL_HANDLE | wc -w`
651	[ $num_nodes == 1 ]
652	check_err $? "Expected 1 rate node in output but got $num_nodes"
653
654	local node_tx_share=10
655	rate_attr_tx_rate_check $node1 tx_share $node_tx_share \
656		$DEBUGFS_DIR/rate_nodes/${node1##*/}/tx_share
657
658	local node_tx_max=100
659	rate_attr_tx_rate_check $node1 tx_max $node_tx_max \
660		$DEBUGFS_DIR/rate_nodes/${node1##*/}/tx_max
661
662	rate_node_del "$node1"
663	check_err $? "Failed to delete node $node1"
664	local num_nodes=`rate_nodes_get $DL_HANDLE | wc -w`
665	[ $num_nodes == 0 ]
666	check_err $? "Expected 0 rate node but got $num_nodes"
667
668	local node1_name='group1'
669	local node1="$DL_HANDLE/$node1_name"
670	rate_node_add "$node1"
671	check_err $? "Failed to add node $node1"
672
673	rate_attr_parent_check $r_obj $node1_name \
674		$DEBUGFS_DIR/ports/${r_obj##*/}/rate_parent
675
676	local node2_name='group2'
677	local node2="$DL_HANDLE/$node2_name"
678	rate_node_add "$node2"
679	check_err $? "Failed to add node $node2"
680
681	rate_attr_parent_check $node2 $node1_name \
682		$DEBUGFS_DIR/rate_nodes/$node2_name/rate_parent
683	rate_node_del "$node2"
684	check_err $? "Failed to delete node $node2"
685	rate_attr_set "$r_obj" noparent
686	check_err $? "Failed to unset $r_obj parent node"
687	rate_node_del "$node1"
688	check_err $? "Failed to delete node $node1"
689
690	log_test "rate test"
691}
692
693setup_prepare()
694{
695	modprobe netdevsim
696	echo "$BUS_ADDR $PORT_COUNT" > /sys/bus/netdevsim/new_device
697	while [ ! -d $SYSFS_NET_DIR ] ; do :; done
698}
699
700cleanup()
701{
702	pre_cleanup
703	echo "$BUS_ADDR" > /sys/bus/netdevsim/del_device
704	modprobe -r netdevsim
705}
706
707trap cleanup EXIT
708
709setup_prepare
710
711tests_run
712
713exit $EXIT_STATUS
714