2017-12-19 10:14:41 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2017-10-09 14:21:40 +00:00
|
|
|
*
|
2020-01-27 09:07:24 +00:00
|
|
|
* Copyright 2016-2020 NXP
|
2017-10-09 14:21:40 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DPAA_SEC_H_
|
|
|
|
#define _DPAA_SEC_H_
|
|
|
|
|
2018-04-02 15:33:17 +00:00
|
|
|
#define CRYPTODEV_NAME_DPAA_SEC_PMD crypto_dpaa_sec
|
|
|
|
/**< NXP DPAA - SEC PMD device name */
|
|
|
|
|
2019-01-09 15:14:17 +00:00
|
|
|
#define MAX_DPAA_CORES 4
|
2017-10-09 14:21:40 +00:00
|
|
|
#define NUM_POOL_CHANNELS 4
|
2018-01-11 11:44:06 +00:00
|
|
|
#define DPAA_SEC_BURST 7
|
2017-10-09 14:21:40 +00:00
|
|
|
#define DPAA_SEC_ALG_UNSUPPORT (-1)
|
|
|
|
#define TDES_CBC_IV_LEN 8
|
|
|
|
#define AES_CBC_IV_LEN 16
|
|
|
|
#define AES_CTR_IV_LEN 16
|
|
|
|
#define AES_GCM_IV_LEN 12
|
|
|
|
|
2019-09-05 12:48:05 +00:00
|
|
|
#define DPAA_IPv6_DEFAULT_VTC_FLOW 0x60000000
|
|
|
|
|
2017-10-09 14:21:40 +00:00
|
|
|
/* Minimum job descriptor consists of a oneword job descriptor HEADER and
|
|
|
|
* a pointer to the shared descriptor.
|
|
|
|
*/
|
|
|
|
#define MIN_JOB_DESC_SIZE (CAAM_CMD_SZ + CAAM_PTR_SZ)
|
|
|
|
/* CTX_POOL_NUM_BUFS is set as per the ipsec-secgw application */
|
|
|
|
#define CTX_POOL_NUM_BUFS 32000
|
|
|
|
#define CTX_POOL_BUF_SIZE sizeof(struct dpaa_sec_op_ctx)
|
|
|
|
#define CTX_POOL_CACHE_SIZE 512
|
2019-01-09 15:14:17 +00:00
|
|
|
#define RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS 1024
|
2017-10-09 14:21:40 +00:00
|
|
|
|
|
|
|
#define DIR_ENC 1
|
|
|
|
#define DIR_DEC 0
|
|
|
|
|
|
|
|
enum dpaa_sec_op_type {
|
|
|
|
DPAA_SEC_NONE, /*!< No Cipher operations*/
|
|
|
|
DPAA_SEC_CIPHER,/*!< CIPHER operations */
|
|
|
|
DPAA_SEC_AUTH, /*!< Authentication Operations */
|
2019-10-14 06:53:30 +00:00
|
|
|
DPAA_SEC_AEAD, /*!< AEAD (AES-GCM/CCM) type operations */
|
|
|
|
DPAA_SEC_CIPHER_HASH, /*!< Authenticated Encryption with
|
|
|
|
* associated data
|
|
|
|
*/
|
|
|
|
DPAA_SEC_HASH_CIPHER, /*!< Encryption with Authenticated
|
|
|
|
* associated data
|
|
|
|
*/
|
2017-10-09 14:21:40 +00:00
|
|
|
DPAA_SEC_IPSEC, /*!< IPSEC protocol operations*/
|
|
|
|
DPAA_SEC_PDCP, /*!< PDCP protocol operations*/
|
|
|
|
DPAA_SEC_PKC, /*!< Public Key Cryptographic Operations */
|
|
|
|
DPAA_SEC_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DPAA_SEC_MAX_DESC_SIZE 64
|
|
|
|
/* code or cmd block to caam */
|
|
|
|
struct sec_cdb {
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
uint32_t word;
|
|
|
|
struct {
|
|
|
|
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
|
|
|
|
uint16_t rsvd63_48;
|
|
|
|
unsigned int rsvd47_39:9;
|
|
|
|
unsigned int idlen:7;
|
|
|
|
#else
|
|
|
|
unsigned int idlen:7;
|
|
|
|
unsigned int rsvd47_39:9;
|
|
|
|
uint16_t rsvd63_48;
|
|
|
|
#endif
|
|
|
|
} field;
|
|
|
|
} __packed hi;
|
|
|
|
|
|
|
|
union {
|
|
|
|
uint32_t word;
|
|
|
|
struct {
|
|
|
|
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
|
|
|
|
unsigned int rsvd31_30:2;
|
|
|
|
unsigned int fsgt:1;
|
|
|
|
unsigned int lng:1;
|
|
|
|
unsigned int offset:2;
|
|
|
|
unsigned int abs:1;
|
|
|
|
unsigned int add_buf:1;
|
|
|
|
uint8_t pool_id;
|
|
|
|
uint16_t pool_buffer_size;
|
|
|
|
#else
|
|
|
|
uint16_t pool_buffer_size;
|
|
|
|
uint8_t pool_id;
|
|
|
|
unsigned int add_buf:1;
|
|
|
|
unsigned int abs:1;
|
|
|
|
unsigned int offset:2;
|
|
|
|
unsigned int lng:1;
|
|
|
|
unsigned int fsgt:1;
|
|
|
|
unsigned int rsvd31_30:2;
|
|
|
|
#endif
|
|
|
|
} field;
|
|
|
|
} __packed lo;
|
|
|
|
} __packed sh_hdr;
|
|
|
|
|
|
|
|
uint32_t sh_desc[DPAA_SEC_MAX_DESC_SIZE];
|
|
|
|
};
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_LIB_SECURITY
|
2019-01-09 15:13:16 +00:00
|
|
|
/*!
|
|
|
|
* The structure is to be filled by user as a part of
|
|
|
|
* dpaa_sec_proto_ctxt for PDCP Protocol
|
|
|
|
*/
|
|
|
|
struct sec_pdcp_ctxt {
|
|
|
|
enum rte_security_pdcp_domain domain; /*!< Data/Control mode*/
|
|
|
|
int8_t bearer; /*!< PDCP bearer ID */
|
|
|
|
int8_t pkt_dir;/*!< PDCP Frame Direction 0:UL 1:DL*/
|
|
|
|
int8_t hfn_ovd;/*!< Overwrite HFN per packet*/
|
2019-09-30 14:40:44 +00:00
|
|
|
uint8_t sn_size; /*!< Sequence number size, 5/7/12/15/18 */
|
2020-10-12 14:10:03 +00:00
|
|
|
uint8_t sdap_enabled; /*!< SDAP header is enabled */
|
|
|
|
uint16_t hfn_ovd_offset;/*!< offset from rte_crypto_op at which
|
2019-09-30 14:40:44 +00:00
|
|
|
* per packet hfn is stored
|
|
|
|
*/
|
2019-01-09 15:13:16 +00:00
|
|
|
uint32_t hfn; /*!< Hyper Frame Number */
|
|
|
|
uint32_t hfn_threshold; /*!< HFN Threashold for key renegotiation */
|
|
|
|
};
|
2019-10-23 14:17:02 +00:00
|
|
|
#endif
|
2018-01-15 06:35:52 +00:00
|
|
|
typedef struct dpaa_sec_session_entry {
|
2020-01-27 09:07:24 +00:00
|
|
|
struct sec_cdb cdb; /**< cmd block associated with qp */
|
|
|
|
struct dpaa_sec_qp *qp[MAX_DPAA_CORES];
|
|
|
|
struct qman_fq *inq[MAX_DPAA_CORES];
|
2018-01-15 06:35:52 +00:00
|
|
|
uint8_t dir; /*!< Operation Direction */
|
2019-10-14 06:53:30 +00:00
|
|
|
uint8_t ctxt; /*!< Session Context Type */
|
2018-01-15 06:35:52 +00:00
|
|
|
enum rte_crypto_cipher_algorithm cipher_alg; /*!< Cipher Algorithm*/
|
|
|
|
enum rte_crypto_auth_algorithm auth_alg; /*!< Authentication Algorithm*/
|
2018-01-15 06:35:53 +00:00
|
|
|
enum rte_crypto_aead_algorithm aead_alg; /*!< AEAD Algorithm*/
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_LIB_SECURITY
|
2018-01-15 06:35:53 +00:00
|
|
|
enum rte_security_session_protocol proto_alg; /*!< Security Algorithm*/
|
2019-10-23 14:17:02 +00:00
|
|
|
#endif
|
2018-01-15 06:35:52 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint8_t *data; /**< pointer to key data */
|
|
|
|
size_t length; /**< key length in bytes */
|
2019-10-14 06:53:30 +00:00
|
|
|
uint32_t alg;
|
|
|
|
uint32_t algmode;
|
2018-01-15 06:35:52 +00:00
|
|
|
} aead_key;
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
uint8_t *data; /**< pointer to key data */
|
|
|
|
size_t length; /**< key length in bytes */
|
2019-10-14 06:53:30 +00:00
|
|
|
uint32_t alg;
|
|
|
|
uint32_t algmode;
|
2018-01-15 06:35:52 +00:00
|
|
|
} cipher_key;
|
|
|
|
struct {
|
|
|
|
uint8_t *data; /**< pointer to key data */
|
|
|
|
size_t length; /**< key length in bytes */
|
2019-10-14 06:53:30 +00:00
|
|
|
uint32_t alg;
|
|
|
|
uint32_t algmode;
|
2018-01-15 06:35:52 +00:00
|
|
|
} auth_key;
|
|
|
|
};
|
|
|
|
};
|
2019-01-09 15:13:16 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
uint16_t length;
|
|
|
|
uint16_t offset;
|
|
|
|
} iv; /**< Initialisation vector parameters */
|
|
|
|
uint16_t auth_only_len;
|
|
|
|
/*!< Length of data for Auth only */
|
|
|
|
uint32_t digest_length;
|
|
|
|
struct ipsec_decap_pdb decap_pdb;
|
|
|
|
struct ipsec_encap_pdb encap_pdb;
|
2019-09-05 12:48:05 +00:00
|
|
|
union {
|
|
|
|
struct ip ip4_hdr;
|
|
|
|
struct rte_ipv6_hdr ip6_hdr;
|
|
|
|
};
|
2019-10-14 06:53:30 +00:00
|
|
|
uint8_t auth_cipher_text;
|
|
|
|
/**< Authenticate/cipher ordering */
|
2019-01-09 15:13:16 +00:00
|
|
|
};
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_LIB_SECURITY
|
2019-01-09 15:13:16 +00:00
|
|
|
struct sec_pdcp_ctxt pdcp;
|
2019-10-23 14:17:02 +00:00
|
|
|
#endif
|
2019-01-09 15:13:16 +00:00
|
|
|
};
|
2018-01-15 06:35:52 +00:00
|
|
|
} dpaa_sec_session;
|
|
|
|
|
2017-10-09 14:21:40 +00:00
|
|
|
struct dpaa_sec_qp {
|
|
|
|
struct dpaa_sec_dev_private *internals;
|
2019-09-30 14:41:03 +00:00
|
|
|
struct rte_mempool *ctx_pool; /* mempool for dpaa_sec_op_ctx */
|
2017-10-09 14:21:40 +00:00
|
|
|
struct qman_fq outq;
|
|
|
|
int rx_pkts;
|
|
|
|
int rx_errs;
|
|
|
|
int tx_pkts;
|
|
|
|
int tx_errs;
|
|
|
|
};
|
|
|
|
|
2018-08-30 05:51:00 +00:00
|
|
|
#define RTE_DPAA_MAX_NB_SEC_QPS 2
|
2019-01-09 15:14:17 +00:00
|
|
|
#define RTE_DPAA_MAX_RX_QUEUE (MAX_DPAA_CORES * RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS)
|
2018-01-11 11:44:06 +00:00
|
|
|
#define DPAA_MAX_DEQUEUE_NUM_FRAMES 63
|
2018-01-15 06:35:52 +00:00
|
|
|
|
2017-10-09 14:21:40 +00:00
|
|
|
/* internal sec queue interface */
|
|
|
|
struct dpaa_sec_dev_private {
|
|
|
|
void *sec_hw;
|
2018-01-15 06:35:52 +00:00
|
|
|
struct dpaa_sec_qp qps[RTE_DPAA_MAX_NB_SEC_QPS]; /* i/o queue for sec */
|
|
|
|
struct qman_fq inq[RTE_DPAA_MAX_RX_QUEUE];
|
|
|
|
unsigned char inq_attach[RTE_DPAA_MAX_RX_QUEUE];
|
2017-10-09 14:21:40 +00:00
|
|
|
unsigned int max_nb_queue_pairs;
|
|
|
|
unsigned int max_nb_sessions;
|
2018-08-30 05:50:58 +00:00
|
|
|
rte_spinlock_t lock;
|
2017-10-09 14:21:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_SG_ENTRIES 16
|
2019-09-30 14:41:02 +00:00
|
|
|
#define MAX_JOB_SG_ENTRIES 36
|
|
|
|
|
2017-10-09 14:21:40 +00:00
|
|
|
struct dpaa_sec_job {
|
|
|
|
/* sg[0] output, sg[1] input, others are possible sub frames */
|
2019-09-30 14:41:02 +00:00
|
|
|
struct qm_sg_entry sg[MAX_JOB_SG_ENTRIES];
|
2017-10-09 14:21:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DPAA_MAX_NB_MAX_DIGEST 32
|
|
|
|
struct dpaa_sec_op_ctx {
|
|
|
|
struct dpaa_sec_job job;
|
|
|
|
struct rte_crypto_op *op;
|
|
|
|
struct rte_mempool *ctx_pool; /* mempool pointer for dpaa_sec_op_ctx */
|
|
|
|
uint32_t fd_status;
|
2018-01-15 06:35:51 +00:00
|
|
|
int64_t vtop_offset;
|
2017-10-09 14:21:40 +00:00
|
|
|
uint8_t digest[DPAA_MAX_NB_MAX_DIGEST];
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct rte_cryptodev_capabilities dpaa_sec_capabilities[] = {
|
2019-11-06 05:17:23 +00:00
|
|
|
{ /* NULL (AUTH) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_NULL,
|
|
|
|
.block_size = 1,
|
|
|
|
.key_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.digest_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = { 0 }
|
|
|
|
}, },
|
|
|
|
}, },
|
|
|
|
},
|
2017-10-09 14:21:40 +00:00
|
|
|
{ /* MD5 HMAC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_MD5_HMAC,
|
|
|
|
.block_size = 64,
|
|
|
|
.key_size = {
|
|
|
|
.min = 1,
|
|
|
|
.max = 64,
|
|
|
|
.increment = 1
|
|
|
|
},
|
|
|
|
.digest_size = {
|
2018-04-19 16:52:37 +00:00
|
|
|
.min = 1,
|
2017-10-09 14:21:40 +00:00
|
|
|
.max = 16,
|
2018-04-19 16:52:37 +00:00
|
|
|
.increment = 1
|
2017-10-09 14:21:40 +00:00
|
|
|
},
|
2018-04-19 16:52:37 +00:00
|
|
|
.iv_size = { 0 }
|
2017-10-09 14:21:40 +00:00
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* SHA1 HMAC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
|
|
|
|
.block_size = 64,
|
|
|
|
.key_size = {
|
|
|
|
.min = 1,
|
|
|
|
.max = 64,
|
|
|
|
.increment = 1
|
|
|
|
},
|
|
|
|
.digest_size = {
|
2018-04-19 16:52:37 +00:00
|
|
|
.min = 1,
|
2017-10-09 14:21:40 +00:00
|
|
|
.max = 20,
|
2018-04-19 16:52:37 +00:00
|
|
|
.increment = 1
|
2017-10-09 14:21:40 +00:00
|
|
|
},
|
2018-04-19 16:52:37 +00:00
|
|
|
.iv_size = { 0 }
|
2017-10-09 14:21:40 +00:00
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* SHA224 HMAC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
|
|
|
|
.block_size = 64,
|
|
|
|
.key_size = {
|
|
|
|
.min = 1,
|
|
|
|
.max = 64,
|
|
|
|
.increment = 1
|
|
|
|
},
|
|
|
|
.digest_size = {
|
2018-04-19 16:52:37 +00:00
|
|
|
.min = 1,
|
2017-10-09 14:21:40 +00:00
|
|
|
.max = 28,
|
2018-04-19 16:52:37 +00:00
|
|
|
.increment = 1
|
2017-10-09 14:21:40 +00:00
|
|
|
},
|
2018-04-19 16:52:37 +00:00
|
|
|
.iv_size = { 0 }
|
2017-10-09 14:21:40 +00:00
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* SHA256 HMAC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
|
|
|
|
.block_size = 64,
|
|
|
|
.key_size = {
|
|
|
|
.min = 1,
|
|
|
|
.max = 64,
|
|
|
|
.increment = 1
|
|
|
|
},
|
|
|
|
.digest_size = {
|
2018-04-19 16:52:37 +00:00
|
|
|
.min = 1,
|
2017-10-09 14:21:40 +00:00
|
|
|
.max = 32,
|
2018-04-19 16:52:37 +00:00
|
|
|
.increment = 1
|
2017-10-09 14:21:40 +00:00
|
|
|
},
|
2018-04-19 16:52:37 +00:00
|
|
|
.iv_size = { 0 }
|
2017-10-09 14:21:40 +00:00
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* SHA384 HMAC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
|
|
|
|
.block_size = 128,
|
|
|
|
.key_size = {
|
|
|
|
.min = 1,
|
|
|
|
.max = 128,
|
|
|
|
.increment = 1
|
|
|
|
},
|
|
|
|
.digest_size = {
|
2018-04-19 16:52:37 +00:00
|
|
|
.min = 1,
|
2017-10-09 14:21:40 +00:00
|
|
|
.max = 48,
|
2018-04-19 16:52:37 +00:00
|
|
|
.increment = 1
|
2017-10-09 14:21:40 +00:00
|
|
|
},
|
2018-04-19 16:52:37 +00:00
|
|
|
.iv_size = { 0 }
|
2017-10-09 14:21:40 +00:00
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* SHA512 HMAC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
|
|
|
|
.block_size = 128,
|
|
|
|
.key_size = {
|
|
|
|
.min = 1,
|
|
|
|
.max = 128,
|
|
|
|
.increment = 1
|
|
|
|
},
|
|
|
|
.digest_size = {
|
2018-04-19 16:52:37 +00:00
|
|
|
.min = 1,
|
2017-10-09 14:21:40 +00:00
|
|
|
.max = 64,
|
2018-04-19 16:52:37 +00:00
|
|
|
.increment = 1
|
2017-10-09 14:21:40 +00:00
|
|
|
},
|
2018-04-19 16:52:37 +00:00
|
|
|
.iv_size = { 0 }
|
2017-10-09 14:21:40 +00:00
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* AES GCM */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
|
2018-01-25 09:53:30 +00:00
|
|
|
{.aead = {
|
2017-10-09 14:21:40 +00:00
|
|
|
.algo = RTE_CRYPTO_AEAD_AES_GCM,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 32,
|
|
|
|
.increment = 8
|
|
|
|
},
|
|
|
|
.digest_size = {
|
|
|
|
.min = 8,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 4
|
|
|
|
},
|
|
|
|
.aad_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 240,
|
|
|
|
.increment = 1
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 12,
|
|
|
|
.max = 12,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
2019-11-06 05:17:23 +00:00
|
|
|
{ /* NULL (CIPHER) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_NULL,
|
|
|
|
.block_size = 1,
|
|
|
|
.key_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, },
|
|
|
|
}, }
|
|
|
|
},
|
2017-10-09 14:21:40 +00:00
|
|
|
{ /* AES CBC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_AES_CBC,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 32,
|
|
|
|
.increment = 8
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* AES CTR */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_AES_CTR,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 32,
|
|
|
|
.increment = 8
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
2019-01-09 15:13:16 +00:00
|
|
|
},
|
2017-10-09 14:21:40 +00:00
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* 3DES CBC */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_3DES_CBC,
|
|
|
|
.block_size = 8,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 24,
|
|
|
|
.increment = 8
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 8,
|
|
|
|
.max = 8,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
2019-10-14 06:53:28 +00:00
|
|
|
{ /* SNOW 3G (UIA2) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.digest_size = {
|
|
|
|
.min = 4,
|
|
|
|
.max = 4,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* SNOW 3G (UEA2) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* ZUC (EEA3) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* ZUC (EIA3) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.digest_size = {
|
|
|
|
.min = 4,
|
|
|
|
.max = 4,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
2017-10-09 14:21:40 +00:00
|
|
|
RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
|
|
|
|
};
|
|
|
|
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_LIB_SECURITY
|
2019-01-09 15:13:16 +00:00
|
|
|
static const struct rte_cryptodev_capabilities dpaa_pdcp_capabilities[] = {
|
|
|
|
{ /* SNOW 3G (UIA2) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.digest_size = {
|
|
|
|
.min = 4,
|
|
|
|
.max = 4,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* SNOW 3G (UEA2) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* AES CTR */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_AES_CTR,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 32,
|
|
|
|
.increment = 8
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* NULL (AUTH) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_NULL,
|
|
|
|
.block_size = 1,
|
|
|
|
.key_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.digest_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = { 0 }
|
|
|
|
}, },
|
|
|
|
}, },
|
|
|
|
},
|
|
|
|
{ /* NULL (CIPHER) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_NULL,
|
|
|
|
.block_size = 1,
|
|
|
|
.key_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 0,
|
|
|
|
.max = 0,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, },
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* ZUC (EEA3) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
|
|
|
|
{.cipher = {
|
|
|
|
.algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
{ /* ZUC (EIA3) */
|
|
|
|
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
|
|
|
{.sym = {
|
|
|
|
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
|
|
|
|
{.auth = {
|
|
|
|
.algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
|
|
|
|
.block_size = 16,
|
|
|
|
.key_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.digest_size = {
|
|
|
|
.min = 4,
|
|
|
|
.max = 4,
|
|
|
|
.increment = 0
|
|
|
|
},
|
|
|
|
.iv_size = {
|
|
|
|
.min = 16,
|
|
|
|
.max = 16,
|
|
|
|
.increment = 0
|
|
|
|
}
|
|
|
|
}, }
|
|
|
|
}, }
|
|
|
|
},
|
|
|
|
|
|
|
|
RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
|
|
|
|
};
|
|
|
|
|
2018-01-15 06:35:53 +00:00
|
|
|
static const struct rte_security_capability dpaa_sec_security_cap[] = {
|
|
|
|
{ /* IPsec Lookaside Protocol offload ESP Transport Egress */
|
|
|
|
.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
|
|
|
|
.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
|
|
|
|
.ipsec = {
|
|
|
|
.proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
|
|
|
|
.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
|
|
|
|
.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
|
2019-11-06 06:54:14 +00:00
|
|
|
.options = { 0 },
|
|
|
|
.replay_win_sz_max = 128
|
2018-01-15 06:35:53 +00:00
|
|
|
},
|
|
|
|
.crypto_capabilities = dpaa_sec_capabilities
|
|
|
|
},
|
|
|
|
{ /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */
|
|
|
|
.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
|
|
|
|
.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
|
|
|
|
.ipsec = {
|
|
|
|
.proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
|
|
|
|
.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
|
|
|
|
.direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
|
2019-11-06 06:54:14 +00:00
|
|
|
.options = { 0 },
|
|
|
|
.replay_win_sz_max = 128
|
2018-01-15 06:35:53 +00:00
|
|
|
},
|
|
|
|
.crypto_capabilities = dpaa_sec_capabilities
|
|
|
|
},
|
2019-01-09 15:13:16 +00:00
|
|
|
{ /* PDCP Lookaside Protocol offload Data */
|
|
|
|
.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
|
|
|
|
.protocol = RTE_SECURITY_PROTOCOL_PDCP,
|
|
|
|
.pdcp = {
|
|
|
|
.domain = RTE_SECURITY_PDCP_MODE_DATA,
|
2019-11-06 05:17:19 +00:00
|
|
|
.capa_flags = 0
|
2019-01-09 15:13:16 +00:00
|
|
|
},
|
|
|
|
.crypto_capabilities = dpaa_pdcp_capabilities
|
|
|
|
},
|
|
|
|
{ /* PDCP Lookaside Protocol offload Control */
|
|
|
|
.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
|
|
|
|
.protocol = RTE_SECURITY_PROTOCOL_PDCP,
|
|
|
|
.pdcp = {
|
|
|
|
.domain = RTE_SECURITY_PDCP_MODE_CONTROL,
|
2019-11-06 05:17:19 +00:00
|
|
|
.capa_flags = 0
|
2019-01-09 15:13:16 +00:00
|
|
|
},
|
|
|
|
.crypto_capabilities = dpaa_pdcp_capabilities
|
|
|
|
},
|
2018-01-15 06:35:53 +00:00
|
|
|
{
|
|
|
|
.action = RTE_SECURITY_ACTION_TYPE_NONE
|
|
|
|
}
|
|
|
|
};
|
2019-10-23 14:17:02 +00:00
|
|
|
#endif
|
2018-01-15 06:35:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checksum
|
|
|
|
*
|
|
|
|
* @param buffer calculate chksum for buffer
|
|
|
|
* @param len buffer length
|
|
|
|
*
|
|
|
|
* @return checksum value in host cpu order
|
|
|
|
*/
|
|
|
|
static inline uint16_t
|
|
|
|
calc_chksum(void *buffer, int len)
|
|
|
|
{
|
|
|
|
uint16_t *buf = (uint16_t *)buffer;
|
|
|
|
uint32_t sum = 0;
|
|
|
|
uint16_t result;
|
|
|
|
|
|
|
|
for (sum = 0; len > 1; len -= 2)
|
|
|
|
sum += *buf++;
|
|
|
|
|
|
|
|
if (len == 1)
|
|
|
|
sum += *(unsigned char *)buf;
|
|
|
|
|
|
|
|
sum = (sum >> 16) + (sum & 0xFFFF);
|
|
|
|
sum += (sum >> 16);
|
|
|
|
result = ~sum;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-10-09 14:21:40 +00:00
|
|
|
#endif /* _DPAA_SEC_H_ */
|