ccp-dev.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /*
  2. * AMD Cryptographic Coprocessor (CCP) driver
  3. *
  4. * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
  5. *
  6. * Author: Tom Lendacky <thomas.lendacky@amd.com>
  7. * Author: Gary R Hook <gary.hook@amd.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef __CCP_DEV_H__
  14. #define __CCP_DEV_H__
  15. #include <linux/device.h>
  16. #include <linux/pci.h>
  17. #include <linux/spinlock.h>
  18. #include <linux/mutex.h>
  19. #include <linux/list.h>
  20. #include <linux/wait.h>
  21. #include <linux/dmapool.h>
  22. #include <linux/hw_random.h>
  23. #include <linux/bitops.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irqreturn.h>
  26. #include <linux/dmaengine.h>
  27. #define MAX_CCP_NAME_LEN 16
  28. #define MAX_DMAPOOL_NAME_LEN 32
  29. #define MAX_HW_QUEUES 5
  30. #define MAX_CMD_QLEN 100
  31. #define TRNG_RETRIES 10
  32. #define CACHE_NONE 0x00
  33. #define CACHE_WB_NO_ALLOC 0xb7
  34. /****** Register Mappings ******/
  35. #define Q_MASK_REG 0x000
  36. #define TRNG_OUT_REG 0x00c
  37. #define IRQ_MASK_REG 0x040
  38. #define IRQ_STATUS_REG 0x200
  39. #define DEL_CMD_Q_JOB 0x124
  40. #define DEL_Q_ACTIVE 0x00000200
  41. #define DEL_Q_ID_SHIFT 6
  42. #define CMD_REQ0 0x180
  43. #define CMD_REQ_INCR 0x04
  44. #define CMD_Q_STATUS_BASE 0x210
  45. #define CMD_Q_INT_STATUS_BASE 0x214
  46. #define CMD_Q_STATUS_INCR 0x20
  47. #define CMD_Q_CACHE_BASE 0x228
  48. #define CMD_Q_CACHE_INC 0x20
  49. #define CMD_Q_ERROR(__qs) ((__qs) & 0x0000003f)
  50. #define CMD_Q_DEPTH(__qs) (((__qs) >> 12) & 0x0000000f)
  51. /* ------------------------ CCP Version 5 Specifics ------------------------ */
  52. #define CMD5_QUEUE_MASK_OFFSET 0x00
  53. #define CMD5_QUEUE_PRIO_OFFSET 0x04
  54. #define CMD5_REQID_CONFIG_OFFSET 0x08
  55. #define CMD5_CMD_TIMEOUT_OFFSET 0x10
  56. #define LSB_PUBLIC_MASK_LO_OFFSET 0x18
  57. #define LSB_PUBLIC_MASK_HI_OFFSET 0x1C
  58. #define LSB_PRIVATE_MASK_LO_OFFSET 0x20
  59. #define LSB_PRIVATE_MASK_HI_OFFSET 0x24
  60. #define CMD5_Q_CONTROL_BASE 0x0000
  61. #define CMD5_Q_TAIL_LO_BASE 0x0004
  62. #define CMD5_Q_HEAD_LO_BASE 0x0008
  63. #define CMD5_Q_INT_ENABLE_BASE 0x000C
  64. #define CMD5_Q_INTERRUPT_STATUS_BASE 0x0010
  65. #define CMD5_Q_STATUS_BASE 0x0100
  66. #define CMD5_Q_INT_STATUS_BASE 0x0104
  67. #define CMD5_Q_DMA_STATUS_BASE 0x0108
  68. #define CMD5_Q_DMA_READ_STATUS_BASE 0x010C
  69. #define CMD5_Q_DMA_WRITE_STATUS_BASE 0x0110
  70. #define CMD5_Q_ABORT_BASE 0x0114
  71. #define CMD5_Q_AX_CACHE_BASE 0x0118
  72. #define CMD5_CONFIG_0_OFFSET 0x6000
  73. #define CMD5_TRNG_CTL_OFFSET 0x6008
  74. #define CMD5_AES_MASK_OFFSET 0x6010
  75. #define CMD5_CLK_GATE_CTL_OFFSET 0x603C
  76. /* Address offset between two virtual queue registers */
  77. #define CMD5_Q_STATUS_INCR 0x1000
  78. /* Bit masks */
  79. #define CMD5_Q_RUN 0x1
  80. #define CMD5_Q_HALT 0x2
  81. #define CMD5_Q_MEM_LOCATION 0x4
  82. #define CMD5_Q_SIZE 0x1F
  83. #define CMD5_Q_SHIFT 3
  84. #define COMMANDS_PER_QUEUE 16
  85. #define QUEUE_SIZE_VAL ((ffs(COMMANDS_PER_QUEUE) - 2) & \
  86. CMD5_Q_SIZE)
  87. #define Q_PTR_MASK (2 << (QUEUE_SIZE_VAL + 5) - 1)
  88. #define Q_DESC_SIZE sizeof(struct ccp5_desc)
  89. #define Q_SIZE(n) (COMMANDS_PER_QUEUE*(n))
  90. #define INT_COMPLETION 0x1
  91. #define INT_ERROR 0x2
  92. #define INT_QUEUE_STOPPED 0x4
  93. #define INT_EMPTY_QUEUE 0x8
  94. #define SUPPORTED_INTERRUPTS (INT_COMPLETION | INT_ERROR)
  95. #define LSB_REGION_WIDTH 5
  96. #define MAX_LSB_CNT 8
  97. #define LSB_SIZE 16
  98. #define LSB_ITEM_SIZE 32
  99. #define PLSB_MAP_SIZE (LSB_SIZE)
  100. #define SLSB_MAP_SIZE (MAX_LSB_CNT * LSB_SIZE)
  101. #define LSB_ENTRY_NUMBER(LSB_ADDR) (LSB_ADDR / LSB_ITEM_SIZE)
  102. /* ------------------------ CCP Version 3 Specifics ------------------------ */
  103. #define REQ0_WAIT_FOR_WRITE 0x00000004
  104. #define REQ0_INT_ON_COMPLETE 0x00000002
  105. #define REQ0_STOP_ON_COMPLETE 0x00000001
  106. #define REQ0_CMD_Q_SHIFT 9
  107. #define REQ0_JOBID_SHIFT 3
  108. /****** REQ1 Related Values ******/
  109. #define REQ1_PROTECT_SHIFT 27
  110. #define REQ1_ENGINE_SHIFT 23
  111. #define REQ1_KEY_KSB_SHIFT 2
  112. #define REQ1_EOM 0x00000002
  113. #define REQ1_INIT 0x00000001
  114. /* AES Related Values */
  115. #define REQ1_AES_TYPE_SHIFT 21
  116. #define REQ1_AES_MODE_SHIFT 18
  117. #define REQ1_AES_ACTION_SHIFT 17
  118. #define REQ1_AES_CFB_SIZE_SHIFT 10
  119. /* XTS-AES Related Values */
  120. #define REQ1_XTS_AES_SIZE_SHIFT 10
  121. /* SHA Related Values */
  122. #define REQ1_SHA_TYPE_SHIFT 21
  123. /* RSA Related Values */
  124. #define REQ1_RSA_MOD_SIZE_SHIFT 10
  125. /* Pass-Through Related Values */
  126. #define REQ1_PT_BW_SHIFT 12
  127. #define REQ1_PT_BS_SHIFT 10
  128. /* ECC Related Values */
  129. #define REQ1_ECC_AFFINE_CONVERT 0x00200000
  130. #define REQ1_ECC_FUNCTION_SHIFT 18
  131. /****** REQ4 Related Values ******/
  132. #define REQ4_KSB_SHIFT 18
  133. #define REQ4_MEMTYPE_SHIFT 16
  134. /****** REQ6 Related Values ******/
  135. #define REQ6_MEMTYPE_SHIFT 16
  136. /****** Key Storage Block ******/
  137. #define KSB_START 77
  138. #define KSB_END 127
  139. #define KSB_COUNT (KSB_END - KSB_START + 1)
  140. #define CCP_SB_BITS 256
  141. #define CCP_JOBID_MASK 0x0000003f
  142. /* ------------------------ General CCP Defines ------------------------ */
  143. #define CCP_DMA_DFLT 0x0
  144. #define CCP_DMA_PRIV 0x1
  145. #define CCP_DMA_PUB 0x2
  146. #define CCP_DMAPOOL_MAX_SIZE 64
  147. #define CCP_DMAPOOL_ALIGN BIT(5)
  148. #define CCP_REVERSE_BUF_SIZE 64
  149. #define CCP_AES_KEY_SB_COUNT 1
  150. #define CCP_AES_CTX_SB_COUNT 1
  151. #define CCP_XTS_AES_KEY_SB_COUNT 1
  152. #define CCP_XTS_AES_CTX_SB_COUNT 1
  153. #define CCP_DES3_KEY_SB_COUNT 1
  154. #define CCP_DES3_CTX_SB_COUNT 1
  155. #define CCP_SHA_SB_COUNT 1
  156. #define CCP_RSA_MAX_WIDTH 4096
  157. #define CCP_PASSTHRU_BLOCKSIZE 256
  158. #define CCP_PASSTHRU_MASKSIZE 32
  159. #define CCP_PASSTHRU_SB_COUNT 1
  160. #define CCP_ECC_MODULUS_BYTES 48 /* 384-bits */
  161. #define CCP_ECC_MAX_OPERANDS 6
  162. #define CCP_ECC_MAX_OUTPUTS 3
  163. #define CCP_ECC_SRC_BUF_SIZE 448
  164. #define CCP_ECC_DST_BUF_SIZE 192
  165. #define CCP_ECC_OPERAND_SIZE 64
  166. #define CCP_ECC_OUTPUT_SIZE 64
  167. #define CCP_ECC_RESULT_OFFSET 60
  168. #define CCP_ECC_RESULT_SUCCESS 0x0001
  169. #define CCP_SB_BYTES 32
  170. struct ccp_op;
  171. struct ccp_device;
  172. struct ccp_cmd;
  173. struct ccp_fns;
  174. struct ccp_dma_cmd {
  175. struct list_head entry;
  176. struct ccp_cmd ccp_cmd;
  177. };
  178. struct ccp_dma_desc {
  179. struct list_head entry;
  180. struct ccp_device *ccp;
  181. struct list_head pending;
  182. struct list_head active;
  183. enum dma_status status;
  184. struct dma_async_tx_descriptor tx_desc;
  185. size_t len;
  186. };
  187. struct ccp_dma_chan {
  188. struct ccp_device *ccp;
  189. spinlock_t lock;
  190. struct list_head created;
  191. struct list_head pending;
  192. struct list_head active;
  193. struct list_head complete;
  194. struct tasklet_struct cleanup_tasklet;
  195. enum dma_status status;
  196. struct dma_chan dma_chan;
  197. };
  198. struct ccp_cmd_queue {
  199. struct ccp_device *ccp;
  200. /* Queue identifier */
  201. u32 id;
  202. /* Queue dma pool */
  203. struct dma_pool *dma_pool;
  204. /* Queue base address (not neccessarily aligned)*/
  205. struct ccp5_desc *qbase;
  206. /* Aligned queue start address (per requirement) */
  207. struct mutex q_mutex ____cacheline_aligned;
  208. unsigned int qidx;
  209. /* Version 5 has different requirements for queue memory */
  210. unsigned int qsize;
  211. dma_addr_t qbase_dma;
  212. dma_addr_t qdma_tail;
  213. /* Per-queue reserved storage block(s) */
  214. u32 sb_key;
  215. u32 sb_ctx;
  216. /* Bitmap of LSBs that can be accessed by this queue */
  217. DECLARE_BITMAP(lsbmask, MAX_LSB_CNT);
  218. /* Private LSB that is assigned to this queue, or -1 if none.
  219. * Bitmap for my private LSB, unused otherwise
  220. */
  221. int lsb;
  222. DECLARE_BITMAP(lsbmap, PLSB_MAP_SIZE);
  223. /* Queue processing thread */
  224. struct task_struct *kthread;
  225. unsigned int active;
  226. unsigned int suspended;
  227. /* Number of free command slots available */
  228. unsigned int free_slots;
  229. /* Interrupt masks */
  230. u32 int_ok;
  231. u32 int_err;
  232. /* Register addresses for queue */
  233. void __iomem *reg_control;
  234. void __iomem *reg_tail_lo;
  235. void __iomem *reg_head_lo;
  236. void __iomem *reg_int_enable;
  237. void __iomem *reg_interrupt_status;
  238. void __iomem *reg_status;
  239. void __iomem *reg_int_status;
  240. void __iomem *reg_dma_status;
  241. void __iomem *reg_dma_read_status;
  242. void __iomem *reg_dma_write_status;
  243. u32 qcontrol; /* Cached control register */
  244. /* Status values from job */
  245. u32 int_status;
  246. u32 q_status;
  247. u32 q_int_status;
  248. u32 cmd_error;
  249. /* Interrupt wait queue */
  250. wait_queue_head_t int_queue;
  251. unsigned int int_rcvd;
  252. } ____cacheline_aligned;
  253. struct ccp_device {
  254. struct list_head entry;
  255. struct ccp_vdata *vdata;
  256. unsigned int ord;
  257. char name[MAX_CCP_NAME_LEN];
  258. char rngname[MAX_CCP_NAME_LEN];
  259. struct device *dev;
  260. /* Bus specific device information
  261. */
  262. void *dev_specific;
  263. int (*get_irq)(struct ccp_device *ccp);
  264. void (*free_irq)(struct ccp_device *ccp);
  265. unsigned int qim;
  266. unsigned int irq;
  267. bool use_tasklet;
  268. struct tasklet_struct irq_tasklet;
  269. /* I/O area used for device communication. The register mapping
  270. * starts at an offset into the mapped bar.
  271. * The CMD_REQx registers and the Delete_Cmd_Queue_Job register
  272. * need to be protected while a command queue thread is accessing
  273. * them.
  274. */
  275. struct mutex req_mutex ____cacheline_aligned;
  276. void __iomem *io_map;
  277. void __iomem *io_regs;
  278. /* Master lists that all cmds are queued on. Because there can be
  279. * more than one CCP command queue that can process a cmd a separate
  280. * backlog list is neeeded so that the backlog completion call
  281. * completes before the cmd is available for execution.
  282. */
  283. spinlock_t cmd_lock ____cacheline_aligned;
  284. unsigned int cmd_count;
  285. struct list_head cmd;
  286. struct list_head backlog;
  287. /* The command queues. These represent the queues available on the
  288. * CCP that are available for processing cmds
  289. */
  290. struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES];
  291. unsigned int cmd_q_count;
  292. /* Support for the CCP True RNG
  293. */
  294. struct hwrng hwrng;
  295. unsigned int hwrng_retries;
  296. /* Support for the CCP DMA capabilities
  297. */
  298. struct dma_device dma_dev;
  299. struct ccp_dma_chan *ccp_dma_chan;
  300. struct kmem_cache *dma_cmd_cache;
  301. struct kmem_cache *dma_desc_cache;
  302. /* A counter used to generate job-ids for cmds submitted to the CCP
  303. */
  304. atomic_t current_id ____cacheline_aligned;
  305. /* The v3 CCP uses key storage blocks (SB) to maintain context for
  306. * certain operations. To prevent multiple cmds from using the same
  307. * SB range a command queue reserves an SB range for the duration of
  308. * the cmd. Each queue, will however, reserve 2 SB blocks for
  309. * operations that only require single SB entries (eg. AES context/iv
  310. * and key) in order to avoid allocation contention. This will reserve
  311. * at most 10 SB entries, leaving 40 SB entries available for dynamic
  312. * allocation.
  313. *
  314. * The v5 CCP Local Storage Block (LSB) is broken up into 8
  315. * memrory ranges, each of which can be enabled for access by one
  316. * or more queues. Device initialization takes this into account,
  317. * and attempts to assign one region for exclusive use by each
  318. * available queue; the rest are then aggregated as "public" use.
  319. * If there are fewer regions than queues, all regions are shared
  320. * amongst all queues.
  321. */
  322. struct mutex sb_mutex ____cacheline_aligned;
  323. DECLARE_BITMAP(sb, KSB_COUNT);
  324. wait_queue_head_t sb_queue;
  325. unsigned int sb_avail;
  326. unsigned int sb_count;
  327. u32 sb_start;
  328. /* Bitmap of shared LSBs, if any */
  329. DECLARE_BITMAP(lsbmap, SLSB_MAP_SIZE);
  330. /* Suspend support */
  331. unsigned int suspending;
  332. wait_queue_head_t suspend_queue;
  333. /* DMA caching attribute support */
  334. unsigned int axcache;
  335. };
  336. enum ccp_memtype {
  337. CCP_MEMTYPE_SYSTEM = 0,
  338. CCP_MEMTYPE_SB,
  339. CCP_MEMTYPE_LOCAL,
  340. CCP_MEMTYPE__LAST,
  341. };
  342. #define CCP_MEMTYPE_LSB CCP_MEMTYPE_KSB
  343. struct ccp_dma_info {
  344. dma_addr_t address;
  345. unsigned int offset;
  346. unsigned int length;
  347. enum dma_data_direction dir;
  348. } __packed __aligned(4);
  349. struct ccp_dm_workarea {
  350. struct device *dev;
  351. struct dma_pool *dma_pool;
  352. u8 *address;
  353. struct ccp_dma_info dma;
  354. unsigned int length;
  355. };
  356. struct ccp_sg_workarea {
  357. struct scatterlist *sg;
  358. int nents;
  359. unsigned int sg_used;
  360. struct scatterlist *dma_sg;
  361. struct device *dma_dev;
  362. unsigned int dma_count;
  363. enum dma_data_direction dma_dir;
  364. u64 bytes_left;
  365. };
  366. struct ccp_data {
  367. struct ccp_sg_workarea sg_wa;
  368. struct ccp_dm_workarea dm_wa;
  369. };
  370. struct ccp_mem {
  371. enum ccp_memtype type;
  372. union {
  373. struct ccp_dma_info dma;
  374. u32 sb;
  375. } u;
  376. };
  377. struct ccp_aes_op {
  378. enum ccp_aes_type type;
  379. enum ccp_aes_mode mode;
  380. enum ccp_aes_action action;
  381. unsigned int size;
  382. };
  383. struct ccp_xts_aes_op {
  384. enum ccp_aes_action action;
  385. enum ccp_xts_aes_unit_size unit_size;
  386. };
  387. struct ccp_des3_op {
  388. enum ccp_des3_type type;
  389. enum ccp_des3_mode mode;
  390. enum ccp_des3_action action;
  391. };
  392. struct ccp_sha_op {
  393. enum ccp_sha_type type;
  394. u64 msg_bits;
  395. };
  396. struct ccp_rsa_op {
  397. u32 mod_size;
  398. u32 input_len;
  399. };
  400. struct ccp_passthru_op {
  401. enum ccp_passthru_bitwise bit_mod;
  402. enum ccp_passthru_byteswap byte_swap;
  403. };
  404. struct ccp_ecc_op {
  405. enum ccp_ecc_function function;
  406. };
  407. struct ccp_op {
  408. struct ccp_cmd_queue *cmd_q;
  409. u32 jobid;
  410. u32 ioc;
  411. u32 soc;
  412. u32 sb_key;
  413. u32 sb_ctx;
  414. u32 init;
  415. u32 eom;
  416. struct ccp_mem src;
  417. struct ccp_mem dst;
  418. struct ccp_mem exp;
  419. union {
  420. struct ccp_aes_op aes;
  421. struct ccp_xts_aes_op xts;
  422. struct ccp_des3_op des3;
  423. struct ccp_sha_op sha;
  424. struct ccp_rsa_op rsa;
  425. struct ccp_passthru_op passthru;
  426. struct ccp_ecc_op ecc;
  427. } u;
  428. };
  429. static inline u32 ccp_addr_lo(struct ccp_dma_info *info)
  430. {
  431. return lower_32_bits(info->address + info->offset);
  432. }
  433. static inline u32 ccp_addr_hi(struct ccp_dma_info *info)
  434. {
  435. return upper_32_bits(info->address + info->offset) & 0x0000ffff;
  436. }
  437. /**
  438. * descriptor for version 5 CPP commands
  439. * 8 32-bit words:
  440. * word 0: function; engine; control bits
  441. * word 1: length of source data
  442. * word 2: low 32 bits of source pointer
  443. * word 3: upper 16 bits of source pointer; source memory type
  444. * word 4: low 32 bits of destination pointer
  445. * word 5: upper 16 bits of destination pointer; destination memory type
  446. * word 6: low 32 bits of key pointer
  447. * word 7: upper 16 bits of key pointer; key memory type
  448. */
  449. struct dword0 {
  450. unsigned int soc:1;
  451. unsigned int ioc:1;
  452. unsigned int rsvd1:1;
  453. unsigned int init:1;
  454. unsigned int eom:1; /* AES/SHA only */
  455. unsigned int function:15;
  456. unsigned int engine:4;
  457. unsigned int prot:1;
  458. unsigned int rsvd2:7;
  459. };
  460. struct dword3 {
  461. unsigned int src_hi:16;
  462. unsigned int src_mem:2;
  463. unsigned int lsb_cxt_id:8;
  464. unsigned int rsvd1:5;
  465. unsigned int fixed:1;
  466. };
  467. union dword4 {
  468. __le32 dst_lo; /* NON-SHA */
  469. __le32 sha_len_lo; /* SHA */
  470. };
  471. union dword5 {
  472. struct {
  473. unsigned int dst_hi:16;
  474. unsigned int dst_mem:2;
  475. unsigned int rsvd1:13;
  476. unsigned int fixed:1;
  477. } fields;
  478. __le32 sha_len_hi;
  479. };
  480. struct dword7 {
  481. unsigned int key_hi:16;
  482. unsigned int key_mem:2;
  483. unsigned int rsvd1:14;
  484. };
  485. struct ccp5_desc {
  486. struct dword0 dw0;
  487. __le32 length;
  488. __le32 src_lo;
  489. struct dword3 dw3;
  490. union dword4 dw4;
  491. union dword5 dw5;
  492. __le32 key_lo;
  493. struct dword7 dw7;
  494. };
  495. int ccp_pci_init(void);
  496. void ccp_pci_exit(void);
  497. int ccp_platform_init(void);
  498. void ccp_platform_exit(void);
  499. void ccp_add_device(struct ccp_device *ccp);
  500. void ccp_del_device(struct ccp_device *ccp);
  501. extern void ccp_log_error(struct ccp_device *, int);
  502. struct ccp_device *ccp_alloc_struct(struct device *dev);
  503. bool ccp_queues_suspended(struct ccp_device *ccp);
  504. int ccp_cmd_queue_thread(void *data);
  505. int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait);
  506. int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
  507. int ccp_register_rng(struct ccp_device *ccp);
  508. void ccp_unregister_rng(struct ccp_device *ccp);
  509. int ccp_dmaengine_register(struct ccp_device *ccp);
  510. void ccp_dmaengine_unregister(struct ccp_device *ccp);
  511. /* Structure for computation functions that are device-specific */
  512. struct ccp_actions {
  513. int (*aes)(struct ccp_op *);
  514. int (*xts_aes)(struct ccp_op *);
  515. int (*des3)(struct ccp_op *);
  516. int (*sha)(struct ccp_op *);
  517. int (*rsa)(struct ccp_op *);
  518. int (*passthru)(struct ccp_op *);
  519. int (*ecc)(struct ccp_op *);
  520. u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int);
  521. void (*sbfree)(struct ccp_cmd_queue *, unsigned int, unsigned int);
  522. unsigned int (*get_free_slots)(struct ccp_cmd_queue *);
  523. int (*init)(struct ccp_device *);
  524. void (*destroy)(struct ccp_device *);
  525. irqreturn_t (*irqhandler)(int, void *);
  526. };
  527. /* Structure to hold CCP version-specific values */
  528. struct ccp_vdata {
  529. const unsigned int version;
  530. const unsigned int dma_chan_attr;
  531. void (*setup)(struct ccp_device *);
  532. const struct ccp_actions *perform;
  533. const unsigned int bar;
  534. const unsigned int offset;
  535. };
  536. extern const struct ccp_vdata ccpv3;
  537. extern const struct ccp_vdata ccpv5a;
  538. extern const struct ccp_vdata ccpv5b;
  539. #endif