1 /* SPDX-License-Identifier: GPL-2.0-or-later */
5 * Copyright (c) 2016 Baolin Wang <baolin.wang@linaro.org>
6 * Copyright (c) 2023 Herbert Xu <herbert@gondor.apana.org.au>
8 #ifndef _CRYPTO_INTERNAL_ENGINE_H
9 #define _CRYPTO_INTERNAL_ENGINE_H
11 #include <crypto/algapi.h>
12 #include <crypto/engine.h>
13 #include <linux/kthread.h>
14 #include <linux/spinlock_types.h>
15 #include <linux/types.h>
17 #define ENGINE_NAME_LEN 30
22 * struct crypto_engine - crypto hardware engine
23 * @name: the engine name
24 * @idling: the engine is entering idle state
25 * @busy: request pump is busy
26 * @running: the engine is on working
27 * @retry_support: indication that the hardware allows re-execution
28 * of a failed backlog request
29 * crypto-engine, in head position to keep order
30 * @list: link with the global crypto engine list
31 * @queue_lock: spinlock to synchronise access to request queue
32 * @queue: the crypto queue of the engine
33 * @rt: whether this queue is set to run as a realtime task
34 * @prepare_crypt_hardware: a request will soon arrive from the queue
35 * so the subsystem requests the driver to prepare the hardware
36 * by issuing this call
37 * @unprepare_crypt_hardware: there are currently no more requests on the
38 * queue so the subsystem notifies the driver that it may relax the
39 * hardware by issuing this call
40 * @do_batch_requests: execute a batch of requests. Depends on multiple
42 * @kworker: kthread worker struct for request pump
43 * @pump_requests: work struct for scheduling work to the request pump
44 * @priv_data: the engine private data
45 * @cur_req: the current request which is on processing
47 struct crypto_engine {
48 char name[ENGINE_NAME_LEN];
55 struct list_head list;
56 spinlock_t queue_lock;
57 struct crypto_queue queue;
62 int (*prepare_crypt_hardware)(struct crypto_engine *engine);
63 int (*unprepare_crypt_hardware)(struct crypto_engine *engine);
64 int (*do_batch_requests)(struct crypto_engine *engine);
67 struct kthread_worker *kworker;
68 struct kthread_work pump_requests;
71 struct crypto_async_request *cur_req;