blob: 09ffc9f1d31e4e36e22f25543badec2649e02c9a [file] [log] [blame]
Hariharasubramanian R44473092015-10-15 08:25:28 -05001#ifndef OPENBMC_IPMI_FRU_PARSER_H
2#define OPENBMC_IPMI_FRU_PARSER_H
3
Vishwa4be4b7a2015-10-31 22:55:50 -05004#include <systemd/sd-bus.h>
Ratan Guptacb0d4e52016-12-22 19:05:57 +05305#include <array>
Ratan Gupta6eed4032017-02-10 15:59:31 +05306#include <string>
7#include <map>
Chris Austenb45c4cb2015-11-01 06:34:56 -06008
Hariharasubramanian Ra032c772015-10-20 07:28:19 -05009enum ipmi_fru_area_type
Hariharasubramanian Rc2d79462015-10-16 06:47:56 -050010{
11 IPMI_FRU_AREA_INTERNAL_USE = 0x00,
12 IPMI_FRU_AREA_CHASSIS_INFO,
13 IPMI_FRU_AREA_BOARD_INFO,
14 IPMI_FRU_AREA_PRODUCT_INFO,
15 IPMI_FRU_AREA_MULTI_RECORD,
16 IPMI_FRU_AREA_TYPE_MAX
Hariharasubramanian Ra032c772015-10-20 07:28:19 -050017};
Hariharasubramanian R44473092015-10-15 08:25:28 -050018
Ratan Guptacb0d4e52016-12-22 19:05:57 +053019
20enum openbmc_vpd_key_id
21{
22 OPENBMC_VPD_KEY_CHASSIS_TYPE = 1, /* not a type/len */
23 OPENBMC_VPD_KEY_CHASSIS_PART_NUM,
24 OPENBMC_VPD_KEY_CHASSIS_SERIAL_NUM,
25 OPENBMC_VPD_KEY_CHASSIS_CUSTOM1,
26 OPENBMC_VPD_KEY_CHASSIS_CUSTOM2,
27 OPENBMC_VPD_KEY_CHASSIS_CUSTOM3,
28 OPENBMC_VPD_KEY_CHASSIS_CUSTOM4,
29 OPENBMC_VPD_KEY_CHASSIS_CUSTOM5,
30 OPENBMC_VPD_KEY_CHASSIS_CUSTOM6,
31 OPENBMC_VPD_KEY_CHASSIS_CUSTOM7,
32 OPENBMC_VPD_KEY_CHASSIS_CUSTOM8,
33 OPENBMC_VPD_KEY_CHASSIS_MAX = OPENBMC_VPD_KEY_CHASSIS_CUSTOM8,
34 /* TODO: chassis_custom_fields */
35
36 OPENBMC_VPD_KEY_BOARD_MFG_DATE, /* not a type/len */
37 OPENBMC_VPD_KEY_BOARD_MFR,
38 OPENBMC_VPD_KEY_BOARD_NAME,
39 OPENBMC_VPD_KEY_BOARD_SERIAL_NUM,
40 OPENBMC_VPD_KEY_BOARD_PART_NUM,
41 OPENBMC_VPD_KEY_BOARD_FRU_FILE_ID,
42 OPENBMC_VPD_KEY_BOARD_CUSTOM1,
43 OPENBMC_VPD_KEY_BOARD_CUSTOM2,
44 OPENBMC_VPD_KEY_BOARD_CUSTOM3,
45 OPENBMC_VPD_KEY_BOARD_CUSTOM4,
46 OPENBMC_VPD_KEY_BOARD_CUSTOM5,
47 OPENBMC_VPD_KEY_BOARD_CUSTOM6,
48 OPENBMC_VPD_KEY_BOARD_CUSTOM7,
49 OPENBMC_VPD_KEY_BOARD_CUSTOM8,
50 OPENBMC_VPD_KEY_BOARD_MAX = OPENBMC_VPD_KEY_BOARD_CUSTOM8,
51 /* TODO: board_custom_fields */
52
53 OPENBMC_VPD_KEY_PRODUCT_MFR,
54 OPENBMC_VPD_KEY_PRODUCT_NAME,
55 OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM,
56 OPENBMC_VPD_KEY_PRODUCT_VER,
57 OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM,
58 OPENBMC_VPD_KEY_PRODUCT_ASSET_TAG,
59 OPENBMC_VPD_KEY_PRODUCT_FRU_FILE_ID,
60 OPENBMC_VPD_KEY_PRODUCT_CUSTOM1,
61 OPENBMC_VPD_KEY_PRODUCT_CUSTOM2,
62 OPENBMC_VPD_KEY_PRODUCT_CUSTOM3,
63 OPENBMC_VPD_KEY_PRODUCT_CUSTOM4,
64 OPENBMC_VPD_KEY_PRODUCT_CUSTOM5,
65 OPENBMC_VPD_KEY_PRODUCT_CUSTOM6,
66 OPENBMC_VPD_KEY_PRODUCT_CUSTOM7,
67 OPENBMC_VPD_KEY_PRODUCT_CUSTOM8,
68 OPENBMC_VPD_KEY_PRODUCT_MAX = OPENBMC_VPD_KEY_PRODUCT_CUSTOM8,
69
70 OPENBMC_VPD_KEY_MAX,
71 OPENBMC_VPD_KEY_CUSTOM_FIELDS_MAX=8,
72
73};
74
75using IPMIFruInfo = std::array<std::pair<std::string,std::string>,
76 OPENBMC_VPD_KEY_MAX>;
77
Patrick Williamsaeb726d2017-06-01 19:00:43 -050078struct IPMIFruData
79{
80 std::string section;
81 std::string property;
82 std::string delimiter;
83};
Ratan Gupta6eed4032017-02-10 15:59:31 +053084
85using DbusProperty = std::string;
Patrick Williamsaeb726d2017-06-01 19:00:43 -050086using DbusPropertyMap = std::map<DbusProperty,IPMIFruData>;
Ratan Gupta6eed4032017-02-10 15:59:31 +053087
88using DbusInterface = std::string;
89using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>;
90
91using FruInstancePath = std::string;
92using FruInstanceMap = std::map<FruInstancePath,DbusInterfaceMap>;
93
94using FruId = uint32_t;
95using FruMap = std::map<FruId,FruInstanceMap>;
Ratan Guptacb0d4e52016-12-22 19:05:57 +053096
97/* Parse an IPMI write fru data message into a dictionary containing name value pair of VPD entries.*/
98int parse_fru (const void* msgbuf, sd_bus_message* vpdtbl);
99
100int parse_fru_area (const uint8_t area, const void* msgbuf,
101 const size_t len, IPMIFruInfo& info);
102
Hariharasubramanian R44473092015-10-15 08:25:28 -0500103#endif