Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
Patrick Venture | ab65000 | 2019-03-16 09:08:47 -0700 | [diff] [blame] | 4 | #include <map> |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 5 | #include <string> |
| 6 | #include <tuple> |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 7 | #include <vector> |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 8 | |
| 9 | namespace google |
| 10 | { |
| 11 | namespace ipmi |
| 12 | { |
| 13 | |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 14 | using VersionTuple = |
| 15 | std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>; |
| 16 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 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; |
Patrick Venture | d2037c6 | 2019-03-15 10:29:47 -0700 | [diff] [blame] | 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; |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 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; |
Patrick Venture | aa37412 | 2019-03-15 15:09:10 -0700 | [diff] [blame] | 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; |
Patrick Venture | 07f8515 | 2019-03-15 21:36:56 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
Shounak Mitra | ac4a16f | 2021-02-02 11:11:44 -0800 | [diff] [blame^] | 56 | * Arm for PSU reset on host shutdown. |
| 57 | * |
| 58 | * @throw IpmiException on failure. |
| 59 | */ |
| 60 | virtual void psuResetOnShutdown() const = 0; |
| 61 | |
| 62 | /** |
Patrick Venture | 07f8515 | 2019-03-15 21:36:56 -0700 | [diff] [blame] | 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; |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
William A. Kennington III | 29f35bc | 2020-11-03 23:30:31 -0800 | [diff] [blame] | 77 | * Return the name of the machine, parsed from release information. |
| 78 | * |
| 79 | * @return the machine name |
| 80 | * @throw IpmiException on failure. |
| 81 | */ |
| 82 | virtual std::string getMachineName() = 0; |
| 83 | |
| 84 | /** |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 85 | * Populate the i2c-pcie mapping vector. |
| 86 | */ |
| 87 | virtual void buildI2cPcieMapping() = 0; |
| 88 | |
| 89 | /** |
| 90 | * Return the size of the i2c-pcie mapping vector. |
| 91 | * |
| 92 | * @return the size of the vector holding the i2c-pcie mapping tuples. |
| 93 | */ |
| 94 | virtual size_t getI2cPcieMappingSize() const = 0; |
| 95 | |
| 96 | /** |
| 97 | * Return a copy of the entry in the vector. |
| 98 | * |
| 99 | * @param[in] entry - the index into the vector. |
| 100 | * @return the tuple at that index. |
| 101 | */ |
| 102 | virtual std::tuple<std::uint32_t, std::string> |
| 103 | getI2cEntry(unsigned int entry) const = 0; |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 106 | } // namespace ipmi |
| 107 | } // namespace google |