aacvar.h (133606) | aacvar.h (151086) |
---|---|
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 133606 2004-08-13 01:44:09Z scottl $ | 29 * $FreeBSD: head/sys/dev/aac/aacvar.h 151086 2005-10-08 15:55:09Z scottl $ |
30 */ 31 32#include <sys/bio.h> 33#include <sys/lock.h> 34#include <sys/mutex.h> 35#include <sys/taskqueue.h> 36#include <sys/selinfo.h> 37#include <geom/geom_disk.h> 38 | 30 */ 31 32#include <sys/bio.h> 33#include <sys/lock.h> 34#include <sys/mutex.h> 35#include <sys/taskqueue.h> 36#include <sys/selinfo.h> 37#include <geom/geom_disk.h> 38 |
39#ifndef AAC_DRIVER_BUILD 40# define AAC_DRIVER_BUILD 1 41#endif |
|
39 40/* 41 * Driver Parameter Definitions 42 */ 43 44/* 45 * The firmware interface allows for a 16-bit s/g list length. We limit 46 * ourselves to a reasonable maximum and ensure alignment. --- 4 unchanged lines hidden (view full) --- 51 * We allocate a small set of FIBs for the adapter to use to send us messages. 52 */ 53#define AAC_ADAPTER_FIBS 8 54 55/* 56 * FIBs are allocated in page-size chunks and can grow up to the 512 57 * limit imposed by the hardware. 58 */ | 42 43/* 44 * Driver Parameter Definitions 45 */ 46 47/* 48 * The firmware interface allows for a 16-bit s/g list length. We limit 49 * ourselves to a reasonable maximum and ensure alignment. --- 4 unchanged lines hidden (view full) --- 54 * We allocate a small set of FIBs for the adapter to use to send us messages. 55 */ 56#define AAC_ADAPTER_FIBS 8 57 58/* 59 * FIBs are allocated in page-size chunks and can grow up to the 512 60 * limit imposed by the hardware. 61 */ |
59#define AAC_FIB_COUNT (PAGE_SIZE/sizeof(struct aac_fib)) | |
60#define AAC_PREALLOCATE_FIBS 128 | 62#define AAC_PREALLOCATE_FIBS 128 |
61#define AAC_MAX_FIBS 504 | 63#define AAC_NUM_MGT_FIB 8 |
62 63/* 64 * The controller reports status events in AIFs. We hang on to a number of 65 * these in order to pass them out to user-space management tools. 66 */ 67#define AAC_AIFQ_LENGTH 64 68 69/* --- 71 unchanged lines hidden (view full) --- 141struct aac_command 142{ 143 TAILQ_ENTRY(aac_command) cm_link; /* list linkage */ 144 145 struct aac_softc *cm_sc; /* controller that owns us */ 146 147 struct aac_fib *cm_fib; /* FIB associated with this 148 * command */ | 64 65/* 66 * The controller reports status events in AIFs. We hang on to a number of 67 * these in order to pass them out to user-space management tools. 68 */ 69#define AAC_AIFQ_LENGTH 64 70 71/* --- 71 unchanged lines hidden (view full) --- 143struct aac_command 144{ 145 TAILQ_ENTRY(aac_command) cm_link; /* list linkage */ 146 147 struct aac_softc *cm_sc; /* controller that owns us */ 148 149 struct aac_fib *cm_fib; /* FIB associated with this 150 * command */ |
149 u_int32_t cm_fibphys; /* bus address of the FIB */ | 151 u_int64_t cm_fibphys; /* bus address of the FIB */ |
150 struct bio *cm_data; /* pointer to data in kernel 151 * space */ 152 u_int32_t cm_datalen; /* data length */ 153 bus_dmamap_t cm_datamap; /* DMA map for bio data */ 154 struct aac_sg_table *cm_sgtable; /* pointer to s/g table in 155 * command */ 156 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) | 152 struct bio *cm_data; /* pointer to data in kernel 153 * space */ 154 u_int32_t cm_datalen; /* data length */ 155 bus_dmamap_t cm_datamap; /* DMA map for bio data */ 156 struct aac_sg_table *cm_sgtable; /* pointer to s/g table in 157 * command */ 158 int cm_flags; 159#define AAC_CMD_MAPPED (1<<0) /* command has had its data 160 * mapped */ 161#define AAC_CMD_DATAIN (1<<1) /* command involves data moving 162 * from controller to host */ 163#define AAC_CMD_DATAOUT (1<<2) /* command involves data moving 164 * from host to controller */ 165#define AAC_CMD_COMPLETED (1<<3) /* command has been completed */ 166#define AAC_CMD_TIMEDOUT (1<<4) /* command taken too long */ 167#define AAC_ON_AACQ_FREE (1<<5) 168#define AAC_ON_AACQ_READY (1<<6) 169#define AAC_ON_AACQ_BUSY (1<<7) |
168#define AAC_ON_AACQ_MASK ((1<<5)|(1<<6)|(1<<7)) | 170#define AAC_ON_AACQ_AIF (1<<8) 171#define AAC_ON_AACQ_NORM (1<<10) 172#define AAC_ON_AACQ_MASK ((1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<10)) |
169#define AAC_QUEUE_FRZN (1<<9) /* Freeze the processing of 170 * commands on the queue. */ 171 172 void (* cm_complete)(struct aac_command *cm); 173 void *cm_private; 174 time_t cm_timestamp; /* command creation time */ 175 int cm_queue; 176 int cm_index; --- 46 unchanged lines hidden (view full) --- 223 void (*aif_qnotify)(struct aac_softc *sc, int qbit); 224 int (*aif_get_istatus)(struct aac_softc *sc); 225 void (*aif_clr_istatus)(struct aac_softc *sc, int mask); 226 void (*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command, 227 u_int32_t arg0, u_int32_t arg1, 228 u_int32_t arg2, u_int32_t arg3); 229 int (*aif_get_mailbox)(struct aac_softc *sc, int mb); 230 void (*aif_set_interrupts)(struct aac_softc *sc, int enable); | 173#define AAC_QUEUE_FRZN (1<<9) /* Freeze the processing of 174 * commands on the queue. */ 175 176 void (* cm_complete)(struct aac_command *cm); 177 void *cm_private; 178 time_t cm_timestamp; /* command creation time */ 179 int cm_queue; 180 int cm_index; --- 46 unchanged lines hidden (view full) --- 227 void (*aif_qnotify)(struct aac_softc *sc, int qbit); 228 int (*aif_get_istatus)(struct aac_softc *sc); 229 void (*aif_clr_istatus)(struct aac_softc *sc, int mask); 230 void (*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command, 231 u_int32_t arg0, u_int32_t arg1, 232 u_int32_t arg2, u_int32_t arg3); 233 int (*aif_get_mailbox)(struct aac_softc *sc, int mb); 234 void (*aif_set_interrupts)(struct aac_softc *sc, int enable); |
235 int (*aif_send_command)(struct aac_softc *sc, struct aac_command *cm); 236 int (*aif_get_outb_queue)(struct aac_softc *sc); 237 void (*aif_set_outb_queue)(struct aac_softc *sc, int index); |
|
231}; 232extern struct aac_interface aac_rx_interface; 233extern struct aac_interface aac_sa_interface; 234extern struct aac_interface aac_fa_interface; 235extern struct aac_interface aac_rkt_interface; 236 237#define AAC_GET_FWSTATUS(sc) ((sc)->aac_if.aif_get_fwstatus((sc))) 238#define AAC_QNOTIFY(sc, qbit) ((sc)->aac_if.aif_qnotify((sc), (qbit))) --- 4 unchanged lines hidden (view full) --- 243 ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \ 244 (arg3))) 245#define AAC_GET_MAILBOX(sc, mb) ((sc)->aac_if.aif_get_mailbox((sc), \ 246 (mb))) 247#define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ 248 0)) 249#define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ 250 1)) | 238}; 239extern struct aac_interface aac_rx_interface; 240extern struct aac_interface aac_sa_interface; 241extern struct aac_interface aac_fa_interface; 242extern struct aac_interface aac_rkt_interface; 243 244#define AAC_GET_FWSTATUS(sc) ((sc)->aac_if.aif_get_fwstatus((sc))) 245#define AAC_QNOTIFY(sc, qbit) ((sc)->aac_if.aif_qnotify((sc), (qbit))) --- 4 unchanged lines hidden (view full) --- 250 ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \ 251 (arg3))) 252#define AAC_GET_MAILBOX(sc, mb) ((sc)->aac_if.aif_get_mailbox((sc), \ 253 (mb))) 254#define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ 255 0)) 256#define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ 257 1)) |
258#define AAC_SEND_COMMAND(sc, cm) ((sc)->aac_if.aif_send_command((sc), (cm))) 259#define AAC_GET_OUTB_QUEUE(sc) ((sc)->aac_if.aif_get_outb_queue((sc))) 260#define AAC_SET_OUTB_QUEUE(sc, idx) ((sc)->aac_if.aif_set_outb_queue((sc), (idx))) |
|
251 252#define AAC_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag, \ 253 sc->aac_bhandle, reg, val) 254#define AAC_GETREG4(sc, reg) bus_space_read_4 (sc->aac_btag, \ 255 sc->aac_bhandle, reg) 256#define AAC_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag, \ 257 sc->aac_bhandle, reg, val) 258#define AAC_GETREG2(sc, reg) bus_space_read_2 (sc->aac_btag, \ --- 53 unchanged lines hidden (view full) --- 312 struct aac_command *aac_commands; 313 314 /* command management */ 315 TAILQ_HEAD(,aac_command) aac_free; /* command structures 316 * available for reuse */ 317 TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for 318 * controller resources */ 319 TAILQ_HEAD(,aac_command) aac_busy; | 261 262#define AAC_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag, \ 263 sc->aac_bhandle, reg, val) 264#define AAC_GETREG4(sc, reg) bus_space_read_4 (sc->aac_btag, \ 265 sc->aac_bhandle, reg) 266#define AAC_SETREG2(sc, reg, val) bus_space_write_2(sc->aac_btag, \ 267 sc->aac_bhandle, reg, val) 268#define AAC_GETREG2(sc, reg) bus_space_read_2 (sc->aac_btag, \ --- 53 unchanged lines hidden (view full) --- 322 struct aac_command *aac_commands; 323 324 /* command management */ 325 TAILQ_HEAD(,aac_command) aac_free; /* command structures 326 * available for reuse */ 327 TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for 328 * controller resources */ 329 TAILQ_HEAD(,aac_command) aac_busy; |
330 TAILQ_HEAD(,aac_command) aac_aif; 331#if 0 332 TAILQ_HEAD(,aac_command) aac_norm; 333#endif 334 TAILQ_HEAD(,aac_event) aac_ev_cmfree; |
|
320 struct bio_queue_head aac_bioq; 321 struct aac_queue_table *aac_queues; 322 struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT]; 323 324 struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */ 325 326 /* connected containters */ 327 TAILQ_HEAD(,aac_container) aac_container_tqh; --- 33 unchanged lines hidden (view full) --- 361#define AAC_FLAGS_CAM_NORESET (1 << 2) /* Fake SCSI resets */ 362#define AAC_FLAGS_CAM_PASSONLY (1 << 3) /* Only create pass devices */ 363#define AAC_FLAGS_SG_64BIT (1 << 4) /* Use 64-bit S/G addresses */ 364#define AAC_FLAGS_4GB_WINDOW (1 << 5) /* Device can access host mem 365 * 2GB-4GB range */ 366#define AAC_FLAGS_NO4GB (1 << 6) /* Can't access host mem >2GB */ 367#define AAC_FLAGS_256FIBS (1 << 7) /* Can only do 256 commands */ 368#define AAC_FLAGS_BROKEN_MEMMAP (1 << 8) /* Broken HostPhysMemPages */ | 335 struct bio_queue_head aac_bioq; 336 struct aac_queue_table *aac_queues; 337 struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT]; 338 339 struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */ 340 341 /* connected containters */ 342 TAILQ_HEAD(,aac_container) aac_container_tqh; --- 33 unchanged lines hidden (view full) --- 376#define AAC_FLAGS_CAM_NORESET (1 << 2) /* Fake SCSI resets */ 377#define AAC_FLAGS_CAM_PASSONLY (1 << 3) /* Only create pass devices */ 378#define AAC_FLAGS_SG_64BIT (1 << 4) /* Use 64-bit S/G addresses */ 379#define AAC_FLAGS_4GB_WINDOW (1 << 5) /* Device can access host mem 380 * 2GB-4GB range */ 381#define AAC_FLAGS_NO4GB (1 << 6) /* Can't access host mem >2GB */ 382#define AAC_FLAGS_256FIBS (1 << 7) /* Can only do 256 commands */ 383#define AAC_FLAGS_BROKEN_MEMMAP (1 << 8) /* Broken HostPhysMemPages */ |
384#define AAC_FLAGS_SLAVE (1 << 9) 385#define AAC_FLAGS_MASTER (1 << 10) 386#define AAC_FLAGS_NEW_COMM (1 << 11) /* New comm. interface supported */ 387#define AAC_FLAGS_RAW_IO (1 << 12) /* Raw I/O interface */ 388#define AAC_FLAGS_ARRAY_64BIT (1 << 13) /* 64-bit array size */ |
|
369 370 u_int32_t supported_options; | 389 390 u_int32_t supported_options; |
371 int aac_max_fibs; | |
372 u_int32_t scsi_method_id; 373 TAILQ_HEAD(,aac_sim) aac_sim_tqh; | 391 u_int32_t scsi_method_id; 392 TAILQ_HEAD(,aac_sim) aac_sim_tqh; |
393 394 u_int32_t aac_max_fibs; /* max. FIB count */ 395 u_int32_t aac_max_fibs_alloc; /* max. alloc. per alloc_commands() */ 396 u_int32_t aac_max_fib_size; /* max. FIB size */ 397 u_int32_t aac_sg_tablesize; /* max. sg count from host */ 398 u_int32_t aac_max_sectors; /* max. I/O size from host (blocks) */ |
|
374}; 375 | 399}; 400 |
401/* 402 * Event callback mechanism for the driver 403 */ 404#define AAC_EVENT_NONE 0x00 405#define AAC_EVENT_CMFREE 0x01 406#define AAC_EVENT_MASK 0xff 407#define AAC_EVENT_REPEAT 0x100 |
|
376 | 408 |
409typedef void aac_event_cb_t(struct aac_softc *sc, struct aac_event *event, 410 void *arg); 411struct aac_event { 412 TAILQ_ENTRY(aac_event) ev_links; 413 int ev_type; 414 aac_event_cb_t *ev_callback; 415 void *ev_arg; 416}; 417 |
|
377/* 378 * Public functions 379 */ 380extern void aac_free(struct aac_softc *sc); 381extern int aac_attach(struct aac_softc *sc); 382extern int aac_detach(device_t dev); 383extern int aac_shutdown(device_t dev); 384extern int aac_suspend(device_t dev); 385extern int aac_resume(device_t dev); | 418/* 419 * Public functions 420 */ 421extern void aac_free(struct aac_softc *sc); 422extern int aac_attach(struct aac_softc *sc); 423extern int aac_detach(device_t dev); 424extern int aac_shutdown(device_t dev); 425extern int aac_suspend(device_t dev); 426extern int aac_resume(device_t dev); |
386extern void aac_intr(void *arg); | 427extern void aac_new_intr(void *arg); 428extern void aac_fast_intr(void *arg); |
387extern void aac_submit_bio(struct bio *bp); 388extern void aac_biodone(struct bio *bp); 389extern void aac_startio(struct aac_softc *sc); 390extern int aac_alloc_command(struct aac_softc *sc, 391 struct aac_command **cmp); 392extern void aac_release_command(struct aac_command *cm); 393extern int aac_sync_fib(struct aac_softc *sc, u_int32_t command, 394 u_int32_t xferstate, struct aac_fib *fib, 395 u_int16_t datasize); | 429extern void aac_submit_bio(struct bio *bp); 430extern void aac_biodone(struct bio *bp); 431extern void aac_startio(struct aac_softc *sc); 432extern int aac_alloc_command(struct aac_softc *sc, 433 struct aac_command **cmp); 434extern void aac_release_command(struct aac_command *cm); 435extern int aac_sync_fib(struct aac_softc *sc, u_int32_t command, 436 u_int32_t xferstate, struct aac_fib *fib, 437 u_int16_t datasize); |
438extern void aac_add_event(struct aac_softc *sc, struct aac_event 439 *event); |
|
396 397/* 398 * Debugging levels: 399 * 0 - quiet, only emit warnings 400 * 1 - noisy, emit major function points and things done 401 * 2 - extremely noisy, emit trace items in loops, etc. 402 */ 403#ifdef AAC_DEBUG --- 162 unchanged lines hidden (view full) --- 566 sc->aac_common->ac_printf[0] = 0; 567 AAC_QNOTIFY(sc, AAC_DB_PRINTF); 568} 569 570static __inline int 571aac_alloc_sync_fib(struct aac_softc *sc, struct aac_fib **fib) 572{ 573 | 440 441/* 442 * Debugging levels: 443 * 0 - quiet, only emit warnings 444 * 1 - noisy, emit major function points and things done 445 * 2 - extremely noisy, emit trace items in loops, etc. 446 */ 447#ifdef AAC_DEBUG --- 162 unchanged lines hidden (view full) --- 610 sc->aac_common->ac_printf[0] = 0; 611 AAC_QNOTIFY(sc, AAC_DB_PRINTF); 612} 613 614static __inline int 615aac_alloc_sync_fib(struct aac_softc *sc, struct aac_fib **fib) 616{ 617 |
574 mtx_lock(&sc->aac_io_lock); | 618 mtx_assert(&sc->aac_io_lock, MA_OWNED); |
575 *fib = &sc->aac_common->ac_sync_fib; 576 return (0); 577} 578 579static __inline void 580aac_release_sync_fib(struct aac_softc *sc) 581{ 582 | 619 *fib = &sc->aac_common->ac_sync_fib; 620 return (0); 621} 622 623static __inline void 624aac_release_sync_fib(struct aac_softc *sc) 625{ 626 |
583 mtx_unlock(&sc->aac_io_lock); | 627 mtx_assert(&sc->aac_io_lock, MA_OWNED); |
584} 585 | 628} 629 |