blob: fdb2585fb01b1266b77752c12373fab16e93da1c [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 */
William A. Kennington IIIb69209b2021-07-13 13:22:24 -070027 virtual std::tuple<std::uint8_t, std::string>
28 getEthDetails(std::string intf) const = 0;
Patrick Ventured2037c62019-03-15 10:29:47 -070029
30 /**
31 * Return the value of rx_packets, given a if_name.
32 *
33 * @param[in] name, the interface name.
34 * @return the number of packets received.
35 * @throw IpmiException on failure.
36 */
37 virtual std::int64_t getRxPackets(const std::string& name) const = 0;
Patrick Venturebb90d4f2019-03-15 13:42:06 -070038
39 /**
40 * Return the values from a cpld version file.
41 *
42 * @param[in] id - the cpld id number.
43 * @return the quad of numbers as a tuple (maj,min,pt,subpt)
44 * @throw IpmiException on failure.
45 */
46 virtual VersionTuple getCpldVersion(unsigned int id) const = 0;
Patrick Ventureaa374122019-03-15 15:09:10 -070047
48 /**
49 * Set the PSU Reset delay.
50 *
51 * @param[in] delay - delay in seconds.
52 * @throw IpmiException on failure.
53 */
54 virtual void psuResetDelay(std::uint32_t delay) const = 0;
Patrick Venture07f85152019-03-15 21:36:56 -070055
56 /**
Shounak Mitraac4a16f2021-02-02 11:11:44 -080057 * Arm for PSU reset on host shutdown.
58 *
59 * @throw IpmiException on failure.
60 */
61 virtual void psuResetOnShutdown() const = 0;
62
63 /**
Patrick Venture07f85152019-03-15 21:36:56 -070064 * Return the entity name.
65 * On the first call to this method it'll build the list of entities.
66 * @todo Consider moving the list building to construction time (and ignore
67 * failures).
68 *
69 * @param[in] id - the entity id value
70 * @param[in] instance - the entity instance
71 * @return the entity's name
72 * @throw IpmiException on failure.
73 */
74 virtual std::string getEntityName(std::uint8_t id,
75 std::uint8_t instance) = 0;
Patrick Venture49f23ad2019-03-16 11:59:55 -070076
77 /**
Willy Tu3b1b4272021-03-02 17:58:10 -080078 * Return the flash size of bmc chip.
79 *
80 * @return the flash size of bmc chip
81 * @throw IpmiException on failure.
82 */
83 virtual uint32_t getFlashSize() = 0;
84
85 /**
William A. Kennington III29f35bc2020-11-03 23:30:31 -080086 * Return the name of the machine, parsed from release information.
87 *
88 * @return the machine name
89 * @throw IpmiException on failure.
90 */
91 virtual std::string getMachineName() = 0;
92
93 /**
Patrick Venture49f23ad2019-03-16 11:59:55 -070094 * Populate the i2c-pcie mapping vector.
95 */
96 virtual void buildI2cPcieMapping() = 0;
97
98 /**
99 * Return the size of the i2c-pcie mapping vector.
100 *
101 * @return the size of the vector holding the i2c-pcie mapping tuples.
102 */
103 virtual size_t getI2cPcieMappingSize() const = 0;
104
105 /**
106 * Return a copy of the entry in the vector.
107 *
108 * @param[in] entry - the index into the vector.
109 * @return the tuple at that index.
110 */
111 virtual std::tuple<std::uint32_t, std::string>
112 getI2cEntry(unsigned int entry) const = 0;
linyuny8cfa4c42021-06-16 13:53:08 -0700113
114 /**
115 * Set the Host Power Off delay.
116 *
117 * @param[in] delay - delay in seconds.
118 * @throw IpmiException on failure.
119 */
120 virtual void hostPowerOffDelay(std::uint32_t delay) const = 0;
Patrick Venturef085d912019-03-15 08:50:00 -0700121};
122
Patrick Venturef085d912019-03-15 08:50:00 -0700123} // namespace ipmi
124} // namespace google