void ohoi_mc_event(enum ipmi_update_e op, ipmi_domain_t *domain, ipmi_mc_t *mc, void *cb_data) { struct oh_handler_state *handler = cb_data; struct ohoi_handler *ipmi_handler = handler->data; int rv; if ((ipmi_mc_get_channel(mc) == 0) && (ipmi_mc_get_address(mc) == 32) && ipmi_handler->d_type == IPMI_DOMAIN_TYPE_ATCA) { ipmi_handler->virt_mcid = ipmi_mc_convert_to_id(mc); } g_static_rec_mutex_lock(&ipmi_handler->ohoih_lock); switch (op) { case IPMI_ADDED: /* if we get an MC but inactive, register a call to add it once it goes active */ rv = ipmi_mc_add_active_handler(mc, mc_active, handler); rv = ipmi_mc_set_sdrs_first_read_handler(mc, mc_processed, handler); if(!ipmi_mc_is_active(mc)) { trace_ipmi_mc("ADDED but inactive...we ignore", mc); break; } else { mc_add(mc, handler); break; } case IPMI_DELETED: trace_ipmi_mc("DELETED, but nothing done", mc); break; case IPMI_CHANGED: if(!ipmi_mc_is_active(mc)) { trace_ipmi("CHANGED and is inactive: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); } else { mc_add(mc, handler); } break; } g_static_rec_mutex_unlock(&ipmi_handler->ohoih_lock); }
static void _get_is_sel(ipmi_mc_t *mc, void *cb_data) { int *is_selp = cb_data; *is_selp = ipmi_mc_sel_device_support(mc); printf("~~~~~~ MC (%d,%d). sel_support = %d\n", ipmi_mc_get_channel(mc), ipmi_mc_get_address(mc), *is_selp); }
static void get_mc_entity_event(ipmi_mc_t *mc, SaHpiRptEntryT *entry) { uint8_t vals[4]; SaHpiEntityPathT mc_ep; char mc_name[128]; int sel_support; memset(&mc_ep, 0, sizeof(SaHpiEntityPathT)); dbg("entity_root: %s", entity_root); string2entitypath(entity_root, &mc_ep); append_root(&mc_ep); snprintf(mc_name, sizeof(mc_name), "Management Controller(%x, %x)", ipmi_mc_get_channel(mc), ipmi_mc_get_address(mc)); entry->EntryId = 0; entry->ResourceInfo.ResourceRev = 0; entry->ResourceInfo.SpecificVer = 0; entry->ResourceInfo.DeviceSupport = 0; entry->ResourceInfo.ManufacturerId = (SaHpiManufacturerIdT)ipmi_mc_manufacturer_id(mc); entry->ResourceInfo.ProductId = (SaHpiUint16T)ipmi_mc_product_id(mc); entry->ResourceInfo.FirmwareMajorRev = (SaHpiUint8T)ipmi_mc_major_fw_revision(mc); entry->ResourceInfo.FirmwareMinorRev = (SaHpiUint8T)ipmi_mc_minor_fw_revision(mc); ipmi_mc_aux_fw_revision(mc, vals); /* There are 4, and we only use first. */ entry->ResourceInfo.AuxFirmwareRev = (SaHpiUint8T)vals[0]; entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SYS_MGMNT_MODULE ; /*we get MC number on IPMB for unique identifier */ entry->ResourceEntity.Entry[0].EntityInstance = ipmi_mc_get_address(mc); dbg ("MC Instance: %d", entry->ResourceEntity.Entry[0].EntityInstance); sel_support = ipmi_mc_sel_device_support(mc); if (sel_support == 1) { dbg("MC supports SEL"); entry->ResourceCapabilities = SAHPI_CAPABILITY_SEL; } else { entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE; dbg("MC does not support SEL"); } entry->ResourceSeverity = SAHPI_OK; entry->DomainId = 0; entry->ResourceTag.DataType = SAHPI_TL_TYPE_ASCII6; entry->ResourceTag.Language = SAHPI_LANG_ENGLISH; entry->ResourceTag.DataLength = strlen(mc_name); memcpy(entry->ResourceTag.Data, mc_name, strlen(mc_name)+1); ep_concat(&entry->ResourceEntity, &mc_ep); entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity); dbg("MC ResourceId: %d", (int)entry->ResourceId); }
static void trace_ipmi_mc(char *str, ipmi_mc_t *mc) { if (!getenv("OHOI_TRACE_MC") && !IHOI_TRACE_ALL) { return; } fprintf(stderr, "*** MC (%d, %d): %s. sel support = %d\n", ipmi_mc_get_channel(mc), ipmi_mc_get_address(mc), str, ipmi_mc_sel_device_support(mc)); }
void ohoi_mc_event(enum ipmi_update_e op, ipmi_domain_t *domain, ipmi_mc_t *mc, void *cb_data) { struct oh_handler_state *handler = cb_data; switch (op) { case IPMI_ADDED: if(!ipmi_mc_is_active(mc)) { dbg("MC added but inactive...we ignore (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); break; } else { mc_add(mc, handler); dbg("MC added and is active: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); break; } case IPMI_DELETED: dbg("MC deleted: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); break; case IPMI_CHANGED: if(!ipmi_mc_is_active(mc)) { dbg("MC changed and is inactive: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); /* we need to remove it from RPT */ } else { mc_add(mc, handler); dbg("MC changed and is active: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); } break; } }
static void mc_SDRs_read_done(ipmi_mc_t *mc, void *cb_data) { int *mc_count = cb_data; /* one less MC to wait for */ *mc_count = *mc_count - 1; dbg("mc(%d %x) SDRs read done mc count left: %d", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc), *mc_count); }
static void mc_active(ipmi_mc_t *mc, int active, void *cb_data) { struct oh_handler_state *handler = cb_data; struct ohoi_handler *ipmi_handler = handler->data; int rv; if (active) { dbg("MC added and active...(%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); mc_add(mc, handler); ipmi_handler->mc_count++; /* register MC level SDRs read */ rv = ipmi_mc_set_sdrs_first_read_handler(mc, mc_SDRs_read_done, &ipmi_handler->mc_count); if (rv) dbg("mc level SDRs read handler failed"); } }
static int test_handler_0(ipmi_mc_t *mc, void *cb_data) { ipmi_domain_t *domain = ipmi_mc_get_domain(mc); ipmi_entity_info_t *ents = ipmi_domain_get_entities(domain); ipmi_entity_t *ent = NULL; ipmi_control_t *control; int rv = 0; ipmi_control_cbs_t cbs; if (ipmi_mc_get_channel(mc) == IPMI_BMC_CHANNEL) /* Ignore the connection MCs. */ return 0; rv = ipmi_mc_set_oem_new_sensor_handler(mc, test_sensor_handler_0, NULL); if (rv) { ipmi_log(IPMI_LOG_WARNING, "%soem_test.c(test_handler_0): " "Could not set OEM sensor handler: %x", MC_NAME(mc), rv); goto out; } rv = ipmi_mc_set_sel_oem_event_handler(mc, test_event_handler_0, NULL); if (rv) { ipmi_log(IPMI_LOG_WARNING, "%soem_test.c(test_handler_0): " "Could not set OEM event handler: %x", MC_NAME(mc), rv); goto out; } /* Power control for the entity for MC 0x40 (18.2) */ rv = ipmi_entity_add(ents, domain, 0, 0, 0, IPMI_ENTITY_ID_PROCESSOR_BOARD, 0x20, NULL, IPMI_ASCII_STR, 0, dummy_entity_sdr_add, NULL, &ent); if (rv) { ipmi_log(IPMI_LOG_WARNING, "%soem_test.c(test_handler_0): " "Could not add the MC entity: %x", MC_NAME(mc), rv); goto out; } /* Allocate the power control. */ rv = ipmi_control_alloc_nonstandard(&control); if (rv) { goto out; } ipmi_control_set_type(control, IPMI_CONTROL_POWER); ipmi_control_set_ignore_for_presence(control, 1); ipmi_control_set_id(control, "power", IPMI_ASCII_STR, 5); ipmi_control_set_hot_swap_power(control, 1); ipmi_control_set_settable(control, 1); ipmi_control_set_readable(control, 1); /* Create all the callbacks in the data structure. */ memset(&cbs, 0, sizeof(cbs)); cbs.set_val = power_set; cbs.get_val = power_get; ipmi_control_set_callbacks(control, &cbs); ipmi_control_set_num_elements(control, 1); /* Add it to the MC and entity. We presume this comes from the "main" SDR, so set the source_mc to NULL. */ rv = ipmi_control_add_nonstandard(mc, NULL, control, POWER_CONTROL(0x40), ent, NULL, NULL); if (rv) { ipmi_log(IPMI_LOG_WARNING, "%soem_test.c(test_handler_0): " "Could not add the power control: %x", MC_NAME(mc), rv); ipmi_control_destroy(control); goto out; } rv = ipmi_mc_add_oem_removed_handler(mc, mc_control_removal_handler, control); if (rv) { ipmi_log(IPMI_LOG_WARNING, "%soem_test.c(test_handler_0): " "Could not add the power control removal handler: %x", MC_NAME(mc), rv); ipmi_control_destroy(control); goto out; } /* Allocate the LED control. */ rv = ipmi_control_alloc_nonstandard(&control); if (rv) { goto out; } ipmi_control_set_type(control, IPMI_CONTROL_LIGHT); ipmi_control_set_ignore_for_presence(control, 1); ipmi_control_set_id(control, "Hotswap LED", IPMI_ASCII_STR, 11); ipmi_control_light_set_lights(control, 1, hs_led); ipmi_control_set_hot_swap_indicator(control, 1, 0, 1, 2, 3); ipmi_control_set_settable(control, 1); ipmi_control_set_readable(control, 1); /* Create all the callbacks in the data structure. */ memset(&cbs, 0, sizeof(cbs)); cbs.set_val = hs_led_set; cbs.get_val = hs_led_get; ipmi_control_set_callbacks(control, &cbs); ipmi_control_set_num_elements(control, 1); /* Add it to the MC and entity. We presume this comes from the "main" SDR, so set the source_mc to NULL. */ rv = ipmi_control_add_nonstandard(mc, NULL, control, HS_LED_CONTROL(0x40), ent, NULL, NULL); if (rv) { ipmi_log(IPMI_LOG_WARNING, "%soem_test.c(test_handler_0): " "Could not add the power control: %x", MC_NAME(mc), rv); ipmi_control_destroy(control); _ipmi_control_put(control); goto out; } rv = ipmi_mc_add_oem_removed_handler(mc, mc_control_removal_handler, control); if (rv) { ipmi_log(IPMI_LOG_WARNING, "%soem_test.c(test_handler_0): " "Could not add the power control removal handler: %x", MC_NAME(mc), rv); ipmi_control_destroy(control); _ipmi_control_put(control); goto out; } _ipmi_control_put(control); out: if (ent) _ipmi_entity_put(ent); return rv; }
void ohoi_mc_event(enum ipmi_update_e op, ipmi_domain_t *domain, ipmi_mc_t *mc, void *cb_data) { struct oh_handler_state *handler = cb_data; struct ohoi_handler *ipmi_handler = handler->data; int rv; switch (op) { case IPMI_ADDED: /* if we get an MC but inactive, register a call to add it once it goes active */ rv = ipmi_mc_add_active_handler(mc, mc_active, handler); if(!ipmi_mc_is_active(mc)) { dbg("MC updated but inactive...we ignore (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); break; } else { /* MC is active */ mc_add(mc, handler); ipmi_handler->mc_count++; dbg("OP:ADD - mc count increment: %d", ipmi_handler->mc_count); /* register MC level SDRs read */ ipmi_mc_set_sdrs_first_read_handler(mc, mc_SDRs_read_done, &ipmi_handler->mc_count); dbg("MC updated and is active: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); break; } case IPMI_DELETED: dbg("MC deleted: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); /* most likely won't get called during discovery so comment out for now */ //ipmi_handler->mc_count--; /* need to add call to remove from RPT */ break; case IPMI_CHANGED: if(!ipmi_mc_is_active(mc)) { dbg("MC changed and is inactive: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); } else { mc_add(mc, handler); dbg("MC changed and is active: (%d %x)\n", ipmi_mc_get_address(mc), ipmi_mc_get_channel(mc)); } break; } }
static void get_mc_entity_event(ipmi_mc_t *mc, SaHpiRptEntryT *entry, void *cb_data) { uint8_t vals[4]; SaHpiEntityPathT mc_ep; char mc_name[128]; int sel_support; struct ohoi_handler *ipmi_handler = cb_data; trace_ipmi("entity_root: %s", ipmi_handler->entity_root); oh_encode_entitypath(ipmi_handler->entity_root, &mc_ep); snprintf(mc_name, sizeof(mc_name), "Management Controller(%x, %x)", ipmi_mc_get_channel(mc), ipmi_mc_get_address(mc)); entry->EntryId = 0; entry->ResourceInfo.ResourceRev = 0; entry->ResourceInfo.SpecificVer = 0; entry->ResourceInfo.DeviceSupport = 0; entry->ResourceInfo.ManufacturerId = (SaHpiManufacturerIdT)ipmi_mc_manufacturer_id(mc); entry->ResourceInfo.ProductId = (SaHpiUint16T)ipmi_mc_product_id(mc); entry->ResourceInfo.FirmwareMajorRev = (SaHpiUint8T)ipmi_mc_major_fw_revision(mc); entry->ResourceInfo.FirmwareMinorRev = (SaHpiUint8T)ipmi_mc_minor_fw_revision(mc); ipmi_mc_aux_fw_revision(mc, vals); /* There are 4, and we only use first. */ entry->ResourceInfo.AuxFirmwareRev = (SaHpiUint8T)vals[0]; entry->ResourceEntity.Entry[0].EntityType = SAHPI_ENT_SYS_MGMNT_MODULE ; /*we get MC number on IPMB for unique identifier */ entry->ResourceEntity.Entry[0].EntityLocation = ipmi_mc_get_address(mc); entry->ResourceEntity.Entry[1].EntityType = SAHPI_ENT_ROOT; entry->ResourceEntity.Entry[1].EntityLocation = 0; trace_ipmi("MC Instance: %d", entry->ResourceEntity.Entry[0].EntityLocation); sel_support = ipmi_mc_sel_device_support(mc); if (sel_support == 1) { trace_ipmi("MC supports SEL"); entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE | SAHPI_CAPABILITY_EVENT_LOG; } else { entry->ResourceCapabilities = SAHPI_CAPABILITY_RESOURCE; trace_ipmi("MC does not support SEL"); } entry->ResourceSeverity = SAHPI_CRITICAL; entry->ResourceFailed = SAHPI_FALSE; entry->ResourceTag.DataType = SAHPI_TL_TYPE_TEXT; entry->ResourceTag.Language = SAHPI_LANG_ENGLISH; entry->ResourceTag.DataLength = strlen(mc_name); memcpy(entry->ResourceTag.Data, mc_name, strlen(mc_name)+1); oh_concat_ep(&entry->ResourceEntity, &mc_ep); entry->ResourceId = oh_uid_from_entity_path(&entry->ResourceEntity); trace_ipmi("MC ResourceId: %d", (int)entry->ResourceId); }