Skip to content

Commit

Permalink
ci: guest netdev test case
Browse files Browse the repository at this point in the history
This patch adds guest netdev test case

Signed-off-by: Kommula Shiva Shankar <kshankar@marvell.com>
Change-Id: Ie6f10428737ddd3ea8670939124840d7a50da7bd
Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpu-offload/+/136779
Tested-by: sa_ip-toolkits-Jenkins <sa_ip-toolkits-jenkins@marvell.com>
Reviewed-by: Srujana Challa <schalla@marvell.com>
  • Loading branch information
ShivaShankarKommula authored and jerinjacobk committed Nov 11, 2024
1 parent 44e779f commit f32eef8
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 1 deletion.
50 changes: 50 additions & 0 deletions ci/test/dao-test/common/ep_guest_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,56 @@ function ep_guest_setup()
echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
}

function ep_guest_start_ping_test()
{
local pfx=$1
local src_addr=$2
local dst_addr=$3
local count=$4
local ping_out
local pkt_sizes=(64 1000 1500)
local pkt_size

for pkt_size in "${pkt_sizes[@]}"
do
ping_out=$(ping -c $count -s $pkt_size -i 0.2 \
-I $src_addr $dst_addr || true)
if [[ -n $(echo $ping_out | grep ", 0% packet loss,") ]]; then
echo "$pkt_size packet size ping test SUCCESS" \
>> /root/hostshare/netdev.ping_pass.out.$pfx
else
echo "$pkt_size packet size ping FAILED" \
>> /root/hostshare/netdev.ping_fail.out.$pfx
echo "stopping test execution" \
>> /root/hostshare/netdev.ping_fail.out.$pfx
break
fi
done
}

