meta-fii: meta-mori: Add watchdog support with fallback
Add watchdog service to monitor the host status and execute the expire
actions when host doesn't reset the watchdog timer.
Add fallback support to the watchdog with the interval set to 10
minutes. Timer is reset with changes to host boot progress. If the host
fails to reset the watchdog, then the watchdog action is performed
with fallback to AC cycle after 10 minutes.
Signed-off-by: Vincent Chou <Vincent.Chou@fii-na.com>
Change-Id: Id0905ebc72405713806bbe2d803e6ca559488495
diff --git a/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog/obmc/watchdog/host0 b/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog/obmc/watchdog/host0
new file mode 100644
index 0000000..466f08d
--- /dev/null
+++ b/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog/obmc/watchdog/host0
@@ -0,0 +1,8 @@
+DEVPATH=/xyz/openbmc_project/watchdog/host0
+SERVICE=xyz.openbmc_project.Watchdog
+UNIT_HARD_RESET=ampere-host-power-cycle.service
+UNIT_POWER_OFF=ampere-chassis-poweroff.service
+UNIT_POWER_CYCLE=ampere-chassis-powercycle.service
+FALLBACK_ACTION=xyz.openbmc_project.State.Watchdog.Action.PowerCycle
+FALLBACK_INTERVAL=600000
+MIN_INTERVAL=60000
diff --git a/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog.service b/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog.service
new file mode 100644
index 0000000..003f479
--- /dev/null
+++ b/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog/phosphor-watchdog.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Phosphor Watchdog
+
+[Service]
+EnvironmentFile={envfiledir}/obmc/watchdog/host0
+
+ExecStart=phosphor-watchdog --service=${{SERVICE}} --path=${{DEVPATH}} --watch_postcodes \
+ --continue --fallback_always --min_interval=${{MIN_INTERVAL}} \
+ --fallback_action=${{FALLBACK_ACTION}} --fallback_interval=${{FALLBACK_INTERVAL}} \
+ --action_target=xyz.openbmc_project.State.Watchdog.Action.HardReset=${{UNIT_HARD_RESET}} \
+ --action_target=xyz.openbmc_project.State.Watchdog.Action.PowerOff=${{UNIT_POWER_OFF}} \
+ --action_target=xyz.openbmc_project.State.Watchdog.Action.PowerCycle=${{UNIT_POWER_CYCLE}} \
+
+# This should use state manager instead of the service files currently defined
+
+SyslogIdentifier=phosphor-watchdog
+BusName=xyz.openbmc_project.Watchdog
+Type=dbus
+
+[Install]
+WantedBy=basic.target
diff --git a/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend b/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend
new file mode 100644
index 0000000..6a70555
--- /dev/null
+++ b/meta-fii/meta-mori/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend
@@ -0,0 +1,9 @@
+FILESEXTRAPATHS:prepend:mori := "${THISDIR}/${PN}:"
+SYSTEMD_ENVIRONMENT_FILE:${PN}:append:mori = " obmc/watchdog/host0"
+
+SYSTEMD_LINK:${PN}:remove:mori = "${@compose_list(d, 'ENABLE_WATCHDOG_FMT', 'OBMC_HOST_INSTANCES')}"
+SYSTEMD_LINK:${PN}:remove:mori = "${@compose_list(d, 'WATCHDOG_FMT', 'OBMC_HOST_WATCHDOG_INSTANCES', 'OBMC_HOST_INSTANCES')}"
+# Remove the override to keep service running after DC cycle
+SYSTEMD_OVERRIDE_${PN}:remove:mori = "poweron.conf:phosphor-watchdog@poweron.service.d/poweron.conf"
+SYSTEMD_SERVICE:${PN}:mori = " phosphor-watchdog.service \
+ "