| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Cryptographic API. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> |
|---|
| 5 | 6 | * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 8 | | - * under the terms of the GNU General Public License as published by the Free |
|---|
| 9 | | - * Software Foundation; either version 2 of the License, or (at your option) |
|---|
| 10 | | - * any later version. |
|---|
| 11 | | - * |
|---|
| 12 | 7 | */ |
|---|
| 13 | 8 | #ifndef _CRYPTO_INTERNAL_H |
|---|
| 14 | 9 | #define _CRYPTO_INTERNAL_H |
|---|
| 15 | 10 | |
|---|
| 16 | 11 | #include <crypto/algapi.h> |
|---|
| 17 | 12 | #include <linux/completion.h> |
|---|
| 18 | | -#include <linux/mm.h> |
|---|
| 19 | | -#include <linux/highmem.h> |
|---|
| 20 | | -#include <linux/interrupt.h> |
|---|
| 21 | | -#include <linux/init.h> |
|---|
| 22 | 13 | #include <linux/list.h> |
|---|
| 23 | 14 | #include <linux/module.h> |
|---|
| 24 | | -#include <linux/kernel.h> |
|---|
| 25 | 15 | #include <linux/notifier.h> |
|---|
| 16 | +#include <linux/numa.h> |
|---|
| 17 | +#include <linux/refcount.h> |
|---|
| 26 | 18 | #include <linux/rwsem.h> |
|---|
| 27 | | -#include <linux/slab.h> |
|---|
| 28 | | - |
|---|
| 29 | | -/* Crypto notification events. */ |
|---|
| 30 | | -enum { |
|---|
| 31 | | - CRYPTO_MSG_ALG_REQUEST, |
|---|
| 32 | | - CRYPTO_MSG_ALG_REGISTER, |
|---|
| 33 | | -}; |
|---|
| 19 | +#include <linux/sched.h> |
|---|
| 20 | +#include <linux/types.h> |
|---|
| 34 | 21 | |
|---|
| 35 | 22 | struct crypto_instance; |
|---|
| 36 | 23 | struct crypto_template; |
|---|
| .. | .. |
|---|
| 69 | 56 | struct crypto_alg *crypto_mod_get(struct crypto_alg *alg); |
|---|
| 70 | 57 | struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask); |
|---|
| 71 | 58 | |
|---|
| 72 | | -int crypto_init_cipher_ops(struct crypto_tfm *tfm); |
|---|
| 73 | | -int crypto_init_compress_ops(struct crypto_tfm *tfm); |
|---|
| 74 | | - |
|---|
| 75 | 59 | struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask); |
|---|
| 76 | 60 | void crypto_larval_kill(struct crypto_alg *alg); |
|---|
| 77 | 61 | void crypto_alg_tested(const char *name, int err); |
|---|
| .. | .. |
|---|
| 79 | 63 | void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list, |
|---|
| 80 | 64 | struct crypto_alg *nalg); |
|---|
| 81 | 65 | void crypto_remove_final(struct list_head *list); |
|---|
| 66 | +void crypto_shoot_alg(struct crypto_alg *alg); |
|---|
| 82 | 67 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, |
|---|
| 83 | 68 | u32 mask); |
|---|
| 84 | | -void *crypto_create_tfm(struct crypto_alg *alg, |
|---|
| 85 | | - const struct crypto_type *frontend); |
|---|
| 69 | +void *crypto_create_tfm_node(struct crypto_alg *alg, |
|---|
| 70 | + const struct crypto_type *frontend, int node); |
|---|
| 71 | + |
|---|
| 72 | +static inline void *crypto_create_tfm(struct crypto_alg *alg, |
|---|
| 73 | + const struct crypto_type *frontend) |
|---|
| 74 | +{ |
|---|
| 75 | + return crypto_create_tfm_node(alg, frontend, NUMA_NO_NODE); |
|---|
| 76 | +} |
|---|
| 77 | + |
|---|
| 86 | 78 | struct crypto_alg *crypto_find_alg(const char *alg_name, |
|---|
| 87 | 79 | const struct crypto_type *frontend, |
|---|
| 88 | 80 | u32 type, u32 mask); |
|---|
| 89 | | -void *crypto_alloc_tfm(const char *alg_name, |
|---|
| 90 | | - const struct crypto_type *frontend, u32 type, u32 mask); |
|---|
| 91 | 81 | |
|---|
| 92 | | -int crypto_register_notifier(struct notifier_block *nb); |
|---|
| 93 | | -int crypto_unregister_notifier(struct notifier_block *nb); |
|---|
| 82 | +void *crypto_alloc_tfm_node(const char *alg_name, |
|---|
| 83 | + const struct crypto_type *frontend, u32 type, u32 mask, |
|---|
| 84 | + int node); |
|---|
| 85 | + |
|---|
| 86 | +static inline void *crypto_alloc_tfm(const char *alg_name, |
|---|
| 87 | + const struct crypto_type *frontend, u32 type, u32 mask) |
|---|
| 88 | +{ |
|---|
| 89 | + return crypto_alloc_tfm_node(alg_name, frontend, type, mask, NUMA_NO_NODE); |
|---|
| 90 | +} |
|---|
| 91 | + |
|---|
| 94 | 92 | int crypto_probing_notify(unsigned long val, void *v); |
|---|
| 95 | 93 | |
|---|
| 96 | 94 | unsigned int crypto_alg_extsize(struct crypto_alg *alg); |
|---|
| .. | .. |
|---|
| 140 | 138 | blocking_notifier_call_chain(&crypto_chain, val, v); |
|---|
| 141 | 139 | } |
|---|
| 142 | 140 | |
|---|
| 141 | +static inline void crypto_yield(u32 flags) |
|---|
| 142 | +{ |
|---|
| 143 | + if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) |
|---|
| 144 | + cond_resched(); |
|---|
| 145 | +} |
|---|
| 146 | + |
|---|
| 143 | 147 | #endif /* _CRYPTO_INTERNAL_H */ |
|---|
| 144 | 148 | |
|---|