Deleted Added
full compact
amrvar.h (174544) amrvar.h (175622)
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 *
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 174544 2007-12-12 05:55:03Z scottl $
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
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
103union amr_ccb {
104 struct amr_passthrough ccb_pthru;
105 struct amr_ext_passthrough ccb_epthru;
106 uint8_t bytes[128];
107};
108
109/*
110 * Per-command control structure.
111 */
112struct amr_command
113{
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{
114 TAILQ_ENTRY(amr_command) ac_link;
117 ac_link_t ac_link;
115
116 struct amr_softc *ac_sc;
117 u_int8_t ac_slot;
118 int ac_status; /* command completion status */
119 union {
120 struct amr_sgentry *sg32;
121 struct amr_sg64entry *sg64;
122 } ac_sg;

--- 6 unchanged lines hidden (view full) ---

129#define AMR_CMD_DATAOUT (1<<1)
130#define AMR_CMD_CCB (1<<2)
131#define AMR_CMD_PRIORITY (1<<4)
132#define AMR_CMD_MAPPED (1<<5)
133#define AMR_CMD_SLEEP (1<<6)
134#define AMR_CMD_BUSY (1<<7)
135#define AMR_CMD_SG64 (1<<8)
136#define AC_IS_SG64(ac) ((ac)->ac_flags & AMR_CMD_SG64)
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;
137
138 struct bio *ac_bio;
139 void (* ac_complete)(struct amr_command *ac);
140 void *ac_private;
141
142 void *ac_data;
143 size_t ac_length;
144 bus_dmamap_t ac_dmamap;

--- 69 unchanged lines hidden (view full) ---

214#define AMR_STATE_SHUTDOWN (1<<3)
215#define AMR_STATE_CRASHDUMP (1<<4)
216#define AMR_STATE_QUEUE_FRZN (1<<5)
217#define AMR_STATE_LD_DELETE (1<<6)
218#define AMR_STATE_REMAP_LD (1<<7)
219
220 /* per-controller queues */
221 struct bio_queue_head amr_bioq; /* pending I/O with no commands */
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 */
222 TAILQ_HEAD(,amr_command) amr_ready; /* commands ready to be submitted */
226 ac_qhead_t amr_ready; /* commands ready to be submitted */
223 struct amr_command *amr_busycmd[AMR_MAXCMD];
224 int amr_busyslots;
227 struct amr_command *amr_busycmd[AMR_MAXCMD];
228 int amr_busyslots;
225 TAILQ_HEAD(,amr_command) amr_completed;
226 TAILQ_HEAD(,amr_command) amr_freecmds;
229 ac_qhead_t amr_freecmds;
227 TAILQ_HEAD(,amr_command_cluster) amr_cmd_clusters;
228
229 /* CAM attachments for passthrough */
230 struct cam_sim *amr_cam_sim[AMR_MAX_CHANNELS];
231 TAILQ_HEAD(, ccb_hdr) amr_cam_ccbq;
232 struct cam_devq *amr_cam_devq;
233
234 /* control device */

--- 80 unchanged lines hidden (view full) ---

315 struct bio *bio;
316
317 if ((bio = bioq_first(&sc->amr_bioq)) != NULL)
318 bioq_remove(&sc->amr_bioq, bio);
319 return(bio);
320}
321
322static __inline void
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
323amr_enqueue_ready(struct amr_command *ac)
324{
325
333amr_enqueue_ready(struct amr_command *ac)
334{
335
326 TAILQ_INSERT_TAIL(&ac->ac_sc->amr_ready, ac, ac_link);
336 STAILQ_INSERT_TAIL(&ac->ac_sc->amr_ready, ac, ac_link);
327}
328
329static __inline void
330amr_requeue_ready(struct amr_command *ac)
331{
332
337}
338
339static __inline void
340amr_requeue_ready(struct amr_command *ac)
341{
342
333 TAILQ_INSERT_HEAD(&ac->ac_sc->amr_ready, ac, ac_link);
343 STAILQ_INSERT_HEAD(&ac->ac_sc->amr_ready, ac, ac_link);
334}
335
336static __inline struct amr_command *
337amr_dequeue_ready(struct amr_softc *sc)
338{
339 struct amr_command *ac;
340
344}
345
346static __inline struct amr_command *
347amr_dequeue_ready(struct amr_softc *sc)
348{
349 struct amr_command *ac;
350
341 if ((ac = TAILQ_FIRST(&sc->amr_ready)) != NULL)
342 TAILQ_REMOVE(&sc->amr_ready, ac, ac_link);
351 if ((ac = STAILQ_FIRST(&sc->amr_ready)) != NULL)
352 STAILQ_REMOVE_HEAD(&sc->amr_ready, ac_link);
343 return(ac);
344}
345
346static __inline void
353 return(ac);
354}
355
356static __inline void
347amr_enqueue_completed(struct amr_command *ac)
357amr_enqueue_completed(struct amr_command *ac, ac_qhead_t *head)
348{
349
358{
359
350 TAILQ_INSERT_TAIL(&ac->ac_sc->amr_completed, ac, ac_link);
360 STAILQ_INSERT_TAIL(head, ac, ac_link);
351}
352
353static __inline struct amr_command *
361}
362
363static __inline struct amr_command *
354amr_dequeue_completed(struct amr_softc *sc)
364amr_dequeue_completed(struct amr_softc *sc, ac_qhead_t *head)
355{
356 struct amr_command *ac;
357
365{
366 struct amr_command *ac;
367
358 if ((ac = TAILQ_FIRST(&sc->amr_completed)) != NULL)
359 TAILQ_REMOVE(&sc->amr_completed, ac, ac_link);
368 if ((ac = STAILQ_FIRST(head)) != NULL)
369 STAILQ_REMOVE_HEAD(head, ac_link);
360 return(ac);
361}
362
363static __inline void
364amr_enqueue_free(struct amr_command *ac)
365{
366
370 return(ac);
371}
372
373static __inline void
374amr_enqueue_free(struct amr_command *ac)
375{
376
367 TAILQ_INSERT_TAIL(&ac->ac_sc->amr_freecmds, ac, ac_link);
377 STAILQ_INSERT_HEAD(&ac->ac_sc->amr_freecmds, ac, ac_link);
368}
369
370static __inline struct amr_command *
371amr_dequeue_free(struct amr_softc *sc)
372{
373 struct amr_command *ac;
374
378}
379
380static __inline struct amr_command *
381amr_dequeue_free(struct amr_softc *sc)
382{
383 struct amr_command *ac;
384
375 if ((ac = TAILQ_FIRST(&sc->amr_freecmds)) != NULL)
376 TAILQ_REMOVE(&sc->amr_freecmds, ac, ac_link);
385 if ((ac = STAILQ_FIRST(&sc->amr_freecmds)) != NULL)
386 STAILQ_REMOVE_HEAD(&sc->amr_freecmds, ac_link);
377 return(ac);
378}
387 return(ac);
388}