module: icp: remove unused notification framework
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12901
This commit is contained in:
parent
3fd5ead75e
commit
1c17d2940c
|
@ -28,7 +28,6 @@ KERNEL_C = \
|
||||||
spi/kcf_spi.c \
|
spi/kcf_spi.c \
|
||||||
api/kcf_ctxops.c \
|
api/kcf_ctxops.c \
|
||||||
api/kcf_cipher.c \
|
api/kcf_cipher.c \
|
||||||
api/kcf_miscapi.c \
|
|
||||||
api/kcf_mac.c \
|
api/kcf_mac.c \
|
||||||
algs/aes/aes_impl_aesni.c \
|
algs/aes/aes_impl_aesni.c \
|
||||||
algs/aes/aes_impl_generic.c \
|
algs/aes/aes_impl_generic.c \
|
||||||
|
|
|
@ -16,7 +16,6 @@ ccflags-y := -I$(icp_include)
|
||||||
$(MODULE)-objs += illumos-crypto.o
|
$(MODULE)-objs += illumos-crypto.o
|
||||||
$(MODULE)-objs += api/kcf_cipher.o
|
$(MODULE)-objs += api/kcf_cipher.o
|
||||||
$(MODULE)-objs += api/kcf_mac.o
|
$(MODULE)-objs += api/kcf_mac.o
|
||||||
$(MODULE)-objs += api/kcf_miscapi.o
|
|
||||||
$(MODULE)-objs += api/kcf_ctxops.o
|
$(MODULE)-objs += api/kcf_ctxops.o
|
||||||
$(MODULE)-objs += core/kcf_callprov.o
|
$(MODULE)-objs += core/kcf_callprov.o
|
||||||
$(MODULE)-objs += core/kcf_prov_tabs.o
|
$(MODULE)-objs += core/kcf_prov_tabs.o
|
||||||
|
|
|
@ -1,127 +0,0 @@
|
||||||
/*
|
|
||||||
* CDDL HEADER START
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the terms of the
|
|
||||||
* Common Development and Distribution License (the "License").
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
||||||
* or http://www.opensolaris.org/os/licensing.
|
|
||||||
* See the License for the specific language governing permissions
|
|
||||||
* and limitations under the License.
|
|
||||||
*
|
|
||||||
* When distributing Covered Code, include this CDDL HEADER in each
|
|
||||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
||||||
* If applicable, add the following below this CDDL HEADER, with the
|
|
||||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
||||||
*
|
|
||||||
* CDDL HEADER END
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
|
||||||
#include <sys/crypto/common.h>
|
|
||||||
#include <sys/crypto/api.h>
|
|
||||||
#include <sys/crypto/impl.h>
|
|
||||||
#include <sys/crypto/sched_impl.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All event subscribers are put on a list. kcf_notify_list_lock
|
|
||||||
* protects changes to this list.
|
|
||||||
*
|
|
||||||
* The following locking order is maintained in the code - The
|
|
||||||
* global kcf_notify_list_lock followed by the individual lock
|
|
||||||
* in a kcf_ntfy_elem structure (kn_lock).
|
|
||||||
*/
|
|
||||||
kmutex_t ntfy_list_lock;
|
|
||||||
kcondvar_t ntfy_list_cv; /* cv the service thread waits on */
|
|
||||||
static kcf_ntfy_elem_t *ntfy_list_head;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* crypto_mech2id()
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* . mechname: A null-terminated string identifying the mechanism name.
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Walks the mechanisms tables, looking for an entry that matches the
|
|
||||||
* mechname. Once it find it, it builds the 64-bit mech_type and returns
|
|
||||||
* it. If there are no providers for the mechanism,
|
|
||||||
* but there is an unloaded provider, this routine will attempt
|
|
||||||
* to load it.
|
|
||||||
*
|
|
||||||
* Context:
|
|
||||||
* Process and interruption.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* The unique mechanism identified by 'mechname', if found.
|
|
||||||
* CRYPTO_MECH_INVALID otherwise.
|
|
||||||
*/
|
|
||||||
crypto_mech_type_t
|
|
||||||
crypto_mech2id(const char *mechname)
|
|
||||||
{
|
|
||||||
return (crypto_mech2id_common(mechname, B_TRUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We walk the notification list and do the callbacks.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
kcf_walk_ntfylist(uint32_t event, void *event_arg)
|
|
||||||
{
|
|
||||||
kcf_ntfy_elem_t *nep;
|
|
||||||
int nelem = 0;
|
|
||||||
|
|
||||||
mutex_enter(&ntfy_list_lock);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Count how many clients are on the notification list. We need
|
|
||||||
* this count to ensure that clients which joined the list after we
|
|
||||||
* have started this walk, are not wrongly notified.
|
|
||||||
*/
|
|
||||||
for (nep = ntfy_list_head; nep != NULL; nep = nep->kn_next)
|
|
||||||
nelem++;
|
|
||||||
|
|
||||||
for (nep = ntfy_list_head; (nep != NULL && nelem); nep = nep->kn_next) {
|
|
||||||
nelem--;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if this client is interested in the
|
|
||||||
* event.
|
|
||||||
*/
|
|
||||||
if (!(nep->kn_event_mask & event))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mutex_enter(&nep->kn_lock);
|
|
||||||
nep->kn_state = NTFY_RUNNING;
|
|
||||||
mutex_exit(&nep->kn_lock);
|
|
||||||
mutex_exit(&ntfy_list_lock);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We invoke the callback routine with no locks held. Another
|
|
||||||
* client could have joined the list meanwhile. This is fine
|
|
||||||
* as we maintain nelem as stated above. The NULL check in the
|
|
||||||
* for loop guards against shrinkage. Also, any callers of
|
|
||||||
* crypto_unnotify_events() at this point cv_wait till kn_state
|
|
||||||
* changes to NTFY_WAITING. Hence, nep is assured to be valid.
|
|
||||||
*/
|
|
||||||
(*nep->kn_func)(event, event_arg);
|
|
||||||
|
|
||||||
mutex_enter(&nep->kn_lock);
|
|
||||||
nep->kn_state = NTFY_WAITING;
|
|
||||||
cv_broadcast(&nep->kn_cv);
|
|
||||||
mutex_exit(&nep->kn_lock);
|
|
||||||
|
|
||||||
mutex_enter(&ntfy_list_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_exit(&ntfy_list_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_KERNEL)
|
|
||||||
EXPORT_SYMBOL(crypto_mech2id);
|
|
||||||
#endif
|
|
|
@ -556,6 +556,26 @@ kcf_get_mech_entry(crypto_mech_type_t mech_type, kcf_mech_entry_t **mep)
|
||||||
return (KCF_SUCCESS);
|
return (KCF_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* crypto_mech2id()
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* . mechname: A null-terminated string identifying the mechanism name.
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Walks the mechanisms tables, looking for an entry that matches the
|
||||||
|
* mechname. Once it find it, it builds the 64-bit mech_type and returns
|
||||||
|
* it. If there are no providers for the mechanism,
|
||||||
|
* but there is an unloaded provider, this routine will attempt
|
||||||
|
* to load it.
|
||||||
|
*
|
||||||
|
* Context:
|
||||||
|
* Process and interruption.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* The unique mechanism identified by 'mechname', if found.
|
||||||
|
* CRYPTO_MECH_INVALID otherwise.
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
* Lookup the hash table for an entry that matches the mechname.
|
* Lookup the hash table for an entry that matches the mechname.
|
||||||
* If there are no providers for the mechanism,
|
* If there are no providers for the mechanism,
|
||||||
|
@ -563,8 +583,11 @@ kcf_get_mech_entry(crypto_mech_type_t mech_type, kcf_mech_entry_t **mep)
|
||||||
* to load it.
|
* to load it.
|
||||||
*/
|
*/
|
||||||
crypto_mech_type_t
|
crypto_mech_type_t
|
||||||
crypto_mech2id_common(const char *mechname, boolean_t load_module)
|
crypto_mech2id(const char *mechname)
|
||||||
{
|
{
|
||||||
(void) load_module;
|
|
||||||
return (kcf_mech_hash_find(mechname));
|
return (kcf_mech_hash_find(mechname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_KERNEL)
|
||||||
|
EXPORT_SYMBOL(crypto_mech2id);
|
||||||
|
#endif
|
||||||
|
|
|
@ -287,9 +287,6 @@ kcf_sched_destroy(void)
|
||||||
kmem_cache_destroy(kcf_areq_cache);
|
kmem_cache_destroy(kcf_areq_cache);
|
||||||
if (kcf_sreq_cache)
|
if (kcf_sreq_cache)
|
||||||
kmem_cache_destroy(kcf_sreq_cache);
|
kmem_cache_destroy(kcf_sreq_cache);
|
||||||
|
|
||||||
mutex_destroy(&ntfy_list_lock);
|
|
||||||
cv_destroy(&ntfy_list_cv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -339,10 +336,6 @@ kcf_sched_init(void)
|
||||||
/* Allocate and initialize the thread pool */
|
/* Allocate and initialize the thread pool */
|
||||||
kcfpool_alloc();
|
kcfpool_alloc();
|
||||||
|
|
||||||
/* Initialize the event notification list variables */
|
|
||||||
mutex_init(&ntfy_list_lock, NULL, MUTEX_DEFAULT, NULL);
|
|
||||||
cv_init(&ntfy_list_cv, NULL, CV_DEFAULT, NULL);
|
|
||||||
|
|
||||||
/* Create the kcf kstat */
|
/* Create the kcf kstat */
|
||||||
kcf_misc_kstat = kstat_create("kcf", 0, "framework_stats", "crypto",
|
kcf_misc_kstat = kstat_create("kcf", 0, "framework_stats", "crypto",
|
||||||
KSTAT_TYPE_NAMED, sizeof (kcf_stats_t) / sizeof (kstat_named_t),
|
KSTAT_TYPE_NAMED, sizeof (kcf_stats_t) / sizeof (kstat_named_t),
|
||||||
|
|
|
@ -492,7 +492,6 @@ extern int kcf_get_mech_entry(crypto_mech_type_t, kcf_mech_entry_t **);
|
||||||
extern kcf_provider_desc_t *kcf_alloc_provider_desc(void);
|
extern kcf_provider_desc_t *kcf_alloc_provider_desc(void);
|
||||||
extern void kcf_provider_zero_refcnt(kcf_provider_desc_t *);
|
extern void kcf_provider_zero_refcnt(kcf_provider_desc_t *);
|
||||||
extern void kcf_free_provider_desc(kcf_provider_desc_t *);
|
extern void kcf_free_provider_desc(kcf_provider_desc_t *);
|
||||||
extern crypto_mech_type_t crypto_mech2id_common(const char *, boolean_t);
|
|
||||||
extern void undo_register_provider(kcf_provider_desc_t *, boolean_t);
|
extern void undo_register_provider(kcf_provider_desc_t *, boolean_t);
|
||||||
extern int crypto_uio_data(crypto_data_t *, uchar_t *, int, cmd_type_t,
|
extern int crypto_uio_data(crypto_data_t *, uchar_t *, int, cmd_type_t,
|
||||||
void *, void (*update)(void));
|
void *, void (*update)(void));
|
||||||
|
|
|
@ -346,61 +346,6 @@ typedef struct kcf_pool {
|
||||||
} kcf_pool_t;
|
} kcf_pool_t;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* State of a crypto bufcall element.
|
|
||||||
*/
|
|
||||||
typedef enum cbuf_state {
|
|
||||||
CBUF_FREE = 1,
|
|
||||||
CBUF_WAITING,
|
|
||||||
CBUF_RUNNING
|
|
||||||
} cbuf_state_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure of a crypto bufcall element.
|
|
||||||
*/
|
|
||||||
typedef struct kcf_cbuf_elem {
|
|
||||||
/*
|
|
||||||
* lock and cv to wait for CBUF_RUNNING to be done
|
|
||||||
* kc_lock also protects kc_state.
|
|
||||||
*/
|
|
||||||
kmutex_t kc_lock;
|
|
||||||
kcondvar_t kc_cv;
|
|
||||||
cbuf_state_t kc_state;
|
|
||||||
|
|
||||||
struct kcf_cbuf_elem *kc_next;
|
|
||||||
struct kcf_cbuf_elem *kc_prev;
|
|
||||||
|
|
||||||
void (*kc_func)(void *arg);
|
|
||||||
void *kc_arg;
|
|
||||||
} kcf_cbuf_elem_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* State of a notify element.
|
|
||||||
*/
|
|
||||||
typedef enum ntfy_elem_state {
|
|
||||||
NTFY_WAITING = 1,
|
|
||||||
NTFY_RUNNING
|
|
||||||
} ntfy_elem_state_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure of a notify list element.
|
|
||||||
*/
|
|
||||||
typedef struct kcf_ntfy_elem {
|
|
||||||
/*
|
|
||||||
* lock and cv to wait for NTFY_RUNNING to be done.
|
|
||||||
* kn_lock also protects kn_state.
|
|
||||||
*/
|
|
||||||
kmutex_t kn_lock;
|
|
||||||
kcondvar_t kn_cv;
|
|
||||||
ntfy_elem_state_t kn_state;
|
|
||||||
|
|
||||||
struct kcf_ntfy_elem *kn_next;
|
|
||||||
struct kcf_ntfy_elem *kn_prev;
|
|
||||||
|
|
||||||
crypto_notify_callback_t kn_func;
|
|
||||||
uint32_t kn_event_mask;
|
|
||||||
} kcf_ntfy_elem_t;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following values are based on the assumption that it would
|
* The following values are based on the assumption that it would
|
||||||
|
@ -412,19 +357,6 @@ typedef struct kcf_ntfy_elem {
|
||||||
*/
|
*/
|
||||||
#define CRYPTO_TASKQ_MAX 2 * 1024 * 1024
|
#define CRYPTO_TASKQ_MAX 2 * 1024 * 1024
|
||||||
|
|
||||||
/*
|
|
||||||
* All pending crypto bufcalls are put on a list. cbuf_list_lock
|
|
||||||
* protects changes to this list.
|
|
||||||
*/
|
|
||||||
extern kmutex_t cbuf_list_lock;
|
|
||||||
extern kcondvar_t cbuf_list_cv;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All event subscribers are put on a list. kcf_notify_list_lock
|
|
||||||
* protects changes to this list.
|
|
||||||
*/
|
|
||||||
extern kmutex_t ntfy_list_lock;
|
|
||||||
extern kcondvar_t ntfy_list_cv;
|
|
||||||
|
|
||||||
extern void kcf_free_triedlist(kcf_prov_tried_t *);
|
extern void kcf_free_triedlist(kcf_prov_tried_t *);
|
||||||
extern kcf_prov_tried_t *kcf_insert_triedlist(kcf_prov_tried_t **,
|
extern kcf_prov_tried_t *kcf_insert_triedlist(kcf_prov_tried_t **,
|
||||||
|
@ -447,7 +379,6 @@ extern void verify_unverified_providers(void);
|
||||||
extern void kcf_free_req(kcf_areq_node_t *areq);
|
extern void kcf_free_req(kcf_areq_node_t *areq);
|
||||||
extern void crypto_bufcall_service(void);
|
extern void crypto_bufcall_service(void);
|
||||||
|
|
||||||
extern void kcf_walk_ntfylist(uint32_t, void *);
|
|
||||||
extern void kcf_do_notify(kcf_provider_desc_t *, boolean_t);
|
extern void kcf_do_notify(kcf_provider_desc_t *, boolean_t);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -122,7 +122,6 @@ crypto_register_provider(const crypto_provider_info_t *info,
|
||||||
mutex_enter(&prov_desc->pd_lock);
|
mutex_enter(&prov_desc->pd_lock);
|
||||||
prov_desc->pd_state = KCF_PROV_READY;
|
prov_desc->pd_state = KCF_PROV_READY;
|
||||||
mutex_exit(&prov_desc->pd_lock);
|
mutex_exit(&prov_desc->pd_lock);
|
||||||
kcf_do_notify(prov_desc, B_TRUE);
|
|
||||||
|
|
||||||
*handle = prov_desc->pd_kcf_prov_handle;
|
*handle = prov_desc->pd_kcf_prov_handle;
|
||||||
ret = CRYPTO_SUCCESS;
|
ret = CRYPTO_SUCCESS;
|
||||||
|
@ -209,8 +208,6 @@ crypto_unregister_provider(crypto_kcf_provider_handle_t handle)
|
||||||
cv_wait(&desc->pd_remove_cv, &desc->pd_lock);
|
cv_wait(&desc->pd_remove_cv, &desc->pd_lock);
|
||||||
mutex_exit(&desc->pd_lock);
|
mutex_exit(&desc->pd_lock);
|
||||||
|
|
||||||
kcf_do_notify(desc, B_FALSE);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the only place where kcf_free_provider_desc()
|
* This is the only place where kcf_free_provider_desc()
|
||||||
* is called directly. KCF_PROV_REFRELE() should free the
|
* is called directly. KCF_PROV_REFRELE() should free the
|
||||||
|
@ -366,32 +363,6 @@ undo_register_provider(kcf_provider_desc_t *desc, boolean_t remove_prov)
|
||||||
(void) kcf_prov_tab_rem_provider(desc->pd_prov_id);
|
(void) kcf_prov_tab_rem_provider(desc->pd_prov_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Dispatch events as needed for a provider. is_added flag tells
|
|
||||||
* whether the provider is registering or unregistering.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
kcf_do_notify(kcf_provider_desc_t *prov_desc, boolean_t is_added)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
crypto_notify_event_change_t ec;
|
|
||||||
|
|
||||||
ASSERT(prov_desc->pd_state > KCF_PROV_ALLOCATED);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inform interested clients of the mechanisms becoming
|
|
||||||
* available/unavailable.
|
|
||||||
*/
|
|
||||||
ec.ec_change = is_added ? CRYPTO_MECH_ADDED :
|
|
||||||
CRYPTO_MECH_REMOVED;
|
|
||||||
for (i = 0; i < prov_desc->pd_mech_list_count; i++) {
|
|
||||||
(void) strlcpy(ec.ec_mech_name,
|
|
||||||
prov_desc->pd_mechanisms[i].cm_mech_name,
|
|
||||||
CRYPTO_MAX_MECH_NAME);
|
|
||||||
kcf_walk_ntfylist(CRYPTO_EVENT_MECHS_CHANGED, &ec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_kstat(kcf_provider_desc_t *desc)
|
delete_kstat(kcf_provider_desc_t *desc)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue