blob: e5bed10fdb119da452a188e7fe2fa77626679ae4 [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)
21struct SensorReadingResp
22{
23 uint8_t value;
24 uint8_t operation;
25 uint8_t indication[2];
26};
27
28struct SensorThresholdResp
29{
30 uint8_t readable;
31 uint8_t lowernc;
32 uint8_t lowercritical;
33 uint8_t lowernonrecoverable;
34 uint8_t uppernc;
35 uint8_t uppercritical;
36 uint8_t uppernonrecoverable;
37};
38
39struct SensorThresholdReq
40{
41 uint8_t sensorNum;
42 uint8_t mask;
43 uint8_t lowerNonCritical;
44 uint8_t lowerCritical;
45 uint8_t lowerNonRecoverable;
46 uint8_t upperNonCritical;
47 uint8_t upperCritical;
48 uint8_t upperNonRecoverable;
49};
50#pragma pack(pop)
51
52enum class SensorThresholdReqEnable : uint8_t
53{
54 setLowerNonCritical = 0x1,
55 setLowerCritical = 0x2,
56 setLowerNonRecoverable = 0x4,
57 setUpperNonCritical = 0x8,
58 setUpperCritical = 0x10,
59 setUpperNonRecoverable = 0x20
60};
61
62#pragma pack(push, 1)
63struct SensorEventEnableResp
64{
65 uint8_t enabled;
66 uint8_t assertionEnabledLSB;
67 uint8_t assertionEnabledMSB;
68 uint8_t deassertionEnabledLSB;
69 uint8_t deassertionEnabledMSB;
70};
71
72struct SensorEventStatusResp
73{
74 uint8_t enabled;
75 uint8_t assertionsLSB;
76 uint8_t assertionsMSB;
James Feist392786a2019-03-19 13:36:10 -070077 uint8_t deassertionsLSB;
78 uint8_t deassertionsMSB;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070079};
80#pragma pack(pop)
81
82enum class IPMIhresholdRespBits
83{
84 lowerNonCritical,
85 lowerCritical,
86 lowerNonRecoverable,
87 upperNonCritical,
88 upperCritical,
89 upperNonRecoverable
90};
91
92enum class IPMISensorReadingByte2 : uint8_t
93{
94 eventMessagesEnable = (1 << 7),
95 sensorScanningEnable = (1 << 6),
96 readingStateUnavailable = (1 << 5),
97};
98
99enum class IPMISensorEventEnableByte2 : uint8_t
100{
101 eventMessagesEnable = (1 << 7),
102 sensorScanningEnable = (1 << 6),
103};
104
105enum class IPMISensorEventEnableThresholds : uint8_t
106{
107 upperNonRecoverableGoingHigh = (1 << 3),
108 upperNonRecoverableGoingLow = (1 << 2),
109 upperCriticalGoingHigh = (1 << 1),
110 upperCriticalGoingLow = (1 << 0),
111 upperNonCriticalGoingHigh = (1 << 7),
112 upperNonCriticalGoingLow = (1 << 6),
113 lowerNonRecoverableGoingHigh = (1 << 5),
114 lowerNonRecoverableGoingLow = (1 << 4),
115 lowerCriticalGoingHigh = (1 << 3),
116 lowerCriticalGoingLow = (1 << 2),
117 lowerNonCriticalGoingHigh = (1 << 1),
118 lowerNonCriticalGoingLow = (1 << 0),
119};
120
121enum class IPMINetfnSensorCmds : ipmi_cmd_t
122{
123 ipmiCmdGetDeviceSDRInfo = 0x20,
124 ipmiCmdGetDeviceSDR = 0x21,
125 ipmiCmdReserveDeviceSDRRepo = 0x22,
James Feistfcce83d2019-03-01 15:46:19 -0800126 ipmiCmdSetSensorThreshold = 0x26,
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700127 ipmiCmdGetSensorThreshold = 0x27,
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700128 ipmiCmdGetSensorEventEnable = 0x29,
129 ipmiCmdGetSensorEventStatus = 0x2B,
130 ipmiCmdGetSensorReading = 0x2D,
131 ipmiCmdGetSensorType = 0x2F,
132 ipmiCmdSetSensorReadingAndEventStatus = 0x30,
133};
Richard Marian Thomaiyar01fbcb52018-11-19 22:04:34 +0530134
Richard Marian Thomaiyar4c88d4c2018-12-05 20:52:43 +0530135namespace ipmi
136{
Richard Marian Thomaiyar01fbcb52018-11-19 22:04:34 +0530137extern SensorSubTree sensorTree;
138static ipmi_ret_t getSensorConnection(uint8_t sensnum, std::string &connection,
139 std::string &path)
140{
141 if (sensorTree.empty() && !getSensorSubtree(sensorTree))
142 {
143 return IPMI_CC_RESPONSE_ERROR;
144 }
145
146 if (sensorTree.size() < (sensnum + 1))
147 {
148 return IPMI_CC_INVALID_FIELD_REQUEST;
149 }
150
151 uint8_t sensorIndex = sensnum;
152 for (const auto &sensor : sensorTree)
153 {
154 if (sensorIndex-- == 0)
155 {
156 if (!sensor.second.size())
157 {
158 return IPMI_CC_RESPONSE_ERROR;
159 }
160 connection = sensor.second.begin()->first;
161 path = sensor.first;
162 break;
163 }
164 }
165
166 return 0;
167}
Richard Marian Thomaiyar4c88d4c2018-12-05 20:52:43 +0530168} // namespace ipmi