Skip to content

Commit e023484

Browse files
SruChallajerinjacobk
authored andcommitted
ci: add test case for guest use case
Adds a test case for guest dpdk testpmd use case for virtio. Signed-off-by: Srujana Challa <schalla@marvell.com> Change-Id: I724eb3871a53b71a987980d55aaed45fd946a915 Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpu-offload/+/129466 Tested-by: sa_ip-toolkits-Jenkins <sa_ip-toolkits-jenkins@marvell.com> Reviewed-by: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com> Reviewed-by: Rahul Bhansali <rbhansali@marvell.com>
1 parent 9b72ff7 commit e023484

File tree

5 files changed

+320
-0
lines changed

5 files changed

+320
-0
lines changed

ci/test/common/test_list_helper_funcs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ function get_test_command()
209209
cmd="cd $test_dir &&
210210
$EP_DEVICE_SUDO DEPS_PREFIX=$EP_DEVICE_DIR/deps-prefix \
211211
EP_HOST_DIR=$EP_HOST_DIR \
212+
EP_DEVICE_DIR=$EP_DEVICE_DIR \
212213
EP_SSH_CMD='$EP_SSH_CMD' \
213214
EXTRA_EP_HOST_ENV='$EXTRA_EP_HOST_ENV' $envs $EXTRA_EP_DEVICE_ENV \
214215
$exec_bin $args $extra_args"
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Marvell-MIT
3+
# Copyright (c) 2024 Marvell.
4+
5+
6+
EP_GUEST_DIR="/root/hostshare"
7+
source "$EP_GUEST_DIR/testpmd.sh"
8+
9+
function ep_guest_setup()
10+
{
11+
echo "Setting up hugepages on guest"
12+
# Check for hugepages
13+
if mount | grep hugetlbfs | grep none; then
14+
echo "Hugepages already setup"
15+
else
16+
mkdir /dev/huge
17+
mount -t hugetlbfs none /dev/huge
18+
fi
19+
echo 512 > /proc/sys/vm/nr_hugepages
20+
cd /home
21+
modprobe vfio-pci
22+
echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
23+
./usertools/dpdk-devbind.py -b vfio-pci 0000:00:03.0
24+
}
25+
26+
function ep_guest_testpmd_launch()
27+
{
28+
local pfx=$1
29+
local args=${@:2}
30+
local eal_args
31+
local app_args=""
32+
33+
for a in $args; do
34+
if [[ $a == "--" ]]; then
35+
eal_args=$app_args
36+
app_args=""
37+
continue
38+
fi
39+
app_args+=" $a"
40+
done
41+
42+
echo "Launching testpmd on Guest"
43+
testpmd_launch $pfx "$eal_args" "$app_args"
44+
echo "Launched testpmd on Guest"
45+
}
46+
47+
function ep_guest_testpmd_start()
48+
{
49+
local pfx=$1
50+
51+
echo "Starting Traffic on Guest"
52+
testpmd_cmd $pfx start tx_first 32
53+
echo "Started Traffic on Guest"
54+
}
55+
56+
function ep_guest_testpmd_stop()
57+
{
58+
local pfx=$1
59+
60+
echo "Stopping testpmd on Guest"
61+
testpmd_quit $pfx
62+
testpmd_cleanup $pfx
63+
echo "Stopped testpmd on Guest"
64+
}
65+
66+
function ep_guest_testpmd_pps()
67+
{
68+
local pfx=$1
69+
local wait_time_sec=10
70+
71+
while [[ wait_time_sec -ne 0 ]]; do
72+
local rx_pps=$(testpmd_pps $pfx 0)
73+
74+
if [[ rx_pps -eq 0 ]]; then
75+
echo "Low PPS for ${pfx} ($rx_pps == 0)"
76+
else
77+
echo $rx_pps > /root/hostshare/testpmd.pps.$pfx
78+
return 0
79+
fi
80+
81+
sleep 1
82+
wait_time_sec=$((wait_time_sec - 1))
83+
done
84+
}
85+
86+
# If this script is directly invoked from the shell execute the
87+
# op specified
88+
if [[ ${BASH_SOURCE[0]} == ${0} ]]; then
89+
OP=$1
90+
ARGS=${@:2}
91+
if [[ $(type -t ep_guest_$OP) == function ]]; then
92+
ep_guest_$OP $ARGS
93+
else
94+
$OP $ARGS
95+
fi
96+
fi

ci/test/dao-test/common/ep_host_utils.sh

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,176 @@ function ep_host_testpmd_stop()
107107
echo "Stopped testpmd on Host"
108108
}
109109

