timeout/untimeout ==> callout_*
[dragonfly.git] / sys / dev / raid / aac / aacvar.h
1 /*-
2  * Copyright (c) 2000 Michael Smith
3  * Copyright (c) 2001 Scott Long
4  * Copyright (c) 2000 BSDi
5  * Copyright (c) 2001 Adaptec, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *      $FreeBSD: src/sys/dev/aac/aacvar.h,v 1.4.2.7 2003/04/08 13:22:08 scottl Exp $
30  *      $DragonFly: src/sys/dev/raid/aac/aacvar.h,v 1.7 2004/09/15 16:23:51 joerg Exp $
31  */
32
33 /*
34  * Driver Parameter Definitions
35  */
36
37 /*
38  * The firmware interface allows for a 16-bit s/g list length.  We limit 
39  * ourselves to a reasonable maximum and ensure alignment.
40  */
41 #define AAC_MAXSGENTRIES        64      /* max S/G entries, limit 65535 */              
42
43 /*
44  * We allocate a small set of FIBs for the adapter to use to send us messages.
45  */
46 #define AAC_ADAPTER_FIBS        8
47
48 /*
49  * FIBs are allocated up-front, and the pool isn't grown.  We should allocate
50  * enough here to let us keep the adapter busy without wasting large amounts
51  * of kernel memory.  The current interface implementation limits us to 512
52  * FIBs queued for the adapter at any one time.
53  */
54 #define AAC_FIB_COUNT           128
55
56 /*
57  * The controller reports status events in AIFs.  We hang on to a number of
58  * these in order to pass them out to user-space management tools.
59  */
60 #define AAC_AIFQ_LENGTH         64
61
62 /*
63  * Firmware messages are passed in the printf buffer.
64  */
65 #define AAC_PRINTF_BUFSIZE      256
66
67 /*
68  * We wait this many seconds for the adapter to come ready if it is still 
69  * booting
70  */
71 #define AAC_BOOT_TIMEOUT        (3 * 60)
72
73 /*
74  * Timeout for immediate commands.
75  */
76 #define AAC_IMMEDIATE_TIMEOUT   30              /* seconds */
77
78 /*
79  * Timeout for normal commands
80  */
81 #define AAC_CMD_TIMEOUT         30              /* seconds */
82
83 /*
84  * Rate at which we periodically check for timed out commands and kick the
85  * controller.
86  */
87 #define AAC_PERIODIC_INTERVAL   20              /* seconds */
88
89 /*
90  * Character device major numbers.
91  */
92 #define AAC_DISK_MAJOR  200
93
94 /*
95  * Driver Variable Definitions
96  */
97
98 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
99 # include <sys/taskqueue.h>
100 #endif
101
102 /*
103  * Per-container data structure
104  */
105 struct aac_container
106 {
107         struct aac_mntobj               co_mntobj;
108         device_t                        co_disk;
109         int                             co_found;
110         TAILQ_ENTRY(aac_container)      co_link;
111 };
112
113 /*
114  * Per-disk structure
115  */
116 struct aac_disk 
117 {
118         device_t                        ad_dev;
119         dev_t                           ad_dev_t;
120         struct aac_softc                *ad_controller;
121         struct aac_container            *ad_container;
122         struct disk                     ad_disk;
123         struct devstat                  ad_stats;
124         struct disklabel                ad_label;
125         int                             ad_flags;
126 #define AAC_DISK_OPEN   (1<<0)
127         int                             ad_cylinders;
128         int                             ad_heads;
129         int                             ad_sectors;
130         u_int32_t                       ad_size;
131         int                             unit;
132 };
133
134 /*
135  * Per-command control structure.
136  */
137 struct aac_command
138 {
139         TAILQ_ENTRY(aac_command) cm_link;       /* list linkage */
140
141         struct aac_softc        *cm_sc;         /* controller that owns us */
142
143         struct aac_fib          *cm_fib;        /* FIB associated with this
144                                                  * command */
145         u_int32_t               cm_fibphys;     /* bus address of the FIB */
146         struct bio              *cm_data;       /* pointer to data in kernel
147                                                  * space */
148         u_int32_t               cm_datalen;     /* data length */
149         bus_dmamap_t            cm_datamap;     /* DMA map for bio data */
150         struct aac_sg_table     *cm_sgtable;    /* pointer to s/g table in
151                                                  * command */
152         int                     cm_flags;
153 #define AAC_CMD_MAPPED          (1<<0)          /* command has had its data
154                                                  * mapped */
155 #define AAC_CMD_DATAIN          (1<<1)          /* command involves data moving
156                                                  * from controller to host */
157 #define AAC_CMD_DATAOUT         (1<<2)          /* command involves data moving
158                                                  * from host to controller */
159 #define AAC_CMD_COMPLETED       (1<<3)          /* command has been completed */
160 #define AAC_CMD_TIMEDOUT        (1<<4)          /* command taken too long */
161 #define AAC_ON_AACQ_FREE        (1<<5)
162 #define AAC_ON_AACQ_READY       (1<<6)
163 #define AAC_ON_AACQ_BUSY        (1<<7)
164 #define AAC_ON_AACQ_COMPLETE    (1<<8)
165 #define AAC_ON_AACQ_MASK        ((1<<5)|(1<<6)|(1<<7)|(1<<8))
166
167         void                    (* cm_complete)(struct aac_command *cm);
168         void                    *cm_private;
169         time_t                  cm_timestamp;   /* command creation time */
170         int                     cm_queue;
171 };
172
173 /*
174  * We gather a number of adapter-visible items into a single structure.
175  *
176  * The ordering of this strucure may be important; we copy the Linux driver:
177  *
178  * Adapter FIBs
179  * Init struct
180  * Queue headers (Comm Area)
181  * Printf buffer
182  *
183  * In addition, we add:
184  * Sync Fib
185  */
186 struct aac_common {
187         /* fibs for the controller to send us messages */
188         struct aac_fib          ac_fibs[AAC_ADAPTER_FIBS];
189
190         /* the init structure */
191         struct aac_adapter_init ac_init;
192
193         /* arena within which the queue structures are kept */
194         u_int8_t                ac_qbuf[sizeof(struct aac_queue_table) +
195                                 AAC_QUEUE_ALIGN];
196
197         /* buffer for text messages from the controller */
198         char                    ac_printf[AAC_PRINTF_BUFSIZE];
199         
200         /* fib for synchronous commands */
201         struct aac_fib          ac_sync_fib;
202 };
203
204 /*
205  * Interface operations
206  */
207 struct aac_interface 
208 {
209         int     (*aif_get_fwstatus)(struct aac_softc *sc);
210         void    (*aif_qnotify)(struct aac_softc *sc, int qbit);
211         int     (*aif_get_istatus)(struct aac_softc *sc);
212         void    (*aif_clr_istatus)(struct aac_softc *sc, int mask);
213         void    (*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command,
214                                    u_int32_t arg0, u_int32_t arg1,
215                                    u_int32_t arg2, u_int32_t arg3);
216         int     (*aif_get_mailbox)(struct aac_softc *sc, int mb);
217         void    (*aif_set_interrupts)(struct aac_softc *sc, int enable);
218 };
219 extern struct aac_interface     aac_rx_interface;
220 extern struct aac_interface     aac_sa_interface;
221 extern struct aac_interface     aac_fa_interface;
222
223 #define AAC_GET_FWSTATUS(sc)            ((sc)->aac_if.aif_get_fwstatus((sc)))
224 #define AAC_QNOTIFY(sc, qbit)           ((sc)->aac_if.aif_qnotify((sc), (qbit)))
225 #define AAC_GET_ISTATUS(sc)             ((sc)->aac_if.aif_get_istatus((sc)))
226 #define AAC_CLEAR_ISTATUS(sc, mask)     ((sc)->aac_if.aif_clr_istatus((sc), \
227                                         (mask)))
228 #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \
229         ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \
230         (arg3)))
231 #define AAC_GET_MAILBOX(sc, mb)         ((sc)->aac_if.aif_get_mailbox((sc), \
232                                         (mb)))
233 #define AAC_MASK_INTERRUPTS(sc)         ((sc)->aac_if.aif_set_interrupts((sc), \
234                                         0))
235 #define AAC_UNMASK_INTERRUPTS(sc)       ((sc)->aac_if.aif_set_interrupts((sc), \
236                                         1))
237
238 #define AAC_SETREG4(sc, reg, val)       bus_space_write_4(sc->aac_btag, \
239                                         sc->aac_bhandle, reg, val)
240 #define AAC_GETREG4(sc, reg)            bus_space_read_4 (sc->aac_btag, \
241                                         sc->aac_bhandle, reg)
242 #define AAC_SETREG2(sc, reg, val)       bus_space_write_2(sc->aac_btag, \
243                                         sc->aac_bhandle, reg, val)
244 #define AAC_GETREG2(sc, reg)            bus_space_read_2 (sc->aac_btag, \
245                                         sc->aac_bhandle, reg)
246 #define AAC_SETREG1(sc, reg, val)       bus_space_write_1(sc->aac_btag, \
247                                         sc->aac_bhandle, reg, val)
248 #define AAC_GETREG1(sc, reg)            bus_space_read_1 (sc->aac_btag, \
249                                         sc->aac_bhandle, reg)
250
251 TAILQ_HEAD(aac_container_tq, aac_container);
252
253 /* Define the OS version specific locks */
254 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
255 #include <sys/lock.h>
256 #include <sys/mutex.h>
257 typedef struct mtx aac_lock_t;
258 #define AAC_LOCK_INIT(l, s)     mtx_init(l, s, MTX_DEF)
259 #define AAC_LOCK_ACQUIRE(l)     mtx_lock(l)
260 #define AAC_LOCK_RELEASE(l)     mtx_unlock(l)
261 #else
262 typedef struct lwkt_rwlock aac_lock_t;
263 #define AAC_LOCK_INIT(l, s)     lwkt_rwlock_init(l)
264 #define AAC_LOCK_ACQUIRE(l)     lwkt_exlock(l, "aac")
265 #define AAC_LOCK_RELEASE(l)     lwkt_exunlock(l)
266 #endif
267
268 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
269 #include <sys/selinfo.h>
270 #else
271 #include <sys/select.h>
272 #endif
273
274 /*
275  * Per-controller structure.
276  */
277 struct aac_softc 
278 {
279         /* bus connections */
280         device_t                aac_dev;
281         struct callout          aac_watchdog;
282         struct resource         *aac_regs_resource;     /* register interface
283                                                          * window */
284         int                     aac_regs_rid;           /* resource ID */
285         bus_space_handle_t      aac_bhandle;            /* bus space handle */
286         bus_space_tag_t         aac_btag;               /* bus space tag */
287         bus_dma_tag_t           aac_parent_dmat;        /* parent DMA tag */
288         bus_dma_tag_t           aac_buffer_dmat;        /* data buffer/command
289                                                          * DMA tag */
290         struct resource         *aac_irq;               /* interrupt */
291         int                     aac_irq_rid;
292         void                    *aac_intr;              /* interrupt handle */
293
294         /* controller features, limits and status */
295         int                     aac_state;
296 #define AAC_STATE_SUSPEND       (1<<0)
297 #define AAC_STATE_OPEN          (1<<1)
298 #define AAC_STATE_INTERRUPTS_ON (1<<2)
299 #define AAC_STATE_AIF_SLEEPER   (1<<3)
300         struct FsaRevision              aac_revision;
301
302         /* controller hardware interface */
303         int                     aac_hwif;
304 #define AAC_HWIF_I960RX         0
305 #define AAC_HWIF_STRONGARM      1
306 #define AAC_HWIF_FALCON         2
307 #define AAC_HWIF_UNKNOWN        -1
308         bus_dma_tag_t           aac_common_dmat;        /* common structure
309                                                          * DMA tag */
310         bus_dmamap_t            aac_common_dmamap;      /* common structure
311                                                          * DMA map */
312         struct aac_common       *aac_common;
313         u_int32_t               aac_common_busaddr;
314         struct aac_interface    aac_if;
315
316         /* command/fib resources */
317         bus_dma_tag_t           aac_fib_dmat;   /* DMA tag for allocing FIBs */
318         struct aac_fib          *aac_fibs;
319         bus_dmamap_t            aac_fibmap;
320         u_int32_t               aac_fibphys;
321         struct aac_command      aac_command[AAC_FIB_COUNT];
322
323         /* command management */
324         TAILQ_HEAD(,aac_command) aac_free;      /* command structures 
325                                                  * available for reuse */
326         TAILQ_HEAD(,aac_command) aac_ready;     /* commands on hold for
327                                                  * controller resources */
328         TAILQ_HEAD(,aac_command) aac_busy;
329         TAILQ_HEAD(,aac_command) aac_complete;  /* commands which have been
330                                                  * returned by the controller */
331         struct bio_queue_head   aac_bioq;
332         struct aac_queue_table  *aac_queues;
333         struct aac_queue_entry  *aac_qentries[AAC_QUEUE_COUNT];
334
335         struct aac_qstat        aac_qstat[AACQ_COUNT];  /* queue statistics */
336
337         /* connected containters */
338         struct aac_container_tq aac_container_tqh;
339         aac_lock_t              aac_container_lock;
340
341         /* Protect the sync fib */
342 #define AAC_SYNC_LOCK_FORCE     (1 << 0)
343         aac_lock_t              aac_sync_lock;
344
345         /* delayed activity infrastructure */
346 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
347         struct task             aac_task_complete;      /* deferred-completion
348                                                          * task */
349 #endif
350         struct intr_config_hook aac_ich;
351
352         /* management interface */
353         dev_t                   aac_dev_t;
354         aac_lock_t              aac_aifq_lock;
355         struct aac_aif_command  aac_aifq[AAC_AIFQ_LENGTH];
356         int                     aac_aifq_head;
357         int                     aac_aifq_tail;
358         struct selinfo          rcv_select;
359         struct thread           *aifthread;
360         int                     aifflags;
361 #define AAC_AIFFLAGS_RUNNING    (1 << 0)
362 #define AAC_AIFFLAGS_PENDING    (1 << 1)
363 #define AAC_AIFFLAGS_EXIT       (1 << 2)
364 #define AAC_AIFFLAGS_EXITED     (1 << 3)
365         u_int32_t               flags;
366 #define AAC_FLAGS_PERC2QC       (1 << 0)
367 #define AAC_FLAGS_ENABLE_CAM    (1 << 1)        /* No SCSI passthrough */
368 #define AAC_FLAGS_CAM_NORESET   (1 << 2)        /* Fake SCSI resets */
369 #define AAC_FLAGS_CAM_PASSONLY  (1 << 3)        /* Only create pass devices */
370 #define AAC_FLAGS_4GB_WINDOW    (1 << 5)        /* Device can access host mem
371                                                  * 2GB-4GB range */
372 #define AAC_FLAGS_NO4GB         (1 << 6)        /* Can't access host mem >2GB */
373 #define AAC_FLAGS_256FIBS       (1 << 7)        /* Can only do 256 commands */
374   
375         u_int32_t               supported_options;
376         u_int32_t               scsi_method_id;
377 };
378
379
380 /*
381  * Public functions
382  */
383 extern void             aac_free(struct aac_softc *sc);
384 extern int              aac_attach(struct aac_softc *sc);
385 extern int              aac_detach(device_t dev);
386 extern int              aac_shutdown(device_t dev);
387 extern int              aac_suspend(device_t dev); 
388 extern int              aac_resume(device_t dev);
389 extern void             aac_intr(void *arg);
390 extern devclass_t       aac_devclass;
391 extern void             aac_submit_bio(struct bio *bp);
392 extern void             aac_biodone(struct bio *bp);
393 extern int              aac_dump_enqueue(struct aac_disk *ad, u_int32_t lba,
394                                          void *data, int nblks);
395 extern void             aac_dump_complete(struct aac_softc *sc);
396 extern void             aac_startio(struct aac_softc *sc);
397 extern int              aac_alloc_command(struct aac_softc *sc,
398                                           struct aac_command **cmp);
399 extern void             aac_release_command(struct aac_command *cm);
400 extern int              aac_alloc_sync_fib(struct aac_softc *sc,
401                                          struct aac_fib **fib, int flags);
402 extern void             aac_release_sync_fib(struct aac_softc *sc);
403 extern int              aac_sync_fib(struct aac_softc *sc, u_int32_t command,
404                                      u_int32_t xferstate, struct aac_fib *fib,
405                                      u_int16_t datasize);
406
407 /*
408  * Debugging levels:
409  *  0 - quiet, only emit warnings
410  *  1 - noisy, emit major function points and things done
411  *  2 - extremely noisy, emit trace items in loops, etc.
412  */
413 #ifdef AAC_DEBUG
414 # define debug(level, fmt, args...)                                     \
415         do {                                                            \
416         if (level <=AAC_DEBUG) printf("%s: " fmt "\n", __FUNCTION__ , ##args); \
417         } while (0)
418 # define debug_called(level)                                            \
419         do {                                                            \
420         if (level <= AAC_DEBUG) printf(__FUNCTION__ ": called\n");      \
421         } while (0)
422
423 extern void     aac_print_queues(struct aac_softc *sc);
424 extern void     aac_panic(struct aac_softc *sc, char *reason);
425 extern void     aac_print_fib(struct aac_softc *sc, struct aac_fib *fib,
426                               char *caller);
427 extern void     aac_print_aif(struct aac_softc *sc,
428                               struct aac_aif_command *aif);
429
430 # define AAC_PRINT_FIB(sc, fib) aac_print_fib(sc, fib, __FUNCTION__)
431
432 #else
433 # define debug(level, fmt, args...)
434 # define debug_called(level)
435
436 # define aac_print_queues(sc)
437 # define aac_panic(sc, reason)
438
439 # define AAC_PRINT_FIB(sc, fib)
440 # define aac_print_aif(sc, aac_aif_command)
441 #endif
442
443 struct aac_code_lookup {
444         char    *string;
445         u_int32_t       code;
446 };
447
448 /*
449  * Queue primitives for driver queues.
450  */
451 #define AACQ_ADD(sc, qname)                                     \
452         do {                                                    \
453                 struct aac_qstat *qs;                           \
454                                                                 \
455                 qs = &(sc)->aac_qstat[qname];                   \
456                                                                 \
457                 qs->q_length++;                                 \
458                 if (qs->q_length > qs->q_max)                   \
459                         qs->q_max = qs->q_length;               \
460         } while (0)
461
462 #define AACQ_REMOVE(sc, qname)    (sc)->aac_qstat[qname].q_length--
463 #define AACQ_INIT(sc, qname)                            \
464         do {                                            \
465                 sc->aac_qstat[qname].q_length = 0;      \
466                 sc->aac_qstat[qname].q_max = 0;         \
467         } while (0)
468
469
470 #define AACQ_COMMAND_QUEUE(name, index)                                 \
471 static __inline void                                                    \
472 aac_initq_ ## name (struct aac_softc *sc)                               \
473 {                                                                       \
474         TAILQ_INIT(&sc->aac_ ## name);                                  \
475         AACQ_INIT(sc, index);                                           \
476 }                                                                       \
477 static __inline void                                                    \
478 aac_enqueue_ ## name (struct aac_command *cm)                           \
479 {                                                                       \
480         int s;                                                          \
481                                                                         \
482         s = splbio();                                                   \
483         if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) {                   \
484                 printf("command %p is on another queue, flags = %#x\n", \
485                        cm, cm->cm_flags);                               \
486                 panic("command is on another queue");                   \
487         }                                                               \
488         TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link);       \
489         cm->cm_flags |= AAC_ON_ ## index;                               \
490         AACQ_ADD(cm->cm_sc, index);                                     \
491         splx(s);                                                        \
492 }                                                                       \
493 static __inline void                                                    \
494 aac_requeue_ ## name (struct aac_command *cm)                           \
495 {                                                                       \
496         int s;                                                          \
497                                                                         \
498         s = splbio();                                                   \
499         if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) {                   \
500                 printf("command %p is on another queue, flags = %#x\n", \
501                        cm, cm->cm_flags);                               \
502                 panic("command is on another queue");                   \
503         }                                                               \
504         TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link);       \
505         cm->cm_flags |= AAC_ON_ ## index;                               \
506         AACQ_ADD(cm->cm_sc, index);                                     \
507         splx(s);                                                        \
508 }                                                                       \
509 static __inline struct aac_command *                                    \
510 aac_dequeue_ ## name (struct aac_softc *sc)                             \
511 {                                                                       \
512         struct aac_command *cm;                                         \
513         int s;                                                          \
514                                                                         \
515         s = splbio();                                                   \
516         if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) {            \
517                 if ((cm->cm_flags & AAC_ON_ ## index) == 0) {           \
518                         printf("command %p not in queue, flags = %#x, " \
519                                "bit = %#x\n", cm, cm->cm_flags,         \
520                                AAC_ON_ ## index);                       \
521                         panic("command not in queue");                  \
522                 }                                                       \
523                 TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link);           \
524                 cm->cm_flags &= ~AAC_ON_ ## index;                      \
525                 AACQ_REMOVE(sc, index);                                 \
526         }                                                               \
527         splx(s);                                                        \
528         return(cm);                                                     \
529 }                                                                       \
530 static __inline void                                                    \
531 aac_remove_ ## name (struct aac_command *cm)                            \
532 {                                                                       \
533         int s;                                                          \
534                                                                         \
535         s = splbio();                                                   \
536         if ((cm->cm_flags & AAC_ON_ ## index) == 0) {                   \
537                 printf("command %p not in queue, flags = %#x, "         \
538                        "bit = %#x\n", cm, cm->cm_flags,                 \
539                        AAC_ON_ ## index);                               \
540                 panic("command not in queue");                          \
541         }                                                               \
542         TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link);            \
543         cm->cm_flags &= ~AAC_ON_ ## index;                              \
544         AACQ_REMOVE(cm->cm_sc, index);                                  \
545         splx(s);                                                        \
546 }                                                                       \
547 struct hack
548
549 AACQ_COMMAND_QUEUE(free, AACQ_FREE);
550 AACQ_COMMAND_QUEUE(ready, AACQ_READY);
551 AACQ_COMMAND_QUEUE(busy, AACQ_BUSY);
552 AACQ_COMMAND_QUEUE(complete, AACQ_COMPLETE);
553
554 /*
555  * outstanding bio queue
556  */
557 static __inline void
558 aac_initq_bio(struct aac_softc *sc)
559 {
560         bioq_init(&sc->aac_bioq);
561         AACQ_INIT(sc, AACQ_BIO);
562 }
563
564 static __inline void
565 aac_enqueue_bio(struct aac_softc *sc, struct bio *bp)
566 {
567         int s;
568
569         s = splbio();
570         bioq_insert_tail(&sc->aac_bioq, bp);
571         AACQ_ADD(sc, AACQ_BIO);
572         splx(s);
573 }
574
575 static __inline struct bio *
576 aac_dequeue_bio(struct aac_softc *sc)
577 {
578         int s;
579         struct bio *bp;
580
581         s = splbio();
582         if ((bp = bioq_first(&sc->aac_bioq)) != NULL) {
583                 bioq_remove(&sc->aac_bioq, bp);
584                 AACQ_REMOVE(sc, AACQ_BIO);
585         }
586         splx(s);
587         return(bp);
588 }
589
590 static __inline void
591 aac_print_printf(struct aac_softc *sc)
592 {
593         /*
594          * XXX We have the ability to read the length of the printf string
595          * from out of the mailboxes.
596          */
597         device_printf(sc->aac_dev, "**Monitor** %.*s", AAC_PRINTF_BUFSIZE,
598                       sc->aac_common->ac_printf);
599         AAC_QNOTIFY(sc, AAC_DB_PRINTF);
600 }