~ [ 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-5.0.21)


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