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 >> 21 DB_BITMASK=0x7FFF 12 PERF_RUN_ORDER=32 22 PERF_RUN_ORDER=32 13 MAX_MW_SIZE=0 23 MAX_MW_SIZE=0 14 RUN_DMA_TESTS= 24 RUN_DMA_TESTS= 15 DONT_CLEANUP= 25 DONT_CLEANUP= 16 MW_SIZE=65536 26 MW_SIZE=65536 17 27 18 function show_help() 28 function show_help() 19 { 29 { 20 echo "Usage: $0 [OPTIONS] LOCAL_DEV RE 30 echo "Usage: $0 [OPTIONS] LOCAL_DEV REMOTE_DEV" 21 echo "Run tests on a pair of NTB endpo 31 echo "Run tests on a pair of NTB endpoints." 22 echo 32 echo 23 echo "If the NTB device loops back to 33 echo "If the NTB device loops back to the same host then," 24 echo "just specifying the two PCI ids 34 echo "just specifying the two PCI ids on the command line is" 25 echo "sufficient. Otherwise, if the NT 35 echo "sufficient. Otherwise, if the NTB link spans two hosts" 26 echo "use the -r option to specify the 36 echo "use the -r option to specify the hostname for the remote" 27 echo "device. SSH will then be used to 37 echo "device. SSH will then be used to test the remote side." 28 echo "An SSH key between the root user 38 echo "An SSH key between the root users of the host would then" 29 echo "be highly recommended." 39 echo "be highly recommended." 30 echo 40 echo 31 echo "Options:" 41 echo "Options:" >> 42 echo " -b BITMASK doorbell clear bitmask for ntb_tool" 32 echo " -C don't cleanup 43 echo " -C don't cleanup ntb modules on exit" >> 44 echo " -d run dma tests" 33 echo " -h show this help 45 echo " -h show this help message" 34 echo " -l list available 46 echo " -l list available local and remote PCI ids" 35 echo " -r REMOTE_HOST specify the re 47 echo " -r REMOTE_HOST specify the remote's hostname to connect" 36 echo " to for the tes !! 48 echo " to for the test (using ssh)" 37 echo " -m MW_SIZE memory window !! 49 echo " -p NUM ntb_perf run order (default: $PERF_RUN_ORDER)" 38 echo " (default: $MW_ !! 50 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 51 echo 44 } 52 } 45 53 46 function parse_args() 54 function parse_args() 47 { 55 { 48 OPTIND=0 56 OPTIND=0 49 while getopts "b:Cdhlm:r:p:w:" opt; do 57 while getopts "b:Cdhlm:r:p:w:" opt; do 50 case "$opt" in 58 case "$opt" in >> 59 b) DB_BITMASK=${OPTARG} ;; 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() << 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() 130 function link_test() 177 { 131 { 178 LOC=$1 132 LOC=$1 179 REM=$2 133 REM=$2 180 EXP=0 134 EXP=0 181 135 182 echo "Running link tests on: $(subdirn !! 136 echo "Running link tests on: $(basename $LOC) / $(basename $REM)" 183 137 184 if ! write_file "N" "$LOC/../link" 2> !! 138 if ! write_file "N" "$LOC/link" 2> /dev/null; then 185 echo " Unsupported" 139 echo " Unsupported" 186 return 140 return 187 fi 141 fi 188 142 189 write_file "N" "$LOC/link_event" 143 write_file "N" "$LOC/link_event" 190 144 191 if [[ $(read_file "$REM/link") != "N" 145 if [[ $(read_file "$REM/link") != "N" ]]; then 192 echo "Expected link to be down !! 146 echo "Expected remote link to be down in $REM/link" >&2 193 exit -1 147 exit -1 194 fi 148 fi 195 149 196 write_file "Y" "$LOC/../link" !! 150 write_file "Y" "$LOC/link" >> 151 write_file "Y" "$LOC/link_event" 197 152 198 echo " Passed" 153 echo " Passed" 199 } 154 } 200 155 201 function doorbell_test() 156 function doorbell_test() 202 { 157 { 203 LOC=$1 158 LOC=$1 204 REM=$2 159 REM=$2 205 EXP=0 160 EXP=0 206 161 207 echo "Running db tests on: $(basename 162 echo "Running db tests on: $(basename $LOC) / $(basename $REM)" 208 163 209 DB_VALID_MASK=$(read_file "$LOC/db_val !! 164 write_file "c $DB_BITMASK" "$REM/db" 210 << 211 write_file "c $DB_VALID_MASK" "$REM/db << 212 165 213 for ((i = 0; i < 64; i++)); do !! 166 for ((i=1; i <= 8; i++)); do 214 DB=$(read_file "$REM/db") !! 167 let DB=$(read_file "$REM/db") || true 215 if [[ "$DB" -ne "$EXP" ]]; the !! 168 if [[ "$DB" != "$EXP" ]]; then 216 echo "Doorbell doesn't 169 echo "Doorbell doesn't match expected value $EXP " \ 217 "in $REM/db" >&2 170 "in $REM/db" >&2 218 exit -1 171 exit -1 219 fi 172 fi 220 173 221 let "MASK = (1 << $i) & $DB_VA !! 174 let "MASK=1 << ($i-1)" || true 222 let "EXP = $EXP | $MASK" || tr !! 175 let "EXP=$EXP | $MASK" || true 223 << 224 write_file "s $MASK" "$LOC/pee 176 write_file "s $MASK" "$LOC/peer_db" 225 done 177 done 226 178 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" 179 echo " Passed" 234 } 180 } 235 181 236 function get_files_count() !! 182 function read_spad() 237 { 183 { 238 NAME=$1 !! 184 VPATH=$1 239 LOC=$2 !! 185 IDX=$2 240 << 241 split_remote $LOC << 242 186 243 if [[ "$REMOTE" == "" ]]; then !! 187 ROW=($(read_file "$VPATH" | grep -e "^$IDX")) 244 echo $(ls -1 "$VPATH"/${NAME}* !! 188 let VAL=${ROW[1]} || true 245 else !! 189 echo $VAL 246 echo $(ssh "$REMOTE" "ls -1 \" << 247 wc -l" 2> /dev/null) << 248 fi << 249 } 190 } 250 191 251 function scratchpad_test() 192 function scratchpad_test() 252 { 193 { 253 LOC=$1 194 LOC=$1 254 REM=$2 195 REM=$2 >> 196 CNT=$(read_file "$LOC/spad" | wc -l) 255 197 256 echo "Running spad tests on: $(subdirn !! 198 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 199 265 for ((i = 0; i < $CNT; i++)); do 200 for ((i = 0; i < $CNT; i++)); do 266 VAL=$RANDOM 201 VAL=$RANDOM 267 write_file "$VAL" "$LOC/spad$i !! 202 write_file "$i $VAL" "$LOC/peer_spad" 268 RVAL=$(read_file "$REM/../spad !! 203 RVAL=$(read_spad "$REM/spad" $i) 269 204 270 if [[ "$VAL" -ne "$RVAL" ]]; t !! 205 if [[ "$VAL" != "$RVAL" ]]; then 271 echo "Scratchpad $i va !! 206 echo "Scratchpad doesn't match expected value $VAL " \ >> 207 "in $REM/spad, got $RVAL" >&2 272 exit -1 208 exit -1 273 fi 209 fi 274 done << 275 << 276 echo " Passed" << 277 } << 278 210 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 211 done 309 212 310 echo " Passed" 213 echo " Passed" 311 } 214 } 312 215 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() 216 function write_mw() 340 { 217 { 341 split_remote $2 218 split_remote $2 342 219 343 if [[ "$REMOTE" != "" ]]; then 220 if [[ "$REMOTE" != "" ]]; then 344 ssh "$REMOTE" \ 221 ssh "$REMOTE" \ 345 dd if=/dev/urandom "of 222 dd if=/dev/urandom "of=$VPATH" 2> /dev/null || true 346 else 223 else 347 dd if=/dev/urandom "of=$VPATH" 224 dd if=/dev/urandom "of=$VPATH" 2> /dev/null || true 348 fi 225 fi 349 } 226 } 350 227 351 function mw_check() !! 228 function mw_test() 352 { 229 { 353 IDX=$1 230 IDX=$1 354 LOC=$2 231 LOC=$2 355 REM=$3 232 REM=$3 356 233 357 write_mw "$LOC/mw$IDX" !! 234 echo "Running $IDX tests on: $(basename $LOC) / $(basename $REM)" >> 235 >> 236 write_mw "$LOC/$IDX" 358 237 359 split_remote "$LOC/mw$IDX" !! 238 split_remote "$LOC/$IDX" 360 if [[ "$REMOTE" == "" ]]; then 239 if [[ "$REMOTE" == "" ]]; then 361 A=$VPATH 240 A=$VPATH 362 else 241 else 363 A=/tmp/ntb_test.$$.A 242 A=/tmp/ntb_test.$$.A 364 ssh "$REMOTE" cat "$VPATH" > " 243 ssh "$REMOTE" cat "$VPATH" > "$A" 365 fi 244 fi 366 245 367 split_remote "$REM/peer_mw$IDX" !! 246 split_remote "$REM/peer_$IDX" 368 if [[ "$REMOTE" == "" ]]; then 247 if [[ "$REMOTE" == "" ]]; then 369 B=$VPATH 248 B=$VPATH 370 else 249 else 371 B=/tmp/ntb_test.$$.B 250 B=/tmp/ntb_test.$$.B 372 ssh "$REMOTE" cat "$VPATH" > " 251 ssh "$REMOTE" cat "$VPATH" > "$B" 373 fi 252 fi 374 253 375 cmp -n $MW_ALIGNED_SIZE "$A" "$B" !! 254 cmp -n $MW_SIZE "$A" "$B" 376 if [[ $? != 0 ]]; then 255 if [[ $? != 0 ]]; then 377 echo "Memory window $MW did no 256 echo "Memory window $MW did not match!" >&2 378 fi 257 fi 379 258 380 if [[ "$A" == "/tmp/*" ]]; then 259 if [[ "$A" == "/tmp/*" ]]; then 381 rm "$A" 260 rm "$A" 382 fi 261 fi 383 262 384 if [[ "$B" == "/tmp/*" ]]; then 263 if [[ "$B" == "/tmp/*" ]]; then 385 rm "$B" 264 rm "$B" 386 fi 265 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 266 >> 267 echo " Passed" 420 } 268 } 421 269 422 function pingpong_test() 270 function pingpong_test() 423 { 271 { 424 LOC=$1 272 LOC=$1 425 REM=$2 273 REM=$2 426 274 427 echo "Running ping pong tests on: $(ba 275 echo "Running ping pong tests on: $(basename $LOC) / $(basename $REM)" 428 276 429 LOC_START=$(read_file "$LOC/count") !! 277 LOC_START=$(read_file $LOC/count) 430 REM_START=$(read_file "$REM/count") !! 278 REM_START=$(read_file $REM/count) 431 279 432 sleep 7 280 sleep 7 433 281 434 LOC_END=$(read_file "$LOC/count") !! 282 LOC_END=$(read_file $LOC/count) 435 REM_END=$(read_file "$REM/count") !! 283 REM_END=$(read_file $REM/count) 436 284 437 if [[ $LOC_START == $LOC_END ]] || [[ 285 if [[ $LOC_START == $LOC_END ]] || [[ $REM_START == $REM_END ]]; then 438 echo "Ping pong counter not in 286 echo "Ping pong counter not incrementing!" >&2 439 exit 1 287 exit 1 440 fi 288 fi 441 289 442 echo " Passed" 290 echo " Passed" 443 } 291 } 444 292 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() 293 function perf_test() 470 { 294 { 471 USE_DMA=$1 295 USE_DMA=$1 472 296 473 if [[ $USE_DMA == "1" ]]; then 297 if [[ $USE_DMA == "1" ]]; then 474 WITH="with" 298 WITH="with" 475 else 299 else 476 WITH="without" 300 WITH="without" 477 fi 301 fi 478 302 479 _modprobe ntb_perf total_order=$PERF_R !! 303 _modprobe ntb_perf run_order=$PERF_RUN_ORDER \ 480 max_mw_size=$MAX_MW_SIZE use_d 304 max_mw_size=$MAX_MW_SIZE use_dma=$USE_DMA 481 305 482 echo "Running local perf test $WITH DM 306 echo "Running local perf test $WITH DMA" 483 write_file "$LOCAL_PIDX" "$LOCAL_PERF/ !! 307 write_file "" $LOCAL_PERF/run 484 echo -n " " 308 echo -n " " 485 read_file "$LOCAL_PERF/run" !! 309 read_file $LOCAL_PERF/run 486 echo " Passed" 310 echo " Passed" 487 311 488 echo "Running remote perf test $WITH D 312 echo "Running remote perf test $WITH DMA" 489 write_file "$REMOTE_PIDX" "$REMOTE_PER !! 313 write_file "" $REMOTE_PERF/run 490 echo -n " " 314 echo -n " " 491 read_file "$REMOTE_PERF/run" !! 315 read_file $REMOTE_PERF/run 492 echo " Passed" 316 echo " Passed" 493 317 494 _modprobe -r ntb_perf 318 _modprobe -r ntb_perf 495 } 319 } 496 320 497 function ntb_tool_tests() 321 function ntb_tool_tests() 498 { 322 { 499 LOCAL_TOOL="$DEBUGFS/ntb_tool/$LOCAL_D !! 323 LOCAL_TOOL=$DEBUGFS/ntb_tool/$LOCAL_DEV 500 REMOTE_TOOL="$REMOTE_HOST:$DEBUGFS/ntb !! 324 REMOTE_TOOL=$REMOTE_HOST:$DEBUGFS/ntb_tool/$REMOTE_DEV 501 325 502 echo "Starting ntb_tool tests..." 326 echo "Starting ntb_tool tests..." 503 327 504 _modprobe ntb_tool 328 _modprobe ntb_tool 505 329 506 port_test "$LOCAL_TOOL" "$REMOTE_TOOL" !! 330 write_file Y $LOCAL_TOOL/link_event 507 !! 331 write_file Y $REMOTE_TOOL/link_event 508 LOCAL_PEER_TOOL="$LOCAL_TOOL/peer$LOCA << 509 REMOTE_PEER_TOOL="$REMOTE_TOOL/peer$RE << 510 332 511 link_test "$LOCAL_PEER_TOOL" "$REMOTE_ !! 333 link_test $LOCAL_TOOL $REMOTE_TOOL 512 link_test "$REMOTE_PEER_TOOL" "$LOCAL_ !! 334 link_test $REMOTE_TOOL $LOCAL_TOOL 513 335 514 #Ensure the link is up on both sides b 336 #Ensure the link is up on both sides before continuing 515 write_file "Y" "$LOCAL_PEER_TOOL/link_ !! 337 write_file Y $LOCAL_TOOL/link_event 516 write_file "Y" "$REMOTE_PEER_TOOL/link !! 338 write_file Y $REMOTE_TOOL/link_event 517 339 518 doorbell_test "$LOCAL_TOOL" "$REMOTE_T !! 340 for PEER_TRANS in $(ls $LOCAL_TOOL/peer_trans*); do 519 doorbell_test "$REMOTE_TOOL" "$LOCAL_T !! 341 PT=$(basename $PEER_TRANS) >> 342 write_file $MW_SIZE $LOCAL_TOOL/$PT >> 343 write_file $MW_SIZE $REMOTE_TOOL/$PT >> 344 done 520 345 521 scratchpad_test "$LOCAL_PEER_TOOL" "$R !! 346 doorbell_test $LOCAL_TOOL $REMOTE_TOOL 522 scratchpad_test "$REMOTE_PEER_TOOL" "$ !! 347 doorbell_test $REMOTE_TOOL $LOCAL_TOOL >> 348 scratchpad_test $LOCAL_TOOL $REMOTE_TOOL >> 349 scratchpad_test $REMOTE_TOOL $LOCAL_TOOL 523 350 524 message_test "$LOCAL_PEER_TOOL" "$REMO !! 351 for MW in $(ls $LOCAL_TOOL/mw*); do 525 message_test "$REMOTE_PEER_TOOL" "$LOC !! 352 MW=$(basename $MW) 526 353 527 mw_test "$LOCAL_PEER_TOOL" "$REMOTE_PE !! 354 mw_test $MW $LOCAL_TOOL $REMOTE_TOOL 528 mw_test "$REMOTE_PEER_TOOL" "$LOCAL_PE !! 355 mw_test $MW $REMOTE_TOOL $LOCAL_TOOL >> 356 done 529 357 530 _modprobe -r ntb_tool 358 _modprobe -r ntb_tool 531 } 359 } 532 360 533 function ntb_pingpong_tests() 361 function ntb_pingpong_tests() 534 { 362 { 535 LOCAL_PP="$DEBUGFS/ntb_pingpong/$LOCAL !! 363 LOCAL_PP=$DEBUGFS/ntb_pingpong/$LOCAL_DEV 536 REMOTE_PP="$REMOTE_HOST:$DEBUGFS/ntb_p !! 364 REMOTE_PP=$REMOTE_HOST:$DEBUGFS/ntb_pingpong/$REMOTE_DEV 537 365 538 echo "Starting ntb_pingpong tests..." 366 echo "Starting ntb_pingpong tests..." 539 367 540 _modprobe ntb_pingpong 368 _modprobe ntb_pingpong 541 369 542 pingpong_test $LOCAL_PP $REMOTE_PP 370 pingpong_test $LOCAL_PP $REMOTE_PP 543 371 544 _modprobe -r ntb_pingpong 372 _modprobe -r ntb_pingpong 545 } 373 } 546 374 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() 375 function ntb_perf_tests() 571 { 376 { 572 LOCAL_PERF="$DEBUGFS/ntb_perf/$LOCAL_D !! 377 LOCAL_PERF=$DEBUGFS/ntb_perf/$LOCAL_DEV 573 REMOTE_PERF="$REMOTE_HOST:$DEBUGFS/ntb !! 378 REMOTE_PERF=$REMOTE_HOST:$DEBUGFS/ntb_perf/$REMOTE_DEV 574 379 575 echo "Starting ntb_perf tests..." 380 echo "Starting ntb_perf tests..." 576 381 577 perf_test 0 382 perf_test 0 578 383 579 if [[ $RUN_DMA_TESTS ]]; then 384 if [[ $RUN_DMA_TESTS ]]; then 580 perf_test 1 385 perf_test 1 581 fi 386 fi 582 } 387 } 583 388 584 function cleanup() 389 function cleanup() 585 { 390 { 586 set +e 391 set +e 587 _modprobe -r ntb_tool 2> /dev/null 392 _modprobe -r ntb_tool 2> /dev/null 588 _modprobe -r ntb_perf 2> /dev/null 393 _modprobe -r ntb_perf 2> /dev/null 589 _modprobe -r ntb_pingpong 2> /dev/null 394 _modprobe -r ntb_pingpong 2> /dev/null 590 _modprobe -r ntb_transport 2> /dev/nul 395 _modprobe -r ntb_transport 2> /dev/null 591 _modprobe -r ntb_msi_test 2> /dev/null << 592 set -e 396 set -e 593 } 397 } 594 398 595 cleanup 399 cleanup 596 400 597 if ! [[ $$DONT_CLEANUP ]]; then 401 if ! [[ $$DONT_CLEANUP ]]; then 598 trap cleanup EXIT 402 trap cleanup EXIT 599 fi 403 fi 600 404 601 if [ "$(id -u)" != "0" ]; then 405 if [ "$(id -u)" != "0" ]; then 602 echo "This script must be run as root" 406 echo "This script must be run as root" 1>&2 603 exit 1 407 exit 1 604 fi 408 fi 605 409 606 if [[ "$LIST_DEVS" == TRUE ]]; then 410 if [[ "$LIST_DEVS" == TRUE ]]; then 607 echo "Local Devices:" 411 echo "Local Devices:" 608 ls -1 /sys/bus/ntb/devices 412 ls -1 /sys/bus/ntb/devices 609 echo 413 echo 610 414 611 if [[ "$REMOTE_HOST" != "" ]]; then 415 if [[ "$REMOTE_HOST" != "" ]]; then 612 echo "Remote Devices:" 416 echo "Remote Devices:" 613 ssh $REMOTE_HOST ls -1 /sys/bu 417 ssh $REMOTE_HOST ls -1 /sys/bus/ntb/devices 614 fi 418 fi 615 419 616 exit 0 420 exit 0 617 fi 421 fi 618 422 619 if [[ "$LOCAL_DEV" == $"" ]] || [[ "$REMOTE_DE 423 if [[ "$LOCAL_DEV" == $"" ]] || [[ "$REMOTE_DEV" == $"" ]]; then 620 show_help 424 show_help 621 exit 1 425 exit 1 622 fi 426 fi 623 427 624 ntb_tool_tests 428 ntb_tool_tests 625 echo 429 echo 626 ntb_pingpong_tests 430 ntb_pingpong_tests 627 echo << 628 ntb_msi_tests << 629 echo 431 echo 630 ntb_perf_tests 432 ntb_perf_tests 631 echo 433 echo
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.