From: <mxb...@us...> - 2010-04-16 21:24:47
|
Revision: 7063 http://openhpi.svn.sourceforge.net/openhpi/?rev=7063&view=rev Author: mxbishop Date: 2010-04-16 21:24:41 +0000 (Fri, 16 Apr 2010) Log Message: ----------- Fix for enhancement #2982733 (Add power mgmt controls to oa_soap plugin) Modified Paths: -------------- openhpi/trunk/include/SaHpiOaSoap.h openhpi/trunk/plugins/oa_soap/oa_soap.h openhpi/trunk/plugins/oa_soap/oa_soap_calls.c openhpi/trunk/plugins/oa_soap/oa_soap_calls.h openhpi/trunk/plugins/oa_soap/oa_soap_control.c openhpi/trunk/plugins/oa_soap/oa_soap_control.h openhpi/trunk/plugins/oa_soap/oa_soap_discover.c openhpi/trunk/plugins/oa_soap/oa_soap_discover.h openhpi/trunk/plugins/oa_soap/oa_soap_event.c openhpi/trunk/plugins/oa_soap/oa_soap_ps_event.c openhpi/trunk/plugins/oa_soap/oa_soap_resources.c Modified: openhpi/trunk/include/SaHpiOaSoap.h =================================================================== --- openhpi/trunk/include/SaHpiOaSoap.h 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/include/SaHpiOaSoap.h 2010-04-16 21:24:41 UTC (rev 7063) @@ -222,7 +222,27 @@ #define OA_SOAP_PWR_CNTRL (SaHpiCtrlNumT) 0x001 /* LCD Button Lock control */ #define OA_SOAP_LCD_BUTN_LCK_CNTRL (SaHpiCtrlNumT) 0x002 +/* Power Mode Control */ +#define OA_SOAP_PWR_MODE_CNTRL (SaHpiCtrlNumT) 0x003 +/* Dynamic Power Control */ +#define OA_SOAP_DYNAMIC_PWR_CNTRL (SaHpiCtrlNumT) 0x004 +/* Power Limit Mode Control */ +#define OA_SOAP_PWR_LIMIT_MODE_CNTRL (SaHpiCtrlNumT) 0x005 +/* Static Power Limit Control */ +#define OA_SOAP_STATIC_PWR_LIMIT_CNTRL (SaHpiCtrlNumT) 0x006 +/* Dynamic Power Cap Control */ +#define OA_SOAP_DYNAMIC_PWR_CAP_CNTRL (SaHpiCtrlNumT) 0x007 +/* HP c7000 Power Modes */ +#define C7000_PWR_NON_REDUNDANT 1 +#define C7000_PWR_AC_REDUNDANT 2 +#define C7000_PWR_SUPPLY_REDUNDANT 3 + +/* HP c7000 Power Limit Modes */ +#define C7000_PWR_LIMIT_NONE 0 +#define C7000_PWR_LIMIT_STATIC 1 +#define C7000_PWR_LIMIT_DYNAMIC_CAP 2 + /* Custom inventory Area and fields used in OA SOAP plugin * On adding new inventory area or field, fan zone mapping rray in in * plugin/oa_soap/oa_soap_resources.c may require updation. Modified: openhpi/trunk/plugins/oa_soap/oa_soap.h =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap.h 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap.h 2010-04-16 21:24:41 UTC (rev 7063) @@ -88,11 +88,6 @@ #define OA_SOAP_ENC_C7000 0 #define OA_SOAP_ENC_C3000 1 -/* Max Blade in HP BladeSystem c7000 c-Class enclosure*/ -#define OA_SOAP_C7000_MAX_BLADE 16 -/* Max Blade in HP BladeSystem c3000 c-Class enclosure*/ -#define OA_SOAP_C3000_MAX_BLADE 8 - /* Maximum Fan Zones present in different HP BladeSystem c-Class enclosures */ #define OA_SOAP_C7000_MAX_FZ 4 #define OA_SOAP_C3000_MAX_FZ 1 @@ -205,6 +200,13 @@ SaHpiBoolT shutdown_event_thread; SaHpiInt32T oa_switching; GMutex *mutex; + + /* This is local state for holding data for the */ + /* enclosure power management controls. */ + struct powerConfigInfo power_config_info; + struct powerCapConfig power_cap_config; + uint desired_static_pwr_limit; + uint desired_dynamic_pwr_cap; }; /* Structure for storing the current hotswap state of the resource */ Modified: openhpi/trunk/plugins/oa_soap/oa_soap_calls.c =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap_calls.c 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap_calls.c 2010-04-16 21:24:41 UTC (rev 7063) @@ -288,6 +288,44 @@ response->extraData = soap_walk_tree(node, "extraData"); } +/* parse_powerConfigInfo - Parses a getPowerConfigInfo response structure */ +static void parse_powerConfigInfo(xmlNode *node, struct powerConfigInfo *response) +{ + response->powerCeiling = atoi(soap_tree_value(node, "powerCeiling")); + response->redundancyMode = + soap_enum(powerRedundancy_S, soap_tree_value(node, "redundancyMode")); + response->dynamicPowerSaverEnabled = + parse_xsdBoolean(soap_tree_value(node, "dynamicPowerSaverEnabled")); + response->extraData = soap_walk_tree(node, "extraData"); +} + +/* parse_powerCapConfig - Parses a getPowerCapConfig response structure */ +static void parse_powerCapConfig(xmlNode *node, struct powerCapConfig *response) +{ + xmlNode *bay_data; + int i; + + response->enclosureMinWattageMeasured = atoi(soap_tree_value(node, "enclosureMinWattageMeasured")); + response->enclosureMaxWattageMeasured = atoi(soap_tree_value(node, "enclosureMaxWattageMeasured")); + response->enclosurePowerCapLowerBound = atoi(soap_tree_value(node, "enclosurePowerCapLowerBound")); + response->enclosurePowerCapUpperBound = atoi(soap_tree_value(node, "enclosurePowerCapUpperBound")); + response->enclosureHighLine = parse_xsdBoolean(soap_tree_value(node, "enclosureHighLine")); + response->enclosureAcPhaseType = atoi(soap_tree_value(node, "enclosureAcPhaseType")); + response->enclosureEstimatedVoltage = atoi(soap_tree_value(node, "enclosureEstimatedVoltage")); + response->powerCap = atoi(soap_tree_value(node, "powerCap")); + response->extraData = soap_walk_tree(node, "extraData"); + + bay_data = soap_walk_tree(node, "optOutBayArray"); + bay_data = soap_walk_tree(bay_data, "bay"); + i = 0; + while (bay_data) { + /* Copy optOutBayArray data for later use: data is either "true" or "false" */ + strncpy(response->optOutBayArray[i], soap_value(bay_data), 6); + bay_data = soap_next_node(bay_data); + i++; + } +} + /* parse_oaStatus - Parses an oaStatus response structure */ static void parse_oaStatus(xmlNode *node, struct oaStatus *response) { @@ -1329,6 +1367,93 @@ return(ret); } +int soap_getPowerConfigInfo(SOAP_CON *con, + struct powerConfigInfo *response, + uint *desired_static_pwr_limit) +{ + SOAP_PARM_CHECK_NRQ + if (! (ret = soap_request(con, GET_POWER_CONFIG_INFO))) { + parse_powerConfigInfo(soap_walk_doc(con->doc, + "Body:" + "getPowerConfigInfoResponse:" + "powerConfigInfo"), + response); + } + + /* If user's desired static power limit is 0, then update it with the OA value, */ + /* otherwise preserve the user's intention for a static power limit. */ + if (*desired_static_pwr_limit == 0) { + *desired_static_pwr_limit = response->powerCeiling; + } + + return(ret); +} + +int soap_setPowerConfigInfo(SOAP_CON *con, + const struct powerConfigInfo *request) +{ + char hpoa_boolean[HPOA_BOOLEAN_LENGTH]; + char powerRedundancy[POWER_REDUNDANCY_LENGTH]; + + SOAP_PARM_CHECK_NRS + if (soap_inv_enum(hpoa_boolean, hpoa_boolean_S, request->dynamicPowerSaverEnabled)) { + err("invalid dynamic power parameter"); + return(-1); + } + if (soap_inv_enum(powerRedundancy, powerRedundancy_S, request->redundancyMode)) { + err("invalid power redundancy mode parameter"); + return(-1); + } + return(soap_request(con, SET_POWER_CONFIG_INFO, request->redundancyMode, + request->powerCeiling, request->dynamicPowerSaverEnabled)); +} + +int soap_getPowerCapConfig(SOAP_CON *con, + struct powerCapConfig *response, + uint *desired_dynamic_pwr_cap_limit) +{ + SOAP_PARM_CHECK_NRQ + if (! (ret = soap_request(con, GET_POWER_CAP_CONFIG))) { + parse_powerCapConfig(soap_walk_doc(con->doc, + "Body:" + "getPowerCapConfigResponse:" + "powerCapConfig"), + response); + } + + /* If user's desired dynamic power cap limit is 0, then update it with the OA value, */ + /* otherwise preserve the user's intention for a dynamic power cap limit. */ + if (*desired_dynamic_pwr_cap_limit == 0) { + *desired_dynamic_pwr_cap_limit = response->powerCap; + } + + return(ret); +} + +int soap_setPowerCapConfig(SOAP_CON *con, + const struct powerCapConfig *request) +{ + SOAP_PARM_CHECK_NRS + return(soap_request(con, SET_POWER_CAP_CONFIG, request->powerCap, + request->optOutBayArray[0], + request->optOutBayArray[1], + request->optOutBayArray[2], + request->optOutBayArray[3], + request->optOutBayArray[4], + request->optOutBayArray[5], + request->optOutBayArray[6], + request->optOutBayArray[7], + request->optOutBayArray[8], + request->optOutBayArray[9], + request->optOutBayArray[10], + request->optOutBayArray[11], + request->optOutBayArray[12], + request->optOutBayArray[13], + request->optOutBayArray[14], + request->optOutBayArray[15], + "")); +} + int soap_getOaStatus(SOAP_CON *con, const struct getOaStatus *request, struct oaStatus *response) Modified: openhpi/trunk/plugins/oa_soap/oa_soap_calls.h =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap_calls.h 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap_calls.h 2010-04-16 21:24:41 UTC (rev 7063) @@ -47,6 +47,11 @@ #define MAX_PART_NUM_LENGTH 32 #define MAX_MODEL_NUM_LENGTH 32 +/* Moved these #defines from oa_soap.h - which includes this header file. */ +/* Max Blade in HP BladeSystem c7000 c-Class enclosure*/ +#define OA_SOAP_C7000_MAX_BLADE 16 +/* Max Blade in HP BladeSystem c3000 c-Class enclosure*/ +#define OA_SOAP_C3000_MAX_BLADE 8 /* Data types used to help us be more consistent with the WSDL description */ typedef unsigned char byte; @@ -114,6 +119,47 @@ "<hpoa:bayNumber>%d</hpoa:bayNumber>" \ "</hpoa:getOaInfo>\n" +#define GET_POWER_CONFIG_INFO \ + "<hpoa:getPowerConfigInfo>" \ + "</hpoa:getPowerConfigInfo>\n" + +#define SET_POWER_CONFIG_INFO \ + "<hpoa:setPowerConfigInfo>" \ + "<hpoa:redundancyMode>%d</hpoa:redundancyMode>" \ + "<hpoa:powerCeiling>%d</hpoa:powerCeiling>" \ + "<hpoa:dynamicPowerSaverEnabled>%d</hpoa:dynamicPowerSaverEnabled>" \ + "</hpoa:setPowerConfigInfo>\n" + +#define GET_POWER_CAP_CONFIG \ + "<hpoa:getPowerCapConfig>" \ + "</hpoa:getPowerCapConfig>\n" + +#define SET_POWER_CAP_CONFIG \ + "<hpoa:setPowerCapConfig>" \ + "<hpoa:config>" \ + "<hpoa:powerCap>%d</hpoa:powerCap>" \ + "<hpoa:optOutBayArray>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "<hpoa:bay>%s</hpoa:bay>" \ + "</hpoa:optOutBayArray>" \ + "<hpoa:extraData hpoa:name=\"\">%s</hpoa:extraData>" \ + "</hpoa:config>" \ + "</hpoa:setPowerCapConfig>\n" + #define GET_INTERCONNECT_TRAY_STATUS \ "<hpoa:getInterconnectTrayStatus>" \ "<hpoa:bayNumber>%d</hpoa:bayNumber>" \ @@ -234,6 +280,7 @@ "</hpoa:setLcdButtonLock>\n" /* Enumerated types used for specific SOAP commands */ +#define HPOA_BOOLEAN_LENGTH 11 /* Max length of these enums + 1 */ OA_SOAP_ENUM(hpoa_boolean, HPOA_FALSE, HPOA_TRUE) @@ -457,6 +504,7 @@ NOT_REDUNDANT, REDUNDANT) +#define POWER_REDUNDANCY_LENGTH 42 /* Max length of these enums + 1 */ OA_SOAP_ENUM(powerRedundancy, REDUNDANT_UNKNOWN, NON_REDUNDANT, @@ -466,6 +514,12 @@ POWER_SUPPLY_REDUNDANT_WITH_POWER_CEILING, NON_REDUNDANT_WITH_POWER_CEILING) +#define POWER_LIMIT_MODE_LENGTH 19 /* Max length of these enums + 1 */ +OA_SOAP_ENUM(powerLimitMode, + POWER_LIMIT_NONE, + STATIC_POWER_LIMIT, + DYNAMIC_POWER_CAP) + #define SENSOR_TYPE_LENGTH 25 /* Max length of these enums + 1 */ OA_SOAP_ENUM(sensorType, SENSOR_TYPE_BLADE, @@ -745,7 +799,8 @@ EVENT_MEDIA_DRIVE_INSERTED2, EVENT_MEDIA_DRIVE_REMOVED2, EVENT_MEDIA_INSERTED2, - EVENT_MEDIA_REMOVED2) + EVENT_MEDIA_REMOVED2, + EVENT_ENC_GRP_CAP) /* This is not part of the SOAP response data from the OA, but is useful * for identifying the type of data that comes back from getAllEvents(). @@ -805,7 +860,8 @@ NUMVALUE, STRING, MESSAGE, - NOPAYLOAD) + NOPAYLOAD, + POWERCAPCONFIG) OA_SOAP_ENUM(enum_usbMode, USB_KVM_ENABLED, @@ -1304,8 +1360,26 @@ enum powerRedundancy redundancyMode; enum hpoa_boolean dynamicPowerSaverEnabled; xmlNode *extraData; /* Items are struct extraDataInfo */ + /* These are needed as high/low limits of the analog control RDRs */ + /* static power limit. */ + int ACLimitLow; + int ACLimitHigh; }; +struct powerCapConfig +{ + int enclosureMinWattageMeasured; + int enclosureMaxWattageMeasured; + int enclosurePowerCapLowerBound; + int enclosurePowerCapUpperBound; + enum hpoa_boolean enclosureHighLine; + int enclosureAcPhaseType; + int enclosureEstimatedVoltage; + int powerCap; + char optOutBayArray[OA_SOAP_C7000_MAX_BLADE][8]; /* holds true or false for each bay */ + xmlNode *extraData; /* Items are struct extraDataInfo */ +}; + struct thermalInfo { enum sensorType sensorType; @@ -1820,6 +1894,7 @@ struct powerSupplyStatus powerSupplyStatus; struct powerSubsystemInfo powerSubsystemInfo; struct powerConfigInfo powerConfigInfo; + struct powerCapConfig powerCapConfig; struct thermalInfo thermalInfo; xmlNode *userInfoArray; /* Items are struct userInfo */ struct userInfo userInfo; @@ -1965,6 +2040,20 @@ int soap_getEnclosureInfo(SOAP_CON *connection, struct enclosureInfo *response); +int soap_getPowerConfigInfo(SOAP_CON *connection, + struct powerConfigInfo *response, + uint *desired_static_pwr_limit); + +int soap_setPowerConfigInfo(SOAP_CON *connection, + const struct powerConfigInfo *request); + +int soap_getPowerCapConfig(SOAP_CON *connection, + struct powerCapConfig *response, + uint *desired_dynamic_pwr_cap_limit); + +int soap_setPowerCapConfig(SOAP_CON *connection, + const struct powerCapConfig *request); + int soap_getOaStatus(SOAP_CON *connection, const struct getOaStatus *request, struct oaStatus *response); Modified: openhpi/trunk/plugins/oa_soap/oa_soap_control.c =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap_control.c 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap_control.c 2010-04-16 21:24:41 UTC (rev 7063) @@ -55,6 +55,26 @@ * * oa_soap_get_uid_cntrl() - Gets the UID control * + * oa_soap_set_dynamic_pwr_cntrl() - Sets the dynamic power control + * + * oa_soap_get_dynamic_pwr_cntrl() - Gets the dynamic power control + * + * oa_soap_set_pwr_mode_cntrl() - Sets the power mode control + * + * oa_soap_get_pwr_mode_cntrl() - Gets the power mode control + * + * oa_soap_set_pwr_limit_mode_cntrl() - Sets the power limit mode control + * + * oa_soap_get_pwr_limit_mode_cntrl() - Gets the power limit mode control + * + * oa_soap_set_static_pwr_limit_cntrl() - Sets the static power limit control + * + * oa_soap_get_static_pwr_limit_cntrl() - Gets the static power limit control + * + * oa_soap_set_dynamic_pwr_cap_cntrl() - Sets the dynamic power cap control + * + * oa_soap_get_dynamic_pwr_cap_cntrl() - Gets the dynamic power cap control + * */ #include "oa_soap_control.h" @@ -82,6 +102,36 @@ static SaErrorT oa_soap_get_uid_cntrl(struct oh_handler_state *oh_handler, SaHpiRptEntryT *rpt, SaHpiCtrlStateDigitalT *control_state); +static SaErrorT oa_soap_set_dynamic_pwr_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDigitalT control_state); +static SaErrorT oa_soap_get_dynamic_pwr_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDigitalT *control_state); +static SaErrorT oa_soap_set_pwr_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT control_state); +static SaErrorT oa_soap_get_pwr_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT *control_state); +static SaErrorT oa_soap_set_pwr_limit_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT control_state); +static SaErrorT oa_soap_get_pwr_limit_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT *control_state); +static SaErrorT oa_soap_set_static_pwr_limit_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT control_state); +static SaErrorT oa_soap_get_static_pwr_limit_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT *control_state); +static SaErrorT oa_soap_set_dynamic_pwr_cap_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT control_state); +static SaErrorT oa_soap_get_dynamic_pwr_cap_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT *control_state); /** * oa_soap_get_control_state @@ -125,6 +175,8 @@ SaHpiCtrlRecDigitalT *digital = NULL; SaHpiCtrlRecT *ctrl = NULL; SaHpiCtrlStateDigitalT control_digital_state; + SaHpiCtrlStateDiscreteT control_discrete_state; + SaHpiCtrlStateAnalogT control_analog_state; if (oh_handler == NULL || mode == NULL || state == NULL) { err("Invalid parameter."); @@ -186,11 +238,67 @@ return rv; } break; + case OA_SOAP_DYNAMIC_PWR_CNTRL: + rv = oa_soap_get_dynamic_pwr_cntrl(handler, resource_id, + &control_digital_state); + if (rv != SA_OK) { + err("Failed to get the dynamic power state RDR"); + return rv; + } + break; + case OA_SOAP_PWR_MODE_CNTRL: + rv = oa_soap_get_pwr_mode_cntrl(handler, resource_id, + &control_discrete_state); + if (rv != SA_OK) { + err("Failed to get the power mode state RDR"); + return rv; + } + break; + case OA_SOAP_PWR_LIMIT_MODE_CNTRL: + rv = oa_soap_get_pwr_limit_mode_cntrl(handler, resource_id, + &control_discrete_state); + if (rv != SA_OK) { + err("Failed to get the power limit mode state RDR"); + return rv; + } + break; + case OA_SOAP_STATIC_PWR_LIMIT_CNTRL: + rv = oa_soap_get_static_pwr_limit_cntrl(handler, resource_id, + &control_analog_state); + if (rv != SA_OK) { + err("Failed to get the static power limit state RDR"); + return rv; + } + break; + case OA_SOAP_DYNAMIC_PWR_CAP_CNTRL: + rv = oa_soap_get_dynamic_pwr_cap_cntrl(handler, resource_id, + &control_analog_state); + if (rv != SA_OK) { + err("Failed to get the dynamic power cap state RDR"); + return rv; + } + break; default: err("Invalid control rdr num"); return SA_ERR_HPI_INTERNAL_ERROR; } - ctrl_state.StateUnion.Digital = control_digital_state; + switch (rdr_num){ + case OA_SOAP_PWR_CNTRL: + case OA_SOAP_UID_CNTRL: + case OA_SOAP_LCD_BUTN_LCK_CNTRL: + case OA_SOAP_DYNAMIC_PWR_CNTRL: + ctrl_state.StateUnion.Digital = control_digital_state; + break; + case OA_SOAP_PWR_MODE_CNTRL: + case OA_SOAP_PWR_LIMIT_MODE_CNTRL: + ctrl_state.StateUnion.Discrete = control_discrete_state; + break; + case OA_SOAP_STATIC_PWR_LIMIT_CNTRL: + case OA_SOAP_DYNAMIC_PWR_CAP_CNTRL: + ctrl_state.StateUnion.Analog = control_analog_state; + break; + } + /* Return the appropriately mapped control state */ *state = ctrl_state; return rv; @@ -281,15 +389,27 @@ } /* Return error for Non digital type control request */ - if (state->Type != SAHPI_CTRL_TYPE_DIGITAL) { + if ((state->Type != SAHPI_CTRL_TYPE_DIGITAL) && + (state->Type != SAHPI_CTRL_TYPE_DISCRETE) && + (state->Type != SAHPI_CTRL_TYPE_ANALOG)) { err("Control type not supported"); return SA_ERR_HPI_INTERNAL_ERROR; } - /* If control mode is MANUAL and specified state is of digital type, - * then the control state is updated with specified state value + /* If control mode is MANUAL and specified state could be digital, discrete, or + * analog type, then the control state is updated with specified state value */ - ctrl->TypeUnion.Digital.Default = state->StateUnion.Digital; + if (state->Type == SAHPI_CTRL_TYPE_DIGITAL) { + ctrl->TypeUnion.Digital.Default = state->StateUnion.Digital; + } + else { + if (state->Type == SAHPI_CTRL_TYPE_DISCRETE) { + ctrl->TypeUnion.Discrete.Default = state->StateUnion.Discrete; + } + else { + ctrl->TypeUnion.Analog.Default = state->StateUnion.Analog; + } + } switch (rdr_num) { case OA_SOAP_PWR_CNTRL: rv = oa_soap_set_pwr_cntrl(handler, resource_id, @@ -315,6 +435,46 @@ return rv; } break; + case OA_SOAP_DYNAMIC_PWR_CNTRL: + rv = oa_soap_set_dynamic_pwr_cntrl(handler, resource_id, + state->StateUnion.Digital); + if (rv != SA_OK) { + err("Failed to set the dynamic power state"); + return rv; + } + break; + case OA_SOAP_PWR_MODE_CNTRL: + rv = oa_soap_set_pwr_mode_cntrl(handler, resource_id, + state->StateUnion.Discrete); + if (rv != SA_OK) { + err("Failed to set the power mode state"); + return rv; + } + break; + case OA_SOAP_PWR_LIMIT_MODE_CNTRL: + rv = oa_soap_set_pwr_limit_mode_cntrl(handler, resource_id, + state->StateUnion.Discrete); + if (rv != SA_OK) { + err("Failed to set the power limit mode state"); + return rv; + } + break; + case OA_SOAP_STATIC_PWR_LIMIT_CNTRL: + rv = oa_soap_set_static_pwr_limit_cntrl(handler, resource_id, + state->StateUnion.Analog); + if (rv != SA_OK) { + err("Failed to set the static power limit state"); + return rv; + } + break; + case OA_SOAP_DYNAMIC_PWR_CAP_CNTRL: + rv = oa_soap_set_dynamic_pwr_cap_cntrl(handler, resource_id, + state->StateUnion.Analog); + if (rv != SA_OK) { + err("Failed to set the dynamic power cap state"); + return rv; + } + break; default: err("Invalid control rdr num"); return SA_ERR_HPI_INTERNAL_ERROR; @@ -328,6 +488,8 @@ * @rdr: Pointer to the rdr structure * @resource_id: Resource ID * @control_num: Control rdr number + * @analogLimitLow: RDR lower limit for analog control + * @analogLimitHigh: RDR upper limit for analog control * * Purpose: * Builds the control rdr. @@ -344,7 +506,9 @@ SaErrorT oa_soap_build_control_rdr(struct oh_handler_state *oh_handler, SaHpiRdrT *rdr, SaHpiResourceIdT resource_id, - SaHpiCtrlNumT control_num) + SaHpiCtrlNumT control_num, + int analogLimitLow, + int analogLimitHigh) { SaHpiRptEntryT *rpt = NULL; @@ -364,9 +528,15 @@ rdr->RdrType = SAHPI_CTRL_RDR; rdr->RdrTypeUnion.CtrlRec = oa_soap_cntrl_arr[control_num].control; + oh_init_textbuffer(&(rdr->IdString)); oh_append_textbuffer(&(rdr->IdString), oa_soap_cntrl_arr[control_num].comment); + + if (rdr->RdrTypeUnion.CtrlRec.Type == SAHPI_CTRL_TYPE_ANALOG) { + rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Min = analogLimitLow; + rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Max = analogLimitHigh; + } return SA_OK; } @@ -860,6 +1030,623 @@ return SA_OK; } +/** + * oa_soap_get_dynamic_pwr_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Pointer to digital control state + * + * Purpose: + * Gets the control state of the dynamic power control on resource + * + * Detailed Description: + * - Gets the dynamic power state of resource and maps it to control state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_get_dynamic_pwr_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDigitalT *control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL || control_state == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + + /* Make a soap call to get the enclosure power config info */ + g_mutex_lock(oa_handler->mutex); + rv = soap_getPowerConfigInfo(oa_handler->active_con, + power_config_info, + &(oa_handler->desired_static_pwr_limit)); + g_mutex_unlock(oa_handler->mutex); + if (rv != SOAP_OK) { + err("Get enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + switch (power_config_info->dynamicPowerSaverEnabled) { + case HPOA_FALSE: + *control_state = SAHPI_CTRL_STATE_OFF; + break; + case HPOA_TRUE: + *control_state = SAHPI_CTRL_STATE_ON; + break; + default: + err("Invalid dynamic power state"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + return SA_OK; +} + +/** + * oa_soap_set_dynamic_pwr_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Digital control state + * + * Purpose: + * Sets the control state of the dynamic power control on resource + * + * Detailed Description: + * - Sets the dynamic power state of resource after mapping the control state + * appropriate dynamic power state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_set_dynamic_pwr_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDigitalT control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + /* Return error if the control state is PULSE_ON or PULSE_OFF */ + if ((control_state == SAHPI_CTRL_STATE_PULSE_ON) || + (control_state == SAHPI_CTRL_STATE_PULSE_OFF)) { + err("Setting the control state to PULSE ON/OFF not supported"); + return SA_ERR_HPI_INVALID_DATA; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + + if (control_state == SAHPI_CTRL_STATE_ON) { + power_config_info->dynamicPowerSaverEnabled = HPOA_TRUE; + } else { + power_config_info->dynamicPowerSaverEnabled = HPOA_FALSE; + } + + /* Make a soap call to set the enclosure power config info */ + rv = soap_setPowerConfigInfo(oa_handler->active_con, + power_config_info); + if (rv != SOAP_OK) { + err("Set enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + return SA_OK; +} + +/** + * oa_soap_get_pwr_mode_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Pointer to discrete control state + * + * Purpose: + * Gets the control state of the power mode control on resource + * + * Detailed Description: + * - Gets the power mode state of resource and maps it to control state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_get_pwr_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT *control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL || control_state == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + + /* Make a soap call to get the enclosure power config info */ + g_mutex_lock(oa_handler->mutex); + rv = soap_getPowerConfigInfo(oa_handler->active_con, + power_config_info, + &(oa_handler->desired_static_pwr_limit)); + g_mutex_unlock(oa_handler->mutex); + if (rv != SOAP_OK) { + err("Get enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + if ((power_config_info->redundancyMode < NON_REDUNDANT) || + (power_config_info->redundancyMode > POWER_SUPPLY_REDUNDANT)) { + err("Invalid power mode state"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + else { + *control_state = power_config_info->redundancyMode; + } + + return SA_OK; +} + +/** + * oa_soap_set_pwr_mode_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Discrete control state + * + * Purpose: + * Sets the control state of the power mode control on resource + * + * Detailed Description: + * - Sets the power mode state of resource after mapping the control state + * appropriate power mode state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_set_pwr_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + /* Return error if the control state is PULSE_ON or PULSE_OFF */ + if ((control_state < NON_REDUNDANT) || + (control_state > POWER_SUPPLY_REDUNDANT)) { + err("Cannot set the control state to %d - value out of range", control_state); + return SA_ERR_HPI_INVALID_DATA; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + + power_config_info->redundancyMode = control_state; + + /* Make a soap call to set the enclosure power config info */ + rv = soap_setPowerConfigInfo(oa_handler->active_con, + power_config_info); + if (rv != SOAP_OK) { + err("Set enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + return SA_OK; +} + +/** + * oa_soap_get_pwr_limit_mode_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Pointer to discrete control state + * + * Purpose: + * Gets the control state of the power limit mode control on resource + * + * Detailed Description: + * - Gets the power limit mode state of resource and maps it to control state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_get_pwr_limit_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT *control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct powerCapConfig *power_cap_config; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL || control_state == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + power_cap_config = &(oa_handler->power_cap_config); + + /* Make a soap call to get the enclosure power config info */ + g_mutex_lock(oa_handler->mutex); + rv = soap_getPowerConfigInfo(oa_handler->active_con, + power_config_info, + &(oa_handler->desired_static_pwr_limit)); + g_mutex_unlock(oa_handler->mutex); + if (rv != SOAP_OK) { + err("Get enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + /* Make a soap call to get the enclosure power dynamic power cap config */ + g_mutex_lock(oa_handler->mutex); + rv = soap_getPowerCapConfig(oa_handler->active_con, + power_cap_config, + &(oa_handler->desired_dynamic_pwr_cap)); + g_mutex_unlock(oa_handler->mutex); + if (rv != SOAP_OK) { + err("Get enclosure dynamic power cap config failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + if (power_config_info->powerCeiling > 0) { + *control_state = STATIC_POWER_LIMIT; + } + else { + if (power_cap_config->powerCap > 0) { + *control_state = DYNAMIC_POWER_CAP; + } else { + *control_state = POWER_LIMIT_NONE; + } + } + + return SA_OK; +} + +/** + * oa_soap_set_pwr_limit_mode_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Discrete control state + * + * Purpose: + * Sets the control state of the power limit mode control on resource + * + * Detailed Description: + * - Sets the power limit mode state of resource after mapping the control state + * appropriate power limit mode state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_set_pwr_limit_mode_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateDiscreteT control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct powerCapConfig *power_cap_config; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + /* Return error if the control state is out of range */ + if ((control_state < POWER_LIMIT_NONE) || + (control_state > DYNAMIC_POWER_CAP)) { + err("Cannot set the control state to %d - value out of range", control_state); + return SA_ERR_HPI_INVALID_DATA; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + power_cap_config = &(oa_handler->power_cap_config); + + if (control_state == POWER_LIMIT_NONE) { + power_config_info->powerCeiling = 0; + power_cap_config->powerCap = 0; + } else { + if (control_state == STATIC_POWER_LIMIT) { + /* Checked desired setting, if non-zero - then send it - else user error */ + if (oa_handler->desired_static_pwr_limit > 0) { + power_config_info->powerCeiling = oa_handler->desired_static_pwr_limit; + power_cap_config->powerCap = 0; + } + else { + err("Cannot set the control state to %d - no static pwr limit value has been set", + control_state); + return SA_ERR_HPI_INVALID_DATA; + } + } else { + /* DYNAMIC_POWER_CAP */ + /* Checked desired setting, if non-zero - then send it - else user error */ + if (oa_handler->desired_dynamic_pwr_cap > 0) { + power_cap_config->powerCap = oa_handler->desired_dynamic_pwr_cap; + power_config_info->powerCeiling = 0; + } + else { + err("Cannot set the control state to %d - no dynamic pwr cap value has been set", + control_state); + return SA_ERR_HPI_INVALID_DATA; + } + } + } + + /* Make soaps calls to set the enclosure power config info, and dynamic power cap config */ + if (control_state == POWER_LIMIT_NONE) { + /* Must turn off dynamic power cap config, and reset power config info */ + rv = soap_setPowerCapConfig(oa_handler->active_con, + power_cap_config); + if (rv != SOAP_OK) { + err("Set enclosure power cap config failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + rv = soap_setPowerConfigInfo(oa_handler->active_con, + power_config_info); + if (rv != SOAP_OK) { + err("Set enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + } else { + if (control_state == STATIC_POWER_LIMIT) { + /* Make a soap call to set the enclosure power config info */ + rv = soap_setPowerConfigInfo(oa_handler->active_con, + power_config_info); + if (rv != SOAP_OK) { + err("Set enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + } + else { + /* DYNAMIC_POWER_CAP */ + /* Make a soap call to set the enclosure power cap config */ + rv = soap_setPowerCapConfig(oa_handler->active_con, + power_cap_config); + if (rv != SOAP_OK) { + err("Set enclosure power cap config failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + } + } + + return SA_OK; +} + +/** + * oa_soap_get_static_pwr_limit_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Pointer to analog control state + * + * Purpose: + * Gets the control state of the static power limit control on resource + * + * Detailed Description: + * - Gets the static power limit state of resource and maps it to control state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_get_static_pwr_limit_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT *control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL || control_state == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + + /* Make a soap call to get the enclosure power config info */ + g_mutex_lock(oa_handler->mutex); + rv = soap_getPowerConfigInfo(oa_handler->active_con, + power_config_info, + &(oa_handler->desired_static_pwr_limit)); + g_mutex_unlock(oa_handler->mutex); + if (rv != SOAP_OK) { + err("Get enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + /* Always report the OA view of the static power limit - regardless of the user's desired setting */ + *control_state = power_config_info->powerCeiling; + + return SA_OK; +} + +/** + * oa_soap_set_static_pwr_limit_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Analog control state + * + * Purpose: + * Sets the control state of the static power limit control on resource + * + * Detailed Description: + * - Sets the static power limit state of resource after mapping the control state + * appropriate static power limit state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_set_static_pwr_limit_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + + oa_handler->desired_static_pwr_limit = control_state; + + /* If user already has the static power limit turned on, then let this new value go thru */ + if (power_config_info->powerCeiling != 0) { + power_config_info->powerCeiling = control_state; + + /* Make a soap call to set the enclosure power config info */ + rv = soap_setPowerConfigInfo(oa_handler->active_con, + power_config_info); + if (rv != SOAP_OK) { + err("Set enclosure power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + } + + return SA_OK; +} + +/** + * oa_soap_get_dyanmic_pwr_cap_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Pointer to analog control state + * + * Purpose: + * Gets the control state of the dynamic power cap control on resource + * + * Detailed Description: + * - Gets the dynamic power cap state of resource and maps it to control state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_get_dynamic_pwr_cap_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT *control_state) +{ + SaErrorT rv = SA_OK; + struct powerCapConfig *power_cap_config; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL || control_state == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_cap_config = &(oa_handler->power_cap_config); + + /* Make a soap call to get the enclosure power cap config */ + g_mutex_lock(oa_handler->mutex); + rv = soap_getPowerCapConfig(oa_handler->active_con, + power_cap_config, + &(oa_handler->desired_dynamic_pwr_cap)); + g_mutex_unlock(oa_handler->mutex); + if (rv != SOAP_OK) { + err("Get enclosure power cap config failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + /* Always report the OA view of the dynamic power cap - regardless of the user's desired setting */ + *control_state = power_cap_config->powerCap; + + return SA_OK; +} + +/** + * oa_soap_set_dynamic_pwr_cap_cntrl: + * @oh_handler: Handler data pointer + * @resource_id: Resource id + * @control state: Analog control state + * + * Purpose: + * Sets the control state of the dynamic power cap control on resource + * + * Detailed Description: + * - Sets the dynamic power cap state of resource after mapping the control state + * appropriate dynamic power cap state + * + * Return values: + * SA_OK - Normal case. + * SA_ERR_HPI_INVALID_PARAMS - On wrong parameter + * SA_ERR_HPI_INTERNAL_ERROR - Internal error encountered + **/ +static SaErrorT oa_soap_set_dynamic_pwr_cap_cntrl(struct oh_handler_state *oh_handler, + SaHpiResourceIdT resource_id, + SaHpiCtrlStateAnalogT control_state) +{ + SaErrorT rv = SA_OK; + struct powerConfigInfo *power_config_info; + struct powerCapConfig *power_cap_config; + struct oa_soap_handler *oa_handler = NULL; + + if (oh_handler == NULL) { + err("Invalid parameters"); + return SA_ERR_HPI_INVALID_PARAMS; + } + + oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + power_cap_config = &(oa_handler->power_cap_config); + + oa_handler->desired_dynamic_pwr_cap = control_state; + + /* If user already has the dynamic power cap turned on, then let this new value go thru */ + if (power_cap_config->powerCap != 0) { + power_cap_config->powerCap = control_state; + + /* Make a soap call to set the enclosure power cap config */ + rv = soap_setPowerCapConfig(oa_handler->active_con, + power_cap_config); + if (rv != SOAP_OK) { + err("Set enclosure power cap config failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + } + + return SA_OK; +} + void *oh_get_control_state (void *, SaHpiResourceIdT, SaHpiCtrlNumT, Modified: openhpi/trunk/plugins/oa_soap/oa_soap_control.h =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap_control.h 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap_control.h 2010-04-16 21:24:41 UTC (rev 7063) @@ -59,9 +59,12 @@ SaHpiCtrlModeT mode, SaHpiCtrlStateT *state); +/* Set analog limits to 0 if building a non-analog control. */ SaErrorT oa_soap_build_control_rdr(struct oh_handler_state *oh_handler, SaHpiRdrT *rdr, SaHpiResourceIdT resource_id, - SaHpiCtrlNumT control_num); + SaHpiCtrlNumT control_num, + int analogLimitLow, + int analogLimitHigh); #endif Modified: openhpi/trunk/plugins/oa_soap/oa_soap_discover.c =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap_discover.c 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap_discover.c 2010-04-16 21:24:41 UTC (rev 7063) @@ -983,7 +983,7 @@ diag_ex_status[DIAG_EX_DEV_NOT_SUPPORT]) /* Build UID control rdr for Enclosure */ - OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL) + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL, 0, 0) return SA_OK; } @@ -1216,7 +1216,7 @@ thermal_response) /* Build UID control rdr for OA */ - OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL) + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL, 0, 0) status_request.bayNumber = response->bayNumber; rv = soap_getOaStatus(con, &status_request, &status_response); @@ -1735,10 +1735,10 @@ if (rpt->ResourceEntity.Entry[0].EntityType == SAHPI_ENT_SYSTEM_BLADE) { /* Build power control rdr for server */ - OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_PWR_CNTRL) + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_PWR_CNTRL, 0, 0) } /* Build UID control rdr for server */ - OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL) + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL, 0, 0) status_request.bayNumber = bay_number; rv = soap_getBladeStatus(con, &status_request, &status_response); @@ -2202,10 +2202,10 @@ thermal_response) /* Build power control rdr for server */ - OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_PWR_CNTRL) + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_PWR_CNTRL, 0, 0) /* Build UID control rdr for server */ - OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL) + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_UID_CNTRL, 0, 0) status_request.bayNumber = bay_number; rv = soap_getInterconnectTrayStatus(con, &status_request, @@ -2438,7 +2438,8 @@ memset(&rpt, 0, sizeof(SaHpiRptEntryT)); rpt.ResourceCapabilities = SAHPI_CAPABILITY_RDR | SAHPI_CAPABILITY_RESOURCE | - SAHPI_CAPABILITY_SENSOR; + SAHPI_CAPABILITY_SENSOR | + SAHPI_CAPABILITY_CONTROL; rpt.ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT; rpt.ResourceEntity.Entry[1].EntityLocation = 0; rpt.ResourceEntity.Entry[0].EntityType = SAHPI_ENT_POWER_MGMNT; @@ -2500,12 +2501,22 @@ struct powerSubsystemInfo response; SaHpiInt32T sensor_status; + struct powerConfigInfo *power_config_info; + struct powerCapConfig *power_cap_config; + xmlNode *extra_data; + struct extraDataInfo extra_data_info; + if (oh_handler == NULL) { err("Invalid parameter"); return SA_ERR_HPI_INVALID_PARAMS; } oa_handler = (struct oa_soap_handler *) oh_handler->data; + power_config_info = &(oa_handler->power_config_info); + power_cap_config = &(oa_handler->power_cap_config); + /* Initialize user's desired static power limit - and dynamic power cap to zero to start with */ + oa_handler->desired_static_pwr_limit = 0; + oa_handler->desired_dynamic_pwr_cap = 0; /* Build the input power sensor RDR */ OA_SOAP_BUILD_SENSOR_RDR(OA_SOAP_SEN_IN_PWR) @@ -2519,12 +2530,51 @@ /* Build the power capacity sensor RDR */ OA_SOAP_BUILD_SENSOR_RDR(OA_SOAP_SEN_PWR_CAPACITY) + /* Make a soap call to get the enclosure power config info */ + rv = soap_getPowerConfigInfo(oa_handler->active_con, + power_config_info, + &(oa_handler->desired_static_pwr_limit)); + if (rv != SOAP_OK) { + err("build_power_subsystem get power config info failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + /* Make a soap call to get the enclosure power cap config */ + rv = soap_getPowerCapConfig(oa_handler->active_con, + power_cap_config, + &(oa_handler->desired_dynamic_pwr_cap)); + if (rv != SOAP_OK) { + err("build_power_subsystem get power cap config failed"); + return SA_ERR_HPI_INTERNAL_ERROR; + } + + /* Build power mode control rdr for Enclosure */ + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_PWR_MODE_CNTRL, 0, 0) + + /* Build dynamic power control rdr for Enclosure */ + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_DYNAMIC_PWR_CNTRL, 0, 0); + + /* Build power limit mode control rdr for Enclosure */ + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_PWR_LIMIT_MODE_CNTRL, 0, 0) + rv = soap_getPowerSubsystemInfo(oa_handler->active_con, &response); if (rv != SOAP_OK) { err("Get power subsystem info SOAP call failed"); return SA_ERR_HPI_INTERNAL_ERROR; } + extra_data = response.extraData; + while (extra_data) { + soap_getExtraData(extra_data, &extra_data_info); + if (!(strcmp(extra_data_info.name, "ACLimitLow"))) { + power_config_info->ACLimitLow = atoi(extra_data_info.value); + } + if (!(strcmp(extra_data_info.name, "ACLimitHigh"))) { + power_config_info->ACLimitHigh = atoi(extra_data_info.value); + } + extra_data = soap_next_node(extra_data); + } + /* Build operational status sensor rdr */ OA_SOAP_BUILD_ENABLE_SENSOR_RDR(OA_SOAP_SEN_OPER_STATUS, response.operationalStatus) @@ -2537,6 +2587,16 @@ OA_SOAP_BUILD_ENABLE_SENSOR_RDR(OA_SOAP_SEN_REDUND, response.redundancy) + /* Build static power limit control for Enclosure */ + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_STATIC_PWR_LIMIT_CNTRL, + power_config_info->ACLimitLow, + power_config_info->ACLimitHigh) + + /* Build dynamic power cap config control rdr for Enclosure */ + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_DYNAMIC_PWR_CAP_CNTRL, + power_cap_config->enclosurePowerCapLowerBound, + power_cap_config->enclosurePowerCapUpperBound); + return SA_OK; } @@ -3608,7 +3668,7 @@ } /* Build LCD button lock control rdr */ - OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_LCD_BUTN_LCK_CNTRL) + OA_SOAP_BUILD_CONTROL_RDR(OA_SOAP_LCD_BUTN_LCK_CNTRL, 0, 0) /* Build operational status sensor rdr */ rv = soap_getLcdStatus(oa_handler->active_con, &status); Modified: openhpi/trunk/plugins/oa_soap/oa_soap_discover.h =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap_discover.h 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap_discover.h 2010-04-16 21:24:41 UTC (rev 7063) @@ -131,12 +131,13 @@ } \ } -/* Builds the control rdr */ -#define OA_SOAP_BUILD_CONTROL_RDR(control_num) \ +/* Builds the control rdr. */ +/* Set analog limits to 0 if building a non-analog control. */ +#define OA_SOAP_BUILD_CONTROL_RDR(control_num, analogLimitLow, analogLimitHigh) \ { \ memset(&rdr, 0, sizeof(SaHpiRdrT)); \ rv = oa_soap_build_control_rdr(oh_handler, &rdr, resource_id, \ - control_num); \ + control_num, analogLimitLow, analogLimitHigh); \ if (rv != SA_OK) { \ err("Failed to create rdr for control %x", control_num);\ return rv; \ Modified: openhpi/trunk/plugins/oa_soap/oa_soap_event.c =================================================================== --- openhpi/trunk/plugins/oa_soap/oa_soap_event.c 2010-04-15 10:51:55 UTC (rev 7062) +++ openhpi/trunk/plugins/oa_soap/oa_soap_event.c 2010-04-16 21:24:41 UTC (rev 7063) @@ -1120,6 +1120,9 @@ case EVENT_ENC_WIZARD_STATUS: dbg("EVENT_ENC_WIZARD_STATUS -- Not processed"); break; + ... [truncated message content] |