xref: /illumos-gate/usr/src/uts/sun/sys/dada/impl/transport.h (revision 628e3cbed6489fa1db545d8524a06cd6535af456)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_DADA_IMPL_TRANSPORT_H
28 #define	_SYS_DADA_IMPL_TRANSPORT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Include loadable module wrapper.
34  */
35 #include <sys/modctl.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #ifdef _KERNEL
42 /*
43  * DCD transport structure
44  *	As each host adapter makes itself known to the system,
45  * 	It will create and register with the library the structure
46  * 	describe below. This is so that the library knows how to route
47  *	packets, resource control requests, and capability requests
48  * 	for any  particular host adapter. The 'a_hba_tran' field of a
49  *	dcd_address structure made known to a target driver will point to
50  *	one of these transport structures.
51  */
52 
53 typedef	struct dcd_hba_tran	dcd_hba_tran_t;
54 
55 struct dcd_hba_tran {
56 	uint_t		version;
57 	/*
58 	 * Ptr to the device info structure for thsi particular HBA
59 	 */
60 	dev_info_t	*tran_hba_dip;
61 
62 	/*
63 	 * Private fields for use by the HBA itself
64 	 */
65 	void		*tran_hba_private; /* HBA Softstate */
66 	void		*tran_tgt_private; /* Target specific info */
67 
68 	/*
69 	 * Only used to refer to a particular dcd device
70 	 * if the entire dcd_hba_tran_structure is cloned
71 	 * per target device, otherwise NULL.
72 	 */
73 
74 	struct	dcd_device	*tran_sd;
75 
76 	/*
77 	 * vectors to point to specific HBA entry points.
78 	 */
79 	int 		(*tran_tgt_init)(
80 				dev_info_t	*hba_dip,
81 				dev_info_t	*tgt_dip,
82 				dcd_hba_tran_t	*hba_tran,
83 				struct	dcd_device	*dcd);
84 
85 	int		(*tran_tgt_probe)(
86 				struct dcd_device	*dcd,
87 				int		(*callback)(void));
88 	int		(*tran_tgt_free)(
89 				dev_info_t	*hba_dip,
90 				dev_info_t	*tgt_dip,
91 				dcd_hba_tran_t	*hba_tran,
92 				struct	dcd_device	*dcd);
93 
94 	int		(*tran_start)(
95 				struct	dcd_address *ap,
96 				struct	dcd_pkt	*pkt);
97 
98 	int		(*tran_reset)(
99 				struct dcd_address *ap,
100 				int		level);
101 
102 	int		(*tran_abort)(
103 				struct	dcd_address *ap,
104 				struct  dcd_pkt	 *pkt);
105 
106 	struct dcd_pkt *(*tran_init_pkt)(
107 				struct dcd_address	*ap,
108 				struct	dcd_pkt		*pkt,
109 				struct	buf		*bp,
110 				int			cmdlen,
111 				int			statuslen,
112 				int			tgtlen,
113 				int			flags,
114 				int			(*callback)(
115 							caddr_t arg),
116 				caddr_t			callback_arg);
117 
118 	void		(*tran_destroy_pkt)(
119 				struct dcd_address *ap,
120 				struct	dcd_pkt		*pkt);
121 
122 	void		(*tran_dmafree)(
123 				struct dcd_address	*ap,
124 				struct	dcd_pkt		*pkt);
125 	void		(*tran_sync_pkt)(
126 				struct dcd_address	*ap,
127 				struct dcd_pkt		*pkt);
128 
129 
130 	/*
131 	 * Implementation private specifics.
132 	 */
133 	int		tran_hba_flags;		/* flag option */
134 
135 	/*
136 	 * min xfer and min/max burst sizes for DDI_CTLOPS_IOMIN
137 	 */
138 	uint_t		tran_min_xfer;
139 	uchar_t		tran_min_burst_size;
140 	uchar_t		tran_max_burst_size;
141 };
142 
143 
144 /*
145  * Prototypes for DCD HBA interface function.
146  */
147 
148 extern void	dcd_initialize_hba_interface(void);
149 
150 #ifdef	NO_DADA_FINI_YET
151 extern	void	dcd_uninitialize_hba_interface(void);
152 #endif
153 
154 extern	int	dcd_hba_init(struct modlinkage	*modlp);
155 
156 extern	void	dcd_hab_fini(struct modlinkage	*modlp);
157 
158 #ifdef NOTNEEDED
159 extern	int	dcd_hba_attach(
160 			dev_info_t	*dip,
161 			ddi_dma_lim_t	*hba_lim,
162 			dcd_hba_tran_t	*hba_tran,
163 			int		flags,
164 			void		*hba_options);
165 #endif
166 
167 extern int	dcd_hba_attach(
168 			dev_info_t	*dip,
169 			ddi_dma_attr_t	*hba_dma_attr,
170 			dcd_hba_tran_t	*hba_tran,
171 			int		flags);
172 
173 extern int	dcd_hba_detach(
174 			dev_info_t	*dip);
175 
176 extern	dcd_hba_tran_t	*dcd_hba_tran_alloc(
177 			dev_info_t	*dip,
178 			int		flags);
179 
180 extern	void	dcd_hba_tran_free(
181 			dcd_hba_tran_t	*hba_tran);
182 
183 extern int	dcd_hba_probe(
184 			struct	dcd_device  *dcd,
185 			int	(*callback)(void));
186 
187 extern	struct	dcd_pkt	*dcd_hba_pkt_alloc(
188 			struct	dcd_address	*ap,
189 			int		cmdlen,
190 			int		statuslen,
191 			int		tgtlen,
192 			int		hbalen,
193 			int 		(*callback)(caddr_t),
194 			caddr_t		arg);
195 
196 extern	void 	dcd_hba_pkt_free(
197 		struct dcd_address 	*ap,
198 		struct dcd_pkt		*pkt);
199 
200 extern	int	dcd_hba_lookup_capstr(
201 			char	*capstr);
202 extern	int	dcd_hba_in_panic(void);
203 
204 /*
205  * Flags for dcd_hba_attach
206  */
207 #define	 DCD_HBA_TRAN_CLONE	0x01
208 
209 /*
210  * Flags for scsi_hab alloaction functions
211  */
212 #define	DCD_HBA_CANSLEEP 0x01
213 
214 #endif	/* _KERNEL */
215 
216 #ifdef	__cplusplus
217 }
218 #endif
219 
220 #endif	/* _SYS_DADA_IMPL_TRANSPORT_H */
221