blob: 5e78c6430bdaab104f14b750f29b0ed6d253762a [file] [log] [blame]
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001/*
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
18#include <cstdint>
19
20#pragma pack(push, 1)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070021
22struct SensorThresholdResp
23{
24 uint8_t readable;
25 uint8_t lowernc;
26 uint8_t lowercritical;
27 uint8_t lowernonrecoverable;
28 uint8_t uppernc;
29 uint8_t uppercritical;
30 uint8_t uppernonrecoverable;
31};
32
33struct SensorThresholdReq
34{
35 uint8_t sensorNum;
36 uint8_t mask;
37 uint8_t lowerNonCritical;
38 uint8_t lowerCritical;
39 uint8_t lowerNonRecoverable;
40 uint8_t upperNonCritical;
41 uint8_t upperCritical;
42 uint8_t upperNonRecoverable;
43};
44#pragma pack(pop)
45
46enum class SensorThresholdReqEnable : uint8_t
47{
48 setLowerNonCritical = 0x1,
49 setLowerCritical = 0x2,
50 setLowerNonRecoverable = 0x4,
51 setUpperNonCritical = 0x8,
52 setUpperCritical = 0x10,
53 setUpperNonRecoverable = 0x20
54};
55
56#pragma pack(push, 1)
57struct SensorEventEnableResp
58{
59 uint8_t enabled;
60 uint8_t assertionEnabledLSB;
61 uint8_t assertionEnabledMSB;
62 uint8_t deassertionEnabledLSB;
63 uint8_t deassertionEnabledMSB;
64};
65
66struct SensorEventStatusResp
67{
68 uint8_t enabled;
69 uint8_t assertionsLSB;
70 uint8_t assertionsMSB;
James Feist392786a2019-03-19 13:36:10 -070071 uint8_t deassertionsLSB;
72 uint8_t deassertionsMSB;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070073};
74#pragma pack(pop)
75
James Feist902c4c52019-04-16 14:51:31 -070076enum class IPMIThresholdRespBits
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070077{
78 lowerNonCritical,
79 lowerCritical,
80 lowerNonRecoverable,
81 upperNonCritical,
82 upperCritical,
83 upperNonRecoverable
84};
85
86enum class IPMISensorReadingByte2 : uint8_t
87{
88 eventMessagesEnable = (1 << 7),
89 sensorScanningEnable = (1 << 6),
90 readingStateUnavailable = (1 << 5),
91};
92
James Feist0cd014a2019-04-08 15:04:33 -070093enum class IPMISensorReadingByte3 : uint8_t
94{
95 upperNonRecoverable = (1 << 5),
96 upperCritical = (1 << 4),
97 upperNonCritical = (1 << 3),
98 lowerNonRecoverable = (1 << 2),
99 lowerCritical = (1 << 1),
100 lowerNonCritical = (1 << 0),
101};
102
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700103enum class IPMISensorEventEnableByte2 : uint8_t
104{
105 eventMessagesEnable = (1 << 7),
106 sensorScanningEnable = (1 << 6),
107};
108
109enum class IPMISensorEventEnableThresholds : uint8_t
110{
111 upperNonRecoverableGoingHigh = (1 << 3),
112 upperNonRecoverableGoingLow = (1 << 2),
113 upperCriticalGoingHigh = (1 << 1),
114 upperCriticalGoingLow = (1 << 0),
115 upperNonCriticalGoingHigh = (1 << 7),
116 upperNonCriticalGoingLow = (1 << 6),
117 lowerNonRecoverableGoingHigh = (1 << 5),
118 lowerNonRecoverableGoingLow = (1 << 4),
119 lowerCriticalGoingHigh = (1 << 3),
120 lowerCriticalGoingLow = (1 << 2),
121 lowerNonCriticalGoingHigh = (1 << 1),
122 lowerNonCriticalGoingLow = (1 << 0),
123};
124
125enum class IPMINetfnSensorCmds : ipmi_cmd_t
126{
127 ipmiCmdGetDeviceSDRInfo = 0x20,
128 ipmiCmdGetDeviceSDR = 0x21,
129 ipmiCmdReserveDeviceSDRRepo = 0x22,
James Feistfcce83d2019-03-01 15:46:19 -0800130 ipmiCmdSetSensorThreshold = 0x26,
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700131 ipmiCmdGetSensorThreshold = 0x27,
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700132 ipmiCmdGetSensorEventEnable = 0x29,
133 ipmiCmdGetSensorEventStatus = 0x2B,
134 ipmiCmdGetSensorReading = 0x2D,
135 ipmiCmdGetSensorType = 0x2F,
136 ipmiCmdSetSensorReadingAndEventStatus = 0x30,
137};
Richard Marian Thomaiyar01fbcb52018-11-19 22:04:34 +0530138
Richard Marian Thomaiyar4c88d4c2018-12-05 20:52:43 +0530139namespace ipmi
140{
Richard Marian Thomaiyar01fbcb52018-11-19 22:04:34 +0530141extern SensorSubTree sensorTree;
142static ipmi_ret_t getSensorConnection(uint8_t sensnum, std::string &connection,
143 std::string &path)
144{
145 if (sensorTree.empty() && !getSensorSubtree(sensorTree))
146 {
147 return IPMI_CC_RESPONSE_ERROR;
148 }
149
150 if (sensorTree.size() < (sensnum + 1))
151 {
152 return IPMI_CC_INVALID_FIELD_REQUEST;
153 }
154
155 uint8_t sensorIndex = sensnum;
156 for (const auto &sensor : sensorTree)
157 {
158 if (sensorIndex-- == 0)
159 {
160 if (!sensor.second.size())
161 {
162 return IPMI_CC_RESPONSE_ERROR;
163 }
164 connection = sensor.second.begin()->first;
165 path = sensor.first;
166 break;
167 }
168 }
169
170 return 0;
171}
James Feist902c4c52019-04-16 14:51:31 -0700172
173struct IPMIThresholds
174{
175 std::optional<uint8_t> warningLow;
176 std::optional<uint8_t> warningHigh;
177 std::optional<uint8_t> criticalLow;
178 std::optional<uint8_t> criticalHigh;
179};
180
Richard Marian Thomaiyar4c88d4c2018-12-05 20:52:43 +0530181} // namespace ipmi