1*c87de558SPatrick Venture #pragma once
2*c87de558SPatrick Venture 
3*c87de558SPatrick Venture #include "handler.hpp"
4*c87de558SPatrick Venture 
5*c87de558SPatrick Venture #include <cstdint>
6*c87de558SPatrick Venture #include <map>
7*c87de558SPatrick Venture #include <nlohmann/json.hpp>
8*c87de558SPatrick Venture #include <string>
9*c87de558SPatrick Venture #include <tuple>
10*c87de558SPatrick Venture #include <vector>
11*c87de558SPatrick Venture 
12*c87de558SPatrick Venture namespace google
13*c87de558SPatrick Venture {
14*c87de558SPatrick Venture namespace ipmi
15*c87de558SPatrick Venture {
16*c87de558SPatrick Venture 
17*c87de558SPatrick Venture extern const std::string defaultConfigFile;
18*c87de558SPatrick Venture 
19*c87de558SPatrick Venture class Handler : public HandlerInterface
20*c87de558SPatrick Venture {
21*c87de558SPatrick Venture   public:
22*c87de558SPatrick Venture     explicit Handler(const std::string& entityConfigPath = defaultConfigFile) :
23*c87de558SPatrick Venture         _configFile(entityConfigPath){};
24*c87de558SPatrick Venture     ~Handler() = default;
25*c87de558SPatrick Venture 
26*c87de558SPatrick Venture     std::tuple<std::uint8_t, std::string> getEthDetails() const override;
27*c87de558SPatrick Venture     std::int64_t getRxPackets(const std::string& name) const override;
28*c87de558SPatrick Venture     VersionTuple getCpldVersion(unsigned int id) const override;
29*c87de558SPatrick Venture     void psuResetDelay(std::uint32_t delay) const override;
30*c87de558SPatrick Venture     std::string getEntityName(std::uint8_t id, std::uint8_t instance) override;
31*c87de558SPatrick Venture     void buildI2cPcieMapping() override;
32*c87de558SPatrick Venture     size_t getI2cPcieMappingSize() const override;
33*c87de558SPatrick Venture     std::tuple<std::uint32_t, std::string>
34*c87de558SPatrick Venture         getI2cEntry(unsigned int entry) const override;
35*c87de558SPatrick Venture 
36*c87de558SPatrick Venture   private:
37*c87de558SPatrick Venture     std::string _configFile;
38*c87de558SPatrick Venture 
39*c87de558SPatrick Venture     bool _entityConfigParsed = false;
40*c87de558SPatrick Venture 
41*c87de558SPatrick Venture     const std::map<uint8_t, std::string> _entityIdToName{
42*c87de558SPatrick Venture         {0x03, "cpu"},
43*c87de558SPatrick Venture         {0x04, "storage_device"},
44*c87de558SPatrick Venture         {0x06, "system_management_module"},
45*c87de558SPatrick Venture         {0x07, "system_board"},
46*c87de558SPatrick Venture         {0x08, "memory_module"},
47*c87de558SPatrick Venture         {0x0B, "add_in_card"},
48*c87de558SPatrick Venture         {0x0E, "power_system_board"},
49*c87de558SPatrick Venture         {0x10, "system_internal_expansion_board"},
50*c87de558SPatrick Venture         {0x11, "other_system_board"},
51*c87de558SPatrick Venture         {0x17, "system_chassis"},
52*c87de558SPatrick Venture         {0x1D, "fan"},
53*c87de558SPatrick Venture         {0x1E, "cooling_unit"},
54*c87de558SPatrick Venture         {0x20, "memory_device"}};
55*c87de558SPatrick Venture 
56*c87de558SPatrick Venture     nlohmann::json _entityConfig{};
57*c87de558SPatrick Venture 
58*c87de558SPatrick Venture     std::vector<std::tuple<uint32_t, std::string>> _pcie_i2c_map;
59*c87de558SPatrick Venture };
60*c87de558SPatrick Venture 
61*c87de558SPatrick Venture } // namespace ipmi
62*c87de558SPatrick Venture } // namespace google
63