#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
-#include "armv8_crypto_defs.h"
+#include "AArch64cryptolib.h"
-#include "rte_armv8_pmd_private.h"
+#include "armv8_pmd_private.h"
static uint8_t cryptodev_driver_id;
static const crypto_func_tbl_t
crypto_op_ca_encrypt = {
/* [cipher alg][auth alg][key length] = crypto_function, */
- [CIPH_AES_CBC][AUTH_SHA1_HMAC][KEYL(128)] = aes128cbc_sha1_hmac,
- [CIPH_AES_CBC][AUTH_SHA256_HMAC][KEYL(128)] = aes128cbc_sha256_hmac,
+ [CIPH_AES_CBC][AUTH_SHA1_HMAC][KEYL(128)] =
+ armv8_enc_aes_cbc_sha1_128,
+ [CIPH_AES_CBC][AUTH_SHA256_HMAC][KEYL(128)] =
+ armv8_enc_aes_cbc_sha256_128,
};
static const crypto_func_tbl_t
crypto_op_ca_decrypt = {
- NULL
+ { {NULL} }
};
static const crypto_func_tbl_t
crypto_op_ac_encrypt = {
- NULL
+ { {NULL} }
};
static const crypto_func_tbl_t
crypto_op_ac_decrypt = {
/* [cipher alg][auth alg][key length] = crypto_function, */
- [CIPH_AES_CBC][AUTH_SHA1_HMAC][KEYL(128)] = sha1_hmac_aes128cbc_dec,
- [CIPH_AES_CBC][AUTH_SHA256_HMAC][KEYL(128)] = sha256_hmac_aes128cbc_dec,
+ [CIPH_AES_CBC][AUTH_SHA1_HMAC][KEYL(128)] =
+ armv8_dec_aes_cbc_sha1_128,
+ [CIPH_AES_CBC][AUTH_SHA256_HMAC][KEYL(128)] =
+ armv8_dec_aes_cbc_sha256_128,
};
/**
crypto_func_tbl_t *func_tbl = \
(crypto_chain_order[(order)])[(cop)]; \
\
- ((*func_tbl)[(calg)][(aalg)][KEYL(keyl)]); \
+ ((calg >= CRYPTO_CIPHER_MAX) || (aalg >= CRYPTO_AUTH_MAX)) ? \
+ NULL : ((*func_tbl)[(calg)][(aalg)][KEYL(keyl)]); \
})
/*----------------------------------------------------------------------------*/
static const crypto_key_sched_tbl_t
crypto_key_sched_encrypt = {
/* [cipher alg][key length] = key_expand_func, */
- [CIPH_AES_CBC][KEYL(128)] = aes128_key_sched_enc,
+ [CIPH_AES_CBC][KEYL(128)] = armv8_expandkeys_enc_aes_cbc_128,
};
static const crypto_key_sched_tbl_t
crypto_key_sched_decrypt = {
/* [cipher alg][key length] = key_expand_func, */
- [CIPH_AES_CBC][KEYL(128)] = aes128_key_sched_dec,
+ [CIPH_AES_CBC][KEYL(128)] = armv8_expandkeys_dec_aes_cbc_128,
};
/**
({ \
crypto_key_sched_tbl_t *ks_tbl = crypto_key_sched_dir[(cop)]; \
\
- ((*ks_tbl)[(calg)][KEYL(keyl)]); \
+ (calg >= CRYPTO_CIPHER_MAX) ? \
+ NULL : ((*ks_tbl)[(calg)][KEYL(keyl)]); \
})
/*----------------------------------------------------------------------------*/
* Calculate partial hash values for i_key_pad and o_key_pad.
* Will be used as initialization state for final HMAC.
*/
- error = sha1_block_partial(NULL, sess->auth.hmac.i_key_pad,
- partial, SHA1_BLOCK_SIZE);
+ error = armv8_sha1_block_partial(NULL,
+ sess->auth.hmac.i_key_pad,
+ partial, SHA1_BLOCK_SIZE);
if (error != 0)
return -1;
memcpy(sess->auth.hmac.i_key_pad, partial, SHA1_BLOCK_SIZE);
- error = sha1_block_partial(NULL, sess->auth.hmac.o_key_pad,
- partial, SHA1_BLOCK_SIZE);
+ error = armv8_sha1_block_partial(NULL,
+ sess->auth.hmac.o_key_pad,
+ partial, SHA1_BLOCK_SIZE);
if (error != 0)
return -1;
memcpy(sess->auth.hmac.o_key_pad, partial, SHA1_BLOCK_SIZE);
* Calculate partial hash values for i_key_pad and o_key_pad.
* Will be used as initialization state for final HMAC.
*/
- error = sha256_block_partial(NULL, sess->auth.hmac.i_key_pad,
- partial, SHA256_BLOCK_SIZE);
+ error = armv8_sha256_block_partial(NULL,
+ sess->auth.hmac.i_key_pad,
+ partial, SHA256_BLOCK_SIZE);
if (error != 0)
return -1;
memcpy(sess->auth.hmac.i_key_pad, partial, SHA256_BLOCK_SIZE);
- error = sha256_block_partial(NULL, sess->auth.hmac.o_key_pad,
- partial, SHA256_BLOCK_SIZE);
+ error = armv8_sha256_block_partial(NULL,
+ sess->auth.hmac.o_key_pad,
+ partial, SHA256_BLOCK_SIZE);
if (error != 0)
return -1;
memcpy(sess->auth.hmac.o_key_pad, partial, SHA256_BLOCK_SIZE);
/* Select cipher key */
sess->cipher.key.length = cipher_xform->cipher.key.length;
/* Set cipher direction */
- cop = sess->cipher.direction;
+ switch (sess->cipher.direction) {
+ case RTE_CRYPTO_CIPHER_OP_ENCRYPT:
+ cop = ARMV8_CRYPTO_CIPHER_OP_ENCRYPT;
+ break;
+ case RTE_CRYPTO_CIPHER_OP_DECRYPT:
+ cop = ARMV8_CRYPTO_CIPHER_OP_DECRYPT;
+ break;
+ default:
+ return -ENOTSUP;
+ }
/* Set cipher algorithm */
calg = cipher_xform->cipher.algo;
return -ENOTSUP;
}
- if (unlikely(sess->crypto_func == NULL)) {
+ if (unlikely(sess->crypto_func == NULL ||
+ sess->cipher.key_sched == NULL)) {
/*
* If we got here that means that there must be a bug
* in the algorithms selection above. Nevertheless keep
struct rte_mbuf *mbuf_src, struct rte_mbuf *mbuf_dst)
{
crypto_func_t crypto_func;
- crypto_arg_t arg;
+ armv8_cipher_digest_t arg;
struct rte_mbuf *m_asrc, *m_adst;
uint8_t *csrc, *cdst;
uint8_t *adst, *asrc;
arg.cipher.key = sess->cipher.key.data;
/* Acquire combined mode function */
crypto_func = sess->crypto_func;
- ARMV8_CRYPTO_ASSERT(crypto_func != NULL);
+ RTE_VERIFY(crypto_func != NULL);
error = crypto_func(csrc, cdst, clen, asrc, adst, alen, &arg);
if (error != 0) {
op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
memset(op->sym->session, 0,
rte_cryptodev_sym_get_existing_header_session_size(
op->sym->session));
- rte_mempool_put(qp->sess_mp, sess);
- rte_mempool_put(qp->sess_mp_priv, op->sym->session);
+ rte_mempool_put(qp->sess_mp_priv, sess);
+ rte_mempool_put(qp->sess_mp, op->sym->session);
op->sym->session = NULL;
}
dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
RTE_CRYPTODEV_FF_CPU_NEON |
- RTE_CRYPTODEV_FF_CPU_ARM_CE;
+ RTE_CRYPTODEV_FF_CPU_ARM_CE |
+ RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
- /* Set vector instructions mode supported */
internals = dev->data->dev_private;
internals->max_nb_qpairs = init_params->max_nb_queue_pairs;
+ rte_cryptodev_pmd_probing_finish(dev);
+
return 0;
init_error:
static struct cryptodev_driver armv8_crypto_drv;
+RTE_LOG_REGISTER_DEFAULT(crypto_armv8_log_type, ERR);
+
RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_ARMV8_PMD, armv8_crypto_pmd_drv);
RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_ARMV8_PMD, cryptodev_armv8_pmd);
RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ARMV8_PMD,