Ejemplo n.º 1
0
static void add_entity_event(ipmi_entity_t	        *entity,
			     struct oh_handler_state    *handler)
{
      	struct ohoi_resource_info *ohoi_res_info;
	SaHpiRptEntryT	entry;
	int rv;

	dbg("adding ipmi entity: %s", ipmi_entity_get_entity_id_string(entity));

	struct ohoi_handler *ipmi_handler = handler->data;

	ohoi_res_info = g_malloc0(sizeof(*ohoi_res_info));

	if (!ohoi_res_info) {
	      	dbg("Out of memory");
		return;
	}

	ohoi_res_info->type       = OHOI_RESOURCE_ENTITY; 
	ohoi_res_info->u.entity_id= ipmi_entity_convert_to_id(entity);
//	entity_rpt_set_updated(ohoi_res_info, handler->data);

	get_entity_event(entity, &entry, ipmi_handler);	
	rv = oh_add_resource(handler->rptcache, &entry, ohoi_res_info, 1);
	if (rv) {
	      	dbg("oh_add_resource failed for %d = %s\n", entry.ResourceId, oh_lookup_error(rv));
	}
}
Ejemplo n.º 2
0
int entity_presence(ipmi_entity_t		*entity,
			    int			present,
			    void		*cb_data,
			    ipmi_event_t	*event)
{
	struct oh_handler_state *handler = (struct oh_handler_state *)cb_data;

	SaHpiRptEntryT  *rpt;
	SaHpiResourceIdT rid;
	ipmi_entity_id_t ent_id;
  	struct ohoi_resource_info	*res_info;
	
	ent_id = ipmi_entity_convert_to_id(entity);

	rpt = ohoi_get_resource_by_entityid(handler->rptcache, &ent_id);
	if (!rpt) {
		dbg("No rpt");
		return SA_ERR_HPI_NOT_PRESENT;
	}
	rid = rpt->ResourceId;
	res_info = oh_get_resource_data(handler->rptcache, rid);;
	dbg("%s(%d)  %s",ipmi_entity_get_entity_id_string(entity), rid, present ? "present" : "not present");
	entity_rpt_set_presence(res_info, handler->data,  present);
	return SA_OK;
}
Ejemplo n.º 3
0
static void get_entity_event(ipmi_entity_t	*entity,
			     SaHpiRptEntryT	*entry, void *cb_data)
{
	SaHpiEntityPathT entity_ep;

	struct ohoi_handler *ipmi_handler = cb_data;

	entry->ResourceInfo.ResourceRev = 0;
	entry->ResourceInfo.SpecificVer = 0;
	entry->ResourceInfo.DeviceSupport = 0;
	entry->ResourceInfo.ManufacturerId = 0;
	entry->ResourceInfo.ProductId = 0;
	entry->ResourceInfo.FirmwareMajorRev = 0;
	entry->ResourceInfo.FirmwareMinorRev = 0;
	
	entry->ResourceInfo.AuxFirmwareRev = 0;
	entry->ResourceEntity.Entry[0].EntityType 
                = ipmi_entity_get_entity_id(entity);
	entry->ResourceEntity.Entry[0].EntityLocation 
                = ipmi_entity_get_entity_instance(entity);
	entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT;
	entry->ResourceEntity.Entry[1].EntityLocation = 0;
	
	/* let's append entity_root from config */

	string2entitypath(ipmi_handler->entity_root, &entity_ep);

	ep_concat(&entry->ResourceEntity, &entity_ep);

	entry->EntryId = 0;
	entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity);

	entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE;
	
	if (ipmi_entity_hot_swappable(entity)) {
			entry->ResourceCapabilities |= SAHPI_CAPABILITY_MANAGED_HOTSWAP
					| SAHPI_CAPABILITY_FRU;
	}

	if(ipmi_entity_get_is_fru(entity)) {
			entry->ResourceCapabilities |= SAHPI_CAPABILITY_FRU | SAHPI_CAPABILITY_INVENTORY_DATA;
	}
				
	entry->ResourceSeverity = SAHPI_OK;
#if 0
	entry->DomainId = 0;
#endif
	entry->ResourceTag.DataType = SAHPI_TL_TYPE_ASCII6;
	
	entry->ResourceTag.Language = SAHPI_LANG_ENGLISH;
	entry->ResourceTag.DataLength = (SaHpiUint32T) ipmi_entity_get_id_length(entity); 

	ipmi_entity_get_id(entity, entry->ResourceTag.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH);
	if ((strlen(entry->ResourceTag.Data) == 0) || (!strcmp(entry->ResourceTag.Data, "invalid"))) {
			char *str;
			str = ipmi_entity_get_entity_id_string(entity);
			memcpy(entry->ResourceTag.Data, str, strlen(str) + 1);
	}
}
Ejemplo n.º 4
0
static void	got_control_reading(ipmi_control_t *control, int err, int *val, void *cb_data)
{
	const char		*__function_name = "got_control_reading";
	zbx_ipmi_host_t		*h = cb_data;
	int			n;
	zbx_ipmi_control_t	*c;
	const char		*e_string;
	ipmi_entity_t		*ent;
	size_t			sz;

	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);

	if (0 != err)
	{
		zabbix_log(LOG_LEVEL_DEBUG, "%s() fail: %s", __function_name, zbx_strerror(err));

		h->err = zbx_dsprintf(h->err, "error 0x%x while reading control", err);
		h->ret = NETWORK_ERROR;
		h->done = 1;
		goto out;
	}

	c = get_ipmi_control(h, control);

	if (NULL == c)
	{
		THIS_SHOULD_NEVER_HAPPEN;
		h->err = zbx_strdup(h->err, "fatal error");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		goto out;
	}

	if (c->num_values == 0)
	{
		THIS_SHOULD_NEVER_HAPPEN;
		h->err = zbx_strdup(h->err, "no value present for control");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		goto out;
	}

	ent = ipmi_control_get_entity(control);
	e_string = ipmi_entity_get_entity_id_string(ent);

	for (n = 0; n < c->num_values; n++)
	{
		zabbix_log(LOG_LEVEL_DEBUG, "control values [%s | %s | %d:%d]",
				c->c_name, e_string, n + 1, val[n]);
	}

	sz = sizeof(int) * c->num_values;
	memcpy(c->val, val, sz);

	h->done = 1;
