blob: f4b1bbd159cc0db596f5a3b42195a4acf30b5100 [file] [log] [blame]
Patrick Venturef085d912019-03-15 08:50:00 -07001#pragma once
2
3#include <cstdint>
Patrick Ventureab650002019-03-16 09:08:47 -07004#include <map>
Patrick Venturef085d912019-03-15 08:50:00 -07005#include <string>
6#include <tuple>
Patrick Venture49f23ad2019-03-16 11:59:55 -07007#include <vector>
Patrick Venturef085d912019-03-15 08:50:00 -07008
9namespace google
10{
11namespace ipmi
12{
13
Patrick Venturebb90d4f2019-03-15 13:42:06 -070014using VersionTuple =
15 std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;
16
Patrick Venturef085d912019-03-15 08:50:00 -070017class 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;
Patrick Ventured2037c62019-03-15 10:29:47 -070028
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;
Patrick Venturebb90d4f2019-03-15 13:42:06 -070037
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;
Patrick Ventureaa374122019-03-15 15:09:10 -070046
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;
Patrick Venture07f85152019-03-15 21:36:56 -070054
55 /**
Shounak Mitraac4a16f2021-02-02 11:11:44 -080056 * Arm for PSU reset on host shutdown.
57 *
58 * @throw IpmiException on failure.
59 */
60 virtual void psuResetOnShutdown() const = 0;
61
62 /**
Patrick Venture07f85152019-03-15 21:36:56 -070063 * 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;
Patrick Venture49f23ad2019-03-16 11:59:55 -070075
76 /**
Willy Tu3b1b4272021-03-02 17:58:10 -080077 * 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 /**
William A. Kennington III29f35bc2020-11-03 23:30:31 -080085 * 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 /**
Patrick Venture49f23ad2019-03-16 11:59:55 -070093 * 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;
linyuny8cfa4c42021-06-16 13:53:08 -0700112
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;
Patrick Venturef085d912019-03-15 08:50:00 -0700120};
121
Patrick Venturef085d912019-03-15 08:50:00 -0700122} // namespace ipmi
123} // namespace google