blob: 766ddde0e27b9beadd4f72072e976947e6cc211f [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 /**
56 * Return the entity name.
57 * On the first call to this method it'll build the list of entities.
58 * @todo Consider moving the list building to construction time (and ignore
59 * failures).
60 *
61 * @param[in] id - the entity id value
62 * @param[in] instance - the entity instance
63 * @return the entity's name
64 * @throw IpmiException on failure.
65 */
66 virtual std::string getEntityName(std::uint8_t id,
67 std::uint8_t instance) = 0;
Patrick Venture49f23ad2019-03-16 11:59:55 -070068
69 /**
William A. Kennington III29f35bc2020-11-03 23:30:31 -080070 * Return the name of the machine, parsed from release information.
71 *
72 * @return the machine name
73 * @throw IpmiException on failure.
74 */
75 virtual std::string getMachineName() = 0;
76
77 /**
Patrick Venture49f23ad2019-03-16 11:59:55 -070078 * Populate the i2c-pcie mapping vector.
79 */
80 virtual void buildI2cPcieMapping() = 0;
81
82 /**
83 * Return the size of the i2c-pcie mapping vector.
84 *
85 * @return the size of the vector holding the i2c-pcie mapping tuples.
86 */
87 virtual size_t getI2cPcieMappingSize() const = 0;
88
89 /**
90 * Return a copy of the entry in the vector.
91 *
92 * @param[in] entry - the index into the vector.
93 * @return the tuple at that index.
94 */
95 virtual std::tuple<std::uint32_t, std::string>
96 getI2cEntry(unsigned int entry) const = 0;
Patrick Venturef085d912019-03-15 08:50:00 -070097};
98
Patrick Venturef085d912019-03-15 08:50:00 -070099} // namespace ipmi
100} // namespace google