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