1 /* SPDX-License-Identifier: BSD-3-Clause
10 #define NUM_POOL_CHANNELS 4
11 #define DPAA_SEC_BURST 32
12 #define DPAA_SEC_ALG_UNSUPPORT (-1)
13 #define TDES_CBC_IV_LEN 8
14 #define AES_CBC_IV_LEN 16
15 #define AES_CTR_IV_LEN 16
16 #define AES_GCM_IV_LEN 12
18 /* Minimum job descriptor consists of a oneword job descriptor HEADER and
19 * a pointer to the shared descriptor.
21 #define MIN_JOB_DESC_SIZE (CAAM_CMD_SZ + CAAM_PTR_SZ)
22 /* CTX_POOL_NUM_BUFS is set as per the ipsec-secgw application */
23 #define CTX_POOL_NUM_BUFS 32000
24 #define CTX_POOL_BUF_SIZE sizeof(struct dpaa_sec_op_ctx)
25 #define CTX_POOL_CACHE_SIZE 512
30 enum dpaa_sec_op_type {
31 DPAA_SEC_NONE, /*!< No Cipher operations*/
32 DPAA_SEC_CIPHER,/*!< CIPHER operations */
33 DPAA_SEC_AUTH, /*!< Authentication Operations */
34 DPAA_SEC_AEAD, /*!< Authenticated Encryption with associated data */
35 DPAA_SEC_IPSEC, /*!< IPSEC protocol operations*/
36 DPAA_SEC_PDCP, /*!< PDCP protocol operations*/
37 DPAA_SEC_PKC, /*!< Public Key Cryptographic Operations */
42 #define DPAA_SEC_MAX_DESC_SIZE 64
43 /* code or cmd block to caam */
49 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
51 unsigned int rsvd47_39:9;
55 unsigned int rsvd47_39:9;
64 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
65 unsigned int rsvd31_30:2;
68 unsigned int offset:2;
70 unsigned int add_buf:1;
72 uint16_t pool_buffer_size;
74 uint16_t pool_buffer_size;
76 unsigned int add_buf:1;
78 unsigned int offset:2;
81 unsigned int rsvd31_30:2;
87 uint32_t sh_desc[DPAA_SEC_MAX_DESC_SIZE];
90 typedef struct dpaa_sec_session_entry {
91 uint8_t dir; /*!< Operation Direction */
92 enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/
93 enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/
94 enum rte_crypto_aead_algorithm aead_alg; /*!< Authentication Algorithm*/
97 uint8_t *data; /**< pointer to key data */
98 size_t length; /**< key length in bytes */
102 uint8_t *data; /**< pointer to key data */
103 size_t length; /**< key length in bytes */
106 uint8_t *data; /**< pointer to key data */
107 size_t length; /**< key length in bytes */
114 } iv; /**< Initialisation vector parameters */
115 uint16_t auth_only_len; /*!< Length of data for Auth only */
116 uint32_t digest_length;
117 struct dpaa_sec_qp *qp;
119 struct sec_cdb cdb; /**< cmd block associated with qp */
120 struct rte_mempool *ctx_pool; /* session mempool for dpaa_sec_op_ctx */
124 struct dpaa_sec_dev_private *internals;
132 #define RTE_DPAA_MAX_NB_SEC_QPS 1
133 #define RTE_DPAA_MAX_RX_QUEUE RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS
135 /* internal sec queue interface */
136 struct dpaa_sec_dev_private {
138 struct rte_mempool *ctx_pool; /* per dev mempool for dpaa_sec_op_ctx */
139 struct dpaa_sec_qp qps[RTE_DPAA_MAX_NB_SEC_QPS]; /* i/o queue for sec */
140 struct qman_fq inq[RTE_DPAA_MAX_RX_QUEUE];
141 unsigned char inq_attach[RTE_DPAA_MAX_RX_QUEUE];
142 unsigned int max_nb_queue_pairs;
143 unsigned int max_nb_sessions;
146 #define MAX_SG_ENTRIES 16
147 #define SG_CACHELINE_0 0
148 #define SG_CACHELINE_1 4
149 #define SG_CACHELINE_2 8
150 #define SG_CACHELINE_3 12
151 struct dpaa_sec_job {
152 /* sg[0] output, sg[1] input, others are possible sub frames */
153 struct qm_sg_entry sg[MAX_SG_ENTRIES];
156 #define DPAA_MAX_NB_MAX_DIGEST 32
157 struct dpaa_sec_op_ctx {
158 struct dpaa_sec_job job;
159 struct rte_crypto_op *op;
160 struct rte_mempool *ctx_pool; /* mempool pointer for dpaa_sec_op_ctx */
163 uint8_t digest[DPAA_MAX_NB_MAX_DIGEST];
166 static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = {
168 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
170 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
172 .algo = RTE_CRYPTO_AUTH_MD5_HMAC,
188 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
190 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
192 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
208 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
210 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
212 .algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
228 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
230 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
232 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
248 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
250 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
252 .algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
268 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
270 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
272 .algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
288 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
290 .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
292 .algo = RTE_CRYPTO_AEAD_AES_GCM,
318 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
320 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
322 .algo = RTE_CRYPTO_CIPHER_AES_CBC,
338 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
340 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
342 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
358 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
360 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
362 .algo = RTE_CRYPTO_CIPHER_3DES_CBC,
378 RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
381 #endif /* _DPAA_SEC_H_ */