xref: /titanic_50/usr/src/cmd/picl/plugins/sun4v/snmp/snmpplugin.h (revision 1da7e59911a9f3f267c3ef294dc342767dee7952)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SNMPPLUGIN_H
28 #define	_SNMPPLUGIN_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * The /physical-platform node
36  */
37 #define	PICL_NODE_PHYSPLAT		"physical-platform"
38 
39 /*
40  * List of volatile property OIDs to lookup and update when needed
41  */
42 typedef struct {
43 	picl_prophdl_t  prop;
44 	char		*oidstr;
45 	int		row;
46 	int		proptype;
47 } vol_prophdl_t;
48 
49 /*
50  * Types of volatile properties (proptype values)
51  */
52 #define	VPT_PLATOPSTATE		1
53 #define	VPT_NUMSENSOR		2
54 #define	VPT_BINSENSOR		3
55 #define	VPT_ALARMSTATE		4
56 #define	VPT_BATTERYSTATUS	5
57 
58 /*
59  * Storage related and miscellaneous definitions
60  */
61 #define	N_ELEMS_IN_VOLPROP_BLOCK	512
62 #define	N_ELEMS_IN_NODE_BLOCK		256
63 #define	NODE_BLOCK_SHIFT		8
64 #define	DEFAULT_SLOT_TYPE		"slot"
65 
66 /*
67  * Local macros and property ids
68  */
69 #define	ADD_NODE(cl)							\
70 {									\
71 	if (ptree_create_and_add_node(parenth, node_name, cl,		\
72 	    &nodeh) != PICL_SUCCESS) {					\
73 		log_msg(LOG_ERR, SNMPP_ADD_NODE_FAIL, node_name, cl);	\
74 		return (NULL);						\
75 	}								\
76 }
77 
78 #define	CHECK_LINKRESET(errp, retval)		\
79 	if ((errp) && (*errp == ECANCELED)) {	\
80 		return (retval);		\
81 	}
82 
83 #define	CHECK_LINKRESET_VOID(errp)		\
84 	if ((errp) && (*errp == ECANCELED)) {	\
85 		return;				\
86 	}
87 
88 #define	min(x, y)	((x) < (y) ? (x) : (y))
89 
90 typedef enum {
91 	PP_SERIAL_NUM = 1,
92 	PP_SLOT_TYPE,
93 	PP_STATE,
94 	PP_OPSTATUS,
95 	PP_BATT_STATUS,
96 	PP_TEMPERATURE,
97 	PP_VOLTAGE,
98 	PP_CURRENT,
99 	PP_SPEED,
100 	PP_SENSOR_VALUE,
101 	PP_BASE_UNITS,
102 	PP_EXPONENT,
103 	PP_RATE_UNITS,
104 	PP_CONDITION,
105 	PP_EXPECTED,
106 	PP_REPLACEABLE,
107 	PP_HOTSWAPPABLE,
108 	PP_IS_FRU,
109 	PP_HW_REVISION,
110 	PP_FW_REVISION,
111 	PP_MFG_NAME,
112 	PP_MODEL_NAME,
113 	PP_DESCRIPTION,
114 	PP_LABEL,
115 	PP_HUMIDITY
116 } sp_propid_t;
117 
118 /*
119  * Plugin global routines
120  */
121 void snmpplugin_init(void);
122 void snmpplugin_fini(void);
123 
124 /*
125  * Plugin messages
126  */
127 #define	SNMPP_NO_ROOT			\
128     gettext("PICL snmpplugin: cannot get picl tree root (ret=%d)\n")
129 
130 #define	SNMPP_CANT_INIT			\
131     gettext("PICL snmpplugin: cannot initialize snmp service\n")
132 
133 #define	SNMPP_CANT_CREATE_PHYSPLAT	\
134     gettext("PICL snmpplugin: cannot create physical-platform root (ret=%d)\n")
135 
136 #define	SNMPP_CANT_CREATE_TREE_BUILDER	\
137     gettext("PICL snmpplugin: cannot create thr to handle hotplugs (ret=%d)\n")
138 
139 #define	SNMPP_NO_ENTPHYSNAME		\
140     gettext("PICL snmpplugin: cannot get entPhysicalName (row=%d)\n")
141 
142 #define	SNMPP_ADD_NODE_FAIL		\
143     gettext("PICL snmpplugin: couldn't add node %s (class=%d)\n")
144 
145 #define	SNMPP_UNSUPP_SENSOR_CLASS	\
146     gettext("PICL snmpplugin: sunPlatSensorClass %d unsupported (row=%d)\n")
147 
148 #define	SNMPP_UNKNOWN_ENTPHYSCLASS	\
149     gettext("PICL snmpplugin: entPhysicalClass %d unknown (row=%d)\n")
150 
151 #define	SNMPP_NO_MEM			\
152     gettext("PICL snmpplugin: failed to allocate %d bytes\n")
153 
154 #define	SNMPP_CANT_FIND_VOLPROP		\
155     gettext("PICL snmpplugin: cannot find volatile property (proph=%lx)\n")
156 
157 #define	SNMPP_INV_PLAT_EQUIP_OPSTATE	\
158     gettext("PICL snmpplugin: invalid sunPlatEquipmentOpState %d (row=%d)\n")
159 
160 #define	SNMPP_INV_PLAT_BINSNSR_CURRENT	\
161     gettext("PICL snmpplugin: invalid sunPlatBinarySensorCurrent %d (row=%d)\n")
162 
163 #define	SNMPP_NO_SLOT_TYPE		\
164     gettext("PICL snmpplugin: no acceptable slot types (row=%d)\n")
165 
166 #define	SNMPP_CANT_INIT_PROPINFO	\
167     gettext("PICL snmpplugin: cannot init picl propinfo (err=%d)\n")
168 
169 #define	SNMPP_CANT_ADD_PROP		\
170     gettext("PICL snmpplugin: cannot add property, err=%d (node=%lx)\n")
171 
172 #define	SNMPP_CANT_INIT_STR_PROPINFO	\
173     gettext("PICL snmpplugin: cannot init picl str propinfo (err=%d)\n")
174 
175 #define	SNMPP_CANT_ADD_STR_PROP		\
176     gettext("PICL snmpplugin: cannot add string property (err=%d, node=%lx)\n")
177 
178 #define	SNMPP_CANT_INIT_VOID_PROPINFO	\
179     gettext("PICL snmpplugin: cannot init picl void propinfo (err=%d)\n")
180 
181 #define	SNMPP_CANT_ADD_VOID_PROP	\
182     gettext("PICL snmpplugin: cannot add void property (err=%d, node=%lx)\n")
183 
184 #define	SNMPP_CANT_INIT_INT_PROPINFO	\
185     gettext("PICL snmpplugin: cannot init picl int propinfo (err=%d)\n")
186 
187 #define	SNMPP_CANT_ADD_INT_PROP	\
188     gettext("PICL snmpplugin: cannot add int property (err=%d, node=%lx)\n")
189 
190 #define	SNMPP_CANT_FETCH_OBJECT_VAL	\
191     gettext("PICL snmpplugin: cannot fetch object value " \
192 	"(err=%d, OID=<%s>, row=%d)\n")
193 
194 #define	SNMPP_LINK_RESET	\
195     gettext("PICL snmpplugin: snmp ds reset happened, rebuilding tree\n")
196 
197 #ifdef SNMPPLUGIN_DEBUG
198 #define	SNMPPLUGIN_DBLOCK_SZ		4096
199 #define	SNMPPLUGIN_DMAX_LINE		80
200 #define	LOGINIT()			snmpplugin_log_init()
201 #define	LOGPRINTF(s)			snmpplugin_log(s)
202 #define	LOGPRINTF1(s, a1)		snmpplugin_log(s, a1)
203 #define	LOGPRINTF2(s, a1, a2)		snmpplugin_log(s, a1, a2)
204 #else
205 #define	LOGINIT()
206 #define	LOGPRINTF(s)
207 #define	LOGPRINTF1(s, a1)
208 #define	LOGPRINTF2(s, a1, a2)
209 #endif
210 
211 #ifdef	__cplusplus
212 }
213 #endif
214 
215 #endif	/* _SNMPPLUGIN_H */
216