~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/crypto/engine.h

Version: ~ [ linux-5.18-rc6 ] ~ [ linux-5.17.6 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.38 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.114 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.192 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.241 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.277 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.312 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Crypto engine API
  3  *
  4  * Copyright (c) 2016 Baolin Wang <baolin.wang@linaro.org>
  5  *
  6  * This program is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License as published by the Free
  8  * Software Foundation; either version 2 of the License, or (at your option)
  9  * any later version.
 10  *
 11  */
 12 #ifndef _CRYPTO_ENGINE_H
 13 #define _CRYPTO_ENGINE_H
 14 
 15 #include <linux/crypto.h>
 16 #include <linux/list.h>
 17 #include <linux/kernel.h>
 18 #include <linux/kthread.h>
 19 #include <crypto/algapi.h>
 20 #include <crypto/aead.h>
 21 #include <crypto/akcipher.h>
 22 #include <crypto/hash.h>
 23 #include <crypto/skcipher.h>
 24 
 25 #define ENGINE_NAME_LEN 30
 26 /*
 27  * struct crypto_engine - crypto hardware engine
 28  * @name: the engine name
 29  * @idling: the engine is entering idle state
 30  * @busy: request pump is busy
 31  * @running: the engine is on working
 32  * @cur_req_prepared: current request is prepared
 33  * @list: link with the global crypto engine list
 34  * @queue_lock: spinlock to syncronise access to request queue
 35  * @queue: the crypto queue of the engine
 36  * @rt: whether this queue is set to run as a realtime task
 37  * @prepare_crypt_hardware: a request will soon arrive from the queue
 38  * so the subsystem requests the driver to prepare the hardware
 39  * by issuing this call
 40  * @unprepare_crypt_hardware: there are currently no more requests on the
 41  * queue so the subsystem notifies the driver that it may relax the
 42  * hardware by issuing this call
 43  * @kworker: kthread worker struct for request pump
 44  * @pump_requests: work struct for scheduling work to the request pump
 45  * @priv_data: the engine private data
 46  * @cur_req: the current request which is on processing
 47  */
 48 struct crypto_engine {
 49         char                    name[ENGINE_NAME_LEN];
 50         bool                    idling;
 51         bool                    busy;
 52         bool                    running;
 53         bool                    cur_req_prepared;
 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 
 65         struct kthread_worker           *kworker;
 66         struct kthread_work             pump_requests;
 67 
 68         void                            *priv_data;
 69         struct crypto_async_request     *cur_req;
 70 };
 71 
 72 /*
 73  * struct crypto_engine_op - crypto hardware engine operations
 74  * @prepare__request: do some prepare if need before handle the current request
 75  * @unprepare_request: undo any work done by prepare_request()
 76  * @do_one_request: do encryption for current request
 77  */
 78 struct crypto_engine_op {
 79         int (*prepare_request)(struct crypto_engine *engine,
 80                                void *areq);
 81         int (*unprepare_request)(struct crypto_engine *engine,
 82                                  void *areq);
 83         int (*do_one_request)(struct crypto_engine *engine,
 84                               void *areq);
 85 };
 86 
 87 struct crypto_engine_ctx {
 88         struct crypto_engine_op op;
 89 };
 90 
 91 int crypto_transfer_ablkcipher_request_to_engine(struct crypto_engine *engine,
 92                                                  struct ablkcipher_request *req);
 93 int crypto_transfer_aead_request_to_engine(struct crypto_engine *engine,
 94                                            struct aead_request *req);
 95 int crypto_transfer_akcipher_request_to_engine(struct crypto_engine *engine,
 96                                                struct akcipher_request *req);
 97 int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine,
 98                                                struct ahash_request *req);
 99 int crypto_transfer_skcipher_request_to_engine(struct crypto_engine *engine,
100                                                struct skcipher_request *req);
101 void crypto_finalize_ablkcipher_request(struct crypto_engine *engine,
102                                         struct ablkcipher_request *req, int err);
103 void crypto_finalize_aead_request(struct crypto_engine *engine,
104                                   struct aead_request *req, int err);
105 void crypto_finalize_akcipher_request(struct crypto_engine *engine,
106                                       struct akcipher_request *req, int err);
107 void crypto_finalize_hash_request(struct crypto_engine *engine,
108                                   struct ahash_request *req, int err);
109 void crypto_finalize_skcipher_request(struct crypto_engine *engine,
110                                       struct skcipher_request *req, int err);
111 int crypto_engine_start(struct crypto_engine *engine);
112 int crypto_engine_stop(struct crypto_engine *engine);
113 struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt);
114 int crypto_engine_exit(struct crypto_engine *engine);
115 
116 #endif /* _CRYPTO_ENGINE_H */
117 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp