xref: /onnv-gate/usr/src/uts/common/avs/ns/sdbc/sd_ft.h (revision 7836:4e95154b5b7a)
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_FT_H
27*7836SJohn.Forte@Sun.COM #define	_SD_FT_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 #include <sys/ncall/ncall.h>
34*7836SJohn.Forte@Sun.COM 
35*7836SJohn.Forte@Sun.COM typedef struct _sd_ft_info {
36*7836SJohn.Forte@Sun.COM 	char 	fi_crashed;		/* mirror cache state */
37*7836SJohn.Forte@Sun.COM 	char 	fi_host_state;		/* mirror node state */
38*7836SJohn.Forte@Sun.COM 	kmutex_t	fi_lock;
39*7836SJohn.Forte@Sun.COM 	kcondvar_t	fi_rem_sv;
40*7836SJohn.Forte@Sun.COM 	volatile int 	fi_numio;
41*7836SJohn.Forte@Sun.COM 	kmutex_t fi_sleep;
42*7836SJohn.Forte@Sun.COM 
43*7836SJohn.Forte@Sun.COM } _sd_ft_info_t;
44*7836SJohn.Forte@Sun.COM 
45*7836SJohn.Forte@Sun.COM 
46*7836SJohn.Forte@Sun.COM #define	_SD_MIRROR_CONFIGD	(_sd_ft_data.fi_host_state ==\
47*7836SJohn.Forte@Sun.COM 				_SD_HOST_CONFIGURED)
48*7836SJohn.Forte@Sun.COM #define	_SD_MIRROR_DECONFIGD	(_sd_ft_data.fi_host_state == \
49*7836SJohn.Forte@Sun.COM 				_SD_HOST_DECONFIGURED)
50*7836SJohn.Forte@Sun.COM #define	_SD_MIRROR_NOCACHE	(_sd_ft_data.fi_host_state == \
51*7836SJohn.Forte@Sun.COM 				_SD_HOST_NOCACHE)
52*7836SJohn.Forte@Sun.COM 
53*7836SJohn.Forte@Sun.COM #define	_SD_HOST_NONE		0x00	/* mirror node dead or state unknown */
54*7836SJohn.Forte@Sun.COM #define	_SD_HOST_CONFIGURED	0x01	/* mirror cache configured */
55*7836SJohn.Forte@Sun.COM #define	_SD_HOST_DECONFIGURED	0x02	/* mirror cache deconfigured */
56*7836SJohn.Forte@Sun.COM #define	_SD_HOST_NOCACHE	0x03	/* mirror cache deconfigured and */
57*7836SJohn.Forte@Sun.COM 					/* waiting for node down or re-enable */
58*7836SJohn.Forte@Sun.COM 
59*7836SJohn.Forte@Sun.COM /*
60*7836SJohn.Forte@Sun.COM  * mirror node has paniced with cache enabled,
61*7836SJohn.Forte@Sun.COM  * or mirror cache has been deconfigured.
62*7836SJohn.Forte@Sun.COM  */
63*7836SJohn.Forte@Sun.COM #define	_sd_is_mirror_crashed()	((!_INFSD_NODE_UP(_SD_MIRROR_HOST) &&\
64*7836SJohn.Forte@Sun.COM 				_SD_MIRROR_CONFIGD) || _SD_MIRROR_DECONFIGD)
65*7836SJohn.Forte@Sun.COM 
66*7836SJohn.Forte@Sun.COM /*
67*7836SJohn.Forte@Sun.COM  * mirror node has shutdown having previously
68*7836SJohn.Forte@Sun.COM  * deconfigured its cache.
69*7836SJohn.Forte@Sun.COM  */
70*7836SJohn.Forte@Sun.COM #define	_sd_is_mirror_node_down()	\
71*7836SJohn.Forte@Sun.COM 				(!_INFSD_NODE_UP(_SD_MIRROR_HOST) &&\
72*7836SJohn.Forte@Sun.COM 				_SD_MIRROR_NOCACHE)
73*7836SJohn.Forte@Sun.COM 
74*7836SJohn.Forte@Sun.COM #define	_sd_is_mirror_down()	(_sd_ft_data.fi_crashed)
75*7836SJohn.Forte@Sun.COM #define	_sd_mirror_cache_down()	(_sd_ft_data.fi_crashed = 1,\
76*7836SJohn.Forte@Sun.COM 				_sd_ft_data.fi_host_state = _SD_HOST_NOCACHE)
77*7836SJohn.Forte@Sun.COM #define	_sd_mirror_down()	(_sd_ft_data.fi_crashed = 1,\
78*7836SJohn.Forte@Sun.COM 				_sd_ft_data.fi_host_state = _SD_HOST_NONE)
79*7836SJohn.Forte@Sun.COM #define	_sd_mirror_up()		(_sd_ft_data.fi_crashed = 0)
80*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
81*7836SJohn.Forte@Sun.COM 
82*7836SJohn.Forte@Sun.COM extern _sd_ft_info_t _sd_ft_data;
83*7836SJohn.Forte@Sun.COM extern int _sd_node_recovery;
84*7836SJohn.Forte@Sun.COM 
85*7836SJohn.Forte@Sun.COM extern void _sdbc_ft_unload(void);
86*7836SJohn.Forte@Sun.COM extern int _sdbc_ft_load(void);
87*7836SJohn.Forte@Sun.COM extern int _sdbc_ft_configure(void);
88*7836SJohn.Forte@Sun.COM extern void _sdbc_ft_deconfigure(void);
89*7836SJohn.Forte@Sun.COM extern int _sd_recovery_wait(void);
90*7836SJohn.Forte@Sun.COM extern int _sd_recovery_wblk_wait(int cd);
91*7836SJohn.Forte@Sun.COM extern void _sd_mirror_iodone(void);
92*7836SJohn.Forte@Sun.COM extern int _sd_repin_cd(int);
93*7836SJohn.Forte@Sun.COM extern void _sd_remote_disable(int);
94*7836SJohn.Forte@Sun.COM extern void r_sd_ifs_cache_enable(ncall_t *, int *);
95*7836SJohn.Forte@Sun.COM extern void r_sd_ifs_cache_disable(ncall_t *, int *);
96*7836SJohn.Forte@Sun.COM extern void _sd_hash_invalidate_cd(int);
97*7836SJohn.Forte@Sun.COM extern void r_cd_discard(ncall_t *, int *);
98*7836SJohn.Forte@Sun.COM extern int _sd_uncommit(_sd_buf_handle_t *, nsc_off_t, nsc_size_t, int);
99*7836SJohn.Forte@Sun.COM extern int _sd_uncommit_refresh(_sd_cctl_t *, int);
100*7836SJohn.Forte@Sun.COM extern void r_sd_uncommit_refresh(ncall_t *, int *);
101*7836SJohn.Forte@Sun.COM extern int _sd_wait_for_flush(int);
102*7836SJohn.Forte@Sun.COM extern int _sdbc_warm_start(void);
103*7836SJohn.Forte@Sun.COM extern void _sdbc_set_warm_start(void);
104*7836SJohn.Forte@Sun.COM 
105*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */
106*7836SJohn.Forte@Sun.COM 
107*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
108*7836SJohn.Forte@Sun.COM }
109*7836SJohn.Forte@Sun.COM #endif
110*7836SJohn.Forte@Sun.COM 
111*7836SJohn.Forte@Sun.COM #endif /* _SD_FT_H */
112