xref: /onnv-gate/usr/src/lib/cfgadm_plugins/sbd/common/ap.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_CFGA_SBD_H
28*0Sstevel@tonic-gate #define	_CFGA_SBD_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef __cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #define	DEVDIR	"/devices"
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #ifdef	SBD_DEBUG
39*0Sstevel@tonic-gate #define	DBG	dbg
40*0Sstevel@tonic-gate void dbg(char *, ...);
41*0Sstevel@tonic-gate #else
42*0Sstevel@tonic-gate #define	DBG
43*0Sstevel@tonic-gate #endif
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate typedef struct {
46*0Sstevel@tonic-gate 	int flags;
47*0Sstevel@tonic-gate 	int code;
48*0Sstevel@tonic-gate 	char *mid;
49*0Sstevel@tonic-gate 	char *platform;
50*0Sstevel@tonic-gate 	int skip;
51*0Sstevel@tonic-gate 	int err;
52*0Sstevel@tonic-gate } ap_opts_t;
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /*
55*0Sstevel@tonic-gate  * Command options.
56*0Sstevel@tonic-gate  *
57*0Sstevel@tonic-gate  * Some of the options are provided for testing purpose and
58*0Sstevel@tonic-gate  * will not published (e.g. err,code,mid).
59*0Sstevel@tonic-gate  */
60*0Sstevel@tonic-gate #define	OPT_UNASSIGN		0
61*0Sstevel@tonic-gate #define	OPT_SKIP		1
62*0Sstevel@tonic-gate #define	OPT_PARSABLE		2
63*0Sstevel@tonic-gate #define	OPT_NOPOWEROFF		3
64*0Sstevel@tonic-gate #define	OPT_CODE		4
65*0Sstevel@tonic-gate #define	OPT_MID			5
66*0Sstevel@tonic-gate #define	OPT_ERR			6
67*0Sstevel@tonic-gate #define	OPT_PLATFORM		7
68*0Sstevel@tonic-gate #define	OPT_SIM			8
69*0Sstevel@tonic-gate #define	OPT_SUSPEND_OK		9
70*0Sstevel@tonic-gate #define	OPT_LIST_ALL		29
71*0Sstevel@tonic-gate #define	OPT_FORCE		30
72*0Sstevel@tonic-gate #define	OPT_VERBOSE		31
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate #define	ap_getopt(a, o)	((a)->opts.flags &  ((uint_t)1 << (o)))
75*0Sstevel@tonic-gate #define	ap_setopt(a, o)	((a)->opts.flags |= ((uint_t)1 << (o)))
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate typedef enum {
78*0Sstevel@tonic-gate 	AP_NONE = 0,
79*0Sstevel@tonic-gate 	AP_BOARD,
80*0Sstevel@tonic-gate 	AP_CPU,
81*0Sstevel@tonic-gate 	AP_MEM,
82*0Sstevel@tonic-gate 	AP_IO,
83*0Sstevel@tonic-gate 	AP_CMP
84*0Sstevel@tonic-gate } ap_target_t;
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate #define	AP_NCLASS	6
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /*
89*0Sstevel@tonic-gate  * Attachment point descriptor.
90*0Sstevel@tonic-gate  *
91*0Sstevel@tonic-gate  * All commands are processed as follows:
92*0Sstevel@tonic-gate  *
93*0Sstevel@tonic-gate  * . allocate a command descriptor
94*0Sstevel@tonic-gate  * . parse the physical ap_id
95*0Sstevel@tonic-gate  * . parse the command and its options.
96*0Sstevel@tonic-gate  * . sequence if necessary (state change commands)
97*0Sstevel@tonic-gate  * . execute
98*0Sstevel@tonic-gate  *
99*0Sstevel@tonic-gate  */
100*0Sstevel@tonic-gate typedef struct {
101*0Sstevel@tonic-gate 	int fd;
102*0Sstevel@tonic-gate 	int bnum;
103*0Sstevel@tonic-gate 	int cnum;
104*0Sstevel@tonic-gate 	int ncm;
105*0Sstevel@tonic-gate 	int inst;
106*0Sstevel@tonic-gate 	int norcm;
107*0Sstevel@tonic-gate 	int statonly;
108*0Sstevel@tonic-gate 	const char *class;
109*0Sstevel@tonic-gate 	const char *apid;
110*0Sstevel@tonic-gate 	char *drv;
111*0Sstevel@tonic-gate 	char *path;
112*0Sstevel@tonic-gate 	char *target;
113*0Sstevel@tonic-gate 	char *minor;
114*0Sstevel@tonic-gate 	char *cid;
115*0Sstevel@tonic-gate 	char *cname;
116*0Sstevel@tonic-gate 	char *options;
117*0Sstevel@tonic-gate 	char **errstring;
118*0Sstevel@tonic-gate 	ap_opts_t opts;
119*0Sstevel@tonic-gate 	ap_target_t tgt;
120*0Sstevel@tonic-gate 	struct cfga_msg *msgp;
121*0Sstevel@tonic-gate 	struct cfga_confirm *confp;
122*0Sstevel@tonic-gate 	void *ctl;
123*0Sstevel@tonic-gate 	void *stat;
124*0Sstevel@tonic-gate 	void *cmstat;
125*0Sstevel@tonic-gate 	void *rcm;
126*0Sstevel@tonic-gate } apd_t;
127*0Sstevel@tonic-gate 
128*0Sstevel@tonic-gate /*
129*0Sstevel@tonic-gate  * Command definitions.
130*0Sstevel@tonic-gate  *
131*0Sstevel@tonic-gate  * The command order is significant.  The sequenced (-c) commands
132*0Sstevel@tonic-gate  * are sorted in execution order. The configure command starts from
133*0Sstevel@tonic-gate  * assign and ends with online.  The disconnect command starts
134*0Sstevel@tonic-gate  * from offline and goes to unassign.  Steps in the sequencing may
135*0Sstevel@tonic-gate  * be optionally skipped.
136*0Sstevel@tonic-gate  */
137*0Sstevel@tonic-gate #define	CMD_ASSIGN		0
138*0Sstevel@tonic-gate #define	CMD_POWERON		1
139*0Sstevel@tonic-gate #define	CMD_TEST		2
140*0Sstevel@tonic-gate #define	CMD_CONNECT		3
141*0Sstevel@tonic-gate #define	CMD_CONFIGURE		4
142*0Sstevel@tonic-gate #define	CMD_RCM_ONLINE		5
143*0Sstevel@tonic-gate #define	CMD_RCM_CAP_ADD		6
144*0Sstevel@tonic-gate #define	CMD_SUSPEND_CHECK	7
145*0Sstevel@tonic-gate #define	CMD_RCM_SUSPEND		8
146*0Sstevel@tonic-gate #define	CMD_RCM_CAP_DEL		9
147*0Sstevel@tonic-gate #define	CMD_RCM_OFFLINE		10
148*0Sstevel@tonic-gate #define	CMD_UNCONFIGURE		11
149*0Sstevel@tonic-gate #define	CMD_RCM_REMOVE		12
150*0Sstevel@tonic-gate #define	CMD_RCM_CAP_NOTIFY	13
151*0Sstevel@tonic-gate #define	CMD_DISCONNECT		14
152*0Sstevel@tonic-gate #define	CMD_POWEROFF		15
153*0Sstevel@tonic-gate #define	CMD_UNASSIGN		16
154*0Sstevel@tonic-gate #define	CMD_RCM_RESUME		17
155*0Sstevel@tonic-gate #define	CMD_STATUS		18
156*0Sstevel@tonic-gate #define	CMD_GETNCM		19
157*0Sstevel@tonic-gate #define	CMD_PASSTHRU		20
158*0Sstevel@tonic-gate #define	CMD_HELP		21
159*0Sstevel@tonic-gate #define	CMD_ERRTEST		22
160*0Sstevel@tonic-gate #define	CMD_NONE		23
161*0Sstevel@tonic-gate 
162*0Sstevel@tonic-gate /*
163*0Sstevel@tonic-gate  * Error messages.
164*0Sstevel@tonic-gate  */
165*0Sstevel@tonic-gate #define	ERR_CMD_INVAL		0
166*0Sstevel@tonic-gate #define	ERR_CMD_FAIL		1
167*0Sstevel@tonic-gate #define	ERR_CMD_NACK		2
168*0Sstevel@tonic-gate #define	ERR_CMD_NOTSUPP		3
169*0Sstevel@tonic-gate #define	ERR_CMD_ABORT		4
170*0Sstevel@tonic-gate #define	ERR_OPT_INVAL		5
171*0Sstevel@tonic-gate #define	ERR_OPT_NOVAL		6
172*0Sstevel@tonic-gate #define	ERR_OPT_VAL		7
173*0Sstevel@tonic-gate #define	ERR_OPT_BADVAL		8
174*0Sstevel@tonic-gate #define	ERR_AP_INVAL		9
175*0Sstevel@tonic-gate #define	ERR_CM_INVAL		10
176*0Sstevel@tonic-gate #define	ERR_TRANS_INVAL		11
177*0Sstevel@tonic-gate #define	ERR_SIG_CHANGE		12
178*0Sstevel@tonic-gate #define	ERR_RCM_HANDLE		13
179*0Sstevel@tonic-gate #define	ERR_RCM_CMD		14
180*0Sstevel@tonic-gate #define	ERR_RCM_INFO		15
181*0Sstevel@tonic-gate #define	ERR_LIB_OPEN		16
182*0Sstevel@tonic-gate #define	ERR_LIB_SYM		17
183*0Sstevel@tonic-gate #define	ERR_STAT		18
184*0Sstevel@tonic-gate #define	ERR_NOMEM		19
185*0Sstevel@tonic-gate #define	ERR_PLUGIN		20
186*0Sstevel@tonic-gate #define	ERR_NONE		21
187*0Sstevel@tonic-gate 
188*0Sstevel@tonic-gate #define	MSG_ISSUE		0
189*0Sstevel@tonic-gate #define	MSG_SKIP		1
190*0Sstevel@tonic-gate #define	MSG_SUSPEND		2
191*0Sstevel@tonic-gate #define	MSG_ABORT		3
192*0Sstevel@tonic-gate #define	MSG_DONE		4
193*0Sstevel@tonic-gate #define	MSG_FAIL		5
194*0Sstevel@tonic-gate #define	MSG_NORCM		6
195*0Sstevel@tonic-gate #define	MSG_NONE		7
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate #define	s_free(x)	(((x) != NULL) ? (free(x), (x) = NULL) : (void *)0)
198*0Sstevel@tonic-gate #define	str_valid(p)	((p) != NULL && *(p) != '\0')
199*0Sstevel@tonic-gate #define	mask(x)		((uint_t)1 << (x))
200*0Sstevel@tonic-gate 
201*0Sstevel@tonic-gate #define	CM_DFLT		-1	/* default (current) component */
202*0Sstevel@tonic-gate 
203*0Sstevel@tonic-gate int ap_cnt(apd_t *);
204*0Sstevel@tonic-gate int ap_parse(apd_t *, const char *);
205*0Sstevel@tonic-gate int ap_confirm(apd_t *);
206*0Sstevel@tonic-gate int ap_state_cmd(cfga_cmd_t, int *);
207*0Sstevel@tonic-gate int ap_symid(apd_t *, char *, char *, size_t);
208*0Sstevel@tonic-gate char *ap_sys_err(apd_t *, char **);
209*0Sstevel@tonic-gate char *ap_cmd_name(int);
210*0Sstevel@tonic-gate char *ap_opt_name(int);
211*0Sstevel@tonic-gate char *ap_logid(apd_t *, char *);
212*0Sstevel@tonic-gate void ap_err(apd_t *, ...);
213*0Sstevel@tonic-gate void ap_msg(apd_t *, ...);
214*0Sstevel@tonic-gate void ap_info(apd_t *, cfga_info_t, ap_target_t);
215*0Sstevel@tonic-gate void ap_init(apd_t *, cfga_list_data_t *);
216*0Sstevel@tonic-gate void ap_state(apd_t *, cfga_stat_t *, cfga_stat_t *);
217*0Sstevel@tonic-gate cfga_err_t ap_stat(apd_t *a, int);
218*0Sstevel@tonic-gate cfga_err_t ap_ioctl(apd_t *, int);
219*0Sstevel@tonic-gate cfga_err_t ap_help(struct cfga_msg *, const char *, cfga_flags_t);
220*0Sstevel@tonic-gate cfga_err_t ap_cmd_exec(apd_t *, int);
221*0Sstevel@tonic-gate cfga_err_t ap_cmd_seq(apd_t *, int);
222*0Sstevel@tonic-gate cfga_err_t ap_suspend_query(apd_t *, int, int *);
223*0Sstevel@tonic-gate cfga_err_t ap_platopts_check(apd_t *, int, int);
224*0Sstevel@tonic-gate cfga_err_t ap_cmd_parse(apd_t *, const char *, const char *, int *);
225*0Sstevel@tonic-gate cfga_err_t ap_test_err(apd_t *, const char *);
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate int ap_cm_capacity(apd_t *, int, void *, int *, cfga_stat_t *);
228*0Sstevel@tonic-gate int ap_cm_ncap(apd_t *, int);
229*0Sstevel@tonic-gate void ap_cm_id(apd_t *, int, char *, size_t);
230*0Sstevel@tonic-gate void ap_cm_init(apd_t *, cfga_list_data_t *, int);
231*0Sstevel@tonic-gate char *ap_cm_devpath(apd_t *, int);
232*0Sstevel@tonic-gate ap_target_t ap_cm_type(apd_t *, int);
233*0Sstevel@tonic-gate 
234*0Sstevel@tonic-gate cfga_err_t ap_rcm_init(apd_t *);
235*0Sstevel@tonic-gate void ap_rcm_fini(apd_t *);
236*0Sstevel@tonic-gate cfga_err_t ap_rcm_ctl(apd_t *, int);
237*0Sstevel@tonic-gate int ap_rcm_info(apd_t *, char **);
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate apd_t *apd_alloc(const char *, cfga_flags_t, char **,
240*0Sstevel@tonic-gate 	struct cfga_msg *, struct cfga_confirm *);
241*0Sstevel@tonic-gate void apd_free(apd_t *a);
242*0Sstevel@tonic-gate cfga_err_t apd_init(apd_t *, int);
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate int debugging();
245*0Sstevel@tonic-gate 
246*0Sstevel@tonic-gate #ifdef __cplusplus
247*0Sstevel@tonic-gate }
248*0Sstevel@tonic-gate #endif
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate #endif	/* _CFGA_SBD_H */
251