fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Definitions for kstats
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Global kstat field names */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* per-cache descriptor kstats field names */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_CDKSTAT_CACHE_WRITE "sdbc_cache_write"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* dynmem kstats field names */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_MONITOR_DYNMEM "sdbc_monitor_dynmem"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_MAX_DYN_LIST "sdbc_max_dyn_list"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_CT1 "sdbc_cache_aging_ct1"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_CT2 "sdbc_cache_aging_ct2"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_CT3 "sdbc_cache_aging_ct3"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_SEC1 "sdbc_cache_aging_sec1"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_SEC2 "sdbc_cache_aging_sec2"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_SEC3 "sdbc_cache_aging_sec3"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_PCNT1 "sdbc_cache_aging_pcnt1"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_CACHE_AGING_PCNT2 "sdbc_cache_aging_pcnt2"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_MAX_HOLDS_PCNT "sdbc_max_holds_pcnt"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_DEALLOC_CNT "sdbc_dealloc_cnt"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_DMKSTAT_PROCESS_DIRECTIVE "sdbc_process_directive"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ... values are in range [0-BLK_FBAS] */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef uint32_t sdbc_cblk_fba_t; /* FBA len or offset in cache block */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef unsigned char *ucaddr_t; /* unsigned char pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Atomic exchange function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: ldstub sets all bits in the memory byte.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so far this is compatible with the usage of xmem_bu() whereby
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the values of ptr are either 0 or 1, and the xmem_bu() is used
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to set the byte to 1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define xmem_bu(val, ptr) nsc_ldstub((uint8_t *)ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CCTL flag types
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: CC_INUSE and CC_PAGEIO are dummy flags that are used in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * individual flags bytes (cc_inuse and cc_pageio) NOT cc_flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Thus they can take any convenient value, however, they must be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * distinct and non-zero.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CC_PAGEIO 0x02 /* Pagelist IO is active for cache entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Real cc_flag values.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CC_PEND_DIRTY 0x02 /* The entry needs to be reprocessed for io */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CC_PINNED 0x04 /* The entry has data that is "pinned" */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CC_PINNABLE 0x08 /* Issue pin if write fails */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CC_QHEAD 0x10 /* NSC_NOCACHE: requeue at head */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* specify the size of _sd_cctl[] array */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Individual SDBC cache block entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "cc_lock" must be held when changing dirty/valid bits.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "cc_inuse" (optimistic) atomic exchange replaces check/set of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CC_INUSE bit in cc_flag; special handling of rare collisions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "cc_pageio" flusher / client locking of pagelist io operations,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * atomic exchange - needs machine ld/st protection.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "cc_iostatus" is set by flusher without holding cc_lock,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * writer will set CC_PEND_DIRTY if cc_iostatus is set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Thus "cc_inuse", "cc_iostatus" and "cc_pageio" are volatile.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The cc_await_* values are in the main _sd_cctl to avoid over
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * signalling _cc_blkcv.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The _sd_cctl structure is aligned to group related members and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to ensure good packing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t _cc_blkcv; /* Synchronisation var to block on */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct sd_addr_s { /* Generic address structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *sa_virt; /* Virtual address of data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See notes above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_hash_hd_t cc_head; /* hash information - must be first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_next, *cc_prev; /* next and prev in a chain */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_chain; /* chaining request centries */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_dirty_next; /* for chaining sequential writes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_dirty_link; /* for chaining the dirty lists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_dirty_net_next; /* for chaining net writes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_dirty_net_link; /* for chaining net lists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t cc_seq; /* sequence number: for lru optim */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int net_iostatus; /* net status of io */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile _sd_bitmap_t net_dirty; /* net cache block dirty mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_bitmap_t cc_valid; /* Cache block valid mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_bitmap_t cc_toflush; /* Cache block deferred dirty mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile _sd_bitmap_t cc_dirty; /* Cache block dirty mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile ushort_t cc_await_use; /* # waiting for this entry (inuse) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile ushort_t cc_await_page; /* # waiting for this entry (pageio) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uchar_t cc_inuse; /* atomic_swap(CC_INUSE, cc_inuse) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uchar_t cc_pageio; /* atomic_swap(CC_PAGEIO, cc_pageio) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t cc_prot; /* Segmented LRU protection flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sd_addr_t cc_addr; /* Data address information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ss_centry_info_t *cc_write; /* mirrored writes control block */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl_sync *cc_sync; /* Cache block synchronisation blk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* support for backend i/o memory coalescing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sd_addr_t cc_anon_addr; /* address for backend mem coalescing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dynamic memory support fields */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* see defines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* size bytes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_head_dm; /* ptr to host centry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_next_dm; /* ptr to next centry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* in host/pest chain */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cc_link_list_dm; /* simple link list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ptr of all centrys */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dynmem chains */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* _sd_queue_t *cc_dmchain_q; dmqueue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cc_cblocks; /* number of centrys for size_dm */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* debugging stats */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* cache entry allocation tokens */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte intptr_t opaque[2]; /* must be initialized to 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bits for flag argument to sdbc_centry_alloc() and callees.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ALLOC_LOCKED 0x1 /* locked status of sdbc_queue_lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ALLOC_NOWAIT 0x2 /* do not block, return NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * definitions supporting the dynmem dealloc thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * definitions supporing the ddditional fields in the cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entry structure for dyn mem
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FOUND_IN_HASH_DM 0x00000100 /* used to bring cent info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* out of sd_centry_alloc() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FOUND_HOLD_OVER_DM 0x00000200 /* used to bring cent info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* out of sd_centry_alloc() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CATAGORY_ENTRY_DM (HOST_ENTRY_DM|PARASITIC_ENTRY_DM| \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ENTRY_FIELD_DM (ELIGIBLE_ENTRY_DM|HASH_ENTRY_DM|HOLD_ENTRY_DM)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* info only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PREFETCH_BUF_I 0x00040000 /* implicit read-ahead */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PREFETCH_BUF_E 0x00080000 /* explicit read-ahead */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PREFETCH_BUF_IR 0x00100000 /* release when read complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* error processing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define BAD_ENTRY_DM 0x20000000 /* inconsistent ccent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define BAD_CHAIN_DM 0x40000000 /* chain containing bad ccent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * definitions supporting the dynmem monitoring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RPT_DEALLOC_STATS1_DM 0x00000002 /* nodat,cand,host,pest,meta, */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* other,dealloc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RPT_DEALLOC_STATS2_DM 0x00000004 /* hysterisis,grossct */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * definitions supporting the processing directive bit flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define WAKE_DEALLOC_THREAD_DM 0x00000001 /* one shot - acted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* on then cleared */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_OUT_ACCEL_HIST_FLAG_DM 0x00000002 /* one shot - acted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* on then cleared */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Default - Max - Min definitions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_AGING_CT_MAX FINAL_AGING_DM /* 255 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_AGING_SEC1_MAX 255 /* arbitrary but easy to remember */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_AGING_SEC2_MAX 255 /* arbitrary but easy to remember */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_AGING_SEC3_MAX 255 /* arbitrary but easy to remember */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dynmem global structure defn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sd_dealloc_flagx; /* gen'l purpose bit flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int monitor_dynmem_process; /* bit flag indicating what to report */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int max_dyn_list; /* max num of pages to allow list to */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cache aging parameter set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_ct1; /* hosts/pests - aging hits which */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger dealloc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_ct2; /* metas - aging hits which */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger dealloc not yet imple */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_ct3; /* holds - aging hits which */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger dealloc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_sec1; /* sleep time between cache list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* exam - 100% to pcnt1 free */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_sec2; /* sleep time between cache list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* exam - pcnt1 to pcnt2 free */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_sec3; /* sleep time between cache list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* exam - pcnt2 to 0% free */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_pcnt1; /* % free when to kick in accel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* aging - sec2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cache_aging_pcnt2; /* % free when to kick in accel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* aging - sec3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int max_holds_pcnt; /* max % of cents to act as holdovers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* stats - debug */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* thread stats - debug and on the fly tuning of dealloc vars */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int candidates; /* # cand. for dealloc checking */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int holds; /* # holdovers - single page, fully */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* aged but not dealloc'd or hash */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int process_directive; /* processing directive bitmap flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* standard stats (no prefetch tallies here) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int write_misses; /* not found in cache memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int write_thru; /* not bothering to put in cache mem */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * prefetch tracked by _sd_prefetch_valid_cnt and _sd_prefetch_busy_cnt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * might want different usage ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dynmem interface
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint sdbc_edit_xfer_process_vars_dm(_dm_process_vars_t *process_vars);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Defines to hide the sd_addr_t structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Defines to hide the synchronisation block
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This struct exists solely so that sd_info is able to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extract this kind of data from sdbc without passing out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the entire _sd_cctl_t which has lots of pointers which
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * makes it impossible to deal with in 32bit program and an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LP64 kernel.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int sq_seq; /* sequence number for lru optim */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dmchain support */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sq_dmchain_cblocks; /* dmchain len in ccents */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The net structure contains which memory net has been configured for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache, the amount of space allocated, the write control and fault
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tolerant blocks etc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned short sn_psize; /* Page size of memory in this net */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char sn_configured; /* is this network configured */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL || _KMEMUSER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared structure shared between cds and statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE - this structure is visible as an ioctl result.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If anything changes here _sd_get_stats() and convert_stats()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will need to be changed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uchar_t sh_alloc; /* Is this allocated? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uchar_t sh_failed; /* Disk failure status (0 == ok, */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 1 == i/o error, 2 == open failed ) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned short sh_cd; /* the cache descriptor. (for stats) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sh_cache_read; /* Number of FBAs read from cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sh_cache_write; /* Number of FBAs written to cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sh_disk_read; /* Number of FBAs read from disk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sh_disk_write; /* Number of FBAs written to disk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int sh_numdirty; /* Number of dirty blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int sh_numio; /* Number of blocks on way to disk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile int sh_numfail; /* Number of blocks failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sh_flag; /* Flags visible to user programs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sh_destaged; /* number of bytes destaged to disk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sh_wrcancelns; /* number of writes to dirty blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cache descriptor information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_fd_t *cd_rawfd; /* File descriptor for raw device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strategy_fn_t cd_strategy; /* Cached copy of strategy func */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_iodev_t *cd_iodev; /* I/O device for callbacks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t cd_lock; /* spinlock guarding this cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile uchar_t cd_writer; /* Disk writer status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int cd_hint; /* Hints for this descriptor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ss_voldata_t *cd_global; /* RM information for this cd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cd_dirty_head, *cd_dirty_tail; /* dirty chain */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cd_last_ent; /* last entry in dirty chain, for */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cd_lastchain_ptr; /* last sequential chain */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_cctl *cd_io_head, *cd_io_tail; /* io in progress q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _sd_shared *cd_info; /* shared info (filename, size) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cd_failover; /* done nsc_reserve during failover */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volatile char cd_recovering; /* cd is being recovered failover or */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* disk_online */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL || _KMEMUSER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Index into the following st_mem_sizes[] array
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_LOCAL_MEM 0x00 /* type of memory to allocate */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* maintain stat struct layout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache statistics structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE - if anything changes here _sd_get_stats() and convert_stats()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * must be changed and _sd_stats32_t must also be synchronized.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int st_blksize; /* cache block size (in bytes) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int st_wrcancelns; /* # of write cancellations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int st_destaged; /* # of bytes destaged to disk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_shared_t st_shared[1]; /* shared structures */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int st_blksize; /* cache block size (in bytes) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int st_wrcancelns; /* # of write cancellations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int st_destaged; /* # of bytes destaged to disk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_shared_t st_shared[1]; /* shared structures */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The map structure contains mapping between a mask and relevent information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that would take some computation at runtime.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given a mask, what is the first LSB set (stpos)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given a mask, what are the consecutive number of LSB bits set (len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given a mask, what would be a new mask if the consecutive LSB bits are reset
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given a mask, how many ios would be needed to flush this block.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given a mask, how many buffer descriptor lists (bdls) would be needed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on a read.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char mi_stpos; /* position of first LSB set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char mi_len; /* Length of consecutive LSB set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char mi_dirty_count; /* number of fragmented bits */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char mi_io_count; /* number of bdls for a given mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_bitmap_t mi_mask; /* new mask with cons. LSB's reset */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cc_inuse is set with atomic exchange instruction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * when clearing, must check for waiters.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sd_serialize prohibits speculative reads
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((centry)->cc_inuse || atomic_swap(CC_INUSE, &(centry)->cc_inuse))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cc_pageio is set with atomic exchange instruction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * when clearing, must check for waiters.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sd_serialize prohibits speculative reads
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_PAGEIO(centry) ((centry)->cc_pageio)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((centry)->cc_pageio || atomic_swap(CC_PAGEIO, &(centry)->cc_pageio))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cc_wait(CENTRY_CD(centry), CENTRY_BLK(centry), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_DIRTY_PENDING(centry) ((centry)->cc_flag & CC_PEND_DIRTY)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_PINNED(centry) ((centry)->cc_flag & CC_PINNED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_PINNABLE(centry) ((centry)->cc_flag & CC_PINNABLE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_QHEAD(centry) ((centry)->cc_flag & CC_QHEAD)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_CD(centry) ((centry)->cc_head.hh_cd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_BLK(centry) ((centry)->cc_head.hh_blk_num)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CENTRY_IO_INPROGRESS(centry) ((centry)->cc_iostatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL || _KMEMUSER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_ZEROADDR ((ucaddr_t)(_sd_net_config.sn_zeroaddr))
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(ASSERT_LEN) fba exceeds limits. fba_len %" \
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana NSC_SZFMT ". Max %d", len, _SD_MAX_FBAS); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_sd_cache_files[(cd)].cd_info->sh_filesize)) { \
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(ASSERT_IO_SIZE) io beyond end of file." \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " fpos %" NSC_SZFMT " len %" NSC_SZFMT " file size 0 - %" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ASSERT_HANDLE_LIMITS(m_h1, m_fpos, m_flen) \
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(ASSERT_HANDLE_LIMITS) operation out of bounds" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " cd %x want %" NSC_SZFMT " to %" NSC_SZFMT ". Handle %" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NSC_SZFMT " to %" NSC_SZFMT, HANDLE_CD(m_h1), m_fpos,\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_flen, (m_h1)->bh_fba_pos, (m_h1)->bh_fba_len); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_HANDLE_ACTIVE(handle) ((handle)->bh_flag & NSC_HACTIVE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_CD_HINTS(cd) (_sd_cache_files[(cd)].cd_hint)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_SETUP_HANDLE(hndl, cd, fpos, flen, flag) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_NOT_WRTHRU(handle) (((handle)->bh_flag & _SD_WRTHRU_MASK) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_IS_WRTHRU(handle) ((handle)->bh_flag & _SD_WRTHRU_MASK)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FILE_OPENED(cd) (((cd) >= 0) && ((cd) < (sdbc_max_devs)) && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bitmap stuff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_LOOKUP_STPOS(mask) (_sd_lookup_map[(mask)].mi_stpos)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_LOOKUP_LEN(mask) (_sd_lookup_map[(mask)].mi_len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_LOOKUP_MASK(mask) (_sd_lookup_map[(mask)].mi_mask)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_LOOKUP_DTCOUNT(mask) (_sd_lookup_map[(mask)].mi_dirty_count)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_LOOKUP_IOCOUNT(mask) (_sd_lookup_map[(mask)].mi_io_count)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_LOOKUP_MODIFY(mask) (mask &= ~(_sd_lookup_map[(mask)].mi_mask))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_IS_FRAGMENTED(bmap) (!_sd_contig_bmap[(bmap)])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_IS_CONTIGUOUS(bmap) (_sd_contig_bmap[(bmap)])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_SET_VALID_BITS(fba_off, fba_len, cc_entry) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cc_entry)->cc_valid |= SDBC_GET_BITS(fba_off, fba_len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_SET_DIRTY(fba_off, fba_len, cc_entry) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_bitmap_t dirty, newdb = SDBC_GET_BITS(fba_off, fba_len); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_SET_TOFLUSH(fba_off, fba_len, cc_entry) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_bitmap_t dirty, newdb = SDBC_GET_BITS(fba_off, fba_len); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dirty = (cc_entry)->cc_toflush | (cc_entry)->cc_dirty; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_VALID_BITS(fba_off, fba_len, cc_entry) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((((cc_entry)->cc_valid) & (SDBC_GET_BITS(fba_off, fba_len))) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte(((last)->cc_dirty & (1 << (BLK_FBAS - 1))) && ((next)->cc_dirty & 0x01)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FULLY_VALID(cc_entry) ((cc_entry)->cc_valid == BLK_FBA_BITS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FULLY_DIRTY(cc_entry) ((cc_entry)->cc_dirty == BLK_FBA_BITS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_BIT_ISSET(bmap, bit) ((bmap & (1 << bit)) ? 1 : 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_BMAP_ISFULL(bmap) (bmap == BLK_FBA_BITS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL || _KMEMUSER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[(cd)].sh_cache_read += (blks)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[(cd)].sh_disk_read += (blks)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[(cd)].sh_cache_write += (blks)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[(cd)].sh_disk_write += (blks)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_READ_HIT _sd_cache_stats->st_rdhits++
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_READ_MISS _sd_cache_stats->st_rdmiss++
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_WRITE_HIT _sd_cache_stats->st_wrhits++
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CACHE_WRITE_MISS _sd_cache_stats->st_wrmiss++
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[(cd)].sh_wrcancelns++;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[(cd)].sh_destaged += (bytes);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((cd) >= 0) && ((cd) < sdbc_max_devs) && sdbc_cd_io_kstats[(cd)]) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)])->nread += (bytes);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_IO_PTR(sdbc_global_io_kstat)->nread += (bytes);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((cd) >= 0) && ((cd) < sdbc_max_devs) && sdbc_cd_io_kstats[(cd)]) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)])->writes++;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)])->nwritten += (bytes);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_IO_PTR(sdbc_global_io_kstat)->nwritten += (bytes);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* start timer measuring amount of time spent in the cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cd_io_kstats[(cd)] && sdbc_cd_io_kstats_mutexes) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_runq_enter(KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)]));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_runq_enter(KSTAT_IO_PTR(sdbc_global_io_kstat));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* stop timer measuring amount of time spent in the cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cd_io_kstats[(cd)] && sdbc_cd_io_kstats_mutexes) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_runq_exit(KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)]));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_runq_exit(KSTAT_IO_PTR(sdbc_global_io_kstat));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* defines for sh_alloc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* defines for sh_flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef void (*sdbc_ea_fn_t) (blind_t, nsc_off_t, nsc_size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDTRACE(SDF_DISCONNECT, (hndl)->bh_cd, (hndl)->bh_fba_len, \
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(_SD_READ_CALLBACK) not registered. io lost");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(_SD_WRITE_CALLBACK) not registered. io lost");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Do not requeue if we fall into the tail 25% of the lru
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((q->sq_seq - ent->cc_seq) > LRU_REQ_LIMIT(q)) ?\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SD_DCON_THRESH 0x10000 /* Disconnect if io len greater than 64 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These defines are the hardwired values after sd_config_param was
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zapped. Ought to remove the use of these entirely ....
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_CD_WRITER(cd) ((_sd_cache_files[(cd)].cd_info->sh_numdirty>\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_FORCE_DISCONNECT(len) (SD_DCON_THRESH < FBA_SIZE(len))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* -------------------------------- END sd_config_param defines ---------- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_CD_WBLK_USED(cd) (_sd_cache_stats->st_shared[(cd)].sh_numio +\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_CD_ALL_WRITES(cd) (_sd_cache_stats->st_shared[(cd)].sh_numio +\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ncall usage
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sdbc_cache_configure(int cblocks, spcs_s_info_t kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sdbc_cache_deconfigure(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_open_cd(char *filename, const int cd, const int flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_cc_copy(_sd_cctl_t *cc_real, _sd_cctl_t *cc_shadow);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _sd_buf_handle_t *_sd_allocate_buf(int cd, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_cc_wait(int cd, nsc_off_t cblk, _sd_cctl_t *centry, int flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_alloc_buf(blind_t xcd, nsc_off_t fba_pos, nsc_size_t fba_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_free_buf(_sd_buf_handle_t *handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _sd_cctl_t *_sd_centry_alloc(int, int, int *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_centry_setup_dm(_sd_cctl_t *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _sd_cctl_t *_sd_shadow_centry(_sd_cctl_t *, _sd_cctl_t *, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_centry_release(_sd_cctl_t *centry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_alloc_write(_sd_cctl_t *centry, int *stall);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_read(_sd_buf_handle_t *handle, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_read_complete(_sd_buf_handle_t *handle, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_write(_sd_buf_handle_t *handle, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_zero(_sd_buf_handle_t *handle, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_copy(_sd_buf_handle_t *handle1, _sd_buf_handle_t *handle2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t fba_pos1, nsc_off_t fba_pos2, nsc_size_t fba_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_enqueue_dirty(int cd, _sd_cctl_t *chain, _sd_cctl_t *cc_last,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_enqueue_dirty_chain(int cd, _sd_cctl_t *chain_first,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_get_stats(_sd_stats_t *uptr, int convert_32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_get_partsize(blind_t cd, nsc_size_t *ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_get_maxfbas(blind_t cd, int flag, nsc_size_t *ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_discard_pinned(blind_t cd, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sdbc_handles_unload(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sdbc_handles_load(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sdbc_handles_deconfigure(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _sd_buf_handle_t *_sd_alloc_handle(sdbc_callback_fn_t d_cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_callback_fn_t r_cb, sdbc_callback_fn_t w_cb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sd_free_handle(_sd_buf_handle_t *handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_init_contig_bmap(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sd_init_lookup_map(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _sd_cctl_t *sdbc_centry_alloc(int, nsc_off_t, nsc_size_t, int *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _sd_cctl_t *sdbc_centry_alloc_blks(int, nsc_off_t, nsc_size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* for testing only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sdbc_flush_flag; /* inhibit flush for testing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sdbc_clear_ioerr(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sdbc_inject_ioerr(int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SD_BCACHE_H */