blob: 69ae2c52a2a65c29bb33be76cd246faa8c545e3b [file] [log] [blame]
jinuthomas6555e7e2023-02-14 21:48:00 -06001#pragma once
2
3#include "impl.hpp"
4#include "parser_interface.hpp"
5#include "types.hpp"
6
7namespace openpower
8{
9namespace vpd
10{
jinuthomas5700b3c2023-03-07 22:51:00 -060011namespace isdimm
jinuthomas6555e7e2023-02-14 21:48:00 -060012{
13namespace parser
14{
15using ParserInterface = openpower::vpd::parser::interface::ParserInterface;
16using kwdVpdMap = inventory::KeywordVpdMap;
17
18class isdimmVpdParser : public ParserInterface
19{
20 public:
21 isdimmVpdParser() = delete;
22 isdimmVpdParser(const isdimmVpdParser&) = delete;
23 isdimmVpdParser& operator=(const isdimmVpdParser&) = delete;
24 isdimmVpdParser(isdimmVpdParser&&) = delete;
25 isdimmVpdParser& operator=(isdimmVpdParser&&) = delete;
26 ~isdimmVpdParser() = default;
27
28 /**
29 * @brief Constructor
30 *
31 * Move memVpdVector to parser object's memVpdVector
32 */
Patrick Williamsc78d8872023-05-10 07:50:56 -050033 isdimmVpdParser(const Binary& VpdVector) : memVpd(VpdVector) {}
jinuthomas6555e7e2023-02-14 21:48:00 -060034
35 /**
36 * @brief Parse the memory SPD binary data.
37 * Collects and emplace the keyword-value pairs in map.
38 *
39 * @return map of keyword:value
40 */
41 std::variant<kwdVpdMap, Store> parse();
42
43 /**
44 * @brief An api to return interface name with respect to
45 * published data on cache
46 *
47 * @return - Interface name for that vpd type.
48 */
49 std::string getInterfaceName() const;
50
51 private:
52 /**
53 * @brief An api to read keywords.
54 *
55 * @return- map of kwd:value
56 */
57 kwdVpdMap readKeywords(Binary::const_iterator& iterator);
58
59 /**
60 * @brief This function calculates DIMM size from SPD
61 *
62 * @param[in] iterator - iterator to buffer containing SPD
63 * @return calculated data or 0 in case of any error.
64 */
65 auto getDDR4DimmCapacity(Binary::const_iterator& iterator);
66
67 /**
68 * @brief This function calculates part number from SPD
69 *
70 * @param[in] iterator - iterator to buffer containing SPD
71 * @return calculated part number.
72 */
73 auto getDDR4PartNumber(Binary::const_iterator& iterator);
74
75 /**
76 * @brief This function calculates serial number from SPD
77 *
78 * @param[in] iterator - iterator to buffer containing SPD
79 * @return calculated serial number.
80 */
81 auto getDDR4SerialNumber(Binary::const_iterator& iterator);
82
83 /**
84 * @brief This function allocates FRU number based on part number
85 *
86 * @param[in] partNumber - part number of the DIMM
87 * @return allocated FRU number.
88 */
89 auto getDDR4FruNumber(const std::string& partNumber);
90
91 /**
92 * @brief This function allocates CCIN based on part number
93 *
94 * @param[in] partNumber - part number of the DIMM
95 * @return allocated CCIN.
96 */
97 auto getDDR4CCIN(const std::string& partNumber);
98
99 /**
100 * @brief This function calculates DIMM size from SPD
101 *
102 * @param[in] iterator - iterator to buffer containing SPD
103 * @return calculated data or 0 in case of any error.
104 */
105 auto getDDR5DimmCapacity(Binary::const_iterator& iterator);
106
107 /**
108 * @brief This function calculates part number from SPD
109 *
110 * @param[in] iterator - iterator to buffer containing SPD
111 * @return calculated part number.
112 */
113 auto getDDR5PartNumber(Binary::const_iterator& iterator);
114
115 /**
116 * @brief This function calculates serial number from SPD
117 *
118 * @param[in] iterator - iterator to buffer containing SPD
119 * @return calculated serial number.
120 */
121 auto getDDR5SerialNumber(Binary::const_iterator& iterator);
122
123 /**
124 * @brief This function allocates FRU number based on part number
125 *
126 * @param[in] partNumber - part number of the DIMM
127 * @return allocated FRU number.
128 */
129 auto getDDR5FruNumber(const std::string& partNumber);
130
131 /**
132 * @brief This function allocates CCIN based on part number
133 *
134 * @param[in] partNumber - part number of the DIMM
135 * @return allocated CCIN.
136 */
137 auto getDDR5CCIN(const std::string& partNumber);
138
139 // vdp file to be parsed
140 const Binary& memVpd;
141};
142
143inline std::string isdimmVpdParser::getInterfaceName() const
144{
145 return constants::memVpdInf;
146}
147
148} // namespace parser
jinuthomas5700b3c2023-03-07 22:51:00 -0600149} // namespace isdimm
jinuthomas6555e7e2023-02-14 21:48:00 -0600150} // namespace vpd
151} // namespace openpower