Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / crypto / cavium / cpt / cptvf_algs.h
blob902f25751123a559d63f3e63bf8d4dd3c494d0da
1 /*
2 * Copyright (C) 2016 Cavium, Inc.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 */
9 #ifndef _CPTVF_ALGS_H_
10 #define _CPTVF_ALGS_H_
12 #include "request_manager.h"
14 #define MAX_DEVICES 16
15 #define MAJOR_OP_FC 0x33
16 #define MAX_ENC_KEY_SIZE 32
17 #define MAX_HASH_KEY_SIZE 64
18 #define MAX_KEY_SIZE (MAX_ENC_KEY_SIZE + MAX_HASH_KEY_SIZE)
19 #define CONTROL_WORD_LEN 8
20 #define KEY2_OFFSET 48
22 #define DMA_MODE_FLAG(dma_mode) \
23 (((dma_mode) == DMA_GATHER_SCATTER) ? (1 << 7) : 0)
25 enum req_type {
26 AE_CORE_REQ,
27 SE_CORE_REQ,
30 enum cipher_type {
31 DES3_CBC = 0x1,
32 DES3_ECB = 0x2,
33 AES_CBC = 0x3,
34 AES_ECB = 0x4,
35 AES_CFB = 0x5,
36 AES_CTR = 0x6,
37 AES_GCM = 0x7,
38 AES_XTS = 0x8
41 enum aes_type {
42 AES_128_BIT = 0x1,
43 AES_192_BIT = 0x2,
44 AES_256_BIT = 0x3
47 union encr_ctrl {
48 u64 flags;
49 struct {
50 #if defined(__BIG_ENDIAN_BITFIELD)
51 u64 enc_cipher:4;
52 u64 reserved1:1;
53 u64 aes_key:2;
54 u64 iv_source:1;
55 u64 hash_type:4;
56 u64 reserved2:3;
57 u64 auth_input_type:1;
58 u64 mac_len:8;
59 u64 reserved3:8;
60 u64 encr_offset:16;
61 u64 iv_offset:8;
62 u64 auth_offset:8;
63 #else
64 u64 auth_offset:8;
65 u64 iv_offset:8;
66 u64 encr_offset:16;
67 u64 reserved3:8;
68 u64 mac_len:8;
69 u64 auth_input_type:1;
70 u64 reserved2:3;
71 u64 hash_type:4;
72 u64 iv_source:1;
73 u64 aes_key:2;
74 u64 reserved1:1;
75 u64 enc_cipher:4;
76 #endif
77 } e;
80 struct cvm_cipher {
81 const char *name;
82 u8 value;
85 struct enc_context {
86 union encr_ctrl enc_ctrl;
87 u8 encr_key[32];
88 u8 encr_iv[16];
91 struct fchmac_context {
92 u8 ipad[64];
93 u8 opad[64]; /* or OPAD */
96 struct fc_context {
97 struct enc_context enc;
98 struct fchmac_context hmac;
101 struct cvm_enc_ctx {
102 u32 key_len;
103 u8 enc_key[MAX_KEY_SIZE];
104 u8 cipher_type:4;
105 u8 key_type:2;
108 struct cvm_des3_ctx {
109 u32 key_len;
110 u8 des3_key[MAX_KEY_SIZE];
113 struct cvm_req_ctx {
114 struct cpt_request_info cpt_req;
115 u64 control_word;
116 struct fc_context fctx;
119 int cptvf_do_request(void *cptvf, struct cpt_request_info *req);
120 #endif /*_CPTVF_ALGS_H_*/