xref: /titanic_51/usr/src/uts/common/io/aac/aac.h (revision a6d42e7d71324c5193c3b94d57d96ba2925d52e1)
1 /*
2  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright 2005-06 Adaptec, Inc.
8  * Copyright (c) 2005-06 Adaptec Inc., Achim Leubner
9  * Copyright (c) 2000 Michael Smith
10  * Copyright (c) 2001 Scott Long
11  * Copyright (c) 2000 BSDi
12  * All rights reserved.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *    $FreeBSD: src/sys/dev/aac/aacvar.h,v 1.47 2005/10/08 15:55:09 scottl Exp $
36  */
37 
38 #ifndef	_AAC_H_
39 #define	_AAC_H_
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 #define	AAC_ROUNDUP(x, y)		(((x) + (y) - 1) / (y) * (y))
46 
47 #define	AAC_TYPE_DEVO			1
48 #define	AAC_TYPE_ALPHA			2
49 #define	AAC_TYPE_BETA			3
50 #define	AAC_TYPE_RELEASE		4
51 
52 #ifndef	AAC_DRIVER_BUILD
53 #define	AAC_DRIVER_BUILD		1
54 #endif
55 
56 #define	AAC_DRIVER_MAJOR_VERSION	2
57 #define	AAC_DRIVER_MINOR_VERSION	2
58 #define	AAC_DRIVER_BUGFIX_LEVEL		5
59 #define	AAC_DRIVER_TYPE			AAC_TYPE_RELEASE
60 
61 #define	STR(s)				# s
62 #define	AAC_VERSION(a, b, c)		STR(a.b.c)
63 #define	AAC_DRIVER_VERSION		AAC_VERSION(AAC_DRIVER_MAJOR_VERSION, \
64 					AAC_DRIVER_MINOR_VERSION, \
65 					AAC_DRIVER_BUGFIX_LEVEL)
66 
67 #define	AACOK				0
68 #define	AACERR				-1
69 
70 #define	AAC_MAX_ADAPTERS		64
71 
72 /* Definitions for mode sense */
73 #ifndef	SD_MODE_SENSE_PAGE3_CODE
74 #define	SD_MODE_SENSE_PAGE3_CODE	0x03
75 #endif
76 
77 #ifndef	SD_MODE_SENSE_PAGE4_CODE
78 #define	SD_MODE_SENSE_PAGE4_CODE	0x04
79 #endif
80 
81 #ifndef	SCMD_SYNCHRONIZE_CACHE
82 #define	SCMD_SYNCHRONIZE_CACHE		0x35
83 #endif
84 
85 /*
86  * The controller reports status events in AIFs. We hang on to a number of
87  * these in order to pass them out to user-space management tools.
88  */
89 #define	AAC_AIFQ_LENGTH			64
90 
91 #ifdef __x86
92 #define	AAC_IMMEDIATE_TIMEOUT		30	/* seconds */
93 #else
94 #define	AAC_IMMEDIATE_TIMEOUT		60	/* seconds */
95 #endif
96 #define	AAC_FWUP_TIMEOUT		180	/* wait up to 3 minutes */
97 #define	AAC_IOCTL_TIMEOUT		900	/* wait up to 15 minutes */
98 
99 /* Adapter hardware interface types */
100 #define	AAC_HWIF_UNKNOWN		0
101 #define	AAC_HWIF_I960RX			1
102 #define	AAC_HWIF_RKT			2
103 
104 #define	AAC_TYPE_UNKNOWN		0
105 #define	AAC_TYPE_SCSI			1
106 #define	AAC_TYPE_SATA			2
107 #define	AAC_TYPE_SAS			3
108 
109 #define	AAC_LS32(d)			((uint32_t)((d) & 0xffffffffull))
110 #define	AAC_MS32(d)			((uint32_t)((d) >> 32))
111 #define	AAC_LO32(p64)			((uint32_t *)(p64))
112 #define	AAC_HI32(p64)			((uint32_t *)(p64) + 1)
113 
114 /*
115  * AAC_CMDQ_SYNC should be 0 and AAC_CMDQ_ASYNC be 1 for Sync FIB io
116  * to be served before async FIB io, see aac_start_waiting_io().
117  * So that io requests sent by interactive userland commands get
118  * responded asap.
119  */
120 enum aac_cmdq {
121 	AAC_CMDQ_SYNC,	/* sync FIB queue */
122 	AAC_CMDQ_ASYNC,	/* async FIB queue */
123 	AAC_CMDQ_NUM
124 };
125 
126 /*
127  * IO command flags
128  */
129 #define	AAC_IOCMD_SYNC		(1 << AAC_CMDQ_SYNC)
130 #define	AAC_IOCMD_ASYNC		(1 << AAC_CMDQ_ASYNC)
131 #define	AAC_IOCMD_OUTSTANDING	(1 << AAC_CMDQ_NUM)
132 #define	AAC_IOCMD_ALL		(AAC_IOCMD_SYNC | AAC_IOCMD_ASYNC | \
133 				AAC_IOCMD_OUTSTANDING)
134 
135 struct aac_cmd_queue {
136 	struct aac_cmd *q_head; /* also as the header of aac_cmd */
137 	struct aac_cmd *q_tail;
138 };
139 
140 struct aac_card_type {
141 	uint16_t vendor;	/* PCI Vendor ID */
142 	uint16_t device;	/* PCI Device ID */
143 	uint16_t subvendor;	/* PCI Subsystem Vendor ID */
144 	uint16_t subsys;	/* PCI Subsystem ID */
145 	uint16_t hwif;		/* card chip type: i960 or Rocket */
146 	uint16_t quirks;	/* card odd limits */
147 	uint16_t type;		/* hard drive type */
148 	char *vid;		/* ASCII data for INQUIRY command vendor id */
149 	char *desc;		/* ASCII data for INQUIRY command product id */
150 };
151 
152 /* Device types */
153 #define	AAC_DEV_LD		0	/* logical device */
154 #define	AAC_DEV_PD		1	/* physical device */
155 
156 /* DR events */
157 #define	AAC_EVT_NONE		0
158 #define	AAC_EVT_ONLINE		1
159 #define	AAC_EVT_OFFLINE		2
160 
161 /* Device flags */
162 #define	AAC_DFLAG_VALID		(1 << 0)
163 #define	AAC_DFLAG_CONFIGURING	(1 << 1)
164 
165 #define	AAC_DEV_IS_VALID(dvp)	((dvp)->flags & AAC_DFLAG_VALID)
166 
167 struct aac_device {
168 	int flags;
169 
170 	uint8_t type;
171 	dev_info_t *dip;
172 	int ncmds[AAC_CMDQ_NUM];	/* outstanding cmds of the device */
173 	int throttle[AAC_CMDQ_NUM];	/* hold IO cmds for the device */
174 };
175 
176 /* Array description */
177 struct aac_container {
178 	struct aac_device dev;
179 
180 	uint32_t cid;		/* container id */
181 	uint32_t uid;		/* container uid */
182 	uint64_t size;		/* in block */
183 	uint8_t locked;
184 	uint8_t deleted;
185 	uint8_t reset;		/* container is being reseted */
186 };
187 
188 /* Non-DASD phys. device descrption, eg. CDROM or tape */
189 struct aac_nondasd {
190 	struct aac_device dev;
191 
192 	uint32_t bus;
193 	uint32_t tid;
194 };
195 
196 /*
197  * The firmware can support a lot of outstanding commands. Each aac_slot
198  * is corresponding to one of such commands. It records the command and
199  * associated DMA resource for FIB command.
200  */
201 struct aac_slot {
202 	struct aac_slot *next;	/* next slot in the free slot list */
203 	int index;		/* index of this slot */
204 	ddi_acc_handle_t fib_acc_handle;
205 	ddi_dma_handle_t fib_dma_handle;
206 	uint64_t fib_phyaddr;	/* physical address of FIB memory */
207 	struct aac_cmd *acp;	/* command using this slot */
208 	struct aac_fib *fibp;	/* virtual address of FIB memory */
209 };
210 
211 /* Flags for attach tracking */
212 #define	AAC_ATTACH_SOFTSTATE_ALLOCED	(1 << 0)
213 #define	AAC_ATTACH_CARD_DETECTED	(1 << 1)
214 #define	AAC_ATTACH_PCI_MEM_MAPPED	(1 << 2)
215 #define	AAC_ATTACH_KMUTEX_INITED	(1 << 3)
216 #define	AAC_ATTACH_HARD_INTR_SETUP	(1 << 4)
217 #define	AAC_ATTACH_SOFT_INTR_SETUP	(1 << 5)
218 #define	AAC_ATTACH_SCSI_TRAN_SETUP	(1 << 6)
219 #define	AAC_ATTACH_COMM_SPACE_SETUP	(1 << 7)
220 #define	AAC_ATTACH_CREATE_DEVCTL	(1 << 8)
221 #define	AAC_ATTACH_CREATE_SCSI		(1 << 9)
222 
223 /* Driver running states */
224 #define	AAC_STATE_STOPPED	0
225 #define	AAC_STATE_RUN		(1 << 0)
226 #define	AAC_STATE_RESET		(1 << 1)
227 #define	AAC_STATE_QUIESCED	(1 << 2)
228 #define	AAC_STATE_DEAD		(1 << 3)
229 
230 /*
231  * Flags for aac firmware
232  * Note: Quirks are only valid for the older cards. These cards only supported
233  * old comm. Thus they are not valid for any cards that support new comm.
234  */
235 #define	AAC_FLAGS_SG_64BIT	(1 << 0) /* Use 64-bit S/G addresses */
236 #define	AAC_FLAGS_4GB_WINDOW	(1 << 1) /* Can access host mem 2-4GB range */
237 #define	AAC_FLAGS_NO4GB	(1 << 2)	/* quirk: FIB addresses must reside */
238 					/*	  between 0x2000 & 0x7FFFFFFF */
239 #define	AAC_FLAGS_256FIBS	(1 << 3) /* quirk: Can only do 256 commands */
240 #define	AAC_FLAGS_NEW_COMM	(1 << 4) /* New comm. interface supported */
241 #define	AAC_FLAGS_RAW_IO	(1 << 5) /* Raw I/O interface */
242 #define	AAC_FLAGS_ARRAY_64BIT	(1 << 6) /* 64-bit array size */
243 #define	AAC_FLAGS_LBA_64BIT	(1 << 7) /* 64-bit LBA supported */
244 #define	AAC_FLAGS_17SG		(1 << 8) /* quirk: 17 scatter gather maximum */
245 #define	AAC_FLAGS_34SG		(1 << 9) /* quirk: 34 scatter gather maximum */
246 #define	AAC_FLAGS_NONDASD	(1 << 10) /* non-DASD device supported */
247 
248 struct aac_softstate;
249 struct aac_interface {
250 	int (*aif_get_fwstatus)(struct aac_softstate *);
251 	int (*aif_get_mailbox)(struct aac_softstate *, int);
252 	void (*aif_set_mailbox)(struct aac_softstate *, uint32_t,
253 	    uint32_t, uint32_t, uint32_t, uint32_t);
254 };
255 
256 struct aac_fib_context {
257 	uint32_t unique;
258 	int ctx_idx;
259 	int ctx_filled;		/* aifq is full for this fib context */
260 	struct aac_fib_context *next, *prev;
261 };
262 
263 typedef void (*aac_cmd_fib_t)(struct aac_softstate *, struct aac_cmd *);
264 
265 #define	AAC_VENDOR_LEN		8
266 #define	AAC_PRODUCT_LEN		16
267 
268 struct aac_softstate {
269 	int card;		/* index to aac_cards */
270 	uint16_t hwif;		/* card chip type: i960 or Rocket */
271 	uint16_t vendid;	/* vendor id */
272 	uint16_t subvendid;	/* sub vendor id */
273 	uint16_t devid;		/* device id */
274 	uint16_t subsysid;	/* sub system id */
275 	char vendor_name[AAC_VENDOR_LEN + 1];
276 	char product_name[AAC_PRODUCT_LEN + 1];
277 	uint32_t support_opt;	/* firmware features */
278 	uint32_t atu_size;	/* actual size of PCI mem space */
279 	uint32_t map_size;	/* mapped PCI mem space size */
280 	uint32_t map_size_min;	/* minimum size of PCI mem that must be */
281 				/* mapped to address the card */
282 	int flags;		/* firmware features enabled */
283 	int instance;
284 	dev_info_t *devinfo_p;
285 	scsi_hba_tran_t *hba_tran;
286 	int slen;
287 	int legacy;		/* legacy device naming */
288 
289 	/* DMA attributes */
290 	ddi_dma_attr_t buf_dma_attr;
291 	ddi_dma_attr_t addr_dma_attr;
292 
293 	/* PCI spaces */
294 	ddi_device_acc_attr_t acc_attr;
295 	ddi_acc_handle_t pci_mem_handle;
296 	uint8_t *pci_mem_base_vaddr;
297 	uint32_t pci_mem_base_paddr;
298 
299 	struct aac_interface aac_if;	/* adapter hardware interface */
300 
301 	struct aac_slot sync_slot;	/* sync FIB */
302 
303 	/* Communication space */
304 	struct aac_comm_space *comm_space;
305 	ddi_acc_handle_t comm_space_acc_handle;
306 	ddi_dma_handle_t comm_space_dma_handle;
307 	uint32_t comm_space_phyaddr;
308 
309 	/* Old Comm. interface: message queues */
310 	struct aac_queue_table *qtablep;
311 	struct aac_queue_entry *qentries[AAC_QUEUE_COUNT];
312 
313 	/* New Comm. interface */
314 	uint32_t aac_max_fibs;		/* max. FIB count */
315 	uint32_t aac_max_fib_size;	/* max. FIB size */
316 	uint32_t aac_sg_tablesize;	/* max. sg count from host */
317 	uint32_t aac_max_sectors;	/* max. I/O size from host (blocks) */
318 
319 	aac_cmd_fib_t aac_cmd_fib;	/* IO cmd FIB construct function */
320 	aac_cmd_fib_t aac_cmd_fib_scsi;	/* SRB construct function */
321 
322 	ddi_softintr_t softint_id;	/* soft intr */
323 
324 	kmutex_t io_lock;
325 	int state;			/* driver state */
326 
327 	struct aac_container containers[AAC_MAX_LD];
328 	int container_count;		/* max container id + 1 */
329 	struct aac_nondasd *nondasds;
330 	uint32_t bus_max;		/* max FW buses exposed */
331 	uint32_t tgt_max;		/* max FW target per bus */
332 
333 	/*
334 	 * Command queues
335 	 * Each aac command flows through wait(or wait_sync) queue,
336 	 * busy queue, and complete queue sequentially.
337 	 */
338 	struct aac_cmd_queue q_wait[AAC_CMDQ_NUM];
339 	struct aac_cmd_queue q_busy;	/* outstanding cmd queue */
340 	kmutex_t q_comp_mutex;
341 	struct aac_cmd_queue q_comp;	/* completed io requests */
342 
343 	/* I/O slots and FIBs */
344 	int total_slots;		/* total slots allocated */
345 	int total_fibs;			/* total FIBs allocated */
346 	struct aac_slot *io_slot;	/* static list for allocated slots */
347 	struct aac_slot *free_io_slot_head;
348 
349 	timeout_id_t timeout_id;	/* for timeout daemon */
350 
351 	kcondvar_t event;		/* for ioctl_send_fib() and sync IO */
352 
353 	int bus_ncmds[AAC_CMDQ_NUM];	/* total outstanding async cmds */
354 	int bus_throttle[AAC_CMDQ_NUM];	/* hold IO cmds for the bus */
355 	int ndrains;			/* number of draining threads */
356 	timeout_id_t drain_timeid;	/* for outstanding cmd drain */
357 	kcondvar_t drain_cv;		/* for quiesce drain */
358 
359 	/* AIF */
360 	kmutex_t aifq_mutex;		/* for AIF queue aifq */
361 	kcondvar_t aifv;
362 	union aac_fib_align aifq[AAC_AIFQ_LENGTH];
363 	int aifq_idx;			/* slot for next new AIF */
364 	int aifq_wrap;			/* AIF queue has ever been wrapped */
365 	struct aac_fib_context *fibctx;
366 	int devcfg_wait_on;		/* AIF event waited for rescan */
367 
368 	int fm_capabilities;
369 	ddi_taskq_t *taskq;
370 
371 	/* MSI specific fields */
372 	ddi_intr_handle_t *htable;	/* For array of interrupts */
373 	int intr_type;			/* What type of interrupt */
374 	int intr_cnt;			/* # of intrs count returned */
375 	uint_t intr_pri;		/* Interrupt priority   */
376 	int intr_cap;			/* Interrupt capabilities */
377 
378 #ifdef DEBUG
379 	/* UART trace printf variables */
380 	uint32_t debug_flags;		/* debug print flags bitmap */
381 	uint32_t debug_fib_flags;	/* debug FIB print flags bitmap */
382 	uint32_t debug_fw_flags;	/* FW debug flags */
383 	uint32_t debug_buf_offset;	/* offset from DPMEM start */
384 	uint32_t debug_buf_size;	/* FW debug buffer size in bytes */
385 	uint32_t debug_header_size;	/* size of debug header */
386 #endif
387 };
388 
389 /*
390  * The following data are kept stable because they are only written at driver
391  * initialization, and we do not allow them changed otherwise even at driver
392  * re-initialization.
393  */
394 _NOTE(SCHEME_PROTECTS_DATA("stable data", aac_softstate::{flags slen \
395     buf_dma_attr pci_mem_handle pci_mem_base_vaddr \
396     comm_space_acc_handle comm_space_dma_handle aac_max_fib_size \
397     aac_sg_tablesize aac_cmd_fib aac_cmd_fib_scsi debug_flags bus_max tgt_max}))
398 
399 /*
400  * Scatter-gather list structure defined by HBA hardware
401  */
402 struct aac_sge {
403 	uint32_t bcount;	/* byte count */
404 	union {
405 		uint32_t ad32;	/* 32 bit address */
406 		struct {
407 			uint32_t lo;
408 			uint32_t hi;
409 		} ad64;		/* 64 bit address */
410 	} addr;
411 };
412 
413 /* aac_cmd flags */
414 #define	AAC_CMD_CONSISTENT		(1 << 0)
415 #define	AAC_CMD_DMA_PARTIAL		(1 << 1)
416 #define	AAC_CMD_DMA_VALID		(1 << 2)
417 #define	AAC_CMD_BUF_READ		(1 << 3)
418 #define	AAC_CMD_BUF_WRITE		(1 << 4)
419 #define	AAC_CMD_SYNC			(1 << 5) /* use sync FIB */
420 #define	AAC_CMD_NO_INTR			(1 << 6) /* poll IO, no intr */
421 #define	AAC_CMD_NO_CB			(1 << 7) /* sync IO, no callback */
422 #define	AAC_CMD_NTAG			(1 << 8)
423 #define	AAC_CMD_CMPLT			(1 << 9) /* cmd exec'ed by driver/fw */
424 #define	AAC_CMD_ABORT			(1 << 10)
425 #define	AAC_CMD_TIMEOUT			(1 << 11)
426 #define	AAC_CMD_ERR			(1 << 12)
427 
428 struct aac_cmd {
429 	/*
430 	 * Note: should be the first member for aac_cmd_queue to work
431 	 * correctly.
432 	 */
433 	struct aac_cmd *next;
434 	struct aac_cmd *prev;
435 
436 	struct scsi_pkt *pkt;
437 	int cmdlen;
438 	int flags;
439 	uint32_t timeout; /* time when the cmd should have completed */
440 	struct buf *bp;
441 	ddi_dma_handle_t buf_dma_handle;
442 
443 	/* For non-aligned buffer and SRB */
444 	caddr_t abp;
445 	ddi_acc_handle_t abh;
446 
447 	/* Data transfer state */
448 	ddi_dma_cookie_t cookie;
449 	uint_t left_cookien;
450 	uint_t cur_win;
451 	uint_t total_nwin;
452 	size_t total_xfer;
453 	uint64_t blkno;
454 	uint32_t bcount;	/* buffer size in byte */
455 	struct aac_sge *sgt;	/* sg table */
456 
457 	/* FIB construct function */
458 	aac_cmd_fib_t aac_cmd_fib;
459 	/* Call back function for completed command */
460 	void (*ac_comp)(struct aac_softstate *, struct aac_cmd *);
461 
462 	struct aac_slot *slotp;	/* slot used by this command */
463 	struct aac_device *dvp;	/* target device */
464 
465 	/* FIB for this IO command */
466 	int fib_size; /* size of the FIB xferred to/from the card */
467 	struct aac_fib *fibp;
468 
469 #ifdef DEBUG
470 	uint32_t fib_flags;
471 #endif
472 };
473 
474 #ifdef DEBUG
475 
476 #define	AACDB_FLAGS_MASK		0x0000ffff
477 #define	AACDB_FLAGS_KERNEL_PRINT	0x00000001
478 #define	AACDB_FLAGS_FW_PRINT		0x00000002
479 #define	AACDB_FLAGS_NO_HEADERS		0x00000004
480 
481 #define	AACDB_FLAGS_MISC		0x00000010
482 #define	AACDB_FLAGS_FUNC1		0x00000020
483 #define	AACDB_FLAGS_FUNC2		0x00000040
484 #define	AACDB_FLAGS_SCMD		0x00000080
485 #define	AACDB_FLAGS_AIF			0x00000100
486 #define	AACDB_FLAGS_FIB			0x00000200
487 #define	AACDB_FLAGS_IOCTL		0x00000400
488 
489 /*
490  * Flags for FIB print
491  */
492 /* FIB sources */
493 #define	AACDB_FLAGS_FIB_SCMD		0x00000001
494 #define	AACDB_FLAGS_FIB_IOCTL		0x00000002
495 #define	AACDB_FLAGS_FIB_SRB		0x00000004
496 #define	AACDB_FLAGS_FIB_SYNC		0x00000008
497 /* FIB components */
498 #define	AACDB_FLAGS_FIB_HEADER		0x00000010
499 /* FIB states */
500 #define	AACDB_FLAGS_FIB_TIMEOUT		0x00000100
501 
502 extern uint32_t aac_debug_flags;
503 extern int aac_dbflag_on(struct aac_softstate *, int);
504 extern void aac_printf(struct aac_softstate *, uint_t, const char *, ...);
505 extern void aac_print_fib(struct aac_softstate *, struct aac_slot *);
506 
507 #define	AACDB_PRINT(s, lev, ...) { \
508 	if (aac_dbflag_on((s), AACDB_FLAGS_MISC)) \
509 		aac_printf((s), (lev), __VA_ARGS__); }
510 
511 #define	AACDB_PRINT_IOCTL(s, ...) { \
512 	if (aac_dbflag_on((s), AACDB_FLAGS_IOCTL)) \
513 		aac_printf((s), CE_NOTE, __VA_ARGS__); }
514 
515 #define	AACDB_PRINT_TRAN(s, ...) { \
516 	if (aac_dbflag_on((s), AACDB_FLAGS_SCMD)) \
517 		aac_printf((s), CE_NOTE, __VA_ARGS__); }
518 
519 #define	DBCALLED(s, n) { \
520 	if (aac_dbflag_on((s), AACDB_FLAGS_FUNC ## n)) \
521 		aac_printf((s), CE_NOTE, "--- %s() called ---", __func__); }
522 
523 #define	AACDB_PRINT_SCMD(s, x) { \
524 	if (aac_dbflag_on((s), AACDB_FLAGS_SCMD)) aac_print_scmd((s), (x)); }
525 
526 #define	AACDB_PRINT_AIF(s, x) { \
527 	if (aac_dbflag_on((s), AACDB_FLAGS_AIF)) aac_print_aif((s), (x)); }
528 
529 #define	AACDB_PRINT_FIB(s, x) { \
530 	if (aac_dbflag_on((s), AACDB_FLAGS_FIB)) aac_print_fib((s), (x)); }
531 
532 #else /* DEBUG */
533 
534 #define	AACDB_PRINT(s, lev, ...)
535 #define	AACDB_PRINT_IOCTL(s, ...)
536 #define	AACDB_PRINT_TRAN(s, ...)
537 #define	AACDB_PRINT_FIB(s, x)
538 #define	AACDB_PRINT_SCMD(s, x)
539 #define	AACDB_PRINT_AIF(s, x)
540 #define	DBCALLED(s, n)
541 
542 #endif /* DEBUG */
543 
544 #ifdef	__cplusplus
545 }
546 #endif
547 
548 #endif /* _AAC_H_ */
549