out:
	zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(h->ret));
}
Ejemplo n.º 5
0
static void change_entity(struct oh_handler_state	*handler,
		          ipmi_entity_t			*entity)
{
	struct ohoi_handler *ipmi_handler = handler->data;
	ipmi_entity_id_t entity_id = ipmi_entity_convert_to_id(entity);
	SaHpiRptEntryT	*rpt;
	SaHpiResourceIdT slot_id;
	struct ohoi_resource_info *s_r_info;
	struct ohoi_resource_info *res_info;
	unsigned int dummy;
	
	rpt = ohoi_get_resource_by_entityid(handler->rptcache, &entity_id);
	if (rpt == NULL) {
		dbg("Couldn't find out resource by entity %d.%.d.%d.%d  %s",
			ipmi_entity_get_entity_id(entity), 
			ipmi_entity_get_entity_instance(entity),
			ipmi_entity_get_device_channel(entity),
			ipmi_entity_get_device_address(entity),
			ipmi_entity_get_entity_id_string(entity));
		trace_ipmi_entity("CAN NOT CHANGE RESOURCE. NO RPT",
			0, entity);
		return;
	}
	res_info =  oh_get_resource_data(handler->rptcache, rpt->ResourceId);
	update_resource_capabilities(entity, rpt, res_info);
	entity_rpt_set_updated(res_info, ipmi_handler);
	if (ipmi_handler->d_type != IPMI_DOMAIN_TYPE_ATCA) {
		return;
	}
	if (ipmi_entity_get_physical_slot_num(entity, &dummy)) {
		// entity does not have a slot
		return;
	}
#if 0
	if (ipmi_entity_get_type(entity) == IPMI_ENTITY_MC) {
		if (!(res_info->type & OHOI_MC_RESET_CONTROL_CREATED)) {
			ohoi_create_fru_mc_reset_control(handler,
							rpt->ResourceId);
		}
		if (!(res_info->type & OHOI_MC_IPMB0_CONTROL_CREATED) &&
				(res_info->max_ipmb0_link >= 0)) {
			ohoi_create_ipmb0_controls(handler, entity,
			     (SaHpiCtrlStateAnalogT)res_info->max_ipmb0_link);
		}
	}
#endif
	slot_id = ohoi_get_parent_id(rpt);
	s_r_info = oh_get_resource_data(handler->rptcache, slot_id);
	if (s_r_info && (s_r_info->type & OHOI_RESOURCE_SLOT)) {
		s_r_info->u.slot.devid =
					ipmi_entity_get_fru_device_id(entity);
		s_r_info->u.slot.addr =
					ipmi_entity_get_device_address(entity);
	} else {
		dbg("No res_info(%p) for slot %d", s_r_info, slot_id);
	}
}
Ejemplo n.º 6
0
static void	got_control_reading(ipmi_control_t *control, int err, int *val, void *cb_data)
{
	zbx_ipmi_host_t		*h = cb_data;
	int			n;
	zbx_ipmi_control_t	*c;
	const char		*c_type, *e_string;
	ipmi_entity_t		*ent;
	size_t			sz;

	zabbix_log(LOG_LEVEL_DEBUG, "In got_control_reading()");

	if (err) {
		h->err = zbx_dsprintf(h->err, "Error 0x%x while read control", err);
		h->ret = NETWORK_ERROR;
		h->done = 1;
		return;
	}

	c = get_ipmi_control(h, control);

	if (NULL == c)
	{
		/* this should never happen */
		h->err = zbx_dsprintf(h->err, "Fatal error");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		return;
	}

	if (c->num_values == 0)
	{
		/* this should never happen */
		h->err = zbx_dsprintf(h->err, "No value present for control");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		return;
	}

	ent = ipmi_control_get_entity(control);
	e_string = ipmi_entity_get_entity_id_string(ent);
	c_type = ipmi_control_get_type_string(control);

	for (n = 0; n < c->num_values; n++)
	{
		zabbix_log(LOG_LEVEL_DEBUG, "Control values [%s | %s | %d:%d]",
				c->c_name, e_string, n + 1, val[n]);
	}

	sz = sizeof(int) * c->num_values;
	memcpy(c->val, val, sz);

	h->done = 1;
}
Ejemplo n.º 7
0
static void trace_ipmi_fru(char *str, ipmi_entity_t *entity)
{
	if (!getenv("OHOI_TRACE_FRU") && !IHOI_TRACE_ALL) {
		return;
	}
	fprintf(stderr, "*** FRU %s: for (%d,%d,%d,%d) %s\n", str,
		ipmi_entity_get_entity_id(entity), 
		ipmi_entity_get_entity_instance(entity),
		ipmi_entity_get_device_channel(entity),
		ipmi_entity_get_device_address(entity),
		ipmi_entity_get_entity_id_string(entity));
}
Ejemplo n.º 8
0
static void trace_ipmi_entity(char *str, int inst, ipmi_entity_t *entity)
{
    if (!getenv("OHOI_TRACE_ENTITY") && !IHOI_TRACE_ALL) {
        return;
    }

    char *type;
    char logical[24];

    logical[0] = 0;
    switch (ipmi_entity_get_type(entity)) {
    case IPMI_ENTITY_UNKNOWN:
        type = "UNKNOWN";
        break;
    case IPMI_ENTITY_MC:
        type = "MC";
        break;
    case IPMI_ENTITY_FRU:
        type = "FRU";
        if (ipmi_entity_get_is_logical_fru(entity)) {
            snprintf(logical, 24, " Logical (%d) ",
                     ipmi_entity_get_fru_device_id(entity));
        } else {
            snprintf(logical, 24, " NonLogic(%d) ",
                     ipmi_entity_get_fru_device_id(entity));
        }
        break;
    case IPMI_ENTITY_GENERIC:
        type = "GENERIC";
        break;
    case IPMI_ENTITY_EAR:
        type = "EAR";
        break;
    case IPMI_ENTITY_DREAR:
        type = "DREAR";
        break;
    default :
        type = "INVALID";
        break;
    }

    fprintf(stderr, "*** Entity %s %s %s: %d (%d.%d.%d.%d) (%s)   entity = %p\n",
            type, logical, str,
            inst,
            ipmi_entity_get_entity_id(entity),
            ipmi_entity_get_entity_instance(entity),
            ipmi_entity_get_device_channel(entity),
            ipmi_entity_get_device_address(entity),
            ipmi_entity_get_entity_id_string(entity),
            entity);
}
Ejemplo n.º 9
0
static void add_parent_ep(ipmi_entity_t *ent, ipmi_entity_t *parent, void *cb_data)
{
	struct add_parent_ep_s *info = cb_data;
	ipmi_entity_id_t parent_id = ipmi_entity_convert_to_id(parent);
	SaHpiRptEntryT *pr_rpt;


	pr_rpt = ohoi_get_resource_by_entityid(info->handler->rptcache, &parent_id);
	if (pr_rpt == NULL) {
		dbg("       Couldn't find out res-info for parent: %d.%d.%d.%d %s",
			ipmi_entity_get_entity_id(parent),
			ipmi_entity_get_entity_instance(parent),
			ipmi_entity_get_device_channel(parent),
			ipmi_entity_get_device_address(parent),
			ipmi_entity_get_entity_id_string(parent));
		trace_ipmi_entity("CAN NOT FIND OUT PARENT. NO RES_INFO",
			0, parent);
		
		return;
	}
	append_parent_epath(info->entry, pr_rpt);
	return;
}
Ejemplo n.º 10
0
static void entity_presence(ipmi_entity_t	*entity,
			    int			present,
			    void		*cb_data,
			    ipmi_event_t	*event)
{
	struct oh_handler_state *handler = (struct oh_handler_state *)cb_data;

	SaHpiRptEntryT  *rpt;
	SaHpiResourceIdT rid;
	ipmi_entity_id_t ent_id;

	ent_id = ipmi_entity_convert_to_id(entity);

	rpt = ohoi_get_resource_by_entityid(handler->rptcache, &ent_id);
	if (!rpt) {
		dbg("No rpt");
		return;
	}
	rid = rpt->ResourceId;
	dbg("%s %s",ipmi_entity_get_entity_id_string(entity), present?"present":"not present");
#if 0
	entity_update_rpt(handler->rptcache, rid, present);
#endif
}
Ejemplo n.º 11
0
static int ignore_sensor(ipmi_sensor_t *sensor)
{
        ipmi_entity_t *ent;

        if (ipmi_sensor_get_ignore_if_no_entity(sensor)) {
		dbg("ignore if no entity");
                return 0;
	}
        ent = ipmi_sensor_get_entity(sensor);
	if (ent == NULL) {
		dbg("ipmi_sensor_get_entity = NULL");
		return 1;
	}
        if (!ipmi_entity_is_present(ent)) {
		dbg("!ipmi_entity_is_present. (%d,%d,%d,%d) %s",
		ipmi_entity_get_entity_id(ent), 
		ipmi_entity_get_entity_instance(ent),
		ipmi_entity_get_device_channel(ent),
		ipmi_entity_get_device_address(ent),
		ipmi_entity_get_entity_id_string(ent));
                return 0;
	}
        return 0;
}
Ejemplo n.º 12
0
static void	got_control_setting(ipmi_control_t *control, int err, void *cb_data)
{
	zbx_ipmi_host_t		*h = cb_data;
	zbx_ipmi_control_t	*c;
	const char		*c_type, *e_string;
	ipmi_entity_t		*ent;

	zabbix_log(LOG_LEVEL_DEBUG, "In got_control_setting()");

	if (err) {
		h->err = zbx_dsprintf(h->err, "Error 0x%x while set control", err);
		h->ret = NETWORK_ERROR;
		h->done = 1;
		return;
	}

	c = get_ipmi_control(h, control);

	if (NULL == c)
	{
		/* this should never happen */
		h->err = zbx_dsprintf(h->err, "Fatal error");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		return;
	}

	ent = ipmi_control_get_entity(control);
	e_string = ipmi_entity_get_entity_id_string(ent);
	c_type = ipmi_control_get_type_string(control);

	zabbix_log(LOG_LEVEL_DEBUG, "Set value completed for control %s@[%s]:%d",
			c->c_name, h->ip, h->port);

	h->done = 1;
}
Ejemplo n.º 13
0
static void get_entity_event(ipmi_entity_t	*entity,
			     SaHpiRptEntryT	*entry, void *cb_data)
{
	SaHpiEntityPathT entity_ep;
	int er;

	struct ohoi_handler *ipmi_handler = cb_data;

	entry->ResourceInfo.ResourceRev = 0;
	entry->ResourceInfo.SpecificVer = 0;
	entry->ResourceInfo.DeviceSupport = 0;
	entry->ResourceInfo.ManufacturerId = 0;
	entry->ResourceInfo.ProductId = 0;
	entry->ResourceInfo.FirmwareMajorRev = 0;
	entry->ResourceInfo.FirmwareMinorRev = 0;
	
	entry->ResourceInfo.AuxFirmwareRev = 0;
	entry->ResourceEntity.Entry[0].EntityType 
                = ipmi_entity_get_entity_id(entity);
	entry->ResourceEntity.Entry[0].EntityLocation 
                = ipmi_entity_get_entity_instance(entity);
	entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT;
	entry->ResourceEntity.Entry[1].EntityLocation = 0;
	    /* AdvancedTCA fixe-up */

        if (ipmi_entity_get_entity_instance(entity) >= 96) {
                        entry->ResourceEntity.Entry[0].EntityLocation -= 96;
                                //|ipmi_entity_get_device_channel(entity)
                                //|ipmi_entity_get_device_address(entity);
        }

        if ((ipmi_entity_get_entity_id(entity) == 160) &&
                        (ipmi_entity_get_entity_instance(entity) == 96)) {
                dbg("SBC_Blade");
               entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SBC_BLADE;
        }

        if ((ipmi_entity_get_entity_id(entity) == 160) &&
                        (ipmi_entity_get_entity_instance(entity) == 102)) {
                dbg("DISK Blade");
               entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_DISK_BLADE;
        }

        /* End AdvancedTCA Fix-ups */

	
	/* let's append entity_root from config */

	oh_encode_entitypath(ipmi_handler->entity_root, &entity_ep);

	oh_concat_ep(&entry->ResourceEntity, &entity_ep);

	entry->EntryId = 0;
	entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity);

	entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE;
	
	entry->HotSwapCapabilities = 0;
	if (ipmi_entity_supports_managed_hot_swap(entity)) {
			entry->ResourceCapabilities |= SAHPI_CAPABILITY_MANAGED_HOTSWAP;
			/* if entity supports managed hot swap
			 * check if it has indicator */
			dbg("Entity %d supports managed hotswap\n", entry->ResourceId);

			/* we need only return value from function */
			er = ipmi_entity_get_hot_swap_indicator(entity, NULL, NULL);
			if (!er) {
				dbg("resource %d has HS Indicator\n", entry->ResourceId);
				entry->HotSwapCapabilities |= SAHPI_HS_CAPABILITY_INDICATOR_SUPPORTED;
			}
	}

	/* OpenIPMI used ipmi_entity_hot_swappable to indicate it's FRU
	 * do not use ipmi_entity_get_is_fru()
	 * it's used only for checking if entity has FRU data
	 */
	if(ipmi_entity_hot_swappable(entity)) {
		dbg("Entity supports simplified hotswap");
		entry->ResourceCapabilities |= SAHPI_CAPABILITY_FRU;
	}

	if (ipmi_entity_get_is_fru(entity)) {
		dbg("Entity supports FRU Inventory Data");
		entry->ResourceCapabilities |= SAHPI_CAPABILITY_INVENTORY_DATA;
	}
			
	if (entry->ResourceEntity.Entry[0].EntityType == SAHPI_ENT_SYSTEM_BOARD)
	{	/* This is the BMC entry, so we need to add watchdog. */
		entry->ResourceCapabilities |= SAHPI_CAPABILITY_WATCHDOG;
	}
	entry->ResourceSeverity = SAHPI_OK;	/* Default Value -- not related to IPMI */
	entry->ResourceTag.DataType = SAHPI_TL_TYPE_TEXT;
	
	entry->ResourceTag.Language = SAHPI_LANG_ENGLISH;

	ipmi_entity_get_id(entity, entry->ResourceTag.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH);
	if ((strlen(entry->ResourceTag.Data) == 0)
	    || (!strcmp(entry->ResourceTag.Data, "invalid"))
	    || ((ipmi_entity_get_entity_id(entity) == 7 || 15))) {

			char *str;
			char *str2;

			str = ipmi_entity_get_entity_id_string(entity);

			if (!(strcmp(str, "invalid"))) {
				dbg("entity_id_string is invlaid, bad SDR..stick to entity_id");
			} else {
			  	/* Let's identify the entity-instance in the ResourceTag */
				  str2 = (char *)calloc(strlen(str) + 3, sizeof(char));
				  snprintf(str2, strlen(str) + 3, "%s-%d",str,
					   	ipmi_entity_get_entity_instance(entity));
				  memcpy(entry->ResourceTag.Data, str2, strlen(str2) + 1);
			}
	}
	entry->ResourceTag.DataLength = (SaHpiUint32T)strlen(entry->ResourceTag.Data);
}
Ejemplo n.º 14
0
int ohoi_hot_swap_cb(ipmi_entity_t  *ent,
		     enum ipmi_hot_swap_states last_state,
                     enum ipmi_hot_swap_states curr_state,
		     void                      *cb_data,
		     ipmi_event_t              *event)
{
	struct oh_handler_state *handler =  (struct oh_handler_state*)cb_data;
	struct ohoi_handler *ipmi_handler =
					(struct ohoi_handler *)handler->data;
	ipmi_entity_id_t entity_id;
	SaHpiRptEntryT  *rpt_entry;
        struct ohoi_resource_info   *res_info;
	struct oh_event  *e;

#if 0
if (event) {
unsigned char	data[IPMI_EVENT_DATA_MAX_LEN];
unsigned int	dt_len, i;
printf("event body : ");
dt_len = ipmi_event_get_data(event, data, 0, IPMI_EVENT_DATA_MAX_LEN);
for (i =0; i < dt_len; i++) printf(" 0x%02x", data[i]);
printf("\n");
}
#endif



	if (getenv("OHOI_TRACE_HOTSWAP") || IHOI_TRACE_ALL) {
		printf(" *** Hotswap HANDLER for entity %d,%d,%d,%d "
			"(%s). states 0x%x -> 0x%x.    entity = %p\n",
			ipmi_entity_get_entity_id(ent),
			ipmi_entity_get_entity_instance(ent),
			ipmi_entity_get_device_channel(ent),
			ipmi_entity_get_device_address(ent),
			ipmi_entity_get_entity_id_string(ent),
			last_state, curr_state, ent);
	}
	trace_ipmi("HotSwap Handler called");

	entity_id = ipmi_entity_convert_to_id(ent);

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

	if (!rpt_entry) {
		err(" No rpt\n");
		return IPMI_EVENT_HANDLED;
	}
        res_info = oh_get_resource_data(handler->rptcache, rpt_entry->ResourceId);
	if ((last_state == IPMI_HOT_SWAP_ACTIVATION_IN_PROGRESS) &&
			(curr_state == IPMI_HOT_SWAP_DEACTIVATION_IN_PROGRESS)) {
		if (res_info) {
			res_info->hs_mark = 1;
		}
		return IPMI_EVENT_HANDLED;
	}
	e = malloc(sizeof(*e));
	if (!e) {
		err("Out of space");
		return IPMI_EVENT_HANDLED;
	}

	memset(e, 0, sizeof(*e));
	e->event.Source = rpt_entry->ResourceId;
	if ((curr_state == IPMI_HOT_SWAP_OUT_OF_CON) &&
			(last_state != IPMI_HOT_SWAP_NOT_PRESENT)) {
		// special case. connection to entity lost
		rpt_entry->ResourceFailed = SAHPI_TRUE;
		e->event.EventType = SAHPI_ET_RESOURCE;
		e->event.Severity = rpt_entry->ResourceSeverity;
		oh_gettimeofday(&e->event.Timestamp);
		e->event.Source = rpt_entry->ResourceId;
		e->event.EventDataUnion.ResourceEvent.
			ResourceEventType = SAHPI_RESE_RESOURCE_FAILURE;
		e->resource = *rpt_entry;
                e->hid = handler->hid;
                oh_evt_queue_push(handler->eventq, e);
		if (!IS_ATCA(ipmi_handler->d_type)) {
			return IPMI_EVENT_HANDLED;
		}
		if (ipmi_entity_get_entity_id(ent) == 0xf0) {
			// Shelf Manager. Handle ShM Redundancy Sensor
			if (ipmi_handler->fully_up) {
				ipmi_handler->shmc_present_num--;
				ohoi_send_vshmgr_redundancy_sensor_event(
						handler, 0);
			}
		}
		return IPMI_EVENT_HANDLED;
	}

	if ((curr_state != IPMI_HOT_SWAP_OUT_OF_CON) &&
			rpt_entry->ResourceFailed) {
		// special case
		rpt_entry->ResourceFailed = SAHPI_FALSE;
		if (curr_state != IPMI_HOT_SWAP_NOT_PRESENT) {
			// connection to entity restored
			e->event.EventType = SAHPI_ET_RESOURCE;
			e->event.Severity = rpt_entry->ResourceSeverity;
			oh_gettimeofday(&e->event.Timestamp);
			e->event.Source = rpt_entry->ResourceId;
			e->event.EventDataUnion.ResourceEvent.
				ResourceEventType = SAHPI_RESE_RESOURCE_RESTORED;
			e->resource = *rpt_entry;
			e->hid = handler->hid;
                        oh_evt_queue_push(handler->eventq, e);
			if (!IS_ATCA(ipmi_handler->d_type)) {
				return IPMI_EVENT_HANDLED;
			}
			if (ipmi_entity_get_entity_id(ent) == 0xf0) {
				// Shelf Manager. Handle ShM Redundancy Sensor
				if (ipmi_handler->fully_up) {
					ipmi_handler->shmc_present_num++;
					ohoi_send_vshmgr_redundancy_sensor_event(
						handler, 1);
				}
			}
			return IPMI_EVENT_HANDLED;
		}
		// XXX here must be handled M7->M0 transition
	}

	e->event.Source = rpt_entry->ResourceId;
	e->event.EventType = SAHPI_ET_HOTSWAP;
	e->event.Severity = get_severity(last_state, curr_state,
					rpt_entry, res_info);


	if (event != NULL) {
	      	e->event.Timestamp =
		    (SaHpiTimeT)ipmi_event_get_timestamp(event);
	} else {
	      	e->event.Timestamp = SAHPI_TIME_UNSPECIFIED;
	}
	if (e->event.Timestamp == SAHPI_TIME_UNSPECIFIED) {
		oh_gettimeofday(&e->event.Timestamp);
	}


	e->event.EventDataUnion.HotSwapEvent.HotSwapState
			= _ipmi_to_hpi_state_conv(curr_state);
	e->event.EventDataUnion.HotSwapEvent.PreviousHotSwapState
			= _ipmi_to_hpi_state_conv(last_state);

	e->resource = *rpt_entry;

	if (e->event.EventDataUnion.HotSwapEvent.PreviousHotSwapState ==
		e->event.EventDataUnion.HotSwapEvent.HotSwapState) {
		free(e);
		return IPMI_EVENT_HANDLED;
	}
	if (e->event.EventDataUnion.HotSwapEvent.HotSwapState ==
					SAHPI_HS_STATE_INSERTION_PENDING) {
		res_info->hs_inspen_time = e->event.Timestamp;
	} else {
		res_info->hs_inspen_time = SAHPI_TIME_UNSPECIFIED;
	}
	if (e->event.EventDataUnion.HotSwapEvent.HotSwapState ==
	    					SAHPI_HS_STATE_NOT_PRESENT) {
		trace_ipmi("HS_STATE NOT PRESENT, removing RPT");
	  	e->hid = handler->hid;
                oh_evt_queue_push(handler->eventq, e);
	}else if (e->event.EventDataUnion.HotSwapEvent.HotSwapState ==
			SAHPI_HS_STATE_ACTIVE) {
		trace_ipmi("HS_STATE ACTIVE");
		e->hid = handler->hid;
                oh_evt_queue_push(handler->eventq, e);
	}else {
	  	e->hid = handler->hid;
                oh_evt_queue_push(handler->eventq, e);
	}
//	oh_wake_event_thread(0);
	if (!IS_ATCA(ipmi_handler->d_type) || !event) {
		return IPMI_EVENT_HANDLED;
	}

	unsigned char	data[IPMI_EVENT_DATA_MAX_LEN];
	unsigned int	dt_len;

	dt_len = ipmi_event_get_data(event, data, 0, IPMI_EVENT_DATA_MAX_LEN);
	if (dt_len < 12) {
		err("event data len (%d) too short", dt_len);
		return IPMI_EVENT_HANDLED;
	}

	e = malloc(sizeof(*e));
	if (!e) {
		err("Out of space");
		return IPMI_EVENT_HANDLED;
	}
	memset(e, 0, sizeof(*e));

	e->resource = *rpt_entry;
	e->event.Source = rpt_entry->ResourceId;
	e->event.Timestamp =
		    (SaHpiTimeT)ipmi_event_get_timestamp(event);
	e->event.Severity = SAHPI_INFORMATIONAL;
	e->event.EventType = SAHPI_ET_OEM;
	e->event.EventDataUnion.OemEvent.MId = ATCAHPI_PICMG_MID;
	e->event.EventDataUnion.OemEvent.OemEventData.DataType =
					SAHPI_TL_TYPE_TEXT;
	e->event.EventDataUnion.OemEvent.OemEventData.Language =
					SAHPI_LANG_UNDEF;
	e->event.EventDataUnion.OemEvent.OemEventData.DataLength =
					 3;
	e->event.EventDataUnion.OemEvent.OemEventData.Data[0] =
					_ipmi_to_hpi_state_conv(curr_state);
	e->event.EventDataUnion.OemEvent.OemEventData.Data[1] =
					_ipmi_to_hpi_state_conv(last_state);
	e->event.EventDataUnion.OemEvent.OemEventData.Data[2] =
			_ipmi_to_hpi_cause_of_change_conv(data[11] >> 4);

	e->hid = handler->hid;
        oh_evt_queue_push(handler->eventq, e);

	return IPMI_EVENT_HANDLED;

}
Ejemplo n.º 15
0
static void get_entity_event(ipmi_entity_t	*entity,
			     struct ohoi_resource_info *ohoi_res_info,
			     SaHpiRptEntryT	*entry,
			     void *cb_data)
{
	SaHpiEntityPathT entity_ep;
	struct oh_handler_state *handler = cb_data;
	struct ohoi_handler *ipmi_handler = handler->data;
//	int rv;
	const char *str;
	int entity_id = ipmi_entity_get_entity_id(entity);
	int entity_instance = ipmi_entity_get_entity_instance(entity);
	SaHpiEntityPathT ep;
	unsigned char slot_n_str[8];
	int no_slot = 1;
	unsigned int slot_val = 0;


	init_rpt(entry);

	entry->ResourceEntity.Entry[0].EntityType = entity_id; 
	if(entity_instance >= 96) {
		entry->ResourceEntity.Entry[0].EntityLocation = 
                				entity_instance- 96;
	} else {
		entry->ResourceEntity.Entry[0].EntityLocation =  
                					entity_instance;
	}

	entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT;
	entry->ResourceEntity.Entry[1].EntityLocation = 0;


	update_resource_capabilities(entity, entry, ohoi_res_info);

			
	if (entry->ResourceEntity.Entry[0].EntityType == SAHPI_ENT_SYSTEM_BOARD) {
		/* This is the BMC entry, so we need to add watchdog. */
		if (!ipmi_handler->islan) {
			// no watchdog commands over lan
			entry->ResourceCapabilities |= SAHPI_CAPABILITY_WATCHDOG;
		}
	}



	if (ipmi_handler->d_type != IPMI_DOMAIN_TYPE_ATCA) {
		goto no_atca;
	}
	
	if (entry->ResourceEntity.Entry[0].EntityType == SAHPI_ENT_SYSTEM_CHASSIS) {
		entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_ROOT;
		entry->ResourceEntity.Entry[0].EntityLocation = 0;
		oh_append_textbuffer(&entry->ResourceTag, "Shelf");
	}

	/* Since OpenIPMI does not hand us a more descriptive
	   tag which is an SDR issue in the chassis really, we'll over-ride
	   it here until things change
	*/

		/*
		 * If entity has a slot try to get it's number
		 */
	no_slot = ipmi_entity_get_physical_slot_num(entity, &slot_val);
	trace_ipmi_entity("  SLOT presence for Entity", no_slot ? 0 : 1, entity);     
	if (no_slot) {
		/* will use device address */
		goto end_of_slot;
	}

	{ // create Resource for phisical blade slot if it hasn't already been created
		SaHpiEntityPathT rootep;
		SaHpiRptEntryT *rpt;
		struct ohoi_resource_info *s_r_info;
		char *name;
		
		switch (entity_id) {
		case 0xa0: // Blade
			ep.Entry[0].EntityType = SAHPI_ENT_PHYSICAL_SLOT;
			name = "Blade Slot ";
			break;
		case 0xf0: // Shelf Manager
			ep.Entry[0].EntityType = ATCAHPI_ENT_SHELF_MANAGER_SLOT;
			name = "Shelf Manager Slot ";
			break;
		case 0xf1: // Filtration Unit
			ep.Entry[0].EntityType = ATCAHPI_ENT_FAN_FILTER_TRAY_SLOT;
			name = "Fan Filter Tray Slot ";
			break;
		case 0x0a: // PEM
			ep.Entry[0].EntityType = ATCAHPI_ENT_POWER_ENTRY_MODULE_SLOT;
			name = "PEM Slot ";
			break;
		case 0xf2: // Shelf FRU
			ep.Entry[0].EntityType = ATCAHPI_ENT_SHELF_FRU_DEVICE_SLOT;
			name = "Shelf FRU Device Slot ";
			break;
		case 0x1e: // Fan Tray
			ep.Entry[0].EntityType = ATCAHPI_ENT_FAN_TRAY_SLOT;
			name = "Fan Tray Slot ";
			break;
		case 0xc0: // RTM
			ep.Entry[0].EntityType = ATCAHPI_ENT_RTM_SLOT;
			name = "RTM Slot ";
			break;
		default:
			no_slot = 1;
			goto end_of_slot;
		}   
		ep.Entry[0].EntityLocation = slot_val;
		ep.Entry[1].EntityType = SAHPI_ENT_ROOT;
		ep.Entry[1].EntityLocation = 0;   
		oh_encode_entitypath(ipmi_handler->entity_root, &rootep);
		oh_concat_ep(&ep, &rootep);
		rpt = oh_get_resource_by_ep(handler->rptcache, &ep);
		if (rpt == NULL) {
			// create rpt for slot
			SaHpiRptEntryT srpt;
			int i;

			init_rpt(&srpt);
			for (i = 0; i < SAHPI_MAX_ENTITY_PATH; i ++) {
				srpt.ResourceEntity.Entry[i].EntityLocation =
					ep.Entry[i].EntityLocation;
				srpt.ResourceEntity.Entry[i].EntityType =
					ep.Entry[i].EntityType;
				if (ep.Entry[i].EntityType == SAHPI_ENT_ROOT) {
					break;
				}
			}
			oh_append_textbuffer(&srpt.ResourceTag, name);
			snprintf((char *)slot_n_str, 8, "%d", slot_val);
			oh_append_textbuffer(&srpt.ResourceTag, (char *)slot_n_str);
			srpt.ResourceId =
				oh_uid_from_entity_path(&srpt.ResourceEntity);
			
			s_r_info = malloc(sizeof(*ohoi_res_info));
			if (s_r_info == NULL) {
				dbg("Out of Memory");
				goto end_of_slot;
			}
			memset(s_r_info, 0, sizeof(*ohoi_res_info));
			s_r_info->type = OHOI_RESOURCE_SLOT;
			s_r_info->u.slot.devid =
				ipmi_entity_get_fru_device_id(entity);
			s_r_info->u.slot.addr =
				ipmi_entity_get_device_address(entity);
			s_r_info->u.slot.entity_id =
				ipmi_entity_convert_to_id(entity);
			if (oh_add_resource(handler->rptcache, &srpt,
								s_r_info, 1)) {
				dbg("couldn't add resource for slot %d",
						ep.Entry[0].EntityLocation);
				trace_ipmi_entity("COULD NOT CREATE SLOT for ",
					0, entity);
				no_slot = 1;
				g_free(s_r_info);
				goto end_of_slot;
			}
			trace_ipmi_entity("CREATE SLOT for ", 0, entity);
			if (ipmi_entity_get_entity_id(entity) == 0xf0) {
				// this is not virtual shelf manager
				ipmi_handler->shmc_num++;
			}
			entity_rpt_set_presence(s_r_info, ipmi_handler, 1);
			rpt = oh_get_resource_by_ep(handler->rptcache, &ep);
			atca_create_slot_rdrs(handler, srpt.ResourceId);
		} else {
			s_r_info = oh_get_resource_data(handler->rptcache,
					rpt->ResourceId);
			if (s_r_info && (s_r_info->type & OHOI_RESOURCE_SLOT)) {
				s_r_info->u.slot.devid =
					ipmi_entity_get_fru_device_id(entity);
				s_r_info->u.slot.addr =
					ipmi_entity_get_device_address(entity);
				s_r_info->u.slot.entity_id =
					ipmi_entity_convert_to_id(entity);
			} else {
				dbg("Internal error. s_r_info == %p", s_r_info);
			}
		}
	}
end_of_slot:
		
	if ((entity_id == 0xa0) && (entity_instance >= 96)) {
		// ATCA Board
		if ((ipmi_entity_get_device_address(entity) == 130)
			|| (ipmi_entity_get_device_address(entity) == 132)) {
			oh_append_textbuffer(&entry->ResourceTag, "Switch ");
			entry->ResourceEntity.Entry[0].EntityType =
							SAHPI_ENT_SWITCH_BLADE;
		} else if (entity_instance == 102) {
			/* this is here for Force-made Storage blades
	 		* until we have access to latest hardware
	 		* DO NOT CHANGE
			*/
			oh_append_textbuffer(&entry->ResourceTag,
							"Storage/Disk Blade ");
			entry->ResourceEntity.Entry[0].EntityType =
							SAHPI_ENT_DISK_BLADE;
		} else {
			oh_append_textbuffer(&entry->ResourceTag, "Blade ");
			entry->ResourceEntity.Entry[0].EntityType =
							SAHPI_ENT_SBC_BLADE;
		}
        }


	
	if ((entity_id == 0x0a) && (entity_instance >= 96)) {
		// Power Unit
		oh_append_textbuffer(&entry->ResourceTag, "PEM ");

        }
	
       if ((entity_id == 0xf0) && (entity_instance >= 96))  {
		// Shelf Manager
		if ((ipmi_entity_get_device_channel(entity) != 0) ||
				(ipmi_entity_get_device_address(entity) != 32)) {
			oh_append_textbuffer(&entry->ResourceTag, "Shelf Manager ");
		} else {
			oh_append_textbuffer(&entry->ResourceTag, "Virtual Shelf Manager");
			no_slot = 1;
			// XXXX Temporary. Until SDRs fixed
			ohoi_res_info->type |= OHOI_RESOURCE_MC;
			ohoi_res_info->u.entity.mc_id = ipmi_handler->virt_mcid;
//			entry->ResourceCapabilities |= SAHPI_CAPABILITY_EVENT_LOG;
		}
		entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SHELF_MANAGER;
        }        

	if ((entity_id == 0xf2) && (entity_instance >= 96))  {
		// Shelf FRU
		oh_append_textbuffer(&entry->ResourceTag, "Shelf FRU Device ");
		entry->ResourceEntity.Entry[0].EntityType =
					ATCAHPI_ENT_SHELF_FRU_DEVICE;
        }

	if ((entity_id == 0xf1) && (entity_instance >= 96)) {
		// Filtration Unit
		oh_append_textbuffer(&entry->ResourceTag, "Fan Filter Tray ");
		entry->ResourceEntity.Entry[0].EntityType =
					ATCAHPI_ENT_FILTRATION_UNIT;
	}
	
	if ((entity_id == 0x1e) && (entity_instance >= 96)) {
		// Fan Tray
		oh_append_textbuffer(&entry->ResourceTag, "Fan Tray ");
	}

	if ((entity_id == 0xc0) && (entity_instance >= 96)) {
		// Fan Tray
		oh_append_textbuffer(&entry->ResourceTag, "RTM ");
	}

	/* End AdvancedTCA Fix-ups */

	if (!no_slot) {
		oh_append_textbuffer(&entry->ResourceTag, (char *)slot_n_str);
	}

no_atca:
	if (entry->ResourceTag.DataLength == 0) {
		str = ipmi_entity_get_entity_id_string(entity);
		oh_append_textbuffer(&entry->ResourceTag, str);
	}
	if (!no_slot) {
		oh_concat_ep(&entry->ResourceEntity, &ep);
	} else if (ipmi_entity_get_is_child(entity)) {
		struct add_parent_ep_s info;
		info.handler = handler;
		info.entry = entry;
		ipmi_entity_iterate_parents(entity, add_parent_ep, &info);
	} else {
		oh_encode_entitypath(ipmi_handler->entity_root, &entity_ep);
		oh_concat_ep(&entry->ResourceEntity, &entity_ep);
	}

	entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity);
}
Ejemplo n.º 16
0
static void entity_presence(ipmi_entity_t	*entity,
			    int			present,
			    void		*cb_data,
			    ipmi_event_t	*event)
{
	struct oh_handler_state *handler = (struct oh_handler_state *)cb_data;

	SaHpiRptEntryT  *rpt;
	SaHpiResourceIdT rid;
	ipmi_entity_id_t ent_id;

	ent_id = ipmi_entity_convert_to_id(entity);

	rpt = ohoi_get_resource_by_entityid(handler->rptcache, &ent_id);
	if (!rpt) {
		dbg("No rpt");
		return;
	}
	rid = rpt->ResourceId;
	dbg("%s %s",ipmi_entity_get_entity_id_string(entity), present?"present":"not present");
	entity_update_rpt(handler->rptcache, rid, present);
#if 0
/*
	The following code is masked by Racing. The reasons are listed as:

	1. The hotswap event is not populated to HPI
	2. The param 3 is changed to handler
           in ipmi_entity_set_presence_handler(entity, entity_presence, handler);
	3. The orignal param (&entry.ResourceID) is a bug. Because entity_presence 
	is callback function and entry.ResourceID is local variable, it may cause
	segment fault
*/
	struct oh_event	*e;
	SaHpiResourceIdT *rid = cb_data;

	e = malloc(sizeof(*e));
	if (!e) {
		dbg("Out of space");
		return;
	}

	memset(e, 0, sizeof(*e));
	e->type = OH_ET_HPI;
	e->u.hpi_event.parent = *rid;
	e->u.hpi_event.id = 0;

	e->u.hpi_event.event.Source = 0;
	/* Do not find EventType in IPMI */
	e->u.hpi_event.event.EventType = SAHPI_ET_HOTSWAP;

	/* FIXIT! */
	if (event)
		e->u.hpi_event.event.Timestamp 
                        = ipmi_get_uint32(ipmi_event_get_data_ptr(event));

	/* Do not find the severity of hotswap event */
	e->u.hpi_event.event.Severity = SAHPI_MAJOR;

	if (present)
		e->u.hpi_event.event.EventDataUnion.HotSwapEvent.HotSwapState
			= SAHPI_HS_STATE_ACTIVE_HEALTHY;
	else
		e->u.hpi_event.event.EventDataUnion.HotSwapEvent.HotSwapState
			= SAHPI_HS_STATE_NOT_PRESENT;
#endif	
}
Ejemplo n.º 17
0
static void add_entity_event(ipmi_entity_t	        *entity,
			     struct oh_handler_state    *handler)
{
		struct ohoi_resource_info *ohoi_res_info;
		SaHpiRptEntryT	entry;
		int 		rv;

