Пример #1
0
SaHpiRdrT *ohoi_get_rdr_by_data(RPTable *table,
                                SaHpiResourceIdT rid,
                                SaHpiRdrTypeT  type, 
                                void  *data)
{
        SaHpiRdrT *rdr;
        
        rdr = oh_get_rdr_next(table, rid, SAHPI_FIRST_ENTRY);

        while (rdr) {
              void * data2;

              data2 = oh_get_rdr_data(table, rid, rdr->RecordId);
              if ((type == SAHPI_SENSOR_RDR) && (rdr->RdrType == type)) {
                      ipmi_sensor_id_t *tid1 = data;
                      ipmi_sensor_id_t *tid2 = data2;
                      if (tid1 && tid2) {
                              if (!ipmi_cmp_sensor_id(*tid1, *tid2))
                                      return rdr;
                      }
              }

              rdr = oh_get_rdr_next(table, rid, rdr->RecordId);
        }
        return NULL;
}
Пример #2
0
/**
 * rpt_diff
 * @cur_rpt: IN. Pointer to RPTable that represents the current state of resources
 * and rdrs.
 * @new_rpt: IN. Pointer to RPTable that contains rpt entries and rdrs just recently
 * discovered.
 * @res_new: OUT. List of new or changed rpt entries
 * @rdr_new: OUT. List of new or changed rdrs
 * @res_gone: OUT. List of old and not present resources.
 * @rdr_gone: OUT. List of old and not present rdrs.
 *
 * Extracts from current the resources and rdrs that are not found
 * in new and puts them in res_gone and rdr_gone. Also, puts in res_new and rdr_new
 * the resources and rdrs that are not already in current Or that are not identical
 * to the ones in current.
 *
 * Returns: void.
 **/
