adw.c revision 1.12.2.5 1 1.12.2.5 bouyer /* $NetBSD: adw.c,v 1.12.2.5 2000/11/20 11:40:07 bouyer 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.12.2.5 bouyer * 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.12.2.5 bouyer #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.12.2.5 bouyer #include <uvm/uvm_extern.h>
57 1.1 dante
58 1.1 dante #include <dev/scsipi/scsi_all.h>
59 1.1 dante #include <dev/scsipi/scsipi_all.h>
60 1.1 dante #include <dev/scsipi/scsiconf.h>
61 1.1 dante
62 1.1 dante #include <dev/ic/adwlib.h>
63 1.12.2.5 bouyer #include <dev/ic/adwmcode.h>
64 1.1 dante #include <dev/ic/adw.h>
65 1.1 dante
66 1.1 dante #ifndef DDB
67 1.11 dante #define Debugger() panic("should call debugger here (adw.c)")
68 1.2 dante #endif /* ! DDB */
69 1.1 dante
70 1.1 dante /******************************************************************************/
71 1.1 dante
72 1.1 dante
73 1.12.2.5 bouyer static int adw_alloc_controls __P((ADW_SOFTC *));
74 1.12.2.5 bouyer static int adw_alloc_carriers __P((ADW_SOFTC *));
75 1.1 dante static int adw_create_ccbs __P((ADW_SOFTC *, ADW_CCB *, int));
76 1.1 dante static void adw_free_ccb __P((ADW_SOFTC *, ADW_CCB *));
77 1.1 dante static void adw_reset_ccb __P((ADW_CCB *));
78 1.1 dante static int adw_init_ccb __P((ADW_SOFTC *, ADW_CCB *));
79 1.12.2.2 thorpej static ADW_CCB *adw_get_ccb __P((ADW_SOFTC *));
80 1.12.2.5 bouyer static int adw_queue_ccb __P((ADW_SOFTC *, ADW_CCB *));
81 1.1 dante
82 1.12.2.1 thorpej static void adw_scsipi_request __P((struct scsipi_channel *,
83 1.12.2.1 thorpej scsipi_adapter_req_t, void *));
84 1.12.2.1 thorpej static int adw_build_req __P((ADW_SOFTC *, ADW_CCB *));
85 1.7 dante static void adw_build_sglist __P((ADW_CCB *, ADW_SCSI_REQ_Q *, ADW_SG_BLOCK *));
86 1.1 dante static void adwminphys __P((struct buf *));
87 1.12.2.5 bouyer static void adw_isr_callback __P((ADW_SOFTC *, ADW_SCSI_REQ_Q *));
88 1.12.2.5 bouyer static void adw_async_callback __P((ADW_SOFTC *, u_int8_t));
89 1.12.2.5 bouyer
90 1.12.2.5 bouyer static void adw_print_info __P((ADW_SOFTC *, int));
91 1.1 dante
92 1.1 dante static int adw_poll __P((ADW_SOFTC *, struct scsipi_xfer *, int));
93 1.1 dante static void adw_timeout __P((void *));
94 1.12.2.5 bouyer static void adw_reset_bus __P((ADW_SOFTC *));
95 1.1 dante
96 1.1 dante
97 1.1 dante /******************************************************************************/
98 1.12.2.5 bouyer /* DMA Mapping for Control Blocks */
99 1.1 dante /******************************************************************************/
100 1.1 dante
101 1.1 dante
102 1.1 dante static int
103 1.12.2.5 bouyer adw_alloc_controls(sc)
104 1.1 dante ADW_SOFTC *sc;
105 1.1 dante {
106 1.1 dante bus_dma_segment_t seg;
107 1.1 dante int error, rseg;
108 1.1 dante
109 1.1 dante /*
110 1.12.2.5 bouyer * Allocate the control structure.
111 1.1 dante */
112 1.1 dante if ((error = bus_dmamem_alloc(sc->sc_dmat, sizeof(struct adw_control),
113 1.1 dante NBPG, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
114 1.1 dante printf("%s: unable to allocate control structures,"
115 1.1 dante " error = %d\n", sc->sc_dev.dv_xname, error);
116 1.1 dante return (error);
117 1.1 dante }
118 1.1 dante if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
119 1.1 dante sizeof(struct adw_control), (caddr_t *) & sc->sc_control,
120 1.1 dante BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
121 1.1 dante printf("%s: unable to map control structures, error = %d\n",
122 1.1 dante sc->sc_dev.dv_xname, error);
123 1.1 dante return (error);
124 1.1 dante }
125 1.12.2.5 bouyer
126 1.1 dante /*
127 1.1 dante * Create and load the DMA map used for the control blocks.
128 1.1 dante */
129 1.1 dante if ((error = bus_dmamap_create(sc->sc_dmat, sizeof(struct adw_control),
130 1.1 dante 1, sizeof(struct adw_control), 0, BUS_DMA_NOWAIT,
131 1.1 dante &sc->sc_dmamap_control)) != 0) {
132 1.1 dante printf("%s: unable to create control DMA map, error = %d\n",
133 1.1 dante sc->sc_dev.dv_xname, error);
134 1.1 dante return (error);
135 1.1 dante }
136 1.1 dante if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap_control,
137 1.1 dante sc->sc_control, sizeof(struct adw_control), NULL,
138 1.1 dante BUS_DMA_NOWAIT)) != 0) {
139 1.1 dante printf("%s: unable to load control DMA map, error = %d\n",
140 1.1 dante sc->sc_dev.dv_xname, error);
141 1.1 dante return (error);
142 1.1 dante }
143 1.12.2.5 bouyer
144 1.12.2.5 bouyer return (0);
145 1.12.2.5 bouyer }
146 1.12.2.5 bouyer
147 1.12.2.5 bouyer
148 1.12.2.5 bouyer static int
149 1.12.2.5 bouyer adw_alloc_carriers(sc)
150 1.12.2.5 bouyer ADW_SOFTC *sc;
151 1.12.2.5 bouyer {
152 1.12.2.5 bouyer bus_dma_segment_t seg;
153 1.12.2.5 bouyer int error, rseg;
154 1.12.2.5 bouyer
155 1.12.2.5 bouyer /*
156 1.12.2.5 bouyer * Allocate the control structure.
157 1.12.2.5 bouyer */
158 1.12.2.5 bouyer sc->sc_control->carriers = malloc(sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
159 1.12.2.5 bouyer M_DEVBUF, M_WAITOK);
160 1.12.2.5 bouyer if(!sc->sc_control->carriers) {
161 1.12.2.5 bouyer printf("%s: malloc() failed in allocating carrier structures\n",
162 1.12.2.5 bouyer sc->sc_dev.dv_xname);
163 1.12.2.5 bouyer return (ENOMEM);
164 1.12.2.5 bouyer }
165 1.12.2.5 bouyer
166 1.12.2.5 bouyer if ((error = bus_dmamem_alloc(sc->sc_dmat,
167 1.12.2.5 bouyer sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
168 1.12.2.5 bouyer 0x10, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
169 1.12.2.5 bouyer printf("%s: unable to allocate carrier structures,"
170 1.12.2.5 bouyer " error = %d\n", sc->sc_dev.dv_xname, error);
171 1.12.2.5 bouyer return (error);
172 1.12.2.5 bouyer }
173 1.12.2.5 bouyer if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
174 1.12.2.5 bouyer sizeof(ADW_CARRIER) * ADW_MAX_CARRIER,
175 1.12.2.5 bouyer (caddr_t *) &sc->sc_control->carriers,
176 1.12.2.5 bouyer BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
177 1.12.2.5 bouyer printf("%s: unable to map carrier structures,"
178 1.12.2.5 bouyer " error = %d\n", sc->sc_dev.dv_xname, error);
179 1.12.2.5 bouyer return (error);
180 1.12.2.5 bouyer }
181 1.12.2.5 bouyer
182 1.12.2.5 bouyer /*
183 1.12.2.5 bouyer * Create and load the DMA map used for the control blocks.
184 1.12.2.5 bouyer */
185 1.12.2.5 bouyer if ((error = bus_dmamap_create(sc->sc_dmat,
186 1.12.2.5 bouyer sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, 1,
187 1.12.2.5 bouyer sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, 0,BUS_DMA_NOWAIT,
188 1.12.2.5 bouyer &sc->sc_dmamap_carrier)) != 0) {
189 1.12.2.5 bouyer printf("%s: unable to create carriers DMA map,"
190 1.12.2.5 bouyer " error = %d\n", sc->sc_dev.dv_xname, error);
191 1.12.2.5 bouyer return (error);
192 1.12.2.5 bouyer }
193 1.12.2.5 bouyer if ((error = bus_dmamap_load(sc->sc_dmat,
194 1.12.2.5 bouyer sc->sc_dmamap_carrier, sc->sc_control->carriers,
195 1.12.2.5 bouyer sizeof(ADW_CARRIER) * ADW_MAX_CARRIER, NULL,
196 1.12.2.5 bouyer BUS_DMA_NOWAIT)) != 0) {
197 1.12.2.5 bouyer printf("%s: unable to load carriers DMA map,"
198 1.12.2.5 bouyer " error = %d\n", sc->sc_dev.dv_xname, error);
199 1.12.2.5 bouyer return (error);
200 1.12.2.5 bouyer }
201 1.12.2.5 bouyer
202 1.1 dante return (0);
203 1.1 dante }
204 1.1 dante
205 1.1 dante
206 1.12.2.5 bouyer /******************************************************************************/
207 1.12.2.5 bouyer /* Control Blocks routines */
208 1.12.2.5 bouyer /******************************************************************************/
209 1.12.2.5 bouyer
210 1.12.2.5 bouyer
211 1.1 dante /*
212 1.1 dante * Create a set of ccbs and add them to the free list. Called once
213 1.1 dante * by adw_init(). We return the number of CCBs successfully created.
214 1.1 dante */
215 1.1 dante static int
216 1.1 dante adw_create_ccbs(sc, ccbstore, count)
217 1.1 dante ADW_SOFTC *sc;
218 1.1 dante ADW_CCB *ccbstore;
219 1.1 dante int count;
220 1.1 dante {
221 1.1 dante ADW_CCB *ccb;
222 1.1 dante int i, error;
223 1.1 dante
224 1.1 dante for (i = 0; i < count; i++) {
225 1.1 dante ccb = &ccbstore[i];
226 1.1 dante if ((error = adw_init_ccb(sc, ccb)) != 0) {
227 1.1 dante printf("%s: unable to initialize ccb, error = %d\n",
228 1.1 dante sc->sc_dev.dv_xname, error);
229 1.1 dante return (i);
230 1.1 dante }
231 1.1 dante TAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, chain);
232 1.1 dante }
233 1.1 dante
234 1.1 dante return (i);
235 1.1 dante }
236 1.1 dante
237 1.1 dante
238 1.1 dante /*
239 1.1 dante * A ccb is put onto the free list.
240 1.1 dante */
241 1.1 dante static void
242 1.1 dante adw_free_ccb(sc, ccb)
243 1.1 dante ADW_SOFTC *sc;
244 1.1 dante ADW_CCB *ccb;
245 1.1 dante {
246 1.1 dante int s;
247 1.1 dante
248 1.1 dante s = splbio();
249 1.12.2.5 bouyer
250 1.1 dante adw_reset_ccb(ccb);
251 1.1 dante TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, chain);
252 1.12.2.5 bouyer
253 1.1 dante splx(s);
254 1.1 dante }
255 1.1 dante
256 1.1 dante
257 1.1 dante static void
258 1.1 dante adw_reset_ccb(ccb)
259 1.1 dante ADW_CCB *ccb;
260 1.1 dante {
261 1.1 dante
262 1.1 dante ccb->flags = 0;
263 1.1 dante }
264 1.1 dante
265 1.1 dante
266 1.1 dante static int
267 1.1 dante adw_init_ccb(sc, ccb)
268 1.1 dante ADW_SOFTC *sc;
269 1.1 dante ADW_CCB *ccb;
270 1.1 dante {
271 1.7 dante int hashnum, error;
272 1.1 dante
273 1.1 dante /*
274 1.1 dante * Create the DMA map for this CCB.
275 1.1 dante */
276 1.1 dante error = bus_dmamap_create(sc->sc_dmat,
277 1.1 dante (ADW_MAX_SG_LIST - 1) * PAGE_SIZE,
278 1.1 dante ADW_MAX_SG_LIST, (ADW_MAX_SG_LIST - 1) * PAGE_SIZE,
279 1.1 dante 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &ccb->dmamap_xfer);
280 1.1 dante if (error) {
281 1.12.2.5 bouyer printf("%s: unable to create CCB DMA map, error = %d\n",
282 1.1 dante sc->sc_dev.dv_xname, error);
283 1.1 dante return (error);
284 1.1 dante }
285 1.7 dante
286 1.7 dante /*
287 1.7 dante * put in the phystokv hash table
288 1.7 dante * Never gets taken out.
289 1.7 dante */
290 1.7 dante ccb->hashkey = sc->sc_dmamap_control->dm_segs[0].ds_addr +
291 1.7 dante ADW_CCB_OFF(ccb);
292 1.7 dante hashnum = CCB_HASH(ccb->hashkey);
293 1.7 dante ccb->nexthash = sc->sc_ccbhash[hashnum];
294 1.7 dante sc->sc_ccbhash[hashnum] = ccb;
295 1.1 dante adw_reset_ccb(ccb);
296 1.1 dante return (0);
297 1.1 dante }
298 1.1 dante
299 1.1 dante
300 1.1 dante /*
301 1.1 dante * Get a free ccb
302 1.1 dante *
303 1.1 dante * If there are none, see if we can allocate a new one
304 1.1 dante */
305 1.1 dante static ADW_CCB *
306 1.12.2.2 thorpej adw_get_ccb(sc)
307 1.1 dante ADW_SOFTC *sc;
308 1.1 dante {
309 1.1 dante ADW_CCB *ccb = 0;
310 1.1 dante int s;
311 1.1 dante
312 1.1 dante s = splbio();
313 1.12.2.5 bouyer
314 1.12.2.5 bouyer ccb = sc->sc_free_ccb.tqh_first;
315 1.12.2.2 thorpej if (ccb != NULL) {
316 1.12.2.2 thorpej TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain);
317 1.12.2.2 thorpej ccb->flags |= CCB_ALLOC;
318 1.1 dante }
319 1.1 dante splx(s);
320 1.1 dante return (ccb);
321 1.1 dante }
322 1.1 dante
323 1.1 dante
324 1.1 dante /*
325 1.7 dante * Given a physical address, find the ccb that it corresponds to.
326 1.7 dante */
327 1.7 dante ADW_CCB *
328 1.7 dante adw_ccb_phys_kv(sc, ccb_phys)
329 1.7 dante ADW_SOFTC *sc;
330 1.9 thorpej u_int32_t ccb_phys;
331 1.7 dante {
332 1.7 dante int hashnum = CCB_HASH(ccb_phys);
333 1.7 dante ADW_CCB *ccb = sc->sc_ccbhash[hashnum];
334 1.7 dante
335 1.7 dante while (ccb) {
336 1.7 dante if (ccb->hashkey == ccb_phys)
337 1.7 dante break;
338 1.7 dante ccb = ccb->nexthash;
339 1.7 dante }
340 1.7 dante return (ccb);
341 1.7 dante }
342 1.7 dante
343 1.7 dante
344 1.7 dante /*
345 1.1 dante * Queue a CCB to be sent to the controller, and send it if possible.
346 1.1 dante */
347 1.12.2.5 bouyer static int
348 1.1 dante adw_queue_ccb(sc, ccb)
349 1.1 dante ADW_SOFTC *sc;
350 1.1 dante ADW_CCB *ccb;
351 1.1 dante {
352 1.12.2.5 bouyer int errcode = ADW_SUCCESS;
353 1.1 dante
354 1.1 dante TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain);
355 1.1 dante
356 1.1 dante while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) {
357 1.1 dante
358 1.1 dante TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
359 1.12.2.5 bouyer errcode = AdwExeScsiQueue(sc, &ccb->scsiq);
360 1.12.2.5 bouyer switch(errcode) {
361 1.12.2.5 bouyer case ADW_SUCCESS:
362 1.12.2.5 bouyer break;
363 1.12.2.5 bouyer
364 1.12.2.5 bouyer case ADW_BUSY:
365 1.12.2.5 bouyer printf("ADW_BUSY\n");
366 1.12.2.5 bouyer return(ADW_BUSY);
367 1.12.2.5 bouyer
368 1.12.2.5 bouyer case ADW_ERROR:
369 1.12.2.5 bouyer printf("ADW_ERROR\n");
370 1.12.2.5 bouyer return(ADW_ERROR);
371 1.12.2.5 bouyer }
372 1.12.2.5 bouyer
373 1.12.2.5 bouyer TAILQ_INSERT_TAIL(&sc->sc_pending_ccb, ccb, chain);
374 1.1 dante
375 1.12 thorpej if ((ccb->xs->xs_control & XS_CTL_POLL) == 0)
376 1.12.2.5 bouyer callout_reset(&ccb->xs->xs_callout,
377 1.12.2.5 bouyer (ccb->timeout * hz) / 1000, adw_timeout, ccb);
378 1.1 dante }
379 1.12.2.5 bouyer
380 1.12.2.5 bouyer return(errcode);
381 1.1 dante }
382 1.1 dante
383 1.1 dante
384 1.1 dante /******************************************************************************/
385 1.12.2.5 bouyer /* SCSI layer interfacing routines */
386 1.1 dante /******************************************************************************/
387 1.1 dante
388 1.1 dante
389 1.1 dante int
390 1.1 dante adw_init(sc)
391 1.1 dante ADW_SOFTC *sc;
392 1.1 dante {
393 1.2 dante u_int16_t warn_code;
394 1.1 dante
395 1.1 dante
396 1.1 dante sc->cfg.lib_version = (ADW_LIB_VERSION_MAJOR << 8) |
397 1.2 dante ADW_LIB_VERSION_MINOR;
398 1.1 dante sc->cfg.chip_version =
399 1.1 dante ADW_GET_CHIP_VERSION(sc->sc_iot, sc->sc_ioh, sc->bus_type);
400 1.1 dante
401 1.1 dante /*
402 1.1 dante * Reset the chip to start and allow register writes.
403 1.1 dante */
404 1.1 dante if (ADW_FIND_SIGNATURE(sc->sc_iot, sc->sc_ioh) == 0) {
405 1.1 dante panic("adw_init: adw_find_signature failed");
406 1.2 dante } else {
407 1.12.2.5 bouyer AdwResetChip(sc->sc_iot, sc->sc_ioh);
408 1.1 dante
409 1.12.2.5 bouyer warn_code = AdwInitFromEEPROM(sc);
410 1.12.2.5 bouyer
411 1.12.2.5 bouyer if (warn_code & ADW_WARN_EEPROM_CHKSUM)
412 1.1 dante printf("%s: Bad checksum found. "
413 1.2 dante "Setting default values\n",
414 1.2 dante sc->sc_dev.dv_xname);
415 1.12.2.5 bouyer if (warn_code & ADW_WARN_EEPROM_TERMINATION)
416 1.1 dante printf("%s: Bad bus termination setting."
417 1.2 dante "Using automatic termination.\n",
418 1.2 dante sc->sc_dev.dv_xname);
419 1.1 dante }
420 1.1 dante
421 1.12.2.5 bouyer sc->isr_callback = (ADW_CALLBACK) adw_isr_callback;
422 1.12.2.5 bouyer sc->async_callback = (ADW_CALLBACK) adw_async_callback;
423 1.1 dante
424 1.12.2.5 bouyer return 0;
425 1.1 dante }
426 1.1 dante
427 1.1 dante
428 1.1 dante void
429 1.1 dante adw_attach(sc)
430 1.1 dante ADW_SOFTC *sc;
431 1.1 dante {
432 1.12.2.1 thorpej struct scsipi_adapter *adapt = &sc->sc_adapter;
433 1.12.2.1 thorpej struct scsipi_channel *chan = &sc->sc_channel;
434 1.12.2.5 bouyer int ncontrols, error;
435 1.12.2.5 bouyer
436 1.12.2.5 bouyer TAILQ_INIT(&sc->sc_free_ccb);
437 1.12.2.5 bouyer TAILQ_INIT(&sc->sc_waiting_ccb);
438 1.12.2.5 bouyer TAILQ_INIT(&sc->sc_pending_ccb);
439 1.12.2.5 bouyer
440 1.12.2.5 bouyer /*
441 1.12.2.5 bouyer * Allocate the Control Blocks.
442 1.12.2.5 bouyer */
443 1.12.2.5 bouyer error = adw_alloc_controls(sc);
444 1.12.2.5 bouyer if (error)
445 1.12.2.5 bouyer return; /* (error) */ ;
446 1.12.2.5 bouyer
447 1.12.2.5 bouyer bzero(sc->sc_control, sizeof(struct adw_control));
448 1.12.2.5 bouyer
449 1.12.2.5 bouyer /*
450 1.12.2.5 bouyer * Create and initialize the Control Blocks.
451 1.12.2.5 bouyer */
452 1.12.2.5 bouyer ncontrols = adw_create_ccbs(sc, sc->sc_control->ccbs, ADW_MAX_CCB);
453 1.12.2.5 bouyer if (ncontrols == 0) {
454 1.12.2.5 bouyer printf("%s: unable to create Control Blocks\n",
455 1.12.2.5 bouyer sc->sc_dev.dv_xname);
456 1.12.2.5 bouyer return; /* (ENOMEM) */ ;
457 1.12.2.5 bouyer } else if (ncontrols != ADW_MAX_CCB) {
458 1.12.2.5 bouyer printf("%s: WARNING: only %d of %d Control Blocks"
459 1.12.2.5 bouyer " created\n",
460 1.12.2.5 bouyer sc->sc_dev.dv_xname, ncontrols, ADW_MAX_CCB);
461 1.12.2.5 bouyer }
462 1.12.2.5 bouyer
463 1.12.2.5 bouyer /*
464 1.12.2.5 bouyer * Create and initialize the Carriers.
465 1.12.2.5 bouyer */
466 1.12.2.5 bouyer error = adw_alloc_carriers(sc);
467 1.12.2.5 bouyer if (error)
468 1.12.2.5 bouyer return; /* (error) */ ;
469 1.12.2.5 bouyer
470 1.12.2.5 bouyer /*
471 1.12.2.5 bouyer * Zero's the freeze_device status
472 1.12.2.5 bouyer */
473 1.12.2.5 bouyer bzero(sc->sc_freeze_dev, sizeof(sc->sc_freeze_dev));
474 1.1 dante
475 1.1 dante /*
476 1.12.2.5 bouyer * Initialize the adapter
477 1.1 dante */
478 1.12.2.5 bouyer switch (AdwInitDriver(sc)) {
479 1.12.2.5 bouyer case ADW_IERR_BIST_PRE_TEST:
480 1.12.2.5 bouyer panic("%s: BIST pre-test error",
481 1.12.2.5 bouyer sc->sc_dev.dv_xname);
482 1.12.2.5 bouyer break;
483 1.12.2.5 bouyer
484 1.12.2.5 bouyer case ADW_IERR_BIST_RAM_TEST:
485 1.12.2.5 bouyer panic("%s: BIST RAM test error",
486 1.12.2.5 bouyer sc->sc_dev.dv_xname);
487 1.12.2.5 bouyer break;
488 1.12.2.5 bouyer
489 1.12.2.5 bouyer case ADW_IERR_MCODE_CHKSUM:
490 1.2 dante panic("%s: Microcode checksum error",
491 1.2 dante sc->sc_dev.dv_xname);
492 1.2 dante break;
493 1.2 dante
494 1.12.2.5 bouyer case ADW_IERR_ILLEGAL_CONNECTION:
495 1.2 dante panic("%s: All three connectors are in use",
496 1.2 dante sc->sc_dev.dv_xname);
497 1.2 dante break;
498 1.2 dante
499 1.12.2.5 bouyer case ADW_IERR_REVERSED_CABLE:
500 1.2 dante panic("%s: Cable is reversed",
501 1.2 dante sc->sc_dev.dv_xname);
502 1.2 dante break;
503 1.2 dante
504 1.12.2.5 bouyer case ADW_IERR_HVD_DEVICE:
505 1.12.2.5 bouyer panic("%s: HVD attached to LVD connector",
506 1.12.2.5 bouyer sc->sc_dev.dv_xname);
507 1.12.2.5 bouyer break;
508 1.12.2.5 bouyer
509 1.12.2.5 bouyer case ADW_IERR_SINGLE_END_DEVICE:
510 1.2 dante panic("%s: single-ended device is attached to"
511 1.2 dante " one of the connectors",
512 1.2 dante sc->sc_dev.dv_xname);
513 1.2 dante break;
514 1.12.2.5 bouyer
515 1.12.2.5 bouyer case ADW_IERR_NO_CARRIER:
516 1.12.2.5 bouyer panic("%s: unable to create Carriers",
517 1.12.2.5 bouyer sc->sc_dev.dv_xname);
518 1.12.2.5 bouyer break;
519 1.12.2.5 bouyer
520 1.12.2.5 bouyer case ADW_WARN_BUSRESET_ERROR:
521 1.12.2.5 bouyer printf("%s: WARNING: Bus Reset Error\n",
522 1.12.2.5 bouyer sc->sc_dev.dv_xname);
523 1.12.2.5 bouyer break;
524 1.1 dante }
525 1.1 dante
526 1.4 thorpej /*
527 1.12.2.1 thorpej * Fill in the scsipi_adapter.
528 1.4 thorpej */
529 1.12.2.1 thorpej memset(adapt, 0, sizeof(*adapt));
530 1.12.2.1 thorpej adapt->adapt_dev = &sc->sc_dev;
531 1.12.2.1 thorpej adapt->adapt_nchannels = 1;
532 1.12.2.5 bouyer adapt->adapt_openings = ncontrols;
533 1.12.2.5 bouyer adapt->adapt_max_periph = adapt->adapt_openings;
534 1.12.2.1 thorpej adapt->adapt_request = adw_scsipi_request;
535 1.12.2.1 thorpej adapt->adapt_minphys = adwminphys;
536 1.1 dante
537 1.1 dante /*
538 1.12.2.1 thorpej * Fill in the scsipi_channel.
539 1.12.2.1 thorpej */
540 1.12.2.1 thorpej memset(chan, 0, sizeof(*chan));
541 1.12.2.5 bouyer chan->chan_adapter = adapt;
542 1.12.2.1 thorpej chan->chan_bustype = &scsi_bustype;
543 1.12.2.1 thorpej chan->chan_channel = 0;
544 1.12.2.1 thorpej chan->chan_ntargets = ADW_MAX_TID + 1;
545 1.12.2.1 thorpej chan->chan_nluns = 7;
546 1.12.2.1 thorpej chan->chan_id = sc->chip_scsi_id;
547 1.1 dante
548 1.12.2.1 thorpej config_found(&sc->sc_dev, &sc->sc_channel, scsiprint);
549 1.1 dante }
550 1.1 dante
551 1.1 dante
552 1.1 dante static void
553 1.1 dante adwminphys(bp)
554 1.1 dante struct buf *bp;
555 1.1 dante {
556 1.1 dante
557 1.1 dante if (bp->b_bcount > ((ADW_MAX_SG_LIST - 1) * PAGE_SIZE))
558 1.1 dante bp->b_bcount = ((ADW_MAX_SG_LIST - 1) * PAGE_SIZE);
559 1.1 dante minphys(bp);
560 1.1 dante }
561 1.1 dante
562 1.1 dante
563 1.1 dante /*
564 1.2 dante * start a scsi operation given the command and the data address.
565 1.2 dante * Also needs the unit, target and lu.
566 1.1 dante */
567 1.12.2.1 thorpej static void
568 1.12.2.1 thorpej adw_scsipi_request(chan, req, arg)
569 1.12.2.5 bouyer struct scsipi_channel *chan;
570 1.12.2.1 thorpej scsipi_adapter_req_t req;
571 1.12.2.1 thorpej void *arg;
572 1.1 dante {
573 1.12.2.1 thorpej struct scsipi_xfer *xs;
574 1.12.2.1 thorpej ADW_SOFTC *sc = (void *)chan->chan_adapter->adapt_dev;
575 1.1 dante ADW_CCB *ccb;
576 1.12.2.5 bouyer int s, retry;
577 1.1 dante
578 1.12.2.1 thorpej switch (req) {
579 1.12.2.1 thorpej case ADAPTER_REQ_RUN_XFER:
580 1.12.2.1 thorpej xs = arg;
581 1.1 dante
582 1.1 dante /*
583 1.12.2.5 bouyer * get a ccb to use. If the transfer
584 1.12.2.5 bouyer * is from a buf (possibly from interrupt time)
585 1.12.2.5 bouyer * then we can't allow it to sleep
586 1.12.2.1 thorpej */
587 1.12.2.5 bouyer
588 1.12.2.2 thorpej ccb = adw_get_ccb(sc);
589 1.12.2.1 thorpej #ifdef DIAGNOSTIC
590 1.1 dante /*
591 1.12.2.5 bouyer * This should never happen as we track the resources
592 1.12.2.1 thorpej * in the mid-layer.
593 1.12.2.5 bouyer */
594 1.12.2.1 thorpej if (ccb == NULL) {
595 1.12.2.1 thorpej scsipi_printaddr(xs->xs_periph);
596 1.12.2.1 thorpej printf("unable to allocate ccb\n");
597 1.12.2.1 thorpej panic("adw_scsipi_request");
598 1.1 dante }
599 1.12.2.1 thorpej #endif
600 1.1 dante
601 1.12.2.1 thorpej ccb->xs = xs;
602 1.12.2.1 thorpej ccb->timeout = xs->timeout;
603 1.1 dante
604 1.12.2.1 thorpej if (adw_build_req(sc, ccb)) {
605 1.12.2.5 bouyer s = splbio();
606 1.12.2.5 bouyer retry = adw_queue_ccb(sc, ccb);
607 1.12.2.5 bouyer splx(s);
608 1.12.2.5 bouyer
609 1.12.2.5 bouyer switch(retry) {
610 1.12.2.5 bouyer case ADW_BUSY:
611 1.12.2.5 bouyer xs->error = XS_RESOURCE_SHORTAGE;
612 1.12.2.5 bouyer adw_free_ccb(sc, ccb);
613 1.12.2.5 bouyer scsipi_done(xs);
614 1.12.2.5 bouyer return;
615 1.1 dante
616 1.12.2.5 bouyer case ADW_ERROR:
617 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
618 1.12.2.5 bouyer adw_free_ccb(sc, ccb);
619 1.12.2.5 bouyer scsipi_done(xs);
620 1.12.2.5 bouyer return;
621 1.12.2.5 bouyer }
622 1.12.2.1 thorpej if ((xs->xs_control & XS_CTL_POLL) == 0)
623 1.12.2.1 thorpej return;
624 1.12.2.1 thorpej /*
625 1.12.2.1 thorpej * Not allowed to use interrupts, poll for completion.
626 1.12.2.1 thorpej */
627 1.12.2.1 thorpej if (adw_poll(sc, xs, ccb->timeout)) {
628 1.1 dante adw_timeout(ccb);
629 1.12.2.1 thorpej if (adw_poll(sc, xs, ccb->timeout))
630 1.12.2.1 thorpej adw_timeout(ccb);
631 1.12.2.1 thorpej }
632 1.1 dante }
633 1.12.2.1 thorpej return;
634 1.12.2.1 thorpej
635 1.12.2.1 thorpej case ADAPTER_REQ_GROW_RESOURCES:
636 1.12.2.1 thorpej /* XXX Not supported. */
637 1.12.2.1 thorpej return;
638 1.12.2.1 thorpej
639 1.12.2.1 thorpej case ADAPTER_REQ_SET_XFER_MODE:
640 1.12.2.5 bouyer /* XXX XXX XXX */
641 1.12.2.1 thorpej return;
642 1.1 dante }
643 1.1 dante }
644 1.1 dante
645 1.12.2.5 bouyer
646 1.1 dante /*
647 1.1 dante * Build a request structure for the Wide Boards.
648 1.1 dante */
649 1.1 dante static int
650 1.12.2.1 thorpej adw_build_req(sc, ccb)
651 1.12.2.5 bouyer ADW_SOFTC *sc;
652 1.12.2.5 bouyer ADW_CCB *ccb;
653 1.1 dante {
654 1.12.2.1 thorpej struct scsipi_xfer *xs = ccb->xs;
655 1.12.2.1 thorpej struct scsipi_periph *periph = xs->xs_periph;
656 1.2 dante bus_dma_tag_t dmat = sc->sc_dmat;
657 1.2 dante ADW_SCSI_REQ_Q *scsiqp;
658 1.2 dante int error;
659 1.1 dante
660 1.1 dante scsiqp = &ccb->scsiq;
661 1.1 dante bzero(scsiqp, sizeof(ADW_SCSI_REQ_Q));
662 1.1 dante
663 1.1 dante /*
664 1.7 dante * Set the ADW_SCSI_REQ_Q 'ccb_ptr' to point to the
665 1.7 dante * physical CCB structure.
666 1.1 dante */
667 1.10 thorpej scsiqp->ccb_ptr = ccb->hashkey;
668 1.1 dante
669 1.1 dante /*
670 1.1 dante * Build the ADW_SCSI_REQ_Q request.
671 1.1 dante */
672 1.1 dante
673 1.1 dante /*
674 1.1 dante * Set CDB length and copy it to the request structure.
675 1.12.2.5 bouyer * For wide boards a CDB length maximum of 16 bytes
676 1.12.2.5 bouyer * is supported.
677 1.1 dante */
678 1.12.2.5 bouyer bcopy(xs->cmd, &scsiqp->cdb, ((scsiqp->cdb_len = xs->cmdlen) <= 12)?
679 1.12.2.5 bouyer xs->cmdlen : 12 );
680 1.12.2.5 bouyer if(xs->cmdlen > 12)
681 1.12.2.5 bouyer bcopy(&(xs->cmd[12]), &scsiqp->cdb16, xs->cmdlen - 12);
682 1.1 dante
683 1.12.2.1 thorpej scsiqp->target_id = periph->periph_target;
684 1.12.2.1 thorpej scsiqp->target_lun = periph->periph_lun;
685 1.1 dante
686 1.7 dante scsiqp->vsense_addr = &ccb->scsi_sense;
687 1.12.2.5 bouyer scsiqp->sense_addr = sc->sc_dmamap_control->dm_segs[0].ds_addr +
688 1.12.2.5 bouyer ADW_CCB_OFF(ccb) + offsetof(struct adw_ccb, scsi_sense);
689 1.1 dante scsiqp->sense_len = sizeof(struct scsipi_sense_data);
690 1.1 dante
691 1.1 dante /*
692 1.1 dante * Build ADW_SCSI_REQ_Q for a scatter-gather buffer command.
693 1.1 dante */
694 1.1 dante if (xs->datalen) {
695 1.1 dante /*
696 1.1 dante * Map the DMA transfer.
697 1.1 dante */
698 1.1 dante #ifdef TFS
699 1.12 thorpej if (xs->xs_control & SCSI_DATA_UIO) {
700 1.1 dante error = bus_dmamap_load_uio(dmat,
701 1.12.2.5 bouyer ccb->dmamap_xfer, (struct uio *) xs->data,
702 1.12.2.5 bouyer BUS_DMA_NOWAIT);
703 1.1 dante } else
704 1.12.2.5 bouyer #endif /* TFS */
705 1.1 dante {
706 1.1 dante error = bus_dmamap_load(dmat,
707 1.12.2.5 bouyer ccb->dmamap_xfer, xs->data, xs->datalen, NULL,
708 1.12.2.5 bouyer BUS_DMA_NOWAIT);
709 1.1 dante }
710 1.1 dante
711 1.12.2.3 thorpej switch (error) {
712 1.12.2.3 thorpej case 0:
713 1.12.2.3 thorpej break;
714 1.12.2.3 thorpej case ENOMEM:
715 1.12.2.3 thorpej case EAGAIN:
716 1.12.2.3 thorpej xs->error = XS_RESOURCE_SHORTAGE;
717 1.12.2.5 bouyer goto out_bad;
718 1.12.2.3 thorpej
719 1.12.2.3 thorpej default:
720 1.12.2.1 thorpej xs->error = XS_DRIVER_STUFFUP;
721 1.12.2.3 thorpej printf("%s: error %d loading DMA map\n",
722 1.12.2.3 thorpej sc->sc_dev.dv_xname, error);
723 1.12.2.5 bouyer out_bad:
724 1.12.2.3 thorpej adw_free_ccb(sc, ccb);
725 1.12.2.1 thorpej scsipi_done(xs);
726 1.12.2.5 bouyer return(0);
727 1.1 dante }
728 1.12.2.5 bouyer
729 1.1 dante bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
730 1.12.2.1 thorpej ccb->dmamap_xfer->dm_mapsize,
731 1.12.2.1 thorpej (xs->xs_control & XS_CTL_DATA_IN) ?
732 1.12.2.1 thorpej BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
733 1.1 dante
734 1.1 dante /*
735 1.1 dante * Build scatter-gather list.
736 1.1 dante */
737 1.1 dante scsiqp->data_cnt = xs->datalen;
738 1.7 dante scsiqp->vdata_addr = xs->data;
739 1.1 dante scsiqp->data_addr = ccb->dmamap_xfer->dm_segs[0].ds_addr;
740 1.7 dante bzero(ccb->sg_block, sizeof(ADW_SG_BLOCK) * ADW_NUM_SG_BLOCK);
741 1.7 dante adw_build_sglist(ccb, scsiqp, ccb->sg_block);
742 1.1 dante } else {
743 1.1 dante /*
744 1.1 dante * No data xfer, use non S/G values.
745 1.1 dante */
746 1.1 dante scsiqp->data_cnt = 0;
747 1.1 dante scsiqp->vdata_addr = 0;
748 1.1 dante scsiqp->data_addr = 0;
749 1.1 dante }
750 1.1 dante
751 1.1 dante return (1);
752 1.1 dante }
753 1.1 dante
754 1.1 dante
755 1.1 dante /*
756 1.1 dante * Build scatter-gather list for Wide Boards.
757 1.1 dante */
758 1.1 dante static void
759 1.7 dante adw_build_sglist(ccb, scsiqp, sg_block)
760 1.2 dante ADW_CCB *ccb;
761 1.2 dante ADW_SCSI_REQ_Q *scsiqp;
762 1.7 dante ADW_SG_BLOCK *sg_block;
763 1.1 dante {
764 1.9 thorpej u_long sg_block_next_addr; /* block and its next */
765 1.9 thorpej u_int32_t sg_block_physical_addr;
766 1.12.2.5 bouyer int i; /* how many SG entries */
767 1.1 dante bus_dma_segment_t *sg_list = &ccb->dmamap_xfer->dm_segs[0];
768 1.2 dante int sg_elem_cnt = ccb->dmamap_xfer->dm_nsegs;
769 1.1 dante
770 1.1 dante
771 1.9 thorpej sg_block_next_addr = (u_long) sg_block; /* allow math operation */
772 1.10 thorpej sg_block_physical_addr = ccb->hashkey +
773 1.10 thorpej offsetof(struct adw_ccb, sg_block[0]);
774 1.1 dante scsiqp->sg_real_addr = sg_block_physical_addr;
775 1.1 dante
776 1.1 dante /*
777 1.1 dante * If there are more than NO_OF_SG_PER_BLOCK dma segments (hw sg-list)
778 1.1 dante * then split the request into multiple sg-list blocks.
779 1.1 dante */
780 1.1 dante
781 1.2 dante do {
782 1.2 dante for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
783 1.1 dante sg_block->sg_list[i].sg_addr = sg_list->ds_addr;
784 1.1 dante sg_block->sg_list[i].sg_count = sg_list->ds_len;
785 1.1 dante
786 1.2 dante if (--sg_elem_cnt == 0) {
787 1.1 dante /* last entry, get out */
788 1.12.2.5 bouyer sg_block->sg_cnt = i + i;
789 1.2 dante sg_block->sg_ptr = NULL; /* next link = NULL */
790 1.1 dante return;
791 1.1 dante }
792 1.1 dante sg_list++;
793 1.1 dante }
794 1.1 dante sg_block_next_addr += sizeof(ADW_SG_BLOCK);
795 1.1 dante sg_block_physical_addr += sizeof(ADW_SG_BLOCK);
796 1.1 dante
797 1.12.2.5 bouyer sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
798 1.9 thorpej sg_block->sg_ptr = sg_block_physical_addr;
799 1.2 dante sg_block = (ADW_SG_BLOCK *) sg_block_next_addr; /* virt. addr */
800 1.10 thorpej } while (1);
801 1.1 dante }
802 1.1 dante
803 1.1 dante
804 1.12.2.5 bouyer /******************************************************************************/
805 1.12.2.5 bouyer /* Interrupts and TimeOut routines */
806 1.12.2.5 bouyer /******************************************************************************/
807 1.12.2.5 bouyer
808 1.12.2.5 bouyer
809 1.1 dante int
810 1.1 dante adw_intr(arg)
811 1.1 dante void *arg;
812 1.1 dante {
813 1.1 dante ADW_SOFTC *sc = arg;
814 1.1 dante
815 1.12.2.5 bouyer
816 1.12.2.5 bouyer if(AdwISR(sc) != ADW_FALSE) {
817 1.12.2.5 bouyer return (1);
818 1.12.2.5 bouyer }
819 1.12.2.5 bouyer
820 1.12.2.5 bouyer return (0);
821 1.1 dante }
822 1.1 dante
823 1.1 dante
824 1.1 dante /*
825 1.1 dante * Poll a particular unit, looking for a particular xs
826 1.1 dante */
827 1.1 dante static int
828 1.1 dante adw_poll(sc, xs, count)
829 1.1 dante ADW_SOFTC *sc;
830 1.1 dante struct scsipi_xfer *xs;
831 1.1 dante int count;
832 1.1 dante {
833 1.1 dante
834 1.1 dante /* timeouts are in msec, so we loop in 1000 usec cycles */
835 1.1 dante while (count) {
836 1.1 dante adw_intr(sc);
837 1.12 thorpej if (xs->xs_status & XS_STS_DONE)
838 1.1 dante return (0);
839 1.1 dante delay(1000); /* only happens in boot so ok */
840 1.1 dante count--;
841 1.1 dante }
842 1.1 dante return (1);
843 1.1 dante }
844 1.1 dante
845 1.1 dante
846 1.1 dante static void
847 1.1 dante adw_timeout(arg)
848 1.1 dante void *arg;
849 1.1 dante {
850 1.1 dante ADW_CCB *ccb = arg;
851 1.1 dante struct scsipi_xfer *xs = ccb->xs;
852 1.12.2.1 thorpej struct scsipi_periph *periph = xs->xs_periph;
853 1.12.2.1 thorpej ADW_SOFTC *sc =
854 1.12.2.1 thorpej (void *)periph->periph_channel->chan_adapter->adapt_dev;
855 1.1 dante int s;
856 1.1 dante
857 1.12.2.1 thorpej scsipi_printaddr(periph);
858 1.1 dante printf("timed out");
859 1.1 dante
860 1.1 dante s = splbio();
861 1.1 dante
862 1.11 dante if (ccb->flags & CCB_ABORTED) {
863 1.11 dante /*
864 1.11 dante * Abort Timed Out
865 1.12.2.5 bouyer *
866 1.12.2.5 bouyer * No more opportunities. Lets try resetting the bus and
867 1.12.2.5 bouyer * reinitialize the host adapter.
868 1.11 dante */
869 1.12.2.5 bouyer callout_stop(&xs->xs_callout);
870 1.11 dante printf(" AGAIN. Resetting SCSI Bus\n");
871 1.12.2.5 bouyer adw_reset_bus(sc);
872 1.12.2.5 bouyer splx(s);
873 1.12.2.5 bouyer return;
874 1.12.2.5 bouyer } else if (ccb->flags & CCB_ABORTING) {
875 1.12.2.5 bouyer /*
876 1.12.2.5 bouyer * Abort the operation that has timed out.
877 1.12.2.5 bouyer *
878 1.12.2.5 bouyer * Second opportunity.
879 1.12.2.5 bouyer */
880 1.12.2.5 bouyer printf("\n");
881 1.12.2.5 bouyer xs->error = XS_TIMEOUT;
882 1.12.2.5 bouyer ccb->flags |= CCB_ABORTED;
883 1.12.2.5 bouyer #if 0
884 1.12.2.5 bouyer /*
885 1.12.2.5 bouyer * - XXX - 3.3a microcode is BROKEN!!!
886 1.12.2.5 bouyer *
887 1.12.2.5 bouyer * We cannot abort a CCB, so we can only hope the command
888 1.12.2.5 bouyer * get completed before the next timeout, otherwise a
889 1.12.2.5 bouyer * Bus Reset will arrive inexorably.
890 1.12.2.5 bouyer */
891 1.12.2.5 bouyer /*
892 1.12.2.5 bouyer * ADW_ABORT_CCB() makes the board to generate an interrupt
893 1.12.2.5 bouyer *
894 1.12.2.5 bouyer * - XXX - The above assertion MUST be verified (and this
895 1.12.2.5 bouyer * code changed as well [callout_*()]), when the
896 1.12.2.5 bouyer * ADW_ABORT_CCB will be working again
897 1.12.2.5 bouyer */
898 1.12.2.5 bouyer ADW_ABORT_CCB(sc, ccb);
899 1.12.2.5 bouyer #endif
900 1.12.2.5 bouyer /*
901 1.12.2.5 bouyer * waiting for multishot callout_reset() let's restart it
902 1.12.2.5 bouyer * by hand so the next time a timeout event will occour
903 1.12.2.5 bouyer * we will reset the bus.
904 1.12.2.5 bouyer */
905 1.12.2.5 bouyer callout_reset(&xs->xs_callout,
906 1.12.2.5 bouyer (ccb->timeout * hz) / 1000, adw_timeout, ccb);
907 1.1 dante } else {
908 1.11 dante /*
909 1.12.2.5 bouyer * Abort the operation that has timed out.
910 1.12.2.5 bouyer *
911 1.12.2.5 bouyer * First opportunity.
912 1.11 dante */
913 1.1 dante printf("\n");
914 1.11 dante xs->error = XS_TIMEOUT;
915 1.11 dante ccb->flags |= CCB_ABORTING;
916 1.12.2.5 bouyer #if 0
917 1.12.2.5 bouyer /*
918 1.12.2.5 bouyer * - XXX - 3.3a microcode is BROKEN!!!
919 1.12.2.5 bouyer *
920 1.12.2.5 bouyer * We cannot abort a CCB, so we can only hope the command
921 1.12.2.5 bouyer * get completed before the next 2 timeout, otherwise a
922 1.12.2.5 bouyer * Bus Reset will arrive inexorably.
923 1.12.2.5 bouyer */
924 1.12.2.5 bouyer /*
925 1.12.2.5 bouyer * ADW_ABORT_CCB() makes the board to generate an interrupt
926 1.12.2.5 bouyer *
927 1.12.2.5 bouyer * - XXX - The above assertion MUST be verified (and this
928 1.12.2.5 bouyer * code changed as well [callout_*()]), when the
929 1.12.2.5 bouyer * ADW_ABORT_CCB will be working again
930 1.12.2.5 bouyer */
931 1.1 dante ADW_ABORT_CCB(sc, ccb);
932 1.12.2.5 bouyer #endif
933 1.12.2.5 bouyer /*
934 1.12.2.5 bouyer * waiting for multishot callout_reset() let's restart it
935 1.12.2.5 bouyer * by hand so to give a second opportunity to the command
936 1.12.2.5 bouyer * which timed-out.
937 1.12.2.5 bouyer */
938 1.12.2.5 bouyer callout_reset(&xs->xs_callout,
939 1.12.2.5 bouyer (ccb->timeout * hz) / 1000, adw_timeout, ccb);
940 1.1 dante }
941 1.1 dante
942 1.1 dante splx(s);
943 1.1 dante }
944 1.1 dante
945 1.1 dante
946 1.12.2.5 bouyer static void
947 1.12.2.5 bouyer adw_reset_bus(sc)
948 1.12.2.5 bouyer ADW_SOFTC *sc;
949 1.12.2.5 bouyer {
950 1.12.2.5 bouyer ADW_CCB *ccb;
951 1.12.2.5 bouyer int s;
952 1.12.2.5 bouyer struct scsipi_xfer *xs;
953 1.12.2.5 bouyer
954 1.12.2.5 bouyer s = splbio();
955 1.12.2.5 bouyer AdwResetSCSIBus(sc);
956 1.12.2.5 bouyer while((ccb = TAILQ_LAST(&sc->sc_pending_ccb,
957 1.12.2.5 bouyer adw_pending_ccb)) != NULL) {
958 1.12.2.5 bouyer callout_stop(&ccb->xs->xs_callout);
959 1.12.2.5 bouyer TAILQ_REMOVE(&sc->sc_pending_ccb, ccb, chain);
960 1.12.2.5 bouyer xs = ccb->xs;
961 1.12.2.5 bouyer adw_free_ccb(sc, ccb);
962 1.12.2.5 bouyer xs->error = XS_RESOURCE_SHORTAGE;
963 1.12.2.5 bouyer scsipi_done(xs);
964 1.12.2.5 bouyer }
965 1.12.2.5 bouyer splx(s);
966 1.12.2.5 bouyer }
967 1.12.2.5 bouyer
968 1.12.2.5 bouyer
969 1.1 dante /******************************************************************************/
970 1.12.2.5 bouyer /* Host Adapter and Peripherals Information Routines */
971 1.12.2.5 bouyer /******************************************************************************/
972 1.12.2.5 bouyer
973 1.12.2.5 bouyer
974 1.12.2.5 bouyer static void
975 1.12.2.5 bouyer adw_print_info(sc, tid)
976 1.12.2.5 bouyer ADW_SOFTC *sc;
977 1.12.2.5 bouyer int tid;
978 1.12.2.5 bouyer {
979 1.12.2.5 bouyer bus_space_tag_t iot = sc->sc_iot;
980 1.12.2.5 bouyer bus_space_handle_t ioh = sc->sc_ioh;
981 1.12.2.5 bouyer u_int16_t wdtr_able, wdtr_done, wdtr;
982 1.12.2.5 bouyer u_int16_t sdtr_able, sdtr_done, sdtr, period;
983 1.12.2.5 bouyer static int wdtr_reneg = 0, sdtr_reneg = 0;
984 1.12.2.5 bouyer
985 1.12.2.5 bouyer if (tid == 0){
986 1.12.2.5 bouyer wdtr_reneg = sdtr_reneg = 0;
987 1.12.2.5 bouyer }
988 1.12.2.5 bouyer
989 1.12.2.5 bouyer printf("%s: target %d ", sc->sc_dev.dv_xname, tid);
990 1.12.2.5 bouyer
991 1.12.2.5 bouyer ADW_READ_WORD_LRAM(iot, ioh, ADW_MC_SDTR_ABLE, wdtr_able);
992 1.12.2.5 bouyer if(wdtr_able & ADW_TID_TO_TIDMASK(tid)) {
993 1.12.2.5 bouyer ADW_READ_WORD_LRAM(iot, ioh, ADW_MC_SDTR_DONE, wdtr_done);
994 1.12.2.5 bouyer ADW_READ_WORD_LRAM(iot, ioh, ADW_MC_DEVICE_HSHK_CFG_TABLE +
995 1.12.2.5 bouyer (2 * tid), wdtr);
996 1.12.2.5 bouyer printf("using %d-bits wide, ", (wdtr & 0x8000)? 16 : 8);
997 1.12.2.5 bouyer if((wdtr_done & ADW_TID_TO_TIDMASK(tid)) == 0)
998 1.12.2.5 bouyer wdtr_reneg = 1;
999 1.12.2.5 bouyer } else {
1000 1.12.2.5 bouyer printf("wide transfers disabled, ");
1001 1.12.2.5 bouyer }
1002 1.12.2.5 bouyer
1003 1.12.2.5 bouyer ADW_READ_WORD_LRAM(iot, ioh, ADW_MC_SDTR_ABLE, sdtr_able);
1004 1.12.2.5 bouyer if(sdtr_able & ADW_TID_TO_TIDMASK(tid)) {
1005 1.12.2.5 bouyer ADW_READ_WORD_LRAM(iot, ioh, ADW_MC_SDTR_DONE, sdtr_done);
1006 1.12.2.5 bouyer ADW_READ_WORD_LRAM(iot, ioh, ADW_MC_DEVICE_HSHK_CFG_TABLE +
1007 1.12.2.5 bouyer (2 * tid), sdtr);
1008 1.12.2.5 bouyer sdtr &= ~0x8000;
1009 1.12.2.5 bouyer if((sdtr & 0x1F) != 0) {
1010 1.12.2.5 bouyer if((sdtr & 0x1F00) == 0x1100){
1011 1.12.2.5 bouyer printf("80.0 MHz");
1012 1.12.2.5 bouyer } else if((sdtr & 0x1F00) == 0x1000){
1013 1.12.2.5 bouyer printf("40.0 MHz");
1014 1.12.2.5 bouyer } else {
1015 1.12.2.5 bouyer /* <= 20.0 MHz */
1016 1.12.2.5 bouyer period = (((sdtr >> 8) * 25) + 50)/4;
1017 1.12.2.5 bouyer if(period == 0) {
1018 1.12.2.5 bouyer /* Should never happen. */
1019 1.12.2.5 bouyer printf("? MHz");
1020 1.12.2.5 bouyer } else {
1021 1.12.2.5 bouyer printf("%d.%d MHz", 250/period,
1022 1.12.2.5 bouyer ADW_TENTHS(250, period));
1023 1.12.2.5 bouyer }
1024 1.12.2.5 bouyer }
1025 1.12.2.5 bouyer printf(" synchronous transfers\n");
1026 1.12.2.5 bouyer } else {
1027 1.12.2.5 bouyer printf("asynchronous transfers\n");
1028 1.12.2.5 bouyer }
1029 1.12.2.5 bouyer if((sdtr_done & ADW_TID_TO_TIDMASK(tid)) == 0)
1030 1.12.2.5 bouyer sdtr_reneg = 1;
1031 1.12.2.5 bouyer } else {
1032 1.12.2.5 bouyer printf("synchronous transfers disabled\n");
1033 1.12.2.5 bouyer }
1034 1.12.2.5 bouyer
1035 1.12.2.5 bouyer if(wdtr_reneg || sdtr_reneg) {
1036 1.12.2.5 bouyer printf("%s: target %d %s", sc->sc_dev.dv_xname, tid,
1037 1.12.2.5 bouyer (wdtr_reneg)? ((sdtr_reneg)? "wide/sync" : "wide") :
1038 1.12.2.5 bouyer ((sdtr_reneg)? "sync" : "") );
1039 1.12.2.5 bouyer printf(" renegotiation pending before next command.\n");
1040 1.12.2.5 bouyer }
1041 1.12.2.5 bouyer }
1042 1.12.2.5 bouyer
1043 1.12.2.5 bouyer
1044 1.12.2.5 bouyer /******************************************************************************/
1045 1.12.2.5 bouyer /* WIDE boards Interrupt callbacks */
1046 1.1 dante /******************************************************************************/
1047 1.1 dante
1048 1.1 dante
1049 1.1 dante /*
1050 1.12.2.5 bouyer * adw_isr_callback() - Second Level Interrupt Handler called by AdwISR()
1051 1.1 dante *
1052 1.1 dante * Interrupt callback function for the Wide SCSI Adv Library.
1053 1.12.2.5 bouyer *
1054 1.12.2.5 bouyer * Notice:
1055 1.12.2.5 bouyer * Interrupts are disabled by the caller (AdwISR() function), and will be
1056 1.12.2.5 bouyer * enabled at the end of the caller.
1057 1.1 dante */
1058 1.1 dante static void
1059 1.12.2.5 bouyer adw_isr_callback(sc, scsiq)
1060 1.1 dante ADW_SOFTC *sc;
1061 1.1 dante ADW_SCSI_REQ_Q *scsiq;
1062 1.1 dante {
1063 1.2 dante bus_dma_tag_t dmat = sc->sc_dmat;
1064 1.7 dante ADW_CCB *ccb;
1065 1.7 dante struct scsipi_xfer *xs;
1066 1.1 dante struct scsipi_sense_data *s1, *s2;
1067 1.1 dante
1068 1.7 dante
1069 1.7 dante ccb = adw_ccb_phys_kv(sc, scsiq->ccb_ptr);
1070 1.11 dante
1071 1.12.2.5 bouyer callout_stop(&ccb->xs->xs_callout);
1072 1.11 dante
1073 1.7 dante xs = ccb->xs;
1074 1.1 dante
1075 1.1 dante /*
1076 1.1 dante * If we were a data transfer, unload the map that described
1077 1.1 dante * the data buffer.
1078 1.1 dante */
1079 1.1 dante if (xs->datalen) {
1080 1.1 dante bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
1081 1.1 dante ccb->dmamap_xfer->dm_mapsize,
1082 1.12 thorpej (xs->xs_control & XS_CTL_DATA_IN) ?
1083 1.12 thorpej BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
1084 1.1 dante bus_dmamap_unload(dmat, ccb->dmamap_xfer);
1085 1.1 dante }
1086 1.12.2.5 bouyer
1087 1.1 dante if ((ccb->flags & CCB_ALLOC) == 0) {
1088 1.1 dante printf("%s: exiting ccb not allocated!\n", sc->sc_dev.dv_xname);
1089 1.1 dante Debugger();
1090 1.1 dante return;
1091 1.1 dante }
1092 1.12.2.5 bouyer
1093 1.1 dante /*
1094 1.1 dante * 'done_status' contains the command's ending status.
1095 1.12.2.5 bouyer * 'host_status' conatins the host adapter status.
1096 1.12.2.5 bouyer * 'scsi_status' contains the scsi peripheral status.
1097 1.1 dante */
1098 1.12.2.5 bouyer if ((scsiq->host_status == QHSTA_NO_ERROR) &&
1099 1.12.2.5 bouyer ((scsiq->done_status == QD_NO_ERROR) ||
1100 1.12.2.5 bouyer (scsiq->done_status == QD_WITH_ERROR))) {
1101 1.1 dante switch (scsiq->host_status) {
1102 1.12.2.5 bouyer case SCSI_STATUS_GOOD:
1103 1.12.2.5 bouyer if ((scsiq->cdb[0] == INQUIRY) &&
1104 1.12.2.5 bouyer (scsiq->target_lun == 0)) {
1105 1.12.2.5 bouyer adw_print_info(sc, scsiq->target_id);
1106 1.12.2.5 bouyer }
1107 1.1 dante xs->error = XS_NOERROR;
1108 1.12.2.5 bouyer xs->resid = scsiq->data_cnt;
1109 1.12.2.5 bouyer sc->sc_freeze_dev[scsiq->target_id] = 0;
1110 1.1 dante break;
1111 1.12.2.5 bouyer
1112 1.12.2.5 bouyer case SCSI_STATUS_CHECK_CONDITION:
1113 1.12.2.5 bouyer case SCSI_STATUS_CMD_TERMINATED:
1114 1.12.2.5 bouyer s1 = &ccb->scsi_sense;
1115 1.12.2.5 bouyer s2 = &xs->sense.scsi_sense;
1116 1.12.2.5 bouyer *s2 = *s1;
1117 1.12.2.5 bouyer xs->error = XS_SENSE;
1118 1.12.2.5 bouyer sc->sc_freeze_dev[scsiq->target_id] = 1;
1119 1.12.2.5 bouyer break;
1120 1.12.2.5 bouyer
1121 1.1 dante default:
1122 1.12.2.5 bouyer xs->error = XS_BUSY;
1123 1.12.2.5 bouyer sc->sc_freeze_dev[scsiq->target_id] = 1;
1124 1.1 dante break;
1125 1.1 dante }
1126 1.12.2.5 bouyer } else if (scsiq->done_status == QD_ABORTED_BY_HOST) {
1127 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1128 1.12.2.5 bouyer } else {
1129 1.1 dante switch (scsiq->host_status) {
1130 1.12.2.5 bouyer case QHSTA_M_SEL_TIMEOUT:
1131 1.12.2.5 bouyer xs->error = XS_SELTIMEOUT;
1132 1.1 dante break;
1133 1.1 dante
1134 1.12.2.5 bouyer case QHSTA_M_SXFR_OFF_UFLW:
1135 1.12.2.5 bouyer case QHSTA_M_SXFR_OFF_OFLW:
1136 1.12.2.5 bouyer case QHSTA_M_DATA_OVER_RUN:
1137 1.12.2.5 bouyer printf("%s: Overrun/Overflow/Underflow condition\n",
1138 1.12.2.5 bouyer sc->sc_dev.dv_xname);
1139 1.11 dante xs->error = XS_DRIVER_STUFFUP;
1140 1.11 dante break;
1141 1.11 dante
1142 1.12.2.5 bouyer case QHSTA_M_SXFR_DESELECTED:
1143 1.12.2.5 bouyer case QHSTA_M_UNEXPECTED_BUS_FREE:
1144 1.12.2.5 bouyer printf("%s: Unexpected BUS free\n",sc->sc_dev.dv_xname);
1145 1.1 dante xs->error = XS_DRIVER_STUFFUP;
1146 1.1 dante break;
1147 1.1 dante
1148 1.12.2.5 bouyer case QHSTA_M_SCSI_BUS_RESET:
1149 1.12.2.5 bouyer case QHSTA_M_SCSI_BUS_RESET_UNSOL:
1150 1.12.2.5 bouyer printf("%s: BUS Reset\n", sc->sc_dev.dv_xname);
1151 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1152 1.12.2.5 bouyer break;
1153 1.11 dante
1154 1.12.2.5 bouyer case QHSTA_M_BUS_DEVICE_RESET:
1155 1.12.2.5 bouyer printf("%s: Device Reset\n", sc->sc_dev.dv_xname);
1156 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1157 1.12.2.5 bouyer break;
1158 1.12.2.5 bouyer
1159 1.12.2.5 bouyer case QHSTA_M_QUEUE_ABORTED:
1160 1.12.2.5 bouyer printf("%s: Queue Aborted\n", sc->sc_dev.dv_xname);
1161 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1162 1.12.2.5 bouyer break;
1163 1.12.2.5 bouyer
1164 1.12.2.5 bouyer case QHSTA_M_SXFR_SDMA_ERR:
1165 1.12.2.5 bouyer case QHSTA_M_SXFR_SXFR_PERR:
1166 1.12.2.5 bouyer case QHSTA_M_RDMA_PERR:
1167 1.12.2.5 bouyer /*
1168 1.12.2.5 bouyer * DMA Error. This should *NEVER* happen!
1169 1.12.2.5 bouyer *
1170 1.12.2.5 bouyer * Lets try resetting the bus and reinitialize
1171 1.12.2.5 bouyer * the host adapter.
1172 1.12.2.5 bouyer */
1173 1.12.2.5 bouyer printf("%s: DMA Error. Reseting bus\n",
1174 1.12.2.5 bouyer sc->sc_dev.dv_xname);
1175 1.12.2.5 bouyer TAILQ_REMOVE(&sc->sc_pending_ccb, ccb, chain);
1176 1.12.2.5 bouyer adw_reset_bus(sc);
1177 1.12.2.5 bouyer xs->error = XS_BUSY;
1178 1.12.2.5 bouyer goto done;
1179 1.12.2.5 bouyer
1180 1.12.2.5 bouyer case QHSTA_M_WTM_TIMEOUT:
1181 1.12.2.5 bouyer case QHSTA_M_SXFR_WD_TMO:
1182 1.12.2.5 bouyer /* The SCSI bus hung in a phase */
1183 1.12.2.5 bouyer printf("%s: Watch Dog timer expired. Reseting bus\n",
1184 1.12.2.5 bouyer sc->sc_dev.dv_xname);
1185 1.12.2.5 bouyer TAILQ_REMOVE(&sc->sc_pending_ccb, ccb, chain);
1186 1.12.2.5 bouyer adw_reset_bus(sc);
1187 1.12.2.5 bouyer xs->error = XS_BUSY;
1188 1.12.2.5 bouyer goto done;
1189 1.12.2.5 bouyer
1190 1.12.2.5 bouyer case QHSTA_M_SXFR_XFR_PH_ERR:
1191 1.12.2.5 bouyer printf("%s: Transfer Error\n", sc->sc_dev.dv_xname);
1192 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1193 1.12.2.5 bouyer break;
1194 1.12.2.5 bouyer
1195 1.12.2.5 bouyer case QHSTA_M_BAD_CMPL_STATUS_IN:
1196 1.12.2.5 bouyer /* No command complete after a status message */
1197 1.12.2.5 bouyer printf("%s: Bad Completion Status\n",
1198 1.12.2.5 bouyer sc->sc_dev.dv_xname);
1199 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1200 1.12.2.5 bouyer break;
1201 1.12.2.5 bouyer
1202 1.12.2.5 bouyer case QHSTA_M_AUTO_REQ_SENSE_FAIL:
1203 1.12.2.5 bouyer printf("%s: Auto Sense Failed\n", sc->sc_dev.dv_xname);
1204 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1205 1.12.2.5 bouyer break;
1206 1.12.2.5 bouyer
1207 1.12.2.5 bouyer case QHSTA_M_INVALID_DEVICE:
1208 1.12.2.5 bouyer printf("%s: Invalid Device\n", sc->sc_dev.dv_xname);
1209 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1210 1.12.2.5 bouyer break;
1211 1.12.2.5 bouyer
1212 1.12.2.5 bouyer case QHSTA_M_NO_AUTO_REQ_SENSE:
1213 1.12.2.5 bouyer /*
1214 1.12.2.5 bouyer * User didn't request sense, but we got a
1215 1.12.2.5 bouyer * check condition.
1216 1.12.2.5 bouyer */
1217 1.12.2.5 bouyer printf("%s: Unexpected Check Condition\n",
1218 1.12.2.5 bouyer sc->sc_dev.dv_xname);
1219 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1220 1.12.2.5 bouyer break;
1221 1.12.2.5 bouyer
1222 1.12.2.5 bouyer case QHSTA_M_SXFR_UNKNOWN_ERROR:
1223 1.12.2.5 bouyer printf("%s: Unknown Error\n", sc->sc_dev.dv_xname);
1224 1.12.2.5 bouyer xs->error = XS_DRIVER_STUFFUP;
1225 1.12.2.5 bouyer break;
1226 1.12.2.5 bouyer
1227 1.12.2.5 bouyer default:
1228 1.12.2.5 bouyer panic("%s: Unhandled Host Status Error %x",
1229 1.12.2.5 bouyer sc->sc_dev.dv_xname, scsiq->host_status);
1230 1.12.2.5 bouyer }
1231 1.1 dante }
1232 1.1 dante
1233 1.12.2.5 bouyer TAILQ_REMOVE(&sc->sc_pending_ccb, ccb, chain);
1234 1.12.2.5 bouyer done: adw_free_ccb(sc, ccb);
1235 1.1 dante scsipi_done(xs);
1236 1.11 dante }
1237 1.11 dante
1238 1.11 dante
1239 1.12.2.5 bouyer /*
1240 1.12.2.5 bouyer * adw_async_callback() - Adv Library asynchronous event callback function.
1241 1.12.2.5 bouyer */
1242 1.11 dante static void
1243 1.12.2.5 bouyer adw_async_callback(sc, code)
1244 1.11 dante ADW_SOFTC *sc;
1245 1.12.2.5 bouyer u_int8_t code;
1246 1.11 dante {
1247 1.12.2.5 bouyer switch (code) {
1248 1.12.2.5 bouyer case ADV_ASYNC_SCSI_BUS_RESET_DET:
1249 1.12.2.5 bouyer /* The firmware detected a SCSI Bus reset. */
1250 1.12.2.5 bouyer printf("%s: SCSI Bus reset detected\n", sc->sc_dev.dv_xname);
1251 1.12.2.5 bouyer break;
1252 1.12.2.5 bouyer
1253 1.12.2.5 bouyer case ADV_ASYNC_RDMA_FAILURE:
1254 1.12.2.5 bouyer /*
1255 1.12.2.5 bouyer * Handle RDMA failure by resetting the SCSI Bus and
1256 1.12.2.5 bouyer * possibly the chip if it is unresponsive.
1257 1.12.2.5 bouyer */
1258 1.12.2.5 bouyer printf("%s: RDMA failure. Resetting the SCSI Bus and"
1259 1.12.2.5 bouyer " the adapter\n", sc->sc_dev.dv_xname);
1260 1.12.2.5 bouyer AdwResetSCSIBus(sc);
1261 1.12.2.5 bouyer break;
1262 1.12.2.5 bouyer
1263 1.12.2.5 bouyer case ADV_HOST_SCSI_BUS_RESET:
1264 1.12.2.5 bouyer /* Host generated SCSI bus reset occurred. */
1265 1.12.2.5 bouyer printf("%s: Host generated SCSI bus reset occurred\n",
1266 1.12.2.5 bouyer sc->sc_dev.dv_xname);
1267 1.12.2.5 bouyer break;
1268 1.12.2.5 bouyer
1269 1.12.2.5 bouyer case ADV_ASYNC_CARRIER_READY_FAILURE:
1270 1.12.2.5 bouyer /* Carrier Ready failure. */
1271 1.12.2.5 bouyer printf("%s: Carrier Ready failure!\n", sc->sc_dev.dv_xname);
1272 1.12.2.5 bouyer break;
1273 1.12.2.5 bouyer
1274 1.12.2.5 bouyer default:
1275 1.12.2.5 bouyer break;
1276 1.12.2.5 bouyer }
1277 1.1 dante }
1278