16555e7efSjinuthomas #pragma once
26555e7efSjinuthomas 
36555e7efSjinuthomas #include "impl.hpp"
46555e7efSjinuthomas #include "parser_interface.hpp"
56555e7efSjinuthomas #include "types.hpp"
66555e7efSjinuthomas 
76555e7efSjinuthomas namespace openpower
86555e7efSjinuthomas {
96555e7efSjinuthomas namespace vpd
106555e7efSjinuthomas {
115700b3c8Sjinuthomas namespace isdimm
126555e7efSjinuthomas {
136555e7efSjinuthomas namespace parser
146555e7efSjinuthomas {
156555e7efSjinuthomas using ParserInterface = openpower::vpd::parser::interface::ParserInterface;
166555e7efSjinuthomas using kwdVpdMap = inventory::KeywordVpdMap;
176555e7efSjinuthomas 
186555e7efSjinuthomas class isdimmVpdParser : public ParserInterface
196555e7efSjinuthomas {
206555e7efSjinuthomas   public:
216555e7efSjinuthomas     isdimmVpdParser() = delete;
226555e7efSjinuthomas     isdimmVpdParser(const isdimmVpdParser&) = delete;
236555e7efSjinuthomas     isdimmVpdParser& operator=(const isdimmVpdParser&) = delete;
246555e7efSjinuthomas     isdimmVpdParser(isdimmVpdParser&&) = delete;
256555e7efSjinuthomas     isdimmVpdParser& operator=(isdimmVpdParser&&) = delete;
266555e7efSjinuthomas     ~isdimmVpdParser() = default;
276555e7efSjinuthomas 
286555e7efSjinuthomas     /**
296555e7efSjinuthomas      * @brief Constructor
306555e7efSjinuthomas      *
316555e7efSjinuthomas      * Move memVpdVector to parser object's memVpdVector
326555e7efSjinuthomas      */
isdimmVpdParser(const Binary & VpdVector)33c78d887cSPatrick Williams     isdimmVpdParser(const Binary& VpdVector) : memVpd(VpdVector) {}
346555e7efSjinuthomas 
356555e7efSjinuthomas     /**
366555e7efSjinuthomas      * @brief Parse the memory SPD binary data.
376555e7efSjinuthomas      * Collects and emplace the keyword-value pairs in map.
386555e7efSjinuthomas      *
396555e7efSjinuthomas      * @return map of keyword:value
406555e7efSjinuthomas      */
416555e7efSjinuthomas     std::variant<kwdVpdMap, Store> parse();
426555e7efSjinuthomas 
436555e7efSjinuthomas     /**
446555e7efSjinuthomas      * @brief An api to return interface name with respect to
456555e7efSjinuthomas      * published data on cache
466555e7efSjinuthomas      *
476555e7efSjinuthomas      * @return - Interface name for that vpd type.
486555e7efSjinuthomas      */
496555e7efSjinuthomas     std::string getInterfaceName() const;
506555e7efSjinuthomas 
516555e7efSjinuthomas   private:
526555e7efSjinuthomas     /**
536555e7efSjinuthomas      * @brief An api to read keywords.
546555e7efSjinuthomas      *
556555e7efSjinuthomas      * @return- map of kwd:value
566555e7efSjinuthomas      */
576555e7efSjinuthomas     kwdVpdMap readKeywords(Binary::const_iterator& iterator);
586555e7efSjinuthomas 
596555e7efSjinuthomas     /**
606555e7efSjinuthomas      * @brief This function calculates DIMM size from SPD
616555e7efSjinuthomas      *
626555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
636555e7efSjinuthomas      * @return calculated data or 0 in case of any error.
646555e7efSjinuthomas      */
656555e7efSjinuthomas     auto getDDR4DimmCapacity(Binary::const_iterator& iterator);
666555e7efSjinuthomas 
676555e7efSjinuthomas     /**
686555e7efSjinuthomas      * @brief This function calculates part number from SPD
696555e7efSjinuthomas      *
706555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
716555e7efSjinuthomas      * @return calculated part number.
726555e7efSjinuthomas      */
736555e7efSjinuthomas     auto getDDR4PartNumber(Binary::const_iterator& iterator);
746555e7efSjinuthomas 
756555e7efSjinuthomas     /**
766555e7efSjinuthomas      * @brief This function calculates serial number from SPD
776555e7efSjinuthomas      *
786555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
796555e7efSjinuthomas      * @return calculated serial number.
806555e7efSjinuthomas      */
816555e7efSjinuthomas     auto getDDR4SerialNumber(Binary::const_iterator& iterator);
826555e7efSjinuthomas 
836555e7efSjinuthomas     /**
846555e7efSjinuthomas      * @brief This function allocates FRU number based on part number
856555e7efSjinuthomas      *
866555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
87680960e2Sjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
886555e7efSjinuthomas      * @return allocated FRU number.
896555e7efSjinuthomas      */
90680960e2Sjinuthomas     auto getDDR4FruNumber(const std::string& partNumber,
91680960e2Sjinuthomas                           Binary::const_iterator& iterator);
926555e7efSjinuthomas 
936555e7efSjinuthomas     /**
946555e7efSjinuthomas      * @brief This function allocates CCIN based on part number
956555e7efSjinuthomas      *
966555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
976555e7efSjinuthomas      * @return allocated CCIN.
986555e7efSjinuthomas      */
996555e7efSjinuthomas     auto getDDR4CCIN(const std::string& partNumber);
1006555e7efSjinuthomas 
1016555e7efSjinuthomas     /**
102*172e74fdSSunny Srivastava      * @brief The function fetches manufacturer's ID of DIMM.
103*172e74fdSSunny Srivastava      *
104*172e74fdSSunny Srivastava      * @return manufacturer ID.
105*172e74fdSSunny Srivastava      */
106*172e74fdSSunny Srivastava     auto getDDR4ManufacturerId();
107*172e74fdSSunny Srivastava 
108*172e74fdSSunny Srivastava     /**
1096555e7efSjinuthomas      * @brief This function calculates DIMM size from SPD
1106555e7efSjinuthomas      *
1116555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
1126555e7efSjinuthomas      * @return calculated data or 0 in case of any error.
1136555e7efSjinuthomas      */
1146555e7efSjinuthomas     auto getDDR5DimmCapacity(Binary::const_iterator& iterator);
1156555e7efSjinuthomas 
1166555e7efSjinuthomas     /**
1176555e7efSjinuthomas      * @brief This function calculates part number from SPD
1186555e7efSjinuthomas      *
1196555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
1206555e7efSjinuthomas      * @return calculated part number.
1216555e7efSjinuthomas      */
1226555e7efSjinuthomas     auto getDDR5PartNumber(Binary::const_iterator& iterator);
1236555e7efSjinuthomas 
1246555e7efSjinuthomas     /**
1256555e7efSjinuthomas      * @brief This function calculates serial number from SPD
1266555e7efSjinuthomas      *
1276555e7efSjinuthomas      * @param[in] iterator - iterator to buffer containing SPD
1286555e7efSjinuthomas      * @return calculated serial number.
1296555e7efSjinuthomas      */
1306555e7efSjinuthomas     auto getDDR5SerialNumber(Binary::const_iterator& iterator);
1316555e7efSjinuthomas 
1326555e7efSjinuthomas     /**
1336555e7efSjinuthomas      * @brief This function allocates FRU number based on part number
1346555e7efSjinuthomas      *
1356555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
1366555e7efSjinuthomas      * @return allocated FRU number.
1376555e7efSjinuthomas      */
1386555e7efSjinuthomas     auto getDDR5FruNumber(const std::string& partNumber);
1396555e7efSjinuthomas 
1406555e7efSjinuthomas     /**
1416555e7efSjinuthomas      * @brief This function allocates CCIN based on part number
1426555e7efSjinuthomas      *
1436555e7efSjinuthomas      * @param[in] partNumber - part number of the DIMM
1446555e7efSjinuthomas      * @return allocated CCIN.
1456555e7efSjinuthomas      */
1466555e7efSjinuthomas     auto getDDR5CCIN(const std::string& partNumber);
1476555e7efSjinuthomas 
148*172e74fdSSunny Srivastava     /**
149*172e74fdSSunny Srivastava      * @brief The function fetches manufacturer's ID of DIMM.
150*172e74fdSSunny Srivastava      *
151*172e74fdSSunny Srivastava      * @return manufacturer ID.
152*172e74fdSSunny Srivastava      */
153*172e74fdSSunny Srivastava     auto getDDR5ManufacturerId();
154*172e74fdSSunny Srivastava 
1556555e7efSjinuthomas     // vdp file to be parsed
1566555e7efSjinuthomas     const Binary& memVpd;
1576555e7efSjinuthomas };
1586555e7efSjinuthomas 
getInterfaceName() const1596555e7efSjinuthomas inline std::string isdimmVpdParser::getInterfaceName() const
1606555e7efSjinuthomas {
1616555e7efSjinuthomas     return constants::memVpdInf;
1626555e7efSjinuthomas }
1636555e7efSjinuthomas 
1646555e7efSjinuthomas } // namespace parser
1655700b3c8Sjinuthomas } // namespace isdimm
1666555e7efSjinuthomas } // namespace vpd
1676555e7efSjinuthomas } // namespace openpower
168