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