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 #ifndef _SD_SAFESTORE_IMPL_H 27*7836SJohn.Forte@Sun.COM #define _SD_SAFESTORE_IMPL_H 28*7836SJohn.Forte@Sun.COM 29*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 30*7836SJohn.Forte@Sun.COM extern "C" { 31*7836SJohn.Forte@Sun.COM #endif 32*7836SJohn.Forte@Sun.COM 33*7836SJohn.Forte@Sun.COM #ifdef _KERNEL 34*7836SJohn.Forte@Sun.COM 35*7836SJohn.Forte@Sun.COM /* ss config stages */ 36*7836SJohn.Forte@Sun.COM #define SD_WR_SLP_Q_MAX 256 37*7836SJohn.Forte@Sun.COM 38*7836SJohn.Forte@Sun.COM /* 39*7836SJohn.Forte@Sun.COM * Global fields for cache LRU entry. Fault tolerant structure in RMS. 40*7836SJohn.Forte@Sun.COM */ 41*7836SJohn.Forte@Sun.COM 42*7836SJohn.Forte@Sun.COM #define INCX(x) (x = (x + 1 + SD_WR_SLP_Q_MAX) % SD_WR_SLP_Q_MAX) 43*7836SJohn.Forte@Sun.COM #define DECX(x) (x = (x - 1 + SD_WR_SLP_Q_MAX) % SD_WR_SLP_Q_MAX) 44*7836SJohn.Forte@Sun.COM 45*7836SJohn.Forte@Sun.COM typedef struct _sd_wr_slp_queue { 46*7836SJohn.Forte@Sun.COM kcondvar_t slp_wqcv; 47*7836SJohn.Forte@Sun.COM int slp_wqneed; 48*7836SJohn.Forte@Sun.COM } _sd_wr_slp_queue_t; 49*7836SJohn.Forte@Sun.COM 50*7836SJohn.Forte@Sun.COM typedef struct _sd_wr_queue { 51*7836SJohn.Forte@Sun.COM struct ss_wr_cctl *wq_qtop; /* Top of write control blocks */ 52*7836SJohn.Forte@Sun.COM kmutex_t wq_qlock; /* allocation spinlock */ 53*7836SJohn.Forte@Sun.COM int wq_inq; /* number of write blocks available in q */ 54*7836SJohn.Forte@Sun.COM int wq_nentries; /* total Number of write blocks in q */ 55*7836SJohn.Forte@Sun.COM unsigned int wq_slp_top; 56*7836SJohn.Forte@Sun.COM unsigned int wq_slp_index; 57*7836SJohn.Forte@Sun.COM unsigned int wq_slp_inq; 58*7836SJohn.Forte@Sun.COM _sd_wr_slp_queue_t wq_slp[SD_WR_SLP_Q_MAX]; 59*7836SJohn.Forte@Sun.COM } _sd_writeq_t; 60*7836SJohn.Forte@Sun.COM 61*7836SJohn.Forte@Sun.COM #define WQ_SET_NEED(q, need, i) { \ 62*7836SJohn.Forte@Sun.COM (q->wq_slp[i].slp_wqneed = need); \ 63*7836SJohn.Forte@Sun.COM } 64*7836SJohn.Forte@Sun.COM 65*7836SJohn.Forte@Sun.COM #define WQ_SVWAIT_BOTTOM(q, need) \ 66*7836SJohn.Forte@Sun.COM { \ 67*7836SJohn.Forte@Sun.COM int ix = q->wq_slp_index; \ 68*7836SJohn.Forte@Sun.COM INCX(q->wq_slp_index); \ 69*7836SJohn.Forte@Sun.COM WQ_SET_NEED(q, need, ix); \ 70*7836SJohn.Forte@Sun.COM cv_wait(&q->wq_slp[ix].slp_wqcv, &q->wq_qlock); \ 71*7836SJohn.Forte@Sun.COM mutex_exit(&q->wq_qlock); \ 72*7836SJohn.Forte@Sun.COM } 73*7836SJohn.Forte@Sun.COM 74*7836SJohn.Forte@Sun.COM #define WQ_SVWAIT_TOP(q, need) \ 75*7836SJohn.Forte@Sun.COM { \ 76*7836SJohn.Forte@Sun.COM DECX(q->wq_slp_top); \ 77*7836SJohn.Forte@Sun.COM WQ_SET_NEED(q, need, q->wq_slp_top); \ 78*7836SJohn.Forte@Sun.COM cv_wait(&q->wq_slp[q->wq_slp_top].slp_wqcv, &q->wq_qlock);\ 79*7836SJohn.Forte@Sun.COM mutex_exit(&q->wq_qlock); \ 80*7836SJohn.Forte@Sun.COM } 81*7836SJohn.Forte@Sun.COM 82*7836SJohn.Forte@Sun.COM #define WQ_NEED_SIG(q) \ 83*7836SJohn.Forte@Sun.COM (q->wq_slp_inq && (q->wq_slp[q->wq_slp_top].slp_wqneed <= q->wq_inq)) 84*7836SJohn.Forte@Sun.COM 85*7836SJohn.Forte@Sun.COM #define WQ_SVSIG(q) \ 86*7836SJohn.Forte@Sun.COM { \ 87*7836SJohn.Forte@Sun.COM int tp = q->wq_slp_top; \ 88*7836SJohn.Forte@Sun.COM INCX(q->wq_slp_top); \ 89*7836SJohn.Forte@Sun.COM q->wq_slp[tp].slp_wqneed = 0; \ 90*7836SJohn.Forte@Sun.COM cv_signal(&q->wq_slp[tp].slp_wqcv); \ 91*7836SJohn.Forte@Sun.COM } 92*7836SJohn.Forte@Sun.COM 93*7836SJohn.Forte@Sun.COM /* 94*7836SJohn.Forte@Sun.COM * cache entry information 95*7836SJohn.Forte@Sun.COM * note -- this structure is a identical to the first 4 words of 96*7836SJohn.Forte@Sun.COM * the exported ss_centry_info_t. internal copies depened on this 97*7836SJohn.Forte@Sun.COM * fact. changes to this structure may require changes to the 98*7836SJohn.Forte@Sun.COM * *getcentry() and *setcentry() functions. 99*7836SJohn.Forte@Sun.COM * 100*7836SJohn.Forte@Sun.COM */ 101*7836SJohn.Forte@Sun.COM typedef struct ss_centry_info_impl_s { 102*7836SJohn.Forte@Sun.COM int sci_cd; /* Cache descriptor */ 103*7836SJohn.Forte@Sun.COM nsc_off_t sci_fpos; /* File position */ 104*7836SJohn.Forte@Sun.COM int sci_dirty; /* Dirty mask */ 105*7836SJohn.Forte@Sun.COM int sci_flag; /* CC_PINNABLE | CC_PINNED */ 106*7836SJohn.Forte@Sun.COM } ss_centry_info_impl_t; 107*7836SJohn.Forte@Sun.COM 108*7836SJohn.Forte@Sun.COM /* 109*7836SJohn.Forte@Sun.COM * The write control structure has information about the remote page that 110*7836SJohn.Forte@Sun.COM * will mirror a write. 111*7836SJohn.Forte@Sun.COM */ 112*7836SJohn.Forte@Sun.COM typedef struct ss_wr_cctl { 113*7836SJohn.Forte@Sun.COM struct ss_wr_cctl *wc_next; /* chaining queue entries */ 114*7836SJohn.Forte@Sun.COM caddr_t wc_addr; /* points to data address */ 115*7836SJohn.Forte@Sun.COM ss_centry_info_impl_t *wc_gl_info; /* information for the page */ 116*7836SJohn.Forte@Sun.COM unsigned char wc_flag; /* flag */ 117*7836SJohn.Forte@Sun.COM } ss_wr_cctl_t; 118*7836SJohn.Forte@Sun.COM 119*7836SJohn.Forte@Sun.COM /* volume information */ 120*7836SJohn.Forte@Sun.COM typedef struct ss_voldata_impl_s { 121*7836SJohn.Forte@Sun.COM char svi_volname[NSC_MAXPATH]; /* Filename in RMS for failover */ 122*7836SJohn.Forte@Sun.COM int svi_cd; /* NOTE may need dual node map info */ 123*7836SJohn.Forte@Sun.COM int svi_pinned; /* Device has failed/pinned blocks */ 124*7836SJohn.Forte@Sun.COM int svi_attached; /* Node which has device attached */ 125*7836SJohn.Forte@Sun.COM int svi_devidsz; /* unique dev id length */ 126*7836SJohn.Forte@Sun.COM uchar_t svi_devid[NSC_MAXPATH]; /* wwn id - physical devs only */ 127*7836SJohn.Forte@Sun.COM int svi_reserved[13]; /* Reserved global space */ 128*7836SJohn.Forte@Sun.COM } ss_voldata_impl_t; 129*7836SJohn.Forte@Sun.COM 130*7836SJohn.Forte@Sun.COM extern int _sd_fill_pattern(caddr_t addr, uint_t pat, uint_t size); 131*7836SJohn.Forte@Sun.COM extern int _sdbc_writeq_configure(_sd_writeq_t *); 132*7836SJohn.Forte@Sun.COM extern void _sdbc_writeq_deconfigure(_sd_writeq_t *); 133*7836SJohn.Forte@Sun.COM extern void ss_release_write(ss_wr_cctl_t *, _sd_writeq_t *); 134*7836SJohn.Forte@Sun.COM extern ss_wr_cctl_t *ss_alloc_write(int, int *, _sd_writeq_t *); 135*7836SJohn.Forte@Sun.COM 136*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */ 137*7836SJohn.Forte@Sun.COM 138*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 139*7836SJohn.Forte@Sun.COM } 140*7836SJohn.Forte@Sun.COM #endif 141*7836SJohn.Forte@Sun.COM 142*7836SJohn.Forte@Sun.COM #endif /* _SD_SAFESTORE_IMPL_H */ 143