ONLP
Open Network Linux Platform APIs
thermal.h
Go to the documentation of this file.
1 /************************************************************
2  * <bsn.cl fy=2014 v=onl>
3  *
4  * Copyright 2014, 2015 Big Switch Networks, Inc.
5  *
6  * Licensed under the Eclipse Public License, Version 1.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.eclipse.org/legal/epl-v10.html
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific
16  * language governing permissions and limitations under the
17  * License.
18  *
19  * </bsn.cl>
20  ********************************************************/
28 #ifndef __ONLP_THERMAL_H__
29 #define __ONLP_THERMAL_H__
30 
31 #include <onlp/onlp_config.h>
32 #include <onlp/onlp.h>
33 #include <onlp/oids.h>
34 
35 /* <auto.start.enum(tag:thermal).define> */
37 typedef enum onlp_thermal_caps_e {
38  ONLP_THERMAL_CAPS_GET_TEMPERATURE = (1 << 0),
39  ONLP_THERMAL_CAPS_GET_WARNING_THRESHOLD = (1 << 1),
40  ONLP_THERMAL_CAPS_GET_ERROR_THRESHOLD = (1 << 2),
41  ONLP_THERMAL_CAPS_GET_SHUTDOWN_THRESHOLD = (1 << 3),
43 
46  ONLP_THERMAL_THRESHOLD_WARNING_DEFAULT = 45000,
47  ONLP_THERMAL_THRESHOLD_ERROR_DEFAULT = 55000,
48  ONLP_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 60000,
50 /* <auto.end.enum(tag:thermal).define> */
51 
55 #define ONLP_THERMAL_CAPS_ALL 0xF
56 
60 #define ONLP_THERMAL_CAPS_GET_ANY_THRESHOLD \
61  ( ONLP_THERMAL_CAPS_GET_WARNING_THRESHOLD | \
62  ONLP_THERMAL_CAPS_GET_ERROR_THRESHOLD | \
63  ONLP_THERMAL_CAPS_GET_SHUTDOWN_THRESHOLD )
64 
68 #define ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \
69  { ONLP_THERMAL_THRESHOLD_WARNING_DEFAULT, \
70  ONLP_THERMAL_THRESHOLD_ERROR_DEFAULT, \
71  ONLP_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT }
72 
76 typedef struct onlp_thermal_info_s {
77 
80 
82  uint32_t caps;
83 
85  int mcelsius;
86 
88  struct {
90  int warning;
91 
93  int error;
94 
96  int shutdown;
97  } thresholds;
98 
100 
101 
105 #define ONLP_THERMAL_INFO_CAP_IS_SET(_pinfo, _name) \
106  ((_pinfo)->caps & ONLP_THERMAL_CAPS_##_name)
107 
111 int onlp_thermal_sw_init(void);
112 
117 int onlp_thermal_hw_init(uint32_t flags);
118 
125 int onlp_thermal_sw_denit(void);
126 
133 
140 
147 int onlp_thermal_info_to_json(onlp_thermal_info_t* info, cJSON** rv, uint32_t flags);
148 
149 
156 
164 int onlp_thermal_info_to_user_json(onlp_thermal_info_t* info, cJSON** rv, uint32_t flags);
165 
166 
167 
168 /******************************************************************************
169  *
170  * Enumeration Support Definitions.
171  *
172  * Please do not add additional code beyond this point.
173  *
174  *****************************************************************************/
175 /* <auto.start.enum(tag:thermal).supportheader> */
178 
180 int onlp_thermal_caps_value(const char* str, onlp_thermal_caps_t* e, int substr);
181 
184 
187 
189 #define ONLP_THERMAL_CAPS_VALID(_e) \
190  (onlp_thermal_caps_valid((_e)))
191 
193 extern aim_map_si_t onlp_thermal_caps_map[];
195 extern aim_map_si_t onlp_thermal_caps_desc_map[];
196 
199 
201 int onlp_thermal_threshold_value(const char* str, onlp_thermal_threshold_t* e, int substr);
202 
205 
208 
210 #define ONLP_THERMAL_THRESHOLD_VALID(_e) \
211  (onlp_thermal_threshold_valid((_e)))
212 
214 extern aim_map_si_t onlp_thermal_threshold_map[];
216 extern aim_map_si_t onlp_thermal_threshold_desc_map[];
217 /* <auto.end.enum(tag:thermal).supportheader> */
218 
219 #endif /* __ONLP_THERMAL_H__ */
220 /* @} */
onlp Configuration Header
int onlp_thermal_sw_init(void)
Software initialization of the thermal module.
Definition: thermal.h:76
onlp_thermal_caps_e
Definition: thermal.h:37
int onlp_thermal_caps_value(const char *str, onlp_thermal_caps_t *e, int substr)
int warning
Definition: thermal.h:90
aim_map_si_t onlp_thermal_caps_map[]
struct onlp_thermal_info_s::@1 thresholds
Object Identifiers.
uint32_t onlp_oid_t
Definition: oids.h:52
int onlp_thermal_sw_denit(void)
Deinitialize the thermal software module.
int error
Definition: thermal.h:93
uint32_t caps
Definition: thermal.h:82
const char * onlp_thermal_threshold_desc(onlp_thermal_threshold_t e)
const char * onlp_thermal_threshold_name(onlp_thermal_threshold_t e)
int onlp_thermal_threshold_valid(onlp_thermal_threshold_t e)
int onlp_thermal_info_get(onlp_oid_t oid, onlp_thermal_info_t *rv)
Retrieve information about the given thermal id.
onlp_thermal_threshold_e
Definition: thermal.h:45
int onlp_thermal_info_to_json(onlp_thermal_info_t *info, cJSON **rv, uint32_t flags)
Convert a thermal info structure to json.
int shutdown
Definition: thermal.h:96
onlp_oid_hdr_t hdr
Definition: thermal.h:79
const char * onlp_thermal_caps_name(onlp_thermal_caps_t e)
int onlp_thermal_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t *rv)
Retrieve the thermal&#39;s oid header.
int onlp_thermal_caps_valid(onlp_thermal_caps_t e)
int onlp_thermal_hw_init(uint32_t flags)
Hardware initialization of the thermal module.
aim_map_si_t onlp_thermal_threshold_desc_map[]
struct onlp_thermal_info_s onlp_thermal_info_t
enum onlp_thermal_caps_e onlp_thermal_caps_t
int onlp_thermal_info_to_user_json(onlp_thermal_info_t *info, cJSON **rv, uint32_t flags)
Convert a thermal info structure to user json.
enum onlp_thermal_threshold_e onlp_thermal_threshold_t
const char * onlp_thermal_caps_desc(onlp_thermal_caps_t e)
int mcelsius
Definition: thermal.h:85
int onlp_thermal_threshold_value(const char *str, onlp_thermal_threshold_t *e, int substr)
Definition: oids.h:296
aim_map_si_t onlp_thermal_threshold_map[]
int onlp_thermal_info_from_json(cJSON *cj, onlp_thermal_info_t *info)
Convert a JSON object to a thermal info structure.
aim_map_si_t onlp_thermal_caps_desc_map[]