xref: /illumos-gate/usr/src/cmd/picl/plugins/sun4v/snmp/snmpplugin.h (revision 8b80e8cb6855118d46f605e91b5ed4ce83417395)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * The /physical-platform node
38  */
39 #define	PICL_NODE_PHYSPLAT		"physical-platform"
40 
41 /*
42  * List of volatile property OIDs to lookup and update when needed
43  */
44 typedef struct {
45 	picl_prophdl_t  prop;
46 	char		*oidstr;
47 	int		row;
48 	int		proptype;
49 } vol_prophdl_t;
50 
51 /*
52  * Types of volatile properties (proptype values)
53  */
54 #define	VPT_PLATOPSTATE		1
55 #define	VPT_NUMSENSOR		2
56 #define	VPT_BINSENSOR		3
57 #define	VPT_ALARMSTATE		4
58 #define	VPT_BATTERYSTATUS	5
59 
60 /*
61  * Storage related and miscellaneous definitions
62  */
63 #define	N_ELEMS_IN_VOLPROP_BLOCK	512
64 #define	N_ELEMS_IN_NODE_BLOCK		256
65 #define	NODE_BLOCK_SHIFT		8
66 #define	DEFAULT_SLOT_TYPE		"slot"
67 
68 /*
69  * Local macros and property ids
70  */
71 #define	ADD_NODE(cl)							\
72 {									\
73 	if (ptree_create_and_add_node(parenth, node_name, cl,		\
74 	    &nodeh) != PICL_SUCCESS) {					\
75 		log_msg(LOG_ERR, SNMPP_ADD_NODE_FAIL, node_name, cl);	\
76 		return (NULL);						\
77 	}								\
78 }
79 
80 #define	CHECK_LINKRESET(errp, retval)		\
81 	if ((errp) && (*errp == ECANCELED)) {	\
82 		return (retval);		\
83 	}
84 
85 #define	CHECK_LINKRESET_VOID(errp)		\
86 	if ((errp) && (*errp == ECANCELED)) {	\
87 		return;				\
88 	}
89 
90 #define	min(x, y)	((x) < (y) ? (x) : (y))
91 
92 typedef enum {
93 	PP_SERIAL_NUM = 1,
94 	PP_SLOT_TYPE,
95 	PP_STATE,
96 	PP_OPSTATUS,
97 	PP_BATT_STATUS,
98 	PP_TEMPERATURE,
99 	PP_VOLTAGE,
100 	PP_CURRENT,
101 	PP_SPEED,
102 	PP_SENSOR_VALUE,
103 	PP_BASE_UNITS,
104 	PP_EXPONENT,
105 	PP_RATE_UNITS,
106 	PP_CONDITION,
107 	PP_EXPECTED,
108 	PP_REPLACEABLE,
109 	PP_HOTSWAPPABLE,
110 	PP_IS_FRU,
111 	PP_HW_REVISION,
112 	PP_FW_REVISION,
113 	PP_MFG_NAME,
114 	PP_MODEL_NAME,
115 	PP_DESCRIPTION,
116 	PP_LABEL
117 } sp_propid_t;
118 
119 /*
120  * Plugin global routines
121  */
122 void snmpplugin_init(void);
123 void snmpplugin_fini(void);
124 
125 /*
126  * Plugin messages
127  */
128 #define	SNMPP_NO_ROOT			\
129     gettext("PICL snmpplugin: cannot get picl tree root (ret=%d)\n")
130 
131 #define	SNMPP_CANT_INIT			\
132     gettext("PICL snmpplugin: cannot initialize snmp service\n")
133 
134 #define	SNMPP_CANT_CREATE_PHYSPLAT	\
135     gettext("PICL snmpplugin: cannot create physical-platform root (ret=%d)\n")
136 
137 #define	SNMPP_CANT_CREATE_TREE_BUILDER	\
138     gettext("PICL snmpplugin: cannot create thr to handle hotplugs (ret=%d)\n")
139 
140 #define	SNMPP_NO_ENTPHYSNAME		\
141     gettext("PICL snmpplugin: cannot get entPhysicalName (row=%d)\n")
142 
143 #define	SNMPP_ADD_NODE_FAIL		\
144     gettext("PICL snmpplugin: couldn't add node %s (class=%d)\n")
145 
146 #define	SNMPP_UNSUPP_SENSOR_CLASS	\
147     gettext("PICL snmpplugin: sunPlatSensorClass %d unsupported (row=%d)\n")
148 
149 #define	SNMPP_UNKNOWN_ENTPHYSCLASS	\
150     gettext("PICL snmpplugin: entPhysicalClass %d unknown (row=%d)\n")
151 
152 #define	SNMPP_NO_MEM			\
153     gettext("PICL snmpplugin: failed to allocate %d bytes\n")
154 
155 #define	SNMPP_CANT_FIND_VOLPROP		\
156     gettext("PICL snmpplugin: cannot find volatile property (proph=%lx)\n")
157 
158 #define	SNMPP_INV_PLAT_EQUIP_OPSTATE	\
159     gettext("PICL snmpplugin: invalid sunPlatEquipmentOpState %d (row=%d)\n")
160 
161 #define	SNMPP_INV_PLAT_BINSNSR_CURRENT	\
162     gettext("PICL snmpplugin: invalid sunPlatBinarySensorCurrent %d (row=%d)\n")
163 
164 #define	SNMPP_NO_SLOT_TYPE		\
165     gettext("PICL snmpplugin: no acceptable slot types (row=%d)\n")
166 
167 #define	SNMPP_CANT_INIT_PROPINFO	\
168     gettext("PICL snmpplugin: cannot init picl propinfo (err=%d)\n")
169 
170 #define	SNMPP_CANT_ADD_PROP		\
171     gettext("PICL snmpplugin: cannot add property, err=%d (node=%lx)\n")
172 
173 #define	SNMPP_CANT_INIT_STR_PROPINFO	\
174     gettext("PICL snmpplugin: cannot init picl str propinfo (err=%d)\n")
175 
176 #define	SNMPP_CANT_ADD_STR_PROP		\
177     gettext("PICL snmpplugin: cannot add string property (err=%d, node=%lx)\n")
178 
179 #define	SNMPP_CANT_INIT_VOID_PROPINFO	\
180     gettext("PICL snmpplugin: cannot init picl void propinfo (err=%d)\n")
181 
182 #define	SNMPP_CANT_ADD_VOID_PROP	\
183     gettext("PICL snmpplugin: cannot add void property (err=%d, node=%lx)\n")
184 
185 #define	SNMPP_CANT_INIT_INT_PROPINFO	\
186     gettext("PICL snmpplugin: cannot init picl int propinfo (err=%d)\n")
187 
188 #define	SNMPP_CANT_ADD_INT_PROP	\
189     gettext("PICL snmpplugin: cannot add int property (err=%d, node=%lx)\n")
190 
191 #define	SNMPP_CANT_FETCH_OBJECT_VAL	\
192     gettext("PICL snmpplugin: cannot fetch object value " \
193 	"(err=%d, OID=<%s>, row=%d)\n")
194 
195 #define	SNMPP_LINK_RESET	\
196     gettext("PICL snmpplugin: snmp ds reset happened, rebuilding tree\n")
197 
198 #ifdef SNMPPLUGIN_DEBUG
199 #define	SNMPPLUGIN_DBLOCK_SZ		4096
200 #define	SNMPPLUGIN_DMAX_LINE		80
201 #define	LOGINIT()			snmpplugin_log_init()
202 #define	LOGPRINTF(s)			snmpplugin_log(s)
203 #define	LOGPRINTF1(s, a1)		snmpplugin_log(s, a1)
204 #define	LOGPRINTF2(s, a1, a2)		snmpplugin_log(s, a1, a2)
205 #else
206 #define	LOGINIT()
207 #define	LOGPRINTF(s)
208 #define	LOGPRINTF1(s, a1)
209 #define	LOGPRINTF2(s, a1, a2)
210 #endif
211 
212 #ifdef	__cplusplus
213 }
214 #endif
215 
216 #endif	/* _SNMPPLUGIN_H */
217