		dbg("adding ipmi entity: %s", ipmi_entity_get_entity_id_string(entity));

		struct ohoi_handler *ipmi_handler = handler->data;

		ohoi_res_info = g_malloc0(sizeof(*ohoi_res_info));

		if (!ohoi_res_info) {
				dbg("Out of memory");
				return;
		}

		ohoi_res_info->type       = OHOI_RESOURCE_ENTITY; 
		ohoi_res_info->u.entity_id= ipmi_entity_convert_to_id(entity);

		get_entity_event(entity, &entry, ipmi_handler);	

		/* bug #957513 keeping for histirical reasons until it's verified */
		//handler->eventq = g_slist_append(handler->eventq, e);

		oh_add_resource(handler->rptcache, &entry, ohoi_res_info, 1);

		/* sensors */

		rv= ipmi_entity_set_sensor_update_handler(entity, ohoi_sensor_event,
						handler);

		if (rv) {
				dbg("ipmi_entity_set_sensor_update_handler: %#x", rv);
				return;
		}

		/* controls */
		
		rv = ipmi_entity_set_control_update_handler(entity, ohoi_control_event,
							handler);

		if (rv) {
				dbg("ipmi_entity_set_control_update_handler: %#x", rv);
				return;
		}

		/* inventory (a.k.a FRU) */

