New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / crypto / aesni_mb / rte_aesni_mb_pmd.c
index 45b25c9..83250e3 100644 (file)
@@ -1,45 +1,24 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Intel Corporation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2015-2017 Intel Corporation
  */
 
+#include <intel-ipsec-mb.h>
+
 #include <rte_common.h>
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_vdev.h>
+#include <rte_bus_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
 #include "rte_aesni_mb_pmd_private.h"
 
+#define AES_CCM_DIGEST_MIN_LEN 4
+#define AES_CCM_DIGEST_MAX_LEN 16
+#define HMAC_MAX_BLOCK_SIZE 128
+static uint8_t cryptodev_driver_id;
+
 typedef void (*hash_one_block_t)(const void *data, void *digest);
 typedef void (*aes_keyexp_t)(const void *key, void *enc_exp_keys, void *dec_exp_keys);
 
@@ -106,6 +85,16 @@ aesni_mb_get_chain_order(const struct rte_crypto_sym_xform *xform)
                        return AESNI_MB_OP_HASH_CIPHER;
        }
 
+       if (xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
+               if (xform->aead.algo == RTE_CRYPTO_AEAD_AES_CCM ||
+                               xform->aead.algo == RTE_CRYPTO_AEAD_AES_GCM) {
+                       if (xform->aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT)
+                               return AESNI_MB_OP_AEAD_CIPHER_HASH;
+                       else
+                               return AESNI_MB_OP_AEAD_HASH_CIPHER;
+               }
+       }
+
        return AESNI_MB_OP_NOT_SUPPORTED;
 }
 
