| @@ -1,408 +1,410 @@ | | | @@ -1,408 +1,410 @@ |
1 | /* $NetBSD: isp_netbsd.h,v 1.69 2009/11/23 02:13:46 rmind Exp $ */ | | 1 | /* $NetBSD: isp_netbsd.h,v 1.70 2009/12/03 14:51:48 mjacob Exp $ */ |
2 | /* | | 2 | /* |
3 | * NetBSD Specific definitions for the Qlogic ISP Host Adapter | | 3 | * NetBSD Specific definitions for the Qlogic ISP Host Adapter |
4 | */ | | 4 | */ |
5 | /* | | 5 | /* |
6 | * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration | | 6 | * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * Additional Copyright (C) 2000-2007 by Matthew Jacob | | 9 | * Additional Copyright (C) 2000-2007 by Matthew Jacob |
10 | * All rights reserved. | | 10 | * All rights reserved. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
15 | * 1. Redistributions of source code must retain the above copyright | | 15 | * 1. Redistributions of source code must retain the above copyright |
16 | * notice, this list of conditions and the following disclaimer. | | 16 | * notice, this list of conditions and the following disclaimer. |
17 | * 2. Redistributions in binary form must reproduce the above copyright | | 17 | * 2. Redistributions in binary form must reproduce the above copyright |
18 | * notice, this list of conditions and the following disclaimer in the | | 18 | * notice, this list of conditions and the following disclaimer in the |
19 | * documentation and/or other materials provided with the distribution. | | 19 | * documentation and/or other materials provided with the distribution. |
20 | * 3. The name of the author may not be used to endorse or promote products | | 20 | * 3. The name of the author may not be used to endorse or promote products |
21 | * derived from this software without specific prior written permission | | 21 | * derived from this software without specific prior written permission |
22 | * | | 22 | * |
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | #ifndef _ISP_NETBSD_H | | 34 | #ifndef _ISP_NETBSD_H |
35 | #define _ISP_NETBSD_H | | 35 | #define _ISP_NETBSD_H |
36 | | | 36 | |
37 | #include <sys/types.h> | | 37 | #include <sys/types.h> |
38 | #include <sys/param.h> | | 38 | #include <sys/param.h> |
39 | #include <sys/systm.h> | | 39 | #include <sys/systm.h> |
40 | #include <sys/kernel.h> | | 40 | #include <sys/kernel.h> |
41 | #include <sys/errno.h> | | 41 | #include <sys/errno.h> |
42 | #include <sys/ioctl.h> | | 42 | #include <sys/ioctl.h> |
43 | #include <sys/device.h> | | 43 | #include <sys/device.h> |
44 | #include <sys/malloc.h> | | 44 | #include <sys/malloc.h> |
45 | #include <sys/buf.h> | | 45 | #include <sys/buf.h> |
46 | #include <sys/proc.h> | | 46 | #include <sys/proc.h> |
47 | #include <sys/kthread.h> | | 47 | #include <sys/kthread.h> |
48 | | | 48 | |
49 | #include <sys/bus.h> | | 49 | #include <sys/bus.h> |
50 | | | 50 | |
51 | #include <dev/scsipi/scsi_all.h> | | 51 | #include <dev/scsipi/scsi_all.h> |
52 | #include <dev/scsipi/scsipi_all.h> | | 52 | #include <dev/scsipi/scsipi_all.h> |
53 | #include <dev/scsipi/scsiconf.h> | | 53 | #include <dev/scsipi/scsiconf.h> |
54 | | | 54 | |
55 | #include <dev/scsipi/scsi_message.h> | | 55 | #include <dev/scsipi/scsi_message.h> |
56 | #include <dev/scsipi/scsipi_debug.h> | | 56 | #include <dev/scsipi/scsipi_debug.h> |
57 | | | 57 | |
58 | #include <machine/stdarg.h> | | 58 | #include <machine/stdarg.h> |
59 | | | 59 | |
60 | #include "opt_isp.h" | | 60 | #include "opt_isp.h" |
61 | | | 61 | |
62 | /* | | 62 | /* |
63 | * Efficiency- get rid of SBus code && tests unless we need them. | | 63 | * Efficiency- get rid of SBus code && tests unless we need them. |
64 | */ | | 64 | */ |
65 | #if defined(__sparcv9__ ) || defined(__sparc__) | | 65 | #if defined(__sparcv9__ ) || defined(__sparc__) |
66 | #define ISP_SBUS_SUPPORTED 1 | | 66 | #define ISP_SBUS_SUPPORTED 1 |
67 | #else | | 67 | #else |
68 | #define ISP_SBUS_SUPPORTED 0 | | 68 | #define ISP_SBUS_SUPPORTED 0 |
69 | #endif | | 69 | #endif |
70 | | | 70 | |
71 | #define ISP_PLATFORM_VERSION_MAJOR 5 | | 71 | #define ISP_PLATFORM_VERSION_MAJOR 5 |
72 | #define ISP_PLATFORM_VERSION_MINOR 0 | | 72 | #define ISP_PLATFORM_VERSION_MINOR 0 |
73 | | | 73 | |
74 | struct isposinfo { | | 74 | struct isposinfo { |
75 | device_t dev; | | 75 | device_t dev; |
76 | struct scsipi_adapter adapter; | | 76 | struct scsipi_adapter adapter; |
77 | struct scsipi_channel * chan; | | 77 | struct scsipi_channel * chan; |
78 | bus_dma_tag_t dmatag; | | 78 | bus_dma_tag_t dmatag; |
79 | bus_dmamap_t rqdmap; | | 79 | bus_dmamap_t rqdmap; |
80 | bus_dmamap_t rsdmap; | | 80 | bus_dmamap_t rsdmap; |
81 | bus_dmamap_t scdmap; /* FC only */ | | 81 | bus_dmamap_t scdmap; /* FC only */ |
82 | int splsaved; | | 82 | int splsaved; |
83 | int mboxwaiting; | | 83 | int mboxwaiting; |
84 | uint32_t islocked; | | 84 | uint32_t islocked; |
85 | uint32_t onintstack; | | 85 | uint32_t onintstack; |
86 | uint32_t loop_down_time; | | 86 | uint32_t loop_down_time; |
87 | uint32_t loop_down_limit; | | 87 | uint32_t loop_down_limit; |
88 | uint32_t gone_device_time; | | 88 | uint32_t gone_device_time; |
89 | unsigned int : 16, | | 89 | unsigned int : 16, |
90 | : 8, | | 90 | : 8, |
91 | gdt_running : 1, | | 91 | gdt_running : 1, |
92 | loop_checked : 1, | | 92 | loop_checked : 1, |
93 | mbox_sleeping : 1, | | 93 | mbox_sleeping : 1, |
94 | mbox_sleep_ok : 1, | | 94 | mbox_sleep_ok : 1, |
95 | mboxcmd_done : 1, | | 95 | mboxcmd_done : 1, |
96 | mboxbsy : 1, | | 96 | mboxbsy : 1, |
97 | paused : 1, | | 97 | paused : 1, |
98 | blocked : 1; | | 98 | blocked : 1; |
99 | struct callout ldt; /* loop down timer */ | | 99 | struct callout ldt; /* loop down timer */ |
100 | struct callout gdt; /* gone device timer */ | | 100 | struct callout gdt; /* gone device timer */ |
101 | uint64_t wwn; | | 101 | uint64_t wwn; |
102 | uint16_t framesize; | | 102 | uint16_t framesize; |
103 | uint16_t exec_throttle; | | 103 | uint16_t exec_throttle; |
104 | struct lwp * thread; | | 104 | struct lwp * thread; |
105 | }; | | 105 | }; |
106 | #define isp_dmatag isp_osinfo.dmatag | | 106 | #define isp_dmatag isp_osinfo.dmatag |
107 | #define isp_rqdmap isp_osinfo.rqdmap | | 107 | #define isp_rqdmap isp_osinfo.rqdmap |
108 | #define isp_rsdmap isp_osinfo.rsdmap | | 108 | #define isp_rsdmap isp_osinfo.rsdmap |
109 | #define isp_scdmap isp_osinfo.scdmap | | 109 | #define isp_scdmap isp_osinfo.scdmap |
110 | | | 110 | |
111 | #define ISP_MUSTPOLL(isp) \ | | 111 | #define ISP_MUSTPOLL(isp) \ |
112 | (isp->isp_osinfo.onintstack || isp->isp_osinfo.mbox_sleep_ok == 0) | | 112 | (isp->isp_osinfo.onintstack || isp->isp_osinfo.mbox_sleep_ok == 0) |
113 | | | 113 | |
114 | /* | | 114 | /* |
115 | * Required Macros/Defines | | 115 | * Required Macros/Defines |
116 | */ | | 116 | */ |
117 | | | 117 | |
118 | #define ISP_FC_SCRLEN 0x1000 | | 118 | #define ISP_FC_SCRLEN 0x1000 |
119 | | | 119 | |
120 | #define ISP_MEMZERO(dst, a) memset((dst), 0, (a)) | | 120 | #define ISP_MEMZERO(dst, a) memset((dst), 0, (a)) |
121 | #define ISP_MEMCPY(dst, src, a) memcpy((dst), (src), (a)) | | 121 | #define ISP_MEMCPY(dst, src, a) memcpy((dst), (src), (a)) |
122 | #define ISP_SNPRINTF snprintf | | 122 | #define ISP_SNPRINTF snprintf |
123 | #define ISP_DELAY DELAY | | 123 | #define ISP_DELAY DELAY |
124 | #define ISP_SLEEP(isp, x) \ | | 124 | #define ISP_SLEEP(isp, x) \ |
125 | if (!ISP_MUSTPOLL(isp)) \ | | 125 | if (!ISP_MUSTPOLL(isp)) \ |
126 | ISP_UNLOCK(isp); \ | | 126 | ISP_UNLOCK(isp); \ |
127 | DELAY(x); \ | | 127 | DELAY(x); \ |
128 | if (!ISP_MUSTPOLL(isp)) \ | | 128 | if (!ISP_MUSTPOLL(isp)) \ |
129 | ISP_LOCK(isp) | | 129 | ISP_LOCK(isp) |
130 | | | 130 | |
131 | #define ISP_INLINE | | 131 | #define ISP_INLINE |
132 | | | 132 | |
133 | #define NANOTIME_T struct timeval | | 133 | #define NANOTIME_T struct timeval |
134 | #define GET_NANOTIME microtime | | 134 | #define GET_NANOTIME microtime |
135 | #define GET_NANOSEC(x) (((x)->tv_sec * 1000000 + (x)->tv_usec) * 1000) | | 135 | #define GET_NANOSEC(x) (((x)->tv_sec * 1000000 + (x)->tv_usec) * 1000) |
136 | #define NANOTIME_SUB isp_microtime_sub | | 136 | #define NANOTIME_SUB isp_microtime_sub |
137 | | | 137 | |
138 | #define MAXISPREQUEST(isp) 256 | | 138 | #define MAXISPREQUEST(isp) 256 |
139 | | | 139 | |
140 | | | 140 | |
141 | #define MEMORYBARRIER(isp, type, offset, size) \ | | 141 | #define MEMORYBARRIER(isp, type, offset, size) \ |
142 | switch (type) { \ | | 142 | switch (type) { \ |
143 | case SYNC_REQUEST: \ | | 143 | case SYNC_REQUEST: \ |
144 | { \ | | 144 | { \ |
145 | off_t off = (off_t) offset * QENTRY_LEN; \ | | 145 | off_t off = (off_t) offset * QENTRY_LEN; \ |
146 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_rqdmap, \ | | 146 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_rqdmap, \ |
147 | off, size, BUS_DMASYNC_PREWRITE); \ | | 147 | off, size, BUS_DMASYNC_PREWRITE); \ |
148 | break; \ | | 148 | break; \ |
149 | } \ | | 149 | } \ |
150 | case SYNC_RESULT: \ | | 150 | case SYNC_RESULT: \ |
151 | { \ | | 151 | { \ |
152 | off_t off = (off_t) offset * QENTRY_LEN; \ | | 152 | off_t off = (off_t) offset * QENTRY_LEN; \ |
153 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_rsdmap, \ | | 153 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_rsdmap, \ |
154 | off, size, BUS_DMASYNC_POSTREAD); \ | | 154 | off, size, BUS_DMASYNC_POSTREAD); \ |
155 | break; \ | | 155 | break; \ |
156 | } \ | | 156 | } \ |
157 | case SYNC_SFORDEV: \ | | 157 | case SYNC_SFORDEV: \ |
158 | { \ | | 158 | { \ |
159 | off_t off = (off_t) offset; \ | | 159 | off_t off = (off_t) offset; \ |
160 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap, \ | | 160 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap, \ |
161 | off, size, BUS_DMASYNC_PREWRITE); \ | | 161 | off, size, BUS_DMASYNC_PREWRITE); \ |
162 | break; \ | | 162 | break; \ |
163 | } \ | | 163 | } \ |
164 | case SYNC_SFORCPU: \ | | 164 | case SYNC_SFORCPU: \ |
165 | { \ | | 165 | { \ |
166 | off_t off = (off_t) offset; \ | | 166 | off_t off = (off_t) offset; \ |
167 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap, \ | | 167 | bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap, \ |
168 | off, size, BUS_DMASYNC_POSTREAD); \ | | 168 | off, size, BUS_DMASYNC_POSTREAD); \ |
169 | break; \ | | 169 | break; \ |
170 | } \ | | 170 | } \ |
171 | default: \ | | 171 | default: \ |
172 | break; \ | | 172 | break; \ |
173 | } | | 173 | } |
174 | | | 174 | |
175 | #define MBOX_ACQUIRE isp_mbox_acquire | | 175 | #define MBOX_ACQUIRE isp_mbox_acquire |
176 | #define MBOX_WAIT_COMPLETE isp_mbox_wait_complete | | 176 | #define MBOX_WAIT_COMPLETE isp_mbox_wait_complete |
177 | #define MBOX_NOTIFY_COMPLETE isp_mbox_notify_done | | 177 | #define MBOX_NOTIFY_COMPLETE isp_mbox_notify_done |
178 | #define MBOX_RELEASE isp_mbox_release | | 178 | #define MBOX_RELEASE isp_mbox_release |
179 | | | 179 | |
180 | #define FC_SCRATCH_ACQUIRE(isp, chan) 0 | | 180 | #define FC_SCRATCH_ACQUIRE(isp, chan) 0 |
181 | #define FC_SCRATCH_RELEASE(isp, chan) do { } while (0) | | 181 | #define FC_SCRATCH_RELEASE(isp, chan) do { } while (0) |
182 | | | 182 | |
183 | #ifndef SCSI_GOOD | | 183 | #ifndef SCSI_GOOD |
184 | #define SCSI_GOOD 0x0 | | 184 | #define SCSI_GOOD 0x0 |
185 | #endif | | 185 | #endif |
186 | #ifndef SCSI_CHECK | | 186 | #ifndef SCSI_CHECK |
187 | #define SCSI_CHECK 0x2 | | 187 | #define SCSI_CHECK 0x2 |
188 | #endif | | 188 | #endif |
189 | #ifndef SCSI_BUSY | | 189 | #ifndef SCSI_BUSY |
190 | #define SCSI_BUSY 0x8 | | 190 | #define SCSI_BUSY 0x8 |
191 | #endif | | 191 | #endif |
192 | #ifndef SCSI_QFULL | | 192 | #ifndef SCSI_QFULL |
193 | #define SCSI_QFULL 0x28 | | 193 | #define SCSI_QFULL 0x28 |
194 | #endif | | 194 | #endif |
195 | | | 195 | |
196 | #define XS_T struct scsipi_xfer | | 196 | #define XS_T struct scsipi_xfer |
197 | #define XS_DMA_ADDR_T bus_addr_t | | 197 | #define XS_DMA_ADDR_T bus_addr_t |
198 | #define XS_DMA_ADDR_T bus_addr_t | | 198 | #define XS_DMA_ADDR_T bus_addr_t |
199 | #define XS_GET_DMA64_SEG(a, b, c) \ | | 199 | #define XS_GET_DMA64_SEG(a, b, c) \ |
200 | { \ | | 200 | { \ |
201 | ispds64_t *d = a; \ | | 201 | ispds64_t *d = a; \ |
202 | bus_dma_segment_t *e = b; \ | | 202 | bus_dma_segment_t *e = b; \ |
203 | uint32_t f = c; \ | | 203 | uint32_t f = c; \ |
204 | e += f; \ | | 204 | e += f; \ |
205 | d->ds_base = DMA_LO32(e->ds_addr); \ | | 205 | d->ds_base = DMA_LO32(e->ds_addr); \ |
206 | d->ds_basehi = DMA_HI32(e->ds_addr); \ | | 206 | d->ds_basehi = DMA_HI32(e->ds_addr); \ |
207 | d->ds_count = e->ds_len; \ | | 207 | d->ds_count = e->ds_len; \ |
208 | } | | 208 | } |
209 | #define XS_GET_DMA_SEG(a, b, c) \ | | 209 | #define XS_GET_DMA_SEG(a, b, c) \ |
210 | { \ | | 210 | { \ |
211 | ispds_t *d = a; \ | | 211 | ispds_t *d = a; \ |
212 | bus_dma_segment_t *e = b; \ | | 212 | bus_dma_segment_t *e = b; \ |
213 | uint32_t f = c; \ | | 213 | uint32_t f = c; \ |
214 | e += f; \ | | 214 | e += f; \ |
215 | d->ds_base = DMA_LO32(e->ds_addr); \ | | 215 | d->ds_base = DMA_LO32(e->ds_addr); \ |
216 | d->ds_count = e->ds_len; \ | | 216 | d->ds_count = e->ds_len; \ |
217 | } | | 217 | } |
218 | #define XS_CHANNEL(xs) \ | | 218 | #define XS_CHANNEL(xs) \ |
219 | ((int) (xs)->xs_periph->periph_channel->chan_channel) | | 219 | ((int) (xs)->xs_periph->periph_channel->chan_channel) |
220 | #define XS_ISP(xs) \ | | 220 | #define XS_ISP(xs) \ |
221 | device_private((xs)->xs_periph->periph_channel->chan_adapter->adapt_dev) | | 221 | device_private((xs)->xs_periph->periph_channel->chan_adapter->adapt_dev) |
222 | #define XS_LUN(xs) ((int) (xs)->xs_periph->periph_lun) | | 222 | #define XS_LUN(xs) ((int) (xs)->xs_periph->periph_lun) |
223 | #define XS_TGT(xs) ((int) (xs)->xs_periph->periph_target) | | 223 | #define XS_TGT(xs) ((int) (xs)->xs_periph->periph_target) |
224 | #define XS_CDBP(xs) ((uint8_t *) (xs)->cmd) | | 224 | #define XS_CDBP(xs) ((uint8_t *) (xs)->cmd) |
225 | #define XS_CDBLEN(xs) (xs)->cmdlen | | 225 | #define XS_CDBLEN(xs) (xs)->cmdlen |
226 | #define XS_XFRLEN(xs) (xs)->datalen | | 226 | #define XS_XFRLEN(xs) (xs)->datalen |
227 | #define XS_TIME(xs) (xs)->timeout | | 227 | #define XS_TIME(xs) (xs)->timeout |
228 | #define XS_GET_RESID(xs) (xs)->resid | | 228 | #define XS_GET_RESID(xs) (xs)->resid |
229 | #define XS_SET_RESID(xs, r) (xs)->resid = r | | 229 | #define XS_SET_RESID(xs, r) (xs)->resid = r |
230 | #define XS_STSP(xs) (&(xs)->status) | | 230 | #define XS_STSP(xs) (&(xs)->status) |
231 | #define XS_SNSP(xs) (&(xs)->sense.scsi_sense) | | 231 | #define XS_SNSP(xs) (&(xs)->sense.scsi_sense) |
232 | #define XS_SNSLEN(xs) (sizeof (xs)->sense) | | 232 | #define XS_SNSLEN(xs) (sizeof (xs)->sense) |
233 | #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags) | | 233 | #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags) |
234 | /* PORTING NOTES: check to see if there's a better way of checking for tagged */ | | 234 | /* PORTING NOTES: check to see if there's a better way of checking for tagged */ |
235 | #define XS_TAG_P(ccb) (((xs)->xs_control & XS_CTL_POLL) != 0) | | 235 | #define XS_TAG_P(ccb) (((xs)->xs_control & XS_CTL_POLL) != 0) |
236 | /* PORTING NOTES: We elimited OTAG option for performance */ | | 236 | /* PORTING NOTES: We elimited OTAG option for performance */ |
237 | #define XS_TAG_TYPE(xs) \ | | 237 | #define XS_TAG_TYPE(xs) \ |
238 | (((xs)->xs_control & XS_CTL_URGENT) ? REQFLAG_HTAG : REQFLAG_STAG) | | 238 | (((xs)->xs_control & XS_CTL_URGENT) ? REQFLAG_HTAG : REQFLAG_STAG) |
239 | | | 239 | |
240 | #define XS_SETERR(xs, v) (xs)->error = v | | 240 | #define XS_SETERR(xs, v) (xs)->error = v |
241 | | | 241 | |
242 | # define HBA_NOERROR XS_NOERROR | | 242 | # define HBA_NOERROR XS_NOERROR |
243 | # define HBA_BOTCH XS_DRIVER_STUFFUP | | 243 | # define HBA_BOTCH XS_DRIVER_STUFFUP |
244 | # define HBA_CMDTIMEOUT XS_TIMEOUT | | 244 | # define HBA_CMDTIMEOUT XS_TIMEOUT |
245 | # define HBA_SELTIMEOUT XS_SELTIMEOUT | | 245 | # define HBA_SELTIMEOUT XS_SELTIMEOUT |
246 | # define HBA_TGTBSY XS_BUSY | | 246 | # define HBA_TGTBSY XS_BUSY |
247 | # define HBA_BUSRESET XS_RESET | | 247 | # define HBA_BUSRESET XS_RESET |
248 | # define HBA_ABORTED XS_DRIVER_STUFFUP | | 248 | # define HBA_ABORTED XS_DRIVER_STUFFUP |
249 | # define HBA_DATAOVR XS_DRIVER_STUFFUP | | 249 | # define HBA_DATAOVR XS_DRIVER_STUFFUP |
250 | # define HBA_ARQFAIL XS_DRIVER_STUFFUP | | 250 | # define HBA_ARQFAIL XS_DRIVER_STUFFUP |
251 | | | 251 | |
252 | #define XS_ERR(xs) (xs)->error | | 252 | #define XS_ERR(xs) (xs)->error |
253 | #define XS_NOERR(xs) (xs)->error == XS_NOERROR | | 253 | #define XS_NOERR(xs) (xs)->error == XS_NOERROR |
254 | #define XS_INITERR(xs) (xs)->error = 0, XS_CMD_S_CLEAR(xs) | | 254 | #define XS_INITERR(xs) (xs)->error = 0, XS_CMD_S_CLEAR(xs) |
255 | | | 255 | |
256 | #define XS_SAVE_SENSE(xs, ptr, len) \ | | 256 | #define XS_SAVE_SENSE(xs, ptr, len) \ |
257 | if (xs->error == XS_NOERROR) { \ | | 257 | if (xs->error == XS_NOERROR) { \ |
258 | xs->error = XS_SENSE; \ | | 258 | xs->error = XS_SENSE; \ |
259 | } \ | | 259 | } \ |
260 | memcpy(&(xs)->sense, ptr, imin(XS_SNSLEN(xs), len)) | | 260 | memcpy(&(xs)->sense, ptr, imin(XS_SNSLEN(xs), len)) |
261 | | | 261 | |
262 | #define DEFAULT_FRAMESIZE(isp) (isp)->isp_osinfo.framesize | | 262 | #define DEFAULT_FRAMESIZE(isp) (isp)->isp_osinfo.framesize |
263 | #define DEFAULT_EXEC_THROTTLE(isp) (isp)->isp_osinfo.exec_throttle | | 263 | #define DEFAULT_EXEC_THROTTLE(isp) (isp)->isp_osinfo.exec_throttle |
264 | #define GET_DEFAULT_ROLE(isp, chan) ISP_ROLE_INITIATOR | | 264 | #define GET_DEFAULT_ROLE(isp, chan) ISP_ROLE_INITIATOR |
265 | #define SET_DEFAULT_ROLE(isp, chan) do { } while (0) | | 265 | #define SET_DEFAULT_ROLE(isp, chan) do { } while (0) |
266 | #define DEFAULT_IID(x, chan) 7 | | 266 | #define DEFAULT_IID(x, chan) 7 |
267 | #define DEFAULT_LOOPID(x, chan) 108 | | 267 | #define DEFAULT_LOOPID(x, chan) 108 |
268 | #define DEFAULT_NODEWWN(isp, chan) (isp)->isp_osinfo.wwn | | 268 | #define DEFAULT_NODEWWN(isp, chan) (isp)->isp_osinfo.wwn |
269 | #define DEFAULT_PORTWWN(isp, chan) (isp)->isp_osinfo.wwn | | 269 | #define DEFAULT_PORTWWN(isp, chan) (isp)->isp_osinfo.wwn |
270 | #define ACTIVE_NODEWWN(isp, chan) \ | | 270 | #define ACTIVE_NODEWWN(isp, chan) \ |
271 | (isp)->isp_osinfo.wwn? (isp)->isp_osinfo.wwn : \ | | 271 | ((isp)->isp_osinfo.wwn? (isp)->isp_osinfo.wwn : \ |
272 | FCPARAM(isp, chan)->isp_wwnn_nvram | | 272 | (FCPARAM(isp, chan)->isp_wwnn_nvram? \ |
| | | 273 | FCPARAM(isp, chan)->isp_wwnn_nvram : 0x400000007F000008ull)) |
273 | #define ACTIVE_PORTWWN(isp, chan) \ | | 274 | #define ACTIVE_PORTWWN(isp, chan) \ |
274 | (isp)->isp_osinfo.wwn? (isp)->isp_osinfo.wwn : \ | | 275 | ((isp)->isp_osinfo.wwn? (isp)->isp_osinfo.wwn : \ |
275 | FCPARAM(isp, chan)->isp_wwpn_nvram | | 276 | (FCPARAM(isp, chan)->isp_wwpn_nvram? \ |
| | | 277 | FCPARAM(isp, chan)->isp_wwpn_nvram : 0x400000007F000008ull)) |
276 | | | 278 | |
277 | #if _BYTE_ORDER == _BIG_ENDIAN | | 279 | #if _BYTE_ORDER == _BIG_ENDIAN |
278 | #ifdef ISP_SBUS_SUPPORTED | | 280 | #ifdef ISP_SBUS_SUPPORTED |
279 | #define ISP_IOXPUT_8(isp, s, d) *(d) = s | | 281 | #define ISP_IOXPUT_8(isp, s, d) *(d) = s |
280 | #define ISP_IOXPUT_16(isp, s, d) \ | | 282 | #define ISP_IOXPUT_16(isp, s, d) \ |
281 | *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap16(s) | | 283 | *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap16(s) |
282 | #define ISP_IOXPUT_32(isp, s, d) \ | | 284 | #define ISP_IOXPUT_32(isp, s, d) \ |
283 | *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap32(s) | | 285 | *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap32(s) |
284 | | | 286 | |
285 | #define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) | | 287 | #define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) |
286 | #define ISP_IOXGET_16(isp, s, d) \ | | 288 | #define ISP_IOXGET_16(isp, s, d) \ |
287 | d = (isp->isp_bustype == ISP_BT_SBUS)? \ | | 289 | d = (isp->isp_bustype == ISP_BT_SBUS)? \ |
288 | *((uint16_t *)s) : bswap16(*((uint16_t *)s)) | | 290 | *((uint16_t *)s) : bswap16(*((uint16_t *)s)) |
289 | #define ISP_IOXGET_32(isp, s, d) \ | | 291 | #define ISP_IOXGET_32(isp, s, d) \ |
290 | d = (isp->isp_bustype == ISP_BT_SBUS)? \ | | 292 | d = (isp->isp_bustype == ISP_BT_SBUS)? \ |
291 | *((uint32_t *)s) : bswap32(*((uint32_t *)s)) | | 293 | *((uint32_t *)s) : bswap32(*((uint32_t *)s)) |
292 | | | 294 | |
293 | #else /* ISP_SBUS_SUPPORTED */ | | 295 | #else /* ISP_SBUS_SUPPORTED */ |
294 | #define ISP_IOXPUT_8(isp, s, d) *(d) = s | | 296 | #define ISP_IOXPUT_8(isp, s, d) *(d) = s |
295 | #define ISP_IOXPUT_16(isp, s, d) *(d) = bswap16(s) | | 297 | #define ISP_IOXPUT_16(isp, s, d) *(d) = bswap16(s) |
296 | #define ISP_IOXPUT_32(isp, s, d) *(d) = bswap32(s) | | 298 | #define ISP_IOXPUT_32(isp, s, d) *(d) = bswap32(s) |
297 | #define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) | | 299 | #define ISP_IOXGET_8(isp, s, d) d = (*((uint8_t *)s)) |
298 | #define ISP_IOXGET_16(isp, s, d) d = bswap16(*((uint16_t *)s)) | | 300 | #define ISP_IOXGET_16(isp, s, d) d = bswap16(*((uint16_t *)s)) |
299 | #define ISP_IOXGET_32(isp, s, d) d = bswap32(*((uint32_t *)s)) | | 301 | #define ISP_IOXGET_32(isp, s, d) d = bswap32(*((uint32_t *)s)) |
300 | #endif /* ISP_SBUS_SUPPORTED */ | | 302 | #endif /* ISP_SBUS_SUPPORTED */ |
301 | #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = bswap16(*rp) | | 303 | #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = bswap16(*rp) |
302 | #define ISP_SWIZZLE_NVRAM_LONG(isp, rp) *rp = bswap32(*rp) | | 304 | #define ISP_SWIZZLE_NVRAM_LONG(isp, rp) *rp = bswap32(*rp) |
303 | | | 305 | |
304 | #define ISP_IOZGET_8(isp, s, d) d = (*((uint8_t *)s)) | | 306 | #define ISP_IOZGET_8(isp, s, d) d = (*((uint8_t *)s)) |
305 | #define ISP_IOZGET_16(isp, s, d) d = (*((uint16_t *)s)) | | 307 | #define ISP_IOZGET_16(isp, s, d) d = (*((uint16_t *)s)) |
306 | #define ISP_IOZGET_32(isp, s, d) d = (*((uint32_t *)s)) | | 308 | #define ISP_IOZGET_32(isp, s, d) d = (*((uint32_t *)s)) |
307 | #define ISP_IOZPUT_8(isp, s, d) *(d) = s | | 309 | #define ISP_IOZPUT_8(isp, s, d) *(d) = s |
308 | #define ISP_IOZPUT_16(isp, s, d) *(d) = s | | 310 | #define ISP_IOZPUT_16(isp, s, d) *(d) = s |
309 | #define ISP_IOZPUT_32(isp, s, d) *(d) = s | | 311 | #define ISP_IOZPUT_32(isp, s, d) *(d) = s |
310 | | | 312 | |
311 | #else | | 313 | #else |
312 | #define ISP_IOXPUT_8(isp, s, d) *(d) = s | | 314 | #define ISP_IOXPUT_8(isp, s, d) *(d) = s |
313 | #define ISP_IOXPUT_16(isp, s, d) *(d) = s | | 315 | #define ISP_IOXPUT_16(isp, s, d) *(d) = s |
314 | #define ISP_IOXPUT_32(isp, s, d) *(d) = s | | 316 | #define ISP_IOXPUT_32(isp, s, d) *(d) = s |
315 | #define ISP_IOXGET_8(isp, s, d) d = *(s) | | 317 | #define ISP_IOXGET_8(isp, s, d) d = *(s) |
316 | #define ISP_IOXGET_16(isp, s, d) d = *(s) | | 318 | #define ISP_IOXGET_16(isp, s, d) d = *(s) |
317 | #define ISP_IOXGET_32(isp, s, d) d = *(s) | | 319 | #define ISP_IOXGET_32(isp, s, d) d = *(s) |
318 | #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) | | 320 | #define ISP_SWIZZLE_NVRAM_WORD(isp, rp) |
319 | #define ISP_SWIZZLE_NVRAM_LONG(isp, rp) | | 321 | #define ISP_SWIZZLE_NVRAM_LONG(isp, rp) |
320 | | | 322 | |
321 | #define ISP_IOZPUT_8(isp, s, d) *(d) = s | | 323 | #define ISP_IOZPUT_8(isp, s, d) *(d) = s |
322 | #define ISP_IOZPUT_16(isp, s, d) *(d) = bswap16(s) | | 324 | #define ISP_IOZPUT_16(isp, s, d) *(d) = bswap16(s) |
323 | #define ISP_IOZPUT_32(isp, s, d) *(d) = bswap32(s) | | 325 | #define ISP_IOZPUT_32(isp, s, d) *(d) = bswap32(s) |
324 | | | 326 | |
325 | #define ISP_IOZGET_8(isp, s, d) d = (*((uint8_t *)(s))) | | 327 | #define ISP_IOZGET_8(isp, s, d) d = (*((uint8_t *)(s))) |
326 | #define ISP_IOZGET_16(isp, s, d) d = bswap16(*((uint16_t *)(s))) | | 328 | #define ISP_IOZGET_16(isp, s, d) d = bswap16(*((uint16_t *)(s))) |
327 | #define ISP_IOZGET_32(isp, s, d) d = bswap32(*((uint32_t *)(s))) | | 329 | #define ISP_IOZGET_32(isp, s, d) d = bswap32(*((uint32_t *)(s))) |
328 | | | 330 | |
329 | #endif | | 331 | #endif |
330 | | | 332 | |
331 | #define ISP_SWAP16(isp, x) bswap16(x) | | 333 | #define ISP_SWAP16(isp, x) bswap16(x) |
332 | #define ISP_SWAP32(isp, x) bswap32(x) | | 334 | #define ISP_SWAP32(isp, x) bswap32(x) |
333 | | | 335 | |
334 | /* | | 336 | /* |
335 | * Includes of common header files | | 337 | * Includes of common header files |
336 | */ | | 338 | */ |
337 | | | 339 | |
338 | #include <dev/ic/ispreg.h> | | 340 | #include <dev/ic/ispreg.h> |
339 | #include <dev/ic/ispvar.h> | | 341 | #include <dev/ic/ispvar.h> |
340 | #include <dev/ic/ispmbox.h> | | 342 | #include <dev/ic/ispmbox.h> |
341 | | | 343 | |
342 | /* | | 344 | /* |
343 | * isp_osinfo definitions, extensions and shorthand. | | 345 | * isp_osinfo definitions, extensions and shorthand. |
344 | */ | | 346 | */ |
345 | #define isp_unit device_unit(isp_osinfo.dev) | | 347 | #define isp_unit device_unit(isp_osinfo.dev) |
346 | | | 348 | |
347 | | | 349 | |
348 | /* | | 350 | /* |
349 | * Driver prototypes.. | | 351 | * Driver prototypes.. |
350 | */ | | 352 | */ |
351 | void isp_attach(ispsoftc_t *); | | 353 | void isp_attach(ispsoftc_t *); |
352 | void isp_uninit(ispsoftc_t *); | | 354 | void isp_uninit(ispsoftc_t *); |
353 | | | 355 | |
354 | /* | | 356 | /* |
355 | * Driver wide data... | | 357 | * Driver wide data... |
356 | */ | | 358 | */ |
357 | | | 359 | |
358 | /* | | 360 | /* |
359 | * Locking macros... | | 361 | * Locking macros... |
360 | */ | | 362 | */ |
361 | #define ISP_LOCK isp_lock | | 363 | #define ISP_LOCK isp_lock |
362 | #define ISP_UNLOCK isp_unlock | | 364 | #define ISP_UNLOCK isp_unlock |
363 | #define ISP_ILOCK(x) isp_lock(x); isp->isp_osinfo.onintstack++ | | 365 | #define ISP_ILOCK(x) isp_lock(x); isp->isp_osinfo.onintstack++ |
364 | #define ISP_IUNLOCK(x) isp->isp_osinfo.onintstack--; isp_unlock(x) | | 366 | #define ISP_IUNLOCK(x) isp->isp_osinfo.onintstack--; isp_unlock(x) |
365 | | | 367 | |
366 | /* | | 368 | /* |
367 | * Platform private flags | | 369 | * Platform private flags |
368 | */ | | 370 | */ |
369 | | | 371 | |
370 | #define XS_PSTS_INWDOG 0x10000000 | | 372 | #define XS_PSTS_INWDOG 0x10000000 |
371 | #define XS_PSTS_GRACE 0x20000000 | | 373 | #define XS_PSTS_GRACE 0x20000000 |
372 | #define XS_PSTS_ALL 0x30000000 | | 374 | #define XS_PSTS_ALL 0x30000000 |
373 | | | 375 | |
374 | #define XS_CMD_S_WDOG(xs) (xs)->xs_status |= XS_PSTS_INWDOG | | 376 | #define XS_CMD_S_WDOG(xs) (xs)->xs_status |= XS_PSTS_INWDOG |
375 | #define XS_CMD_C_WDOG(xs) (xs)->xs_status &= ~XS_PSTS_INWDOG | | 377 | #define XS_CMD_C_WDOG(xs) (xs)->xs_status &= ~XS_PSTS_INWDOG |
376 | #define XS_CMD_WDOG_P(xs) (((xs)->xs_status & XS_PSTS_INWDOG) != 0) | | 378 | #define XS_CMD_WDOG_P(xs) (((xs)->xs_status & XS_PSTS_INWDOG) != 0) |
377 | | | 379 | |
378 | #define XS_CMD_S_GRACE(xs) (xs)->xs_status |= XS_PSTS_GRACE | | 380 | #define XS_CMD_S_GRACE(xs) (xs)->xs_status |= XS_PSTS_GRACE |
379 | #define XS_CMD_C_GRACE(xs) (xs)->xs_status &= ~XS_PSTS_GRACE | | 381 | #define XS_CMD_C_GRACE(xs) (xs)->xs_status &= ~XS_PSTS_GRACE |
380 | #define XS_CMD_GRACE_P(xs) (((xs)->xs_status & XS_PSTS_GRACE) != 0) | | 382 | #define XS_CMD_GRACE_P(xs) (((xs)->xs_status & XS_PSTS_GRACE) != 0) |
381 | | | 383 | |
382 | #define XS_CMD_S_DONE(xs) (xs)->xs_status |= XS_STS_DONE | | 384 | #define XS_CMD_S_DONE(xs) (xs)->xs_status |= XS_STS_DONE |
383 | #define XS_CMD_C_DONE(xs) (xs)->xs_status &= ~XS_STS_DONE | | 385 | #define XS_CMD_C_DONE(xs) (xs)->xs_status &= ~XS_STS_DONE |
384 | #define XS_CMD_DONE_P(xs) (((xs)->xs_status & XS_STS_DONE) != 0) | | 386 | #define XS_CMD_DONE_P(xs) (((xs)->xs_status & XS_STS_DONE) != 0) |
385 | | | 387 | |
386 | #define XS_CMD_S_CLEAR(xs) (xs)->xs_status &= ~XS_PSTS_ALL | | 388 | #define XS_CMD_S_CLEAR(xs) (xs)->xs_status &= ~XS_PSTS_ALL |
387 | | | 389 | |
388 | /* | | 390 | /* |
389 | * Platform Library Functionw | | 391 | * Platform Library Functionw |
390 | */ | | 392 | */ |
391 | void isp_prt(ispsoftc_t *, int level, const char *, ...); | | 393 | void isp_prt(ispsoftc_t *, int level, const char *, ...); |
392 | void isp_lock(ispsoftc_t *); | | 394 | void isp_lock(ispsoftc_t *); |
393 | void isp_unlock(ispsoftc_t *); | | 395 | void isp_unlock(ispsoftc_t *); |
394 | uint64_t isp_microtime_sub(struct timeval *, struct timeval *); | | 396 | uint64_t isp_microtime_sub(struct timeval *, struct timeval *); |
395 | int isp_mbox_acquire(ispsoftc_t *); | | 397 | int isp_mbox_acquire(ispsoftc_t *); |
396 | void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *); | | 398 | void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *); |
397 | void isp_mbox_notify_done(ispsoftc_t *); | | 399 | void isp_mbox_notify_done(ispsoftc_t *); |
398 | void isp_mbox_release(ispsoftc_t *); | | 400 | void isp_mbox_release(ispsoftc_t *); |
399 | | | 401 | |
400 | /* | | 402 | /* |
401 | * Common Library functions | | 403 | * Common Library functions |
402 | */ | | 404 | */ |
403 | #include <dev/ic/isp_library.h> | | 405 | #include <dev/ic/isp_library.h> |
404 | | | 406 | |
405 | #if !defined(ISP_DISABLE_FW) && !defined(ISP_COMPILE_FW) | | 407 | #if !defined(ISP_DISABLE_FW) && !defined(ISP_COMPILE_FW) |
406 | #define ISP_COMPILE_FW 1 | | 408 | #define ISP_COMPILE_FW 1 |
407 | #endif | | 409 | #endif |
408 | #endif /* _ISP_NETBSD_H */ | | 410 | #endif /* _ISP_NETBSD_H */ |