Willy Tu | a2056e9 | 2021-10-10 13:36:16 -0700 | [diff] [blame] | 1 | // Copyright 2021 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 15 | #pragma once |
| 16 | |
| 17 | #include <cstdint> |
Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 18 | #include <ipmid/api-types.hpp> |
Patrick Venture | ab65000 | 2019-03-16 09:08:47 -0700 | [diff] [blame] | 19 | #include <map> |
Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 20 | #include <span> |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 21 | #include <string> |
| 22 | #include <tuple> |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 23 | #include <vector> |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 24 | |
| 25 | namespace google |
| 26 | { |
| 27 | namespace ipmi |
| 28 | { |
| 29 | |
Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 30 | using Resp = ::ipmi::RspType<std::uint8_t, std::vector<uint8_t>>; |
| 31 | |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 32 | using VersionTuple = |
| 33 | std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>; |
| 34 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 35 | class HandlerInterface |
| 36 | { |
| 37 | public: |
| 38 | virtual ~HandlerInterface() = default; |
| 39 | |
| 40 | /** |
| 41 | * Return ethernet details (hard-coded). |
| 42 | * |
| 43 | * @return tuple of ethernet details (channel, if name). |
| 44 | */ |
William A. Kennington III | b69209b | 2021-07-13 13:22:24 -0700 | [diff] [blame] | 45 | virtual std::tuple<std::uint8_t, std::string> |
| 46 | getEthDetails(std::string intf) const = 0; |
Patrick Venture | d2037c6 | 2019-03-15 10:29:47 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Return the value of rx_packets, given a if_name. |
| 50 | * |
| 51 | * @param[in] name, the interface name. |
| 52 | * @return the number of packets received. |
| 53 | * @throw IpmiException on failure. |
| 54 | */ |
| 55 | virtual std::int64_t getRxPackets(const std::string& name) const = 0; |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Return the values from a cpld version file. |
| 59 | * |
| 60 | * @param[in] id - the cpld id number. |
| 61 | * @return the quad of numbers as a tuple (maj,min,pt,subpt) |
| 62 | * @throw IpmiException on failure. |
| 63 | */ |
| 64 | virtual VersionTuple getCpldVersion(unsigned int id) const = 0; |
Patrick Venture | aa37412 | 2019-03-15 15:09:10 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Set the PSU Reset delay. |
| 68 | * |
| 69 | * @param[in] delay - delay in seconds. |
| 70 | * @throw IpmiException on failure. |
| 71 | */ |
| 72 | virtual void psuResetDelay(std::uint32_t delay) const = 0; |
Patrick Venture | 07f8515 | 2019-03-15 21:36:56 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
Shounak Mitra | ac4a16f | 2021-02-02 11:11:44 -0800 | [diff] [blame] | 75 | * Arm for PSU reset on host shutdown. |
| 76 | * |
| 77 | * @throw IpmiException on failure. |
| 78 | */ |
| 79 | virtual void psuResetOnShutdown() const = 0; |
| 80 | |
| 81 | /** |
Patrick Venture | 07f8515 | 2019-03-15 21:36:56 -0700 | [diff] [blame] | 82 | * Return the entity name. |
| 83 | * On the first call to this method it'll build the list of entities. |
| 84 | * @todo Consider moving the list building to construction time (and ignore |
| 85 | * failures). |
| 86 | * |
| 87 | * @param[in] id - the entity id value |
| 88 | * @param[in] instance - the entity instance |
| 89 | * @return the entity's name |
| 90 | * @throw IpmiException on failure. |
| 91 | */ |
| 92 | virtual std::string getEntityName(std::uint8_t id, |
| 93 | std::uint8_t instance) = 0; |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
Willy Tu | 3b1b427 | 2021-03-02 17:58:10 -0800 | [diff] [blame] | 96 | * Return the flash size of bmc chip. |
| 97 | * |
| 98 | * @return the flash size of bmc chip |
| 99 | * @throw IpmiException on failure. |
| 100 | */ |
| 101 | virtual uint32_t getFlashSize() = 0; |
| 102 | |
| 103 | /** |
William A. Kennington III | 29f35bc | 2020-11-03 23:30:31 -0800 | [diff] [blame] | 104 | * Return the name of the machine, parsed from release information. |
| 105 | * |
| 106 | * @return the machine name |
| 107 | * @throw IpmiException on failure. |
| 108 | */ |
| 109 | virtual std::string getMachineName() = 0; |
| 110 | |
| 111 | /** |
Patrick Venture | 49f23ad | 2019-03-16 11:59:55 -0700 | [diff] [blame] | 112 | * Populate the i2c-pcie mapping vector. |
| 113 | */ |
| 114 | virtual void buildI2cPcieMapping() = 0; |
| 115 | |
| 116 | /** |
| 117 | * Return the size of the i2c-pcie mapping vector. |
| 118 | * |
| 119 | * @return the size of the vector holding the i2c-pcie mapping tuples. |
| 120 | */ |
| 121 | virtual size_t getI2cPcieMappingSize() const = 0; |
| 122 | |
| 123 | /** |
| 124 | * Return a copy of the entry in the vector. |
| 125 | * |
| 126 | * @param[in] entry - the index into the vector. |
| 127 | * @return the tuple at that index. |
| 128 | */ |
| 129 | virtual std::tuple<std::uint32_t, std::string> |
| 130 | getI2cEntry(unsigned int entry) const = 0; |
linyuny | 8cfa4c4 | 2021-06-16 13:53:08 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
| 133 | * Set the Host Power Off delay. |
| 134 | * |
| 135 | * @param[in] delay - delay in seconds. |
| 136 | * @throw IpmiException on failure. |
| 137 | */ |
| 138 | virtual void hostPowerOffDelay(std::uint32_t delay) const = 0; |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 139 | }; |
| 140 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 141 | } // namespace ipmi |
| 142 | } // namespace google |