LK_EXCLUSIVE has no business being in lockinit.
[dragonfly.git] / sys / dev / raid / aac / aacvar.h
blobec4966bbd4cdfdad9f3e74470a35d3d45822bea7
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.
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.
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.
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.21 2008/04/06 19:03:18 pavalos Exp $
33 #include <sys/buf.h>
34 #include <sys/buf2.h>
35 #include <sys/eventhandler.h>
36 #include <sys/lock.h>
37 #include <sys/selinfo.h>
38 #include <sys/taskqueue.h>
39 #include <sys/thread2.h>
42 * Driver Parameter Definitions
46 * The firmware interface allows for a 16-bit s/g list length. We limit
47 * ourselves to a reasonable maximum and ensure alignment.
49 #define AAC_MAXSGENTRIES 64 /* max S/G entries, limit 65535 */
52 * We allocate a small set of FIBs for the adapter to use to send us messages.
54 #define AAC_ADAPTER_FIBS 8
57 * FIBs are allocated in page-size chunks and can grow up to the 512
58 * limit imposed by the hardware.
60 #define AAC_PREALLOCATE_FIBS 128
61 #define AAC_NUM_MGT_FIB 8
63 * The controller reports status events in AIFs. We hang on to a number of
64 * these in order to pass them out to user-space management tools.
66 #define AAC_AIFQ_LENGTH 64
69 * Firmware messages are passed in the kprintf buffer.
71 #define AAC_PRINTF_BUFSIZE 256
74 * We wait this many seconds for the adapter to come ready if it is still
75 * booting
77 #define AAC_BOOT_TIMEOUT (3 * 60)
80 * Timeout for immediate commands.
82 #define AAC_IMMEDIATE_TIMEOUT 30 /* seconds */
85 * Timeout for normal commands
87 #define AAC_CMD_TIMEOUT 30 /* seconds */
90 * Rate at which we periodically check for timed out commands and kick the
91 * controller.
93 #define AAC_PERIODIC_INTERVAL 20 /* seconds */
96 * Character device major numbers.
98 #define AAC_DISK_MAJOR 200
101 * Per-container data structure
103 struct aac_container
105 struct aac_mntobj co_mntobj;
106 device_t co_disk;
107 int co_found;
108 TAILQ_ENTRY(aac_container) co_link;
112 * Per-SIM data structure
114 struct aac_sim
116 device_t sim_dev;
117 int TargetsPerBus;
118 int BusNumber;
119 int InitiatorBusId;
120 struct aac_softc *aac_sc;
121 TAILQ_ENTRY(aac_sim) sim_link;
125 * Per-disk structure
127 struct aac_disk
129 device_t ad_dev;
130 cdev_t ad_dev_t;
131 struct aac_softc *ad_controller;
132 struct aac_container *ad_container;
133 struct disk ad_disk;
134 struct devstat ad_stats;
135 int ad_flags;
136 #define AAC_DISK_OPEN (1<<0)
137 int ad_cylinders;
138 int ad_heads;
139 int ad_sectors;
140 u_int32_t ad_size;
141 int unit;
145 * Per-command control structure.
147 struct aac_command
149 TAILQ_ENTRY(aac_command) cm_link; /* list linkage */
151 struct aac_softc *cm_sc; /* controller that owns us */
153 struct aac_fib *cm_fib; /* FIB associated with this
154 * command */
155 u_int64_t cm_fibphys; /* bus address of the FIB */
156 struct buf *cm_data; /* pointer to data in kernel
157 * space */
158 u_int32_t cm_datalen; /* data length */
159 bus_dmamap_t cm_datamap; /* DMA map for bio data */
160 struct aac_sg_table *cm_sgtable; /* pointer to s/g table in
161 * command */
162 int cm_flags;
163 #define AAC_CMD_MAPPED (1<<0) /* command has had its data
164 * mapped */
165 #define AAC_CMD_DATAIN (1<<1) /* command involves data moving
166 * from controller to host */
167 #define AAC_CMD_DATAOUT (1<<2) /* command involves data moving
168 * from host to controller */
169 #define AAC_CMD_COMPLETED (1<<3) /* command has been completed */
170 #define AAC_CMD_TIMEDOUT (1<<4) /* command taken too long */
171 #define AAC_ON_AACQ_FREE (1<<5)
172 #define AAC_ON_AACQ_READY (1<<6)
173 #define AAC_ON_AACQ_BUSY (1<<7)
174 #define AAC_ON_AACQ_COMPLETE (1<<8)
175 #define AAC_ON_AACQ_NORM (1<<10)
176 #define AAC_ON_AACQ_AIF (1<<11)
177 #define AAC_ON_AACQ_MASK ((1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<10)|(1<11))
178 #define AAC_QUEUE_FRZN (1<<9) /* Freeze the processing of
179 * commands on the queue. */
181 void (* cm_complete)(struct aac_command *cm);
182 void *cm_private;
183 time_t cm_timestamp; /* command creation time */
184 int cm_queue;
185 int cm_index;
188 struct aac_fibmap {
189 TAILQ_ENTRY(aac_fibmap) fm_link; /* list linkage */
190 struct aac_fib *aac_fibs;
191 bus_dmamap_t aac_fibmap;
192 struct aac_command *aac_commands;
196 * We gather a number of adapter-visible items into a single structure.
198 * The ordering of this strucure may be important; we copy the Linux driver:
200 * Adapter FIBs
201 * Init struct
202 * Queue headers (Comm Area)
203 * Printf buffer
205 * In addition, we add:
206 * Sync Fib
208 struct aac_common {
209 /* fibs for the controller to send us messages */
210 struct aac_fib ac_fibs[AAC_ADAPTER_FIBS];
212 /* the init structure */
213 struct aac_adapter_init ac_init;
215 /* arena within which the queue structures are kept */
216 u_int8_t ac_qbuf[sizeof(struct aac_queue_table) +
217 AAC_QUEUE_ALIGN];
219 /* buffer for text messages from the controller */
220 char ac_printf[AAC_PRINTF_BUFSIZE];
222 /* fib for synchronous commands */
223 struct aac_fib ac_sync_fib;
227 * Interface operations
229 struct aac_interface
231 int (*aif_get_fwstatus)(struct aac_softc *sc);
232 void (*aif_qnotify)(struct aac_softc *sc, int qbit);
233 int (*aif_get_istatus)(struct aac_softc *sc);
234 void (*aif_clr_istatus)(struct aac_softc *sc, int mask);
235 void (*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command,
236 u_int32_t arg0, u_int32_t arg1,
237 u_int32_t arg2, u_int32_t arg3);
238 int (*aif_get_mailbox)(struct aac_softc *sc, int mb);
239 void (*aif_set_interrupts)(struct aac_softc *sc, int enable);
240 int (*aif_send_command)(struct aac_softc *sc, struct aac_command *cm);
241 int (*aif_get_outb_queue)(struct aac_softc *sc);
242 void (*aif_set_outb_queue)(struct aac_softc *sc, int index);
244 extern struct aac_interface aac_rx_interface;
245 extern struct aac_interface aac_sa_interface;
246 extern struct aac_interface aac_fa_interface;
247 extern struct aac_interface aac_rkt_interface;
249 #define AAC_GET_FWSTATUS(sc) ((sc)->aac_if.aif_get_fwstatus((sc)))
250 #define AAC_QNOTIFY(sc, qbit) ((sc)->aac_if.aif_qnotify((sc), (qbit)))
251 #define AAC_GET_ISTATUS(sc) ((sc)->aac_if.aif_get_istatus((sc)))
252 #define AAC_CLEAR_ISTATUS(sc, mask) ((sc)->aac_if.aif_clr_istatus((sc), \
253 (mask)))
254 #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \
255 ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \
256 (arg3)))
257 #define AAC_GET_MAILBOX(sc, mb) ((sc)->aac_if.aif_get_mailbox((sc), \
258 (mb)))
259 #define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \
261 #define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \
263 #define AAC_SEND_COMMAND(sc, cm) ((sc)->aac_if.aif_send_command((sc), (cm)))
264 #define AAC_GET_OUTB_QUEUE(sc) ((sc)->aac_if.aif_get_outb_queue((sc)))
265 #define AAC_SET_OUTB_QUEUE(sc, idx) ((sc)->aac_if.aif_set_outb_queue((sc), (idx)))
267 #define AAC_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag, \
268 sc->aac_bhandle, reg, val)
269 #define AAC_GETREG4(sc, reg) bus_space_read_4 (sc->aac_btag, \
270 sc->aac_bhandle, reg)
271 #define AAC_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag, \
272 sc->aac_bhandle, reg, val)
273 #define AAC_GETREG2(sc, reg) bus_space_read_2 (sc->aac_btag, \
274 sc->aac_bhandle, reg)
275 #define AAC_SETREG1(sc, reg, val) bus_space_write_1(sc->aac_btag, \
276 sc->aac_bhandle, reg, val)
277 #define AAC_GETREG1(sc, reg) bus_space_read_1 (sc->aac_btag, \
278 sc->aac_bhandle, reg)
280 /* Define the OS version specific locks */
281 typedef struct lock aac_lock_t;
282 #define AAC_LOCK_INIT(l, s) lockinit(l, s, 0, LK_CANRECURSE)
283 #define AAC_LOCK_ACQUIRE(l) lockmgr(l, LK_EXCLUSIVE)
284 #define AAC_LOCK_RELEASE(l) lockmgr(l, LK_RELEASE)
287 * Per-controller structure.
289 struct aac_softc
291 /* bus connections */
292 device_t aac_dev;
293 struct callout aac_watchdog;
294 struct resource *aac_regs_resource; /* register interface
295 * window */
296 int aac_regs_rid; /* resource ID */
297 bus_space_handle_t aac_bhandle; /* bus space handle */
298 bus_space_tag_t aac_btag; /* bus space tag */
299 bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */
300 bus_dma_tag_t aac_buffer_dmat; /* data buffer/command
301 * DMA tag */
302 struct resource *aac_irq; /* interrupt */
303 int aac_irq_rid;
304 void *aac_intr; /* interrupt handle */
305 eventhandler_tag eh;
307 /* controller features, limits and status */
308 int aac_state;
309 #define AAC_STATE_SUSPEND (1<<0)
310 #define AAC_STATE_OPEN (1<<1)
311 #define AAC_STATE_INTERRUPTS_ON (1<<2)
312 #define AAC_STATE_AIF_SLEEPER (1<<3)
313 struct FsaRevision aac_revision;
315 /* controller hardware interface */
316 int aac_hwif;
317 #define AAC_HWIF_I960RX 0
318 #define AAC_HWIF_STRONGARM 1
319 #define AAC_HWIF_FALCON 2
320 #define AAC_HWIF_RKT 3
321 #define AAC_HWIF_UNKNOWN -1
322 bus_dma_tag_t aac_common_dmat; /* common structure
323 * DMA tag */
324 bus_dmamap_t aac_common_dmamap; /* common structure
325 * DMA map */
326 struct aac_common *aac_common;
327 u_int32_t aac_common_busaddr;
328 struct aac_interface aac_if;
330 /* command/fib resources */
331 bus_dma_tag_t aac_fib_dmat; /* DMA tag for allocing FIBs */
332 TAILQ_HEAD(,aac_fibmap) aac_fibmap_tqh;
333 u_int total_fibs;
334 struct aac_command *aac_commands;
336 /* command management */
337 TAILQ_HEAD(,aac_command) aac_free; /* command structures
338 * available for reuse */
339 TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for
340 * controller resources */
341 TAILQ_HEAD(,aac_command) aac_busy;
342 TAILQ_HEAD(,aac_command) aac_complete; /* commands which have been
343 * returned by the controller */
344 TAILQ_HEAD(,aac_command) aac_aif;
345 #if 0
346 TAILQ_HEAD(,aac_command) aac_norm;
347 #endif
348 TAILQ_HEAD(,aac_event) aac_ev_cmfree;
349 struct bio_queue_head aac_bioq;
350 struct aac_queue_table *aac_queues;
351 struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT];
353 struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */
355 /* connected containters */
356 TAILQ_HEAD(,aac_container) aac_container_tqh;
357 aac_lock_t aac_container_lock;
360 * The general I/O lock. This protects the sync fib, the lists, the
361 * queues, and the registers.
363 aac_lock_t aac_io_lock;
365 /* delayed activity infrastructure */
366 struct task aac_task_complete; /* deferred-completion
367 * task */
368 struct intr_config_hook aac_ich;
370 /* management interface */
371 cdev_t aac_dev_t;
372 aac_lock_t aac_aifq_lock;
373 struct aac_aif_command aac_aifq[AAC_AIFQ_LENGTH];
374 int aac_aifq_head;
375 int aac_aifq_tail;
376 struct selinfo rcv_select;
377 struct thread *aifthread;
378 int aifflags;
379 #define AAC_AIFFLAGS_RUNNING (1 << 0)
380 #define AAC_AIFFLAGS_AIF (1 << 1)
381 #define AAC_AIFFLAGS_EXIT (1 << 2)
382 #define AAC_AIFFLAGS_EXITED (1 << 3)
383 #define AAC_AIFFLAGS_PRINTF (1 << 4)
384 #define AAC_AIFFLAGS_ALLOCFIBS (1 << 5)
385 #define AAC_AIFFLAGS_PENDING (AAC_AIFFLAGS_AIF | AAC_AIFFLAGS_PRINTF | \
386 AAC_AIFFLAGS_ALLOCFIBS)
387 u_int32_t flags;
388 #define AAC_FLAGS_PERC2QC (1 << 0)
389 #define AAC_FLAGS_ENABLE_CAM (1 << 1) /* No SCSI passthrough */
390 #define AAC_FLAGS_CAM_NORESET (1 << 2) /* Fake SCSI resets */
391 #define AAC_FLAGS_CAM_PASSONLY (1 << 3) /* Only create pass devices */
392 #define AAC_FLAGS_SG_64BIT (1 << 4) /* Use 64-bit S/G addresses */
393 #define AAC_FLAGS_4GB_WINDOW (1 << 5) /* Device can access host mem
394 * 2GB-4GB range */
395 #define AAC_FLAGS_NO4GB (1 << 6) /* Can't access host mem >2GB */
396 #define AAC_FLAGS_256FIBS (1 << 7) /* Can only do 256 commands */
397 #define AAC_FLAGS_BROKEN_MEMMAP (1 << 8) /* Broken HostPhysMemPages */
398 #define AAC_FLAGS_SLAVE (1 << 9)
399 #define AAC_FLAGS_MASTER (1 << 10)
400 #define AAC_FLAGS_NEW_COMM (1 << 11) /* New comm. interface supported */
401 #define AAC_FLAGS_RAW_IO (1 << 12) /* Raw I/O interface */
402 #define AAC_FLAGS_ARRAY_64BIT (1 << 13) /* 64-bit array size */
404 u_int32_t supported_options;
405 u_int32_t scsi_method_id;
406 TAILQ_HEAD(,aac_sim) aac_sim_tqh;
408 u_int32_t aac_max_fibs; /* max. FIB count */
409 u_int32_t aac_max_fibs_alloc; /* max. alloc. per alloc_commands() */
410 u_int32_t aac_max_fib_size; /* max. FIB size */
411 u_int32_t aac_sg_tablesize; /* max. sg count from host */
412 u_int32_t aac_max_sectors; /* max. I/O size from host (blocks) */
416 * Event callback mechanism for the driver
418 #define AAC_EVENT_NONE 0x00
419 #define AAC_EVENT_CMFREE 0x01
420 #define AAC_EVENT_MASK 0xff
421 #define AAC_EVENT_REPEAT 0x100
423 typedef void aac_event_cb_t(struct aac_softc *sc, struct aac_event *event,
424 void *arg);
425 struct aac_event {
426 TAILQ_ENTRY(aac_event) ev_links;
427 int ev_type;
428 aac_event_cb_t *ev_callback;
429 void *ev_arg;
432 #ifndef AAC_DRIVER_BUILD
433 # define AAC_DRIVER_BUILD 1
434 #endif
437 * Public functions
439 extern void aac_free(struct aac_softc *sc);
440 extern int aac_attach(struct aac_softc *sc);
441 extern int aac_detach(device_t dev);
442 extern int aac_suspend(device_t dev);
443 extern int aac_resume(device_t dev);
444 extern void aac_new_intr(void *arg);
445 extern void aac_fast_intr(void *arg);
446 extern devclass_t aac_devclass;
447 extern void aac_submit_bio(struct aac_disk *ad, struct bio *bio);
448 extern void aac_biodone(struct bio *bio, const char *code);
449 extern int aac_dump_enqueue(struct aac_disk *ad, u_int64_t lba,
450 void *data, int nblks);
451 extern void aac_dump_complete(struct aac_softc *sc);
452 extern void aac_startio(struct aac_softc *sc);
453 extern int aac_alloc_command(struct aac_softc *sc,
454 struct aac_command **cmp);
455 extern void aac_release_command(struct aac_command *cm);
456 extern int aac_sync_fib(struct aac_softc *sc, u_int32_t command,
457 u_int32_t xferstate, struct aac_fib *fib,
458 u_int16_t datasize);
459 extern void aac_add_event(struct aac_softc *sc, struct aac_event
460 *event);
463 * Debugging levels:
464 * 0 - quiet, only emit warnings
465 * 1 - noisy, emit major function points and things done
466 * 2 - extremely noisy, emit trace items in loops, etc.
468 #ifdef AAC_DEBUG
469 # define debug(level, fmt, args...) \
470 do { \
471 if (level <=AAC_DEBUG) kprintf("%s: " fmt "\n", __func__ , ##args); \
472 } while (0)
473 # define debug_called(level) \
474 do { \
475 if (level <= AAC_DEBUG) kprintf("%s: called\n", __func__); \
476 } while (0)
478 extern void aac_print_fib(struct aac_softc *sc, struct aac_fib *fib,
479 const char *caller);
480 extern void aac_print_aif(struct aac_softc *sc,
481 struct aac_aif_command *aif);
483 # define AAC_PRINT_FIB(sc, fib) aac_print_fib(sc, fib, __func__)
485 #else
486 # define debug(level, fmt, args...)
487 # define debug_called(level)
489 # define AAC_PRINT_FIB(sc, fib)
490 # define aac_print_aif(sc, aac_aif_command)
491 #endif
493 struct aac_code_lookup {
494 char *string;
495 u_int32_t code;
499 * Queue primitives for driver queues.
501 #define AACQ_ADD(sc, qname) \
502 do { \
503 struct aac_qstat *qs; \
505 qs = &(sc)->aac_qstat[qname]; \
507 qs->q_length++; \
508 if (qs->q_length > qs->q_max) \
509 qs->q_max = qs->q_length; \
510 } while (0)
512 #define AACQ_REMOVE(sc, qname) (sc)->aac_qstat[qname].q_length--
513 #define AACQ_INIT(sc, qname) \
514 do { \
515 sc->aac_qstat[qname].q_length = 0; \
516 sc->aac_qstat[qname].q_max = 0; \
517 } while (0)
520 #define AACQ_COMMAND_QUEUE(name, index) \
521 static __inline void \
522 aac_initq_ ## name (struct aac_softc *sc) \
524 TAILQ_INIT(&sc->aac_ ## name); \
525 AACQ_INIT(sc, index); \
527 static __inline void \
528 aac_enqueue_ ## name (struct aac_command *cm) \
530 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \
531 kprintf("command %p is on another queue, flags = %#x\n", \
532 cm, cm->cm_flags); \
533 panic("command is on another queue"); \
535 TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link); \
536 cm->cm_flags |= AAC_ON_ ## index; \
537 AACQ_ADD(cm->cm_sc, index); \
539 static __inline void \
540 aac_requeue_ ## name (struct aac_command *cm) \
542 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \
543 kprintf("command %p is on another queue, flags = %#x\n", \
544 cm, cm->cm_flags); \
545 panic("command is on another queue"); \
547 TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link); \
548 cm->cm_flags |= AAC_ON_ ## index; \
549 AACQ_ADD(cm->cm_sc, index); \
551 static __inline struct aac_command * \
552 aac_dequeue_ ## name (struct aac_softc *sc) \
554 struct aac_command *cm; \
556 if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) { \
557 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \
558 kprintf("command %p not in queue, flags = %#x, " \
559 "bit = %#x\n", cm, cm->cm_flags, \
560 AAC_ON_ ## index); \
561 panic("command not in queue"); \
563 TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link); \
564 cm->cm_flags &= ~AAC_ON_ ## index; \
565 AACQ_REMOVE(sc, index); \
567 return(cm); \
569 static __inline void \
570 aac_remove_ ## name (struct aac_command *cm) \
572 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \
573 kprintf("command %p not in queue, flags = %#x, " \
574 "bit = %#x\n", cm, cm->cm_flags, \
575 AAC_ON_ ## index); \
576 panic("command not in queue"); \
578 TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link); \
579 cm->cm_flags &= ~AAC_ON_ ## index; \
580 AACQ_REMOVE(cm->cm_sc, index); \
582 struct hack
584 AACQ_COMMAND_QUEUE(free, AACQ_FREE);
585 AACQ_COMMAND_QUEUE(ready, AACQ_READY);
586 AACQ_COMMAND_QUEUE(busy, AACQ_BUSY);
587 AACQ_COMMAND_QUEUE(complete, AACQ_COMPLETE);
590 * outstanding bio queue
592 static __inline void
593 aac_initq_bio(struct aac_softc *sc)
595 bioq_init(&sc->aac_bioq);
596 AACQ_INIT(sc, AACQ_BIO);
599 static __inline void
600 aac_enqueue_bio(struct aac_softc *sc, struct bio *bio)
602 bioq_insert_tail(&sc->aac_bioq, bio);
603 AACQ_ADD(sc, AACQ_BIO);
606 static __inline struct bio *
607 aac_dequeue_bio(struct aac_softc *sc)
609 struct bio *bio;
611 if ((bio = bioq_first(&sc->aac_bioq)) != NULL) {
612 bioq_remove(&sc->aac_bioq, bio);
613 AACQ_REMOVE(sc, AACQ_BIO);
615 return(bio);
618 static __inline void
619 aac_print_printf(struct aac_softc *sc)
622 * XXX We have the ability to read the length of the kprintf string
623 * from out of the mailboxes.
625 device_printf(sc->aac_dev, "**Monitor** %.*s", AAC_PRINTF_BUFSIZE,
626 sc->aac_common->ac_printf);
627 sc->aac_common->ac_printf[0] = 0;
628 AAC_QNOTIFY(sc, AAC_DB_PRINTF);
631 static __inline int
632 aac_alloc_sync_fib(struct aac_softc *sc, struct aac_fib **fib)
635 KKASSERT(lockstatus(&sc->aac_io_lock, curthread) != 0);
636 *fib = &sc->aac_common->ac_sync_fib;
637 return (0);
640 static __inline void
641 aac_release_sync_fib(struct aac_softc *sc)
644 KKASSERT(lockstatus(&sc->aac_io_lock, curthread) != 0);