xref: /dragonfly/sys/dev/raid/aac/aacvar.h (revision 0e085424)
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.10 2005/08/08 01:25:31 hmp 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 printf 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 	dev_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 	struct disklabel		ad_label;
127 	int				ad_flags;
128 #define AAC_DISK_OPEN	(1<<0)
129 	int				ad_cylinders;
130 	int				ad_heads;
131 	int				ad_sectors;
132 	u_int32_t			ad_size;
133 	int				unit;
134 };
135 
136 /*
137  * Per-command control structure.
138  */
139 struct aac_command
140 {
141 	TAILQ_ENTRY(aac_command) cm_link;	/* list linkage */
142 
143 	struct aac_softc	*cm_sc;		/* controller that owns us */
144 
145 	struct aac_fib		*cm_fib;	/* FIB associated with this
146 						 * command */
147 	u_int32_t		cm_fibphys;	/* bus address of the FIB */
148 	struct buf		*cm_data;	/* pointer to data in kernel
149 						 * space */
150 	u_int32_t		cm_datalen;	/* data length */
151 	bus_dmamap_t		cm_datamap;	/* DMA map for bio data */
152 	struct aac_sg_table	*cm_sgtable;	/* pointer to s/g table in
153 						 * command */
154 	int			cm_flags;
155 #define AAC_CMD_MAPPED		(1<<0)		/* command has had its data
156 						 * mapped */
157 #define AAC_CMD_DATAIN		(1<<1)		/* command involves data moving
158 						 * from controller to host */
159 #define AAC_CMD_DATAOUT		(1<<2)		/* command involves data moving
160 						 * from host to controller */
161 #define AAC_CMD_COMPLETED	(1<<3)		/* command has been completed */
162 #define AAC_CMD_TIMEDOUT	(1<<4)		/* command taken too long */
163 #define AAC_ON_AACQ_FREE	(1<<5)
164 #define AAC_ON_AACQ_READY	(1<<6)
165 #define AAC_ON_AACQ_BUSY	(1<<7)
166 #define AAC_ON_AACQ_COMPLETE	(1<<8)
167 #define AAC_ON_AACQ_MASK	((1<<5)|(1<<6)|(1<<7)|(1<<8))
168 
169 	void			(* cm_complete)(struct aac_command *cm);
170 	void			*cm_private;
171 	time_t			cm_timestamp;	/* command creation time */
172 	int			cm_queue;
173 };
174 
175 /*
176  * We gather a number of adapter-visible items into a single structure.
177  *
178  * The ordering of this strucure may be important; we copy the Linux driver:
179  *
180  * Adapter FIBs
181  * Init struct
182  * Queue headers (Comm Area)
183  * Printf buffer
184  *
185  * In addition, we add:
186  * Sync Fib
187  */
188 struct aac_common {
189 	/* fibs for the controller to send us messages */
190 	struct aac_fib		ac_fibs[AAC_ADAPTER_FIBS];
191 
192 	/* the init structure */
193 	struct aac_adapter_init	ac_init;
194 
195 	/* arena within which the queue structures are kept */
196 	u_int8_t		ac_qbuf[sizeof(struct aac_queue_table) +
197 				AAC_QUEUE_ALIGN];
198 
199 	/* buffer for text messages from the controller */
200 	char		       	ac_printf[AAC_PRINTF_BUFSIZE];
201 
202 	/* fib for synchronous commands */
203 	struct aac_fib		ac_sync_fib;
204 };
205 
206 /*
207  * Interface operations
208  */
209 struct aac_interface
210 {
211 	int	(*aif_get_fwstatus)(struct aac_softc *sc);
212 	void	(*aif_qnotify)(struct aac_softc *sc, int qbit);
213 	int	(*aif_get_istatus)(struct aac_softc *sc);
214 	void	(*aif_clr_istatus)(struct aac_softc *sc, int mask);
215 	void	(*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command,
216 				   u_int32_t arg0, u_int32_t arg1,
217 				   u_int32_t arg2, u_int32_t arg3);
218 	int	(*aif_get_mailbox)(struct aac_softc *sc, int mb);
219 	void	(*aif_set_interrupts)(struct aac_softc *sc, int enable);
220 };
221 extern struct aac_interface	aac_rx_interface;
222 extern struct aac_interface	aac_sa_interface;
223 extern struct aac_interface	aac_fa_interface;
224 
225 #define AAC_GET_FWSTATUS(sc)		((sc)->aac_if.aif_get_fwstatus((sc)))
226 #define AAC_QNOTIFY(sc, qbit)		((sc)->aac_if.aif_qnotify((sc), (qbit)))
227 #define AAC_GET_ISTATUS(sc)		((sc)->aac_if.aif_get_istatus((sc)))
228 #define AAC_CLEAR_ISTATUS(sc, mask)	((sc)->aac_if.aif_clr_istatus((sc), \
229 					(mask)))
230 #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \
231 	((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \
232 	(arg3)))
233 #define AAC_GET_MAILBOX(sc, mb)		((sc)->aac_if.aif_get_mailbox((sc), \
234 					(mb)))
235 #define	AAC_MASK_INTERRUPTS(sc)		((sc)->aac_if.aif_set_interrupts((sc), \
236 					0))
237 #define AAC_UNMASK_INTERRUPTS(sc)	((sc)->aac_if.aif_set_interrupts((sc), \
238 					1))
239 
240 #define AAC_SETREG4(sc, reg, val)	bus_space_write_4(sc->aac_btag, \
241 					sc->aac_bhandle, reg, val)
242 #define AAC_GETREG4(sc, reg)		bus_space_read_4 (sc->aac_btag, \
243 					sc->aac_bhandle, reg)
244 #define AAC_SETREG2(sc, reg, val)	bus_space_write_2(sc->aac_btag, \
245 					sc->aac_bhandle, reg, val)
246 #define AAC_GETREG2(sc, reg)		bus_space_read_2 (sc->aac_btag, \
247 					sc->aac_bhandle, reg)
248 #define AAC_SETREG1(sc, reg, val)	bus_space_write_1(sc->aac_btag, \
249 					sc->aac_bhandle, reg, val)
250 #define AAC_GETREG1(sc, reg)		bus_space_read_1 (sc->aac_btag, \
251 					sc->aac_bhandle, reg)
252 
253 TAILQ_HEAD(aac_container_tq, aac_container);
254 
255 /* Define the OS version specific locks */
256 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
257 #include <sys/lock.h>
258 #include <sys/mutex.h>
259 typedef struct mtx aac_lock_t;
260 #define AAC_LOCK_INIT(l, s)	mtx_init(l, s, MTX_DEF)
261 #define AAC_LOCK_ACQUIRE(l)	mtx_lock(l)
262 #define AAC_LOCK_RELEASE(l)	mtx_unlock(l)
263 #else
264 typedef struct lwkt_rwlock aac_lock_t;
265 #define AAC_LOCK_INIT(l, s)	lwkt_rwlock_init(l)
266 #define AAC_LOCK_ACQUIRE(l)	lwkt_exlock(l, "aac")
267 #define AAC_LOCK_RELEASE(l)	lwkt_exunlock(l)
268 #endif
269 
270 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
271 #include <sys/selinfo.h>
272 #else
273 #include <sys/select.h>
274 #endif
275 
276 /*
277  * Per-controller structure.
278  */
279 struct aac_softc
280 {
281 	/* bus connections */
282 	device_t		aac_dev;
283 	struct callout		aac_watchdog;
284 	struct resource		*aac_regs_resource;	/* register interface
285 							 * window */
286 	int			aac_regs_rid;		/* resource ID */
287 	bus_space_handle_t	aac_bhandle;		/* bus space handle */
288 	bus_space_tag_t		aac_btag;		/* bus space tag */
289 	bus_dma_tag_t		aac_parent_dmat;	/* parent DMA tag */
290 	bus_dma_tag_t		aac_buffer_dmat;	/* data buffer/command
291 							 * DMA tag */
292 	struct resource		*aac_irq;		/* interrupt */
293 	int			aac_irq_rid;
294 	void			*aac_intr;		/* interrupt handle */
295 
296 	/* controller features, limits and status */
297 	int			aac_state;
298 #define AAC_STATE_SUSPEND	(1<<0)
299 #define	AAC_STATE_OPEN		(1<<1)
300 #define AAC_STATE_INTERRUPTS_ON	(1<<2)
301 #define AAC_STATE_AIF_SLEEPER	(1<<3)
302 	struct FsaRevision		aac_revision;
303 
304 	/* controller hardware interface */
305 	int			aac_hwif;
306 #define AAC_HWIF_I960RX		0
307 #define AAC_HWIF_STRONGARM	1
308 #define	AAC_HWIF_FALCON		2
309 #define AAC_HWIF_UNKNOWN	-1
310 	bus_dma_tag_t		aac_common_dmat;	/* common structure
311 							 * DMA tag */
312 	bus_dmamap_t		aac_common_dmamap;	/* common structure
313 							 * DMA map */
314 	struct aac_common	*aac_common;
315 	u_int32_t		aac_common_busaddr;
316 	struct aac_interface	aac_if;
317 
318 	/* command/fib resources */
319 	bus_dma_tag_t		aac_fib_dmat;	/* DMA tag for allocing FIBs */
320 	struct aac_fib		*aac_fibs;
321 	bus_dmamap_t		aac_fibmap;
322 	u_int32_t		aac_fibphys;
323 	struct aac_command	aac_command[AAC_FIB_COUNT];
324 
325 	/* command management */
326 	TAILQ_HEAD(,aac_command) aac_free;	/* command structures
327 						 * available for reuse */
328 	TAILQ_HEAD(,aac_command) aac_ready;	/* commands on hold for
329 						 * controller resources */
330 	TAILQ_HEAD(,aac_command) aac_busy;
331 	TAILQ_HEAD(,aac_command) aac_complete;	/* commands which have been
332 						 * returned by the controller */
333 	struct buf_queue_head	aac_bioq;
334 	struct aac_queue_table	*aac_queues;
335 	struct aac_queue_entry	*aac_qentries[AAC_QUEUE_COUNT];
336 
337 	struct aac_qstat	aac_qstat[AACQ_COUNT];	/* queue statistics */
338 
339 	/* connected containters */
340 	struct aac_container_tq	aac_container_tqh;
341 	aac_lock_t		aac_container_lock;
342 
343 	/* Protect the sync fib */
344 #define AAC_SYNC_LOCK_FORCE	(1 << 0)
345 	aac_lock_t		aac_sync_lock;
346 
347 	/* delayed activity infrastructure */
348 #if defined(__FreeBSD__) && __FreeBSD_version >= 500005
349 	struct task		aac_task_complete;	/* deferred-completion
350 							 * task */
351 #endif
352 	struct intr_config_hook	aac_ich;
353 
354 	/* management interface */
355 	dev_t			aac_dev_t;
356 	aac_lock_t		aac_aifq_lock;
357 	struct aac_aif_command	aac_aifq[AAC_AIFQ_LENGTH];
358 	int			aac_aifq_head;
359 	int			aac_aifq_tail;
360 	struct selinfo		rcv_select;
361 	struct thread		*aifthread;
362 	int			aifflags;
363 #define AAC_AIFFLAGS_RUNNING	(1 << 0)
364 #define AAC_AIFFLAGS_PENDING	(1 << 1)
365 #define	AAC_AIFFLAGS_EXIT	(1 << 2)
366 #define AAC_AIFFLAGS_EXITED	(1 << 3)
367 	u_int32_t		flags;
368 #define AAC_FLAGS_PERC2QC	(1 << 0)
369 #define	AAC_FLAGS_ENABLE_CAM	(1 << 1)	/* No SCSI passthrough */
370 #define	AAC_FLAGS_CAM_NORESET	(1 << 2)	/* Fake SCSI resets */
371 #define	AAC_FLAGS_CAM_PASSONLY	(1 << 3)	/* Only create pass devices */
372 #define	AAC_FLAGS_4GB_WINDOW	(1 << 5)	/* Device can access host mem
373  						 * 2GB-4GB range */
374 #define	AAC_FLAGS_NO4GB		(1 << 6)	/* Can't access host mem >2GB */
375 #define	AAC_FLAGS_256FIBS	(1 << 7)	/* Can only do 256 commands */
376 
377 	u_int32_t		supported_options;
378 	u_int32_t		scsi_method_id;
379 };
380 
381 
382 /*
383  * Public functions
384  */
385 extern void		aac_free(struct aac_softc *sc);
386 extern int		aac_attach(struct aac_softc *sc);
387 extern int		aac_detach(device_t dev);
388 extern int		aac_shutdown(device_t dev);
389 extern int		aac_suspend(device_t dev);
390 extern int		aac_resume(device_t dev);
391 extern void		aac_intr(void *arg);
392 extern devclass_t	aac_devclass;
393 extern void		aac_submit_bio(struct buf *bp);
394 extern void		aac_biodone(struct buf *bp);
395 extern int		aac_dump_enqueue(struct aac_disk *ad, u_int32_t lba,
396 					 void *data, int nblks);
397 extern void		aac_dump_complete(struct aac_softc *sc);
398 extern void		aac_startio(struct aac_softc *sc);
399 extern int		aac_alloc_command(struct aac_softc *sc,
400 					  struct aac_command **cmp);
401 extern void		aac_release_command(struct aac_command *cm);
402 extern int		aac_alloc_sync_fib(struct aac_softc *sc,
403 					 struct aac_fib **fib, int flags);
404 extern void		aac_release_sync_fib(struct aac_softc *sc);
405 extern int		aac_sync_fib(struct aac_softc *sc, u_int32_t command,
406 				     u_int32_t xferstate, struct aac_fib *fib,
407 				     u_int16_t datasize);
408 
409 /*
410  * Debugging levels:
411  *  0 - quiet, only emit warnings
412  *  1 - noisy, emit major function points and things done
413  *  2 - extremely noisy, emit trace items in loops, etc.
414  */
415 #ifdef AAC_DEBUG
416 # define debug(level, fmt, args...)					\
417 	do {								\
418 	if (level <=AAC_DEBUG) printf("%s: " fmt "\n", __func__ , ##args); \
419 	} while (0)
420 # define debug_called(level)						\
421 	do {								\
422 	if (level <= AAC_DEBUG) printf(__func__ ": called\n");	\
423 	} while (0)
424 
425 extern void	aac_print_queues(struct aac_softc *sc);
426 extern void	aac_panic(struct aac_softc *sc, char *reason);
427 extern void	aac_print_fib(struct aac_softc *sc, struct aac_fib *fib,
428 			      char *caller);
429 extern void	aac_print_aif(struct aac_softc *sc,
430 			      struct aac_aif_command *aif);
431 
432 # define AAC_PRINT_FIB(sc, fib)	aac_print_fib(sc, fib, __func__)
433 
434 #else
435 # define debug(level, fmt, args...)
436 # define debug_called(level)
437 
438 # define aac_print_queues(sc)
439 # define aac_panic(sc, reason)
440 
441 # define AAC_PRINT_FIB(sc, fib)
442 # define aac_print_aif(sc, aac_aif_command)
443 #endif
444 
445 struct aac_code_lookup {
446 	char	*string;
447 	u_int32_t	code;
448 };
449 
450 /*
451  * Queue primitives for driver queues.
452  */
453 #define AACQ_ADD(sc, qname)					\
454 	do {							\
455 		struct aac_qstat *qs;				\
456 								\
457 		qs = &(sc)->aac_qstat[qname];			\
458 								\
459 		qs->q_length++;					\
460 		if (qs->q_length > qs->q_max)			\
461 			qs->q_max = qs->q_length;		\
462 	} while (0)
463 
464 #define AACQ_REMOVE(sc, qname)    (sc)->aac_qstat[qname].q_length--
465 #define AACQ_INIT(sc, qname)				\
466 	do {						\
467 		sc->aac_qstat[qname].q_length = 0;	\
468 		sc->aac_qstat[qname].q_max = 0;		\
469 	} while (0)
470 
471 
472 #define AACQ_COMMAND_QUEUE(name, index)					\
473 static __inline void							\
474 aac_initq_ ## name (struct aac_softc *sc)				\
475 {									\
476 	TAILQ_INIT(&sc->aac_ ## name);					\
477 	AACQ_INIT(sc, index);						\
478 }									\
479 static __inline void							\
480 aac_enqueue_ ## name (struct aac_command *cm)				\
481 {									\
482 	crit_enter();							\
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 	crit_exit();							\
492 }									\
493 static __inline void							\
494 aac_requeue_ ## name (struct aac_command *cm)				\
495 {									\
496 	crit_enter();							\
497 	if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) {			\
498 		printf("command %p is on another queue, flags = %#x\n",	\
499 		       cm, cm->cm_flags);				\
500 		panic("command is on another queue");			\
501 	}								\
502 	TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link);	\
503 	cm->cm_flags |= AAC_ON_ ## index;				\
504 	AACQ_ADD(cm->cm_sc, index);					\
505 	crit_exit();							\
506 }									\
507 static __inline struct aac_command *					\
508 aac_dequeue_ ## name (struct aac_softc *sc)				\
509 {									\
510 	struct aac_command *cm;						\
511 									\
512 	crit_enter();							\
513 	if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) {		\
514 		if ((cm->cm_flags & AAC_ON_ ## index) == 0) {		\
515 			printf("command %p not in queue, flags = %#x, "	\
516 		       	       "bit = %#x\n", cm, cm->cm_flags,		\
517 			       AAC_ON_ ## index);			\
518 			panic("command not in queue");			\
519 		}							\
520 		TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link);		\
521 		cm->cm_flags &= ~AAC_ON_ ## index;			\
522 		AACQ_REMOVE(sc, index);					\
523 	}								\
524 	crit_exit();							\
525 	return(cm);							\
526 }									\
527 static __inline void							\
528 aac_remove_ ## name (struct aac_command *cm)				\
529 {									\
530 	crit_enter();							\
531 	if ((cm->cm_flags & AAC_ON_ ## index) == 0) {			\
532 		printf("command %p not in queue, flags = %#x, "		\
533 		       "bit = %#x\n", cm, cm->cm_flags, 		\
534 		       AAC_ON_ ## index);				\
535 		panic("command not in queue");				\
536 	}								\
537 	TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link);		\
538 	cm->cm_flags &= ~AAC_ON_ ## index;				\
539 	AACQ_REMOVE(cm->cm_sc, index);					\
540 	crit_exit();							\
541 }									\
542 struct hack
543 
544 AACQ_COMMAND_QUEUE(free, AACQ_FREE);
545 AACQ_COMMAND_QUEUE(ready, AACQ_READY);
546 AACQ_COMMAND_QUEUE(busy, AACQ_BUSY);
547 AACQ_COMMAND_QUEUE(complete, AACQ_COMPLETE);
548 
549 /*
550  * outstanding bio queue
551  */
552 static __inline void
553 aac_initq_bio(struct aac_softc *sc)
554 {
555 	bioq_init(&sc->aac_bioq);
556 	AACQ_INIT(sc, AACQ_BIO);
557 }
558 
559 static __inline void
560 aac_enqueue_bio(struct aac_softc *sc, struct buf *bp)
561 {
562 	crit_enter();
563 	bioq_insert_tail(&sc->aac_bioq, bp);
564 	AACQ_ADD(sc, AACQ_BIO);
565 	crit_exit();
566 }
567 
568 static __inline struct buf *
569 aac_dequeue_bio(struct aac_softc *sc)
570 {
571 	struct buf *bp;
572 
573 	crit_enter();
574 	if ((bp = bioq_first(&sc->aac_bioq)) != NULL) {
575 		bioq_remove(&sc->aac_bioq, bp);
576 		AACQ_REMOVE(sc, AACQ_BIO);
577 	}
578 	crit_exit();
579 	return(bp);
580 }
581 
582 static __inline void
583 aac_print_printf(struct aac_softc *sc)
584 {
585 	/*
586 	 * XXX We have the ability to read the length of the printf string
587 	 * from out of the mailboxes.
588 	 */
589 	device_printf(sc->aac_dev, "**Monitor** %.*s", AAC_PRINTF_BUFSIZE,
590 		      sc->aac_common->ac_printf);
591 	AAC_QNOTIFY(sc, AAC_DB_PRINTF);
592 }
593