@@ -116,6 +105,8 @@ aesni_mb_set_session_auth_parameters(const struct aesni_mb_op_fns *mb_ops,
                const struct rte_crypto_sym_xform *xform)
 {
        hash_one_block_t hash_oneblock_fn;
+       unsigned int key_larger_block_size = 0;
+       uint8_t hashed_key[HMAC_MAX_BLOCK_SIZE] = { 0 };
 
        if (xform == NULL) {
                sess->auth.algo = NULL_HASH;
@@ -123,22 +114,69 @@ aesni_mb_set_session_auth_parameters(const struct aesni_mb_op_fns *mb_ops,
        }
 
        if (xform->type != RTE_CRYPTO_SYM_XFORM_AUTH) {
-               MB_LOG_ERR("Crypto xform struct not of type auth");
+               AESNI_MB_LOG(ERR, "Crypto xform struct not of type auth");
                return -1;
        }
 
+       /* Set the request digest size */
+       sess->auth.req_digest_len = xform->auth.digest_length;
+
        /* Select auth generate/verify */
        sess->auth.operation = xform->auth.op;
 
        /* Set Authentication Parameters */
        if (xform->auth.algo == RTE_CRYPTO_AUTH_AES_XCBC_MAC) {
                sess->auth.algo = AES_XCBC;
+
+               uint16_t xcbc_mac_digest_len =
+                       get_truncated_digest_byte_length(AES_XCBC);
+               if (sess->auth.req_digest_len != xcbc_mac_digest_len) {
+                       AESNI_MB_LOG(ERR, "Invalid digest size\n");
+                       return -EINVAL;
+               }
+               sess->auth.gen_digest_len = sess->auth.req_digest_len;
                (*mb_ops->aux.keyexp.aes_xcbc)(xform->auth.key.data,
                                sess->auth.xcbc.k1_expanded,
                                sess->auth.xcbc.k2, sess->auth.xcbc.k3);
                return 0;
        }
 
+       if (xform->auth.algo == RTE_CRYPTO_AUTH_AES_CMAC) {
+               sess->auth.algo = AES_CMAC;
+
+               uint16_t cmac_digest_len = get_digest_byte_length(AES_CMAC);
+
+               if (sess->auth.req_digest_len > cmac_digest_len) {
+                       AESNI_MB_LOG(ERR, "Invalid digest size\n");
+                       return -EINVAL;
+               }
+               /*
+                * Multi-buffer lib supports digest sizes from 4 to 16 bytes
+                * in version 0.50 and sizes of 12 and 16 bytes,
+                * in version 0.49.
+                * If size requested is different, generate the full digest
+                * (16 bytes) in a temporary location and then memcpy
+                * the requested number of bytes.
+                */
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+               if (sess->auth.req_digest_len < 4)
+#else
+               uint16_t cmac_trunc_digest_len =
+                               get_truncated_digest_byte_length(AES_CMAC);
+               if (sess->auth.req_digest_len != cmac_digest_len &&
+                               sess->auth.req_digest_len != cmac_trunc_digest_len)
+#endif
+                       sess->auth.gen_digest_len = cmac_digest_len;
+               else
+                       sess->auth.gen_digest_len = sess->auth.req_digest_len;
+               (*mb_ops->aux.keyexp.aes_cmac_expkey)(xform->auth.key.data,
+                               sess->auth.cmac.expkey);
+
+               (*mb_ops->aux.keyexp.aes_cmac_subkey)(sess->auth.cmac.expkey,
+                               sess->auth.cmac.skey1, sess->auth.cmac.skey2);
+               return 0;
+       }
+
        switch (xform->auth.algo) {
        case RTE_CRYPTO_AUTH_MD5_HMAC:
                sess->auth.algo = MD5;
@@ -147,34 +185,107 @@ aesni_mb_set_session_auth_parameters(const struct aesni_mb_op_fns *mb_ops,
        case RTE_CRYPTO_AUTH_SHA1_HMAC:
                sess->auth.algo = SHA1;
                hash_oneblock_fn = mb_ops->aux.one_block.sha1;
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+               if (xform->auth.key.length > get_auth_algo_blocksize(SHA1)) {
+                       mb_ops->aux.multi_block.sha1(
+                               xform->auth.key.data,
+                               xform->auth.key.length,
+                               hashed_key);
+                       key_larger_block_size = 1;
+               }
+#endif
                break;
        case RTE_CRYPTO_AUTH_SHA224_HMAC:
                sess->auth.algo = SHA_224;
                hash_oneblock_fn = mb_ops->aux.one_block.sha224;
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+               if (xform->auth.key.length > get_auth_algo_blocksize(SHA_224)) {
+                       mb_ops->aux.multi_block.sha224(
+                               xform->auth.key.data,
+                               xform->auth.key.length,
+                               hashed_key);
+                       key_larger_block_size = 1;
+               }
+#endif
                break;
        case RTE_CRYPTO_AUTH_SHA256_HMAC:
                sess->auth.algo = SHA_256;
                hash_oneblock_fn = mb_ops->aux.one_block.sha256;
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+               if (xform->auth.key.length > get_auth_algo_blocksize(SHA_256)) {
+                       mb_ops->aux.multi_block.sha256(
+                               xform->auth.key.data,
+                               xform->auth.key.length,
+                               hashed_key);
+                       key_larger_block_size = 1;
+               }
+#endif
                break;
        case RTE_CRYPTO_AUTH_SHA384_HMAC:
                sess->auth.algo = SHA_384;
                hash_oneblock_fn = mb_ops->aux.one_block.sha384;
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+               if (xform->auth.key.length > get_auth_algo_blocksize(SHA_384)) {
+                       mb_ops->aux.multi_block.sha384(
+                               xform->auth.key.data,
+                               xform->auth.key.length,
+                               hashed_key);
+                       key_larger_block_size = 1;
+               }
+#endif
                break;
        case RTE_CRYPTO_AUTH_SHA512_HMAC:
                sess->auth.algo = SHA_512;
                hash_oneblock_fn = mb_ops->aux.one_block.sha512;
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+               if (xform->auth.key.length > get_auth_algo_blocksize(SHA_512)) {
+                       mb_ops->aux.multi_block.sha512(
+                               xform->auth.key.data,
+                               xform->auth.key.length,
+                               hashed_key);
+                       key_larger_block_size = 1;
+               }
+#endif
                break;
        default:
-               MB_LOG_ERR("Unsupported authentication algorithm selection");
-               return -1;
+               AESNI_MB_LOG(ERR, "Unsupported authentication algorithm selection");
+               return -ENOTSUP;
+       }
+       uint16_t trunc_digest_size =
+                       get_truncated_digest_byte_length(sess->auth.algo);
+       uint16_t full_digest_size =
+                       get_digest_byte_length(sess->auth.algo);
+
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+       if (sess->auth.req_digest_len > full_digest_size ||
+                       sess->auth.req_digest_len == 0) {
+#else
+       if (sess->auth.req_digest_len != trunc_digest_size) {
+#endif
+               AESNI_MB_LOG(ERR, "Invalid digest size\n");
+               return -EINVAL;
        }
 
+       if (sess->auth.req_digest_len != trunc_digest_size &&
+                       sess->auth.req_digest_len != full_digest_size)
+               sess->auth.gen_digest_len = full_digest_size;
+       else
+               sess->auth.gen_digest_len = sess->auth.req_digest_len;
+
        /* Calculate Authentication precomputes */
-       calculate_auth_precomputes(hash_oneblock_fn,
+       if (key_larger_block_size) {
+               calculate_auth_precomputes(hash_oneblock_fn,
+                       sess->auth.pads.inner, sess->auth.pads.outer,
+                       hashed_key,
+                       xform->auth.key.length,
+                       get_auth_algo_blocksize(sess->auth.algo));
+       } else {
+               calculate_auth_precomputes(hash_oneblock_fn,
                        sess->auth.pads.inner, sess->auth.pads.outer,
                        xform->auth.key.data,
                        xform->auth.key.length,
                        get_auth_algo_blocksize(sess->auth.algo));
+       }
 
        return 0;
 }
@@ -185,6 +296,8 @@ aesni_mb_set_session_cipher_parameters(const struct aesni_mb_op_fns *mb_ops,
                struct aesni_mb_session *sess,
                const struct rte_crypto_sym_xform *xform)
 {
+       uint8_t is_aes = 0;
+       uint8_t is_3DES = 0;
        aes_keyexp_t aes_keyexp_fn;
 
        if (xform == NULL) {
@@ -193,8 +306,8 @@ aesni_mb_set_session_cipher_parameters(const struct aesni_mb_op_fns *mb_ops,
        }
 
        if (xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) {
-               MB_LOG_ERR("Crypto xform struct not of type cipher");
-               return -1;
+               AESNI_MB_LOG(ERR, "Crypto xform struct not of type cipher");
+               return -EINVAL;
        }
 
        /* Select cipher direction */
@@ -206,49 +319,220 @@ aesni_mb_set_session_cipher_parameters(const struct aesni_mb_op_fns *mb_ops,
                sess->cipher.direction = DECRYPT;
                break;
        default:
-               MB_LOG_ERR("Unsupported cipher operation parameter");
-               return -1;
+               AESNI_MB_LOG(ERR, "Invalid cipher operation parameter");
+               return -EINVAL;
        }
 
        /* Select cipher mode */
        switch (xform->cipher.algo) {
        case RTE_CRYPTO_CIPHER_AES_CBC:
                sess->cipher.mode = CBC;
+               is_aes = 1;
                break;
        case RTE_CRYPTO_CIPHER_AES_CTR:
                sess->cipher.mode = CNTR;
+               is_aes = 1;
                break;
        case RTE_CRYPTO_CIPHER_AES_DOCSISBPI:
                sess->cipher.mode = DOCSIS_SEC_BPI;
+               is_aes = 1;
+               break;
+       case RTE_CRYPTO_CIPHER_DES_CBC:
+               sess->cipher.mode = DES;
+               break;
+       case RTE_CRYPTO_CIPHER_DES_DOCSISBPI:
+               sess->cipher.mode = DOCSIS_DES;
+               break;
+       case RTE_CRYPTO_CIPHER_3DES_CBC:
+               sess->cipher.mode = DES3;
+               is_3DES = 1;
                break;
        default:
-               MB_LOG_ERR("Unsupported cipher mode parameter");
-               return -1;
+               AESNI_MB_LOG(ERR, "Unsupported cipher mode parameter");
+               return -ENOTSUP;
        }
 
-       /* Check key length and choose key expansion function */
-       switch (xform->cipher.key.length) {
-       case AES_128_BYTES:
-               sess->cipher.key_length_in_bytes = AES_128_BYTES;
-               aes_keyexp_fn = mb_ops->aux.keyexp.aes128;
+       /* Set IV parameters */
+       sess->iv.offset = xform->cipher.iv.offset;
+       sess->iv.length = xform->cipher.iv.length;
+
+       /* Check key length and choose key expansion function for AES */
+       if (is_aes) {
+               switch (xform->cipher.key.length) {
+               case AES_128_BYTES:
+                       sess->cipher.key_length_in_bytes = AES_128_BYTES;
+                       aes_keyexp_fn = mb_ops->aux.keyexp.aes128;
+                       break;
+               case AES_192_BYTES:
+                       sess->cipher.key_length_in_bytes = AES_192_BYTES;
+                       aes_keyexp_fn = mb_ops->aux.keyexp.aes192;
+                       break;
+               case AES_256_BYTES:
+                       sess->cipher.key_length_in_bytes = AES_256_BYTES;
+                       aes_keyexp_fn = mb_ops->aux.keyexp.aes256;
+                       break;
+               default:
+                       AESNI_MB_LOG(ERR, "Invalid cipher key length");
+                       return -EINVAL;
+               }
+
+               /* Expanded cipher keys */
+               (*aes_keyexp_fn)(xform->cipher.key.data,
+                               sess->cipher.expanded_aes_keys.encode,
+                               sess->cipher.expanded_aes_keys.decode);
+
+       } else if (is_3DES) {
+               uint64_t *keys[3] = {sess->cipher.exp_3des_keys.key[0],
+                               sess->cipher.exp_3des_keys.key[1],
+                               sess->cipher.exp_3des_keys.key[2]};
+
+               switch (xform->cipher.key.length) {
+               case  24:
+                       des_key_schedule(keys[0], xform->cipher.key.data);
+                       des_key_schedule(keys[1], xform->cipher.key.data+8);
+                       des_key_schedule(keys[2], xform->cipher.key.data+16);
+
+                       /* Initialize keys - 24 bytes: [K1-K2-K3] */
+                       sess->cipher.exp_3des_keys.ks_ptr[0] = keys[0];
+                       sess->cipher.exp_3des_keys.ks_ptr[1] = keys[1];
+                       sess->cipher.exp_3des_keys.ks_ptr[2] = keys[2];
+                       break;
+               case 16:
+                       des_key_schedule(keys[0], xform->cipher.key.data);
+                       des_key_schedule(keys[1], xform->cipher.key.data+8);
+
+                       /* Initialize keys - 16 bytes: [K1=K1,K2=K2,K3=K1] */
+                       sess->cipher.exp_3des_keys.ks_ptr[0] = keys[0];
+                       sess->cipher.exp_3des_keys.ks_ptr[1] = keys[1];
+                       sess->cipher.exp_3des_keys.ks_ptr[2] = keys[0];
+                       break;
+               case 8:
+                       des_key_schedule(keys[0], xform->cipher.key.data);
+
+                       /* Initialize keys - 8 bytes: [K1 = K2 = K3] */
+                       sess->cipher.exp_3des_keys.ks_ptr[0] = keys[0];
+                       sess->cipher.exp_3des_keys.ks_ptr[1] = keys[0];
+                       sess->cipher.exp_3des_keys.ks_ptr[2] = keys[0];
+                       break;
+               default:
+                       AESNI_MB_LOG(ERR, "Invalid cipher key length");
+                       return -EINVAL;
+               }
+
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+               sess->cipher.key_length_in_bytes = 24;
+#else
+               sess->cipher.key_length_in_bytes = 8;
+#endif
+       } else {
+               if (xform->cipher.key.length != 8) {
+                       AESNI_MB_LOG(ERR, "Invalid cipher key length");
+                       return -EINVAL;
+               }
+               sess->cipher.key_length_in_bytes = 8;
+
+               des_key_schedule((uint64_t *)sess->cipher.expanded_aes_keys.encode,
+                               xform->cipher.key.data);
+               des_key_schedule((uint64_t *)sess->cipher.expanded_aes_keys.decode,
+                               xform->cipher.key.data);
+       }
+
+       return 0;
+}
+
+static int
+aesni_mb_set_session_aead_parameters(const struct aesni_mb_op_fns *mb_ops,
+               struct aesni_mb_session *sess,
+               const struct rte_crypto_sym_xform *xform)
+{
+       union {
+               aes_keyexp_t aes_keyexp_fn;
+               aes_gcm_keyexp_t aes_gcm_keyexp_fn;
+       } keyexp;
+
+       switch (xform->aead.op) {
+       case RTE_CRYPTO_AEAD_OP_ENCRYPT:
+               sess->cipher.direction = ENCRYPT;
+               sess->auth.operation = RTE_CRYPTO_AUTH_OP_GENERATE;
                break;
-       case AES_192_BYTES:
-               sess->cipher.key_length_in_bytes = AES_192_BYTES;
-               aes_keyexp_fn = mb_ops->aux.keyexp.aes192;
+       case RTE_CRYPTO_AEAD_OP_DECRYPT:
+               sess->cipher.direction = DECRYPT;
+               sess->auth.operation = RTE_CRYPTO_AUTH_OP_VERIFY;
                break;
-       case AES_256_BYTES:
-               sess->cipher.key_length_in_bytes = AES_256_BYTES;
-               aes_keyexp_fn = mb_ops->aux.keyexp.aes256;
+       default:
+               AESNI_MB_LOG(ERR, "Invalid aead operation parameter");
+               return -EINVAL;
+       }
+
+       switch (xform->aead.algo) {
+       case RTE_CRYPTO_AEAD_AES_CCM:
+               sess->cipher.mode = CCM;
+               sess->auth.algo = AES_CCM;
+
+               /* Check key length and choose key expansion function for AES */
+               switch (xform->aead.key.length) {
+               case AES_128_BYTES:
+                       sess->cipher.key_length_in_bytes = AES_128_BYTES;
+                       keyexp.aes_keyexp_fn = mb_ops->aux.keyexp.aes128;
+                       break;
+               default:
+                       AESNI_MB_LOG(ERR, "Invalid cipher key length");
+                       return -EINVAL;
+               }
+
+               /* Expanded cipher keys */
+               (*keyexp.aes_keyexp_fn)(xform->aead.key.data,
+                               sess->cipher.expanded_aes_keys.encode,
+                               sess->cipher.expanded_aes_keys.decode);
+               break;
+
+       case RTE_CRYPTO_AEAD_AES_GCM:
+               sess->cipher.mode = GCM;
+               sess->auth.algo = AES_GMAC;
+
+               switch (xform->aead.key.length) {
+               case AES_128_BYTES:
+                       sess->cipher.key_length_in_bytes = AES_128_BYTES;
+                       keyexp.aes_gcm_keyexp_fn =
+                                       mb_ops->aux.keyexp.aes_gcm_128;
+                       break;
+               case AES_192_BYTES:
+                       sess->cipher.key_length_in_bytes = AES_192_BYTES;
+                       keyexp.aes_gcm_keyexp_fn =
+                                       mb_ops->aux.keyexp.aes_gcm_192;
+                       break;
+               case AES_256_BYTES:
+                       sess->cipher.key_length_in_bytes = AES_256_BYTES;
+                       keyexp.aes_gcm_keyexp_fn =
+                                       mb_ops->aux.keyexp.aes_gcm_256;
+                       break;
+               default:
+                       AESNI_MB_LOG(ERR, "Invalid cipher key length");
+                       return -EINVAL;
+               }
+
+               (keyexp.aes_gcm_keyexp_fn)(xform->aead.key.data,
+                               &sess->cipher.gcm_key);
                break;
+
        default:
-               MB_LOG_ERR("Unsupported cipher key length");
-               return -1;
+               AESNI_MB_LOG(ERR, "Unsupported aead mode parameter");
+               return -ENOTSUP;
        }
 
-       /* Expanded cipher keys */
-       (*aes_keyexp_fn)(xform->cipher.key.data,
-                       sess->cipher.expanded_aes_keys.encode,
-                       sess->cipher.expanded_aes_keys.decode);
+       /* Set IV parameters */
+       sess->iv.offset = xform->aead.iv.offset;
+       sess->iv.length = xform->aead.iv.length;
+
+       sess->auth.req_digest_len = xform->aead.digest_length;
+       /* CCM digests must be between 4 and 16 and an even number */
+       if (sess->auth.req_digest_len < AES_CCM_DIGEST_MIN_LEN ||
+                       sess->auth.req_digest_len > AES_CCM_DIGEST_MAX_LEN ||
+                       (sess->auth.req_digest_len & 1) == 1) {
+               AESNI_MB_LOG(ERR, "Invalid digest size\n");
+               return -EINVAL;
+       }
+       sess->auth.gen_digest_len = sess->auth.req_digest_len;
 
        return 0;
 }
@@ -261,6 +545,8 @@ aesni_mb_set_session_parameters(const struct aesni_mb_op_fns *mb_ops,
 {
        const struct rte_crypto_sym_xform *auth_xform = NULL;
        const struct rte_crypto_sym_xform *cipher_xform = NULL;
+       const struct rte_crypto_sym_xform *aead_xform = NULL;
+       int ret;
 
        /* Select Crypto operation - hash then cipher / cipher then hash */
        switch (aesni_mb_get_chain_order(xform)) {
@@ -293,22 +579,47 @@ aesni_mb_set_session_parameters(const struct aesni_mb_op_fns *mb_ops,
                auth_xform = NULL;
                cipher_xform = xform;
                break;
+       case AESNI_MB_OP_AEAD_CIPHER_HASH:
+               sess->chain_order = CIPHER_HASH;
+               sess->aead.aad_len = xform->aead.aad_length;
+               aead_xform = xform;
+               break;
+       case AESNI_MB_OP_AEAD_HASH_CIPHER:
+               sess->chain_order = HASH_CIPHER;
+               sess->aead.aad_len = xform->aead.aad_length;
+               aead_xform = xform;
+               break;
        case AESNI_MB_OP_NOT_SUPPORTED:
        default:
-               MB_LOG_ERR("Unsupported operation chain order parameter");
-               return -1;
+               AESNI_MB_LOG(ERR, "Unsupported operation chain order parameter");
+               return -ENOTSUP;
        }
 
-       if (aesni_mb_set_session_auth_parameters(mb_ops, sess, auth_xform)) {
-               MB_LOG_ERR("Invalid/unsupported authentication parameters");
-               return -1;
+       /* Default IV length = 0 */
+       sess->iv.length = 0;
+
+       ret = aesni_mb_set_session_auth_parameters(mb_ops, sess, auth_xform);
+       if (ret != 0) {
+               AESNI_MB_LOG(ERR, "Invalid/unsupported authentication parameters");
+               return ret;
        }
 
-       if (aesni_mb_set_session_cipher_parameters(mb_ops, sess,
-                       cipher_xform)) {
-               MB_LOG_ERR("Invalid/unsupported cipher parameters");
-               return -1;
+       ret = aesni_mb_set_session_cipher_parameters(mb_ops, sess,
+                       cipher_xform);
+       if (ret != 0) {
+               AESNI_MB_LOG(ERR, "Invalid/unsupported cipher parameters");
+               return ret;
+       }
+
+       if (aead_xform) {
+               ret = aesni_mb_set_session_aead_parameters(mb_ops, sess,
+                               aead_xform);
+               if (ret != 0) {
+                       AESNI_MB_LOG(ERR, "Invalid/unsupported aead parameters");
+                       return ret;
+               }
        }
+
        return 0;
 }
 
@@ -344,30 +655,38 @@ get_session(struct aesni_mb_qp *qp, struct rte_crypto_op *op)
 {
        struct aesni_mb_session *sess = NULL;
 
-       if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-               if (unlikely(op->sym->session->dev_type !=
-                               RTE_CRYPTODEV_AESNI_MB_PMD)) {
-                       return NULL;
-               }
-
-               sess = (struct aesni_mb_session *)op->sym->session->_private;
-       } else  {
+       if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+               if (likely(op->sym->session != NULL))
+                       sess = (struct aesni_mb_session *)
+                                       get_sym_session_private_data(
+                                       op->sym->session,
+                                       cryptodev_driver_id);
+       } else {
                void *_sess = NULL;
+               void *_sess_private_data = NULL;
 
                if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
                        return NULL;
 
-               sess = (struct aesni_mb_session *)
-                       ((struct rte_cryptodev_sym_session *)_sess)->_private;
+               if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
+                       return NULL;
+
+               sess = (struct aesni_mb_session *)_sess_private_data;
 
                if (unlikely(aesni_mb_set_session_parameters(qp->op_fns,
                                sess, op->sym->xform) != 0)) {
                        rte_mempool_put(qp->sess_mp, _sess);
+                       rte_mempool_put(qp->sess_mp, _sess_private_data);
                        sess = NULL;
                }
                op->sym->session = (struct rte_cryptodev_sym_session *)_sess;
+               set_sym_session_private_data(op->sym->session,
+                               cryptodev_driver_id, _sess_private_data);
        }
 
+       if (unlikely(sess == NULL))
+               op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
+
        return sess;
 }
 
@@ -385,7 +704,7 @@ get_session(struct aesni_mb_qp *qp, struct rte_crypto_op *op)
  */
 static inline int
 set_mb_job_params(JOB_AES_HMAC *job, struct aesni_mb_qp *qp,
-               struct rte_crypto_op *op)
+               struct rte_crypto_op *op, uint8_t *digest_idx)
 {
        struct rte_mbuf *m_src = op->sym->m_src, *m_dst;
        struct aesni_mb_session *session;
@@ -396,7 +715,6 @@ set_mb_job_params(JOB_AES_HMAC *job, struct aesni_mb_qp *qp,
                op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
                return -1;
        }
-       op->status = RTE_CRYPTO_OP_STATUS_ENQUEUED;
 
        /* Set crypto operation */
        job->chain_order = session->chain_order;
@@ -406,19 +724,63 @@ set_mb_job_params(JOB_AES_HMAC *job, struct aesni_mb_qp *qp,
        job->cipher_mode = session->cipher.mode;
 
        job->aes_key_len_in_bytes = session->cipher.key_length_in_bytes;
-       job->aes_enc_key_expanded = session->cipher.expanded_aes_keys.encode;
-       job->aes_dec_key_expanded = session->cipher.expanded_aes_keys.decode;
-
 
        /* Set authentication parameters */
        job->hash_alg = session->auth.algo;
-       if (job->hash_alg == AES_XCBC) {
-               job->_k1_expanded = session->auth.xcbc.k1_expanded;
-               job->_k2 = session->auth.xcbc.k2;
-               job->_k3 = session->auth.xcbc.k3;
-       } else {
-               job->hashed_auth_key_xor_ipad = session->auth.pads.inner;
-               job->hashed_auth_key_xor_opad = session->auth.pads.outer;
+
+       switch (job->hash_alg) {
+       case AES_XCBC:
+               job->u.XCBC._k1_expanded = session->auth.xcbc.k1_expanded;
+               job->u.XCBC._k2 = session->auth.xcbc.k2;
+               job->u.XCBC._k3 = session->auth.xcbc.k3;
+
+               job->aes_enc_key_expanded =
+                               session->cipher.expanded_aes_keys.encode;
+               job->aes_dec_key_expanded =
+                               session->cipher.expanded_aes_keys.decode;
+               break;
+
+       case AES_CCM:
+               job->u.CCM.aad = op->sym->aead.aad.data + 18;
+               job->u.CCM.aad_len_in_bytes = session->aead.aad_len;
+               job->aes_enc_key_expanded =
+                               session->cipher.expanded_aes_keys.encode;
+               job->aes_dec_key_expanded =
+                               session->cipher.expanded_aes_keys.decode;
+               break;
+
+       case AES_CMAC:
+               job->u.CMAC._key_expanded = session->auth.cmac.expkey;
+               job->u.CMAC._skey1 = session->auth.cmac.skey1;
+               job->u.CMAC._skey2 = session->auth.cmac.skey2;
+               job->aes_enc_key_expanded =
+                               session->cipher.expanded_aes_keys.encode;
+               job->aes_dec_key_expanded =
+                               session->cipher.expanded_aes_keys.decode;
+               break;
+
+       case AES_GMAC:
+               job->u.GCM.aad = op->sym->aead.aad.data;
+               job->u.GCM.aad_len_in_bytes = session->aead.aad_len;
+               job->aes_enc_key_expanded = &session->cipher.gcm_key;
+               job->aes_dec_key_expanded = &session->cipher.gcm_key;
+               break;
+
+       default:
+               job->u.HMAC._hashed_auth_key_xor_ipad = session->auth.pads.inner;
+               job->u.HMAC._hashed_auth_key_xor_opad = session->auth.pads.outer;
+
+               if (job->cipher_mode == DES3) {
+                       job->aes_enc_key_expanded =
+                               session->cipher.exp_3des_keys.ks_ptr;
+                       job->aes_dec_key_expanded =
+                               session->cipher.exp_3des_keys.ks_ptr;
+               } else {
+                       job->aes_enc_key_expanded =
+                               session->cipher.expanded_aes_keys.encode;
+                       job->aes_dec_key_expanded =
+                               session->cipher.expanded_aes_keys.decode;
+               }
        }
 
        /* Mutable crypto operation parameters */
@@ -429,7 +791,7 @@ set_mb_job_params(JOB_AES_HMAC *job, struct aesni_mb_qp *qp,
                char *odata = rte_pktmbuf_append(m_dst,
                                rte_pktmbuf_data_len(op->sym->m_src));
                if (odata == NULL) {
-                       MB_LOG_ERR("failed to allocate space in destination "
+                       AESNI_MB_LOG(ERR, "failed to allocate space in destination "
                                        "mbuf for source data");
                        op->status = RTE_CRYPTO_OP_STATUS_ERROR;
                        return -1;
@@ -439,103 +801,144 @@ set_mb_job_params(JOB_AES_HMAC *job, struct aesni_mb_qp *qp,
                                rte_pktmbuf_data_len(op->sym->m_src));
        } else {
                m_dst = m_src;
-               m_offset = op->sym->cipher.data.offset;
+               if (job->hash_alg == AES_CCM || job->hash_alg == AES_GMAC)
+                       m_offset = op->sym->aead.data.offset;
+               else
+                       m_offset = op->sym->cipher.data.offset;
        }
 
        /* Set digest output location */
        if (job->hash_alg != NULL_HASH &&
                        session->auth.operation == RTE_CRYPTO_AUTH_OP_VERIFY) {
-               job->auth_tag_output = (uint8_t *)rte_pktmbuf_append(m_dst,
-                               get_digest_byte_length(job->hash_alg));
+               job->auth_tag_output = qp->temp_digests[*digest_idx];
+               *digest_idx = (*digest_idx + 1) % MAX_JOBS;
+       } else {
+               if (job->hash_alg == AES_CCM || job->hash_alg == AES_GMAC)
+                       job->auth_tag_output = op->sym->aead.digest.data;
+               else
+                       job->auth_tag_output = op->sym->auth.digest.data;
 
-               if (job->auth_tag_output == NULL) {
-                       MB_LOG_ERR("failed to allocate space in output mbuf "
-                                       "for temp digest");
-                       op->status = RTE_CRYPTO_OP_STATUS_ERROR;
-                       return -1;
+               if (session->auth.req_digest_len != session->auth.gen_digest_len) {
+                       job->auth_tag_output = qp->temp_digests[*digest_idx];
+                       *digest_idx = (*digest_idx + 1) % MAX_JOBS;
                }
-
-               memset(job->auth_tag_output, 0,
-                               sizeof(get_digest_byte_length(job->hash_alg)));
-
-       } else {
-               job->auth_tag_output = op->sym->auth.digest.data;
        }
-
        /*
         * Multi-buffer library current only support returning a truncated
         * digest length as specified in the relevant IPsec RFCs
         */
-       job->auth_tag_output_len_in_bytes =
-                       get_truncated_digest_byte_length(job->hash_alg);
+
+       /* Set digest length */
+       job->auth_tag_output_len_in_bytes = session->auth.gen_digest_len;
 
        /* Set IV parameters */
-       job->iv = op->sym->cipher.iv.data;
-       job->iv_len_in_bytes = op->sym->cipher.iv.length;
+       job->iv_len_in_bytes = session->iv.length;
 
        /* Data  Parameter */
        job->src = rte_pktmbuf_mtod(m_src, uint8_t *);
        job->dst = rte_pktmbuf_mtod_offset(m_dst, uint8_t *, m_offset);
 
-       job->cipher_start_src_offset_in_bytes = op->sym->cipher.data.offset;
-       job->msg_len_to_cipher_in_bytes = op->sym->cipher.data.length;
+       switch (job->hash_alg) {
+       case AES_CCM:
+               job->cipher_start_src_offset_in_bytes =
+                               op->sym->aead.data.offset;
+               job->msg_len_to_cipher_in_bytes = op->sym->aead.data.length;
+               job->hash_start_src_offset_in_bytes = op->sym->aead.data.offset;
+               job->msg_len_to_hash_in_bytes = op->sym->aead.data.length;
 
-       job->hash_start_src_offset_in_bytes = op->sym->auth.data.offset;
-       job->msg_len_to_hash_in_bytes = op->sym->auth.data.length;
+               job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                       session->iv.offset + 1);
+               break;
+
+       case AES_GMAC:
+               job->cipher_start_src_offset_in_bytes =
+                               op->sym->aead.data.offset;
+               job->hash_start_src_offset_in_bytes = op->sym->aead.data.offset;
+               job->msg_len_to_cipher_in_bytes = op->sym->aead.data.length;
+               job->msg_len_to_hash_in_bytes = job->msg_len_to_cipher_in_bytes;
+               job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                               session->iv.offset);
+               break;
+
+       default:
+               job->cipher_start_src_offset_in_bytes =
+                               op->sym->cipher.data.offset;
+               job->msg_len_to_cipher_in_bytes = op->sym->cipher.data.length;
+
+               job->hash_start_src_offset_in_bytes = op->sym->auth.data.offset;
+               job->msg_len_to_hash_in_bytes = op->sym->auth.data.length;
+
+               job->iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                       session->iv.offset);
+       }
 
        /* Set user data to be crypto operation data struct */
        job->user_data = op;
-       job->user_data2 = m_dst;
 
        return 0;
 }
 
 static inline void
-verify_digest(JOB_AES_HMAC *job, struct rte_crypto_op *op) {
-       struct rte_mbuf *m_dst = (struct rte_mbuf *)job->user_data2;
-
-       RTE_ASSERT(m_dst == NULL);
-
+verify_digest(JOB_AES_HMAC *job, struct rte_crypto_op *op,
+               struct aesni_mb_session *sess)
+{
        /* Verify digest if required */
-       if (memcmp(job->auth_tag_output, op->sym->auth.digest.data,
-                       job->auth_tag_output_len_in_bytes) != 0)
-               op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+       if (job->hash_alg == AES_CCM || job->hash_alg == AES_GMAC) {
+               if (memcmp(job->auth_tag_output, op->sym->aead.digest.data,
+                               sess->auth.req_digest_len) != 0)
+                       op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+       } else {
+               if (memcmp(job->auth_tag_output, op->sym->auth.digest.data,
+                               sess->auth.req_digest_len) != 0)
+                       op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+       }
+}
+
+static inline void
+generate_digest(JOB_AES_HMAC *job, struct rte_crypto_op *op,
+               struct aesni_mb_session *sess)
+{
+       /* No extra copy neeed */
+       if (likely(sess->auth.req_digest_len == sess->auth.gen_digest_len))
+               return;
 
-       /* trim area used for digest from mbuf */
-       rte_pktmbuf_trim(m_dst, get_digest_byte_length(job->hash_alg));
+       /*
+        * This can only happen for HMAC, so only digest
+        * for authentication algos is required
+        */
+       memcpy(op->sym->auth.digest.data, job->auth_tag_output,
+                       sess->auth.req_digest_len);
 }
 
 /**
  * Process a completed job and return rte_mbuf which job processed
  *
+ * @param qp           Queue Pair to process
  * @param job  JOB_AES_HMAC job to process
  *
  * @return
- * - Returns processed mbuf which is trimmed of output digest used in
- * verification of supplied digest in the case of a HASH_CIPHER operation
+ * - Returns processed crypto operation.
  * - Returns NULL on invalid job
  */
 static inline struct rte_crypto_op *
 post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
 {
        struct rte_crypto_op *op = (struct rte_crypto_op *)job->user_data;
+       struct aesni_mb_session *sess = get_sym_session_private_data(
+                                                       op->sym->session,
+                                                       cryptodev_driver_id);
 
-       struct aesni_mb_session *sess;
-
-       RTE_ASSERT(op == NULL);
-
-       if (unlikely(op->status == RTE_CRYPTO_OP_STATUS_ENQUEUED)) {
+       if (likely(op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)) {
                switch (job->status) {
                case STS_COMPLETED:
                        op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
                        if (job->hash_alg != NULL_HASH) {
-                               sess = (struct aesni_mb_session *)
-                                               op->sym->session->_private;
-
                                if (sess->auth.operation ==
                                                RTE_CRYPTO_AUTH_OP_VERIFY)
-                                       verify_digest(job, op);
+                                       verify_digest(job, op, sess);
+                               else
+                                       generate_digest(job, op, sess);
                        }
                        break;
                default:
@@ -544,7 +947,11 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
        }
 
        /* 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 aesni_mb_session));
+               memset(op->sym->session, 0,
+                               rte_cryptodev_sym_get_header_session_size());
+               rte_mempool_put(qp->sess_mp, sess);
                rte_mempool_put(qp->sess_mp, op->sym->session);
                op->sym->session = NULL;
        }
@@ -569,7 +976,7 @@ handle_completed_jobs(struct aesni_mb_qp *qp, JOB_AES_HMAC *job,
        struct rte_crypto_op *op = NULL;
        unsigned processed_jobs = 0;
 
-       while (job != NULL && processed_jobs < nb_ops) {
+       while (job != NULL) {
                op = post_process_mb_job(qp, job);
 
                if (op) {
@@ -579,8 +986,10 @@ handle_completed_jobs(struct aesni_mb_qp *qp, JOB_AES_HMAC *job,
                        qp->stats.dequeue_err_count++;
                        break;
                }
+               if (processed_jobs == nb_ops)
+                       break;
 
-               job = (*qp->op_fns->job.get_completed_job)(&qp->mb_mgr);
+               job = (*qp->op_fns->job.get_completed_job)(qp->mb_mgr);
        }
 
        return processed_jobs;
@@ -593,7 +1002,7 @@ flush_mb_mgr(struct aesni_mb_qp *qp, struct rte_crypto_op **ops,
        int processed_ops = 0;
 
        /* Flush the remaining jobs */
-       JOB_AES_HMAC *job = (*qp->op_fns->job.flush_job)(&qp->mb_mgr);
+       JOB_AES_HMAC *job = (*qp->op_fns->job.flush_job)(qp->mb_mgr);
 
        if (job)
                processed_ops += handle_completed_jobs(qp, job,
@@ -603,13 +1012,16 @@ flush_mb_mgr(struct aesni_mb_qp *qp, struct rte_crypto_op **ops,
 }
 
 static inline JOB_AES_HMAC *
-set_job_null_op(JOB_AES_HMAC *job)
+set_job_null_op(JOB_AES_HMAC *job, struct rte_crypto_op *op)
 {
        job->chain_order = HASH_CIPHER;
        job->cipher_mode = NULL_CIPHER;
        job->hash_alg = NULL_HASH;
        job->cipher_direction = DECRYPT;
 
+       /* Set user data to be crypto operation data struct */
+       job->user_data = op;
+
        return job;
 }
 
@@ -624,31 +1036,43 @@ aesni_mb_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
 
        int retval, processed_jobs = 0;
 
-       do {
-               /* Get next operation to process from ingress queue */
-               retval = rte_ring_dequeue(qp->ingress_queue, (void **)&op);
-               if (retval < 0)
-                       break;
+       if (unlikely(nb_ops == 0))
+               return 0;
 
+       uint8_t digest_idx = qp->digest_idx;
+       do {
                /* Get next free mb job struct from mb manager */
-               job = (*qp->op_fns->job.get_next)(&qp->mb_mgr);
+               job = (*qp->op_fns->job.get_next)(qp->mb_mgr);
                if (unlikely(job == NULL)) {
                        /* if no free mb job structs we need to flush mb_mgr */
                        processed_jobs += flush_mb_mgr(qp,
                                        &ops[processed_jobs],
-                                       (nb_ops - processed_jobs) - 1);
+                                       nb_ops - processed_jobs);
+
+                       if (nb_ops == processed_jobs)
+                               break;
 
-                       job = (*qp->op_fns->job.get_next)(&qp->mb_mgr);
+                       job = (*qp->op_fns->job.get_next)(qp->mb_mgr);
                }
 
-               retval = set_mb_job_params(job, qp, op);
+               /*
+                * Get next operation to process from ingress queue.
+                * There is no need to return the job to the MB_MGR
+                * if there are no more operations to process, since the MB_MGR
+                * can use that pointer again in next get_next calls.
+                */
+               retval = rte_ring_dequeue(qp->ingress_queue, (void **)&op);
+               if (retval < 0)
+                       break;
+
+               retval = set_mb_job_params(job, qp, op, &digest_idx);
                if (unlikely(retval != 0)) {
                        qp->stats.dequeue_err_count++;
-                       set_job_null_op(job);
+                       set_job_null_op(job, op);
                }
 
                /* Submit job to multi-buffer for processing */
-               job = (*qp->op_fns->job.submit)(&qp->mb_mgr);
+               job = (*qp->op_fns->job.submit)(qp->mb_mgr);
 
                /*
                 * If submit returns a processed job then handle it,
@@ -661,6 +1085,8 @@ aesni_mb_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
 
        } while (processed_jobs < nb_ops);
 
+       qp->digest_idx = digest_idx;
+
        if (processed_jobs < 1)
                processed_jobs += flush_mb_mgr(qp,
                                &ops[processed_jobs],
@@ -674,15 +1100,23 @@ static int cryptodev_aesni_mb_remove(struct rte_vdev_device *vdev);
 static int
 cryptodev_aesni_mb_create(const char *name,
                        struct rte_vdev_device *vdev,
-                       struct rte_crypto_vdev_init_params *init_params)
+                       struct rte_cryptodev_pmd_init_params *init_params)
 {
        struct rte_cryptodev *dev;
        struct aesni_mb_private *internals;
        enum aesni_mb_vector_mode vector_mode;
 
-       if (init_params->name[0] == '\0')
-               snprintf(init_params->name, sizeof(init_params->name),
-                               "%s", name);
+       /* Check CPU for support for AES instruction set */
+       if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AES)) {
+               AESNI_MB_LOG(ERR, "AES instructions not supported by CPU");
+               return -EFAULT;
+       }
+
+       dev = rte_cryptodev_pmd_create(name, &vdev->device, init_params);
+       if (dev == NULL) {
+               AESNI_MB_LOG(ERR, "failed to create cryptodev vdev");
+               return -ENODEV;
+       }
 
        /* Check CPU for supported vector instruction set */
        if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
@@ -691,21 +1125,10 @@ cryptodev_aesni_mb_create(const char *name,
                vector_mode = RTE_AESNI_MB_AVX2;
        else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
                vector_mode = RTE_AESNI_MB_AVX;
-       else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
+       else
                vector_mode = RTE_AESNI_MB_SSE;
-       else {
-               MB_LOG_ERR("Vector instructions are not supported by CPU");
-               return -EFAULT;
-       }
-
-       dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
-                       sizeof(struct aesni_mb_private), init_params->socket_id);
-       if (dev == NULL) {
-               MB_LOG_ERR("failed to create cryptodev vdev");
-               goto init_error;
-       }
 
-       dev->dev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
+       dev->driver_id = cryptodev_driver_id;
        dev->dev_ops = rte_aesni_mb_pmd_ops;
 
        /* register rx/tx burst functions for data path */
@@ -738,44 +1161,41 @@ cryptodev_aesni_mb_create(const char *name,
 
        internals->vector_mode = vector_mode;
        internals->max_nb_queue_pairs = init_params->max_nb_queue_pairs;
-       internals->max_nb_sessions = init_params->max_nb_sessions;
 
-       return 0;
-init_error:
-       MB_LOG_ERR("driver %s: cryptodev_aesni_create failed",
-                       init_params->name);
+#if IMB_VERSION_NUM >= IMB_VERSION(0, 50, 0)
+       AESNI_MB_LOG(INFO, "IPSec Multi-buffer library version used: %s\n",
+                       imb_get_version_str());
+#else
+       AESNI_MB_LOG(INFO, "IPSec Multi-buffer library version used: 0.49.0\n");
+#endif
 
-       cryptodev_aesni_mb_remove(vdev);
-       return -EFAULT;
+       return 0;
 }
 
 static int
 cryptodev_aesni_mb_probe(struct rte_vdev_device *vdev)
 {
-       struct rte_crypto_vdev_init_params init_params = {
-               RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS,
-               RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_SESSIONS,
+       struct rte_cryptodev_pmd_init_params init_params = {
+               "",
+               sizeof(struct aesni_mb_private),
                rte_socket_id(),
-               ""
+               RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS
        };
-       const char *name;
-       const char *input_args;
+       const char *name, *args;
+       int retval;
 
        name = rte_vdev_device_name(vdev);
        if (name == NULL)
                return -EINVAL;
-       input_args = rte_vdev_device_args(vdev);
-       rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
-
-       RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name,
-                       init_params.socket_id);
-       if (init_params.name[0] != '\0')
-               RTE_LOG(INFO, PMD, "  User defined name = %s\n",
-                       init_params.name);
-       RTE_LOG(INFO, PMD, "  Max number of queue pairs = %d\n",
-                       init_params.max_nb_queue_pairs);
-       RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
-                       init_params.max_nb_sessions);
+
+       args = rte_vdev_device_args(vdev);
+
+       retval = rte_cryptodev_pmd_parse_input_args(&init_params, args);
+       if (retval) {
+               AESNI_MB_LOG(ERR, "Failed to parse initialisation arguments[%s]",
+                               args);
+               return -EINVAL;
+       }
 
        return cryptodev_aesni_mb_create(name, vdev, &init_params);
 }
@@ -783,16 +1203,18 @@ cryptodev_aesni_mb_probe(struct rte_vdev_device *vdev)
 static int
 cryptodev_aesni_mb_remove(struct rte_vdev_device *vdev)
 {
+       struct rte_cryptodev *cryptodev;
        const char *name;
 
        name = rte_vdev_device_name(vdev);
        if (name == NULL)
                return -EINVAL;
 
-       RTE_LOG(INFO, PMD, "Closing AESNI crypto device %s on numa socket %u\n",
-                       name, rte_socket_id());
+       cryptodev = rte_cryptodev_pmd_get_named_dev(name);
+       if (cryptodev == NULL)
+               return -ENODEV;
 
-       return 0;
+       return rte_cryptodev_pmd_destroy(cryptodev);
 }
 
 static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
@@ -800,9 +1222,18 @@ static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
        .remove = cryptodev_aesni_mb_remove
 };
 
+static struct cryptodev_driver aesni_mb_crypto_drv;
+
 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd_drv);
 RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
        "max_nb_queue_pairs=<int> "
-       "max_nb_sessions=<int> "
        "socket_id=<int>");
+RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_mb_crypto_drv,
+               cryptodev_aesni_mb_pmd_drv.driver,
+               cryptodev_driver_id);
+
+RTE_INIT(aesni_mb_init_log)
+{
+       aesni_mb_logtype_driver = rte_log_register("pmd.crypto.aesni_mb");
+}