blob: 82708849d5f07a444c72287ca2eae00f111b848b [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 /**
Sunny Srivastava172e74f2024-05-21 02:02:05 -0500102 * @brief The function fetches manufacturer's ID of DIMM.
103 *
104 * @return manufacturer ID.
105 */
106 auto getDDR4ManufacturerId();
107
108 /**
jinuthomas6555e7e2023-02-14 21:48:00 -0600109 * @brief This function calculates DIMM size from SPD
110 *
111 * @param[in] iterator - iterator to buffer containing SPD
112 * @return calculated data or 0 in case of any error.
113 */
114 auto getDDR5DimmCapacity(Binary::const_iterator& iterator);
115
116 /**
117 * @brief This function calculates part number from SPD
118 *
119 * @param[in] iterator - iterator to buffer containing SPD
120 * @return calculated part number.
121 */
122 auto getDDR5PartNumber(Binary::const_iterator& iterator);
123
124 /**
125 * @brief This function calculates serial number from SPD
126 *
127 * @param[in] iterator - iterator to buffer containing SPD
128 * @return calculated serial number.
129 */
130 auto getDDR5SerialNumber(Binary::const_iterator& iterator);
131
132 /**
133 * @brief This function allocates FRU number based on part number
134 *
135 * @param[in] partNumber - part number of the DIMM
136 * @return allocated FRU number.
137 */
138 auto getDDR5FruNumber(const std::string& partNumber);
139
140 /**
141 * @brief This function allocates CCIN based on part number
142 *
143 * @param[in] partNumber - part number of the DIMM
144 * @return allocated CCIN.
145 */
146 auto getDDR5CCIN(const std::string& partNumber);
147
Sunny Srivastava172e74f2024-05-21 02:02:05 -0500148 /**
149 * @brief The function fetches manufacturer's ID of DIMM.
150 *
151 * @return manufacturer ID.
152 */
153 auto getDDR5ManufacturerId();
154
jinuthomas6555e7e2023-02-14 21:48:00 -0600155 // vdp file to be parsed
156 const Binary& memVpd;
157};
158
159inline std::string isdimmVpdParser::getInterfaceName() const
160{
161 return constants::memVpdInf;
162}
163
164} // namespace parser
jinuthomas5700b3c2023-03-07 22:51:00 -0600165} // namespace isdimm
jinuthomas6555e7e2023-02-14 21:48:00 -0600166} // namespace vpd
167} // namespace openpower