110+
EP_SCP_CMD=${EP_SCP_CMD:-"scp -o LogLevel=ERROR -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"}
111+
EP_GUEST_DIR="/root/hostshare"
112+
EP_GUEST_SHARE_DIR=$EP_HOST_DIR/guest
113+
114+
function ep_host_launch_guest()
115+
{
116+
local unbuffer="stdbuf -o0"
117+
local pfx=$1
118+
local in=guest.in.$pfx
119+
local out=guest.out.$pfx
120+
121+
$EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/qemu-system-x86_64 $EP_HOST_DIR/
122+
$EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/noble-server-cloudimg-amd64.img $EP_HOST_DIR/
123+
$EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/bios-256k.bin /usr/share/qemu
124+
$EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/vgabios-stdvga.bin /usr/share/qemu
125+
$EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/efi-virtio.rom /usr/share/qemu
126+
127+
# Folder to be shared with the guest
128+
rm -rf $EP_GUEST_SHARE_DIR
129+
mkdir $EP_GUEST_SHARE_DIR
130+
131+
cp $EP_HOST_DIR/ci/test/dao-test/common/utils.sh $EP_GUEST_SHARE_DIR
132+
cp $EP_HOST_DIR/ci/test/dao-test/common/testpmd.sh $EP_GUEST_SHARE_DIR
133+
cp $EP_HOST_DIR/ci/test/dao-test/common/ep_guest_utils.sh $EP_GUEST_SHARE_DIR
134+
135+
if [[ -f $EP_HOST_DIR/qemu-system-x86_64 ]]; then
136+
QEMU_BIN=$EP_HOST_DIR/qemu-system-x86_64
137+
else
138+
echo "qemu-system-x86_64 not found !!"
139+
return 1
140+
fi
141+
142+
if [[ -f $EP_HOST_DIR/noble-server-cloudimg-amd64.img ]]; then
143+
VM_IMAGE=$EP_HOST_DIR/noble-server-cloudimg-amd64.img
144+
else
145+
echo "x86 QEMU cloud image not found !!"
146+
return 1
147+
fi
148+
149+
ulimit -l unlimited
150+
rm -f $out
151+
rm -f $in
152+
touch $in
153+
tail -f $in | ($unbuffer $QEMU_BIN -hda "$VM_IMAGE" -name vm1 \
154+
-netdev type=vhost-vdpa,vhostdev="/dev/vhost-vdpa-0",id=vhost-vdpa1 \
155+
-device virtio-net-pci,netdev=vhost-vdpa1,disable-modern=off,page-per-vq=on,packed=on,mrg_rxbuf=on,mq=on,rss=on,rx_queue_size=1024,tx_queue_size=1024,disable-legacy=on -fsdev local,path=$EP_GUEST_SHARE_DIR,security_model=passthrough,id=hostshare -device virtio-9p-pci,id=fs0,fsdev=hostshare,mount_tag=host_tag \
156+
-enable-kvm -nographic -m 4G -cpu host -smp 8 -L /usr/share/qemu &>$out) &
157+
158+
# Wait for guest to be up
159+
local itr=0
160+
while ! (tail -n15 $out | grep -q "ubuntu login:"); do
161+
sleep 10
162+
itr=$((itr + 1))
163+
if [[ itr -eq 20 ]]; then
164+
echo "Timeout waiting for Guest";
165+
cat $out
166+
return 1;
167+
fi
168+
echo "Waiting for guest to be up"
169+
done
170+
echo "Guest is launched"
171+
echo "root" >>$in
172+
sleep 1;
173+
echo "a" >>$in
174+
sleep 1;
175+
echo "rm -rf $EP_GUEST_DIR; mkdir $EP_GUEST_DIR" >>$in
176+
echo "cp /home/dpdk-testpmd /bin" >> $in
177+
echo "mount -t 9p -o trans=virtio host_tag $EP_GUEST_DIR" >>$in
178+
echo "$EP_GUEST_DIR/ep_guest_utils.sh setup" >> $in
179+
echo "cd $EP_GUEST_DIR" >> $in
180+
}
181+
182+
function guest_testpmd_prompt()
183+
{
184+
local pfx=$1
185+
local refresh=${2:-}
186+
local skip_bytes=${3:-}
187+
local in=$EP_GUEST_SHARE_DIR/testpmd.in.$pfx
188+
local out=$EP_GUEST_SHARE_DIR/testpmd.out.$pfx
189+
190+
local cmd="tail -n1 $out"
191+
192+
if [[ "$skip_bytes" != "" ]]
193+
then
194+
cmd="tail -c +$skip_bytes $out"
195+
fi
196+
197+
while ! ($cmd | grep -q "^testpmd> $"); do
198+
if [ "$refresh" == "yes" ]
199+
then
200+
sleep 1
201+
echo "" >>$in
202+
fi
203+
continue;
204+
done
205+
}
206+
207+
function ep_host_start_guest_traffic()
208+
{
209+
local unbuffer="stdbuf -o0"
210+
local pfx=$1
211+
local in=guest.in.$pfx
212+
local out=guest.out.$pfx
213+
local testpmd_out="$EP_GUEST_SHARE_DIR/testpmd.out.$pfx"
214+
local args=${@:2}
215+
216+
echo "Starting Traffic on Guest"
217+
echo "./ep_guest_utils.sh testpmd_launch $pfx $args" >> $in
218+
# Wait till out file is created
219+
local itr=0
220+
while [[ ! -f $testpmd_out ]]; do
221+
itr=$((itr + 1))
222+
sleep 1
223+
if [[ itr -eq 20 ]]; then
224+
echo "Timeout waiting for Guest testpmd";
225+
cat $out
226+
return 1;
227+
fi
228+
echo "Waiting for guest testpmd to be up"
229+
continue
230+
done
231+
# Wait till testpmd prompt comes up
232+
guest_testpmd_prompt $pfx
233+
echo "./ep_guest_utils.sh testpmd_start $pfx" >> $in
234+
echo "Started Traffic on Guest"
235+
}
236+
237+
function ep_host_guest_testpmd_pps()
238+
{
239+
local pfx=$1
240+
local in=guest.in.$pfx
241+
local testpmd_pps="$EP_GUEST_SHARE_DIR/testpmd.pps.$pfx"
242+
local rx_pps
243+
244+
echo "./ep_guest_utils.sh testpmd_pps $pfx" >> $in
245+
while [[ ! -f $testpmd_pps ]]; do
246+
sleep 1
247+
echo "Waiting for $testpmd_pps to be created"
248+
done
249+
rx_pps=$(cat $testpmd_pps)
250+
if [[ $rx_pps -eq 0 ]]; then
251+
echo "Low PPS for ${pfx} ($rx_pps == 0)"
252+
return 1
253+
else
254+
echo "Rx PPS $rx_pps as expected"
255+
return 0
256+
fi
257+
}
258+
259+
function ep_host_stop_guest_traffic()
260+
{
261+
local pfx=$1
262+
local in=guest.in.$pfx
263+
local testpmd_out=$EP_GUEST_SHARE_DIR/testpmd.out.$pfx
264+
265+
cat $testpmd_out
266+
echo "./ep_guest_utils.sh testpmd_stop $pfx" >> $in
267+
}
268+
269+
function ep_host_shutdown_guest()
270+
{
271+
local pfx=$1
272+
local in=guest.in.$pfx
273+
274+
echo "cd /home" >>$in
275+
echo "umount $EP_GUEST_DIR" >>$in
276+
echo "shutdown now" >>$in
277+
sleep 10;
278+
}
279+
110280
# If this script is directly invoked from the shell execute the
111281
# op specified
112282
if [[ ${BASH_SOURCE[0]} == ${0} ]]; then

