~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/ntb/ntb_test.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/ntb/ntb_test.sh (Version linux-6.12-rc7) and /tools/testing/selftests/ntb/ntb_test.sh (Version linux-4.10.17)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0-or-later    << 
  3 # Copyright (c) 2016 Microsemi. All Rights Res      2 # Copyright (c) 2016 Microsemi. All Rights Reserved.
  4 #                                                   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.
                                                   >>  13 #
  5 # Author: Logan Gunthorpe <logang@deltatee.com>     14 # Author: Logan Gunthorpe <logang@deltatee.com>
  6                                                    15 
  7 REMOTE_HOST=                                       16 REMOTE_HOST=
  8 LIST_DEVS=FALSE                                    17 LIST_DEVS=FALSE
  9                                                    18 
 10 DEBUGFS=${DEBUGFS-/sys/kernel/debug}               19 DEBUGFS=${DEBUGFS-/sys/kernel/debug}
 11                                                    20 
 12 PERF_RUN_ORDER=32                                  21 PERF_RUN_ORDER=32
 13 MAX_MW_SIZE=0                                      22 MAX_MW_SIZE=0
 14 RUN_DMA_TESTS=                                     23 RUN_DMA_TESTS=
 15 DONT_CLEANUP=                                      24 DONT_CLEANUP=
 16 MW_SIZE=65536                                      25 MW_SIZE=65536
 17                                                    26 
 18 function show_help()                               27 function show_help()
 19 {                                                  28 {
 20         echo "Usage: $0 [OPTIONS] LOCAL_DEV RE     29         echo "Usage: $0 [OPTIONS] LOCAL_DEV REMOTE_DEV"
 21         echo "Run tests on a pair of NTB endpo     30         echo "Run tests on a pair of NTB endpoints."
 22         echo                                       31         echo
 23         echo "If the NTB device loops back to      32         echo "If the NTB device loops back to the same host then,"
 24         echo "just specifying the two PCI ids      33         echo "just specifying the two PCI ids on the command line is"
 25         echo "sufficient. Otherwise, if the NT     34         echo "sufficient. Otherwise, if the NTB link spans two hosts"
 26         echo "use the -r option to specify the     35         echo "use the -r option to specify the hostname for the remote"
 27         echo "device. SSH will then be used to     36         echo "device. SSH will then be used to test the remote side."
 28         echo "An SSH key between the root user     37         echo "An SSH key between the root users of the host would then"
 29         echo "be highly recommended."              38         echo "be highly recommended."
 30         echo                                       39         echo
 31         echo "Options:"                            40         echo "Options:"
 32         echo "  -C              don't cleanup      41         echo "  -C              don't cleanup ntb modules on exit"
                                                   >>  42         echo "  -d              run dma tests"
 33         echo "  -h              show this help     43         echo "  -h              show this help message"
 34         echo "  -l              list available     44         echo "  -l              list available local and remote PCI ids"
 35         echo "  -r REMOTE_HOST  specify the re     45         echo "  -r REMOTE_HOST  specify the remote's hostname to connect"
 36         echo "                  to for the tes !!  46         echo "                  to for the test (using ssh)"
 37         echo "  -m MW_SIZE      memory window  !!  47         echo "  -p NUM          ntb_perf run order (default: $PERF_RUN_ORDER)"
 38         echo "                  (default: $MW_ !!  48         echo "  -w max_mw_size  maxmium memory window size"
 39         echo "  -d              run dma tests  << 
 40         echo "  -p ORDER        total data ord << 
 41         echo "                  (default: $PER << 
 42         echo "  -w MAX_MW_SIZE  maxmium memory << 
 43         echo                                       49         echo
 44 }                                                  50 }
 45                                                    51 
 46 function parse_args()                              52 function parse_args()
 47 {                                                  53 {
 48         OPTIND=0                                   54         OPTIND=0
 49         while getopts "b:Cdhlm:r:p:w:" opt; do !!  55         while getopts "Cdhlm:r:p:w:" opt; do
 50                 case "$opt" in                     56                 case "$opt" in
 51                 C)  DONT_CLEANUP=1 ;;              57                 C)  DONT_CLEANUP=1 ;;
 52                 d)  RUN_DMA_TESTS=1 ;;             58                 d)  RUN_DMA_TESTS=1 ;;
 53                 h)  show_help; exit 0 ;;           59                 h)  show_help; exit 0 ;;
 54                 l)  LIST_DEVS=TRUE ;;              60                 l)  LIST_DEVS=TRUE ;;
 55                 m)  MW_SIZE=${OPTARG} ;;           61                 m)  MW_SIZE=${OPTARG} ;;
 56                 r)  REMOTE_HOST=${OPTARG} ;;       62                 r)  REMOTE_HOST=${OPTARG} ;;
 57                 p)  PERF_RUN_ORDER=${OPTARG} ;     63                 p)  PERF_RUN_ORDER=${OPTARG} ;;
 58                 w)  MAX_MW_SIZE=${OPTARG} ;;       64                 w)  MAX_MW_SIZE=${OPTARG} ;;
 59                 \?)                                65                 \?)
 60                     echo "Invalid option: -$OP     66                     echo "Invalid option: -$OPTARG" >&2
 61                     exit 1                         67                     exit 1
 62                     ;;                             68                     ;;
 63                 esac                               69                 esac
 64         done                                       70         done
 65 }                                                  71 }
 66                                                    72 
 67 parse_args "$@"                                    73 parse_args "$@"
 68 shift $((OPTIND-1))                                74 shift $((OPTIND-1))
 69 LOCAL_DEV=$1                                       75 LOCAL_DEV=$1
 70 shift                                              76 shift
 71 parse_args "$@"                                    77 parse_args "$@"
 72 shift $((OPTIND-1))                                78 shift $((OPTIND-1))
 73 REMOTE_DEV=$1                                      79 REMOTE_DEV=$1
 74 shift                                              80 shift
 75 parse_args "$@"                                    81 parse_args "$@"
 76                                                    82 
 77 set -e                                             83 set -e
 78                                                    84 
 79 function _modprobe()                               85 function _modprobe()
 80 {                                                  86 {
 81         modprobe "$@" || return 1              !!  87         modprobe "$@"
 82                                                << 
 83         if [[ "$REMOTE_HOST" != "" ]]; then    << 
 84                 ssh "$REMOTE_HOST" modprobe "$ << 
 85         fi                                     << 
 86 }                                                  88 }
 87                                                    89 
 88 function split_remote()                            90 function split_remote()
 89 {                                                  91 {
 90         VPATH=$1                                   92         VPATH=$1
 91         REMOTE=                                    93         REMOTE=
 92                                                    94 
 93         if [[ "$VPATH" == *":/"* ]]; then          95         if [[ "$VPATH" == *":/"* ]]; then
 94                 REMOTE=${VPATH%%:*}                96                 REMOTE=${VPATH%%:*}
 95                 VPATH=${VPATH#*:}                  97                 VPATH=${VPATH#*:}
 96         fi                                         98         fi
 97 }                                                  99 }
 98                                                   100 
 99 function read_file()                              101 function read_file()
100 {                                                 102 {
101         split_remote $1                           103         split_remote $1
102         if [[ "$REMOTE" != "" ]]; then            104         if [[ "$REMOTE" != "" ]]; then
103                 ssh "$REMOTE" cat "$VPATH"        105                 ssh "$REMOTE" cat "$VPATH"
104         else                                      106         else
105                 cat "$VPATH"                      107                 cat "$VPATH"
106         fi                                        108         fi
107 }                                                 109 }
108                                                   110 
109 function write_file()                             111 function write_file()
110 {                                                 112 {
111         split_remote $2                           113         split_remote $2
112         VALUE=$1                                  114         VALUE=$1
113                                                   115 
114         if [[ "$REMOTE" != "" ]]; then            116         if [[ "$REMOTE" != "" ]]; then
115                 ssh "$REMOTE" "echo \"$VALUE\"    117                 ssh "$REMOTE" "echo \"$VALUE\" > \"$VPATH\""
116         else                                      118         else
117                 echo "$VALUE" > "$VPATH"          119                 echo "$VALUE" > "$VPATH"
118         fi                                        120         fi
119 }                                                 121 }
120                                                   122 
121 function check_file()                          << 
122 {                                              << 
123         split_remote $1                        << 
124                                                << 
125         if [[ "$REMOTE" != "" ]]; then         << 
126                 ssh "$REMOTE" "[[ -e ${VPATH}  << 
127         else                                   << 
128                 [[ -e ${VPATH} ]]              << 
129         fi                                     << 
130 }                                              << 
131                                                << 
132 function subdirname()                          << 
133 {                                              << 
134         echo $(basename $(dirname $1)) 2> /dev << 
135 }                                              << 
136                                                << 
137 function find_pidx()                           << 
138 {                                              << 
139         PORT=$1                                << 
140         PPATH=$2                               << 
141                                                << 
142         for ((i = 0; i < 64; i++)); do         << 
143                 PEER_DIR="$PPATH/peer$i"       << 
144                                                << 
145                 check_file ${PEER_DIR} || brea << 
146                                                << 
147                 PEER_PORT=$(read_file "${PEER_ << 
148                 if [[ ${PORT} -eq $PEER_PORT ] << 
149                         echo $i                << 
150                         return 0               << 
151                 fi                             << 
152         done                                   << 
153                                                << 
154         return 1                               << 
155 }                                              << 
156                                                << 
157 function port_test()                           << 
158 {                                              << 
159         LOC=$1                                 << 
160         REM=$2                                 << 
161                                                << 
162         echo "Running port tests on: $(basenam << 
163                                                << 
164         LOCAL_PORT=$(read_file "$LOC/port")    << 
165         REMOTE_PORT=$(read_file "$REM/port")   << 
166                                                << 
167         LOCAL_PIDX=$(find_pidx ${REMOTE_PORT}  << 
168         REMOTE_PIDX=$(find_pidx ${LOCAL_PORT}  << 
169                                                << 
170         echo "Local port ${LOCAL_PORT} with in << 
171         echo "Peer port ${REMOTE_PORT} with in << 
172                                                << 
173         echo "  Passed"                        << 
174 }                                              << 
175                                                << 
176 function link_test()                              123 function link_test()
177 {                                                 124 {
178         LOC=$1                                    125         LOC=$1
179         REM=$2                                    126         REM=$2
180         EXP=0                                     127         EXP=0
181                                                   128 
182         echo "Running link tests on: $(subdirn !! 129         echo "Running link tests on: $(basename $LOC) / $(basename $REM)"
183                                                   130 
184         if ! write_file "N" "$LOC/../link" 2>  !! 131         if ! write_file "N" "$LOC/link" 2> /dev/null; then
185                 echo "  Unsupported"              132                 echo "  Unsupported"
186                 return                            133                 return
187         fi                                        134         fi
188                                                   135 
189         write_file "N" "$LOC/link_event"          136         write_file "N" "$LOC/link_event"
190                                                   137 
191         if [[ $(read_file "$REM/link") != "N"     138         if [[ $(read_file "$REM/link") != "N" ]]; then
192                 echo "Expected link to be down !! 139                 echo "Expected remote link to be down in $REM/link" >&2
193                 exit -1                           140                 exit -1
194         fi                                        141         fi
195                                                   142 
196         write_file "Y" "$LOC/../link"          !! 143         write_file "Y" "$LOC/link"
                                                   >> 144         write_file "Y" "$LOC/link_event"
197                                                   145 
198         echo "  Passed"                           146         echo "  Passed"
199 }                                                 147 }
200                                                   148 
201 function doorbell_test()                          149 function doorbell_test()
202 {                                                 150 {
203         LOC=$1                                    151         LOC=$1
204         REM=$2                                    152         REM=$2
205         EXP=0                                     153         EXP=0
206                                                   154 
207         echo "Running db tests on: $(basename     155         echo "Running db tests on: $(basename $LOC) / $(basename $REM)"
208                                                   156 
209         DB_VALID_MASK=$(read_file "$LOC/db_val !! 157         write_file "c 0xFFFFFFFF" "$REM/db"
210                                                << 
211         write_file "c $DB_VALID_MASK" "$REM/db << 
212                                                   158 
213         for ((i = 0; i < 64; i++)); do         !! 159         for ((i=1; i <= 8; i++)); do
214                 DB=$(read_file "$REM/db")      !! 160                 let DB=$(read_file "$REM/db") || true
215                 if [[ "$DB" -ne "$EXP" ]]; the !! 161                 if [[ "$DB" != "$EXP" ]]; then
216                         echo "Doorbell doesn't    162                         echo "Doorbell doesn't match expected value $EXP " \
217                              "in $REM/db" >&2     163                              "in $REM/db" >&2
218                         exit -1                   164                         exit -1
219                 fi                                165                 fi
220                                                   166 
221                 let "MASK = (1 << $i) & $DB_VA !! 167                 let "MASK=1 << ($i-1)" || true
222                 let "EXP = $EXP | $MASK" || tr !! 168                 let "EXP=$EXP | $MASK" || true
223                                                << 
224                 write_file "s $MASK" "$LOC/pee    169                 write_file "s $MASK" "$LOC/peer_db"
225         done                                      170         done
226                                                   171 
227         write_file "c $DB_VALID_MASK" "$REM/db << 
228         write_file $DB_VALID_MASK "$REM/db_eve << 
229         write_file "s $DB_VALID_MASK" "$REM/db << 
230                                                << 
231         write_file "c $DB_VALID_MASK" "$REM/db << 
232                                                << 
233         echo "  Passed"                           172         echo "  Passed"
234 }                                                 173 }
235                                                   174 
236 function get_files_count()                     !! 175 function read_spad()
237 {                                                 176 {
238         NAME=$1                                !! 177        VPATH=$1
239         LOC=$2                                 !! 178        IDX=$2
240                                                << 
241         split_remote $LOC                      << 
242                                                   179 
243         if [[ "$REMOTE" == "" ]]; then         !! 180        ROW=($(read_file "$VPATH" | grep -e "^$IDX"))
244                 echo $(ls -1 "$VPATH"/${NAME}* !! 181        let VAL=${ROW[1]} || true
245         else                                   !! 182        echo $VAL
246                 echo $(ssh "$REMOTE" "ls -1 \" << 
247                        wc -l" 2> /dev/null)    << 
248         fi                                     << 
249 }                                                 183 }
250                                                   184 
251 function scratchpad_test()                        185 function scratchpad_test()
252 {                                                 186 {
253         LOC=$1                                    187         LOC=$1
254         REM=$2                                    188         REM=$2
                                                   >> 189         CNT=$(read_file "$LOC/spad" | wc -l)
255                                                   190 
256         echo "Running spad tests on: $(subdirn !! 191         echo "Running spad tests on: $(basename $LOC) / $(basename $REM)"
257                                                << 
258         CNT=$(get_files_count "spad" "$LOC")   << 
259                                                << 
260         if [[ $CNT -eq 0 ]]; then              << 
261                 echo "  Unsupported"           << 
262                 return                         << 
263         fi                                     << 
264                                                   192 
265         for ((i = 0; i < $CNT; i++)); do          193         for ((i = 0; i < $CNT; i++)); do
266                 VAL=$RANDOM                       194                 VAL=$RANDOM
267                 write_file "$VAL" "$LOC/spad$i !! 195                 write_file "$i $VAL" "$LOC/peer_spad"
268                 RVAL=$(read_file "$REM/../spad !! 196                 RVAL=$(read_spad "$REM/spad" $i)
269                                                   197 
270                 if [[ "$VAL" -ne "$RVAL" ]]; t !! 198                 if [[ "$VAL" != "$RVAL" ]]; then
271                         echo "Scratchpad $i va !! 199                         echo "Scratchpad doesn't match expected value $VAL " \
                                                   >> 200                              "in $REM/spad, got $RVAL" >&2
272                         exit -1                   201                         exit -1
273                 fi                                202                 fi
274         done                                   << 
275                                                   203 
276         echo "  Passed"                        << 
277 }                                              << 
278                                                << 
279 function message_test()                        << 
280 {                                              << 
281         LOC=$1                                 << 
282         REM=$2                                 << 
283                                                << 
284         echo "Running msg tests on: $(subdirna << 
285                                                << 
286         CNT=$(get_files_count "msg" "$LOC")    << 
287                                                << 
288         if [[ $CNT -eq 0 ]]; then              << 
289                 echo "  Unsupported"           << 
290                 return                         << 
291         fi                                     << 
292                                                << 
293         MSG_OUTBITS_MASK=$(read_file "$LOC/../ << 
294         MSG_INBITS_MASK=$(read_file "$REM/../m << 
295                                                << 
296         write_file "c $MSG_OUTBITS_MASK" "$LOC << 
297         write_file "c $MSG_INBITS_MASK" "$REM/ << 
298                                                << 
299         for ((i = 0; i < $CNT; i++)); do       << 
300                 VAL=$RANDOM                    << 
301                 write_file "$VAL" "$LOC/msg$i" << 
302                 RVAL=$(read_file "$REM/../msg$ << 
303                                                << 
304                 if [[ "$VAL" -ne "${RVAL%%<-*} << 
305                         echo "Message $i value << 
306                         exit -1                << 
307                 fi                             << 
308         done                                      204         done
309                                                   205 
310         echo "  Passed"                           206         echo "  Passed"
311 }                                                 207 }
312                                                   208 
313 function get_number()                          << 
314 {                                              << 
315         KEY=$1                                 << 
316                                                << 
317         sed -n "s/^\(${KEY}\)[ \t]*\(0x[0-9a-f << 
318 }                                              << 
319                                                << 
320 function mw_alloc()                            << 
321 {                                              << 
322         IDX=$1                                 << 
323         LOC=$2                                 << 
324         REM=$3                                 << 
325                                                << 
326         write_file $MW_SIZE "$LOC/mw_trans$IDX << 
327                                                << 
328         INB_MW=$(read_file "$LOC/mw_trans$IDX" << 
329         MW_ALIGNED_SIZE=$(echo "$INB_MW" | get << 
330         MW_DMA_ADDR=$(echo "$INB_MW" | get_num << 
331                                                << 
332         write_file "$MW_DMA_ADDR:$(($MW_ALIGNE << 
333                                                << 
334         if [[ $MW_SIZE -ne $MW_ALIGNED_SIZE ]] << 
335                 echo "MW $IDX size aligned to  << 
336         fi                                     << 
337 }                                              << 
338                                                << 
339 function write_mw()                               209 function write_mw()
340 {                                                 210 {
341         split_remote $2                           211         split_remote $2
342                                                   212 
343         if [[ "$REMOTE" != "" ]]; then            213         if [[ "$REMOTE" != "" ]]; then
344                 ssh "$REMOTE" \                   214                 ssh "$REMOTE" \
345                         dd if=/dev/urandom "of    215                         dd if=/dev/urandom "of=$VPATH" 2> /dev/null || true
346         else                                      216         else
347                 dd if=/dev/urandom "of=$VPATH"    217                 dd if=/dev/urandom "of=$VPATH" 2> /dev/null || true
348         fi                                        218         fi
349 }                                                 219 }
350                                                   220 
351 function mw_check()                            !! 221 function mw_test()
352 {                                                 222 {
353         IDX=$1                                    223         IDX=$1
354         LOC=$2                                    224         LOC=$2
355         REM=$3                                    225         REM=$3
356                                                   226 
357         write_mw "$LOC/mw$IDX"                 !! 227         echo "Running $IDX tests on: $(basename $LOC) / $(basename $REM)"
                                                   >> 228 
                                                   >> 229         write_mw "$LOC/$IDX"
358                                                   230 
359         split_remote "$LOC/mw$IDX"             !! 231         split_remote "$LOC/$IDX"
360         if [[ "$REMOTE" == "" ]]; then            232         if [[ "$REMOTE" == "" ]]; then
361                 A=$VPATH                          233                 A=$VPATH
362         else                                      234         else
363                 A=/tmp/ntb_test.$$.A              235                 A=/tmp/ntb_test.$$.A
364                 ssh "$REMOTE" cat "$VPATH" > "    236                 ssh "$REMOTE" cat "$VPATH" > "$A"
365         fi                                        237         fi
366                                                   238 
367         split_remote "$REM/peer_mw$IDX"        !! 239         split_remote "$REM/peer_$IDX"
368         if [[ "$REMOTE" == "" ]]; then            240         if [[ "$REMOTE" == "" ]]; then
369                 B=$VPATH                          241                 B=$VPATH
370         else                                      242         else
371                 B=/tmp/ntb_test.$$.B              243                 B=/tmp/ntb_test.$$.B
372                 ssh "$REMOTE" cat "$VPATH" > "    244                 ssh "$REMOTE" cat "$VPATH" > "$B"
373         fi                                        245         fi
374                                                   246 
375         cmp -n $MW_ALIGNED_SIZE "$A" "$B"      !! 247         cmp -n $MW_SIZE "$A" "$B"
376         if [[ $? != 0 ]]; then                    248         if [[ $? != 0 ]]; then
377                 echo "Memory window $MW did no    249                 echo "Memory window $MW did not match!" >&2
378         fi                                        250         fi
379                                                   251 
380         if [[ "$A" == "/tmp/*" ]]; then           252         if [[ "$A" == "/tmp/*" ]]; then
381                 rm "$A"                           253                 rm "$A"
382         fi                                        254         fi
383                                                   255 
384         if [[ "$B" == "/tmp/*" ]]; then           256         if [[ "$B" == "/tmp/*" ]]; then
385                 rm "$B"                           257                 rm "$B"
386         fi                                        258         fi
387 }                                              << 
388                                                << 
389 function mw_free()                             << 
390 {                                              << 
391         IDX=$1                                 << 
392         LOC=$2                                 << 
393         REM=$3                                 << 
394                                                << 
395         write_file "$MW_DMA_ADDR:0" "$REM/peer << 
396                                                << 
397         write_file 0 "$LOC/mw_trans$IDX"       << 
398 }                                              << 
399                                                << 
400 function mw_test()                             << 
401 {                                              << 
402         LOC=$1                                 << 
403         REM=$2                                 << 
404                                                << 
405         CNT=$(get_files_count "mw_trans" "$LOC << 
406                                                << 
407         for ((i = 0; i < $CNT; i++)); do       << 
408                 echo "Running mw$i tests on: $ << 
409                      "$(subdirname $REM)"      << 
410                                                << 
411                 mw_alloc $i $LOC $REM          << 
412                                                << 
413                 mw_check $i $LOC $REM          << 
414                                                << 
415                 mw_free $i $LOC  $REM          << 
416                                                << 
417                 echo "  Passed"                << 
418         done                                   << 
419                                                   259 
                                                   >> 260         echo "  Passed"
420 }                                                 261 }
421                                                   262 
422 function pingpong_test()                          263 function pingpong_test()
423 {                                                 264 {
424         LOC=$1                                    265         LOC=$1
425         REM=$2                                    266         REM=$2
426                                                   267 
427         echo "Running ping pong tests on: $(ba    268         echo "Running ping pong tests on: $(basename $LOC) / $(basename $REM)"
428                                                   269 
429         LOC_START=$(read_file "$LOC/count")    !! 270         LOC_START=$(read_file $LOC/count)
430         REM_START=$(read_file "$REM/count")    !! 271         REM_START=$(read_file $REM/count)
431                                                   272 
432         sleep 7                                   273         sleep 7
433                                                   274 
434         LOC_END=$(read_file "$LOC/count")      !! 275         LOC_END=$(read_file $LOC/count)
435         REM_END=$(read_file "$REM/count")      !! 276         REM_END=$(read_file $REM/count)
436                                                   277 
437         if [[ $LOC_START == $LOC_END ]] || [[     278         if [[ $LOC_START == $LOC_END ]] || [[ $REM_START == $REM_END ]]; then
438                 echo "Ping pong counter not in    279                 echo "Ping pong counter not incrementing!" >&2
439                 exit 1                            280                 exit 1
440         fi                                        281         fi
441                                                   282 
442         echo "  Passed"                           283         echo "  Passed"
443 }                                                 284 }
444                                                   285 
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:  << 
453                                                << 
454         CNT=$(read_file "$LOC/count")          << 
455         for ((i = 0; i < $CNT; i++)); do       << 
456                 START=$(read_file $REM/../irq$ << 
457                 write_file $i $LOC/trigger     << 
458                 END=$(read_file $REM/../irq${i << 
459                                                << 
460                 if [[ $(($END - $START)) != 1  << 
461                         echo "MSI did not trig << 
462                         exit 1                 << 
463                 fi                             << 
464         done                                   << 
465                                                << 
466         echo "  Passed"                        << 
467 }                                              << 
468                                                << 
469 function perf_test()                              286 function perf_test()
470 {                                                 287 {
471         USE_DMA=$1                                288         USE_DMA=$1
472                                                   289 
473         if [[ $USE_DMA == "1" ]]; then            290         if [[ $USE_DMA == "1" ]]; then
474                 WITH="with"                       291                 WITH="with"
475         else                                      292         else
476                 WITH="without"                    293                 WITH="without"
477         fi                                        294         fi
478                                                   295 
479         _modprobe ntb_perf total_order=$PERF_R !! 296         _modprobe ntb_perf run_order=$PERF_RUN_ORDER \
480                 max_mw_size=$MAX_MW_SIZE use_d    297                 max_mw_size=$MAX_MW_SIZE use_dma=$USE_DMA
481                                                   298 
482         echo "Running local perf test $WITH DM    299         echo "Running local perf test $WITH DMA"
483         write_file "$LOCAL_PIDX" "$LOCAL_PERF/ !! 300         write_file "" $LOCAL_PERF/run
484         echo -n "  "                              301         echo -n "  "
485         read_file "$LOCAL_PERF/run"            !! 302         read_file $LOCAL_PERF/run
486         echo "  Passed"                           303         echo "  Passed"
487                                                   304 
488         echo "Running remote perf test $WITH D    305         echo "Running remote perf test $WITH DMA"
489         write_file "$REMOTE_PIDX" "$REMOTE_PER !! 306         write_file "" $REMOTE_PERF/run
490         echo -n "  "                              307         echo -n "  "
491         read_file "$REMOTE_PERF/run"           !! 308         read_file $LOCAL_PERF/run
492         echo "  Passed"                           309         echo "  Passed"
493                                                   310 
494         _modprobe -r ntb_perf                     311         _modprobe -r ntb_perf
495 }                                                 312 }
496                                                   313 
497 function ntb_tool_tests()                         314 function ntb_tool_tests()
498 {                                                 315 {
499         LOCAL_TOOL="$DEBUGFS/ntb_tool/$LOCAL_D !! 316         LOCAL_TOOL=$DEBUGFS/ntb_tool/$LOCAL_DEV
500         REMOTE_TOOL="$REMOTE_HOST:$DEBUGFS/ntb !! 317         REMOTE_TOOL=$REMOTE_HOST:$DEBUGFS/ntb_tool/$REMOTE_DEV
501                                                   318 
502         echo "Starting ntb_tool tests..."         319         echo "Starting ntb_tool tests..."
503                                                   320 
504         _modprobe ntb_tool                        321         _modprobe ntb_tool
505                                                   322 
506         port_test "$LOCAL_TOOL" "$REMOTE_TOOL" !! 323         write_file Y $LOCAL_TOOL/link_event
507                                                !! 324         write_file Y $REMOTE_TOOL/link_event
508         LOCAL_PEER_TOOL="$LOCAL_TOOL/peer$LOCA << 
509         REMOTE_PEER_TOOL="$REMOTE_TOOL/peer$RE << 
510                                                << 
511         link_test "$LOCAL_PEER_TOOL" "$REMOTE_ << 
512         link_test "$REMOTE_PEER_TOOL" "$LOCAL_ << 
513                                                   325 
514         #Ensure the link is up on both sides b !! 326         link_test $LOCAL_TOOL $REMOTE_TOOL
515         write_file "Y" "$LOCAL_PEER_TOOL/link_ !! 327         link_test $REMOTE_TOOL $LOCAL_TOOL
516         write_file "Y" "$REMOTE_PEER_TOOL/link << 
517                                                   328 
518         doorbell_test "$LOCAL_TOOL" "$REMOTE_T !! 329         for PEER_TRANS in $(ls $LOCAL_TOOL/peer_trans*); do
519         doorbell_test "$REMOTE_TOOL" "$LOCAL_T !! 330                 PT=$(basename $PEER_TRANS)
                                                   >> 331                 write_file $MW_SIZE $LOCAL_TOOL/$PT
                                                   >> 332                 write_file $MW_SIZE $REMOTE_TOOL/$PT
                                                   >> 333         done
520                                                   334 
521         scratchpad_test "$LOCAL_PEER_TOOL" "$R !! 335         doorbell_test $LOCAL_TOOL $REMOTE_TOOL
522         scratchpad_test "$REMOTE_PEER_TOOL" "$ !! 336         doorbell_test $REMOTE_TOOL $LOCAL_TOOL
                                                   >> 337         scratchpad_test $LOCAL_TOOL $REMOTE_TOOL
                                                   >> 338         scratchpad_test $REMOTE_TOOL $LOCAL_TOOL
523                                                   339 
524         message_test "$LOCAL_PEER_TOOL" "$REMO !! 340         for MW in $(ls $LOCAL_TOOL/mw*); do
525         message_test "$REMOTE_PEER_TOOL" "$LOC !! 341                 MW=$(basename $MW)
526                                                   342 
527         mw_test "$LOCAL_PEER_TOOL" "$REMOTE_PE !! 343                 mw_test $MW $LOCAL_TOOL $REMOTE_TOOL
528         mw_test "$REMOTE_PEER_TOOL" "$LOCAL_PE !! 344                 mw_test $MW $REMOTE_TOOL $LOCAL_TOOL
                                                   >> 345         done
529                                                   346 
530         _modprobe -r ntb_tool                     347         _modprobe -r ntb_tool
531 }                                                 348 }
532                                                   349 
533 function ntb_pingpong_tests()                     350 function ntb_pingpong_tests()
534 {                                                 351 {
535         LOCAL_PP="$DEBUGFS/ntb_pingpong/$LOCAL !! 352         LOCAL_PP=$DEBUGFS/ntb_pingpong/$LOCAL_DEV
536         REMOTE_PP="$REMOTE_HOST:$DEBUGFS/ntb_p !! 353         REMOTE_PP=$REMOTE_HOST:$DEBUGFS/ntb_pingpong/$REMOTE_DEV
537                                                   354 
538         echo "Starting ntb_pingpong tests..."     355         echo "Starting ntb_pingpong tests..."
539                                                   356 
540         _modprobe ntb_pingpong                    357         _modprobe ntb_pingpong
541                                                   358 
542         pingpong_test $LOCAL_PP $REMOTE_PP        359         pingpong_test $LOCAL_PP $REMOTE_PP
543                                                   360 
544         _modprobe -r ntb_pingpong                 361         _modprobe -r ntb_pingpong
545 }                                                 362 }
546                                                   363 
547 function ntb_msi_tests()                       << 
548 {                                              << 
549         LOCAL_MSI="$DEBUGFS/ntb_msi_test/$LOCA << 
550         REMOTE_MSI="$REMOTE_HOST:$DEBUGFS/ntb_ << 
551                                                << 
552         echo "Starting ntb_msi_test tests..."  << 
553                                                << 
554         if ! _modprobe ntb_msi_test 2> /dev/nu << 
555                 echo "  Not doing MSI tests se << 
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_P << 
563                                                << 
564         msi_test $LOCAL_PEER $REMOTE_PEER      << 
565         msi_test $REMOTE_PEER $LOCAL_PEER      << 
566                                                << 
567         _modprobe -r ntb_msi_test              << 
568 }                                              << 
569                                                << 
570 function ntb_perf_tests()                         364 function ntb_perf_tests()
571 {                                                 365 {
572         LOCAL_PERF="$DEBUGFS/ntb_perf/$LOCAL_D !! 366         LOCAL_PERF=$DEBUGFS/ntb_perf/$LOCAL_DEV
573         REMOTE_PERF="$REMOTE_HOST:$DEBUGFS/ntb !! 367         REMOTE_PERF=$REMOTE_HOST:$DEBUGFS/ntb_perf/$REMOTE_DEV
574                                                   368 
575         echo "Starting ntb_perf tests..."         369         echo "Starting ntb_perf tests..."
576                                                   370 
577         perf_test 0                               371         perf_test 0
578                                                   372 
579         if [[ $RUN_DMA_TESTS ]]; then             373         if [[ $RUN_DMA_TESTS ]]; then
580                 perf_test 1                       374                 perf_test 1
581         fi                                        375         fi
582 }                                                 376 }
583                                                   377 
584 function cleanup()                                378 function cleanup()
585 {                                                 379 {
586         set +e                                    380         set +e
587         _modprobe -r ntb_tool 2> /dev/null        381         _modprobe -r ntb_tool 2> /dev/null
588         _modprobe -r ntb_perf 2> /dev/null        382         _modprobe -r ntb_perf 2> /dev/null
589         _modprobe -r ntb_pingpong 2> /dev/null    383         _modprobe -r ntb_pingpong 2> /dev/null
590         _modprobe -r ntb_transport 2> /dev/nul    384         _modprobe -r ntb_transport 2> /dev/null
591         _modprobe -r ntb_msi_test 2> /dev/null << 
592         set -e                                    385         set -e
593 }                                                 386 }
594                                                   387 
595 cleanup                                           388 cleanup
596                                                   389 
597 if ! [[ $$DONT_CLEANUP ]]; then                   390 if ! [[ $$DONT_CLEANUP ]]; then
598         trap cleanup EXIT                         391         trap cleanup EXIT
599 fi                                                392 fi
600                                                   393 
601 if [ "$(id -u)" != "0" ]; then                    394 if [ "$(id -u)" != "0" ]; then
602         echo "This script must be run as root"    395         echo "This script must be run as root" 1>&2
603         exit 1                                    396         exit 1
604 fi                                                397 fi
605                                                   398 
606 if [[ "$LIST_DEVS" == TRUE ]]; then               399 if [[ "$LIST_DEVS" == TRUE ]]; then
607         echo "Local Devices:"                     400         echo "Local Devices:"
608         ls -1 /sys/bus/ntb/devices                401         ls -1 /sys/bus/ntb/devices
609         echo                                      402         echo
610                                                   403 
611         if [[ "$REMOTE_HOST" != "" ]]; then       404         if [[ "$REMOTE_HOST" != "" ]]; then
612                 echo "Remote Devices:"            405                 echo "Remote Devices:"
613                 ssh $REMOTE_HOST ls -1 /sys/bu    406                 ssh $REMOTE_HOST ls -1 /sys/bus/ntb/devices
614         fi                                        407         fi
615                                                   408 
616         exit 0                                    409         exit 0
617 fi                                                410 fi
618                                                   411 
619 if [[ "$LOCAL_DEV" == $"" ]] || [[ "$REMOTE_DE    412 if [[ "$LOCAL_DEV" == $"" ]] || [[ "$REMOTE_DEV" == $"" ]]; then
620         show_help                                 413         show_help
621         exit 1                                    414         exit 1
622 fi                                                415 fi
623                                                   416 
624 ntb_tool_tests                                    417 ntb_tool_tests
625 echo                                              418 echo
626 ntb_pingpong_tests                                419 ntb_pingpong_tests
627 echo                                           << 
628 ntb_msi_tests                                  << 
629 echo                                              420 echo
630 ntb_perf_tests                                    421 ntb_perf_tests
631 echo                                              422 echo
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php