1*03831d35Sstevel /*
2*03831d35Sstevel  * CDDL HEADER START
3*03831d35Sstevel  *
4*03831d35Sstevel  * The contents of this file are subject to the terms of the
5*03831d35Sstevel  * Common Development and Distribution License (the "License").
6*03831d35Sstevel  * You may not use this file except in compliance with the License.
7*03831d35Sstevel  *
8*03831d35Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*03831d35Sstevel  * or http://www.opensolaris.org/os/licensing.
10*03831d35Sstevel  * See the License for the specific language governing permissions
11*03831d35Sstevel  * and limitations under the License.
12*03831d35Sstevel  *
13*03831d35Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*03831d35Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*03831d35Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*03831d35Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*03831d35Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*03831d35Sstevel  *
19*03831d35Sstevel  * CDDL HEADER END
20*03831d35Sstevel  */
21*03831d35Sstevel 
22*03831d35Sstevel /*
23*03831d35Sstevel  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*03831d35Sstevel  * Use is subject to license terms.
25*03831d35Sstevel  */
26*03831d35Sstevel 
27*03831d35Sstevel #ifndef	_SYS_SGSBBC_MAILBOX_H
28*03831d35Sstevel #define	_SYS_SGSBBC_MAILBOX_H
29*03831d35Sstevel 
30*03831d35Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*03831d35Sstevel 
32*03831d35Sstevel #include <sys/sgsbbc.h>
33*03831d35Sstevel 
34*03831d35Sstevel #ifdef	__cplusplus
35*03831d35Sstevel extern "C" {
36*03831d35Sstevel #endif
37*03831d35Sstevel 
38*03831d35Sstevel /*
39*03831d35Sstevel  * Message types - one per client!
40*03831d35Sstevel  */
41*03831d35Sstevel #define	SBBC_BROADCAST_MSG		0x0
42*03831d35Sstevel #define	OBP_MBOX			0x1
43*03831d35Sstevel #define	DR_MBOX				0x2
44*03831d35Sstevel #define	WILDCAT_RSM_MBOX		0x3
45*03831d35Sstevel #define	SG_ENV				0x4	/* environmental data */
46*03831d35Sstevel #define	CPCI_MBOX			0x5
47*03831d35Sstevel #define	INFO_MBOX			0x6	/* for passing info to the SC */
48*03831d35Sstevel #define	SGFRU_MBOX			0x7	/* FRUID messages */
49*03831d35Sstevel #define	MBOX_EVENT_GENERIC		0x8
50*03831d35Sstevel #define	MBOX_EVENT_KEY_SWITCH		0x9
51*03831d35Sstevel #define	MBOX_EVENT_PANIC_SHUTDOWN	0xb
52*03831d35Sstevel #define	MBOX_EVENT_ENV			0xc
53*03831d35Sstevel #define	MBOX_EVENT_CPCI_ENUM		0xd
54*03831d35Sstevel #define	LW8_MBOX			0xe
55*03831d35Sstevel #define	MBOX_EVENT_LW8			0xf
56*03831d35Sstevel #define	MBOX_EVENT_DP_ERROR		0x10	/* datapath error */
57*03831d35Sstevel #define	MBOX_EVENT_DP_FAULT		0x11	/* datapath fault */
58*03831d35Sstevel 
59*03831d35Sstevel #ifdef	DEBUG
60*03831d35Sstevel #define	DBG_MBOX		0x1f	/* debug messages */
61*03831d35Sstevel #endif	/* DEBUG */
62*03831d35Sstevel 
63*03831d35Sstevel /*
64*03831d35Sstevel  * INFO_MBOX message sub-types
65*03831d35Sstevel  */
66*03831d35Sstevel #define	INFO_MBOX_NODENAME	0x6000	/* for passing nodename to SC */
67*03831d35Sstevel #define	INFO_MBOX_ERROR_NOTICE	0x6001	/* for logging ECC errors to SC */
68*03831d35Sstevel #define	INFO_MBOX_ERROR_ECC	0x6003	/* updated interface for logging */
69*03831d35Sstevel 					/* ECC errors to SC */
70*03831d35Sstevel #define	INFO_MBOX_ERROR_INDICT	0x6004	/* for logging ECC indictments to SC */
71*03831d35Sstevel #define	INFO_MBOX_ECC		0x6005	/* new interface for logging */
72*03831d35Sstevel #define	INFO_MBOX_ECC_CAP	0x6006	/* capability message */
73*03831d35Sstevel 
74*03831d35Sstevel /*
75*03831d35Sstevel  * Message status values returned by the SC to the various mailbox clients.
76*03831d35Sstevel  *
77*03831d35Sstevel  * These values need to be kept in sync with MailboxProtocol.java
78*03831d35Sstevel  * in the SCAPP source code.
79*03831d35Sstevel  */
80*03831d35Sstevel #define	SG_MBOX_STATUS_SUCCESS				0
81*03831d35Sstevel #define	SG_MBOX_STATUS_COMMAND_FAILURE			(-1)
82*03831d35Sstevel #define	SG_MBOX_STATUS_HARDWARE_FAILURE			(-2)
83*03831d35Sstevel #define	SG_MBOX_STATUS_ILLEGAL_PARAMETER		(-3)
84*03831d35Sstevel #define	SG_MBOX_STATUS_BOARD_ACCESS_DENIED		(-4)
85*03831d35Sstevel #define	SG_MBOX_STATUS_STALE_CONTENTS			(-5)
86*03831d35Sstevel #define	SG_MBOX_STATUS_STALE_OBJECT			(-6)
87*03831d35Sstevel #define	SG_MBOX_STATUS_NO_SEPROM_SPACE			(-7)
88*03831d35Sstevel #define	SG_MBOX_STATUS_NO_MEMORY			(-8)
89*03831d35Sstevel #define	SG_MBOX_STATUS_NOT_SUPPORTED			(-9)
90*03831d35Sstevel #define	SG_MBOX_STATUS_ILLEGAL_NODE			(-10)
91*03831d35Sstevel #define	SG_MBOX_STATUS_ILLEGAL_SLOT			(-11)
92*03831d35Sstevel 
93*03831d35Sstevel 
94*03831d35Sstevel /*
95*03831d35Sstevel  * Time out values in seconds.
96*03831d35Sstevel  *
97*03831d35Sstevel  * These definitions should not be used directly except by the
98*03831d35Sstevel  * sbbc_mbox_xxx_timeout variables. All clients should then use
99*03831d35Sstevel  * these variables to allow running kernels to modify wait times.
100*03831d35Sstevel  */
101*03831d35Sstevel #define	MBOX_MIN_TIMEOUT	1	/* min time to wait before timeout */
102*03831d35Sstevel #define	MBOX_DEFAULT_TIMEOUT	30	/* suggested wait time */
103*03831d35Sstevel 
104*03831d35Sstevel /*
105*03831d35Sstevel  * Timeout variables
106*03831d35Sstevel  */
107*03831d35Sstevel extern int	sbbc_mbox_min_timeout;		/* minimum wait time */
108*03831d35Sstevel extern int	sbbc_mbox_default_timeout;	/* suggested wait time */
109*03831d35Sstevel 
110*03831d35Sstevel 
111*03831d35Sstevel /*
112*03831d35Sstevel  * Message type consists of two parts
113*03831d35Sstevel  * type - client ID
114*03831d35Sstevel  * sub_type - client defined message type
115*03831d35Sstevel  */
116*03831d35Sstevel typedef struct {
117*03831d35Sstevel 	uint16_t	sub_type;
118*03831d35Sstevel 	uint16_t	type;
119*03831d35Sstevel } sbbc_msg_type_t;
120*03831d35Sstevel 
121*03831d35Sstevel /*
122*03831d35Sstevel  * this struct is used by client programs to request
123*03831d35Sstevel  * mailbox message services
124*03831d35Sstevel  */
125*03831d35Sstevel typedef struct sbbc_msg {
126*03831d35Sstevel 	sbbc_msg_type_t	msg_type;	/* message type */
127*03831d35Sstevel 	int	msg_status;		/* message return value */
128*03831d35Sstevel 	int	msg_len;		/* size of message buffer */
129*03831d35Sstevel 	int	msg_bytes;		/* number of bytes returned */
130*03831d35Sstevel 	caddr_t	msg_buf;		/* message buffer */
131*03831d35Sstevel 	int32_t	msg_data[2];		/* for junk mail */
132*03831d35Sstevel } sbbc_msg_t;
133*03831d35Sstevel 
134*03831d35Sstevel /*
135*03831d35Sstevel  * This data structure is used for queueing up ECC event mailbox
136*03831d35Sstevel  * messages through the SBBC taskq.
137*03831d35Sstevel  */
138*03831d35Sstevel 
139*03831d35Sstevel typedef struct sbbc_ecc_mbox {
140*03831d35Sstevel 	sbbc_msg_t	ecc_req;	/* request */
141*03831d35Sstevel 	sbbc_msg_t	ecc_resp;	/* response */
142*03831d35Sstevel 	int		ecc_log_error;	/* Log errors to /var/adm/messages */
143*03831d35Sstevel } sbbc_ecc_mbox_t;
144*03831d35Sstevel 
145*03831d35Sstevel /*
146*03831d35Sstevel  * ECC event mailbox taskq parameters
147*03831d35Sstevel  */
148*03831d35Sstevel #define	ECC_MBOX_TASKQ_MIN	2	/* minimum number of jobs */
149*03831d35Sstevel #define	ECC_MBOX_TASKQ_MAX	512	/* maximum number of jobs */
150*03831d35Sstevel 
151*03831d35Sstevel /*
152*03831d35Sstevel  * These are used to throttle error messages that may appear if
153*03831d35Sstevel  * the attempt to enqueue an ECC event message to the SC fails.
154*03831d35Sstevel  * If set to N > 0, then only every Nth message will be output.
155*03831d35Sstevel  * Set to 0 or 1 to disable this throttling and allow all error
156*03831d35Sstevel  * messages to appear.
157*03831d35Sstevel  *
158*03831d35Sstevel  * ECC_MBOX_TASKQ_ERR_THROTTLE is the default value for
159*03831d35Sstevel  * sbbc_ecc_mbox_err_throttle, which may be overridden in
160*03831d35Sstevel  * /etc/system or at run time via debugger.
161*03831d35Sstevel  */
162*03831d35Sstevel #define	ECC_MBOX_TASKQ_ERR_THROTTLE	64
163*03831d35Sstevel extern int	sbbc_ecc_mbox_err_throttle;
164*03831d35Sstevel 
165*03831d35Sstevel extern int	sbbc_mbox_reg_intr(uint32_t, sbbc_intrfunc_t,
166*03831d35Sstevel 		sbbc_msg_t *, uint_t *, kmutex_t *);
167*03831d35Sstevel extern int	sbbc_mbox_unreg_intr(uint32_t, sbbc_intrfunc_t);
168*03831d35Sstevel extern int	sbbc_mbox_request_response(sbbc_msg_t *,
169*03831d35Sstevel 		sbbc_msg_t *, time_t);
170*03831d35Sstevel 
171*03831d35Sstevel #ifdef	__cplusplus
172*03831d35Sstevel }
173*03831d35Sstevel #endif
174*03831d35Sstevel 
175*03831d35Sstevel #endif	/* _SYS_SGSBBC_MAILBOX_H */
176