void rpt_diff(RPTable *cur_rpt, RPTable *new_rpt,
              GSList **res_new, GSList **rdr_new,
              GSList **res_gone, GSList **rdr_gone) {

        SaHpiRptEntryT *res = NULL;

        if (!cur_rpt || !new_rpt ||
            !res_new || !rdr_new || !res_gone || !rdr_gone) return;

        /* Look for absent resources and rdrs */
        for (res = oh_get_resource_by_id(cur_rpt, SAHPI_FIRST_ENTRY);
             res != NULL;
             res = oh_get_resource_next(cur_rpt, res->ResourceId)) {

                SaHpiRptEntryT *tmp_res = oh_get_resource_by_id(new_rpt, res->ResourceId);

                if (tmp_res == NULL) *res_gone = g_slist_append(*res_gone, (gpointer)res);
                else {
                        SaHpiRdrT *rdr = NULL;

                        for (rdr = oh_get_rdr_by_id(cur_rpt, res->ResourceId, SAHPI_FIRST_ENTRY);
                             rdr != NULL;
                             rdr = oh_get_rdr_next(cur_rpt, res->ResourceId, rdr->RecordId)) {

                                SaHpiRdrT *tmp_rdr =
                                        oh_get_rdr_by_id(new_rpt, res->ResourceId, rdr->RecordId);

                                if (tmp_rdr == NULL)
                                        *rdr_gone = g_slist_append(*rdr_gone, (gpointer)rdr);
                        }
                }
        }

        /* Look for new resources and rdrs*/
        for (res = oh_get_resource_by_id(new_rpt, SAHPI_FIRST_ENTRY);
             res != NULL;
             res = oh_get_resource_next(new_rpt, res->ResourceId)) {

                SaHpiRptEntryT *tmp_res = oh_get_resource_by_id(cur_rpt, res->ResourceId);
                SaHpiRdrT *rdr = NULL;
                if (tmp_res == NULL || memcmp(res, tmp_res, sizeof(SaHpiRptEntryT))) {
                        *res_new = g_slist_append(*res_new, (gpointer)res);
                }

                for (rdr = oh_get_rdr_by_id(new_rpt, res->ResourceId, SAHPI_FIRST_ENTRY);
                     rdr != NULL;
                     rdr = oh_get_rdr_next(new_rpt, res->ResourceId, rdr->RecordId)) {

                        SaHpiRdrT *tmp_rdr = NULL;

                        if (tmp_res != NULL)
                                tmp_rdr = oh_get_rdr_by_id(cur_rpt, res->ResourceId, rdr->RecordId);

                        if (tmp_rdr == NULL || memcmp(rdr, tmp_rdr, sizeof(SaHpiRdrT)))
                                *rdr_new = g_slist_append(*rdr_new, (gpointer)rdr);

                }
        }
}
Пример #3
0
/* need to update some information here */
static void entity_update_rpt(RPTable *table, SaHpiResourceIdT rid, int present)
{
	SaHpiRdrT  *rdr;

	rdr = oh_get_rdr_next(table, rid, SAHPI_FIRST_ENTRY);
	while (rdr) {
		if(rdr->RdrType == SAHPI_SENSOR_RDR) {
		}
		rdr = oh_get_rdr_next(table, rid, rdr->RecordId);
	}
}
Пример #4
0
/**
 * main: Starts with an RPTable of 10 resources, adds 5 rdr
 * to first resource. Fetches sensors ++in sequence by record id and compares
 * with original. A failed comparison means the test failed,
 * otherwise the test passed.
 *
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv)
{
        RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable));
        oh_init_rpt(rptable);
        SaHpiRdrT *tmprdr = NULL;
        guint i = 0;

        for (i = 0; rptentries[i].ResourceId != 0; i++) {
                if (oh_add_resource(rptable, rptentries + i, NULL, 0))
                        return 1;
        }

        for (i = 0; i < 5; i++) {
                if (oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, sensors + i, NULL,0))
                        return 1;                
        }

        for (i = 0, tmprdr = oh_get_rdr_by_id(rptable, SAHPI_FIRST_ENTRY, SAHPI_FIRST_ENTRY);
             tmprdr;
             tmprdr = oh_get_rdr_next(rptable, SAHPI_FIRST_ENTRY, tmprdr->RecordId)) {
                if (memcmp(sensors + (i++), tmprdr, sizeof(SaHpiRdrT)))
                        return 1;                
        }

        return 0;
}
Пример #5
0
static void entity_update_rpt(RPTable *table, SaHpiResourceIdT rid, int present)
{
	SaHpiRdrT  *rdr;

	rdr = oh_get_rdr_next(table, rid, SAHPI_FIRST_ENTRY);
	while (rdr) {
		if(rdr->RdrType == SAHPI_SENSOR_RDR) {
#if 0
			if (present) {
				dbg("present");
				rdr->RdrTypeUnion.SensorRec.Ignore = SAHPI_FALSE;
			}else {
				dbg("not present");
				rdr->RdrTypeUnion.SensorRec.Ignore = SAHPI_TRUE;
			}
#endif
		}
		rdr = oh_get_rdr_next(table, rid, rdr->RecordId);
	}
}
Пример #6
0
int eventq_event_add(struct oh_handler_state *oh_hnd)
{
	struct oh_event event;
	SaHpiRptEntryT *rpt_entry;
	SaHpiRdrT      *rdr_entry;

	/* get the first rpt entry */
	
	rpt_entry = oh_get_resource_next(oh_hnd->rptcache, RPT_ENTRY_BEGIN);
	
	while (rpt_entry) {
		memset(&event, 0, sizeof(event));
		event.type = OH_ET_RESOURCE;
		memcpy(&event.u.res_event.entry, rpt_entry, sizeof(SaHpiRptEntryT));
		oh_hnd->eventq = g_slist_append(oh_hnd->eventq, eventdup(&event) );
	
	
		/* get every resource rdr's */
		rdr_entry = oh_get_rdr_next(oh_hnd->rptcache, 
					    rpt_entry->ResourceId, 
					    RDR_BEGIN);
		while (rdr_entry) {
			memset(&event, 0, sizeof(event));
			event.type = OH_ET_RDR;
			memcpy(&event.u.rdr_event.rdr, rdr_entry, sizeof(SaHpiRdrT));
			oh_hnd->eventq = g_slist_append(oh_hnd->eventq, eventdup(&event));
			rdr_entry = oh_get_rdr_next(oh_hnd->rptcache, 
						    rpt_entry->ResourceId, 
						    rdr_entry->RecordId);
		}
		/* get any resource rdr's end */
	
	
		rpt_entry = oh_get_resource_next(oh_hnd->rptcache, rpt_entry->ResourceId);
	}

	
	return SA_OK;
}
Пример #7
0
/**
 * main: Starts with an RPTable of 1 resource, adds 5 rdrs to first resource.
 * Fetches an rdr using get_next with the Record Id as RDR_BEGIN.
 * Success if the interface returns a valid pointer, otherwise there was a failure.
 *
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv)
{
        RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable));
        guint i;

        if (oh_add_resource(rptable, rptentries, NULL, 1))
                return 1;

        for (i = 0; i < 5; i++) {
                if (oh_add_rdr(rptable, rptentries[0].ResourceId, rdrs+i, NULL, 1))
                        return 1;
        }

        if (!oh_get_rdr_next(rptable, rptentries[0].ResourceId, RDR_BEGIN))
                return 1;

        return 0;
}
Пример #8
0
/* Per IPMI spec., one FRU per entity */
void ohoi_inventory_event(enum ipmi_update_e    op,
                          ipmi_entity_t         *entity,
                          void                  *cb_data)
{
       struct oh_handler_state  *handler = cb_data;
       struct ohoi_resource_info *res_info;

       ipmi_entity_id_t         entity_id;
       SaHpiRptEntryT           *rpt_entry;

       entity_id = ipmi_entity_convert_to_id(entity);
       
       rpt_entry = ohoi_get_resource_by_entityid(
                       handler->rptcache,
                       &entity_id);
       if (!rpt_entry) {
		trace_ipmi_fru("NO RPT ENTRY", entity);
		dump_entity_id("FRU without RPT entry?!", entity_id);
		return;
       }

       res_info = oh_get_resource_data(handler->rptcache,
				       rpt_entry->ResourceId);
       if (op == IPMI_ADDED) {
		trace_ipmi_fru("ADDED", entity);
		add_inventory_event(res_info, entity, handler, rpt_entry);
	} else if (op == IPMI_DELETED) {
		trace_ipmi_fru("DELETED", entity);
		ohoi_delete_rpt_fru(res_info);
		rpt_entry->ResourceCapabilities &= ~SAHPI_CAPABILITY_INVENTORY_DATA;
		if (oh_get_rdr_next(handler->rptcache, rpt_entry->ResourceId,
					 SAHPI_FIRST_ENTRY) == NULL) {
			rpt_entry->ResourceCapabilities &= ~SAHPI_CAPABILITY_RDR;
		}
	}
	trace_ipmi("Set updated for res_info %p(%d). Inventory",
		res_info, rpt_entry->ResourceId);
	entity_rpt_set_updated(res_info, handler->data);;
			   
}
Пример #9
0
void ohoi_control_event(enum ipmi_update_e op,
                        ipmi_entity_t      *ent,
                        ipmi_control_t     *control,
                        void               *cb_data)
{
    struct oh_handler_state *handler = cb_data;
    struct ohoi_handler *ipmi_handler = handler->data;
    struct ohoi_resource_info *ohoi_res_info;
    int ctrl_type = ipmi_control_get_type(control);
    ipmi_control_id_t cid = ipmi_control_convert_to_id(control);


    ipmi_entity_id_t	entity_id;
    SaHpiRptEntryT		*rpt_entry;
    char str[24];
    int rv;

    entity_id = ipmi_entity_convert_to_id(ent);
    rpt_entry = ohoi_get_resource_by_entityid(handler->rptcache,
                &entity_id);

    if (!rpt_entry) {
        dump_entity_id("Control with RPT Entry?!", entity_id);
        return;
    }

    g_static_rec_mutex_lock(&ipmi_handler->ohoih_lock);
    ohoi_res_info = oh_get_resource_data(handler->rptcache,
                                         rpt_entry->ResourceId);

    if (op == IPMI_ADDED) {
        trace_ipmi_control("ADD", control, rpt_entry);
        /* attach power and reset to chassis entity since
           IPMI provides them as such */
        switch (ctrl_type) {
        case IPMI_CONTROL_ONE_SHOT_RESET:
            ohoi_res_info->reset_ctrl = cid;
            rpt_entry->ResourceCapabilities |=
                SAHPI_CAPABILITY_RESET;
            break;
        case IPMI_CONTROL_POWER:
            if ((ipmi_handler->d_type == IPMI_DOMAIN_TYPE_ATCA) &&
                    (ipmi_entity_get_entity_id(ent) ==
                     SAHPI_ENT_SYSTEM_CHASSIS)) {
                // never power off ATCA chassis
                break;
            }
            ohoi_res_info->power_ctrl = cid;
            rpt_entry->ResourceCapabilities |=
                SAHPI_CAPABILITY_POWER;
            break;
        case IPMI_CONTROL_ALARM:
            rv = add_alarm_rdrs(handler,rpt_entry,control);
            if (rv) {
                dbg("add_alarms_rdrs failed");
                break;
            }
            rpt_entry->ResourceCapabilities |=
                SAHPI_CAPABILITY_CONTROL |
                SAHPI_CAPABILITY_RDR;
            break;
        case IPMI_CONTROL_IDENTIFIER:
#if 0
            rv = address_control_get(control,handler, ent, rpt_entry);
            if (rv) {
                dbg("address_control_get failed");
                break;
            }
            rpt_entry->ResourceCapabilities |=
                SAHPI_CAPABILITY_CONTROL |
                SAHPI_CAPABILITY_RDR;
#endif
            break;
        case IPMI_CONTROL_LIGHT:
            ipmi_control_get_id(control, str, 24);
            if (add_led_control_event(ent, control, handler, rpt_entry)) {
                break;
            }
            rpt_entry->ResourceCapabilities |=
                SAHPI_CAPABILITY_CONTROL |
                SAHPI_CAPABILITY_RDR;
            break;
        default:
            if (SA_OK != add_control_event(ent, control, handler,
                                           rpt_entry->ResourceEntity,
                                           rpt_entry->ResourceId)) {
                break;
            }
            rpt_entry->ResourceCapabilities |=
                SAHPI_CAPABILITY_CONTROL |
                SAHPI_CAPABILITY_RDR;
            break;
        }
    } else if (op == IPMI_DELETED) {
        trace_ipmi_control("DELETE", control, rpt_entry);
        switch (ctrl_type) {
        case IPMI_CONTROL_ONE_SHOT_RESET:
            ipmi_control_id_set_invalid(
                &ohoi_res_info->reset_ctrl);
            rpt_entry->ResourceCapabilities &=
                ~SAHPI_CAPABILITY_RESET;
            break;
        case IPMI_CONTROL_POWER:
            ipmi_control_id_set_invalid(
                &ohoi_res_info->power_ctrl);
            rpt_entry->ResourceCapabilities &=
                ~SAHPI_CAPABILITY_POWER;
            break;
        default:
            if (ohoi_delete_orig_control_rdr(handler,
                                             rpt_entry, &cid)) {
                // no more controlss for rpt
                rpt_entry->ResourceCapabilities &=
                    ~SAHPI_CAPABILITY_CONTROL;
                ohoi_res_info->ctrl_count = 0;
            }
            break;
        }
        if ((oh_get_rdr_next(handler->rptcache, rpt_entry->ResourceId,
                             SAHPI_FIRST_ENTRY) == NULL) &&
                (ohoi_res_info->fru == NULL)) {
            // no more rdrs for rpt
            rpt_entry->ResourceCapabilities &=
                ~SAHPI_CAPABILITY_RDR;
        }
    }
    trace_ipmi("Set updated for res_info %p(%d). Control", ohoi_res_info, rpt_entry->ResourceId);
    entity_rpt_set_updated(ohoi_res_info, ipmi_handler);
    g_static_rec_mutex_unlock(&ipmi_handler->ohoih_lock);
}
Пример #10
0
/**
 * oa_soap_push_power_events
 *      @oh_handler     : Pointer to openhpi handler structure
 *      @info           : Pointer to power subsystem info structure
 *      @resource_id    : Power subsystem resource id
 *
 * Purpose:
 *      Pushes changes to oa_power controls upstream to HPI domain
 *
 * Detailed Description: NA
 *
 * Return values:
 *      NONE
 **/
