blob: e0d73d7dba19fb1f9f99281b1e5fe08d93fc001a [file] [log] [blame]
Willy Tua2056e92021-10-10 13:36:16 -07001// 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 Venturef085d912019-03-15 08:50:00 -070015#pragma once
16
17#include <cstdint>
Patrick Ventureab650002019-03-16 09:08:47 -070018#include <map>
Patrick Venturef085d912019-03-15 08:50:00 -070019#include <string>
20#include <tuple>
Patrick Venture49f23ad2019-03-16 11:59:55 -070021#include <vector>
Patrick Venturef085d912019-03-15 08:50:00 -070022
23namespace google
24{
25namespace ipmi
26{
27
Patrick Venturebb90d4f2019-03-15 13:42:06 -070028using VersionTuple =
29 std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;
30
Patrick Venturef085d912019-03-15 08:50:00 -070031class HandlerInterface
32{
33 public:
34 virtual ~HandlerInterface() = default;
35
36 /**
37 * Return ethernet details (hard-coded).
38 *
39 * @return tuple of ethernet details (channel, if name).
40 */
William A. Kennington IIIb69209b2021-07-13 13:22:24 -070041 virtual std::tuple<std::uint8_t, std::string>
42 getEthDetails(std::string intf) const = 0;
Patrick Ventured2037c62019-03-15 10:29:47 -070043
44 /**
45 * Return the value of rx_packets, given a if_name.
46 *
47 * @param[in] name, the interface name.
48 * @return the number of packets received.
49 * @throw IpmiException on failure.
50 */
51 virtual std::int64_t getRxPackets(const std::string& name) const = 0;
Patrick Venturebb90d4f2019-03-15 13:42:06 -070052
53 /**
54 * Return the values from a cpld version file.
55 *
56 * @param[in] id - the cpld id number.
57 * @return the quad of numbers as a tuple (maj,min,pt,subpt)
58 * @throw IpmiException on failure.
59 */
60 virtual VersionTuple getCpldVersion(unsigned int id) const = 0;
Patrick Ventureaa374122019-03-15 15:09:10 -070061
62 /**
63 * Set the PSU Reset delay.
64 *
65 * @param[in] delay - delay in seconds.
66 * @throw IpmiException on failure.
67 */
68 virtual void psuResetDelay(std::uint32_t delay) const = 0;
Patrick Venture07f85152019-03-15 21:36:56 -070069
70 /**
Shounak Mitraac4a16f2021-02-02 11:11:44 -080071 * Arm for PSU reset on host shutdown.
72 *
73 * @throw IpmiException on failure.
74 */
75 virtual void psuResetOnShutdown() const = 0;
76
77 /**
Patrick Venture07f85152019-03-15 21:36:56 -070078 * Return the entity name.
79 * On the first call to this method it'll build the list of entities.
80 * @todo Consider moving the list building to construction time (and ignore
81 * failures).
82 *
83 * @param[in] id - the entity id value
84 * @param[in] instance - the entity instance
85 * @return the entity's name
86 * @throw IpmiException on failure.
87 */
88 virtual std::string getEntityName(std::uint8_t id,
89 std::uint8_t instance) = 0;
Patrick Venture49f23ad2019-03-16 11:59:55 -070090
91 /**
Willy Tu3b1b4272021-03-02 17:58:10 -080092 * Return the flash size of bmc chip.
93 *
94 * @return the flash size of bmc chip
95 * @throw IpmiException on failure.
96 */
97 virtual uint32_t getFlashSize() = 0;
98
99 /**
William A. Kennington III29f35bc2020-11-03 23:30:31 -0800100 * Return the name of the machine, parsed from release information.
101 *
102 * @return the machine name
103 * @throw IpmiException on failure.
104 */
105 virtual std::string getMachineName() = 0;
106
107 /**
Patrick Venture49f23ad2019-03-16 11:59:55 -0700108 * Populate the i2c-pcie mapping vector.
109 */
110 virtual void buildI2cPcieMapping() = 0;
111
112 /**
113 * Return the size of the i2c-pcie mapping vector.
114 *
115 * @return the size of the vector holding the i2c-pcie mapping tuples.
116 */
117 virtual size_t getI2cPcieMappingSize() const = 0;
118
119 /**
120 * Return a copy of the entry in the vector.
121 *
122 * @param[in] entry - the index into the vector.
123 * @return the tuple at that index.
124 */
125 virtual std::tuple<std::uint32_t, std::string>
126 getI2cEntry(unsigned int entry) const = 0;
linyuny8cfa4c42021-06-16 13:53:08 -0700127
128 /**
129 * Set the Host Power Off delay.
130 *
131 * @param[in] delay - delay in seconds.
132 * @throw IpmiException on failure.
133 */
134 virtual void hostPowerOffDelay(std::uint32_t delay) const = 0;
Patrick Venturef085d912019-03-15 08:50:00 -0700135};
136
Patrick Venturef085d912019-03-15 08:50:00 -0700137} // namespace ipmi
138} // namespace google