summaryrefslogtreecommitdiff
path: root/lib/ipmi_dcmi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipmi_dcmi.c')
-rw-r--r--[-rwxr-xr-x]lib/ipmi_dcmi.c1265
1 files changed, 689 insertions, 576 deletions
diff --git a/lib/ipmi_dcmi.c b/lib/ipmi_dcmi.c
index 2cfe48f..8ed87a9 100755..100644
--- a/lib/ipmi_dcmi.c
+++ b/lib/ipmi_dcmi.c
@@ -36,7 +36,6 @@
* This code conforms to the 1.0 DCMI Specification
* released by Hari Ramachandran of the Intel Corporation
*/
-#define _BSD_SOURCE
#include <stdlib.h>
#include <string.h>
@@ -57,6 +56,7 @@
#include <ipmitool/ipmi_entity.h>
#include <ipmitool/ipmi_constants.h>
#include <ipmitool/ipmi_sensor.h>
+#include <ipmitool/ipmi_time.h>
#include "../src/plugins/lanplus/lanplus.h"
@@ -74,31 +74,40 @@ static int ipmi_print_sensor_info(struct ipmi_intf *intf, uint16_t rec_id);
* to change a lot of the code in the main(). *
******************************************************************************/
+/*
+ * This is a termination macro for all struct dcmi_cmd arrays,
+ * def argument is the default value returned by str2val2()
+ * when string is not found in the array
+ */
+#define DCMI_CMD_END(def) { (def), NULL, NULL }
+
/* Main set of DCMI commands */
const struct dcmi_cmd dcmi_cmd_vals[] = {
- { 0x00, "discover", " Used to discover supported DCMI capabilities" },
- { 0x01, "power", " Platform power limit command options" },
- { 0x02, "sensors", " Prints the available DCMI sensors" },
- { 0x03, "asset_tag", " Prints the platform's asset tag" },
- { 0x04, "set_asset_tag", " Sets the platform's asset tag" },
- { 0x05, "get_mc_id_string", " Get management controller ID string" },
- { 0x06, "set_mc_id_string", " Set management controller ID string" },
- { 0x07, "thermalpolicy", " Thermal policy get/set" },
- { 0x08, "get_temp_reading", " Get Temperature Readings" },
- { 0x09, "get_conf_param", " Get DCMI Config Parameters" },
- { 0x0A, "set_conf_param", " Set DCMI Config Parameters" },
- { 0x0B, "oob_discover", " Ping/Pong Message for DCMI Discovery" },
- { 0xFF, NULL, NULL }
+ { 0x00, "discover", "Used to discover supported DCMI capabilities" },
+ { 0x01, "power", "Platform power limit command options" },
+ { 0x02, "sensors", "Prints the available DCMI sensors" },
+ { 0x03, "asset_tag", "Prints the platform's asset tag" },
+ { 0x04, "set_asset_tag", "Sets the platform's asset tag" },
+ { 0x05, "get_mc_id_string", "Get management controller ID string" },
+ { 0x06, "set_mc_id_string", "Set management controller ID string" },
+ { 0x07, "thermalpolicy", "Thermal policy get/set" },
+ { 0x08, "get_temp_reading", "Get Temperature Readings" },
+ { 0x09, "get_conf_param", "Get DCMI Config Parameters" },
+ { 0x0A, "set_conf_param", "Set DCMI Config Parameters" },
+ { 0x0B, "oob_discover", "Ping/Pong Message for DCMI Discovery" },
+
+ DCMI_CMD_END(0xFF)
};
-/* get capabilites */
+/* get capabilities */
const struct dcmi_cmd dcmi_capable_vals[] = {
- { 0x01, "platform", " Lists the system capabilities" },
+ { 0x01, "platform", "Lists the system capabilities" },
{ 0x02, "mandatory_attributes", "Lists SEL, identification and"
- "temperature attributes" },
- { 0x03, "optional_attributes", " Lists power capabilities" },
- { 0x04, "managebility access", " Lists OOB channel information" },
- { 0xFF, NULL, NULL }
+ "temperature attributes" },
+ { 0x03, "optional_attributes", "Lists power capabilities" },
+ { 0x04, "managebility access", "Lists OOB channel information" },
+
+ DCMI_CMD_END(0xFF)
};
/* platform capabilities
@@ -107,54 +116,60 @@ const struct dcmi_cmd dcmi_capable_vals[] = {
*/
const struct dcmi_cmd dcmi_mandatory_platform_capabilities[] = {
{ 0x01, "Identification support available", "" },
- { 0x02, "SEL logging available", "" },
- { 0x03, "Chassis power available", "" },
- { 0x04, "Temperature monitor available", "" },
- { 0xFF, NULL, NULL }
+ { 0x02, "SEL logging available", "" },
+ { 0x03, "Chassis power available", "" },
+ { 0x04, "Temperature monitor available", "" },
+
+ DCMI_CMD_END(0xFF)
};
/* optional capabilities */
const struct dcmi_cmd dcmi_optional_platform_capabilities[] = {
- { 0x01, "Power management available", "" },
- { 0xFF, NULL, NULL }
+ { 0x01, "Power management available", "" },
+
+ DCMI_CMD_END(0xFF)
};
-/* access capabilties */
+/* access capabilities */
const struct dcmi_cmd dcmi_management_access_capabilities[] = {
- { 0x01, "In-band KCS channel available", "" },
- { 0x02, "Out-of-band serial TMODE available", "" },
+ { 0x01, "In-band KCS channel available", "" },
+ { 0x02, "Out-of-band serial TMODE available", "" },
{ 0x03, "Out-of-band secondary LAN channel available", "" },
- { 0x04, "Out-of-band primary LAN channel available", "" },
- { 0x05, "SOL enabled", "" },
- { 0x06, "VLAN capable", "" },
- { 0xFF, NULL, NULL }
+ { 0x04, "Out-of-band primary LAN channel available", "" },
+ { 0x05, "SOL enabled", "" },
+ { 0x06, "VLAN capable", "" },
+
+ DCMI_CMD_END(0xFF)
};
/* identification capabilities */
const struct dcmi_cmd dcmi_id_capabilities_vals[] = {
- { 0x01, "GUID", "" },
+ { 0x01, "GUID", "" },
{ 0x02, "DHCP hostname", "" },
- { 0x03, "Asset tag", "" },
- { 0xFF, NULL, NULL }
+ { 0x03, "Asset tag", "" },
+
+ DCMI_CMD_END(0xFF)
};
/* Configuration parameters*/
const struct dcmi_cmd dcmi_conf_param_vals[] = {
- { 0x01, "activate_dhcp", "\tActivate DHCP"},
- { 0x02, "dhcp_config", "\tDHCP Configuration" },
- { 0x03, "init", "\t\tInitial timeout interval" },
- { 0x04, "timeout", "\t\tServer contact timeout interval" },
- { 0x05, "retry", "\t\tServer contact retry interval" },
- { 0xFF, NULL, NULL }
+ { 0x01, "activate_dhcp", "\tActivate DHCP" },
+ { 0x02, "dhcp_config", "\tDHCP Configuration" },
+ { 0x03, "init", "\t\tInitial timeout interval" },
+ { 0x04, "timeout", "\t\tServer contact timeout interval" },
+ { 0x05, "retry", "\t\tServer contact retry interval" },
+
+ DCMI_CMD_END(0xFF)
};
/* temperature monitoring capabilities */
const struct dcmi_cmd dcmi_temp_monitoring_vals[] = {
- { 0x01, "inlet", " Inlet air temperature sensors" },
- { 0x02, "cpu", " CPU temperature sensors" },
- { 0x03, "baseboard", "Baseboard temperature sensors" },
- { 0xff, NULL, NULL }
+ { 0x01, "inlet", "Inlet air temperature sensors" },
+ { 0x02, "cpu", "CPU temperature sensors" },
+ { 0x03, "baseboard", "Baseboard temperature sensors" },
+
+ DCMI_CMD_END(0xFF)
};
/* These are not comands. These are the DCMI temp sensors and their numbers
@@ -162,113 +177,121 @@ const struct dcmi_cmd dcmi_temp_monitoring_vals[] = {
* sensor number
*/
const struct dcmi_cmd dcmi_discvry_snsr_vals[] = {
- { 0x40, "Inlet", " Inlet air temperature sensors" },
- { 0x41, "CPU", " CPU temperature sensors" },
- { 0x42, "Baseboard", "Baseboard temperature sensors" },
- { 0xff, NULL, NULL }
+ { 0x40, "Inlet", "Inlet air temperature sensors" },
+ { 0x41, "CPU", "CPU temperature sensors" },
+ { 0x42, "Baseboard", "Baseboard temperature sensors" },
+
+ DCMI_CMD_END(0xFF)
};
/* Temperature Readings */
const struct dcmi_cmd dcmi_temp_read_vals[] = {
- { 0x40, "Inlet", "Inlet air temperature(40h) " },
- { 0x41, "CPU", "CPU temperature sensors(41h) " },
- { 0x42, "Baseboard", "Baseboard temperature sensors(42h) " },
- { 0xff, NULL, NULL }
+ { 0x40, "Inlet", "Inlet air temperature(40h)" },
+ { 0x41, "CPU", "CPU temperature sensors(41h)" },
+ { 0x42, "Baseboard", "Baseboard temperature sensors(42h)" },
+
+ DCMI_CMD_END(0xFF)
};
/* power management/control commands */
const struct dcmi_cmd dcmi_pwrmgmt_vals[] = {
- { 0x00, "reading", " Get power related readings from the system" },
- { 0x01, "get_limit", " Get the configured power limits" },
- { 0x02, "set_limit", " Set a power limit option" },
- { 0x03, "activate", " Activate the set power limit" },
- { 0x04, "deactivate", "Deactivate the set power limit" },
- { 0xFF, NULL, NULL }
+ { 0x00, "reading", "Get power related readings from the system" },
+ { 0x01, "get_limit", "Get the configured power limits" },
+ { 0x02, "set_limit", "Set a power limit option" },
+ { 0x03, "activate", "Activate the set power limit" },
+ { 0x04, "deactivate", "Deactivate the set power limit" },
+
+ DCMI_CMD_END(0xFF)
};
/* set power limit commands */
const struct dcmi_cmd dcmi_pwrmgmt_set_usage_vals[] = {
- { 0x00, "action", " <no_action | sel_logging | power_off>" },
- { 0x01, "limit", " <number in Watts>" },
+ { 0x00, "action", "<no_action | sel_logging | power_off>" },
+ { 0x01, "limit", "<number in Watts>" },
{ 0x02, "correction", "<number in milliseconds>" },
- { 0x03, "sample", " <number in seconds>" },
- { 0xFF, NULL, NULL }
+ { 0x03, "sample", "<number in seconds>" },
+
+ DCMI_CMD_END(0xFF)
};
/* power management/get action commands */
const struct dcmi_cmd dcmi_pwrmgmt_get_action_vals[] = {
- { 0x00, "No Action", ""},
- { 0x01, "Hard Power Off & Log Event to SEL", ""},
-
- { 0x02, "OEM reserved (02h)", ""},
- { 0x03, "OEM reserved (03h)", ""},
- { 0x04, "OEM reserved (04h)", ""},
- { 0x05, "OEM reserved (05h)", ""},
- { 0x06, "OEM reserved (06h)", ""},
- { 0x07, "OEM reserved (07h)", ""},
- { 0x08, "OEM reserved (08h)", ""},
- { 0x09, "OEM reserved (09h)", ""},
- { 0x0a, "OEM reserved (0ah)", ""},
- { 0x0b, "OEM reserved (0bh)", ""},
- { 0x0c, "OEM reserved (0ch)", ""},
- { 0x0d, "OEM reserved (0dh)", ""},
- { 0x0e, "OEM reserved (0eh)", ""},
- { 0x0f, "OEM reserved (0fh)", ""},
- { 0x10, "OEM reserved (10h)", ""},
-
- { 0x11, "Log Event to SEL", ""},
- { 0xFF, NULL, NULL }
+ { 0x00, "No Action", "" },
+ { 0x01, "Hard Power Off & Log Event to SEL", "" },
+
+ { 0x02, "OEM reserved (02h)", "" },
+ { 0x03, "OEM reserved (03h)", "" },
+ { 0x04, "OEM reserved (04h)", "" },
+ { 0x05, "OEM reserved (05h)", "" },
+ { 0x06, "OEM reserved (06h)", "" },
+ { 0x07, "OEM reserved (07h)", "" },
+ { 0x08, "OEM reserved (08h)", "" },
+ { 0x09, "OEM reserved (09h)", "" },
+ { 0x0a, "OEM reserved (0ah)", "" },
+ { 0x0b, "OEM reserved (0bh)", "" },
+ { 0x0c, "OEM reserved (0ch)", "" },
+ { 0x0d, "OEM reserved (0dh)", "" },
+ { 0x0e, "OEM reserved (0eh)", "" },
+ { 0x0f, "OEM reserved (0fh)", "" },
+ { 0x10, "OEM reserved (10h)", "" },
+
+ { 0x11, "Log Event to SEL", "" },
+
+ DCMI_CMD_END(0xFF)
};
/* power management/set action commands */
const struct dcmi_cmd dcmi_pwrmgmt_action_vals[] = {
- { 0x00, "no_action", "No Action"},
- { 0x01, "power_off", "Hard Power Off & Log Event to SEL"},
- { 0x11, "sel_logging", "Log Event to SEL"},
-
- { 0x02, "oem_02", "OEM reserved (02h)"},
- { 0x03, "oem_03", "OEM reserved (03h)"},
- { 0x04, "oem_04", "OEM reserved (04h)"},
- { 0x05, "oem_05", "OEM reserved (05h)"},
- { 0x06, "oem_06", "OEM reserved (06h)"},
- { 0x07, "oem_07", "OEM reserved (07h)"},
- { 0x08, "oem_08", "OEM reserved (08h)"},
- { 0x09, "oem_09", "OEM reserved (09h)"},
- { 0x0a, "oem_0a", "OEM reserved (0ah)"},
- { 0x0b, "oem_0b", "OEM reserved (0bh)"},
- { 0x0c, "oem_0c", "OEM reserved (0ch)"},
- { 0x0d, "oem_0d", "OEM reserved (0dh)"},
- { 0x0e, "oem_0e", "OEM reserved (0eh)"},
- { 0x0f, "oem_0f", "OEM reserved (0fh)"},
- { 0x10, "oem_10", "OEM reserved (10h)"},
-
- { 0xFF, NULL, NULL }
+ { 0x00, "no_action", "No Action" },
+ { 0x01, "power_off", "Hard Power Off & Log Event to SEL" },
+ { 0x11, "sel_logging", "Log Event to SEL" },
+
+ { 0x02, "oem_02", "OEM reserved (02h)" },
+ { 0x03, "oem_03", "OEM reserved (03h)" },
+ { 0x04, "oem_04", "OEM reserved (04h)" },
+ { 0x05, "oem_05", "OEM reserved (05h)" },
+ { 0x06, "oem_06", "OEM reserved (06h)" },
+ { 0x07, "oem_07", "OEM reserved (07h)" },
+ { 0x08, "oem_08", "OEM reserved (08h)" },
+ { 0x09, "oem_09", "OEM reserved (09h)" },
+ { 0x0a, "oem_0a", "OEM reserved (0ah)" },
+ { 0x0b, "oem_0b", "OEM reserved (0bh)" },
+ { 0x0c, "oem_0c", "OEM reserved (0ch)" },
+ { 0x0d, "oem_0d", "OEM reserved (0dh)" },
+ { 0x0e, "oem_0e", "OEM reserved (0eh)" },
+ { 0x0f, "oem_0f", "OEM reserved (0fh)" },
+ { 0x10, "oem_10", "OEM reserved (10h)" },
+
+ DCMI_CMD_END(0xFF)
};
/* thermal policy action commands */
const struct dcmi_cmd dcmi_thermalpolicy_vals[] = {
- { 0x00, "get", "Get thermal policy" },
- { 0x01, "set", "Set thermal policy" },
- { 0xFF, NULL, NULL }
+ { 0x00, "get", "Get thermal policy" },
+ { 0x01, "set", "Set thermal policy" },
+
+ DCMI_CMD_END(0xFF)
};
/* thermal policy action commands */
const struct dcmi_cmd dcmi_confparameters_vals[] = {
- { 0x00, "get", "Get configuration parameters" },
- { 0x01, "set", "Set configuration parameters" },
- { 0xFF, NULL, NULL }
+ { 0x00, "get", "Get configuration parameters" },
+ { 0x01, "set", "Set configuration parameters" },
+
+ DCMI_CMD_END(0xFF)
};
/* entityIDs used in thermap policy */
const struct dcmi_cmd dcmi_thermalpolicy_set_parameters_vals[] = {
- { 0x00, "volatile", " Current Power Cycle" },
- { 0x01, "nonvolatile", "Set across power cycles" },
- { 0x01, "poweroff", " Hard Power Off system" },
- { 0x00, "nopoweroff", " No 'Hard Power Off' action" },
- { 0x01, "sel", " Log event to SEL" },
- { 0x00, "nosel", " No 'Log event to SEL' action" },
- { 0x00, "disabled", " Disabled" },
- { 0x00, NULL, NULL }
+ { 0x00, "volatile", "Current Power Cycle" },
+ { 0x01, "nonvolatile", "Set across power cycles" },
+ { 0x01, "poweroff", "Hard Power Off system" },
+ { 0x00, "nopoweroff", "No 'Hard Power Off' action" },
+ { 0x01, "sel", "Log event to SEL" },
+ { 0x00, "nosel", "No 'Log event to SEL' action" },
+ { 0x00, "disabled", "Disabled" },
+
+ DCMI_CMD_END(0)
};
@@ -301,54 +324,59 @@ const struct valstr dcmi_ccode_vals[] = {
*/
const struct dcmi_cmd dcmi_sampling_vals[] = {
- { 0x05, "5_sec", "" },
+ { 0x05, "5_sec", "" },
{ 0x0f, "15_sec", "" },
{ 0x1E, "30_sec", "" },
- { 0x41, "1_min", "" },
- { 0x43, "3_min", "" },
- { 0x47, "7_min", "" },
+ { 0x41, "1_min", "" },
+ { 0x43, "3_min", "" },
+ { 0x47, "7_min", "" },
{ 0x4F, "15_min", "" },
{ 0x5E, "30_min", "" },
- { 0x81, "1_hour", ""},
- { 0x00, NULL, NULL },
+ { 0x81, "1_hour", "" },
+
+ DCMI_CMD_END(0)
};
/* Primary Node Manager commands */
const struct dcmi_cmd nm_cmd_vals[] = {
- { 0x00, "discover", "Discover Node Manager " },
+ { 0x00, "discover", "Discover Node Manager" },
{ 0x01, "capability", "Get Node Manager Capabilities" },
- { 0x02, "control", "Enable/Disable Policy Control" },
- { 0x03, "policy", "Add/Remove Policies" },
+ { 0x02, "control", "Enable/Disable Policy Control" },
+ { 0x03, "policy", "Add/Remove Policies" },
{ 0x04, "statistics", "Get Statistics" },
- { 0x05, "power", "Set Power Draw Range" },
- { 0x06, "suspend", "Set/Get Policy suspend periods" },
- { 0x07, "reset", "Reset Statistics" },
- { 0x08, "alert", "Set/Get/Clear Alert destination" },
- { 0x09, "threshold", "Set/Get Alert Thresholds" },
- { 0xFF, NULL, NULL },
+ { 0x05, "power", "Set Power Draw Range" },
+ { 0x06, "suspend", "Set/Get Policy suspend periods" },
+ { 0x07, "reset", "Reset Statistics" },
+ { 0x08, "alert", "Set/Get/Clear Alert destination" },
+ { 0x09, "threshold", "Set/Get Alert Thresholds" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_ctl_cmds[] = {
- { 0x01, "enable", " <control scope>" },
- { 0x00, "disable", "<control scope>"},
- { 0xFF, NULL, NULL },
+ { 0x01, "enable", "<control scope>" },
+ { 0x00, "disable", "<control scope>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_ctl_domain[] = {
- { 0x00, "global", "" },
+ { 0x00, "global", "" },
{ 0x02, "per_domain", "<platform|CPU|Memory> (default is platform)" },
- { 0x04, "per_policy", "<0-7>" },
- { 0xFF, NULL, NULL },
+ { 0x04, "per_policy", "<0-255>" },
+
+ DCMI_CMD_END(0xFF),
};
/* Node Manager Domain codes */
const struct dcmi_cmd nm_domain_vals[] = {
- { 0x00, "platform", "" },
- { 0x01, "CPU", "" },
- { 0x02, "Memory", "" },
+ { 0x00, "platform", "" },
+ { 0x01, "CPU", "" },
+ { 0x02, "Memory", "" },
{ 0x03, "protection", "" },
- { 0x04, "I/O", "" },
- { 0xFF, NULL, NULL },
+ { 0x04, "I/O", "" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_version_vals[] = {
@@ -357,76 +385,90 @@ const struct dcmi_cmd nm_version_vals[] = {
{ 0x03, "2.0", "" },
{ 0x04, "2.5", "" },
{ 0x05, "3.0", "" },
- { 0xFF, NULL, NULL },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_capability_opts[] = {
- { 0x01, "domain", "<platform|CPU|Memory> (default is platform)" },
- { 0x02, "inlet", "Inlet temp trigger" },
+ { 0x01, "domain", "<platform|CPU|Memory> (default is platform)" },
+ { 0x02, "inlet", "Inlet temp trigger" },
{ 0x03, "missing", "Missing Power reading trigger" },
- { 0x04, "reset", "Time after Host reset trigger" },
- { 0x05, "boot", "Boot time policy" },
- { 0xFF, NULL, NULL },
+ { 0x04, "reset", "Time after Host reset trigger" },
+ { 0x05, "boot", "Boot time policy" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_policy_type_vals[] = {
- { 0x00, "No trigger, use Power Limit", "" },
- { 0x01, "Inlet temp trigger", "" },
- { 0x02, "Missing Power reading trigger", "" },
- { 0x03, "Time after Host reset trigger", "" },
+ { 0x00, "No trigger, use Power Limit", "" },
+ { 0x01, "Inlet temp trigger", "" },
+ { 0x02, "Missing Power reading trigger", "" },
+ { 0x03, "Time after Host reset trigger", "" },
{ 0x04, "number of cores to disable at boot time", "" },
- { 0xFF, NULL, NULL },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_stats_opts[] = {
- { 0x01, "domain", "<platform|CPU|Memory> (default is platform)" },
- { 0x02, "policy_id", "<0-7>" },
- { 0xFF, NULL, NULL },
+ { 0x01, "domain", "<platform|CPU|Memory> (default is platform)" },
+ { 0x02, "policy_id", "<0-255>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_stats_mode[] = {
- { 0x01, "power", "global power" },
- { 0x02, "temps", "inlet temperature" },
- { 0x11, "policy_power", "per policy power" },
- { 0x12, "policy_temps", "per policy inlet temp" },
- { 0x13, "policy_throt", "per policy throttling stats" },
- { 0x1B, "requests", "unhandled requests" },
- { 0x1C, "response", "response time" },
+ { 0x01, "power", "global power" },
+ { 0x02, "temps", "inlet temperature" },
+ { 0x11, "policy_power", "per policy power" },
+ { 0x12, "policy_temps", "per policy inlet temp" },
+ { 0x13, "policy_throt", "per policy throttling stats" },
+ { 0x1B, "requests", "unhandled requests" },
+ { 0x1C, "response", "response time" },
{ 0x1D, "cpu_throttling", "CPU throttling" },
{ 0x1E, "mem_throttling", "memory throttling" },
- { 0x1F, "comm_fail", "host communication failures" },
- { 0xFF, NULL, NULL },
+ { 0x1F, "comm_fail", "host communication failures" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_policy_action[] = {
- { 0x00, "get", "nm policy get policy_id <0-7> [domain <platform|CPU|Memory>]" },
- { 0x04, "add", "nm policy add policy_id <0-7> [domain <platform|CPU|Memory>] correction auto|soft|hard power <watts>|inlet <temp> trig_lim <param> stats <seconds> enable|disable" },
- { 0x05, "remove", "nm policy remove policy_id <0-7> [domain <platform|CPU|Memory>]" },
+ { 0x00, "get", "nm policy get policy_id <0-255> "
+ "[domain <platform|CPU|Memory>]" },
+ { 0x04, "add", "nm policy add policy_id <0-255> "
+ "[domain <platform|CPU|Memory>] "
+ "correction auto|soft|hard power <watts> | "
+ "inlet <temp> trig_lim <param> "
+ "stats <seconds> enable|disable" },
+ { 0x05, "remove", "nm policy remove policy_id <0-255> "
+ "[domain <platform|CPU|Memory>]" },
{ 0x06, "limiting", "nm policy limiting [domain <platform|CPU|Memory>]" },
- { 0xFF, NULL, NULL },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_policy_options[] = {
- { 0x01, "enable", "" },
- { 0x02, "disable", "" },
- { 0x03, "domain", "" },
- { 0x04, "inlet", "inlet air temp full limiting (SCRAM)"},
- { 0x06, "correction", "auto, soft, hard" },
- { 0x08, "power", "power limit in watts" },
- { 0x09, "trig_lim", "time to send alert" },
- { 0x0A, "stats", "moving window averaging time" },
+ { 0x01, "enable", "" },
+ { 0x02, "disable", "" },
+ { 0x03, "domain", "" },
+ { 0x04, "inlet", "inlet air temp full limiting (SCRAM)" },
+ { 0x06, "correction","auto, soft, hard" },
+ { 0x08, "power", "power limit in watts" },
+ { 0x09, "trig_lim", "time to send alert" },
+ { 0x0A, "stats", "moving window averaging time" },
{ 0x0B, "policy_id", "policy number" },
- { 0x0C, "volatile", "save policy in volatiel memory" },
+ { 0x0C, "volatile", "save policy in volatiel memory" },
{ 0x0D, "cores_off", "at boot time, disable N cores" },
- { 0xFF, NULL, NULL },
+
+ DCMI_CMD_END(0xFF),
};
/* if "trigger" command used from nm_policy_options */
const struct dcmi_cmd nm_trigger[] = {
- { 0x00, "none", "" },
- { 0x01, "temp", "" },
+ { 0x00, "none", "" },
+ { 0x01, "temp", "" },
{ 0x02, "reset", "" },
- { 0x03, "boot", "" },
- { 0xFF, NULL, NULL },
+ { 0x03, "boot", "" },
+
+ DCMI_CMD_END(0xFF),
};
/* if "correction" used from nm_policy_options */
@@ -434,86 +476,105 @@ const struct dcmi_cmd nm_correction[] = {
{ 0x00, "auto", "" },
{ 0x01, "soft", "" },
{ 0x02, "hard", "" },
- { 0xFF, NULL, NULL },
+
+ DCMI_CMD_END(0xFF),
};
/* returned codes from get policy */
const struct dcmi_cmd nm_correction_vals[] = {
{ 0x00, "no T-state use", "" },
{ 0x01, "no T-state use", "" },
- { 0x02, "use T-states", "" },
- { 0xFF, NULL, NULL },
+ { 0x02, "use T-states", "" },
+
+ DCMI_CMD_END(0xFF),
};
/* if "exception" used from nm_policy_options */
const struct dcmi_cmd nm_exception[] = {
- { 0x00, "none", "" },
- { 0x01, "alert", "" },
+ { 0x00, "none", "" },
+ { 0x01, "alert", "" },
{ 0x02, "shutdown", "" },
- { 0xFF, NULL, NULL },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_reset_mode[] = {
- { 0x00, "global", "" },
+ { 0x00, "global", "" },
{ 0x01, "per_policy", "" },
- { 0x1B, "requests", "" },
- { 0x1C, "response", "" },
+ { 0x1B, "requests", "" },
+ { 0x1C, "response", "" },
{ 0x1D, "throttling", "" },
- { 0x1E, "memory", "", },
- { 0x1F, "comm", "" },
- { 0xFF, NULL, NULL },
+ { 0x1E, "memory", "" },
+ { 0x1F, "comm", "" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_power_range[] = {
{ 0x01, "domain", "domain <platform|CPU|Memory> (default is platform)" },
- { 0x02, "min", " min <integer value>" },
- { 0x03, "max", "max <integer value>" },
- { 0xFF, NULL, NULL },
+ { 0x02, "min", "min <integer value>" },
+ { 0x03, "max", "max <integer value>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_alert_opts[] = {
- { 0x01, "set", "nm alert set chan <chan> dest <dest> string <string>" },
- { 0x02, "get", "nm alert get" },
+ { 0x01, "set", "nm alert set chan <chan> dest <dest> string <string>" },
+ { 0x02, "get", "nm alert get" },
{ 0x03, "clear", "nm alert clear dest <dest>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_set_alert_param[] = {
- { 0x01, "chan", "chan <channel>" },
- { 0x02, "dest", "dest <destination>" },
+ { 0x01, "chan", "chan <channel>" },
+ { 0x02, "dest", "dest <destination>" },
{ 0x03, "string", "string <string>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_thresh_cmds[] = {
- { 0x01, "set", "nm thresh set [domain <platform|CPU|Memory>] policy_id <policy> thresh_array" },
- { 0x02, "get", "nm thresh get [domain <platform|CPU|Memory>] policy_id <policy>" },
+ { 0x01, "set", "nm thresh set [domain <platform|CPU|Memory>] "
+ "policy_id <policy> thresh_array" },
+ { 0x02, "get", "nm thresh get [domain <platform|CPU|Memory>] "
+ "policy_id <policy>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_thresh_param[] = {
- { 0x01, "domain", "<platform|CPU|Memory> (default is platform)" },
- { 0x02, "policy_id", "<0-7>" },
- { 0xFF, NULL, NULL },
+ { 0x01, "domain", "<platform|CPU|Memory> (default is platform)" },
+ { 0x02, "policy_id", "<0-255>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct dcmi_cmd nm_suspend_cmds[] = {
- { 0x01, "set", "nm suspend set [domain <platform|CPU|Memory]> policy_id <policy> <start> <stop> <pattern>" },
- { 0x02, "get", "nm suspend get [domain <platform|CPU|Memory]> policy_id <policy>" },
+ { 0x01, "set", "nm suspend set [domain <platform|CPU|Memory]> "
+ "policy_id <policy> <start> "
+ "<stop> <pattern>" },
+ { 0x02, "get", "nm suspend get [domain <platform|CPU|Memory]> "
+ "policy_id <policy>" },
+
+ DCMI_CMD_END(0xFF),
};
const struct valstr nm_ccode_vals[] = {
- { 0x80, "Policy ID Invalid"},
- { 0x81, "Domain ID Invalid"},
- { 0x82, "Unknown policy trigger type"},
- { 0x84, "Power Limit out of range"},
- { 0x85, "Correction Time out of range"},
- { 0x86, "Policy Trigger value out of range"},
- { 0x88, "Invalid Mode"},
- { 0x89, "Statistics Reporting Period out of range"},
- { 0x8B, "Invalid value for Aggressive CPU correction field"},
- { 0xA1, "No policy is currently limiting for the specified domain ID"},
- { 0xC4, "No space available"},
- { 0xD4, "Insufficient privledge level due wrong responder LUN"},
- { 0xD5, "Policy exists and param unchangeable while enabled"},
- { 0xD6, "Command subfunction disabled or unavailable"},
+ { 0x80, "Policy ID Invalid" },
+ { 0x81, "Domain ID Invalid" },
+ { 0x82, "Unknown policy trigger type" },
+ { 0x84, "Power Limit out of range" },
+ { 0x85, "Correction Time out of range" },
+ { 0x86, "Policy Trigger value out of range" },
+ { 0x88, "Invalid Mode" },
+ { 0x89, "Statistics Reporting Period out of range" },
+ { 0x8B, "Invalid value for Aggressive CPU correction field" },
+ { 0xA1, "No policy is currently limiting for the specified domain ID" },
+ { 0xC4, "No space available" },
+ { 0xD4, "Insufficient privilege level due wrong responder LUN" },
+ { 0xD5, "Policy exists and param unchangeable while enabled" },
+ { 0xD6, "Command subfunction disabled or unavailable" },
{ 0xFF, NULL },
};
@@ -533,20 +594,20 @@ const struct valstr nm_ccode_vals[] = {
*/
void
print_strs(const struct dcmi_cmd * vs, const char * title, int loglevel,
- int verthorz)
+ int verthorz)
{
int i;
- if (vs == NULL)
+ if (!vs)
return;
- if (title != NULL) {
+ if (title) {
if (loglevel < 0)
printf("\n%s\n", title);
else
lprintf(loglevel, "\n%s", title);
}
- for (i = 0; vs[i].str != NULL; i++) {
+ for (i = 0; vs[i].str; i++) {
if (loglevel < 0) {
if (vs[i].val < 256)
if (verthorz == 0)
@@ -566,7 +627,7 @@ print_strs(const struct dcmi_cmd * vs, const char * title, int loglevel,
/* Check to see if this is NOT the last element in vs.str if true
* print the | else don't print anything.
*/
- if ((verthorz == 1) && (vs[i+1].str != NULL))
+ if (verthorz == 1 && vs[i+1].str)
printf(" | ");
}
if (verthorz == 0) {
@@ -590,14 +651,12 @@ uint16_t
str2val2(const char *str, const struct dcmi_cmd *vs)
{
int i;
- if (vs == NULL || str == NULL) {
+ if (!vs || !str) {
return 0;
}
- for (i = 0; vs[i].str != NULL; i++) {
- if (strncasecmp(vs[i].str, str,
- __maxlen(str, vs[i].str)) == 0) {
+ for (i = 0; vs[i].str; i++) {
+ if (strcasecmp(vs[i].str, str) == 0)
return vs[i].val;
- }
}
return vs[i].val;
}
@@ -616,10 +675,10 @@ val2str2(uint16_t val, const struct dcmi_cmd *vs)
static char un_str[32];
int i;
- if (vs == NULL)
+ if (!vs)
return NULL;
- for (i = 0; vs[i].str != NULL; i++) {
+ for (i = 0; vs[i].str; i++) {
if (vs[i].val == val)
return vs[i].str;
}
@@ -637,7 +696,7 @@ chk_rsp(struct ipmi_rs * rsp)
/* if the response from the intf is NULL then the BMC is experiencing
* some issue and cannot complete the command
*/
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "\n Unable to get DCMI information");
return 1;
}
@@ -647,16 +706,17 @@ chk_rsp(struct ipmi_rs * rsp)
*/
if ((rsp->ccode >= 0x80) && (rsp->ccode <= 0x8F)) {
lprintf(LOG_ERR, "\n DCMI request failed because: %s (%x)",
- val2str(rsp->ccode, dcmi_ccode_vals), rsp->ccode);
+ val2str(rsp->ccode, dcmi_ccode_vals), rsp->ccode);
return 1;
- } else if (rsp->ccode > 0) {
+ } else if (rsp->ccode) {
lprintf(LOG_ERR, "\n DCMI request failed because: %s (%x)",
- val2str(rsp->ccode, completion_code_vals), rsp->ccode);
+ val2str(rsp->ccode, completion_code_vals), rsp->ccode);
return 1;
}
/* check to make sure this is a DCMI firmware */
if(rsp->data[0] != IPMI_DCMI) {
- printf("\n A valid DCMI command was not returned! (%x)", rsp->data[0]);
+ printf("\n A valid DCMI command was not returned! (%x)",
+ rsp->data[0]);
return 1;
}
return 0;
@@ -671,7 +731,7 @@ chk_nm_rsp(struct ipmi_rs * rsp)
/* if the response from the intf is NULL then the BMC is experiencing
* some issue and cannot complete the command
*/
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "\n No response to NM request");
return 1;
}
@@ -683,7 +743,7 @@ chk_nm_rsp(struct ipmi_rs * rsp)
lprintf(LOG_ERR, "\n NM request failed because: %s (%x)",
val2str(rsp->ccode, nm_ccode_vals), rsp->ccode);
return 1;
- } else if (rsp->ccode > 0) {
+ } else if (rsp->ccode) {
lprintf(LOG_ERR, "\n NM request failed because: %s (%x)",
val2str(rsp->ccode, completion_code_vals), rsp->ccode);
return 1;
@@ -753,11 +813,11 @@ ipmi_dcmi_prnt_oobDiscover(struct ipmi_intf * intf)
# else
struct ipmi_session_params *p;
- if (intf->opened == 0 && intf->open != NULL) {
+ if (intf->opened == 0 && intf->open) {
if (intf->open(intf) < 0)
return (-1);
}
- if (intf == NULL || intf->session == NULL)
+ if (!intf || !intf->session)
return -1;
p = &intf->ssn_params;
@@ -771,7 +831,7 @@ ipmi_dcmi_prnt_oobDiscover(struct ipmi_intf * intf)
if (p->retry == 0)
p->retry = IPMI_LAN_RETRY;
- if (p->hostname == NULL || strlen((const char *)p->hostname) == 0) {
+ if (!p->hostname || strlen((const char *)p->hostname) == 0) {
lprintf(LOG_ERR, "No hostname specified!");
return -1;
}
@@ -786,7 +846,7 @@ ipmi_dcmi_prnt_oobDiscover(struct ipmi_intf * intf)
if (intf->fd < 0) {
lperror(LOG_ERR, "Connect to %s failed",
- p->hostname);
+ p->hostname);
intf->close(intf);
return -1;
}
@@ -822,16 +882,17 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
memcpy(&reply, rsp->data, sizeof (reply));
/* check to make sure that this is a 1.0/1.1/1.5 command */
if ((cape.conformance != IPMI_DCMI_CONFORM)
- && (cape.conformance != IPMI_DCMI_1_1_CONFORM)
- && (cape.conformance != IPMI_DCMI_1_5_CONFORM)) {
+ && (cape.conformance != IPMI_DCMI_1_1_CONFORM)
+ && (cape.conformance != IPMI_DCMI_1_5_CONFORM))
+ {
lprintf(LOG_ERR,
- "ERROR! This command is not available on this platform");
+ "ERROR! This command is not available on this platform");
return -1;
}
/* check to make sure that this is a rev .01 or .02 */
if (cape.revision != 0x01 && cape.revision != 0x02) {
lprintf(LOG_ERR,
- "ERROR! This command is not compatible with this version");
+ "ERROR! This command is not compatible with this version");
return -1;
}
/* 0x01 - platform capabilities
@@ -847,21 +908,21 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
/* loop through each of the entries in the first byte from the
* struct
*/
- printf("\n Mandatory platform capabilties\n");
- display_capabilities_attributes(
- dcmi_mandatory_platform_capabilities, cape.data_byte1);
+ printf("\n Mandatory platform capabilities\n");
+ display_capabilities_attributes(dcmi_mandatory_platform_capabilities,
+ cape.data_byte1);
/* loop through each of the entries in the second byte from the
* struct
*/
- printf("\n Optional platform capabilties\n");
- display_capabilities_attributes(
- dcmi_optional_platform_capabilities, cape.data_byte2);
+ printf("\n Optional platform capabilities\n");
+ display_capabilities_attributes(dcmi_optional_platform_capabilities,
+ cape.data_byte2);
/* loop through each of the entries in the third byte from the
* struct
*/
- printf("\n Managebility access capabilties\n");
- display_capabilities_attributes(
- dcmi_management_access_capabilities, cape.data_byte3);
+ printf("\n Managebility access capabilities\n");
+ display_capabilities_attributes(dcmi_management_access_capabilities,
+ cape.data_byte3);
break;
case 0x02:
printf("\n Mandatory platform attributes:\n");
@@ -885,12 +946,12 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
printf("\n %d SEL entries\n", sel_entries & 0xFFF);
/* byte 3 data */
printf("\n Identification Attributes: \n");
- display_capabilities_attributes(
- dcmi_id_capabilities_vals, cape.data_byte3);
+ display_capabilities_attributes(dcmi_id_capabilities_vals,
+ cape.data_byte3);
/* byte 4 data */
printf("\n Temperature Monitoring Attributes: \n");
display_capabilities_attributes(dcmi_temp_monitoring_vals,
- cape.data_byte4);
+ cape.data_byte4);
break;
case 0x03:
printf("\n Optional Platform Attributes: \n");
@@ -900,19 +961,19 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
printf(" Slave address of device: 20h (BMC)\n" );
} else {
printf(" Slave address of device: %xh (8bits)"
- "(Satellite/External controller)\n",
- cape.data_byte1);
+ "(Satellite/External controller)\n",
+ cape.data_byte1);
}
/* Controller channel number (4-7) bits */
if ((cape.data_byte2>>4) == 0x00) {
printf(" Channel number is 0h (Primary BMC)\n");
} else {
printf(" Channel number is %xh \n",
- (cape.data_byte2>>4));
+ (cape.data_byte2 >> 4));
}
/* Device revision (0-3) */
printf(" Device revision is %d \n",
- cape.data_byte2 &0xf);
+ cape.data_byte2 & 0xf);
break;
case 0x04:
/* LAN */
@@ -921,20 +982,20 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
printf(" Primary LAN channel is not available for OOB\n");
} else {
printf(" Primary LAN channel number: %d is available\n",
- cape.data_byte1);
+ cape.data_byte1);
}
if (cape.data_byte2 == 0xFF) {
printf(" Secondary LAN channel is not available for OOB\n");
} else {
printf(" Secondary LAN channel number: %d is available\n",
- cape.data_byte2);
+ cape.data_byte2);
}
/* serial */
if (cape.data_byte3 == 0xFF) {
printf(" No serial channel is available\n");
} else {
printf(" Serial channel number: %d is available\n",
- cape.data_byte3);
+ cape.data_byte3);
}
break;
case 0x05:
@@ -943,7 +1004,7 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
printf(" DCMI Specification %d.%d\n", reply[1], reply[2]);
printf(" Rolling average time period options: %d\n", reply[4]);
printf(" Sample time options: ");
- for (j = 1; dcmi_sampling_vals[j-1].str != NULL; j++)
+ for (j = 1; dcmi_sampling_vals[j-1].str; j++)
printf(" %s ", val2str2(reply[4+j],dcmi_sampling_vals));
printf("\n");
break;
@@ -1008,13 +1069,14 @@ ipmi_dcmi_prnt_getassettag(struct ipmi_intf * intf)
taglength = rsp->data[1];
printf("\n Asset tag: ");
while (taglength) {
- getlength = taglength / DCMI_MAX_BYTE_SIZE ?
- DCMI_MAX_BYTE_SIZE : taglength%DCMI_MAX_BYTE_SIZE;
+ /* TODO: Add parentheses for clarity */
+ getlength = taglength / DCMI_MAX_BYTE_SIZE ? DCMI_MAX_BYTE_SIZE
+ : taglength % DCMI_MAX_BYTE_SIZE;
rsp = ipmi_dcmi_getassettag(intf, offset, getlength);
/* macro has no effect here where can generate sig segv
* if rsp occurs with null
*/
- if (rsp != NULL) {
+ if (rsp) {
GOOD_ASSET_TAG_CCODE(rsp->ccode);
}
if (chk_rsp(rsp)) {
@@ -1081,8 +1143,9 @@ ipmi_dcmi_prnt_setassettag(struct ipmi_intf * intf, uint8_t * data)
}
printf("\n Set Asset Tag: ");
while (taglength) {
- getlength = taglength / DCMI_MAX_BYTE_SIZE ?
- DCMI_MAX_BYTE_SIZE : taglength%DCMI_MAX_BYTE_SIZE;
+ /* TODO: Use a macro or an inline for this repeating calculation */
+ getlength = taglength / DCMI_MAX_BYTE_SIZE ? DCMI_MAX_BYTE_SIZE
+ : taglength % DCMI_MAX_BYTE_SIZE;
memcpy(tmpData, data + offset, getlength);
rsp = ipmi_dcmi_setassettag(intf, offset, getlength, tmpData);
if (chk_rsp(rsp)) {
@@ -1146,8 +1209,9 @@ ipmi_dcmi_prnt_getmngctrlids(struct ipmi_intf * intf)
printf("\n Get Management Controller Identifier String: ");
while (taglength) {
- getlength = taglength / DCMI_MAX_BYTE_SIZE ?
- DCMI_MAX_BYTE_SIZE : taglength%DCMI_MAX_BYTE_SIZE;
+ /* TODO: Use a macro or an inline for this repeating calculation */
+ getlength = taglength / DCMI_MAX_BYTE_SIZE ? DCMI_MAX_BYTE_SIZE
+ : taglength % DCMI_MAX_BYTE_SIZE;
rsp = ipmi_dcmi_getmngctrlids(intf, offset, getlength);
if (chk_rsp(rsp)) {
@@ -1223,14 +1287,15 @@ ipmi_dcmi_prnt_setmngctrlids(struct ipmi_intf * intf, uint8_t * data)
printf("\n Set Management Controller Identifier String Command: ");
while (taglength) {
- getlength = taglength / DCMI_MAX_BYTE_SIZE ?
- DCMI_MAX_BYTE_SIZE : taglength%DCMI_MAX_BYTE_SIZE;
+ /* TODO: Use a macro or an inline for this repeating calculation */
+ getlength = taglength / DCMI_MAX_BYTE_SIZE ? DCMI_MAX_BYTE_SIZE
+ : taglength % DCMI_MAX_BYTE_SIZE;
memcpy(tmpData, data + offset, getlength);
rsp = ipmi_dcmi_setmngctrlids(intf, offset, getlength, tmpData);
/* because after call "Set mc id string" RMCP+ will go down
* we have no "rsp"
*/
- if (strncmp(intf->name, "lanplus", 7)) {
+ if (strcmp(intf->name, "lanplus")) {
if (chk_rsp(rsp)) {
return -1;
}
@@ -1250,7 +1315,7 @@ ipmi_dcmi_prnt_setmngctrlids(struct ipmi_intf * intf, uint8_t * data)
*
* @intf: ipmi interface handler
* @isnsr: entity ID
- * @offset: offset (Entity instace start)
+ * @offset: offset (Entity instance start)
*
* returns ipmi_rs structure
*/
@@ -1264,7 +1329,7 @@ ipmi_dcmi_discvry_snsr(struct ipmi_intf * intf, uint8_t isnsr, uint8_t offset)
msg_data[1] = 0x01; /* Senser Type = Temp (01h) */
msg_data[2] = isnsr; /* Sensor Number */
msg_data[3] = 0x00; /* Entity Instance, set to read all instances */
- msg_data[4] = offset; /* Entity instace start */
+ msg_data[4] = offset; /* Entity instance start */
memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_DCGRP;
@@ -1299,9 +1364,9 @@ ipmi_dcmi_prnt_discvry_snsr(struct ipmi_intf * intf, uint8_t isnsr)
}
instances = rsp->data[1];
printf("\n%s: %d temperature sensor%s found:\n",
- val2str2(isnsr, dcmi_discvry_snsr_vals),
- instances,
- (instances > 1) ? "s" : "");
+ val2str2(isnsr, dcmi_discvry_snsr_vals),
+ instances,
+ (instances > 1) ? "s" : "");
while(instances > 0) {
ipmi_dcmi_discvry_snsr(intf, isnsr, offset);
if (chk_rsp(rsp)) {
@@ -1335,11 +1400,7 @@ ipmi_dcmi_pwr_rd(struct ipmi_intf * intf, uint8_t sample_time)
struct ipmi_rs * rsp;
struct ipmi_rq req;
struct power_reading val;
- struct tm tm_t;
- time_t t;
uint8_t msg_data[4]; /* number of request data bytes */
- memset(&tm_t, 0, sizeof(tm_t));
- memset(&t, 0, sizeof(t));
msg_data[0] = IPMI_DCMI; /* Group Extension Identification */
if (sample_time) {
@@ -1365,19 +1426,17 @@ ipmi_dcmi_pwr_rd(struct ipmi_intf * intf, uint8_t sample_time)
/* rsp->data[0] is equal to response data byte 2 in spec */
/* printf("Group Extension Identification: %02x\n", rsp->data[0]); */
memcpy(&val, rsp->data, sizeof (val));
- t = val.time_stamp;
- gmtime_r(&t, &tm_t);
printf("\n");
printf(" Instantaneous power reading: %8d Watts\n",
- val.curr_pwr);
+ val.curr_pwr);
printf(" Minimum during sampling period: %8d Watts\n",
- val.min_sample);
+ val.min_sample);
printf(" Maximum during sampling period: %8d Watts\n",
- val.max_sample);
+ val.max_sample);
printf(" Average power reading over sample period: %8d Watts\n",
- val.avg_pwr);
+ val.avg_pwr);
printf(" IPMI timestamp: %s",
- asctime(&tm_t));
+ ipmi_timestamp_numeric(ipmi32toh(&val.time_stamp)));
printf(" Sampling period: ");
if (sample_time)
printf("%s \n", val2str2(val.sample,dcmi_sampling_vals));
@@ -1428,16 +1487,16 @@ ipmi_dcmi_getthermalpolicy(struct ipmi_intf * intf, uint8_t entityID,
memcpy(&val, rsp->data, sizeof (val));
printf("\n");
printf(" Persistence flag is: %s\n",
- ((val.exceptionActions & 0x80) ? "set" : "notset"));
+ ((val.exceptionActions & 0x80) ? "set" : "notset"));
printf(" Exception Actions, taken if the Temperature Limit exceeded:\n");
printf(" Hard Power Off system and log event: %s\n",
- ((val.exceptionActions & 0x40) ? "active":"inactive"));
+ ((val.exceptionActions & 0x40) ? "active":"inactive"));
printf(" Log event to SEL only: %s\n",
- ((val.exceptionActions & 0x20) ? "active":"inactive"));
+ ((val.exceptionActions & 0x20) ? "active":"inactive"));
printf(" Temperature Limit %d degrees\n",
- val.tempLimit);
+ val.tempLimit);
printf(" Exception Time %d seconds\n",
- val.exceptionTime);
+ val.exceptionTime);
printf("\n\n");
return 0;
}
@@ -1448,14 +1507,14 @@ ipmi_dcmi_getthermalpolicy(struct ipmi_intf * intf, uint8_t entityID,
*/
int
ipmi_dcmi_setthermalpolicy(struct ipmi_intf * intf,
- uint8_t entityID,
- uint8_t entityInst,
- uint8_t persistanceFlag,
- uint8_t actionHardPowerOff,
- uint8_t actionLogToSEL,
- uint8_t tempLimit,
- uint8_t samplingTimeLSB,
- uint8_t samplingTimeMSB)
+ uint8_t entityID,
+ uint8_t entityInst,
+ uint8_t persistanceFlag,
+ uint8_t actionHardPowerOff,
+ uint8_t actionLogToSEL,
+ uint8_t tempLimit,
+ uint8_t samplingTimeLSB,
+ uint8_t samplingTimeMSB)
{
struct ipmi_rs * rsp;
struct ipmi_rq req;
@@ -1464,10 +1523,10 @@ ipmi_dcmi_setthermalpolicy(struct ipmi_intf * intf,
msg_data[0] = IPMI_DCMI; /* Group Extension Identification */
msg_data[1] = entityID; /* Inlet Temperature DCMI ID*/
msg_data[2] = entityInst; /* Entity Instance */
- /* persistance and actions or disabled if no actions */
+ /* persistence and actions or disabled if no actions */
msg_data[3] = (((persistanceFlag ? 1 : 0) << 7) |
- ((actionHardPowerOff? 1 : 0) << 6) |
- ((actionLogToSEL ? 1 : 0) << 5));
+ ((actionHardPowerOff? 1 : 0) << 6) |
+ ((actionLogToSEL ? 1 : 0) << 5));
msg_data[4] = tempLimit;
msg_data[5] = samplingTimeLSB;
msg_data[6] = samplingTimeMSB;
@@ -1486,7 +1545,7 @@ ipmi_dcmi_setthermalpolicy(struct ipmi_intf * intf,
}
/* rsp->data[0] is equal to response data byte 2 in spec */
printf("\nThermal policy %d for %0Xh entity successfully set.\n\n",
- entityInst, entityID);
+ entityInst, entityID);
return 0;
}
@@ -1498,9 +1557,9 @@ ipmi_dcmi_setthermalpolicy(struct ipmi_intf * intf,
*/
struct ipmi_rs *
ipmi_dcmi_get_temp_readings(struct ipmi_intf * intf,
- uint8_t entityID,
- uint8_t entityInst,
- uint8_t entityInstStart)
+ uint8_t entityID,
+ uint8_t entityInst,
+ uint8_t entityInstStart)
{
struct ipmi_rq req;
uint8_t msg_data[5]; /* number of request data bytes */
@@ -1527,10 +1586,11 @@ ipmi_dcmi_prnt_get_temp_readings(struct ipmi_intf * intf)
int i,j, tota_inst, get_inst, offset = 0;
/* Print sensor description */
printf("\n\tEntity ID\t\t\tEntity Instance\t Temp. Readings");
- for (i = 0; dcmi_temp_read_vals[i].str != NULL; i++) {
+ for (i = 0; dcmi_temp_read_vals[i].str; i++) {
/* get all of the information about this sensor */
rsp = ipmi_dcmi_get_temp_readings(intf,
- dcmi_temp_read_vals[i].val, 0, 0);
+ dcmi_temp_read_vals[i].val,
+ 0, 0);
if (chk_rsp(rsp)) {
continue;
}
@@ -1539,10 +1599,11 @@ ipmi_dcmi_prnt_get_temp_readings(struct ipmi_intf * intf)
tota_inst = rsp->data[1];
while (tota_inst > 0) {
get_inst = ((tota_inst / DCMI_MAX_BYTE_TEMP_READ_SIZE) ?
- DCMI_MAX_BYTE_TEMP_READ_SIZE :
- (tota_inst % DCMI_MAX_BYTE_TEMP_READ_SIZE));
+ DCMI_MAX_BYTE_TEMP_READ_SIZE :
+ (tota_inst % DCMI_MAX_BYTE_TEMP_READ_SIZE));
rsp = ipmi_dcmi_get_temp_readings(intf,
- dcmi_temp_read_vals[i].val, offset, 0);
+ dcmi_temp_read_vals[i].val,
+ offset, 0);
if (chk_rsp(rsp)) {
continue;
}
@@ -1553,8 +1614,9 @@ ipmi_dcmi_prnt_get_temp_readings(struct ipmi_intf * intf)
/* Print Instance temperature info */
printf("\n%s",dcmi_temp_read_vals[i].desc);
printf("\t\t%i\t\t%c%i C", rsp->data[j+4],
- ((rsp->data[j+3]) >> 7) ?
- '-' : '+', (rsp->data[j+3] & 127));
+ ((rsp->data[j+3]) >> 7) ? '-'
+ : '+',
+ (rsp->data[j+3] & 127));
}
offset += get_inst;
tota_inst -= get_inst;
@@ -1599,8 +1661,10 @@ ipmi_dcmi_prnt_getconfparam(struct ipmi_intf * intf)
int param_selector;
uint16_t tmp_value = 0;
/* We are not interested in parameter 1 which always will return 0 */
- for (param_selector = 2 ; param_selector <= dcmi_conf_params;
- param_selector++) {
+ for (param_selector = 2;
+ param_selector <= dcmi_conf_params;
+ param_selector++)
+ {
rsp = ipmi_dcmi_getconfparam(intf, param_selector);
if (chk_rsp(rsp)) {
return -1;
@@ -1611,9 +1675,10 @@ ipmi_dcmi_prnt_getconfparam(struct ipmi_intf * intf)
tmp_value = (rsp->data[4])& 1;
printf("\n\tDHCP Discovery method\t: ");
printf("\n\t\tManagement Controller ID String is %s",
- tmp_value ? "enabled" : "disabled");
- printf("\n\t\tVendor class identifier DCMI IANA and Vendor class-specific Informationa are %s",
- ((rsp->data[4])& 2) ? "enabled" : "disabled" );
+ tmp_value ? "enabled" : "disabled");
+ printf("\n\t\tVendor class identifier DCMI IANA and Vendor "
+ "class-specific Informationa are %s",
+ ((rsp->data[4])& 2) ? "enabled" : "disabled" );
break;
case 3:
printf("\n\tInitial timeout interval\t: %i seconds",
@@ -1621,11 +1686,11 @@ ipmi_dcmi_prnt_getconfparam(struct ipmi_intf * intf)
break;
case 4:
printf("\n\tServer contact timeout interval\t: %i seconds",
- rsp->data[4] + (rsp->data[5]<<8));
+ rsp->data[4] + (rsp->data[5]<<8));
break;
case 5:
printf("\n\tServer contact retry interval\t: %i seconds",
- rsp->data[4] + (rsp->data[5] << 8));
+ rsp->data[4] + (rsp->data[5] << 8));
break;
default:
printf("\n\tConfiguration Parameter not supported.");
@@ -1724,7 +1789,7 @@ ipmi_dcmi_pwr_prnt_glimit(struct ipmi_intf * intf)
/* rsp can be a null so check response before any operation
* on it to avoid sig segv
*/
- if (rsp != NULL) {
+ if (rsp) {
realCc = rsp->ccode;
GOOD_PWR_GLIMIT_CCODE(rsp->ccode);
}
@@ -1735,10 +1800,10 @@ ipmi_dcmi_pwr_prnt_glimit(struct ipmi_intf * intf)
/* printf("Group Extension Identification: %02x\n", rsp->data[0]); */
memcpy(&val, rsp->data, sizeof (val));
printf("\n Current Limit State: %s\n",
- (realCc == 0) ?
- "Power Limit Active" : "No Active Power Limit");
+ (realCc == 0) ?
+ "Power Limit Active" : "No Active Power Limit");
printf(" Exception actions: %s\n",
- val2str2(val.action, dcmi_pwrmgmt_get_action_vals));
+ val2str2(val.action, dcmi_pwrmgmt_get_action_vals));
printf(" Power Limit: %i Watts\n", val.limit);
printf(" Correction time: %i milliseconds\n", val.correction);
printf(" Sampling period: %i seconds\n", val.sample);
@@ -1772,7 +1837,7 @@ ipmi_dcmi_pwr_slimit(struct ipmi_intf * intf, const char * option,
/* rsp can be a null so check response before any operation on it to
* avoid sig segv
*/
- if (rsp != NULL) {
+ if (rsp) {
GOOD_PWR_GLIMIT_CCODE(rsp->ccode);
}
if (chk_rsp(rsp)) {
@@ -1796,8 +1861,8 @@ ipmi_dcmi_pwr_slimit(struct ipmi_intf * intf, const char * option,
* val.sample = *(uint16_t*)(&rsp->data[12]);
*/
lprintf(LOG_INFO,
- "DCMI IN Limit=%d Correction=%d Action=%d Sample=%d\n",
- val.limit, val.correction, val.action, val.sample);
+ "DCMI IN Limit=%d Correction=%d Action=%d Sample=%d\n",
+ val.limit, val.correction, val.action, val.sample);
switch (str2val2(option, dcmi_pwrmgmt_set_usage_vals)) {
case 0x00:
/* action */
@@ -1877,7 +1942,7 @@ ipmi_dcmi_pwr_slimit(struct ipmi_intf * intf, const char * option,
case 0xFF:
/* error - not a string we knew what to do with */
lprintf(LOG_ERR, "Given %s '%s' is invalid.",
- option, value);
+ option, value);
return -1;
}
break;
@@ -1885,7 +1950,7 @@ ipmi_dcmi_pwr_slimit(struct ipmi_intf * intf, const char * option,
/* limit */
if (str2uint(value, &lvalue) != 0) {
lprintf(LOG_ERR, "Given %s '%s' is invalid.",
- option, value);
+ option, value);
return (-1);
}
val.limit = *(uint16_t*)(&lvalue);
@@ -1894,7 +1959,7 @@ ipmi_dcmi_pwr_slimit(struct ipmi_intf * intf, const char * option,
/* correction */
if (str2uint(value, &lvalue) != 0) {
lprintf(LOG_ERR, "Given %s '%s' is invalid.",
- option, value);
+ option, value);
return (-1);
}
val.correction = *(uint32_t*)(&lvalue);
@@ -1903,7 +1968,7 @@ ipmi_dcmi_pwr_slimit(struct ipmi_intf * intf, const char * option,
/* sample */
if (str2uint(value, &lvalue) != 0) {
lprintf(LOG_ERR, "Given %s '%s' is invalid.",
- option, value);
+ option, value);
return (-1);
}
val.sample = *(uint16_t*)(&lvalue);
@@ -2024,7 +2089,8 @@ _ipmi_nm_discover(struct ipmi_intf * intf, struct nm_discover *disc)
* @caps: fills in capability struct
*/
static int
-_ipmi_nm_getcapabilities(struct ipmi_intf * intf, uint8_t domain, uint8_t trigger, struct nm_capability *caps)
+_ipmi_nm_getcapabilities(struct ipmi_intf * intf, uint8_t domain,
+ uint8_t trigger, struct nm_capability *caps)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2049,7 +2115,8 @@ _ipmi_nm_getcapabilities(struct ipmi_intf * intf, uint8_t domain, uint8_t trigge
}
static int
-_ipmi_nm_get_policy(struct ipmi_intf * intf, uint8_t domain, uint8_t policy_id, struct nm_get_policy *policy)
+_ipmi_nm_get_policy(struct ipmi_intf * intf, uint8_t domain,
+ uint8_t policy_id, struct nm_get_policy *policy)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2083,7 +2150,9 @@ _ipmi_nm_set_policy(struct ipmi_intf * intf, struct nm_policy *policy)
req.msg.cmd = IPMI_NM_SET_POLICY;
req.msg.data = (uint8_t *)policy;
req.msg.data_len = sizeof(struct nm_policy);
- policy->intel_id[0] = 0x57; policy->intel_id[1] =1; policy->intel_id[2] =0;
+ policy->intel_id[0] = 0x57;
+ policy->intel_id[1] = 1;
+ policy->intel_id[2] = 0;
rsp = intf->sendrecv(intf, &req);
if (chk_nm_rsp(rsp)) {
return -1;
@@ -2117,7 +2186,8 @@ _ipmi_nm_policy_limiting(struct ipmi_intf * intf, uint8_t domain)
}
static int
-_ipmi_nm_control(struct ipmi_intf * intf, uint8_t scope, uint8_t domain, uint8_t policy_id)
+_ipmi_nm_control(struct ipmi_intf * intf, uint8_t scope,
+ uint8_t domain, uint8_t policy_id)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2151,7 +2221,8 @@ _ipmi_nm_control(struct ipmi_intf * intf, uint8_t scope, uint8_t domain, uint8_t
* @selector: Parameter selector
*/
static int
-_ipmi_nm_statistics(struct ipmi_intf * intf, uint8_t mode, uint8_t domain, uint8_t policy_id, struct nm_statistics *caps)
+_ipmi_nm_statistics(struct ipmi_intf * intf, uint8_t mode, uint8_t domain,
+ uint8_t policy_id, struct nm_statistics *caps)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2177,7 +2248,8 @@ _ipmi_nm_statistics(struct ipmi_intf * intf, uint8_t mode, uint8_t domain, uint8
}
static int
-_ipmi_nm_reset_stats(struct ipmi_intf * intf, uint8_t mode, uint8_t domain, uint8_t policy_id)
+_ipmi_nm_reset_stats(struct ipmi_intf * intf, uint8_t mode,
+ uint8_t domain, uint8_t policy_id)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2202,7 +2274,8 @@ _ipmi_nm_reset_stats(struct ipmi_intf * intf, uint8_t mode, uint8_t domain, uint
}
static int
-_nm_set_range(struct ipmi_intf * intf, uint8_t domain, uint16_t minimum, uint16_t maximum)
+_nm_set_range(struct ipmi_intf * intf, uint8_t domain,
+ uint16_t minimum, uint16_t maximum)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2284,7 +2357,8 @@ _ipmi_nm_set_alert(struct ipmi_intf * intf, struct nm_set_alert *alert)
* This array is filled in for valid thresholds returned.
*/
static int
-_ipmi_nm_get_thresh(struct ipmi_intf * intf, uint8_t domain, uint8_t policy_id, uint16_t *list)
+_ipmi_nm_get_thresh(struct ipmi_intf * intf, uint8_t domain,
+ uint8_t policy_id, uint16_t *list)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2357,7 +2431,8 @@ _ipmi_nm_set_thresh(struct ipmi_intf * intf, struct nm_thresh * thresh)
*
*/
static int
-_ipmi_nm_get_suspend(struct ipmi_intf * intf, uint8_t domain, uint8_t policy_id, int *count, struct nm_period *periods)
+_ipmi_nm_get_suspend(struct ipmi_intf * intf, uint8_t domain,
+ uint8_t policy_id, int *count, struct nm_period *periods)
{
struct ipmi_rq req; /* request data to send to the BMC */
struct ipmi_rs *rsp;
@@ -2400,9 +2475,12 @@ _ipmi_nm_set_suspend(struct ipmi_intf * intf, struct nm_suspend *suspend)
msg_data[1] = 1;
msg_data[2] = 0;
msg_data[3] = suspend->domain;
- msg_data[4] = suspend->policy_id;
+ msg_data[4] = suspend->policy_id;
msg_data[5] = suspend->count;
- for (i = 0, periods = &suspend->period[0]; i < (suspend->count*3); i += 3, periods++) {
+ for (i = 0, periods = &suspend->period[0];
+ i < (suspend->count*3);
+ i += 3, periods++)
+ {
msg_data[6+i] = periods->start;
msg_data[7+i] = periods->stop;
msg_data[8+i] = periods->repeat;
@@ -2412,8 +2490,8 @@ _ipmi_nm_set_suspend(struct ipmi_intf * intf, struct nm_suspend *suspend)
req.msg.netfn = IPMI_NETFN_OEM;
req.msg.cmd = IPMI_NM_SET_SUSPEND;
req.msg.data = msg_data;
- rsp = intf->sendrecv(intf, &req);
- if (chk_nm_rsp(rsp)) {
+ rsp = intf->sendrecv(intf, &req);
+ if (chk_nm_rsp(rsp)) {
return -1;
}
return 0;
@@ -2427,9 +2505,9 @@ ipmi_nm_getcapabilities(struct ipmi_intf * intf, int argc, char **argv)
uint8_t trigger = 0; /* default power policy (no trigger) */
struct nm_capability caps;
- while (--argc > 0) {
+ while (--argc > 0) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if ((option = str2val2(argv[0], nm_capability_opts)) == 0xFF) {
print_strs(nm_capability_opts, "Capability commands", LOG_ERR, 0);
return -1;
@@ -2465,35 +2543,35 @@ ipmi_nm_getcapabilities(struct ipmi_intf * intf, int argc, char **argv)
return -1;
if (csv_output) {
printf("%d,%u,%u,%u,%u,%u,%u,%s\n",
- caps.max_settings, caps.max_value,caps.min_value,
- caps.min_corr/1000, caps.max_corr/1000,
- caps.min_stats, caps.max_stats,
- val2str2(caps.scope&0xF, nm_domain_vals));
+ caps.max_settings, caps.max_value,caps.min_value,
+ caps.min_corr/1000, caps.max_corr/1000,
+ caps.min_stats, caps.max_stats,
+ val2str2(caps.scope&0xF, nm_domain_vals));
return 0;
}
printf(" power policies:\t\t%d\n", caps.max_settings);
switch (trigger&0xF) {
case 0: /* power */
printf(" max_power\t\t%7u Watts\n min_power\t\t%7u Watts\n",
- caps.max_value, caps.min_value);
+ caps.max_value, caps.min_value);
break;
case 1: /* Inlet */
printf(" max_temp\t\t%7u C\n min_temp\t\t%7u C\n",
- caps.max_value, caps.min_value);
+ caps.max_value, caps.min_value);
break;
case 2: /* Missing reading time */
case 3: /* Time after host reset */
printf(" max_time\t\t%7u Secs\n min_time\t\t%7u Secs\n",
- caps.max_value/10, caps.min_value/10);
+ caps.max_value/10, caps.min_value/10);
break;
case 4: /* boot time policy does not use these values */
default:
break;
}
printf(" min_corr\t\t%7u secs\n max_corr\t\t%7u secs\n",
- caps.min_corr/1000, caps.max_corr/1000);
+ caps.min_corr/1000, caps.max_corr/1000);
printf(" min_stats\t\t%7u secs\n max_stats\t\t%7u secs\n",
- caps.min_stats, caps.max_stats);
+ caps.min_stats, caps.max_stats);
printf(" domain scope:\t%s\n", val2str2(caps.scope&0xF, nm_domain_vals));
return 0;
}
@@ -2504,13 +2582,14 @@ ipmi_nm_get_policy(struct ipmi_intf * intf, int argc, char **argv)
uint8_t option;
uint8_t domain = 0; /* default domain of platform */
uint8_t policy_id = -1;
+ uint8_t have_policy_id = FALSE;
struct nm_get_policy policy;
memset(&policy, 0, sizeof(policy));
while (--argc) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if ((option = str2val2(argv[0], nm_policy_options)) == 0xFF) {
print_strs(nm_policy_options, "Get Policy commands", LOG_ERR, 0);
return -1;
@@ -2525,9 +2604,10 @@ ipmi_nm_get_policy(struct ipmi_intf * intf, int argc, char **argv)
break;
case 0x0B: /* policy id */
if (str2uchar(argv[1], &policy_id) < 0) {
- lprintf(LOG_ERR," Policy ID must be a positive integer 0-7.\n");
+ lprintf(LOG_ERR," Policy ID must be a positive integer (0-255)\n");
return -1;
}
+ have_policy_id = TRUE;
break;
default:
printf(" Unknown command 0x%x, skipping.\n", option);
@@ -2536,53 +2616,54 @@ ipmi_nm_get_policy(struct ipmi_intf * intf, int argc, char **argv)
argc--;
argv++;
}
- if (policy_id == 0xFF) {
+ if (!have_policy_id) {
print_strs(nm_stats_opts, "Missing policy_id parameter:", LOG_ERR, 0);
- return -1;
- }
+ return -1;
+ }
if (_ipmi_nm_get_policy(intf, policy.domain, policy_id, &policy))
return -1;
if (csv_output) {
printf("%s,0x%x,%s,%s,%s,%u,%u,%u,%u,%s\n",
- val2str2(policy.domain&0xF, nm_domain_vals),
- policy.domain,
- (policy.policy_type & 0x10) ? "power" : "nopower ",
- val2str2(policy.policy_type & 0xF, nm_policy_type_vals),
- val2str2(policy.policy_exception, nm_exception),
- policy.policy_limits,
- policy.corr_time,
- policy.trigger_limit,
- policy.stats_period,
- policy.policy_type & 0x80 ? "volatile" : "non-volatile");
+ val2str2(policy.domain&0xF, nm_domain_vals),
+ policy.domain,
+ (policy.policy_type & 0x10) ? "power" : "nopower ",
+ val2str2(policy.policy_type & 0xF, nm_policy_type_vals),
+ val2str2(policy.policy_exception, nm_exception),
+ policy.policy_limits,
+ policy.corr_time,
+ policy.trigger_limit,
+ policy.stats_period,
+ policy.policy_type & 0x80 ? "volatile" : "non-volatile");
return 0;
}
printf(" Power domain: %s\n",
- val2str2(policy.domain&0xF, nm_domain_vals));
+ val2str2(policy.domain&0xF, nm_domain_vals));
printf(" Policy is %s %s%s%s\n",
- policy.domain&0x10 ? "enabled" : "not enabled",
- policy.domain&0x20 ? "per Domain " : "",
- policy.domain&0x40 ? "Globally " : "",
- policy.domain&0x80 ? "via DCMI api " : "");
- printf(" Policy is %sa power control type.\n", (policy.policy_type & 0x10) ? "" : "not ");
+ policy.domain&0x10 ? "enabled" : "not enabled",
+ policy.domain&0x20 ? "per Domain " : "",
+ policy.domain&0x40 ? "Globally " : "",
+ policy.domain&0x80 ? "via DCMI api " : "");
+ printf(" Policy is %sa power control type.\n",
+ (policy.policy_type & 0x10) ? "" : "not ");
printf(" Policy Trigger Type: %s\n",
- val2str2(policy.policy_type & 0xF, nm_policy_type_vals));
+ val2str2(policy.policy_type & 0xF, nm_policy_type_vals));
printf(" Correction Aggressiveness: %s\n",
- val2str2((policy.policy_type>> 5) & 0x3, nm_correction_vals));
+ val2str2((policy.policy_type>> 5) & 0x3, nm_correction_vals));
printf(" Policy Exception Actions: %s\n",
- val2str2(policy.policy_exception, nm_exception));
+ val2str2(policy.policy_exception, nm_exception));
printf(" Power Limit: %u Watts\n",
- policy.policy_limits);
+ policy.policy_limits);
printf(" Correction Time Limit: %u milliseconds\n",
- policy.corr_time);
+ policy.corr_time);
printf(" Trigger Limit: %u units\n",
- policy.trigger_limit);
+ policy.trigger_limit);
printf(" Statistics Reporting Period: %u seconds\n",
- policy.stats_period);
+ policy.stats_period);
printf(" Policy retention: %s\n",
- policy.policy_type & 0x80 ? "volatile" : "non-volatile");
+ policy.policy_type & 0x80 ? "volatile" : "non-volatile");
if ( (policy_id == 0) && ((policy.domain & 0xf) == 0x3) )
printf(" HW Prot Power domain: %s\n",
- policy.policy_type & 0x80 ? "Secondary" : "Primary");
+ policy.policy_type & 0x80 ? "Secondary" : "Primary");
return 0;
}
@@ -2594,6 +2675,7 @@ ipmi_nm_policy(struct ipmi_intf * intf, int argc, char **argv)
uint8_t correction;
uint8_t domain = 0; /* default domain of platform */
uint8_t policy_id = -1;
+ uint8_t have_policy_id = FALSE;
uint16_t power, period, inlet;
uint16_t cores;
uint32_t limit;
@@ -2601,8 +2683,9 @@ ipmi_nm_policy(struct ipmi_intf * intf, int argc, char **argv)
argv++;
argc--;
- if ((argv[0] == NULL) ||
- ((action = str2val2(argv[0], nm_policy_action)) == 0xFF)) {
+ if (!argv[0] ||
+ 0xFF == (action = str2val2(argv[0], nm_policy_action)))
+ {
print_strs(nm_policy_action, "Policy commands", LOG_ERR, 0);
return -1;
}
@@ -2610,13 +2693,15 @@ ipmi_nm_policy(struct ipmi_intf * intf, int argc, char **argv)
return (ipmi_nm_get_policy(intf, argc, argv));
memset(&policy, 0, sizeof(policy));
/*
- * nm policy add [domain <param>] enable|disable policy_id <param> correction <opt> power <watts> limit <param> period <param>
+ * nm policy add [domain <param>] enable|disable policy_id <param>
+ * correction <opt> power <watts> limit <param>
+ * period <param>
* nm policy remove [domain <param>] policy_id <param>
* nm policy limiting {domain <param>]
*/
while (--argc > 0) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if ((option = str2val2(argv[0], nm_policy_options)) == 0xFF) {
print_strs(nm_policy_options, "Policy options", LOG_ERR, 0);
return -1;
@@ -2676,10 +2761,11 @@ ipmi_nm_policy(struct ipmi_intf * intf, int argc, char **argv)
break;
case 0x0B: /* policy ID */
if (str2uchar(argv[1], &policy_id) < 0) {
- printf("Policy ID must be a positive integer 0-7.\n");
+ printf("Policy ID must be a positive integer (0-255)\n");
return -1;
}
policy.policy_id = policy_id;
+ have_policy_id = TRUE;
break;
case 0x0C: /* volatile */
policy.policy_type |= 0x80;
@@ -2709,7 +2795,7 @@ ipmi_nm_policy(struct ipmi_intf * intf, int argc, char **argv)
printf("limit %x\n", limit);
return 0;
}
- if (policy_id == 0xFF) {
+ if (!have_policy_id) {
print_strs(nm_stats_opts, "Missing policy_id parameter:", LOG_ERR, 0);
return -1;
}
@@ -2728,12 +2814,14 @@ ipmi_nm_control(struct ipmi_intf * intf, int argc, char **argv)
uint8_t scope = 0; /* default control scope of global */
uint8_t domain = 0; /* default domain of platform */
uint8_t policy_id = -1;
+ uint8_t have_policy_id = FALSE;
argv++;
argc--;
/* nm_ctl_cmds returns 0 for disable, 1 for enable */
- if ((argv[0] == NULL) ||
- ((action = str2val2(argv[0], nm_ctl_cmds)) == 0xFF)) {
+ if (!argv[0] ||
+ 0xFF == (action = str2val2(argv[0], nm_ctl_cmds)))
+ {
print_strs(nm_ctl_cmds, "Control parameters:", LOG_ERR, 0);
print_strs(nm_ctl_domain, "control Scope (required):", LOG_ERR, 0);
return -1;
@@ -2741,30 +2829,31 @@ ipmi_nm_control(struct ipmi_intf * intf, int argc, char **argv)
argv++;
while (--argc) {
/* nm_ctl_domain returns correct bit field except for action */
- if ((argv[0] == NULL) ||
- ((scope = str2val2(argv[0], nm_ctl_domain)) == 0xFF)) {
+ if (!argv[0] ||
+ 0xFF == (scope = str2val2(argv[0], nm_ctl_domain)))
+ {
print_strs(nm_ctl_domain, "Control Scope (required):", LOG_ERR, 0);
return -1;
}
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if (scope == 0x02) { /* domain */
if ((domain = str2val2(argv[0], nm_domain_vals)) == 0xFF) {
print_strs(nm_domain_vals, "Domain Scope:", LOG_ERR, 0);
return -1;
}
} else if (scope == 0x04) { /* per_policy */
-
if (str2uchar(argv[0], &policy_id) < 0) {
- lprintf(LOG_ERR,"Policy ID must be a positive integer.\n");
+ lprintf(LOG_ERR,"Policy ID must be a positive integer (0-255)\n");
return -1;
}
+ have_policy_id = TRUE;
break;
}
argc--;
argv++;
}
- if ((scope == 0x04) && (policy_id == 0xFF)) {
+ if ((scope == 0x04) && !have_policy_id) {
print_strs(nm_stats_opts, "Missing policy_id parameter:", LOG_ERR, 0);
return -1;
}
@@ -2780,25 +2869,23 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
uint8_t option;
uint8_t domain = 0; /* default domain of platform */
uint8_t policy_id = -1;
+ uint8_t have_policy_id = FALSE;
int policy_mode = 0;
- int cut;
char *units = "";
- char datebuf[27];
struct nm_statistics stats;
- struct tm tm_t;
- time_t t;
argv++;
- if ((argv[0] == NULL) ||
- ((mode = str2val2(argv[0], nm_stats_mode)) == 0xFF)) {
+ if (!argv[0] ||
+ 0xFF == (mode = str2val2(argv[0], nm_stats_mode)))
+ {
print_strs(nm_stats_mode, "Statistics commands", LOG_ERR, 0);
return -1;
}
while (--argc) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if ((option = str2val2(argv[0], nm_stats_opts)) == 0xFF) {
- print_strs(nm_stats_opts, "Control Scope options", LOG_ERR, 0);
+ print_strs(nm_stats_opts, "Control Scope options", LOG_ERR, 0);
return -1;
}
switch (option) {
@@ -2810,9 +2897,10 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
break;
case 0x02: /* policy ID */
if (str2uchar(argv[1], &policy_id) < 0) {
- lprintf(LOG_ERR,"Policy ID must be a positive integer.\n");
+ lprintf(LOG_ERR,"Policy ID must be a positive integer (0-255)\n");
return -1;
}
+ have_policy_id = TRUE;
break;
default:
break;
@@ -2836,7 +2924,7 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
case 0x13:
policy_mode = 1;
units = (mode == 0x11) ? "Watts" : (mode == 0x12) ? "Celsius" : " %";
- if (policy_id == 0xFF) {
+ if (!have_policy_id) {
print_strs(nm_stats_opts, "Missing policy_id parameter:", LOG_ERR, 0);
return -1;
}
@@ -2846,47 +2934,53 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
}
if (_ipmi_nm_statistics(intf, mode, domain, policy_id, &stats))
return -1;
- t = stats.time_stamp;
- gmtime_r(&t, &tm_t);
- sprintf(datebuf, "%s", asctime(&tm_t));
- cut = strlen(datebuf) -1;
- datebuf[cut] = 0;
if (csv_output) {
printf("%s,%s,%s,%s,%s,%d,%d,%d,%d,%s,%d\n",
- val2str2(stats.id_state & 0xF, nm_domain_vals),
- ((stats.id_state >> 4) & 1) ? (policy_mode ? "Policy Enabled" : "Globally Enabled") : "Disabled" ,
- ((stats.id_state >> 5) & 1) ? "active" : "suspended",
- ((stats.id_state >> 6) & 1) ? "in progress" : "suspended",
- ((stats.id_state >> 7) & 1) ? "triggered" : "not triggered",
- stats.curr_value,
- stats.min_value,
- stats.max_value,
- stats.ave_value,
- datebuf,
- stats.stat_period);
+ val2str2(stats.id_state & 0xF, nm_domain_vals),
+ ((stats.id_state >> 4) & 1) ? (policy_mode ? "Policy Enabled"
+ : "Globally Enabled")
+ : "Disabled" ,
+ ((stats.id_state >> 5) & 1) ? "active"
+ : "suspended",
+ ((stats.id_state >> 6) & 1) ? "in progress"
+ : "suspended",
+ ((stats.id_state >> 7) & 1) ? "triggered"
+ : "not triggered",
+ stats.curr_value,
+ stats.min_value,
+ stats.max_value,
+ stats.ave_value,
+ ipmi_timestamp_numeric(ipmi32toh(&stats.time_stamp)),
+ stats.stat_period);
return 0;
}
printf(" Power domain: %s\n",
- val2str2(stats.id_state & 0xF, nm_domain_vals));
+ val2str2(stats.id_state & 0xF, nm_domain_vals));
printf(" Policy/Global Admin state %s\n",
- ((stats.id_state >> 4) & 1) ? (policy_mode ? "Policy Enabled" : "Globally Enabled") : "Disabled" );
+ ((stats.id_state >> 4) & 1) ? (policy_mode ? "Policy Enabled"
+ : "Globally Enabled")
+ : "Disabled" );
printf(" Policy/Global Operational state %s\n",
- ((stats.id_state >> 5) & 1) ? "active" : "suspended");
+ ((stats.id_state >> 5) & 1) ? "active"
+ : "suspended");
printf(" Policy/Global Measurement state %s\n",
- ((stats.id_state >> 6) & 1) ? "in progress" : "suspended");
+ ((stats.id_state >> 6) & 1) ? "in progress"
+ : "suspended");
printf(" Policy Activation state %s\n",
- ((stats.id_state >> 7) & 1) ? "triggered" : "not triggered");
+ ((stats.id_state >> 7) & 1) ? "triggered"
+ : "not triggered");
printf(" Instantaneous reading: %8d %s\n",
- stats.curr_value, units);
+ stats.curr_value, units);
printf(" Minimum during sampling period: %8d %s\n",
- stats.min_value, units);
+ stats.min_value, units);
printf(" Maximum during sampling period: %8d %s\n",
- stats.max_value, units);
+ stats.max_value, units);
printf(" Average reading over sample period: %8d %s\n",
- stats.ave_value, units);
+ stats.ave_value, units);
printf(" IPMI timestamp: %s\n",
- datebuf);
- printf(" Sampling period: %08d Seconds.\n", stats.stat_period);
+ ipmi_timestamp_numeric(ipmi32toh(&stats.time_stamp)));
+ printf(" Sampling period: %08d Seconds.\n",
+ stats.stat_period);
printf("\n");
return 0;
}
@@ -2898,16 +2992,18 @@ ipmi_nm_reset_statistics(struct ipmi_intf * intf, int argc, char **argv)
uint8_t option;
uint8_t domain = 0; /* default domain of platform */
uint8_t policy_id = -1;
+ uint8_t have_policy_id = FALSE;
argv++;
- if ((argv[0] == NULL) ||
- ((mode = str2val2(argv[0], nm_reset_mode)) == 0xFF)) {
+ if (!argv[0] ||
+ 0xFF == (mode = str2val2(argv[0], nm_reset_mode)))
+ {
print_strs(nm_reset_mode, "Reset Statistics Modes:", LOG_ERR, 0);
return -1;
}
while (--argc) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if ((option = str2val2(argv[0], nm_stats_opts)) == 0xFF) {
print_strs(nm_stats_opts, "Reset Scope options", LOG_ERR, 0);
return -1;
@@ -2921,9 +3017,10 @@ ipmi_nm_reset_statistics(struct ipmi_intf * intf, int argc, char **argv)
break;
case 0x02: /* policy ID */
if (str2uchar(argv[1], &policy_id) < 0) {
- lprintf(LOG_ERR,"Policy ID must be a positive integer.\n");
+ lprintf(LOG_ERR,"Policy ID must be a positive integer (0-255)\n");
return -1;
}
+ have_policy_id = TRUE;
break;
default:
break;
@@ -2931,7 +3028,7 @@ ipmi_nm_reset_statistics(struct ipmi_intf * intf, int argc, char **argv)
argc--;
argv++;
}
- if (mode && (policy_id == 0xFF)) {
+ if (mode && !have_policy_id) {
print_strs(nm_stats_opts, "Missing policy_id parameter:", LOG_ERR, 0);
return -1;
}
@@ -2950,7 +3047,7 @@ ipmi_nm_set_range(struct ipmi_intf * intf, int argc, char **argv)
while (--argc) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if ((param = str2val2(argv[0], nm_power_range)) == 0xFF) {
print_strs(nm_power_range, "power range parameters:", LOG_ERR, 0);
return -1;
@@ -2981,7 +3078,8 @@ ipmi_nm_set_range(struct ipmi_intf * intf, int argc, char **argv)
argv++;
}
if ((minimum == 0xFFFF) || (maximum == 0xFFFF)) {
- lprintf(LOG_ERR,"Missing parameters: nm power range min <minimum> max <maximum>.\n");
+ lprintf(LOG_ERR,"Missing parameters: nm power range min <minimum> "
+ "max <maximum>.\n");
return -1;
}
if (_nm_set_range(intf, domain, minimum, maximum) < 0)
@@ -2999,23 +3097,25 @@ ipmi_nm_get_alert(struct ipmi_intf * intf)
return -1;
if (csv_output) {
printf("%d,%s,0x%x,%s,0x%x\n",
- alert.chan&0xF,
- (alert.chan >> 7) ? "not registered" : "registered",
- alert.dest,
- (alert.string >> 7) ? "yes" : "no",
- alert.string & 0x7F);
+ alert.chan & 0xF,
+ (alert.chan >> 7) ? "not registered"
+ : "registered",
+ alert.dest,
+ (alert.string >> 7) ? "yes"
+ : "no",
+ alert.string & 0x7F);
return 0;
}
printf(" Alert Chan: %d\n",
- alert.chan&0xF);
+ alert.chan & 0xF);
printf(" Alert Receiver: %s\n",
- (alert.chan >> 7) ? "not registered" : "registered");
+ (alert.chan >> 7) ? "not registered" : "registered");
printf(" Alert Lan Destination: 0x%x\n",
- alert.dest);
+ alert.dest);
printf(" Use Alert String: %s\n",
- (alert.string >> 7) ? "yes" : "no");
+ (alert.string >> 7) ? "yes" : "no");
printf(" Alert String Selector: 0x%x\n",
- alert.string & 0x7F);
+ alert.string & 0x7F);
return 0;
}
@@ -3031,8 +3131,9 @@ ipmi_nm_alert(struct ipmi_intf * intf, int argc, char **argv)
argv++;
argc--;
- if ((argv[0] == NULL) ||
- ((action = str2val2(argv[0], nm_alert_opts)) == 0xFF)) {
+ if (!argv[0] ||
+ 0xFF == (action = str2val2(argv[0], nm_alert_opts)))
+ {
print_strs(nm_alert_opts, "Alert commands", LOG_ERR, 0);
return -1;
}
@@ -3042,19 +3143,19 @@ ipmi_nm_alert(struct ipmi_intf * intf, int argc, char **argv)
memset(&alert, 0, sizeof(alert));
while (--argc) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
if ((param = str2val2(argv[0], nm_set_alert_param)) == 0xFF) {
print_strs(nm_set_alert_param, "Set alert Parameters:", LOG_ERR, 0);
return -1;
}
switch (param) {
- case 0x01: /* channnel */
+ case 0x01: /* channel */
if (str2uchar(argv[1], &chan) < 0) {
lprintf(LOG_ERR,"Alert Lan chan must be a positive integer.\n");
return -1;
}
if (action == 0x03) /* Clear */
- chan |= 0x80; /* deactivate alert reciever */
+ chan |= 0x80; /* deactivate alert receiver */
break;
case 0x02: /* dest */
if (str2uchar(argv[1], &dest) < 0) {
@@ -3096,15 +3197,15 @@ ipmi_nm_get_thresh(struct ipmi_intf *intf, uint8_t domain, uint8_t policy_id)
return -1;
printf(" Alert Threshold domain: %s\n",
- val2str2(domain, nm_domain_vals));
+ val2str2(domain, nm_domain_vals));
printf(" Alert Threshold Policy ID: %d\n",
- policy_id);
+ policy_id);
printf(" Alert Threshold 1: %d\n",
- list[0]);
+ list[0]);
printf(" Alert Threshold 2: %d\n",
- list[1]);
+ list[1]);
printf(" Alert Threshold 3: %d\n",
- list[2]);
+ list[2]);
return 0;
}
@@ -3115,21 +3216,23 @@ ipmi_nm_thresh(struct ipmi_intf * intf, int argc, char **argv)
uint8_t action;
uint8_t domain = 0; /* default domain of platform */
uint8_t policy_id = -1;
+ uint8_t have_policy_id = FALSE;
struct nm_thresh thresh;
int i = 0;
argv++;
argc--;
/* set or get */
- if ((argv[0] == NULL) || (argc < 3) ||
- ((action = str2val2(argv[0], nm_thresh_cmds)) == 0xFF)) {
- print_strs(nm_thresh_cmds, "Theshold commands", LOG_ERR, 0);
+ if (!argv[0] || argc < 3
+ || 0xFF == (action = str2val2(argv[0], nm_thresh_cmds)))
+ {
+ print_strs(nm_thresh_cmds, "Threshold commands", LOG_ERR, 0);
return -1;
}
memset(&thresh, 0, sizeof(thresh));
while (--argc) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
option = str2val2(argv[0], nm_thresh_param);
switch (option) {
case 0x01: /* get domain scope */
@@ -3142,9 +3245,10 @@ ipmi_nm_thresh(struct ipmi_intf * intf, int argc, char **argv)
break;
case 0x02: /* policy ID */
if (str2uchar(argv[1], &policy_id) < 0) {
- lprintf(LOG_ERR,"Policy ID must be a positive integer.\n");
+ lprintf(LOG_ERR,"Policy ID must be a positive integer (0-255)\n");
return -1;
}
+ have_policy_id = TRUE;
argc--;
argv++;
break;
@@ -3161,7 +3265,7 @@ ipmi_nm_thresh(struct ipmi_intf * intf, int argc, char **argv)
break;
}
}
- if (policy_id == 0xFF) {
+ if (!have_policy_id) {
print_strs(nm_stats_opts, "Missing policy_id parameter:", LOG_ERR, 0);
return -1;
}
@@ -3213,9 +3317,10 @@ ipmi_nm_get_suspend(struct ipmi_intf *intf, uint8_t domain, uint8_t policy_id)
}
for (i = 0; i < count; i++) {
printf(" Suspend Period %d: %02d:%02d to %02d:%02d",
- i, click2hour(periods[i].start), click2min(periods[i].start),
- click2hour(periods[i].stop), click2min(periods[i].stop));
- if (periods[i].repeat) printf(", ");
+ i, click2hour(periods[i].start), click2min(periods[i].start),
+ click2hour(periods[i].stop), click2min(periods[i].stop));
+ if (periods[i].repeat)
+ printf(", ");
for (j = 0; j < 7; j++)
printf("%s", (periods[i].repeat >> j)&1 ? days[j] : "");
printf("\n");
@@ -3230,6 +3335,7 @@ ipmi_nm_suspend(struct ipmi_intf * intf, int argc, char **argv)
uint8_t action;
uint8_t domain = 0; /* default domain of platform */
uint8_t policy_id = -1;
+ uint8_t have_policy_id = FALSE;
uint8_t count = 0;
struct nm_suspend suspend;
int i;
@@ -3237,15 +3343,16 @@ ipmi_nm_suspend(struct ipmi_intf * intf, int argc, char **argv)
argv++;
argc--;
/* set or get */
- if ((argv[0] == NULL) || (argc < 3) ||
- ((action = str2val2(argv[0], nm_suspend_cmds)) == 0xFF)) {
+ if (!argv[0] || argc < 3 ||
+ 0xFF == (action = str2val2(argv[0], nm_suspend_cmds)))
+ {
print_strs(nm_suspend_cmds, "Suspend commands", LOG_ERR, 0);
return -1;
}
memset(&suspend, 0, sizeof(suspend));
while (--argc > 0) {
argv++;
- if (argv[0] == NULL) break;
+ if (!argv[0]) break;
option = str2val2(argv[0], nm_thresh_param);
switch (option) {
case 0x01: /* get domain scope */
@@ -3258,13 +3365,14 @@ ipmi_nm_suspend(struct ipmi_intf * intf, int argc, char **argv)
break;
case 0x02: /* policy ID */
if (str2uchar(argv[1], &policy_id) < 0) {
- lprintf(LOG_ERR,"Policy ID must be a positive integer.\n");
+ lprintf(LOG_ERR,"Policy ID must be a positive integer (0-255)\n");
return -1;
}
+ have_policy_id = TRUE;
argc--;
argv++;
break;
- case 0xFF: /* process periods */
+ case 0xFF: /* process periods */
for (i = 0; count < IPMI_NM_SUSPEND_PERIOD_MAX; i += 3, count++) {
if (argc < 3) {
lprintf(LOG_ERR,"Error: suspend period requires a start, stop, and repeat values.\n");
@@ -3289,10 +3397,16 @@ ipmi_nm_suspend(struct ipmi_intf * intf, int argc, char **argv)
if (argc <= 0)
break;
break;
- default:
- break;
- }
- }
+ default:
+ break;
+ }
+ }
+
+ if (!have_policy_id) {
+ print_strs(nm_stats_opts, "Missing policy_id parameter:", LOG_ERR, 0);
+ return -1;
+ }
+
if (action == 0x02) /* get */
return (ipmi_nm_get_suspend(intf, domain, policy_id));
@@ -3349,7 +3463,7 @@ ipmi_dcmi_set_limit(struct ipmi_intf * intf, int argc, char **argv)
case 0xFF:
/* error - not a string we knew what to do with */
lprintf(LOG_ERR, "Given Action '%s' is invalid.",
- argv[2]);
+ argv[2]);
return -1;
}
/* limit */
@@ -3364,8 +3478,8 @@ ipmi_dcmi_set_limit(struct ipmi_intf * intf, int argc, char **argv)
/* correction */
if (str2uint(argv[6], &correction) != 0) {
lprintf(LOG_ERR,
- "Given Correction '%s' is invalid.",
- argv[6]);
+ "Given Correction '%s' is invalid.",
+ argv[6]);
return (-1);
}
data[7] = correction >> 0;
@@ -3377,8 +3491,8 @@ ipmi_dcmi_set_limit(struct ipmi_intf * intf, int argc, char **argv)
/* sample */
if (str2ushort(argv[8], &sample) != 0) {
lprintf(LOG_ERR,
- "Given Sample '%s' is invalid.",
- argv[8]);
+ "Given Sample '%s' is invalid.",
+ argv[8]);
return (-1);
}
data[13] = sample >> 0;
@@ -3390,12 +3504,12 @@ ipmi_dcmi_set_limit(struct ipmi_intf * intf, int argc, char **argv)
}
} else {
/* loop through each parameter and value until we have neither */
- while ((argv[1] != NULL) && (argv[2] != NULL)) {
+ while (argv[1] && argv[2]) {
rc = ipmi_dcmi_pwr_slimit(intf, argv[1], argv[2]);
/* catch any error that the set limit function returned */
if (rc > 0) {
print_strs(dcmi_pwrmgmt_set_usage_vals,
- "set_limit <parameter> <value>", LOG_ERR, 0);
+ "set_limit <parameter> <value>", LOG_ERR, 0);
return -1;
}
/* the first argument is the command and the second is the
@@ -3416,11 +3530,11 @@ ipmi_dcmi_parse_power(struct ipmi_intf * intf, int argc, char **argv)
switch (str2val2(argv[0], dcmi_pwrmgmt_vals)) {
case 0x00:
/* get reading */
- if (argv[1] != NULL) {
+ if (argv[1]) {
if (!(sample_time = str2val2(argv[1], dcmi_sampling_vals))) {
print_strs(dcmi_sampling_vals,
- "Invalid sample time. Valid times are: ",
- LOG_ERR, 1);
+ "Invalid sample time. Valid times are: ",
+ LOG_ERR, 1);
printf("\n");
return -1;
}
@@ -3439,8 +3553,8 @@ ipmi_dcmi_parse_power(struct ipmi_intf * intf, int argc, char **argv)
/* set limit */
if (argc < 4) {
print_strs(dcmi_pwrmgmt_set_usage_vals,
- "set_limit <parameter> <value>",
- LOG_ERR, 0);
+ "set_limit <parameter> <value>",
+ LOG_ERR, 0);
return -1;
}
if (ipmi_dcmi_set_limit(intf, argc, argv) < 0)
@@ -3458,7 +3572,7 @@ ipmi_dcmi_parse_power(struct ipmi_intf * intf, int argc, char **argv)
default:
/* no valid options */
print_strs(dcmi_pwrmgmt_vals,
- "power <command>", LOG_ERR, 0);
+ "power <command>", LOG_ERR, 0);
break;
}
return rc;
@@ -3488,14 +3602,14 @@ ipmi_dcmi_thermalpolicy(struct ipmi_intf * intf, int argc, char **argv)
}
if (str2uchar(argv[2], &entityID) != 0) {
lprintf(LOG_ERR,
- "Given Entity ID '%s' is invalid.",
- argv[2]);
+ "Given Entity ID '%s' is invalid.",
+ argv[2]);
return (-1);
}
if (str2uchar(argv[3], &entityInst) != 0) {
lprintf(LOG_ERR,
- "Given Instance ID '%s' is invalid.",
- argv[3]);
+ "Given Instance ID '%s' is invalid.",
+ argv[3]);
return (-1);
}
rc = ipmi_dcmi_getthermalpolicy(intf, entityID, entityInst);
@@ -3505,24 +3619,24 @@ ipmi_dcmi_thermalpolicy(struct ipmi_intf * intf, int argc, char **argv)
lprintf(LOG_NOTICE, "Set <entityID> <instanceID>");
return -1;
} else if (argc < 9) {
- print_strs(dcmi_thermalpolicy_set_parameters_vals,
- "Set thermalpolicy instance parameters: "
- "<volatile/nonvolatile/disabled> "
- "<poweroff/nopoweroff/disabled> "
- "<sel/nosel/disabled> <templimitByte> <exceptionTime>",
- LOG_ERR, 0);
+ print_strs(dcmi_thermalpolicy_set_parameters_vals,
+ "Set thermalpolicy instance parameters: "
+ "<volatile/nonvolatile/disabled> "
+ "<poweroff/nopoweroff/disabled> "
+ "<sel/nosel/disabled> <templimitByte> <exceptionTime>",
+ LOG_ERR, 0);
return -1;
}
if (str2uchar(argv[2], &entityID) != 0) {
lprintf(LOG_ERR,
- "Given Entity ID '%s' is invalid.",
- argv[2]);
+ "Given Entity ID '%s' is invalid.",
+ argv[2]);
return (-1);
}
if (str2uchar(argv[3], &entityInst) != 0) {
lprintf(LOG_ERR,
- "Given Instance ID '%s' is invalid.",
- argv[3]);
+ "Given Instance ID '%s' is invalid.",
+ argv[3]);
return (-1);
}
persistanceFlag = (uint8_t) str2val2(argv[4], dcmi_thermalpolicy_set_parameters_vals);
@@ -3530,14 +3644,14 @@ ipmi_dcmi_thermalpolicy(struct ipmi_intf * intf, int argc, char **argv)
actionLogToSEL = (uint8_t) str2val2(argv[6], dcmi_thermalpolicy_set_parameters_vals);
if (str2uchar(argv[7], &tempLimit) != 0) {
lprintf(LOG_ERR,
- "Given Temp Limit '%s' is invalid.",
- argv[7]);
+ "Given Temp Limit '%s' is invalid.",
+ argv[7]);
return (-1);
}
if (str2ushort(argv[8], &samplingTime) != 0) {
lprintf(LOG_ERR,
- "Given Sampling Time '%s' is invalid.",
- argv[8]);
+ "Given Sampling Time '%s' is invalid.",
+ argv[8]);
return (-1);
}
samplingTimeLSB = (samplingTime & 0xFF);
@@ -3556,8 +3670,8 @@ ipmi_dcmi_thermalpolicy(struct ipmi_intf * intf, int argc, char **argv)
break;
default:
print_strs(dcmi_thermalpolicy_vals,
- "thermalpolicy <command>",
- LOG_ERR, 0);
+ "thermalpolicy <command>",
+ LOG_ERR, 0);
return -1;
}
return rc;
@@ -3576,20 +3690,20 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
int i;
struct ipmi_rs *rsp;
- if ((argc == 0) || (strncmp(argv[0], "help", 4) == 0)) {
+ if (!argc || !strcmp(argv[0], "help")) {
print_strs(dcmi_cmd_vals,
- "Data Center Management Interface commands",
- LOG_ERR, 0);
+ "Data Center Management Interface commands",
+ LOG_ERR, 0);
return -1;
}
/* start the cmd requested */
switch (str2val2(argv[0], dcmi_cmd_vals)) {
case 0x00:
/* discover capabilities*/
- for (i = 1; dcmi_capable_vals[i-1].str != NULL; i++) {
+ for (i = 1; dcmi_capable_vals[i-1].str; i++) {
if (ipmi_dcmi_prnt_getcapabilities(intf, i) < 0) {
lprintf(LOG_ERR,"Error discovering %s capabilities!\n",
- val2str2(i, dcmi_capable_vals));
+ val2str2(i, dcmi_capable_vals));
return -1;
}
}
@@ -3597,9 +3711,9 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
case 0x01:
/* power */
argv++;
- if (argv[0] == NULL) {
+ if (!argv[0]) {
print_strs(dcmi_pwrmgmt_vals, "power <command>",
- LOG_ERR, 0);
+ LOG_ERR, 0);
return -1;
}
rc = ipmi_dcmi_parse_power(intf, argc, argv);
@@ -3611,10 +3725,10 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
* and if it exists, print the sdr record id(s) for it.
* Use the val from each one as the sensor number.
*/
- for (i = 0; dcmi_discvry_snsr_vals[i].str != NULL; i++) {
+ for (i = 0; dcmi_discvry_snsr_vals[i].str; i++) {
/* get all of the information about this sensor */
rc = ipmi_dcmi_prnt_discvry_snsr(intf,
- dcmi_discvry_snsr_vals[i].val);
+ dcmi_discvry_snsr_vals[i].val);
}
break;
/* end sensor print */
@@ -3631,8 +3745,8 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
/* set asset tag */
if (argc == 1 ) {
print_strs(dcmi_cmd_vals,
- "Data Center Management Interface commands",
- LOG_ERR, 0);
+ "Data Center Management Interface commands",
+ LOG_ERR, 0);
return -1;
}
if (ipmi_dcmi_prnt_setassettag(intf, (uint8_t *)argv[1]) < 0) {
@@ -3646,7 +3760,7 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
/* get management controller identifier string */
if (ipmi_dcmi_prnt_getmngctrlids(intf) < 0) {
lprintf(LOG_ERR,
- "Error getting management controller identifier string!");
+ "Error getting management controller identifier string!");
return -1;
}
break;
@@ -3656,13 +3770,13 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
/* set management controller identifier string */
if (argc == 1 ) {
print_strs(dcmi_cmd_vals,
- "Data Center Management Interface commands",
- LOG_ERR, 0);
+ "Data Center Management Interface commands",
+ LOG_ERR, 0);
return -1;
}
if (ipmi_dcmi_prnt_setmngctrlids(intf, (uint8_t *)argv[1]) < 0) {
lprintf(LOG_ERR,
- "Error setting management controller identifier string!");
+ "Error setting management controller identifier string!");
return -1;
}
break;
@@ -3675,14 +3789,14 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
case 0x08:
if(ipmi_dcmi_prnt_get_temp_readings(intf) < 0 ) {
lprintf(LOG_ERR,
- "Error get temperature readings!");
+ "Error get temperature readings!");
return -1;
}
break;
case 0x09:
if(ipmi_dcmi_prnt_getconfparam(intf) < 0 ) {
lprintf(LOG_ERR,
- "Error Get DCMI Configuration Parameters!");
+ "Error Get DCMI Configuration Parameters!");
return -1;
};
break;
@@ -3690,46 +3804,44 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
{
switch (argc) {
case 2:
- if (strncmp(argv[1], "activate_dhcp", 13) != 0) {
+ if (strcmp(argv[1], "activate_dhcp")) {
print_strs( dcmi_conf_param_vals,
- "DCMI Configuration Parameters",
- LOG_ERR, 0);
+ "DCMI Configuration Parameters",
+ LOG_ERR, 0);
return -1;
}
break;
default:
- if (argc != 3 || strncmp(argv[1], "help", 4) == 0) {
+ if (argc != 3 || !strcmp(argv[1], "help")) {
print_strs(dcmi_conf_param_vals,
- "DCMI Configuration Parameters",
- LOG_ERR, 0);
+ "DCMI Configuration Parameters",
+ LOG_ERR, 0);
return -1;
}
}
- if (strncmp(argv[1], "activate_dhcp", 13) == 0) {
+ if (!strcmp(argv[1], "activate_dhcp")) {
rsp = ipmi_dcmi_setconfparam(intf, 1, 1);
} else {
uint16_t tmp_val = 0;
if (str2ushort(argv[2], &tmp_val) != 0) {
- lprintf(LOG_ERR,
- "Given %s '%s' is invalid.",
- argv[1], argv[2]);
+ lprintf(LOG_ERR, "Given %s '%s' is invalid.",
+ argv[1], argv[2]);
return (-1);
}
rsp = ipmi_dcmi_setconfparam(intf,
- str2val2(argv[1], dcmi_conf_param_vals),
- tmp_val);
+ str2val2(argv[1], dcmi_conf_param_vals),
+ tmp_val);
}
if (chk_rsp(rsp)) {
- lprintf(LOG_ERR,
- "Error Set DCMI Configuration Parameters!");
+ lprintf(LOG_ERR, "Error Set DCMI Configuration Parameters!");
}
break;
}
case 0x0B:
{
- if (intf->session == NULL) {
+ if (!intf->session) {
lprintf(LOG_ERR,
- "\nOOB discovery is available only via RMCP interface.");
+ "\nOOB discovery is available only via RMCP interface.");
return -1;
}
if(ipmi_dcmi_prnt_oobDiscover(intf) < 0) {
@@ -3741,8 +3853,8 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
default:
/* couldn't detect what the user entered */
print_strs(dcmi_cmd_vals,
- "Data Center Management Interface commands",
- LOG_ERR, 0);
+ "Data Center Management Interface commands",
+ LOG_ERR, 0);
return -1;
break;
}
@@ -3761,10 +3873,10 @@ ipmi_nm_main(struct ipmi_intf * intf, int argc, char **argv)
{
struct nm_discover disc;
- if ((argc == 0) || (strncmp(argv[0], "help", 4) == 0)) {
+ if (!argc || !strcmp(argv[0], "help")) {
print_strs(nm_cmd_vals,
- "Node Manager Interface commands",
- LOG_ERR, 0);
+ "Node Manager Interface commands",
+ LOG_ERR, 0);
return -1;
}
@@ -3775,7 +3887,7 @@ ipmi_nm_main(struct ipmi_intf * intf, int argc, char **argv)
return -1;
printf(" Node Manager Version %s\n", val2str2(disc.nm_version, nm_version_vals));
printf(" revision %d.%d%d patch version %d\n", disc.major_rev,
- disc.minor_rev>>4, disc.minor_rev&0xf, disc.patch_version);
+ disc.minor_rev>>4, disc.minor_rev&0xf, disc.patch_version);
break;
/* capability */
case 0x01:
@@ -3846,37 +3958,38 @@ ipmi_print_sensor_info(struct ipmi_intf *intf, uint16_t rec_id)
uint8_t *rec = NULL;
itr = ipmi_sdr_start(intf, 0);
- if (itr == NULL) {
+ if (!itr) {
lprintf(LOG_ERR, "Unable to open SDR for reading");
return (-1);
}
- while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL) {
+ while ((header = ipmi_sdr_get_next_header(intf, itr))) {
if (header->id == rec_id) {
break;
}
}
- if (header == NULL) {
+ if (!header) {
lprintf(LOG_DEBUG, "header == NULL");
- ipmi_sdr_end(intf, itr);
+ ipmi_sdr_end(itr);
return (-1);
}
/* yes, we found the SDR for this record ID, now get full record */
rec = ipmi_sdr_get_record(intf, header, itr);
- if (rec == NULL) {
+ if (!rec) {
lprintf(LOG_DEBUG, "rec == NULL");
- ipmi_sdr_end(intf, itr);
+ ipmi_sdr_end(itr);
return (-1);
}
if ((header->type == SDR_RECORD_TYPE_FULL_SENSOR) ||
- (header->type == SDR_RECORD_TYPE_COMPACT_SENSOR)) {
+ (header->type == SDR_RECORD_TYPE_COMPACT_SENSOR))
+ {
rc = ipmi_sdr_print_rawentry(intf, header->type,
- rec, header->length);
+ rec, header->length);
} else {
rc = (-1);
}
free(rec);
rec = NULL;
- ipmi_sdr_end(intf, itr);
+ ipmi_sdr_end(itr);
return rc;
}