blob: 91846333347b1adf6077a6b70e7958b027ac4153 [file] [log] [blame]
Willy Tude54f482021-01-26 15:59:09 -08001/*
2// Copyright (c) 2017 2018 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16
17#pragma once
Willy Tude54f482021-01-26 15:59:09 -080018#include <dbus-sdr/sdrutils.hpp>
19
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -050020#include <cstdint>
21
Willy Tude54f482021-01-26 15:59:09 -080022#pragma pack(push, 1)
23
24struct SensorThresholdResp
25{
26 uint8_t readable;
27 uint8_t lowernc;
28 uint8_t lowercritical;
29 uint8_t lowernonrecoverable;
30 uint8_t uppernc;
31 uint8_t uppercritical;
32 uint8_t uppernonrecoverable;
33};
34
35#pragma pack(pop)
36
37enum class IPMIThresholdRespBits
38{
39 lowerNonCritical,
40 lowerCritical,
41 lowerNonRecoverable,
42 upperNonCritical,
43 upperCritical,
44 upperNonRecoverable
45};
46
47enum class IPMISensorReadingByte2 : uint8_t
48{
49 eventMessagesEnable = (1 << 7),
50 sensorScanningEnable = (1 << 6),
51 readingStateUnavailable = (1 << 5),
52};
53
54enum class IPMISensorReadingByte3 : uint8_t
55{
56 upperNonRecoverable = (1 << 5),
57 upperCritical = (1 << 4),
58 upperNonCritical = (1 << 3),
59 lowerNonRecoverable = (1 << 2),
60 lowerCritical = (1 << 1),
61 lowerNonCritical = (1 << 0),
62};
63
64enum class IPMISensorEventEnableByte2 : uint8_t
65{
66 eventMessagesEnable = (1 << 7),
67 sensorScanningEnable = (1 << 6),
68};
69
70enum class IPMISensorEventEnableThresholds : uint8_t
71{
72 nonRecoverableThreshold = (1 << 6),
73 criticalThreshold = (1 << 5),
74 nonCriticalThreshold = (1 << 4),
75 upperNonRecoverableGoingHigh = (1 << 3),
76 upperNonRecoverableGoingLow = (1 << 2),
77 upperCriticalGoingHigh = (1 << 1),
78 upperCriticalGoingLow = (1 << 0),
79 upperNonCriticalGoingHigh = (1 << 7),
80 upperNonCriticalGoingLow = (1 << 6),
81 lowerNonRecoverableGoingHigh = (1 << 5),
82 lowerNonRecoverableGoingLow = (1 << 4),
83 lowerCriticalGoingHigh = (1 << 3),
84 lowerCriticalGoingLow = (1 << 2),
85 lowerNonCriticalGoingHigh = (1 << 1),
86 lowerNonCriticalGoingLow = (1 << 0),
87};
88
89enum class IPMIGetSensorEventEnableThresholds : uint8_t
90{
91 lowerNonCriticalGoingLow = 0,
92 lowerNonCriticalGoingHigh = 1,
93 lowerCriticalGoingLow = 2,
94 lowerCriticalGoingHigh = 3,
95 lowerNonRecoverableGoingLow = 4,
96 lowerNonRecoverableGoingHigh = 5,
97 upperNonCriticalGoingLow = 6,
98 upperNonCriticalGoingHigh = 7,
99 upperCriticalGoingLow = 8,
100 upperCriticalGoingHigh = 9,
101 upperNonRecoverableGoingLow = 10,
102 upperNonRecoverableGoingHigh = 11,
103};
104
Willy Tude54f482021-01-26 15:59:09 -0800105namespace ipmi
106{
107
Johnathan Mantey777cfaf2024-06-13 10:45:47 -0700108uint16_t getNumberOfSensors();
Willy Tude54f482021-01-26 15:59:09 -0800109
Johnathan Mantey777cfaf2024-06-13 10:45:47 -0700110SensorSubTree& getSensorTree();
Willy Tude54f482021-01-26 15:59:09 -0800111
Johnathan Mantey777cfaf2024-06-13 10:45:47 -0700112ipmi_ret_t getSensorConnection(ipmi::Context::ptr ctx, uint8_t sensnum,
113 std::string& connection, std::string& path,
114 std::vector<std::string>* interfaces = nullptr);
Willy Tude54f482021-01-26 15:59:09 -0800115
116struct IPMIThresholds
117{
118 std::optional<uint8_t> warningLow;
119 std::optional<uint8_t> warningHigh;
120 std::optional<uint8_t> criticalLow;
121 std::optional<uint8_t> criticalHigh;
122};
123
Johnathan Mantey777cfaf2024-06-13 10:45:47 -0700124namespace sensor
125{
126/**
127 * @brief Retrieve the number of sensors that are not included in the list of
128 * sensors published via D-Bus
129 *
130 * @param[in]: ctx: the pointer to the D-Bus context
131 * @return: The number of additional sensors separate from those published
132 * dynamically on D-Bus
133 */
134size_t getOtherSensorsCount(ipmi::Context::ptr ctx);
135
136/**
137 * @brief Retrieve the record data for the sensors not published via D-Bus
138 *
139 * @param[in]: ctx: the pointer to the D-Bus context
140 * @param[in]: recordID: the integer index for the sensor to retrieve
141 * @param[out]: SDR data for the indexed sensor
142 * @return: 0: success
143 * negative number: error condition
144 */
145int getOtherSensorsDataRecord(ipmi::Context::ptr ctx, uint16_t recordID,
146 std::vector<uint8_t>& recordData);
147} // namespace sensor
148
Thang Tranb1416ef2023-08-02 13:57:09 +0700149namespace dcmi
150{
151
152struct sensorInfo
153{
154 std::string objectPath;
155 uint8_t type;
156 uint16_t recordId;
157 uint8_t entityId;
158 uint8_t entityInstance;
159};
160
161} // namespace dcmi
162
Willy Tude54f482021-01-26 15:59:09 -0800163} // namespace ipmi