summaryrefslogtreecommitdiff
path: root/usr/src/cmd/picl/plugins/sun4v/snmp/snmpplugin.h
blob: 6454552b7abe0ad3e525209b74a3f4a2d5f35c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SNMPPLUGIN_H
#define	_SNMPPLUGIN_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The /physical-platform node
 */
#define	PICL_NODE_PHYSPLAT		"physical-platform"

/*
 * List of volatile property OIDs to lookup and update when needed
 */
typedef struct {
	picl_prophdl_t  prop;
	char		*oidstr;
	int		row;
	int		proptype;
} vol_prophdl_t;

/*
 * Types of volatile properties (proptype values)
 */
#define	VPT_PLATOPSTATE		1
#define	VPT_NUMSENSOR		2
#define	VPT_BINSENSOR		3
#define	VPT_ALARMSTATE		4
#define	VPT_BATTERYSTATUS	5

/*
 * Storage related and miscellaneous definitions
 */
#define	N_ELEMS_IN_VOLPROP_BLOCK	512
#define	N_ELEMS_IN_NODE_BLOCK		256
#define	NODE_BLOCK_SHIFT		8
#define	DEFAULT_SLOT_TYPE		"slot"

/*
 * Local macros and property ids
 */
#define	ADD_NODE(cl)							\
{									\
	if (ptree_create_and_add_node(parenth, node_name, cl,		\
	    &nodeh) != PICL_SUCCESS) {					\
		log_msg(LOG_ERR, SNMPP_ADD_NODE_FAIL, node_name, cl);	\
		return (0);						\
	}								\
}

#define	CHECK_LINKRESET(errp, retval)		\
	if ((errp) && (*errp == ECANCELED)) {	\
		return (retval);		\
	}

#define	CHECK_LINKRESET_VOID(errp)		\
	if ((errp) && (*errp == ECANCELED)) {	\
		return;				\
	}

#define	min(x, y)	((x) < (y) ? (x) : (y))

typedef enum {
	PP_SERIAL_NUM = 1,
	PP_SLOT_TYPE,
	PP_STATE,
	PP_OPSTATUS,
	PP_BATT_STATUS,
	PP_TEMPERATURE,
	PP_VOLTAGE,
	PP_CURRENT,
	PP_SPEED,
	PP_SENSOR_VALUE,
	PP_BASE_UNITS,
	PP_EXPONENT,
	PP_RATE_UNITS,
	PP_CONDITION,
	PP_EXPECTED,
	PP_REPLACEABLE,
	PP_HOTSWAPPABLE,
	PP_IS_FRU,
	PP_HW_REVISION,
	PP_FW_REVISION,
	PP_MFG_NAME,
	PP_MODEL_NAME,
	PP_DESCRIPTION,
	PP_LABEL
} sp_propid_t;

/*
 * Plugin global routines
 */
void snmpplugin_init(void);
void snmpplugin_fini(void);

/*
 * Plugin messages
 */
#define	SNMPP_NO_ROOT			\
    gettext("PICL snmpplugin: cannot get picl tree root (ret=%d)\n")

#define	SNMPP_CANT_INIT			\
    gettext("PICL snmpplugin: cannot initialize snmp service\n")

#define	SNMPP_CANT_CREATE_PHYSPLAT	\
    gettext("PICL snmpplugin: cannot create physical-platform root (ret=%d)\n")

#define	SNMPP_CANT_CREATE_TREE_BUILDER	\
    gettext("PICL snmpplugin: cannot create thr to handle hotplugs (ret=%d)\n")

#define	SNMPP_NO_ENTPHYSNAME		\
    gettext("PICL snmpplugin: cannot get entPhysicalName (row=%d)\n")

#define	SNMPP_ADD_NODE_FAIL		\
    gettext("PICL snmpplugin: couldn't add node %s (class=%d)\n")

#define	SNMPP_UNSUPP_SENSOR_CLASS	\
    gettext("PICL snmpplugin: sunPlatSensorClass %d unsupported (row=%d)\n")

#define	SNMPP_UNKNOWN_ENTPHYSCLASS	\
    gettext("PICL snmpplugin: entPhysicalClass %d unknown (row=%d)\n")

#define	SNMPP_NO_MEM			\
    gettext("PICL snmpplugin: failed to allocate %d bytes\n")

#define	SNMPP_CANT_FIND_VOLPROP		\
    gettext("PICL snmpplugin: cannot find volatile property (proph=%lx)\n")

#define	SNMPP_INV_PLAT_EQUIP_OPSTATE	\
    gettext("PICL snmpplugin: invalid sunPlatEquipmentOpState %d (row=%d)\n")

#define	SNMPP_INV_PLAT_BINSNSR_CURRENT	\
    gettext("PICL snmpplugin: invalid sunPlatBinarySensorCurrent %d (row=%d)\n")

#define	SNMPP_NO_SLOT_TYPE		\
    gettext("PICL snmpplugin: no acceptable slot types (row=%d)\n")

#define	SNMPP_CANT_INIT_PROPINFO	\
    gettext("PICL snmpplugin: cannot init picl propinfo (err=%d)\n")

#define	SNMPP_CANT_ADD_PROP		\
    gettext("PICL snmpplugin: cannot add property, err=%d (node=%lx)\n")

#define	SNMPP_CANT_INIT_STR_PROPINFO	\
    gettext("PICL snmpplugin: cannot init picl str propinfo (err=%d)\n")

#define	SNMPP_CANT_ADD_STR_PROP		\
    gettext("PICL snmpplugin: cannot add string property (err=%d, node=%lx)\n")

#define	SNMPP_CANT_INIT_VOID_PROPINFO	\
    gettext("PICL snmpplugin: cannot init picl void propinfo (err=%d)\n")

#define	SNMPP_CANT_ADD_VOID_PROP	\
    gettext("PICL snmpplugin: cannot add void property (err=%d, node=%lx)\n")

#define	SNMPP_CANT_INIT_INT_PROPINFO	\
    gettext("PICL snmpplugin: cannot init picl int propinfo (err=%d)\n")

#define	SNMPP_CANT_ADD_INT_PROP	\
    gettext("PICL snmpplugin: cannot add int property (err=%d, node=%lx)\n")

#define	SNMPP_CANT_FETCH_OBJECT_VAL	\
    gettext("PICL snmpplugin: cannot fetch object value " \
	"(err=%d, OID=<%s>, row=%d)\n")

#define	SNMPP_LINK_RESET	\
    gettext("PICL snmpplugin: snmp ds reset happened, rebuilding tree\n")

#define	SIGACT_FAILED	\
    gettext("PICL snmpplugin: Failed to install signal handler for %s: %s\n")

#ifdef SNMPPLUGIN_DEBUG
#define	SNMPPLUGIN_DBLOCK_SZ		4096
#define	SNMPPLUGIN_DMAX_LINE		80
#define	LOGINIT()			snmpplugin_log_init()
#define	LOGPRINTF(s)			snmpplugin_log(s)
#define	LOGPRINTF1(s, a1)		snmpplugin_log(s, a1)
#define	LOGPRINTF2(s, a1, a2)		snmpplugin_log(s, a1, a2)
#else
#define	LOGINIT()
#define	LOGPRINTF(s)
#define	LOGPRINTF1(s, a1)
#define	LOGPRINTF2(s, a1, a2)
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _SNMPPLUGIN_H */