13a31b7ebSMike Smith /*- 23a31b7ebSMike Smith * Copyright (c) 2001 Michael Smith 33a31b7ebSMike Smith * All rights reserved. 43a31b7ebSMike Smith * 53a31b7ebSMike Smith * Redistribution and use in source and binary forms, with or without 63a31b7ebSMike Smith * modification, are permitted provided that the following conditions 73a31b7ebSMike Smith * are met: 83a31b7ebSMike Smith * 1. Redistributions of source code must retain the above copyright 93a31b7ebSMike Smith * notice, this list of conditions and the following disclaimer. 103a31b7ebSMike Smith * 2. Redistributions in binary form must reproduce the above copyright 113a31b7ebSMike Smith * notice, this list of conditions and the following disclaimer in the 123a31b7ebSMike Smith * documentation and/or other materials provided with the distribution. 133a31b7ebSMike Smith * 143a31b7ebSMike Smith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 153a31b7ebSMike Smith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 163a31b7ebSMike Smith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 173a31b7ebSMike Smith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 183a31b7ebSMike Smith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 193a31b7ebSMike Smith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 203a31b7ebSMike Smith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 213a31b7ebSMike Smith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 223a31b7ebSMike Smith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 233a31b7ebSMike Smith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 243a31b7ebSMike Smith * SUCH DAMAGE. 253a31b7ebSMike Smith * 263a31b7ebSMike Smith * $FreeBSD$ 273a31b7ebSMike Smith */ 283a31b7ebSMike Smith 293a31b7ebSMike Smith /* 303a31b7ebSMike Smith * CISS adapter driver datastructures 313a31b7ebSMike Smith */ 323a31b7ebSMike Smith 333a31b7ebSMike Smith /************************************************************************ 343a31b7ebSMike Smith * Tunable parameters 353a31b7ebSMike Smith */ 363a31b7ebSMike Smith 373a31b7ebSMike Smith /* 383a31b7ebSMike Smith * There is no guaranteed upper bound on the number of concurrent 393a31b7ebSMike Smith * commands an adapter may claim to support. Cap it at a reasonable 403a31b7ebSMike Smith * value. 413a31b7ebSMike Smith */ 423a31b7ebSMike Smith #define CISS_MAX_REQUESTS 256 433a31b7ebSMike Smith 443a31b7ebSMike Smith /* 453a31b7ebSMike Smith * Maximum number of logical drives we support. 463a31b7ebSMike Smith */ 473a31b7ebSMike Smith #define CISS_MAX_LOGICAL 15 483a31b7ebSMike Smith 493a31b7ebSMike Smith /* 503a31b7ebSMike Smith * Interrupt reduction can be controlled by tuning the interrupt 513a31b7ebSMike Smith * coalesce delay and count paramters. The delay (in microseconds) 523a31b7ebSMike Smith * defers delivery of interrupts to increase the chance of there being 533a31b7ebSMike Smith * more than one completed command ready when the interrupt is 543a31b7ebSMike Smith * delivered. The count expedites the delivery of the interrupt when 553a31b7ebSMike Smith * the given number of commands are ready. 563a31b7ebSMike Smith * 573a31b7ebSMike Smith * If the delay is set to 0, interrupts are delivered immediately. 583a31b7ebSMike Smith */ 593a31b7ebSMike Smith #define CISS_INTERRUPT_COALESCE_DELAY 1000 603a31b7ebSMike Smith #define CISS_INTERRUPT_COALESCE_COUNT 16 613a31b7ebSMike Smith 623a31b7ebSMike Smith /* 633a31b7ebSMike Smith * Heartbeat routine timeout in seconds. Note that since event 643a31b7ebSMike Smith * handling is performed on a callback basis, we don't need this to 653a31b7ebSMike Smith * run very often. 663a31b7ebSMike Smith */ 673a31b7ebSMike Smith #define CISS_HEARTBEAT_RATE 10 683a31b7ebSMike Smith 693a31b7ebSMike Smith /* 703a31b7ebSMike Smith * Maximum number of events we will queue for a monitoring utility. 713a31b7ebSMike Smith */ 723a31b7ebSMike Smith #define CISS_MAX_EVENTS 32 733a31b7ebSMike Smith 743a31b7ebSMike Smith /************************************************************************ 75d3e4392cSMike Smith * Compatibility with older versions of FreeBSD 76d3e4392cSMike Smith */ 77d3e4392cSMike Smith #if __FreeBSD_version < 440001 78d3e4392cSMike Smith #warning testing old-FreeBSD compat 79d3e4392cSMike Smith typedef struct proc d_thread_t; 80d3e4392cSMike Smith #endif 81d3e4392cSMike Smith 82d3e4392cSMike Smith /************************************************************************ 833a31b7ebSMike Smith * Command queue statistics 843a31b7ebSMike Smith */ 853a31b7ebSMike Smith 863a31b7ebSMike Smith #define CISSQ_FREE 0 873a31b7ebSMike Smith #define CISSQ_BUSY 1 883a31b7ebSMike Smith #define CISSQ_COMPLETE 2 893a31b7ebSMike Smith #define CISSQ_COUNT 3 903a31b7ebSMike Smith 913a31b7ebSMike Smith struct ciss_qstat 923a31b7ebSMike Smith { 933a31b7ebSMike Smith u_int32_t q_length; 943a31b7ebSMike Smith u_int32_t q_max; 953a31b7ebSMike Smith }; 963a31b7ebSMike Smith 973a31b7ebSMike Smith /************************************************************************ 983a31b7ebSMike Smith * Driver version. Only really significant to the ACU interface. 993a31b7ebSMike Smith */ 100d3e4392cSMike Smith #define CISS_DRIVER_VERSION 20011201 1013a31b7ebSMike Smith 1023a31b7ebSMike Smith /************************************************************************ 1033a31b7ebSMike Smith * Driver data structures 1043a31b7ebSMike Smith */ 1053a31b7ebSMike Smith 1063a31b7ebSMike Smith /* 1073a31b7ebSMike Smith * Each command issued to the adapter is managed by a request 1083a31b7ebSMike Smith * structure. 1093a31b7ebSMike Smith */ 1103a31b7ebSMike Smith struct ciss_request 1113a31b7ebSMike Smith { 1123a31b7ebSMike Smith TAILQ_ENTRY(ciss_request) cr_link; 1133a31b7ebSMike Smith int cr_onq; /* which queue we are on */ 1143a31b7ebSMike Smith 1153a31b7ebSMike Smith struct ciss_softc *cr_sc; /* controller softc */ 1163a31b7ebSMike Smith void *cr_data; /* data buffer */ 1173a31b7ebSMike Smith u_int32_t cr_length; /* data length */ 1183a31b7ebSMike Smith bus_dmamap_t cr_datamap; /* DMA map for data */ 1193a31b7ebSMike Smith int cr_tag; 1203a31b7ebSMike Smith int cr_flags; 1213a31b7ebSMike Smith #define CISS_REQ_MAPPED (1<<0) /* data mapped */ 1223a31b7ebSMike Smith #define CISS_REQ_SLEEP (1<<1) /* submitter sleeping */ 1233a31b7ebSMike Smith #define CISS_REQ_POLL (1<<2) /* submitter polling */ 1243a31b7ebSMike Smith #define CISS_REQ_DATAOUT (1<<3) /* data host->adapter */ 1253a31b7ebSMike Smith #define CISS_REQ_DATAIN (1<<4) /* data adapter->host */ 1263a31b7ebSMike Smith 1273a31b7ebSMike Smith void (* cr_complete)(struct ciss_request *); 1283a31b7ebSMike Smith void *cr_private; 1293a31b7ebSMike Smith }; 1303a31b7ebSMike Smith 1313a31b7ebSMike Smith /* 1323a31b7ebSMike Smith * The adapter command structure is defined with a zero-length 1333a31b7ebSMike Smith * scatter/gather list size. In practise, we want space for a 1343a31b7ebSMike Smith * scatter-gather list, and we also want to avoid having commands 1353a31b7ebSMike Smith * cross page boundaries. 1363a31b7ebSMike Smith * 1373a31b7ebSMike Smith * Note that 512 bytes yields 28 scatter/gather entries, or the 1383a31b7ebSMike Smith * ability to map (26 * PAGE_SIZE) + 2 bytes of data. On x86, this is 1393a31b7ebSMike Smith * 104kB. 256 bytes would only yield 12 entries, giving a mere 40kB, 1403a31b7ebSMike Smith * too small. 1413a31b7ebSMike Smith */ 1423a31b7ebSMike Smith 1433a31b7ebSMike Smith #define CISS_COMMAND_ALLOC_SIZE 512 /* XXX tune to get sensible s/g list length */ 1443a31b7ebSMike Smith #define CISS_COMMAND_SG_LENGTH ((CISS_COMMAND_ALLOC_SIZE - sizeof(struct ciss_command)) \ 1453a31b7ebSMike Smith / sizeof(struct ciss_sg_entry)) 1463a31b7ebSMike Smith 1473a31b7ebSMike Smith /* 1483a31b7ebSMike Smith * Per-logical-drive data. 1493a31b7ebSMike Smith */ 1503a31b7ebSMike Smith struct ciss_ldrive 1513a31b7ebSMike Smith { 1523a31b7ebSMike Smith union ciss_device_address cl_address; 1533a31b7ebSMike Smith 1543a31b7ebSMike Smith int cl_status; 1553a31b7ebSMike Smith #define CISS_LD_NONEXISTENT 0 1563a31b7ebSMike Smith #define CISS_LD_ONLINE 1 1573a31b7ebSMike Smith #define CISS_LD_OFFLINE 2 1583a31b7ebSMike Smith 1593a31b7ebSMike Smith struct ciss_bmic_id_ldrive *cl_ldrive; 1603a31b7ebSMike Smith struct ciss_bmic_id_lstatus *cl_lstatus; 1613a31b7ebSMike Smith 1623a31b7ebSMike Smith char cl_name[16]; /* device name */ 1633a31b7ebSMike Smith }; 1643a31b7ebSMike Smith 1653a31b7ebSMike Smith /* 1663a31b7ebSMike Smith * Per-adapter data 1673a31b7ebSMike Smith */ 1683a31b7ebSMike Smith struct ciss_softc 1693a31b7ebSMike Smith { 1703a31b7ebSMike Smith /* bus connections */ 1713a31b7ebSMike Smith device_t ciss_dev; /* bus attachment */ 1723a31b7ebSMike Smith dev_t ciss_dev_t; /* control device */ 1733a31b7ebSMike Smith 1743a31b7ebSMike Smith struct resource *ciss_regs_resource; /* register interface window */ 1753a31b7ebSMike Smith int ciss_regs_rid; /* resource ID */ 1763a31b7ebSMike Smith bus_space_handle_t ciss_regs_bhandle; /* bus space handle */ 1773a31b7ebSMike Smith bus_space_tag_t ciss_regs_btag; /* bus space tag */ 1783a31b7ebSMike Smith 1793a31b7ebSMike Smith struct resource *ciss_cfg_resource; /* config struct interface window */ 1803a31b7ebSMike Smith int ciss_cfg_rid; /* resource ID */ 1813a31b7ebSMike Smith struct ciss_config_table *ciss_cfg; /* config table in adapter memory */ 1823a31b7ebSMike Smith struct ciss_bmic_id_table *ciss_id; /* ID table in host memory */ 1833a31b7ebSMike Smith u_int32_t ciss_heartbeat; /* last heartbeat value */ 1843a31b7ebSMike Smith int ciss_heart_attack; /* number of times we have seen this value */ 1853a31b7ebSMike Smith 1863a31b7ebSMike Smith struct resource *ciss_irq_resource; /* interrupt */ 1873a31b7ebSMike Smith int ciss_irq_rid; /* resource ID */ 1883a31b7ebSMike Smith void *ciss_intr; /* interrupt handle */ 1893a31b7ebSMike Smith 1903a31b7ebSMike Smith bus_dma_tag_t ciss_parent_dmat; /* parent DMA tag */ 1913a31b7ebSMike Smith bus_dma_tag_t ciss_buffer_dmat; /* data buffer/command DMA tag */ 1923a31b7ebSMike Smith 1933a31b7ebSMike Smith u_int32_t ciss_interrupt_mask; /* controller interrupt mask bits */ 1943a31b7ebSMike Smith 1953a31b7ebSMike Smith int ciss_max_requests; 1963a31b7ebSMike Smith struct ciss_request ciss_request[CISS_MAX_REQUESTS]; /* requests */ 1973a31b7ebSMike Smith void *ciss_command; /* command structures */ 1983a31b7ebSMike Smith bus_dma_tag_t ciss_command_dmat; /* command DMA tag */ 1993a31b7ebSMike Smith bus_dmamap_t ciss_command_map; /* command DMA map */ 2003a31b7ebSMike Smith u_int32_t ciss_command_phys; /* command array base address */ 2013a31b7ebSMike Smith TAILQ_HEAD(,ciss_request) ciss_free; /* requests available for reuse */ 2023a31b7ebSMike Smith TAILQ_HEAD(,ciss_request) ciss_busy; /* requests in the adapter */ 2033a31b7ebSMike Smith TAILQ_HEAD(,ciss_request) ciss_complete; /* requests which have been returned by the adapter */ 2043a31b7ebSMike Smith 2053a31b7ebSMike Smith struct callout_handle ciss_periodic; /* periodic event handling */ 2063a31b7ebSMike Smith struct ciss_request *ciss_periodic_notify; /* notify callback request */ 2073a31b7ebSMike Smith 2083a31b7ebSMike Smith struct ciss_notify ciss_notify[CISS_MAX_EVENTS]; 2093a31b7ebSMike Smith int ciss_notify_head; /* saved-event ringbuffer */ 2103a31b7ebSMike Smith int ciss_notify_tail; 2113a31b7ebSMike Smith 2123a31b7ebSMike Smith struct ciss_ldrive ciss_logical[CISS_MAX_LOGICAL]; 2133a31b7ebSMike Smith 2143a31b7ebSMike Smith struct cam_devq *ciss_cam_devq; 2153a31b7ebSMike Smith struct cam_sim *ciss_cam_sim; 2163a31b7ebSMike Smith struct cam_path *ciss_cam_path; 2173a31b7ebSMike Smith 2183a31b7ebSMike Smith int ciss_flags; 2193a31b7ebSMike Smith #define CISS_FLAG_NOTIFY_OK (1<<0) /* notify command running OK */ 2203a31b7ebSMike Smith #define CISS_FLAG_CONTROL_OPEN (1<<1) /* control device is open */ 2213a31b7ebSMike Smith #define CISS_FLAG_ABORTING (1<<2) /* driver is going away */ 2223a31b7ebSMike Smith #define CISS_FLAG_RUNNING (1<<3) /* driver is running (interrupts usable) */ 2233a31b7ebSMike Smith 2243a31b7ebSMike Smith #define CISS_FLAG_FAKE_SYNCH (1<<16) /* needs SYNCHRONISE_CACHE faked */ 2253a31b7ebSMike Smith #define CISS_FLAG_BMIC_ABORT (1<<17) /* use BMIC command to abort Notify on Event */ 2263a31b7ebSMike Smith 2273a31b7ebSMike Smith struct ciss_qstat ciss_qstat[CISSQ_COUNT]; /* queue statistics */ 2283a31b7ebSMike Smith }; 2293a31b7ebSMike Smith 2303a31b7ebSMike Smith /* 2313a31b7ebSMike Smith * Given a request tag, find the corresponding command in virtual or 2323a31b7ebSMike Smith * physical space. 2333a31b7ebSMike Smith * 2343a31b7ebSMike Smith * The arithmetic here is due to the allocation of ciss_command structures 2353a31b7ebSMike Smith * inside CISS_COMMAND_ALLOC_SIZE blocks. See the comment at the definition 2363a31b7ebSMike Smith * of CISS_COMMAND_ALLOC_SIZE above. 2373a31b7ebSMike Smith */ 2383a31b7ebSMike Smith #define CISS_FIND_COMMAND(cr) \ 2393a31b7ebSMike Smith (struct ciss_command *)((u_int8_t *)(cr)->cr_sc->ciss_command + \ 2403a31b7ebSMike Smith ((cr)->cr_tag * CISS_COMMAND_ALLOC_SIZE)) 2413a31b7ebSMike Smith #define CISS_FIND_COMMANDPHYS(cr) ((cr)->cr_sc->ciss_command_phys + \ 2423a31b7ebSMike Smith ((cr)->cr_tag * CISS_COMMAND_ALLOC_SIZE)) 2433a31b7ebSMike Smith 2443a31b7ebSMike Smith /************************************************************************ 2453a31b7ebSMike Smith * Debugging/diagnostic output. 2463a31b7ebSMike Smith */ 2473a31b7ebSMike Smith 2483a31b7ebSMike Smith /* 2493a31b7ebSMike Smith * Debugging levels: 2503a31b7ebSMike Smith * 0 - quiet, only emit warnings 2513a31b7ebSMike Smith * 1 - talkative, log major events, but nothing on the I/O path 2523a31b7ebSMike Smith * 2 - noisy, log events on the I/O path 2533a31b7ebSMike Smith * 3 - extremely noisy, log items in loops 2543a31b7ebSMike Smith */ 2553a31b7ebSMike Smith #ifdef CISS_DEBUG 2563a31b7ebSMike Smith # define debug(level, fmt, args...) \ 2573a31b7ebSMike Smith do { \ 2583a31b7ebSMike Smith if (level <= CISS_DEBUG) printf("%s: " fmt "\n", __FUNCTION__ , ##args); \ 2593a31b7ebSMike Smith } while(0) 2603a31b7ebSMike Smith # define debug_called(level) \ 2613a31b7ebSMike Smith do { \ 2623a31b7ebSMike Smith if (level <= CISS_DEBUG) printf(__FUNCTION__ ": called\n"); \ 2633a31b7ebSMike Smith } while(0) 2643a31b7ebSMike Smith # define debug_struct(s) printf(" SIZE %s: %d\n", #s, sizeof(struct s)) 2653a31b7ebSMike Smith # define debug_union(s) printf(" SIZE %s: %d\n", #s, sizeof(union s)) 2663a31b7ebSMike Smith # define debug_type(s) printf(" SIZE %s: %d\n", #s, sizeof(s)) 2673a31b7ebSMike Smith # define debug_field(s, f) printf(" OFFSET %s.%s: %d\n", #s, #f, ((int)&(((struct s *)0)->f))) 2683a31b7ebSMike Smith # define debug_const(c) printf(" CONST %s %d/0x%x\n", #c, c, c); 2693a31b7ebSMike Smith #else 2703a31b7ebSMike Smith # define debug(level, fmt, args...) 2713a31b7ebSMike Smith # define debug_called(level) 2723a31b7ebSMike Smith # define debug_struct(s) 2733a31b7ebSMike Smith # define debug_union(s) 2743a31b7ebSMike Smith # define debug_type(s) 2753a31b7ebSMike Smith # define debug_field(s, f) 2763a31b7ebSMike Smith # define debug_const(c) 2773a31b7ebSMike Smith #endif 2783a31b7ebSMike Smith 2793a31b7ebSMike Smith #define ciss_printf(sc, fmt, args...) device_printf(sc->ciss_dev, fmt , ##args) 2803a31b7ebSMike Smith 2813a31b7ebSMike Smith /************************************************************************ 2823a31b7ebSMike Smith * Queue primitives 2833a31b7ebSMike Smith */ 2843a31b7ebSMike Smith 2853a31b7ebSMike Smith #define CISSQ_ADD(sc, qname) \ 2863a31b7ebSMike Smith do { \ 2873a31b7ebSMike Smith struct ciss_qstat *qs = &(sc)->ciss_qstat[qname]; \ 2883a31b7ebSMike Smith \ 2893a31b7ebSMike Smith qs->q_length++; \ 2903a31b7ebSMike Smith if (qs->q_length > qs->q_max) \ 2913a31b7ebSMike Smith qs->q_max = qs->q_length; \ 2923a31b7ebSMike Smith } while(0) 2933a31b7ebSMike Smith 2943a31b7ebSMike Smith #define CISSQ_REMOVE(sc, qname) (sc)->ciss_qstat[qname].q_length-- 2953a31b7ebSMike Smith #define CISSQ_INIT(sc, qname) \ 2963a31b7ebSMike Smith do { \ 2973a31b7ebSMike Smith sc->ciss_qstat[qname].q_length = 0; \ 2983a31b7ebSMike Smith sc->ciss_qstat[qname].q_max = 0; \ 2993a31b7ebSMike Smith } while(0) 3003a31b7ebSMike Smith 3013a31b7ebSMike Smith 3023a31b7ebSMike Smith #define CISSQ_REQUEST_QUEUE(name, index) \ 3033a31b7ebSMike Smith static __inline void \ 3043a31b7ebSMike Smith ciss_initq_ ## name (struct ciss_softc *sc) \ 3053a31b7ebSMike Smith { \ 3063a31b7ebSMike Smith TAILQ_INIT(&sc->ciss_ ## name); \ 3073a31b7ebSMike Smith CISSQ_INIT(sc, index); \ 3083a31b7ebSMike Smith } \ 3093a31b7ebSMike Smith static __inline void \ 3103a31b7ebSMike Smith ciss_enqueue_ ## name (struct ciss_request *cr) \ 3113a31b7ebSMike Smith { \ 3123a31b7ebSMike Smith int s; \ 3133a31b7ebSMike Smith \ 3143a31b7ebSMike Smith s = splcam(); \ 3153a31b7ebSMike Smith TAILQ_INSERT_TAIL(&cr->cr_sc->ciss_ ## name, cr, cr_link); \ 3163a31b7ebSMike Smith CISSQ_ADD(cr->cr_sc, index); \ 3173a31b7ebSMike Smith cr->cr_onq = index; \ 3183a31b7ebSMike Smith splx(s); \ 3193a31b7ebSMike Smith } \ 3203a31b7ebSMike Smith static __inline void \ 3213a31b7ebSMike Smith ciss_requeue_ ## name (struct ciss_request *cr) \ 3223a31b7ebSMike Smith { \ 3233a31b7ebSMike Smith int s; \ 3243a31b7ebSMike Smith \ 3253a31b7ebSMike Smith s = splcam(); \ 3263a31b7ebSMike Smith TAILQ_INSERT_HEAD(&cr->cr_sc->ciss_ ## name, cr, cr_link); \ 3273a31b7ebSMike Smith CISSQ_ADD(cr->cr_sc, index); \ 3283a31b7ebSMike Smith cr->cr_onq = index; \ 3293a31b7ebSMike Smith splx(s); \ 3303a31b7ebSMike Smith } \ 3313a31b7ebSMike Smith static __inline struct ciss_request * \ 3323a31b7ebSMike Smith ciss_dequeue_ ## name (struct ciss_softc *sc) \ 3333a31b7ebSMike Smith { \ 3343a31b7ebSMike Smith struct ciss_request *cr; \ 3353a31b7ebSMike Smith int s; \ 3363a31b7ebSMike Smith \ 3373a31b7ebSMike Smith s = splcam(); \ 3383a31b7ebSMike Smith if ((cr = TAILQ_FIRST(&sc->ciss_ ## name)) != NULL) { \ 3393a31b7ebSMike Smith TAILQ_REMOVE(&sc->ciss_ ## name, cr, cr_link); \ 3403a31b7ebSMike Smith CISSQ_REMOVE(sc, index); \ 3413a31b7ebSMike Smith cr->cr_onq = -1; \ 3423a31b7ebSMike Smith } \ 3433a31b7ebSMike Smith splx(s); \ 3443a31b7ebSMike Smith return(cr); \ 3453a31b7ebSMike Smith } \ 3463a31b7ebSMike Smith static __inline int \ 3473a31b7ebSMike Smith ciss_remove_ ## name (struct ciss_request *cr) \ 3483a31b7ebSMike Smith { \ 3493a31b7ebSMike Smith int s, error; \ 3503a31b7ebSMike Smith \ 3513a31b7ebSMike Smith s = splcam(); \ 3523a31b7ebSMike Smith if (cr->cr_onq != index) { \ 3533a31b7ebSMike Smith printf("request on queue %d (expected %d)\n", cr->cr_onq, index);\ 3543a31b7ebSMike Smith error = 1; \ 3553a31b7ebSMike Smith } else { \ 3563a31b7ebSMike Smith TAILQ_REMOVE(&cr->cr_sc->ciss_ ## name, cr, cr_link); \ 3573a31b7ebSMike Smith CISSQ_REMOVE(cr->cr_sc, index); \ 3583a31b7ebSMike Smith cr->cr_onq = -1; \ 3593a31b7ebSMike Smith error = 0; \ 3603a31b7ebSMike Smith } \ 3613a31b7ebSMike Smith splx(s); \ 3623a31b7ebSMike Smith return(error); \ 3633a31b7ebSMike Smith } \ 3643a31b7ebSMike Smith struct hack 3653a31b7ebSMike Smith 3663a31b7ebSMike Smith CISSQ_REQUEST_QUEUE(free, CISSQ_FREE); 3673a31b7ebSMike Smith CISSQ_REQUEST_QUEUE(busy, CISSQ_BUSY); 3683a31b7ebSMike Smith CISSQ_REQUEST_QUEUE(complete, CISSQ_COMPLETE); 3693a31b7ebSMike Smith 3703a31b7ebSMike Smith /******************************************************************************** 3713a31b7ebSMike Smith * space-fill a character string 3723a31b7ebSMike Smith */ 3733a31b7ebSMike Smith static __inline void 3743a31b7ebSMike Smith padstr(char *targ, const char *src, int len) 3753a31b7ebSMike Smith { 3763a31b7ebSMike Smith while (len-- > 0) { 3773a31b7ebSMike Smith if (*src != 0) { 3783a31b7ebSMike Smith *targ++ = *src++; 3793a31b7ebSMike Smith } else { 3803a31b7ebSMike Smith *targ++ = ' '; 3813a31b7ebSMike Smith } 3823a31b7ebSMike Smith } 3833a31b7ebSMike Smith } 384