Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 1 | #ifndef OPENBMC_IPMI_FRU_PARSER_H |
| 2 | #define OPENBMC_IPMI_FRU_PARSER_H |
| 3 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 4 | #include <systemd/sd-bus.h> |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 5 | #include <array> |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 6 | #include <string> |
| 7 | #include <map> |
Patrick Williams | a71d0f1 | 2017-06-01 19:19:09 -0500 | [diff] [blame^] | 8 | #include <vector> |
Chris Austen | b45c4cb | 2015-11-01 06:34:56 -0600 | [diff] [blame] | 9 | |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 10 | enum ipmi_fru_area_type |
Hariharasubramanian R | c2d7946 | 2015-10-16 06:47:56 -0500 | [diff] [blame] | 11 | { |
| 12 | IPMI_FRU_AREA_INTERNAL_USE = 0x00, |
| 13 | IPMI_FRU_AREA_CHASSIS_INFO, |
| 14 | IPMI_FRU_AREA_BOARD_INFO, |
| 15 | IPMI_FRU_AREA_PRODUCT_INFO, |
| 16 | IPMI_FRU_AREA_MULTI_RECORD, |
| 17 | IPMI_FRU_AREA_TYPE_MAX |
Hariharasubramanian R | a032c77 | 2015-10-20 07:28:19 -0500 | [diff] [blame] | 18 | }; |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 19 | |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 20 | |
| 21 | enum openbmc_vpd_key_id |
| 22 | { |
| 23 | OPENBMC_VPD_KEY_CHASSIS_TYPE = 1, /* not a type/len */ |
| 24 | OPENBMC_VPD_KEY_CHASSIS_PART_NUM, |
| 25 | OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM, |
| 26 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM1, |
| 27 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM2, |
| 28 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM3, |
| 29 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM4, |
| 30 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM5, |
| 31 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM6, |
| 32 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM7, |
| 33 | OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, |
| 34 | OPENBMC_VPD_KEY_CHASSIS_MAX = OPENBMC_VPD_KEY_CHASSIS_CUSTOM8, |
| 35 | /* TODO: chassis_custom_fields */ |
| 36 | |
| 37 | OPENBMC_VPD_KEY_BOARD_MFG_DATE, /* not a type/len */ |
| 38 | OPENBMC_VPD_KEY_BOARD_MFR, |
| 39 | OPENBMC_VPD_KEY_BOARD_NAME, |
| 40 | OPENBMC_VPD_KEY_BOARD_SERIAL_NUM, |
| 41 | OPENBMC_VPD_KEY_BOARD_PART_NUM, |
| 42 | OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID, |
| 43 | OPENBMC_VPD_KEY_BOARD_CUSTOM1, |
| 44 | OPENBMC_VPD_KEY_BOARD_CUSTOM2, |
| 45 | OPENBMC_VPD_KEY_BOARD_CUSTOM3, |
| 46 | OPENBMC_VPD_KEY_BOARD_CUSTOM4, |
| 47 | OPENBMC_VPD_KEY_BOARD_CUSTOM5, |
| 48 | OPENBMC_VPD_KEY_BOARD_CUSTOM6, |
| 49 | OPENBMC_VPD_KEY_BOARD_CUSTOM7, |
| 50 | OPENBMC_VPD_KEY_BOARD_CUSTOM8, |
| 51 | OPENBMC_VPD_KEY_BOARD_MAX = OPENBMC_VPD_KEY_BOARD_CUSTOM8, |
| 52 | /* TODO: board_custom_fields */ |
| 53 | |
| 54 | OPENBMC_VPD_KEY_PRODUCT_MFR, |
| 55 | OPENBMC_VPD_KEY_PRODUCT_NAME, |
| 56 | OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM, |
| 57 | OPENBMC_VPD_KEY_PRODUCT_VER, |
| 58 | OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM, |
| 59 | OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG, |
| 60 | OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID, |
| 61 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM1, |
| 62 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM2, |
| 63 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM3, |
| 64 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM4, |
| 65 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM5, |
| 66 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM6, |
| 67 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM7, |
| 68 | OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, |
| 69 | OPENBMC_VPD_KEY_PRODUCT_MAX = OPENBMC_VPD_KEY_PRODUCT_CUSTOM8, |
| 70 | |
| 71 | OPENBMC_VPD_KEY_MAX, |
| 72 | OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX=8, |
| 73 | |
| 74 | }; |
| 75 | |
| 76 | using IPMIFruInfo = std::array<std::pair<std::string,std::string>, |
| 77 | OPENBMC_VPD_KEY_MAX>; |
| 78 | |
Patrick Williams | aeb726d | 2017-06-01 19:00:43 -0500 | [diff] [blame] | 79 | struct IPMIFruData |
| 80 | { |
| 81 | std::string section; |
| 82 | std::string property; |
| 83 | std::string delimiter; |
| 84 | }; |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 85 | |
| 86 | using DbusProperty = std::string; |
Patrick Williams | a71d0f1 | 2017-06-01 19:19:09 -0500 | [diff] [blame^] | 87 | using DbusPropertyVec = std::vector<std::pair<DbusProperty,IPMIFruData>>; |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 88 | |
| 89 | using DbusInterface = std::string; |
Patrick Williams | a71d0f1 | 2017-06-01 19:19:09 -0500 | [diff] [blame^] | 90 | using DbusInterfaceVec = std::vector<std::pair<DbusInterface,DbusPropertyVec>>; |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 91 | |
| 92 | using FruInstancePath = std::string; |
Patrick Williams | a71d0f1 | 2017-06-01 19:19:09 -0500 | [diff] [blame^] | 93 | using FruInstanceVec = std::vector<std::pair<FruInstancePath,DbusInterfaceVec>>; |
Ratan Gupta | 6eed403 | 2017-02-10 15:59:31 +0530 | [diff] [blame] | 94 | |
| 95 | using FruId = uint32_t; |
Patrick Williams | a71d0f1 | 2017-06-01 19:19:09 -0500 | [diff] [blame^] | 96 | using FruMap = std::map<FruId,FruInstanceVec>; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 97 | |
| 98 | /* Parse an IPMI write fru data message into a dictionary containing name value pair of VPD entries.*/ |
| 99 | int parse_fru (const void* msgbuf, sd_bus_message* vpdtbl); |
| 100 | |
| 101 | int parse_fru_area (const uint8_t area, const void* msgbuf, |
| 102 | const size_t len, IPMIFruInfo& info); |
| 103 | |
Hariharasubramanian R | 4447309 | 2015-10-15 08:25:28 -0500 | [diff] [blame] | 104 | #endif |