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 (c) 1996, by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_DADA_IMPL_TRANSPORT_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_DADA_IMPL_TRANSPORT_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  * Include loadable module wrapper.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
38*7c478bd9Sstevel@tonic-gate extern "C" {
39*7c478bd9Sstevel@tonic-gate #endif
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * DCD transport structure
44*7c478bd9Sstevel@tonic-gate  *	As each host adapter makes itself known to the system,
45*7c478bd9Sstevel@tonic-gate  * 	It will create and register with the library the structure
46*7c478bd9Sstevel@tonic-gate  * 	describe below. This is so that the library knows how to route
47*7c478bd9Sstevel@tonic-gate  *	packets, resource control requests, and capability requests
48*7c478bd9Sstevel@tonic-gate  * 	for any  particular host adapter. The 'a_hba_tran' field of a
49*7c478bd9Sstevel@tonic-gate  *	dcd_address structure made known to a target driver will point to
50*7c478bd9Sstevel@tonic-gate  *	one of these transport structures.
51*7c478bd9Sstevel@tonic-gate  */
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate typedef	struct dcd_hba_tran	dcd_hba_tran_t;
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate struct dcd_hba_tran {
56*7c478bd9Sstevel@tonic-gate 	uint_t		version;
57*7c478bd9Sstevel@tonic-gate 	/*
58*7c478bd9Sstevel@tonic-gate 	 * Ptr to the device info structure for thsi particular HBA
59*7c478bd9Sstevel@tonic-gate 	 */
60*7c478bd9Sstevel@tonic-gate 	dev_info_t	*tran_hba_dip;
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate 	/*
63*7c478bd9Sstevel@tonic-gate 	 * Private fields for use by the HBA itself
64*7c478bd9Sstevel@tonic-gate 	 */
65*7c478bd9Sstevel@tonic-gate 	void		*tran_hba_private; /* HBA Softstate */
66*7c478bd9Sstevel@tonic-gate 	void		*tran_tgt_private; /* Target specific info */
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate 	/*
69*7c478bd9Sstevel@tonic-gate 	 * Only used to refer to a particular dcd device
70*7c478bd9Sstevel@tonic-gate 	 * if the entire dcd_hba_tran_structure is cloned
71*7c478bd9Sstevel@tonic-gate 	 * per target device, otherwise NULL.
72*7c478bd9Sstevel@tonic-gate 	 */
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate 	struct	dcd_device	*tran_sd;
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate 	/*
77*7c478bd9Sstevel@tonic-gate 	 * vectors to point to specific HBA entry points.
78*7c478bd9Sstevel@tonic-gate 	 */
79*7c478bd9Sstevel@tonic-gate 	int 		(*tran_tgt_init)(
80*7c478bd9Sstevel@tonic-gate 				dev_info_t	*hba_dip,
81*7c478bd9Sstevel@tonic-gate 				dev_info_t	*tgt_dip,
82*7c478bd9Sstevel@tonic-gate 				dcd_hba_tran_t	*hba_tran,
83*7c478bd9Sstevel@tonic-gate 				struct	dcd_device	*dcd);
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate 	int		(*tran_tgt_probe)(
86*7c478bd9Sstevel@tonic-gate 				struct dcd_device	*dcd,
87*7c478bd9Sstevel@tonic-gate 				int		(*callback)(void));
88*7c478bd9Sstevel@tonic-gate 	int		(*tran_tgt_free)(
89*7c478bd9Sstevel@tonic-gate 				dev_info_t	*hba_dip,
90*7c478bd9Sstevel@tonic-gate 				dev_info_t	*tgt_dip,
91*7c478bd9Sstevel@tonic-gate 				dcd_hba_tran_t	*hba_tran,
92*7c478bd9Sstevel@tonic-gate 				struct	dcd_device	*dcd);
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate 	int		(*tran_start)(
95*7c478bd9Sstevel@tonic-gate 				struct	dcd_address *ap,
96*7c478bd9Sstevel@tonic-gate 				struct	dcd_pkt	*pkt);
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 	int		(*tran_reset)(
99*7c478bd9Sstevel@tonic-gate 				struct dcd_address *ap,
100*7c478bd9Sstevel@tonic-gate 				int		level);
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate 	int		(*tran_abort)(
103*7c478bd9Sstevel@tonic-gate 				struct	dcd_address *ap,
104*7c478bd9Sstevel@tonic-gate 				struct  dcd_pkt	 *pkt);
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 	struct dcd_pkt *(*tran_init_pkt)(
107*7c478bd9Sstevel@tonic-gate 				struct dcd_address	*ap,
108*7c478bd9Sstevel@tonic-gate 				struct	dcd_pkt		*pkt,
109*7c478bd9Sstevel@tonic-gate 				struct	buf		*bp,
110*7c478bd9Sstevel@tonic-gate 				int			cmdlen,
111*7c478bd9Sstevel@tonic-gate 				int			statuslen,
112*7c478bd9Sstevel@tonic-gate 				int			tgtlen,
113*7c478bd9Sstevel@tonic-gate 				int			flags,
114*7c478bd9Sstevel@tonic-gate 				int			(*callback)(
115*7c478bd9Sstevel@tonic-gate 							caddr_t arg),
116*7c478bd9Sstevel@tonic-gate 				caddr_t			callback_arg);
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate 	void		(*tran_destroy_pkt)(
119*7c478bd9Sstevel@tonic-gate 				struct dcd_address *ap,
120*7c478bd9Sstevel@tonic-gate 				struct	dcd_pkt		*pkt);
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate 	void		(*tran_dmafree)(
123*7c478bd9Sstevel@tonic-gate 				struct dcd_address	*ap,
124*7c478bd9Sstevel@tonic-gate 				struct	dcd_pkt		*pkt);
125*7c478bd9Sstevel@tonic-gate 	void		(*tran_sync_pkt)(
126*7c478bd9Sstevel@tonic-gate 				struct dcd_address	*ap,
127*7c478bd9Sstevel@tonic-gate 				struct dcd_pkt		*pkt);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate 	/*
131*7c478bd9Sstevel@tonic-gate 	 * Implementation private specifics.
132*7c478bd9Sstevel@tonic-gate 	 */
133*7c478bd9Sstevel@tonic-gate 	int		tran_hba_flags;		/* flag option */
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate 	/*
136*7c478bd9Sstevel@tonic-gate 	 * min xfer and min/max burst sizes for DDI_CTLOPS_IOMIN
137*7c478bd9Sstevel@tonic-gate 	 */
138*7c478bd9Sstevel@tonic-gate 	uint_t		tran_min_xfer;
139*7c478bd9Sstevel@tonic-gate 	uchar_t		tran_min_burst_size;
140*7c478bd9Sstevel@tonic-gate 	uchar_t		tran_max_burst_size;
141*7c478bd9Sstevel@tonic-gate };
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /*
145*7c478bd9Sstevel@tonic-gate  * Prototypes for DCD HBA interface function.
146*7c478bd9Sstevel@tonic-gate  */
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate extern void	dcd_initialize_hba_interface(void);
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate #ifdef	NO_DADA_FINI_YET
151*7c478bd9Sstevel@tonic-gate extern	void	dcd_uninitialize_hba_interface(void);
152*7c478bd9Sstevel@tonic-gate #endif
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate extern	int	dcd_hba_init(struct modlinkage	*modlp);
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate extern	void	dcd_hab_fini(struct modlinkage	*modlp);
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate #ifdef NOTNEEDED
159*7c478bd9Sstevel@tonic-gate extern	int	dcd_hba_attach(
160*7c478bd9Sstevel@tonic-gate 			dev_info_t	*dip,
161*7c478bd9Sstevel@tonic-gate 			ddi_dma_lim_t	*hba_lim,
162*7c478bd9Sstevel@tonic-gate 			dcd_hba_tran_t	*hba_tran,
163*7c478bd9Sstevel@tonic-gate 			int		flags,
164*7c478bd9Sstevel@tonic-gate 			void		*hba_options);
165*7c478bd9Sstevel@tonic-gate #endif
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate extern int	dcd_hba_attach(
168*7c478bd9Sstevel@tonic-gate 			dev_info_t	*dip,
169*7c478bd9Sstevel@tonic-gate 			ddi_dma_attr_t	*hba_dma_attr,
170*7c478bd9Sstevel@tonic-gate 			dcd_hba_tran_t	*hba_tran,
171*7c478bd9Sstevel@tonic-gate 			int		flags);
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate extern int	dcd_hba_detach(
174*7c478bd9Sstevel@tonic-gate 			dev_info_t	*dip);
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate extern	dcd_hba_tran_t	*dcd_hba_tran_alloc(
177*7c478bd9Sstevel@tonic-gate 			dev_info_t	*dip,
178*7c478bd9Sstevel@tonic-gate 			int		flags);
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate extern	void	dcd_hba_tran_free(
181*7c478bd9Sstevel@tonic-gate 			dcd_hba_tran_t	*hba_tran);
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate extern int	dcd_hba_probe(
184*7c478bd9Sstevel@tonic-gate 			struct	dcd_device  *dcd,
185*7c478bd9Sstevel@tonic-gate 			int	(*callback)(void));
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate extern	struct	dcd_pkt	*dcd_hba_pkt_alloc(
188*7c478bd9Sstevel@tonic-gate 			struct	dcd_address	*ap,
189*7c478bd9Sstevel@tonic-gate 			int		cmdlen,
190*7c478bd9Sstevel@tonic-gate 			int		statuslen,
191*7c478bd9Sstevel@tonic-gate 			int		tgtlen,
192*7c478bd9Sstevel@tonic-gate 			int		hbalen,
193*7c478bd9Sstevel@tonic-gate 			int 		(*callback)(caddr_t),
194*7c478bd9Sstevel@tonic-gate 			caddr_t		arg);
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate extern	void 	dcd_hba_pkt_free(
197*7c478bd9Sstevel@tonic-gate 		struct dcd_address 	*ap,
198*7c478bd9Sstevel@tonic-gate 		struct dcd_pkt		*pkt);
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate extern	int	dcd_hba_lookup_capstr(
201*7c478bd9Sstevel@tonic-gate 			char	*capstr);
202*7c478bd9Sstevel@tonic-gate extern	int	dcd_hba_in_panic(void);
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate /*
205*7c478bd9Sstevel@tonic-gate  * Flags for dcd_hba_attach
206*7c478bd9Sstevel@tonic-gate  */
207*7c478bd9Sstevel@tonic-gate #define	 DCD_HBA_TRAN_CLONE	0x01
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate /*
210*7c478bd9Sstevel@tonic-gate  * Flags for scsi_hab alloaction functions
211*7c478bd9Sstevel@tonic-gate  */
212*7c478bd9Sstevel@tonic-gate #define	DCD_HBA_CANSLEEP 0x01
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
217*7c478bd9Sstevel@tonic-gate }
218*7c478bd9Sstevel@tonic-gate #endif
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_DADA_IMPL_TRANSPORT_H */
221