2023-08-13 14:54:41 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
|
|
* Crypto engine API
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Baolin Wang <baolin.wang@linaro.org>
|
|
|
|
* Copyright (c) 2023 Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
*/
|
|
|
|
#ifndef _CRYPTO_INTERNAL_ENGINE_H
|
|
|
|
#define _CRYPTO_INTERNAL_ENGINE_H
|
|
|
|
|
2023-08-13 14:54:47 +08:00
|
|
|
#include <crypto/algapi.h>
|
2023-08-13 14:54:41 +08:00
|
|
|
#include <crypto/engine.h>
|
2023-08-13 14:54:47 +08:00
|
|
|
#include <linux/kthread.h>
|
|
|
|
#include <linux/spinlock_types.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#define ENGINE_NAME_LEN 30
|
|
|
|
|
|
|
|
struct device;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* struct crypto_engine - crypto hardware engine
|
|
|
|
* @name: the engine name
|
|
|
|
* @busy: request pump is busy
|
|
|
|
* @running: the engine is on working
|
|
|
|
* @retry_support: indication that the hardware allows re-execution
|
|
|
|
* of a failed backlog request
|
|
|
|
* crypto-engine, in head position to keep order
|
crypto: engine - Realign struct crypto_engine to save 8 bytes
Realign struct crypto_engine to reduce its size by 8 bytes. Total size
is now 192 bytes, allowing it to fit within 3 cachelines instead of 4.
pahole output before:
/* size: 200, cachelines: 4, members: 17 */
/* sum members: 183, holes: 3, sum holes: 17 */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 8 bytes */
and after:
/* size: 192, cachelines: 3, members: 17 */
/* sum members: 183, holes: 2, sum holes: 9 */
/* paddings: 1, sum paddings: 4 */
No functional changes intended.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-18 00:36:49 +02:00
|
|
|
* @rt: whether this queue is set to run as a realtime task
|
2023-08-13 14:54:47 +08:00
|
|
|
* @list: link with the global crypto engine list
|
|
|
|
* @queue_lock: spinlock to synchronise access to request queue
|
|
|
|
* @queue: the crypto queue of the engine
|
|
|
|
* @kworker: kthread worker struct for request pump
|
|
|
|
* @pump_requests: work struct for scheduling work to the request pump
|
|
|
|
* @priv_data: the engine private data
|
|
|
|
* @cur_req: the current request which is on processing
|
|
|
|
*/
|
|
|
|
struct crypto_engine {
|
|
|
|
char name[ENGINE_NAME_LEN];
|
|
|
|
bool busy;
|
|
|
|
bool running;
|
|
|
|
|
|
|
|
bool retry_support;
|
crypto: engine - Realign struct crypto_engine to save 8 bytes
Realign struct crypto_engine to reduce its size by 8 bytes. Total size
is now 192 bytes, allowing it to fit within 3 cachelines instead of 4.
pahole output before:
/* size: 200, cachelines: 4, members: 17 */
/* sum members: 183, holes: 3, sum holes: 17 */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 8 bytes */
and after:
/* size: 192, cachelines: 3, members: 17 */
/* sum members: 183, holes: 2, sum holes: 9 */
/* paddings: 1, sum paddings: 4 */
No functional changes intended.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-18 00:36:49 +02:00
|
|
|
bool rt;
|
2023-08-13 14:54:47 +08:00
|
|
|
|
|
|
|
struct list_head list;
|
|
|
|
spinlock_t queue_lock;
|
|
|
|
struct crypto_queue queue;
|
|
|
|
struct device *dev;
|
|
|
|
|
|
|
|
struct kthread_worker *kworker;
|
|
|
|
struct kthread_work pump_requests;
|
|
|
|
|
|
|
|
void *priv_data;
|
|
|
|
struct crypto_async_request *cur_req;
|
|
|
|
};
|
2023-08-13 14:54:41 +08:00
|
|
|
|
|
|
|
#endif
|