ci/test/dao-test/virtio/l2fwd/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tests = [
66
# Name, Script, Args
77
['virtio_l2fwd_1c', 'virtio_l2fwd_1c.sh', ''],
88
['virtio_l2fwd_multiseg', 'virtio_l2fwd_1c.sh', ''],
9+
['virtio_l2fwd_guest_1c', 'virtio_l2fwd_1c.sh', ''],
910
]
1011

1112
test_dir = meson.current_build_dir()

ci/test/dao-test/virtio/l2fwd/virtio_l2fwd_1c.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,56 @@ function virtio_l2fwd_multiseg()
161161
return $k
162162
}
163163

164+
function virtio_l2fwd_guest_1c()
165+
{
166+
local l2fwd_pfx=${DAO_TEST}
167+
local host_pfx=${DAO_TEST}_guest
168+
local l2fwd_out=virtio_l2fwd.${l2fwd_pfx}.out
169+
local if0=$(ep_device_get_inactive_if)
170+
local device_part
171+
local args
172+
173+
l2fwd_register_sig_handler ${DAO_TEST} $host_pfx $l2fwd_out
174+
175+
ep_device_vfio_bind $if0
176+
177+
# Launch virtio l2fwd
178+
if ! l2fwd_app_launch $if0 $l2fwd_pfx $l2fwd_out "4-7" "-p 0x1 -v 0x1 -P -l"; then
179+
echo "Failed to launch virtio l2fwd"
180+
# Quit l2fwd app
181+
l2fwd_app_quit $l2fwd_pfx $l2fwd_out
182+
return 1
183+
fi
184+
185+
device_part=$(ep_device_op get_part)
186+
ep_host_op vdpa_setup $device_part
187+
ep_host_op_bg 220 launch_guest $host_pfx
188+
local k=$?
189+
if [[ "$k" != "0" ]]; then
190+
echo "Failed to launch Guest"
191+
# Quit l2fwd app
192+
l2fwd_app_quit $l2fwd_pfx $l2fwd_out
193+
ep_host_op vdpa_cleanup
194+
return 1
195+
fi
196+
197+
args="-c 0xff -a 0000:00:03.0 -- --nb-cores=4 --port-topology=loop --rxq=4 --txq=4 -i"
198+
# Start traffic
199+
ep_host_op start_guest_traffic $host_pfx $args
200+
201+
# Check the performance
202+
ep_host_op guest_testpmd_pps $host_pfx
203+
local k=$?
204+
205+
# Stop Traffic
206+
ep_host_op stop_guest_traffic $host_pfx
207+
208+
ep_host_op shutdown_guest $host_pfx
209+
ep_host_op vdpa_cleanup
210+
# Quit l2fwd app
211+
l2fwd_app_quit $l2fwd_pfx $l2fwd_out
212+
213+
return $k
214+
}
215+
164216
test_run ${DAO_TEST} 2

0 commit comments

Comments
 (0)