119c617b7SRatan Gupta #ifndef OPENBMC_IPMI_FRU_PARSER_H 219c617b7SRatan Gupta #define OPENBMC_IPMI_FRU_PARSER_H 319c617b7SRatan Gupta 419c617b7SRatan Gupta #include <systemd/sd-bus.h> 519c617b7SRatan Gupta #include <array> 66eed4032SRatan Gupta #include <string> 76eed4032SRatan Gupta #include <map> 8a71d0f15SPatrick Williams #include <vector> 919c617b7SRatan Gupta 1019c617b7SRatan Gupta enum ipmi_fru_area_type 1119c617b7SRatan Gupta { 1219c617b7SRatan Gupta IPMI_FRU_AREA_INTERNAL_USE = 0x00, 1319c617b7SRatan Gupta IPMI_FRU_AREA_CHASSIS_INFO, 1419c617b7SRatan Gupta IPMI_FRU_AREA_BOARD_INFO, 1519c617b7SRatan Gupta IPMI_FRU_AREA_PRODUCT_INFO, 1619c617b7SRatan Gupta IPMI_FRU_AREA_MULTI_RECORD, 1719c617b7SRatan Gupta IPMI_FRU_AREA_TYPE_MAX 1819c617b7SRatan Gupta }; 1919c617b7SRatan Gupta 2019c617b7SRatan Gupta 2119c617b7SRatan Gupta enum openbmc_vpd_key_id 2219c617b7SRatan Gupta { 2319c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_TYPE = 1, /* not a type/len */ 2419c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_PART_NUM, 2519c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM, 2619c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM1, 2719c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM2, 2819c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM3, 2919c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM4, 3019c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM5, 3119c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM6, 3219c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM7, 3319c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, 3419c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_MAX = OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, 3519c617b7SRatan Gupta /* TODO: chassis_custom_fields */ 3619c617b7SRatan Gupta 3719c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_MFG_DATE, /* not a type/len */ 3819c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_MFR, 3919c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_NAME, 4019c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_SERIAL_NUM, 4119c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_PART_NUM, 4219c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID, 4319c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM1, 4419c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM2, 4519c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM3, 4619c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM4, 4719c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM5, 4819c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM6, 4919c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM7, 5019c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM8, 5119c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_MAX = OPENBMC_VPD_KEY_BOARD_CUSTOM8, 5219c617b7SRatan Gupta /* TODO: board_custom_fields */ 5319c617b7SRatan Gupta 5419c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_MFR, 5519c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_NAME, 5619c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM, 5719c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_VER, 5819c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM, 5919c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG, 6019c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID, 6119c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM1, 6219c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM2, 6319c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM3, 6419c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM4, 6519c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM5, 6619c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM6, 6719c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM7, 6819c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, 6919c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_MAX = OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, 7019c617b7SRatan Gupta 7119c617b7SRatan Gupta OPENBMC_VPD_KEY_MAX, 7219c617b7SRatan Gupta OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX=8, 7319c617b7SRatan Gupta 7419c617b7SRatan Gupta }; 7519c617b7SRatan Gupta 7619c617b7SRatan Gupta using IPMIFruInfo = std::array<std::pair<std::string,std::string>, 7719c617b7SRatan Gupta OPENBMC_VPD_KEY_MAX>; 7819c617b7SRatan Gupta 79aeb726dfSPatrick Williams struct IPMIFruData 80aeb726dfSPatrick Williams { 81aeb726dfSPatrick Williams std::string section; 82aeb726dfSPatrick Williams std::string property; 83aeb726dfSPatrick Williams std::string delimiter; 84aeb726dfSPatrick Williams }; 856eed4032SRatan Gupta 866eed4032SRatan Gupta using DbusProperty = std::string; 87a71d0f15SPatrick Williams using DbusPropertyVec = std::vector<std::pair<DbusProperty, IPMIFruData>>; 886eed4032SRatan Gupta 896eed4032SRatan Gupta using DbusInterface = std::string; 90a71d0f15SPatrick Williams using DbusInterfaceVec = std::vector<std::pair<DbusInterface, DbusPropertyVec>>; 916eed4032SRatan Gupta 926eed4032SRatan Gupta using FruInstancePath = std::string; 93*c19c054cSRatan Gupta 94*c19c054cSRatan Gupta struct FruInstance 95*c19c054cSRatan Gupta { 96*c19c054cSRatan Gupta uint8_t entityID; 97*c19c054cSRatan Gupta uint8_t entityInstance; 98*c19c054cSRatan Gupta FruInstancePath path; 99*c19c054cSRatan Gupta DbusInterfaceVec interfaces; 100*c19c054cSRatan Gupta }; 101*c19c054cSRatan Gupta 102*c19c054cSRatan Gupta using FruInstanceVec = std::vector<FruInstance>; 1036eed4032SRatan Gupta 1046eed4032SRatan Gupta using FruId = uint32_t; 105a71d0f15SPatrick Williams using FruMap = std::map<FruId, FruInstanceVec>; 10619c617b7SRatan Gupta 10719c617b7SRatan Gupta /* Parse an IPMI write fru data message into a dictionary containing name value pair of VPD entries.*/ 10819c617b7SRatan Gupta int parse_fru (const void* msgbuf, sd_bus_message* vpdtbl); 10919c617b7SRatan Gupta 11019c617b7SRatan Gupta int parse_fru_area (const uint8_t area, const void* msgbuf, 11119c617b7SRatan Gupta const size_t len, IPMIFruInfo& info); 11219c617b7SRatan Gupta 11319c617b7SRatan Gupta #endif 114