xref: /titanic_50/usr/src/uts/sun4u/starfire/sys/idn_sigb.h (revision 7ff178cd8db129d385d3177eb20744d3b6efc59b)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  *
26  * Inter-Domain Network Sigblock Interface.
27  *
28  * ******************************************************
29  * ******************************************************
30  * IMPORTANT:	THE DEFINITIONS HERE ARE DUPLICATES OF
31  *		THE cbe_idn_sigb.h FILE IN cbe/cbutils.
32  *		ANY CHANGES THERE MUST BE RELECTED
33  *		HERE AND VICE VERSA.  WE CANNOT INCLUDE
34  *		THIS HEADER IN THE BUILD OF CBE.
35  * ******************************************************
36  * ******************************************************
37  */
38 
39 #ifndef _SYS_IDN_SIGB_H
40 #define	_SYS_IDN_SIGB_H
41 
42 #pragma ident	"%Z%%M%	%I%	%E% SMI"
43 
44 #include <sys/types.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #ifdef _SSP
51 #include <domain_config.h>
52 #include <sigblock.h>
53 #define	_MAX_DOMAINS	MAX_DOMAINS_PER_MACH
54 #else /* _SSP */
55 #include <sys/starfire.h>
56 #include <sys/cpu_sgnblk_defs.h>
57 #include <sys/cpu_sgn.h>
58 #define	MAX_BOARDS	STARFIRE_MAX_BOARDS
59 #define	MAX_DOMAINS	MAX_BOARDS
60 #define	_MAX_DOMAINS	MAX_DOMAINS
61 #endif /* _SSP */
62 
63 #define	SSI_LINK	(('I' << 8) | 0x01)
64 #define	SSI_UNLINK	(('I' << 8) | 0x02)
65 #define	SSI_INFO	(('I' << 8) | 0x03)
66 #define	SSI_ACK		0x10
67 
68 #define	VALID_IDNSIGBCMD(c)	((((c) & ~SSI_ACK) == SSI_LINK) || \
69 				(((c) & ~SSI_ACK) == SSI_UNLINK) || \
70 				(((c) & ~SSI_ACK) == SSI_INFO))
71 
72 /*
73  * SSI_LINK
74  * timeout field must be first.
75  */
76 typedef struct {
77 	int32_t		timeout;	/* seconds */
78 	int32_t		cpuid;
79 	int32_t		domid;
80 	int32_t		master_pri;
81 } idnsb_link_t;
82 
83 
84 /*
85  * SSI_UNLINK
86  * timeout field must be first.
87  *
88  * If both cpuid and domid are specified then they must match the
89  * correct domain from the local domain's perspective.  The cpuid
90  * and/or domid have precedence over the boardset parameter.
91  * The boardset parameter is provided if the caller is unable to
92  * determine the cpuid/domid of the target domain.  This may happen
93  * if the target domain is currently down.
94  *
95  * idnsb_unlink_t.force values.
96  */
97 #define	SSIFORCE_OFF	0
98 #define	SSIFORCE_SOFT	1
99 #define	SSIFORCE_HARD	2
100 
101 typedef struct {
102 	int32_t		timeout;	/* seconds */
103 	int32_t		cpuid;
104 	int32_t		domid;
105 	ushort_t	boardset;
106 	short		force;
107 	ushort_t	idnset;
108 } idnsb_unlink_t;
109 
110 
111 /*
112  * SSI_INFO
113  *	Assumes max of 16 boards/domain.
114  *
115  * idnsb_info_t.idn_active values.
116  */
117 #define	SSISTATE_INACTIVE	0
118 #define	SSISTATE_BUSY		1
119 #define	SSISTATE_ACTIVE		2
120 
121 typedef struct {
122 	ushort_t	domain_boardset[_MAX_DOMAINS];
123 	uchar_t		idn_active;
124 	uchar_t		idn_state;	/* same as GSTATE */
125 	uchar_t		local_index;
126 	uchar_t		local_cpuid;
127 	uchar_t		master_index;
128 	uchar_t		master_cpuid;
129 	ushort_t	awol_domset;
130 	ushort_t	conn_domset;
131 	ushort_t	_filler;
132 } idnsb_info_t;
133 
134 #define	INIT_IDNKERR(ep) \
135 		(bzero((caddr_t)(ep), sizeof (idnsb_error_t)))
136 #define	SET_IDNKERR_ERRNO(ep, err)	((ep)->k_errno = (int)(err))
137 #define	SET_IDNKERR_IDNERR(ep, err)	((ep)->k_idnerr = (int)(err))
138 #define	SET_IDNKERR_PARAM0(ep, p0)	((ep)->k_param[0] = (uint_t)(p0))
139 #define	SET_IDNKERR_PARAM1(ep, p1)	((ep)->k_param[1] = (uint_t)(p1))
140 #define	SET_IDNKERR_PARAM2(ep, p2)	((ep)->k_param[2] = (uint_t)(p2))
141 #define	GET_IDNKERR_ERRNO(ep)		((ep)->k_errno)
142 #define	GET_IDNKERR_IDNERR(ep)		((ep)->k_idnerr)
143 #define	GET_IDNKERR_PARAM0(ep)		((ep)->k_param[0])
144 #define	GET_IDNKERR_PARAM1(ep)		((ep)->k_param[1])
145 #define	GET_IDNKERR_PARAM2(ep)		((ep)->k_param[2])
146 
147 #define	IDNKERR_DRV_DISABLED	0x100	/* IDN driver disabled */
148 					/* param=none */
149 #define	IDNKERR_DATA_LEN	0x101	/* invalid length of idnsb_data_t */
150 					/* p0=length */
151 #define	IDNKERR_INFO_FAILED	0x102	/* SSI_INFO failed */
152 					/* param=none */
153 #define	IDNKERR_INVALID_DOMAIN	0x103	/* invalid domain specified */
154 					/* p0=domid, p1=cpuid */
155 #define	IDNKERR_INVALID_FORCE	0x104	/* invalid force option specified */
156 					/* p0=force */
157 #define	IDNKERR_INVALID_CMD	0x105	/* invalid IDN/SSI command req */
158 					/* p0=cmd */
159 #define	IDNKERR_INVALID_WTIME	0x106	/* invalid waittime specified */
160 					/* p0=waittime */
161 #define	IDNKERR_SMR_CORRUPTED	0x107	/* SMR memory is corrupted */
162 					/* p0=domid (against who detected) */
163 #define	IDNKERR_CPU_CONFIG	0x108	/* missing a cpu per board */
164 					/* p0=domid */
165 #define	IDNKERR_HW_ERROR	0x109	/* error programming hardware */
166 					/* p0=domid */
167 #define	IDNKERR_SIGBINTR_LOCKED	0x10a	/* sigbintr is locked */
168 #define	IDNKERR_SIGBINTR_BUSY	0x10b	/* sigbintr is busy working */
169 #define	IDNKERR_SIGBINTR_NOTRDY	0x10c	/* sigbintr thread not ready */
170 #define	IDNKERR_CONFIG_FATAL	0x10d	/* fatal error during config */
171 #define	IDNKERR_CONFIG_MULTIPLE	0x10e	/* multiple config conflicts */
172 					/* p0=domid, p1=count */
173 	/*
174 	 * For all CONFIG errors:
175 	 *	p0=domid, p1=expected, p2=actual.
176 	 */
177 #define	IDNKERR_CONFIG_MTU	0x10f	/* MTU configs conflict */
178 #define	IDNKERR_CONFIG_BUF	0x110	/* SMR_BUF_SIZE conflicts */
179 #define	IDNKERR_CONFIG_SLAB	0x111	/* slab-size conflicts */
180 #define	IDNKERR_CONFIG_NWR	0x112	/* NWR sizes conflict */
181 #define	IDNKERR_CONFIG_NETS	0x113	/* MAX_NETS conflict */
182 #define	IDNKERR_CONFIG_MBOX	0x114	/* MBOX_PER_NETS conflict */
183 #define	IDNKERR_CONFIG_NMCADR	0x115	/* Number of MCADRS conflicts */
184 #define	IDNKERR_CONFIG_MCADR	0x116	/* Missing MCADR */
185 #define	IDNKERR_CONFIG_CKSUM	0x117	/* checksum setting conflicts */
186 #define	IDNKERR_CONFIG_SMR	0x118	/* master's SMR too large */
187 
188 typedef struct {
189 	int		k_errno;
190 	int		k_idnerr;
191 	uint_t		k_param[3];
192 } idnsb_error_t;
193 
194 typedef struct {
195 	union {
196 		int		_ssb_timeout;	/* link & unlink only (secs) */
197 		idnsb_link_t	_ssb_link;
198 		idnsb_unlink_t	_ssb_unlink;
199 		idnsb_info_t	_ssb_info;
200 	} _u;
201 	idnsb_error_t	ssb_error;
202 } idnsb_data_t;
203 
204 #define	ssb_timeout	_u._ssb_timeout
205 #define	ssb_link	_u._ssb_link
206 #define	ssb_unlink	_u._ssb_unlink
207 #define	ssb_info	_u._ssb_info
208 
209 
210 /*
211  * Boot information set by IDN driver when loaded.
212  * SSIEVENT_BOOT Indicates IDN driver is ready for linking.
213  *		 If this nibble is cleared (0) it
214  *		 indicates domain has halted.
215  * SSIEVENT_AWOL Indicates local IDN has reported
216  *		 some domains (boards) have gone AWOL.
217  * (event_handled) is primarily used by SSP/CB applications for
218  * synchronization with respect to handling event triggered in (event).
219  * The respective bits from (event) are set in (event_handled)
220  * when the event has been successfully processed by IDNevent(SSP).
221  * It is cleared by CBE based TCL scripts (mon_signatures.tcl, idn.tcl)
222  * when event is detected and needs processing.
223  * SSIEVENT_VERSION represents the version of the SSP side of
224  * the IDN software.  While idnsb_event_t.version represents the
225  * version of the OS side of the IDN software.
226  *
227  * Protocol:	Host				SSP
228  *		----				---
229  *		event
230  *		- 1 -> evt[].e_handled
231  *		- X -> evt[].e_event
232  *		- Y -> evt[].e_event_data
233  *		- 0 -> evt[].e_handled
234  *					(!evt[].e_handled)
235  *					...process(evt[].e_event)
236  *					- evt[].e_handled_data =
237  *							evt[].e_event_data
238  *					- evt[].e_handled = 1
239  */
240 #define	SSIEVENT_COOKIE		"IDN"
241 #define	SSIEVENT_COOKIE_LEN	3
242 #define	SSIEVENT_VERSION	1
243 
244 #define	SSIEVENT_BOOT		0	/* index to evt[] */
245 #define	_SSIEVENT_BOOT_VAL	0xb
246 #define	_SSIEVENT_BOOT_SHIFT	(SSIEVENT_BOOT << 2)
247 #define	_SSIEVENT_BOOT_MASK	(_SSIEVENT_BOOT_VAL << _SSIEVENT_BOOT_SHIFT)
248 
249 #define	SSIEVENT_AWOL		1
250 #define	_SSIEVENT_AWOL_VAL	0xa
251 #define	_SSIEVENT_AWOL_SHIFT	(SSIEVENT_AWOL << 2)
252 #define	_SSIEVENT_AWOL_MASK	(_SSIEVENT_AWOL_VAL << _SSIEVENT_AWOL_SHIFT)
253 
254 #define	SSIEVENT_NUM		2	/* actual max simultaneous events */
255 #define	SSIEVENT_MAXNUM		3	/* last one in reserve */
256 
257 #define	_SSIEVENT_VALUE(i) \
258 	((i == 0) ? _SSIEVENT_BOOT_VAL : ((i == 1) ? _SSIEVENT_AWOL_VAL : 0))
259 
260 #define	_SSIEVENT_MASKS(i) \
261 	((i == 0) ? _SSIEVENT_BOOT_MASK : ((i == 1) ? _SSIEVENT_AWOL_MASK : 0))
262 /*
263  * Get a bitmask of the current "state".
264  */
265 #define	SSIEVENT_GET_STATE_MASK(s) \
266 	(((s).idn_evt[SSIEVENT_BOOT].e_event ? _SSIEVENT_BOOT_MASK : 0) \
267 	| ((s).idn_evt[SSIEVENT_AWOL].e_event ? _SSIEVENT_AWOL_MASK : 0))
268 
269 #define	SSIEVENT_GET_STATE(s, e) \
270 			((s).idn_evt[e].e_event ? _SSIEVENT_VALUE(e) : 0)
271 #define	SSIEVENT_CLR_STATE(s, e) \
272 			((s).idn_evt[e].e_event = 0)
273 #define	SSIEVENT_SET_STATE(s, e) \
274 			((s).idn_evt[e].e_event = _SSIEVENT_VALUE(e))
275 
276 /*
277  * Get a bitmask of the currently handled states.
278  */
279 #define	SSIEVENT_GET_HANDLED_MASK(s) \
280 	(((s).idn_evt[SSIEVENT_BOOT].e_handled ? _SSIEVENT_BOOT_MASK : 0) \
281 	| ((s).idn_evt[SSIEVENT_AWOL].e_handled ? _SSIEVENT_AWOL_MASK : 0))
282 
283 #define	SSIEVENT_GET_HANDLED(s, e) \
284 			((s).idn_evt[e].e_handled ? _SSIEVENT_VALUE(e) : 0)
285 #define	SSIEVENT_CLR_HANDLED(s, e) \
286 			((s).idn_evt[e].e_handled = 0)
287 #define	SSIEVENT_SET_HANDLED(s, e) \
288 			((s).idn_evt[e].e_handled = _SSIEVENT_VALUE(e))
289 #define	SSIEVENT_SET_HANDLED_DATA(s, e, d) \
290 			((s).idn_evt[e].e_handled_data = (ushort_t)(d))
291 #define	SSIEVENT_GET_HANDLED_EVT(i, e) \
292 				((i).e_handled ? _SSIEVENT_VALUE(e) : 0)
293 #define	SSIEVENT_CLR_HANDLED_EVT(i)	((i).e_handled = 0)
294 #define	SSIEVENT_SET_HANDLED_EVT(i, e)	((i).e_handled = _SSIEVENT_VALUE(e))
295 
296 /*
297  * Check for the state of a particular event within a state bitmask.
298  */
299 #define	SSIEVENT_CHK_STATE_MASK(m, e) \
300 	((((m) & (0xf << ((e) << 2))) == _SSIEVENT_MASKS(e)) ? 1 : 0)
301 #define	SSIEVENT_CHK_HANDLED_MASK(m, e)	SSIEVENT_CHK_STATE_MASK((m), (e))
302 
303 /*
304  * Build the state mask managed in the cbe to represent the state
305  * of the respective events above.
306  */
307 #define	SSIEVENT_DEL_STATE_MASK(m, e)	((m) &= ~(0xf << ((e) << 2)))
308 #define	SSIEVENT_ADD_STATE_MASK(m, e) \
309 		(SSIEVENT_DEL_STATE_MASK((m), (e)), \
310 		((m) |= _SSIEVENT_MASKS(e)))
311 #define	SSIEVENT_STATE_MASK	(_SSIEVENT_BOOT_MASK | _SSIEVENT_AWOL_MASK)
312 #define	SSIEVENT_STATE_NIL	0
313 
314 #ifdef _KERNEL
315 #define	SSIEVENT_SET(s, e, d) { \
316 		SSIEVENT_SET_HANDLED(*(s), (e)); \
317 		membar_stst_stld(); \
318 		SSIEVENT_SET_STATE(*(s), (e)); \
319 		(s)->idn_evt[e].e_event_data = (ushort_t)(d); \
320 		membar_stst_stld(); \
321 		SSIEVENT_CLR_HANDLED(*(s), (e)); \
322 }
323 #define	SSIEVENT_CLEAR(s, e, d) { \
324 		SSIEVENT_SET_HANDLED(*(s), (e)); \
325 		membar_stst_stld(); \
326 		SSIEVENT_CLR_STATE(*(s), (e)); \
327 		(s)->idn_evt[e].e_event_data &= (ushort_t)~(d); \
328 		membar_stst_stld(); \
329 		SSIEVENT_CLR_HANDLED(*(s), (e)); \
330 }
331 #define	SSIEVENT_ADD(s, e, d) { \
332 		SSIEVENT_SET_HANDLED(*(s), (e)); \
333 		membar_stst_stld(); \
334 		SSIEVENT_SET_STATE(*(s), (e)); \
335 		(s)->idn_evt[e].e_event_data |= (ushort_t)(d); \
336 		membar_stst_stld(); \
337 		SSIEVENT_CLR_HANDLED(*(s), (e)); \
338 }
339 #define	SSIEVENT_DEL(s, e, d) { \
340 		SSIEVENT_SET_HANDLED(*(s), (e)); \
341 		membar_stst_stld(); \
342 		(s)->idn_evt[e].e_event_data &= (ushort_t)~(d); \
343 		if ((s)->idn_evt[e].e_event_data != 0) { \
344 			SSIEVENT_SET_STATE(*(s), (e)); \
345 			membar_stst_stld(); \
346 			SSIEVENT_CLR_HANDLED(*(s), (e)); \
347 		} else { \
348 			membar_stst_stld(); \
349 			SSIEVENT_CLR_STATE(*(s), (e)); \
350 		} \
351 }
352 #endif /* _KERNEL */
353 
354 typedef struct idnevent {
355 	uchar_t		e_event;
356 	uchar_t		e_handled;
357 	ushort_t	e_event_data;
358 	ushort_t	e_handled_data;
359 	ushort_t	reserved;
360 } idnevent_t;
361 
362 /*
363  * IMPORTANT: This data structure must be the size of a sigbmbox_t
364  *	      so that it fits in the space it steals in the sigblock.
365  *            Also, any changes to this structure must be cross-checked
366  *	      with (struct idnsb) in <sun4u1/sys/idn.h> with respect
367  *	      the area from reserved1 on down.
368  */
369 #define	IDNSB_EVENT_SIZE	(sizeof (sigbmbox_t))
370 typedef struct {
371 	struct _idnsb_event {
372 		union {
373 			struct {
374 				char	_cookie[SSIEVENT_COOKIE_LEN];
375 				uchar_t	_version;
376 			} _ss;
377 			struct {
378 				uint_t	_cookie : 24;
379 				uint_t	_version : 8;
380 			} _sn;
381 		} _u;
382 		uint_t		_reserved1;	/* reserved for IDN driver */
383 		idnevent_t	_evt[SSIEVENT_MAXNUM];
384 	} _s;
385 
386 		/* reserved for IDN driver */
387 	char	reserved2[IDNSB_EVENT_SIZE - sizeof (struct _idnsb_event)];
388 } idnsb_event_t;
389 
390 #define	idn_evt			_s._evt
391 #define	idn_reserved1		_s._reserved1
392 #define	idn_cookie_str		_s._u._ss._cookie
393 #define	idn_version_byte	_s._u._ss._version
394 #define	idn_cookie		_s._u._sn._cookie
395 #define	idn_version		_s._u._sn._version
396 
397 #ifdef	__cplusplus
398 }
399 #endif
400 
401 #endif /* _SYS_IDN_SIGB_H */
402