summaryrefslogtreecommitdiffstats
path: root/sys/geom/eli/g_eli_key_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/geom/eli/g_eli_key_cache.c')
-rw-r--r--sys/geom/eli/g_eli_key_cache.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/sys/geom/eli/g_eli_key_cache.c b/sys/geom/eli/g_eli_key_cache.c
index cb86716..0b909be 100644
--- a/sys/geom/eli/g_eli_key_cache.c
+++ b/sys/geom/eli/g_eli_key_cache.c
@@ -28,17 +28,20 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#ifdef _KERNEL
#include <sys/kernel.h>
#include <sys/malloc.h>
-#include <sys/queue.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#endif /* _KERNEL */
+#include <sys/queue.h>
#include <sys/tree.h>
#include <geom/geom.h>
#include <geom/eli/g_eli.h>
+#ifdef _KERNEL
MALLOC_DECLARE(M_ELI);
SYSCTL_DECL(_kern_geom_eli);
@@ -56,22 +59,7 @@ static uint64_t g_eli_key_cache_misses;
SYSCTL_UQUAD(_kern_geom_eli, OID_AUTO, key_cache_misses, CTLFLAG_RW,
&g_eli_key_cache_misses, 0, "Key cache misses");
-#define G_ELI_KEY_MAGIC 0xe11341c
-
-struct g_eli_key {
- /* Key value, must be first in the structure. */
- uint8_t gek_key[G_ELI_DATAKEYLEN];
- /* Magic. */
- int gek_magic;
- /* Key number. */
- uint64_t gek_keyno;
- /* Reference counter. */
- int gek_count;
- /* Keeps keys sorted by most recent use. */
- TAILQ_ENTRY(g_eli_key) gek_next;
- /* Keeps keys sorted by number. */
- RB_ENTRY(g_eli_key) gek_link;
-};
+#endif /* _KERNEL */
static int
g_eli_key_cmp(const struct g_eli_key *a, const struct g_eli_key *b)
@@ -84,10 +72,7 @@ g_eli_key_cmp(const struct g_eli_key *a, const struct g_eli_key *b)
return (0);
}
-RB_PROTOTYPE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp);
-RB_GENERATE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp);
-
-static void
+void
g_eli_key_fill(struct g_eli_softc *sc, struct g_eli_key *key, uint64_t keyno)
{
const uint8_t *ekey;
@@ -110,6 +95,10 @@ g_eli_key_fill(struct g_eli_softc *sc, struct g_eli_key *key, uint64_t keyno)
key->gek_magic = G_ELI_KEY_MAGIC;
}
+#ifdef _KERNEL
+RB_PROTOTYPE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp);
+RB_GENERATE(g_eli_key_tree, g_eli_key, gek_link, g_eli_key_cmp);
+
static struct g_eli_key *
g_eli_key_allocate(struct g_eli_softc *sc, uint64_t keyno)
{
@@ -350,3 +339,4 @@ g_eli_key_drop(struct g_eli_softc *sc, uint8_t *rawkey)
}
mtx_unlock(&sc->sc_ekeys_lock);
}
+#endif /* _KERNEL */
OpenPOWER on IntegriCloud