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> |
| 5 | #include <nlohmann/json.hpp> |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 6 | #include <string> |
| 7 | #include <tuple> |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 8 | #include <vector> |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 9 | |
| 10 | namespace google |
| 11 | { |
| 12 | namespace ipmi |
| 13 | { |
| 14 | |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 15 | using VersionTuple = |
| 16 | std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>; |
| 17 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 18 | class HandlerInterface |
| 19 | { |
| 20 | public: |
| 21 | virtual ~HandlerInterface() = default; |
| 22 | |
| 23 | /** |
| 24 | * Return ethernet details (hard-coded). |
| 25 | * |
| 26 | * @return tuple of ethernet details (channel, if name). |
| 27 | */ |
| 28 | virtual std::tuple<std::uint8_t, std::string> getEthDetails() const = 0; |
Patrick Venture | d2037c6 | 2019-03-15 10:29:47 -0700 | [diff] [blame] | 29 | |
| 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 Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 38 | |
| 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 Venture | aa37412 | 2019-03-15 15:09:10 -0700 | [diff] [blame] | 47 | |
| 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 Venture | 07f8515 | 2019-03-15 21:36:56 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Return the entity name. |
| 58 | * On the first call to this method it'll build the list of entities. |
| 59 | * @todo Consider moving the list building to construction time (and ignore |
| 60 | * failures). |
| 61 | * |
| 62 | * @param[in] id - the entity id value |
| 63 | * @param[in] instance - the entity instance |
| 64 | * @return the entity's name |
| 65 | * @throw IpmiException on failure. |
| 66 | */ |
| 67 | virtual std::string getEntityName(std::uint8_t id, |
| 68 | std::uint8_t instance) = 0; |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * Populate the i2c-pcie mapping vector. |
| 72 | */ |
| 73 | virtual void buildI2cPcieMapping() = 0; |
| 74 | |
| 75 | /** |
| 76 | * Return the size of the i2c-pcie mapping vector. |
| 77 | * |
| 78 | * @return the size of the vector holding the i2c-pcie mapping tuples. |
| 79 | */ |
| 80 | virtual size_t getI2cPcieMappingSize() const = 0; |
| 81 | |
| 82 | /** |
| 83 | * Return a copy of the entry in the vector. |
| 84 | * |
| 85 | * @param[in] entry - the index into the vector. |
| 86 | * @return the tuple at that index. |
| 87 | */ |
| 88 | virtual std::tuple<std::uint32_t, std::string> |
| 89 | getI2cEntry(unsigned int entry) const = 0; |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
Patrick Venture | ab65000 | 2019-03-16 09:08:47 -0700 | [diff] [blame] | 92 | /** |
| 93 | * Given a type, entity instance, and a configuration, return the name. |
| 94 | * |
| 95 | * @param[in] type - the entity type |
| 96 | * @param[in] instance - the entity instance |
| 97 | * @param[in] config - the json object holding the entity mapping |
| 98 | * @return the name of the entity from the map |
| 99 | */ |
| 100 | std::string readNameFromConfig(const std::string& type, uint8_t instance, |
| 101 | const nlohmann::json& config); |
| 102 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 103 | } // namespace ipmi |
| 104 | } // namespace google |