1 #pragma once
2 
3 #include "impl.hpp"
4 #include "parser_interface.hpp"
5 #include "types.hpp"
6 
7 namespace openpower
8 {
9 namespace vpd
10 {
11 namespace isdimm
12 {
13 namespace parser
14 {
15 using ParserInterface = openpower::vpd::parser::interface::ParserInterface;
16 using kwdVpdMap = inventory::KeywordVpdMap;
17 
18 class 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      */
isdimmVpdParser(const Binary & VpdVector)33     isdimmVpdParser(const Binary& VpdVector) : memVpd(VpdVector) {}
34 
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      * @param[in] iterator - iterator to buffer containing SPD
88      * @return allocated FRU number.
89      */
90     auto getDDR4FruNumber(const std::string& partNumber,
91                           Binary::const_iterator& iterator);
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 The function fetches manufacturer's ID of DIMM.
103      *
104      * @return manufacturer ID.
105      */
106     auto getDDR4ManufacturerId();
107 
108     /**
109      * @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 
148     /**
149      * @brief The function fetches manufacturer's ID of DIMM.
150      *
151      * @return manufacturer ID.
152      */
153     auto getDDR5ManufacturerId();
154 
155     // vdp file to be parsed
156     const Binary& memVpd;
157 };
158 
getInterfaceName() const159 inline std::string isdimmVpdParser::getInterfaceName() const
160 {
161     return constants::memVpdInf;
162 }
163 
164 } // namespace parser
165 } // namespace isdimm
166 } // namespace vpd
167 } // namespace openpower
168