aacvar.h (82527) | aacvar.h (83114) |
---|---|
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 --- 12 unchanged lines hidden (view full) --- 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 * | 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 --- 12 unchanged lines hidden (view full) --- 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: head/sys/dev/aac/aacvar.h 82527 2001-08-29 23:34:05Z scottl $ | 29 * $FreeBSD: head/sys/dev/aac/aacvar.h 83114 2001-09-05 20:43:02Z scottl $ |
30 */ 31 | 30 */ 31 |
32/****************************************************************************** 33 ****************************************************************************** 34 Driver Parameter Definitions 35 ****************************************************************************** 36 ******************************************************************************/ | 32/* 33 * Driver Parameter Definitions 34 */ |
37 38/* 39 * The firmware interface allows for a 16-bit s/g list length. We limit 40 * ourselves to a reasonable maximum and ensure alignment. 41 */ 42#define AAC_MAXSGENTRIES 64 /* max S/G entries, limit 65535 */ 43 44/* --- 42 unchanged lines hidden (view full) --- 87 */ 88#define AAC_PERIODIC_INTERVAL 20 /* seconds */ 89 90/* 91 * Character device major numbers. 92 */ 93#define AAC_DISK_MAJOR 200 94 | 35 36/* 37 * The firmware interface allows for a 16-bit s/g list length. We limit 38 * ourselves to a reasonable maximum and ensure alignment. 39 */ 40#define AAC_MAXSGENTRIES 64 /* max S/G entries, limit 65535 */ 41 42/* --- 42 unchanged lines hidden (view full) --- 85 */ 86#define AAC_PERIODIC_INTERVAL 20 /* seconds */ 87 88/* 89 * Character device major numbers. 90 */ 91#define AAC_DISK_MAJOR 200 92 |
95/****************************************************************************** 96 ****************************************************************************** 97 Driver Variable Definitions 98 ****************************************************************************** 99 ******************************************************************************/ | 93/* 94 * Driver Variable Definitions 95 */ |
100 101#if __FreeBSD_version >= 500005 102# include <sys/taskqueue.h> 103#endif 104 105/* 106 * Per-container data structure 107 */ 108struct aac_container 109{ | 96 97#if __FreeBSD_version >= 500005 98# include <sys/taskqueue.h> 99#endif 100 101/* 102 * Per-container data structure 103 */ 104struct aac_container 105{ |
110 struct aac_mntobj co_mntobj; 111 device_t co_disk; 112 int co_found; 113 TAILQ_ENTRY(aac_container) co_link; | 106 struct aac_mntobj co_mntobj; 107 device_t co_disk; 108 int co_found; 109 TAILQ_ENTRY(aac_container) co_link; |
114}; 115 116/* 117 * Per-disk structure 118 */ 119struct aac_disk 120{ | 110}; 111 112/* 113 * Per-disk structure 114 */ 115struct aac_disk 116{ |
121 device_t ad_dev; 122 dev_t ad_dev_t; 123 struct aac_softc *ad_controller; 124 struct aac_container *ad_container; 125 struct disk ad_disk; 126 struct devstat ad_stats; 127 struct disklabel ad_label; 128 int ad_flags; | 117 device_t ad_dev; 118 dev_t ad_dev_t; 119 struct aac_softc *ad_controller; 120 struct aac_container *ad_container; 121 struct disk ad_disk; 122 struct devstat ad_stats; 123 struct disklabel ad_label; 124 int ad_flags; |
129#define AAC_DISK_OPEN (1<<0) | 125#define AAC_DISK_OPEN (1<<0) |
130 int ad_cylinders; 131 int ad_heads; 132 int ad_sectors; 133 u_int32_t ad_size; 134 int unit; | 126 int ad_cylinders; 127 int ad_heads; 128 int ad_sectors; 129 u_int32_t ad_size; 130 int unit; |
135}; 136 137/* 138 * Per-command control structure. 139 */ 140struct aac_command 141{ | 131}; 132 133/* 134 * Per-command control structure. 135 */ 136struct aac_command 137{ |
142 TAILQ_ENTRY(aac_command) cm_link; /* list linkage */ | 138 TAILQ_ENTRY(aac_command) cm_link; /* list linkage */ |
143 | 139 |
144 struct aac_softc *cm_sc; /* controller that owns us */ | 140 struct aac_softc *cm_sc; /* controller that owns us */ |
145 | 141 |
146 struct aac_fib *cm_fib; /* FIB associated with this | 142 struct aac_fib *cm_fib; /* FIB associated with this |
147 * command */ | 143 * command */ |
148 u_int32_t cm_fibphys; /* bus address of the FIB */ 149 struct bio *cm_data; /* pointer to data in kernel | 144 u_int32_t cm_fibphys; /* bus address of the FIB */ 145 struct bio *cm_data; /* pointer to data in kernel |
150 * space */ | 146 * space */ |
151 u_int32_t cm_datalen; /* data length */ 152 bus_dmamap_t cm_datamap; /* DMA map for bio data */ 153 struct aac_sg_table *cm_sgtable; /* pointer to s/g table in | 147 u_int32_t cm_datalen; /* data length */ 148 bus_dmamap_t cm_datamap; /* DMA map for bio data */ 149 struct aac_sg_table *cm_sgtable; /* pointer to s/g table in |
154 * command */ | 150 * command */ |
155 156 int cm_flags; | 151 int cm_flags; |
157#define AAC_CMD_MAPPED (1<<0) /* command has had its data 158 * mapped */ 159#define AAC_CMD_DATAIN (1<<1) /* command involves data moving 160 * from controller to host */ 161#define AAC_CMD_DATAOUT (1<<2) /* command involves data moving 162 * from host to controller */ 163#define AAC_CMD_COMPLETED (1<<3) /* command has been completed */ 164#define AAC_CMD_TIMEDOUT (1<<4) /* command taken too long */ 165#define AAC_ON_AACQ_FREE (1<<5) 166#define AAC_ON_AACQ_READY (1<<6) 167#define AAC_ON_AACQ_BUSY (1<<7) 168#define AAC_ON_AACQ_COMPLETE (1<<8) 169#define AAC_ON_AACQ_MASK ((1<<5)|(1<<6)|(1<<7)|(1<<8)) 170 | 152#define AAC_CMD_MAPPED (1<<0) /* command has had its data 153 * mapped */ 154#define AAC_CMD_DATAIN (1<<1) /* command involves data moving 155 * from controller to host */ 156#define AAC_CMD_DATAOUT (1<<2) /* command involves data moving 157 * from host to controller */ 158#define AAC_CMD_COMPLETED (1<<3) /* command has been completed */ 159#define AAC_CMD_TIMEDOUT (1<<4) /* command taken too long */ 160#define AAC_ON_AACQ_FREE (1<<5) 161#define AAC_ON_AACQ_READY (1<<6) 162#define AAC_ON_AACQ_BUSY (1<<7) 163#define AAC_ON_AACQ_COMPLETE (1<<8) 164#define AAC_ON_AACQ_MASK ((1<<5)|(1<<6)|(1<<7)|(1<<8)) 165 |
171 void (* cm_complete)(struct aac_command *cm); 172 void *cm_private; 173 time_t cm_timestamp; /* command creation time */ 174 int cm_queue; | 166 void (* cm_complete)(struct aac_command *cm); 167 void *cm_private; 168 time_t cm_timestamp; /* command creation time */ 169 int cm_queue; |
175}; 176 177/* 178 * We gather a number of adapter-visible items into a single structure. 179 * 180 * The ordering of this strucure may be important; we copy the Linux driver: 181 * 182 * Adapter FIBs 183 * Init struct 184 * Queue headers (Comm Area) 185 * Printf buffer 186 * 187 * In addition, we add: 188 * Sync Fib 189 */ 190struct aac_common { | 170}; 171 172/* 173 * We gather a number of adapter-visible items into a single structure. 174 * 175 * The ordering of this strucure may be important; we copy the Linux driver: 176 * 177 * Adapter FIBs 178 * Init struct 179 * Queue headers (Comm Area) 180 * Printf buffer 181 * 182 * In addition, we add: 183 * Sync Fib 184 */ 185struct aac_common { |
191 /* fibs for the controller to send us messages */ 192 struct aac_fib ac_fibs[AAC_ADAPTER_FIBS]; | 186 /* fibs for the controller to send us messages */ 187 struct aac_fib ac_fibs[AAC_ADAPTER_FIBS]; |
193 | 188 |
194 /* the init structure */ 195 struct aac_adapter_init ac_init; | 189 /* the init structure */ 190 struct aac_adapter_init ac_init; |
196 | 191 |
197 /* arena within which the queue structures are kept */ 198 u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + 199 AAC_QUEUE_ALIGN]; | 192 /* arena within which the queue structures are kept */ 193 u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + 194 AAC_QUEUE_ALIGN]; |
200 | 195 |
201 /* buffer for text messages from the controller */ 202 char ac_printf[AAC_PRINTF_BUFSIZE]; 203 204 /* fib for synchronous commands */ 205 struct aac_fib ac_sync_fib; | 196 /* buffer for text messages from the controller */ 197 char ac_printf[AAC_PRINTF_BUFSIZE]; 198 199 /* fib for synchronous commands */ 200 struct aac_fib ac_sync_fib; |
206}; 207 208/* 209 * Interface operations 210 */ 211struct aac_interface 212{ | 201}; 202 203/* 204 * Interface operations 205 */ 206struct aac_interface 207{ |
213 int (* aif_get_fwstatus)(struct aac_softc *sc); 214 void (* aif_qnotify)(struct aac_softc *sc, int qbit); 215 int (* aif_get_istatus)(struct aac_softc *sc); 216 void (* aif_set_istatus)(struct aac_softc *sc, int mask); 217 void (* aif_set_mailbox)(struct aac_softc *sc, u_int32_t command, 218 u_int32_t arg0, u_int32_t arg1, 219 u_int32_t arg2, u_int32_t arg3); 220 int (* aif_get_mailboxstatus)(struct aac_softc *sc); 221 void (* aif_set_interrupts)(struct aac_softc *sc, int enable); | 208 int (*aif_get_fwstatus)(struct aac_softc *sc); 209 void (*aif_qnotify)(struct aac_softc *sc, int qbit); 210 int (*aif_get_istatus)(struct aac_softc *sc); 211 void (*aif_set_istatus)(struct aac_softc *sc, int mask); 212 void (*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command, 213 u_int32_t arg0, u_int32_t arg1, 214 u_int32_t arg2, u_int32_t arg3); 215 int (*aif_get_mailboxstatus)(struct aac_softc *sc); 216 void (*aif_set_interrupts)(struct aac_softc *sc, int enable); |
222}; 223extern struct aac_interface aac_rx_interface; 224extern struct aac_interface aac_sa_interface; 225 226#define AAC_GET_FWSTATUS(sc) ((sc)->aac_if.aif_get_fwstatus((sc))) 227#define AAC_QNOTIFY(sc, qbit) ((sc)->aac_if.aif_qnotify((sc), (qbit))) 228#define AAC_GET_ISTATUS(sc) ((sc)->aac_if.aif_get_istatus((sc))) 229#define AAC_CLEAR_ISTATUS(sc, mask) ((sc)->aac_if.aif_set_istatus((sc), \ 230 (mask))) 231#define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \ 232 ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \ 233 (arg3))) | 217}; 218extern struct aac_interface aac_rx_interface; 219extern struct aac_interface aac_sa_interface; 220 221#define AAC_GET_FWSTATUS(sc) ((sc)->aac_if.aif_get_fwstatus((sc))) 222#define AAC_QNOTIFY(sc, qbit) ((sc)->aac_if.aif_qnotify((sc), (qbit))) 223#define AAC_GET_ISTATUS(sc) ((sc)->aac_if.aif_get_istatus((sc))) 224#define AAC_CLEAR_ISTATUS(sc, mask) ((sc)->aac_if.aif_set_istatus((sc), \ 225 (mask))) 226#define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \ 227 ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \ 228 (arg3))) |
234#define AAC_GET_MAILBOXSTATUS(sc) ((sc)->aac_if.aif_get_mailboxstatus((sc))) 235#define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), 0)) 236#define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), 1)) | 229#define AAC_GET_MAILBOXSTATUS(sc) ((sc)->aac_if.aif_get_mailboxstatus( \ 230 (sc))) 231#define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ 232 0)) 233#define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ 234 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, \ --- 20 unchanged lines hidden (view full) --- 265#define AAC_LOCK_RELEASE(l) simple_unlock(l) 266#endif 267 268/* 269 * Per-controller structure. 270 */ 271struct aac_softc 272{ | 235 236#define AAC_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag, \ 237 sc->aac_bhandle, reg, val) 238#define AAC_GETREG4(sc, reg) bus_space_read_4 (sc->aac_btag, \ 239 sc->aac_bhandle, reg) 240#define AAC_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag, \ 241 sc->aac_bhandle, reg, val) 242#define AAC_GETREG2(sc, reg) bus_space_read_2 (sc->aac_btag, \ --- 20 unchanged lines hidden (view full) --- 263#define AAC_LOCK_RELEASE(l) simple_unlock(l) 264#endif 265 266/* 267 * Per-controller structure. 268 */ 269struct aac_softc 270{ |
273 /* bus connections */ 274 device_t aac_dev; 275 struct resource *aac_regs_resource; /* register interface | 271 /* bus connections */ 272 device_t aac_dev; 273 struct resource *aac_regs_resource; /* register interface |
276 * window */ | 274 * window */ |
277 int aac_regs_rid; /* resource ID */ 278 bus_space_handle_t aac_bhandle; /* bus space handle */ 279 bus_space_tag_t aac_btag; /* bus space tag */ 280 bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */ 281 bus_dma_tag_t aac_buffer_dmat; /* data buffer/command | 275 int aac_regs_rid; /* resource ID */ 276 bus_space_handle_t aac_bhandle; /* bus space handle */ 277 bus_space_tag_t aac_btag; /* bus space tag */ 278 bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */ 279 bus_dma_tag_t aac_buffer_dmat; /* data buffer/command |
282 * DMA tag */ | 280 * DMA tag */ |
283 struct resource *aac_irq; /* interrupt */ 284 int aac_irq_rid; 285 void *aac_intr; /* interrupt handle */ | 281 struct resource *aac_irq; /* interrupt */ 282 int aac_irq_rid; 283 void *aac_intr; /* interrupt handle */ |
286 | 284 |
287 /* controller features, limits and status */ 288 int aac_state; | 285 /* controller features, limits and status */ 286 int aac_state; |
289#define AAC_STATE_SUSPEND (1<<0) 290#define AAC_STATE_OPEN (1<<1) 291#define AAC_STATE_INTERRUPTS_ON (1<<2) 292#define AAC_STATE_AIF_SLEEPER (1<<3) | 287#define AAC_STATE_SUSPEND (1<<0) 288#define AAC_STATE_OPEN (1<<1) 289#define AAC_STATE_INTERRUPTS_ON (1<<2) 290#define AAC_STATE_AIF_SLEEPER (1<<3) |
293 struct FsaRevision aac_revision; | 291 struct FsaRevision aac_revision; |
294 | 292 |
295 /* controller hardware interface */ 296 int aac_hwif; | 293 /* controller hardware interface */ 294 int aac_hwif; |
297#define AAC_HWIF_I960RX 0 298#define AAC_HWIF_STRONGARM 1 299#define AAC_HWIF_UNKNOWN -1 | 295#define AAC_HWIF_I960RX 0 296#define AAC_HWIF_STRONGARM 1 297#define AAC_HWIF_UNKNOWN -1 |
300 bus_dma_tag_t aac_common_dmat; /* common structure | 298 bus_dma_tag_t aac_common_dmat; /* common structure |
301 * DMA tag */ | 299 * DMA tag */ |
302 bus_dmamap_t aac_common_dmamap; /* common structure | 300 bus_dmamap_t aac_common_dmamap; /* common structure |
303 * DMA map */ | 301 * DMA map */ |
304 struct aac_common *aac_common; 305 u_int32_t aac_common_busaddr; 306 struct aac_interface aac_if; | 302 struct aac_common *aac_common; 303 u_int32_t aac_common_busaddr; 304 struct aac_interface aac_if; |
307 | 305 |
308 /* command/fib resources */ 309 bus_dma_tag_t aac_fib_dmat; /* DMA tag for allocing FIBs */ 310 struct aac_fib *aac_fibs; 311 bus_dmamap_t aac_fibmap; 312 u_int32_t aac_fibphys; 313 struct aac_command aac_command[AAC_FIB_COUNT]; | 306 /* command/fib resources */ 307 bus_dma_tag_t aac_fib_dmat; /* DMA tag for allocing FIBs */ 308 struct aac_fib *aac_fibs; 309 bus_dmamap_t aac_fibmap; 310 u_int32_t aac_fibphys; 311 struct aac_command aac_command[AAC_FIB_COUNT]; |
314 | 312 |
315 /* command management */ 316 TAILQ_HEAD(,aac_command) aac_free; /* command structures | 313 /* command management */ 314 TAILQ_HEAD(,aac_command) aac_free; /* command structures |
317 * available for reuse */ | 315 * available for reuse */ |
318 TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for | 316 TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for |
319 * controller resources */ | 317 * controller resources */ |
320 TAILQ_HEAD(,aac_command) aac_busy; 321 TAILQ_HEAD(,aac_command) aac_complete; /* commands which have been | 318 TAILQ_HEAD(,aac_command) aac_busy; 319 TAILQ_HEAD(,aac_command) aac_complete; /* commands which have been |
322 * returned by the controller */ | 320 * returned by the controller */ |
323 struct bio_queue_head aac_bioq; 324 struct aac_queue_table *aac_queues; 325 struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT]; | 321 struct bio_queue_head aac_bioq; 322 struct aac_queue_table *aac_queues; 323 struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT]; |
326 | 324 |
327 struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */ | 325 struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */ |
328 | 326 |
329 /* connected containters */ 330 struct aac_container_tq aac_container_tqh; 331 aac_lock_t aac_container_lock; | 327 /* connected containters */ 328 struct aac_container_tq aac_container_tqh; 329 aac_lock_t aac_container_lock; |
332 | 330 |
333 /* delayed activity infrastructure */ | 331 /* delayed activity infrastructure */ |
334#if __FreeBSD_version >= 500005 | 332#if __FreeBSD_version >= 500005 |
335 struct task aac_task_complete; /* deferred-completion | 333 struct task aac_task_complete; /* deferred-completion |
336 * task */ 337#endif | 334 * task */ 335#endif |
338 struct intr_config_hook aac_ich; | 336 struct intr_config_hook aac_ich; |
339 | 337 |
340 /* management interface */ 341 dev_t aac_dev_t; 342 struct aac_aif_command aac_aifq[AAC_AIFQ_LENGTH]; 343 int aac_aifq_head; 344 int aac_aifq_tail; 345 struct proc *aifthread; 346 int aifflags; | 338 /* management interface */ 339 dev_t aac_dev_t; 340 struct aac_aif_command aac_aifq[AAC_AIFQ_LENGTH]; 341 int aac_aifq_head; 342 int aac_aifq_tail; 343 struct proc *aifthread; 344 int aifflags; |
347#define AAC_AIFFLAGS_RUNNING (1 << 0) 348#define AAC_AIFFLAGS_PENDING (1 << 1) 349#define AAC_AIFFLAGS_EXIT (1 << 2) 350#define AAC_AIFFLAGS_EXITED (1 << 3) 351}; 352 353 354/* --- 16 unchanged lines hidden (view full) --- 371/* 372 * Debugging levels: 373 * 0 - quiet, only emit warnings 374 * 1 - noisy, emit major function points and things done 375 * 2 - extremely noisy, emit trace items in loops, etc. 376 */ 377#ifdef AAC_DEBUG 378# define debug(level, fmt, args...) \ | 345#define AAC_AIFFLAGS_RUNNING (1 << 0) 346#define AAC_AIFFLAGS_PENDING (1 << 1) 347#define AAC_AIFFLAGS_EXIT (1 << 2) 348#define AAC_AIFFLAGS_EXITED (1 << 3) 349}; 350 351 352/* --- 16 unchanged lines hidden (view full) --- 369/* 370 * Debugging levels: 371 * 0 - quiet, only emit warnings 372 * 1 - noisy, emit major function points and things done 373 * 2 - extremely noisy, emit trace items in loops, etc. 374 */ 375#ifdef AAC_DEBUG 376# define debug(level, fmt, args...) \ |
379 do { \ | 377 do { \ |
380 if (level <=AAC_DEBUG) printf("%s: " fmt "\n", __FUNCTION__ , ##args); \ | 378 if (level <=AAC_DEBUG) printf("%s: " fmt "\n", __FUNCTION__ , ##args); \ |
381 } while(0) | 379 } while (0) |
382# define debug_called(level) \ | 380# define debug_called(level) \ |
383 do { \ | 381 do { \ |
384 if (level <= AAC_DEBUG) printf(__FUNCTION__ ": called\n"); \ | 382 if (level <= AAC_DEBUG) printf(__FUNCTION__ ": called\n"); \ |
385 } while(0) | 383 } while (0) |
386 387extern void aac_print_queues(struct aac_softc *sc); 388extern void aac_panic(struct aac_softc *sc, char *reason); 389extern void aac_print_fib(struct aac_softc *sc, struct aac_fib *fib, 390 char *caller); 391extern void aac_print_aif(struct aac_softc *sc, 392 struct aac_aif_command *aif); 393 --- 6 unchanged lines hidden (view full) --- 400# define aac_print_queues(sc) 401# define aac_panic(sc, reason) 402 403# define AAC_PRINT_FIB(sc, fib) 404# define aac_print_aif(sc, aac_aif_command) 405#endif 406 407struct aac_code_lookup { | 384 385extern void aac_print_queues(struct aac_softc *sc); 386extern void aac_panic(struct aac_softc *sc, char *reason); 387extern void aac_print_fib(struct aac_softc *sc, struct aac_fib *fib, 388 char *caller); 389extern void aac_print_aif(struct aac_softc *sc, 390 struct aac_aif_command *aif); 391 --- 6 unchanged lines hidden (view full) --- 398# define aac_print_queues(sc) 399# define aac_panic(sc, reason) 400 401# define AAC_PRINT_FIB(sc, fib) 402# define aac_print_aif(sc, aac_aif_command) 403#endif 404 405struct aac_code_lookup { |
408 char *string; 409 u_int32_t code; | 406 char *string; 407 u_int32_t code; |
410}; 411 | 408}; 409 |
412/****************************************************************************** | 410/* |
413 * Queue primitives for driver queues. 414 */ 415#define AACQ_ADD(sc, qname) \ 416 do { \ | 411 * Queue primitives for driver queues. 412 */ 413#define AACQ_ADD(sc, qname) \ 414 do { \ |
417 struct aac_qstat *qs = &(sc)->aac_qstat[qname]; \ | 415 struct aac_qstat *qs; \ |
418 \ | 416 \ |
419 qs->q_length++; \ 420 if (qs->q_length > qs->q_max) \ 421 qs->q_max = qs->q_length; \ 422 } while(0) | 417 qs = &(sc)->aac_qstat[qname]; \ 418 \ 419 qs->q_length++; \ 420 if (qs->q_length > qs->q_max) \ 421 qs->q_max = qs->q_length; \ 422 } while (0) |
423 424#define AACQ_REMOVE(sc, qname) (sc)->aac_qstat[qname].q_length-- | 423 424#define AACQ_REMOVE(sc, qname) (sc)->aac_qstat[qname].q_length-- |
425#define AACQ_INIT(sc, qname) \ 426 do { \ 427 sc->aac_qstat[qname].q_length = 0; \ 428 sc->aac_qstat[qname].q_max = 0; \ 429 } while(0) | 425#define AACQ_INIT(sc, qname) \ 426 do { \ 427 sc->aac_qstat[qname].q_length = 0; \ 428 sc->aac_qstat[qname].q_max = 0; \ 429 } while (0) |
430 431 432#define AACQ_COMMAND_QUEUE(name, index) \ 433static __inline void \ 434aac_initq_ ## name (struct aac_softc *sc) \ 435{ \ | 430 431 432#define AACQ_COMMAND_QUEUE(name, index) \ 433static __inline void \ 434aac_initq_ ## name (struct aac_softc *sc) \ 435{ \ |
436 TAILQ_INIT(&sc->aac_ ## name); \ 437 AACQ_INIT(sc, index); \ | 436 TAILQ_INIT(&sc->aac_ ## name); \ 437 AACQ_INIT(sc, index); \ |
438} \ 439static __inline void \ 440aac_enqueue_ ## name (struct aac_command *cm) \ 441{ \ | 438} \ 439static __inline void \ 440aac_enqueue_ ## name (struct aac_command *cm) \ 441{ \ |
442 int s; \ | 442 int s; \ |
443 \ | 443 \ |
444 s = splbio(); \ 445 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ 446 printf("command %p is on another queue, flags = %#x\n", \ 447 cm, cm->cm_flags); \ 448 panic("command is on another queue"); \ 449 } \ 450 TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link); \ 451 cm->cm_flags |= AAC_ON_ ## index; \ 452 AACQ_ADD(cm->cm_sc, index); \ 453 splx(s); \ | 444 s = splbio(); \ 445 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ 446 printf("command %p is on another queue, flags = %#x\n", \ 447 cm, cm->cm_flags); \ 448 panic("command is on another queue"); \ 449 } \ 450 TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link); \ 451 cm->cm_flags |= AAC_ON_ ## index; \ 452 AACQ_ADD(cm->cm_sc, index); \ 453 splx(s); \ |
454} \ 455static __inline void \ 456aac_requeue_ ## name (struct aac_command *cm) \ 457{ \ | 454} \ 455static __inline void \ 456aac_requeue_ ## name (struct aac_command *cm) \ 457{ \ |
458 int s; \ | 458 int s; \ |
459 \ | 459 \ |
460 s = splbio(); \ 461 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ 462 printf("command %p is on another queue, flags = %#x\n", \ 463 cm, cm->cm_flags); \ 464 panic("command is on another queue"); \ 465 } \ 466 TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link); \ 467 cm->cm_flags |= AAC_ON_ ## index; \ 468 AACQ_ADD(cm->cm_sc, index); \ 469 splx(s); \ | 460 s = splbio(); \ 461 if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ 462 printf("command %p is on another queue, flags = %#x\n", \ 463 cm, cm->cm_flags); \ 464 panic("command is on another queue"); \ 465 } \ 466 TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link); \ 467 cm->cm_flags |= AAC_ON_ ## index; \ 468 AACQ_ADD(cm->cm_sc, index); \ 469 splx(s); \ |
470} \ 471static __inline struct aac_command * \ 472aac_dequeue_ ## name (struct aac_softc *sc) \ 473{ \ | 470} \ 471static __inline struct aac_command * \ 472aac_dequeue_ ## name (struct aac_softc *sc) \ 473{ \ |
474 struct aac_command *cm; \ 475 int s; \ | 474 struct aac_command *cm; \ 475 int s; \ |
476 \ | 476 \ |
477 s = splbio(); \ 478 if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) { \ 479 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ 480 printf("command %p not in queue, flags = %#x, bit = %#x\n",\ 481 cm, cm->cm_flags, AAC_ON_ ## index); \ 482 panic("command not in queue"); \ | 477 s = splbio(); \ 478 if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) { \ 479 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ 480 printf("command %p not in queue, flags = %#x, " \ 481 "bit = %#x\n", cm, cm->cm_flags, \ 482 AAC_ON_ ## index); \ 483 panic("command not in queue"); \ 484 } \ 485 TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link); \ 486 cm->cm_flags &= ~AAC_ON_ ## index; \ 487 AACQ_REMOVE(sc, index); \ |
483 } \ | 488 } \ |
484 TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link); \ 485 cm->cm_flags &= ~AAC_ON_ ## index; \ 486 AACQ_REMOVE(sc, index); \ 487 } \ 488 splx(s); \ 489 return(cm); \ | 489 splx(s); \ 490 return(cm); \ |
490} \ 491static __inline void \ 492aac_remove_ ## name (struct aac_command *cm) \ 493{ \ | 491} \ 492static __inline void \ 493aac_remove_ ## name (struct aac_command *cm) \ 494{ \ |
494 int s; \ | 495 int s; \ |
495 \ | 496 \ |
496 s = splbio(); \ 497 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ 498 printf("command %p not in queue, flags = %#x, bit = %#x\n", \ 499 cm, cm->cm_flags, AAC_ON_ ## index); \ 500 panic("command not in queue"); \ 501 } \ 502 TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link); \ 503 cm->cm_flags &= ~AAC_ON_ ## index; \ 504 AACQ_REMOVE(cm->cm_sc, index); \ 505 splx(s); \ | 497 s = splbio(); \ 498 if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ 499 printf("command %p not in queue, flags = %#x, " \ 500 "bit = %#x\n", cm, cm->cm_flags, \ 501 AAC_ON_ ## index); \ 502 panic("command not in queue"); \ 503 } \ 504 TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link); \ 505 cm->cm_flags &= ~AAC_ON_ ## index; \ 506 AACQ_REMOVE(cm->cm_sc, index); \ 507 splx(s); \ |
506} \ 507struct hack 508 509AACQ_COMMAND_QUEUE(free, AACQ_FREE); 510AACQ_COMMAND_QUEUE(ready, AACQ_READY); 511AACQ_COMMAND_QUEUE(busy, AACQ_BUSY); 512AACQ_COMMAND_QUEUE(complete, AACQ_COMPLETE); 513 514/* 515 * outstanding bio queue 516 */ 517static __inline void 518aac_initq_bio(struct aac_softc *sc) 519{ | 508} \ 509struct hack 510 511AACQ_COMMAND_QUEUE(free, AACQ_FREE); 512AACQ_COMMAND_QUEUE(ready, AACQ_READY); 513AACQ_COMMAND_QUEUE(busy, AACQ_BUSY); 514AACQ_COMMAND_QUEUE(complete, AACQ_COMPLETE); 515 516/* 517 * outstanding bio queue 518 */ 519static __inline void 520aac_initq_bio(struct aac_softc *sc) 521{ |
520 bioq_init(&sc->aac_bioq); 521 AACQ_INIT(sc, AACQ_BIO); | 522 bioq_init(&sc->aac_bioq); 523 AACQ_INIT(sc, AACQ_BIO); |
522} 523 524static __inline void 525aac_enqueue_bio(struct aac_softc *sc, struct bio *bp) 526{ | 524} 525 526static __inline void 527aac_enqueue_bio(struct aac_softc *sc, struct bio *bp) 528{ |
527 int s; | 529 int s; |
528 | 530 |
529 s = splbio(); 530 bioq_insert_tail(&sc->aac_bioq, bp); 531 AACQ_ADD(sc, AACQ_BIO); 532 splx(s); | 531 s = splbio(); 532 bioq_insert_tail(&sc->aac_bioq, bp); 533 AACQ_ADD(sc, AACQ_BIO); 534 splx(s); |
533} 534 535static __inline struct bio * 536aac_dequeue_bio(struct aac_softc *sc) 537{ | 535} 536 537static __inline struct bio * 538aac_dequeue_bio(struct aac_softc *sc) 539{ |
538 int s; 539 struct bio *bp; | 540 int s; 541 struct bio *bp; |
540 | 542 |
541 s = splbio(); 542 if ((bp = bioq_first(&sc->aac_bioq)) != NULL) { | 543 s = splbio(); 544 if ((bp = bioq_first(&sc->aac_bioq)) != NULL) { |
543 bioq_remove(&sc->aac_bioq, bp); 544 AACQ_REMOVE(sc, AACQ_BIO); | 545 bioq_remove(&sc->aac_bioq, bp); 546 AACQ_REMOVE(sc, AACQ_BIO); |
545 } 546 splx(s); 547 return(bp); | 547 } 548 splx(s); 549 return(bp); |
548} 549 550static __inline void 551aac_print_printf(struct aac_softc *sc) 552{ | 550} 551 552static __inline void 553aac_print_printf(struct aac_softc *sc) 554{ |
553 if (sc->aac_common->ac_printf[0]) { | 555 if (sc->aac_common->ac_printf[0]) { |
554 device_printf(sc->aac_dev, "**Monitor** %.*s", AAC_PRINTF_BUFSIZE, 555 sc->aac_common->ac_printf); 556 sc->aac_common->ac_printf[0] = 0; 557 AAC_QNOTIFY(sc, AAC_DB_PRINTF); | 556 device_printf(sc->aac_dev, "**Monitor** %.*s", AAC_PRINTF_BUFSIZE, 557 sc->aac_common->ac_printf); 558 sc->aac_common->ac_printf[0] = 0; 559 AAC_QNOTIFY(sc, AAC_DB_PRINTF); |
558 } | 560 } |
559} | 561} |