1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
8 #ifndef _RTE_DPAA2_SEC_PMD_PRIVATE_H_
9 #define _RTE_DPAA2_SEC_PMD_PRIVATE_H_
11 #define CRYPTODEV_NAME_DPAA2_SEC_PMD crypto_dpaa2_sec
12 /**< NXP DPAA2 - SEC PMD device name */
15 #define MAX_DESC_SIZE 64
16 /** private data structure for each DPAA2_SEC device */
17 struct dpaa2_sec_dev_private {
18 void *mc_portal; /**< MC Portal for configuring this device */
19 void *hw; /**< Hardware handle for this device.Used by NADK framework */
20 struct rte_mempool *fle_pool; /* per device memory pool for FLE */
21 int32_t hw_id; /**< An unique ID of this device instance */
22 int32_t vfio_fd; /**< File descriptor received via VFIO */
23 uint16_t token; /**< Token required by DPxxx objects */
24 unsigned int max_nb_queue_pairs;
25 /**< Max number of queue pairs supported by device */
26 unsigned int max_nb_sessions;
27 /**< Max number of sessions supported by device */
31 struct dpaa2_queue rx_vq;
32 struct dpaa2_queue tx_vq;
44 #define DPAA2_SET_FLC_EWS(flc) (flc->word1_bits23_16 |= 0x1)
45 #define DPAA2_SET_FLC_RSC(flc) (flc->word1_bits31_24 |= 0x1)
46 #define DPAA2_SET_FLC_REUSE_BS(flc) (flc->mode_bits |= 0x8000)
47 #define DPAA2_SET_FLC_REUSE_FF(flc) (flc->mode_bits |= 0x2000)
49 /* SEC Flow Context Descriptor */
50 struct sec_flow_context {
52 uint16_t word0_sdid; /* 11-0 SDID */
53 uint16_t word0_res; /* 31-12 reserved */
56 uint8_t word1_sdl; /* 5-0 SDL */
59 uint8_t word1_bits_15_8; /* 11-8 CRID */
63 uint8_t word1_bits23_16; /* 16 EWS */
68 uint8_t word1_bits31_24; /* 24 RSC */
72 /* word 2 RFLC[31-0] */
73 uint32_t word2_rflc_31_0;
75 /* word 3 RFLC[63-32] */
76 uint32_t word3_rflc_63_32;
79 uint16_t word4_iicid; /* 15-0 IICID */
80 uint16_t word4_oicid; /* 31-16 OICID */
83 uint32_t word5_ofqid:24; /* 23-0 OFQID */
84 uint32_t word5_31_24:8;
91 uint32_t word6_oflc_31_0;
94 uint32_t word7_oflc_63_32;
96 /* Word 8-15 storage profiles */
97 uint16_t dl; /**< DataLength(correction) */
98 uint16_t reserved; /**< reserved */
99 uint16_t dhr; /**< DataHeadRoom(correction) */
100 uint16_t mode_bits; /**< mode bits */
101 uint16_t bpv0; /**< buffer pool0 valid */
102 uint16_t bpid0; /**< Bypass Memory Translation */
103 uint16_t bpv1; /**< buffer pool1 valid */
104 uint16_t bpid1; /**< Bypass Memory Translation */
105 uint64_t word_12_15[2]; /**< word 12-15 are reserved */
108 struct sec_flc_desc {
109 struct sec_flow_context flc;
110 uint32_t desc[MAX_DESC_SIZE];
114 struct rte_mempool *fle_pool; /* per device memory pool for FLE */
115 struct sec_flc_desc flc_desc[0];
118 enum dpaa2_sec_op_type {
119 DPAA2_SEC_NONE, /*!< No Cipher operations*/
120 DPAA2_SEC_CIPHER,/*!< CIPHER operations */
121 DPAA2_SEC_AUTH, /*!< Authentication Operations */
122 DPAA2_SEC_AEAD, /*!< AEAD (AES-GCM/CCM) type operations */
123 DPAA2_SEC_CIPHER_HASH, /*!< Authenticated Encryption with
126 DPAA2_SEC_HASH_CIPHER, /*!< Encryption with Authenticated
129 DPAA2_SEC_IPSEC, /*!< IPSEC protocol operations*/
130 DPAA2_SEC_PDCP, /*!< PDCP protocol operations*/
131 DPAA2_SEC_PKC, /*!< Public Key Cryptographic Operations */
135 struct dpaa2_sec_aead_ctxt {
136 uint16_t auth_only_len; /*!< Length of data for Auth only */
137 uint8_t auth_cipher_text; /**< Authenticate/cipher ordering */
140 typedef struct dpaa2_sec_session_entry {
143 uint8_t dir; /*!< Operation Direction */
144 enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/
145 enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/
146 enum rte_crypto_aead_algorithm aead_alg; /*!< AEAD Algorithm*/
149 uint8_t *data; /**< pointer to key data */
150 size_t length; /**< key length in bytes */
154 uint8_t *data; /**< pointer to key data */
155 size_t length; /**< key length in bytes */
158 uint8_t *data; /**< pointer to key data */
159 size_t length; /**< key length in bytes */
164 uint16_t length; /**< IV length in bytes */
165 uint16_t offset; /**< IV offset in bytes */
167 uint16_t digest_length;
170 struct dpaa2_sec_aead_ctxt aead_ctxt;
174 static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
176 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
178 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
180 .algo = RTE_CRYPTO_AUTH_MD5_HMAC,
197 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
199 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
201 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
218 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
220 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
222 .algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
239 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
241 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
243 .algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
260 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
262 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
264 .algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
281 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
283 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
285 .algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
302 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
304 .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
306 .algo = RTE_CRYPTO_AEAD_AES_GCM,
332 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
334 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
336 .algo = RTE_CRYPTO_CIPHER_AES_CBC,
352 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
354 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
356 .algo = RTE_CRYPTO_CIPHER_AES_CTR,
372 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
374 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
376 .algo = RTE_CRYPTO_CIPHER_3DES_CBC,
392 RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
395 static const struct rte_security_capability dpaa2_sec_security_cap[] = {
396 { /* IPsec Lookaside Protocol offload ESP Transport Egress */
397 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
398 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
400 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
401 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
402 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
405 .crypto_capabilities = dpaa2_sec_capabilities
407 { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */
408 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
409 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
411 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
412 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
413 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
416 .crypto_capabilities = dpaa2_sec_capabilities
419 .action = RTE_SECURITY_ACTION_TYPE_NONE
426 * @param buffer calculate chksum for buffer
427 * @param len buffer length
429 * @return checksum value in host cpu order
431 static inline uint16_t
432 calc_chksum(void *buffer, int len)
434 uint16_t *buf = (uint16_t *)buffer;
438 for (sum = 0; len > 1; len -= 2)
442 sum += *(unsigned char *)buf;
444 sum = (sum >> 16) + (sum & 0xFFFF);
451 #endif /* _RTE_DPAA2_SEC_PMD_PRIVATE_H_ */