xref: /onnv-gate/usr/src/cmd/isns/isnsd/isns_cache.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 /*
23*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
25*7836SJohn.Forte@Sun.COM  */
26*7836SJohn.Forte@Sun.COM 
27*7836SJohn.Forte@Sun.COM #ifndef _ISNS_CACHE_H
28*7836SJohn.Forte@Sun.COM #define	_ISNS_CACHE_H
29*7836SJohn.Forte@Sun.COM 
30*7836SJohn.Forte@Sun.COM #include <synch.h>
31*7836SJohn.Forte@Sun.COM #include <isns_htab.h>
32*7836SJohn.Forte@Sun.COM #include <isns_dd.h>
33*7836SJohn.Forte@Sun.COM 
34*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
35*7836SJohn.Forte@Sun.COM extern "C" {
36*7836SJohn.Forte@Sun.COM #endif
37*7836SJohn.Forte@Sun.COM 
38*7836SJohn.Forte@Sun.COM #define	CACHE_FLAG_UPDATED	0x1
39*7836SJohn.Forte@Sun.COM 
40*7836SJohn.Forte@Sun.COM #define	SET_CACHE_UPDATED()	(cache_flag |= CACHE_FLAG_UPDATED)
41*7836SJohn.Forte@Sun.COM #define	RESET_CACHE_UPDATED()	(cache_flag &= ~CACHE_FLAG_UPDATED)
42*7836SJohn.Forte@Sun.COM 
43*7836SJohn.Forte@Sun.COM #define	IS_CACHE_UPDATED()	(cache_flag & CACHE_FLAG_UPDATED)
44*7836SJohn.Forte@Sun.COM 
45*7836SJohn.Forte@Sun.COM #define	CACHE_NO_ACTION	(0)
46*7836SJohn.Forte@Sun.COM #define	CACHE_READ	(1)
47*7836SJohn.Forte@Sun.COM #define	CACHE_TRY_READ	(2)
48*7836SJohn.Forte@Sun.COM #define	CACHE_WRITE	(3)
49*7836SJohn.Forte@Sun.COM 
50*7836SJohn.Forte@Sun.COM typedef struct cache {
51*7836SJohn.Forte@Sun.COM 	rwlock_t l;
52*7836SJohn.Forte@Sun.COM 	htab_t **t;
53*7836SJohn.Forte@Sun.COM 	matrix_t **x;
54*7836SJohn.Forte@Sun.COM 	uint32_t (*get_hval)(void *, uint16_t, uint32_t *);
55*7836SJohn.Forte@Sun.COM 	uint32_t (*get_uid)(const void *);
56*7836SJohn.Forte@Sun.COM 	uint32_t (*set_uid)(void *, uint32_t);
57*7836SJohn.Forte@Sun.COM 	uint32_t (*timestamp)(void);
58*7836SJohn.Forte@Sun.COM 	int (*add_hook)(void *);
59*7836SJohn.Forte@Sun.COM 	int (*replace_hook)(void *, void *, uint32_t *, int);
60*7836SJohn.Forte@Sun.COM 	int (*cmp)(void *, void *, int);
61*7836SJohn.Forte@Sun.COM 	void *(*clone)(void *, int);
62*7836SJohn.Forte@Sun.COM 	int (*ddd)(void *, const uchar_t);
63*7836SJohn.Forte@Sun.COM #ifdef DEBUG
64*7836SJohn.Forte@Sun.COM 	void (*dump)(void *);
65*7836SJohn.Forte@Sun.COM #endif
66*7836SJohn.Forte@Sun.COM } cache_t;
67*7836SJohn.Forte@Sun.COM 
68*7836SJohn.Forte@Sun.COM int cache_init(void);
69*7836SJohn.Forte@Sun.COM void cache_destroy(void);
70*7836SJohn.Forte@Sun.COM int cache_lock(int);
71*7836SJohn.Forte@Sun.COM int cache_unlock(int, int);
72*7836SJohn.Forte@Sun.COM int cache_lock_read(void);
73*7836SJohn.Forte@Sun.COM int cache_lock_write(void);
74*7836SJohn.Forte@Sun.COM int cache_unlock_sync(int);
75*7836SJohn.Forte@Sun.COM int cache_unlock_nosync(void);
76*7836SJohn.Forte@Sun.COM htab_t *cache_get_htab(isns_type_t);
77*7836SJohn.Forte@Sun.COM matrix_t *cache_get_matrix(isns_type_t);
78*7836SJohn.Forte@Sun.COM int cache_lookup(lookup_ctrl_t *, uint32_t *, int (*)(void *, void *));
79*7836SJohn.Forte@Sun.COM int cache_rekey(lookup_ctrl_t *, uint32_t *, int (*)(void *, void *));
80*7836SJohn.Forte@Sun.COM int cache_add(isns_obj_t *, int, uint32_t *, int *);
81*7836SJohn.Forte@Sun.COM isns_obj_t *cache_remove(lookup_ctrl_t *, int);
82*7836SJohn.Forte@Sun.COM 
83*7836SJohn.Forte@Sun.COM #ifdef DEBUG
84*7836SJohn.Forte@Sun.COM void cache_dump_htab(isns_type_t);
85*7836SJohn.Forte@Sun.COM #endif
86*7836SJohn.Forte@Sun.COM 
87*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
88*7836SJohn.Forte@Sun.COM }
89*7836SJohn.Forte@Sun.COM #endif
90*7836SJohn.Forte@Sun.COM 
91*7836SJohn.Forte@Sun.COM #endif /* _ISNS_CACHE_H */
92