-
Notifications
You must be signed in to change notification settings - Fork 14
Reset tests #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Reset tests #35
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ocxl_reset_tests.sh | ||
| =================== | ||
|
|
||
| `ocxl_reset_tests.sh` is a script for testing the reset of an OpenCAPI card. | ||
|
|
||
| Requirements | ||
| ------------ | ||
|
|
||
| The OpenCAPI card must be flashed with either an IBM,AFP3 or IBM,MEMCPY3 AFU | ||
| image. | ||
|
|
||
| This test requires the kernel module pnv-php, that will be automatically | ||
| loaded. | ||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| $ ../../afuobj/ocxl_reset_tests.sh # Reset the first card and check AFU | ||
|
|
||
| ``` | ||
| Usage: ocxl_reset_tests [ options ] | ||
| Options: | ||
| -d <device> Use this capi card | ||
| -l <loops> Run this number of resets (default 1) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Copyright 2019 International Business Machines | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| # ocxl_reset_tests.sh | ||
| # | ||
| # This test assumes that user is root and memcpy afu is programmed. | ||
|
|
||
| function usage | ||
| { | ||
| echo 'ocxl_reset_tests.sh [-d <device_path>] [-l <loops>]' >&2 | ||
| exit 2 | ||
| } | ||
|
|
||
| device= | ||
| loops=1 # default | ||
|
|
||
| while true | ||
| do | ||
| case $1 in | ||
| ('') break ;; | ||
| (-d) device=$2; shift 2 || break ;; | ||
| (-l) loops=$2; shift 2 || break ;; | ||
| (*) usage ;; | ||
| esac | ||
| done | ||
| (( $# == 0 )) || usage | ||
|
|
||
| [[ $device == -* ]] && usage | ||
| (( loops < 1 )) && usage | ||
|
|
||
| if [[ $device ]] | ||
| then | ||
| if ! ls "$device" >/dev/null 2>&1 | ||
| then | ||
| echo ocxl_reset_tests.sh: "$device": no such device >&2 | ||
| exit 2 | ||
| fi | ||
| card=${device##*/} | ||
| fi | ||
|
|
||
| if [[ -z $card ]] | ||
| then | ||
| # find first IBM,AFP3 or IBM,MEMCPY3 opencapi card | ||
| card=$( | ||
| set -- $(ls /dev/ocxl/$card 2>/dev/null) | ||
| for i | ||
| do | ||
| case $i in | ||
| (*IBM,AFP3*) echo $i; break ;; | ||
| (*IBM,MEMCPY3*) echo $i; break ;; | ||
| esac | ||
| done | ||
| ) | ||
| fi | ||
|
|
||
| if [[ -z $card ]] | ||
| then | ||
| echo ocxl_reset_tests.sh: could not find afu IBM,AFP3 nor IBM,MEMCPY3 >&2 | ||
| exit 3 | ||
| fi | ||
|
|
||
| # load module pnv-php | ||
| if ! modprobe pnv-php | ||
| then | ||
| echo ocxl_reset_tests.sh: cannot load module pnv-php >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| slot=${card#*.} | ||
| slot=${slot%%:*} | ||
| slot=/sys/bus/pci/slots/OPENCAPI-$slot | ||
|
|
||
| for ((i = 0; i < loops; i++)) | ||
| do | ||
| ((loops > 1)) && echo Loop: $((i+1))/$loops | ||
|
|
||
| echo ocxl_reset_tests.sh: resetting card $card | ||
| if ! echo 0 > $slot/power | ||
| then | ||
| echo ocxl_reset_tests.sh: could not write to $slot/power | ||
| exit 4 | ||
| fi | ||
|
|
||
| if ! echo 1 > $slot/power | ||
| then | ||
| echo ocxl_reset_tests.sh: could not write to $slot/power | ||
| exit 5 | ||
| fi | ||
|
|
||
| echo ocxl_reset_tests.sh: card $card has been reset | ||
|
|
||
| case $card in | ||
| (*,AFP3.*) | ||
| ocxl_afp3=$(which ocxl_afp3 2>/dev/null) | ||
| [[ $ocxl_afp3 ]] || ocxl_afp3=${0%/*}/ocxl_afp3 | ||
|
|
||
| if [[ ! -x $ocxl_afp3 ]] | ||
| then | ||
| echo ocxl_reset_tests.sh: could not find test program $ocxl_afp3 | ||
| echo ocxl_reset_tests.sh: skipping IBM,AFP3 afu check | ||
| else | ||
| echo ocxl_reset_tests.sh: verifying afu IBM,AFP3 | ||
|
|
||
| if ! "$ocxl_afp3" >/tmp/ocxl_reset_afp3.log | ||
| then | ||
| echo ocxl_reset_tests.sh: ocxl_afp3 fails after reset | ||
| exit 6 | ||
| fi | ||
| fi ;; | ||
| (*,MEMCPY3.*) | ||
| ocxl_memcpy=$(which ocxl_memcpy 2>/dev/null) | ||
| [[ $ocxl_memcpy ]] || ocxl_memcpy=${0%/*}/ocxl_memcpy | ||
|
|
||
| if [[ ! -x $ocxl_memcpy ]] | ||
| then | ||
| echo ocxl_reset_tests.sh: could not find test program $ocxl_memcpy | ||
| echo ocxl_reset_tests.sh: skipping IBM,MEMCPY3 afu check | ||
| else | ||
| echo ocxl_reset_tests.sh: verifying afu IBM,MEMCPY3 | ||
|
|
||
| if ! "$ocxl_memcpy" -p0 -l10000 >/tmp/ocxl_reset_memcpy.log | ||
| then | ||
| echo ocxl_reset_tests.sh: ocxl_memcpy fails after reset | ||
| exit 7 | ||
| fi | ||
| fi ;; | ||
| esac | ||
| done | ||
|
|
||
| echo ocxl_reset_tests.sh: ocxl_reset test passes | ||
| exit 0 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $card here seems spurious, as $card is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks