/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2017-2018 NXP
+ * Copyright 2017-2019 NXP
*/
#include <fcntl.h>
#include <caam_jr_log.h>
/* RTA header files */
-#include <hw/desc/common.h>
-#include <hw/desc/algo.h>
+#include <desc/common.h>
+#include <desc/algo.h>
#include <of.h>
-
+#ifdef RTE_LIBRTE_PMD_CAAM_JR_DEBUG
+#define CAAM_JR_DBG 1
+#else
#define CAAM_JR_DBG 0
+#endif
#define CRYPTODEV_NAME_CAAM_JR_PMD crypto_caam_jr
static uint8_t cryptodev_driver_id;
int caam_jr_logtype;
static inline phys_addr_t
caam_jr_vtop_ctx(struct caam_jr_op_ctx *ctx, void *vaddr)
{
- PMD_INIT_FUNC_TRACE();
return (size_t)vaddr - ctx->vtop_offset;
}
static inline void
caam_jr_op_ending(struct caam_jr_op_ctx *ctx)
{
- PMD_INIT_FUNC_TRACE();
- /* report op status to sym->op and then free the ctx memeory */
+ /* report op status to sym->op and then free the ctx memory */
rte_mempool_put(ctx->ctx_pool, (void *)ctx);
}
struct caam_jr_op_ctx *ctx;
int ret;
- PMD_INIT_FUNC_TRACE();
ret = rte_mempool_get(ses->ctx_pool, (void **)(&ctx));
if (!ctx || ret) {
CAAM_JR_DP_WARN("Alloc sec descriptor failed!");
static inline int
is_cipher_only(struct caam_jr_session *ses)
{
- PMD_INIT_FUNC_TRACE();
return ((ses->cipher_alg != RTE_CRYPTO_CIPHER_NULL) &&
(ses->auth_alg == RTE_CRYPTO_AUTH_NULL));
}
static inline int
is_auth_only(struct caam_jr_session *ses)
{
- PMD_INIT_FUNC_TRACE();
return ((ses->cipher_alg == RTE_CRYPTO_CIPHER_NULL) &&
(ses->auth_alg != RTE_CRYPTO_AUTH_NULL));
}
static inline int
is_aead(struct caam_jr_session *ses)
{
- PMD_INIT_FUNC_TRACE();
return ((ses->cipher_alg == 0) &&
(ses->auth_alg == 0) &&
(ses->aead_alg != 0));
static inline int
is_auth_cipher(struct caam_jr_session *ses)
{
- PMD_INIT_FUNC_TRACE();
return ((ses->cipher_alg != RTE_CRYPTO_CIPHER_NULL) &&
(ses->auth_alg != RTE_CRYPTO_AUTH_NULL) &&
(ses->proto_alg != RTE_SECURITY_PROTOCOL_IPSEC));
static inline int
is_proto_ipsec(struct caam_jr_session *ses)
{
- PMD_INIT_FUNC_TRACE();
return (ses->proto_alg == RTE_SECURITY_PROTOCOL_IPSEC);
}
static inline int
is_encode(struct caam_jr_session *ses)
{
- PMD_INIT_FUNC_TRACE();
return ses->dir == DIR_ENC;
}
static inline int
is_decode(struct caam_jr_session *ses)
{
- PMD_INIT_FUNC_TRACE();
return ses->dir == DIR_DEC;
}
static inline void
caam_auth_alg(struct caam_jr_session *ses, struct alginfo *alginfo_a)
{
- PMD_INIT_FUNC_TRACE();
switch (ses->auth_alg) {
case RTE_CRYPTO_AUTH_NULL:
ses->digest_length = 0;
static inline void
caam_cipher_alg(struct caam_jr_session *ses, struct alginfo *alginfo_c)
{
- PMD_INIT_FUNC_TRACE();
switch (ses->cipher_alg) {
case RTE_CRYPTO_CIPHER_NULL:
break;
static inline void
caam_aead_alg(struct caam_jr_session *ses, struct alginfo *alginfo)
{
- PMD_INIT_FUNC_TRACE();
switch (ses->aead_alg) {
case RTE_CRYPTO_AEAD_AES_GCM:
alginfo->algtype = OP_ALG_ALGSEL_AES;
int32_t shared_desc_len = 0;
struct sec_cdb *cdb;
int err;
-#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+#if CAAM_BYTE_ORDER == CORE_BYTE_ORDER
int swap = false;
#else
int swap = true;
#endif
- PMD_INIT_FUNC_TRACE();
if (ses->cdb)
caam_jr_dma_free(ses->cdb);
shared_desc_len = cnstr_shdsc_blkcipher(
cdb->sh_desc, true,
- swap, &alginfo_c,
+ swap, SHR_NEVER, &alginfo_c,
NULL,
ses->iv.length,
ses->dir);
alginfo_a.key_type = RTA_DATA_IMM;
shared_desc_len = cnstr_shdsc_hmac(cdb->sh_desc, true,
- swap, &alginfo_a,
+ swap, SHR_NEVER, &alginfo_a,
!ses->dir,
ses->digest_length);
} else if (is_aead(ses)) {
if (ses->dir == DIR_ENC)
shared_desc_len = cnstr_shdsc_gcm_encap(
cdb->sh_desc, true, swap,
- &alginfo,
+ SHR_NEVER, &alginfo,
ses->iv.length,
ses->digest_length);
else
shared_desc_len = cnstr_shdsc_gcm_decap(
cdb->sh_desc, true, swap,
- &alginfo,
+ SHR_NEVER, &alginfo,
ses->iv.length,
ses->digest_length);
} else {
&alginfo_c, &alginfo_a);
}
} else {
- /* Auth_only_len is set as 0 here and it will be
- * overwritten in fd for each packet.
- */
+ /* Auth_only_len is overwritten in fd for each job */
shared_desc_len = cnstr_shdsc_authenc(cdb->sh_desc,
- true, swap, &alginfo_c, &alginfo_a,
- ses->iv.length, 0,
+ true, swap, SHR_SERIAL,
+ &alginfo_c, &alginfo_a,
+ ses->iv.length,
ses->digest_length, ses->dir);
}
}
int32_t jobs_no_to_discard = 0;
int32_t discarded_descs_no = 0;
- PMD_INIT_FUNC_TRACE();
CAAM_JR_DEBUG("Jr[%p] pi[%d] ci[%d].Flushing jr notify desc=[%d]",
job_ring, job_ring->pidx, job_ring->cidx, do_notify);
phys_addr_t *temp_addr;
struct caam_jr_op_ctx *ctx;
- PMD_INIT_FUNC_TRACE();
/* TODO check for ops have memory*/
/* check here if any JR error that cannot be written
* in the output status word has occurred
int num_rx;
int ret;
- PMD_INIT_FUNC_TRACE();
CAAM_JR_DP_DEBUG("Jr[%p]Polling. limit[%d]", ring, nb_ops);
/* Poll job ring
struct sec_job_descriptor_t *jobdescr;
uint8_t extra_segs;
- PMD_INIT_FUNC_TRACE();
if (is_decode(ses))
extra_segs = 2;
else
sg->len = cpu_to_caam32(ses->digest_length);
length += ses->digest_length;
} else {
- length -= ses->digest_length;
+ sg->len -= ses->digest_length;
}
/* last element*/
uint64_t sdesc_offset;
struct sec_job_descriptor_t *jobdescr;
- PMD_INIT_FUNC_TRACE();
ctx = caam_jr_alloc_ctx(ses);
if (!ctx)
return NULL;
struct sec_job_descriptor_t *jobdescr;
uint8_t reg_segs;
- PMD_INIT_FUNC_TRACE();
if (sym->m_dst) {
mbuf = sym->m_dst;
reg_segs = mbuf->nb_segs + sym->m_src->nb_segs + 2;
ses->iv.offset);
struct sec_job_descriptor_t *jobdescr;
- PMD_INIT_FUNC_TRACE();
ctx = caam_jr_alloc_ctx(ses);
if (!ctx)
return NULL;
uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
ses->iv.offset);
struct sec_job_descriptor_t *jobdescr;
- uint32_t auth_only_len;
-
- PMD_INIT_FUNC_TRACE();
- auth_only_len = op->sym->auth.data.length -
- op->sym->cipher.data.length;
+ uint16_t auth_hdr_len = sym->cipher.data.offset -
+ sym->auth.data.offset;
+ uint16_t auth_tail_len = sym->auth.data.length -
+ sym->cipher.data.length - auth_hdr_len;
+ uint32_t auth_only_len = (auth_tail_len << 16) | auth_hdr_len;
if (sym->m_dst) {
mbuf = sym->m_dst;
uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
ses->iv.offset);
struct sec_job_descriptor_t *jobdescr;
- uint32_t auth_only_len;
-
- PMD_INIT_FUNC_TRACE();
- auth_only_len = op->sym->auth.data.length -
- op->sym->cipher.data.length;
+ uint16_t auth_hdr_len = sym->cipher.data.offset -
+ sym->auth.data.offset;
+ uint16_t auth_tail_len = sym->auth.data.length -
+ sym->cipher.data.length - auth_hdr_len;
+ uint32_t auth_only_len = (auth_tail_len << 16) | auth_hdr_len;
src_start_addr = rte_pktmbuf_iova(sym->m_src);
if (sym->m_dst)
uint64_t sdesc_offset;
struct sec_job_descriptor_t *jobdescr;
- PMD_INIT_FUNC_TRACE();
ctx = caam_jr_alloc_ctx(ses);
if (!ctx)
return NULL;
struct caam_jr_op_ctx *ctx = NULL;
struct sec_job_descriptor_t *jobdescr __rte_unused;
- PMD_INIT_FUNC_TRACE();
switch (op->sess_type) {
case RTE_CRYPTO_OP_WITH_SESSION:
ses = (struct caam_jr_session *)
int32_t ret;
struct caam_jr_qp *jr_qp = (struct caam_jr_qp *)qp;
uint16_t num_tx = 0;
-
- PMD_INIT_FUNC_TRACE();
/*Prepare each packet which is to be sent*/
for (loop = 0; loop < nb_ops; loop++) {
ret = caam_jr_enqueue_op(ops[loop], jr_qp);
struct rte_crypto_sym_xform *xform,
struct caam_jr_session *session)
{
- PMD_INIT_FUNC_TRACE();
session->cipher_alg = xform->cipher.algo;
session->iv.length = xform->cipher.iv.length;
session->iv.offset = xform->cipher.iv.offset;
struct rte_crypto_sym_xform *xform,
struct caam_jr_session *session)
{
- PMD_INIT_FUNC_TRACE();
session->auth_alg = xform->auth.algo;
session->auth_key.data = rte_zmalloc(NULL, xform->auth.key.length,
RTE_CACHE_LINE_SIZE);
struct rte_crypto_sym_xform *xform,
struct caam_jr_session *session)
{
- PMD_INIT_FUNC_TRACE();
session->aead_alg = xform->aead.algo;
session->iv.length = xform->aead.iv.length;
session->iv.offset = xform->aead.iv.offset;
PDBOPTS_ESP_OIHI_PDB_INL |
PDBOPTS_ESP_IVSRC |
PDBHMO_ESP_ENCAP_DTTL;
+ if (ipsec_xform->options.esn)
+ session->encap_pdb.options |= PDBOPTS_ESP_ESN;
session->encap_pdb.spi = ipsec_xform->spi;
session->encap_pdb.ip_hdr_len = sizeof(struct ip);
RTE_SECURITY_IPSEC_SA_DIR_INGRESS) {
memset(&session->decap_pdb, 0, sizeof(struct ipsec_decap_pdb));
session->decap_pdb.options = sizeof(struct ip) << 16;
+ if (ipsec_xform->options.esn)
+ session->decap_pdb.options |= PDBOPTS_ESP_ESN;
session->dir = DIR_DEC;
} else
goto out;
struct rte_cryptodev *cdev = (struct rte_cryptodev *)dev;
int ret;
- PMD_INIT_FUNC_TRACE();
if (rte_mempool_get(mempool, &sess_private_data)) {
CAAM_JR_ERR("Couldn't get object from session mempool");
return -ENOMEM;
PMD_INIT_FUNC_TRACE();
internals = dev->data->dev_private;
- sprintf(str, "ctx_pool_%d", dev->data->dev_id);
+ snprintf(str, sizeof(str), "ctx_pool_%d", dev->data->dev_id);
if (!internals->ctx_pool) {
internals->ctx_pool = rte_mempool_create((const char *)str,
CTX_POOL_NUM_BUFS,
static void
close_job_ring(struct sec_job_ring_t *job_ring)
{
- PMD_INIT_FUNC_TRACE();
if (job_ring->irq_fd) {
/* Producer index is frozen. If consumer index is not equal
* with producer index, then we have descs to flush.