adw.c revision 1.21 1 1.21 dante /* $NetBSD: adw.c,v 1.21 2000/05/14 18:25:49 dante Exp $ */
2 1.1 dante
3 1.1 dante /*
4 1.1 dante * Generic driver for the Advanced Systems Inc. SCSI controllers
5 1.1 dante *
6 1.13 dante * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
7 1.1 dante * All rights reserved.
8 1.1 dante *
9 1.1 dante * Author: Baldassare Dante Profeta <dante (at) mclink.it>
10 1.1 dante *
11 1.1 dante * Redistribution and use in source and binary forms, with or without
12 1.1 dante * modification, are permitted provided that the following conditions
13 1.1 dante * are met:
14 1.1 dante * 1. Redistributions of source code must retain the above copyright
15 1.1 dante * notice, this list of conditions and the following disclaimer.
16 1.1 dante * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 dante * notice, this list of conditions and the following disclaimer in the
18 1.1 dante * documentation and/or other materials provided with the distribution.
19 1.1 dante * 3. All advertising materials mentioning features or use of this software
20 1.1 dante * must display the following acknowledgement:
21 1.1 dante * This product includes software developed by the NetBSD
22 1.1 dante * Foundation, Inc. and its contributors.
23 1.1 dante * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.1 dante * contributors may be used to endorse or promote products derived
25 1.1 dante * from this software without specific prior written permission.
26 1.1 dante *
27 1.1 dante * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.1 dante * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.1 dante * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.1 dante * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.1 dante * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.1 dante * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.1 dante * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.1 dante * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.1 dante * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.1 dante * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.1 dante * POSSIBILITY OF SUCH DAMAGE.
38 1.1 dante */
39 1.1 dante
40 1.1 dante #include <sys/types.h>
41 1.1 dante #include <sys/param.h>
42 1.1 dante #include <sys/systm.h>
43 1.15 thorpej #include <sys/callout.h>
44 1.1 dante #include <sys/kernel.h>
45 1.1 dante #include <sys/errno.h>
46 1.1 dante #include <sys/ioctl.h>
47 1.1 dante #include <sys/device.h>
48 1.1 dante #include <sys/malloc.h>
49 1.1 dante #include <sys/buf.h>
50 1.1 dante #include <sys/proc.h>
51 1.1 dante #include <sys/user.h>
52 1.1 dante
53 1.1 dante #include <machine/bus.h>
54 1.1 dante #include <machine/intr.h>
55 1.1 dante
56 1.1 dante #include <vm/vm.h>
57 1.1 dante #include <vm/vm_param.h>
58 1.1 dante #include <vm/pmap.h>
59 1.1 dante
60 1.1 dante #include <dev/scsipi/scsi_all.h>
61 1.1 dante #include <dev/scsipi/scsipi_all.h>
62 1.1 dante #include <dev/scsipi/scsiconf.h>
63 1.1 dante
64 1.1 dante #include <dev/ic/adwlib.h>
65 1.1 dante #include <dev/ic/adw.h>
66 1.1 dante
67 1.1 dante #ifndef DDB
68 1.11 dante #define Debugger() panic("should call debugger here (adw.c)")
69 1.2 dante #endif /* ! DDB */
70 1.1 dante
71 1.1 dante /******************************************************************************/
72 1.1 dante
73 1.1 dante
74 1.13 dante static int adw_alloc_controls __P((ADW_SOFTC *));
75 1.13 dante static int adw_alloc_carriers __P((ADW_SOFTC *));
76 1.13 dante static int adw_create_carriers __P((ADW_SOFTC *));
77 1.1 dante static int adw_create_ccbs __P((ADW_SOFTC *, ADW_CCB *, int));
78 1.1 dante static void adw_free_ccb __P((ADW_SOFTC *, ADW_CCB *));
79 1.1 dante static void adw_reset_ccb __P((ADW_CCB *));
80 1.1 dante static int adw_init_ccb __P((ADW_SOFTC *, ADW_CCB *));
81 1.1 dante static ADW_CCB *adw_get_ccb __P((ADW_SOFTC *, int));
82 1.13 dante static int adw_queue_ccb __P((ADW_SOFTC *, ADW_CCB *, int));
83 1.1 dante
84 1.1 dante static int adw_scsi_cmd __P((struct scsipi_xfer *));
85 1.14 thorpej static int adw_build_req __P((struct scsipi_xfer *, ADW_CCB *, int));
86 1.7 dante static void adw_build_sglist __P((ADW_CCB *, ADW_SCSI_REQ_Q *, ADW_SG_BLOCK *));
87 1.1 dante static void adwminphys __P((struct buf *));
88 1.13 dante static void adw_isr_callback __P((ADW_SOFTC *, ADW_SCSI_REQ_Q *));
89 1.13 dante static void adw_async_callback __P((ADW_SOFTC *, u_int8_t));
90 1.1 dante
91 1.19 dante static void adw_print_info __P((ADW_SOFTC *, int));
92 1.19 dante
93 1.1 dante static int adw_poll __P((ADW_SOFTC *, struct scsipi_xfer *, int));
94 1.1 dante static void adw_timeout __P((void *));
95 1.21 dante static void adw_reset_bus __P((ADW_SOFTC *, struct scsipi_xfer *));
96 1.1 dante
97 1.1 dante
98 1.1 dante /******************************************************************************/
99 1.1 dante
100 1.1 dante
101 1.19 dante /* the below structure is so we have a default dev struct for our link struct */
102 1.1 dante struct scsipi_device adw_dev =
103 1.1 dante {
104 1.1 dante NULL, /* Use default error handler */
105 1.1 dante NULL, /* have a queue, served by this */
106 1.1 dante NULL, /* have no async handler */
107 1.1 dante NULL, /* Use default 'done' routine */
108 1.1 dante };
109 1.1 dante
110 1.1 dante
111 1.1 dante /******************************************************************************/
112 1.19 dante /* Control Blocks routines */
113 1.1 dante /******************************************************************************/
114 1.1 dante
115 1.1 dante
116 1.1 dante static int
117 1.13 dante adw_alloc_controls(sc)
118 1.1 dante ADW_SOFTC *sc;
119 1.1 dante {
120 1.1 dante bus_dma_segment_t seg;
121 1.1 dante int error, rseg;
122 1.1 dante
123 1.1 dante /*
124 1.13 dante * Allocate the control structure.
125 1.1 dante */
126 1.1 dante if ((error = bus_dmamem_alloc(sc->sc_dmat, sizeof(struct adw_control),
127 1.1 dante NBPG, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
128 1.1 dante printf("%s: unable to allocate control structures,"
129 1.1 dante " error = %d\n", sc->sc_dev.dv_xname, error);
130 1.1 dante return (error);
131 1.1 dante }
132 1.1 dante if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
133 1.1 dante sizeof(struct adw_control), (caddr_t *) & sc->sc_control,
134 1.1 dante BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
135 1.1 dante printf("%s: unable to map control structures, error = %d\n",
136 1.1 dante sc->sc_dev.dv_xname, error);
137 1.1 dante return (error);
138 1.1 dante }
139 1.13 dante
140 1.1 dante /*
141 1.1 dante * Create and load the DMA map used for the control blocks.
142 1.1 dante */
143 1.1 dante if ((error = bus_dmamap_create(sc->sc_dmat, sizeof(struct adw_control),
144 1.1 dante 1, sizeof(struct adw_control), 0, BUS_DMA_NOWAIT,
145 1.1 dante &sc->sc_dmamap_control)) != 0) {
146 1.1 dante printf("%s: unable to create control DMA map, error = %d\n",
147 1.1 dante sc->sc_dev.dv_xname, error);
148 1.1 dante return (error);
149 1.1 dante }
150 1.1 dante if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap_control,
151 1.1 dante sc->sc_control, sizeof(struct adw_control), NULL,
152 1.1 dante BUS_DMA_NOWAIT)) != 0) {
153 1.1 dante printf("%s: unable to load control DMA map, error = %d\n",
154 1.1 dante sc->sc_dev.dv_xname, error);
155 1.1 dante return (error);
156 1.1 dante }
157 1.13 dante
158 1.13 dante return (0);
159 1.13 dante }
160 1.13 dante
161 1.13 dante
162 1.13 dante static int
163 1.13 dante adw_alloc_carriers(sc)
164 1.13 dante ADW_SOFTC *sc;
165 1.13 dante {
166 1.13 dante bus_dma_segment_t seg;
167 1.13 dante int error, rseg;
168 1.13 dante
169 1.13 dante /*
170 1.13 dante * Allocate the control structure.
171 1.13 dante */
172 1.19 dante sc->sc_control->carriers = malloc(sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
173 1.13 dante M_DEVBUF, M_WAITOK);
174 1.13 dante if(!sc->sc_control->carriers) {
175 1.18 thorpej printf("%s: malloc() failed in allocating carrier structures\n",
176 1.18 thorpej sc->sc_dev.dv_xname);
177 1.18 thorpej return (ENOMEM);
178 1.13 dante }
179 1.13 dante
180 1.13 dante if ((error = bus_dmamem_alloc(sc->sc_dmat,
181 1.19 dante sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
182 1.19 dante 0x10, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
183 1.13 dante printf("%s: unable to allocate carrier structures,"
184 1.13 dante " error = %d\n", sc->sc_dev.dv_xname, error);
185 1.13 dante return (error);
186 1.13 dante }
187 1.13 dante if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
188 1.19 dante sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
189 1.13 dante (caddr_t *) &sc->sc_control->carriers,
190 1.13 dante BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
191 1.13 dante printf("%s: unable to map carrier structures,"
192 1.13 dante " error = %d\n", sc->sc_dev.dv_xname, error);
193 1.13 dante return (error);
194 1.13 dante }
195 1.13 dante
196 1.13 dante /*
197 1.13 dante * Create and load the DMA map used for the control blocks.
198 1.13 dante */
199 1.13 dante if ((error = bus_dmamap_create(sc->sc_dmat,
200 1.19 dante sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, 1,
201 1.19 dante sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, 0,BUS_DMA_NOWAIT,
202 1.13 dante &sc->sc_dmamap_carrier)) != 0) {
203 1.13 dante printf("%s: unable to create carriers DMA map,"
204 1.13 dante " error = %d\n", sc->sc_dev.dv_xname, error);
205 1.13 dante return (error);
206 1.13 dante }
207 1.13 dante if ((error = bus_dmamap_load(sc->sc_dmat,
208 1.13 dante sc->sc_dmamap_carrier, sc->sc_control->carriers,
209 1.19 dante sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, NULL,
210 1.13 dante BUS_DMA_NOWAIT)) != 0) {
211 1.13 dante printf("%s: unable to load carriers DMA map,"
212 1.13 dante " error = %d\n", sc->sc_dev.dv_xname, error);
213 1.13 dante return (error);
214 1.13 dante }
215 1.13 dante
216 1.1 dante return (0);
217 1.1 dante }
218 1.1 dante
219 1.1 dante
220 1.1 dante /*
221 1.13 dante * Create a set of Carriers and add them to the free list. Called once
222 1.13 dante * by adw_init(). We return the number of Carriers successfully created.
223 1.13 dante */
224 1.13 dante static int
225 1.13 dante adw_create_carriers(sc)
226 1.13 dante ADW_SOFTC *sc;
227 1.13 dante {
228 1.13 dante ADW_CARRIER *carr;
229 1.13 dante u_int32_t carr_next = NULL;
230 1.19 dante int i;
231 1.13 dante
232 1.13 dante for(i=0; i < ADW_MAX_CARRIER; i++) {
233 1.13 dante carr = (ADW_CARRIER *)(((u_int8_t *)sc->sc_control->carriers) +
234 1.19 dante (sizeof(ADW_CARRIER) * i));
235 1.20 dante carr->carr_ba = ADW_CARRIER_BADDR(sc, carr);
236 1.19 dante carr->carr_id = i;
237 1.20 dante carr->next_ba = carr_next;
238 1.20 dante carr_next = carr->carr_ba;
239 1.13 dante }
240 1.13 dante sc->carr_freelist = carr;
241 1.13 dante return (i);
242 1.13 dante }
243 1.13 dante
244 1.13 dante
245 1.13 dante /*
246 1.13 dante * Given a physical address, find the Carrier that it corresponds to.
247 1.13 dante */
248 1.19 dante inline ADW_CARRIER *
249 1.13 dante adw_carrier_phys_kv(sc, carr_phys)
250 1.13 dante ADW_SOFTC *sc;
251 1.13 dante u_int32_t carr_phys;
252 1.13 dante {
253 1.19 dante return (ADW_CARRIER_VADDR(sc, carr_phys));
254 1.13 dante }
255 1.13 dante
256 1.13 dante
257 1.13 dante /*
258 1.1 dante * Create a set of ccbs and add them to the free list. Called once
259 1.1 dante * by adw_init(). We return the number of CCBs successfully created.
260 1.1 dante */
261 1.1 dante static int
262 1.1 dante adw_create_ccbs(sc, ccbstore, count)
263 1.1 dante ADW_SOFTC *sc;
264 1.1 dante ADW_CCB *ccbstore;
265 1.1 dante int count;
266 1.1 dante {
267 1.1 dante ADW_CCB *ccb;
268 1.1 dante int i, error;
269 1.1 dante
270 1.1 dante for (i = 0; i < count; i++) {
271 1.1 dante ccb = &ccbstore[i];
272 1.1 dante if ((error = adw_init_ccb(sc, ccb)) != 0) {
273 1.1 dante printf("%s: unable to initialize ccb, error = %d\n",
274 1.1 dante sc->sc_dev.dv_xname, error);
275 1.1 dante return (i);
276 1.1 dante }
277 1.1 dante TAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, chain);
278 1.1 dante }
279 1.1 dante
280 1.1 dante return (i);
281 1.1 dante }
282 1.1 dante
283 1.1 dante
284 1.1 dante /*
285 1.1 dante * A ccb is put onto the free list.
286 1.1 dante */
287 1.1 dante static void
288 1.1 dante adw_free_ccb(sc, ccb)
289 1.1 dante ADW_SOFTC *sc;
290 1.1 dante ADW_CCB *ccb;
291 1.1 dante {
292 1.1 dante int s;
293 1.1 dante
294 1.1 dante s = splbio();
295 1.1 dante
296 1.1 dante adw_reset_ccb(ccb);
297 1.1 dante TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, chain);
298 1.1 dante
299 1.1 dante /*
300 1.1 dante * If there were none, wake anybody waiting for one to come free,
301 1.1 dante * starting with queued entries.
302 1.1 dante */
303 1.1 dante if (ccb->chain.tqe_next == 0)
304 1.1 dante wakeup(&sc->sc_free_ccb);
305 1.1 dante
306 1.1 dante splx(s);
307 1.1 dante }
308 1.1 dante
309 1.1 dante
310 1.1 dante static void
311 1.1 dante adw_reset_ccb(ccb)
312 1.1 dante ADW_CCB *ccb;
313 1.1 dante {
314 1.1 dante
315 1.1 dante ccb->flags = 0;
316 1.1 dante }
317 1.1 dante
318 1.1 dante
319 1.1 dante static int
320 1.1 dante adw_init_ccb(sc, ccb)
321 1.1 dante ADW_SOFTC *sc;
322 1.1 dante ADW_CCB *ccb;
323 1.1 dante {
324 1.7 dante int hashnum, error;
325 1.1 dante
326 1.1 dante /*
327 1.1 dante * Create the DMA map for this CCB.
328 1.1 dante */
329 1.1 dante error = bus_dmamap_create(sc->sc_dmat,
330 1.1 dante (ADW_MAX_SG_LIST - 1) * PAGE_SIZE,
331 1.1 dante ADW_MAX_SG_LIST, (ADW_MAX_SG_LIST - 1) * PAGE_SIZE,
332 1.1 dante 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &ccb->dmamap_xfer);
333 1.1 dante if (error) {
334 1.13 dante printf("%s: unable to create CCB DMA map, error = %d\n",
335 1.1 dante sc->sc_dev.dv_xname, error);
336 1.1 dante return (error);
337 1.1 dante }
338 1.7 dante
339 1.7 dante /*
340 1.7 dante * put in the phystokv hash table
341 1.7 dante * Never gets taken out.
342 1.7 dante */
343 1.7 dante ccb->hashkey = sc->sc_dmamap_control->dm_segs[0].ds_addr +
344 1.7 dante ADW_CCB_OFF(ccb);
345 1.7 dante hashnum = CCB_HASH(ccb->hashkey);
346 1.7 dante ccb->nexthash = sc->sc_ccbhash[hashnum];
347 1.7 dante sc->sc_ccbhash[hashnum] = ccb;
348 1.1 dante adw_reset_ccb(ccb);
349 1.1 dante return (0);
350 1.1 dante }
351 1.1 dante
352 1.1 dante
353 1.1 dante /*
354 1.1 dante * Get a free ccb
355 1.1 dante *
356 1.1 dante * If there are none, see if we can allocate a new one
357 1.1 dante */
358 1.1 dante static ADW_CCB *
359 1.1 dante adw_get_ccb(sc, flags)
360 1.1 dante ADW_SOFTC *sc;
361 1.1 dante int flags;
362 1.1 dante {
363 1.1 dante ADW_CCB *ccb = 0;
364 1.1 dante int s;
365 1.1 dante
366 1.1 dante s = splbio();
367 1.1 dante
368 1.1 dante /*
369 1.1 dante * If we can and have to, sleep waiting for one to come free
370 1.1 dante * but only if we can't allocate a new one.
371 1.1 dante */
372 1.1 dante for (;;) {
373 1.1 dante ccb = sc->sc_free_ccb.tqh_first;
374 1.1 dante if (ccb) {
375 1.1 dante TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain);
376 1.1 dante break;
377 1.1 dante }
378 1.12 thorpej if ((flags & XS_CTL_NOSLEEP) != 0)
379 1.1 dante goto out;
380 1.1 dante
381 1.1 dante tsleep(&sc->sc_free_ccb, PRIBIO, "adwccb", 0);
382 1.1 dante }
383 1.1 dante
384 1.1 dante ccb->flags |= CCB_ALLOC;
385 1.1 dante
386 1.1 dante out:
387 1.1 dante splx(s);
388 1.1 dante return (ccb);
389 1.1 dante }
390 1.1 dante
391 1.1 dante
392 1.1 dante /*
393 1.7 dante * Given a physical address, find the ccb that it corresponds to.
394 1.7 dante */
395 1.7 dante ADW_CCB *
396 1.7 dante adw_ccb_phys_kv(sc, ccb_phys)
397 1.7 dante ADW_SOFTC *sc;
398 1.9 thorpej u_int32_t ccb_phys;
399 1.7 dante {
400 1.7 dante int hashnum = CCB_HASH(ccb_phys);
401 1.7 dante ADW_CCB *ccb = sc->sc_ccbhash[hashnum];
402 1.7 dante
403 1.7 dante while (ccb) {
404 1.7 dante if (ccb->hashkey == ccb_phys)
405 1.7 dante break;
406 1.7 dante ccb = ccb->nexthash;
407 1.7 dante }
408 1.7 dante return (ccb);
409 1.7 dante }
410 1.7 dante
411 1.7 dante
412 1.7 dante /*
413 1.1 dante * Queue a CCB to be sent to the controller, and send it if possible.
414 1.1 dante */
415 1.13 dante static int
416 1.13 dante adw_queue_ccb(sc, ccb, retry)
417 1.1 dante ADW_SOFTC *sc;
418 1.1 dante ADW_CCB *ccb;
419 1.13 dante int retry;
420 1.1 dante {
421 1.19 dante int errcode = ADW_SUCCESS;
422 1.1 dante
423 1.19 dante if(!retry) {
424 1.13 dante TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain);
425 1.19 dante }
426 1.1 dante
427 1.13 dante while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) {
428 1.1 dante
429 1.13 dante errcode = AdvExeScsiQueue(sc, &ccb->scsiq);
430 1.13 dante switch(errcode) {
431 1.13 dante case ADW_SUCCESS:
432 1.13 dante break;
433 1.1 dante
434 1.13 dante case ADW_BUSY:
435 1.13 dante printf("ADW_BUSY\n");
436 1.13 dante return(ADW_BUSY);
437 1.13 dante
438 1.13 dante case ADW_ERROR:
439 1.13 dante printf("ADW_ERROR\n");
440 1.13 dante TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
441 1.13 dante return(ADW_ERROR);
442 1.13 dante }
443 1.11 dante
444 1.1 dante TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
445 1.19 dante TAILQ_INSERT_TAIL(&sc->sc_pending_ccb, ccb, chain);
446 1.1 dante
447 1.12 thorpej if ((ccb->xs->xs_control & XS_CTL_POLL) == 0)
448 1.15 thorpej callout_reset(&ccb->xs->xs_callout,
449 1.15 thorpej (ccb->timeout * hz) / 1000, adw_timeout, ccb);
450 1.1 dante }
451 1.13 dante
452 1.13 dante return(errcode);
453 1.1 dante }
454 1.1 dante
455 1.1 dante
456 1.1 dante /******************************************************************************/
457 1.7 dante /* SCSI layer interfacing routines */
458 1.1 dante /******************************************************************************/
459 1.1 dante
460 1.1 dante
461 1.1 dante int
462 1.1 dante adw_init(sc)
463 1.1 dante ADW_SOFTC *sc;
464 1.1 dante {
465 1.2 dante u_int16_t warn_code;
466 1.1 dante
467 1.1 dante
468 1.1 dante sc->cfg.lib_version = (ADW_LIB_VERSION_MAJOR << 8) |
469 1.2 dante ADW_LIB_VERSION_MINOR;
470 1.1 dante sc->cfg.chip_version =
471 1.1 dante ADW_GET_CHIP_VERSION(sc->sc_iot, sc->sc_ioh, sc->bus_type);
472 1.1 dante
473 1.1 dante /*
474 1.1 dante * Reset the chip to start and allow register writes.
475 1.1 dante */
476 1.1 dante if (ADW_FIND_SIGNATURE(sc->sc_iot, sc->sc_ioh) == 0) {
477 1.1 dante panic("adw_init: adw_find_signature failed");
478 1.2 dante } else {
479 1.1 dante AdvResetChip(sc->sc_iot, sc->sc_ioh);
480 1.1 dante
481 1.16 dante switch(sc->chip_type) {
482 1.16 dante case ADV_CHIP_ASC3550:
483 1.16 dante warn_code = AdvInitFrom3550EEP(sc);
484 1.16 dante break;
485 1.16 dante
486 1.16 dante case ADV_CHIP_ASC38C0800:
487 1.16 dante warn_code = AdvInitFrom38C0800EEP(sc);
488 1.16 dante break;
489 1.16 dante
490 1.16 dante case ADV_CHIP_ASC38C1600:
491 1.16 dante warn_code = AdvInitFrom38C1600EEP(sc);
492 1.16 dante break;
493 1.16 dante
494 1.16 dante default:
495 1.16 dante return -1;
496 1.16 dante }
497 1.13 dante
498 1.2 dante if (warn_code & ASC_WARN_EEPROM_CHKSUM)
499 1.1 dante printf("%s: Bad checksum found. "
500 1.2 dante "Setting default values\n",
501 1.2 dante sc->sc_dev.dv_xname);
502 1.2 dante if (warn_code & ASC_WARN_EEPROM_TERMINATION)
503 1.1 dante printf("%s: Bad bus termination setting."
504 1.2 dante "Using automatic termination.\n",
505 1.2 dante sc->sc_dev.dv_xname);
506 1.1 dante }
507 1.1 dante
508 1.13 dante sc->isr_callback = (ADW_CALLBACK) adw_isr_callback;
509 1.13 dante sc->async_callback = (ADW_CALLBACK) adw_async_callback;
510 1.1 dante
511 1.16 dante return 0;
512 1.1 dante }
513 1.1 dante
514 1.1 dante
515 1.1 dante void
516 1.1 dante adw_attach(sc)
517 1.1 dante ADW_SOFTC *sc;
518 1.1 dante {
519 1.1 dante int i, error;
520 1.1 dante
521 1.1 dante
522 1.13 dante TAILQ_INIT(&sc->sc_free_ccb);
523 1.13 dante TAILQ_INIT(&sc->sc_waiting_ccb);
524 1.19 dante TAILQ_INIT(&sc->sc_pending_ccb);
525 1.13 dante TAILQ_INIT(&sc->sc_queue);
526 1.13 dante
527 1.13 dante
528 1.13 dante /*
529 1.13 dante * Allocate the Control Blocks.
530 1.13 dante */
531 1.13 dante error = adw_alloc_controls(sc);
532 1.13 dante if (error)
533 1.13 dante return; /* (error) */ ;
534 1.13 dante
535 1.13 dante bzero(sc->sc_control, sizeof(struct adw_control));
536 1.13 dante
537 1.13 dante /*
538 1.13 dante * Create and initialize the Control Blocks.
539 1.13 dante */
540 1.13 dante i = adw_create_ccbs(sc, sc->sc_control->ccbs, ADW_MAX_CCB);
541 1.13 dante if (i == 0) {
542 1.13 dante printf("%s: unable to create Control Blocks\n",
543 1.13 dante sc->sc_dev.dv_xname);
544 1.13 dante return; /* (ENOMEM) */ ;
545 1.13 dante } else if (i != ADW_MAX_CCB) {
546 1.13 dante printf("%s: WARNING: only %d of %d Control Blocks"
547 1.13 dante " created\n",
548 1.13 dante sc->sc_dev.dv_xname, i, ADW_MAX_CCB);
549 1.13 dante }
550 1.13 dante
551 1.13 dante /*
552 1.13 dante * Create and initialize the Carriers.
553 1.13 dante */
554 1.13 dante error = adw_alloc_carriers(sc);
555 1.13 dante if (error)
556 1.13 dante return; /* (error) */ ;
557 1.13 dante
558 1.19 dante bzero(sc->sc_control->carriers, sizeof(ADW_CARRIER) * ADW_MAX_CARRIER);
559 1.13 dante
560 1.13 dante i = adw_create_carriers(sc);
561 1.13 dante if (i == 0) {
562 1.13 dante printf("%s: unable to create Carriers\n",
563 1.13 dante sc->sc_dev.dv_xname);
564 1.13 dante return; /* (ENOMEM) */ ;
565 1.13 dante } else if (i != ADW_MAX_CARRIER) {
566 1.13 dante printf("%s: WARNING: only %d of %d Carriers created\n",
567 1.13 dante sc->sc_dev.dv_xname, i, ADW_MAX_CARRIER);
568 1.13 dante }
569 1.13 dante
570 1.21 dante /*
571 1.21 dante * Zero's the freeze_device status
572 1.21 dante */
573 1.21 dante bzero(sc->sc_freeze_dev, sizeof(sc->sc_freeze_dev));
574 1.13 dante
575 1.1 dante /*
576 1.16 dante * Initialize the adapter
577 1.1 dante */
578 1.16 dante switch(sc->chip_type) {
579 1.16 dante case ADV_CHIP_ASC3550:
580 1.16 dante error = AdvInitAsc3550Driver(sc);
581 1.16 dante break;
582 1.16 dante
583 1.16 dante case ADV_CHIP_ASC38C0800:
584 1.16 dante error = AdvInitAsc38C0800Driver(sc);
585 1.16 dante break;
586 1.16 dante
587 1.16 dante case ADV_CHIP_ASC38C1600:
588 1.16 dante error = AdvInitAsc38C1600Driver(sc);
589 1.16 dante break;
590 1.16 dante
591 1.16 dante default:
592 1.16 dante return;
593 1.16 dante }
594 1.16 dante
595 1.13 dante switch (error) {
596 1.19 dante case ASC_IERR_BIST_PRE_TEST:
597 1.19 dante panic("%s: BIST pre-test error",
598 1.19 dante sc->sc_dev.dv_xname);
599 1.19 dante break;
600 1.19 dante
601 1.19 dante case ASC_IERR_BIST_RAM_TEST:
602 1.19 dante panic("%s: BIST RAM test error",
603 1.19 dante sc->sc_dev.dv_xname);
604 1.19 dante break;
605 1.19 dante
606 1.2 dante case ASC_IERR_MCODE_CHKSUM:
607 1.2 dante panic("%s: Microcode checksum error",
608 1.2 dante sc->sc_dev.dv_xname);
609 1.2 dante break;
610 1.2 dante
611 1.2 dante case ASC_IERR_ILLEGAL_CONNECTION:
612 1.2 dante panic("%s: All three connectors are in use",
613 1.2 dante sc->sc_dev.dv_xname);
614 1.2 dante break;
615 1.2 dante
616 1.2 dante case ASC_IERR_REVERSED_CABLE:
617 1.2 dante panic("%s: Cable is reversed",
618 1.2 dante sc->sc_dev.dv_xname);
619 1.2 dante break;
620 1.2 dante
621 1.19 dante case ASC_IERR_HVD_DEVICE:
622 1.19 dante panic("%s: HVD attached to LVD connector",
623 1.19 dante sc->sc_dev.dv_xname);
624 1.19 dante break;
625 1.19 dante
626 1.2 dante case ASC_IERR_SINGLE_END_DEVICE:
627 1.2 dante panic("%s: single-ended device is attached to"
628 1.2 dante " one of the connectors",
629 1.2 dante sc->sc_dev.dv_xname);
630 1.2 dante break;
631 1.13 dante
632 1.13 dante case ASC_IERR_NO_CARRIER:
633 1.13 dante panic("%s: no carrier",
634 1.13 dante sc->sc_dev.dv_xname);
635 1.13 dante break;
636 1.13 dante
637 1.13 dante case ASC_WARN_BUSRESET_ERROR:
638 1.13 dante printf("%s: WARNING: Bus Reset Error\n",
639 1.13 dante sc->sc_dev.dv_xname);
640 1.13 dante break;
641 1.1 dante }
642 1.1 dante
643 1.4 thorpej /*
644 1.4 thorpej * Fill in the adapter.
645 1.4 thorpej */
646 1.4 thorpej sc->sc_adapter.scsipi_cmd = adw_scsi_cmd;
647 1.4 thorpej sc->sc_adapter.scsipi_minphys = adwminphys;
648 1.1 dante
649 1.1 dante /*
650 1.1 dante * fill in the prototype scsipi_link.
651 1.1 dante */
652 1.1 dante sc->sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
653 1.1 dante sc->sc_link.adapter_softc = sc;
654 1.1 dante sc->sc_link.scsipi_scsi.adapter_target = sc->chip_scsi_id;
655 1.4 thorpej sc->sc_link.adapter = &sc->sc_adapter;
656 1.1 dante sc->sc_link.device = &adw_dev;
657 1.1 dante sc->sc_link.openings = 4;
658 1.1 dante sc->sc_link.scsipi_scsi.max_target = ADW_MAX_TID;
659 1.5 mjacob sc->sc_link.scsipi_scsi.max_lun = 7;
660 1.1 dante sc->sc_link.type = BUS_SCSI;
661 1.1 dante
662 1.1 dante
663 1.1 dante config_found(&sc->sc_dev, &sc->sc_link, scsiprint);
664 1.1 dante }
665 1.1 dante
666 1.1 dante
667 1.1 dante static void
668 1.1 dante adwminphys(bp)
669 1.1 dante struct buf *bp;
670 1.1 dante {
671 1.1 dante
672 1.1 dante if (bp->b_bcount > ((ADW_MAX_SG_LIST - 1) * PAGE_SIZE))
673 1.1 dante bp->b_bcount = ((ADW_MAX_SG_LIST - 1) * PAGE_SIZE);
674 1.1 dante minphys(bp);
675 1.1 dante }
676 1.1 dante
677 1.1 dante
678 1.1 dante /*
679 1.2 dante * start a scsi operation given the command and the data address.
680 1.2 dante * Also needs the unit, target and lu.
681 1.1 dante */
682 1.1 dante static int
683 1.1 dante adw_scsi_cmd(xs)
684 1.1 dante struct scsipi_xfer *xs;
685 1.1 dante {
686 1.1 dante struct scsipi_link *sc_link = xs->sc_link;
687 1.1 dante ADW_SOFTC *sc = sc_link->adapter_softc;
688 1.1 dante ADW_CCB *ccb;
689 1.14 thorpej int s, fromqueue = 1, dontqueue = 0, nowait = 0, retry = 0;
690 1.14 thorpej int flags;
691 1.1 dante
692 1.1 dante s = splbio(); /* protect the queue */
693 1.1 dante
694 1.1 dante /*
695 1.1 dante * If we're running the queue from adw_done(), we've been
696 1.1 dante * called with the first queue entry as our argument.
697 1.1 dante */
698 1.6 thorpej if (xs == TAILQ_FIRST(&sc->sc_queue)) {
699 1.21 dante if(sc->sc_freeze_dev[xs->sc_link->scsipi_scsi.target]) {
700 1.21 dante splx(s);
701 1.21 dante return (TRY_AGAIN_LATER);
702 1.21 dante }
703 1.21 dante
704 1.6 thorpej TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q);
705 1.1 dante fromqueue = 1;
706 1.14 thorpej nowait = 1;
707 1.1 dante } else {
708 1.21 dante if(sc->sc_freeze_dev[xs->sc_link->scsipi_scsi.target]) {
709 1.21 dante splx(s);
710 1.21 dante xs->error = XS_DRIVER_STUFFUP;
711 1.21 dante return (TRY_AGAIN_LATER);
712 1.21 dante }
713 1.1 dante
714 1.1 dante /* Polled requests can't be queued for later. */
715 1.12 thorpej dontqueue = xs->xs_control & XS_CTL_POLL;
716 1.1 dante
717 1.1 dante /*
718 1.1 dante * If there are jobs in the queue, run them first.
719 1.1 dante */
720 1.6 thorpej if (TAILQ_FIRST(&sc->sc_queue) != NULL) {
721 1.1 dante /*
722 1.1 dante * If we can't queue, we have to abort, since
723 1.1 dante * we have to preserve order.
724 1.1 dante */
725 1.1 dante if (dontqueue) {
726 1.1 dante splx(s);
727 1.1 dante xs->error = XS_DRIVER_STUFFUP;
728 1.1 dante return (TRY_AGAIN_LATER);
729 1.1 dante }
730 1.1 dante /*
731 1.1 dante * Swap with the first queue entry.
732 1.1 dante */
733 1.6 thorpej TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q);
734 1.6 thorpej xs = TAILQ_FIRST(&sc->sc_queue);
735 1.6 thorpej TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q);
736 1.1 dante fromqueue = 1;
737 1.1 dante }
738 1.1 dante }
739 1.1 dante
740 1.1 dante
741 1.1 dante /*
742 1.1 dante * get a ccb to use. If the transfer
743 1.1 dante * is from a buf (possibly from interrupt time)
744 1.1 dante * then we can't allow it to sleep
745 1.1 dante */
746 1.1 dante
747 1.14 thorpej flags = xs->xs_control;
748 1.14 thorpej if (nowait)
749 1.14 thorpej flags |= XS_CTL_NOSLEEP;
750 1.14 thorpej if ((ccb = adw_get_ccb(sc, flags)) == NULL) {
751 1.1 dante /*
752 1.1 dante * If we can't queue, we lose.
753 1.1 dante */
754 1.1 dante if (dontqueue) {
755 1.1 dante splx(s);
756 1.1 dante xs->error = XS_DRIVER_STUFFUP;
757 1.1 dante return (TRY_AGAIN_LATER);
758 1.1 dante }
759 1.1 dante /*
760 1.1 dante * Stuff ourselves into the queue, in front
761 1.1 dante * if we came off in the first place.
762 1.1 dante */
763 1.6 thorpej if (fromqueue)
764 1.6 thorpej TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q);
765 1.6 thorpej else
766 1.6 thorpej TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q);
767 1.1 dante splx(s);
768 1.1 dante return (SUCCESSFULLY_QUEUED);
769 1.1 dante }
770 1.1 dante splx(s); /* done playing with the queue */
771 1.1 dante
772 1.1 dante ccb->xs = xs;
773 1.1 dante ccb->timeout = xs->timeout;
774 1.1 dante
775 1.14 thorpej if (adw_build_req(xs, ccb, flags)) {
776 1.13 dante retryagain:
777 1.13 dante s = splbio();
778 1.13 dante retry = adw_queue_ccb(sc, ccb, retry);
779 1.13 dante splx(s);
780 1.13 dante
781 1.13 dante switch(retry) {
782 1.13 dante case ADW_BUSY:
783 1.13 dante goto retryagain;
784 1.13 dante
785 1.13 dante case ADW_ERROR:
786 1.13 dante xs->error = XS_DRIVER_STUFFUP;
787 1.13 dante return (COMPLETE);
788 1.13 dante }
789 1.1 dante
790 1.1 dante /*
791 1.1 dante * Usually return SUCCESSFULLY QUEUED
792 1.1 dante */
793 1.12 thorpej if ((xs->xs_control & XS_CTL_POLL) == 0)
794 1.1 dante return (SUCCESSFULLY_QUEUED);
795 1.1 dante
796 1.1 dante /*
797 1.1 dante * If we can't use interrupts, poll on completion
798 1.1 dante */
799 1.1 dante if (adw_poll(sc, xs, ccb->timeout)) {
800 1.1 dante adw_timeout(ccb);
801 1.1 dante if (adw_poll(sc, xs, ccb->timeout))
802 1.1 dante adw_timeout(ccb);
803 1.1 dante }
804 1.1 dante }
805 1.2 dante return (COMPLETE);
806 1.1 dante }
807 1.1 dante
808 1.1 dante
809 1.1 dante /*
810 1.1 dante * Build a request structure for the Wide Boards.
811 1.1 dante */
812 1.1 dante static int
813 1.14 thorpej adw_build_req(xs, ccb, flags)
814 1.2 dante struct scsipi_xfer *xs;
815 1.2 dante ADW_CCB *ccb;
816 1.14 thorpej int flags;
817 1.1 dante {
818 1.2 dante struct scsipi_link *sc_link = xs->sc_link;
819 1.2 dante ADW_SOFTC *sc = sc_link->adapter_softc;
820 1.2 dante bus_dma_tag_t dmat = sc->sc_dmat;
821 1.2 dante ADW_SCSI_REQ_Q *scsiqp;
822 1.2 dante int error;
823 1.1 dante
824 1.1 dante scsiqp = &ccb->scsiq;
825 1.1 dante bzero(scsiqp, sizeof(ADW_SCSI_REQ_Q));
826 1.1 dante
827 1.1 dante /*
828 1.7 dante * Set the ADW_SCSI_REQ_Q 'ccb_ptr' to point to the
829 1.7 dante * physical CCB structure.
830 1.1 dante */
831 1.10 thorpej scsiqp->ccb_ptr = ccb->hashkey;
832 1.1 dante
833 1.1 dante /*
834 1.1 dante * Build the ADW_SCSI_REQ_Q request.
835 1.1 dante */
836 1.1 dante
837 1.1 dante /*
838 1.1 dante * Set CDB length and copy it to the request structure.
839 1.16 dante * For wide boards a CDB length maximum of 16 bytes
840 1.16 dante * is supported.
841 1.1 dante */
842 1.16 dante bcopy(xs->cmd, &scsiqp->cdb, ((scsiqp->cdb_len = xs->cmdlen) <= 12)?
843 1.16 dante xs->cmdlen : 12 );
844 1.16 dante if(xs->cmdlen > 12)
845 1.16 dante bcopy(&(xs->cmd[12]), &scsiqp->cdb16, xs->cmdlen - 12);
846 1.1 dante
847 1.1 dante scsiqp->target_id = sc_link->scsipi_scsi.target;
848 1.1 dante scsiqp->target_lun = sc_link->scsipi_scsi.lun;
849 1.1 dante
850 1.7 dante scsiqp->vsense_addr = &ccb->scsi_sense;
851 1.13 dante scsiqp->sense_addr = sc->sc_dmamap_control->dm_segs[0].ds_addr +
852 1.13 dante ADW_CCB_OFF(ccb) + offsetof(struct adw_ccb, scsi_sense);
853 1.21 dante scsiqp->sense_len = sizeof(struct scsipi_sense_data);
854 1.1 dante
855 1.1 dante /*
856 1.1 dante * Build ADW_SCSI_REQ_Q for a scatter-gather buffer command.
857 1.1 dante */
858 1.1 dante if (xs->datalen) {
859 1.1 dante /*
860 1.1 dante * Map the DMA transfer.
861 1.1 dante */
862 1.1 dante #ifdef TFS
863 1.12 thorpej if (xs->xs_control & SCSI_DATA_UIO) {
864 1.1 dante error = bus_dmamap_load_uio(dmat,
865 1.2 dante ccb->dmamap_xfer, (struct uio *) xs->data,
866 1.14 thorpej (flags & XS_CTL_NOSLEEP) ?
867 1.12 thorpej BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
868 1.1 dante } else
869 1.13 dante #endif /* TFS */
870 1.1 dante {
871 1.1 dante error = bus_dmamap_load(dmat,
872 1.2 dante ccb->dmamap_xfer, xs->data, xs->datalen, NULL,
873 1.14 thorpej (flags & XS_CTL_NOSLEEP) ?
874 1.12 thorpej BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
875 1.1 dante }
876 1.1 dante
877 1.1 dante if (error) {
878 1.1 dante if (error == EFBIG) {
879 1.1 dante printf("%s: adw_scsi_cmd, more than %d dma"
880 1.1 dante " segments\n",
881 1.1 dante sc->sc_dev.dv_xname, ADW_MAX_SG_LIST);
882 1.1 dante } else {
883 1.1 dante printf("%s: adw_scsi_cmd, error %d loading"
884 1.1 dante " dma map\n",
885 1.1 dante sc->sc_dev.dv_xname, error);
886 1.1 dante }
887 1.1 dante
888 1.1 dante xs->error = XS_DRIVER_STUFFUP;
889 1.1 dante adw_free_ccb(sc, ccb);
890 1.1 dante return (0);
891 1.1 dante }
892 1.1 dante bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
893 1.1 dante ccb->dmamap_xfer->dm_mapsize,
894 1.13 dante (xs->xs_control & XS_CTL_DATA_IN) ?
895 1.13 dante BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
896 1.1 dante
897 1.1 dante /*
898 1.1 dante * Build scatter-gather list.
899 1.1 dante */
900 1.1 dante scsiqp->data_cnt = xs->datalen;
901 1.7 dante scsiqp->vdata_addr = xs->data;
902 1.1 dante scsiqp->data_addr = ccb->dmamap_xfer->dm_segs[0].ds_addr;
903 1.7 dante bzero(ccb->sg_block, sizeof(ADW_SG_BLOCK) * ADW_NUM_SG_BLOCK);
904 1.7 dante adw_build_sglist(ccb, scsiqp, ccb->sg_block);
905 1.1 dante } else {
906 1.1 dante /*
907 1.1 dante * No data xfer, use non S/G values.
908 1.1 dante */
909 1.1 dante scsiqp->data_cnt = 0;
910 1.1 dante scsiqp->vdata_addr = 0;
911 1.1 dante scsiqp->data_addr = 0;
912 1.1 dante }
913 1.1 dante
914 1.1 dante return (1);
915 1.1 dante }
916 1.1 dante
917 1.1 dante
918 1.1 dante /*
919 1.1 dante * Build scatter-gather list for Wide Boards.
920 1.1 dante */
921 1.1 dante static void
922 1.7 dante adw_build_sglist(ccb, scsiqp, sg_block)
923 1.2 dante ADW_CCB *ccb;
924 1.2 dante ADW_SCSI_REQ_Q *scsiqp;
925 1.7 dante ADW_SG_BLOCK *sg_block;
926 1.1 dante {
927 1.9 thorpej u_long sg_block_next_addr; /* block and its next */
928 1.9 thorpej u_int32_t sg_block_physical_addr;
929 1.13 dante int i; /* how many SG entries */
930 1.1 dante bus_dma_segment_t *sg_list = &ccb->dmamap_xfer->dm_segs[0];
931 1.2 dante int sg_elem_cnt = ccb->dmamap_xfer->dm_nsegs;
932 1.1 dante
933 1.1 dante
934 1.9 thorpej sg_block_next_addr = (u_long) sg_block; /* allow math operation */
935 1.10 thorpej sg_block_physical_addr = ccb->hashkey +
936 1.10 thorpej offsetof(struct adw_ccb, sg_block[0]);
937 1.1 dante scsiqp->sg_real_addr = sg_block_physical_addr;
938 1.1 dante
939 1.1 dante /*
940 1.1 dante * If there are more than NO_OF_SG_PER_BLOCK dma segments (hw sg-list)
941 1.1 dante * then split the request into multiple sg-list blocks.
942 1.1 dante */
943 1.1 dante
944 1.2 dante do {
945 1.2 dante for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
946 1.1 dante sg_block->sg_list[i].sg_addr = sg_list->ds_addr;
947 1.1 dante sg_block->sg_list[i].sg_count = sg_list->ds_len;
948 1.1 dante
949 1.2 dante if (--sg_elem_cnt == 0) {
950 1.1 dante /* last entry, get out */
951 1.13 dante sg_block->sg_cnt = i + i;
952 1.2 dante sg_block->sg_ptr = NULL; /* next link = NULL */
953 1.1 dante return;
954 1.1 dante }
955 1.1 dante sg_list++;
956 1.1 dante }
957 1.1 dante sg_block_next_addr += sizeof(ADW_SG_BLOCK);
958 1.1 dante sg_block_physical_addr += sizeof(ADW_SG_BLOCK);
959 1.1 dante
960 1.13 dante sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
961 1.9 thorpej sg_block->sg_ptr = sg_block_physical_addr;
962 1.2 dante sg_block = (ADW_SG_BLOCK *) sg_block_next_addr; /* virt. addr */
963 1.10 thorpej } while (1);
964 1.1 dante }
965 1.1 dante
966 1.1 dante
967 1.1 dante int
968 1.1 dante adw_intr(arg)
969 1.1 dante void *arg;
970 1.1 dante {
971 1.1 dante ADW_SOFTC *sc = arg;
972 1.1 dante struct scsipi_xfer *xs;
973 1.1 dante
974 1.1 dante
975 1.13 dante if(AdvISR(sc) != ADW_FALSE) {
976 1.13 dante /*
977 1.13 dante * If there are queue entries in the software queue, try to
978 1.13 dante * run the first one. We should be more or less guaranteed
979 1.13 dante * to succeed, since we just freed a CCB.
980 1.13 dante *
981 1.13 dante * NOTE: adw_scsi_cmd() relies on our calling it with
982 1.13 dante * the first entry in the queue.
983 1.13 dante */
984 1.13 dante if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL)
985 1.13 dante (void) adw_scsi_cmd(xs);
986 1.16 dante
987 1.16 dante return (1);
988 1.13 dante }
989 1.1 dante
990 1.16 dante return (0);
991 1.1 dante }
992 1.1 dante
993 1.1 dante
994 1.1 dante /*
995 1.1 dante * Poll a particular unit, looking for a particular xs
996 1.1 dante */
997 1.1 dante static int
998 1.1 dante adw_poll(sc, xs, count)
999 1.1 dante ADW_SOFTC *sc;
1000 1.1 dante struct scsipi_xfer *xs;
1001 1.1 dante int count;
1002 1.1 dante {
1003 1.1 dante
1004 1.1 dante /* timeouts are in msec, so we loop in 1000 usec cycles */
1005 1.1 dante while (count) {
1006 1.1 dante adw_intr(sc);
1007 1.12 thorpej if (xs->xs_status & XS_STS_DONE)
1008 1.1 dante return (0);
1009 1.1 dante delay(1000); /* only happens in boot so ok */
1010 1.1 dante count--;
1011 1.1 dante }
1012 1.1 dante return (1);
1013 1.1 dante }
1014 1.1 dante
1015 1.1 dante
1016 1.1 dante static void
1017 1.1 dante adw_timeout(arg)
1018 1.1 dante void *arg;
1019 1.1 dante {
1020 1.1 dante ADW_CCB *ccb = arg;
1021 1.1 dante struct scsipi_xfer *xs = ccb->xs;
1022 1.1 dante struct scsipi_link *sc_link = xs->sc_link;
1023 1.1 dante ADW_SOFTC *sc = sc_link->adapter_softc;
1024 1.1 dante int s;
1025 1.1 dante
1026 1.1 dante scsi_print_addr(sc_link);
1027 1.1 dante printf("timed out");
1028 1.1 dante
1029 1.1 dante s = splbio();
1030 1.1 dante
1031 1.11 dante if (ccb->flags & CCB_ABORTED) {
1032 1.11 dante /*
1033 1.11 dante * Abort Timed Out
1034 1.19 dante *
1035 1.20 dante * No more opportunities. Lets try resetting the bus and
1036 1.20 dante * reinitialize the host adapter.
1037 1.11 dante */
1038 1.19 dante callout_stop(&xs->xs_callout);
1039 1.11 dante printf(" AGAIN. Resetting SCSI Bus\n");
1040 1.21 dante adw_reset_bus(sc, xs);
1041 1.19 dante splx(s);
1042 1.19 dante return;
1043 1.19 dante } else if (ccb->flags & CCB_ABORTING) {
1044 1.19 dante /*
1045 1.20 dante * Abort the operation that has timed out.
1046 1.19 dante *
1047 1.19 dante * Second opportunity.
1048 1.19 dante */
1049 1.19 dante printf("\n");
1050 1.19 dante xs->error = XS_TIMEOUT;
1051 1.19 dante ccb->flags |= CCB_ABORTED;
1052 1.19 dante #if 0
1053 1.19 dante /*
1054 1.19 dante * - XXX - 3.3a microcode is BROKEN!!!
1055 1.19 dante *
1056 1.19 dante * We cannot abort a CCB, so we can only hope the command
1057 1.19 dante * get completed before the next timeout, otherwise a
1058 1.19 dante * Bus Reset will arrive inexorably.
1059 1.19 dante */
1060 1.19 dante /*
1061 1.19 dante * ADW_ABORT_CCB() makes the board to generate an interrupt
1062 1.19 dante *
1063 1.19 dante * - XXX - The above assertion MUST be verified (and this
1064 1.19 dante * code changed as well [callout_*()]), when the
1065 1.19 dante * ADW_ABORT_CCB will be working again
1066 1.19 dante */
1067 1.19 dante ADW_ABORT_CCB(sc, ccb);
1068 1.19 dante #endif
1069 1.19 dante /*
1070 1.19 dante * waiting for multishot callout_reset() let's restart it
1071 1.19 dante * by hand so the next time a timeout event will occour
1072 1.19 dante * we will reset the bus.
1073 1.19 dante */
1074 1.19 dante callout_reset(&xs->xs_callout,
1075 1.19 dante (ccb->timeout * hz) / 1000, adw_timeout, ccb);
1076 1.1 dante } else {
1077 1.11 dante /*
1078 1.20 dante * Abort the operation that has timed out.
1079 1.19 dante *
1080 1.19 dante * First opportunity.
1081 1.11 dante */
1082 1.1 dante printf("\n");
1083 1.11 dante xs->error = XS_TIMEOUT;
1084 1.11 dante ccb->flags |= CCB_ABORTING;
1085 1.19 dante #if 0
1086 1.19 dante /*
1087 1.19 dante * - XXX - 3.3a microcode is BROKEN!!!
1088 1.19 dante *
1089 1.19 dante * We cannot abort a CCB, so we can only hope the command
1090 1.19 dante * get completed before the next 2 timeout, otherwise a
1091 1.19 dante * Bus Reset will arrive inexorably.
1092 1.19 dante */
1093 1.19 dante /*
1094 1.19 dante * ADW_ABORT_CCB() makes the board to generate an interrupt
1095 1.19 dante *
1096 1.19 dante * - XXX - The above assertion MUST be verified (and this
1097 1.19 dante * code changed as well [callout_*()]), when the
1098 1.19 dante * ADW_ABORT_CCB will be working again
1099 1.19 dante */
1100 1.1 dante ADW_ABORT_CCB(sc, ccb);
1101 1.19 dante #endif
1102 1.19 dante /*
1103 1.19 dante * waiting for multishot callout_reset() let's restart it
1104 1.20 dante * by hand so to give a second opportunity to the command
1105 1.20 dante * which timed-out.
1106 1.19 dante */
1107 1.19 dante callout_reset(&xs->xs_callout,
1108 1.19 dante (ccb->timeout * hz) / 1000, adw_timeout, ccb);
1109 1.1 dante }
1110 1.1 dante
1111 1.1 dante splx(s);
1112 1.1 dante }
1113 1.1 dante
1114 1.1 dante
1115 1.21 dante static void
1116 1.21 dante adw_reset_bus(sc, xs)
1117 1.21 dante ADW_SOFTC *sc;
1118 1.21 dante struct scsipi_xfer *xs;
1119 1.21 dante {
1120 1.21 dante ADW_CCB *ccb;
1121 1.21 dante int s;
1122 1.21 dante
1123 1.21 dante s = splbio();
1124 1.21 dante AdvResetSCSIBus(sc);
1125 1.21 dante while((ccb = TAILQ_LAST(&sc->sc_pending_ccb,
1126 1.21 dante adw_pending_ccb)) != NULL) {
1127 1.21 dante callout_stop(&ccb->xs->xs_callout);
1128 1.21 dante TAILQ_REMOVE(&sc->sc_pending_ccb, ccb, chain);
1129 1.21 dante TAILQ_INSERT_HEAD(&sc->sc_waiting_ccb, ccb, chain);
1130 1.21 dante }
1131 1.21 dante adw_queue_ccb(sc, TAILQ_FIRST(&sc->sc_waiting_ccb), 1);
1132 1.21 dante splx(s);
1133 1.21 dante }
1134 1.21 dante
1135 1.21 dante
1136 1.1 dante /******************************************************************************/
1137 1.19 dante /* Host Adapter and Peripherals Information Routines */
1138 1.19 dante /******************************************************************************/
1139 1.19 dante
1140 1.19 dante
1141 1.19 dante static void
1142 1.19 dante adw_print_info(sc, tid)
1143 1.19 dante ADW_SOFTC *sc;
1144 1.19 dante int tid;
1145 1.19 dante {
1146 1.19 dante bus_space_tag_t iot = sc->sc_iot;
1147 1.19 dante bus_space_handle_t ioh = sc->sc_ioh;
1148 1.19 dante u_int16_t wdtr_able, wdtr_done, wdtr;
1149 1.19 dante u_int16_t sdtr_able, sdtr_done, sdtr, period;
1150 1.20 dante static int wdtr_reneg = 0, sdtr_reneg = 0;
1151 1.20 dante
1152 1.20 dante if (tid == 0){
1153 1.20 dante wdtr_reneg = sdtr_reneg = 0;
1154 1.20 dante }
1155 1.19 dante
1156 1.19 dante printf("%s: target %d ", sc->sc_dev.dv_xname, tid);
1157 1.19 dante
1158 1.19 dante ADW_READ_WORD_LRAM(iot, ioh, ASC_MC_SDTR_ABLE, wdtr_able);
1159 1.19 dante if(wdtr_able & ADW_TID_TO_TIDMASK(tid)) {
1160 1.19 dante ADW_READ_WORD_LRAM(iot, ioh, ASC_MC_SDTR_DONE, wdtr_done);
1161 1.19 dante ADW_READ_WORD_LRAM(iot, ioh, ASC_MC_DEVICE_HSHK_CFG_TABLE +
1162 1.19 dante (2 * tid), wdtr);
1163 1.19 dante printf("using %d-bits wide, ", (wdtr & 0x8000)? 16 : 8);
1164 1.19 dante if((wdtr_done & ADW_TID_TO_TIDMASK(tid)) == 0)
1165 1.19 dante wdtr_reneg = 1;
1166 1.19 dante } else {
1167 1.19 dante printf("wide transfers disabled, ");
1168 1.19 dante }
1169 1.19 dante
1170 1.19 dante ADW_READ_WORD_LRAM(iot, ioh, ASC_MC_SDTR_ABLE, sdtr_able);
1171 1.19 dante if(sdtr_able & ADW_TID_TO_TIDMASK(tid)) {
1172 1.19 dante ADW_READ_WORD_LRAM(iot, ioh, ASC_MC_SDTR_DONE, sdtr_done);
1173 1.19 dante ADW_READ_WORD_LRAM(iot, ioh, ASC_MC_DEVICE_HSHK_CFG_TABLE +
1174 1.19 dante (2 * tid), sdtr);
1175 1.19 dante sdtr &= ~0x8000;
1176 1.19 dante if((sdtr & 0x1F) != 0) {
1177 1.19 dante if((sdtr & 0x1F00) == 0x1100){
1178 1.19 dante printf("80.0 MHz");
1179 1.19 dante } else if((sdtr & 0x1F00) == 0x1000){
1180 1.19 dante printf("40.0 MHz");
1181 1.19 dante } else {
1182 1.19 dante /* <= 20.0 MHz */
1183 1.19 dante period = (((sdtr >> 8) * 25) + 50)/4;
1184 1.19 dante if(period == 0) {
1185 1.19 dante /* Should never happen. */
1186 1.19 dante printf("? MHz");
1187 1.19 dante } else {
1188 1.19 dante printf("%d.%d MHz", 250/period,
1189 1.19 dante ADW_TENTHS(250, period));
1190 1.19 dante }
1191 1.19 dante }
1192 1.19 dante printf(" synchronous transfers\n");
1193 1.19 dante } else {
1194 1.19 dante printf("asynchronous transfers\n");
1195 1.19 dante }
1196 1.19 dante if((sdtr_done & ADW_TID_TO_TIDMASK(tid)) == 0)
1197 1.19 dante sdtr_reneg = 1;
1198 1.19 dante } else {
1199 1.19 dante printf("synchronous transfers disabled\n");
1200 1.19 dante }
1201 1.19 dante
1202 1.19 dante if(wdtr_reneg || sdtr_reneg) {
1203 1.19 dante printf("%s: target %d %s", sc->sc_dev.dv_xname, tid,
1204 1.19 dante (wdtr_reneg)? ((sdtr_reneg)? "wide/sync" : "wide") :
1205 1.19 dante ((sdtr_reneg)? "sync" : "") );
1206 1.19 dante printf(" renegotiation pending before next command.\n");
1207 1.19 dante }
1208 1.19 dante }
1209 1.19 dante
1210 1.19 dante
1211 1.19 dante /******************************************************************************/
1212 1.19 dante /* WIDE boards Interrupt callbacks */
1213 1.1 dante /******************************************************************************/
1214 1.1 dante
1215 1.1 dante
1216 1.1 dante /*
1217 1.19 dante * adw_isr_callback() - Second Level Interrupt Handler called by AdvISR()
1218 1.1 dante *
1219 1.1 dante * Interrupt callback function for the Wide SCSI Adv Library.
1220 1.19 dante *
1221 1.19 dante * Notice:
1222 1.19 dante * Intrrupts are disabled by the caller (AdvISR() function), and will be
1223 1.19 dante * enabled at the end of the caller.
1224 1.1 dante */
1225 1.1 dante static void
1226 1.13 dante adw_isr_callback(sc, scsiq)
1227 1.1 dante ADW_SOFTC *sc;
1228 1.1 dante ADW_SCSI_REQ_Q *scsiq;
1229 1.1 dante {
1230 1.2 dante bus_dma_tag_t dmat = sc->sc_dmat;
1231 1.7 dante ADW_CCB *ccb;
1232 1.7 dante struct scsipi_xfer *xs;
1233 1.1 dante struct scsipi_sense_data *s1, *s2;
1234 1.1 dante
1235 1.7 dante
1236 1.7 dante ccb = adw_ccb_phys_kv(sc, scsiq->ccb_ptr);
1237 1.11 dante
1238 1.15 thorpej callout_stop(&ccb->xs->xs_callout);
1239 1.11 dante
1240 1.7 dante xs = ccb->xs;
1241 1.1 dante
1242 1.1 dante /*
1243 1.1 dante * If we were a data transfer, unload the map that described
1244 1.1 dante * the data buffer.
1245 1.1 dante */
1246 1.1 dante if (xs->datalen) {
1247 1.1 dante bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
1248 1.1 dante ccb->dmamap_xfer->dm_mapsize,
1249 1.12 thorpej (xs->xs_control & XS_CTL_DATA_IN) ?
1250 1.12 thorpej BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
1251 1.1 dante bus_dmamap_unload(dmat, ccb->dmamap_xfer);
1252 1.1 dante }
1253 1.20 dante
1254 1.1 dante if ((ccb->flags & CCB_ALLOC) == 0) {
1255 1.1 dante printf("%s: exiting ccb not allocated!\n", sc->sc_dev.dv_xname);
1256 1.1 dante Debugger();
1257 1.1 dante return;
1258 1.1 dante }
1259 1.20 dante
1260 1.1 dante /*
1261 1.1 dante * 'done_status' contains the command's ending status.
1262 1.20 dante * 'host_status' conatins the host adapter status.
1263 1.20 dante * 'scsi_status' contains the scsi peripheral status.
1264 1.1 dante */
1265 1.21 dante if ((scsiq->host_status == QHSTA_NO_ERROR) &&
1266 1.21 dante ((scsiq->done_status == QD_NO_ERROR) ||
1267 1.21 dante (scsiq->done_status == QD_WITH_ERROR))) {
1268 1.21 dante switch (scsiq->host_status) {
1269 1.21 dante case SCSI_STATUS_GOOD:
1270 1.21 dante if ((scsiq->cdb[0] == INQUIRY) &&
1271 1.21 dante (scsiq->target_lun == 0)) {
1272 1.21 dante adw_print_info(sc, scsiq->target_id);
1273 1.21 dante }
1274 1.21 dante xs->error = XS_NOERROR;
1275 1.21 dante xs->resid = scsiq->data_cnt;
1276 1.21 dante sc->sc_freeze_dev[scsiq->target_id] = 0;
1277 1.21 dante break;
1278 1.21 dante
1279 1.21 dante case SCSI_STATUS_CHECK_CONDITION:
1280 1.21 dante case SCSI_STATUS_CMD_TERMINATED:
1281 1.21 dante s1 = &ccb->scsi_sense;
1282 1.21 dante s2 = &xs->sense.scsi_sense;
1283 1.21 dante *s2 = *s1;
1284 1.21 dante xs->error = XS_SENSE;
1285 1.21 dante sc->sc_freeze_dev[scsiq->target_id] = 1;
1286 1.21 dante break;
1287 1.21 dante
1288 1.21 dante default:
1289 1.21 dante xs->error = XS_BUSY;
1290 1.21 dante sc->sc_freeze_dev[scsiq->target_id] = 1;
1291 1.21 dante break;
1292 1.20 dante }
1293 1.21 dante } else if (scsiq->done_status == QD_ABORTED_BY_HOST) {
1294 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1295 1.21 dante } else {
1296 1.21 dante switch (scsiq->host_status) {
1297 1.21 dante case QHSTA_M_SEL_TIMEOUT:
1298 1.21 dante xs->error = XS_SELTIMEOUT;
1299 1.21 dante break;
1300 1.21 dante
1301 1.21 dante case QHSTA_M_SXFR_OFF_UFLW:
1302 1.21 dante case QHSTA_M_SXFR_OFF_OFLW:
1303 1.21 dante case QHSTA_M_DATA_OVER_RUN:
1304 1.21 dante printf("%s: Overrun/Overflow/Underflow condition\n",
1305 1.21 dante sc->sc_dev.dv_xname);
1306 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1307 1.21 dante break;
1308 1.21 dante
1309 1.21 dante case QHSTA_M_SXFR_DESELECTED:
1310 1.21 dante case QHSTA_M_UNEXPECTED_BUS_FREE:
1311 1.21 dante printf("%s: Unexpected BUS free\n",sc->sc_dev.dv_xname);
1312 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1313 1.21 dante break;
1314 1.21 dante
1315 1.21 dante case QHSTA_M_SCSI_BUS_RESET:
1316 1.21 dante case QHSTA_M_SCSI_BUS_RESET_UNSOL:
1317 1.21 dante printf("%s: BUS Reset\n", sc->sc_dev.dv_xname);
1318 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1319 1.21 dante break;
1320 1.1 dante
1321 1.21 dante case QHSTA_M_BUS_DEVICE_RESET:
1322 1.21 dante printf("%s: Device Reset\n", sc->sc_dev.dv_xname);
1323 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1324 1.21 dante break;
1325 1.20 dante
1326 1.21 dante case QHSTA_M_QUEUE_ABORTED:
1327 1.21 dante printf("%s: Queue Aborted\n", sc->sc_dev.dv_xname);
1328 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1329 1.1 dante break;
1330 1.1 dante
1331 1.20 dante case QHSTA_M_SXFR_SDMA_ERR:
1332 1.21 dante case QHSTA_M_SXFR_SXFR_PERR:
1333 1.21 dante case QHSTA_M_RDMA_PERR:
1334 1.20 dante /*
1335 1.21 dante * DMA Error. This should *NEVER* happen!
1336 1.20 dante *
1337 1.20 dante * Lets try resetting the bus and reinitialize
1338 1.20 dante * the host adapter.
1339 1.20 dante */
1340 1.21 dante printf("%s: DMA Error. Reseting bus\n",
1341 1.21 dante sc->sc_dev.dv_xname);
1342 1.21 dante adw_reset_bus(sc, xs);
1343 1.21 dante xs->error = XS_BUSY;
1344 1.21 dante break;
1345 1.21 dante
1346 1.21 dante case QHSTA_M_WTM_TIMEOUT:
1347 1.21 dante case QHSTA_M_SXFR_WD_TMO:
1348 1.21 dante /* The SCSI bus hung in a phase */
1349 1.21 dante printf("%s: Watch Dog timer expired. Reseting bus\n",
1350 1.21 dante sc->sc_dev.dv_xname);
1351 1.21 dante adw_reset_bus(sc, xs);
1352 1.21 dante xs->error = XS_BUSY;
1353 1.21 dante break;
1354 1.21 dante
1355 1.21 dante case QHSTA_M_SXFR_XFR_PH_ERR:
1356 1.21 dante printf("%s: Transfer Error\n", sc->sc_dev.dv_xname);
1357 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1358 1.21 dante break;
1359 1.21 dante
1360 1.21 dante case QHSTA_M_BAD_CMPL_STATUS_IN:
1361 1.21 dante /* No command complete after a status message */
1362 1.21 dante printf("%s: Bad Completion Status\n",
1363 1.21 dante sc->sc_dev.dv_xname);
1364 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1365 1.21 dante break;
1366 1.21 dante
1367 1.21 dante case QHSTA_M_AUTO_REQ_SENSE_FAIL:
1368 1.21 dante printf("%s: Auto Sense Failed\n", sc->sc_dev.dv_xname);
1369 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1370 1.21 dante break;
1371 1.21 dante
1372 1.21 dante case QHSTA_M_INVALID_DEVICE:
1373 1.21 dante printf("%s: Invalid Device\n", sc->sc_dev.dv_xname);
1374 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1375 1.21 dante break;
1376 1.11 dante
1377 1.21 dante case QHSTA_M_NO_AUTO_REQ_SENSE:
1378 1.21 dante /*
1379 1.21 dante * User didn't request sense, but we got a
1380 1.21 dante * check condition.
1381 1.21 dante */
1382 1.21 dante printf("%s: Unexpected Check Condition\n",
1383 1.21 dante sc->sc_dev.dv_xname);
1384 1.1 dante xs->error = XS_DRIVER_STUFFUP;
1385 1.1 dante break;
1386 1.1 dante
1387 1.21 dante case QHSTA_M_SXFR_UNKNOWN_ERROR:
1388 1.21 dante printf("%s: Unknown Error\n", sc->sc_dev.dv_xname);
1389 1.21 dante xs->error = XS_DRIVER_STUFFUP;
1390 1.21 dante break;
1391 1.11 dante
1392 1.21 dante default:
1393 1.21 dante panic("%s: Unhandled Host Status Error %x",
1394 1.21 dante sc->sc_dev.dv_xname, scsiq->host_status);
1395 1.21 dante }
1396 1.1 dante }
1397 1.1 dante
1398 1.19 dante TAILQ_REMOVE(&sc->sc_pending_ccb, ccb, chain);
1399 1.1 dante adw_free_ccb(sc, ccb);
1400 1.12 thorpej xs->xs_status |= XS_STS_DONE;
1401 1.1 dante scsipi_done(xs);
1402 1.11 dante }
1403 1.11 dante
1404 1.11 dante
1405 1.13 dante /*
1406 1.13 dante * adv_async_callback() - Adv Library asynchronous event callback function.
1407 1.13 dante */
1408 1.11 dante static void
1409 1.13 dante adw_async_callback(sc, code)
1410 1.11 dante ADW_SOFTC *sc;
1411 1.13 dante u_int8_t code;
1412 1.11 dante {
1413 1.13 dante switch (code) {
1414 1.13 dante case ADV_ASYNC_SCSI_BUS_RESET_DET:
1415 1.21 dante /* The firmware detected a SCSI Bus reset. */
1416 1.19 dante printf("%s: SCSI Bus reset detected\n", sc->sc_dev.dv_xname);
1417 1.13 dante break;
1418 1.13 dante
1419 1.13 dante case ADV_ASYNC_RDMA_FAILURE:
1420 1.13 dante /*
1421 1.13 dante * Handle RDMA failure by resetting the SCSI Bus and
1422 1.19 dante * possibly the chip if it is unresponsive.
1423 1.13 dante */
1424 1.20 dante printf("%s: RDMA failure. Resetting the SCSI Bus and"
1425 1.20 dante " the adapter\n", sc->sc_dev.dv_xname);
1426 1.13 dante AdvResetSCSIBus(sc);
1427 1.13 dante break;
1428 1.13 dante
1429 1.13 dante case ADV_HOST_SCSI_BUS_RESET:
1430 1.21 dante /* Host generated SCSI bus reset occurred. */
1431 1.19 dante printf("%s: Host generated SCSI bus reset occurred\n",
1432 1.19 dante sc->sc_dev.dv_xname);
1433 1.19 dante break;
1434 1.19 dante
1435 1.19 dante case ADV_ASYNC_CARRIER_READY_FAILURE:
1436 1.21 dante /* Carrier Ready failure. */
1437 1.19 dante printf("%s: Carrier Ready failure!\n", sc->sc_dev.dv_xname);
1438 1.19 dante break;
1439 1.13 dante
1440 1.13 dante default:
1441 1.13 dante break;
1442 1.13 dante }
1443 1.1 dante }
1444