blob: c8105f441a48310b6e506bbbb19634fae3d9a071 [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
jinuthomas680960e2023-05-17 05:58:50 -050087 * @param[in] iterator - iterator to buffer containing SPD
jinuthomas6555e7e2023-02-14 21:48:00 -060088 * @return allocated FRU number.
89 */
jinuthomas680960e2023-05-17 05:58:50 -050090 auto getDDR4FruNumber(const std::string& partNumber,
91 Binary::const_iterator& iterator);
jinuthomas6555e7e2023-02-14 21:48:00 -060092
93 /**
94 * @brief This function allocates CCIN based on part number
95 *
96 * @param[in] partNumber - part number of the DIMM
97 * @return allocated CCIN.
98 */
99 auto getDDR4CCIN(const std::string& partNumber);
100
101 /**
102 * @brief This function calculates DIMM size from SPD
103 *
104 * @param[in] iterator - iterator to buffer containing SPD
105 * @return calculated data or 0 in case of any error.
106 */
107 auto getDDR5DimmCapacity(Binary::const_iterator& iterator);
108
109 /**
110 * @brief This function calculates part number from SPD
111 *
112 * @param[in] iterator - iterator to buffer containing SPD
113 * @return calculated part number.
114 */
115 auto getDDR5PartNumber(Binary::const_iterator& iterator);
116
117 /**
118 * @brief This function calculates serial number from SPD
119 *
120 * @param[in] iterator - iterator to buffer containing SPD
121 * @return calculated serial number.
122 */
123 auto getDDR5SerialNumber(Binary::const_iterator& iterator);
124
125 /**
126 * @brief This function allocates FRU number based on part number
127 *
128 * @param[in] partNumber - part number of the DIMM
129 * @return allocated FRU number.
130 */
131 auto getDDR5FruNumber(const std::string& partNumber);
132
133 /**
134 * @brief This function allocates CCIN based on part number
135 *
136 * @param[in] partNumber - part number of the DIMM
137 * @return allocated CCIN.
138 */
139 auto getDDR5CCIN(const std::string& partNumber);
140
141 // vdp file to be parsed
142 const Binary& memVpd;
143};
144
145inline std::string isdimmVpdParser::getInterfaceName() const
146{
147 return constants::memVpdInf;
148}
149
150} // namespace parser
jinuthomas5700b3c2023-03-07 22:51:00 -0600151} // namespace isdimm
jinuthomas6555e7e2023-02-14 21:48:00 -0600152} // namespace vpd
153} // namespace openpower