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 */
41 typedef struct dpaa_sec_session_entry {
42 uint8_t dir; /*!< Operation Direction */
43 enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/
44 enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/
45 enum rte_crypto_aead_algorithm aead_alg; /*!< Authentication Algorithm*/
48 uint8_t *data; /**< pointer to key data */
49 size_t length; /**< key length in bytes */
53 uint8_t *data; /**< pointer to key data */
54 size_t length; /**< key length in bytes */
57 uint8_t *data; /**< pointer to key data */
58 size_t length; /**< key length in bytes */
65 } iv; /**< Initialisation vector parameters */
66 uint16_t auth_only_len; /*!< Length of data for Auth only */
67 uint32_t digest_length;
68 struct dpaa_sec_qp *qp;
69 struct rte_mempool *ctx_pool; /* session mempool for dpaa_sec_op_ctx */
72 #define DPAA_SEC_MAX_DESC_SIZE 64
73 /* code or cmd block to caam */
79 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
81 unsigned int rsvd47_39:9;
85 unsigned int rsvd47_39:9;
94 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
95 unsigned int rsvd31_30:2;
98 unsigned int offset:2;
100 unsigned int add_buf:1;
102 uint16_t pool_buffer_size;
104 uint16_t pool_buffer_size;
106 unsigned int add_buf:1;
108 unsigned int offset:2;
111 unsigned int rsvd31_30:2;
117 uint32_t sh_desc[DPAA_SEC_MAX_DESC_SIZE];
121 struct dpaa_sec_dev_private *internals;
122 struct sec_cdb cdb; /* cmd block associated with qp */
123 dpaa_sec_session *ses; /* session associated with qp */
132 #define RTE_MAX_NB_SEC_QPS RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS
133 /* internal sec queue interface */
134 struct dpaa_sec_dev_private {
136 struct rte_mempool *ctx_pool; /* per dev mempool for dpaa_sec_op_ctx */
137 struct dpaa_sec_qp qps[RTE_MAX_NB_SEC_QPS]; /* i/o queue for sec */
138 unsigned int max_nb_queue_pairs;
139 unsigned int max_nb_sessions;
142 #define MAX_SG_ENTRIES 16
143 #define SG_CACHELINE_0 0
144 #define SG_CACHELINE_1 4
145 #define SG_CACHELINE_2 8
146 #define SG_CACHELINE_3 12
147 struct dpaa_sec_job {
148 /* sg[0] output, sg[1] input, others are possible sub frames */
149 struct qm_sg_entry sg[MAX_SG_ENTRIES];
152 #define DPAA_MAX_NB_MAX_DIGEST 32
153 struct dpaa_sec_op_ctx {
154 struct dpaa_sec_job job;
155 struct rte_crypto_op *op;
156 struct rte_mempool *ctx_pool; /* mempool pointer for dpaa_sec_op_ctx */
158 uint8_t digest[DPAA_MAX_NB_MAX_DIGEST];
161 static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = {
163 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
165 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
167 .algo = RTE_CRYPTO_AUTH_MD5_HMAC,
183 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
185 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
187 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
203 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
205 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
207 .algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
223 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
225 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
227 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
243 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
245 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
247 .algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
263 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
265 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
267 .algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
283 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
285 .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
287 .algo = RTE_CRYPTO_AEAD_AES_GCM,
313 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
315 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
317 .algo = RTE_CRYPTO_CIPHER_AES_CBC,
333 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
335 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
337 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
353 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
355 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
357 .algo = RTE_CRYPTO_CIPHER_3DES_CBC,
373 RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
376 #endif /* _DPAA_SEC_H_ */