1/*- 2 * Copyright (c) 1999,2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 39 unchanged lines hidden (view full) --- 48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 * SUCH DAMAGE. 54 * 55 * |
56 * $FreeBSD: head/sys/dev/amr/amrvar.h 175622 2008-01-24 07:26:53Z scottl $ |
57 */ 58 59#include <geom/geom_disk.h> 60#include <sys/lock.h> 61#include <sys/mutex.h> 62 63#define LSI_DESC_PCI "LSILogic MegaRAID 1.53" 64 --- 30 unchanged lines hidden (view full) --- 95 * memory wastage due to allocating lots of these small structures. 96 * 97 * 16k gives us a little under 200 command structures, which should 98 * normally be plenty. We will grab more if we need them. 99 */ 100 101#define AMR_CMD_CLUSTERSIZE (16 * 1024) 102 |
103typedef STAILQ_HEAD(, amr_command) ac_qhead_t; 104typedef STAILQ_ENTRY(amr_command) ac_link_t; 105 |
106union amr_ccb { 107 struct amr_passthrough ccb_pthru; 108 struct amr_ext_passthrough ccb_epthru; 109 uint8_t bytes[128]; 110}; 111 112/* 113 * Per-command control structure. 114 */ 115struct amr_command 116{ |
117 ac_link_t ac_link; |
118 119 struct amr_softc *ac_sc; 120 u_int8_t ac_slot; 121 int ac_status; /* command completion status */ 122 union { 123 struct amr_sgentry *sg32; 124 struct amr_sg64entry *sg64; 125 } ac_sg; --- 6 unchanged lines hidden (view full) --- 132#define AMR_CMD_DATAOUT (1<<1) 133#define AMR_CMD_CCB (1<<2) 134#define AMR_CMD_PRIORITY (1<<4) 135#define AMR_CMD_MAPPED (1<<5) 136#define AMR_CMD_SLEEP (1<<6) 137#define AMR_CMD_BUSY (1<<7) 138#define AMR_CMD_SG64 (1<<8) 139#define AC_IS_SG64(ac) ((ac)->ac_flags & AMR_CMD_SG64) |
140 u_int ac_retries; |
141 142 struct bio *ac_bio; 143 void (* ac_complete)(struct amr_command *ac); 144 void *ac_private; 145 146 void *ac_data; 147 size_t ac_length; 148 bus_dmamap_t ac_dmamap; --- 69 unchanged lines hidden (view full) --- 218#define AMR_STATE_SHUTDOWN (1<<3) 219#define AMR_STATE_CRASHDUMP (1<<4) 220#define AMR_STATE_QUEUE_FRZN (1<<5) 221#define AMR_STATE_LD_DELETE (1<<6) 222#define AMR_STATE_REMAP_LD (1<<7) 223 224 /* per-controller queues */ 225 struct bio_queue_head amr_bioq; /* pending I/O with no commands */ |
226 ac_qhead_t amr_ready; /* commands ready to be submitted */ |
227 struct amr_command *amr_busycmd[AMR_MAXCMD]; 228 int amr_busyslots; |
229 ac_qhead_t amr_freecmds; |
230 TAILQ_HEAD(,amr_command_cluster) amr_cmd_clusters; 231 232 /* CAM attachments for passthrough */ 233 struct cam_sim *amr_cam_sim[AMR_MAX_CHANNELS]; 234 TAILQ_HEAD(, ccb_hdr) amr_cam_ccbq; 235 struct cam_devq *amr_cam_devq; 236 237 /* control device */ --- 80 unchanged lines hidden (view full) --- 318 struct bio *bio; 319 320 if ((bio = bioq_first(&sc->amr_bioq)) != NULL) 321 bioq_remove(&sc->amr_bioq, bio); 322 return(bio); 323} 324 325static __inline void |
326amr_init_qhead(ac_qhead_t *head) 327{ 328 329 STAILQ_INIT(head); 330} 331 332static __inline void |
333amr_enqueue_ready(struct amr_command *ac) 334{ 335 |
336 STAILQ_INSERT_TAIL(&ac->ac_sc->amr_ready, ac, ac_link); |
337} 338 339static __inline void 340amr_requeue_ready(struct amr_command *ac) 341{ 342 |
343 STAILQ_INSERT_HEAD(&ac->ac_sc->amr_ready, ac, ac_link); |
344} 345 346static __inline struct amr_command * 347amr_dequeue_ready(struct amr_softc *sc) 348{ 349 struct amr_command *ac; 350 |
351 if ((ac = STAILQ_FIRST(&sc->amr_ready)) != NULL) 352 STAILQ_REMOVE_HEAD(&sc->amr_ready, ac_link); |
353 return(ac); 354} 355 356static __inline void |
357amr_enqueue_completed(struct amr_command *ac, ac_qhead_t *head) |
358{ 359 |
360 STAILQ_INSERT_TAIL(head, ac, ac_link); |
361} 362 363static __inline struct amr_command * |
364amr_dequeue_completed(struct amr_softc *sc, ac_qhead_t *head) |
365{ 366 struct amr_command *ac; 367 |
368 if ((ac = STAILQ_FIRST(head)) != NULL) 369 STAILQ_REMOVE_HEAD(head, ac_link); |
370 return(ac); 371} 372 373static __inline void 374amr_enqueue_free(struct amr_command *ac) 375{ 376 |
377 STAILQ_INSERT_HEAD(&ac->ac_sc->amr_freecmds, ac, ac_link); |
378} 379 380static __inline struct amr_command * 381amr_dequeue_free(struct amr_softc *sc) 382{ 383 struct amr_command *ac; 384 |
385 if ((ac = STAILQ_FIRST(&sc->amr_freecmds)) != NULL) 386 STAILQ_REMOVE_HEAD(&sc->amr_freecmds, ac_link); |
387 return(ac); 388} |