isp_netbsd.h revision 1.18.2.4 1 /* $NetBSD: isp_netbsd.h,v 1.18.2.4 1999/11/01 22:54:17 thorpej Exp $ */
2 /* release_6_5_99 */
3 /*
4 * NetBSD Specific definitions for the Qlogic ISP Host Adapter
5 * Matthew Jacob <mjacob (at) nas.nasa.gov>
6 */
7 /*
8 * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 #ifndef _ISP_NETBSD_H
34 #define _ISP_NETBSD_H
35
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/errno.h>
41 #include <sys/ioctl.h>
42 #include <sys/device.h>
43 #include <sys/malloc.h>
44 #include <sys/buf.h>
45 #include <sys/proc.h>
46 #include <sys/user.h>
47
48
49 #include <dev/scsipi/scsi_all.h>
50 #include <dev/scsipi/scsipi_all.h>
51 #include <dev/scsipi/scsiconf.h>
52
53 #include <dev/scsipi/scsi_message.h>
54 #include <dev/scsipi/scsipi_debug.h>
55
56 #include <vm/vm.h>
57 #include <vm/vm_param.h>
58 #include <vm/pmap.h>
59
60 #include "opt_isp.h"
61
62 #define ISP_PLATFORM_VERSION_MAJOR 0
63 #define ISP_PLATFORM_VERSION_MINOR 997
64
65 #define ISP_SCSI_XFER_T struct scsipi_xfer
66 struct isposinfo {
67 struct device _dev;
68 struct scsipi_adapter _adapter;
69 struct scsipi_channel _channels[2];
70 int seed;
71 };
72
73 #define MAXISPREQUEST 256
74 #ifdef ISP2100_FABRIC
75 #define ISP2100_SCRLEN 0x400
76 #else
77 #define ISP2100_SCRLEN 0x100
78 #endif
79
80 #include <dev/ic/ispreg.h>
81 #include <dev/ic/ispvar.h>
82 #include <dev/ic/ispmbox.h>
83
84 #define PRINTF printf
85 #define IDPRINTF(lev, x) if (isp->isp_dblev >= lev) printf x
86 #ifdef DIAGNOSTIC
87 #else
88 #endif
89
90 #define MEMZERO bzero
91 #define MEMCPY(dst, src, count) bcopy((src), (dst), (count))
92 #ifdef __alpha__
93 #define MemoryBarrier alpha_mb
94 #else
95 #define MemoryBarrier()
96 #endif
97
98 #define DMA_MSW(x) (((x) >> 16) & 0xffff)
99 #define DMA_LSW(x) (((x) & 0xffff))
100
101 #if defined(SCSIPI_DEBUG)
102 #define DFLT_DBLEVEL 3
103 #define CFGPRINTF printf
104 #else
105 #if defined(DIAGNOSTIC) || defined(DEBUG)
106 #define DFLT_DBLEVEL 1
107 #define CFGPRINTF printf
108 #else
109 #define DFLT_DBLEVEL 0
110 #define CFGPRINTF if (0) printf
111 #endif
112 #endif
113
114 #define ISP_LOCKVAL_DECL int isp_spl_save
115 #define ISP_ILOCKVAL_DECL ISP_LOCKVAL_DECL
116 #define ISP_LOCK(x) isp_spl_save = splbio()
117 #define ISP_UNLOCK(x) (void) splx(isp_spl_save)
118 #define ISP_ILOCK ISP_LOCK
119 #define ISP_IUNLOCK ISP_UNLOCK
120
121
122 #define XS_NULL(xs) xs == NULL || xs->xs_periph == NULL
123 #define XS_ISP(xs) \
124 (void *)(xs)->xs_periph->periph_channel->chan_adapter->adapt_dev
125 #define XS_LUN(xs) ((int) (xs)->xs_periph->periph_lun)
126 #define XS_TGT(xs) ((int) (xs)->xs_periph->periph_target)
127 #define XS_CHANNEL(xs) \
128 (xs)->xs_periph->periph_channel->chan_channel
129 #define XS_RESID(xs) (xs)->resid
130 #define XS_XFRLEN(xs) (xs)->datalen
131 #define XS_CDBLEN(xs) (xs)->cmdlen
132 #define XS_CDBP(xs) ((caddr_t) (xs)->cmd)
133 #define XS_STS(xs) (xs)->status
134 #define XS_TIME(xs) (xs)->timeout
135 #define XS_SNSP(xs) (&(xs)->sense.scsi_sense)
136 #define XS_SNSLEN(xs) (sizeof (xs)->sense.scsi_sense)
137 #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags)
138
139 #define HBA_NOERROR XS_NOERROR
140 #define HBA_BOTCH XS_DRIVER_STUFFUP
141 #define HBA_CMDTIMEOUT XS_TIMEOUT
142 #define HBA_SELTIMEOUT XS_SELTIMEOUT
143 #define HBA_TGTBSY XS_BUSY
144 #ifdef XS_RESET
145 #define HBA_BUSRESET XS_RESET
146 #else
147 #define HBA_BUSRESET XS_DRIVER_STUFFUP
148 #endif
149 #define HBA_ABORTED XS_DRIVER_STUFFUP
150 #define HBA_DATAOVR XS_DRIVER_STUFFUP
151 #define HBA_ARQFAIL XS_DRIVER_STUFFUP
152
153 #define XS_SNS_IS_VALID(xs) (xs)->error = XS_SENSE
154 #define XS_IS_SNS_VALID(xs) ((xs)->error == XS_SENSE)
155
156 #define XS_INITERR(xs) (xs)->error = 0
157 #define XS_SETERR(xs, v) (xs)->error = v
158 #define XS_ERR(xs) (xs)->error
159 #define XS_NOERR(xs) (xs)->error == XS_NOERROR
160
161 #define XS_CMD_DONE(xs) scsipi_done(xs)
162 #define XS_IS_CMD_DONE(xs) (((xs)->xs_status & XS_STS_DONE) != 0)
163
164 /*
165 * Can we use tagging?
166 */
167 #define XS_CANTAG(xs) (XS_CTL_TAGTYPE(xs) != 0)
168
169 /*
170 * The kind of tag to use for this command.
171 */
172 #define XS_KINDOF_TAG(xs) \
173 (XS_CTL_TAGTYPE(xs) == XS_CTL_SIMPLE_TAG ? REQFLAG_STAG : \
174 (XS_CTL_TAGTYPE(xs) == XS_CTL_HEAD_TAG ? REQFLAG_HTAG : \
175 REQFLAG_OTAG))
176
177 /*
178 * These get turned into NetBSD midlayer codes
179 */
180 #define CMD_COMPLETE 100
181 #define CMD_EAGAIN 101
182 #define CMD_QUEUED 102
183 #define CMD_RQLATER 103
184
185
186 #define isp_name isp_osinfo._dev.dv_xname
187 #define isp_unit isp_osinfo._dev.dv_unit
188
189 #define SCSI_QFULL 0x28
190
191 #define SYS_DELAY(x) delay(x)
192
193 #define WATCH_INTERVAL 30
194
195 #define FC_FW_READY_DELAY (12 * 1000000)
196 #define DEFAULT_LOOPID(x) 108
197 #define DEFAULT_WWN(x) (0x1000beed00000000LL + (x)->isp_osinfo.seed)
198
199 extern void isp_attach __P((struct ispsoftc *));
200 extern void isp_uninit __P((struct ispsoftc *));
201
202 #define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src) \
203 bcopy(src, dest, sizeof (isp_pdb_t))
204 #define ISP_SWIZZLE_ICB(a, b)
205 #ifdef __sparc__
206 #define ISP_SWIZZLE_REQUEST(a, b) \
207 ISP_SBUSIFY_ISPHDR(a, &(b)->req_header); \
208 ISP_SBUSIFY_ISPREQ(a, b)
209 #define ISP_UNSWIZZLE_RESPONSE(a, b) \
210 ISP_SBUSIFY_ISPHDR(a, &(b)->req_header)
211 #else
212 #define ISP_SWIZZLE_REQUEST(a, b)
213 #define ISP_UNSWIZZLE_RESPONSE(a, b)
214 #endif
215 #define ISP_SWIZZLE_SNS_REQ(a, b)
216 #define ISP_UNSWIZZLE_SNS_RSP(a, b, c)
217
218 #define INLINE inline
219 #include <dev/ic/isp_inline.h>
220
221 #endif /* _ISP_NETBSD_H */
222