void oa_soap_push_power_events(struct oh_handler_state *oh_handler,
                               struct powerSubsystemInfo *info,
                               SaHpiResourceIdT resource_id)
{
        struct oa_soap_handler *oa_handler;
        SaErrorT rv = SA_OK;
        SaHpiRptEntryT *rpt = NULL;
        SaHpiRdrT *rdr = NULL;
        struct powerConfigInfo *power_config_info;
        struct powerCapConfig *power_cap_config;
        xmlNode *extra_data;
        struct extraDataInfo extra_data_info;
        struct oh_event event;
        int oldMin = 0, oldMax = 0;
        int oldMinDerated = 0, oldMaxDerated = 0;
        int oldMinRated = 0, oldMaxRated = 0;
        int newMin = 0, newMax = 0;
        
        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);

        extra_data = info->extraData;
        while (extra_data) {
                soap_getExtraData(extra_data, &extra_data_info);
                if (!(strcmp(extra_data_info.name, "ACLimitLow"))) {
                  newMin = atoi(extra_data_info.value);
                }
                if (!(strcmp(extra_data_info.name, "ACLimitHigh"))) {
                  newMax = atoi(extra_data_info.value);
                }
                extra_data = soap_next_node(extra_data);
        }

        /* If we have a new ACLimitLow or a new ACLimitHigh, then we need to */
        /* push an oh_event                                                  */
        if ((power_config_info->ACLimitLow != newMin) ||
            (power_config_info->ACLimitHigh != newMax)) {
            /* Need to re-build static power limit control for enclosure */
            dbg("Static power limits have changed\n");
            dbg("New static power limit low: %d\n", newMin);
            dbg("New static power limit high: %d\n", newMax);

            rpt = oh_get_resource_by_id(oh_handler->rptcache, resource_id);
            rdr = oh_get_rdr_next(oh_handler->rptcache, rpt->ResourceId,
                                  SAHPI_FIRST_ENTRY);

            while (rdr) {
                if (rdr->RdrType == SAHPI_CTRL_RDR) {
                    /* Test to see if this is the static power limit  */
                    /* control rdr                                    */
                    if (rdr->RdrTypeUnion.CtrlRec.Num ==
                        OA_SOAP_STATIC_PWR_LIMIT_CNTRL) {
                        power_config_info->ACLimitLow = newMin;
                        power_config_info->ACLimitHigh = newMax;
                        rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Min = newMin;
                        rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Max = newMax;

                        /* We need to constuct/send an oh_event to update the */
                        /* HPI domain                                         */
                        memset(&event, 0, sizeof(struct oh_event));
                        event.event.EventType = SAHPI_ET_RESOURCE;
                        memcpy(&event.resource, rpt, sizeof(SaHpiRptEntryT));
                        event.event.Severity = SAHPI_INFORMATIONAL;
                        event.event.Source = event.resource.ResourceId;
                        if (oh_gettimeofday(&(event.event.Timestamp))
                            != SA_OK) {
                            event.event.Timestamp = SAHPI_TIME_UNSPECIFIED;
                        }
                        event.event.EventDataUnion.ResourceEvent.
                          ResourceEventType = SAHPI_RESE_RESOURCE_UPDATED;
                        event.rdrs = g_slist_append(event.rdrs, g_memdup(rdr,
                                                    sizeof(SaHpiRdrT)));
                        event.hid = oh_handler->hid;

                        oh_evt_queue_push(oh_handler->eventq,
                                          copy_oa_soap_event(&event));
                        break;
                    }
                }
                rdr = oh_get_rdr_next(oh_handler->rptcache,
                                  rpt->ResourceId,
                                  rdr->RecordId);
                if (rdr == NULL) {
                        err("Did not find static power limit control rdr");
                }
            }
        }

        /* Since we do not get the EVENT_ENC_GRP_CAP event - which is  */
        /* supposed to contain new dynamic power cap limits, we will   */
        /* instead query for the latest powerCapConfig, and and        */
        /* inspect the returned data to see if the dynamic power cap   */
        /* limits have changed. We also inspect the derated and rated  */
        /* circuit caps for OA firmware 3.00 and higher. If the limits */
        /* have changed, then construct oh_event and push it to the    */
        /* HPI domain.                                                 */

        /* Save the old limit values for comparison later              */
        oldMin = power_cap_config->enclosurePowerCapLowerBound;
        oldMax = power_cap_config->enclosurePowerCapUpperBound;
        oldMinDerated = power_cap_config->deratedCircuitCapLowerBound;
        oldMaxDerated = power_cap_config->deratedCircuitCapUpperBound;
        oldMinRated = power_cap_config->ratedCircuitCapLowerBound;
        oldMaxRated = power_cap_config->ratedCircuitCapUpperBound;

        /* Make a soap call to get the enclosure power cap config which */
        /* may contain new dynamic power cap limits                     */
        dbg("\n Threadid=%p \n",g_thread_self());

        rv = soap_getPowerCapConfig(oa_handler->active_con,
                                    power_cap_config,
                                    &(oa_handler->desired_dynamic_pwr_cap),
                                    &(oa_handler->desired_derated_circuit_cap),
                                    &(oa_handler->desired_rated_circuit_cap));

        if (rv != SOAP_OK) {
                err("Getting the power cap config failed");
                return;
        }

        newMin = power_cap_config->enclosurePowerCapLowerBound;
        newMax = power_cap_config->enclosurePowerCapUpperBound;

        /* If we have a new enclosurePowerCapLowerBound or a new         */
        /* enclosurePowerCapUpperBound then we need to push an oh_event. */
        if ((newMin != oldMin) || (newMax != oldMax)) {
            /* Need to re-build dynamic power cap control for enclosure */
            dbg("Dynamic power cap has changed\n");
            dbg("New dynamic power cap low: %d\n", newMin);
            dbg("New dynamic power cap high: %d\n", newMax);

            rpt = oh_get_resource_by_id(oh_handler->rptcache, resource_id);
            rdr = oh_get_rdr_next(oh_handler->rptcache, rpt->ResourceId,
                  SAHPI_FIRST_ENTRY);

            while (rdr) {
                if (rdr->RdrType == SAHPI_CTRL_RDR) {
                    /* Test to see if this is the dynamic power cap control  */
                    /* rdr                                                   */
                    if (rdr->RdrTypeUnion.CtrlRec.Num ==
                        OA_SOAP_DYNAMIC_PWR_CAP_CNTRL) {
                        rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Min = newMin;
                        rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Max = newMax;

                        /* We need to constuct/send an oh_event to update the */
                        /* HPI domain                                         */
                        memset(&event, 0, sizeof(struct oh_event));
                        event.event.EventType = SAHPI_ET_RESOURCE;
                        memcpy(&event.resource, rpt, sizeof(SaHpiRptEntryT));
                        event.event.Severity = SAHPI_INFORMATIONAL;
                        event.event.Source = event.resource.ResourceId;
                        if (oh_gettimeofday(&(event.event.Timestamp))
                            != SA_OK) {
                            event.event.Timestamp = SAHPI_TIME_UNSPECIFIED;
                        }
                        event.event.EventDataUnion.ResourceEvent.
                          ResourceEventType = SAHPI_RESE_RESOURCE_UPDATED;
                        event.rdrs = g_slist_append(event.rdrs, g_memdup(rdr,
                                                    sizeof(SaHpiRdrT)));
                        event.hid = oh_handler->hid;

                        oh_evt_queue_push(oh_handler->eventq,
                                          copy_oa_soap_event(&event));
                        break;
                    }
                }
                rdr = oh_get_rdr_next(oh_handler->rptcache,
                                      rpt->ResourceId,
                                      rdr->RecordId);
                if (rdr == NULL) {
                        err("Did not find dynamic power cap control rdr");
                }
            }
        }

        /* Check the OA firmware version.  For OA firmware 3.00 and higher, */
        /* we have to check if the limits for derated and rated circuit     */
        /* caps have changed.                                               */
        if (oa_handler->active_fm_ver >= 3.0) {
            /* Check derated circuit cap limits for changes. */
            newMin = power_cap_config->deratedCircuitCapLowerBound;
            newMax = power_cap_config->deratedCircuitCapUpperBound;
            if ((newMin != oldMinDerated) || (newMax != oldMaxDerated)) {
                /* Need to re-build derated circuit cap control for enclosure */
                dbg("Derated circuit cap has changed\n");
                dbg("New derated circuit cap low: %d\n", newMin);
                dbg("New derated circuit cap high: %d\n", newMax);

                rpt = oh_get_resource_by_id(oh_handler->rptcache, resource_id);
                rdr = oh_get_rdr_next(oh_handler->rptcache, rpt->ResourceId,
                                      SAHPI_FIRST_ENTRY);

                while (rdr) {
                    if (rdr->RdrType == SAHPI_CTRL_RDR) {
                        /* Test to see if this is the derated circuit cap   */
                        /* control rdr                                      */
                        if (rdr->RdrTypeUnion.CtrlRec.Num ==
                            OA_SOAP_DERATED_CIRCUIT_CAP_CNTRL) {
                            rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Min =
                              newMin;
                            rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Max =
                              newMax;

                            /* We need to constuct/send an oh_event to update */
                            /* the HPI domain                                 */
                            memset(&event, 0, sizeof(struct oh_event));
                            event.event.EventType = SAHPI_ET_RESOURCE;
                            memcpy(&event.resource, rpt,
                                   sizeof(SaHpiRptEntryT));
                            event.event.Severity = SAHPI_INFORMATIONAL;
                            event.event.Source = event.resource.ResourceId;
                            if (oh_gettimeofday(&(event.event.Timestamp))
                                != SA_OK) {
                                    event.event.Timestamp =
                                      SAHPI_TIME_UNSPECIFIED;
                            }
                            event.event.EventDataUnion.ResourceEvent.
                              ResourceEventType = SAHPI_RESE_RESOURCE_UPDATED;
                            event.rdrs = g_slist_append(event.rdrs,
                                                        g_memdup(rdr,
                                                        sizeof(SaHpiRdrT)));
                            event.hid = oh_handler->hid;

                            oh_evt_queue_push(oh_handler->eventq,
                              copy_oa_soap_event(&event));
                            break;
                        }
                    }
                    rdr = oh_get_rdr_next(oh_handler->rptcache,
                                          rpt->ResourceId,
                                          rdr->RecordId);
                    if (rdr == NULL) {
                            err("Did not find derated circuit cap control rdr");
                    }
                }
            }

            /* Check rated circuit cap limits for changes. */
            newMin = power_cap_config->ratedCircuitCapLowerBound;
            newMax = power_cap_config->ratedCircuitCapUpperBound;
            if ((newMin != oldMinRated) || (newMax != oldMaxRated)) {
                /* Need to re-build rated circuit cap control for enclosure */
                dbg("Rated circuit cap has changed\n");
                dbg("New rated circuit cap low: %d\n", newMin);
                dbg("New rated circuit cap high: %d\n", newMax);

                rpt = oh_get_resource_by_id(oh_handler->rptcache, resource_id);
                rdr = oh_get_rdr_next(oh_handler->rptcache, rpt->ResourceId,
                                      SAHPI_FIRST_ENTRY);

                while (rdr) {
                    if (rdr->RdrType == SAHPI_CTRL_RDR) {
                        /* Test to see if this is the rated circuit cap   */
                        /* control rdr                                    */
                        if (rdr->RdrTypeUnion.CtrlRec.Num ==
                            OA_SOAP_RATED_CIRCUIT_CAP_CNTRL) {
                            rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Min =
                              newMin;
                            rdr->RdrTypeUnion.CtrlRec.TypeUnion.Analog.Max =
                              newMax;

                            /* We need to constuct/send an oh_event to    */
                            /* update the HPI domain                      */
                            memset(&event, 0, sizeof(struct oh_event));
                            event.event.EventType = SAHPI_ET_RESOURCE;
                            memcpy(&event.resource, rpt,
                                   sizeof(SaHpiRptEntryT));
                            event.event.Severity = SAHPI_INFORMATIONAL;
                            event.event.Source = event.resource.ResourceId;
                            if (oh_gettimeofday(&(event.event.Timestamp))
                                != SA_OK) {
                                    event.event.Timestamp =
                                      SAHPI_TIME_UNSPECIFIED;
                            }
                            event.event.EventDataUnion.ResourceEvent.
                              ResourceEventType = SAHPI_RESE_RESOURCE_UPDATED;
                            event.rdrs = g_slist_append(event.rdrs,
                                                        g_memdup(rdr,
                                                        sizeof(SaHpiRdrT)));
                            event.hid = oh_handler->hid;

                            oh_evt_queue_push(oh_handler->eventq,
                                              copy_oa_soap_event(&event));
                            break;
                        }
                    }
                    rdr = oh_get_rdr_next(oh_handler->rptcache,
                                          rpt->ResourceId,
                                          rdr->RecordId);
                    if (rdr == NULL) {
                            err("Did not find rated circuit cap control rdr");
                    }
                }
            }
        }

        return;
}
Пример #11
0
/**
 * oa_soap_set_thermal_sensor
 *      @oh_handler	: Pointer to openhpi handler structure
 *      @rpt		: Pointer to rpt structure
 *      @response	: Pointer to bladeThermalInfoArray response structure
 *	@enable_flag	: Sensor Enable Flag
 *
 * Purpose:
 *      Enables or Disables the thermal sensors associated with server blade
 *
 * Detailed Description:
 *	- For Disable request of thermal sensor, the function walks through 
 *	  the rdr list of the blade resource and disables only the thermal
 *	  sensors
 *	- Also disable the user control to enable the thermal sensor.
 *	- For Enable request of thermal sensors, following steps are done:
 *	  	1. Make soap getBladeThermalInfoArray soap call to the 
 *		blade resource.
 *		2.  Walk through the rdr list of the resource and enable
 *	  	only those thermal sensor which have the "SensorPresent" value
 *		as "true" in getBladeThermalInfoArray response.
 *
 * Return values:
 *      SA_OK                     - success.
 *      SA_ERR_HPI_INTERNAL_ERROR - on failure
 **/
