xref: /illumos-gate/usr/src/cmd/picl/plugins/sun4v/snmp/snmpplugin.h (revision ada2da53edc6b7d3afbdff4975c5c32c01a7c72d)
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 2010 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 (0);						\
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 } sp_propid_t;
116 
117 /*
118  * Plugin global routines
119  */
120 void snmpplugin_init(void);
121 void snmpplugin_fini(void);
122 
123 /*
124  * Plugin messages
125  */
126 #define	SNMPP_NO_ROOT			\
127     gettext("PICL snmpplugin: cannot get picl tree root (ret=%d)\n")
128 
129 #define	SNMPP_CANT_INIT			\
130     gettext("PICL snmpplugin: cannot initialize snmp service\n")
131 
132 #define	SNMPP_CANT_CREATE_PHYSPLAT	\
133     gettext("PICL snmpplugin: cannot create physical-platform root (ret=%d)\n")
134 
135 #define	SNMPP_CANT_CREATE_TREE_BUILDER	\
136     gettext("PICL snmpplugin: cannot create thr to handle hotplugs (ret=%d)\n")
137 
138 #define	SNMPP_NO_ENTPHYSNAME		\
139     gettext("PICL snmpplugin: cannot get entPhysicalName (row=%d)\n")
140 
141 #define	SNMPP_ADD_NODE_FAIL		\
142     gettext("PICL snmpplugin: couldn't add node %s (class=%d)\n")
143 
144 #define	SNMPP_UNSUPP_SENSOR_CLASS	\
145     gettext("PICL snmpplugin: sunPlatSensorClass %d unsupported (row=%d)\n")
146 
147 #define	SNMPP_UNKNOWN_ENTPHYSCLASS	\
148     gettext("PICL snmpplugin: entPhysicalClass %d unknown (row=%d)\n")
149 
150 #define	SNMPP_NO_MEM			\
151     gettext("PICL snmpplugin: failed to allocate %d bytes\n")
152 
153 #define	SNMPP_CANT_FIND_VOLPROP		\
154     gettext("PICL snmpplugin: cannot find volatile property (proph=%lx)\n")
155 
156 #define	SNMPP_INV_PLAT_EQUIP_OPSTATE	\
157     gettext("PICL snmpplugin: invalid sunPlatEquipmentOpState %d (row=%d)\n")
158 
159 #define	SNMPP_INV_PLAT_BINSNSR_CURRENT	\
160     gettext("PICL snmpplugin: invalid sunPlatBinarySensorCurrent %d (row=%d)\n")
161 
162 #define	SNMPP_NO_SLOT_TYPE		\
163     gettext("PICL snmpplugin: no acceptable slot types (row=%d)\n")
164 
165 #define	SNMPP_CANT_INIT_PROPINFO	\
166     gettext("PICL snmpplugin: cannot init picl propinfo (err=%d)\n")
167 
168 #define	SNMPP_CANT_ADD_PROP		\
169     gettext("PICL snmpplugin: cannot add property, err=%d (node=%lx)\n")
170 
171 #define	SNMPP_CANT_INIT_STR_PROPINFO	\
172     gettext("PICL snmpplugin: cannot init picl str propinfo (err=%d)\n")
173 
174 #define	SNMPP_CANT_ADD_STR_PROP		\
175     gettext("PICL snmpplugin: cannot add string property (err=%d, node=%lx)\n")
176 
177 #define	SNMPP_CANT_INIT_VOID_PROPINFO	\
178     gettext("PICL snmpplugin: cannot init picl void propinfo (err=%d)\n")
179 
180 #define	SNMPP_CANT_ADD_VOID_PROP	\
181     gettext("PICL snmpplugin: cannot add void property (err=%d, node=%lx)\n")
182 
183 #define	SNMPP_CANT_INIT_INT_PROPINFO	\
184     gettext("PICL snmpplugin: cannot init picl int propinfo (err=%d)\n")
185 
186 #define	SNMPP_CANT_ADD_INT_PROP	\
187     gettext("PICL snmpplugin: cannot add int property (err=%d, node=%lx)\n")
188 
189 #define	SNMPP_CANT_FETCH_OBJECT_VAL	\
190     gettext("PICL snmpplugin: cannot fetch object value " \
191 	"(err=%d, OID=<%s>, row=%d)\n")
192 
193 #define	SNMPP_LINK_RESET	\
194     gettext("PICL snmpplugin: snmp ds reset happened, rebuilding tree\n")
195 
196 #define	SIGACT_FAILED	\
197     gettext("PICL snmpplugin: Failed to install signal handler for %s: %s\n")
198 
199 #ifdef SNMPPLUGIN_DEBUG
200 #define	SNMPPLUGIN_DBLOCK_SZ		4096
201 #define	SNMPPLUGIN_DMAX_LINE		80
202 #define	LOGINIT()			snmpplugin_log_init()
203 #define	LOGPRINTF(s)			snmpplugin_log(s)
204 #define	LOGPRINTF1(s, a1)		snmpplugin_log(s, a1)
205 #define	LOGPRINTF2(s, a1, a2)		snmpplugin_log(s, a1, a2)
206 #else
207 #define	LOGINIT()
208 #define	LOGPRINTF(s)
209 #define	LOGPRINTF1(s, a1)
210 #define	LOGPRINTF2(s, a1, a2)
211 #endif
212 
213 #ifdef	__cplusplus
214 }
215 #endif
216 
217 #endif	/* _SNMPPLUGIN_H */
218