		rv = ipmi_entity_set_fru_update_handler(entity, ohoi_inventory_event, handler);

		if (rv) {
                dbg("ipmi_entity_set_fru_update_handler: %#x", rv);
                return;
        }

		/* entity presence overall */

		rv = ipmi_entity_set_presence_handler(entity, entity_presence, handler);
		if (rv) {
				dbg("ipmi_entity_set_presence_handler: %#x", rv);
				return;
		}

}
Ejemplo n.º 18
0
static void get_entity_event(ipmi_entity_t	*entity,
                             SaHpiRptEntryT	*entry, void *cb_data)
{
    SaHpiEntityPathT entity_ep;
    struct oh_handler_state *handler = cb_data;
    struct ohoi_handler *ipmi_handler = handler->data;

    int er, i;
    int rv;
    const char *str;

    g_static_rec_mutex_lock(&ipmi_handler->ohoih_lock);

    entry->ResourceInfo.ResourceRev = 0;
    entry->ResourceInfo.SpecificVer = 0;
    entry->ResourceInfo.DeviceSupport = 0;
    entry->ResourceInfo.ManufacturerId = 0;
    entry->ResourceInfo.ProductId = 0;
    entry->ResourceInfo.FirmwareMajorRev = 0;
    entry->ResourceInfo.FirmwareMinorRev = 0;
    for (i=0; i<15; i++) {
        entry->ResourceInfo.Guid[i] = 0;
    }

    entry->ResourceInfo.AuxFirmwareRev = 0;
    entry->ResourceEntity.Entry[0].EntityType
        = ipmi_entity_get_entity_id(entity);
    entry->ResourceEntity.Entry[0].EntityLocation
        = ipmi_entity_get_entity_instance(entity);
    if(ipmi_entity_get_entity_instance(entity) >= 96) {
        entry->ResourceEntity.Entry[0].EntityLocation
            = ipmi_entity_get_entity_instance(entity)- 96;
    }

    entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT;
    entry->ResourceEntity.Entry[1].EntityLocation = 0;

    entry->EntryId = 0;
    entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity);
    entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE;

    entry->HotSwapCapabilities = 0;
    if (ipmi_entity_supports_managed_hot_swap(entity)) {
        trace_ipmi("Entity is hot swapable");
        entry->ResourceCapabilities |= SAHPI_CAPABILITY_MANAGED_HOTSWAP;
        /* if entity supports managed hot swap
         * check if it has indicator */

        /* we need only return value from function */
        er = ipmi_entity_get_hot_swap_indicator(entity, NULL, NULL);
        if (!er) {
            entry->HotSwapCapabilities |= SAHPI_HS_CAPABILITY_INDICATOR_SUPPORTED;
        }
    }

    /* OpenIPMI used ipmi_entity_hot_swappable to indicate it's FRU
     * do not use ipmi_entity_get_is_fru()
     * it's used only for checking if entity has FRU data
     */
    if(ipmi_entity_hot_swappable(entity)) {
        trace_ipmi("Entity supports simplified hotswap");
        entry->ResourceCapabilities |= SAHPI_CAPABILITY_FRU;
    }

