1 /*
2  * Copyright (C) 2003-2015 FreeIPMI Core Team
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18 /*****************************************************************************\
19  *  Copyright (C) 2007-2015 Lawrence Livermore National Security, LLC.
20  *  Copyright (C) 2006-2007 The Regents of the University of California.
21  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
22  *  Written by Albert Chu <chu11@llnl.gov>
23  *  UCRL-CODE-222073
24  *
25  *  This file is part of Ipmimonitoring, an IPMI sensor monitoring
26  *  library.  For details, see http://www.llnl.gov/linux/.
27  *
28  *  Ipmimonitoring is free software; you can redistribute it and/or modify
29  *  it under the terms of the GNU General Public License as published by the
30  *  Free Software Foundation; either version 3 of the License, or (at your
31  *  option) any later version.
32  *
33  *  Ipmimonitoring is distributed in the hope that it will be useful, but
34  *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
35  *  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36  *  for more details.
37  *
38  *  You should have received a copy of the GNU General Public License along
39  *  with Ipmimonitoring.  If not, see <http://www.gnu.org/licenses/>.
40 \*****************************************************************************/
41 
42 #ifndef IPMI_SDR_H
43 #define IPMI_SDR_H
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #include <stdint.h>
50 #include <freeipmi/api/ipmi-api.h>
51 
52 #define IPMI_SDR_ERR_SUCCESS                                      0
53 #define IPMI_SDR_ERR_CONTEXT_NULL                                 1
54 #define IPMI_SDR_ERR_CONTEXT_INVALID                              2
55 #define IPMI_SDR_ERR_PARAMETERS                                   3
56 #define IPMI_SDR_ERR_OUT_OF_MEMORY                                4
57 #define IPMI_SDR_ERR_FILENAME_INVALID                             5
58 #define IPMI_SDR_ERR_FILESYSTEM                                   6
59 #define IPMI_SDR_ERR_PERMISSION                                   7
60 #define IPMI_SDR_ERR_CONTEXT_PERFORMING_OTHER_OPERATION           8
61 #define IPMI_SDR_ERR_CACHE_CREATE_CACHE_EXISTS                    9
62 #define IPMI_SDR_ERR_CACHE_CREATE_DUPLICATE_RECORD_ID             10
63 #define IPMI_SDR_ERR_CACHE_CREATE_INVALID_RECORD_LENGTH           11
64 #define IPMI_SDR_ERR_CACHE_CREATE_INVALID_RECORD_COUNT            12
65 #define IPMI_SDR_ERR_CACHE_READ_ALREADY_INITIALIZED               13
66 #define IPMI_SDR_ERR_CACHE_READ_INITIALIZATION                    14
67 #define IPMI_SDR_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST              15
68 #define IPMI_SDR_ERR_CACHE_INVALID                                16
69 #define IPMI_SDR_ERR_CACHE_OUT_OF_DATE                            17
70 #define IPMI_SDR_ERR_STATS_NOT_COMPILED                           18
71 #define IPMI_SDR_ERR_PARSE_INVALID_SDR_RECORD                     19
72 #define IPMI_SDR_ERR_PARSE_INCOMPLETE_SDR_RECORD                  20
73 #define IPMI_SDR_ERR_PARSE_CANNOT_PARSE_OR_CALCULATE              21
74 #define IPMI_SDR_ERR_ERROR_RETURNED_IN_CALLBACK                   22
75 #define IPMI_SDR_ERR_NOT_FOUND                                    23
76 #define IPMI_SDR_ERR_IPMI_ERROR                                   24
77 #define IPMI_SDR_ERR_SYSTEM_ERROR                                 25
78 #define IPMI_SDR_ERR_OVERFLOW                                     26
79 #define IPMI_SDR_ERR_INTERNAL_ERROR                               27
80 #define IPMI_SDR_ERR_ERRNUMRANGE                                  28
81 
82 #define IPMI_SDR_FLAGS_DEFAULT                   0x0000
83 #define IPMI_SDR_FLAGS_DEBUG_DUMP                0x0001
84 
85 /* Flags just for cache creation
86  *
87  * OVERWRITE - overwrite any previously created cache.
88  *
89  * DUPLICATE_RECORD_ID - check for duplicate record IDs and return error if one is found.
90  *
91  * ASSUME_MAX_SDR_RECORD_COUNT - If motherboard does not implement SDR
92  * record reading properly, this workaround will allow code to not
93  * fail out.
94  */
95 #define IPMI_SDR_CACHE_CREATE_FLAGS_DEFAULT                     0x00
96 #define IPMI_SDR_CACHE_CREATE_FLAGS_OVERWRITE                   0x01
97 #define IPMI_SDR_CACHE_CREATE_FLAGS_DUPLICATE_RECORD_ID         0x02
98 #define IPMI_SDR_CACHE_CREATE_FLAGS_ASSUME_MAX_SDR_RECORD_COUNT 0x04
99 
100 #define IPMI_SDR_SENSOR_NAME_FLAGS_DEFAULT                       0x00000000
101 #define IPMI_SDR_SENSOR_NAME_FLAGS_IGNORE_SHARED_SENSORS         0x00000001
102 /* applicable only to entity sensor names */
103 #define IPMI_SDR_SENSOR_NAME_FLAGS_ALWAYS_OUTPUT_INSTANCE_NUMBER 0x00000002
104 
105 #define IPMI_SDR_MAX_RECORD_LENGTH                      261 /* 256 + header */
106 
107 #define IPMI_SDR_MAX_SENSOR_NAME_LENGTH                 128
108 
109 typedef struct ipmi_sdr_ctx *ipmi_sdr_ctx_t;
110 
111 typedef void (*Ipmi_Sdr_Cache_Create_Callback)(uint8_t sdr_version,
112                                                uint16_t record_count,
113                                                uint32_t most_recent_addition_timestamp,
114                                                uint32_t most_recent_erase_timestamp,
115                                                uint16_t record_id,
116                                                void *data);
117 
118 /* return != 0 to quit iteration, return val will be returned up
119  * through original caller.  return < 0 will result in
120  * IPMI_SDR_ERR_ERROR_RETURNED_IN_CALLBACK to bet set.
121  *
122  * Users should be mindful of the API calls they make will in a
123  * callback.  Calls to some functions, such as ipmi_sdr_cache_first()
124  * may change iteration behavior.
125  */
126 typedef int (*Ipmi_Sdr_Cache_Iterate_Callback)(ipmi_sdr_ctx_t ctx,
127                                                uint8_t record_type,
128                                                const void *sdr_record,
129                                                unsigned int sdr_record_len,
130                                                void *data);
131 
132 /*
133  * SDR Cache Context and General functions
134  */
135 ipmi_sdr_ctx_t ipmi_sdr_ctx_create (void);
136 void ipmi_sdr_ctx_destroy (ipmi_sdr_ctx_t ctx);
137 int ipmi_sdr_ctx_errnum (ipmi_sdr_ctx_t ctx);
138 char * ipmi_sdr_ctx_strerror (int errnum);
139 char * ipmi_sdr_ctx_errormsg (ipmi_sdr_ctx_t ctx);
140 
141 int ipmi_sdr_ctx_get_flags (ipmi_sdr_ctx_t ctx, unsigned int *flags);
142 int ipmi_sdr_ctx_set_flags (ipmi_sdr_ctx_t ctx, unsigned int flags);
143 char *ipmi_sdr_ctx_get_debug_prefix (ipmi_sdr_ctx_t ctx);
144 int ipmi_sdr_ctx_set_debug_prefix (ipmi_sdr_ctx_t ctx, const char *debug_prefix);
145 
146 /*
147  * SDR Cache Creation Functions
148  */
149 /* ipmi_sdr_cache_create
150  * - callback called between every record that is cached
151  */
152 int ipmi_sdr_cache_create (ipmi_sdr_ctx_t ctx,
153                            ipmi_ctx_t ipmi_ctx,
154                            const char *filename,
155                            int cache_create_flags,
156                            Ipmi_Sdr_Cache_Create_Callback create_callback,
157                            void *create_callback_data);
158 
159 /*
160  * SDR Cache Reading Functions
161  */
162 
163 /* ipmi_sdr_cache_open
164  *  - ipmi_ctx is optional
165  * - if ipmi_ctx is specified, timestamps/version of the SDR will be
166  *   checked for out-of-dateness
167  */
168 int ipmi_sdr_cache_open (ipmi_sdr_ctx_t ctx,
169                          ipmi_ctx_t ipmi_ctx,
170                          const char *filename);
171 
172 int ipmi_sdr_cache_sdr_version (ipmi_sdr_ctx_t ctx, uint8_t *sdr_version);
173 int ipmi_sdr_cache_record_count (ipmi_sdr_ctx_t ctx, uint16_t *record_count);
174 int ipmi_sdr_cache_most_recent_addition_timestamp (ipmi_sdr_ctx_t ctx,
175                                                    uint32_t *most_recent_addition_timestamp);
176 int ipmi_sdr_cache_most_recent_erase_timestamp (ipmi_sdr_ctx_t ctx,
177                                                 uint32_t *most_recent_erase_timestamp);
178 
179 int ipmi_sdr_cache_first (ipmi_sdr_ctx_t ctx);
180 int ipmi_sdr_cache_next (ipmi_sdr_ctx_t ctx);
181 int ipmi_sdr_cache_seek (ipmi_sdr_ctx_t ctx, unsigned int index);
182 int ipmi_sdr_cache_search_record_id (ipmi_sdr_ctx_t ctx, uint16_t record_id);
183 /* sensor owner id is 8bit field - 7 bit slave or system software id + 1 bit indicating type */
184 int ipmi_sdr_cache_search_sensor (ipmi_sdr_ctx_t ctx, uint8_t sensor_number, uint8_t sensor_owner_id);
185 
186 /* return length of data read into buffer on success, -1 on error */
187 int ipmi_sdr_cache_record_read (ipmi_sdr_ctx_t ctx,
188                                 void *buf,
189                                 unsigned int buflen);
190 
191 /* ipmi_sdr_cache_iterate
192  * - iterate through all SDR records calling callback for each one.
193  * - if callback returns < 0, that will break iteration and return
194  *   value is returned here.
195  */
196 int ipmi_sdr_cache_iterate (ipmi_sdr_ctx_t ctx,
197                             Ipmi_Sdr_Cache_Iterate_Callback iterate_callback,
198                             void *iterate_callback_data);
199 
200 int ipmi_sdr_cache_close (ipmi_sdr_ctx_t ctx);
201 
202 /*
203  * SDR stats functions
204  *
205  * After opening an SDR cache (i.e. ipmi_sdr_cache_open() has been
206  * called), loop through the cache and compile data on the cache for
207  * a variety of utility functions.
208  */
209 
210 int ipmi_sdr_stats_compile (ipmi_sdr_ctx_t ctx);
211 
212 /* returns the number of unique entity instances for an entity id found
213  * in the SDR
214  */
215 int ipmi_sdr_stats_entity_instance_unique (ipmi_sdr_ctx_t ctx, uint8_t entity_id);
216 
217 /*
218  * SDR Record Parsing Functions
219  *
220  * For all parsing functions, if currently reading the SDR cache
221  * (i.e. ipmi_sdr_cache_open() has been called), if sdr_record is NULL
222  * and sdr_record_len is 0, the current sdr record in the iterator
223  * will be used in parsing.
224  *
225  * See ipmi-sdr-oem.h for parsing OEM records.
226  */
227 
228 /* For all SDR records */
229 int ipmi_sdr_parse_record_id_and_type (ipmi_sdr_ctx_t ctx,
230                                        const void *sdr_record,
231                                        unsigned int sdr_record_len,
232                                        uint16_t *record_id,
233                                        uint8_t *record_type);
234 
235 /* For Full, Compact, Event SDR records */
236 int ipmi_sdr_parse_sensor_owner_id (ipmi_sdr_ctx_t ctx,
237                                     const void *sdr_record,
238                                     unsigned int sdr_record_len,
239                                     uint8_t *sensor_owner_id_type,
240                                     uint8_t *sensor_owner_id);
241 
242 /* For Full, Compact, Event SDR records */
243 int ipmi_sdr_parse_sensor_owner_lun (ipmi_sdr_ctx_t ctx,
244                                      const void *sdr_record,
245                                      unsigned int sdr_record_len,
246                                      uint8_t *sensor_owner_lun,
247                                      uint8_t *channel_number);
248 
249 /* For Full, Compact, Event SDR records */
250 int ipmi_sdr_parse_sensor_number (ipmi_sdr_ctx_t ctx,
251                                   const void *sdr_record,
252                                   unsigned int sdr_record_len,
253                                   uint8_t *sensor_number);
254 
255 /* For Full, Compact, Event SDR, Generic Device Locator, Management Controller Device Locator SDR records */
256 int ipmi_sdr_parse_entity_id_instance_type (ipmi_sdr_ctx_t ctx,
257                                             const void *sdr_record,
258                                             unsigned int sdr_record_len,
259                                             uint8_t *entity_id,
260                                             uint8_t *entity_instance,
261                                             uint8_t *entity_instance_type);
262 
263 /* For Full, Compact, Event SDR records */
264 int ipmi_sdr_parse_sensor_type (ipmi_sdr_ctx_t ctx,
265                                 const void *sdr_record,
266                                 unsigned int sdr_record_len,
267                                 uint8_t *sensor_type);
268 
269 /* For Full, Compact, Event SDR records */
270 int ipmi_sdr_parse_event_reading_type_code (ipmi_sdr_ctx_t ctx,
271                                             const void *sdr_record,
272                                             unsigned int sdr_record_len,
273                                             uint8_t *event_reading_type_code);
274 
275 /* For Full, Compact, Event SDR records */
276 /* return length of data read into buffer on success, -1 on error */
277 int ipmi_sdr_parse_id_string (ipmi_sdr_ctx_t ctx,
278                               const void *sdr_record,
279                               unsigned int sdr_record_len,
280                               char *id_string,
281                               unsigned int id_string_len);
282 
283 /* For Full, Compact SDR records */
284 int ipmi_sdr_parse_sensor_units (ipmi_sdr_ctx_t ctx,
285                                  const void *sdr_record,
286                                  unsigned int sdr_record_len,
287                                  uint8_t *sensor_units_percentage,
288                                  uint8_t *sensor_units_modifier,
289                                  uint8_t *sensor_units_rate,
290                                  uint8_t *sensor_base_unit_type,
291                                  uint8_t *sensor_modifier_unit_type);
292 
293 /* For Full, Compact SDR records */
294 int ipmi_sdr_parse_sensor_capabilities (ipmi_sdr_ctx_t ctx,
295                                         const void *sdr_record,
296                                         unsigned int sdr_record_len,
297                                         uint8_t *event_message_control_support,
298                                         uint8_t *threshold_access_support,
299                                         uint8_t *hysteresis_support,
300                                         uint8_t *auto_re_arm_support,
301                                         uint8_t *entity_ignore_support);
302 
303 /* For Full, Compact SDR records */
304 int ipmi_sdr_parse_sensor_direction (ipmi_sdr_ctx_t ctx,
305                                      const void *sdr_record,
306                                      unsigned int sdr_record_len,
307                                      uint8_t *sensor_direction);
308 
309 /* For Full, Compact SDR records */
310 /* event reading type must indicate a discrete sensor */
311 int ipmi_sdr_parse_assertion_supported (ipmi_sdr_ctx_t ctx,
312                                         const void *sdr_record,
313                                         unsigned int sdr_record_len,
314                                         uint8_t *event_state_0,
315                                         uint8_t *event_state_1,
316                                         uint8_t *event_state_2,
317                                         uint8_t *event_state_3,
318                                         uint8_t *event_state_4,
319                                         uint8_t *event_state_5,
320                                         uint8_t *event_state_6,
321                                         uint8_t *event_state_7,
322                                         uint8_t *event_state_8,
323                                         uint8_t *event_state_9,
324                                         uint8_t *event_state_10,
325                                         uint8_t *event_state_11,
326                                         uint8_t *event_state_12,
327                                         uint8_t *event_state_13,
328                                         uint8_t *event_state_14);
329 
330 /* For Full, Compact SDR records */
331 /* event reading type must indicate a discrete sensor */
332 int ipmi_sdr_parse_deassertion_supported (ipmi_sdr_ctx_t ctx,
333                                           const void *sdr_record,
334                                           unsigned int sdr_record_len,
335                                           uint8_t *event_state_0,
336                                           uint8_t *event_state_1,
337                                           uint8_t *event_state_2,
338                                           uint8_t *event_state_3,
339                                           uint8_t *event_state_4,
340                                           uint8_t *event_state_5,
341                                           uint8_t *event_state_6,
342                                           uint8_t *event_state_7,
343                                           uint8_t *event_state_8,
344                                           uint8_t *event_state_9,
345                                           uint8_t *event_state_10,
346                                           uint8_t *event_state_11,
347                                           uint8_t *event_state_12,
348                                           uint8_t *event_state_13,
349                                           uint8_t *event_state_14);
350 
351 /* For Full SDR records */
352 /* event reading type must indicate a threshold sensor */
353 int ipmi_sdr_parse_threshold_assertion_supported (ipmi_sdr_ctx_t ctx,
354                                                   const void *sdr_record,
355                                                   unsigned int sdr_record_len,
356                                                   uint8_t *lower_non_critical_going_low,
357                                                   uint8_t *lower_non_critical_going_high,
358                                                   uint8_t *lower_critical_going_low,
359                                                   uint8_t *lower_critical_going_high,
360                                                   uint8_t *lower_non_recoverable_going_low,
361                                                   uint8_t *lower_non_recoverable_going_high,
362                                                   uint8_t *upper_non_critical_going_low,
363                                                   uint8_t *upper_non_critical_going_high,
364                                                   uint8_t *upper_critical_going_low,
365                                                   uint8_t *upper_critical_going_high,
366                                                   uint8_t *upper_non_recoverable_going_low,
367                                                   uint8_t *upper_non_recoverable_going_high);
368 
369 /* For Full SDR records */
370 /* event reading type must indicate a threshold sensor */
371 int ipmi_sdr_parse_threshold_deassertion_supported (ipmi_sdr_ctx_t ctx,
372                                                     const void *sdr_record,
373                                                     unsigned int sdr_record_len,
374                                                     uint8_t *lower_non_critical_going_low,
375                                                     uint8_t *lower_non_critical_going_high,
376                                                     uint8_t *lower_critical_going_low,
377                                                     uint8_t *lower_critical_going_high,
378                                                     uint8_t *lower_non_recoverable_going_low,
379                                                     uint8_t *lower_non_recoverable_going_high,
380                                                     uint8_t *upper_non_critical_going_low,
381                                                     uint8_t *upper_non_critical_going_high,
382                                                     uint8_t *upper_critical_going_low,
383                                                     uint8_t *upper_critical_going_high,
384                                                     uint8_t *upper_non_recoverable_going_low,
385                                                     uint8_t *upper_non_recoverable_going_high);
386 
387 /* For Full SDR records */
388 /* event reading type must indicate a threshold sensor */
389 int ipmi_sdr_parse_threshold_readable (ipmi_sdr_ctx_t ctx,
390                                        const void *sdr_record,
391                                        unsigned int sdr_record_len,
392                                        uint8_t *lower_non_critical_threshold,
393                                        uint8_t *lower_critical_threshold,
394                                        uint8_t *lower_non_recoverable_threshold,
395                                        uint8_t *upper_non_critical_threshold,
396                                        uint8_t *upper_critical_threshold,
397                                        uint8_t *upper_non_recoverable_threshold);
398 
399 /* For Full SDR records */
400 /* event reading type must indicate a threshold sensor */
401 int ipmi_sdr_parse_threshold_settable (ipmi_sdr_ctx_t ctx,
402                                        const void *sdr_record,
403                                        unsigned int sdr_record_len,
404                                        uint8_t *lower_non_critical_threshold,
405                                        uint8_t *lower_critical_threshold,
406                                        uint8_t *lower_non_recoverable_threshold,
407                                        uint8_t *upper_non_critical_threshold,
408                                        uint8_t *upper_critical_threshold,
409                                        uint8_t *upper_non_recoverable_threshold);
410 
411 /* For Full SDR records */
412 /* b_exponent - sometimes documented as k1 */
413 /* r_exponent - sometimes documented as k2 */
414 int ipmi_sdr_parse_sensor_decoding_data (ipmi_sdr_ctx_t ctx,
415                                          const void *sdr_record,
416                                          unsigned int sdr_record_len,
417                                          int8_t *r_exponent,
418                                          int8_t *b_exponent,
419                                          int16_t *m,
420                                          int16_t *b,
421                                          uint8_t *linearization,
422                                          uint8_t *analog_data_format);
423 
424 /* For Full SDR records */
425 int ipmi_sdr_parse_sensor_reading_ranges_specified (ipmi_sdr_ctx_t ctx,
426                                                     const void *sdr_record,
427                                                     unsigned int sdr_record_len,
428                                                     uint8_t *nominal_reading_specified,
429                                                     uint8_t *normal_maximum_specified,
430                                                     uint8_t *normal_minimum_specified);
431 
432 /* For Full SDR records */
433 /* Results must be freed by user */
434 int ipmi_sdr_parse_sensor_reading_ranges (ipmi_sdr_ctx_t ctx,
435                                           const void *sdr_record,
436                                           unsigned int sdr_record_len,
437                                           double **nominal_reading,
438                                           double **normal_maximum,
439                                           double **normal_minimum,
440                                           double **sensor_maximum_reading,
441                                           double **sensor_minimum_reading);
442 
443 /* For Full SDR records */
444 /* Results must be freed by user */
445 int ipmi_sdr_parse_thresholds (ipmi_sdr_ctx_t ctx,
446                                const void *sdr_record,
447                                unsigned int sdr_record_len,
448                                double **lower_non_critical_threshold,
449                                double **lower_critical_threshold,
450                                double **lower_non_recoverable_threshold,
451                                double **upper_non_critical_threshold,
452                                double **upper_critical_threshold,
453                                double **upper_non_recoverable_threshold);
454 
455 
456 /* For Full SDR records */
457 int ipmi_sdr_parse_thresholds_raw (ipmi_sdr_ctx_t ctx,
458                                    const void *sdr_record,
459                                    unsigned int sdr_record_len,
460                                    uint8_t *lower_non_critical_threshold,
461                                    uint8_t *lower_critical_threshold,
462                                    uint8_t *lower_non_recoverable_threshold,
463                                    uint8_t *upper_non_critical_threshold,
464                                    uint8_t *upper_critical_threshold,
465                                    uint8_t *upper_non_recoverable_threshold);
466 
467 /* For Full SDR records */
468 /* Results must be freed by user */
469 int ipmi_sdr_parse_tolerance (ipmi_sdr_ctx_t ctx,
470                               const void *sdr_record,
471                               unsigned int sdr_record_len,
472                               double **tolerance);
473 
474 /* For Full SDR records */
475 /* Result returned is in percentage */
476 /* Results must be freed by user */
477 int ipmi_sdr_parse_accuracy (ipmi_sdr_ctx_t ctx,
478                              const void *sdr_record,
479                              unsigned int sdr_record_len,
480                              double **tolerance);
481 
482 /* For Full SDR records */
483 int ipmi_sdr_parse_hysteresis (ipmi_sdr_ctx_t ctx,
484                                const void *sdr_record,
485                                unsigned int sdr_record_len,
486                                uint8_t *positive_going_threshold_hysteresis,
487                                uint8_t *negative_going_threshold_hysteresis);
488 
489 /* For Compact SDR records */
490 int ipmi_sdr_parse_sensor_record_sharing (ipmi_sdr_ctx_t ctx,
491                                           const void *sdr_record,
492                                           unsigned int sdr_record_len,
493                                           uint8_t *share_count,
494                                           uint8_t *id_string_instance_modifier_type,
495                                           uint8_t *id_string_instance_modifier_offset,
496                                           uint8_t *entity_instance_sharing);
497 
498 /* For Entity Association, Device Relative Entity Association SDR
499    records */
500 int ipmi_sdr_parse_container_entity (ipmi_sdr_ctx_t ctx,
501                                      const void *sdr_record,
502                                      unsigned int sdr_record_len,
503                                      uint8_t *container_entity_id,
504                                      uint8_t *container_entity_instance);
505 
506 /* For Generic Device Locator, FRU Device Locator, Management
507    Controller Device Locator SDR records */
508 /* return length of data read into buffer on success, -1 on error */
509 int ipmi_sdr_parse_device_id_string (ipmi_sdr_ctx_t ctx,
510                                      const void *sdr_record,
511                                      unsigned int sdr_record_len,
512                                      char *device_id_string,
513                                      unsigned int device_id_string_len);
514 
515 /* For Generic Device Locator, FRU Device Locator SDR records */
516 int ipmi_sdr_parse_device_type (ipmi_sdr_ctx_t ctx,
517                                 const void *sdr_record,
518                                 unsigned int sdr_record_len,
519                                 uint8_t *device_type,
520                                 uint8_t *device_type_modifier);
521 
522 /* For Generic Device Locator SDR records */
523 int ipmi_sdr_parse_generic_device_locator_parameters (ipmi_sdr_ctx_t ctx,
524                                                       const void *sdr_record,
525                                                       unsigned int sdr_record_len,
526                                                       uint8_t *device_access_address,
527                                                       uint8_t *channel_number,
528                                                       uint8_t *device_slave_address,
529                                                       uint8_t *private_bus_id,
530                                                       uint8_t *lun_for_master_write_read_command,
531                                                       uint8_t *address_span,
532                                                       uint8_t *oem);
533 
534 /* For FRU Device Locator SDR records */
535 int ipmi_sdr_parse_fru_device_locator_parameters (ipmi_sdr_ctx_t ctx,
536                                                   const void *sdr_record,
537                                                   unsigned int sdr_record_len,
538                                                   uint8_t *device_access_address,
539                                                   uint8_t *logical_fru_device_device_slave_address,
540                                                   uint8_t *private_bus_id,
541                                                   uint8_t *lun_for_master_write_read_fru_command,
542                                                   uint8_t *logical_physical_fru_device,
543                                                   uint8_t *channel_number);
544 
545 /* For FRU Device Locator SDR records */
546 int ipmi_sdr_parse_fru_entity_id_and_instance (ipmi_sdr_ctx_t ctx,
547                                                const void *sdr_record,
548                                                unsigned int sdr_record_len,
549                                                uint8_t *fru_entity_id,
550                                                uint8_t *fru_entity_instance);
551 
552 /* For Management Controller Device Locator SDR records */
553 int ipmi_sdr_parse_management_controller_device_locator_parameters (ipmi_sdr_ctx_t ctx,
554                                                                     const void *sdr_record,
555                                                                     unsigned int sdr_record_len,
556                                                                     uint8_t *device_slave_address,
557                                                                     uint8_t *channel_number,
558                                                                     uint8_t *global_initialization_event_message_generation,
559                                                                     uint8_t *global_initialization_log_initialization_agent_errors,
560                                                                     uint8_t *global_initialization_controller_logs_initialization_agent_errors,
561                                                                     uint8_t *power_state_notification_controller,
562                                                                     uint8_t *power_state_notification_acpi_device_power_state_notification,
563                                                                     uint8_t *power_state_notification_acpi_system_power_state_notification,
564                                                                     uint8_t *device_capabilities_sensor_device,
565                                                                     uint8_t *device_capabilities_sdr_repository_device,
566                                                                     uint8_t *device_capabilities_sel_device,
567                                                                     uint8_t *device_capabilities_fru_inventory_device,
568                                                                     uint8_t *device_capabilities_ipmb_event_receiver,
569                                                                     uint8_t *device_capabilities_ipmb_event_generator,
570                                                                     uint8_t *device_capabilities_bridge,
571                                                                     uint8_t *device_capabilities_chassis_device);
572 
573 /* For Management Controller Confirmation, OEM SDR records */
574 int ipmi_sdr_parse_manufacturer_id (ipmi_sdr_ctx_t ctx,
575                                     const void *sdr_record,
576                                     unsigned int sdr_record_len,
577                                     uint32_t *manufacturer_id);
578 
579 /* For Management Controller Confirmation SDR records */
580 int ipmi_sdr_parse_product_id (ipmi_sdr_ctx_t ctx,
581                                const void *sdr_record,
582                                unsigned int sdr_record_len,
583                                uint16_t *product_id);
584 
585 /* For OEM SDR records */
586 /* return length of data read into buffer on success, -1 on error */
587 int ipmi_sdr_parse_oem_data (ipmi_sdr_ctx_t ctx,
588                              const void *sdr_record,
589                              unsigned int sdr_record_len,
590                              void *oem_data,
591                              unsigned int oem_data_len);
592 
593 /*
594  * SDR Cache Utility Functions
595  */
596 
597 int ipmi_sdr_cache_delete (ipmi_sdr_ctx_t ctx, const char *filename);
598 
599 /* ipmi_sensor_parse_sensor_name_string
600  * - Wrapper that will return id_string or device_id_string dependent
601  *   on SDR type.
602  * - Based on flags, will deal with shared sensors and alter sensor
603  *   name if necessary.
604  * - if sdr_record is NULL and sdr_record_len is 0, the current sdr
605  *   record in the iterator will be used in parsing.
606  */
607 /* For Full, Compact, Event, Generic Device Locator, FRU Device
608  * Locator, and Management Controller Device Locator SDR records
609  */
610 /* returns length written into buffer on success, -1 on error */
611 int ipmi_sdr_parse_sensor_name (ipmi_sdr_ctx_t ctx,
612                                 const void *sdr_record,
613                                 unsigned int sdr_record_len,
614                                 uint8_t sensor_number,
615                                 unsigned int flags,
616                                 char *buf,
617                                 unsigned int buflen);
618 
619 /* ipmi_sensor_parse_entity_sensor_name
620  * - Creates sensor names with the entity id and instance for better
621  *   names on some systems.
622  * - For example, on some systems sensor ID strings are all called
623  *   "Temp".  The entity ID and instance are needed to turn the name
624  *   into "Processor 1 Temp" or "Processor 2 Temp".
625  * - Based on flags, will deal with shared sensors and alter sensor
626  *   name if necessary.
627  * - if sdr_record is NULL and sdr_record_len is 0, the current sdr
628  *   record in the iterator will be used in parsing.
629  */
630 /* For Full, Compact, Event, Generic Device Locator, and Management
631  * Controller Device Locator SDR records
632  */
633 /* returns length written into buffer on success, -1 on error */
634 int ipmi_sdr_parse_entity_sensor_name (ipmi_sdr_ctx_t ctx,
635                                        const void *sdr_record,
636                                        unsigned int sdr_record_len,
637                                        uint8_t sensor_number,
638                                        unsigned int flags,
639                                        char *buf,
640                                        unsigned int buflen);
641 
642 #ifdef __cplusplus
643 }
644 #endif
645 
646 #endif /* IPMI_SDR_H */
647