engine.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Crypto engine API
  4. *
  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_H
  9. #define _CRYPTO_INTERNAL_ENGINE_H
  10. #include <crypto/algapi.h>
  11. #include <crypto/engine.h>
  12. #include <linux/kthread.h>
  13. #include <linux/spinlock_types.h>
  14. #include <linux/types.h>
  15. #define ENGINE_NAME_LEN 30
  16. struct device;
  17. /*
  18. * struct crypto_engine - crypto hardware engine
  19. * @name: the engine name
  20. * @busy: request pump is busy
  21. * @running: the engine is on working
  22. * @retry_support: indication that the hardware allows re-execution
  23. * of a failed backlog request
  24. * crypto-engine, in head position to keep order
  25. * @rt: whether this queue is set to run as a realtime task
  26. * @list: link with the global crypto engine list
  27. * @queue_lock: spinlock to synchronise access to request queue
  28. * @queue: the crypto queue of the engine
  29. * @kworker: kthread worker struct for request pump
  30. * @pump_requests: work struct for scheduling work to the request pump
  31. * @priv_data: the engine private data
  32. * @cur_req: the current request which is on processing
  33. */
  34. struct crypto_engine {
  35. char name[ENGINE_NAME_LEN];
  36. bool busy;
  37. bool running;
  38. bool retry_support;
  39. bool rt;
  40. struct list_head list;
  41. spinlock_t queue_lock;
  42. struct crypto_queue queue __guarded_by(&queue_lock);
  43. struct device *dev;
  44. struct kthread_worker *kworker;
  45. struct kthread_work pump_requests;
  46. void *priv_data;
  47. struct crypto_async_request *cur_req;
  48. };
  49. #endif