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