SaErrorT oa_soap_set_thermal_sensor(struct oh_handler_state *oh_handler,
				    SaHpiRptEntryT *rpt,
				    struct bladeThermalInfoArrayResponse
					*thermal_response,
				    SaHpiBoolT enable_flag)
{
	SaErrorT rv = SA_OK;
        SaHpiRdrT *rdr = NULL;
	struct bladeThermalInfo bld_thrm_info;
	struct extraDataInfo extra_data;

	if (oh_handler == NULL || rpt == NULL) {
		err("Invalid parameters");
		return SA_ERR_HPI_INVALID_PARAMS;
	}

	rdr = oh_get_rdr_next(oh_handler->rptcache, rpt->ResourceId,
			      SAHPI_FIRST_ENTRY);
	while (rdr) {
		if (rdr->RdrType == SAHPI_SENSOR_RDR) {
			if ((rdr->RdrTypeUnion.SensorRec.Num == 
					OA_SOAP_SEN_TEMP_STATUS) ||
			    ((rdr->RdrTypeUnion.SensorRec.Num >=
					OA_SOAP_BLD_THRM_SEN_START) && 
			    (rdr->RdrTypeUnion.SensorRec.Num <= 
						OA_SOAP_BLD_THRM_SEN_END))) {
				if (enable_flag == SAHPI_TRUE) {
					/* Verify with of the thermal
					 * response to enable the sensor
					 */
					if (thermal_response == NULL) {
						err ("Valid thermal response"
						     " required for processing"
						     " sensor enable operation");
						return 
						SA_ERR_HPI_INTERNAL_ERROR;
					}

					/* Fetch the mapping bladeThermalInfo 
					 * structure instance from response for
					 * for thermal sensor number to 
					 * whether the sensor can be enabled
					 */
					rv = oa_soap_get_bld_thrm_sen_data(
						rdr->RdrTypeUnion.SensorRec.Num,
						*thermal_response,
						&bld_thrm_info);

					if (rv != SA_OK) {
						err("Could not find the"
						    " matching sensor");
						return 
						SA_ERR_HPI_INTERNAL_ERROR;
					}

			                soap_getExtraData(bld_thrm_info.
								extraData,
                                                	  &extra_data);
                			if ((extra_data.value != NULL) &&
					    (!(strcasecmp(extra_data.value, 
							  "false")))) {
						dbg("sensor can not be enabled");
						rdr = oh_get_rdr_next(
							oh_handler->rptcache, 
							rpt->ResourceId, 
							rdr->RecordId);
						continue;
					}
				}
				rv = oa_soap_set_sensor_enable(oh_handler, 
						rpt->ResourceId, 
						rdr->RdrTypeUnion.SensorRec.Num,
						enable_flag);
				if (rv != SA_OK) {
					err("Sensor set failed");
					return rv;
				}
			}
		}
		rdr = oh_get_rdr_next(oh_handler->rptcache, rpt->ResourceId,
				      rdr->RecordId);
	}
	return SA_OK;
}