//	if (ipmi_entity_get_is_fru(entity)) {
//		dbg("Entity supports FRU Inventory Data");
//		entry->ResourceCapabilities |= SAHPI_CAPABILITY_INVENTORY_DATA;
//	}

    if (entry->ResourceEntity.Entry[0].EntityType == SAHPI_ENT_SYSTEM_BOARD)
    {   /* This is the BMC entry, so we need to add watchdog. */
        entry->ResourceCapabilities |= SAHPI_CAPABILITY_WATCHDOG;
    }
    entry->ResourceSeverity = SAHPI_MAJOR;	/* Default Value -- not related to IPMI */
    entry->ResourceFailed = SAHPI_FALSE;
    entry->ResourceTag.DataType = SAHPI_TL_TYPE_TEXT;

    entry->ResourceTag.Language = SAHPI_LANG_ENGLISH;

    //ipmi_entity_get_id(entity, entry->ResourceTag.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH);
    str = ipmi_entity_get_entity_id_string(entity);
    memcpy(entry->ResourceTag.Data,str, strlen(str) +1);
    entry->ResourceTag.DataLength = strlen(entry->ResourceTag.Data);
#if 0
    if ((strlen(entry->ResourceTag.Data) == 0)
            || (!strcmp(entry->ResourceTag.Data, "invalid"))
            || ((ipmi_entity_get_entity_id(entity) == 7 || 15))) {

        const char *str;
        char *str2;
        int inst;

        inst = ipmi_entity_get_entity_instance(entity);
        if (inst >= 96)
            inst = inst - 96;
        str = ipmi_entity_get_entity_id_string(entity);

        if (!(strcmp(str, "invalid"))) {
            dbg("entity_id_string is invlaid, bad SDR..stick to entity_id");
        } else {
            /* Let's identify the entity-instance in the ResourceTag */
            dbg("Instance for ResourceTag %d", inst);
            str2 = (char *)calloc(strlen(str) + 4, sizeof(char));
            snprintf(str2, strlen(str) + 4, "%s-%d",str, inst);
            memcpy(entry->ResourceTag.Data, str2, strlen(str2) + 1);
        }
    }

    /* AdvancedTCA fix-up */

    /* Here we start dealing with device relative entities */
