Skip to content
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

[arista] Backport watchdog support for all products #2106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Type=oneshot
RemainAfterExit=true

ExecStart=
ExecStart=/usr/bin/arista-gardena-watchdog --stop
ExecStart=/usr/bin/arista-watchdog -l --stop

ExecStop=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include /usr/share/dpkg/pkg-info.mk
export INSTALL_MOD_DIR:=extra

SCRIPT_FILES := reset
BIN_FILES := arista boot-eos arista-gardena-watchdog
BIN_FILES := arista boot-eos arista-watchdog
SERVICE_FILES := gardena-watchdog-stop.service

KVERSION ?= $(shell uname -r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ drivers_start() {
if grep -q sid=Gardena /proc/cmdline; then
timeout=600
echo "Enabling watchdog for $timeout seconds"
/usr/bin/arista-gardena-watchdog -o $timeout
/usr/bin/arista-watchdog -l -o $timeout
fi
/usr/bin/arista --syslog -l /var/log/arista.log setup --reset --background
echo "done."
Expand Down
39 changes: 33 additions & 6 deletions ...ules-arista/utils/arista-gardena-watchdog → ...form-modules-arista/utils/arista-watchdog
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ def status( scd ):
"timeout": timeout,
}

def getCmdline():
data = {}
with open( '/proc/cmdline' ) as f:
for entry in f.read().split():
idx = entry.find( '=' )
if idx == -1:
data[ entry ] = None
else:
data[ entry[ :idx ] ] = entry[ idx + 1: ]
return data

def getResource():
cmdline = getCmdline()
platform = cmdline.get( 'platform' )
if platform == 'rook':
return '/sys/bus/pci/devices/0000:06:00.0/resource0'
if platform == 'crow':
return '/sys/bus/pci/devices/0000:02:00.0/resource0'
if platform == 'raven':
return '/sys/bus/pci/devices/0000:04:00.0/resource0'
assert False, "Failed to detect platform"
return None

def main():
parser = argparse.ArgumentParser()
parser.add_argument( '-o', '--arm', type=int,
Expand All @@ -108,15 +131,18 @@ def main():
help='Disable the watchdog' )
parser.add_argument( '--status', action='store_true',
help='Show watchdog status' )
parser.add_argument( '-l', '--klog', action='store_true',
help='Print the events in the dmesg' )
args = parser.parse_args()

if not args.arm and not args.stop and not args.status:
print( 'No option specified' )
sys.exit( 1 )

busName = "/sys/bus/pci/devices/0000:06:00.0/resource0"
subprocess.call( [ 'modprobe', 'scd' ] )
scd = MmapResource( busName )
if not os.path.isdir( '/sys/module/scd' ):
subprocess.call( [ 'modprobe', 'scd' ] )

scd = MmapResource( getResource() )

scdScrRegTest( scd )

Expand All @@ -126,17 +152,18 @@ def main():
print( 'watchdog: %s' % kv )
sys.exit( 0 )


time = 0
if args.arm:
klog( 'watchdog: arm for %ds' % args.arm )
if args.klog:
klog( 'watchdog: arm for %ds' % args.arm )
# Tens of milliseconds
time = args.arm * 100
if time >= 65536:
print( 'Error Time value is too big' )
sys.exit( 1 )
else:
klog( 'watchdog: disable' )
if args.klog:
klog( 'watchdog: disable' )

arm( scd, time )

Expand Down