xref: /openbmc/google-ipmi-sys/handler.hpp (revision 8cfa4c4400201459690c2ec6537df0f9c197f730)
1 #pragma once
2 
3 #include <cstdint>
4 #include <map>
5 #include <string>
6 #include <tuple>
7 #include <vector>
8 
9 namespace google
10 {
11 namespace ipmi
12 {
13 
14 using VersionTuple =
15     std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;
16 
17 class HandlerInterface
18 {
19   public:
20     virtual ~HandlerInterface() = default;
21 
22     /**
23      * Return ethernet details (hard-coded).
24      *
25      * @return tuple of ethernet details (channel, if name).
26      */
27     virtual std::tuple<std::uint8_t, std::string> getEthDetails() const = 0;
28 
29     /**
30      * Return the value of rx_packets, given a if_name.
31      *
32      * @param[in] name, the interface name.
33      * @return the number of packets received.
34      * @throw IpmiException on failure.
35      */
36     virtual std::int64_t getRxPackets(const std::string& name) const = 0;
37 
38     /**
39      * Return the values from a cpld version file.
40      *
41      * @param[in] id - the cpld id number.
42      * @return the quad of numbers as a tuple (maj,min,pt,subpt)
43      * @throw IpmiException on failure.
44      */
45     virtual VersionTuple getCpldVersion(unsigned int id) const = 0;
46 
47     /**
48      * Set the PSU Reset delay.
49      *
50      * @param[in] delay - delay in seconds.
51      * @throw IpmiException on failure.
52      */
53     virtual void psuResetDelay(std::uint32_t delay) const = 0;
54 
55     /**
56      * Arm for PSU reset on host shutdown.
57      *
58      * @throw IpmiException on failure.
59      */
60     virtual void psuResetOnShutdown() const = 0;
61 
62     /**
63      * Return the entity name.
64      * On the first call to this method it'll build the list of entities.
65      * @todo Consider moving the list building to construction time (and ignore
66      * failures).
67      *
68      * @param[in] id - the entity id value
69      * @param[in] instance - the entity instance
70      * @return the entity's name
71      * @throw IpmiException on failure.
72      */
73     virtual std::string getEntityName(std::uint8_t id,
74                                       std::uint8_t instance) = 0;
75 
76     /**
77      * Return the flash size of bmc chip.
78      *
79      * @return the flash size of bmc chip
80      * @throw IpmiException on failure.
81      */
82     virtual uint32_t getFlashSize() = 0;
83 
84     /**
85      * Return the name of the machine, parsed from release information.
86      *
87      * @return the machine name
88      * @throw IpmiException on failure.
89      */
90     virtual std::string getMachineName() = 0;
91 
92     /**
93      * Populate the i2c-pcie mapping vector.
94      */
95     virtual void buildI2cPcieMapping() = 0;
96 
97     /**
98      * Return the size of the i2c-pcie mapping vector.
99      *
100      * @return the size of the vector holding the i2c-pcie mapping tuples.
101      */
102     virtual size_t getI2cPcieMappingSize() const = 0;
103 
104     /**
105      * Return a copy of the entry in the vector.
106      *
107      * @param[in] entry - the index into the vector.
108      * @return the tuple at that index.
109      */
110     virtual std::tuple<std::uint32_t, std::string>
111         getI2cEntry(unsigned int entry) const = 0;
112 
113     /**
114      * Set the Host Power Off delay.
115      *
116      * @param[in] delay - delay in seconds.
117      * @throw IpmiException on failure.
118      */
119     virtual void hostPowerOffDelay(std::uint32_t delay) const = 0;
120 };
121 
122 } // namespace ipmi
123 } // namespace google
124