1*7836SJohn.Forte@Sun.COM /* 2*7836SJohn.Forte@Sun.COM * CDDL HEADER START 3*7836SJohn.Forte@Sun.COM * 4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 7*7836SJohn.Forte@Sun.COM * 8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 11*7836SJohn.Forte@Sun.COM * and limitations under the License. 12*7836SJohn.Forte@Sun.COM * 13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*7836SJohn.Forte@Sun.COM * 19*7836SJohn.Forte@Sun.COM * CDDL HEADER END 20*7836SJohn.Forte@Sun.COM */ 21*7836SJohn.Forte@Sun.COM /* 22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*7836SJohn.Forte@Sun.COM * Use is subject to license terms. 24*7836SJohn.Forte@Sun.COM */ 25*7836SJohn.Forte@Sun.COM 26*7836SJohn.Forte@Sun.COM 27*7836SJohn.Forte@Sun.COM #ifndef _SD_IOB_H 28*7836SJohn.Forte@Sun.COM #define _SD_IOB_H 29*7836SJohn.Forte@Sun.COM 30*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 31*7836SJohn.Forte@Sun.COM extern "C" { 32*7836SJohn.Forte@Sun.COM #endif 33*7836SJohn.Forte@Sun.COM 34*7836SJohn.Forte@Sun.COM #define MAX_HOOK_LOCKS 32 35*7836SJohn.Forte@Sun.COM typedef int (*dcb_t)(struct buf *); /* driver callback type */ 36*7836SJohn.Forte@Sun.COM 37*7836SJohn.Forte@Sun.COM /* 38*7836SJohn.Forte@Sun.COM * order of end action calls: 39*7836SJohn.Forte@Sun.COM * driver callback (iob_drv_iodone) is stuffed in b_iodone and called by 40*7836SJohn.Forte@Sun.COM * the device driver when i/o completes. It calls the hook end action 41*7836SJohn.Forte@Sun.COM * (iob_hook_iodone) which maintains the completion count (iob_hook.count) 42*7836SJohn.Forte@Sun.COM * and calls the clients end action (iob_hook.func) when the chain is complete. 43*7836SJohn.Forte@Sun.COM */ 44*7836SJohn.Forte@Sun.COM typedef struct iob_hook { 45*7836SJohn.Forte@Sun.COM struct iob_hook *next_hook; 46*7836SJohn.Forte@Sun.COM struct buf *chain; /* all the buffers for this iob */ 47*7836SJohn.Forte@Sun.COM struct buf *tail; /* tail of buffer chain */ 48*7836SJohn.Forte@Sun.COM int count; /* number of bufs on the chain */ 49*7836SJohn.Forte@Sun.COM nsc_off_t start_fba; /* initial disk block for the xfer */ 50*7836SJohn.Forte@Sun.COM nsc_off_t last_fba; /* last disk block for the xfer */ 51*7836SJohn.Forte@Sun.COM nsc_size_t size; /* # bytes for entire transfer */ 52*7836SJohn.Forte@Sun.COM unsigned char *last_vaddr; /* ending addr of last i/o request */ 53*7836SJohn.Forte@Sun.COM sdbc_ea_fn_t func; /* clients end action routine */ 54*7836SJohn.Forte@Sun.COM int (* iob_hook_iodone)(struct buf *, struct iob_hook *); 55*7836SJohn.Forte@Sun.COM dcb_t iob_drv_iodone; /* driver call back */ 56*7836SJohn.Forte@Sun.COM blind_t param; /* param for clnt end action routine */ 57*7836SJohn.Forte@Sun.COM int flags; /* flags for each buffer */ 58*7836SJohn.Forte@Sun.COM int error; /* any error */ 59*7836SJohn.Forte@Sun.COM int skipped; /* this iob used sd_add_mem */ 60*7836SJohn.Forte@Sun.COM kmutex_t *lockp; /* mutex for releasing buffers */ 61*7836SJohn.Forte@Sun.COM kcondvar_t wait; /* sync for sleeping on synch i/o */ 62*7836SJohn.Forte@Sun.COM #ifdef _SD_BIO_STATS 63*7836SJohn.Forte@Sun.COM int PAGE_IO, NORM_IO, SKIP_IO; 64*7836SJohn.Forte@Sun.COM int PAGE_COMBINED; 65*7836SJohn.Forte@Sun.COM nsc_size_t NORM_IO_SIZE; 66*7836SJohn.Forte@Sun.COM #endif /* _SD_BIO_STATS */ 67*7836SJohn.Forte@Sun.COM } iob_hook_t; 68*7836SJohn.Forte@Sun.COM 69*7836SJohn.Forte@Sun.COM typedef struct _sd_buf_list { 70*7836SJohn.Forte@Sun.COM iob_hook_t *hooks; /* all of the iob hooks */ 71*7836SJohn.Forte@Sun.COM iob_hook_t *hook_head; /* free iob hook */ 72*7836SJohn.Forte@Sun.COM int bl_init_count; /* total count */ 73*7836SJohn.Forte@Sun.COM int bl_hooks_avail; /* monitor available hook count */ 74*7836SJohn.Forte@Sun.COM int bl_hook_lowmark; /* record if ever run out of hooks */ 75*7836SJohn.Forte@Sun.COM int hook_waiters; /* count of waiters */ 76*7836SJohn.Forte@Sun.COM int max_hook_waiters; /* record max ever waiters */ 77*7836SJohn.Forte@Sun.COM kcondvar_t hook_wait; /* sync for sleeping on synch i/o */ 78*7836SJohn.Forte@Sun.COM kmutex_t hook_locks[MAX_HOOK_LOCKS]; 79*7836SJohn.Forte@Sun.COM } _sd_buf_list_t; 80*7836SJohn.Forte@Sun.COM 81*7836SJohn.Forte@Sun.COM /* 82*7836SJohn.Forte@Sun.COM * NOTE: if you change this, then also make changes to the generation 83*7836SJohn.Forte@Sun.COM * of sd_iob_impl*.c in src/uts/common/Makefile.files and Makefile.rules! 84*7836SJohn.Forte@Sun.COM */ 85*7836SJohn.Forte@Sun.COM #define _SD_DEFAULT_IOBUFS 4096 86*7836SJohn.Forte@Sun.COM 87*7836SJohn.Forte@Sun.COM /* define driver callback and driver callback function table */ 88*7836SJohn.Forte@Sun.COM 89*7836SJohn.Forte@Sun.COM #define IOB_DCBP(i) (sd_iob_dcb ## i) 90*7836SJohn.Forte@Sun.COM 91*7836SJohn.Forte@Sun.COM #define IOB_DCB(i) \ 92*7836SJohn.Forte@Sun.COM int \ 93*7836SJohn.Forte@Sun.COM IOB_DCBP(i)(struct buf *bp) \ 94*7836SJohn.Forte@Sun.COM { \ 95*7836SJohn.Forte@Sun.COM return ((*_sd_buflist.hooks[i].iob_hook_iodone) \ 96*7836SJohn.Forte@Sun.COM (bp, &_sd_buflist.hooks[i])); \ 97*7836SJohn.Forte@Sun.COM } 98*7836SJohn.Forte@Sun.COM 99*7836SJohn.Forte@Sun.COM extern _sd_buf_list_t _sd_buflist; 100*7836SJohn.Forte@Sun.COM 101*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 102*7836SJohn.Forte@Sun.COM } 103*7836SJohn.Forte@Sun.COM #endif 104*7836SJohn.Forte@Sun.COM 105*7836SJohn.Forte@Sun.COM #endif /* _SD_IOB_H */ 106