cryptodev: remove digest length from crypto op
[dpdk.git] / drivers / crypto / armv8 / rte_armv8_pmd.c
index 3d603a5..4a23ff1 100644 (file)
@@ -36,6 +36,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
+#include <rte_cryptodev_vdev.h>
 #include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
@@ -431,7 +432,7 @@ armv8_crypto_set_session_chained_parameters(struct armv8_crypto_session *sess,
        case RTE_CRYPTO_CIPHER_AES_CBC:
                sess->cipher.algo = calg;
                /* IV len is always 16 bytes (block size) for AES CBC */
-               sess->cipher.iv_len = 16;
+               sess->cipher.iv.length = 16;
                break;
        default:
                return -EINVAL;
@@ -451,6 +452,9 @@ armv8_crypto_set_session_chained_parameters(struct armv8_crypto_session *sess,
                return -EINVAL;
        }
 
+       /* Set the digest length */
+       sess->auth.digest_length = auth_xform->auth.digest_length;
+
        /* Verify supported key lengths and extract proper algorithm */
        switch (cipher_xform->cipher.key.length << 3) {
        case 128:
@@ -522,6 +526,9 @@ armv8_crypto_set_session_parameters(struct armv8_crypto_session *sess,
                return -EINVAL;
        }
 
+       /* Set IV offset */
+       sess->cipher.iv.offset = cipher_xform->cipher.iv.offset;
+
        if (is_chained_op) {
                ret = armv8_crypto_set_session_chained_parameters(sess,
                                                cipher_xform, auth_xform);
@@ -544,7 +551,7 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 {
        struct armv8_crypto_session *sess = NULL;
 
-       if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
+       if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
                /* get existing session */
                if (likely(op->sym->session != NULL &&
                                op->sym->session->dev_type ==
@@ -645,15 +652,11 @@ process_armv8_chained_op
                }
        } else {
                adst = (uint8_t *)rte_pktmbuf_append(m_asrc,
-                               op->sym->auth.digest.length);
-       }
-
-       if (unlikely(op->sym->cipher.iv.length != sess->cipher.iv_len)) {
-               op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-               return;
+                               sess->auth.digest_length);
        }
 
-       arg.cipher.iv = op->sym->cipher.iv.data;
+       arg.cipher.iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                                       sess->cipher.iv.offset);
        arg.cipher.key = sess->cipher.key.data;
        /* Acquire combined mode function */
        crypto_func = sess->crypto_func;
@@ -667,12 +670,12 @@ process_armv8_chained_op
        op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
        if (sess->auth.operation == RTE_CRYPTO_AUTH_OP_VERIFY) {
                if (memcmp(adst, op->sym->auth.digest.data,
-                               op->sym->auth.digest.length) != 0) {
+                               sess->auth.digest_length) != 0) {
                        op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
                }
                /* Trim area used for digest from mbuf. */
                rte_pktmbuf_trim(m_asrc,
-                               op->sym->auth.digest.length);
+                               sess->auth.digest_length);
        }
 }
 
@@ -699,7 +702,7 @@ process_op(const struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
        }
 
        /* Free session if a session-less crypto op */
-       if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
+       if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                memset(sess, 0, sizeof(struct armv8_crypto_session));
                rte_mempool_put(qp->sess_mp, op->sym->session);
                op->sym->session = NULL;
@@ -806,9 +809,10 @@ cryptodev_armv8_crypto_create(const char *name,
                snprintf(init_params->name, sizeof(init_params->name),
                                "%s", name);
 
-       dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
+       dev = rte_cryptodev_vdev_pmd_init(init_params->name,
                                sizeof(struct armv8_crypto_private),
-                               init_params->socket_id);
+                               init_params->socket_id,
+                               vdev);
        if (dev == NULL) {
                ARMV8_CRYPTO_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
@@ -860,7 +864,7 @@ cryptodev_armv8_crypto_init(struct rte_vdev_device *vdev)
        if (name == NULL)
                return -EINVAL;
        input_args = rte_vdev_device_args(vdev);
-       rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
+       rte_cryptodev_vdev_parse_init_params(&init_params, input_args);
 
        RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name,
                        init_params.socket_id);