#endif

#if 0
    if (ipmi_entity_get_entity_instance(entity) >= 96) {
        entry->ResourceEntity.Entry[0].EntityLocation =
            ipmi_entity_get_entity_instance(entity) - 96;
        entry->ResourceEntity.Entry[0].EntityType =
            ipmi_entity_get_entity_id(entity);

        entry->ResourceEntity.Entry[1].EntityType =
            SAHPI_ENT_PHYSICAL_SLOT;
        int rv;
        unsigned int val;

        rv = ipmi_entity_get_physical_slot_num(entity, &val);
        if (rv != 0) {
            entry->ResourceEntity.Entry[1].EntityLocation =
                ipmi_entity_get_device_address(entity);
        } else {
            entry->ResourceEntity.Entry[1].EntityLocation = val;
        }

        entry->ResourceEntity.Entry[2].EntityType = SAHPI_ENT_ROOT;
        entry->ResourceEntity.Entry[2].EntityLocation = 0;
    }
#endif
    /* Since OpenIPMI does not hand us a more descriptive
       tag which is an SDR issue inthe chassis really, we'll over-ride
       it here until things change
    */

    if ((ipmi_entity_get_entity_id(entity) == 160) &&
            (ipmi_entity_get_entity_instance(entity) >= 96)) {
        dbg("SBC Blade");
        const char sbc_tag[] = "SBC Blade";
        memcpy(entry->ResourceTag.Data, sbc_tag, strlen(sbc_tag) + 1);

        entry->ResourceEntity.Entry[0].EntityLocation =
            ipmi_entity_get_entity_instance(entity) - 96;
        entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SBC_BLADE;
        entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_PHYSICAL_SLOT;
        unsigned int val;
        rv = ipmi_entity_get_physical_slot_num(entity, &val);
        if (rv != 0) {
            entry->ResourceEntity.Entry[1].EntityLocation =
                ipmi_entity_get_device_address(entity);
            dbg("Erro getting Physical Slot Number");
        } else {
            dbg("Physical lot Num: %d", val);
            entry->ResourceEntity.Entry[1].EntityLocation = val;
        }
        entry->ResourceEntity.Entry[2].EntityType = SAHPI_ENT_ROOT;
        entry->ResourceEntity.Entry[2].EntityLocation = 0;
    }

    if ((ipmi_entity_get_entity_id(entity) == 160) &&
            ((ipmi_entity_get_device_address(entity) == 130)
             || (ipmi_entity_get_device_address(entity) == 132)))	{
        dbg("Switch Blade");
        const char switch_tag[] = "Switch Blade";
        memcpy(entry->ResourceTag.Data, switch_tag, strlen(switch_tag) + 1);

        entry->ResourceEntity.Entry[0].EntityLocation =
            ipmi_entity_get_entity_instance(entity) - 96;
        entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SWITCH_BLADE;
        entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_PHYSICAL_SLOT;
        unsigned int val;
        rv = ipmi_entity_get_physical_slot_num(entity, &val);
        if (rv != 0)
            entry->ResourceEntity.Entry[1].EntityLocation =
                ipmi_entity_get_device_address(entity);
        else
            entry->ResourceEntity.Entry[1].EntityLocation = val;
        dbg("Physical lot Num: %d", val);
        entry->ResourceEntity.Entry[2].EntityType = SAHPI_ENT_ROOT;
        entry->ResourceEntity.Entry[2].EntityLocation = 0;
    }

    //if ((ipmi_entity_get_entity_id(entity) == 10)) {

    //dbg("PowerSupply  Device");
    //entry->ResourceEntity.Entry[1].EntityLocation = 0;
    //entry->ResourceEntity.Entry[1].EntityType =
    //SAHPI_ENT_POWER_UNIT;
    //}

    if ((ipmi_entity_get_entity_id(entity) == 30)) {

        dbg("Cooling Device");
        //const char disk_tag[] = "Cooling Unit";
        //memcpy(entry->ResourceTag.Data, disk_tag, strlen(disk_tag) + 1);
        entry->ResourceEntity.Entry[0].EntityLocation =
            ipmi_entity_get_entity_instance(entity) - 96;
        entry->ResourceEntity.Entry[0].EntityType = ipmi_entity_get_entity_id(entity);
    }

    /* this is here for Force-made Storage blades
     * until we have access to latest hardware
     * DO NOT CHANGE
    */
    if ((ipmi_entity_get_entity_id(entity) == 160) &&
            (ipmi_entity_get_entity_instance(entity) == 102)) {
        dbg("DISK Blade");
        const char disk_tag[] = "Storage/Disk Blade";
        memcpy(entry->ResourceTag.Data, disk_tag, strlen(disk_tag) + 1);
        //entry->ResourceEntity.Entry[0].EntityLocation =
        //ipmi_entity_get_entity_instance(entity) - 96;
        entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_DISK_BLADE;
    }


    /* End AdvancedTCA Fix-ups */

    entry->ResourceTag.DataLength = (SaHpiUint32T)strlen(entry->ResourceTag.Data);

    oh_encode_entitypath(ipmi_handler->entity_root, &entity_ep);
    oh_concat_ep(&entry->ResourceEntity, &entity_ep);
    entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity);
    trace_ipmi("ResourceId: %d", entry->ResourceId);

    /* controls */
    rv = ipmi_entity_add_control_update_handler(entity,
            ohoi_control_event,
            handler);

    if (rv) {
        dbg("ipmi_entity_set_control_update_handler: %#x", rv);
        return;
    }

    g_static_rec_mutex_unlock(&ipmi_handler->ohoih_lock);
}
Ejemplo n.º 19
0
void ohoi_entity_event(enum ipmi_update_e       op,
                       ipmi_domain_t            *domain,
                       ipmi_entity_t            *entity,
                       void                     *cb_data)
{
  	struct oh_handler_state *handler = cb_data;
	int rv;
		
	switch (op) {
	  	case IPMI_ADDED:
		  	add_entity_event(entity, handler);

			dbg("Entity added: %d.%d (%s)", 
					ipmi_entity_get_entity_id(entity), 
					ipmi_entity_get_entity_instance(entity),
					ipmi_entity_get_entity_id_string(entity));

			/* entity presence overall */
			rv = ipmi_entity_add_presence_handler(entity,
							      entity_presence,
							      handler);       		
			if (rv) 
				dbg("ipmi_entity_set_presence_handler: %#x", rv);

			/* hotswap handler */
			rv = ipmi_entity_add_hot_swap_handler(entity,
							      ohoi_hot_swap_cb,
							      cb_data);
			if(rv)
			  	dbg("Failed to set entity hot swap handler");

			/* sensors */
			rv= ipmi_entity_add_sensor_update_handler(entity,
								  ohoi_sensor_event,
								  handler);
			if (rv) {
				dbg("ipmi_entity_set_sensor_update_handler: %#x", rv);
				return;
			}
                                                                                
			/* controls */
			rv = ipmi_entity_add_control_update_handler(entity,
								    ohoi_control_event,
								    handler);
                                                                                
			if (rv) {
				dbg("ipmi_entity_set_control_update_handler: %#x", rv);
				return;
			}
                                                                                
			/* inventory (a.k.a FRU) */
			rv = ipmi_entity_add_fru_update_handler(entity,
								ohoi_inventory_event,
								handler);
			if (rv) {
			  	dbg("ipmi_entity_set_fru_update_handler: %#x", rv);
				return;
			}
				                                                                              
			break;
			
		case IPMI_DELETED:
			return;              /* we need to remove_entity */
			dbg("Entity deleted: %d.%d", 
						ipmi_entity_get_entity_id(entity), 
						ipmi_entity_get_entity_instance(entity));
			break;
			
		case IPMI_CHANGED:
			add_entity_event(entity, handler);

			dbg("Entity changed: %d.%d",
						ipmi_entity_get_entity_id(entity), 
						ipmi_entity_get_entity_instance(entity));
			break;
		default:
			dbg("Entity: Unknow change?!");
	}

}
Ejemplo n.º 20
0
static void	got_thresh_reading(ipmi_sensor_t *sensor, int err, enum ipmi_value_present_e value_present,
		unsigned int raw_value, double val, ipmi_states_t *states, void *cb_data)
{
	const char		*e_string, *s_type_string, *s_reading_type_string;
	ipmi_entity_t		*ent;
	const char		*percent = "", *base, *mod_use = "", *modifier = "", *rate;
	zbx_ipmi_host_t	*h = cb_data;
	zbx_ipmi_sensor_t	*s;

	zabbix_log(LOG_LEVEL_DEBUG, "In got_thresh_reading()");

	if (err) {
		h->err = zbx_dsprintf(h->err, "Error 0x%x while read threshold sensor", err);
		h->ret = NETWORK_ERROR;
		h->done = 1;
		return;
	}

	s = get_ipmi_sensor(h, sensor);

	if (NULL == s)
	{
		/* this should never happen */
		h->err = zbx_dsprintf(h->err, "Fatal error");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		return;
	}

	switch (value_present)
	{
		case IPMI_NO_VALUES_PRESENT:
		case IPMI_RAW_VALUE_PRESENT:
			h->err = zbx_dsprintf(h->err, "No value present for threshold sensor");
			h->ret = NOTSUPPORTED;
			break;
		case IPMI_BOTH_VALUES_PRESENT:
			s->value = val;

			/* next lines only for debug logging */
			ent = ipmi_sensor_get_entity(sensor);
			e_string = ipmi_entity_get_entity_id_string(ent);
			s_type_string = ipmi_sensor_get_sensor_type_string(sensor);
			s_reading_type_string = ipmi_sensor_get_event_reading_type_string(sensor);

			base = ipmi_sensor_get_base_unit_string(sensor);
			if (ipmi_sensor_get_percentage(sensor))
				percent = "%";
			switch (ipmi_sensor_get_modifier_unit_use(sensor)) {
				case IPMI_MODIFIER_UNIT_NONE:
					break;
				case IPMI_MODIFIER_UNIT_BASE_DIV_MOD:
					mod_use = "/";
					modifier = ipmi_sensor_get_modifier_unit_string(sensor);
					break;
				case IPMI_MODIFIER_UNIT_BASE_MULT_MOD:
					mod_use = "*";
					modifier = ipmi_sensor_get_modifier_unit_string(sensor);
					break;
			}
			rate = ipmi_sensor_get_rate_unit_string(sensor);

			zabbix_log(LOG_LEVEL_DEBUG, "Value [%s | %s | %s | %s | " ZBX_FS_DBL "%s %s%s%s%s]",
					s->s_name, e_string, s_type_string, s_reading_type_string,
					val, percent, base, mod_use, modifier, rate);
			break;
	}
	h->done = 1;
}
Ejemplo n.º 21
0
/* callback function invoked from OpenIPMI */
static void	got_thresh_reading(ipmi_sensor_t *sensor, int err, enum ipmi_value_present_e value_present,
		unsigned int raw_value, double val, ipmi_states_t *states, void *cb_data)
{
	const char		*__function_name = "got_thresh_reading";
	char			id_str[2 * IPMI_SENSOR_ID_SZ + 1];
	const char		*e_string, *s_type_string, *s_reading_type_string;
	ipmi_entity_t		*ent;
	const char		*percent = "", *base, *mod_use = "", *modifier = "", *rate;
	zbx_ipmi_host_t		*h = cb_data;
	zbx_ipmi_sensor_t	*s;

	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);

	if (0 != err)
	{
		zabbix_log(LOG_LEVEL_DEBUG, "%s() fail: %s", __function_name, zbx_strerror(err));

		h->err = zbx_dsprintf(h->err, "error 0x%x while reading threshold sensor", err);
		h->ret = NETWORK_ERROR;
		h->done = 1;
		goto out;
	}

	s = get_ipmi_sensor(h, sensor);

	if (NULL == s)
	{
		THIS_SHOULD_NEVER_HAPPEN;
		h->err = zbx_dsprintf(h->err, "fatal error");
		h->ret = NOTSUPPORTED;
		h->done = 1;
		goto out;
	}

	switch (value_present)
	{
		case IPMI_NO_VALUES_PRESENT:
		case IPMI_RAW_VALUE_PRESENT:
			h->err = zbx_dsprintf(h->err, "no value present for threshold sensor");
			h->ret = NOTSUPPORTED;
			break;
		case IPMI_BOTH_VALUES_PRESENT:
			s->value.threshold = val;

			/* next lines only for debug logging */
			ent = ipmi_sensor_get_entity(sensor);
			e_string = ipmi_entity_get_entity_id_string(ent);
			s_type_string = ipmi_sensor_get_sensor_type_string(sensor);
			s_reading_type_string = ipmi_sensor_get_event_reading_type_string(sensor);

			base = ipmi_sensor_get_base_unit_string(sensor);
			if (ipmi_sensor_get_percentage(sensor))
				percent = "%";
			switch (ipmi_sensor_get_modifier_unit_use(sensor))
			{
				case IPMI_MODIFIER_UNIT_NONE:
					break;
				case IPMI_MODIFIER_UNIT_BASE_DIV_MOD:
					mod_use = "/";
					modifier = ipmi_sensor_get_modifier_unit_string(sensor);
					break;
				case IPMI_MODIFIER_UNIT_BASE_MULT_MOD:
					mod_use = "*";
					modifier = ipmi_sensor_get_modifier_unit_string(sensor);
					break;
			}
			rate = ipmi_sensor_get_rate_unit_string(sensor);

			zabbix_log(LOG_LEVEL_DEBUG, "Value [%s | %s | %s | %s | " ZBX_FS_DBL "%s %s%s%s%s]",
					sensor_id_to_str(id_str, sizeof(id_str), s->id, s->id_type, s->id_sz),
					e_string, s_type_string, s_reading_type_string, val, percent, base,
					mod_use, modifier, rate);
			break;
	}
	h->done = 1;
