Skip to content

Commit

Permalink
Adding PIM reset feature to wedge_power.sh
Browse files Browse the repository at this point in the history
Summary:
[YAMP] Adding PIM reset feature to wedge_power.sh
Internal logic for this is totally different from that of Accton Minipack,
but we still add the same UI (the same script parameter) as Minipack for tool compatibility

Test Plan: Tested on MPK17 Glacier #17

Reviewed By: benwei13

fbshipit-source-id: 08999f67e
  • Loading branch information
mikechoifb authored and facebook-github-bot committed Oct 23, 2018
1 parent 31b8a48 commit 299a3d8
Showing 1 changed file with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ usage() {
echo " options:"
echo " -s: Power reset whole yamp system ungracefully"
echo
echo " pimreset: Power-cycle one or all PIM(s)"
echo " options:"
echo " -a : Reset all PIMs or "
echo " -2 , -3 , ... , -9 : Reset a single PIM (2, 3 ... 9) "
echo
}

do_status() {
Expand Down Expand Up @@ -137,6 +142,81 @@ do_reset() {
fi
}

toggle_pim_reset() {
pim=$1
# First, put the PIMs we want into reset
for slot in 2 3 4 5 6 7 8 9; do
if [ $pim -eq 0 ] || [ $slot -eq $pim ]; then
# Unlike Minipack, YAMP pim index is 1 based
index=$(expr $slot - 1)
# Unlike Minipack, YAMP uses GPIO
echo Power-cycling PIM in slot $slot
echo out > /tmp/gpionames/LC${index}_LC_PWR_CYC/direction
echo high > /tmp/gpionames/LC${index}_LC_PWR_CYC/direction
fi
done
# Sleep 1 sec
sleep 1
# Finally, put the LC_PWR_CYC bit to 0
for slot in 2 3 4 5 6 7 8 9; do
if [ $pim -eq 0 ] || [ $slot -eq $pim ]; then
# Unlike Minipack, YAMP pim index is 1 based
index=$(expr $slot - 1)
# Unlike Minipack, YAMP uses GPIO
echo Putting PIM in $slot into normal operation
echo low > /tmp/gpionames/LC${index}_LC_PWR_CYC/direction
fi
done
}
do_pimreset() {
local pim opt retval rc
retval=0
pim=-1
while getopts "23456789a" opt; do
case $opt in
a)
pim=0
;;
2)
pim=2
;;
3)
pim=3
;;
4)
pim=4
;;
5)
pim=5
;;
6)
pim=6
;;
7)
pim=7
;;
8)
pim=8
;;
9)
pim=9
;;
*)
usage
exit -1
;;
esac
done
if [ $pim -eq -1 ]; then
usage
exit -1
fi

toggle_pim_reset $pim

return $retval
}

if [ $# -lt 1 ]; then
usage
exit -1
Expand All @@ -158,6 +238,9 @@ case "$command" in
reset)
do_reset $@
;;
pimreset)
do_pimreset $@
;;
*)
usage
exit -1
Expand Down

0 comments on commit 299a3d8

Please sign in to comment.