xref: /titanic_44/usr/src/uts/common/sys/1394/s1394.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_1394_S1394_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_1394_S1394_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * s1394.h
34*7c478bd9Sstevel@tonic-gate  *    Contains all of the structures used (internally) by the 1394
35*7c478bd9Sstevel@tonic-gate  *    Software Framework
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
40*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/sunndi.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/callb.h>
44*7c478bd9Sstevel@tonic-gate #include <sys/note.h>
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate #include <sys/1394/s1394_impl.h>
47*7c478bd9Sstevel@tonic-gate #include <sys/1394/t1394.h>
48*7c478bd9Sstevel@tonic-gate #include <sys/1394/h1394.h>
49*7c478bd9Sstevel@tonic-gate #include <sys/1394/cmd1394.h>
50*7c478bd9Sstevel@tonic-gate #include <sys/1394/ieee1212.h>
51*7c478bd9Sstevel@tonic-gate #include <sys/1394/ieee1394.h>
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
54*7c478bd9Sstevel@tonic-gate extern "C" {
55*7c478bd9Sstevel@tonic-gate #endif
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate /* SelfID buffer size */
58*7c478bd9Sstevel@tonic-gate #define	S1394_SELFID_BUF_SIZE		8192
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /* Maximum number of allocated commands per target */
61*7c478bd9Sstevel@tonic-gate #define	MAX_NUMBER_ALLOC_CMDS		256
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /* Maximum number of lock retries */
64*7c478bd9Sstevel@tonic-gate #define	MAX_NUMBER_OF_LOCK_RETRIES	256
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate #define	S1394_INITIAL_STATES		2
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate /* Invalid entry in the Speed Map */
69*7c478bd9Sstevel@tonic-gate #define	SPEED_MAP_INVALID		0xFF
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /* Invalid node num */
72*7c478bd9Sstevel@tonic-gate #define	S1394_INVALID_NODE_NUM		0x3F
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate /* Node state */
75*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_OFFLINE		1
76*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_ONLINE		2
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /* Where are commands inserted onto the pending Q? */
79*7c478bd9Sstevel@tonic-gate #define	S1394_PENDING_Q_FRONT		1
80*7c478bd9Sstevel@tonic-gate #define	S1394_PENDING_Q_REAR		2
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate /* Number of self-initiated bus resets until HAL fails */
83*7c478bd9Sstevel@tonic-gate #define	NUM_BR_FAIL			5
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate /* Reasons for Self-Initiated Bus Reset */
86*7c478bd9Sstevel@tonic-gate #define	NON_CRITICAL			0
87*7c478bd9Sstevel@tonic-gate #define	CRITICAL			1
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate /* Bus Mgr (IRM) defines */
90*7c478bd9Sstevel@tonic-gate #define	ROOT_HOLDOFF			(1 << 0)
91*7c478bd9Sstevel@tonic-gate #define	GAP_COUNT			(1 << 1)
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /* Root Node has no parents */
94*7c478bd9Sstevel@tonic-gate #define	NO_PARENT			-1
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate /* Maximum number of Hops between Nodes on the Bus */
97*7c478bd9Sstevel@tonic-gate #define	MAX_HOPS			23
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate /* Invalid lo and hi addresses used in s1394_init_addr_space() */
100*7c478bd9Sstevel@tonic-gate #define	ADDR_LO_INVALID			0x0000000000000001
101*7c478bd9Sstevel@tonic-gate #define	ADDR_HI_INVALID			0x0000000000000000
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate /* Time to delay after CYCLE_TOO_LONG before enabling cycle master */
104*7c478bd9Sstevel@tonic-gate #define	CYCLE_MASTER_TIMER		1000	/* 1 second */
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /* Size of directory stack used during config rom scan */
107*7c478bd9Sstevel@tonic-gate #define	S1394_DIR_STACK_SIZE		16
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /*
110*7c478bd9Sstevel@tonic-gate  * P1394a (Draft 2.x) proposes to disallow a
111*7c478bd9Sstevel@tonic-gate  * Config ROM "generation" to be repeated within
112*7c478bd9Sstevel@tonic-gate  * a 60 second window.
113*7c478bd9Sstevel@tonic-gate  * Because of that, this value should not be set
114*7c478bd9Sstevel@tonic-gate  * to any value smaller than 5 seconds without
115*7c478bd9Sstevel@tonic-gate  * another method in place to ensure that this
116*7c478bd9Sstevel@tonic-gate  * "generation" reuse can not happen.
117*7c478bd9Sstevel@tonic-gate  */
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate /*
120*7c478bd9Sstevel@tonic-gate  * Time delay (in ms) from Config ROM update to
121*7c478bd9Sstevel@tonic-gate  * software-initiated bus reset.
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate #define	CONFIG_ROM_UPDATE_DELAY		5000	/* 5 seconds */
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate #define	S1394_ROOT_TEXT_LEAF_SZ		36
126*7c478bd9Sstevel@tonic-gate #define	S1394_ROOT_TEXT_LEAF_QUAD_SZ	9
127*7c478bd9Sstevel@tonic-gate #define	S1394_ROOT_TEXT_KEY		0x81
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_UNIQUE_ID_SZ		12
130*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_UNIQUE_ID_QUAD_SZ	3
131*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_UNIQUE_ID_KEY	0x8D
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate #define	S1394_UNIT_DIR_SZ		56
134*7c478bd9Sstevel@tonic-gate #define	S1394_UNIT_DIR_QUAD_SZ		14
135*7c478bd9Sstevel@tonic-gate #define	S1394_UNIT_DIR_KEY		0xD1
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate /* The Organizationally Unique Identifier for Sun Microsystems, Inc. */
138*7c478bd9Sstevel@tonic-gate #define	S1394_SUNW_OUI			0x080020
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /* Number of retries in reading the Config ROM */
141*7c478bd9Sstevel@tonic-gate #define	CFGROM_READ_RETRIES		5
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate /* Delay time between reads of the Config ROM */
144*7c478bd9Sstevel@tonic-gate #define	CFGROM_READ_DELAY		20000	/* 20ms */
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate /* Error message for serious HBA hardware shutdowns */
147*7c478bd9Sstevel@tonic-gate #define	HALT_ERROR_MESSAGE	"%s%d: Unexpected Error: Shutting down HBA -" \
148*7c478bd9Sstevel@tonic-gate 	" Hardware disabled until next reboot"
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate /* Command Transaction Type */
151*7c478bd9Sstevel@tonic-gate #define	S1394_CMD_READ		0
152*7c478bd9Sstevel@tonic-gate #define	S1394_CMD_WRITE		1
153*7c478bd9Sstevel@tonic-gate #define	S1394_CMD_LOCK		2
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate /* Channel allocations */
156*7c478bd9Sstevel@tonic-gate #define	S1394_CHANNEL_ALLOC_HI	1
157*7c478bd9Sstevel@tonic-gate #define	S1394_CHANNEL_ALLOC_LO	0
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /* Maximum number of bus resets allowed in isoch rsrc alloc */
160*7c478bd9Sstevel@tonic-gate #define	S1394_ISOCH_ALLOC_RETRIES	5
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate #define	ADDR_RESERVED		1
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate /* Flags used by the used tree (red-black tree) */
165*7c478bd9Sstevel@tonic-gate #define	BLACK			0
166*7c478bd9Sstevel@tonic-gate #define	RED			1
167*7c478bd9Sstevel@tonic-gate #define	LEFT			0
168*7c478bd9Sstevel@tonic-gate #define	RIGHT			1
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate /* Isoch Bandwidth Allocation Units conversion */
171*7c478bd9Sstevel@tonic-gate #define	ISOCH_SPEED_FACTOR_S100		16
172*7c478bd9Sstevel@tonic-gate #define	ISOCH_SPEED_FACTOR_S200		8
173*7c478bd9Sstevel@tonic-gate #define	ISOCH_SPEED_FACTOR_S400		4
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate /* TNF probes */
176*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL			"1394 s1394 "
177*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ERROR		"1394 s1394 error "
178*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_STACK		"1394 s1394 stacktrace "
179*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ARREQ_STACK	"1394 s1394 arreq stacktrace "
180*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ARREQ_ERROR	"1394 s1394 arreq error "
181*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_STACK	"1394 s1394 atreq stacktrace "
182*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_ERROR	"1394 s1394 atreq error "
183*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ATRESP_STACK	"1394 s1394 atresp stacktrace "
184*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ATRESP_ERROR	"1394 s1394 atresp error "
185*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_ATRESP_STACK	"1394 s1394 atreq atresp stacktrace "
186*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_ATRESP_ERROR	"1394 s1394 atreq atresp error "
187*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_BR_STACK		"1394 s1394 bus_reset stacktrace "
188*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_BR_ERROR		"1394 s1394 bus_reset error "
189*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_IOCTL_STACK	"1394 s1394 ioctl stacktrace "
190*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_HOTPLUG_STACK	"1394 s1394 hotplug stacktrace "
191*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_HOTPLUG_ERROR	"1394 s1394 hotplug error "
192*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_NX1394_STACK	"1394 s1394 nx1394 stacktrace "
193*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_CSR_ERROR		"1394 s1394 csr error "
194*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_CSR_STACK		"1394 s1394 csr stacktrace "
195*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_BR_CSR_STACK	"1394 s1394 bus_reset csr stacktrace "
196*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_CFGROM_ERROR	"1394 s1394 cfgrom error "
197*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_CFGROM_STACK	"1394 s1394 cfgrom stacktrace "
198*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ISOCH_ERROR	"1394 s1394 isoch error "
199*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_ISOCH_STACK	"1394 s1394 isoch stacktrace "
200*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_NEXUS_ERROR	"1394 s1394 nexus error "
201*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_NEXUS_STACK	"1394 s1394 nexus stacktrace "
202*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_FA_STACK		"1394 s1394 FA stacktrace "
203*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_FA_ERROR		"1394 s1394 FA error "
204*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_FCP_STACK		"1394 s1394 FCP stacktrace "
205*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_FCP_ERROR		"1394 s1394 FCP error "
206*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_CMP_STACK		"1394 s1394 CMP stacktrace "
207*7c478bd9Sstevel@tonic-gate #define	S1394_TNF_SL_CMP_ERROR		"1394 s1394 CMP error "
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate /* s1394_hal_state_t */
210*7c478bd9Sstevel@tonic-gate typedef enum {
211*7c478bd9Sstevel@tonic-gate 	S1394_HAL_INIT,
212*7c478bd9Sstevel@tonic-gate 	S1394_HAL_RESET,
213*7c478bd9Sstevel@tonic-gate 	S1394_HAL_NORMAL,
214*7c478bd9Sstevel@tonic-gate 	S1394_HAL_DREQ,
215*7c478bd9Sstevel@tonic-gate 	S1394_HAL_SHUTDOWN
216*7c478bd9Sstevel@tonic-gate } s1394_hal_state_t;
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate /* s1394_isoch_cec_type_t */
219*7c478bd9Sstevel@tonic-gate typedef enum {
220*7c478bd9Sstevel@tonic-gate 	S1394_SINGLE		= 1,
221*7c478bd9Sstevel@tonic-gate 	S1394_PEER_TO_PEER	= 2
222*7c478bd9Sstevel@tonic-gate } s1394_isoch_cec_type_t;
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate /* s1394_isoch_cec_state_t */
225*7c478bd9Sstevel@tonic-gate typedef enum {
226*7c478bd9Sstevel@tonic-gate 	ISOCH_CEC_FREE		= (1 << 0),
227*7c478bd9Sstevel@tonic-gate 	ISOCH_CEC_JOIN		= (1 << 1),
228*7c478bd9Sstevel@tonic-gate 	ISOCH_CEC_LEAVE		= (1 << 2),
229*7c478bd9Sstevel@tonic-gate 	ISOCH_CEC_SETUP		= (1 << 3),
230*7c478bd9Sstevel@tonic-gate 	ISOCH_CEC_TEARDOWN	= (1 << 4),
231*7c478bd9Sstevel@tonic-gate 	ISOCH_CEC_START		= (1 << 5),
232*7c478bd9Sstevel@tonic-gate 	ISOCH_CEC_STOP		= (1 << 6)
233*7c478bd9Sstevel@tonic-gate } s1394_isoch_cec_state_t;
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate /* s1394_status_t */
236*7c478bd9Sstevel@tonic-gate typedef enum {
237*7c478bd9Sstevel@tonic-gate 	S1394_NOSTATUS		= (1 << 0),
238*7c478bd9Sstevel@tonic-gate 	S1394_LOCK_FAILED	= (1 << 1),
239*7c478bd9Sstevel@tonic-gate 	S1394_CMD_ALLOC_FAILED	= (1 << 2),
240*7c478bd9Sstevel@tonic-gate 	S1394_XFER_FAILED	= (1 << 3),
241*7c478bd9Sstevel@tonic-gate 	S1394_UNKNOWN		= (1 << 4),
242*7c478bd9Sstevel@tonic-gate 	S1394_CMD_INFLIGHT	= (1 << 5)
243*7c478bd9Sstevel@tonic-gate } s1394_status_t;
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate /* s1394_free_cfgrom_t */
246*7c478bd9Sstevel@tonic-gate typedef enum {
247*7c478bd9Sstevel@tonic-gate 	S1394_FREE_CFGROM_BOTH,
248*7c478bd9Sstevel@tonic-gate 	S1394_FREE_CFGROM_NEW,
249*7c478bd9Sstevel@tonic-gate 	S1394_FREE_CFGROM_OLD
250*7c478bd9Sstevel@tonic-gate } s1394_free_cfgrom_t;
251*7c478bd9Sstevel@tonic-gate 
252*7c478bd9Sstevel@tonic-gate typedef struct s1394_node_s		s1394_node_t;
253*7c478bd9Sstevel@tonic-gate typedef struct s1394_target_s		s1394_target_t;
254*7c478bd9Sstevel@tonic-gate typedef struct s1394_hal_s		s1394_hal_t;
255*7c478bd9Sstevel@tonic-gate typedef struct s1394_addr_space_blk_s	s1394_addr_space_blk_t;
256*7c478bd9Sstevel@tonic-gate typedef struct s1394_config_rom_s	s1394_config_rom_t;
257*7c478bd9Sstevel@tonic-gate typedef struct s1394_kstat_s		s1394_kstat_t;
258*7c478bd9Sstevel@tonic-gate typedef struct s1394_isoch_cec_s	s1394_isoch_cec_t;
259*7c478bd9Sstevel@tonic-gate typedef struct s1394_isoch_cec_member_s	s1394_isoch_cec_member_t;
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate /* cfgrom_dir_t */
262*7c478bd9Sstevel@tonic-gate typedef struct {
263*7c478bd9Sstevel@tonic-gate 	ushort_t		dir_start;
264*7c478bd9Sstevel@tonic-gate 	ushort_t		dir_size;
265*7c478bd9Sstevel@tonic-gate 	ushort_t		dir_next_quad;
266*7c478bd9Sstevel@tonic-gate } cfgrom_dir_t;
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate /* s1394_selfid_pkt_t */
269*7c478bd9Sstevel@tonic-gate typedef struct s1394_selfid_pkt_s {
270*7c478bd9Sstevel@tonic-gate 	uint32_t		spkt_data;
271*7c478bd9Sstevel@tonic-gate 	uint32_t		spkt_inverse;
272*7c478bd9Sstevel@tonic-gate } s1394_selfid_pkt_t;
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate /* s1394_node_t */
275*7c478bd9Sstevel@tonic-gate struct s1394_node_s {
276*7c478bd9Sstevel@tonic-gate 	s1394_selfid_pkt_t	*selfid_packet;
277*7c478bd9Sstevel@tonic-gate 	s1394_node_t		*phy_port[IEEE1394_MAX_NUM_PORTS];
278*7c478bd9Sstevel@tonic-gate 	s1394_node_t		*old_node;
279*7c478bd9Sstevel@tonic-gate 	s1394_node_t		*cur_node;
280*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*target_list;
281*7c478bd9Sstevel@tonic-gate 	ushort_t		cfgrom_size;		/* in quads */
282*7c478bd9Sstevel@tonic-gate 	ushort_t		cfgrom_valid_size;	/* in quads */
283*7c478bd9Sstevel@tonic-gate 	uchar_t			link_active;
284*7c478bd9Sstevel@tonic-gate 	uchar_t			node_num;
285*7c478bd9Sstevel@tonic-gate 	uchar_t			max_1st;
286*7c478bd9Sstevel@tonic-gate 	uchar_t			max_2nd;
287*7c478bd9Sstevel@tonic-gate 	uchar_t			last_port_checked;
288*7c478bd9Sstevel@tonic-gate 	uchar_t			parent_port;
289*7c478bd9Sstevel@tonic-gate 	uchar_t			is_a_leaf;
290*7c478bd9Sstevel@tonic-gate 	/* All fields above can be zero'd while initing the topology tree */
291*7c478bd9Sstevel@tonic-gate 	uint32_t		*cfgrom;
292*7c478bd9Sstevel@tonic-gate #define	node_guid_hi		cfgrom[3]
293*7c478bd9Sstevel@tonic-gate #define	node_guid_lo		cfgrom[4]
294*7c478bd9Sstevel@tonic-gate #define	node_root_dir		cfgrom[5]
295*7c478bd9Sstevel@tonic-gate 	uint_t			node_state;
296*7c478bd9Sstevel@tonic-gate 	uint_t			cfgrom_state;
297*7c478bd9Sstevel@tonic-gate 	uint_t			bus_enum_flags;
298*7c478bd9Sstevel@tonic-gate 	/* fields dir_stack through expected_dir_quad constitute dir stack */
299*7c478bd9Sstevel@tonic-gate 	cfgrom_dir_t		dir_stack[S1394_DIR_STACK_SIZE];
300*7c478bd9Sstevel@tonic-gate 	ushort_t		cur_dir_start;
301*7c478bd9Sstevel@tonic-gate 	ushort_t		cur_dir_size;
302*7c478bd9Sstevel@tonic-gate 	char			dir_stack_top;
303*7c478bd9Sstevel@tonic-gate 	uchar_t			expected_type;
304*7c478bd9Sstevel@tonic-gate 	uchar_t			expected_dir_quad;
305*7c478bd9Sstevel@tonic-gate 	ushort_t		cfgrom_quad_to_read;
306*7c478bd9Sstevel@tonic-gate 	ushort_t		cfgrom_quad_read_cnt; /* if rdg blk */
307*7c478bd9Sstevel@tonic-gate 	uchar_t			rescan_cnt;
308*7c478bd9Sstevel@tonic-gate 	uchar_t			cfgrom_read_fails;
309*7c478bd9Sstevel@tonic-gate 	uchar_t			cfgrom_read_delay;	/* in ms */
310*7c478bd9Sstevel@tonic-gate };
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate /* defines used during enumeration */
313*7c478bd9Sstevel@tonic-gate #define	NODE_DIR_SIZE(data)		((data) & 0xff)
314*7c478bd9Sstevel@tonic-gate #define	NODE_DIR_START(data)		(((data) >> 8) & 0xff)
315*7c478bd9Sstevel@tonic-gate #define	NODE_DIR_QUAD(data)		(((data) >> 16) & 0xff)
316*7c478bd9Sstevel@tonic-gate 
317*7c478bd9Sstevel@tonic-gate /* defines for link_active */
318*7c478bd9Sstevel@tonic-gate #define	SET_LINK_ACTIVE(n)	((n)->link_active = 1)
319*7c478bd9Sstevel@tonic-gate #define	CLEAR_LINK_ACTIVE(n) 	((n)->link_active = 0)
320*7c478bd9Sstevel@tonic-gate #define	LINK_ACTIVE(n)			\
321*7c478bd9Sstevel@tonic-gate 		(((n)->link_active == 0) ? B_FALSE : B_TRUE)
322*7c478bd9Sstevel@tonic-gate /* defines for state */
323*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_CONSUMING_PWR	0x00000001
324*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_ACTIVE		0x00000010
325*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_BUS_PWR_CONSUMER(n)		\
326*7c478bd9Sstevel@tonic-gate 	((IEEE1394_SELFID_POWER((n)->selfid_packet) > 0x3) ? B_TRUE : B_FALSE)
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate /* defines for cfgrom_state */
329*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_NEW_ALLOC		0x00000001 /* fresh alloc */
330*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_BIB_READ		0x00000002 /* bus info blocks read */
331*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_ALL_READ		0x00000004 /* read all of it */
332*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_BLK_READ_OK	0x00000008 /* can be read in blocks */
333*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_GEN_CHANGED	0x00000010 /* config rom gen changed */
334*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_PARSED		0x00000020 /* rom enumerated */
335*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_DIR_STACK_OFF	0x00000040 /* dir stack turned off */
336*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_SIZE_IS_CRCSIZE	0x00000080 /* crc size == cfgrom size */
337*7c478bd9Sstevel@tonic-gate 
338*7c478bd9Sstevel@tonic-gate #define	S1394_CFGROM_READ_MASK	(S1394_CFGROM_BIB_READ | S1394_CFGROM_ALL_READ)
339*7c478bd9Sstevel@tonic-gate 
340*7c478bd9Sstevel@tonic-gate #define	S1394_VALID_MASK			\
341*7c478bd9Sstevel@tonic-gate 	(S1394_CFGROM_READ_MASK | S1394_CFGROM_BLK_READ_OK | \
342*7c478bd9Sstevel@tonic-gate 	S1394_CFGROM_GEN_CHANGED | S1394_CFGROM_PARSED)
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_STATE(n)	((n)->cfgrom_state &= ~S1394_VALID_MASK)
345*7c478bd9Sstevel@tonic-gate #define	CFGROM_VALID(n)				\
346*7c478bd9Sstevel@tonic-gate 	((((n)->cfgrom_state & S1394_CFGROM_READ_MASK) != 0 && (n)->cfgrom != \
347*7c478bd9Sstevel@tonic-gate 	    NULL) ? B_TRUE : B_FALSE)
348*7c478bd9Sstevel@tonic-gate 
349*7c478bd9Sstevel@tonic-gate /* macros for cfgrom_state */
350*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_NEW_ALLOC(n)	((n)->cfgrom_state |= S1394_CFGROM_NEW_ALLOC)
351*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_NEW_ALLOC(n) ((n)->cfgrom_state &= ~S1394_CFGROM_NEW_ALLOC)
352*7c478bd9Sstevel@tonic-gate #define	CFGROM_NEW_ALLOC(n)			\
353*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_NEW_ALLOC) != 0 ? B_TRUE : B_FALSE)
354*7c478bd9Sstevel@tonic-gate 
355*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_BIB_READ(n)	((n)->cfgrom_state |= S1394_CFGROM_BIB_READ)
356*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_BIB_READ(n) ((n)->cfgrom_state &= ~S1394_CFGROM_BIB_READ)
357*7c478bd9Sstevel@tonic-gate #define	CFGROM_BIB_READ(n)			\
358*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_BIB_READ) != 0 ? B_TRUE : B_FALSE)
359*7c478bd9Sstevel@tonic-gate 
360*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_ALL_READ(n)	((n)->cfgrom_state |= S1394_CFGROM_ALL_READ)
361*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_ALL_READ(n)	((n)->cfgrom_state &= \
362*7c478bd9Sstevel@tonic-gate 	~S1394_CFGROM_ALL_READ)
363*7c478bd9Sstevel@tonic-gate #define	CFGROM_ALL_READ(n)				\
364*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_ALL_READ) != 0 ? B_TRUE : B_FALSE)
365*7c478bd9Sstevel@tonic-gate 
366*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_BLK_READ_OK(n)		\
367*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_BLK_READ_OK)
368*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_BLK_READ_OK(n)		\
369*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_BLK_READ_OK)
370*7c478bd9Sstevel@tonic-gate #define	CFGROM_BLK_READ_OK(n)			\
371*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_BLK_READ_OK) != 0 : B_TRUE : B_FALSE)
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_GEN_CHANGED(n)		\
374*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_GEN_CHANGED)
375*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_GEN_CHANGED(n)		\
376*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_GEN_CHANGED)
377*7c478bd9Sstevel@tonic-gate #define	CFGROM_GEN_CHANGED(n)			\
378*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_GEN_CHANGED) != 0 ? B_TRUE : B_FALSE)
379*7c478bd9Sstevel@tonic-gate 
380*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_PARSED(n)	((n)->cfgrom_state |= S1394_CFGROM_PARSED)
381*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_PARSED(n)	((n)->cfgrom_state &= ~S1394_CFGROM_PARSED)
382*7c478bd9Sstevel@tonic-gate #define	CFGROM_PARSED(n)			\
383*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_PARSED) != 0 ? B_TRUE : B_FALSE)
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_DIR_STACK_OFF(n)		\
386*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_DIR_STACK_OFF)
387*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_DIR_STACK_OFF(n)		\
388*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_DIR_STACK_OFF)
389*7c478bd9Sstevel@tonic-gate #define	CFGROM_DIR_STACK_OFF(n)			\
390*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_DIR_STACK_OFF) != 0 ? B_TRUE : \
391*7c478bd9Sstevel@tonic-gate 	    B_FALSE)
392*7c478bd9Sstevel@tonic-gate 
393*7c478bd9Sstevel@tonic-gate #define	SET_CFGROM_SIZE_IS_CRCSIZE(n)		\
394*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_SIZE_IS_CRCSIZE)
395*7c478bd9Sstevel@tonic-gate #define	CLEAR_CFGROM_SIZE_IS_CRCSIZE(n)		\
396*7c478bd9Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_SIZE_IS_CRCSIZE)
397*7c478bd9Sstevel@tonic-gate #define	CFGROM_SIZE_IS_CRCSIZE(n)			\
398*7c478bd9Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_SIZE_IS_CRCSIZE) != 0 ? B_TRUE : \
399*7c478bd9Sstevel@tonic-gate 	    B_FALSE)
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate /* defines for bus_enum_flags */
402*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_VISITED		0x00000001
403*7c478bd9Sstevel@tonic-gate #define	S1394_NODE_MATCHED		0x00000010
404*7c478bd9Sstevel@tonic-gate 
405*7c478bd9Sstevel@tonic-gate /* macros that set/clear bus_enum_flags */
406*7c478bd9Sstevel@tonic-gate #define	SET_NODE_VISITED(n)	((n)->bus_enum_flags |= S1394_NODE_VISITED)
407*7c478bd9Sstevel@tonic-gate #define	CLEAR_NODE_VISITED(n)	((n)->bus_enum_flags &= ~S1394_NODE_VISITED)
408*7c478bd9Sstevel@tonic-gate #define	NODE_VISITED(n)				\
409*7c478bd9Sstevel@tonic-gate 	(((n)->bus_enum_flags & S1394_NODE_VISITED) != 0 ? B_TRUE : B_FALSE)
410*7c478bd9Sstevel@tonic-gate 
411*7c478bd9Sstevel@tonic-gate #define	SET_NODE_MATCHED(n)	((n)->bus_enum_flags |= S1394_NODE_MATCHED)
412*7c478bd9Sstevel@tonic-gate #define	CLEAR_NODE_MATCHED(n)	((n)->bus_enum_flags &= ~S1394_NODE_MATCHED)
413*7c478bd9Sstevel@tonic-gate #define	NODE_MATCHED(n)				\
414*7c478bd9Sstevel@tonic-gate 	(((n)->bus_enum_flags & S1394_NODE_MATCHED) != 0 ? B_TRUE : B_FALSE)
415*7c478bd9Sstevel@tonic-gate 
416*7c478bd9Sstevel@tonic-gate #define	SET_NODE_IDENTIFIED(n)	((n)->bus_enum_flags |= S1394_NODE_IDENTIFIED)
417*7c478bd9Sstevel@tonic-gate #define	CLEAR_NODE_IDENTIFIED(n) ((n)->bus_enum_flags &= ~S1394_NODE_IDENTIFIED)
418*7c478bd9Sstevel@tonic-gate #define	NODE_IDENTIFIED(n)			\
419*7c478bd9Sstevel@tonic-gate 	(((n)->bus_enum_flags & S1394_NODE_IDENTIFIED) != 0 ? B_TRUE : B_FALSE)
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate /*
422*7c478bd9Sstevel@tonic-gate  * s1394_fa_type_t - FA types, used as index into target_fa and hal_fa
423*7c478bd9Sstevel@tonic-gate  */
424*7c478bd9Sstevel@tonic-gate typedef enum {
425*7c478bd9Sstevel@tonic-gate 	S1394_FA_TYPE_FCP_CTL,		/* FCP controller */
426*7c478bd9Sstevel@tonic-gate 	S1394_FA_TYPE_FCP_TGT,		/* FCP target */
427*7c478bd9Sstevel@tonic-gate 	S1394_FA_TYPE_CMP_OMPR,		/* CMP oMPR */
428*7c478bd9Sstevel@tonic-gate 	S1394_FA_TYPE_CMP_IMPR,		/* CMP iMPR */
429*7c478bd9Sstevel@tonic-gate 	S1394_FA_NTYPES,		/* should remain the last field */
430*7c478bd9Sstevel@tonic-gate 	S1394_FA_TYPE_CMP = S1394_FA_TYPE_CMP_OMPR	/* common CMP type */
431*7c478bd9Sstevel@tonic-gate } s1394_fa_type_t;
432*7c478bd9Sstevel@tonic-gate 
433*7c478bd9Sstevel@tonic-gate 
434*7c478bd9Sstevel@tonic-gate /*
435*7c478bd9Sstevel@tonic-gate  * s1394_fa_descr_t - FA type descriptor
436*7c478bd9Sstevel@tonic-gate  */
437*7c478bd9Sstevel@tonic-gate typedef struct s1394_fa_descr_s {
438*7c478bd9Sstevel@tonic-gate 	uint64_t		fd_addr;	/* address space  */
439*7c478bd9Sstevel@tonic-gate 	size_t			fd_size;	/* address space size */
440*7c478bd9Sstevel@tonic-gate 	t1394_addr_enable_t	fd_enable;	/* access types */
441*7c478bd9Sstevel@tonic-gate 	t1394_addr_evts_t	fd_evts;	/* event callbacks */
442*7c478bd9Sstevel@tonic-gate 	uint64_t		fd_conv_base;	/* address conversion base */
443*7c478bd9Sstevel@tonic-gate } s1394_fa_descr_t;
444*7c478bd9Sstevel@tonic-gate 
445*7c478bd9Sstevel@tonic-gate /*
446*7c478bd9Sstevel@tonic-gate  * s1394_fcp_target_t - per-target data required for FCP support
447*7c478bd9Sstevel@tonic-gate  */
448*7c478bd9Sstevel@tonic-gate typedef struct s1394_fcp_target_s {
449*7c478bd9Sstevel@tonic-gate 	t1394_fcp_evts_t	fc_evts;
450*7c478bd9Sstevel@tonic-gate } s1394_fcp_target_t;
451*7c478bd9Sstevel@tonic-gate 
452*7c478bd9Sstevel@tonic-gate /*
453*7c478bd9Sstevel@tonic-gate  * s1394_cmp_target_t - per-target data required for CMP support
454*7c478bd9Sstevel@tonic-gate  */
455*7c478bd9Sstevel@tonic-gate typedef struct s1394_cmp_target_s {
456*7c478bd9Sstevel@tonic-gate 	t1394_cmp_evts_t	cm_evts;
457*7c478bd9Sstevel@tonic-gate } s1394_cmp_target_t;
458*7c478bd9Sstevel@tonic-gate 
459*7c478bd9Sstevel@tonic-gate /*
460*7c478bd9Sstevel@tonic-gate  * s1394_fa_target_t - per-target data required for fixed address support
461*7c478bd9Sstevel@tonic-gate  */
462*7c478bd9Sstevel@tonic-gate typedef struct s1394_fa_target_s {
463*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*fat_next;	/* next in the list */
464*7c478bd9Sstevel@tonic-gate 	/* type-specific data */
465*7c478bd9Sstevel@tonic-gate 	union {
466*7c478bd9Sstevel@tonic-gate 		s1394_fcp_target_t	fcp;
467*7c478bd9Sstevel@tonic-gate 		s1394_cmp_target_t	cmp;
468*7c478bd9Sstevel@tonic-gate 	} fat_u;
469*7c478bd9Sstevel@tonic-gate } s1394_fa_target_t;
470*7c478bd9Sstevel@tonic-gate 
471*7c478bd9Sstevel@tonic-gate /* s1394_target_t - fields protected by the HAL's target_list_rwlock */
472*7c478bd9Sstevel@tonic-gate struct s1394_target_s {
473*7c478bd9Sstevel@tonic-gate 	int			target_version;
474*7c478bd9Sstevel@tonic-gate 
475*7c478bd9Sstevel@tonic-gate 	dev_info_t		*target_dip;
476*7c478bd9Sstevel@tonic-gate 
477*7c478bd9Sstevel@tonic-gate 	/* Pointers to the node and HAL on which the target exists */
478*7c478bd9Sstevel@tonic-gate 	s1394_node_t		*on_node;
479*7c478bd9Sstevel@tonic-gate 	s1394_hal_t		*on_hal;
480*7c478bd9Sstevel@tonic-gate 
481*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*target_next;
482*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*target_prev;
483*7c478bd9Sstevel@tonic-gate 
484*7c478bd9Sstevel@tonic-gate 	/* target_list is a copy of target_list pointer in the node */
485*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*target_list;
486*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*target_sibling;
487*7c478bd9Sstevel@tonic-gate 
488*7c478bd9Sstevel@tonic-gate 	uint_t			unit_dir;
489*7c478bd9Sstevel@tonic-gate 
490*7c478bd9Sstevel@tonic-gate 	/* The max_payload sizes - max and current conditions */
491*7c478bd9Sstevel@tonic-gate 	uint_t			dev_max_payload;
492*7c478bd9Sstevel@tonic-gate 	uint_t			current_max_payload;
493*7c478bd9Sstevel@tonic-gate 
494*7c478bd9Sstevel@tonic-gate 	/* Number of asynch command target has allocated */
495*7c478bd9Sstevel@tonic-gate 	uint_t			target_num_cmds;
496*7c478bd9Sstevel@tonic-gate 
497*7c478bd9Sstevel@tonic-gate 	/*
498*7c478bd9Sstevel@tonic-gate 	 * Are physical AR requests allowed from this target's node?
499*7c478bd9Sstevel@tonic-gate 	 * This field keeps track of the number of allocated blocks
500*7c478bd9Sstevel@tonic-gate 	 * of physical memory the target has.
501*7c478bd9Sstevel@tonic-gate 	 */
502*7c478bd9Sstevel@tonic-gate 	uint_t			physical_arreq_enabled;
503*7c478bd9Sstevel@tonic-gate 
504*7c478bd9Sstevel@tonic-gate 	uint_t			target_state;
505*7c478bd9Sstevel@tonic-gate 
506*7c478bd9Sstevel@tonic-gate 	/* FCP controller and target */
507*7c478bd9Sstevel@tonic-gate 	s1394_fa_target_t	target_fa[S1394_FA_NTYPES];
508*7c478bd9Sstevel@tonic-gate };
509*7c478bd9Sstevel@tonic-gate #define	S1394_TARG_HP_NODE		0x00000001	/* on a hp node */
510*7c478bd9Sstevel@tonic-gate #define	S1394_TARG_GONE			0x00000002	/* unplugged */
511*7c478bd9Sstevel@tonic-gate #define	S1394_TARG_USING_BUS_PWR	0x00000004	/* consuming pwr now */
512*7c478bd9Sstevel@tonic-gate #define	S1394_TARG_BUS_PWR_CONSUMER	0x00000008	/* power consumer */
513*7c478bd9Sstevel@tonic-gate #define	S1394_TARG_ACTIVE		0x00000010	/* active */
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate /*
516*7c478bd9Sstevel@tonic-gate  * s1394_fa_hal_t - per-hal data required for fixed address support
517*7c478bd9Sstevel@tonic-gate  */
518*7c478bd9Sstevel@tonic-gate typedef struct s1394_fa_hal_s {
519*7c478bd9Sstevel@tonic-gate 	/*
520*7c478bd9Sstevel@tonic-gate 	 * each hal keeps a list of registered fixed address clients
521*7c478bd9Sstevel@tonic-gate 	 */
522*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*fal_head;
523*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*fal_tail;
524*7c478bd9Sstevel@tonic-gate 	uint_t			fal_gen;	/* list generation */
525*7c478bd9Sstevel@tonic-gate 
526*7c478bd9Sstevel@tonic-gate 	s1394_fa_descr_t	*fal_descr;	/* type descriptor */
527*7c478bd9Sstevel@tonic-gate 	s1394_addr_space_blk_t	*fal_addr_blk;	/* address space block */
528*7c478bd9Sstevel@tonic-gate } s1394_fa_hal_t;
529*7c478bd9Sstevel@tonic-gate 
530*7c478bd9Sstevel@tonic-gate /*
531*7c478bd9Sstevel@tonic-gate  * s1394_cmp_hal_t - per-hal data required for fixed address support
532*7c478bd9Sstevel@tonic-gate  */
533*7c478bd9Sstevel@tonic-gate typedef struct s1394_cmp_hal_s {
534*7c478bd9Sstevel@tonic-gate 	/* oMPR */
535*7c478bd9Sstevel@tonic-gate 	krwlock_t		cmp_ompr_rwlock;
536*7c478bd9Sstevel@tonic-gate 	uint32_t		cmp_ompr_val;
537*7c478bd9Sstevel@tonic-gate 	/* iMPR */
538*7c478bd9Sstevel@tonic-gate 	krwlock_t		cmp_impr_rwlock;
539*7c478bd9Sstevel@tonic-gate 	uint32_t		cmp_impr_val;
540*7c478bd9Sstevel@tonic-gate } s1394_cmp_hal_t;
541*7c478bd9Sstevel@tonic-gate 
542*7c478bd9Sstevel@tonic-gate /* s1394_hal_t */
543*7c478bd9Sstevel@tonic-gate struct s1394_hal_s {
544*7c478bd9Sstevel@tonic-gate 	s1394_hal_t		*hal_next;
545*7c478bd9Sstevel@tonic-gate 	s1394_hal_t		*hal_prev;
546*7c478bd9Sstevel@tonic-gate 
547*7c478bd9Sstevel@tonic-gate 	/* Target list */
548*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*target_head;
549*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*target_tail;
550*7c478bd9Sstevel@tonic-gate 	krwlock_t		target_list_rwlock;
551*7c478bd9Sstevel@tonic-gate 
552*7c478bd9Sstevel@tonic-gate 	/* halinfo structure given at attach time */
553*7c478bd9Sstevel@tonic-gate 	h1394_halinfo_t		halinfo;
554*7c478bd9Sstevel@tonic-gate 
555*7c478bd9Sstevel@tonic-gate 	boolean_t		hal_was_suspended;
556*7c478bd9Sstevel@tonic-gate 
557*7c478bd9Sstevel@tonic-gate 	/* Bus reset thread */
558*7c478bd9Sstevel@tonic-gate 	kthread_t		*br_thread;
559*7c478bd9Sstevel@tonic-gate 	kmutex_t		br_thread_mutex;
560*7c478bd9Sstevel@tonic-gate 	kcondvar_t		br_thread_cv;
561*7c478bd9Sstevel@tonic-gate 	uint_t			br_thread_ev_type;
562*7c478bd9Sstevel@tonic-gate 	uint32_t		br_cfgrom_read_gen;
563*7c478bd9Sstevel@tonic-gate 	kmutex_t		br_cmplq_mutex;
564*7c478bd9Sstevel@tonic-gate 	kcondvar_t		br_cmplq_cv;
565*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*br_cmplq_head;
566*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*br_cmplq_tail;
567*7c478bd9Sstevel@tonic-gate 
568*7c478bd9Sstevel@tonic-gate 	s1394_hal_state_t	hal_state;
569*7c478bd9Sstevel@tonic-gate 
570*7c478bd9Sstevel@tonic-gate 	/* kstats - kernel statistics for the Services Layer */
571*7c478bd9Sstevel@tonic-gate 	s1394_kstat_t		*hal_kstats;
572*7c478bd9Sstevel@tonic-gate 	kstat_t			*hal_ksp;
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate 	/* CSR STATE register bits (DREQ and ABDICATE) */
575*7c478bd9Sstevel@tonic-gate 	uint_t			disable_requests_bit;
576*7c478bd9Sstevel@tonic-gate 	uint_t			abdicate_bus_mgr_bit;
577*7c478bd9Sstevel@tonic-gate 
578*7c478bd9Sstevel@tonic-gate 	boolean_t		initiated_bus_reset;
579*7c478bd9Sstevel@tonic-gate 	int			initiated_br_reason;
580*7c478bd9Sstevel@tonic-gate 	uint32_t		num_bus_reset_till_fail;
581*7c478bd9Sstevel@tonic-gate 
582*7c478bd9Sstevel@tonic-gate 	/* IRM and Bus Manager */
583*7c478bd9Sstevel@tonic-gate 	int			IRM_node;
584*7c478bd9Sstevel@tonic-gate 	kmutex_t		bus_mgr_node_mutex;
585*7c478bd9Sstevel@tonic-gate 	kcondvar_t		bus_mgr_node_cv;
586*7c478bd9Sstevel@tonic-gate 	int			bus_mgr_node;
587*7c478bd9Sstevel@tonic-gate 	boolean_t		incumbent_bus_mgr;
588*7c478bd9Sstevel@tonic-gate 	timeout_id_t		bus_mgr_timeout_id;
589*7c478bd9Sstevel@tonic-gate 	timeout_id_t		bus_mgr_query_timeout_id;
590*7c478bd9Sstevel@tonic-gate 
591*7c478bd9Sstevel@tonic-gate 	/* 1394 Bus stats */
592*7c478bd9Sstevel@tonic-gate 	int			gap_count;
593*7c478bd9Sstevel@tonic-gate 	int			optimum_gap_count;
594*7c478bd9Sstevel@tonic-gate 	uint8_t			slowest_node_speed;
595*7c478bd9Sstevel@tonic-gate 
596*7c478bd9Sstevel@tonic-gate 	/* Local Config ROM */
597*7c478bd9Sstevel@tonic-gate 	kmutex_t		local_config_rom_mutex;
598*7c478bd9Sstevel@tonic-gate 	uint32_t		*local_config_rom;
599*7c478bd9Sstevel@tonic-gate 	uint32_t		*temp_config_rom_buf;
600*7c478bd9Sstevel@tonic-gate 	s1394_config_rom_t	*root_directory;
601*7c478bd9Sstevel@tonic-gate 	uint_t			free_space;
602*7c478bd9Sstevel@tonic-gate 	uint_t			config_rom_update_amount;
603*7c478bd9Sstevel@tonic-gate 	boolean_t		config_rom_timer_set;
604*7c478bd9Sstevel@tonic-gate 	timeout_id_t		config_rom_timer;
605*7c478bd9Sstevel@tonic-gate 
606*7c478bd9Sstevel@tonic-gate 	/* Cycle Master - CYCLE_TOO_LONG timer */
607*7c478bd9Sstevel@tonic-gate 	kmutex_t		cm_timer_mutex;
608*7c478bd9Sstevel@tonic-gate 	boolean_t		cm_timer_set;
609*7c478bd9Sstevel@tonic-gate 	timeout_id_t		cm_timer;
610*7c478bd9Sstevel@tonic-gate 
611*7c478bd9Sstevel@tonic-gate 	/* Incoming (AR) request and 1394 address space */
612*7c478bd9Sstevel@tonic-gate 	kmutex_t		addr_space_free_mutex;
613*7c478bd9Sstevel@tonic-gate 	s1394_addr_space_blk_t	*addr_space_free_list;
614*7c478bd9Sstevel@tonic-gate 	kmutex_t		addr_space_used_mutex;
615*7c478bd9Sstevel@tonic-gate 	s1394_addr_space_blk_t	*addr_space_used_tree;
616*7c478bd9Sstevel@tonic-gate 	uint64_t		physical_addr_lo;
617*7c478bd9Sstevel@tonic-gate 	uint64_t		physical_addr_hi;
618*7c478bd9Sstevel@tonic-gate 	uint64_t		csr_addr_lo;
619*7c478bd9Sstevel@tonic-gate 	uint64_t		csr_addr_hi;
620*7c478bd9Sstevel@tonic-gate 	uint64_t		normal_addr_lo;
621*7c478bd9Sstevel@tonic-gate 	uint64_t		normal_addr_hi;
622*7c478bd9Sstevel@tonic-gate 	uint64_t		posted_write_addr_lo;
623*7c478bd9Sstevel@tonic-gate 	uint64_t		posted_write_addr_hi;
624*7c478bd9Sstevel@tonic-gate 
625*7c478bd9Sstevel@tonic-gate 	/* Outgoing (AT) request queues */
626*7c478bd9Sstevel@tonic-gate 	kmutex_t		outstanding_q_mutex;
627*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*outstanding_q_head;
628*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*outstanding_q_tail;
629*7c478bd9Sstevel@tonic-gate 	kmutex_t		pending_q_mutex;
630*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*pending_q_head;
631*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*pending_q_tail;
632*7c478bd9Sstevel@tonic-gate 
633*7c478bd9Sstevel@tonic-gate 	/* SelfID buffers */
634*7c478bd9Sstevel@tonic-gate 	void			*selfid_buf0;
635*7c478bd9Sstevel@tonic-gate 	void			*selfid_buf1;
636*7c478bd9Sstevel@tonic-gate 	int			current_buffer;
637*7c478bd9Sstevel@tonic-gate 	s1394_selfid_pkt_t	*selfid_ptrs[IEEE1394_MAX_NODES];
638*7c478bd9Sstevel@tonic-gate 
639*7c478bd9Sstevel@tonic-gate 	/* Topology trees and local bus stats */
640*7c478bd9Sstevel@tonic-gate 	kmutex_t		topology_tree_mutex;
641*7c478bd9Sstevel@tonic-gate 	uint32_t		cfgroms_being_read;
642*7c478bd9Sstevel@tonic-gate 	s1394_node_t		*topology_tree;
643*7c478bd9Sstevel@tonic-gate 	s1394_node_t		*old_tree;
644*7c478bd9Sstevel@tonic-gate 	uint32_t		generation_count;
645*7c478bd9Sstevel@tonic-gate 	ushort_t		number_of_nodes;
646*7c478bd9Sstevel@tonic-gate 	ushort_t		node_id;
647*7c478bd9Sstevel@tonic-gate 	boolean_t		topology_tree_valid;
648*7c478bd9Sstevel@tonic-gate 	boolean_t		topology_tree_processed;
649*7c478bd9Sstevel@tonic-gate 	uint32_t		old_generation_count;
650*7c478bd9Sstevel@tonic-gate 	ushort_t		old_number_of_nodes;
651*7c478bd9Sstevel@tonic-gate 	ushort_t		old_node_id;
652*7c478bd9Sstevel@tonic-gate 	s1394_node_t		current_tree[IEEE1394_MAX_NODES];
653*7c478bd9Sstevel@tonic-gate 	s1394_node_t		last_valid_tree[IEEE1394_MAX_NODES];
654*7c478bd9Sstevel@tonic-gate 	boolean_t		old_tree_valid;
655*7c478bd9Sstevel@tonic-gate 
656*7c478bd9Sstevel@tonic-gate 	/* TOPOLOGY_MAP backing store buffer */
657*7c478bd9Sstevel@tonic-gate 	uint32_t		*CSR_topology_map;
658*7c478bd9Sstevel@tonic-gate 
659*7c478bd9Sstevel@tonic-gate 	/* Speed Map */
660*7c478bd9Sstevel@tonic-gate 	uint8_t		speed_map[IEEE1394_MAX_NODES][IEEE1394_MAX_NODES];
661*7c478bd9Sstevel@tonic-gate 
662*7c478bd9Sstevel@tonic-gate 	/* Stack, Queue, and Node Number list */
663*7c478bd9Sstevel@tonic-gate 	void 			*hal_stack[IEEE1394_MAX_NODES];
664*7c478bd9Sstevel@tonic-gate 	int			hal_stack_depth;
665*7c478bd9Sstevel@tonic-gate 	void 			*hal_queue[IEEE1394_MAX_NODES];
666*7c478bd9Sstevel@tonic-gate 	int   			hal_queue_front;
667*7c478bd9Sstevel@tonic-gate 	int   			hal_queue_back;
668*7c478bd9Sstevel@tonic-gate 	int			hal_node_number_list[IEEE1394_MAX_NODES];
669*7c478bd9Sstevel@tonic-gate 	int 			hal_node_number_list_size;
670*7c478bd9Sstevel@tonic-gate 
671*7c478bd9Sstevel@tonic-gate 	/* Isoch CEC list */
672*7c478bd9Sstevel@tonic-gate 	kmutex_t		isoch_cec_list_mutex;
673*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_t	*isoch_cec_list_head;
674*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_t	*isoch_cec_list_tail;
675*7c478bd9Sstevel@tonic-gate 
676*7c478bd9Sstevel@tonic-gate 	struct kmem_cache	*hal_kmem_cachep;
677*7c478bd9Sstevel@tonic-gate 
678*7c478bd9Sstevel@tonic-gate 	ndi_event_hdl_t		hal_ndi_event_hdl;
679*7c478bd9Sstevel@tonic-gate 
680*7c478bd9Sstevel@tonic-gate 	callb_cpr_t		hal_cprinfo;
681*7c478bd9Sstevel@tonic-gate 
682*7c478bd9Sstevel@tonic-gate 	/* FCP controllers and targets */
683*7c478bd9Sstevel@tonic-gate 	s1394_fa_hal_t		hal_fa[S1394_FA_NTYPES];
684*7c478bd9Sstevel@tonic-gate 
685*7c478bd9Sstevel@tonic-gate 	/* CMP support */
686*7c478bd9Sstevel@tonic-gate 	s1394_cmp_hal_t		hal_cmp;
687*7c478bd9Sstevel@tonic-gate };
688*7c478bd9Sstevel@tonic-gate 
689*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("No lock needed to start/stop timer", \
690*7c478bd9Sstevel@tonic-gate 	s1394_hal_s::cm_timer))
691*7c478bd9Sstevel@tonic-gate 
692*7c478bd9Sstevel@tonic-gate /* defines for br_thread_ev_type */
693*7c478bd9Sstevel@tonic-gate #define	BR_THR_CFGROM_SCAN		0x00000001	/* start reading */
694*7c478bd9Sstevel@tonic-gate #define	BR_THR_GO_AWAY			0x00000002	/* clean & exit */
695*7c478bd9Sstevel@tonic-gate 
696*7c478bd9Sstevel@tonic-gate /*
697*7c478bd9Sstevel@tonic-gate  * FCP command and response address space
698*7c478bd9Sstevel@tonic-gate  */
699*7c478bd9Sstevel@tonic-gate #define	IEC61883_FCP_BASE_ADDR	0xFFFFF0000B00
700*7c478bd9Sstevel@tonic-gate #define	IEC61883_FCP_CMD_ADDR	IEC61883_FCP_BASE_ADDR
701*7c478bd9Sstevel@tonic-gate #define	IEC61883_FCP_CMD_SIZE	0x200
702*7c478bd9Sstevel@tonic-gate #define	IEC61883_FCP_RESP_ADDR	(IEC61883_FCP_CMD_ADDR + IEC61883_FCP_CMD_SIZE)
703*7c478bd9Sstevel@tonic-gate #define	IEC61883_FCP_RESP_SIZE	0x200
704*7c478bd9Sstevel@tonic-gate #define	IEC61883_FCP_END_ADDR (IEC61883_FCP_RESP_ADDR + IEC61883_FCP_RESP_SIZE)
705*7c478bd9Sstevel@tonic-gate 
706*7c478bd9Sstevel@tonic-gate /* CMP master plugs */
707*7c478bd9Sstevel@tonic-gate #define	IEC61883_CMP_OMPR_ADDR		0xFFFFF0000900
708*7c478bd9Sstevel@tonic-gate #define	IEC61883_CMP_IMPR_ADDR		0xFFFFF0000980
709*7c478bd9Sstevel@tonic-gate #define	IEC61883_CMP_OMPR_INIT_VAL	0xBFFFFF00
710*7c478bd9Sstevel@tonic-gate #define	IEC61883_CMP_IMPR_INIT_VAL	0x80FFFF00
711*7c478bd9Sstevel@tonic-gate #define	IEC61883_CMP_OMPR_LOCK_MASK	0x3FFFFF00
712*7c478bd9Sstevel@tonic-gate #define	IEC61883_CMP_IMPR_LOCK_MASK	0x00FFFF00
713*7c478bd9Sstevel@tonic-gate 
714*7c478bd9Sstevel@tonic-gate /* s1394_addr_space_blk_t */
715*7c478bd9Sstevel@tonic-gate struct s1394_addr_space_blk_s {
716*7c478bd9Sstevel@tonic-gate 	/* Pointers and coloring for Red-Black tree */
717*7c478bd9Sstevel@tonic-gate 	s1394_addr_space_blk_t		*asb_parent;
718*7c478bd9Sstevel@tonic-gate 	s1394_addr_space_blk_t		*asb_left;
719*7c478bd9Sstevel@tonic-gate 	s1394_addr_space_blk_t		*asb_right;
720*7c478bd9Sstevel@tonic-gate 	uint32_t			asb_color;
721*7c478bd9Sstevel@tonic-gate 	boolean_t			free_kmem_bufp;
722*7c478bd9Sstevel@tonic-gate 
723*7c478bd9Sstevel@tonic-gate 	/* Addr Blk info - callbacks, permissions, backing store, etc. */
724*7c478bd9Sstevel@tonic-gate 	uint64_t			addr_lo;
725*7c478bd9Sstevel@tonic-gate 	uint64_t			addr_hi;
726*7c478bd9Sstevel@tonic-gate 	uint32_t			addr_reserved;
727*7c478bd9Sstevel@tonic-gate 	t1394_addr_enable_t		addr_enable;
728*7c478bd9Sstevel@tonic-gate 	t1394_addr_type_t		addr_type;
729*7c478bd9Sstevel@tonic-gate 	t1394_addr_evts_t		addr_events;
730*7c478bd9Sstevel@tonic-gate 	caddr_t				kmem_bufp;
731*7c478bd9Sstevel@tonic-gate 	void				*addr_arg;
732*7c478bd9Sstevel@tonic-gate };
733*7c478bd9Sstevel@tonic-gate 
734*7c478bd9Sstevel@tonic-gate /* s1394_config_rom_t */
735*7c478bd9Sstevel@tonic-gate struct s1394_config_rom_s {
736*7c478bd9Sstevel@tonic-gate 	boolean_t		cfgrom_used;
737*7c478bd9Sstevel@tonic-gate 	uint32_t		cfgrom_addr_lo;
738*7c478bd9Sstevel@tonic-gate 	uint32_t		cfgrom_addr_hi;
739*7c478bd9Sstevel@tonic-gate 
740*7c478bd9Sstevel@tonic-gate 	uint_t			root_dir_offset;
741*7c478bd9Sstevel@tonic-gate 
742*7c478bd9Sstevel@tonic-gate 	s1394_config_rom_t	*cfgrom_next;
743*7c478bd9Sstevel@tonic-gate 	s1394_config_rom_t	*cfgrom_prev;
744*7c478bd9Sstevel@tonic-gate };
745*7c478bd9Sstevel@tonic-gate 
746*7c478bd9Sstevel@tonic-gate /* s1394_kstat_t */
747*7c478bd9Sstevel@tonic-gate struct s1394_kstat_s {
748*7c478bd9Sstevel@tonic-gate 	/* Asynch Receive (AR) requests */
749*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_quad_rd;
750*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_blk_rd;
751*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_quad_wr;
752*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_blk_wr;
753*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_lock32;
754*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_lock64;
755*7c478bd9Sstevel@tonic-gate 
756*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_blk_rd_size;
757*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_blk_wr_size;
758*7c478bd9Sstevel@tonic-gate 
759*7c478bd9Sstevel@tonic-gate 	uint_t			arreq_posted_write_error;
760*7c478bd9Sstevel@tonic-gate 
761*7c478bd9Sstevel@tonic-gate 	/* Failure responses to AR requests (sent) */
762*7c478bd9Sstevel@tonic-gate 	uint_t			arresp_quad_rd_fail;
763*7c478bd9Sstevel@tonic-gate 	uint_t			arresp_blk_rd_fail;
764*7c478bd9Sstevel@tonic-gate 	uint_t			arresp_quad_wr_fail;
765*7c478bd9Sstevel@tonic-gate 	uint_t			arresp_blk_wr_fail;
766*7c478bd9Sstevel@tonic-gate 	uint_t			arresp_lock32_fail;
767*7c478bd9Sstevel@tonic-gate 	uint_t			arresp_lock64_fail;
768*7c478bd9Sstevel@tonic-gate 
769*7c478bd9Sstevel@tonic-gate 	/* Asynch Transmit (AT) requests */
770*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_quad_rd;
771*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_blk_rd;
772*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_quad_wr;
773*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_blk_wr;
774*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_lock32;
775*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_lock64;
776*7c478bd9Sstevel@tonic-gate 
777*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_blk_rd_size;
778*7c478bd9Sstevel@tonic-gate 	uint_t			atreq_blk_wr_size;
779*7c478bd9Sstevel@tonic-gate 
780*7c478bd9Sstevel@tonic-gate 	/* Failure responses to AT requests (received) */
781*7c478bd9Sstevel@tonic-gate 	uint_t			atresp_quad_rd_fail;
782*7c478bd9Sstevel@tonic-gate 	uint_t			atresp_blk_rd_fail;
783*7c478bd9Sstevel@tonic-gate 	uint_t			atresp_quad_wr_fail;
784*7c478bd9Sstevel@tonic-gate 	uint_t			atresp_blk_wr_fail;
785*7c478bd9Sstevel@tonic-gate 	uint_t			atresp_lock32_fail;
786*7c478bd9Sstevel@tonic-gate 	uint_t			atresp_lock64_fail;
787*7c478bd9Sstevel@tonic-gate 
788*7c478bd9Sstevel@tonic-gate 
789*7c478bd9Sstevel@tonic-gate 	/* Allocate & free requests */
790*7c478bd9Sstevel@tonic-gate 	uint_t			cmd_alloc;
791*7c478bd9Sstevel@tonic-gate 	uint_t			cmd_alloc_fail;
792*7c478bd9Sstevel@tonic-gate 	uint_t			cmd_free;
793*7c478bd9Sstevel@tonic-gate 	uint_t			addr_phys_alloc;
794*7c478bd9Sstevel@tonic-gate 	uint_t			addr_posted_alloc;
795*7c478bd9Sstevel@tonic-gate 	uint_t			addr_normal_alloc;
796*7c478bd9Sstevel@tonic-gate 	uint_t			addr_csr_alloc;
797*7c478bd9Sstevel@tonic-gate 	uint_t			addr_alloc_fail;
798*7c478bd9Sstevel@tonic-gate 	uint_t			addr_space_free;
799*7c478bd9Sstevel@tonic-gate 
800*7c478bd9Sstevel@tonic-gate 	/* Bus reset and miscellaneous */
801*7c478bd9Sstevel@tonic-gate 	uint_t			bus_reset;
802*7c478bd9Sstevel@tonic-gate 	uint_t			selfid_complete;
803*7c478bd9Sstevel@tonic-gate 	uint_t			selfid_buffer_error;
804*7c478bd9Sstevel@tonic-gate 	uint_t			pending_q_insert;
805*7c478bd9Sstevel@tonic-gate 	uint64_t		guid;
806*7c478bd9Sstevel@tonic-gate };
807*7c478bd9Sstevel@tonic-gate 
808*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Statistics", \
809*7c478bd9Sstevel@tonic-gate 	s1394_kstat_s::{arreq_blk_rd arreq_blk_wr arreq_quad_rd arreq_quad_wr \
810*7c478bd9Sstevel@tonic-gate 	cmd_free selfid_buffer_error arreq_posted_write_error}))
811*7c478bd9Sstevel@tonic-gate 
812*7c478bd9Sstevel@tonic-gate /* s1394_isoch_cec_t */
813*7c478bd9Sstevel@tonic-gate struct s1394_isoch_cec_s {
814*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_t		*cec_next;
815*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_t		*cec_prev;
816*7c478bd9Sstevel@tonic-gate 
817*7c478bd9Sstevel@tonic-gate 	kmutex_t			isoch_cec_mutex;
818*7c478bd9Sstevel@tonic-gate 
819*7c478bd9Sstevel@tonic-gate 	/* Isoch CEC member list */
820*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_type_t		cec_type;
821*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_member_list_head;
822*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_member_list_tail;
823*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_member_talker;
824*7c478bd9Sstevel@tonic-gate 
825*7c478bd9Sstevel@tonic-gate 	/* Properties given in t1394_alloc_isoch_cec() */
826*7c478bd9Sstevel@tonic-gate 	t1394_isoch_cec_props_t		cec_alloc_props;
827*7c478bd9Sstevel@tonic-gate 
828*7c478bd9Sstevel@tonic-gate 	/* Current state of Isoch CEC */
829*7c478bd9Sstevel@tonic-gate 	uint_t				filter_min_speed;
830*7c478bd9Sstevel@tonic-gate 	uint_t				filter_max_speed;
831*7c478bd9Sstevel@tonic-gate 	uint_t				filter_current_speed;
832*7c478bd9Sstevel@tonic-gate 	uint64_t			filter_channel_mask;
833*7c478bd9Sstevel@tonic-gate 	uint_t				bandwidth;
834*7c478bd9Sstevel@tonic-gate 	t1394_cec_options_t		cec_options;
835*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_state_t		state_transitions;
836*7c478bd9Sstevel@tonic-gate 	boolean_t			in_callbacks;
837*7c478bd9Sstevel@tonic-gate 	boolean_t			in_fail_callbacks;
838*7c478bd9Sstevel@tonic-gate 	kcondvar_t			in_callbacks_cv;
839*7c478bd9Sstevel@tonic-gate 	boolean_t			cec_want_wakeup;
840*7c478bd9Sstevel@tonic-gate 
841*7c478bd9Sstevel@tonic-gate 	boolean_t			realloc_valid;
842*7c478bd9Sstevel@tonic-gate 	boolean_t			realloc_failed;
843*7c478bd9Sstevel@tonic-gate 	t1394_isoch_rsrc_error_t	realloc_fail_reason;
844*7c478bd9Sstevel@tonic-gate 	uint_t				realloc_chnl_num;
845*7c478bd9Sstevel@tonic-gate 	uint_t				realloc_bandwidth;
846*7c478bd9Sstevel@tonic-gate 	uint_t				realloc_speed;
847*7c478bd9Sstevel@tonic-gate };
848*7c478bd9Sstevel@tonic-gate #define	CEC_IN_ANY_CALLBACKS(cec)	(((cec)->in_callbacks == B_TRUE) || \
849*7c478bd9Sstevel@tonic-gate 					((cec)->in_fail_callbacks == B_TRUE))
850*7c478bd9Sstevel@tonic-gate 
851*7c478bd9Sstevel@tonic-gate #define	CEC_TRANSITION_LEGAL(cec, tran)	((cec)->state_transitions & (tran))
852*7c478bd9Sstevel@tonic-gate #define	CEC_SET_LEGAL(cec, tran)	((cec)->state_transitions |= (tran))
853*7c478bd9Sstevel@tonic-gate #define	CEC_SET_ILLEGAL(cec, tran)	((cec)->state_transitions &= ~(tran))
854*7c478bd9Sstevel@tonic-gate 
855*7c478bd9Sstevel@tonic-gate 
856*7c478bd9Sstevel@tonic-gate /* s1394_isoch_cec_member_t */
857*7c478bd9Sstevel@tonic-gate struct s1394_isoch_cec_member_s {
858*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_mem_next;
859*7c478bd9Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_mem_prev;
860*7c478bd9Sstevel@tonic-gate 
861*7c478bd9Sstevel@tonic-gate 	/* Events for Isoch CEC member - given in t1394_join_isoch_cec() */
862*7c478bd9Sstevel@tonic-gate 	t1394_isoch_cec_evts_t		isoch_cec_evts;
863*7c478bd9Sstevel@tonic-gate 	opaque_t			isoch_cec_evts_arg;
864*7c478bd9Sstevel@tonic-gate 	uint64_t			req_channel_mask;
865*7c478bd9Sstevel@tonic-gate 	uint_t				req_max_speed;
866*7c478bd9Sstevel@tonic-gate 	t1394_jii_options_t		cec_mem_options;
867*7c478bd9Sstevel@tonic-gate 	s1394_target_t			*cec_mem_target;
868*7c478bd9Sstevel@tonic-gate };
869*7c478bd9Sstevel@tonic-gate 
870*7c478bd9Sstevel@tonic-gate /* cmd1394_fa_cmd_priv_t - per-command data for fixed address support */
871*7c478bd9Sstevel@tonic-gate typedef struct s1394_fa_cmd_priv_s {
872*7c478bd9Sstevel@tonic-gate 	s1394_fa_type_t		type;
873*7c478bd9Sstevel@tonic-gate 	void			(*completion_callback)();
874*7c478bd9Sstevel@tonic-gate 	opaque_t		callback_arg;
875*7c478bd9Sstevel@tonic-gate } s1394_fa_cmd_priv_t;
876*7c478bd9Sstevel@tonic-gate 
877*7c478bd9Sstevel@tonic-gate /* s1394_cmd_priv_t */
878*7c478bd9Sstevel@tonic-gate typedef struct s1394_cmd_priv_s {
879*7c478bd9Sstevel@tonic-gate 	/* Services Layer private structure for asynch commands */
880*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*cmd_priv_next;
881*7c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t		*cmd_priv_prev;
882*7c478bd9Sstevel@tonic-gate 
883*7c478bd9Sstevel@tonic-gate 	uint32_t		cmd_priv_xfer_type;
884*7c478bd9Sstevel@tonic-gate 	s1394_target_t		*sent_by_target;
885*7c478bd9Sstevel@tonic-gate 	s1394_hal_t		*sent_on_hal;
886*7c478bd9Sstevel@tonic-gate 
887*7c478bd9Sstevel@tonic-gate 	int			lock_req_step;
888*7c478bd9Sstevel@tonic-gate 	int			temp_num_retries;
889*7c478bd9Sstevel@tonic-gate 
890*7c478bd9Sstevel@tonic-gate 	size_t			data_remaining;
891*7c478bd9Sstevel@tonic-gate 
892*7c478bd9Sstevel@tonic-gate 	kmutex_t		blocking_mutex;
893*7c478bd9Sstevel@tonic-gate 	kcondvar_t		blocking_cv;
894*7c478bd9Sstevel@tonic-gate 	boolean_t		blocking_flag;
895*7c478bd9Sstevel@tonic-gate 
896*7c478bd9Sstevel@tonic-gate 	boolean_t		cmd_in_use;
897*7c478bd9Sstevel@tonic-gate 	boolean_t		posted_write;
898*7c478bd9Sstevel@tonic-gate 	boolean_t		arreq_valid_addr;
899*7c478bd9Sstevel@tonic-gate 
900*7c478bd9Sstevel@tonic-gate 	/*
901*7c478bd9Sstevel@tonic-gate 	 * Commands can be extended to support additional functionality.
902*7c478bd9Sstevel@tonic-gate 	 * The only extension at this time is FA (currently used only for FCP).
903*7c478bd9Sstevel@tonic-gate 	 * The downside here is that every command should carry FA overhead
904*7c478bd9Sstevel@tonic-gate 	 * even if the target doesn't use FA. However, alternative approaches
905*7c478bd9Sstevel@tonic-gate 	 * would require separate allocation of FA overhead per command, which
906*7c478bd9Sstevel@tonic-gate 	 * complicates the code and fragments the memory -- seems not worth it
907*7c478bd9Sstevel@tonic-gate 	 * given that FA overhead is just a few bytes and there's a limit of
908*7c478bd9Sstevel@tonic-gate 	 * 256 commands per target.
909*7c478bd9Sstevel@tonic-gate 	 */
910*7c478bd9Sstevel@tonic-gate 	int			cmd_ext_type;
911*7c478bd9Sstevel@tonic-gate 	union {
912*7c478bd9Sstevel@tonic-gate 		s1394_fa_cmd_priv_t	fa;
913*7c478bd9Sstevel@tonic-gate 	} cmd_ext;
914*7c478bd9Sstevel@tonic-gate 
915*7c478bd9Sstevel@tonic-gate 	h1394_cmd_priv_t	hal_cmd_private;
916*7c478bd9Sstevel@tonic-gate } s1394_cmd_priv_t;
917*7c478bd9Sstevel@tonic-gate #define	S1394_GET_CMD_PRIV(cmd)	\
918*7c478bd9Sstevel@tonic-gate 	((s1394_cmd_priv_t *)((uchar_t *)(cmd) + sizeof (cmd1394_cmd_t)))
919*7c478bd9Sstevel@tonic-gate 
920*7c478bd9Sstevel@tonic-gate /* command extension types */
921*7c478bd9Sstevel@tonic-gate enum {
922*7c478bd9Sstevel@tonic-gate 	S1394_CMD_EXT_FA	= 1
923*7c478bd9Sstevel@tonic-gate };
924*7c478bd9Sstevel@tonic-gate #define	S1394_GET_FA_CMD_PRIV(cmd)	(&(S1394_GET_CMD_PRIV(cmd)->cmd_ext.fa))
925*7c478bd9Sstevel@tonic-gate 
926*7c478bd9Sstevel@tonic-gate #define	S1394_IS_CMD_FCP(s_priv) \
927*7c478bd9Sstevel@tonic-gate 	((s_priv->cmd_ext.fa.type == S1394_FA_TYPE_FCP_CTL) || \
928*7c478bd9Sstevel@tonic-gate 	(s_priv->cmd_ext.fa.type == S1394_FA_TYPE_FCP_TGT))
929*7c478bd9Sstevel@tonic-gate 
930*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Unique per command", \
931*7c478bd9Sstevel@tonic-gate 	s1394_cmd_priv_s::cmd_priv_xfer_type))
932*7c478bd9Sstevel@tonic-gate 
933*7c478bd9Sstevel@tonic-gate 
934*7c478bd9Sstevel@tonic-gate /* s1394_state_t */
935*7c478bd9Sstevel@tonic-gate typedef struct s1394_state_s {
936*7c478bd9Sstevel@tonic-gate 	/* HAL list */
937*7c478bd9Sstevel@tonic-gate 	kmutex_t	hal_list_mutex;
938*7c478bd9Sstevel@tonic-gate 	s1394_hal_t	*hal_head;
939*7c478bd9Sstevel@tonic-gate 	s1394_hal_t	*hal_tail;
940*7c478bd9Sstevel@tonic-gate } s1394_state_t;
941*7c478bd9Sstevel@tonic-gate 
942*7c478bd9Sstevel@tonic-gate /* Service Layer Global State Pointer */
943*7c478bd9Sstevel@tonic-gate extern   s1394_state_t  *s1394_statep;
944*7c478bd9Sstevel@tonic-gate 
945*7c478bd9Sstevel@tonic-gate 
946*7c478bd9Sstevel@tonic-gate /* 1394 Services Layer Internals - 1394 Address Space Routines */
947*7c478bd9Sstevel@tonic-gate int s1394_request_addr_blk(s1394_hal_t *hal, t1394_alloc_addr_t *addr_allocp);
948*7c478bd9Sstevel@tonic-gate 
949*7c478bd9Sstevel@tonic-gate int s1394_claim_addr_blk(s1394_hal_t *hal, t1394_alloc_addr_t *addr_allocp);
950*7c478bd9Sstevel@tonic-gate 
951*7c478bd9Sstevel@tonic-gate int s1394_free_addr_blk(s1394_hal_t *hal, s1394_addr_space_blk_t *blk);
952*7c478bd9Sstevel@tonic-gate 
953*7c478bd9Sstevel@tonic-gate int s1394_reserve_addr_blk(s1394_hal_t *hal, t1394_alloc_addr_t *addr_allocp);
954*7c478bd9Sstevel@tonic-gate 
955*7c478bd9Sstevel@tonic-gate int s1394_init_addr_space(s1394_hal_t *hal);
956*7c478bd9Sstevel@tonic-gate 
957*7c478bd9Sstevel@tonic-gate void s1394_destroy_addr_space(s1394_hal_t *hal);
958*7c478bd9Sstevel@tonic-gate 
959*7c478bd9Sstevel@tonic-gate void s1394_free_list_insert(s1394_hal_t *hal, s1394_addr_space_blk_t *new_blk);
960*7c478bd9Sstevel@tonic-gate 
961*7c478bd9Sstevel@tonic-gate s1394_addr_space_blk_t *s1394_used_tree_search(s1394_hal_t *hal,
962*7c478bd9Sstevel@tonic-gate     uint64_t addr);
963*7c478bd9Sstevel@tonic-gate 
964*7c478bd9Sstevel@tonic-gate s1394_addr_space_blk_t *s1394_used_tree_delete(s1394_hal_t *hal,
965*7c478bd9Sstevel@tonic-gate     s1394_addr_space_blk_t *z);
966*7c478bd9Sstevel@tonic-gate 
967*7c478bd9Sstevel@tonic-gate boolean_t s1394_is_posted_write(s1394_hal_t *hal, uint64_t addr);
968*7c478bd9Sstevel@tonic-gate 
969*7c478bd9Sstevel@tonic-gate boolean_t s1394_is_physical_addr(s1394_hal_t *hal, uint64_t addr);
970*7c478bd9Sstevel@tonic-gate 
971*7c478bd9Sstevel@tonic-gate boolean_t s1394_is_csr_addr(s1394_hal_t *hal, uint64_t addr);
972*7c478bd9Sstevel@tonic-gate 
973*7c478bd9Sstevel@tonic-gate boolean_t s1394_is_normal_addr(s1394_hal_t *hal, uint64_t addr);
974*7c478bd9Sstevel@tonic-gate 
975*7c478bd9Sstevel@tonic-gate /* 1394 Services Layer Internals - Asynchronous Communications Routines */
976*7c478bd9Sstevel@tonic-gate int s1394_alloc_cmd(s1394_hal_t *hal, uint_t flags, cmd1394_cmd_t **cmdp);
977*7c478bd9Sstevel@tonic-gate 
978*7c478bd9Sstevel@tonic-gate int s1394_free_cmd(s1394_hal_t *hal, cmd1394_cmd_t **cmdp);
979*7c478bd9Sstevel@tonic-gate 
980*7c478bd9Sstevel@tonic-gate int s1394_xfer_asynch_command(s1394_hal_t *hal, cmd1394_cmd_t *cmd, int *err);
981*7c478bd9Sstevel@tonic-gate 
982*7c478bd9Sstevel@tonic-gate int s1394_setup_asynch_command(s1394_hal_t *hal, s1394_target_t *target,
983*7c478bd9Sstevel@tonic-gate     cmd1394_cmd_t *cmd, uint32_t xfer_type, int *err);
984*7c478bd9Sstevel@tonic-gate 
985*7c478bd9Sstevel@tonic-gate void s1394_insert_q_asynch_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
986*7c478bd9Sstevel@tonic-gate 
987*7c478bd9Sstevel@tonic-gate void s1394_remove_q_asynch_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
988*7c478bd9Sstevel@tonic-gate 
989*7c478bd9Sstevel@tonic-gate void s1394_atreq_cmd_complete(s1394_hal_t *hal, cmd1394_cmd_t *req,
990*7c478bd9Sstevel@tonic-gate     int status);
991*7c478bd9Sstevel@tonic-gate 
992*7c478bd9Sstevel@tonic-gate void s1394_atresp_cmd_complete(s1394_hal_t *hal, cmd1394_cmd_t *resp,
993*7c478bd9Sstevel@tonic-gate     int status);
994*7c478bd9Sstevel@tonic-gate 
995*7c478bd9Sstevel@tonic-gate int s1394_send_response(s1394_hal_t *hal, cmd1394_cmd_t *resp);
996*7c478bd9Sstevel@tonic-gate 
997*7c478bd9Sstevel@tonic-gate int s1394_compare_swap(s1394_hal_t *hal, s1394_target_t *target,
998*7c478bd9Sstevel@tonic-gate     cmd1394_cmd_t *cmd);
999*7c478bd9Sstevel@tonic-gate 
1000*7c478bd9Sstevel@tonic-gate int s1394_split_lock_req(s1394_hal_t *hal, s1394_target_t *target,
1001*7c478bd9Sstevel@tonic-gate     cmd1394_cmd_t *cmd);
1002*7c478bd9Sstevel@tonic-gate 
1003*7c478bd9Sstevel@tonic-gate void s1394_pending_q_insert(s1394_hal_t *hal, cmd1394_cmd_t *cmd, uint_t flags);
1004*7c478bd9Sstevel@tonic-gate 
1005*7c478bd9Sstevel@tonic-gate void s1394_resend_pending_cmds(s1394_hal_t *hal);
1006*7c478bd9Sstevel@tonic-gate 
1007*7c478bd9Sstevel@tonic-gate /* 1394 Services Layer Internals - Bus Reset Routines */
1008*7c478bd9Sstevel@tonic-gate int s1394_parse_selfid_buffer(s1394_hal_t *hal, void *selfid_buf_addr,
1009*7c478bd9Sstevel@tonic-gate     uint32_t selfid_size);
1010*7c478bd9Sstevel@tonic-gate 
1011*7c478bd9Sstevel@tonic-gate void s1394_sort_selfids(s1394_hal_t *hal);
1012*7c478bd9Sstevel@tonic-gate 
1013*7c478bd9Sstevel@tonic-gate void s1394_init_topology_tree(s1394_hal_t *hal, boolean_t copied,
1014*7c478bd9Sstevel@tonic-gate     ushort_t number_of_nodes);
1015*7c478bd9Sstevel@tonic-gate 
1016*7c478bd9Sstevel@tonic-gate int s1394_topology_tree_build(s1394_hal_t *hal);
1017*7c478bd9Sstevel@tonic-gate 
1018*7c478bd9Sstevel@tonic-gate void s1394_topology_tree_mark_all_unvisited(s1394_hal_t *hal);
1019*7c478bd9Sstevel@tonic-gate 
1020*7c478bd9Sstevel@tonic-gate void s1394_old_tree_mark_all_unvisited(s1394_hal_t *hal);
1021*7c478bd9Sstevel@tonic-gate 
1022*7c478bd9Sstevel@tonic-gate void s1394_old_tree_mark_all_unmatched(s1394_hal_t *hal);
1023*7c478bd9Sstevel@tonic-gate 
1024*7c478bd9Sstevel@tonic-gate void s1394_copy_old_tree(s1394_hal_t *hal);
1025*7c478bd9Sstevel@tonic-gate 
1026*7c478bd9Sstevel@tonic-gate void s1394_match_tree_nodes(s1394_hal_t *hal);
1027*7c478bd9Sstevel@tonic-gate 
1028*7c478bd9Sstevel@tonic-gate int s1394_topology_tree_calculate_diameter(s1394_hal_t *hal);
1029*7c478bd9Sstevel@tonic-gate 
1030*7c478bd9Sstevel@tonic-gate int s1394_gap_count_optimize(int diameter);
1031*7c478bd9Sstevel@tonic-gate 
1032*7c478bd9Sstevel@tonic-gate int s1394_get_current_gap_count(s1394_hal_t *hal);
1033*7c478bd9Sstevel@tonic-gate 
1034*7c478bd9Sstevel@tonic-gate void s1394_speed_map_fill(s1394_hal_t *hal);
1035*7c478bd9Sstevel@tonic-gate 
1036*7c478bd9Sstevel@tonic-gate uint8_t s1394_speed_map_get(s1394_hal_t *hal, uint32_t from_node,
1037*7c478bd9Sstevel@tonic-gate     uint32_t to_node);
1038*7c478bd9Sstevel@tonic-gate 
1039*7c478bd9Sstevel@tonic-gate void s1394_update_speed_map_link_speeds(s1394_hal_t *hal);
1040*7c478bd9Sstevel@tonic-gate 
1041*7c478bd9Sstevel@tonic-gate int s1394_get_isoch_rsrc_mgr(s1394_hal_t *hal);
1042*7c478bd9Sstevel@tonic-gate 
1043*7c478bd9Sstevel@tonic-gate void s1394_physical_arreq_setup_all(s1394_hal_t *hal);
1044*7c478bd9Sstevel@tonic-gate 
1045*7c478bd9Sstevel@tonic-gate void s1394_physical_arreq_set_one(s1394_target_t *target);
1046*7c478bd9Sstevel@tonic-gate 
1047*7c478bd9Sstevel@tonic-gate void s1394_physical_arreq_clear_one(s1394_target_t *target);
1048*7c478bd9Sstevel@tonic-gate 
1049*7c478bd9Sstevel@tonic-gate s1394_node_t *s1394_topology_tree_get_root_node(s1394_hal_t *hal);
1050*7c478bd9Sstevel@tonic-gate 
1051*7c478bd9Sstevel@tonic-gate /* 1394 Services Layer Internals - CSR and Config ROM Routines */
1052*7c478bd9Sstevel@tonic-gate int s1394_setup_CSR_space(s1394_hal_t *hal);
1053*7c478bd9Sstevel@tonic-gate 
1054*7c478bd9Sstevel@tonic-gate void s1394_CSR_topology_map_update(s1394_hal_t *hal);
1055*7c478bd9Sstevel@tonic-gate 
1056*7c478bd9Sstevel@tonic-gate void s1394_CSR_topology_map_disable(s1394_hal_t *hal);
1057*7c478bd9Sstevel@tonic-gate 
1058*7c478bd9Sstevel@tonic-gate int s1394_init_local_config_rom(s1394_hal_t *hal);
1059*7c478bd9Sstevel@tonic-gate 
1060*7c478bd9Sstevel@tonic-gate void s1394_destroy_local_config_rom(s1394_hal_t *hal);
1061*7c478bd9Sstevel@tonic-gate 
1062*7c478bd9Sstevel@tonic-gate int s1394_add_config_rom_entry(s1394_hal_t *hal, uint8_t key,
1063*7c478bd9Sstevel@tonic-gate     uint32_t *buffer, uint_t size, void **handle, int *status);
1064*7c478bd9Sstevel@tonic-gate 
1065*7c478bd9Sstevel@tonic-gate int s1394_remove_config_rom_entry(s1394_hal_t *hal, void **handle,
1066*7c478bd9Sstevel@tonic-gate     int *status);
1067*7c478bd9Sstevel@tonic-gate 
1068*7c478bd9Sstevel@tonic-gate void s1394_update_config_rom_callback(void *arg);
1069*7c478bd9Sstevel@tonic-gate 
1070*7c478bd9Sstevel@tonic-gate /* In s1394_dev_disc.c */
1071*7c478bd9Sstevel@tonic-gate void s1394_br_thread(s1394_hal_t *hal);
1072*7c478bd9Sstevel@tonic-gate 
1073*7c478bd9Sstevel@tonic-gate void s1394_free_cfgrom(s1394_hal_t *hal, s1394_node_t *node,
1074*7c478bd9Sstevel@tonic-gate     s1394_free_cfgrom_t options);
1075*7c478bd9Sstevel@tonic-gate 
1076*7c478bd9Sstevel@tonic-gate void s1394_copy_cfgrom(s1394_node_t *to, s1394_node_t *from);
1077*7c478bd9Sstevel@tonic-gate 
1078*7c478bd9Sstevel@tonic-gate int s1394_read_rest_of_cfgrom(s1394_hal_t *hal, s1394_node_t *node,
1079*7c478bd9Sstevel@tonic-gate     s1394_status_t *status);
1080*7c478bd9Sstevel@tonic-gate 
1081*7c478bd9Sstevel@tonic-gate void s1394_cfgrom_parse_unit_dir(uint32_t *unit_dir, uint32_t *addr_hi,
1082*7c478bd9Sstevel@tonic-gate     uint32_t *addr_lo, uint32_t *size_hi, uint32_t *size_lo);
1083*7c478bd9Sstevel@tonic-gate 
1084*7c478bd9Sstevel@tonic-gate boolean_t s1394_valid_cfgrom(s1394_hal_t *hal, s1394_node_t *node);
1085*7c478bd9Sstevel@tonic-gate 
1086*7c478bd9Sstevel@tonic-gate boolean_t s1394_valid_dir(s1394_hal_t *hal, s1394_node_t *node, uint32_t key,
1087*7c478bd9Sstevel@tonic-gate     uint32_t *dir);
1088*7c478bd9Sstevel@tonic-gate 
1089*7c478bd9Sstevel@tonic-gate void s1394_get_maxpayload(s1394_target_t *target, uint_t *dev_max_payload,
1090*7c478bd9Sstevel@tonic-gate     uint_t *current_max_payload);
1091*7c478bd9Sstevel@tonic-gate 
1092*7c478bd9Sstevel@tonic-gate int s1394_lock_tree(s1394_hal_t *hal);
1093*7c478bd9Sstevel@tonic-gate 
1094*7c478bd9Sstevel@tonic-gate void s1394_unlock_tree(s1394_hal_t *hal);
1095*7c478bd9Sstevel@tonic-gate 
1096*7c478bd9Sstevel@tonic-gate /* 1394 Services Layer Driver - Hotplug Routines */
1097*7c478bd9Sstevel@tonic-gate dev_info_t *s1394_devi_find(dev_info_t *pdip, char *name, char *caddr);
1098*7c478bd9Sstevel@tonic-gate 
1099*7c478bd9Sstevel@tonic-gate int s1394_update_devinfo_tree(s1394_hal_t *hal, s1394_node_t *node);
1100*7c478bd9Sstevel@tonic-gate 
1101*7c478bd9Sstevel@tonic-gate int s1394_offline_node(s1394_hal_t *hal, s1394_node_t *node);
1102*7c478bd9Sstevel@tonic-gate 
1103*7c478bd9Sstevel@tonic-gate int s1394_process_topology_tree(s1394_hal_t *hal, int *wait_for_cbs,
1104*7c478bd9Sstevel@tonic-gate     uint_t *wait_gen);
1105*7c478bd9Sstevel@tonic-gate 
1106*7c478bd9Sstevel@tonic-gate int s1394_process_old_tree(s1394_hal_t *hal);
1107*7c478bd9Sstevel@tonic-gate 
1108*7c478bd9Sstevel@tonic-gate void s1394_add_target_to_node(s1394_target_t *target);
1109*7c478bd9Sstevel@tonic-gate 
1110*7c478bd9Sstevel@tonic-gate void s1394_remove_target_from_node(s1394_target_t *target);
1111*7c478bd9Sstevel@tonic-gate 
1112*7c478bd9Sstevel@tonic-gate /* fixed address support */
1113*7c478bd9Sstevel@tonic-gate int s1394_fa_claim_addr(s1394_hal_t *hal, s1394_fa_type_t type,
1114*7c478bd9Sstevel@tonic-gate     s1394_fa_descr_t *descr);
1115*7c478bd9Sstevel@tonic-gate 
1116*7c478bd9Sstevel@tonic-gate void s1394_fa_free_addr(s1394_hal_t *hal, s1394_fa_type_t type);
1117*7c478bd9Sstevel@tonic-gate 
1118*7c478bd9Sstevel@tonic-gate void s1394_fa_list_add(s1394_hal_t *hal, s1394_target_t *target,
1119*7c478bd9Sstevel@tonic-gate     s1394_fa_type_t type);
1120*7c478bd9Sstevel@tonic-gate 
1121*7c478bd9Sstevel@tonic-gate int s1394_fa_list_remove(s1394_hal_t *hal, s1394_target_t *target,
1122*7c478bd9Sstevel@tonic-gate     s1394_fa_type_t type);
1123*7c478bd9Sstevel@tonic-gate 
1124*7c478bd9Sstevel@tonic-gate boolean_t s1394_fa_list_is_empty(s1394_hal_t *hal, s1394_fa_type_t type);
1125*7c478bd9Sstevel@tonic-gate 
1126*7c478bd9Sstevel@tonic-gate uint_t s1394_fa_list_gen(s1394_hal_t *hal, s1394_fa_type_t type);
1127*7c478bd9Sstevel@tonic-gate 
1128*7c478bd9Sstevel@tonic-gate void s1394_fa_init_cmd(s1394_cmd_priv_t *s_priv, s1394_fa_type_t type);
1129*7c478bd9Sstevel@tonic-gate 
1130*7c478bd9Sstevel@tonic-gate void s1394_fa_convert_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
1131*7c478bd9Sstevel@tonic-gate 
1132*7c478bd9Sstevel@tonic-gate void s1394_fa_restore_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
1133*7c478bd9Sstevel@tonic-gate 
1134*7c478bd9Sstevel@tonic-gate void s1394_fa_check_restore_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
1135*7c478bd9Sstevel@tonic-gate 
1136*7c478bd9Sstevel@tonic-gate /* FCP */
1137*7c478bd9Sstevel@tonic-gate int s1394_fcp_hal_init(s1394_hal_t *hal);
1138*7c478bd9Sstevel@tonic-gate 
1139*7c478bd9Sstevel@tonic-gate int s1394_fcp_register_ctl(s1394_target_t *target, t1394_fcp_evts_t *evts);
1140*7c478bd9Sstevel@tonic-gate 
1141*7c478bd9Sstevel@tonic-gate int s1394_fcp_register_tgt(s1394_target_t *target, t1394_fcp_evts_t *evts);
1142*7c478bd9Sstevel@tonic-gate 
1143*7c478bd9Sstevel@tonic-gate int s1394_fcp_unregister_ctl(s1394_target_t *target);
1144*7c478bd9Sstevel@tonic-gate 
1145*7c478bd9Sstevel@tonic-gate int s1394_fcp_unregister_tgt(s1394_target_t *target);
1146*7c478bd9Sstevel@tonic-gate 
1147*7c478bd9Sstevel@tonic-gate int s1394_fcp_write_check_cmd(cmd1394_cmd_t *cmd);
1148*7c478bd9Sstevel@tonic-gate 
1149*7c478bd9Sstevel@tonic-gate /* CMP */
1150*7c478bd9Sstevel@tonic-gate int s1394_cmp_register(s1394_target_t *target, t1394_cmp_evts_t *evts);
1151*7c478bd9Sstevel@tonic-gate 
1152*7c478bd9Sstevel@tonic-gate int s1394_cmp_unregister(s1394_target_t *target);
1153*7c478bd9Sstevel@tonic-gate 
1154*7c478bd9Sstevel@tonic-gate int s1394_cmp_read(s1394_target_t *target, t1394_cmp_reg_t reg, uint32_t *valp);
1155*7c478bd9Sstevel@tonic-gate 
1156*7c478bd9Sstevel@tonic-gate int s1394_cmp_cas(s1394_target_t *target, t1394_cmp_reg_t reg, uint32_t arg_val,
1157*7c478bd9Sstevel@tonic-gate     uint32_t new_val, uint32_t *old_valp);
1158*7c478bd9Sstevel@tonic-gate 
1159*7c478bd9Sstevel@tonic-gate /* 1394 Services Layer Internals - Isochronous Communication Routines */
1160*7c478bd9Sstevel@tonic-gate void s1394_isoch_rsrc_realloc(s1394_hal_t *hal);
1161*7c478bd9Sstevel@tonic-gate 
1162*7c478bd9Sstevel@tonic-gate void s1394_isoch_rsrc_realloc_notify(s1394_hal_t *hal);
1163*7c478bd9Sstevel@tonic-gate 
1164*7c478bd9Sstevel@tonic-gate int s1394_channel_alloc(s1394_hal_t *hal, uint32_t channel_mask,
1165*7c478bd9Sstevel@tonic-gate     uint_t generation, uint_t flags, uint32_t *old_channels, int *result);
1166*7c478bd9Sstevel@tonic-gate 
1167*7c478bd9Sstevel@tonic-gate int s1394_channel_free(s1394_hal_t *hal, uint32_t channel_mask,
1168*7c478bd9Sstevel@tonic-gate     uint_t generation, uint_t flags, uint32_t *old_channels, int *result);
1169*7c478bd9Sstevel@tonic-gate 
1170*7c478bd9Sstevel@tonic-gate int s1394_bandwidth_alloc(s1394_hal_t *hal, uint32_t bw_alloc_units,
1171*7c478bd9Sstevel@tonic-gate     uint_t generation, int *result);
1172*7c478bd9Sstevel@tonic-gate 
1173*7c478bd9Sstevel@tonic-gate uint_t s1394_compute_bw_alloc_units(s1394_hal_t *hal, uint_t bandwidth,
1174*7c478bd9Sstevel@tonic-gate     uint_t speed);
1175*7c478bd9Sstevel@tonic-gate 
1176*7c478bd9Sstevel@tonic-gate int s1394_bandwidth_free(s1394_hal_t *hal, uint32_t bw_alloc_units,
1177*7c478bd9Sstevel@tonic-gate     uint_t generation, int *result);
1178*7c478bd9Sstevel@tonic-gate 
1179*7c478bd9Sstevel@tonic-gate void s1394_isoch_cec_list_insert(s1394_hal_t *hal, s1394_isoch_cec_t *cec);
1180*7c478bd9Sstevel@tonic-gate 
1181*7c478bd9Sstevel@tonic-gate void s1394_isoch_cec_list_remove(s1394_hal_t *hal, s1394_isoch_cec_t *cec);
1182*7c478bd9Sstevel@tonic-gate 
1183*7c478bd9Sstevel@tonic-gate void s1394_isoch_cec_member_list_insert(s1394_hal_t *hal,
1184*7c478bd9Sstevel@tonic-gate     s1394_isoch_cec_t *cec, s1394_isoch_cec_member_t *member);
1185*7c478bd9Sstevel@tonic-gate 
1186*7c478bd9Sstevel@tonic-gate void s1394_isoch_cec_member_list_remove(s1394_hal_t *hal,
1187*7c478bd9Sstevel@tonic-gate     s1394_isoch_cec_t *cec, s1394_isoch_cec_member_t *member);
1188*7c478bd9Sstevel@tonic-gate 
1189*7c478bd9Sstevel@tonic-gate /* 1394 Services Layer Internals - Miscellaneous Routines */
1190*7c478bd9Sstevel@tonic-gate void s1394_cleanup_for_detach(s1394_hal_t *hal, uint_t cleanup_level);
1191*7c478bd9Sstevel@tonic-gate 
1192*7c478bd9Sstevel@tonic-gate void s1394_hal_shutdown(s1394_hal_t *hal, boolean_t disable_hal);
1193*7c478bd9Sstevel@tonic-gate 
1194*7c478bd9Sstevel@tonic-gate void s1394_initiate_hal_reset(s1394_hal_t *hal, int reason);
1195*7c478bd9Sstevel@tonic-gate 
1196*7c478bd9Sstevel@tonic-gate boolean_t s1394_on_br_thread(s1394_hal_t *hal);
1197*7c478bd9Sstevel@tonic-gate 
1198*7c478bd9Sstevel@tonic-gate void s1394_destroy_br_thread(s1394_hal_t *hal);
1199*7c478bd9Sstevel@tonic-gate 
1200*7c478bd9Sstevel@tonic-gate void s1394_tickle_bus_reset_thread(s1394_hal_t *hal);
1201*7c478bd9Sstevel@tonic-gate 
1202*7c478bd9Sstevel@tonic-gate void s1394_block_on_asynch_cmd(cmd1394_cmd_t *cmd);
1203*7c478bd9Sstevel@tonic-gate 
1204*7c478bd9Sstevel@tonic-gate int s1394_HAL_asynch_error(s1394_hal_t *hal, cmd1394_cmd_t *cmd,
1205*7c478bd9Sstevel@tonic-gate     s1394_hal_state_t state);
1206*7c478bd9Sstevel@tonic-gate 
1207*7c478bd9Sstevel@tonic-gate boolean_t s1394_mblk_too_small(cmd1394_cmd_t *cmd);
1208*7c478bd9Sstevel@tonic-gate 
1209*7c478bd9Sstevel@tonic-gate boolean_t s1394_address_rollover(cmd1394_cmd_t *cmd);
1210*7c478bd9Sstevel@tonic-gate 
1211*7c478bd9Sstevel@tonic-gate uint_t s1394_stoi(char *p, int len, int base);
1212*7c478bd9Sstevel@tonic-gate 
1213*7c478bd9Sstevel@tonic-gate uint_t s1394_CRC16(uint_t *d, uint_t crc_length);
1214*7c478bd9Sstevel@tonic-gate 
1215*7c478bd9Sstevel@tonic-gate uint_t s1394_CRC16_old(uint_t *d, uint_t crc_length);
1216*7c478bd9Sstevel@tonic-gate 
1217*7c478bd9Sstevel@tonic-gate int s1394_ioctl(s1394_hal_t *hal, int cmd, intptr_t arg, int mode,
1218*7c478bd9Sstevel@tonic-gate     cred_t *cred_p, int *rval_p);
1219*7c478bd9Sstevel@tonic-gate 
1220*7c478bd9Sstevel@tonic-gate void s1394_check_pwr_mgmt(s1394_hal_t *hal, s1394_target_t *target,
1221*7c478bd9Sstevel@tonic-gate     boolean_t add);
1222*7c478bd9Sstevel@tonic-gate 
1223*7c478bd9Sstevel@tonic-gate int s1394_kstat_init(s1394_hal_t *hal);
1224*7c478bd9Sstevel@tonic-gate 
1225*7c478bd9Sstevel@tonic-gate int s1394_kstat_delete(s1394_hal_t *hal);
1226*7c478bd9Sstevel@tonic-gate 
1227*7c478bd9Sstevel@tonic-gate int s1394_kstat_update(kstat_t *ksp, int rw);
1228*7c478bd9Sstevel@tonic-gate 
1229*7c478bd9Sstevel@tonic-gate void s1394_addr_alloc_kstat(s1394_hal_t *hal, uint64_t addr);
1230*7c478bd9Sstevel@tonic-gate 
1231*7c478bd9Sstevel@tonic-gate void s1394_print_node_info(s1394_hal_t *hal);
1232*7c478bd9Sstevel@tonic-gate 
1233*7c478bd9Sstevel@tonic-gate s1394_hal_t *s1394_dip_to_hal(dev_info_t *dip);
1234*7c478bd9Sstevel@tonic-gate 
1235*7c478bd9Sstevel@tonic-gate s1394_target_t *s1394_target_from_dip(s1394_hal_t *hal, dev_info_t *tdip);
1236*7c478bd9Sstevel@tonic-gate s1394_target_t *s1394_target_from_dip_locked(s1394_hal_t *hal,
1237*7c478bd9Sstevel@tonic-gate     dev_info_t *tdip);
1238*7c478bd9Sstevel@tonic-gate 
1239*7c478bd9Sstevel@tonic-gate void s1394_destroy_timers(s1394_hal_t *hal);
1240*7c478bd9Sstevel@tonic-gate 
1241*7c478bd9Sstevel@tonic-gate void s1394_cycle_too_long_callback(void *arg);
1242*7c478bd9Sstevel@tonic-gate 
1243*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1244*7c478bd9Sstevel@tonic-gate }
1245*7c478bd9Sstevel@tonic-gate #endif
1246*7c478bd9Sstevel@tonic-gate 
1247*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_1394_S1394_H */
1248