1 /* $FreeBSD: src/sys/dev/isp/isp_freebsd.h,v 1.16.2.5 2000/03/04 06:04:53 mjacob Exp $ */
2 /*
3 * Qlogic ISP SCSI Host Adapter FreeBSD 2.X Wrapper Definitions
4 *---------------------------------------
5 * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
6 * NASA/Ames Research Center
7 * All rights reserved.
8 *---------------------------------------
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice immediately at the beginning of the file, without modification,
15 * 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 AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
26 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34 #ifndef _ISP_FREEBSD_H
35 #define _ISP_FREEBSD_H
36
37 #define ISP_PLATFORM_VERSION_MAJOR 2
38 #define ISP_PLATFORM_VERSION_MINOR 1
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/malloc.h>
43 #include <sys/buf.h>
44 #include <sys/proc.h>
45
46 #include <scsi/scsiconf.h>
47 #include <machine/clock.h>
48 #include <vm/vm.h>
49 #include <vm/vm_param.h>
50 #include <vm/pmap.h>
51 #include <sys/kernel.h>
52
53 #include "opt_isp.h"
54
55 #ifndef SCSI_ISP_PREFER_MEM_MAP
56 #define SCSI_ISP_PREFER_MEM_MAP 0
57 #endif
58
59
60 #ifdef SCSI_ISP_FABRIC
61 #define ISP2100_FABRIC 1
62 #define ISP2100_SCRLEN 0x400
63 #else
64 #define ISP2100_SCRLEN 0x100
65 #endif
66
67 #ifdef SCSI_ISP_SCCLUN
68 #define ISP2100_SCCLUN 1
69 #endif
70
71
72 #define ISP_SCSI_XFER_T struct scsi_xfer
73 struct isposinfo {
74 char name[8];
75 int unit, blocked;
76 union {
77 int _seed;
78 u_int16_t _discovered[2];
79 } un;
80 #define seed un._seed
81 #define discovered un._discovered
82 struct scsi_link _link;
83 struct scsi_link _link_b;
84 struct scsi_xfer *wqf, *wqt;
85 };
86 #define MAXISPREQUEST 64
87
88 #include <dev/isp/ispreg.h>
89 #include <dev/isp/ispvar.h>
90 #include <dev/isp/ispmbox.h>
91
92 #define IDPRINTF(lev, x) if (isp->isp_dblev >= lev) printf x
93 #define PRINTF printf
94
95 #define MEMZERO bzero
96 #define MEMCPY(dst, src, amt) bcopy((src), (dst), (amt))
97 #define MemoryBarrier()
98
99 #define DMA_MSW(x) (((x) >> 16) & 0xffff)
100 #define DMA_LSW(x) (((x) & 0xffff))
101
102 #if defined(SCSIDEBUG)
103 #define DFLT_DBLEVEL 3
104 #define CFGPRINTF printf
105 #elif 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
113 #define ISP_LOCKVAL_DECL int isp_spl_save
114 #define ISP_ILOCKVAL_DECL ISP_LOCKVAL_DECL
115 #define ISP_UNLOCK(isp) (void) splx(isp_spl_save)
116 #define ISP_LOCK(isp) isp_spl_save = splbio()
117 #define ISP_ILOCK(isp) ISP_LOCK(isp)
118 #define ISP_IUNLOCK(isp) ISP_UNLOCK(isp)
119 #define IMASK bio_imask
120
121 #define XS_NULL(xs) xs == NULL || xs->sc_link == NULL
122 #define XS_ISP(xs) \
123 ((struct ispsoftc *) (xs)->sc_link->adapter_softc)
124 #define XS_LUN(xs) ((int) (xs)->sc_link->lun)
125 #define XS_TGT(xs) ((int) (xs)->sc_link->target)
126 #define XS_CHANNEL(xs) ((int) (xs)->sc_link->adapter_bus)
127 #define XS_RESID(xs) (xs)->resid
128 #define XS_XFRLEN(xs) (xs)->datalen
129 #define XS_CDBLEN(xs) (xs)->cmdlen
130 #define XS_CDBP(xs) ((caddr_t) (xs)->cmd)
131 #define XS_STS(xs) (xs)->status
132 #define XS_TIME(xs) (xs)->timeout
133 #define XS_SNSP(xs) (&(xs)->sense)
134 #define XS_SNSLEN(xs) (sizeof((xs)->sense))
135 #define XS_SNSKEY(xs) ((xs)->sense.ext.extended.flags)
136
137 #define HBA_NOERROR XS_NOERROR
138 #define HBA_BOTCH XS_DRIVER_STUFFUP
139 #define HBA_CMDTIMEOUT XS_TIMEOUT
140 #define HBA_SELTIMEOUT XS_SELTIMEOUT
141 #define HBA_TGTBSY XS_BUSY
142 #define HBA_BUSRESET XS_DRIVER_STUFFUP
143 #define HBA_ABORTED XS_DRIVER_STUFFUP
144 #define HBA_DATAOVR XS_DRIVER_STUFFUP
145 #define HBA_ARQFAIL XS_DRIVER_STUFFUP
146
147 #define XS_SNS_IS_VALID(xs) (xs)->error = XS_SENSE
148 #define XS_IS_SNS_VALID(xs) ((xs)->error == XS_SENSE)
149
150 #define XS_INITERR(xs) (xs)->error = 0
151 #define XS_SETERR(xs, v) (xs)->error = v
152 #define XS_ERR(xs) (xs)->error
153 #define XS_NOERR(xs) (xs)->error == XS_NOERROR
154
155 #define XS_CMD_DONE(xs) (xs)->flags |= ITSDONE, scsi_done(xs)
156 #define XS_IS_CMD_DONE(xs) (((xs)->flags & ITSDONE) != 0)
157
158 /*
159 * We decide whether to use tags based upon whether we're polling.
160 */
161 #define XS_CANTAG(xs) (((xs)->flags & SCSI_NOMASK) != 0)
162
163 /*
164 * Our default tag
165 */
166 #define XS_KINDOF_TAG(xs) REQFLAG_OTAG
167
168
169 /*
170 * These get turned into NetBSD midlayer codes
171 */
172 #define CMD_COMPLETE 100
173 #define CMD_EAGAIN 101
174 #define CMD_QUEUED 102
175 #define CMD_RQLATER 103
176
177 #define isp_name isp_osinfo.name
178 #define isp_unit isp_osinfo.unit
179
180 #define SCSI_QFULL 0x28
181
182 #define SYS_DELAY(x) DELAY(x)
183
184 #define WATCH_INTERVAL 30
185
186 #define FC_FW_READY_DELAY (12 * 1000000)
187 #define DEFAULT_LOOPID(x) 109
188 #define DEFAULT_WWN(x) (0x1000feeb00000000LL + (x)->isp_osinfo.seed)
189
190 extern void isp_attach(struct ispsoftc *);
191 extern void isp_uninit(struct ispsoftc *);
192
193 #define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src) \
194 bcopy(src, dest, sizeof (isp_pdb_t))
195 #define ISP_SWIZZLE_ICB(a, b)
196 #ifdef __sparc__
197 #define ISP_SWIZZLE_REQUEST(a, b) \
198 ISP_SBUSIFY_ISPHDR(a, &(b)->req_header); \
199 ISP_SBUSIFY_ISPREQ(a, b)
200 #define ISP_UNSWIZZLE_RESPONSE(a, b) \
201 ISP_SBUSIFY_ISPHDR(a, &(b)->req_header)
202 #else
203 #define ISP_SWIZZLE_REQUEST(a, b)
204 #define ISP_UNSWIZZLE_RESPONSE(a, b)
205 #endif
206 #define ISP_SWIZZLE_SNS_REQ(a, b)
207 #define ISP_UNSWIZZLE_SNS_RSP(a, b, c)
208
209 #define INLINE __inline
210 #include <dev/isp/isp_inline.h>
211
212 #endif /* _ISP_FREEBSD_H */
Cache object: c513067075e307f39ca90a44ecef8b15
|