ONLP
Open Network Linux Platform APIs
psu.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_PSU_H__
29 #define __ONLP_PSU_H__
30 
31 #include <onlp/onlp.h>
32 #include <onlp/oids.h>
33 
34 /* <auto.start.enum(tag:psu).define> */
36 typedef enum onlp_psu_caps_e {
37  ONLP_PSU_CAPS_GET_TYPE = (1 << 0),
38  ONLP_PSU_CAPS_GET_VIN = (1 << 1),
39  ONLP_PSU_CAPS_GET_VOUT = (1 << 2),
40  ONLP_PSU_CAPS_GET_IIN = (1 << 3),
41  ONLP_PSU_CAPS_GET_IOUT = (1 << 4),
42  ONLP_PSU_CAPS_GET_PIN = (1 << 5),
43  ONLP_PSU_CAPS_GET_POUT = (1 << 6),
45 
47 typedef enum onlp_psu_type_e {
48  ONLP_PSU_TYPE_AC,
49  ONLP_PSU_TYPE_DC12,
50  ONLP_PSU_TYPE_DC48,
51  ONLP_PSU_TYPE_LAST = ONLP_PSU_TYPE_DC48,
52  ONLP_PSU_TYPE_COUNT,
53  ONLP_PSU_TYPE_INVALID = -1,
55 /* <auto.end.enum(tag:psu).define> */
56 
57 
61 typedef struct onlp_psu_info_t {
64 
67 
70 
72  uint32_t caps;
73 
76 
78  int mvin;
79 
81  int mvout;
82 
84  int miin;
85 
87  int miout;
88 
90  int mpin;
91 
93  int mpout;
94 
96 
97 
101 #define ONLP_PSU_INFO_CAP_IS_SET(_pinfo, _name) \
102  ((_pinfo)->caps & ONLP_PSU_CAPS_##_name)
103 
107 int onlp_psu_sw_init(void);
108 
113 int onlp_psu_hw_init(uint32_t flags);
114 
121 int onlp_psu_sw_denit(void);
122 
129 
136 
143 int onlp_psu_info_to_user_json(onlp_psu_info_t* info, cJSON** cj, uint32_t flags);
144 
151 int onlp_psu_info_to_json(onlp_psu_info_t* info, cJSON** cj, uint32_t flags);
152 
158 int onlp_psu_info_from_json(cJSON* cj, onlp_psu_info_t* info);
159 
160 
162 #define ONLP_PSU_STATUS_PRESENT(_pi) ( (_pi).status & ONLP_PSU_STATUS_PRESENT )
163 
165 #define ONLP_PSU_STATUS_MISSING(_pi) (!ONLP_PSU_STATUS_PRESENT(_pi))
166 
168 #define ONLP_PSU_STATUS_FAILED(_pi) ( (_pi).status & ONLP_PSU_STATUS_FAILED)
169 
170 
171 
172 /******************************************************************************
173  *
174  * Enumeration Support Definitions.
175  *
176  * Please do not add additional code beyond this point.
177  *
178  *****************************************************************************/
179 /* <auto.start.enum(tag:psu).supportheader> */
181 const char* onlp_psu_caps_name(onlp_psu_caps_t e);
182 
184 int onlp_psu_caps_value(const char* str, onlp_psu_caps_t* e, int substr);
185 
187 const char* onlp_psu_caps_desc(onlp_psu_caps_t e);
188 
191 
193 #define ONLP_PSU_CAPS_VALID(_e) \
194  (onlp_psu_caps_valid((_e)))
195 
197 extern aim_map_si_t onlp_psu_caps_map[];
199 extern aim_map_si_t onlp_psu_caps_desc_map[];
200 
202 #define ONLP_PSU_TYPE_STRINGS \
203 {\
204  "AC", \
205  "DC12", \
206  "DC48", \
207 }
208 
209 const char* onlp_psu_type_name(onlp_psu_type_t e);
210 
212 int onlp_psu_type_value(const char* str, onlp_psu_type_t* e, int substr);
213 
215 const char* onlp_psu_type_desc(onlp_psu_type_t e);
216 
218 #define ONLP_PSU_TYPE_VALID(_e) \
219  ( (0 <= (_e)) && ((_e) <= ONLP_PSU_TYPE_DC48))
220 
222 extern aim_map_si_t onlp_psu_type_map[];
224 extern aim_map_si_t onlp_psu_type_desc_map[];
225 /* <auto.end.enum(tag:psu).supportheader> */
226 
227 #endif /* __ONLP_PSU_H__ */
228 /* @} */
aim_map_si_t onlp_psu_type_map[]
aim_map_si_t onlp_psu_caps_map[]
onlp_psu_type_e
Definition: psu.h:47
int mvout
Definition: psu.h:81
int onlp_psu_caps_value(const char *str, onlp_psu_caps_t *e, int substr)
int onlp_psu_sw_denit(void)
Deinitialize the psu software module.
char serial[ONLP_CONFIG_INFO_STR_MAX]
Definition: psu.h:69
onlp_psu_caps_e
Definition: psu.h:36
Object Identifiers.
uint32_t onlp_oid_t
Definition: oids.h:52
uint32_t caps
Definition: psu.h:72
enum onlp_psu_type_e onlp_psu_type_t
int mpin
Definition: psu.h:90
int onlp_psu_info_to_user_json(onlp_psu_info_t *info, cJSON **cj, uint32_t flags)
Convert a PSU info structure to user JSON.
int miin
Definition: psu.h:84
#define ONLP_CONFIG_INFO_STR_MAX
Definition: onlp_config.h:218
int onlp_psu_sw_init(void)
Software initialization of the PSU module.
enum onlp_psu_caps_e onlp_psu_caps_t
int onlp_psu_info_to_json(onlp_psu_info_t *info, cJSON **cj, uint32_t flags)
Convert a PSU info structure to JSON.
int onlp_psu_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t *rv)
Get the PSU&#39;s oid header.
int onlp_psu_caps_valid(onlp_psu_caps_t e)
const char * onlp_psu_caps_desc(onlp_psu_caps_t e)
int onlp_psu_hw_init(uint32_t flags)
Hardware initialization of the PSU module.
const char * onlp_psu_caps_name(onlp_psu_caps_t e)
const char * onlp_psu_type_name(onlp_psu_type_t e)
int onlp_psu_info_get(onlp_oid_t oid, onlp_psu_info_t *rv)
Get the PSU information.
const char * onlp_psu_type_desc(onlp_psu_type_t e)
int onlp_psu_type_value(const char *str, onlp_psu_type_t *e, int substr)
int miout
Definition: psu.h:87
Definition: psu.h:61
onlp_oid_hdr_t hdr
Definition: psu.h:63
onlp_psu_type_t type
Definition: psu.h:75
struct onlp_psu_info_t onlp_psu_info_t
int mvin
Definition: psu.h:78
aim_map_si_t onlp_psu_caps_desc_map[]
int onlp_psu_info_from_json(cJSON *cj, onlp_psu_info_t *info)
Convert a JSON object to a PSU info structure.
aim_map_si_t onlp_psu_type_desc_map[]
Definition: oids.h:296
char model[ONLP_CONFIG_INFO_STR_MAX]
Definition: psu.h:66
int mpout
Definition: psu.h:93