2 # SPDX-License-Identifier: GPL-2.0
5 NSIM_SV_ID
=$
((256 + RANDOM
% 256))
6 NSIM_SV_SYS
=/sys
/bus
/netdevsim
/devices
/netdevsim
$NSIM_SV_ID
7 NSIM_CL_ID
=$
((512 + RANDOM
% 256))
8 NSIM_CL_SYS
=/sys
/bus
/netdevsim
/devices
/netdevsim
$NSIM_CL_ID
10 NSIM_DEV_SYS_NEW
=/sys
/bus
/netdevsim
/new_device
11 NSIM_DEV_SYS_DEL
=/sys
/bus
/netdevsim
/del_device
12 NSIM_DEV_SYS_LINK
=/sys
/bus
/netdevsim
/link_device
13 NSIM_DEV_SYS_UNLINK
=/sys
/bus
/netdevsim
/unlink_device
26 NAPI_DEFER_HARD_IRQS
=100
27 GRO_FLUSH_TIMEOUT
=50000
28 SUSPEND_TIMEOUT
=20000000
36 NSIM_SV_NAME
=$
(find $NSIM_SV_SYS/net
-maxdepth 1 -type d
! \
37 -path $NSIM_SV_SYS/net
-exec basename {} \
;)
38 NSIM_CL_NAME
=$
(find $NSIM_CL_SYS/net
-maxdepth 1 -type d
! \
39 -path $NSIM_CL_SYS/net
-exec basename {} \
;)
41 # ensure the server has 1 queue
42 ethtool
-L $NSIM_SV_NAME combined
1 2>/dev
/null
44 ip link
set $NSIM_SV_NAME netns nssv
45 ip link
set $NSIM_CL_NAME netns nscl
47 ip netns
exec nssv ip addr add
"${SERVER_IP}/24" dev
$NSIM_SV_NAME
48 ip netns
exec nscl ip addr add
"${CLIENT_IP}/24" dev
$NSIM_CL_NAME
50 ip netns
exec nssv ip link
set dev
$NSIM_SV_NAME up
51 ip netns
exec nscl ip link
set dev
$NSIM_CL_NAME up
68 # fill a test file with random data
69 dd if=/dev
/urandom of
=${tmp_file} bs
=1M count
=1 2> /dev
/null
71 timeout
-k 1s
30s ip netns
exec nssv .
/busy_poller \
75 -u${BUSY_POLL_USECS} \
76 -P${PREFER_BUSY_POLL} \
77 -g${BUSY_POLL_BUDGET} \
82 wait_local_port_listen nssv
${SERVER_PORT} tcp
84 ip netns
exec nscl socat
-u $tmp_file TCP
:${SERVER_IP}:${SERVER_PORT}
88 tmp_file_md5sum
=$
(md5sum $tmp_file | cut
-f1 -d' ')
89 out_file_md5sum
=$
(md5sum $out_file | cut
-f1 -d' ')
91 if [ "$tmp_file_md5sum" = "$out_file_md5sum" ]; then
94 echo "md5sum mismatch"
95 echo "input file md5sum: ${tmp_file_md5sum}";
96 echo "output file md5sum: ${out_file_md5sum}";
100 rm $out_file $tmp_file
105 test_busypoll_with_suspend
()
107 test_busypoll
${SUSPEND_TIMEOUT}
120 echo $NSIM_SV_ID > $NSIM_DEV_SYS_NEW
121 echo $NSIM_CL_ID > $NSIM_DEV_SYS_NEW
126 NSIM_SV_FD
=$
((256 + RANDOM
% 256))
127 exec {NSIM_SV_FD
}</var
/run
/netns
/nssv
128 NSIM_SV_IFIDX
=$
(ip netns
exec nssv
cat /sys
/class
/net
/$NSIM_SV_NAME/ifindex
)
130 NSIM_CL_FD
=$
((256 + RANDOM
% 256))
131 exec {NSIM_CL_FD
}</var
/run
/netns
/nscl
132 NSIM_CL_IFIDX
=$
(ip netns
exec nscl
cat /sys
/class
/net
/$NSIM_CL_NAME/ifindex
)
134 echo "$NSIM_SV_FD:$NSIM_SV_IFIDX $NSIM_CL_FD:$NSIM_CL_IFIDX" > \
137 if [ $?
-ne 0 ]; then
138 echo "linking netdevsim1 with netdevsim2 should succeed"
144 if [ $?
-ne 0 ]; then
145 echo "test_busypoll failed"
150 test_busypoll_with_suspend
151 if [ $?
-ne 0 ]; then
152 echo "test_busypoll_with_suspend failed"
157 echo "$NSIM_SV_FD:$NSIM_SV_IFIDX" > $NSIM_DEV_SYS_UNLINK
159 echo $NSIM_CL_ID > $NSIM_DEV_SYS_DEL
163 modprobe
-r netdevsim