function ep_guest_netdev_config()
{
local net_bdf
local ip_addr=$2
local net_name
local k=1

net_bdf=$(lspci -Dd ::0200 | awk '{print $1}')
for dev in $net_bdf; do
virtio_dir=$(echo /sys/bus/pci/devices/$dev/virtio*)
if [[ -d $virtio_dir ]]; then
if [[ -d $virtio_dir/net ]]; then
net_name=$(basename $(readlink -f $virtio_dir/net/*))
ip link set dev $net_name up
ip addr add $ip_addr dev $net_name
k=0
break
fi
fi
done
return $k
}

function ep_guest_testpmd_launch()
{
local pfx=$1
Expand Down
34 changes: 34 additions & 0 deletions ci/test/dao-test/common/ep_host_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,40 @@ function ep_host_stop_guest_traffic()
echo "./ep_guest_utils.sh testpmd_stop $pfx" >> $in
}

function ep_host_netdev_config()
{
local pfx=$1
local in=guest.in.$pfx
local out=guest.out.$pfx
local args=${@:2}

echo "Configuring guest netdev"
echo "./ep_guest_utils.sh netdev_config $pfx $args" >> $in
}

function ep_host_netdev_ping_test()
{
local pfx=$1
local in=guest.in.$pfx
local out=guest.out.$pfx
local args=${@:2}
local ping_test_fail_res="$EP_GUEST_SHARE_DIR/netdev.ping_fail.out.$pfx"
local ping_test_pass_res="$EP_GUEST_SHARE_DIR/netdev.ping_pass.out.$pfx"
local res

echo "./ep_guest_utils.sh start_ping_test $pfx $args" >> $in
# Wait ping command to complete
sleep 60
if [[ -f $ping_test_fail_res ]]; then
echo "Ping test failed"
echo "$(cat $ping_test_fail_res)"
return 1
elif [[ -f $ping_test_pass_res ]]; then
echo "$(cat $ping_test_pass_res)"
return 0
fi
}

function ep_host_shutdown_guest()
{
local pfx=$1
Expand Down
3 changes: 2 additions & 1 deletion ci/test/dao-test/virtio/l2fwd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ tests = [
['virtio_l2fwd_host_net_1c', 'virtio_l2fwd_1c.sh', ''],
['virtio_l2fwd_csum', 'virtio_l2fwd_csum.sh', ''],
['virtio_l2fwd_mactest', 'virtio_l2fwd_1c.sh', ''],
['virtio_l2fwd_reset', 'virtio_l2fwd_1c.sh', '']
['virtio_l2fwd_reset', 'virtio_l2fwd_1c.sh', ''],
['virtio_l2fwd_guest_net_1c', 'virtio_l2fwd_1c.sh', ''],
]

test_dir = meson.current_build_dir()
Expand Down
99 changes: 99 additions & 0 deletions ci/test/dao-test/virtio/l2fwd/virtio_l2fwd_1c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,84 @@ function virtio_l2fwd_host_net_1c_run()
return $k
}

function virtio_l2fwd_guest_net_1c_run()
{
local l2fwd_pfx=${DAO_TEST}
local guest_net_pfx=${DAO_TEST}_guest_net
local l2fwd_out=virtio_l2fwd.${l2fwd_pfx}.out
local npa_pf=$(ep_device_get_unused_npa_pf)
local ep_device_dtap_addr=20.20.20.2
local ep_guest_ip_addr=20.20.20.1
local app_args
local cidr=24
local ping_out
local count=60
local k=0

if [ -z "${1:-}" ]; then
ff_enable=""
else
ff_enable=$1
fi

l2fwd_register_sig_handler ${DAO_TEST} $guest_net_pfx $l2fwd_out

ep_common_bind_driver pci $npa_pf vfio-pci

# Launch virtio l2fwd without cgx loopback
app_args="-p 0x1 -v 0x1 -P $ff_enable"
if ! l2fwd_app_launch_with_tap_dev $npa_pf $l2fwd_pfx $l2fwd_out "4-7" "$app_args"; then
echo "Failed to launch virtio l2fwd"

# Quit l2fwd app
l2fwd_app_quit $l2fwd_pfx $l2fwd_out

# Unbind NPA device
ep_common_unbind_driver pci $npa_pf vfio-pci

return 1
fi

echo "Configuring TAP interface on EP device"
#By default, Linux interfaces are named dtapX
ep_device_configure_tap_iface dtap0 $ep_device_dtap_addr/$cidr

ep_host_op vdpa_setup $(ep_device_get_part)
ep_host_op_bg 300 launch_guest $guest_net_pfx
local k=$?
if [[ "$k" != "0" ]]; then
echo "Failed to launch Guest"

# Quit l2fwd app
l2fwd_app_quit $l2fwd_pfx $l2fwd_out

# Unbind NPA device
ep_common_unbind_driver pci $npa_pf vfio-pci

return 1
fi

#configure guest netdev
ep_host_op netdev_config $guest_net_pfx $ep_guest_ip_addr/$cidr

echo "Verifying ping"
ep_host_op netdev_ping_test $guest_net_pfx $ep_guest_ip_addr $ep_device_dtap_addr $count
local k=$?

ep_host_op shutdown_guest $guest_net_pfx

echo "virtio_vdpa_cleanup"
ep_host_op virtio_vdpa_cleanup

# Quit l2fwd app
l2fwd_app_quit $l2fwd_pfx $l2fwd_out

#Unbind NPA device
ep_common_unbind_driver pci $npa_pf vfio-pci

return $k
}

function virtio_l2fwd_host_net_1c()
{
local k
Expand All @@ -311,6 +389,27 @@ function virtio_l2fwd_host_net_1c()
echo ${DAO_TEST}" Test PASSED"
}

function virtio_l2fwd_guest_net_1c()
{
local k

virtio_l2fwd_guest_net_1c_run
k=$?
if [[ "$k" != "0" ]]; then
echo ${DAO_TEST}" Guest net FF Test FAILED"
return $k
fi

virtio_l2fwd_guest_net_1c_run -f
k=$?
if [[ "$k" != "0" ]]; then
echo ${DAO_TEST}" Guest net NO_FF Test FAILED "
return $k
fi

echo ${DAO_TEST}" Guest net Test PASSED"
}

function virtio_l2fwd_mactest()
{
tx_upcap=$EP_DIR/ci/test/dao-test/virtio/l2fwd/pcap/ucast.pcap
Expand Down

0 comments on commit f32eef8

Please sign in to comment.