1 /*
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)
21 struct SensorReadingResp
22 {
23     uint8_t value;
24     uint8_t operation;
25     uint8_t indication[2];
26 };
27 
28 struct 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 
39 struct 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 
52 enum 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)
63 struct SensorEventEnableResp
64 {
65     uint8_t enabled;
66     uint8_t assertionEnabledLSB;
67     uint8_t assertionEnabledMSB;
68     uint8_t deassertionEnabledLSB;
69     uint8_t deassertionEnabledMSB;
70 };
71 
72 struct SensorEventStatusResp
73 {
74     uint8_t enabled;
75     uint8_t assertionsLSB;
76     uint8_t assertionsMSB;
77     // deassertion events currently not supported
78     // uint8_t deassertionsLSB;
79     // uint8_t deassertionsMSB;
80 };
81 #pragma pack(pop)
82 
83 enum class IPMIhresholdRespBits
84 {
85     lowerNonCritical,
86     lowerCritical,
87     lowerNonRecoverable,
88     upperNonCritical,
89     upperCritical,
90     upperNonRecoverable
91 };
92 
93 enum class IPMISensorReadingByte2 : uint8_t
94 {
95     eventMessagesEnable = (1 << 7),
96     sensorScanningEnable = (1 << 6),
97     readingStateUnavailable = (1 << 5),
98 };
99 
100 enum class IPMISensorEventEnableByte2 : uint8_t
101 {
102     eventMessagesEnable = (1 << 7),
103     sensorScanningEnable = (1 << 6),
104 };
105 
106 enum class IPMISensorEventEnableThresholds : uint8_t
107 {
108     upperNonRecoverableGoingHigh = (1 << 3),
109     upperNonRecoverableGoingLow = (1 << 2),
110     upperCriticalGoingHigh = (1 << 1),
111     upperCriticalGoingLow = (1 << 0),
112     upperNonCriticalGoingHigh = (1 << 7),
113     upperNonCriticalGoingLow = (1 << 6),
114     lowerNonRecoverableGoingHigh = (1 << 5),
115     lowerNonRecoverableGoingLow = (1 << 4),
116     lowerCriticalGoingHigh = (1 << 3),
117     lowerCriticalGoingLow = (1 << 2),
118     lowerNonCriticalGoingHigh = (1 << 1),
119     lowerNonCriticalGoingLow = (1 << 0),
120 };
121 
122 enum class IPMINetfnSensorCmds : ipmi_cmd_t
123 {
124     ipmiCmdGetDeviceSDRInfo = 0x20,
125     ipmiCmdGetDeviceSDR = 0x21,
126     ipmiCmdReserveDeviceSDRRepo = 0x22,
127     ipmiCmdGetSensorThreshold = 0x27,
128     ipmiCmdSetSensorThreshold = 0x28,
129     ipmiCmdGetSensorEventEnable = 0x29,
130     ipmiCmdGetSensorEventStatus = 0x2B,
131     ipmiCmdGetSensorReading = 0x2D,
132     ipmiCmdGetSensorType = 0x2F,
133     ipmiCmdSetSensorReadingAndEventStatus = 0x30,
134 };
135