OpenBIC
OpenSource Bridge-IC
pdr.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
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#ifndef PDR_H
18#define PDR_H
19
20#include <stdbool.h>
21#include <stdint.h>
22#include <sys/byteorder.h>
23#include "plat_def.h"
24#include "libutil.h"
25
26#define TIMESTAMP104_SIZE 13 //A binary datetime type formatted as a series of 13 bytes
27#define MAX_LANGUAGE_TAG_LEN 3 //name language tag: "en"
28
29#ifndef MAX_AUX_SENSOR_NAME_LEN
30#define MAX_AUX_SENSOR_NAME_LEN 40
31#endif
32
33#ifndef NUMERIC_PDR_SIZE
34#define NUMERIC_PDR_SIZE (78 + MAX_AUX_SENSOR_NAME_LEN)
35#endif
36
37typedef float real32_t;
38
39int pdr_init(void);
40
45};
46
52};
53
78};
79
80typedef struct __attribute__((packed)) {
81 uint32_t record_handle;
82 uint8_t PDR_header_version;
83 uint8_t PDR_type;
84 uint16_t record_change_number;
85 uint16_t data_length;
87
88typedef struct __attribute__((packed)) {
89 /*** PDR common header***/
90 PDR_common_header pdr_common_header;
91
92 /***numeric sensor format***/
93 uint16_t PLDM_terminus_handle;
94 uint16_t sensor_id;
95 uint16_t entity_type;
96 uint16_t entity_instance_number;
97 uint16_t container_id;
98 uint8_t sensor_init;
99 uint8_t sensor_auxiliary_names_pdr;
100 uint8_t base_unit;
101 int8_t unit_modifier;
102 uint8_t rate_unit;
103 uint8_t base_oem_unit_handle;
104 uint8_t aux_unit;
105 int8_t aux_unit_modifier;
106 uint8_t auxrate_unit;
107 uint8_t rel;
108 uint8_t aux_oem_unit_handle;
109 uint8_t is_linear;
110 uint8_t sensor_data_size;
111 real32_t resolution;
113 uint16_t accuracy;
114 uint8_t plus_tolerance;
115 uint8_t minus_tolerance;
116 uint32_t hysteresis;
117 uint8_t supported_thresholds;
118 uint8_t threshold_and_hysteresis_volatility;
119 real32_t state_transition_interval;
120 real32_t update_interval;
121 uint32_t max_readable;
122 uint32_t min_readable;
123 uint8_t range_field_format;
124 uint8_t range_field_support;
125 uint32_t nominal_value;
126 uint32_t normal_max;
127 uint32_t normal_min;
128 int32_t warning_high;
129 int32_t warning_low;
130 int32_t critical_high;
131 int32_t critical_low;
132 int32_t fatal_high;
133 int32_t fatal_low;
135
136typedef struct __attribute__((packed)) {
137 PDR_common_header pdr_common_header;
138 uint16_t terminus_handle;
139 uint16_t sensor_id;
140 uint8_t sensor_count;
141 uint8_t nameStringCount;
142 char nameLanguageTag[MAX_LANGUAGE_TAG_LEN];
145
146typedef struct __attribute__((packed)) {
147 PDR_common_header pdr_common_header;
148 uint16_t entity_type;
149 uint16_t entity_instance_number;
150 uint16_t container_id;
151 uint8_t shared_name_count;
152 uint8_t nameStringCount;
153 char nameLanguageTag[MAX_LANGUAGE_TAG_LEN];
154 char16_t entityName[];
156
157typedef struct __attribute__((packed)) {
158 uint8_t repository_state;
161 uint32_t record_count;
162 uint32_t repository_size;
163 uint32_t largest_record_size;
166
168uint32_t get_record_count();
169uint32_t plat_get_pdr_size(uint8_t pdr_type);
173int pldm_get_sensor_name_via_sensor_id(uint16_t sensor_id, char *sensor_name, size_t max_length);
179int change_pdr_table_critical_high_with_sensor_id(uint32_t sensorID, uint32_t critical_high);
180int change_pdr_table_critical_low_with_sensor_id(uint32_t sensorID, uint32_t critical_low);
181int get_pdr_table_critical_high_and_low_with_sensor_id(uint32_t sensorID, float *critical_high,
182 float *critical_low);
183int check_supported_threshold_with_sensor_id(uint32_t sensorID);
184int get_pdr_with_sensor_id(uint32_t sensorID, PDR_numeric_sensor *numeric_sensor_pdr);
185
186#endif
uint_least16_t char16_t
Definition: libutil.h:86
PDR_numeric_sensor * numeric_sensor_table
Definition: pdr.c:32
PDR_entity_auxiliary_names * get_entity_auxiliary_names_table()
Definition: pdr.c:330
uint16_t plat_get_pdr_entity_aux_names_size()
Definition: pdr.c:317
uint16_t plat_get_disabled_sensor_count()
Definition: pdr.c:323
#define MAX_AUX_SENSOR_NAME_LEN
Definition: pdr.h:30
float real32_t
Definition: pdr.h:37
int pldm_get_sensor_name_via_sensor_id(uint16_t sensor_id, char *sensor_name, size_t max_length)
Definition: pdr.c:190
int get_pdr_table_via_record_handle(uint8_t *record_data, uint32_t record_handle)
Definition: pdr.c:238
#define MAX_LANGUAGE_TAG_LEN
Definition: pdr.h:27
int get_pdr_table_critical_high_and_low_with_sensor_id(uint32_t sensorID, float *critical_high, float *critical_low)
Definition: pdr.c:373
pdr_repository_state
Definition: pdr.h:41
@ PDR_STATE_FAILED
Definition: pdr.h:44
@ PDR_STATE_AVAILABLE
Definition: pdr.h:42
@ PDR_STATE_UPDATE_IN_PROGRESS
Definition: pdr.h:43
int get_pdr_with_sensor_id(uint32_t sensorID, PDR_numeric_sensor *numeric_sensor_pdr)
Definition: pdr.c:419
PDR_common_header
Definition: pdr.h:86
void plat_init_entity_aux_names_pdr_table()
Definition: pdr.c:306
pldm_pdr_types
Definition: pdr.h:54
@ PLDM_OEM_ENTITY_ID_PDR
Definition: pdr.h:71
@ PLDM_EFFECTER_OEM_SEMANTIC_PDR
Definition: pdr.h:68
@ PLDM_PDR_ENTITY_ASSOCIATION
Definition: pdr.h:69
@ PLDM_NUMERIC_SENSOR_PDR
Definition: pdr.h:56
@ PLDM_PDR_FRU_RECORD_SET
Definition: pdr.h:74
@ PLDM_STATE_EFFECTER_INITIALIZATION_PDR
Definition: pdr.h:66
@ PLDM_OEM_PDR
Definition: pdr.h:77
@ PLDM_STATE_SENSOR_INITIALIZATION_PDR
Definition: pdr.h:59
@ PLDM_COMPACT_NUMERIC_SENSOR_PDR
Definition: pdr.h:75
@ PLDM_EFFECTER_AUXILIARY_NAMES_PDR
Definition: pdr.h:67
@ PLDM_STATE_EFFECTER_PDR
Definition: pdr.h:65
@ PLDM_STATE_SENSOR_PDR
Definition: pdr.h:58
@ PLDM_EVENT_LOG_PDR
Definition: pdr.h:73
@ PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR
Definition: pdr.h:64
@ PLDM_OEM_UNIT_PDR
Definition: pdr.h:61
@ PLDM_NUMERIC_EFFECTER_PDR
Definition: pdr.h:63
@ PLDM_OEM_STATE_SET_PDR
Definition: pdr.h:62
@ PLDM_OEM_DEVICE_PDR
Definition: pdr.h:76
@ PLDM_INTERRUPT_ASSOCIATION_PDR
Definition: pdr.h:72
@ PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR
Definition: pdr.h:57
@ PLDM_SENSOR_AUXILIARY_NAMES_PDR
Definition: pdr.h:60
@ PLDM_ENTITY_AUXILIARY_NAMES_PDR
Definition: pdr.h:70
@ PLDM_TERMINUS_LOCATOR_PDR
Definition: pdr.h:55
uint32_t plat_get_pdr_size(uint8_t pdr_type)
Definition: pdr.c:288
void plat_load_entity_aux_names_pdr_table(PDR_entity_auxiliary_names *entity_aux_name_table)
Definition: pdr.c:311
PDR_numeric_sensor
Definition: pdr.h:134
uint32_t get_record_count()
Definition: pdr.c:283
void plat_load_numeric_sensor_pdr_table(PDR_numeric_sensor *numeric_sensor_table)
Definition: pdr.c:294
PDR_INFO
Definition: pdr.h:165
#define TIMESTAMP104_SIZE
Definition: pdr.h:26
PDR_INFO * get_pdr_info()
Definition: pdr.c:144
int change_pdr_table_critical_low_with_sensor_id(uint32_t sensorID, uint32_t critical_low)
Definition: pdr.c:354
PDR_sensor_auxiliary_names
Definition: pdr.h:144
PDR_entity_auxiliary_names
Definition: pdr.h:155
int pdr_init(void)
Definition: pdr.c:36
int check_supported_threshold_with_sensor_id(uint32_t sensorID)
Definition: pdr.c:401
int change_pdr_table_critical_high_with_sensor_id(uint32_t sensorID, uint32_t critical_high)
Definition: pdr.c:335
void plat_load_aux_sensor_names_pdr_table(PDR_sensor_auxiliary_names *aux_sensor_name_table)
Definition: pdr.c:300
PDR_SENSOR_INIT_STATE
Definition: pdr.h:47
@ PDR_SENSOR_ENABLE
Definition: pdr.h:50
@ PDR_SENSOR_NO_INIT
Definition: pdr.h:48
@ PDR_SENSOR_USEINIT_PDR
Definition: pdr.h:49
@ PDR_SENSOR_DISABLE
Definition: pdr.h:51
uint32_t offset
Definition: pldm_firmware_update.h:0
uint8_t data_transfer_handle_timeout
Definition: pldm_monitor.h:7
uint8_t repository_state
Definition: pldm_monitor.h:1
uint8_t record_data[NUMERIC_PDR_SIZE]
Definition: pldm_monitor.h:5
uint16_t record_change_number
Definition: pldm_monitor.h:4
uint16_t sensor_id
Definition: pldm_monitor.h:0
uint32_t record_count
Definition: pldm_monitor.h:4
uint8_t oem_update_time[TIMESTAMP104_SIZE]
Definition: pldm_monitor.h:3
uint32_t largest_record_size
Definition: pldm_monitor.h:6
uint8_t update_time[TIMESTAMP104_SIZE]
Definition: pldm_monitor.h:2
uint32_t record_handle
Definition: pldm_monitor.h:0
uint8_t sensor_data_size
Definition: pldm_monitor.h:1
uint32_t repository_size
Definition: pldm_monitor.h:5
uint32_t data_length
Definition: pldm_oem.h:1
bool sensor_init(void)
Definition: sensor.c:1417
Definition: pldm_smbios.h:61