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> 5c9508db8SPatrick Venture 619c617b7SRatan Gupta #include <array> 76eed4032SRatan Gupta #include <map> 8c9508db8SPatrick Venture #include <string> 9*e4024bc3SPatrick Venture #include <utility> 10a71d0f15SPatrick Williams #include <vector> 1119c617b7SRatan Gupta 1219c617b7SRatan Gupta enum ipmi_fru_area_type 1319c617b7SRatan Gupta { 1419c617b7SRatan Gupta IPMI_FRU_AREA_INTERNAL_USE = 0x00, 1519c617b7SRatan Gupta IPMI_FRU_AREA_CHASSIS_INFO, 1619c617b7SRatan Gupta IPMI_FRU_AREA_BOARD_INFO, 1719c617b7SRatan Gupta IPMI_FRU_AREA_PRODUCT_INFO, 1819c617b7SRatan Gupta IPMI_FRU_AREA_MULTI_RECORD, 1919c617b7SRatan Gupta IPMI_FRU_AREA_TYPE_MAX 2019c617b7SRatan Gupta }; 2119c617b7SRatan Gupta 2219c617b7SRatan Gupta enum openbmc_vpd_key_id 2319c617b7SRatan Gupta { 2419c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_TYPE = 1, /* not a type/len */ 2519c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_PART_NUM, 2619c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM, 2719c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM1, 2819c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM2, 2919c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM3, 3019c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM4, 3119c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM5, 3219c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM6, 3319c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM7, 3419c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, 3519c617b7SRatan Gupta OPENBMC_VPD_KEY_CHASSIS_MAX = OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, 3619c617b7SRatan Gupta /* TODO: chassis_custom_fields */ 3719c617b7SRatan Gupta 3819c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_MFG_DATE, /* not a type/len */ 3919c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_MFR, 4019c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_NAME, 4119c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_SERIAL_NUM, 4219c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_PART_NUM, 4319c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID, 4419c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM1, 4519c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM2, 4619c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM3, 4719c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM4, 4819c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM5, 4919c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM6, 5019c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM7, 5119c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_CUSTOM8, 5219c617b7SRatan Gupta OPENBMC_VPD_KEY_BOARD_MAX = OPENBMC_VPD_KEY_BOARD_CUSTOM8, 5319c617b7SRatan Gupta /* TODO: board_custom_fields */ 5419c617b7SRatan Gupta 5519c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_MFR, 5619c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_NAME, 5719c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM, 5819c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_VER, 5919c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM, 6019c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG, 6119c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID, 6219c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM1, 6319c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM2, 6419c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM3, 6519c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM4, 6619c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM5, 6719c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM6, 6819c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM7, 6919c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, 7019c617b7SRatan Gupta OPENBMC_VPD_KEY_PRODUCT_MAX = OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, 7119c617b7SRatan Gupta 7219c617b7SRatan Gupta OPENBMC_VPD_KEY_MAX, 7319c617b7SRatan Gupta OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX = 8, 7419c617b7SRatan Gupta 7519c617b7SRatan Gupta }; 7619c617b7SRatan Gupta 77c9508db8SPatrick Venture using IPMIFruInfo = 78c9508db8SPatrick Venture std::array<std::pair<std::string, std::string>, OPENBMC_VPD_KEY_MAX>; 7919c617b7SRatan Gupta 80aeb726dfSPatrick Williams struct IPMIFruData 81aeb726dfSPatrick Williams { 82aeb726dfSPatrick Williams std::string section; 83aeb726dfSPatrick Williams std::string property; 84aeb726dfSPatrick Williams std::string delimiter; 85aeb726dfSPatrick Williams }; 866eed4032SRatan Gupta 876eed4032SRatan Gupta using DbusProperty = std::string; 88a71d0f15SPatrick Williams using DbusPropertyVec = std::vector<std::pair<DbusProperty, IPMIFruData>>; 896eed4032SRatan Gupta 906eed4032SRatan Gupta using DbusInterface = std::string; 91a71d0f15SPatrick Williams using DbusInterfaceVec = std::vector<std::pair<DbusInterface, DbusPropertyVec>>; 926eed4032SRatan Gupta 936eed4032SRatan Gupta using FruInstancePath = std::string; 94c19c054cSRatan Gupta 95c19c054cSRatan Gupta struct FruInstance 96c19c054cSRatan Gupta { 97c19c054cSRatan Gupta uint8_t entityID; 98c19c054cSRatan Gupta uint8_t entityInstance; 99c19c054cSRatan Gupta FruInstancePath path; 100c19c054cSRatan Gupta DbusInterfaceVec interfaces; 101c19c054cSRatan Gupta }; 102c19c054cSRatan Gupta 103c19c054cSRatan Gupta using FruInstanceVec = std::vector<FruInstance>; 1046eed4032SRatan Gupta 1056eed4032SRatan Gupta using FruId = uint32_t; 106a71d0f15SPatrick Williams using FruMap = std::map<FruId, FruInstanceVec>; 10719c617b7SRatan Gupta 108c9508db8SPatrick Venture /* Parse an IPMI write fru data message into a dictionary containing name value 109c9508db8SPatrick Venture * pair of VPD entries.*/ 11019c617b7SRatan Gupta int parse_fru(const void* msgbuf, sd_bus_message* vpdtbl); 11119c617b7SRatan Gupta 112c9508db8SPatrick Venture int parse_fru_area(const uint8_t area, const void* msgbuf, const size_t len, 113c9508db8SPatrick Venture IPMIFruInfo& info); 11419c617b7SRatan Gupta 11519c617b7SRatan Gupta #endif 116