brintos

brintos / linux-shallow public Read only

0
0
Text · 2.2 KiB · fbf4be5 Raw
75 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later */2/*3 * Crypto engine API4 *5 * Copyright (c) 2016 Baolin Wang <baolin.wang@linaro.org>6 * Copyright (c) 2023 Herbert Xu <herbert@gondor.apana.org.au>7 */8#ifndef _CRYPTO_INTERNAL_ENGINE_H9#define _CRYPTO_INTERNAL_ENGINE_H10 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>16 17#define ENGINE_NAME_LEN	3018 19struct device;20 21/*22 * struct crypto_engine - crypto hardware engine23 * @name: the engine name24 * @idling: the engine is entering idle state25 * @busy: request pump is busy26 * @running: the engine is on working27 * @retry_support: indication that the hardware allows re-execution28 * of a failed backlog request29 * crypto-engine, in head position to keep order30 * @list: link with the global crypto engine list31 * @queue_lock: spinlock to synchronise access to request queue32 * @queue: the crypto queue of the engine33 * @rt: whether this queue is set to run as a realtime task34 * @prepare_crypt_hardware: a request will soon arrive from the queue35 * so the subsystem requests the driver to prepare the hardware36 * by issuing this call37 * @unprepare_crypt_hardware: there are currently no more requests on the38 * queue so the subsystem notifies the driver that it may relax the39 * hardware by issuing this call40 * @do_batch_requests: execute a batch of requests. Depends on multiple41 * requests support.42 * @kworker: kthread worker struct for request pump43 * @pump_requests: work struct for scheduling work to the request pump44 * @priv_data: the engine private data45 * @cur_req: the current request which is on processing46 */47struct crypto_engine {48	char			name[ENGINE_NAME_LEN];49	bool			idling;50	bool			busy;51	bool			running;52 53	bool			retry_support;54 55	struct list_head	list;56	spinlock_t		queue_lock;57	struct crypto_queue	queue;58	struct device		*dev;59 60	bool			rt;61 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);65 66 67	struct kthread_worker           *kworker;68	struct kthread_work             pump_requests;69 70	void				*priv_data;71	struct crypto_async_request	*cur_req;72};73 74#endif75