mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
dcmi: Refactor
- Refactor the ipmi_dcmi code for better readability; - Get rid of space indents; - Use tabs for indent, spaces for alignment; - Wrap too long lines;
This commit is contained in:
parent
f498e3e296
commit
724f7329a3
208
lib/ipmi_dcmi.c
208
lib/ipmi_dcmi.c
@ -126,6 +126,7 @@ const struct dcmi_cmd dcmi_mandatory_platform_capabilities[] = {
|
||||
/* optional capabilities */
|
||||
const struct dcmi_cmd dcmi_optional_platform_capabilities[] = {
|
||||
{ 0x01, "Power management available", "" },
|
||||
|
||||
DCMI_CMD_END(0xFF)
|
||||
};
|
||||
|
||||
@ -431,9 +432,15 @@ const struct dcmi_cmd nm_stats_mode[] = {
|
||||
};
|
||||
|
||||
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-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>]" },
|
||||
{ 0x06, "limiting", "nm policy limiting [domain <platform|CPU|Memory>]" },
|
||||
|
||||
DCMI_CMD_END(0xFF),
|
||||
@ -443,7 +450,7 @@ const struct dcmi_cmd nm_policy_options[] = {
|
||||
{ 0x02, "disable", "" },
|
||||
{ 0x03, "domain", "" },
|
||||
{ 0x04, "inlet", "inlet air temp full limiting (SCRAM)" },
|
||||
{ 0x06, "correction", "auto, soft, hard" },
|
||||
{ 0x06, "correction" "auto, soft, hard" },
|
||||
{ 0x08, "power", "power limit in watts" },
|
||||
{ 0x09, "trig_lim", "time to send alert" },
|
||||
{ 0x0A, "stats", "moving window averaging time" },
|
||||
@ -497,7 +504,7 @@ const struct dcmi_cmd nm_reset_mode[] = {
|
||||
{ 0x1B, "requests", "" },
|
||||
{ 0x1C, "response", "" },
|
||||
{ 0x1D, "throttling", "" },
|
||||
{ 0x1E, "memory", "", },
|
||||
{ 0x1E, "memory", "" },
|
||||
{ 0x1F, "comm", "" },
|
||||
|
||||
DCMI_CMD_END(0xFF),
|
||||
@ -528,8 +535,10 @@ const struct dcmi_cmd nm_set_alert_param[] = {
|
||||
};
|
||||
|
||||
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),
|
||||
};
|
||||
@ -542,8 +551,11 @@ const struct dcmi_cmd nm_thresh_param[] = {
|
||||
};
|
||||
|
||||
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),
|
||||
};
|
||||
@ -643,11 +655,9 @@ str2val2(const char *str, const struct dcmi_cmd *vs)
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; vs[i].str != NULL; i++) {
|
||||
if (strncasecmp(vs[i].str, str,
|
||||
__maxlen(str, vs[i].str)) == 0) {
|
||||
if (strncasecmp(vs[i].str, str, __maxlen(str, vs[i].str)) == 0)
|
||||
return vs[i].val;
|
||||
}
|
||||
}
|
||||
return vs[i].val;
|
||||
}
|
||||
|
||||
@ -705,7 +715,8 @@ chk_rsp(struct ipmi_rs * rsp)
|
||||
}
|
||||
/* 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;
|
||||
@ -872,7 +883,8 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
|
||||
/* 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_5_CONFORM))
|
||||
{
|
||||
lprintf(LOG_ERR,
|
||||
"ERROR! This command is not available on this platform");
|
||||
return -1;
|
||||
@ -897,20 +909,20 @@ ipmi_dcmi_prnt_getcapabilities(struct ipmi_intf * intf, uint8_t selector)
|
||||
* struct
|
||||
*/
|
||||
printf("\n Mandatory platform capabilties\n");
|
||||
display_capabilities_attributes(
|
||||
dcmi_mandatory_platform_capabilities, cape.data_byte1);
|
||||
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);
|
||||
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);
|
||||
display_capabilities_attributes(dcmi_management_access_capabilities,
|
||||
cape.data_byte3);
|
||||
break;
|
||||
case 0x02:
|
||||
printf("\n Mandatory platform attributes:\n");
|
||||
@ -934,8 +946,8 @@ 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,
|
||||
@ -1057,8 +1069,9 @@ 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
|
||||
@ -1130,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)) {
|
||||
@ -1195,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)) {
|
||||
@ -1272,8 +1287,9 @@ 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
|
||||
@ -1579,7 +1595,8 @@ ipmi_dcmi_prnt_get_temp_readings(struct ipmi_intf * intf)
|
||||
for (i = 0; dcmi_temp_read_vals[i].str != NULL; 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;
|
||||
}
|
||||
@ -1591,7 +1608,8 @@ ipmi_dcmi_prnt_get_temp_readings(struct ipmi_intf * intf)
|
||||
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;
|
||||
}
|
||||
@ -1602,8 +1620,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;
|
||||
@ -1648,8 +1667,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;
|
||||
@ -1661,7 +1682,8 @@ ipmi_dcmi_prnt_getconfparam(struct ipmi_intf * intf)
|
||||
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",
|
||||
printf("\n\t\tVendor class identifier DCMI IANA and Vendor "
|
||||
"class-specific Informationa are %s",
|
||||
((rsp->data[4])& 2) ? "enabled" : "disabled" );
|
||||
break;
|
||||
case 3:
|
||||
@ -2073,7 +2095,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;
|
||||
@ -2098,7 +2121,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;
|
||||
@ -2132,7 +2156,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;
|
||||
@ -2166,7 +2192,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;
|
||||
@ -2200,7 +2227,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;
|
||||
@ -2226,7 +2254,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;
|
||||
@ -2251,7 +2280,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;
|
||||
@ -2333,7 +2363,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;
|
||||
@ -2406,7 +2437,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;
|
||||
@ -2451,7 +2483,10 @@ _ipmi_nm_set_suspend(struct ipmi_intf * intf, struct nm_suspend *suspend)
|
||||
msg_data[3] = suspend->domain;
|
||||
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;
|
||||
@ -2612,7 +2647,8 @@ ipmi_nm_get_policy(struct ipmi_intf * intf, int argc, char **argv)
|
||||
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 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));
|
||||
printf(" Correction Aggressiveness: %s\n",
|
||||
@ -2659,7 +2695,9 @@ 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>]
|
||||
*/
|
||||
@ -2782,7 +2820,8 @@ ipmi_nm_control(struct ipmi_intf * intf, int argc, char **argv)
|
||||
argc--;
|
||||
/* nm_ctl_cmds returns 0 for disable, 1 for enable */
|
||||
if ((argv[0] == NULL) ||
|
||||
((action = str2val2(argv[0], nm_ctl_cmds)) == 0xFF)) {
|
||||
((action = str2val2(argv[0], nm_ctl_cmds)) == 0xFF))
|
||||
{
|
||||
print_strs(nm_ctl_cmds, "Control parameters:", LOG_ERR, 0);
|
||||
print_strs(nm_ctl_domain, "control Scope (required):", LOG_ERR, 0);
|
||||
return -1;
|
||||
@ -2791,7 +2830,8 @@ ipmi_nm_control(struct ipmi_intf * intf, int argc, char **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)) {
|
||||
((scope = str2val2(argv[0], nm_ctl_domain)) == 0xFF))
|
||||
{
|
||||
print_strs(nm_ctl_domain, "Control Scope (required):", LOG_ERR, 0);
|
||||
return -1;
|
||||
}
|
||||
@ -2803,7 +2843,6 @@ ipmi_nm_control(struct ipmi_intf * intf, int argc, char **argv)
|
||||
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");
|
||||
return -1;
|
||||
@ -2839,7 +2878,8 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
|
||||
|
||||
argv++;
|
||||
if ((argv[0] == NULL) ||
|
||||
((mode = str2val2(argv[0], nm_stats_mode)) == 0xFF)) {
|
||||
((mode = str2val2(argv[0], nm_stats_mode)) == 0xFF))
|
||||
{
|
||||
print_strs(nm_stats_mode, "Statistics commands", LOG_ERR, 0);
|
||||
return -1;
|
||||
}
|
||||
@ -2903,10 +2943,15 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
|
||||
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.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,
|
||||
@ -2918,13 +2963,18 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
|
||||
printf(" Power domain: %s\n",
|
||||
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);
|
||||
printf(" Minimum during sampling period: %8d %s\n",
|
||||
@ -2935,7 +2985,8 @@ ipmi_nm_get_statistics(struct ipmi_intf * intf, int argc, char **argv)
|
||||
stats.ave_value, units);
|
||||
printf(" IPMI timestamp: %s\n",
|
||||
datebuf);
|
||||
printf(" Sampling period: %08d Seconds.\n", stats.stat_period);
|
||||
printf(" Sampling period: %08d Seconds.\n",
|
||||
stats.stat_period);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
@ -2950,7 +3001,8 @@ ipmi_nm_reset_statistics(struct ipmi_intf * intf, int argc, char **argv)
|
||||
|
||||
argv++;
|
||||
if ((argv[0] == NULL) ||
|
||||
((mode = str2val2(argv[0], nm_reset_mode)) == 0xFF)) {
|
||||
((mode = str2val2(argv[0], nm_reset_mode)) == 0xFF))
|
||||
{
|
||||
print_strs(nm_reset_mode, "Reset Statistics Modes:", LOG_ERR, 0);
|
||||
return -1;
|
||||
}
|
||||
@ -3030,7 +3082,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)
|
||||
@ -3049,9 +3102,11 @@ ipmi_nm_get_alert(struct ipmi_intf * intf)
|
||||
if (csv_output) {
|
||||
printf("%d,%s,0x%x,%s,0x%x\n",
|
||||
alert.chan & 0xF,
|
||||
(alert.chan >> 7) ? "not registered" : "registered",
|
||||
(alert.chan >> 7) ? "not registered"
|
||||
: "registered",
|
||||
alert.dest,
|
||||
(alert.string >> 7) ? "yes" : "no",
|
||||
(alert.string >> 7) ? "yes"
|
||||
: "no",
|
||||
alert.string & 0x7F);
|
||||
return 0;
|
||||
}
|
||||
@ -3081,7 +3136,8 @@ 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)) {
|
||||
((action = str2val2(argv[0], nm_alert_opts)) == 0xFF))
|
||||
{
|
||||
print_strs(nm_alert_opts, "Alert commands", LOG_ERR, 0);
|
||||
return -1;
|
||||
}
|
||||
@ -3171,7 +3227,8 @@ ipmi_nm_thresh(struct ipmi_intf * intf, int argc, char **argv)
|
||||
argc--;
|
||||
/* set or get */
|
||||
if ((argv[0] == NULL) || (argc < 3) ||
|
||||
((action = str2val2(argv[0], nm_thresh_cmds)) == 0xFF)) {
|
||||
((action = str2val2(argv[0], nm_thresh_cmds)) == 0xFF))
|
||||
{
|
||||
print_strs(nm_thresh_cmds, "Theshold commands", LOG_ERR, 0);
|
||||
return -1;
|
||||
}
|
||||
@ -3264,7 +3321,8 @@ ipmi_nm_get_suspend(struct ipmi_intf *intf, uint8_t domain, uint8_t policy_id)
|
||||
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(", ");
|
||||
if (periods[i].repeat)
|
||||
printf(", ");
|
||||
for (j = 0; j < 7; j++)
|
||||
printf("%s", (periods[i].repeat >> j)&1 ? days[j] : "");
|
||||
printf("\n");
|
||||
@ -3287,7 +3345,8 @@ ipmi_nm_suspend(struct ipmi_intf * intf, int argc, char **argv)
|
||||
argc--;
|
||||
/* set or get */
|
||||
if ((argv[0] == NULL) || (argc < 3) ||
|
||||
((action = str2val2(argv[0], nm_suspend_cmds)) == 0xFF)) {
|
||||
((action = str2val2(argv[0], nm_suspend_cmds)) == 0xFF))
|
||||
{
|
||||
print_strs(nm_suspend_cmds, "Suspend commands", LOG_ERR, 0);
|
||||
return -1;
|
||||
}
|
||||
@ -3759,8 +3818,7 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
|
||||
} else {
|
||||
uint16_t tmp_val = 0;
|
||||
if (str2ushort(argv[2], &tmp_val) != 0) {
|
||||
lprintf(LOG_ERR,
|
||||
"Given %s '%s' is invalid.",
|
||||
lprintf(LOG_ERR, "Given %s '%s' is invalid.",
|
||||
argv[1], argv[2]);
|
||||
return (-1);
|
||||
}
|
||||
@ -3769,8 +3827,7 @@ ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char **argv)
|
||||
tmp_val);
|
||||
}
|
||||
if (chk_rsp(rsp)) {
|
||||
lprintf(LOG_ERR,
|
||||
"Error Set DCMI Configuration Parameters!");
|
||||
lprintf(LOG_ERR, "Error Set DCMI Configuration Parameters!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3918,7 +3975,8 @@ ipmi_print_sensor_info(struct ipmi_intf *intf, uint16_t rec_id)
|
||||
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);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user