1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/ipmi/ipmiconfiglookup.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef __IPMI_IPMICONFIG_LOOKUP_H
#define __IPMI_IPMICONFIG_LOOKUP_H
#include <errl/errlentry.H>
#include <targeting/common/target.H>
namespace IPMI
{
/**
* @brief - Classs to read IPMI sensor information from the targetting
* namespace. This class does not send IPMI messages but rather
* looks up static configuration data.
*
*/
class IpmiConfigLookup
{
public:
/**
* @brief getSensorType. Returns the sensor type of a sensor identified
* by a sensor number.
*
* @param[in] i_sensorNumber. The IPMI sensor whose information we wish
* to gather.
*
* @param[out] o_sensorType. The sensor type as read from the
* IPMI_SENSOR_ARRAY.
*
* @param[in] i_sensorTarget. A Target to use for looking up sensor
* information. If this parameter is equal to nullptr
* then all targets will be searched for the sensor that
* matches the supplied sensor number.
*
* @return An errlHndl_t (aka ErrlEntry*) if an error occurred. If
* the call was successful, the method returns a NULL
* pointer.
*
*/
static errlHndl_t getSensorType(uint32_t i_sensorNumber,
uint8_t & o_sensorType,
TARGETING::Target * i_sensorTarget = nullptr
);
/**
* @brief getEntityId. Returns a sensor entity id of a sensor identified
* by a sensor number.
*
* @param[in] i_sensorNumber. The IPMI sensor whose information we wish
* to gather.
*
* @param[out] o_entityId. The sensor entity id as read from the
* IPMI_SENSOR_ARRAY.
*
* @param[in] i_sensorTarget. A Target to use for looking up sensor
* information. If this parameter is equal to nullptr
* then all targets will be searched for the sensor that
* matches the supplied sensor number.
*
* @return An errlHndl_t (aka ErrlEntry*) if an error occurred. If
* the call was successful, the method returns a NULL
* pointer.
*
*/
static errlHndl_t getEntityId(uint32_t i_sensorNumber,
uint8_t & o_entityId,
TARGETING::Target * i_sensorTarget = nullptr
);
/**
* @brief getSensorName. Returns the sensor name of a sensor identified by
* by a sensor number.
*
* @param[in] i_sensorNumber. The IPMI sensor whose information we wish
* to gather.
*
* @param[out] o_sensorName. Optional parameter to the sensor name.
* The sensor name by definition will be
* (SENSOR_TYPE << 16) | (ENTITY_ID).
* Pass nullptr if the caller is not interested in obtaining
* this value. At least one of o_sensorType, o_entityId or
* o_sensorName must be non-null
*
* @param[in] i_sensorTarget. A Target to use for looking up sensor
* information. If this parameter is equal to nullptr
* then all targets will be searched for the sensor that
* matches the supplied sensor number.
*
* @return An errlHndl_t (aka ErrlEntry*) if an error occurred. If
* the call was successful, the method returns a NULL
* pointer.
*
*/
static errlHndl_t getSensorName(uint32_t i_sensorNumber,
TARGETING::SENSOR_NAME & o_sensorName,
TARGETING::Target * i_sensorTarget = nullptr
);
/**
* @brief getSensorType. Parses a SENSOR_NAME for the sensor type
*
* @param[in] i_sensorName. SENSOR_NAME (SENSOR_TYPE | ENTITY_ID)
*
* @param[out] o_sensorType. The sensor type parsed from the SENSOR_NAME
*
*/
inline static void getSensorType(TARGETING::SENSOR_NAME i_sensorName,
uint8_t & o_sensorType
)
{
o_sensorType = static_cast<uint8_t>(i_sensorName >> 8 & 0x000000FF);
}
/**
* @brief getEntityId. Parses a SENSOR_NAME for the entity id.
*
* @param[in] i_sensorName. SENSOR_NAME (SENSOR_TYPE | ENTITY_ID)
*
* @param[out] o_sensorType. The sensor type parsed from the SENSOR_NAME
*/
inline static void getEntityId(TARGETING::SENSOR_NAME i_sensorName,
uint8_t & o_entityId
)
{
o_entityId = static_cast<uint8_t>(i_sensorName & 0x000000FF);
}
private:
/**
* @brief Returns parsed IPMI_SENSOR_ARRAY attribute information based upon
* a given sensor number.
*
* @param[in] i_sensorNumber. The IPMI sensor whose information we wish
* to gather.
*
* @param[out] o_sensorType. Optional parameter to the sensor type as read
* from the IPMI_SENSOR_ARRAY. Pass nullptr if the caller is not
* interested in obtaining this value. At least one of
* o_sensorType, o_entityId or o_sensorName must be non-null.
*
* @param[out] o_entityId. Optional parameter to the entity id associated with
* the sensor as read from the IPMI_SENSOR_ARRAY. Pass nullptr if
* the caller is not interested in obtaining this value. At least
* one of o_sensorType, o_entityId or o_sensorName must be
* non-null.
*
* @param[out] o_sensorName. Optional parameter to the sensor name. The sensor
* name by definition will be (SENSOR_TYPE << 16) | (ENTITY_ID).
* Pass nullptr if the caller is not interested in obtaining this
* value. At least one of o_sensorType, o_entityId or o_sensorName
* must be non-null.
*
* @param[in] i_sensorTarget. A Target to use for looking up sensor information.
* If this parameter is equal to nullptr all targets will be searched
* for the sensor that matches the supplied sensor number.
*
* @return True if the sensor was found in the IPMI_SENSOR_ARRAY attribute,
* false otherwise.
*/
static bool getIPMISensorInfo(uint32_t i_sensorNumber,
uint8_t * o_sensorType,
uint8_t * o_entityId = nullptr,
TARGETING::SENSOR_NAME * o_sensorName = nullptr,
TARGETING::Target * i_sensorTarget = nullptr
);
/**
* @brief Determines whether the passed in target has the IPMI_SENSOR
* attribute.
*
* @param[in] i_tgt. The target to test.
*
* @reurn True if the target has the IPMI_SENSOR attribute, false otherwise.
*
*/
inline static bool doesTargetHaveIpmiSensorAttr(TARGETING::Target * i_tgt)
{
if(!i_tgt)
{
return false;
}
TARGETING::AttributeTraits<TARGETING::ATTR_IPMI_SENSORS>::Type
l_ipmiArray;
return i_tgt->tryGetAttr<TARGETING::ATTR_IPMI_SENSORS>(l_ipmiArray);
}
/**
* @brief Determines whether the passed in target has the GPU_SENSORS
* attribute.
*
* @param[in] i_tgt. The target to test.
*
* @reurn True if the target has the GPU_SENSORS attribute, false otherwise.
*
*/
inline static bool doesTargetHaveGPUSensorsAttr(TARGETING::Target * i_tgt)
{
if(!i_tgt)
{
return false;
}
TARGETING::AttributeTraits<TARGETING::ATTR_GPU_SENSORS>::Type
l_gpuArray;
return i_tgt->tryGetAttr<TARGETING::ATTR_GPU_SENSORS>(l_gpuArray);
}
/**
* @brief Given a passed in target, looks up IPMI_SENSOR data based upon
* the passed in sensor number.
*
* @param[in] i_target. The target whose IPMI_SENSOR attribute will be
* searched for information based upon the passed
* in sensor number.
*
* @param[in] i_sensorNumber. The IPMI sensor whose information we wish
* to gather.
*
* @param[out] o_sensorType. The sensor type as read from the
* from the IPMI_SENSOR_ARRAY.
*
* @param[out] o_entityId. The entity id associated with
* the sensor as read from the IPMI_SENSOR_ARRAY.
*
* @param[out] o_sensorName. The sensor name as read from
* the IPMI_SENSOR_ARRAY.
*
*/
static bool lookupIPMISensorInfo(TARGETING::Target * i_target,
uint32_t i_sensorNumber,
uint8_t& o_sensorType,
uint8_t& o_entityId,
TARGETING::SENSOR_NAME& o_sensorName
);
/**
* @brief Given a passed in target, looks up GPU_SENSOR data based upon
* the passed in sensor number.
*
* @param[in] i_target. The target whose GPU_SENSORS attribute will be
* searched for information based upon the passed
* in sensor number.
*
* @param[in] i_sensorNumber. The GPU sensor whose information we wish
* to gather.
*
* @param[out] o_sensorType. The sensor type as read from the
* from the GPU_SENSOR_ARRAY.
*
* @param[out] o_entityId. The entity id associated with
* the sensor as read from the GPU_SENSOR_ARRAY.
*
* @param[out] o_sensorName. The sensor name as read from
* the GPU_SENSOR_ARRAY.
*
*/
static bool lookupGPUSensorInfo(TARGETING::Target * i_target,
uint32_t i_sensorNumber,
uint8_t& o_sensorType,
uint8_t& o_entityId,
TARGETING::SENSOR_NAME& o_sensorName
);
};
}
#endif
|