ONLP
Open Network Linux Platform APIs
fan.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_FAN_H__
29 #define __ONLP_FAN_H__
30 
31 #include <onlp/oids.h>
32 #include <onlp/onlp.h>
33 
34 #include <BigList/biglist.h>
35 
36 /* <auto.start.enum(tag:fan).define> */
38 typedef enum onlp_fan_caps_e {
39  ONLP_FAN_CAPS_SET_DIR = (1 << 0),
40  ONLP_FAN_CAPS_GET_DIR = (1 << 1),
41  ONLP_FAN_CAPS_SET_RPM = (1 << 2),
42  ONLP_FAN_CAPS_SET_PERCENTAGE = (1 << 3),
43  ONLP_FAN_CAPS_GET_RPM = (1 << 4),
44  ONLP_FAN_CAPS_GET_PERCENTAGE = (1 << 5),
46 
48 typedef enum onlp_fan_dir_e {
49  ONLP_FAN_DIR_UNKNOWN,
50  ONLP_FAN_DIR_B2F,
51  ONLP_FAN_DIR_F2B,
52  ONLP_FAN_DIR_LAST = ONLP_FAN_DIR_F2B,
53  ONLP_FAN_DIR_COUNT,
54  ONLP_FAN_DIR_INVALID = -1,
56 /* <auto.end.enum(tag:fan).define> */
57 
61 typedef struct onlp_fan_info_s {
64 
67 
69  uint32_t caps;
70 
72  int rpm;
73 
76 
79 
82 
84 
88 #define ONLP_FAN_INFO_CAP_IS_SET(_pinfo, _name) \
89  ((_pinfo)->caps & ONLP_FAN_CAPS_##_name)
90 
94 int onlp_fan_sw_init(void);
95 
100 int onlp_fan_hw_init(uint32_t flags);
101 
108 int onlp_fan_sw_denit(void);
109 
116 
123 
129 int onlp_fan_caps_get(onlp_oid_t oid, uint32_t* caps);
130 
137 int onlp_fan_rpm_set(onlp_oid_t oid, int rpm);
138 
145 int onlp_fan_percentage_set(onlp_oid_t oid, int p);
146 
154 
161 int onlp_fan_info_to_user_json(onlp_fan_info_t* info, cJSON** cj,
162  uint32_t flags);
163 
170 int onlp_fan_info_to_json(onlp_fan_info_t* info, cJSON** cj, uint32_t flags);
171 
177 int onlp_fan_info_from_json(cJSON* cj, onlp_fan_info_t* info);
178 
179 
181 #define ONLP_FAN_STATUS_PRESENT(_fi) ((_fi).hdr.status & ONLP_OID_STATUS.PRESENT)
182 
184 #define ONLP_FAN_STATUS_MISSING(_fi) (!ONLP_FAN_INFO_PRESENT(_fi))
185 
187 #define ONLP_FAN_STATUS_FAILED(_fi) ( (_fi).hdr.status & ONLP_OID_STATUS.FAILED)
188 
190 #define ONLP_FAN_STATUS_NORMAL(_fi) ( ONLP_FAN_STATUS_PRESENT(_fi) && !ONLP_FAN_STATUS_FAILED(_fi) )
191 
192 
193 /******************************************************************************
194  *
195  * Enumeration Support Definitions.
196  *
197  * Please do not add additional code beyond this point.
198  *
199  *****************************************************************************/
200 /* <auto.start.enum(tag:fan).supportheader> */
202 const char* onlp_fan_caps_name(onlp_fan_caps_t e);
203 
205 int onlp_fan_caps_value(const char* str, onlp_fan_caps_t* e, int substr);
206 
208 const char* onlp_fan_caps_desc(onlp_fan_caps_t e);
209 
212 
214 #define ONLP_FAN_CAPS_VALID(_e) \
215  (onlp_fan_caps_valid((_e)))
216 
218 extern aim_map_si_t onlp_fan_caps_map[];
220 extern aim_map_si_t onlp_fan_caps_desc_map[];
221 
223 #define ONLP_FAN_DIR_STRINGS \
224 {\
225  "UNKNOWN", \
226  "B2F", \
227  "F2B", \
228 }
229 
230 const char* onlp_fan_dir_name(onlp_fan_dir_t e);
231 
233 int onlp_fan_dir_value(const char* str, onlp_fan_dir_t* e, int substr);
234 
236 const char* onlp_fan_dir_desc(onlp_fan_dir_t e);
237 
239 #define ONLP_FAN_DIR_VALID(_e) \
240  ( (0 <= (_e)) && ((_e) <= ONLP_FAN_DIR_F2B))
241 
243 extern aim_map_si_t onlp_fan_dir_map[];
245 extern aim_map_si_t onlp_fan_dir_desc_map[];
246 /* <auto.end.enum(tag:fan).supportheader> */
247 
248 
249 #endif /* __ONLP_FAN_H__ */
250 /* @} */
char serial[ONLP_CONFIG_INFO_STR_MAX]
Definition: fan.h:81
struct onlp_fan_info_s onlp_fan_info_t
enum onlp_fan_caps_e onlp_fan_caps_t
int onlp_fan_rpm_set(onlp_oid_t oid, int rpm)
Set the fan speed in RPMs.
int onlp_fan_info_get(onlp_oid_t oid, onlp_fan_info_t *rv)
Retrieve fan information.
onlp_oid_hdr_t hdr
Definition: fan.h:63
int onlp_fan_info_from_json(cJSON *cj, onlp_fan_info_t *info)
Convert a JSON object to a fan info structure.
Definition: fan.h:61
onlp_fan_dir_t dir
Definition: fan.h:66
Object Identifiers.
int percentage
Definition: fan.h:75
uint32_t onlp_oid_t
Definition: oids.h:52
const char * onlp_fan_caps_name(onlp_fan_caps_t e)
aim_map_si_t onlp_fan_caps_map[]
onlp_fan_dir_e
Definition: fan.h:48
int onlp_fan_dir_value(const char *str, onlp_fan_dir_t *e, int substr)
int onlp_fan_info_to_json(onlp_fan_info_t *info, cJSON **cj, uint32_t flags)
Convert a fan info structure to JSON.
int onlp_fan_info_to_user_json(onlp_fan_info_t *info, cJSON **cj, uint32_t flags)
Convert a fan info structure to user JSON.
int onlp_fan_sw_denit(void)
Deinitialize the fan software module.
int onlp_fan_caps_get(onlp_oid_t oid, uint32_t *caps)
Retrieve the fan capabilities.
#define ONLP_CONFIG_INFO_STR_MAX
Definition: onlp_config.h:218
int onlp_fan_sw_init(void)
Software Initialization of the Fan module.
onlp_fan_caps_e
Definition: fan.h:38
int onlp_fan_dir_set(onlp_oid_t oid, onlp_fan_dir_t dir)
Set the fan direction.
const char * onlp_fan_dir_desc(onlp_fan_dir_t e)
aim_map_si_t onlp_fan_dir_map[]
int onlp_fan_percentage_set(onlp_oid_t oid, int p)
Set the fan speed in percentage.
char model[ONLP_CONFIG_INFO_STR_MAX]
Definition: fan.h:78
enum onlp_fan_dir_e onlp_fan_dir_t
const char * onlp_fan_caps_desc(onlp_fan_caps_t e)
int onlp_fan_caps_value(const char *str, onlp_fan_caps_t *e, int substr)
uint32_t caps
Definition: fan.h:69
int onlp_fan_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t *hdr)
Retrieve the fan&#39;s OID hdr.
int onlp_fan_hw_init(uint32_t flags)
Hardware Initialization of the Fan module.
aim_map_si_t onlp_fan_dir_desc_map[]
Definition: oids.h:296
const char * onlp_fan_dir_name(onlp_fan_dir_t e)
aim_map_si_t onlp_fan_caps_desc_map[]
int rpm
Definition: fan.h:72
int onlp_fan_caps_valid(onlp_fan_caps_t e)