summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-02-09 15:23:53 -0800
committerWilliam A. Kennington III <wak@google.com>2018-02-15 12:29:37 -0800
commit61d5f7bcd892b9f546ad5b19ad96238110602743 (patch)
treef2ae22a7015499fbaf0407213f4e851ebde084a6 /app
parentce6a795a8ecc7755290ea4bcef4bf3340a331b49 (diff)
downloadphosphor-host-ipmid-61d5f7bcd892b9f546ad5b19ad96238110602743.zip
phosphor-host-ipmid-61d5f7bcd892b9f546ad5b19ad96238110602743.tar.gz
watchdog: Reorganize header and function names
This is a refactoring of names + header cleanup and has no functional change. Change-Id: Ie90fded80b6a26927f56bb342993193530b8b8ef Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'app')
-rw-r--r--app/watchdog.cpp196
-rw-r--r--app/watchdog.hpp17
2 files changed, 107 insertions, 106 deletions
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index 6870aaa..c8c9ced 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -21,104 +21,7 @@ static constexpr auto objname = "/xyz/openbmc_project/watchdog/host0";
static constexpr auto iface = "xyz.openbmc_project.State.Watchdog";
static constexpr auto property_iface = "org.freedesktop.DBus.Properties";
-ipmi_ret_t ipmi_app_set_watchdog(
- ipmi_netfn_t netfn,
- ipmi_cmd_t cmd,
- ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t data_len,
- ipmi_context_t context)
-{
- sd_bus_message *reply = NULL;
- sd_bus_error error = SD_BUS_ERROR_NULL;
- int r = 0;
- ipmi_ret_t ret = IPMI_CC_UNSPECIFIED_ERROR;
-
- set_wd_data_t *reqptr = (set_wd_data_t*) request;
-
- uint16_t timer = 0;
-
- // Making this uint64_t to match with provider
- uint64_t timer_ms = 0;
- char *busname = NULL;
- *data_len = 0;
-
- // Get number of 100ms intervals
- timer = (((uint16_t)reqptr->ms) << 8) + reqptr->ls;
- // Get timer value in ms
- timer_ms = timer * 100;
-
- printf("WATCHDOG SET Timer:[0x%X] 100ms intervals\n",timer);
-
- // Get bus name
- r = mapper_get_service(bus, objname, &busname);
- if (r < 0) {
- fprintf(stderr, "Failed to get %s bus name: %s\n",
- objname, strerror(-r));
- ret = IPMI_CC_BUSY;
- goto finish;
- }
-
- // Disable watchdog if running
- r = sd_bus_call_method(bus, busname, objname, property_iface,
- "Set", &error, &reply, "ssv",
- iface, "Enabled", "b", false);
- if(r < 0) {
- fprintf(stderr, "Failed to disable Watchdog: %s\n",
- strerror(-r));
- ret = IPMI_CC_BUSY;
- goto finish;
- }
-
- /*
- * If the action is 0, it means, do nothing. Multiple actions on timer
- * expiration aren't supported by phosphor-watchdog yet, so when the
- * action set is "none", we should just leave the timer disabled.
- */
- if (0 == reqptr->timer_action)
- {
- ret = IPMI_CC_OK;
- goto finish;
- }
-
- if (reqptr->timer_use & 0x40)
- {
- sd_bus_error_free(&error);
- reply = sd_bus_message_unref(reply);
-
- // Set the Interval for the Watchdog
- r = sd_bus_call_method(bus, busname, objname, property_iface,
- "Set", &error, &reply, "ssv",
- iface, "Interval", "t", timer_ms);
- if(r < 0) {
- fprintf(stderr, "Failed to set new expiration time: %s\n",
- strerror(-r));
- ret = IPMI_CC_BUSY;
- goto finish;
- }
-
- // Now Enable Watchdog
- r = sd_bus_call_method(bus, busname, objname, property_iface,
- "Set", &error, &reply, "ssv",
- iface, "Enabled", "b", true);
- if(r < 0) {
- fprintf(stderr, "Failed to Enable Watchdog: %s\n",
- strerror(-r));
- ret = IPMI_CC_BUSY;
- goto finish;
- }
- }
-
- ret = IPMI_CC_OK;
-finish:
- sd_bus_error_free(&error);
- reply = sd_bus_message_unref(reply);
- free(busname);
-
- return ret;
-}
-
-ipmi_ret_t ipmi_app_reset_watchdog(
+ipmi_ret_t ipmi_app_watchdog_reset(
ipmi_netfn_t netfn,
ipmi_cmd_t cmd,
ipmi_request_t request,
@@ -222,3 +125,100 @@ finish:
return ret;
}
+
+ipmi_ret_t ipmi_app_watchdog_set(
+ ipmi_netfn_t netfn,
+ ipmi_cmd_t cmd,
+ ipmi_request_t request,
+ ipmi_response_t response,
+ ipmi_data_len_t data_len,
+ ipmi_context_t context)
+{
+ sd_bus_message *reply = NULL;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ int r = 0;
+ ipmi_ret_t ret = IPMI_CC_UNSPECIFIED_ERROR;
+
+ set_wd_data_t *reqptr = (set_wd_data_t*) request;
+
+ uint16_t timer = 0;
+
+ // Making this uint64_t to match with provider
+ uint64_t timer_ms = 0;
+ char *busname = NULL;
+ *data_len = 0;
+
+ // Get number of 100ms intervals
+ timer = (((uint16_t)reqptr->ms) << 8) + reqptr->ls;
+ // Get timer value in ms
+ timer_ms = timer * 100;
+
+ printf("WATCHDOG SET Timer:[0x%X] 100ms intervals\n",timer);
+
+ // Get bus name
+ r = mapper_get_service(bus, objname, &busname);
+ if (r < 0) {
+ fprintf(stderr, "Failed to get %s bus name: %s\n",
+ objname, strerror(-r));
+ ret = IPMI_CC_BUSY;
+ goto finish;
+ }
+
+ // Disable watchdog if running
+ r = sd_bus_call_method(bus, busname, objname, property_iface,
+ "Set", &error, &reply, "ssv",
+ iface, "Enabled", "b", false);
+ if(r < 0) {
+ fprintf(stderr, "Failed to disable Watchdog: %s\n",
+ strerror(-r));
+ ret = IPMI_CC_BUSY;
+ goto finish;
+ }
+
+ /*
+ * If the action is 0, it means, do nothing. Multiple actions on timer
+ * expiration aren't supported by phosphor-watchdog yet, so when the
+ * action set is "none", we should just leave the timer disabled.
+ */
+ if (0 == reqptr->timer_action)
+ {
+ ret = IPMI_CC_OK;
+ goto finish;
+ }
+
+ if (reqptr->timer_use & 0x40)
+ {
+ sd_bus_error_free(&error);
+ reply = sd_bus_message_unref(reply);
+
+ // Set the Interval for the Watchdog
+ r = sd_bus_call_method(bus, busname, objname, property_iface,
+ "Set", &error, &reply, "ssv",
+ iface, "Interval", "t", timer_ms);
+ if(r < 0) {
+ fprintf(stderr, "Failed to set new expiration time: %s\n",
+ strerror(-r));
+ ret = IPMI_CC_BUSY;
+ goto finish;
+ }
+
+ // Now Enable Watchdog
+ r = sd_bus_call_method(bus, busname, objname, property_iface,
+ "Set", &error, &reply, "ssv",
+ iface, "Enabled", "b", true);
+ if(r < 0) {
+ fprintf(stderr, "Failed to Enable Watchdog: %s\n",
+ strerror(-r));
+ ret = IPMI_CC_BUSY;
+ goto finish;
+ }
+ }
+
+ ret = IPMI_CC_OK;
+finish:
+ sd_bus_error_free(&error);
+ reply = sd_bus_message_unref(reply);
+ free(busname);
+
+ return ret;
+}
diff --git a/app/watchdog.hpp b/app/watchdog.hpp
index f434493..c09bd1c 100644
--- a/app/watchdog.hpp
+++ b/app/watchdog.hpp
@@ -1,6 +1,8 @@
-#include "ipmid.hpp"
+#pragma once
-/** @brief The SET watchdog IPMI command.
+#include "host-ipmid/ipmid-api.h"
+
+/** @brief The RESET watchdog IPMI command.
*
* @param[in] netfn
* @param[in] cmd
@@ -9,9 +11,9 @@
* @param[out] data_len
* @param[in] context
*
- * @return IPMI_CC_OK on success, -1 otherwise.
+ * @return IPMI_CC_OK on success, an IPMI error code otherwise.
*/
-ipmi_ret_t ipmi_app_set_watchdog(
+ipmi_ret_t ipmi_app_watchdog_reset(
ipmi_netfn_t netfn,
ipmi_cmd_t cmd,
ipmi_request_t request,
@@ -19,7 +21,7 @@ ipmi_ret_t ipmi_app_set_watchdog(
ipmi_data_len_t data_len,
ipmi_context_t context);
-/** @brief The RESET watchdog IPMI command.
+/** @brief The SET watchdog IPMI command.
*
* @param[in] netfn
* @param[in] cmd
@@ -28,13 +30,12 @@ ipmi_ret_t ipmi_app_set_watchdog(
* @param[out] data_len
* @param[in] context
*
- * @return IPMI_CC_OK on success, -1 otherwise.
+ * @return IPMI_CC_OK on success, an IPMI error code otherwise.
*/
-ipmi_ret_t ipmi_app_reset_watchdog(
+ipmi_ret_t ipmi_app_watchdog_set(
ipmi_netfn_t netfn,
ipmi_cmd_t cmd,
ipmi_request_t request,
ipmi_response_t response,
ipmi_data_len_t data_len,
ipmi_context_t context);
-
OpenPOWER on IntegriCloud