hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/testing/selftests/ntb/ntb_test.sh
....@@ -1,15 +1,6 @@
11 #!/bin/bash
2
+# SPDX-License-Identifier: GPL-2.0-or-later
23 # Copyright (c) 2016 Microsemi. All Rights Reserved.
3
-#
4
-# This program is free software; you can redistribute it and/or
5
-# modify it under the terms of the GNU General Public License as
6
-# published by the Free Software Foundation; either version 2 of
7
-# the License, or (at your option) any later version.
8
-#
9
-# This program is distributed in the hope that it would be useful,
10
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
-# GNU General Public License for more details.
134 #
145 # Author: Logan Gunthorpe <logang@deltatee.com>
156
....@@ -87,10 +78,10 @@
8778
8879 function _modprobe()
8980 {
90
- modprobe "$@"
81
+ modprobe "$@" || return 1
9182
9283 if [[ "$REMOTE_HOST" != "" ]]; then
93
- ssh "$REMOTE_HOST" modprobe "$@"
84
+ ssh "$REMOTE_HOST" modprobe "$@" || return 1
9485 fi
9586 }
9687
....@@ -451,6 +442,30 @@
451442 echo " Passed"
452443 }
453444
445
+function msi_test()
446
+{
447
+ LOC=$1
448
+ REM=$2
449
+
450
+ write_file 1 $LOC/ready
451
+
452
+ echo "Running MSI interrupt tests on: $(subdirname $LOC) / $(subdirname $REM)"
453
+
454
+ CNT=$(read_file "$LOC/count")
455
+ for ((i = 0; i < $CNT; i++)); do
456
+ START=$(read_file $REM/../irq${i}_occurrences)
457
+ write_file $i $LOC/trigger
458
+ END=$(read_file $REM/../irq${i}_occurrences)
459
+
460
+ if [[ $(($END - $START)) != 1 ]]; then
461
+ echo "MSI did not trigger the interrupt on the remote side!" >&2
462
+ exit 1
463
+ fi
464
+ done
465
+
466
+ echo " Passed"
467
+}
468
+
454469 function perf_test()
455470 {
456471 USE_DMA=$1
....@@ -529,6 +544,29 @@
529544 _modprobe -r ntb_pingpong
530545 }
531546
547
+function ntb_msi_tests()
548
+{
549
+ LOCAL_MSI="$DEBUGFS/ntb_msi_test/$LOCAL_DEV"
550
+ REMOTE_MSI="$REMOTE_HOST:$DEBUGFS/ntb_msi_test/$REMOTE_DEV"
551
+
552
+ echo "Starting ntb_msi_test tests..."
553
+
554
+ if ! _modprobe ntb_msi_test 2> /dev/null; then
555
+ echo " Not doing MSI tests seeing the module is not available."
556
+ return
557
+ fi
558
+
559
+ port_test $LOCAL_MSI $REMOTE_MSI
560
+
561
+ LOCAL_PEER="$LOCAL_MSI/peer$LOCAL_PIDX"
562
+ REMOTE_PEER="$REMOTE_MSI/peer$REMOTE_PIDX"
563
+
564
+ msi_test $LOCAL_PEER $REMOTE_PEER
565
+ msi_test $REMOTE_PEER $LOCAL_PEER
566
+
567
+ _modprobe -r ntb_msi_test
568
+}
569
+
532570 function ntb_perf_tests()
533571 {
534572 LOCAL_PERF="$DEBUGFS/ntb_perf/$LOCAL_DEV"
....@@ -550,6 +588,7 @@
550588 _modprobe -r ntb_perf 2> /dev/null
551589 _modprobe -r ntb_pingpong 2> /dev/null
552590 _modprobe -r ntb_transport 2> /dev/null
591
+ _modprobe -r ntb_msi_test 2> /dev/null
553592 set -e
554593 }
555594
....@@ -586,5 +625,7 @@
586625 echo
587626 ntb_pingpong_tests
588627 echo
628
+ntb_msi_tests
629
+echo
589630 ntb_perf_tests
590631 echo