out:
	zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(h->ret));
}
Ejemplo n.º 22
0
void ohoi_entity_event(enum ipmi_update_e       op,
                       ipmi_domain_t            *domain,
                       ipmi_entity_t            *entity,
                       void                     *cb_data)
{
    struct oh_handler_state *handler = cb_data;
    struct ohoi_handler *ipmi_handler = handler->data;
    int rv;
    int inst=0;

    switch (op) {
    case IPMI_ADDED:
        g_static_rec_mutex_lock(&ipmi_handler->ohoih_lock);

        if ((ipmi_entity_get_entity_id(entity) == 3)
                && (ipmi_entity_get_entity_instance(entity)
                    >= 96)) {
            dbg("We got a processor");
            ipmi_entity_iterate_parents(entity,
                                        add_processor_event,
                                        handler);
        } else
            add_entity_event(entity, handler);

        inst=ipmi_entity_get_entity_instance(entity);
        if(inst >=96) {
            inst = inst - 96;
        }

        trace_ipmi("Entity added: %d.%d (%s)",
                   ipmi_entity_get_entity_id(entity),
                   inst,
                   ipmi_entity_get_entity_id_string(entity));

        /* entity presence overall */
        rv = ipmi_entity_add_presence_handler(entity,
                                              entity_presence,
                                              handler);
        if (rv)
            dbg("ipmi_entity_set_presence_handler: %#x", rv);

        /* hotswap handler */
        rv = ipmi_entity_add_hot_swap_handler(entity,
                                              ohoi_hot_swap_cb,
                                              cb_data);
        if(rv)
            dbg("Failed to set entity hot swap handler");

        /* sensors */
        rv= ipmi_entity_add_sensor_update_handler(entity,
                ohoi_sensor_event,
                handler);
        if (rv) {
            dbg("ipmi_entity_set_sensor_update_handler: %#x", rv);
            return;
        }

        /* inventory (a.k.a FRU) */
        rv = ipmi_entity_add_fru_update_handler(entity,
                                                ohoi_inventory_event,
                                                handler);
        if (rv) {
            dbg("ipmi_entity_set_fru_update_handler: %#x", rv);
            return;
        }
        g_static_rec_mutex_unlock(&ipmi_handler->ohoih_lock);

        break;

    case IPMI_DELETED:
        return;              /* we need to remove_entity */
        dbg("Entity deleted: %d.%d",
            ipmi_entity_get_entity_id(entity),
            ipmi_entity_get_entity_instance(entity));
        break;

    case IPMI_CHANGED:
        g_static_rec_mutex_lock(&ipmi_handler->ohoih_lock);
        //add_entity_event(entity, handler);
        inst = 0;
        inst=ipmi_entity_get_entity_instance(entity);
        if(inst >=96) {
            inst = inst - 96;
        }
        trace_ipmi("***Entity changed: %d.%d",
                   ipmi_entity_get_entity_id(entity),
                   inst);
        g_static_rec_mutex_unlock(&ipmi_handler->ohoih_lock);
        break;
    default:
        dbg("Entity: Unknow change?!");
    }

}