blob: 9d6cca8644406b829072c6bfe517fa1257cd480f [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 */
33 isdimmVpdParser(const Binary& VpdVector) : memVpd(VpdVector)
34 {
35 }
36
37 /**
38 * @brief Parse the memory SPD binary data.
39 * Collects and emplace the keyword-value pairs in map.
40 *
41 * @return map of keyword:value
42 */
43 std::variant<kwdVpdMap, Store> parse();
44
45 /**
46 * @brief An api to return interface name with respect to
47 * published data on cache
48 *
49 * @return - Interface name for that vpd type.
50 */
51 std::string getInterfaceName() const;
52
53 private:
54 /**
55 * @brief An api to read keywords.
56 *
57 * @return- map of kwd:value
58 */
59 kwdVpdMap readKeywords(Binary::const_iterator& iterator);
60
61 /**
62 * @brief This function calculates DIMM size from SPD
63 *
64 * @param[in] iterator - iterator to buffer containing SPD
65 * @return calculated data or 0 in case of any error.
66 */
67 auto getDDR4DimmCapacity(Binary::const_iterator& iterator);
68
69 /**
70 * @brief This function calculates part number from SPD
71 *
72 * @param[in] iterator - iterator to buffer containing SPD
73 * @return calculated part number.
74 */
75 auto getDDR4PartNumber(Binary::const_iterator& iterator);
76
77 /**
78 * @brief This function calculates serial number from SPD
79 *
80 * @param[in] iterator - iterator to buffer containing SPD
81 * @return calculated serial number.
82 */
83 auto getDDR4SerialNumber(Binary::const_iterator& iterator);
84
85 /**
86 * @brief This function allocates FRU number based on part number
87 *
88 * @param[in] partNumber - part number of the DIMM
89 * @return allocated FRU number.
90 */
91 auto getDDR4FruNumber(const std::string& partNumber);
92
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