Skip to content

Commit 76ab785

Browse files
lsgunthjonmason
authored andcommitted
NTB: Add ntb_msi_test support to ntb_test
When the ntb_msi_test module is available, the test code will trigger each of the interrupts and ensure the corresponding occurrences files gets incremented. Signed-off-by: Logan Gunthorpe <[email protected]> Cc: Dave Jiang <[email protected]> Cc: Allen Hubbe <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent a6bed7a commit 76ab785

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

tools/testing/selftests/ntb/ntb_test.sh

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ set -e
8787

8888
function _modprobe()
8989
{
90-
modprobe "$@"
90+
modprobe "$@" || return 1
9191

9292
if [[ "$REMOTE_HOST" != "" ]]; then
93-
ssh "$REMOTE_HOST" modprobe "$@"
93+
ssh "$REMOTE_HOST" modprobe "$@" || return 1
9494
fi
9595
}
9696

@@ -451,6 +451,30 @@ function pingpong_test()
451451
echo " Passed"
452452
}
453453

454+
function msi_test()
455+
{
456+
LOC=$1
457+
REM=$2
458+
459+
write_file 1 $LOC/ready
460+
461+
echo "Running MSI interrupt tests on: $(subdirname $LOC) / $(subdirname $REM)"
462+
463+
CNT=$(read_file "$LOC/count")
464+
for ((i = 0; i < $CNT; i++)); do
465+
START=$(read_file $REM/../irq${i}_occurrences)
466+
write_file $i $LOC/trigger
467+
END=$(read_file $REM/../irq${i}_occurrences)
468+
469+
if [[ $(($END - $START)) != 1 ]]; then
470+
echo "MSI did not trigger the interrupt on the remote side!" >&2
471+
exit 1
472+
fi
473+
done
474+
475+
echo " Passed"
476+
}
477+
454478
function perf_test()
455479
{
456480
USE_DMA=$1
@@ -529,6 +553,29 @@ function ntb_pingpong_tests()
529553
_modprobe -r ntb_pingpong
530554
}
531555

556+
function ntb_msi_tests()
557+
{
558+
LOCAL_MSI="$DEBUGFS/ntb_msi_test/$LOCAL_DEV"
559+
REMOTE_MSI="$REMOTE_HOST:$DEBUGFS/ntb_msi_test/$REMOTE_DEV"
560+
561+
echo "Starting ntb_msi_test tests..."
562+
563+
if ! _modprobe ntb_msi_test 2> /dev/null; then
564+
echo " Not doing MSI tests seeing the module is not available."
565+
return
566+
fi
567+
568+
port_test $LOCAL_MSI $REMOTE_MSI
569+
570+
LOCAL_PEER="$LOCAL_MSI/peer$LOCAL_PIDX"
571+
REMOTE_PEER="$REMOTE_MSI/peer$REMOTE_PIDX"
572+
573+
msi_test $LOCAL_PEER $REMOTE_PEER
574+
msi_test $REMOTE_PEER $LOCAL_PEER
575+
576+
_modprobe -r ntb_msi_test
577+
}
578+
532579
function ntb_perf_tests()
533580
{
534581
LOCAL_PERF="$DEBUGFS/ntb_perf/$LOCAL_DEV"
@@ -550,6 +597,7 @@ function cleanup()
550597
_modprobe -r ntb_perf 2> /dev/null
551598
_modprobe -r ntb_pingpong 2> /dev/null
552599
_modprobe -r ntb_transport 2> /dev/null
600+
_modprobe -r ntb_msi_test 2> /dev/null
553601
set -e
554602
}
555603

@@ -586,5 +634,7 @@ ntb_tool_tests
586634
echo
587635
ntb_pingpong_tests
588636
echo
637+
ntb_msi_tests
638+
echo
589639
ntb_perf_tests
590640
echo

0 commit comments

Comments
 (0)