xref: /onnv-gate/usr/src/uts/sun4u/starcat/sys/mboxsc_impl.h (revision 1708:ea74d8598a3a)
1*1708Sstevel /*
2*1708Sstevel  * CDDL HEADER START
3*1708Sstevel  *
4*1708Sstevel  * The contents of this file are subject to the terms of the
5*1708Sstevel  * Common Development and Distribution License (the "License").
6*1708Sstevel  * You may not use this file except in compliance with the License.
7*1708Sstevel  *
8*1708Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1708Sstevel  * or http://www.opensolaris.org/os/licensing.
10*1708Sstevel  * See the License for the specific language governing permissions
11*1708Sstevel  * and limitations under the License.
12*1708Sstevel  *
13*1708Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*1708Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1708Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*1708Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*1708Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1708Sstevel  *
19*1708Sstevel  * CDDL HEADER END
20*1708Sstevel  */
21*1708Sstevel 
22*1708Sstevel /*
23*1708Sstevel  * Copyright 2000 Sun Microsystems, Inc.  All rights reserved.
24*1708Sstevel  * Use is subject to license terms.
25*1708Sstevel  */
26*1708Sstevel 
27*1708Sstevel #ifndef	_MBOXSC_IMPL_H
28*1708Sstevel #define	_MBOXSC_IMPL_H
29*1708Sstevel 
30*1708Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1708Sstevel 
32*1708Sstevel /*
33*1708Sstevel  * This file contains implementation details for the mboxsc API that need to
34*1708Sstevel  * be shared amongst all implementations, but should be hidden from clients.
35*1708Sstevel  */
36*1708Sstevel 
37*1708Sstevel #ifdef __cplusplus
38*1708Sstevel extern "C" {
39*1708Sstevel #endif
40*1708Sstevel 
41*1708Sstevel /*
42*1708Sstevel  * Version number of the current Mailbox Protocol implementation.  This must
43*1708Sstevel  * be updated whenever a new version of the Protocol is implemented.
44*1708Sstevel  */
45*1708Sstevel #define	MBOXSC_PROTOCOL_VERSION	1
46*1708Sstevel 
47*1708Sstevel /*
48*1708Sstevel  * Mailbox message header and checksum.
49*1708Sstevel  */
50*1708Sstevel typedef struct {
51*1708Sstevel 	uint32_t	msg_version;
52*1708Sstevel 	uint32_t	msg_type;
53*1708Sstevel 	uint32_t	msg_cmd;
54*1708Sstevel 	uint32_t	msg_length;
55*1708Sstevel 	uint64_t	msg_transid;
56*1708Sstevel } mboxsc_msghdr_t;
57*1708Sstevel 
58*1708Sstevel typedef uint32_t	mboxsc_chksum_t;
59*1708Sstevel 
60*1708Sstevel /*
61*1708Sstevel  * Constants for various aspects of the protocol.
62*1708Sstevel  */
63*1708Sstevel #define	MBOXSC_MSGHDR_SIZE	(sizeof (mboxsc_msghdr_t))
64*1708Sstevel #define	MBOXSC_CHKSUM_SIZE	(sizeof (mboxsc_chksum_t))
65*1708Sstevel #define	MBOXSC_PROTOCOL_SIZE	(MBOXSC_MSGHDR_SIZE + MBOXSC_CHKSUM_SIZE)
66*1708Sstevel #define	MBOXSC_MSGHDR_OFFSET	(0)
67*1708Sstevel #define	MBOXSC_DATA_OFFSET	MBOXSC_MSGHDR_SIZE
68*1708Sstevel 
69*1708Sstevel /*
70*1708Sstevel  * Timeouts used for various mboxsc operations.  All timeouts are provided
71*1708Sstevel  * in microseconds.
72*1708Sstevel  * XXX - Aside from the conversion factors, these values are currently
73*1708Sstevel  *       somewhat arbitrary, and may need significant modification.
74*1708Sstevel  */
75*1708Sstevel #define	MBOXSC_USECS_PER_SECOND		(1000000L)
76*1708Sstevel #define	MBOXSC_USECS_PER_MSEC		(1000L)
77*1708Sstevel 
78*1708Sstevel /*
79*1708Sstevel  * The amount of time to sleep before retrying an IOSRAM operation that failed
80*1708Sstevel  * because a tunnel switch was in progress.
81*1708Sstevel  * Current value: 0.125 seconds
82*1708Sstevel  */
83*1708Sstevel #define	MBOXSC_EAGAIN_POLL_USECS	(MBOXSC_USECS_PER_SECOND / 8)
84*1708Sstevel 
85*1708Sstevel /*
86*1708Sstevel  * The interval at which the data_valid flag should be polled for a change in
87*1708Sstevel  * status after sending a message.
88*1708Sstevel  * Current value: 0.010 seconds
89*1708Sstevel  */
90*1708Sstevel #define	MBOXSC_PUTMSG_POLL_USECS	(MBOXSC_USECS_PER_SECOND / 100)
91*1708Sstevel 
92*1708Sstevel /*
93*1708Sstevel  * The polling rates for acquisition of the hardware lock used to synchronize
94*1708Sstevel  * data_valid flag access.
95*1708Sstevel  * Current values: 0.025 seconds
96*1708Sstevel  */
97*1708Sstevel #define	MBOXSC_HWLOCK_POLL_USECS 	(MBOXSC_USECS_PER_SECOND / 40)
98*1708Sstevel 
99*1708Sstevel /*
100*1708Sstevel  * Minimum, default, and maximum times for mboxsc_putmsg to spend trying to send
101*1708Sstevel  * a message before giving up.
102*1708Sstevel  * Current value: 0.050, 10, and 1800 seconds, respectively
103*1708Sstevel  *                1800 seconds (30 minutes) is a few minutes shy of the maximum
104*1708Sstevel  *                value of a clock_t in units of microseconds.
105*1708Sstevel  */
106*1708Sstevel #define	MBOXSC_PUTMSG_MIN_TIMEOUT_USECS	(MBOXSC_USECS_PER_SECOND / 20)
107*1708Sstevel #define	MBOXSC_PUTMSG_DEF_TIMEOUT_USECS	(MBOXSC_USECS_PER_SECOND * 10)
108*1708Sstevel #define	MBOXSC_PUTMSG_MAX_TIMEOUT_USECS	(MBOXSC_USECS_PER_SECOND * 60 * 30)
109*1708Sstevel 
110*1708Sstevel #define	MBOXSC_PUTMSG_MIN_TIMEOUT_MSECS \
111*1708Sstevel 	(MBOXSC_PUTMSG_MIN_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC)
112*1708Sstevel #define	MBOXSC_PUTMSG_DEF_TIMEOUT_MSECS \
113*1708Sstevel 	(MBOXSC_PUTMSG_DEF_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC)
114*1708Sstevel #define	MBOXSC_PUTMSG_MAX_TIMEOUT_MSECS \
115*1708Sstevel 	(MBOXSC_PUTMSG_MAX_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC)
116*1708Sstevel 
117*1708Sstevel /*
118*1708Sstevel  * Minimum and maximum times for mboxsc_getmsg to spend trying to receive a
119*1708Sstevel  * message before giving up.
120*1708Sstevel  * Current value: 0 and 1800 seconds, respectively
121*1708Sstevel  *                1800 seconds (30 minutes) is a few minutes shy of the maximum
122*1708Sstevel  *                value of a clock_t in units of microseconds.
123*1708Sstevel  */
124*1708Sstevel #define	MBOXSC_GETMSG_MIN_TIMEOUT_USECS (MBOXSC_USECS_PER_SECOND * 0)
125*1708Sstevel #define	MBOXSC_GETMSG_MAX_TIMEOUT_USECS (MBOXSC_USECS_PER_SECOND * 60 * 30)
126*1708Sstevel 
127*1708Sstevel #define	MBOXSC_GETMSG_MIN_TIMEOUT_MSECS \
128*1708Sstevel 	(MBOXSC_GETMSG_MIN_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC)
129*1708Sstevel #define	MBOXSC_GETMSG_MAX_TIMEOUT_MSECS \
130*1708Sstevel 	(MBOXSC_GETMSG_MAX_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC)
131*1708Sstevel 
132*1708Sstevel #ifdef __cplusplus
133*1708Sstevel }
134*1708Sstevel #endif
135*1708Sstevel 
136*1708Sstevel #endif /* _MBOXSC_IMPL_H */
137