13a31b7ebSMike Smith /*- 2*718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*718cf2ccSPedro F. Giffuni * 43a31b7ebSMike Smith * Copyright (c) 2001 Michael Smith 53a31b7ebSMike Smith * All rights reserved. 63a31b7ebSMike Smith * 73a31b7ebSMike Smith * Redistribution and use in source and binary forms, with or without 83a31b7ebSMike Smith * modification, are permitted provided that the following conditions 93a31b7ebSMike Smith * are met: 103a31b7ebSMike Smith * 1. Redistributions of source code must retain the above copyright 113a31b7ebSMike Smith * notice, this list of conditions and the following disclaimer. 123a31b7ebSMike Smith * 2. Redistributions in binary form must reproduce the above copyright 133a31b7ebSMike Smith * notice, this list of conditions and the following disclaimer in the 143a31b7ebSMike Smith * documentation and/or other materials provided with the distribution. 153a31b7ebSMike Smith * 163a31b7ebSMike Smith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 173a31b7ebSMike Smith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 183a31b7ebSMike Smith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 193a31b7ebSMike Smith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 203a31b7ebSMike Smith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 213a31b7ebSMike Smith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 223a31b7ebSMike Smith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 233a31b7ebSMike Smith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 243a31b7ebSMike Smith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 253a31b7ebSMike Smith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 263a31b7ebSMike Smith * SUCH DAMAGE. 273a31b7ebSMike Smith * 283a31b7ebSMike Smith * $FreeBSD$ 293a31b7ebSMike Smith */ 303a31b7ebSMike Smith 313a31b7ebSMike Smith /* 323a31b7ebSMike Smith * CISS adapter driver datastructures 333a31b7ebSMike Smith */ 343a31b7ebSMike Smith 3522657ce1SScott Long typedef STAILQ_HEAD(, ciss_request) cr_qhead_t; 3622657ce1SScott Long 373a31b7ebSMike Smith /************************************************************************ 383a31b7ebSMike Smith * Tunable parameters 393a31b7ebSMike Smith */ 403a31b7ebSMike Smith 413a31b7ebSMike Smith /* 423a31b7ebSMike Smith * There is no guaranteed upper bound on the number of concurrent 433a31b7ebSMike Smith * commands an adapter may claim to support. Cap it at a reasonable 443a31b7ebSMike Smith * value. 453a31b7ebSMike Smith */ 4695dab4f2SAlexander Motin #define CISS_MAX_REQUESTS 1024 473a31b7ebSMike Smith 483a31b7ebSMike Smith /* 493a31b7ebSMike Smith * Maximum number of logical drives we support. 50e3edca22SSean Bruno * If the controller does not indicate a maximum 51e3edca22SSean Bruno * value. This is a compatibiliy value to support 52e3edca22SSean Bruno * older ciss controllers (e.g. model 6i) 533a31b7ebSMike Smith */ 54e3edca22SSean Bruno #define CISS_MAX_LOGICAL 16 553a31b7ebSMike Smith 563a31b7ebSMike Smith /* 57c6131460SPaul Saab * Maximum number of physical devices we support. 58c6131460SPaul Saab */ 59c6131460SPaul Saab #define CISS_MAX_PHYSICAL 1024 60c6131460SPaul Saab 61c6131460SPaul Saab /* 623a31b7ebSMike Smith * Interrupt reduction can be controlled by tuning the interrupt 63453130d9SPedro F. Giffuni * coalesce delay and count parameters. The delay (in microseconds) 643a31b7ebSMike Smith * defers delivery of interrupts to increase the chance of there being 653a31b7ebSMike Smith * more than one completed command ready when the interrupt is 663a31b7ebSMike Smith * delivered. The count expedites the delivery of the interrupt when 673a31b7ebSMike Smith * the given number of commands are ready. 683a31b7ebSMike Smith * 693a31b7ebSMike Smith * If the delay is set to 0, interrupts are delivered immediately. 703a31b7ebSMike Smith */ 7122657ce1SScott Long #define CISS_INTERRUPT_COALESCE_DELAY 0 723a31b7ebSMike Smith #define CISS_INTERRUPT_COALESCE_COUNT 16 733a31b7ebSMike Smith 743a31b7ebSMike Smith /* 753a31b7ebSMike Smith * Heartbeat routine timeout in seconds. Note that since event 763a31b7ebSMike Smith * handling is performed on a callback basis, we don't need this to 773a31b7ebSMike Smith * run very often. 783a31b7ebSMike Smith */ 793a31b7ebSMike Smith #define CISS_HEARTBEAT_RATE 10 803a31b7ebSMike Smith 813a31b7ebSMike Smith /************************************************************************ 823a31b7ebSMike Smith * Driver version. Only really significant to the ACU interface. 833a31b7ebSMike Smith */ 84d3e4392cSMike Smith #define CISS_DRIVER_VERSION 20011201 853a31b7ebSMike Smith 863a31b7ebSMike Smith /************************************************************************ 873a31b7ebSMike Smith * Driver data structures 883a31b7ebSMike Smith */ 893a31b7ebSMike Smith 903a31b7ebSMike Smith /* 913a31b7ebSMike Smith * Each command issued to the adapter is managed by a request 923a31b7ebSMike Smith * structure. 933a31b7ebSMike Smith */ 943a31b7ebSMike Smith struct ciss_request 953a31b7ebSMike Smith { 9622657ce1SScott Long STAILQ_ENTRY(ciss_request) cr_link; 973a31b7ebSMike Smith int cr_onq; /* which queue we are on */ 983a31b7ebSMike Smith 993a31b7ebSMike Smith struct ciss_softc *cr_sc; /* controller softc */ 1003a31b7ebSMike Smith void *cr_data; /* data buffer */ 1013a31b7ebSMike Smith u_int32_t cr_length; /* data length */ 1023a31b7ebSMike Smith bus_dmamap_t cr_datamap; /* DMA map for data */ 1032fdaa90dSScott Long struct ciss_command *cr_cc; 1042fdaa90dSScott Long uint32_t cr_ccphys; 1053a31b7ebSMike Smith int cr_tag; 1063a31b7ebSMike Smith int cr_flags; 1073a31b7ebSMike Smith #define CISS_REQ_MAPPED (1<<0) /* data mapped */ 1083a31b7ebSMike Smith #define CISS_REQ_SLEEP (1<<1) /* submitter sleeping */ 1093a31b7ebSMike Smith #define CISS_REQ_POLL (1<<2) /* submitter polling */ 1103a31b7ebSMike Smith #define CISS_REQ_DATAOUT (1<<3) /* data host->adapter */ 1113a31b7ebSMike Smith #define CISS_REQ_DATAIN (1<<4) /* data adapter->host */ 11222657ce1SScott Long #define CISS_REQ_BUSY (1<<5) /* controller has req */ 113dd0b4fb6SKonstantin Belousov #define CISS_REQ_CCB (1<<6) /* data is ccb */ 1143a31b7ebSMike Smith 1153a31b7ebSMike Smith void (* cr_complete)(struct ciss_request *); 1163a31b7ebSMike Smith void *cr_private; 11722657ce1SScott Long int cr_sg_tag; 11822657ce1SScott Long #define CISS_SG_MAX ((CISS_SG_FETCH_MAX << 1) | 0x1) 11922657ce1SScott Long #define CISS_SG_1 ((CISS_SG_FETCH_1 << 1) | 0x01) 12022657ce1SScott Long #define CISS_SG_2 ((CISS_SG_FETCH_2 << 1) | 0x01) 12122657ce1SScott Long #define CISS_SG_4 ((CISS_SG_FETCH_4 << 1) | 0x01) 12222657ce1SScott Long #define CISS_SG_8 ((CISS_SG_FETCH_8 << 1) | 0x01) 12322657ce1SScott Long #define CISS_SG_16 ((CISS_SG_FETCH_16 << 1) | 0x01) 12422657ce1SScott Long #define CISS_SG_32 ((CISS_SG_FETCH_32 << 1) | 0x01) 12522657ce1SScott Long #define CISS_SG_NONE ((CISS_SG_FETCH_NONE << 1) | 0x01) 1263a31b7ebSMike Smith }; 1273a31b7ebSMike Smith 1283a31b7ebSMike Smith /* 1293a31b7ebSMike Smith * The adapter command structure is defined with a zero-length 1303a31b7ebSMike Smith * scatter/gather list size. In practise, we want space for a 1313a31b7ebSMike Smith * scatter-gather list, and we also want to avoid having commands 1323a31b7ebSMike Smith * cross page boundaries. 1333a31b7ebSMike Smith * 1342fdaa90dSScott Long * The size of the ciss_command is 52 bytes. 65 s/g elements are reserved 1352fdaa90dSScott Long * to allow a max i/o size of 256k. This gives a total command size of 1362fdaa90dSScott Long * 1120 bytes, including the 32 byte alignment padding. Modern controllers 1372fdaa90dSScott Long * seem to saturate nicely at this value. 1383a31b7ebSMike Smith */ 1393a31b7ebSMike Smith 1402fdaa90dSScott Long #define CISS_MAX_SG_ELEMENTS 65 1412fdaa90dSScott Long #define CISS_COMMAND_ALIGN 32 1422fdaa90dSScott Long #define CISS_COMMAND_SG_LENGTH (sizeof(struct ciss_sg_entry) * CISS_MAX_SG_ELEMENTS) 1432fdaa90dSScott Long #define CISS_COMMAND_ALLOC_SIZE (roundup2(sizeof(struct ciss_command) + CISS_COMMAND_SG_LENGTH, CISS_COMMAND_ALIGN)) 14452c9ce25SScott Long 1453a31b7ebSMike Smith /* 1463a31b7ebSMike Smith * Per-logical-drive data. 1473a31b7ebSMike Smith */ 1483a31b7ebSMike Smith struct ciss_ldrive 1493a31b7ebSMike Smith { 1503a31b7ebSMike Smith union ciss_device_address cl_address; 151c6131460SPaul Saab union ciss_device_address *cl_controller; 1523a31b7ebSMike Smith int cl_status; 1533a31b7ebSMike Smith #define CISS_LD_NONEXISTENT 0 1543a31b7ebSMike Smith #define CISS_LD_ONLINE 1 1553a31b7ebSMike Smith #define CISS_LD_OFFLINE 2 1563a31b7ebSMike Smith 157c6131460SPaul Saab int cl_update; 158c6131460SPaul Saab 1593a31b7ebSMike Smith struct ciss_bmic_id_ldrive *cl_ldrive; 1603a31b7ebSMike Smith struct ciss_bmic_id_lstatus *cl_lstatus; 161440baa08SPaul Saab struct ciss_ldrive_geometry cl_geometry; 1623a31b7ebSMike Smith 1633a31b7ebSMike Smith char cl_name[16]; /* device name */ 1643a31b7ebSMike Smith }; 1653a31b7ebSMike Smith 1663a31b7ebSMike Smith /* 1671fe6c4eeSScott Long * Per-physical-drive data 1681fe6c4eeSScott Long */ 1691fe6c4eeSScott Long struct ciss_pdrive 1701fe6c4eeSScott Long { 1711fe6c4eeSScott Long union ciss_device_address cp_address; 1721fe6c4eeSScott Long int cp_online; 1731fe6c4eeSScott Long }; 1741fe6c4eeSScott Long 1751fe6c4eeSScott Long #define CISS_PHYSICAL_SHIFT 5 1761fe6c4eeSScott Long #define CISS_PHYSICAL_BASE (1 << CISS_PHYSICAL_SHIFT) 177c7241f65SScott Long #define CISS_MAX_PHYSTGT 256 1781fe6c4eeSScott Long 1791fe6c4eeSScott Long #define CISS_IS_PHYSICAL(bus) (bus >= CISS_PHYSICAL_BASE) 1801fe6c4eeSScott Long #define CISS_CAM_TO_PBUS(bus) (bus - CISS_PHYSICAL_BASE) 1811fe6c4eeSScott Long 1821fe6c4eeSScott Long /* 1833a31b7ebSMike Smith * Per-adapter data 1843a31b7ebSMike Smith */ 1853a31b7ebSMike Smith struct ciss_softc 1863a31b7ebSMike Smith { 1873a31b7ebSMike Smith /* bus connections */ 1883a31b7ebSMike Smith device_t ciss_dev; /* bus attachment */ 18989c9c53dSPoul-Henning Kamp struct cdev *ciss_dev_t; /* control device */ 1903a31b7ebSMike Smith 1913a31b7ebSMike Smith struct resource *ciss_regs_resource; /* register interface window */ 1923a31b7ebSMike Smith int ciss_regs_rid; /* resource ID */ 1933a31b7ebSMike Smith bus_space_handle_t ciss_regs_bhandle; /* bus space handle */ 1943a31b7ebSMike Smith bus_space_tag_t ciss_regs_btag; /* bus space tag */ 1953a31b7ebSMike Smith 1963a31b7ebSMike Smith struct resource *ciss_cfg_resource; /* config struct interface window */ 1973a31b7ebSMike Smith int ciss_cfg_rid; /* resource ID */ 1983a31b7ebSMike Smith struct ciss_config_table *ciss_cfg; /* config table in adapter memory */ 19922657ce1SScott Long struct ciss_perf_config *ciss_perf; /* config table for the performant */ 2003a31b7ebSMike Smith struct ciss_bmic_id_table *ciss_id; /* ID table in host memory */ 2013a31b7ebSMike Smith u_int32_t ciss_heartbeat; /* last heartbeat value */ 2023a31b7ebSMike Smith int ciss_heart_attack; /* number of times we have seen this value */ 2033a31b7ebSMike Smith 20422657ce1SScott Long int ciss_msi; 2053a31b7ebSMike Smith struct resource *ciss_irq_resource; /* interrupt */ 20622657ce1SScott Long int ciss_irq_rid[CISS_MSI_COUNT]; /* resource ID */ 2073a31b7ebSMike Smith void *ciss_intr; /* interrupt handle */ 2083a31b7ebSMike Smith 2093a31b7ebSMike Smith bus_dma_tag_t ciss_parent_dmat; /* parent DMA tag */ 2103a31b7ebSMike Smith bus_dma_tag_t ciss_buffer_dmat; /* data buffer/command DMA tag */ 2113a31b7ebSMike Smith 2123a31b7ebSMike Smith u_int32_t ciss_interrupt_mask; /* controller interrupt mask bits */ 2133a31b7ebSMike Smith 21422657ce1SScott Long uint64_t *ciss_reply; 21522657ce1SScott Long int ciss_cycle; 21622657ce1SScott Long int ciss_rqidx; 21722657ce1SScott Long bus_dma_tag_t ciss_reply_dmat; 21822657ce1SScott Long bus_dmamap_t ciss_reply_map; 21922657ce1SScott Long uint32_t ciss_reply_phys; 22022657ce1SScott Long 2213a31b7ebSMike Smith int ciss_max_requests; 2223a31b7ebSMike Smith struct ciss_request ciss_request[CISS_MAX_REQUESTS]; /* requests */ 2233a31b7ebSMike Smith void *ciss_command; /* command structures */ 2243a31b7ebSMike Smith bus_dma_tag_t ciss_command_dmat; /* command DMA tag */ 2253a31b7ebSMike Smith bus_dmamap_t ciss_command_map; /* command DMA map */ 2263a31b7ebSMike Smith u_int32_t ciss_command_phys; /* command array base address */ 22722657ce1SScott Long cr_qhead_t ciss_free; /* requests available for reuse */ 22822657ce1SScott Long cr_qhead_t ciss_notify; /* requests which are defered for processing */ 229c6131460SPaul Saab struct proc *ciss_notify_thread; 2303a31b7ebSMike Smith 231975b7318SScott Long struct callout ciss_periodic; /* periodic event handling */ 2323a31b7ebSMike Smith struct ciss_request *ciss_periodic_notify; /* notify callback request */ 2333a31b7ebSMike Smith 234975b7318SScott Long struct mtx ciss_mtx; 235c6131460SPaul Saab struct ciss_ldrive **ciss_logical; 2361fe6c4eeSScott Long struct ciss_pdrive **ciss_physical; 237c6131460SPaul Saab union ciss_device_address *ciss_controllers; /* controller address */ 238c6131460SPaul Saab int ciss_max_bus_number; /* maximum bus number */ 2391fe6c4eeSScott Long int ciss_max_logical_bus; 2401fe6c4eeSScott Long int ciss_max_physical_bus; 2413a31b7ebSMike Smith 2423a31b7ebSMike Smith struct cam_devq *ciss_cam_devq; 243c6131460SPaul Saab struct cam_sim **ciss_cam_sim; 2443a31b7ebSMike Smith 24517c0792dSPaul Saab int ciss_soft_reset; 24617c0792dSPaul Saab 2473a31b7ebSMike Smith int ciss_flags; 2483a31b7ebSMike Smith #define CISS_FLAG_NOTIFY_OK (1<<0) /* notify command running OK */ 2493a31b7ebSMike Smith #define CISS_FLAG_CONTROL_OPEN (1<<1) /* control device is open */ 2503a31b7ebSMike Smith #define CISS_FLAG_ABORTING (1<<2) /* driver is going away */ 2513a31b7ebSMike Smith #define CISS_FLAG_RUNNING (1<<3) /* driver is running (interrupts usable) */ 25295dab4f2SAlexander Motin #define CISS_FLAG_BUSY (1<<4) /* no free commands */ 2533a31b7ebSMike Smith 2543a31b7ebSMike Smith #define CISS_FLAG_FAKE_SYNCH (1<<16) /* needs SYNCHRONISE_CACHE faked */ 2553a31b7ebSMike Smith #define CISS_FLAG_BMIC_ABORT (1<<17) /* use BMIC command to abort Notify on Event */ 256c6131460SPaul Saab #define CISS_FLAG_THREAD_SHUT (1<<20) /* shutdown the kthread */ 2573a31b7ebSMike Smith 2583a31b7ebSMike Smith struct ciss_qstat ciss_qstat[CISSQ_COUNT]; /* queue statistics */ 2593a31b7ebSMike Smith }; 2603a31b7ebSMike Smith 2613a31b7ebSMike Smith /************************************************************************ 2623a31b7ebSMike Smith * Debugging/diagnostic output. 2633a31b7ebSMike Smith */ 2643a31b7ebSMike Smith 2653a31b7ebSMike Smith /* 2663a31b7ebSMike Smith * Debugging levels: 2673a31b7ebSMike Smith * 0 - quiet, only emit warnings 2683a31b7ebSMike Smith * 1 - talkative, log major events, but nothing on the I/O path 2693a31b7ebSMike Smith * 2 - noisy, log events on the I/O path 2703a31b7ebSMike Smith * 3 - extremely noisy, log items in loops 2713a31b7ebSMike Smith */ 2723a31b7ebSMike Smith #ifdef CISS_DEBUG 2733a31b7ebSMike Smith # define debug(level, fmt, args...) \ 2743a31b7ebSMike Smith do { \ 2756e551fb6SDavid E. O'Brien if (level <= CISS_DEBUG) printf("%s: " fmt "\n", __func__ , ##args); \ 2763a31b7ebSMike Smith } while(0) 2773a31b7ebSMike Smith # define debug_called(level) \ 2783a31b7ebSMike Smith do { \ 2796e551fb6SDavid E. O'Brien if (level <= CISS_DEBUG) printf("%s: called\n", __func__); \ 2803a31b7ebSMike Smith } while(0) 2814caad4e8SMaxime Henrion # define debug_struct(s) printf(" SIZE %s: %zu\n", #s, sizeof(struct s)) 2824caad4e8SMaxime Henrion # define debug_union(s) printf(" SIZE %s: %zu\n", #s, sizeof(union s)) 2834caad4e8SMaxime Henrion # define debug_type(s) printf(" SIZE %s: %zu\n", #s, sizeof(s)) 2843a31b7ebSMike Smith # define debug_field(s, f) printf(" OFFSET %s.%s: %d\n", #s, #f, ((int)&(((struct s *)0)->f))) 2854caad4e8SMaxime Henrion # define debug_const(c) printf(" CONST %s %jd/0x%jx\n", #c, (intmax_t)c, (intmax_t)c); 2863a31b7ebSMike Smith #else 2873a31b7ebSMike Smith # define debug(level, fmt, args...) 2883a31b7ebSMike Smith # define debug_called(level) 2893a31b7ebSMike Smith # define debug_struct(s) 2903a31b7ebSMike Smith # define debug_union(s) 2913a31b7ebSMike Smith # define debug_type(s) 2923a31b7ebSMike Smith # define debug_field(s, f) 2933a31b7ebSMike Smith # define debug_const(c) 2943a31b7ebSMike Smith #endif 2953a31b7ebSMike Smith 2963a31b7ebSMike Smith #define ciss_printf(sc, fmt, args...) device_printf(sc->ciss_dev, fmt , ##args) 2973a31b7ebSMike Smith 2983a31b7ebSMike Smith /************************************************************************ 2993a31b7ebSMike Smith * Queue primitives 3003a31b7ebSMike Smith */ 3013a31b7ebSMike Smith 3023a31b7ebSMike Smith #define CISSQ_ADD(sc, qname) \ 3033a31b7ebSMike Smith do { \ 3043a31b7ebSMike Smith struct ciss_qstat *qs = &(sc)->ciss_qstat[qname]; \ 3053a31b7ebSMike Smith \ 3063a31b7ebSMike Smith qs->q_length++; \ 3073a31b7ebSMike Smith if (qs->q_length > qs->q_max) \ 3083a31b7ebSMike Smith qs->q_max = qs->q_length; \ 3093a31b7ebSMike Smith } while(0) 3103a31b7ebSMike Smith 3113a31b7ebSMike Smith #define CISSQ_REMOVE(sc, qname) (sc)->ciss_qstat[qname].q_length-- 3123a31b7ebSMike Smith #define CISSQ_INIT(sc, qname) \ 3133a31b7ebSMike Smith do { \ 3143a31b7ebSMike Smith sc->ciss_qstat[qname].q_length = 0; \ 3153a31b7ebSMike Smith sc->ciss_qstat[qname].q_max = 0; \ 3163a31b7ebSMike Smith } while(0) 3173a31b7ebSMike Smith 3183a31b7ebSMike Smith 3193a31b7ebSMike Smith #define CISSQ_REQUEST_QUEUE(name, index) \ 3203a31b7ebSMike Smith static __inline void \ 3213a31b7ebSMike Smith ciss_initq_ ## name (struct ciss_softc *sc) \ 3223a31b7ebSMike Smith { \ 32322657ce1SScott Long STAILQ_INIT(&sc->ciss_ ## name); \ 3243a31b7ebSMike Smith CISSQ_INIT(sc, index); \ 3253a31b7ebSMike Smith } \ 3263a31b7ebSMike Smith static __inline void \ 3273a31b7ebSMike Smith ciss_enqueue_ ## name (struct ciss_request *cr) \ 3283a31b7ebSMike Smith { \ 3293a31b7ebSMike Smith \ 33022657ce1SScott Long STAILQ_INSERT_TAIL(&cr->cr_sc->ciss_ ## name, cr, cr_link); \ 3313a31b7ebSMike Smith CISSQ_ADD(cr->cr_sc, index); \ 3323a31b7ebSMike Smith cr->cr_onq = index; \ 3333a31b7ebSMike Smith } \ 3343a31b7ebSMike Smith static __inline void \ 3353a31b7ebSMike Smith ciss_requeue_ ## name (struct ciss_request *cr) \ 3363a31b7ebSMike Smith { \ 3373a31b7ebSMike Smith \ 33822657ce1SScott Long STAILQ_INSERT_HEAD(&cr->cr_sc->ciss_ ## name, cr, cr_link); \ 3393a31b7ebSMike Smith CISSQ_ADD(cr->cr_sc, index); \ 3403a31b7ebSMike Smith cr->cr_onq = index; \ 3413a31b7ebSMike Smith } \ 3423a31b7ebSMike Smith static __inline struct ciss_request * \ 3433a31b7ebSMike Smith ciss_dequeue_ ## name (struct ciss_softc *sc) \ 3443a31b7ebSMike Smith { \ 3453a31b7ebSMike Smith struct ciss_request *cr; \ 3463a31b7ebSMike Smith \ 34722657ce1SScott Long if ((cr = STAILQ_FIRST(&sc->ciss_ ## name)) != NULL) { \ 34822657ce1SScott Long STAILQ_REMOVE_HEAD(&sc->ciss_ ## name, cr_link); \ 3493a31b7ebSMike Smith CISSQ_REMOVE(sc, index); \ 3503a31b7ebSMike Smith cr->cr_onq = -1; \ 3513a31b7ebSMike Smith } \ 3523a31b7ebSMike Smith return(cr); \ 3533a31b7ebSMike Smith } \ 3543a31b7ebSMike Smith struct hack 3553a31b7ebSMike Smith 3563a31b7ebSMike Smith CISSQ_REQUEST_QUEUE(free, CISSQ_FREE); 357c6131460SPaul Saab CISSQ_REQUEST_QUEUE(notify, CISSQ_NOTIFY); 3583a31b7ebSMike Smith 35922657ce1SScott Long static __inline void 36022657ce1SScott Long ciss_enqueue_complete(struct ciss_request *ac, cr_qhead_t *head) 36122657ce1SScott Long { 36222657ce1SScott Long 36322657ce1SScott Long STAILQ_INSERT_TAIL(head, ac, cr_link); 36422657ce1SScott Long } 36522657ce1SScott Long 36622657ce1SScott Long static __inline struct ciss_request * 36722657ce1SScott Long ciss_dequeue_complete(struct ciss_softc *sc, cr_qhead_t *head) 36822657ce1SScott Long { 36922657ce1SScott Long struct ciss_request *ac; 37022657ce1SScott Long 37122657ce1SScott Long if ((ac = STAILQ_FIRST(head)) != NULL) 37222657ce1SScott Long STAILQ_REMOVE_HEAD(head, cr_link); 37322657ce1SScott Long return(ac); 37422657ce1SScott Long } 37522657ce1SScott Long 3763a31b7ebSMike Smith /******************************************************************************** 3773a31b7ebSMike Smith * space-fill a character string 3783a31b7ebSMike Smith */ 3793a31b7ebSMike Smith static __inline void 3803a31b7ebSMike Smith padstr(char *targ, const char *src, int len) 3813a31b7ebSMike Smith { 3823a31b7ebSMike Smith while (len-- > 0) { 3833a31b7ebSMike Smith if (*src != 0) { 3843a31b7ebSMike Smith *targ++ = *src++; 3853a31b7ebSMike Smith } else { 3863a31b7ebSMike Smith *targ++ = ' '; 3873a31b7ebSMike Smith } 3883a31b7ebSMike Smith } 3893a31b7ebSMike Smith } 39022657ce1SScott Long 39122657ce1SScott Long #define ciss_report_request(a, b, c) \ 39222657ce1SScott Long _ciss_report_request(a, b, c, __FUNCTION__) 393