]> www.infradead.org Git - users/willy/xarray.git/commitdiff
NTB: Add ntb_msi_test support to ntb_test
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 23 May 2019 22:30:58 +0000 (16:30 -0600)
committerJon Mason <jdmason@kudzu.us>
Thu, 13 Jun 2019 13:02:59 +0000 (09:02 -0400)
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 <logang@deltatee.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Allen Hubbe <allenbh@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
tools/testing/selftests/ntb/ntb_test.sh

index 08cbfbbc702910e088068ae710713ac2558b70a3..7df497095b72a90d0920b9040a973773f2f0e496 100755 (executable)
@@ -87,10 +87,10 @@ set -e
 
 function _modprobe()
 {
-       modprobe "$@"
+       modprobe "$@" || return 1
 
        if [[ "$REMOTE_HOST" != "" ]]; then
-               ssh "$REMOTE_HOST" modprobe "$@"
+               ssh "$REMOTE_HOST" modprobe "$@" || return 1
        fi
 }
 
@@ -451,6 +451,30 @@ function pingpong_test()
        echo "  Passed"
 }
 
+function msi_test()
+{
+       LOC=$1
+       REM=$2
+
+       write_file 1 $LOC/ready
+
+       echo "Running MSI interrupt tests on: $(subdirname $LOC) / $(subdirname $REM)"
+
+       CNT=$(read_file "$LOC/count")
+       for ((i = 0; i < $CNT; i++)); do
+               START=$(read_file $REM/../irq${i}_occurrences)
+               write_file $i $LOC/trigger
+               END=$(read_file $REM/../irq${i}_occurrences)
+
+               if [[ $(($END - $START)) != 1 ]]; then
+                       echo "MSI did not trigger the interrupt on the remote side!" >&2
+                       exit 1
+               fi
+       done
+
+       echo "  Passed"
+}
+
 function perf_test()
 {
        USE_DMA=$1
@@ -529,6 +553,29 @@ function ntb_pingpong_tests()
        _modprobe -r ntb_pingpong
 }
 
+function ntb_msi_tests()
+{
+       LOCAL_MSI="$DEBUGFS/ntb_msi_test/$LOCAL_DEV"
+       REMOTE_MSI="$REMOTE_HOST:$DEBUGFS/ntb_msi_test/$REMOTE_DEV"
+
+       echo "Starting ntb_msi_test tests..."
+
+       if ! _modprobe ntb_msi_test 2> /dev/null; then
+               echo "  Not doing MSI tests seeing the module is not available."
+               return
+       fi
+
+       port_test $LOCAL_MSI $REMOTE_MSI
+
+       LOCAL_PEER="$LOCAL_MSI/peer$LOCAL_PIDX"
+       REMOTE_PEER="$REMOTE_MSI/peer$REMOTE_PIDX"
+
+       msi_test $LOCAL_PEER $REMOTE_PEER
+       msi_test $REMOTE_PEER $LOCAL_PEER
+
+       _modprobe -r ntb_msi_test
+}
+
 function ntb_perf_tests()
 {
        LOCAL_PERF="$DEBUGFS/ntb_perf/$LOCAL_DEV"
@@ -550,6 +597,7 @@ function cleanup()
        _modprobe -r ntb_perf 2> /dev/null
        _modprobe -r ntb_pingpong 2> /dev/null
        _modprobe -r ntb_transport 2> /dev/null
+       _modprobe -r ntb_msi_test 2> /dev/null
        set -e
 }
 
@@ -586,5 +634,7 @@ ntb_tool_tests
 echo
 ntb_pingpong_tests
 echo
+ntb_msi_tests
+echo
 ntb_perf_tests
 echo