All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cryptodev: make crypto session device independent
@ 2017-05-26 18:45 Michal Jastrzebski
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
  0 siblings, 1 reply; 44+ messages in thread
From: Michal Jastrzebski @ 2017-05-26 18:45 UTC (permalink / raw)
  To: dev
  Cc: pablo.de.lara.guarch, deepak.k.jain, declan.doherty, Slawomir Mrozowicz

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Change crypto device's session management to make it device independent
and simplify architecture when session is intended to be used on more than
one device.

Sessions private data is agnostic to underlying device by adding an
indirection in the sessions private data using the crypto identifier.
A single session can contain indirections to multiple device types.

This functionality is integrated with app/test-crypto-perf application.
To complete this task it is necessary to add documentation and integrate
this implementation with app/test, l2fwd-crypto, ipsec-secgw applications.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
---
This patch depends on patch "cryptodev: remove crypto device driver name"
(http://dpdk.org/dev/patchwork/patch/24451/). 
 app/test-crypto-perf/cperf.h                       |   5 +-
 app/test-crypto-perf/cperf_ops.c                   |  26 +-
 app/test-crypto-perf/cperf_ops.h                   |   1 +
 app/test-crypto-perf/cperf_test_latency.c          |   7 +-
 app/test-crypto-perf/cperf_test_latency.h          |   5 +-
 app/test-crypto-perf/cperf_test_throughput.c       |   7 +-
 app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
 app/test-crypto-perf/cperf_test_verify.c           |   7 +-
 app/test-crypto-perf/cperf_test_verify.h           |   5 +-
 app/test-crypto-perf/main.c                        |  37 ++-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  20 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  21 +-
 drivers/crypto/armv8/rte_armv8_pmd.c               |  13 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |   4 +-
 drivers/crypto/kasumi/rte_kasumi_pmd.c             |  21 +-
 drivers/crypto/null/null_crypto_pmd.c              |  19 +-
 drivers/crypto/openssl/rte_openssl_pmd.c           |  14 +-
 drivers/crypto/qat/qat_crypto.c                    |  21 +-
 drivers/crypto/scheduler/scheduler_failover.c      |  26 +-
 .../crypto/scheduler/scheduler_pkt_size_distr.c    |  28 ++-
 drivers/crypto/scheduler/scheduler_pmd_ops.c       |   8 +-
 drivers/crypto/scheduler/scheduler_roundrobin.c    |  27 ++-
 drivers/crypto/snow3g/rte_snow3g_pmd.c             |  21 +-
 drivers/crypto/zuc/rte_zuc_pmd.c                   |  20 +-
 lib/librte_cryptodev/rte_cryptodev.c               | 268 ++++++++++++---------
 lib/librte_cryptodev/rte_cryptodev.h               | 108 +++++----
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |  15 ++
 lib/librte_cryptodev/rte_cryptodev_version.map     |   2 +
 28 files changed, 446 insertions(+), 315 deletions(-)

diff --git a/app/test-crypto-perf/cperf.h b/app/test-crypto-perf/cperf.h
index 293ba94..42070d6 100644
--- a/app/test-crypto-perf/cperf.h
+++ b/app/test-crypto-perf/cperf.h
@@ -41,7 +41,10 @@ struct cperf_options;
 struct cperf_test_vector;
 struct cperf_op_fns;
 
-typedef void  *(*cperf_constructor_t)(uint8_t dev_id, uint16_t qp_id,
+typedef void  *(*cperf_constructor_t)(
+		struct rte_cryptodev_sym_session *sess,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *t_vec,
 		const struct cperf_op_fns *op_fns);
diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index c2c3db5..8f05dbd 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -334,13 +334,13 @@ cperf_set_ops_aead(struct rte_crypto_op **ops,
 }
 
 static struct rte_cryptodev_sym_session *
-cperf_create_session(uint8_t dev_id,
+cperf_create_session(struct rte_cryptodev_sym_session *sess,
+	uint8_t dev_id,
 	const struct cperf_options *options,
 	const struct cperf_test_vector *test_vector)
 {
 	struct rte_crypto_sym_xform cipher_xform;
 	struct rte_crypto_sym_xform auth_xform;
-	struct rte_cryptodev_sym_session *sess = NULL;
 
 	/*
 	 * cipher only
@@ -362,7 +362,7 @@ cperf_create_session(uint8_t dev_id,
 			cipher_xform.cipher.key.length = 0;
 		}
 		/* create crypto session */
-		sess = rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &cipher_xform);
 	/*
 	 *  auth only
 	 */
@@ -388,7 +388,7 @@ cperf_create_session(uint8_t dev_id,
 			auth_xform.auth.key.data = NULL;
 		}
 		/* create crypto session */
-		sess =  rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &auth_xform);
 	/*
 	 * cipher and auth
 	 */
@@ -452,29 +452,31 @@ cperf_create_session(uint8_t dev_id,
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 				cipher_xform.next = &auth_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-					&cipher_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &cipher_xform);
+
 			} else { /* decrypt */
 				auth_xform.next = &cipher_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-					&auth_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &auth_xform);
 			}
 		} else { /* create crypto session for other */
 			/* cipher then auth */
 			if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
 				cipher_xform.next = &auth_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-						&cipher_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &cipher_xform);
 			} else { /* auth then cipher */
 				auth_xform.next = &cipher_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-						&auth_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &auth_xform);
 			}
 		}
 	}
+
 	return sess;
 }
 
diff --git a/app/test-crypto-perf/cperf_ops.h b/app/test-crypto-perf/cperf_ops.h
index 1b748da..76abdf2 100644
--- a/app/test-crypto-perf/cperf_ops.h
+++ b/app/test-crypto-perf/cperf_ops.h
@@ -41,6 +41,7 @@
 
 
 typedef struct rte_cryptodev_sym_session *(*cperf_sessions_create_t)(
+		struct rte_cryptodev_sym_session *sess,
 		uint8_t dev_id, const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector);
 
diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c
index e61ac97..1a309b6 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -76,7 +76,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -187,7 +187,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(struct rte_cryptodev_sym_session *sess,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -207,7 +208,7 @@ cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_latency.h b/app/test-crypto-perf/cperf_test_latency.h
index 6a2cf61..ddd7404 100644
--- a/app/test-crypto-perf/cperf_test_latency.h
+++ b/app/test-crypto-perf/cperf_test_latency.h
@@ -43,7 +43,10 @@
 #include "cperf_test_vectors.h"
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(
+		struct rte_cryptodev_sym_session *sess,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 61b27ea..bcf64fc 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -65,7 +65,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -175,7 +175,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(struct rte_cryptodev_sym_session *sess,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -195,7 +196,7 @@ cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_throughput.h b/app/test-crypto-perf/cperf_test_throughput.h
index f1b5766..9a8545e 100644
--- a/app/test-crypto-perf/cperf_test_throughput.h
+++ b/app/test-crypto-perf/cperf_test_throughput.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(
+		struct rte_cryptodev_sym_session *sess,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 454221e..287dabb 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -69,7 +69,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -179,7 +179,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(struct rte_cryptodev_sym_session *sess,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -199,7 +200,7 @@ cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_verify.h b/app/test-crypto-perf/cperf_test_verify.h
index 3fa78ee..f324656 100644
--- a/app/test-crypto-perf/cperf_test_verify.h
+++ b/app/test-crypto-perf/cperf_test_verify.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(
+		struct rte_cryptodev_sym_session *sess,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 9ec2a4b..f889acb 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -43,6 +43,9 @@ const struct cperf_test cperf_testmap[] = {
 		}
 };
 
+static struct rte_mempool *cperf_mempool;
+static struct rte_cryptodev_sym_session *cperf_session;
+
 static int
 cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 {
@@ -66,20 +69,21 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		return -EINVAL;
 	}
 
+	struct rte_cryptodev_config conf = {
+			.nb_queue_pairs = 1,
+			.socket_id = SOCKET_ID_ANY,
+			.session_mp = {
+				.nb_objs = 2048,
+				.cache_size = 64
+			}
+		};
+	struct rte_cryptodev_qp_conf qp_conf = {
+			.nb_descriptors = 2048
+	};
+
 	for (cdev_id = 0; cdev_id < enabled_cdev_count &&
 			cdev_id < RTE_CRYPTO_MAX_DEVS; cdev_id++) {
 
-		struct rte_cryptodev_config conf = {
-				.nb_queue_pairs = 1,
-				.socket_id = SOCKET_ID_ANY,
-				.session_mp = {
-					.nb_objs = 2048,
-					.cache_size = 64
-				}
-			};
-		struct rte_cryptodev_qp_conf qp_conf = {
-				.nb_descriptors = 2048
-		};
 
 		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf);
 		if (ret < 0) {
@@ -104,6 +108,14 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		}
 	}
 
+	cperf_mempool = rte_cryptodev_sym_session_pool_create(
+			conf.session_mp.nb_objs,
+			enabled_cdevs,
+			enabled_cdev_count,
+			0, rte_socket_id());
+
+	cperf_session = rte_cryptodev_sym_session_create(cperf_mempool);
+
 	return enabled_cdev_count;
 }
 
@@ -367,7 +379,8 @@ main(int argc, char **argv)
 
 		cdev_id = enabled_cdevs[i];
 
-		ctx[cdev_id] = cperf_testmap[opts.test].constructor(cdev_id, 0,
+		ctx[cdev_id] = cperf_testmap[opts.test].constructor(
+				cperf_session, cdev_id, 0,
 				&opts, t_vec, &op_fns);
 		if (ctx[cdev_id] == NULL) {
 			RTE_LOG(ERR, USER1, "Test run constructor failed\n");
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index b2a0606..9975f1f 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -145,19 +145,20 @@ aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_sym_op *op)
 	struct aesni_gcm_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session->driver_id !=
-				cryptodev_driver_id))
-			return sess;
-
-		sess = (struct aesni_gcm_session *)op->session->_private;
-	} else  {
+		if (likely(op->session != NULL))
+			sess = (struct aesni_gcm_session *)
+					get_session_private_data(
+					op->session,
+					cryptodev_driver_id);
+	} else {
 		void *_sess;
 
 		if (rte_mempool_get(qp->sess_mp, &_sess))
 			return sess;
 
 		sess = (struct aesni_gcm_session *)
-			((struct rte_cryptodev_sym_session *)_sess)->_private;
+				get_session_private_data(_sess,
+				cryptodev_driver_id);
 
 		if (unlikely(aesni_gcm_set_session_parameters(sess,
 				op->xform) != 0)) {
@@ -330,8 +331,9 @@ post_process_gcm_crypto_op(struct rte_crypto_op *op)
 {
 	struct rte_mbuf *m = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
 
-	struct aesni_gcm_session *session =
-		(struct aesni_gcm_session *)op->sym->session->_private;
+	struct aesni_gcm_session *session = (struct aesni_gcm_session *)
+			get_session_private_data(op->sym->session,
+			cryptodev_driver_id);
 
 	op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 9a701ce..ab854f1 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -347,20 +347,19 @@ 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->driver_id !=
-				cryptodev_driver_id)) {
-			return NULL;
-		}
-
-		sess = (struct aesni_mb_session *)op->sym->session->_private;
-	} else  {
+		if (likely(op->sym->session != NULL))
+			sess = (struct aesni_mb_session *)
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
 		void *_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
 			return NULL;
 
-		sess = (struct aesni_mb_session *)
-			((struct rte_cryptodev_sym_session *)_sess)->_private;
+		sess = (struct aesni_mb_session *) get_session_private_data(
+				_sess, cryptodev_driver_id);
 
 		if (unlikely(aesni_mb_set_session_parameters(qp->op_fns,
 				sess, op->sym->xform) != 0)) {
@@ -533,7 +532,9 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
 
 			if (job->hash_alg != NULL_HASH) {
 				sess = (struct aesni_mb_session *)
-						op->sym->session->_private;
+						get_session_private_data(
+						op->sym->session,
+						cryptodev_driver_id);
 
 				if (sess->auth.operation ==
 						RTE_CRYPTO_AUTH_OP_VERIFY)
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index 17dde0b..fdf56ef 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -548,20 +548,19 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id)) {
+		if (likely(op->sym->session != NULL))
 			sess = (struct armv8_crypto_session *)
-				op->sym->session->_private;
-		}
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
 	} else {
 		/* provide internal session */
 		void *_sess = NULL;
 
 		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
 			sess = (struct armv8_crypto_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
+					get_session_private_data(_sess,
+					cryptodev_driver_id);
 
 			if (unlikely(armv8_crypto_set_session_parameters(
 					sess, op->sym->xform) != 0)) {
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 5bb9041..175a591 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -465,7 +465,9 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
 			/*Clear the unused FD fields before sending*/
 			memset(&fd_arr[loop], 0, sizeof(struct qbman_fd));
 			sess = (dpaa2_sec_session *)
-				(*ops)->sym->session->_private;
+					get_session_private_data(
+					(*ops)->sym->session,
+					cryptodev_driver_id);
 			mb_pool = (*ops)->sym->m_src->pool;
 			bpid = mempool_to_bpid(mb_pool);
 			ret = build_sec_fd(sess, *ops, &fd_arr[loop], bpid);
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index aa7eab5..a11596c 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -142,21 +142,22 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
 static struct kasumi_session *
 kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 {
-	struct kasumi_session *sess;
+	struct kasumi_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
-		sess = (struct kasumi_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct kasumi_session *)
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
+		void *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct kasumi_session *)c_sess->_private;
+		sess = (struct kasumi_session *)get_session_private_data(
+				c_sess, cryptodev_driver_id);
 
 		if (unlikely(kasumi_set_session_parameters(sess,
 				op->sym->xform) != 0))
@@ -300,7 +301,7 @@ process_kasumi_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = ops[i]->sym->auth.digest.data;
 
 			sso_kasumi_f9_1_buffer_user(&session->pKeySched_hash,
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 6788865..65ee16c 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -93,21 +93,22 @@ process_op(const struct null_crypto_qp *qp, struct rte_crypto_op *op,
 static struct null_crypto_session *
 get_session(struct null_crypto_qp *qp, struct rte_crypto_sym_op *op)
 {
-	struct null_crypto_session *sess;
+	struct null_crypto_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session == NULL || op->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
-		sess = (struct null_crypto_session *)op->session->_private;
-	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		if (likely(op->session != NULL))
+			sess = (struct null_crypto_session *)
+					get_session_private_data(
+					op->session, cryptodev_driver_id);
+	} else {
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct null_crypto_session *)c_sess->_private;
+		sess = (struct null_crypto_session *)
+				get_session_private_data(
+				c_sess, cryptodev_driver_id);
 
 		if (null_crypto_set_session_parameters(sess, op->xform)	!= 0)
 			return NULL;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index eb5dda3..c5b63dc 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -449,19 +449,19 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id))
+		if (likely(op->sym->session != NULL))
 			sess = (struct openssl_session *)
-				op->sym->session->_private;
-	} else  {
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
 		/* provide internal session */
 		void *_sess = NULL;
 
 		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
 			sess = (struct openssl_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
+					get_session_private_data(_sess,
+					cryptodev_driver_id);
 
 			if (unlikely(openssl_set_session_parameters(
 					sess, op->sym->xform) != 0)) {
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index 9dc3150..12b8c7f 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -60,6 +60,7 @@
 #include <rte_spinlock.h>
 #include <rte_hexdump.h>
 #include <rte_crypto_sym.h>
+#include <rte_cryptodev_pmd.h>
 #include <openssl/evp.h>
 
 #include "qat_logs.h"
@@ -808,7 +809,10 @@ qat_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops,
 			rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
 		} else {
 			struct qat_session *sess = (struct qat_session *)
-						(rx_op->sym->session->_private);
+					get_session_private_data(
+					rx_op->sym->session,
+					cryptodev_qat_driver_id);
+
 			if (sess->bpi_ctx)
 				qat_bpicipher_postprocess(sess, rx_op);
 			rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
@@ -898,7 +902,6 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 	uint64_t src_buf_start = 0, dst_buf_start = 0;
 	uint8_t do_sgl = 0;
 
-
 #ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX
 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
 		PMD_DRV_LOG(ERR, "QAT PMD only supports symmetric crypto "
@@ -913,13 +916,14 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	if (unlikely(op->sym->session->driver_id !=
-			cryptodev_qat_driver_id)) {
+	ctx = (struct qat_session *)get_session_private_data(
+			op->sym->session, cryptodev_qat_driver_id);
+
+	if (unlikely(ctx != NULL)) {
 		PMD_DRV_LOG(ERR, "Session was not created for this device");
 		return -EINVAL;
 	}
 
-	ctx = (struct qat_session *)op->sym->session->_private;
 	qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
 	rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
 	qat_req->comn_mid.opaque_data = (uint64_t)(uintptr_t)op;
@@ -1200,12 +1204,11 @@ static inline uint32_t adf_modulo(uint32_t data, uint32_t shift)
 void qat_crypto_sym_session_init(struct rte_mempool *mp, void *sym_sess)
 {
 	struct rte_cryptodev_sym_session *sess = sym_sess;
-	struct qat_session *s = (void *)sess->_private;
+	struct qat_session *s = (struct qat_session *)get_session_private_data(
+			sess, cryptodev_qat_driver_id);
 
 	PMD_INIT_FUNC_TRACE();
-	s->cd_paddr = rte_mempool_virt2phy(mp, sess) +
-		offsetof(struct qat_session, cd) +
-		offsetof(struct rte_cryptodev_sym_session, _private);
+	s->cd_paddr = rte_mempool_virt2phy(mp, sess);
 }
 
 int qat_dev_config(__rte_unused struct rte_cryptodev *dev,
diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c
index 2471a5f..2989be1 100644
--- a/drivers/crypto/scheduler/scheduler_failover.c
+++ b/drivers/crypto/scheduler/scheduler_failover.c
@@ -31,6 +31,7 @@
  */
 
 #include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
 #include <rte_malloc.h>
 
 #include "rte_cryptodev_scheduler_operations.h"
@@ -65,14 +66,18 @@ failover_slave_enqueue(struct scheduler_slave *slave, uint8_t slave_idx,
 		rte_prefetch0(ops[i + 6]->sym->session);
 		rte_prefetch0(ops[i + 7]->sym->session);
 
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
+		sess0 = (struct scheduler_session *)get_session_private_data(
+				ops[i]->sym->session,
+				cryptodev_scheduler_driver_id);
+		sess1 = (struct scheduler_session *)get_session_private_data(
+				ops[i+1]->sym->session,
+				cryptodev_scheduler_driver_id);
+		sess2 = (struct scheduler_session *)get_session_private_data(
+				ops[i+2]->sym->session,
+				cryptodev_scheduler_driver_id);
+		sess3 = (struct scheduler_session *)get_session_private_data(
+				ops[i+3]->sym->session,
+				cryptodev_scheduler_driver_id);
 
 		sessions[i] = ops[i]->sym->session;
 		sessions[i + 1] = ops[i + 1]->sym->session;
@@ -86,8 +91,9 @@ failover_slave_enqueue(struct scheduler_slave *slave, uint8_t slave_idx,
 	}
 
 	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
+		sess0 = (struct scheduler_session *)get_session_private_data(
+				ops[i]->sym->session,
+				cryptodev_scheduler_driver_id);
 		sessions[i] = ops[i]->sym->session;
 		ops[i]->sym->session = sess0->sessions[slave_idx];
 	}
diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
index 6b628df..2b61f41 100644
--- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
+++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
@@ -31,6 +31,7 @@
  */
 
 #include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
 #include <rte_malloc.h>
 
 #include "rte_cryptodev_scheduler_operations.h"
@@ -97,8 +98,9 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		rte_prefetch0(ops[i + 7]->sym);
 		rte_prefetch0(ops[i + 7]->sym->session);
 
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
+		sess = (struct scheduler_session *)get_session_private_data(
+				ops[i]->sym->session,
+				cryptodev_scheduler_driver_id);
 		/* job_len is initialized as cipher data length, once
 		 * it is 0, equals to auth data length
 		 */
@@ -121,8 +123,10 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		ops[i]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
+		sess = (struct scheduler_session *)get_session_private_data(
+				ops[i+1]->sym->session,
+				cryptodev_scheduler_driver_id);
+
 		job_len = ops[i+1]->sym->cipher.data.length;
 		job_len += (ops[i+1]->sym->cipher.data.length == 0) *
 				ops[i+1]->sym->auth.data.length;
@@ -138,8 +142,10 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		ops[i+1]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
+		sess = (struct scheduler_session *)get_session_private_data(
+				ops[i+2]->sym->session,
+				cryptodev_scheduler_driver_id);
+
 		job_len = ops[i+2]->sym->cipher.data.length;
 		job_len += (ops[i+2]->sym->cipher.data.length == 0) *
 				ops[i+2]->sym->auth.data.length;
@@ -155,8 +161,9 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		ops[i+2]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
+		sess = (struct scheduler_session *)get_session_private_data(
+				ops[i+3]->sym->session,
+				cryptodev_scheduler_driver_id);
 
 		job_len = ops[i+3]->sym->cipher.data.length;
 		job_len += (ops[i+3]->sym->cipher.data.length == 0) *
@@ -175,8 +182,9 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	}
 
 	for (; i < nb_ops; i++) {
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
+		sess = (struct scheduler_session *)get_session_private_data(
+				ops[i]->sym->session,
+				cryptodev_scheduler_driver_id);
 
 		job_len = ops[i]->sym->cipher.data.length;
 		job_len += (ops[i]->sym->cipher.data.length == 0) *
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index 1f91bce..8dd3edd 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -501,15 +501,13 @@ config_slave_sess(struct scheduler_ctx *sched_ctx,
 			if (create)
 				continue;
 			/* !create */
-			sess->sessions[i] = rte_cryptodev_sym_session_free(
-					slave->dev_id, sess->sessions[i]);
+			rte_cryptodev_sym_session_free(sess->sessions[i]);
 		} else {
 			if (!create)
 				continue;
 			/* create */
-			sess->sessions[i] =
-					rte_cryptodev_sym_session_create(
-							slave->dev_id, xform);
+			rte_cryptodev_sym_session_init(slave->dev_id,
+					sess->sessions[i], xform);
 			if (!sess->sessions[i]) {
 				config_slave_sess(sched_ctx, NULL, sess, 0);
 				return -1;
diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c
index 0116276..08b4b4f 100644
--- a/drivers/crypto/scheduler/scheduler_roundrobin.c
+++ b/drivers/crypto/scheduler/scheduler_roundrobin.c
@@ -31,6 +31,7 @@
  */
 
 #include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
 #include <rte_malloc.h>
 
 #include "rte_cryptodev_scheduler_operations.h"
@@ -62,14 +63,18 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		rte_prefetch0(ops[i]->sym->session);
 
 	for (i = 0; (i < (nb_ops - 8)) && (nb_ops > 8); i += 4) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
+		sess0 = (struct scheduler_session *)get_session_private_data(
+				ops[i]->sym->session,
+				cryptodev_scheduler_driver_id);
+		sess1 = (struct scheduler_session *)get_session_private_data(
+				ops[i+1]->sym->session,
+				cryptodev_scheduler_driver_id);
+		sess2 = (struct scheduler_session *)get_session_private_data(
+				ops[i+2]->sym->session,
+				cryptodev_scheduler_driver_id);
+		sess3 = (struct scheduler_session *)get_session_private_data(
+				ops[i+3]->sym->session,
+				cryptodev_scheduler_driver_id);
 
 		sessions[i] = ops[i]->sym->session;
 		sessions[i + 1] = ops[i + 1]->sym->session;
@@ -88,8 +93,10 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	}
 
 	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
+		sess0 = (struct scheduler_session *)get_session_private_data(
+				ops[i]->sym->session,
+				cryptodev_scheduler_driver_id);
+
 		sessions[i] = ops[i]->sym->session;
 		ops[i]->sym->session = sess0->sessions[slave_idx];
 	}
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 7db6409..9f4bb04 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -142,21 +142,22 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
 static struct snow3g_session *
 snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 {
-	struct snow3g_session *sess;
+	struct snow3g_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
-		sess = (struct snow3g_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct snow3g_session *)
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
+		void *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct snow3g_session *)c_sess->_private;
+		sess = (struct snow3g_session *)get_session_private_data(
+				c_sess,	cryptodev_driver_id);
 
 		if (unlikely(snow3g_set_session_parameters(sess,
 				op->sym->xform) != 0))
@@ -289,7 +290,7 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = ops[i]->sym->auth.digest.data;
 
 			sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 5d50bab..99a9e35 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -141,21 +141,21 @@ zuc_set_session_parameters(struct zuc_session *sess,
 static struct zuc_session *
 zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 {
-	struct zuc_session *sess;
+	struct zuc_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
-		sess = (struct zuc_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct zuc_session *)get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
+		void *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct zuc_session *)c_sess->_private;
+		sess = (struct zuc_session *)get_session_private_data(c_sess,
+				cryptodev_driver_id);
 
 		if (unlikely(zuc_set_session_parameters(sess,
 				op->sym->xform) != 0))
@@ -280,7 +280,7 @@ process_zuc_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = (uint32_t *)ops[i]->sym->auth.digest.data;
 
 			sso_zuc_eia3_1_buffer(session->pKey_hash,
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index b8e1018..8f30114 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -934,10 +934,6 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
 
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id);
-
 int
 rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 {
@@ -968,14 +964,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		return diag;
 	}
 
-	/* Setup Session mempool for device */
-	diag = rte_cryptodev_sym_session_pool_create(dev,
-			config->session_mp.nb_objs,
-			config->session_mp.cache_size,
-			config->socket_id);
-	if (diag != 0)
-		return diag;
-
 	return (*dev->dev_ops->dev_configure)(dev, config);
 }
 
@@ -1280,65 +1268,154 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 	rte_spinlock_unlock(&rte_cryptodev_cb_lock);
 }
 
+static inline void
+set_session_private_data(struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id, void *private_data) {
+	sess->sess_private_data[driver_id] = private_data;
+}
 
-static void
-rte_cryptodev_sym_session_init(struct rte_mempool *mp,
-		void *opaque_arg,
-		void *_sess,
-		__rte_unused unsigned i)
-{
-	struct rte_cryptodev_sym_session *sess = _sess;
-	struct rte_cryptodev *dev = opaque_arg;
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_crypto_sym_xform *xforms) {
+
+	struct rte_cryptodev *dev;
+	void *sess_private_data;
+	int index;
 
-	memset(sess, 0, mp->elt_size);
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+	/* No more than 32 device types are expected */
+	index = dev->driver_id;
+
+	if ((sess->sess_mask & (1 << index)) == 0) {
+		sess->sess_mask |= (1 << index);
+
+		if (rte_mempool_get(sess->mp, &sess_private_data)) {
+			CDEV_LOG_ERR(
+				"Couldn't get object from session mempool");
+			return -1;
+		}
+
+		if (dev->dev_ops->session_initialize)
+			(*dev->dev_ops->session_initialize)(sess->mp, sess);
 
-	sess->dev_id = dev->data->dev_id;
-	sess->driver_id = dev->driver_id;
-	sess->mp = mp;
+		if (dev->dev_ops->session_configure(dev, xforms,
+				sess_private_data) == NULL) {
+			CDEV_LOG_ERR(
+				"dev_id %d failed to configure session details",
+				dev_id);
+
+			/* Return session to mempool */
+			rte_mempool_put(sess->mp, sess_private_data);
+			return -1;
+		}
+
+		set_session_private_data(sess, dev->driver_id,
+				sess_private_data);
+	}
 
-	if (dev->dev_ops->session_initialize)
-		(*dev->dev_ops->session_initialize)(mp, sess);
+	return 0;
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id)
+struct rte_mempool *
+rte_cryptodev_sym_session_pool_create(uint32_t nb_objs,
+		uint8_t *device_ids,
+		uint8_t nb_device_ids,
+		uint32_t obj_cache_size,
+		uint8_t socket_id)
 {
+	unsigned int max_priv_sess_size =
+			sizeof(struct rte_cryptodev_sym_session);
+	unsigned int priv_sess_size;
+	unsigned int dev_id, i;
+	struct rte_cryptodev *dev;
+	struct rte_mempool *mempool;
+
 	char mp_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-	unsigned priv_sess_size;
 
-	unsigned n = snprintf(mp_name, sizeof(mp_name), "cdev_%d_sess_mp",
-			dev->data->dev_id);
+	unsigned int n = snprintf(mp_name, sizeof(mp_name),
+			"rte_cryptodev_%d_sess_mp",
+			socket_id);
 	if (n > sizeof(mp_name)) {
 		CDEV_LOG_ERR("Unable to create unique name for session mempool");
-		return -ENOMEM;
+		return NULL;
 	}
 
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_get_size, -ENOTSUP);
-	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
-	if (priv_sess_size == 0) {
-		CDEV_LOG_ERR("%s returned and invalid private session size ",
+	if (device_ids == NULL) {
+
+		/* Walk through all devices */
+		for (dev_id = 0; dev_id < rte_cryptodev_globals->nb_devs;
+				dev_id++) {
+
+			if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+				continue;
+
+			dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+			if (*dev->dev_ops->session_get_size == NULL)
+				continue;
+
+			priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
+
+			if (priv_sess_size == 0) {
+				CDEV_LOG_ERR("%s returned and invalid private "
+						"session size ",
 						dev->data->name);
-		return -ENOMEM;
+				return NULL;
+			}
+
+			if (max_priv_sess_size < priv_sess_size)
+				max_priv_sess_size = priv_sess_size;
+
+		}
+	} else {
+		for (i = 0; i < nb_device_ids; i++) {
+
+			if (!rte_cryptodev_pmd_is_valid_dev(device_ids[i]))
+				continue;
+
+			dev = rte_cryptodev_pmd_get_dev(device_ids[i]);
+
+			if (*dev->dev_ops->session_get_size == NULL)
+				continue;
+
+			priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
+
+			if (priv_sess_size == 0) {
+				CDEV_LOG_ERR("%s returned and invalid private "
+						"session size ",
+						dev->data->name);
+				return NULL;
+			}
+
+			if (max_priv_sess_size < priv_sess_size)
+				max_priv_sess_size = priv_sess_size;
+
+		}
 	}
 
-	unsigned elt_size = sizeof(struct rte_cryptodev_sym_session) +
-			priv_sess_size;
+	if (max_priv_sess_size == 0) {
+		CDEV_LOG_ERR("Cannot determinate maximal private data");
+		return NULL;
+	}
 
-	dev->data->session_pool = rte_mempool_lookup(mp_name);
-	if (dev->data->session_pool != NULL) {
-		if ((dev->data->session_pool->elt_size != elt_size) ||
-				(dev->data->session_pool->cache_size <
+	unsigned int elt_size = max_priv_sess_size;
+
+	mempool = rte_mempool_lookup(mp_name);
+	if (mempool != NULL) {
+		if ((mempool->elt_size != elt_size) ||
+				(mempool->cache_size <
 				obj_cache_size) ||
-				(dev->data->session_pool->size < nb_objs)) {
+				(mempool->size < nb_objs)) {
 
 			CDEV_LOG_ERR("%s mempool already exists with different"
 					" initialization parameters", mp_name);
-			dev->data->session_pool = NULL;
-			return -ENOMEM;
+			mempool = NULL;
+			return NULL;
 		}
 	} else {
-		dev->data->session_pool = rte_mempool_create(
+		mempool = rte_mempool_create(
 				mp_name, /* mempool name */
 				nb_objs, /* number of elements*/
 				elt_size, /* element size*/
@@ -1346,77 +1423,65 @@ rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
 				0, /* private data size */
 				NULL, /* obj initialization constructor */
 				NULL, /* obj initialization constructor arg */
-				rte_cryptodev_sym_session_init,
+				NULL /* rte_crypto_sym_session_init */,
 				/**< obj constructor*/
-				dev, /* obj constructor arg */
+				NULL /* dev */, /* obj constructor arg */
 				socket_id, /* socket id */
 				0); /* flags */
 
-		if (dev->data->session_pool == NULL) {
+		if (mempool == NULL) {
 			CDEV_LOG_ERR("%s mempool allocation failed", mp_name);
-			return -ENOMEM;
+			return NULL;
 		}
 	}
 
 	CDEV_LOG_DEBUG("%s mempool created!", mp_name);
-	return 0;
+
+	return mempool;
 }
 
 struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform)
-{
-	struct rte_cryptodev *dev;
+rte_cryptodev_sym_session_create(struct rte_mempool *mempool) {
 	struct rte_cryptodev_sym_session *sess;
 	void *_sess;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return NULL;
-	}
-
-	dev = &rte_crypto_devices[dev_id];
-
 	/* Allocate a session structure from the session pool */
-	if (rte_mempool_get(dev->data->session_pool, &_sess)) {
+	if (rte_mempool_get(mempool, &_sess)) {
 		CDEV_LOG_ERR("Couldn't get object from session mempool");
 		return NULL;
 	}
 
 	sess = _sess;
-
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL);
-	if (dev->dev_ops->session_configure(dev, xform, sess->_private) ==
-			NULL) {
-		CDEV_LOG_ERR("dev_id %d failed to configure session details",
-				dev_id);
-
-		/* Return session to mempool */
-		rte_mempool_put(sess->mp, _sess);
-		return NULL;
-	}
+	sess->mp = mempool;
 
 	return sess;
 }
 
+void
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) {
+	if (sess != NULL)
+		sess->mp = NULL;
+}
+
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0);
-	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) {
+	if (dev->dev_ops->qp_attach_session(dev, qp_id,
+			(void *)get_session_private_data(sess, dev_id))) {
 		CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
@@ -1424,54 +1489,29 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
 }
 
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0);
-	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) {
+	if (dev->dev_ops->qp_detach_session(dev, qp_id,
+			(void *)get_session_private_data(sess, dev_id))) {
 		CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
 	return 0;
 }
-struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
-		struct rte_cryptodev_sym_session *sess)
-{
-	struct rte_cryptodev *dev;
-
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return sess;
-	}
-
-	dev = &rte_crypto_devices[dev_id];
-
-	/* Check the session belongs to this device type */
-	if (sess->driver_id != dev->driver_id)
-		return sess;
-
-	/* Let device implementation clear session material */
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_clear, sess);
-	dev->dev_ops->session_clear(dev, (void *)sess->_private);
-
-	/* Return session to mempool */
-	rte_mempool_put(sess->mp, (void *)sess);
-
-	return NULL;
-}
 
 /** Initialise rte_crypto_op mempool element */
 static void
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 27a3a07..dfec7ea 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -827,67 +827,61 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 }
 
 
+/** Cryptodev maximal number of session private data */
+#define RTE_CRYPTODEV_SESS_PRIVATE_NUM 32
+
 /** Cryptodev symmetric crypto session */
 struct rte_cryptodev_sym_session {
-	RTE_STD_C11
-	struct {
-		uint8_t dev_id;
-		/**< Device Id */
-		uint8_t driver_id;
-		/** Crypto driver identifier session created on */
-		struct rte_mempool *mp;
-		/**< Mempool session allocated from */
-	} __rte_aligned(8);
-	/**< Public symmetric session details */
-
-	__extension__ char _private[0];
-	/**< Private session material */
+	struct rte_mempool *mp;
+	/**< Mempool session allocated from */
+	uint32_t sess_mask;
+	/**< Mask containing which private data is set */
+	void *sess_private_data[RTE_CRYPTODEV_SESS_PRIVATE_NUM];
+	/**< Device type specific session private data */
 };
 
-
-/**
- * Initialise a session for symmetric cryptographic operations.
- *
- * This function is used by the client to initialize immutable
- * parameters of symmetric cryptographic operation.
- * To perform the operation the rte_cryptodev_enqueue_burst function is
- * used.  Each mbuf should contain a reference to the session
- * pointer returned from this function contained within it's crypto_op if a
- * session-based operation is being provisioned. Memory to contain the session
- * information is allocated from within mempool managed by the cryptodev.
- *
- * The rte_cryptodev_session_free must be called to free allocated
- * memory when the session is no longer required.
+/**<
+ * Frees symmetric crypto session and all related device type specific
+ * private data objects associated with session
  *
- * @param	dev_id		The device identifier.
- * @param	xform		Crypto transform chain.
+ * @param   sess     Session where the private data will be attached to
+ */
+void
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
 
+/**<
+ * Fill out private data for the device id, based on its device type
+ *
+ * @param   dev_id   ID of device that we want the session to be used on
+ * @param   sess     Session where the private data will be attached to
+ * @param   xforms   Symmetric crypto transform operations to apply on flow
+ *                   processed with this session
  *
  * @return
- *  Pointer to the created session or NULL
+ *  - On success, zero.
+ *  - On failure, a negative value.
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform);
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_crypto_sym_xform *xforms);
 
-/**
- * Free the memory associated with a previously allocated session.
- *
- * @param	dev_id		The device identifier.
- * @param	session		Session pointer previously allocated by
- *				*rte_cryptodev_sym_session_create*.
+/**<
+ * Create symmetric crypto session (generic with no private data)
  *
+ * @param   mempool    Symmetric session mempool to allocate session
+ *                     objects from
  * @return
- *   NULL on successful freeing of session.
- *   Session pointer on failure to free session.
+ *  - On success return pointer to sym-session
+ *  - On failure returns NULL
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
-		struct rte_cryptodev_sym_session *session);
+struct rte_cryptodev_sym_session *
+rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
 
 /**
  * Attach queue pair with sym session.
  *
+ * @param	dev_id		The identifier of the device.
  * @param	qp_id		Queue pair to which session will be attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
@@ -897,12 +891,13 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
  * Detach queue pair with sym session.
  *
+ * @param	dev_id		The identifier of the device.
  * @param	qp_id		Queue pair to which session is attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
@@ -912,10 +907,30 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
+ * Create session mempool.
+ *
+ * @param	nb_objs		Number of sessions objects in mempool.
+ * @param	device_ids	The table of the devices identifiers.
+ * @param	nb_device_ids	Number of the devices identifiers.
+ * @param	obj_cache_size	l-core object cache size.
+ * @param	socket_id	Socket to allocate memory on
+ *
+ * @return
+ *  - The created mempool pointer on success.
+ *  - NULL on failure.
+ */
+struct rte_mempool *
+rte_cryptodev_sym_session_pool_create(uint32_t nb_objs,
+		uint8_t *device_ids,
+		uint8_t nb_device_ids,
+		uint32_t obj_cache_size,
+		uint8_t socket_id);
+
+/**
  * Provide driver identifier.
  *
  * @param name
@@ -954,7 +969,6 @@ static void init_ ##driver_id(void)\
 	driver_id = rte_cryptodev_allocate_driver_id(RTE_STR(name));\
 }
 
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index fb3972b..79c128f 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -518,6 +518,21 @@ int rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev);
 int
 rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
 
+/**
+ * Provide session private data.
+ *
+ * @param	sess		The cryptodev session
+ * @param	driver_id	The driver identifier
+ *
+ * @return
+ *  void
+ */
+static inline void *
+get_session_private_data(struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id) {
+	return sess->sess_private_data[driver_id];
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 91f2e56..ec4d792 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -81,5 +81,7 @@ DPDK_17.08 {
 	rte_cryptodev_device_count_by_driver;
 	rte_cryptodev_driver_id_get;
 	rte_cryptodev_driver_name_get;
+	rte_cryptodev_sym_session_init;
+	rte_cryptodev_sym_session_pool_create;
 
 } DPDK_17.05;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 00/11] Device independent crypto sessions
  2017-05-26 18:45 [PATCH] cryptodev: make crypto session device independent Michal Jastrzebski
@ 2017-06-30 17:09 ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 01/11] cryptodev: remove unused cryptodev session structure Pablo de Lara
                     ` (11 more replies)
  0 siblings, 12 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Currently, the cryptodev library requires the session mempools
to be created inside each device.
This can be a waste of memory, as several devices with the same
driver could be using the same session.

This patchset makes changes in the library to allow
session to contain multiple driver private data, so it can be
used by multiple devices (no need to be the same driver).

                                  SESSION MEMPOOL <---|---> DEVICE INSTANCES
                                 --------------------------------------------

.-------------.      .----------------------------.
|   Crypto    |.     |         mempool obj        |
| sym-session |<--.  | .--------------------------+
|   mempool   ||  |  | | rte_cryptodev_session    |             .-------------.
`-------------'|  |  | |                          |             |   DEVICE    |
 `-----|-------'  |  | |                          |             |  INSTANCE   |
       |          `-----                          |             | - device id |
       +------------>| | - private data[type idx] |          .--| - session   |
       |             `-+=================|..|====='          |  |   mempool   |
       |                                 |  |                |  `-------------'
       |                                 |  |                |
       |     .----------------------.    |  |                |  .-------------.
       +---->|      mempool obj     |    |  |   .--------.   |  |   DEVICE    |
       |     | .--------------------+    |  |   | DRIVER |   |  |  INSTANCE   |
       |     | | PMD's private data |<---+------| - type |<--+--|             |
       |     +-+====================+       |   `--------'      |     ...     |
       |                                    |                   |             |
       |                                    |                   `-------------'
       |                                    |
       |     .----------------------.       |                   .-------------.
       `---->|      mempool obj     |       |   .--------.      |   DEVICE    |
             | .--------------------+       |   | DRIVER |      |  INSTANCE   |
             | | PMD's private data |<------+---| - type |<-----|             |
             `-+===================='           `--------'      |     ...     |
                                                                |             |
                                                                `-------------'
Crypto sym-session mempool

   Mempool created to store rte_cryptodev_session objects as well as
   private data for supported device types.

   This mempool replaces existing session mempools in device
   instances to ease session management and improve consistency
   (especially if the session is intended to be used for operations
   performed on different devices).

rte_crypto_session

   New rte_cryptodev_session structure is taken from crypto session
   mempool and can store more than one PMD's private data object (one
   for each device type supported by sesion).

   Crypto operations will use device type id (unique for each driver) to
   retrieve private data from rte_crypto_session right for the device
   type they are performed on.

This patchset was based on the changes proposed in RFC
(http://dpdk.org/ml/archives/dev/2017-May/065259.html)

This patchset depends on:
http://dpdk.org/dev/patchwork/patch/26156/

Changes in v2:
- Split the patch in multiple smaller patches to
  facilitate the review
- Removed new API to create the session mempool,
  since mempool can be created directly withe mempool_create
- Session headers and device private sessions can be
  allocated from different mempools, for better memory
  efficiency.
- Added a cover letter (partially extracted from RFC)
  for better clarification on the intention of this patchset

Pablo de Lara (4):
  cryptodev: remove unused cryptodev session structure
  cryptodev: move session init out of session pool creation
  cryptodev: add mempool pointer in queue pair setup
  doc: add new crypto session information

Slawomir Mrozowicz (7):
  cryptodev: add private session size retrieval function
  cryptodev: do not create session mempool internally
  cryptodev: change attach session to queue pair API
  cryptodev: remove dev_id from crypto session
  cryptodev: remove driver id from session
  cryptodev: remove mempool from session
  cryptodev: support device independent sessions

 app/test-crypto-perf/cperf.h                       |   5 +-
 app/test-crypto-perf/cperf_ops.c                   |  30 +-
 app/test-crypto-perf/cperf_ops.h                   |   1 +
 app/test-crypto-perf/cperf_test_latency.c          |   7 +-
 app/test-crypto-perf/cperf_test_latency.h          |   5 +-
 app/test-crypto-perf/cperf_test_throughput.c       |   7 +-
 app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
 app/test-crypto-perf/cperf_test_verify.c           |   7 +-
 app/test-crypto-perf/cperf_test_verify.h           |   5 +-
 app/test-crypto-perf/main.c                        |  42 ++-
 doc/guides/prog_guide/cryptodev_lib.rst            |  59 ++-
 doc/guides/prog_guide/img/cryptodev_sym_sess.svg   | 418 ++++++++++++++++++---
 doc/guides/rel_notes/release_17_08.rst             |  16 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  58 +--
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  32 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  34 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  31 +-
 drivers/crypto/armv8/rte_armv8_pmd.c               |  13 +-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  35 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  56 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd.c             |  20 +-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  32 +-
 drivers/crypto/null/null_crypto_pmd.c              |  17 +-
 drivers/crypto/null/null_crypto_pmd_ops.c          |  35 +-
 drivers/crypto/openssl/rte_openssl_pmd.c           |  14 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  32 +-
 drivers/crypto/qat/qat_crypto.c                    |  66 ++--
 drivers/crypto/qat/qat_crypto.h                    |  15 +-
 drivers/crypto/qat/qat_qp.c                        |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
 drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
 .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 -
 drivers/crypto/scheduler/scheduler_pmd_ops.c       |  84 ++---
 drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
 drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 --
 drivers/crypto/snow3g/rte_snow3g_pmd.c             |  20 +-
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  32 +-
 drivers/crypto/zuc/rte_zuc_pmd.c                   |  19 +-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  32 +-
 examples/ipsec-secgw/ipsec-secgw.c                 |  41 +-
 examples/ipsec-secgw/ipsec.c                       |   8 +-
 examples/ipsec-secgw/ipsec.h                       |   3 +-
 examples/l2fwd-crypto/main.c                       |  55 ++-
 lib/librte_cryptodev/rte_cryptodev.c               | 240 +++++-------
 lib/librte_cryptodev/rte_cryptodev.h               | 101 ++---
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |  38 +-
 lib/librte_cryptodev/rte_cryptodev_version.map     |   3 +
 test/test/test_cryptodev.c                         | 383 ++++++++++++++-----
 test/test/test_cryptodev_blockcipher.c             |  15 +-
 test/test/test_cryptodev_blockcipher.h             |   1 +
 test/test/test_cryptodev_perf.c                    | 198 +++++++---
 51 files changed, 1620 insertions(+), 861 deletions(-)

-- 
2.9.4

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 01/11] cryptodev: remove unused cryptodev session structure
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 02/11] cryptodev: move session init out of session pool creation Pablo de Lara
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Cryptodev session structure was a duplication of the
cryptodev symmetric structure.
It was used by some PMDs that should use the symmetric
structure instead.

Since this structure was internal, there is no deprecation
notice required.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/kasumi/rte_kasumi_pmd.c   |  2 +-
 drivers/crypto/null/null_crypto_pmd.c    |  2 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c   |  2 +-
 drivers/crypto/zuc/rte_zuc_pmd.c         |  2 +-
 examples/ipsec-secgw/ipsec.h             |  1 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 11 -----------
 6 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 648718c..a1a33c5 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -152,7 +152,7 @@ kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct kasumi_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 7ab3570..50ede06 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -103,7 +103,7 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_sym_op *op)
 
 		sess = (struct null_crypto_session *)op->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index fe074c1..35a2bcd 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -152,7 +152,7 @@ snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct snow3g_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index b7b8dfc..ff8f3b9 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -151,7 +151,7 @@ zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct zuc_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index fe42661..1d63161 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -72,7 +72,6 @@
 
 struct rte_crypto_xform;
 struct ipsec_xform;
-struct rte_cryptodev_session;
 struct rte_mbuf;
 
 struct ipsec_sa;
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index f6aa84d..5911b83 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -56,17 +56,6 @@ extern "C" {
 #include "rte_crypto.h"
 #include "rte_cryptodev.h"
 
-struct rte_cryptodev_session {
-	RTE_STD_C11
-	struct {
-		uint8_t dev_id;
-		uint8_t driver_id;
-		struct rte_mempool *mp;
-	} __rte_aligned(8);
-
-	__extension__ char _private[0];
-};
-
 /** Global structure used for maintaining state of allocated crypto devices */
 struct rte_cryptodev_global {
 	struct rte_cryptodev *devs;	/**< Device information array */
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 02/11] cryptodev: move session init out of session pool creation
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 01/11] cryptodev: remove unused cryptodev session structure Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 03/11] cryptodev: add private session size retrieval function Pablo de Lara
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Prior to removing the session pool creation from cryptodev
configure function, session init function needs to be
separated from the pool creation.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 17f7c63..d1e0ecc 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1030,13 +1030,9 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 
 static void
 rte_cryptodev_sym_session_init(struct rte_mempool *mp,
-		void *opaque_arg,
-		void *_sess,
-		__rte_unused unsigned i)
+		struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	struct rte_cryptodev_sym_session *sess = _sess;
-	struct rte_cryptodev *dev = opaque_arg;
-
 	memset(sess, 0, mp->elt_size);
 
 	sess->dev_id = dev->data->dev_id;
@@ -1093,8 +1089,7 @@ rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
 				0, /* private data size */
 				NULL, /* obj initialization constructor */
 				NULL, /* obj initialization constructor arg */
-				rte_cryptodev_sym_session_init,
-				/**< obj constructor*/
+				NULL, /**< obj constructor*/
 				dev, /* obj constructor arg */
 				socket_id, /* socket id */
 				0); /* flags */
@@ -1132,6 +1127,8 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 
 	sess = _sess;
 
+	rte_cryptodev_sym_session_init(dev->data->session_pool, dev,
+					sess);
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL);
 	if (dev->dev_ops->session_configure(dev, xform, sess->_private) ==
 			NULL) {
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 03/11] cryptodev: add private session size retrieval function
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 01/11] cryptodev: remove unused cryptodev session structure Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 02/11] cryptodev: move session init out of session pool creation Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 04/11] cryptodev: do not create session mempool internally Pablo de Lara
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Provide a function to get the private session size
of any crypto device (specifically, to its crypto driver).

This will be useful once the session mempool is created
outside the library.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c           | 20 ++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 12 ++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 +
 3 files changed, 33 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index d1e0ecc..312a740 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1217,6 +1217,26 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 	return NULL;
 }
 
+unsigned int
+rte_cryptodev_get_private_session_size(uint8_t dev_id)
+{
+	struct rte_cryptodev *dev;
+	unsigned int priv_sess_size;
+
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+		return 0;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+	if (*dev->dev_ops->session_get_size == NULL)
+		return 0;
+
+	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
+
+	return priv_sess_size;
+
+}
+
 /** Initialise rte_crypto_op mempool element */
 static void
 rte_crypto_op_init(struct rte_mempool *mempool,
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index ba51329..d883d8c 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -856,6 +856,18 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
+ * Get the size of the private session data for a device.
+ *
+ * @param	dev_id		The device identifier.
+ *
+ * @return
+ *   - Size of the private data, if successful
+ *   - 0 if device is invalid or does not have private session
+ */
+unsigned int
+rte_cryptodev_get_private_session_size(uint8_t dev_id);
+
+/**
  * Attach queue pair with sym session.
  *
  * @param	qp_id		Queue pair to which session will be attached.
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index afe148a..8855a34 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -65,6 +65,7 @@ DPDK_17.08 {
 	rte_cryptodev_device_count_by_driver;
 	rte_cryptodev_driver_id_get;
 	rte_cryptodev_driver_name_get;
+	rte_cryptodev_get_private_session_size;
 	rte_cryptodev_pci_generic_probe;
 	rte_cryptodev_pci_generic_remove;
 	rte_cryptodev_vdev_parse_init_params;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 04/11] cryptodev: do not create session mempool internally
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (2 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 03/11] cryptodev: add private session size retrieval function Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 05/11] cryptodev: change attach session to queue pair API Pablo de Lara
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Instead of creating the session mempool while configuring
the crypto device, apps will create the mempool themselves.
This way, it gives flexibility to the user to have a single
mempool for all devices (as long as the objects are big
enough to contain the biggest private session size) or
separate mempools for different drivers.

Also, since the mempool is now created outside the
device configuration function, now it needs to be passed
through this function, which will be eventually passed
when setting up the queue pairs, as ethernet devices do.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/main.c                  | 33 +++++++++---
 doc/guides/rel_notes/release_17_08.rst       |  2 +
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 12 +----
 examples/ipsec-secgw/ipsec-secgw.c           | 26 +++++++--
 examples/l2fwd-crypto/main.c                 | 29 ++++++++--
 lib/librte_cryptodev/rte_cryptodev.c         | 77 ++------------------------
 lib/librte_cryptodev/rte_cryptodev.h         |  9 ++--
 test/test/test_cryptodev.c                   | 81 ++++++++++++++++++++++------
 test/test/test_cryptodev_perf.c              | 22 +++++++-
 9 files changed, 167 insertions(+), 124 deletions(-)

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 9ec2a4b..9a22925 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -11,6 +11,9 @@
 #include "cperf_test_latency.h"
 #include "cperf_test_verify.h"
 
+#define NUM_SESSIONS 2048
+#define SESS_MEMPOOL_CACHE_SIZE 64
+
 const char *cperf_test_type_strs[] = {
 	[CPERF_TEST_TYPE_THROUGHPUT] = "throughput",
 	[CPERF_TEST_TYPE_LATENCY] = "latency",
@@ -72,16 +75,34 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		struct rte_cryptodev_config conf = {
 				.nb_queue_pairs = 1,
 				.socket_id = SOCKET_ID_ANY,
-				.session_mp = {
-					.nb_objs = 2048,
-					.cache_size = 64
-				}
-			};
+		};
+
 		struct rte_cryptodev_qp_conf qp_conf = {
 				.nb_descriptors = 2048
 		};
 
-		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf);
+		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(enabled_cdevs[cdev_id]);
+
+		char mp_name[RTE_MEMPOOL_NAMESIZE];
+		struct rte_mempool *sess_mp;
+
+		snprintf(mp_name, sizeof(mp_name), "sess_mp_%u", cdev_id);
+		sess_mp = rte_mempool_create(mp_name,
+					NUM_SESSIONS,
+					session_size,
+					SESS_MEMPOOL_CACHE_SIZE,
+					0, NULL, NULL, NULL,
+					NULL, SOCKET_ID_ANY,
+					0);
+
+		if (sess_mp == NULL) {
+			printf("Failed to create device session mempool\n");
+			return -ENOMEM;
+		}
+
+		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf,
+							sess_mp);
 		if (ret < 0) {
 			printf("Failed to configure cryptodev %u",
 					enabled_cdevs[cdev_id]);
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 23f1bae..f5d6289 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -155,6 +155,8 @@ API Changes
 
   * Device type identification is changed to be based on a unique 1-byte driver id,
     replacing the previous device type enumeration.
+  * ``rte_cryptodev_configure()`` does not create the session mempool
+    for the device anymore.
 
 
 ABI Changes
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index 90e3734..b9d8973 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -85,10 +85,8 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
 /** Configure device */
 static int
 scheduler_pmd_config(struct rte_cryptodev *dev,
-		struct rte_cryptodev_config *config)
+		struct rte_cryptodev_config *config __rte_unused)
 {
-	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
-	uint32_t i;
 	int ret;
 
 	/* although scheduler_attach_init_slave presents multiple times,
@@ -98,14 +96,6 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	if (ret < 0)
 		return ret;
 
-	for (i = 0; i < sched_ctx->nb_slaves; i++) {
-		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
-
-		ret = rte_cryptodev_configure(slave_dev_id, config);
-		if (ret < 0)
-			break;
-	}
-
 	return ret;
 }
 
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 8cbf6ac..a2286fd 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1266,11 +1266,29 @@ cryptodevs_init(void)
 
 		dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
 		dev_conf.nb_queue_pairs = qp;
-		dev_conf.session_mp.nb_objs = CDEV_MP_NB_OBJS;
-		dev_conf.session_mp.cache_size = CDEV_MP_CACHE_SZ;
 
-		if (rte_cryptodev_configure(cdev_id, &dev_conf))
-			rte_panic("Failed to initialize crypodev %u\n",
+		char mp_name[RTE_MEMPOOL_NAMESIZE];
+		struct rte_mempool *sess_mp;
+
+		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(cdev_id);
+
+		snprintf(mp_name, sizeof(mp_name), "sess_mp_%u", cdev_id);
+		sess_mp = rte_mempool_create(mp_name,
+					CDEV_MP_NB_OBJS,
+					session_size,
+					CDEV_MP_CACHE_SZ,
+					0, NULL, NULL, NULL,
+					NULL, dev_conf.socket_id,
+					0);
+
+		if (sess_mp == NULL) {
+			printf("Failed to create device session mempool\n");
+			return -ENOMEM;
+		}
+
+		if (rte_cryptodev_configure(cdev_id, &dev_conf, sess_mp))
+			rte_panic("Failed to initialize cryptodev %u\n",
 					cdev_id);
 
 		qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 779b4fb..c3c6f45 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -89,6 +89,9 @@ enum cdev_type {
 #define MAX_PKT_BURST 32
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
 
+#define NUM_SESSIONS 2048
+#define SESS_MEMPOOL_CACHE_SIZE 64
+
 /*
  * Configurable number of RX/TX ring descriptors
  */
@@ -1566,10 +1569,6 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		struct rte_cryptodev_config conf = {
 			.nb_queue_pairs = 1,
 			.socket_id = SOCKET_ID_ANY,
-			.session_mp = {
-				.nb_objs = 2048,
-				.cache_size = 64
-			}
 		};
 
 		if (check_cryptodev_mask(options, (uint8_t)cdev_id))
@@ -1797,7 +1796,27 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 						cap->sym.auth.digest_size.min;
 		}
 
-		retval = rte_cryptodev_configure(cdev_id, &conf);
+		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(enabled_cdevs[cdev_id]);
+
+		char mp_name[RTE_MEMPOOL_NAMESIZE];
+		struct rte_mempool *sess_mp;
+
+		snprintf(mp_name, sizeof(mp_name), "sess_mp_%u", cdev_id);
+		sess_mp = rte_mempool_create(mp_name,
+					NUM_SESSIONS,
+					session_size,
+					SESS_MEMPOOL_CACHE_SIZE,
+					0, NULL, NULL, NULL,
+					NULL, SOCKET_ID_ANY,
+					0);
+
+		if (sess_mp == NULL) {
+			printf("Failed to create device session mempool\n");
+			return -ENOMEM;
+		}
+
+		retval = rte_cryptodev_configure(cdev_id, &conf, sess_mp);
 		if (retval < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -1;
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 312a740..1e8d3b9 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -683,12 +683,9 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
 
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id);
-
 int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
+		struct rte_mempool *session_pool)
 {
 	struct rte_cryptodev *dev;
 	int diag;
@@ -708,6 +705,8 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
+	dev->data->session_pool = session_pool;
+
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
 			config->socket_id);
@@ -717,14 +716,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		return diag;
 	}
 
-	/* Setup Session mempool for device */
-	diag = rte_cryptodev_sym_session_pool_create(dev,
-			config->session_mp.nb_objs,
-			config->session_mp.cache_size,
-			config->socket_id);
-	if (diag != 0)
-		return diag;
-
 	return (*dev->dev_ops->dev_configure)(dev, config);
 }
 
@@ -1043,66 +1034,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 		(*dev->dev_ops->session_initialize)(mp, sess);
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id)
-{
-	char mp_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-	unsigned priv_sess_size;
-
-	unsigned n = snprintf(mp_name, sizeof(mp_name), "cdev_%d_sess_mp",
-			dev->data->dev_id);
-	if (n > sizeof(mp_name)) {
-		CDEV_LOG_ERR("Unable to create unique name for session mempool");
-		return -ENOMEM;
-	}
-
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_get_size, -ENOTSUP);
-	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
-	if (priv_sess_size == 0) {
-		CDEV_LOG_ERR("%s returned and invalid private session size ",
-						dev->data->name);
-		return -ENOMEM;
-	}
-
-	unsigned elt_size = sizeof(struct rte_cryptodev_sym_session) +
-			priv_sess_size;
-
-	dev->data->session_pool = rte_mempool_lookup(mp_name);
-	if (dev->data->session_pool != NULL) {
-		if ((dev->data->session_pool->elt_size != elt_size) ||
-				(dev->data->session_pool->cache_size <
-				obj_cache_size) ||
-				(dev->data->session_pool->size < nb_objs)) {
-
-			CDEV_LOG_ERR("%s mempool already exists with different"
-					" initialization parameters", mp_name);
-			dev->data->session_pool = NULL;
-			return -ENOMEM;
-		}
-	} else {
-		dev->data->session_pool = rte_mempool_create(
-				mp_name, /* mempool name */
-				nb_objs, /* number of elements*/
-				elt_size, /* element size*/
-				obj_cache_size, /* Cache size*/
-				0, /* private data size */
-				NULL, /* obj initialization constructor */
-				NULL, /* obj initialization constructor arg */
-				NULL, /**< obj constructor*/
-				dev, /* obj constructor arg */
-				socket_id, /* socket id */
-				0); /* flags */
-
-		if (dev->data->session_pool == NULL) {
-			CDEV_LOG_ERR("%s mempool allocation failed", mp_name);
-			return -ENOMEM;
-		}
-	}
-
-	CDEV_LOG_DEBUG("%s mempool created!", mp_name);
-	return 0;
-}
 
 struct rte_cryptodev_sym_session *
 rte_cryptodev_sym_session_create(uint8_t dev_id,
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index d883d8c..1afd2d8 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -428,11 +428,6 @@ struct rte_cryptodev_config {
 	int socket_id;			/**< Socket to allocate resources on */
 	uint16_t nb_queue_pairs;
 	/**< Number of queue pairs to configure on device */
-
-	struct {
-		uint32_t nb_objs;	/**< Number of objects in mempool */
-		uint32_t cache_size;	/**< l-core object cache size */
-	} session_mp;		/**< Session mempool configuration */
 };
 
 /**
@@ -444,13 +439,15 @@ struct rte_cryptodev_config {
  *
  * @param	dev_id		The identifier of the device to configure.
  * @param	config		The crypto device configuration structure.
+ * @param	session_pool	Pointer to device session mempool
  *
  * @return
  *   - 0: Success, device configured.
  *   - <0: Error code returned by the driver configuration function.
  */
 extern int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
+		struct rte_mempool *session_pool);
 
 /**
  * Start an device.
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index afa895e..3979145 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -66,6 +66,8 @@ struct crypto_testsuite_params {
 	struct rte_mempool *mbuf_pool;
 	struct rte_mempool *large_mbuf_pool;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *session_mpool;
+	struct rte_mempool *slave_session_mpool;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_qp_conf qp_conf;
 
@@ -381,10 +383,23 @@ testsuite_setup(void)
 
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
+
+	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+		rte_cryptodev_get_private_session_size(dev_id);
+
+	ts_params->session_mpool = rte_mempool_create(
+				"test_sess_mp",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
+			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev %u with %u qps",
 			dev_id, ts_params->conf.nb_queue_pairs);
 
@@ -416,6 +431,12 @@ testsuite_teardown(void)
 		rte_mempool_avail_count(ts_params->op_mpool));
 	}
 
+	/* Free session mempools */
+	if (ts_params->session_mpool != NULL)
+		rte_mempool_free(ts_params->session_mpool);
+
+	if (ts_params->slave_session_mpool != NULL)
+		rte_mempool_free(ts_params->slave_session_mpool);
 }
 
 static int
@@ -431,10 +452,9 @@ ut_setup(void)
 
 	/* Reconfigure device to default parameters */
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -517,20 +537,23 @@ test_device_configure_invalid_dev_id(void)
 	/* Stop the device in case it's started so it can be configured */
 	rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
 
-	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	/* invalid dev_id values */
 	dev_id = num_devs;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	dev_id = 0xff;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure:"
 			"invalid dev_num %u", dev_id);
 
@@ -550,7 +573,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 1;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
 
@@ -559,16 +582,17 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
-			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
+			ts_params->valid_devs[0],
+			ts_params->conf.nb_queue_pairs);
 
 
 	/* invalid - zero queue pairs */
 	ts_params->conf.nb_queue_pairs = 0;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -579,7 +603,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -590,7 +614,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -619,13 +643,11 @@ test_queue_pair_descriptor_setup(void)
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
 
-	ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
-
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf), "Failed to configure cryptodev %u",
+			&ts_params->conf, ts_params->session_mpool),
+			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
-
 	/*
 	 * Test various ring sizes on this device. memzones can't be
 	 * freed so are re-used if ring is released and re-created.
@@ -7837,6 +7859,31 @@ test_scheduler_attach_slave_op(void)
 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
 			continue;
 
+		/*
+		 * Create a separate mempool for the slaves, as they need different
+		 * session size and then configure them to store the pointer
+		 * to this mempool
+		 */
+		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(i);
+
+		if (ts_params->slave_session_mpool == NULL) {
+			ts_params->slave_session_mpool = rte_mempool_create(
+				"test_slave_sess_mp",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL, NULL,
+				SOCKET_ID_ANY, 0);
+
+			TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
+					"session mempool allocation failed");
+		}
+
+		TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
+				&ts_params->conf, ts_params->slave_session_mpool),
+				"Failed to configure cryptodev %u with %u qps",
+				i, ts_params->conf.nb_queue_pairs);
+
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 6553c94..526be82 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -50,6 +50,7 @@
 struct crypto_testsuite_params {
 	struct rte_mempool *mbuf_mp;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *session_mpool;
 
 	uint16_t nb_queue_pairs;
 
@@ -394,10 +395,23 @@ testsuite_setup(void)
 
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
+
+	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+		rte_cryptodev_get_private_session_size(ts_params->dev_id);
+
+	ts_params->session_mpool = rte_mempool_create(
+				"test_sess_mp_perf",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
+			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev %u",
 			ts_params->dev_id);
 
@@ -426,6 +440,10 @@ testsuite_teardown(void)
 	if (ts_params->op_mpool != NULL)
 		RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_OP POOL count %u\n",
 		rte_mempool_avail_count(ts_params->op_mpool));
+	/* Free session mempool */
+	if (ts_params->session_mpool != NULL)
+		rte_mempool_free(ts_params->session_mpool);
+
 }
 
 static int
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 05/11] cryptodev: change attach session to queue pair API
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (3 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 04/11] cryptodev: do not create session mempool internally Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 06/11] cryptodev: remove dev_id from crypto session Pablo de Lara
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Device id is going to be removed from session,
as the session will be device independent.
Therefore, the functions that attach/dettach a session
to a queue pair need to be updated, to accept the device id
as a parameter, apart from the queue pair id and the session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst |  3 +++
 examples/ipsec-secgw/ipsec.c           |  1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 20 ++++++++++----------
 lib/librte_cryptodev/rte_cryptodev.h   | 10 ++++++----
 4 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index f5d6289..fe46d93 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -157,6 +157,9 @@ API Changes
     replacing the previous device type enumeration.
   * ``rte_cryptodev_configure()`` does not create the session mempool
     for the device anymore.
+  * ``rte_cryptodev_queue_pair_attach_sym_session()`` and
+    ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
+    the new parameter ``device id``.
 
 
 ABI Changes
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index edca5f0..048e441 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -77,6 +77,7 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
 	rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
 	if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
 		ret = rte_cryptodev_queue_pair_attach_sym_session(
+				ipsec_ctx->tbl[cdev_id_qp].id,
 				ipsec_ctx->tbl[cdev_id_qp].qp,
 				sa->crypto_session);
 		if (ret < 0) {
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 1e8d3b9..1852ecf 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1075,23 +1075,23 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 }
 
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0);
 	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) {
 		CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
@@ -1099,23 +1099,23 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
 }
 
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0);
 	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) {
 		CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 1afd2d8..d3d2794 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -867,7 +867,8 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id);
 /**
  * Attach queue pair with sym session.
  *
- * @param	qp_id		Queue pair to which session will be attached.
+ * @param	dev_id		Device to which the session will be attached.
+ * @param	qp_id		Queue pair to which the session will be attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
  *
@@ -876,13 +877,14 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id);
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
  * Detach queue pair with sym session.
  *
- * @param	qp_id		Queue pair to which session is attached.
+ * @param	dev_id		Device to which the session is attached.
+ * @param	qp_id		Queue pair to which the session is attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
  *
@@ -891,7 +893,7 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 06/11] cryptodev: remove dev_id from crypto session
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (4 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 05/11] cryptodev: change attach session to queue pair API Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 07/11] cryptodev: remove driver id from session Pablo de Lara
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Device id is necessary in the crypto session,
as it was only used for the functions that attach/detach
a session to a queue pair.

Since the session is not going to be attached to a device
anymore, this is field is no longer necessary.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst | 1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 1 -
 lib/librte_cryptodev/rte_cryptodev.h   | 2 --
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index fe46d93..df66525 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -160,6 +160,7 @@ API Changes
   * ``rte_cryptodev_queue_pair_attach_sym_session()`` and
     ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
     the new parameter ``device id``.
+  * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 1852ecf..0b381ba 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1026,7 +1026,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->dev_id = dev->data->dev_id;
 	sess->driver_id = dev->driver_id;
 	sess->mp = mp;
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index d3d2794..77a763d 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -798,8 +798,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
 	struct {
-		uint8_t dev_id;
-		/**< Device Id */
 		uint8_t driver_id;
 		/** Crypto driver identifier session created on */
 		struct rte_mempool *mp;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 07/11] cryptodev: remove driver id from session
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (5 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 06/11] cryptodev: remove dev_id from crypto session Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 08/11] cryptodev: remove mempool " Pablo de Lara
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Since crypto session will not be attached to a specific
device or driver, the field driver_id is not required
anymore (only used to check that a session was being
handled by the right device).

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst     | 1 +
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 4 ----
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 5 -----
 drivers/crypto/armv8/rte_armv8_pmd.c       | 4 +---
 drivers/crypto/kasumi/rte_kasumi_pmd.c     | 4 ----
 drivers/crypto/null/null_crypto_pmd.c      | 3 +--
 drivers/crypto/openssl/rte_openssl_pmd.c   | 4 +---
 drivers/crypto/qat/qat_crypto.c            | 6 ------
 drivers/crypto/snow3g/rte_snow3g_pmd.c     | 4 ----
 drivers/crypto/zuc/rte_zuc_pmd.c           | 4 ----
 lib/librte_cryptodev/rte_cryptodev.c       | 5 -----
 lib/librte_cryptodev/rte_cryptodev.h       | 2 --
 12 files changed, 4 insertions(+), 42 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index df66525..04bd3d5 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -161,6 +161,7 @@ API Changes
     ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
     the new parameter ``device id``.
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
+  * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index ef290a3..2774b4e 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -146,10 +146,6 @@ aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_sym_op *op)
 	struct aesni_gcm_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session->driver_id !=
-				cryptodev_driver_id))
-			return sess;
-
 		sess = (struct aesni_gcm_session *)op->session->_private;
 	} else  {
 		void *_sess;
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 4025978..ec348ab 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -348,11 +348,6 @@ 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->driver_id !=
-				cryptodev_driver_id)) {
-			return NULL;
-		}
-
 		sess = (struct aesni_mb_session *)op->sym->session->_private;
 	} else  {
 		void *_sess = NULL;
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index 9fe781b..1ddf6a2 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -549,9 +549,7 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id)) {
+		if (likely(op->sym->session != NULL)) {
 			sess = (struct armv8_crypto_session *)
 				op->sym->session->_private;
 		}
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index a1a33c5..67f0b06 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -146,10 +146,6 @@ kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 	struct kasumi_session *sess;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct kasumi_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 50ede06..9323874 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -97,8 +97,7 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_sym_op *op)
 	struct null_crypto_session *sess;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session == NULL || op->session->driver_id !=
-				cryptodev_driver_id))
+		if (unlikely(op->session == NULL))
 			return NULL;
 
 		sess = (struct null_crypto_session *)op->session->_private;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 4e4394f..3232455 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -450,9 +450,7 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id))
+		if (likely(op->sym->session != NULL))
 			sess = (struct openssl_session *)
 				op->sym->session->_private;
 	} else  {
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index 7c5a9a8..13bd0b5 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -914,12 +914,6 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	if (unlikely(op->sym->session->driver_id !=
-			cryptodev_qat_driver_id)) {
-		PMD_DRV_LOG(ERR, "Session was not created for this device");
-		return -EINVAL;
-	}
-
 	ctx = (struct qat_session *)op->sym->session->_private;
 	qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
 	rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 35a2bcd..677849d 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -146,10 +146,6 @@ snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 	struct snow3g_session *sess;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct snow3g_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index ff8f3b9..385e4e5 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -145,10 +145,6 @@ zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 	struct zuc_session *sess;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct zuc_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 0b381ba..d2772fd 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1026,7 +1026,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->driver_id = dev->driver_id;
 	sess->mp = mp;
 
 	if (dev->dev_ops->session_initialize)
@@ -1133,10 +1132,6 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 
 	dev = &rte_crypto_devices[dev_id];
 
-	/* Check the session belongs to this device type */
-	if (sess->driver_id != dev->driver_id)
-		return sess;
-
 	/* Let device implementation clear session material */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_clear, sess);
 	dev->dev_ops->session_clear(dev, (void *)sess->_private);
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 77a763d..7d574f1 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -798,8 +798,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
 	struct {
-		uint8_t driver_id;
-		/** Crypto driver identifier session created on */
 		struct rte_mempool *mp;
 		/**< Mempool session allocated from */
 	} __rte_aligned(8);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 08/11] cryptodev: remove mempool from session
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (6 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 07/11] cryptodev: remove driver id from session Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 09/11] cryptodev: support device independent sessions Pablo de Lara
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Mempool pointer can be obtained from the object itself,
which means that it is not required to actually store the pointer
in the session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst | 1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 7 +++----
 lib/librte_cryptodev/rte_cryptodev.h   | 6 ------
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 04bd3d5..6215584 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -162,6 +162,7 @@ API Changes
     the new parameter ``device id``.
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
+  * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index d2772fd..cc42c25 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1026,8 +1026,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->mp = mp;
-
 	if (dev->dev_ops->session_initialize)
 		(*dev->dev_ops->session_initialize)(mp, sess);
 }
@@ -1065,7 +1063,7 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 				dev_id);
 
 		/* Return session to mempool */
-		rte_mempool_put(sess->mp, _sess);
+		rte_mempool_put(dev->data->session_pool, _sess);
 		return NULL;
 	}
 
@@ -1137,7 +1135,8 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 	dev->dev_ops->session_clear(dev, (void *)sess->_private);
 
 	/* Return session to mempool */
-	rte_mempool_put(sess->mp, (void *)sess);
+	struct rte_mempool *mp = rte_mempool_from_obj(sess);
+	rte_mempool_put(mp, (void *)sess);
 
 	return NULL;
 }
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 7d574f1..044a4aa 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -797,12 +797,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 /** Cryptodev symmetric crypto session */
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
-	struct {
-		struct rte_mempool *mp;
-		/**< Mempool session allocated from */
-	} __rte_aligned(8);
-	/**< Public symmetric session details */
-
 	__extension__ char _private[0];
 	/**< Private session material */
 };
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 09/11] cryptodev: support device independent sessions
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (7 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 08/11] cryptodev: remove mempool " Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 10/11] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
                     ` (2 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Change crypto device's session management to make it device independent
and simplify architecture when session is intended to be used on more than
one device.

Sessions private data is agnostic to underlying device by adding an
indirection in the sessions private data using the crypto driver identifier.
A single session can contain indirections to multiple device types.

New function rte_cryptodev_sym_session_init has been created,
to initialize the private data per driver to be used on
a same session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/cperf.h                       |   5 +-
 app/test-crypto-perf/cperf_ops.c                   |  30 +-
 app/test-crypto-perf/cperf_ops.h                   |   1 +
 app/test-crypto-perf/cperf_test_latency.c          |   7 +-
 app/test-crypto-perf/cperf_test_latency.h          |   5 +-
 app/test-crypto-perf/cperf_test_throughput.c       |   7 +-
 app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
 app/test-crypto-perf/cperf_test_verify.c           |   7 +-
 app/test-crypto-perf/cperf_test_verify.h           |   5 +-
 app/test-crypto-perf/main.c                        |  50 +--
 doc/guides/rel_notes/release_17_08.rst             |   6 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  54 ++--
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  28 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  29 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  27 +-
 drivers/crypto/armv8/rte_armv8_pmd.c               |  11 +-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  31 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  53 +++-
 drivers/crypto/kasumi/rte_kasumi_pmd.c             |  16 +-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  28 +-
 drivers/crypto/null/null_crypto_pmd.c              |  14 +-
 drivers/crypto/null/null_crypto_pmd_ops.c          |  31 +-
 drivers/crypto/openssl/rte_openssl_pmd.c           |  10 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  28 +-
 drivers/crypto/qat/qat_crypto.c                    |  68 ++--
 drivers/crypto/qat/qat_crypto.h                    |  12 +-
 drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
 drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
 .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 --
 drivers/crypto/scheduler/scheduler_pmd_ops.c       |  87 +++---
 drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
 drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 ---
 drivers/crypto/snow3g/rte_snow3g_pmd.c             |  16 +-
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  28 +-
 drivers/crypto/zuc/rte_zuc_pmd.c                   |  15 +-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  28 +-
 examples/ipsec-secgw/ipsec-secgw.c                 |  41 ++-
 examples/ipsec-secgw/ipsec.c                       |   7 +-
 examples/ipsec-secgw/ipsec.h                       |   2 +
 examples/l2fwd-crypto/main.c                       |  74 +++--
 lib/librte_cryptodev/rte_cryptodev.c               | 128 ++++----
 lib/librte_cryptodev/rte_cryptodev.h               |  65 ++--
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |  24 +-
 lib/librte_cryptodev/rte_cryptodev_version.map     |   2 +
 test/test/test_cryptodev.c                         | 346 ++++++++++++++-------
 test/test/test_cryptodev_blockcipher.c             |  15 +-
 test/test/test_cryptodev_blockcipher.h             |   1 +
 test/test/test_cryptodev_perf.c                    | 187 +++++++----
 48 files changed, 1071 insertions(+), 672 deletions(-)

diff --git a/app/test-crypto-perf/cperf.h b/app/test-crypto-perf/cperf.h
index 293ba94..c9f7f81 100644
--- a/app/test-crypto-perf/cperf.h
+++ b/app/test-crypto-perf/cperf.h
@@ -41,7 +41,10 @@ struct cperf_options;
 struct cperf_test_vector;
 struct cperf_op_fns;
 
-typedef void  *(*cperf_constructor_t)(uint8_t dev_id, uint16_t qp_id,
+typedef void  *(*cperf_constructor_t)(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *t_vec,
 		const struct cperf_op_fns *op_fns);
diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index c2c3db5..23bdd70 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -334,14 +334,16 @@ cperf_set_ops_aead(struct rte_crypto_op **ops,
 }
 
 static struct rte_cryptodev_sym_session *
-cperf_create_session(uint8_t dev_id,
+cperf_create_session(struct rte_mempool *sess_mp,
+	uint8_t dev_id,
 	const struct cperf_options *options,
 	const struct cperf_test_vector *test_vector)
 {
 	struct rte_crypto_sym_xform cipher_xform;
 	struct rte_crypto_sym_xform auth_xform;
-	struct rte_cryptodev_sym_session *sess = NULL;
+	struct rte_cryptodev_sym_session *sess;
 
+	sess = rte_cryptodev_sym_session_create(sess_mp);
 	/*
 	 * cipher only
 	 */
@@ -362,7 +364,8 @@ cperf_create_session(uint8_t dev_id,
 			cipher_xform.cipher.key.length = 0;
 		}
 		/* create crypto session */
-		sess = rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &cipher_xform,
+				sess_mp);
 	/*
 	 *  auth only
 	 */
@@ -388,7 +391,8 @@ cperf_create_session(uint8_t dev_id,
 			auth_xform.auth.key.data = NULL;
 		}
 		/* create crypto session */
-		sess =  rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &auth_xform,
+				sess_mp);
 	/*
 	 * cipher and auth
 	 */
@@ -452,29 +456,31 @@ cperf_create_session(uint8_t dev_id,
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 				cipher_xform.next = &auth_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-					&cipher_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &cipher_xform, sess_mp);
+
 			} else { /* decrypt */
 				auth_xform.next = &cipher_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-					&auth_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &auth_xform, sess_mp);
 			}
 		} else { /* create crypto session for other */
 			/* cipher then auth */
 			if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
 				cipher_xform.next = &auth_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-						&cipher_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &cipher_xform, sess_mp);
 			} else { /* auth then cipher */
 				auth_xform.next = &cipher_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-						&auth_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &auth_xform, sess_mp);
 			}
 		}
 	}
+
 	return sess;
 }
 
diff --git a/app/test-crypto-perf/cperf_ops.h b/app/test-crypto-perf/cperf_ops.h
index 1b748da..36daf9d 100644
--- a/app/test-crypto-perf/cperf_ops.h
+++ b/app/test-crypto-perf/cperf_ops.h
@@ -41,6 +41,7 @@
 
 
 typedef struct rte_cryptodev_sym_session *(*cperf_sessions_create_t)(
+		struct rte_mempool *sess_mp,
 		uint8_t dev_id, const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector);
 
diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c
index e61ac97..546a960 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -76,7 +76,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -187,7 +187,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -207,7 +208,7 @@ cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_latency.h b/app/test-crypto-perf/cperf_test_latency.h
index 6a2cf61..1bbedb4 100644
--- a/app/test-crypto-perf/cperf_test_latency.h
+++ b/app/test-crypto-perf/cperf_test_latency.h
@@ -43,7 +43,10 @@
 #include "cperf_test_vectors.h"
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 61b27ea..df85c67 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -65,7 +65,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -175,7 +175,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -195,7 +196,7 @@ cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_throughput.h b/app/test-crypto-perf/cperf_test_throughput.h
index f1b5766..987d0c3 100644
--- a/app/test-crypto-perf/cperf_test_throughput.h
+++ b/app/test-crypto-perf/cperf_test_throughput.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 454221e..3c2700f 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -69,7 +69,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -179,7 +179,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -199,7 +200,7 @@ cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_verify.h b/app/test-crypto-perf/cperf_test_verify.h
index 3fa78ee..e67b48d 100644
--- a/app/test-crypto-perf/cperf_test_verify.h
+++ b/app/test-crypto-perf/cperf_test_verify.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 9a22925..9f5c6be 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -46,6 +46,8 @@ const struct cperf_test cperf_testmap[] = {
 		}
 };
 
+static struct rte_mempool *cperf_mempool;
+
 static int
 cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 {
@@ -69,6 +71,30 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		return -EINVAL;
 	}
 
+	/* Create a mempool shared by all the devices */
+	uint32_t max_sess_size = 0, sess_size;
+
+	for (cdev_id = 0; cdev_id < enabled_cdev_count &&
+			cdev_id < RTE_CRYPTO_MAX_DEVS; cdev_id++) {
+		uint8_t enabled_id = enabled_cdevs[cdev_id];
+		sess_size = rte_cryptodev_get_private_session_size(enabled_id);
+		if (sess_size > max_sess_size)
+			max_sess_size = sess_size;
+	}
+
+	cperf_mempool = rte_mempool_create("sess_mp",
+				NUM_SESSIONS,
+				max_sess_size,
+				SESS_MEMPOOL_CACHE_SIZE,
+				0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	if (cperf_mempool == NULL) {
+		printf("Failed to create device session mempool\n");
+		return -ENOMEM;
+	}
+
 	for (cdev_id = 0; cdev_id < enabled_cdev_count &&
 			cdev_id < RTE_CRYPTO_MAX_DEVS; cdev_id++) {
 
@@ -81,28 +107,9 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 				.nb_descriptors = 2048
 		};
 
-		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(enabled_cdevs[cdev_id]);
-
-		char mp_name[RTE_MEMPOOL_NAMESIZE];
-		struct rte_mempool *sess_mp;
-
-		snprintf(mp_name, sizeof(mp_name), "sess_mp_%u", cdev_id);
-		sess_mp = rte_mempool_create(mp_name,
-					NUM_SESSIONS,
-					session_size,
-					SESS_MEMPOOL_CACHE_SIZE,
-					0, NULL, NULL, NULL,
-					NULL, SOCKET_ID_ANY,
-					0);
-
-		if (sess_mp == NULL) {
-			printf("Failed to create device session mempool\n");
-			return -ENOMEM;
-		}
 
 		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf,
-							sess_mp);
+							cperf_mempool);
 		if (ret < 0) {
 			printf("Failed to configure cryptodev %u",
 					enabled_cdevs[cdev_id]);
@@ -388,7 +395,8 @@ main(int argc, char **argv)
 
 		cdev_id = enabled_cdevs[i];
 
-		ctx[cdev_id] = cperf_testmap[opts.test].constructor(cdev_id, 0,
+		ctx[cdev_id] = cperf_testmap[opts.test].constructor(
+				cperf_mempool, cdev_id, 0,
 				&opts, t_vec, &op_fns);
 		if (ctx[cdev_id] == NULL) {
 			RTE_LOG(ERR, USER1, "Test run constructor failed\n");
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 6215584..ad1f269 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -77,7 +77,9 @@ New Features
 
 * **Updated cryptodev library.**
 
-  Added helper functions for crypto device driver identification.
+  * Added helper functions for crypto device driver identification.
+  * Added support for multi-device sessions, so a single session can be
+    used in multiple drivers.
 
 
 Resolved Issues
@@ -163,6 +165,8 @@ API Changes
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
+  * Replaced ``private`` marker with array of pointers to private data sessions
+    ``sess_private_data`` in ``rte_cryptodev_sym_session``
 
 
 ABI Changes
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index 2774b4e..2438b55 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -141,27 +141,35 @@ aesni_gcm_set_session_parameters(struct aesni_gcm_session *sess,
 
 /** Get gcm session */
 static struct aesni_gcm_session *
-aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_sym_op *op)
+aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_op *op)
 {
 	struct aesni_gcm_session *sess = NULL;
 
-	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct aesni_gcm_session *)op->session->_private;
-	} else  {
-		void *_sess;
-
-		if (rte_mempool_get(qp->sess_mp, &_sess))
-			return sess;
+	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
+		if (likely(op->sym->session != NULL)) {
+			sess = (struct aesni_gcm_session *)
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+		}
+	} else {
+		/* provide internal session */
+		void *_sess = NULL;
 
-		sess = (struct aesni_gcm_session *)
-			((struct rte_cryptodev_sym_session *)_sess)->_private;
+		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
+			sess = (struct aesni_gcm_session *)_sess;
 
-		if (unlikely(aesni_gcm_set_session_parameters(sess,
-				op->xform) != 0)) {
-			rte_mempool_put(qp->sess_mp, _sess);
-			sess = NULL;
+			if (unlikely(aesni_gcm_set_session_parameters(
+					sess, op->sym->xform) != 0)) {
+				rte_mempool_put(qp->sess_mp, _sess);
+				sess = NULL;
+			}
 		}
 	}
+
+	if (sess == NULL)
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
+
 	return sess;
 }
 
@@ -323,17 +331,16 @@ process_gcm_crypto_op(struct rte_crypto_sym_op *op,
  * - Returns NULL on invalid job
  */
 static void
-post_process_gcm_crypto_op(struct rte_crypto_op *op)
+post_process_gcm_crypto_op(struct rte_crypto_op *op,
+		struct aesni_gcm_session *sess)
 {
 	struct rte_mbuf *m = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
 
-	struct aesni_gcm_session *session =
-		(struct aesni_gcm_session *)op->sym->session->_private;
-
 	op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
+
 	/* Verify digest if required */
-	if (session->op == AESNI_GCM_OP_AUTHENTICATED_DECRYPTION) {
+	if (sess->op == AESNI_GCM_OP_AUTHENTICATED_DECRYPTION) {
 
 		uint8_t *tag = rte_pktmbuf_mtod_offset(m, uint8_t *,
 				m->data_len - op->sym->auth.digest.length);
@@ -365,12 +372,13 @@ post_process_gcm_crypto_op(struct rte_crypto_op *op)
  */
 static void
 handle_completed_gcm_crypto_op(struct aesni_gcm_qp *qp,
-		struct rte_crypto_op *op)
+		struct rte_crypto_op *op, struct aesni_gcm_session *sess)
 {
-	post_process_gcm_crypto_op(op);
+	post_process_gcm_crypto_op(op, sess);
 
 	/* Free session if a session-less crypto op */
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
+		memset(op->sym->session, 0, sizeof(struct aesni_gcm_session));
 		rte_mempool_put(qp->sess_mp, op->sym->session);
 		op->sym->session = NULL;
 	}
@@ -391,7 +399,7 @@ aesni_gcm_pmd_dequeue_burst(void *queue_pair,
 
 	for (i = 0; i < nb_dequeued; i++) {
 
-		sess = aesni_gcm_get_session(qp, ops[i]->sym);
+		sess = aesni_gcm_get_session(qp, ops[i]);
 		if (unlikely(sess == NULL)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			qp->qp_stats.dequeue_err_count++;
@@ -405,7 +413,7 @@ aesni_gcm_pmd_dequeue_burst(void *queue_pair,
 			break;
 		}
 
-		handle_completed_gcm_crypto_op(qp, ops[i]);
+		handle_completed_gcm_crypto_op(qp, ops[i], sess);
 	}
 
 	qp->qp_stats.dequeued_count += i;
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 721dbda..0b063fd 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -313,21 +313,37 @@ aesni_gcm_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a aesni gcm session from a crypto xform chain */
-static void *
+static int
 aesni_gcm_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		GCM_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (aesni_gcm_set_session_parameters(sess, xform) != 0) {
+	if (aesni_gcm_set_session_parameters(sess_private_data, xform) != 0) {
 		GCM_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index ec348ab..c8ec112 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -348,22 +348,33 @@ 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) {
-		sess = (struct aesni_mb_session *)op->sym->session->_private;
-	} else  {
+		if (likely(op->sym->session != NULL))
+			sess = (struct aesni_mb_session *)
+					get_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_session_private_data(op->sym->session, cryptodev_driver_id,
+			_sess_private_data);
+
 	}
 
 	return sess;
@@ -512,7 +523,7 @@ verify_digest(JOB_AES_HMAC *job, struct rte_crypto_op *op) {
  * - Returns NULL on invalid job
  */
 static inline struct rte_crypto_op *
-post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
+post_process_mb_job(JOB_AES_HMAC *job)
 {
 	struct rte_crypto_op *op = (struct rte_crypto_op *)job->user_data;
 
@@ -525,7 +536,9 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
 
 			if (job->hash_alg != NULL_HASH) {
 				sess = (struct aesni_mb_session *)
-						op->sym->session->_private;
+						get_session_private_data(
+						op->sym->session,
+						cryptodev_driver_id);
 
 				if (sess->auth.operation ==
 						RTE_CRYPTO_AUTH_OP_VERIFY)
@@ -539,7 +552,7 @@ 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) {
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
@@ -564,7 +577,7 @@ handle_completed_jobs(struct aesni_mb_qp *qp, JOB_AES_HMAC *job,
 	unsigned processed_jobs = 0;
 
 	while (job != NULL && processed_jobs < nb_ops) {
-		op = post_process_mb_job(qp, job);
+		op = post_process_mb_job(job);
 
 		if (op) {
 			ops[processed_jobs++] = op;
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index 3a2683b..fda8296 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -472,24 +472,39 @@ aesni_mb_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a aesni multi-buffer session from a crypto xform chain */
-static void *
+static int
 aesni_mb_pmd_session_configure(struct rte_cryptodev *dev,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
 	struct aesni_mb_private *internals = dev->data->dev_private;
 
 	if (unlikely(sess == NULL)) {
 		MB_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
 	if (aesni_mb_set_session_parameters(&job_ops[internals->vector_mode],
-			sess, xform) != 0) {
+			sess_private_data, xform) != 0) {
 		MB_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index 1ddf6a2..775280a 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -549,18 +549,17 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL)) {
+		if (likely(op->sym->session != NULL))
 			sess = (struct armv8_crypto_session *)
-				op->sym->session->_private;
-		}
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
 	} else {
 		/* provide internal session */
 		void *_sess = NULL;
 
 		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
-			sess = (struct armv8_crypto_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
+			sess = (struct armv8_crypto_session *)_sess;
 
 			if (unlikely(armv8_crypto_set_session_parameters(
 					sess, op->sym->xform) != 0)) {
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 2911417..3db420b 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -316,22 +316,37 @@ armv8_crypto_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure the session from a crypto xform chain */
-static void *
-armv8_crypto_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform, void *sess)
+static int
+armv8_crypto_pmd_session_configure(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		ARMV8_CRYPTO_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (armv8_crypto_set_session_parameters(
-			sess, xform) != 0) {
+	if (armv8_crypto_set_session_parameters(sess_private_data, xform) != 0) {
 		ARMV8_CRYPTO_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 70ad07a..c71b0c7 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -465,7 +465,9 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
 			/*Clear the unused FD fields before sending*/
 			memset(&fd_arr[loop], 0, sizeof(struct qbman_fd));
 			sess = (dpaa2_sec_session *)
-				(*ops)->sym->session->_private;
+					get_session_private_data(
+					(*ops)->sym->session,
+					cryptodev_driver_id);
 			mb_pool = (*ops)->sym->m_src->pool;
 			bpid = mempool_to_bpid(mb_pool);
 			ret = build_sec_fd(sess, *ops, &fd_arr[loop], bpid);
@@ -749,13 +751,6 @@ dpaa2_sec_session_get_size(struct rte_cryptodev *dev __rte_unused)
 	return sizeof(dpaa2_sec_session);
 }
 
-static void
-dpaa2_sec_session_initialize(struct rte_mempool *mp __rte_unused,
-			     void *sess __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-}
-
 static int
 dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
 		      struct rte_crypto_sym_xform *xform,
@@ -1202,18 +1197,14 @@ dpaa2_sec_aead_init(struct rte_cryptodev *dev,
 	return -1;
 }
 
-static void *
-dpaa2_sec_session_configure(struct rte_cryptodev *dev,
+static int
+dpaa2_sec_set_session_parameters(struct rte_cryptodev *dev,
 			    struct rte_crypto_sym_xform *xform,	void *sess)
 {
 	dpaa2_sec_session *session = sess;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if (unlikely(sess == NULL)) {
-		RTE_LOG(ERR, PMD, "invalid session struct");
-		return NULL;
-	}
 	/* Cipher Only */
 	if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next == NULL) {
 		session->ctxt_type = DPAA2_SEC_CIPHER;
@@ -1238,10 +1229,39 @@ dpaa2_sec_session_configure(struct rte_cryptodev *dev,
 		dpaa2_sec_aead_init(dev, xform, session);
 	} else {
 		RTE_LOG(ERR, PMD, "Invalid crypto type");
-		return NULL;
+		return -1;
 	}
 
-	return session;
+	return 0;
+}
+
+static int
+dpaa2_sec_session_configure(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
+{
+	void *sess_private_data;
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
+	}
+
+	if (dpaa2_sec_set_session_parameters(dev, xform, sess_private_data) != 0) {
+		PMD_DRV_LOG(ERR, "DPAA2 PMD: failed to configure "
+				"session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
+	}
+
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
@@ -1477,7 +1497,6 @@ static struct rte_cryptodev_ops crypto_ops = {
 	.queue_pair_stop      = dpaa2_sec_queue_pair_stop,
 	.queue_pair_count     = dpaa2_sec_queue_pair_count,
 	.session_get_size     = dpaa2_sec_session_get_size,
-	.session_initialize   = dpaa2_sec_session_initialize,
 	.session_configure    = dpaa2_sec_session_configure,
 	.session_clear        = dpaa2_sec_session_clear,
 };
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 67f0b06..a114542 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -143,17 +143,21 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
 static struct kasumi_session *
 kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 {
-	struct kasumi_session *sess;
+	struct kasumi_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct kasumi_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct kasumi_session *)
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
+		void *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct kasumi_session *)c_sess->_private;
+		sess = (struct kasumi_session *)c_sess;
 
 		if (unlikely(kasumi_set_session_parameters(sess,
 				op->sym->xform) != 0))
@@ -297,7 +301,7 @@ process_kasumi_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = ops[i]->sym->auth.digest.data;
 
 			sso_kasumi_f9_1_buffer_user(&session->pKeySched_hash,
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index 343c9b3..d590b91 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -291,21 +291,37 @@ kasumi_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a KASUMI session from a crypto xform chain */
-static void *
+static int
 kasumi_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		KASUMI_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (kasumi_set_session_parameters(sess, xform) != 0) {
+	if (kasumi_set_session_parameters(sess_private_data, xform) != 0) {
 		KASUMI_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 9323874..448bbcf 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -94,20 +94,20 @@ process_op(const struct null_crypto_qp *qp, struct rte_crypto_op *op,
 static struct null_crypto_session *
 get_session(struct null_crypto_qp *qp, struct rte_crypto_sym_op *op)
 {
-	struct null_crypto_session *sess;
+	struct null_crypto_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session == NULL))
-			return NULL;
-
-		sess = (struct null_crypto_session *)op->session->_private;
-	} else  {
+		if (likely(op->session != NULL))
+			sess = (struct null_crypto_session *)
+					get_session_private_data(
+					op->session, cryptodev_driver_id);
+	} else {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct null_crypto_session *)c_sess->_private;
+		sess = (struct null_crypto_session *)c_sess;
 
 		if (null_crypto_set_session_parameters(sess, op->xform)	!= 0)
 			return NULL;
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index a7c891e..04147fe 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -302,24 +302,37 @@ null_crypto_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a null crypto session from a crypto xform chain */
-static void *
+static int
 null_crypto_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform, void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mp)
 {
-	int retval;
+	void *sess_private_data;
 
 	if (unlikely(sess == NULL)) {
 		NULL_CRYPTO_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mp, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
-	retval = null_crypto_set_session_parameters(
-			(struct null_crypto_session *)sess, xform);
-	if (retval != 0) {
+
+	if (null_crypto_set_session_parameters(sess_private_data, xform) != 0) {
 		NULL_CRYPTO_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mp, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 3232455..d34cf16 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -452,15 +452,15 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 		/* get existing session */
 		if (likely(op->sym->session != NULL))
 			sess = (struct openssl_session *)
-				op->sym->session->_private;
-	} else  {
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
 		/* provide internal session */
 		void *_sess = NULL;
 
 		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
-			sess = (struct openssl_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
+			sess = (struct openssl_session *)_sess;
 
 			if (unlikely(openssl_set_session_parameters(
 					sess, op->sym->xform) != 0)) {
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index f65de53..005855b 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -671,22 +671,38 @@ openssl_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure the session from a crypto xform chain */
-static void *
+static int
 openssl_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		OPENSSL_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
 	if (openssl_set_session_parameters(
-			sess, xform) != 0) {
+			sess_private_data, xform) != 0) {
 		OPENSSL_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index 13bd0b5..6e028bb 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -220,7 +220,6 @@ void qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
 		void *session)
 {
 	struct qat_session *sess = session;
-	phys_addr_t cd_paddr;
 
 	PMD_INIT_FUNC_TRACE();
 	if (sess) {
@@ -228,9 +227,7 @@ void qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
 			bpi_cipher_ctx_free(sess->bpi_ctx);
 			sess->bpi_ctx = NULL;
 		}
-		cd_paddr = sess->cd_paddr;
 		memset(sess, 0, qat_crypto_sym_get_session_private_size(dev));
-		sess->cd_paddr = cd_paddr;
 	} else
 		PMD_DRV_LOG(ERR, "NULL session");
 }
@@ -448,9 +445,37 @@ qat_crypto_sym_configure_session_cipher(struct rte_cryptodev *dev,
 	return NULL;
 }
 
-
-void *
+int
 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
+{
+	void *sess_private_data;
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
+	}
+
+	if (qat_crypto_set_session_parameters(dev, xform, sess_private_data) != 0) {
+		PMD_DRV_LOG(ERR, "Crypto QAT PMD: failed to configure "
+				"session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
+	}
+
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
+}
+
+int
+qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
 		struct rte_crypto_sym_xform *xform, void *session_private)
 {
 	struct qat_session *session = session_private;
@@ -458,6 +483,10 @@ qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
 	int qat_cmd_id;
 	PMD_INIT_FUNC_TRACE();
 
+	session->cd_paddr = rte_mempool_virt2phy(NULL, session) +
+			offsetof(struct qat_session, cd);
+
+
 	/* Get requested QAT command id */
 	qat_cmd_id = qat_get_cmd_id(xform);
 	if (qat_cmd_id < 0 || qat_cmd_id >= ICP_QAT_FW_LA_CMD_DELIMITER) {
@@ -498,10 +527,10 @@ qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
 		goto error_out;
 	}
 
-	return session;
+	return 0;
 
 error_out:
-	return NULL;
+	return -1;
 }
 
 struct qat_session *
@@ -809,7 +838,10 @@ qat_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops,
 			rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
 		} else {
 			struct qat_session *sess = (struct qat_session *)
-						(rx_op->sym->session->_private);
+					get_session_private_data(
+					rx_op->sym->session,
+					cryptodev_qat_driver_id);
+
 			if (sess->bpi_ctx)
 				qat_bpicipher_postprocess(sess, rx_op);
 			rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
@@ -914,7 +946,14 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	ctx = (struct qat_session *)op->sym->session->_private;
+	ctx = (struct qat_session *)get_session_private_data(
+			op->sym->session, cryptodev_qat_driver_id);
+
+	if (unlikely(ctx == NULL)) {
+		PMD_DRV_LOG(ERR, "Session was not created for this device");
+		return -EINVAL;
+	}
+
 	qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
 	rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
 	qat_req->comn_mid.opaque_data = (uint64_t)(uintptr_t)op;
@@ -1192,17 +1231,6 @@ static inline uint32_t adf_modulo(uint32_t data, uint32_t shift)
 	return data - mult;
 }
 
-void qat_crypto_sym_session_init(struct rte_mempool *mp, void *sym_sess)
-{
-	struct rte_cryptodev_sym_session *sess = sym_sess;
-	struct qat_session *s = (void *)sess->_private;
-
-	PMD_INIT_FUNC_TRACE();
-	s->cd_paddr = rte_mempool_virt2phy(mp, sess) +
-		offsetof(struct qat_session, cd) +
-		offsetof(struct rte_cryptodev_sym_session, _private);
-}
-
 int qat_dev_config(__rte_unused struct rte_cryptodev *dev,
 		__rte_unused struct rte_cryptodev_config *config)
 {
diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h
index ed27e3b..d5466c2 100644
--- a/drivers/crypto/qat/qat_crypto.h
+++ b/drivers/crypto/qat/qat_crypto.h
@@ -114,11 +114,15 @@ qat_pmd_session_mempool_create(struct rte_cryptodev *dev,
 extern unsigned
 qat_crypto_sym_get_session_private_size(struct rte_cryptodev *dev);
 
-extern void
-qat_crypto_sym_session_init(struct rte_mempool *mempool, void *priv_sess);
-
-extern void *
+extern int
 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool);
+
+
+int
+qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
 		struct rte_crypto_sym_xform *xform, void *session_private);
 
 struct qat_session *
diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c
index 1c5ff77..9a710e6 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -73,7 +73,6 @@ static struct rte_cryptodev_ops crypto_qat_ops = {
 		/* Crypto related operations */
 		.session_get_size	= qat_crypto_sym_get_session_private_size,
 		.session_configure	= qat_crypto_sym_configure_session,
-		.session_initialize	= qat_crypto_sym_session_init,
 		.session_clear		= qat_crypto_sym_clear_session
 };
 
diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c
index 162a29b..2aa13f8 100644
--- a/drivers/crypto/scheduler/scheduler_failover.c
+++ b/drivers/crypto/scheduler/scheduler_failover.c
@@ -49,57 +49,18 @@ struct fo_scheduler_qp_ctx {
 };
 
 static __rte_always_inline uint16_t
-failover_slave_enqueue(struct scheduler_slave *slave, uint8_t slave_idx,
+failover_slave_enqueue(struct scheduler_slave *slave,
 		struct rte_crypto_op **ops, uint16_t nb_ops)
 {
 	uint16_t i, processed_ops;
-	struct rte_cryptodev_sym_session *sessions[nb_ops];
-	struct scheduler_session *sess0, *sess1, *sess2, *sess3;
 
 	for (i = 0; i < nb_ops && i < 4; i++)
 		rte_prefetch0(ops[i]->sym->session);
 
-	for (i = 0; (i < (nb_ops - 8)) && (nb_ops > 8); i += 4) {
-		rte_prefetch0(ops[i + 4]->sym->session);
-		rte_prefetch0(ops[i + 5]->sym->session);
-		rte_prefetch0(ops[i + 6]->sym->session);
-		rte_prefetch0(ops[i + 7]->sym->session);
-
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
-		sessions[i] = ops[i]->sym->session;
-		sessions[i + 1] = ops[i + 1]->sym->session;
-		sessions[i + 2] = ops[i + 2]->sym->session;
-		sessions[i + 3] = ops[i + 3]->sym->session;
-
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-		ops[i + 1]->sym->session = sess1->sessions[slave_idx];
-		ops[i + 2]->sym->session = sess2->sessions[slave_idx];
-		ops[i + 3]->sym->session = sess3->sessions[slave_idx];
-	}
-
-	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sessions[i] = ops[i]->sym->session;
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-	}
-
 	processed_ops = rte_cryptodev_enqueue_burst(slave->dev_id,
 			slave->qp_id, ops, nb_ops);
 	slave->nb_inflight_cops += processed_ops;
 
-	if (unlikely(processed_ops < nb_ops))
-		for (i = processed_ops; i < nb_ops; i++)
-			ops[i]->sym->session = sessions[i];
-
 	return processed_ops;
 }
 
@@ -114,11 +75,11 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		return 0;
 
 	enqueued_ops = failover_slave_enqueue(&qp_ctx->primary_slave,
-			PRIMARY_SLAVE_IDX, ops, nb_ops);
+			ops, nb_ops);
 
 	if (enqueued_ops < nb_ops)
 		enqueued_ops += failover_slave_enqueue(&qp_ctx->secondary_slave,
-				SECONDARY_SLAVE_IDX, &ops[enqueued_ops],
+				&ops[enqueued_ops],
 				nb_ops - enqueued_ops);
 
 	return enqueued_ops;
diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
index 6b628df..1dd1bc3 100644
--- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
+++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
@@ -67,7 +67,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	struct scheduler_qp_ctx *qp_ctx = qp;
 	struct psd_scheduler_qp_ctx *psd_qp_ctx = qp_ctx->private_qp_ctx;
 	struct rte_crypto_op *sched_ops[NB_PKT_SIZE_SLAVES][nb_ops];
-	struct scheduler_session *sess;
 	uint32_t in_flight_ops[NB_PKT_SIZE_SLAVES] = {
 			psd_qp_ctx->primary_slave.nb_inflight_cops,
 			psd_qp_ctx->secondary_slave.nb_inflight_cops
@@ -97,8 +96,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		rte_prefetch0(ops[i + 7]->sym);
 		rte_prefetch0(ops[i + 7]->sym->session);
 
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
 		/* job_len is initialized as cipher data length, once
 		 * it is 0, equals to auth data length
 		 */
@@ -118,11 +115,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i];
-		ops[i]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
 		job_len = ops[i+1]->sym->cipher.data.length;
 		job_len += (ops[i+1]->sym->cipher.data.length == 0) *
 				ops[i+1]->sym->auth.data.length;
@@ -135,11 +129,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+1];
-		ops[i+1]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
 		job_len = ops[i+2]->sym->cipher.data.length;
 		job_len += (ops[i+2]->sym->cipher.data.length == 0) *
 				ops[i+2]->sym->auth.data.length;
@@ -152,12 +143,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+2];
-		ops[i+2]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
 		job_len = ops[i+3]->sym->cipher.data.length;
 		job_len += (ops[i+3]->sym->cipher.data.length == 0) *
 				ops[i+3]->sym->auth.data.length;
@@ -170,14 +157,10 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+3];
-		ops[i+3]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 	}
 
 	for (; i < nb_ops; i++) {
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-
 		job_len = ops[i]->sym->cipher.data.length;
 		job_len += (ops[i]->sym->cipher.data.length == 0) *
 				ops[i]->sym->auth.data.length;
@@ -190,7 +173,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i];
-		ops[i]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 	}
 
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index b9d8973..6e37efc 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -85,8 +85,10 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
 /** Configure device */
 static int
 scheduler_pmd_config(struct rte_cryptodev *dev,
-		struct rte_cryptodev_config *config __rte_unused)
+		struct rte_cryptodev_config *config)
 {
+	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint32_t i;
 	int ret;
 
 	/* although scheduler_attach_init_slave presents multiple times,
@@ -96,6 +98,15 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	if (ret < 0)
 		return ret;
 
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
+
+		ret = rte_cryptodev_configure(slave_dev_id, config,
+				dev->data->session_pool);
+		if (ret < 0)
+			break;
+	}
+
 	return ret;
 }
 
@@ -474,67 +485,43 @@ scheduler_pmd_qp_count(struct rte_cryptodev *dev)
 static uint32_t
 scheduler_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 {
-	return sizeof(struct scheduler_session);
-}
-
-static int
-config_slave_sess(struct scheduler_ctx *sched_ctx,
-		struct rte_crypto_sym_xform *xform,
-		struct scheduler_session *sess,
-		uint32_t create)
-{
-	uint32_t i;
+	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint8_t i = 0;
+	uint32_t max_priv_sess_size = 0;
 
+	/* Check what is the maximum private session size for all slaves */
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
-		struct scheduler_slave *slave = &sched_ctx->slaves[i];
+		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
+		struct rte_cryptodev *dev = &rte_cryptodevs[slave_dev_id];
+		uint32_t priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
 
-		if (sess->sessions[i]) {
-			if (create)
-				continue;
-			/* !create */
-			sess->sessions[i] = rte_cryptodev_sym_session_free(
-					slave->dev_id, sess->sessions[i]);
-		} else {
-			if (!create)
-				continue;
-			/* create */
-			sess->sessions[i] =
-					rte_cryptodev_sym_session_create(
-							slave->dev_id, xform);
-			if (!sess->sessions[i]) {
-				config_slave_sess(sched_ctx, NULL, sess, 0);
-				return -1;
-			}
-		}
+		if (max_priv_sess_size < priv_sess_size)
+			max_priv_sess_size = priv_sess_size;
 	}
 
-	return 0;
-}
-
-/** Clear the memory of session so it doesn't leave key material behind */
-static void
-scheduler_pmd_session_clear(struct rte_cryptodev *dev,
-	void *sess)
-{
-	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
-
-	config_slave_sess(sched_ctx, NULL, sess, 0);
-
-	memset(sess, 0, sizeof(struct scheduler_session));
+	return max_priv_sess_size;
 }
 
-static void *
+static int
 scheduler_pmd_session_configure(struct rte_cryptodev *dev,
-	struct rte_crypto_sym_xform *xform, void *sess)
+	struct rte_crypto_sym_xform *xform,
+	struct rte_cryptodev_sym_session *sess,
+	struct rte_mempool *mempool)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint32_t i;
+
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		struct scheduler_slave *slave = &sched_ctx->slaves[i];
 
-	if (config_slave_sess(sched_ctx, xform, sess, 1) < 0) {
-		CS_LOG_ERR("unabled to config sym session");
-		return NULL;
+		if (rte_cryptodev_sym_session_init(slave->dev_id, sess,
+					xform, mempool) < 0) {
+			CS_LOG_ERR("unabled to config sym session");
+			return -1;
+		}
 	}
 
-	return sess;
+	return 0;
 }
 
 struct rte_cryptodev_ops scheduler_pmd_ops = {
@@ -556,7 +543,7 @@ struct rte_cryptodev_ops scheduler_pmd_ops = {
 
 		.session_get_size	= scheduler_pmd_session_get_size,
 		.session_configure	= scheduler_pmd_session_configure,
-		.session_clear		= scheduler_pmd_session_clear,
+		.session_clear		= NULL,
 };
 
 struct rte_cryptodev_ops *rte_crypto_scheduler_pmd_ops = &scheduler_pmd_ops;
diff --git a/drivers/crypto/scheduler/scheduler_pmd_private.h b/drivers/crypto/scheduler/scheduler_pmd_private.h
index e313a89..639d75a 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_private.h
+++ b/drivers/crypto/scheduler/scheduler_pmd_private.h
@@ -103,10 +103,6 @@ struct scheduler_qp_ctx {
 	uint32_t seqn;
 } __rte_cache_aligned;
 
-struct scheduler_session {
-	struct rte_cryptodev_sym_session *sessions[
-			RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES];
-};
 
 extern uint8_t cryptodev_driver_id;
 
diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c
index 0116276..4a84728 100644
--- a/drivers/crypto/scheduler/scheduler_roundrobin.c
+++ b/drivers/crypto/scheduler/scheduler_roundrobin.c
@@ -52,8 +52,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	uint32_t slave_idx = rr_qp_ctx->last_enq_slave_idx;
 	struct scheduler_slave *slave = &rr_qp_ctx->slaves[slave_idx];
 	uint16_t i, processed_ops;
-	struct rte_cryptodev_sym_session *sessions[nb_ops];
-	struct scheduler_session *sess0, *sess1, *sess2, *sess3;
 
 	if (unlikely(nb_ops == 0))
 		return 0;
@@ -61,39 +59,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	for (i = 0; i < nb_ops && i < 4; i++)
 		rte_prefetch0(ops[i]->sym->session);
 
-	for (i = 0; (i < (nb_ops - 8)) && (nb_ops > 8); i += 4) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
-		sessions[i] = ops[i]->sym->session;
-		sessions[i + 1] = ops[i + 1]->sym->session;
-		sessions[i + 2] = ops[i + 2]->sym->session;
-		sessions[i + 3] = ops[i + 3]->sym->session;
-
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-		ops[i + 1]->sym->session = sess1->sessions[slave_idx];
-		ops[i + 2]->sym->session = sess2->sessions[slave_idx];
-		ops[i + 3]->sym->session = sess3->sessions[slave_idx];
-
-		rte_prefetch0(ops[i + 4]->sym->session);
-		rte_prefetch0(ops[i + 5]->sym->session);
-		rte_prefetch0(ops[i + 6]->sym->session);
-		rte_prefetch0(ops[i + 7]->sym->session);
-	}
-
-	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sessions[i] = ops[i]->sym->session;
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-	}
-
 	processed_ops = rte_cryptodev_enqueue_burst(slave->dev_id,
 			slave->qp_id, ops, nb_ops);
 
@@ -102,12 +67,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	rr_qp_ctx->last_enq_slave_idx += 1;
 	rr_qp_ctx->last_enq_slave_idx %= rr_qp_ctx->nb_slaves;
 
-	/* recover session if enqueue is failed */
-	if (unlikely(processed_ops < nb_ops)) {
-		for (i = processed_ops; i < nb_ops; i++)
-			ops[i]->sym->session = sessions[i];
-	}
-
 	return processed_ops;
 }
 
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 677849d..e1771bb 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -143,17 +143,21 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
 static struct snow3g_session *
 snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 {
-	struct snow3g_session *sess;
+	struct snow3g_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct snow3g_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct snow3g_session *)
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
+		void *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct snow3g_session *)c_sess->_private;
+		sess = (struct snow3g_session *)c_sess;
 
 		if (unlikely(snow3g_set_session_parameters(sess,
 				op->sym->xform) != 0))
@@ -286,7 +290,7 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = ops[i]->sym->auth.digest.data;
 
 			sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index 26cc3e9..1967409 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -289,21 +289,37 @@ snow3g_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a SNOW 3G session from a crypto xform chain */
-static void *
+static int
 snow3g_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		SNOW3G_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (snow3g_set_session_parameters(sess, xform) != 0) {
+	if (snow3g_set_session_parameters(sess_private_data, xform) != 0) {
 		SNOW3G_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 385e4e5..af90f90 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -142,17 +142,20 @@ zuc_set_session_parameters(struct zuc_session *sess,
 static struct zuc_session *
 zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 {
-	struct zuc_session *sess;
+	struct zuc_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct zuc_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct zuc_session *)get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
+		void *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
 
-		sess = (struct zuc_session *)c_sess->_private;
+		sess = (struct zuc_session *)c_sess;
 
 		if (unlikely(zuc_set_session_parameters(sess,
 				op->sym->xform) != 0))
@@ -277,7 +280,7 @@ process_zuc_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = (uint32_t *)ops[i]->sym->auth.digest.data;
 
 			sso_zuc_eia3_1_buffer(session->pKey_hash,
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index 645b80c..cdc783f 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -289,21 +289,37 @@ zuc_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a ZUC session from a crypto xform chain */
-static void *
+static int
 zuc_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		ZUC_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (zuc_set_session_parameters(sess, xform) != 0) {
+	if (zuc_set_session_parameters(sess_private_data, xform) != 0) {
 		ZUC_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index a2286fd..708eadd 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -710,10 +710,12 @@ main_loop(__attribute__((unused)) void *dummy)
 	qconf->inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in;
 	qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
 	qconf->inbound.cdev_map = cdev_map_in;
+	qconf->inbound.session_pool = socket_ctx[socket_id].session_pool;
 	qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
 	qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
 	qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
 	qconf->outbound.cdev_map = cdev_map_out;
+	qconf->outbound.session_pool = socket_ctx[socket_id].session_pool;
 
 	if (qconf->nb_rx_queue == 0) {
 		RTE_LOG(INFO, IPSEC, "lcore %u has nothing to do\n", lcore_id);
@@ -1238,6 +1240,13 @@ cryptodevs_init(void)
 
 	printf("lcore/cryptodev/qp mappings:\n");
 
+	uint32_t max_sess_sz = 0, sess_sz;
+	for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
+		sess_sz = rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_sz > max_sess_sz)
+			max_sess_sz = sess_sz;
+	}
+
 	idx = 0;
 	/* Start from last cdev id to give HW priority */
 	for (cdev_id = rte_cryptodev_count() - 1; cdev_id >= 0; cdev_id--) {
@@ -1267,27 +1276,31 @@ cryptodevs_init(void)
 		dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
 		dev_conf.nb_queue_pairs = qp;
 
-		char mp_name[RTE_MEMPOOL_NAMESIZE];
-		struct rte_mempool *sess_mp;
-
-		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(cdev_id);
+		if (!socket_ctx[dev_conf.socket_id].session_pool) {
+			char mp_name[RTE_MEMPOOL_NAMESIZE];
+			struct rte_mempool *sess_mp;
 
-		snprintf(mp_name, sizeof(mp_name), "sess_mp_%u", cdev_id);
-		sess_mp = rte_mempool_create(mp_name,
+			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+					"sess_mp_%u", dev_conf.socket_id);
+			sess_mp = rte_mempool_create(mp_name,
 					CDEV_MP_NB_OBJS,
-					session_size,
+					max_sess_sz,
 					CDEV_MP_CACHE_SZ,
 					0, NULL, NULL, NULL,
 					NULL, dev_conf.socket_id,
 					0);
-
-		if (sess_mp == NULL) {
-			printf("Failed to create device session mempool\n");
-			return -ENOMEM;
+			if (sess_mp == NULL)
+				rte_exit(EXIT_FAILURE,
+					"Cannot create session pool on socket %d\n",
+					dev_conf.socket_id);
+			else
+				printf("Allocated session pool on socket %d\n",
+					dev_conf.socket_id);
+			socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
 		}
 
-		if (rte_cryptodev_configure(cdev_id, &dev_conf, sess_mp))
+		if (rte_cryptodev_configure(cdev_id, &dev_conf,
+				socket_ctx[dev_conf.socket_id].session_pool))
 			rte_panic("Failed to initialize cryptodev %u\n",
 					cdev_id);
 
@@ -1451,7 +1464,7 @@ main(int32_t argc, char **argv)
 
 	nb_lcores = rte_lcore_count();
 
-	/* Replicate each contex per socket */
+	/* Replicate each context per socket */
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
 		if (rte_lcore_is_enabled(lcore_id) == 0)
 			continue;
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 048e441..c927344 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -45,7 +45,7 @@
 #include "esp.h"
 
 static inline int
-create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
+create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa)
 {
 	struct rte_cryptodev_info cdev_info;
 	unsigned long cdev_id_qp = 0;
@@ -72,7 +72,10 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
 			ipsec_ctx->tbl[cdev_id_qp].qp);
 
 	sa->crypto_session = rte_cryptodev_sym_session_create(
-			ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
+			ipsec_ctx->session_pool);
+	rte_cryptodev_sym_session_init(ipsec_ctx->tbl[cdev_id_qp].id,
+			sa->crypto_session, sa->xforms,
+			ipsec_ctx->session_pool);
 
 	rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
 	if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index 1d63161..593b0a2 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -139,6 +139,7 @@ struct ipsec_ctx {
 	uint16_t nb_qps;
 	uint16_t last_qp;
 	struct cdev_qp tbl[MAX_QP_PER_LCORE];
+	struct rte_mempool *session_pool;
 };
 
 struct cdev_key {
@@ -157,6 +158,7 @@ struct socket_ctx {
 	struct rt_ctx *rt_ip4;
 	struct rt_ctx *rt_ip6;
 	struct rte_mempool *mbuf_pool;
+	struct rte_mempool *session_pool;
 };
 
 struct cnt_blk {
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index c3c6f45..20f28d5 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -88,9 +88,8 @@ enum cdev_type {
 #define MAX_KEY_SIZE 128
 #define MAX_PKT_BURST 32
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
-
-#define NUM_SESSIONS 2048
-#define SESS_MEMPOOL_CACHE_SIZE 64
+#define MAX_SESSIONS 32
+#define SESSION_POOL_CACHE_SIZE 0
 
 /*
  * Configurable number of RX/TX ring descriptors
@@ -226,6 +225,7 @@ static const struct rte_eth_conf port_conf = {
 
 struct rte_mempool *l2fwd_pktmbuf_pool;
 struct rte_mempool *l2fwd_crypto_op_pool;
+struct rte_mempool *l2fwd_session_pool;
 
 /* Per-port statistics struct */
 struct l2fwd_port_statistics {
@@ -589,9 +589,9 @@ generate_random_key(uint8_t *key, unsigned length)
 		rte_exit(EXIT_FAILURE, "Failed to generate random key\n");
 }
 
-static struct rte_cryptodev_sym_session *
+static int
 initialize_crypto_session(struct l2fwd_crypto_options *options,
-		uint8_t cdev_id)
+		uint8_t cdev_id, struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_crypto_sym_xform *first_xform;
 
@@ -608,12 +608,14 @@ initialize_crypto_session(struct l2fwd_crypto_options *options,
 	}
 
 	/* Setup Cipher Parameters */
-	return rte_cryptodev_sym_session_create(cdev_id, first_xform);
+	return rte_cryptodev_sym_session_init(cdev_id, sess, first_xform,
+			l2fwd_session_pool);
 }
 
 static void
 l2fwd_crypto_options_print(struct l2fwd_crypto_options *options);
 
+
 /* main processing loop */
 static void
 l2fwd_main_loop(struct l2fwd_crypto_options *options)
@@ -629,6 +631,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 			US_PER_S * BURST_TX_DRAIN_US;
 	struct l2fwd_crypto_params *cparams;
 	struct l2fwd_crypto_params port_cparams[qconf->nb_crypto_devs];
+	struct rte_cryptodev_sym_session *session;
 
 	if (qconf->nb_rx_ports == 0) {
 		RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id);
@@ -644,6 +647,8 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 			portid);
 	}
 
+	session = rte_cryptodev_sym_session_create(l2fwd_session_pool);
+
 	for (i = 0; i < qconf->nb_crypto_devs; i++) {
 		port_cparams[i].do_cipher = 0;
 		port_cparams[i].do_hash = 0;
@@ -701,11 +706,12 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 			port_cparams[i].cipher_algo = options->cipher_xform.cipher.algo;
 		}
 
-		port_cparams[i].session = initialize_crypto_session(options,
-				port_cparams[i].dev_id);
+		port_cparams[i].session = session;
 
-		if (port_cparams[i].session == NULL)
+		if (initialize_crypto_session(options, port_cparams[i].dev_id,
+				port_cparams[i].session) < 0)
 			return;
+
 		RTE_LOG(INFO, L2FWD, " -- lcoreid=%u cryptoid=%u\n", lcore_id,
 				port_cparams[i].dev_id);
 	}
@@ -1554,6 +1560,8 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 	enum rte_crypto_cipher_algorithm cap_cipher_algo;
 	enum rte_crypto_cipher_algorithm opt_cipher_algo;
 	int retval;
+	uint32_t max_sess_sz = 0, sess_sz;
+	char mp_name[RTE_MEMPOOL_NAMESIZE];
 
 	cdev_count = rte_cryptodev_count();
 	if (cdev_count == 0) {
@@ -1561,6 +1569,29 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		return -1;
 	}
 
+	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+		sess_sz = rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_sz > max_sess_sz)
+			max_sess_sz = sess_sz;
+	}
+
+	snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "sess_mp_%u", rte_socket_id());
+	l2fwd_session_pool = rte_mempool_create(mp_name,
+				MAX_SESSIONS * cdev_count,
+				max_sess_sz,
+				SESSION_POOL_CACHE_SIZE,
+				0, NULL, NULL, NULL,
+				NULL, rte_socket_id(),
+				0);
+
+	if (l2fwd_session_pool == NULL) {
+		printf("Failed to create session mempool on socket %u\n",
+				rte_socket_id());
+		return -ENOMEM;
+	}
+
+	printf("Allocated session mempool on socket %u\n", rte_socket_id());
+
 	for (cdev_id = 0; cdev_id < cdev_count && enabled_cdev_count < nb_ports;
 			cdev_id++) {
 		struct rte_cryptodev_qp_conf qp_conf;
@@ -1796,27 +1827,8 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 						cap->sym.auth.digest_size.min;
 		}
 
-		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(enabled_cdevs[cdev_id]);
-
-		char mp_name[RTE_MEMPOOL_NAMESIZE];
-		struct rte_mempool *sess_mp;
-
-		snprintf(mp_name, sizeof(mp_name), "sess_mp_%u", cdev_id);
-		sess_mp = rte_mempool_create(mp_name,
-					NUM_SESSIONS,
-					session_size,
-					SESS_MEMPOOL_CACHE_SIZE,
-					0, NULL, NULL, NULL,
-					NULL, SOCKET_ID_ANY,
-					0);
-
-		if (sess_mp == NULL) {
-			printf("Failed to create device session mempool\n");
-			return -ENOMEM;
-		}
-
-		retval = rte_cryptodev_configure(cdev_id, &conf, sess_mp);
+		retval = rte_cryptodev_configure(cdev_id, &conf,
+				l2fwd_session_pool);
 		if (retval < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -1;
@@ -1825,7 +1837,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		qp_conf.nb_descriptors = 2048;
 
 		retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
-				SOCKET_ID_ANY);
+				rte_socket_id());
 		if (retval < 0) {
 			printf("Failed to setup queue pair %u on cryptodev %u",
 					0, cdev_id);
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index cc42c25..f5a72de 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -69,6 +69,8 @@
 #include "rte_cryptodev.h"
 #include "rte_cryptodev_pmd.h"
 
+static uint8_t nb_drivers;
+
 struct rte_cryptodev rte_crypto_devices[RTE_CRYPTO_MAX_DEVS];
 
 struct rte_cryptodev *rte_cryptodevs = &rte_crypto_devices[0];
@@ -1018,54 +1020,47 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 	rte_spinlock_unlock(&rte_cryptodev_cb_lock);
 }
 
-
-static void
-rte_cryptodev_sym_session_init(struct rte_mempool *mp,
-		struct rte_cryptodev *dev,
-		struct rte_cryptodev_sym_session *sess)
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_crypto_sym_xform *xforms,
+		struct rte_mempool *mp)
 {
-	memset(sess, 0, mp->elt_size);
+	struct rte_cryptodev *dev;
+	uint8_t index;
 
-	if (dev->dev_ops->session_initialize)
-		(*dev->dev_ops->session_initialize)(mp, sess);
-}
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
 
+	if (sess == NULL || xforms == NULL || dev == NULL)
+		return -1;
 
-struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform)
-{
-	struct rte_cryptodev *dev;
-	struct rte_cryptodev_sym_session *sess;
-	void *_sess;
+	index = dev->driver_id;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return NULL;
+	if (sess->sess_private_data[index] == NULL) {
+		if (dev->dev_ops->session_configure(dev, xforms, sess, mp) < 0) {
+			CDEV_LOG_ERR(
+				"dev_id %d failed to configure session details",
+				dev_id);
+			return -1;
+		}
 	}
 
-	dev = &rte_crypto_devices[dev_id];
+	return 0;
+}
+
+struct rte_cryptodev_sym_session *
+rte_cryptodev_sym_session_create(struct rte_mempool *mp)
+{
+	struct rte_cryptodev_sym_session *sess;
 
 	/* Allocate a session structure from the session pool */
-	if (rte_mempool_get(dev->data->session_pool, &_sess)) {
-		CDEV_LOG_ERR("Couldn't get object from session mempool");
+	if (rte_mempool_get(mp, (void *)&sess)) {
+		CDEV_LOG_ERR("couldn't get object from session mempool");
 		return NULL;
 	}
 
-	sess = _sess;
-
-	rte_cryptodev_sym_session_init(dev->data->session_pool, dev,
-					sess);
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL);
-	if (dev->dev_ops->session_configure(dev, xform, sess->_private) ==
-			NULL) {
-		CDEV_LOG_ERR("dev_id %d failed to configure session details",
-				dev_id);
-
-		/* Return session to mempool */
-		rte_mempool_put(dev->data->session_pool, _sess);
-		return NULL;
-	}
+	/* Clear device session pointer */
+	memset(sess, 0, (sizeof(void *) * nb_drivers));
 
 	return sess;
 }
@@ -1085,7 +1080,10 @@ rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0);
-	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) {
+
+	void *sess_priv = get_session_private_data(sess, dev->driver_id);
+
+	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess_priv)) {
 		CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session",
 				dev_id, qp_id);
 		return -EPERM;
@@ -1109,7 +1107,10 @@ rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0);
-	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) {
+
+	void *sess_priv = get_session_private_data(sess, dev->driver_id);
+
+	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess_priv)) {
 		CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session",
 				dev_id, qp_id);
 		return -EPERM;
@@ -1117,34 +1118,45 @@ rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	return 0;
 }
-struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
-		struct rte_cryptodev_sym_session *sess)
+void
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess)
 {
-	struct rte_cryptodev *dev;
+	uint8_t i;
+	struct rte_mempool *sess_mp;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return sess;
-	}
+	if (sess == NULL)
+		return;
 
-	dev = &rte_crypto_devices[dev_id];
+	void *sess_priv;
 
-	/* Let device implementation clear session material */
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_clear, sess);
-	dev->dev_ops->session_clear(dev, (void *)sess->_private);
+	for (i = 0; i < nb_drivers; i++) {
+		if (sess->sess_private_data[i] != NULL) {
+			sess_priv = get_session_private_data(sess, i);
+			sess_mp = rte_mempool_from_obj(sess_priv);
+			rte_mempool_put(sess_mp, sess_priv);
+		}
+	}
 
 	/* Return session to mempool */
-	struct rte_mempool *mp = rte_mempool_from_obj(sess);
-	rte_mempool_put(mp, (void *)sess);
+	sess_mp = rte_mempool_from_obj(sess);
+	rte_mempool_put(sess_mp, sess);
+}
 
-	return NULL;
+unsigned int
+rte_cryptodev_get_header_session_size(void)
+{
+	/*
+	 * Header contains pointers to the private data
+	 * of all registered drivers
+	 */
+	return (sizeof(void *) * nb_drivers);
 }
 
 unsigned int
 rte_cryptodev_get_private_session_size(uint8_t dev_id)
 {
 	struct rte_cryptodev *dev;
+	unsigned int header_size = sizeof(void *) * nb_drivers;
 	unsigned int priv_sess_size;
 
 	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
@@ -1157,6 +1169,14 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id)
 
 	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
 
+	/*
+	 * If size is less than session header size,
+	 * return the latter, as this guarantees that
+	 * sessionless operations will work
+	 */
+	if (priv_sess_size < header_size)
+		return header_size;
+
 	return priv_sess_size;
 
 }
@@ -1272,8 +1292,6 @@ struct cryptodev_driver {
 	uint8_t id;
 };
 
-static uint8_t nb_drivers;
-
 int
 rte_cryptodev_driver_id_get(const char *name)
 {
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 044a4aa..2204982 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -797,50 +797,59 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 /** Cryptodev symmetric crypto session */
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
-	__extension__ char _private[0];
+	__extension__ void *sess_private_data[0];
 	/**< Private session material */
 };
 
 
 /**
- * Initialise a session for symmetric cryptographic operations.
+ * Create symmetric crypto session (generic with no private data)
  *
- * This function is used by the client to initialize immutable
- * parameters of symmetric cryptographic operation.
- * To perform the operation the rte_cryptodev_enqueue_burst function is
- * used.  Each mbuf should contain a reference to the session
- * pointer returned from this function contained within it's crypto_op if a
- * session-based operation is being provisioned. Memory to contain the session
- * information is allocated from within mempool managed by the cryptodev.
- *
- * The rte_cryptodev_session_free must be called to free allocated
- * memory when the session is no longer required.
+ * @param   mempool    Symmetric session mempool to allocate session
+ *                     objects from
+ * @return
+ *  - On success return pointer to sym-session
+ *  - On failure returns NULL
+ */
+struct rte_cryptodev_sym_session *
+rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
+
+/**
+ * Frees symmetric crypto session and all related device type specific
+ * private data objects associated with session
  *
- * @param	dev_id		The device identifier.
- * @param	xform		Crypto transform chain.
+ * @param   session  Session where the private data will be attached to
+ */
+void
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *session);
 
+/**
+ * Fill out private data for the device id, based on its device type
+ *
+ * @param   dev_id   ID of device that we want the session to be used on
+ * @param   sess     Session where the private data will be attached to
+ * @param   xforms   Symmetric crypto transform operations to apply on flow
+ *                   processed with this session
+ * @param   mempool  Mempool where the private data is allocated.
  *
  * @return
- *  Pointer to the created session or NULL
+ *  - On success, zero.
+ *  - On failure, a negative value.
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform);
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+			struct rte_cryptodev_sym_session *sess,
+			struct rte_crypto_sym_xform *xforms,
+			struct rte_mempool *mempool);
 
 /**
- * Free the memory associated with a previously allocated session.
- *
- * @param	dev_id		The device identifier.
- * @param	session		Session pointer previously allocated by
- *				*rte_cryptodev_sym_session_create*.
+ * Get the size of the header session, for all registered drivers.
  *
  * @return
- *   NULL on successful freeing of session.
- *   Session pointer on failure to free session.
+ *   Size of the header session.
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
-		struct rte_cryptodev_sym_session *session);
+unsigned int
+rte_cryptodev_get_header_session_size(void);
 
 /**
  * Get the size of the private session data for a device.
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 5911b83..959a8ae 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -285,13 +285,16 @@ typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
  * @param	dev		Crypto device pointer
  * @param	xform		Single or chain of crypto xforms
  * @param	priv_sess	Pointer to cryptodev's private session structure
+ * @param	mp		Mempool where the private session is allocated
  *
  * @return
- *  - Returns private session structure on success.
- *  - Returns NULL on failure.
+ *  - Returns 0 if private session structure have been created successfully.
+ *  - Returns -1 on failure.
  */
-typedef void * (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
-		struct rte_crypto_sym_xform *xform, void *session_private);
+typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *session,
+		struct rte_mempool *mp);
 
 /**
  * Free Crypto session.
@@ -413,6 +416,19 @@ void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 int
 rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
 
+static inline void *
+get_session_private_data(struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id) {
+	return sess->sess_private_data[driver_id];
+}
+
+static inline void
+set_session_private_data(struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id, void *private_data)
+{
+	sess->sess_private_data[driver_id] = private_data;
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 8855a34..c117c4f 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -65,9 +65,11 @@ DPDK_17.08 {
 	rte_cryptodev_device_count_by_driver;
 	rte_cryptodev_driver_id_get;
 	rte_cryptodev_driver_name_get;
+	rte_cryptodev_get_header_session_size;
 	rte_cryptodev_get_private_session_size;
 	rte_cryptodev_pci_generic_probe;
 	rte_cryptodev_pci_generic_remove;
+	rte_cryptodev_sym_session_init;
 	rte_cryptodev_vdev_parse_init_params;
 	rte_cryptodev_vdev_pmd_init;
 
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 3979145..9d08eb8 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -67,7 +67,6 @@ struct crypto_testsuite_params {
 	struct rte_mempool *large_mbuf_pool;
 	struct rte_mempool *op_mpool;
 	struct rte_mempool *session_mpool;
-	struct rte_mempool *slave_session_mpool;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_qp_conf qp_conf;
 
@@ -384,12 +383,15 @@ testsuite_setup(void)
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
 
-	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-		rte_cryptodev_get_private_session_size(dev_id);
+	unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
 
+	/*
+	 * Create mempool with maximum number of sessions * 2,
+	 * to include the session headers
+	 */
 	ts_params->session_mpool = rte_mempool_create(
 				"test_sess_mp",
-				info.sym.max_nb_sessions,
+				info.sym.max_nb_sessions * 2,
 				session_size,
 				0, 0, NULL, NULL, NULL,
 				NULL, SOCKET_ID_ANY,
@@ -432,11 +434,10 @@ testsuite_teardown(void)
 	}
 
 	/* Free session mempools */
-	if (ts_params->session_mpool != NULL)
+	if (ts_params->session_mpool != NULL) {
 		rte_mempool_free(ts_params->session_mpool);
-
-	if (ts_params->slave_session_mpool != NULL)
-		rte_mempool_free(ts_params->slave_session_mpool);
+		ts_params->session_mpool = NULL;
+	}
 }
 
 static int
@@ -487,8 +488,7 @@ ut_teardown(void)
 
 	/* free crypto session structure */
 	if (ut_params->sess) {
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
-				ut_params->sess);
+		rte_cryptodev_sym_session_free(ut_params->sess);
 		ut_params->sess = NULL;
 	}
 
@@ -1271,10 +1271,13 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
 
-	/* Create crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0],
-			&ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate crypto op data structure */
@@ -1496,7 +1499,9 @@ test_AES_cipheronly_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1513,7 +1518,9 @@ test_AES_docsis_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1530,7 +1537,9 @@ test_AES_docsis_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1547,7 +1556,9 @@ test_DES_docsis_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_DES_DOCSIS_TYPE);
@@ -1564,7 +1575,9 @@ test_authonly_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1581,7 +1594,9 @@ test_AES_chain_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1600,7 +1615,9 @@ test_AES_cipheronly_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1617,7 +1634,9 @@ test_AES_chain_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1634,7 +1653,9 @@ test_authonly_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1653,7 +1674,9 @@ test_AES_chain_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1670,7 +1693,9 @@ test_AES_cipheronly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1687,7 +1712,9 @@ test_AES_chain_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1704,7 +1731,9 @@ test_AES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1721,7 +1750,9 @@ test_AES_chain_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1738,7 +1769,9 @@ test_AES_cipheronly_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1755,7 +1788,9 @@ test_authonly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1772,7 +1807,9 @@ test_AES_chain_armv8_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1792,6 +1829,7 @@ create_wireless_algo_hash_session(uint8_t dev_id,
 {
 	uint8_t hash_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(hash_key, key, key_len);
@@ -1808,8 +1846,12 @@ create_wireless_algo_hash_session(uint8_t dev_id,
 	ut_params->auth_xform.auth.key.data = hash_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
 	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->auth_xform, ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
 }
@@ -1822,6 +1864,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
 {
 	uint8_t cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_key, key, key_len);
@@ -1835,12 +1878,14 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session */
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-						&ut_params->
-						cipher_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->cipher_xform, ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
 }
@@ -1951,6 +1996,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
 {
 	uint8_t cipher_auth_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_auth_key, key, key_len);
@@ -1976,11 +2022,14 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->cipher_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
@@ -1998,6 +2047,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
 	uint8_t cipher_auth_key[key_len];
 
 	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	const uint8_t *key = tdata->key.data;
 	const uint8_t aad_len = tdata->aad.len;
 	const uint8_t auth_len = tdata->digest.len;
@@ -2025,11 +2075,14 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->cipher_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
@@ -2056,6 +2109,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
 {
 	uint8_t auth_cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(auth_cipher_key, key, key_len);
@@ -2078,11 +2132,14 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -4696,7 +4753,9 @@ test_3DES_chain_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4713,7 +4772,9 @@ test_DES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_DES_CIPHERONLY_TYPE);
@@ -4730,7 +4791,9 @@ test_DES_docsis_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_DES_DOCSIS_TYPE);
@@ -4747,7 +4810,9 @@ test_3DES_chain_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4764,7 +4829,9 @@ test_3DES_cipheronly_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4781,7 +4848,9 @@ test_3DES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4798,7 +4867,9 @@ test_3DES_chain_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4815,7 +4886,9 @@ test_3DES_cipheronly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4835,6 +4908,7 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
 {
 	uint8_t cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_key, key, key_len);
@@ -4862,16 +4936,19 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
 	ut_params->auth_xform.auth.key.length = 0;
 	ut_params->auth_xform.auth.key.data = NULL;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		ut_params->cipher_xform.next = &ut_params->auth_xform;
 
 		/* Create Crypto session*/
-		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->cipher_xform, ts_params->session_mpool);
 	} else {/* Create Crypto session*/
 		ut_params->auth_xform.next = &ut_params->cipher_xform;
-		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform, ts_params->session_mpool);
 	}
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@@ -5769,7 +5846,11 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
 	ut_params->auth_xform.auth.key.data = key;
 
 	ut_params->sess = rte_cryptodev_sym_session_create(
-		ts_params->valid_devs[0], &ut_params->auth_xform);
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
 
 	if (ut_params->sess == NULL)
 		return TEST_FAILED;
@@ -5945,9 +6026,13 @@ test_multi_session(void)
 
 	/* Create multiple crypto sessions*/
 	for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
+
 		sessions[i] = rte_cryptodev_sym_session_create(
-				ts_params->valid_devs[0],
-			&ut_params->auth_xform);
+				ts_params->session_mpool);
+
+		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+				sessions[i], &ut_params->auth_xform,
+				ts_params->session_mpool);
 		TEST_ASSERT_NOT_NULL(sessions[i],
 				"Session creation failed at session number %u",
 				i);
@@ -5983,14 +6068,14 @@ test_multi_session(void)
 	}
 
 	/* Next session create should fail */
-	sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
-			&ut_params->auth_xform);
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			sessions[i], &ut_params->auth_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NULL(sessions[i],
 			"Session creation succeeded unexpectedly!");
 
 	for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
-				sessions[i]);
+		rte_cryptodev_sym_session_free(sessions[i]);
 
 	rte_free(sessions);
 
@@ -6048,6 +6133,9 @@ test_multi_session_random_usage(void)
 					* dev_info.sym.max_nb_sessions) + 1, 0);
 
 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
+		sessions[i] = rte_cryptodev_sym_session_create(
+				ts_params->session_mpool);
+
 		rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
 				sizeof(struct crypto_unittest_params));
 
@@ -6056,9 +6144,11 @@ test_multi_session_random_usage(void)
 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
 
 		/* Create multiple crypto sessions*/
-		sessions[i] = rte_cryptodev_sym_session_create(
+		rte_cryptodev_sym_session_init(
 				ts_params->valid_devs[0],
-				&ut_paramz[i].ut_params.auth_xform);
+				sessions[i],
+				&ut_paramz[i].ut_params.auth_xform,
+				ts_params->session_mpool);
 
 		TEST_ASSERT_NOT_NULL(sessions[i],
 				"Session creation failed at session number %u",
@@ -6102,8 +6192,7 @@ test_multi_session_random_usage(void)
 	}
 
 	for (i = 0; i < MB_SESSION_NUMBER; i++)
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
-				sessions[i]);
+		rte_cryptodev_sym_session_free(sessions[i]);
 
 	rte_free(sessions);
 
@@ -6127,9 +6216,14 @@ test_null_cipher_only_operation(void)
 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+				ut_params->sess,
+				&ut_params->cipher_xform,
+				ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6184,9 +6278,13 @@ test_null_auth_only_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->auth_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6240,9 +6338,13 @@ test_null_cipher_auth_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6306,9 +6408,13 @@ test_null_auth_cipher_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6354,6 +6460,7 @@ test_null_invalid_operation(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
+	int ret;
 
 	/* Setup Cipher Parameters */
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@@ -6362,10 +6469,14 @@ test_null_invalid_operation(void)
 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
-	TEST_ASSERT_NULL(ut_params->sess,
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
+	TEST_ASSERT(ret == -1,
 			"Session creation succeeded unexpectedly");
 
 
@@ -6376,10 +6487,14 @@ test_null_invalid_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->auth_xform);
-	TEST_ASSERT_NULL(ut_params->sess,
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
+	TEST_ASSERT(ret == -1,
 			"Session creation succeeded unexpectedly");
 
 	return TEST_SUCCESS;
@@ -6413,9 +6528,13 @@ test_null_burst_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
@@ -6556,6 +6675,7 @@ static int create_gmac_session(uint8_t dev_id,
 {
 	uint8_t cipher_key[tdata->key.len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_key, tdata->key.data, tdata->key.len);
@@ -6580,8 +6700,12 @@ static int create_gmac_session(uint8_t dev_id,
 
 	ut_params->cipher_xform.next = &ut_params->auth_xform;
 
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-			&ut_params->cipher_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->cipher_xform,
+			ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -6911,6 +7035,7 @@ create_auth_session(struct crypto_unittest_params *ut_params,
 		const struct test_crypto_vector *reference,
 		enum rte_crypto_auth_operation auth_op)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t auth_key[reference->auth_key.len + 1];
 
 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
@@ -6925,9 +7050,13 @@ create_auth_session(struct crypto_unittest_params *ut_params,
 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
 	ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform,
+				ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -6941,6 +7070,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
 		enum rte_crypto_auth_operation auth_op,
 		enum rte_crypto_cipher_operation cipher_op)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t cipher_key[reference->cipher_key.len + 1];
 	uint8_t auth_key[reference->auth_key.len + 1];
 
@@ -6966,9 +7096,13 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
 	ut_params->cipher_xform.cipher.key.data = cipher_key;
 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform,
+				ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -7860,30 +7994,32 @@ test_scheduler_attach_slave_op(void)
 			continue;
 
 		/*
-		 * Create a separate mempool for the slaves, as they need different
-		 * session size and then configure them to store the pointer
-		 * to this mempool
+		 * Create the session mempool again, since now there are new devices
+		 * to use the mempool.
 		 */
-		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(i);
-
-		if (ts_params->slave_session_mpool == NULL) {
-			ts_params->slave_session_mpool = rte_mempool_create(
-				"test_slave_sess_mp",
-				info.sym.max_nb_sessions,
-				session_size,
-				0, 0, NULL, NULL, NULL, NULL,
-				SOCKET_ID_ANY, 0);
+		if (ts_params->session_mpool) {
+			rte_mempool_free(ts_params->session_mpool);
+			ts_params->session_mpool = NULL;
+		}
+		unsigned int session_size = rte_cryptodev_get_private_session_size(i);
 
-			TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
+		/*
+		 * Create mempool with maximum number of sessions * 2,
+		 * to include the session headers
+		 */
+		if (ts_params->session_mpool == NULL) {
+			ts_params->session_mpool = rte_mempool_create(
+					"test_sess_mp",
+					info.sym.max_nb_sessions * 2,
+					session_size,
+					0, 0, NULL, NULL, NULL,
+					NULL, SOCKET_ID_ANY,
+					0);
+
+			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
 					"session mempool allocation failed");
 		}
 
-		TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
-				&ts_params->conf, ts_params->slave_session_mpool),
-				"Failed to configure cryptodev %u with %u qps",
-				i, ts_params->conf.nb_queue_pairs);
-
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
diff --git a/test/test/test_cryptodev_blockcipher.c b/test/test/test_cryptodev_blockcipher.c
index 4bc370d..b2e600f 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -52,6 +52,7 @@ static int
 test_blockcipher_one_case(const struct blockcipher_test_case *t,
 	struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	char *test_msg)
@@ -64,8 +65,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 	struct rte_crypto_sym_xform *init_xform = NULL;
 	struct rte_crypto_sym_op *sym_op = NULL;
 	struct rte_crypto_op *op = NULL;
-	struct rte_cryptodev_sym_session *sess = NULL;
 	struct rte_cryptodev_info dev_info;
+	struct rte_cryptodev_sym_session *sess = NULL;
 
 	int status = TEST_SUCCESS;
 	const struct blockcipher_test_data *tdata = t->test_data;
@@ -349,8 +350,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 
 	/* create session for sessioned op */
 	if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
-		sess = rte_cryptodev_sym_session_create(dev_id,
-			init_xform);
+		sess = rte_cryptodev_sym_session_create(sess_mpool);
+
+		rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
+				sess_mpool);
 		if (!sess) {
 			snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
 				"FAILED: %s", __LINE__,
@@ -448,7 +451,6 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 		else
 			auth_res = pktmbuf_mtod_offset(iobuf,
 					tdata->ciphertext.len);
-
 		if (memcmp(auth_res, tdata->digest.data, digest_len)) {
 			snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
 				"FAILED: %s", __LINE__, "Generated "
@@ -577,7 +579,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 error_exit:
 	if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
 		if (sess)
-			rte_cryptodev_sym_session_free(dev_id, sess);
+			rte_cryptodev_sym_session_free(sess);
 		if (cipher_xform)
 			rte_free(cipher_xform);
 		if (auth_xform)
@@ -599,6 +601,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 int
 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	enum blockcipher_test_type test_type)
@@ -690,7 +693,7 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 			continue;
 
 		status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
-			dev_id, driver_id, test_msg);
+			sess_mpool, dev_id, driver_id, test_msg);
 
 		printf("  %u) TestCase %s %s\n", test_index ++,
 			tc->test_descr, test_msg);
diff --git a/test/test/test_cryptodev_blockcipher.h b/test/test/test_cryptodev_blockcipher.h
index 22fb420..22b8d20 100644
--- a/test/test/test_cryptodev_blockcipher.h
+++ b/test/test/test_cryptodev_blockcipher.h
@@ -125,6 +125,7 @@ struct blockcipher_test_data {
 int
 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	enum blockcipher_test_type test_type);
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 526be82..68c5fdd 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -50,7 +50,7 @@
 struct crypto_testsuite_params {
 	struct rte_mempool *mbuf_mp;
 	struct rte_mempool *op_mpool;
-	struct rte_mempool *session_mpool;
+	struct rte_mempool *sess_mp;
 
 	uint16_t nb_queue_pairs;
 
@@ -100,6 +100,8 @@ struct symmetric_session_attrs {
 	uint32_t digest_len;
 };
 
+static struct rte_cryptodev_sym_session *test_crypto_session;
+
 #define ALIGN_POW2_ROUNDUP(num, align) \
 	(((num) + (align) - 1) & ~((align) - 1))
 
@@ -148,17 +150,17 @@ struct crypto_unittest_params {
 	uint8_t *digest;
 };
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo);
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo);
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
@@ -399,7 +401,7 @@ testsuite_setup(void)
 	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
 		rte_cryptodev_get_private_session_size(ts_params->dev_id);
 
-	ts_params->session_mpool = rte_mempool_create(
+	ts_params->sess_mp = rte_mempool_create(
 				"test_sess_mp_perf",
 				info.sym.max_nb_sessions,
 				session_size,
@@ -407,11 +409,11 @@ testsuite_setup(void)
 				NULL, SOCKET_ID_ANY,
 				0);
 
-	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
+	TEST_ASSERT_NOT_NULL(ts_params->sess_mp,
 			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf, ts_params->sess_mp),
 			"Failed to configure cryptodev %u",
 			ts_params->dev_id);
 
@@ -441,8 +443,10 @@ testsuite_teardown(void)
 		RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_OP POOL count %u\n",
 		rte_mempool_avail_count(ts_params->op_mpool));
 	/* Free session mempool */
-	if (ts_params->session_mpool != NULL)
-		rte_mempool_free(ts_params->session_mpool);
+	if (ts_params->sess_mp != NULL) {
+		rte_mempool_free(ts_params->sess_mp);
+		ts_params->sess_mp = NULL;
+	}
 
 }
 
@@ -476,8 +480,7 @@ ut_teardown(void)
 
 	/* free crypto session structure */
 	if (ut_params->sess)
-		rte_cryptodev_sym_session_free(ts_params->dev_id,
-				ut_params->sess);
+		rte_cryptodev_sym_session_free(ut_params->sess);
 
 	/* free crypto operation structure */
 	if (ut_params->op)
@@ -1956,10 +1959,13 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(ts_params->dev_id,
-		&ut_params->cipher_xform);
 
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
+	rte_cryptodev_sym_session_init(ts_params->dev_id, test_crypto_session,
+			&ut_params->cipher_xform, ts_params->sess_mp);
+
+	TEST_ASSERT_NOT_NULL(test_crypto_session, "Session creation failed");
 
 	/* Generate Crypto op data structure(s) */
 	for (i = 0; i < num_to_submit ; i++) {
@@ -1981,7 +1987,7 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
 				rte_crypto_op_alloc(ts_params->op_mpool,
 						RTE_CRYPTO_OP_TYPE_SYMMETRIC);
 
-		rte_crypto_op_attach_sym_session(op, ut_params->sess);
+		rte_crypto_op_attach_sym_session(op, test_crypto_session);
 
 		op->sym->auth.digest.data = ut_params->digest;
 		op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
@@ -2099,9 +2105,12 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_snow3g_session(ts_params->dev_id,
+	if (test_perf_create_snow3g_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2197,7 +2206,7 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
 		rte_pktmbuf_free(c_ops[i]->sym->m_src);
 		rte_crypto_op_free(c_ops[i]);
 	}
-	rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return TEST_SUCCESS;
 }
@@ -2278,9 +2287,13 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_openssl_session(ts_params->dev_id,
+	if (test_perf_create_openssl_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
+
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2401,7 +2414,7 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
 		rte_pktmbuf_free(c_ops[i]->sym->m_src);
 		rte_crypto_op_free(c_ops[i]);
 	}
-	rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return TEST_SUCCESS;
 }
@@ -2430,9 +2443,12 @@ test_perf_armv8_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_armv8_session(ts_params->dev_id,
+	if (test_perf_create_armv8_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2644,12 +2660,13 @@ static uint8_t snow3g_hash_key[] = {
 		0x1E, 0x26, 0x98, 0xD2, 0xE2, 0x2A, 0xD5, 0x7E
 };
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2671,33 +2688,42 @@ test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
 		auth_xform.auth.digest_length =
 					get_auth_digest_length(auth_algo);
 	}
+
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	case CIPHER_ONLY:
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
 #define SNOW3G_CIPHER_IV_LENGTH 16
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo, unsigned cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = {0};
 	struct rte_crypto_sym_xform auth_xform = {0};
 
@@ -2720,36 +2746,46 @@ test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 	auth_xform.auth.key.length =  get_auth_key_max_length(auth_algo);
 	auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	case CIPHER_ONLY:
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_ONLY:
 		auth_xform.next = NULL;
 		/* Create Crypto session */
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2769,7 +2805,7 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		cipher_xform.cipher.key.data = aes_key;
 		break;
 	default:
-		return NULL;
+		return -1;
 	}
 
 	cipher_xform.cipher.key.length = cipher_key_len;
@@ -2787,34 +2823,40 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		auth_xform.auth.key.data = NULL;
 		break;
 	default:
-		return NULL;
+		return -1;
 	}
 
 	auth_xform.auth.key.length =  get_auth_key_max_length(auth_algo);
 	auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2827,7 +2869,7 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		cipher_xform.cipher.key.data = aes_cbc_128_key;
 		break;
 	default:
-		return NULL;
+		return -1;
 	}
 
 	cipher_xform.cipher.key.length = cipher_key_len;
@@ -2839,6 +2881,8 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 
 	auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
 
+	rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
@@ -2846,16 +2890,20 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		/* Encrypt and hash the result */
 		cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Hash encrypted message and decrypt */
 		cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
@@ -3123,9 +3171,12 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_aes_sha_session(ts_params->dev_id,
+	if (test_perf_create_aes_sha_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3221,7 +3272,7 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3257,9 +3308,12 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_snow3g_session(ts_params->dev_id,
+	if (test_perf_create_snow3g_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3386,7 +3440,7 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3443,9 +3497,12 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_openssl_session(ts_params->dev_id,
+	if (test_perf_create_openssl_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3538,7 +3595,7 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3575,9 +3632,12 @@ test_perf_armv8(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_armv8_session(ts_params->dev_id,
+	if (test_perf_create_armv8_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -4122,7 +4182,7 @@ test_perf_aes_cbc_vary_burst_size(void)
 static struct rte_cryptodev_sym_session *
 test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
 {
-	static struct rte_cryptodev_sym_session *sess;
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -4151,19 +4211,20 @@ test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
 	auth_xform.auth.digest_length = pparams->session_attrs->digest_len;
 	auth_xform.auth.key.length = pparams->session_attrs->key_auth_len;
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 
 	cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 	if (cipher_xform.cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		cipher_xform.next = &auth_xform;
-		sess = rte_cryptodev_sym_session_create(dev_id,
-				&cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, test_crypto_session,
+				&cipher_xform, ts_params->sess_mp);
 	} else {
 		auth_xform.next = &cipher_xform;
-		sess = rte_cryptodev_sym_session_create(dev_id,
-				&auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, test_crypto_session,
+				&auth_xform, ts_params->sess_mp);
 	}
 
-	return sess;
+	return test_crypto_session;
 }
 
 static inline struct rte_crypto_op *
@@ -4405,7 +4466,7 @@ perf_AES_GCM(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < burst; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return 0;
 }
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 10/11] cryptodev: add mempool pointer in queue pair setup
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (8 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 09/11] cryptodev: support device independent sessions Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-06-30 17:09   ` [PATCH v2 11/11] doc: add new crypto session information Pablo de Lara
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
  11 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

The session mempool pointer is needed in each queue pair,
if session-less operations are being handled.
Therefore, the API is changed to accept this parameter,
as the session mempool is created outside the
device configuration function, similar to what ethdev
does with the rx queues.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/main.c                    |  5 +--
 doc/guides/rel_notes/release_17_08.rst         |  2 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c   |  4 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c |  4 +-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c       |  4 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c    |  3 +-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c     |  4 +-
 drivers/crypto/null/null_crypto_pmd_ops.c      |  4 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c   |  4 +-
 drivers/crypto/qat/qat_crypto.h                |  3 +-
 drivers/crypto/qat/qat_qp.c                    |  2 +-
 drivers/crypto/scheduler/scheduler_pmd_ops.c   | 13 ++++--
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c     |  4 +-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c           |  4 +-
 lib/librte_cryptodev/rte_cryptodev.c           | 11 +++--
 lib/librte_cryptodev/rte_cryptodev.h           |  9 ++--
 lib/librte_cryptodev/rte_cryptodev_pmd.h       |  3 +-
 test/test/test_cryptodev.c                     | 58 +++++++++++++++-----------
 test/test/test_cryptodev_perf.c                |  5 ++-
 19 files changed, 81 insertions(+), 65 deletions(-)

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 9f5c6be..0cf4618 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -108,8 +108,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		};
 
 
-		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf,
-							cperf_mempool);
+		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf);
 		if (ret < 0) {
 			printf("Failed to configure cryptodev %u",
 					enabled_cdevs[cdev_id]);
@@ -117,7 +116,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		}
 
 		ret = rte_cryptodev_queue_pair_setup(enabled_cdevs[cdev_id], 0,
-				&qp_conf, SOCKET_ID_ANY);
+				&qp_conf, SOCKET_ID_ANY, cperf_mempool);
 			if (ret < 0) {
 				printf("Failed to setup queue pair %u on "
 					"cryptodev %u",	0, cdev_id);
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index ad1f269..923cc3e 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -167,7 +167,7 @@ API Changes
   * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
   * Replaced ``private`` marker with array of pointers to private data sessions
     ``sess_private_data`` in ``rte_cryptodev_sym_session``
-
+  * Added new field ``session_pool`` to ``rte_cryptodev_queue_pair_setup()``.
 
 ABI Changes
 -----------
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 0b063fd..d47a041 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -244,7 +244,7 @@ aesni_gcm_pmd_qp_create_processed_pkts_ring(struct aesni_gcm_qp *qp,
 static int
 aesni_gcm_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct aesni_gcm_qp *qp = NULL;
 
@@ -269,7 +269,7 @@ aesni_gcm_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_pkts == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index fda8296..1216e56 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -397,7 +397,7 @@ aesni_mb_pmd_qp_create_processed_ops_ring(struct aesni_mb_qp *qp,
 static int
 aesni_mb_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct aesni_mb_qp *qp = NULL;
 	struct aesni_mb_private *internals = dev->data->dev_private;
@@ -426,7 +426,7 @@ aesni_mb_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->ingress_queue == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 3db420b..735116f 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -247,7 +247,7 @@ armv8_crypto_pmd_qp_create_processed_ops_ring(struct armv8_crypto_qp *qp,
 static int
 armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct armv8_crypto_qp *qp = NULL;
 
@@ -272,7 +272,7 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index c71b0c7..0382dc0 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -660,7 +660,8 @@ dpaa2_sec_queue_pair_release(struct rte_cryptodev *dev, uint16_t queue_pair_id)
 static int
 dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		__rte_unused const struct rte_cryptodev_qp_conf *qp_conf,
-		__rte_unused int socket_id)
+		__rte_unused int socket_id,
+		__rte_unused struct rte_mempool *session_pool)
 {
 	struct dpaa2_sec_dev_private *priv = dev->data->dev_private;
 	struct dpaa2_sec_qp *qp;
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index d590b91..2805e6f 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -223,7 +223,7 @@ kasumi_pmd_qp_create_processed_ops_ring(struct kasumi_qp *qp,
 static int
 kasumi_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct kasumi_qp *qp = NULL;
 
@@ -248,7 +248,7 @@ kasumi_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index 04147fe..7d0ac2d 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -215,7 +215,7 @@ null_crypto_pmd_qp_create_processed_pkts_ring(struct null_crypto_qp *qp,
 static int
 null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct null_crypto_private *internals = dev->data->dev_private;
 	struct null_crypto_qp *qp;
@@ -258,7 +258,7 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		goto qp_setup_cleanup;
 	}
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 005855b..d8eb335 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -602,7 +602,7 @@ openssl_pmd_qp_create_processed_ops_ring(struct openssl_qp *qp,
 static int
 openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct openssl_qp *qp = NULL;
 
@@ -627,7 +627,7 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h
index d5466c2..65af962 100644
--- a/drivers/crypto/qat/qat_crypto.h
+++ b/drivers/crypto/qat/qat_crypto.h
@@ -103,7 +103,8 @@ void qat_crypto_sym_stats_get(struct rte_cryptodev *dev,
 void qat_crypto_sym_stats_reset(struct rte_cryptodev *dev);
 
 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
-	const struct rte_cryptodev_qp_conf *rx_conf, int socket_id);
+	const struct rte_cryptodev_qp_conf *rx_conf, int socket_id,
+	struct rte_mempool *session_pool);
 int qat_crypto_sym_qp_release(struct rte_cryptodev *dev,
 	uint16_t queue_pair_id);
 
diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c
index 3921c2e..2b2ab42 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -134,7 +134,7 @@ queue_dma_zone_reserve(const char *queue_name, uint32_t queue_size,
 
 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 	const struct rte_cryptodev_qp_conf *qp_conf,
-	int socket_id)
+	int socket_id, struct rte_mempool *session_pool __rte_unused)
 {
 	struct qat_qp *qp;
 	struct rte_pci_device *pci_dev;
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index 6e37efc..b434244 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -101,8 +101,7 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
 
-		ret = rte_cryptodev_configure(slave_dev_id, config,
-				dev->data->session_pool);
+		ret = rte_cryptodev_configure(slave_dev_id, config);
 		if (ret < 0)
 			break;
 	}
@@ -400,7 +399,8 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 /** Setup a queue pair */
 static int
 scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
-	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+	struct rte_mempool *session_pool)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	struct scheduler_qp_ctx *qp_ctx;
@@ -422,8 +422,13 @@ scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_id = sched_ctx->slaves[i].dev_id;
 
+		/*
+		 * All slaves will share the same session mempool
+		 * for session-less operations, so the objects
+		 * must be big enough for all the drivers used.
+		 */
 		ret = rte_cryptodev_queue_pair_setup(slave_id, qp_id,
-				qp_conf, socket_id);
+				qp_conf, socket_id, session_pool);
 		if (ret < 0)
 			return ret;
 	}
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index 1967409..04151bc 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -220,7 +220,7 @@ snow3g_pmd_qp_create_processed_ops_ring(struct snow3g_qp *qp,
 static int
 snow3g_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct snow3g_qp *qp = NULL;
 
@@ -245,7 +245,7 @@ snow3g_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index cdc783f..7cf6542 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -220,7 +220,7 @@ zuc_pmd_qp_create_processed_ops_ring(struct zuc_qp *qp,
 static int
 zuc_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct zuc_qp *qp = NULL;
 
@@ -245,7 +245,7 @@ zuc_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index f5a72de..7e3b202 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -686,8 +686,7 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
 }
 
 int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
-		struct rte_mempool *session_pool)
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 {
 	struct rte_cryptodev *dev;
 	int diag;
@@ -707,8 +706,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
-	dev->data->session_pool = session_pool;
-
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
 			config->socket_id);
@@ -820,7 +817,9 @@ rte_cryptodev_close(uint8_t dev_id)
 
 int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
-		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+		struct rte_mempool *session_pool)
+
 {
 	struct rte_cryptodev *dev;
 
@@ -844,7 +843,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_pair_setup, -ENOTSUP);
 
 	return (*dev->dev_ops->queue_pair_setup)(dev, queue_pair_id, qp_conf,
-			socket_id);
+			socket_id, session_pool);
 }
 
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 2204982..aa68095 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -439,15 +439,13 @@ struct rte_cryptodev_config {
  *
  * @param	dev_id		The identifier of the device to configure.
  * @param	config		The crypto device configuration structure.
- * @param	session_pool	Pointer to device session mempool
  *
  * @return
  *   - 0: Success, device configured.
  *   - <0: Error code returned by the driver configuration function.
  */
 extern int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
-		struct rte_mempool *session_pool);
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
 
 /**
  * Start an device.
@@ -506,6 +504,8 @@ rte_cryptodev_close(uint8_t dev_id);
  *				*SOCKET_ID_ANY* if there is no NUMA constraint
  *				for the DMA memory allocated for the receive
  *				queue pair.
+ * @param	session_pool	Pointer to device session mempool, used
+ *				for session-less operations.
  *
  * @return
  *   - 0: Success, queue pair correctly set up.
@@ -513,7 +513,8 @@ rte_cryptodev_close(uint8_t dev_id);
  */
 extern int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
-		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
+		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+		struct rte_mempool *session_pool);
 
 /**
  * Start a specified queue pair of a device. It is used
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 959a8ae..886aa23 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -207,12 +207,13 @@ typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
  * @param	qp_id		Queue Pair Index
  * @param	qp_conf		Queue configuration structure
  * @param	socket_id	Socket Index
+ * @param	session_pool	Pointer to device session mempool
  *
  * @return	Returns 0 on success.
  */
 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
 		uint16_t qp_id,	const struct rte_cryptodev_qp_conf *qp_conf,
-		int socket_id);
+		int socket_id, struct rte_mempool *session_pool);
 
 /**
  * Release memory resources allocated by given queue pair.
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 9d08eb8..bf117b3 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -401,7 +401,7 @@ testsuite_setup(void)
 			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u with %u qps",
 			dev_id, ts_params->conf.nb_queue_pairs);
 
@@ -410,7 +410,8 @@ testsuite_setup(void)
 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			dev_id, qp_id, &ts_params->qp_conf,
-			rte_cryptodev_socket_id(dev_id)),
+			rte_cryptodev_socket_id(dev_id),
+			ts_params->session_mpool),
 			"Failed to setup queue pair %u on cryptodev %u",
 			qp_id, dev_id);
 	}
@@ -455,7 +456,7 @@ ut_setup(void)
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -463,7 +464,8 @@ ut_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0], qp_id,
 			&ts_params->qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed to setup queue pair %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
 	}
@@ -537,23 +539,20 @@ test_device_configure_invalid_dev_id(void)
 	/* Stop the device in case it's started so it can be configured */
 	rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
 
-	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	/* invalid dev_id values */
 	dev_id = num_devs;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	dev_id = 0xff;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure:"
 			"invalid dev_num %u", dev_id);
 
@@ -573,7 +572,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 1;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
 
@@ -582,7 +581,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0],
 			ts_params->conf.nb_queue_pairs);
@@ -592,7 +591,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 0;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -603,7 +602,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -614,7 +613,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -644,7 +643,7 @@ test_queue_pair_descriptor_setup(void)
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -658,7 +657,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for "
 				"rte_cryptodev_queue_pair_setup: num_inflights "
 				"%u on qp %u on cryptodev %u",
@@ -672,7 +672,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for"
 				" rte_cryptodev_queue_pair_setup: num_inflights"
 				" %u on qp %u on cryptodev %u",
@@ -686,7 +687,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for "
 				"rte_cryptodev_queue_pair_setup: num_inflights"
 				" %u on qp %u on cryptodev %u",
@@ -701,7 +703,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -716,7 +719,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -730,7 +734,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for"
 				" rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -745,7 +750,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -761,7 +767,8 @@ test_queue_pair_descriptor_setup(void)
 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0],
 			qp_id, &qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed test for rte_cryptodev_queue_pair_setup:"
 			"invalid qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
@@ -771,7 +778,8 @@ test_queue_pair_descriptor_setup(void)
 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0],
 			qp_id, &qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed test for rte_cryptodev_queue_pair_setup:"
 			"invalid qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 68c5fdd..8a40381 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -413,7 +413,7 @@ testsuite_setup(void)
 			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
-			&ts_params->conf, ts_params->sess_mp),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->dev_id);
 
@@ -423,7 +423,8 @@ testsuite_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			ts_params->dev_id, qp_id,
 				&ts_params->qp_conf,
-				rte_cryptodev_socket_id(ts_params->dev_id)),
+				rte_cryptodev_socket_id(ts_params->dev_id),
+				ts_params->sess_mp),
 				"Failed to setup queue pair %u on cryptodev %u",
 				qp_id, ts_params->dev_id);
 	}
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 11/11] doc: add new crypto session information
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (9 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 10/11] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
@ 2017-06-30 17:09   ` Pablo de Lara
  2017-07-02 20:15     ` Mcnamara, John
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
  11 siblings, 1 reply; 44+ messages in thread
From: Pablo de Lara @ 2017-06-30 17:09 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara, Slawomir Mrozowicz

Modified cryptodev library section in Programmer's Guide,
with the recent changes in the rypto sessions.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/prog_guide/cryptodev_lib.rst          |  59 ++--
 doc/guides/prog_guide/img/cryptodev_sym_sess.svg | 418 ++++++++++++++++++++---
 2 files changed, 400 insertions(+), 77 deletions(-)

diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst
index 4644802..690fb72 100644
--- a/doc/guides/prog_guide/cryptodev_lib.rst
+++ b/doc/guides/prog_guide/cryptodev_lib.rst
@@ -114,9 +114,8 @@ The rte_cryptodev_configure API is used to configure a Crypto device.
    int rte_cryptodev_configure(uint8_t dev_id,
                                struct rte_cryptodev_config *config)
 
-The ``rte_cryptodev_config`` structure is used to pass the configuration parameters.
-In contains parameter for socket selection, number of queue pairs and the
-session mempool configuration.
+The ``rte_cryptodev_config`` structure is used to pass the configuration
+parameters for socket selection and number of queue pairs.
 
 .. code-block:: c
 
@@ -125,12 +124,6 @@ session mempool configuration.
         /**< Socket to allocate resources on */
         uint16_t nb_queue_pairs;
         /**< Number of queue pairs to configure on device */
-
-        struct {
-            uint32_t nb_objs;
-            uint32_t cache_size;
-        } session_mp;
-        /**< Session mempool configuration */
     };
 
 
@@ -431,7 +424,7 @@ operations, as well as also supporting AEAD operations.
 Session and Session Management
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Session are used in symmetric cryptographic processing to store the immutable
+Sessions are used in symmetric cryptographic processing to store the immutable
 data defined in a cryptographic transform which is used in the operation
 processing of a packet flow. Sessions are used to manage information such as
 expand cipher keys and HMAC IPADs and OPADs, which need to be calculated for a
@@ -442,27 +435,31 @@ Crypto workloads.
 
 .. figure:: img/cryptodev_sym_sess.*
 
-The Crypto device framework provides a set of session pool management APIs for
-the creation and freeing of the sessions, utilizing the Mempool Library.
-
-The framework also provides hooks so the PMDs can pass the amount of memory
-required for that PMDs private session parameters, as well as initialization
-functions for the configuration of the session parameters and freeing function
-so the PMD can managed the memory on destruction of a session.
-
-**Note**: Sessions created on a particular device can only be used on Crypto
-devices of the same type - the same driver id used by this devices,
-and if you try to use a session on a device different
-to that on which it was created then the Crypto operation will fail.
-
-``rte_cryptodev_sym_session_create()`` is used to create a symmetric session on
-Crypto device. A symmetric transform chain is used to specify the particular
-operation and its parameters. See the section below for details on transforms.
-
-.. code-block:: c
-
-   struct rte_cryptodev_sym_session * rte_cryptodev_sym_session_create(
-          uint8_t dev_id, struct rte_crypto_sym_xform *xform);
+The Crypto device framework provides APIs to allocate and initizalize sessions
+for crypto devices, where sessions are mempool objects.
+It is the application responsability to create and manage the session mempools.
+This approach allows for different scenarios such as having a single session
+mempool for all crypto devices (where the the mempool object size is big
+enough to hold the private session of any crypto device), as well as having
+multiple session mempools of different sizes for better memory usage.
+
+An application could use ``rte_cryptodev_get_private_session_size()`` to
+get the private session size of given crypto device. This function would allow
+an application to calculate the max device session size of all crypto devices
+to create a single session mempool.
+If instead an application creates multiple session mempools, the Crypto device
+framework also provides ``rte_cryptodev_get_header_session_size`` to get
+the size of an uninitialized session.
+
+Once the session mempools have been created, ``rte_cryptodev_sym_session_create()``
+is used to allocate an uninitialized session from the given mempool.
+The session then must be initialized ``rte_cryptodev_sym_session_init()``
+for each of the crypto devices to be used with. A symmetric transform chain
+is used to specify the operation and its parameters. See the section below for
+details on transforms.
+
+Unused session should be free using ``rte_cryptodev_sym_session_free`` which
+returns them to their mempool.
 
 **Note**: For AEAD operations the algorithm selected for authentication and
 ciphering must aligned, eg AES_GCM.
diff --git a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
index e5f41ec..a807ceb 100644
--- a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
+++ b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
@@ -1,10 +1,50 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <!-- Generated by Microsoft Visio, SVG Export cryptodev_sym_sess.svg Page-1 -->
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"
-		width="2.17241in" height="2.8102in" viewBox="0 0 156.413 202.335" xml:space="preserve" color-interpolation-filters="sRGB"
-		class="st10">
-	<style type="text/css">
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="4.8933434in"
+   height="3.8972795in"
+   viewBox="0 0 352.31955 280.60496"
+   xml:space="preserve"
+   class="st10"
+   version="1.1"
+   id="svg70"
+   sodipodi:docname="cryptodev_sym_sess.svg"
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-rule:evenodd;stroke-linecap:square;stroke-miterlimit:3"
+   inkscape:version="0.92.1 r15371"><metadata
+   id="metadata74"><rdf:RDF><cc:Work
+       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+   pagecolor="#ffffff"
+   bordercolor="#666666"
+   borderopacity="1"
+   objecttolerance="10"
+   gridtolerance="10"
+   guidetolerance="10"
+   inkscape:pageopacity="0"
+   inkscape:pageshadow="2"
+   inkscape:window-width="1920"
+   inkscape:window-height="1051"
+   id="namedview72"
+   showgrid="false"
+   inkscape:zoom="1.7495789"
+   inkscape:cx="208.74719"
+   inkscape:cy="216.52777"
+   inkscape:window-x="-9"
+   inkscape:window-y="-9"
+   inkscape:window-maximized="0"
+   inkscape:current-layer="g68-0" />
+	<style
+   type="text/css"
+   id="style2">
 	<![CDATA[
 		.st1 {fill:url(#grad0-4);stroke:#386288;stroke-width:0.75}
 		.st2 {fill:#386288;font-family:Calibri;font-size:0.833336em}
@@ -19,48 +59,334 @@
 	]]>
 	</style>
 
-	<defs id="Patterns_And_Gradients">
-		<linearGradient id="grad0-4" x1="0" y1="0" x2="1" y2="0" gradientTransform="rotate(60 0.5 0.5)">
-			<stop offset="0" stop-color="#e8ebef" stop-opacity="1"/>
-			<stop offset="0.24" stop-color="#f4f5f7" stop-opacity="1"/>
-			<stop offset="0.54" stop-color="#feffff" stop-opacity="1"/>
+	<defs
+   id="Patterns_And_Gradients"><marker
+   inkscape:isstock="true"
+   style="overflow:visible"
+   id="marker5421"
+   refX="0"
+   refY="0"
+   orient="auto"
+   inkscape:stockid="Arrow2Lend"><path
+     transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+     d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+     style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+     id="path5419"
+     inkscape:connector-curvature="0" /></marker><marker
+   inkscape:stockid="Arrow2Lend"
+   orient="auto"
+   refY="0"
+   refX="0"
+   id="Arrow2Lend"
+   style="overflow:visible"
+   inkscape:isstock="true"><path
+     id="path5004"
+     style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+     d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+     transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+     inkscape:connector-curvature="0" /></marker><marker
+   inkscape:stockid="Arrow1Lend"
+   orient="auto"
+   refY="0"
+   refX="0"
+   id="Arrow1Lend"
+   style="overflow:visible"
+   inkscape:isstock="true"><path
+     id="path4986"
+     d="M 0,0 5,-5 -12.5,0 5,5 Z"
+     style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
+     transform="matrix(-0.8,0,0,-0.8,-10,0)"
+     inkscape:connector-curvature="0" /></marker>
+		<linearGradient
+   id="grad0-4"
+   x1="0"
+   y1="0"
+   x2="1"
+   y2="0"
+   gradientTransform="rotate(60,0.5,0.5)">
+			<stop
+   offset="0"
+   stop-color="#e8ebef"
+   stop-opacity="1"
+   id="stop4" />
+			<stop
+   offset="0.24"
+   stop-color="#f4f5f7"
+   stop-opacity="1"
+   id="stop6" />
+			<stop
+   offset="0.54"
+   stop-color="#feffff"
+   stop-opacity="1"
+   id="stop8" />
 		</linearGradient>
-	</defs>
-	<defs id="Filters">
-		<filter id="filter_2">
-			<feGaussianBlur stdDeviation="2"/>
+	<filter
+   id="filter_2-4"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-0" /></filter><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient189"
+   gradientTransform="scale(0.8787489,1.1379815)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /><filter
+   id="filter_2-5"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-8" /></filter><filter
+   id="filter_2-3"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-2" /></filter><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient189-7"
+   gradientTransform="scale(0.8787489,1.1379815)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient500"
+   gradientTransform="matrix(0.8787489,0,0,1.1379815,12.431599,21.739241)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /></defs>
+	<defs
+   id="Filters">
+		<filter
+   id="filter_2">
+			<feGaussianBlur
+   stdDeviation="2"
+   id="feGaussianBlur12" />
 		</filter>
 	</defs>
-	<g>
-		<title>Page-1</title>
-		<g id="shape18-1" transform="translate(0.749889,-0.75)">
-			<title>Rounded Rectangle.12</title>
-			<desc>Crypto Symmetric Session</desc>
-			<path d="M6.78 202.33 L148.14 202.33 A6.77735 6.77735 -180 0 0 154.91 195.56 L154.91 8.28 A6.77735 6.77735 -180 0 0 148.14
-						 1.5 L6.78 1.5 A6.77735 6.77735 -180 0 0 -0 8.28 L0 195.56 A6.77735 6.77735 -180 0 0 6.78 202.33 Z"
-					class="st1"/>
-			<text x="24.76" y="14.5" class="st2">Crypto Symmetric Session</text>		</g>
-		<g id="shape19-6" transform="translate(10.6711,-9.82087)">
-			<title>Rounded Rectangle.13</title>
-			<desc>Private Session Data</desc>
-			<g id="shadow19-7" transform="matrix(1,0,0,1,0.345598,1.97279)" class="st3">
-				<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 103.65 A5.90925 5.90925 -180
-							 0 0 129.16 97.74 L5.91 97.74 A5.90925 5.90925 -180 0 0 -0 103.65 L0 196.43 A5.90925 5.90925 -180 0 0
-							 5.91 202.33 Z" class="st4"/>
-			</g>
-			<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 103.65 A5.90925 5.90925 -180 0 0
-						 129.16 97.74 L5.91 97.74 A5.90925 5.90925 -180 0 0 -0 103.65 L0 196.43 A5.90925 5.90925 -180 0 0 5.91 202.33
-						 Z" class="st5"/>
-			<text x="26.34" y="153.04" class="st6">Private Session Data</text>		</g>
-		<g id="shape20-12" transform="translate(10.6711,-122.923)">
-			<title>Rounded Rectangle.15</title>
-			<desc>General Session Data (struct rte_cryptodev_sym_session)</desc>
-			<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 160.06 A5.90925 5.90925 -180 0 0
-						 129.16 154.15 L5.91 154.15 A5.90925 5.90925 -180 0 0 -0 160.06 L0 196.43 A5.90925 5.90925 -180 0 0 5.91
-						 202.33 Z" class="st7"/>
-			<text x="24.58" y="175.24" class="st6">General Session Data <tspan x="9.16" dy="1.5em" class="st8">(</tspan><tspan
-						class="st9">struct </tspan><tspan class="st8">rte</tspan><tspan class="st8">_</tspan><tspan class="st8">cryptodev</tspan><tspan
-						class="st8">_</tspan><tspan class="st8">sym</tspan><tspan class="st8">_</tspan><tspan class="st8">session</tspan><tspan
-						class="st8">)</tspan></text>		</g>
+	<g
+   id="g68"
+   transform="matrix(1,0,0,0.41409874,-12.807629,-5.4621159)">
+		<title
+   id="title16">Page-1</title>
+		<g
+   id="shape18-1"
+   transform="translate(0.749889,-0.75)">
+			<title
+   id="title18">Rounded Rectangle.12</title>
+			<desc
+   id="desc20">Crypto Symmetric Session</desc>
+			<path
+   d="M 19.211599,224.06924 H 160.5716 a 6.77735,6.77735 0 0 0 6.77,-6.77 V 30.019241 a 6.77735,6.77735 0 0 0 -6.77,-6.78 H 19.211599 a 6.77735,6.77735 0 0 0 -6.78,6.78 V 217.29924 a 6.77735,6.77735 0 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22"
+   style="fill:url(#linearGradient500);stroke:#386288;stroke-width:0.75"
+   inkscape:connector-curvature="0" />
+			<text
+   x="63.123039"
+   y="28.531481"
+   class="st2"
+   id="text24"
+   style="font-size:16.97244835px;font-family:Calibri;fill:#386288;stroke-width:1.69723928"
+   transform="scale(0.58919214,1.6972392)">Crypto Symmetric Session</text>
+
+		</g>
+		<g
+   id="shape19-6"
+   transform="translate(10.6711,-9.82087)">
+			<title
+   id="title27">Rounded Rectangle.13</title>
+			<desc
+   id="desc29">Private Session Data</desc>
+		</g>
+		<g
+   id="shape20-12"
+   transform="matrix(1,0,0,2.5278193,23.531375,-309.78186)">
+			<title
+   id="title39">Rounded Rectangle.15</title>
+			<desc
+   id="desc41">void *sess_private_data[]</desc>
+			<path
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -36.37 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,160.06 v 36.37 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st7"
+   id="path43"
+   inkscape:connector-curvature="0"
+   style="fill:#ffffff;stroke:#41719c;stroke-width:0.75" />
+			<text
+   x="14.072042"
+   y="159.1931"
+   class="st6"
+   id="text65"
+   style="font-size:11.41061592px;font-family:Calibri;fill:#41719c;stroke-width:1.14105785"
+   transform="scale(0.92359087,1.0827305)">void *sess_private_data[] <tspan
+   x="-3.5230706"
+   class="st9"
+   id="tspan47"
+   style="font-weight:bold;font-size:9.12843513px;stroke-width:1.14105785" /></text>
+
+		<rect
+   style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.73305672;stroke-opacity:1"
+   id="rect4604"
+   width="15.968175"
+   height="14.230948"
+   x="13.494645"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7"
+   width="15.968174"
+   height="14.230948"
+   x="29.46282"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6"
+   width="15.968174"
+   height="14.230948"
+   x="45.430992"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9"
+   width="15.968174"
+   height="14.230948"
+   x="61.399166"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8"
+   width="15.968174"
+   height="14.230948"
+   x="77.36734"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8-9"
+   width="15.968174"
+   height="14.230948"
+   x="93.33551"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8-9-6"
+   width="15.968174"
+   height="14.230948"
+   x="109.30369"
+   y="181.68814" /><path
+   style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.72427988px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+   d="m 117.64885,196.01764 0.22164,18.77485 44.6966,-0.0725 -0.22163,-20.00716 16.84434,0.43494"
+   id="path5030"
+   inkscape:connector-curvature="0" /></g>
 	</g>
-</svg>
+<g
+   transform="translate(190.70887,-0.53319281)"
+   id="g68-0"><title
+     id="title16-2">Page-1</title><g
+     id="shape18-1-4"
+     transform="matrix(1,0,0,0.57815109,0.749889,-0.11722686)"><title
+   id="title18-4">Rounded Rectangle.12</title><desc
+   id="desc20-6">Crypto Symmetric Session</desc><path
+   inkscape:connector-curvature="0"
+   d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22-0"
+   style="fill:url(#linearGradient189);stroke:#386288;stroke-width:0.75" /><text
+   x="26.317923"
+   y="17.335487"
+   class="st2"
+   id="text24-5"
+   style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+   transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
+
+</g><g
+     id="shape19-6-5"
+     transform="matrix(1.022976,0,0,0.71529071,9.1114734,-39.403506)"><title
+   id="title27-2">Rounded Rectangle.13</title><desc
+   id="desc29-0">Private Session Data</desc><g
+   id="shadow19-7-1"
+   transform="translate(0.345598,1.97279)"
+   class="st3"
+   style="visibility:visible"><path
+     inkscape:connector-curvature="0"
+     d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+     class="st4"
+     id="path31-8"
+     style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2)" /></g><path
+   inkscape:connector-curvature="0"
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st5"
+   id="path34-8"
+   style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
+   x="34.639763"
+   y="119.96548"
+   class="st6"
+   id="text36-7"
+   style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+   transform="scale(0.76039781,1.3151011)">Private Session Data</text>
+
+</g><g
+     id="shape18-1-4-7"
+     transform="matrix(1,0,0,0.57815109,0.90591369,163.94402)"><title
+   id="title18-4-3">Rounded Rectangle.12</title><desc
+   id="desc20-6-5">Crypto Symmetric Session</desc><path
+   inkscape:connector-curvature="0"
+   d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22-0-8"
+   style="fill:url(#linearGradient189-7);stroke:#386288;stroke-width:0.75" /><text
+   x="26.317923"
+   y="17.335487"
+   class="st2"
+   id="text24-5-1"
+   style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+   transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
+
+</g><g
+     id="shape19-6-5-1"
+     transform="matrix(1.022976,0,0,0.71529071,9.2675037,124.65774)"><title
+   id="title27-2-4">Rounded Rectangle.13</title><desc
+   id="desc29-0-9">Private Session Data</desc><g
+   id="shadow19-7-1-8"
+   transform="translate(0.345598,1.97279)"
+   class="st3"
+   style="visibility:visible"><path
+     inkscape:connector-curvature="0"
+     d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+     class="st4"
+     id="path31-8-4"
+     style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2-3)" /></g><path
+   inkscape:connector-curvature="0"
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st5"
+   id="path34-8-3"
+   style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
+   x="34.639763"
+   y="119.96548"
+   class="st6"
+   id="text36-7-6"
+   style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+   transform="scale(0.76039781,1.3151011)">Private Session Data</text>
+
+</g><text
+     xml:space="preserve"
+     style="font-style:normal;font-weight:normal;font-size:30.00008774px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
+     x="57.540585"
+     y="145.94679"
+     id="text5070"><tspan
+       sodipodi:role="line"
+       id="tspan5068"
+       x="57.540585"
+       y="173.31679"
+       style="stroke-width:0.75000221"></tspan></text>
+<text
+     xml:space="preserve"
+     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
+     x="60.571766"
+     y="143.21872"
+     id="text5074"><tspan
+       sodipodi:role="line"
+       id="tspan5072"
+       x="60.571766"
+       y="143.21872"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.75000221">...</tspan></text>
+<path
+     style="fill:none;stroke:#41719c;stroke-width:0.74499911px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker5421)"
+     d="M -158.57624,71.371238 -157.38,232.04055 -1.1215065,232.19212"
+     id="path5076"
+     inkscape:connector-curvature="0" /></g></svg>
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 00/12] Device independent crypto sessions
  2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
                     ` (10 preceding siblings ...)
  2017-06-30 17:09   ` [PATCH v2 11/11] doc: add new crypto session information Pablo de Lara
@ 2017-07-02 15:57   ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
                       ` (12 more replies)
  11 siblings, 13 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Currently, the cryptodev library requires the session mempools
to be created inside each device.
This can be a waste of memory, as several devices with the same driver
could be using the same session.

This patchset makes changes in the library to allow session to contain multiple
driver private data, so it can be used by multiple devices (no need to be the same driver).

                                  SESSION MEMPOOL <---|---> DEVICE INSTANCES
                                 --------------------------------------------

.-------------.      .----------------------------.
|   Crypto    |.     |         mempool obj        |
| sym-session |<--.  | .--------------------------+
|   mempool   ||  |  | | rte_cryptodev_session    |             .-------------.
`-------------'|  |  | |                          |             |   DEVICE    |
 `-----|-------'  |  | |                          |             |  INSTANCE   |
       |          `-----                          |             | - device id |
       +------------>| | - private data[type idx] |          .--| - session   |
       |             `-+=================|..|====='          |  |   mempool   |
       |                                 |  |                |  `-------------'
       |                                 |  |                |
       |     .----------------------.    |  |                |  .-------------.
       +---->|      mempool obj     |    |  |   .--------.   |  |   DEVICE    |
       |     | .--------------------+    |  |   | DRIVER |   |  |  INSTANCE   |
       |     | | PMD's private data |<---+------| - type |<--+--|             |
       |     +-+====================+       |   `--------'      |     ...     |
       |                                    |                   |             |
       |                                    |                   `-------------'
       |                                    |
       |     .----------------------.       |                   .-------------.
       `---->|      mempool obj     |       |   .--------.      |   DEVICE    |
             | .--------------------+       |   | DRIVER |      |  INSTANCE   |
             | | PMD's private data |<------+---| - type |<-----|             |
             `-+===================='           `--------'      |     ...     |
                                                                |             |
                                                                `-------------'
Crypto sym-session mempool

   Mempool created to store rte_cryptodev_session objects as well as
   private data for supported device types.

   This mempool replaces existing session mempools in device
   instances to ease session management and improve consistency
   (especially if the session is intended to be used for operations
   performed on different devices).

rte_crypto_session

   New rte_cryptodev_session structure is taken from crypto session
   mempool and can store more than one PMD's private data object (one
   for each device type supported by sesion).

   Crypto operations will use device type id (unique for each driver) to
   retrieve private data from rte_crypto_session right for the device
   type they are performed on.

This patchset was based on the changes proposed in RFC
(http://dpdk.org/ml/archives/dev/2017-May/065259.html)

This patchset depends on:
http://dpdk.org/dev/patchwork/patch/26156/

Changes in v3:

- Removed internal PMD's session initialize function

- Created session mempool in the right socket in
  the sample apps

- Get two objects (header and private data) from mempool
  when using sessionless operations, to get a complete
  session

- Fixed commit message (check-git-log failed)

- Added note of removed session_mp from rte_cryptodev_config
  in documentation

- Fixed minor issues in documentation


Changes in v2:

- Split the patch in multiple smaller patches to
  facilitate the review

- Removed new API to create the session mempool,
  since mempool can be created directly withe mempool_create

- Session headers and device private sessions can be
  allocated from different mempools, for better memory
  efficiency.

- Added a cover letter (partially extracted from RFC)
  for better clarification on the intention of this patchset

Pablo de Lara (5):
  cryptodev: remove unused cryptodev session structure
  cryptodev: move session init out of session pool creation
  cryptodev: add mempool pointer in queue pair setup
  cryptodev: remove session init internal function
  doc: add new crypto session information

Slawomir Mrozowicz (7):
  cryptodev: add private session size retrieval function
  cryptodev: do not create session mempool internally
  cryptodev: change attach session to queue pair API
  cryptodev: remove device id from crypto session
  cryptodev: remove driver id from session
  cryptodev: remove mempool from session
  cryptodev: support device independent sessions

 app/test-crypto-perf/cperf.h                       |   5 +-
 app/test-crypto-perf/cperf_ops.c                   |  30 +-
 app/test-crypto-perf/cperf_ops.h                   |   1 +
 app/test-crypto-perf/cperf_test_latency.c          |   7 +-
 app/test-crypto-perf/cperf_test_latency.h          |   5 +-
 app/test-crypto-perf/cperf_test_throughput.c       |   7 +-
 app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
 app/test-crypto-perf/cperf_test_verify.c           |   7 +-
 app/test-crypto-perf/cperf_test_verify.h           |   5 +-
 app/test-crypto-perf/main.c                        |  85 ++++-
 doc/guides/prog_guide/cryptodev_lib.rst            |  59 ++-
 doc/guides/prog_guide/img/cryptodev_sym_sess.svg   | 418 ++++++++++++++++++---
 doc/guides/rel_notes/release_17_08.rst             |  15 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  62 +--
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  32 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  37 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  31 +-
 drivers/crypto/armv8/rte_armv8_pmd.c               |  39 +-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  35 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  56 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd.c             |  44 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  32 +-
 drivers/crypto/null/null_crypto_pmd.c              |  42 ++-
 drivers/crypto/null/null_crypto_pmd_ops.c          |  35 +-
 drivers/crypto/openssl/rte_openssl_pmd.c           |  40 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  32 +-
 drivers/crypto/qat/qat_crypto.c                    |  66 ++--
 drivers/crypto/qat/qat_crypto.h                    |  15 +-
 drivers/crypto/qat/qat_qp.c                        |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
 drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
 .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 -
 drivers/crypto/scheduler/scheduler_pmd_ops.c       |  84 ++---
 drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
 drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 --
 drivers/crypto/snow3g/rte_snow3g_pmd.c             |  44 ++-
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  32 +-
 drivers/crypto/zuc/rte_zuc_pmd.c                   |  40 +-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  32 +-
 examples/ipsec-secgw/ipsec-secgw.c                 |  41 +-
 examples/ipsec-secgw/ipsec.c                       |   8 +-
 examples/ipsec-secgw/ipsec.h                       |   3 +-
 examples/l2fwd-crypto/main.c                       |  75 +++-
 lib/librte_cryptodev/rte_cryptodev.c               | 239 +++++-------
 lib/librte_cryptodev/rte_cryptodev.h               | 101 ++---
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |  54 ++-
 lib/librte_cryptodev/rte_cryptodev_version.map     |   3 +
 test/test/test_cryptodev.c                         | 383 ++++++++++++++-----
 test/test/test_cryptodev_blockcipher.c             |  15 +-
 test/test/test_cryptodev_blockcipher.h             |   1 +
 test/test/test_cryptodev_perf.c                    | 198 +++++++---
 51 files changed, 1793 insertions(+), 918 deletions(-)

-- 
2.9.4

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v3 01/12] cryptodev: remove unused cryptodev session structure
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 02/12] cryptodev: move session init out of session pool creation Pablo de Lara
                       ` (11 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Cryptodev session structure was a duplication of the
cryptodev symmetric structure.
It was used by some PMDs that should use the symmetric
structure instead.

Since this structure was internal, there is no deprecation
notice required.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/kasumi/rte_kasumi_pmd.c   |  2 +-
 drivers/crypto/null/null_crypto_pmd.c    |  2 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c   |  2 +-
 drivers/crypto/zuc/rte_zuc_pmd.c         |  2 +-
 examples/ipsec-secgw/ipsec.h             |  1 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 11 -----------
 6 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 648718c..a1a33c5 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -152,7 +152,7 @@ kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct kasumi_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 7ab3570..50ede06 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -103,7 +103,7 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_sym_op *op)
 
 		sess = (struct null_crypto_session *)op->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index fe074c1..35a2bcd 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -152,7 +152,7 @@ snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct snow3g_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index b7b8dfc..ff8f3b9 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -151,7 +151,7 @@ zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct zuc_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index fe42661..1d63161 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -72,7 +72,6 @@
 
 struct rte_crypto_xform;
 struct ipsec_xform;
-struct rte_cryptodev_session;
 struct rte_mbuf;
 
 struct ipsec_sa;
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index f6aa84d..5911b83 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -56,17 +56,6 @@ extern "C" {
 #include "rte_crypto.h"
 #include "rte_cryptodev.h"
 
-struct rte_cryptodev_session {
-	RTE_STD_C11
-	struct {
-		uint8_t dev_id;
-		uint8_t driver_id;
-		struct rte_mempool *mp;
-	} __rte_aligned(8);
-
-	__extension__ char _private[0];
-};
-
 /** Global structure used for maintaining state of allocated crypto devices */
 struct rte_cryptodev_global {
 	struct rte_cryptodev *devs;	/**< Device information array */
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 02/12] cryptodev: move session init out of session pool creation
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 03/12] cryptodev: add private session size retrieval function Pablo de Lara
                       ` (10 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Prior to removing the session pool creation from cryptodev
configure function, session init function needs to be
separated from the pool creation.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 17f7c63..c914fd4 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1030,13 +1030,9 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 
 static void
 rte_cryptodev_sym_session_init(struct rte_mempool *mp,
-		void *opaque_arg,
-		void *_sess,
-		__rte_unused unsigned i)
+		const struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	struct rte_cryptodev_sym_session *sess = _sess;
-	struct rte_cryptodev *dev = opaque_arg;
-
 	memset(sess, 0, mp->elt_size);
 
 	sess->dev_id = dev->data->dev_id;
@@ -1093,8 +1089,7 @@ rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
 				0, /* private data size */
 				NULL, /* obj initialization constructor */
 				NULL, /* obj initialization constructor arg */
-				rte_cryptodev_sym_session_init,
-				/**< obj constructor*/
+				NULL, /**< obj constructor*/
 				dev, /* obj constructor arg */
 				socket_id, /* socket id */
 				0); /* flags */
@@ -1132,6 +1127,8 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 
 	sess = _sess;
 
+	rte_cryptodev_sym_session_init(dev->data->session_pool, dev,
+					sess);
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL);
 	if (dev->dev_ops->session_configure(dev, xform, sess->_private) ==
 			NULL) {
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 03/12] cryptodev: add private session size retrieval function
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 02/12] cryptodev: move session init out of session pool creation Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 04/12] cryptodev: do not create session mempool internally Pablo de Lara
                       ` (9 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Provide a function to get the private session size
of any crypto device (specifically, to its crypto driver).

This will be useful once the session mempool is created
outside the library.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c           | 20 ++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 12 ++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 +
 3 files changed, 33 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index c914fd4..cb6f5ec 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1217,6 +1217,26 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 	return NULL;
 }
 
+unsigned int
+rte_cryptodev_get_private_session_size(uint8_t dev_id)
+{
+	struct rte_cryptodev *dev;
+	unsigned int priv_sess_size;
+
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+		return 0;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+	if (*dev->dev_ops->session_get_size == NULL)
+		return 0;
+
+	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
+
+	return priv_sess_size;
+
+}
+
 /** Initialise rte_crypto_op mempool element */
 static void
 rte_crypto_op_init(struct rte_mempool *mempool,
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index ba51329..d883d8c 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -856,6 +856,18 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
+ * Get the size of the private session data for a device.
+ *
+ * @param	dev_id		The device identifier.
+ *
+ * @return
+ *   - Size of the private data, if successful
+ *   - 0 if device is invalid or does not have private session
+ */
+unsigned int
+rte_cryptodev_get_private_session_size(uint8_t dev_id);
+
+/**
  * Attach queue pair with sym session.
  *
  * @param	qp_id		Queue pair to which session will be attached.
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index afe148a..8855a34 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -65,6 +65,7 @@ DPDK_17.08 {
 	rte_cryptodev_device_count_by_driver;
 	rte_cryptodev_driver_id_get;
 	rte_cryptodev_driver_name_get;
+	rte_cryptodev_get_private_session_size;
 	rte_cryptodev_pci_generic_probe;
 	rte_cryptodev_pci_generic_remove;
 	rte_cryptodev_vdev_parse_init_params;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 04/12] cryptodev: do not create session mempool internally
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (2 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 03/12] cryptodev: add private session size retrieval function Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 05/12] cryptodev: change attach session to queue pair API Pablo de Lara
                       ` (8 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Instead of creating the session mempool while configuring
the crypto device, apps will create the mempool themselves.
This way, it gives flexibility to the user to have a single
mempool for all devices (as long as the objects are big
enough to contain the biggest private session size) or
separate mempools for different drivers.

Also, since the mempool is now created outside the
device configuration function, now it needs to be passed
through this function, which will be eventually passed
when setting up the queue pairs, as ethernet devices do.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/main.c                  | 91 +++++++++++++++++++++-------
 doc/guides/rel_notes/release_17_08.rst       |  3 +
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 12 +---
 examples/ipsec-secgw/ipsec-secgw.c           | 42 +++++++++++--
 examples/ipsec-secgw/ipsec.h                 |  2 +
 examples/l2fwd-crypto/main.c                 | 65 ++++++++++++++++----
 lib/librte_cryptodev/rte_cryptodev.c         | 77 ++---------------------
 lib/librte_cryptodev/rte_cryptodev.h         |  9 +--
 test/test/test_cryptodev.c                   | 85 ++++++++++++++++++++------
 test/test/test_cryptodev_perf.c              | 24 +++++++-
 10 files changed, 260 insertions(+), 150 deletions(-)

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 9ec2a4b..e013e82 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -11,6 +11,9 @@
 #include "cperf_test_latency.h"
 #include "cperf_test_verify.h"
 
+#define NUM_SESSIONS 2048
+#define SESS_MEMPOOL_CACHE_SIZE 64
+
 const char *cperf_test_type_strs[] = {
 	[CPERF_TEST_TYPE_THROUGHPUT] = "throughput",
 	[CPERF_TEST_TYPE_LATENCY] = "latency",
@@ -44,9 +47,11 @@ const struct cperf_test cperf_testmap[] = {
 };
 
 static int
-cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
+cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
+			struct rte_mempool *session_pool_socket[])
 {
-	uint8_t cdev_id, enabled_cdev_count = 0, nb_lcores;
+	uint8_t enabled_cdev_count = 0, nb_lcores;
+	unsigned int i;
 	int ret;
 
 	enabled_cdev_count = rte_cryptodev_devices_get(opts->device_type,
@@ -66,40 +71,78 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		return -EINVAL;
 	}
 
-	for (cdev_id = 0; cdev_id < enabled_cdev_count &&
-			cdev_id < RTE_CRYPTO_MAX_DEVS; cdev_id++) {
+	/* Create a mempool shared by all the devices */
+	uint32_t max_sess_size = 0, sess_size;
+
+	for (i = 0; i < enabled_cdev_count &&
+			i < RTE_CRYPTO_MAX_DEVS; i++) {
+		uint8_t cdev_id = enabled_cdevs[i];
+		sess_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_size > max_sess_size)
+			max_sess_size = sess_size;
+	}
+
+
+	for (i = 0; i < enabled_cdev_count &&
+			i < RTE_CRYPTO_MAX_DEVS; i++) {
+		uint8_t cdev_id = enabled_cdevs[i];
+		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
 
 		struct rte_cryptodev_config conf = {
 				.nb_queue_pairs = 1,
-				.socket_id = SOCKET_ID_ANY,
-				.session_mp = {
-					.nb_objs = 2048,
-					.cache_size = 64
-				}
-			};
+				.socket_id = socket_id
+		};
+
 		struct rte_cryptodev_qp_conf qp_conf = {
 				.nb_descriptors = 2048
 		};
 
-		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf);
+
+		if (session_pool_socket[socket_id] == NULL) {
+			char mp_name[RTE_MEMPOOL_NAMESIZE];
+			struct rte_mempool *sess_mp;
+
+			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+				"sess_mp_%u", socket_id);
+
+			sess_mp = rte_mempool_create(mp_name,
+						NUM_SESSIONS,
+						max_sess_size,
+						SESS_MEMPOOL_CACHE_SIZE,
+						0, NULL, NULL, NULL,
+						NULL, socket_id,
+						0);
+
+			if (sess_mp == NULL) {
+				printf("Cannot create session pool on socket %d\n",
+					socket_id);
+				return -ENOMEM;
+			}
+
+			printf("Allocated session pool on socket %d\n", socket_id);
+			session_pool_socket[socket_id] = sess_mp;
+		}
+
+		ret = rte_cryptodev_configure(cdev_id, &conf,
+				session_pool_socket[socket_id]);
 		if (ret < 0) {
-			printf("Failed to configure cryptodev %u",
-					enabled_cdevs[cdev_id]);
+			printf("Failed to configure cryptodev %u", cdev_id);
 			return -EINVAL;
 		}
 
-		ret = rte_cryptodev_queue_pair_setup(enabled_cdevs[cdev_id], 0,
-				&qp_conf, SOCKET_ID_ANY);
-			if (ret < 0) {
-				printf("Failed to setup queue pair %u on "
-					"cryptodev %u",	0, cdev_id);
-				return -EINVAL;
-			}
+		ret = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
+				socket_id);
+		if (ret < 0) {
+			printf("Failed to setup queue pair %u on "
+				"cryptodev %u",	0, cdev_id);
+			return -EINVAL;
+		}
 
-		ret = rte_cryptodev_start(enabled_cdevs[cdev_id]);
+		ret = rte_cryptodev_start(cdev_id);
 		if (ret < 0) {
 			printf("Failed to start device %u: error %d\n",
-					enabled_cdevs[cdev_id], ret);
+					cdev_id, ret);
 			return -EPERM;
 		}
 	}
@@ -274,6 +317,7 @@ main(int argc, char **argv)
 	struct cperf_op_fns op_fns;
 
 	void *ctx[RTE_MAX_LCORE] = { };
+	struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 };
 
 	int nb_cryptodevs = 0;
 	uint8_t cdev_id, i;
@@ -309,7 +353,8 @@ main(int argc, char **argv)
 	if (!opts.silent)
 		cperf_options_dump(&opts);
 
-	nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs);
+	nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs,
+			session_pool_socket);
 	if (nb_cryptodevs < 1) {
 		RTE_LOG(ERR, USER1, "Failed to initialise requested crypto "
 				"device type\n");
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 1dcd4d7..8cc01b2 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -157,6 +157,9 @@ API Changes
 
   * Device type identification is changed to be based on a unique 1-byte driver id,
     replacing the previous device type enumeration.
+  * ``rte_cryptodev_configure()`` does not create the session mempool
+    for the device anymore.
+  * Removed ``session_mp`` from ``rte_cryptodev_config``.
 
 
 ABI Changes
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index 90e3734..b9d8973 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -85,10 +85,8 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
 /** Configure device */
 static int
 scheduler_pmd_config(struct rte_cryptodev *dev,
-		struct rte_cryptodev_config *config)
+		struct rte_cryptodev_config *config __rte_unused)
 {
-	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
-	uint32_t i;
 	int ret;
 
 	/* although scheduler_attach_init_slave presents multiple times,
@@ -98,14 +96,6 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	if (ret < 0)
 		return ret;
 
-	for (i = 0; i < sched_ctx->nb_slaves; i++) {
-		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
-
-		ret = rte_cryptodev_configure(slave_dev_id, config);
-		if (ret < 0)
-			break;
-	}
-
 	return ret;
 }
 
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 8cbf6ac..4d6c7ce 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -710,10 +710,12 @@ main_loop(__attribute__((unused)) void *dummy)
 	qconf->inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in;
 	qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
 	qconf->inbound.cdev_map = cdev_map_in;
+	qconf->inbound.session_pool = socket_ctx[socket_id].session_pool;
 	qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
 	qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
 	qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
 	qconf->outbound.cdev_map = cdev_map_out;
+	qconf->outbound.session_pool = socket_ctx[socket_id].session_pool;
 
 	if (qconf->nb_rx_queue == 0) {
 		RTE_LOG(INFO, IPSEC, "lcore %u has nothing to do\n", lcore_id);
@@ -1238,6 +1240,14 @@ cryptodevs_init(void)
 
 	printf("lcore/cryptodev/qp mappings:\n");
 
+	uint32_t max_sess_sz = 0, sess_sz;
+	for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
+		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_sz > max_sess_sz)
+			max_sess_sz = sess_sz;
+	}
+
 	idx = 0;
 	/* Start from last cdev id to give HW priority */
 	for (cdev_id = rte_cryptodev_count() - 1; cdev_id >= 0; cdev_id--) {
@@ -1266,11 +1276,33 @@ cryptodevs_init(void)
 
 		dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
 		dev_conf.nb_queue_pairs = qp;
-		dev_conf.session_mp.nb_objs = CDEV_MP_NB_OBJS;
-		dev_conf.session_mp.cache_size = CDEV_MP_CACHE_SZ;
 
-		if (rte_cryptodev_configure(cdev_id, &dev_conf))
-			rte_panic("Failed to initialize crypodev %u\n",
+		if (!socket_ctx[dev_conf.socket_id].session_pool) {
+			char mp_name[RTE_MEMPOOL_NAMESIZE];
+			struct rte_mempool *sess_mp;
+
+			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+					"sess_mp_%u", dev_conf.socket_id);
+			sess_mp = rte_mempool_create(mp_name,
+					CDEV_MP_NB_OBJS,
+					max_sess_sz,
+					CDEV_MP_CACHE_SZ,
+					0, NULL, NULL, NULL,
+					NULL, dev_conf.socket_id,
+					0);
+			if (sess_mp == NULL)
+				rte_exit(EXIT_FAILURE,
+					"Cannot create session pool on socket %d\n",
+					dev_conf.socket_id);
+			else
+				printf("Allocated session pool on socket %d\n",
+					dev_conf.socket_id);
+			socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
+		}
+
+		if (rte_cryptodev_configure(cdev_id, &dev_conf,
+				socket_ctx[dev_conf.socket_id].session_pool))
+			rte_panic("Failed to initialize cryptodev %u\n",
 					cdev_id);
 
 		qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
@@ -1433,7 +1465,7 @@ main(int32_t argc, char **argv)
 
 	nb_lcores = rte_lcore_count();
 
-	/* Replicate each contex per socket */
+	/* Replicate each context per socket */
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
 		if (rte_lcore_is_enabled(lcore_id) == 0)
 			continue;
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index 1d63161..593b0a2 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -139,6 +139,7 @@ struct ipsec_ctx {
 	uint16_t nb_qps;
 	uint16_t last_qp;
 	struct cdev_qp tbl[MAX_QP_PER_LCORE];
+	struct rte_mempool *session_pool;
 };
 
 struct cdev_key {
@@ -157,6 +158,7 @@ struct socket_ctx {
 	struct rt_ctx *rt_ip4;
 	struct rt_ctx *rt_ip6;
 	struct rte_mempool *mbuf_pool;
+	struct rte_mempool *session_pool;
 };
 
 struct cnt_blk {
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 779b4fb..add9291 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -88,6 +88,8 @@ enum cdev_type {
 #define MAX_KEY_SIZE 128
 #define MAX_PKT_BURST 32
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
+#define MAX_SESSIONS 32
+#define SESSION_POOL_CACHE_SIZE 0
 
 /*
  * Configurable number of RX/TX ring descriptors
@@ -223,6 +225,7 @@ static const struct rte_eth_conf port_conf = {
 
 struct rte_mempool *l2fwd_pktmbuf_pool;
 struct rte_mempool *l2fwd_crypto_op_pool;
+struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 };
 
 /* Per-port statistics struct */
 struct l2fwd_port_statistics {
@@ -587,8 +590,7 @@ generate_random_key(uint8_t *key, unsigned length)
 }
 
 static struct rte_cryptodev_sym_session *
-initialize_crypto_session(struct l2fwd_crypto_options *options,
-		uint8_t cdev_id)
+initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
 {
 	struct rte_crypto_sym_xform *first_xform;
 
@@ -604,7 +606,6 @@ initialize_crypto_session(struct l2fwd_crypto_options *options,
 		first_xform = &options->auth_xform;
 	}
 
-	/* Setup Cipher Parameters */
 	return rte_cryptodev_sym_session_create(cdev_id, first_xform);
 }
 
@@ -626,6 +627,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 			US_PER_S * BURST_TX_DRAIN_US;
 	struct l2fwd_crypto_params *cparams;
 	struct l2fwd_crypto_params port_cparams[qconf->nb_crypto_devs];
+	struct rte_cryptodev_sym_session *session;
 
 	if (qconf->nb_rx_ports == 0) {
 		RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id);
@@ -698,11 +700,13 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 			port_cparams[i].cipher_algo = options->cipher_xform.cipher.algo;
 		}
 
-		port_cparams[i].session = initialize_crypto_session(options,
+		session = initialize_crypto_session(options,
 				port_cparams[i].dev_id);
+		if (session == NULL)
+			rte_exit(EXIT_FAILURE, "Failed to initialize crypto session\n");
+
+		port_cparams[i].session = session;
 
-		if (port_cparams[i].session == NULL)
-			return;
 		RTE_LOG(INFO, L2FWD, " -- lcoreid=%u cryptoid=%u\n", lcore_id,
 				port_cparams[i].dev_id);
 	}
@@ -1550,6 +1554,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 	enum rte_crypto_auth_algorithm opt_auth_algo;
 	enum rte_crypto_cipher_algorithm cap_cipher_algo;
 	enum rte_crypto_cipher_algorithm opt_cipher_algo;
+	unsigned int sess_sz, max_sess_sz = 0;
 	int retval;
 
 	cdev_count = rte_cryptodev_count();
@@ -1558,18 +1563,22 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		return -1;
 	}
 
+	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_sz > max_sess_sz)
+			max_sess_sz = sess_sz;
+	}
+
 	for (cdev_id = 0; cdev_id < cdev_count && enabled_cdev_count < nb_ports;
 			cdev_id++) {
 		struct rte_cryptodev_qp_conf qp_conf;
 		struct rte_cryptodev_info dev_info;
+		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
 
 		struct rte_cryptodev_config conf = {
 			.nb_queue_pairs = 1,
-			.socket_id = SOCKET_ID_ANY,
-			.session_mp = {
-				.nb_objs = 2048,
-				.cache_size = 64
-			}
+			.socket_id = socket_id,
 		};
 
 		if (check_cryptodev_mask(options, (uint8_t)cdev_id))
@@ -1577,6 +1586,35 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 
 		rte_cryptodev_info_get(cdev_id, &dev_info);
 
+		if (session_pool_socket[socket_id] == NULL) {
+			char mp_name[RTE_MEMPOOL_NAMESIZE];
+			struct rte_mempool *sess_mp;
+
+			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+				"sess_mp_%u", socket_id);
+
+			/*
+			 * Create enough objects for session headers and
+			 * device private data
+			 */
+			sess_mp = rte_mempool_create(mp_name,
+						MAX_SESSIONS * 2,
+						max_sess_sz,
+						SESSION_POOL_CACHE_SIZE,
+						0, NULL, NULL, NULL,
+						NULL, socket_id,
+						0);
+
+			if (sess_mp == NULL) {
+				printf("Cannot create session pool on socket %d\n",
+					socket_id);
+				return -ENOMEM;
+			}
+
+			printf("Allocated session pool on socket %d\n", socket_id);
+			session_pool_socket[socket_id] = sess_mp;
+		}
+
 		/* Set cipher parameters */
 		if (options->xform_chain == L2FWD_CRYPTO_CIPHER_HASH ||
 				options->xform_chain == L2FWD_CRYPTO_HASH_CIPHER ||
@@ -1797,7 +1835,8 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 						cap->sym.auth.digest_size.min;
 		}
 
-		retval = rte_cryptodev_configure(cdev_id, &conf);
+		retval = rte_cryptodev_configure(cdev_id, &conf,
+				session_pool_socket[socket_id]);
 		if (retval < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -1;
@@ -1806,7 +1845,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		qp_conf.nb_descriptors = 2048;
 
 		retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
-				SOCKET_ID_ANY);
+				socket_id);
 		if (retval < 0) {
 			printf("Failed to setup queue pair %u on cryptodev %u",
 					0, cdev_id);
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index cb6f5ec..dd10b99 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -683,12 +683,9 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
 
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id);
-
 int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
+		struct rte_mempool *session_pool)
 {
 	struct rte_cryptodev *dev;
 	int diag;
@@ -708,6 +705,8 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
+	dev->data->session_pool = session_pool;
+
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
 			config->socket_id);
@@ -717,14 +716,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		return diag;
 	}
 
-	/* Setup Session mempool for device */
-	diag = rte_cryptodev_sym_session_pool_create(dev,
-			config->session_mp.nb_objs,
-			config->session_mp.cache_size,
-			config->socket_id);
-	if (diag != 0)
-		return diag;
-
 	return (*dev->dev_ops->dev_configure)(dev, config);
 }
 
@@ -1043,66 +1034,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 		(*dev->dev_ops->session_initialize)(mp, sess);
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id)
-{
-	char mp_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-	unsigned priv_sess_size;
-
-	unsigned n = snprintf(mp_name, sizeof(mp_name), "cdev_%d_sess_mp",
-			dev->data->dev_id);
-	if (n > sizeof(mp_name)) {
-		CDEV_LOG_ERR("Unable to create unique name for session mempool");
-		return -ENOMEM;
-	}
-
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_get_size, -ENOTSUP);
-	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
-	if (priv_sess_size == 0) {
-		CDEV_LOG_ERR("%s returned and invalid private session size ",
-						dev->data->name);
-		return -ENOMEM;
-	}
-
-	unsigned elt_size = sizeof(struct rte_cryptodev_sym_session) +
-			priv_sess_size;
-
-	dev->data->session_pool = rte_mempool_lookup(mp_name);
-	if (dev->data->session_pool != NULL) {
-		if ((dev->data->session_pool->elt_size != elt_size) ||
-				(dev->data->session_pool->cache_size <
-				obj_cache_size) ||
-				(dev->data->session_pool->size < nb_objs)) {
-
-			CDEV_LOG_ERR("%s mempool already exists with different"
-					" initialization parameters", mp_name);
-			dev->data->session_pool = NULL;
-			return -ENOMEM;
-		}
-	} else {
-		dev->data->session_pool = rte_mempool_create(
-				mp_name, /* mempool name */
-				nb_objs, /* number of elements*/
-				elt_size, /* element size*/
-				obj_cache_size, /* Cache size*/
-				0, /* private data size */
-				NULL, /* obj initialization constructor */
-				NULL, /* obj initialization constructor arg */
-				NULL, /**< obj constructor*/
-				dev, /* obj constructor arg */
-				socket_id, /* socket id */
-				0); /* flags */
-
-		if (dev->data->session_pool == NULL) {
-			CDEV_LOG_ERR("%s mempool allocation failed", mp_name);
-			return -ENOMEM;
-		}
-	}
-
-	CDEV_LOG_DEBUG("%s mempool created!", mp_name);
-	return 0;
-}
 
 struct rte_cryptodev_sym_session *
 rte_cryptodev_sym_session_create(uint8_t dev_id,
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index d883d8c..1afd2d8 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -428,11 +428,6 @@ struct rte_cryptodev_config {
 	int socket_id;			/**< Socket to allocate resources on */
 	uint16_t nb_queue_pairs;
 	/**< Number of queue pairs to configure on device */
-
-	struct {
-		uint32_t nb_objs;	/**< Number of objects in mempool */
-		uint32_t cache_size;	/**< l-core object cache size */
-	} session_mp;		/**< Session mempool configuration */
 };
 
 /**
@@ -444,13 +439,15 @@ struct rte_cryptodev_config {
  *
  * @param	dev_id		The identifier of the device to configure.
  * @param	config		The crypto device configuration structure.
+ * @param	session_pool	Pointer to device session mempool
  *
  * @return
  *   - 0: Success, device configured.
  *   - <0: Error code returned by the driver configuration function.
  */
 extern int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
+		struct rte_mempool *session_pool);
 
 /**
  * Start an device.
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index afa895e..cdc1cbf 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -66,6 +66,8 @@ struct crypto_testsuite_params {
 	struct rte_mempool *mbuf_pool;
 	struct rte_mempool *large_mbuf_pool;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *session_mpool;
+	struct rte_mempool *slave_session_mpool;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_qp_conf qp_conf;
 
@@ -381,10 +383,23 @@ testsuite_setup(void)
 
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
+
+	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+		rte_cryptodev_get_private_session_size(dev_id);
+
+	ts_params->session_mpool = rte_mempool_create(
+				"test_sess_mp",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
+			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev %u with %u qps",
 			dev_id, ts_params->conf.nb_queue_pairs);
 
@@ -416,6 +431,16 @@ testsuite_teardown(void)
 		rte_mempool_avail_count(ts_params->op_mpool));
 	}
 
+	/* Free session mempools */
+	if (ts_params->session_mpool != NULL) {
+		rte_mempool_free(ts_params->session_mpool);
+		ts_params->session_mpool = NULL;
+	}
+
+	if (ts_params->slave_session_mpool != NULL) {
+		rte_mempool_free(ts_params->slave_session_mpool);
+		ts_params->slave_session_mpool = NULL;
+	}
 }
 
 static int
@@ -431,10 +456,9 @@ ut_setup(void)
 
 	/* Reconfigure device to default parameters */
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -517,20 +541,23 @@ test_device_configure_invalid_dev_id(void)
 	/* Stop the device in case it's started so it can be configured */
 	rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
 
-	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	/* invalid dev_id values */
 	dev_id = num_devs;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	dev_id = 0xff;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure:"
 			"invalid dev_num %u", dev_id);
 
@@ -550,7 +577,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 1;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
 
@@ -559,16 +586,17 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
-			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
+			ts_params->valid_devs[0],
+			ts_params->conf.nb_queue_pairs);
 
 
 	/* invalid - zero queue pairs */
 	ts_params->conf.nb_queue_pairs = 0;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -579,7 +607,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -590,7 +618,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -619,13 +647,11 @@ test_queue_pair_descriptor_setup(void)
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
 
-	ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
-
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf), "Failed to configure cryptodev %u",
+			&ts_params->conf, ts_params->session_mpool),
+			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
-
 	/*
 	 * Test various ring sizes on this device. memzones can't be
 	 * freed so are re-used if ring is released and re-created.
@@ -7837,6 +7863,31 @@ test_scheduler_attach_slave_op(void)
 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
 			continue;
 
+		/*
+		 * Create a separate mempool for the slaves, as they need different
+		 * session size and then configure them to store the pointer
+		 * to this mempool
+		 */
+		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(i);
+
+		if (ts_params->slave_session_mpool == NULL) {
+			ts_params->slave_session_mpool = rte_mempool_create(
+				"test_slave_sess_mp",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL, NULL,
+				SOCKET_ID_ANY, 0);
+
+			TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
+					"session mempool allocation failed");
+		}
+
+		TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
+				&ts_params->conf, ts_params->slave_session_mpool),
+				"Failed to configure cryptodev %u with %u qps",
+				i, ts_params->conf.nb_queue_pairs);
+
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 6553c94..753667a 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -50,6 +50,7 @@
 struct crypto_testsuite_params {
 	struct rte_mempool *mbuf_mp;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *sess_mp;
 
 	uint16_t nb_queue_pairs;
 
@@ -394,10 +395,23 @@ testsuite_setup(void)
 
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
+
+	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+		rte_cryptodev_get_private_session_size(ts_params->dev_id);
+
+	ts_params->sess_mp = rte_mempool_create(
+				"test_sess_mp_perf",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	TEST_ASSERT_NOT_NULL(ts_params->sess_mp,
+			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
-			&ts_params->conf),
+			&ts_params->conf, ts_params->sess_mp),
 			"Failed to configure cryptodev %u",
 			ts_params->dev_id);
 
@@ -426,6 +440,12 @@ testsuite_teardown(void)
 	if (ts_params->op_mpool != NULL)
 		RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_OP POOL count %u\n",
 		rte_mempool_avail_count(ts_params->op_mpool));
+	/* Free session mempool */
+	if (ts_params->sess_mp != NULL) {
+		rte_mempool_free(ts_params->sess_mp);
+		ts_params->sess_mp = NULL;
+	}
+
 }
 
 static int
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 05/12] cryptodev: change attach session to queue pair API
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (3 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 04/12] cryptodev: do not create session mempool internally Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 06/12] cryptodev: remove device id from crypto session Pablo de Lara
                       ` (7 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Device id is going to be removed from session,
as the session will be device independent.
Therefore, the functions that attach/dettach a session
to a queue pair need to be updated, to accept the device id
as a parameter, apart from the queue pair id and the session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst |  3 +++
 examples/ipsec-secgw/ipsec.c           |  1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 20 ++++++++++----------
 lib/librte_cryptodev/rte_cryptodev.h   | 10 ++++++----
 4 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 8cc01b2..c7e58c6 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -160,6 +160,9 @@ API Changes
   * ``rte_cryptodev_configure()`` does not create the session mempool
     for the device anymore.
   * Removed ``session_mp`` from ``rte_cryptodev_config``.
+  * ``rte_cryptodev_queue_pair_attach_sym_session()`` and
+    ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
+    the new parameter ``device id``.
 
 
 ABI Changes
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index edca5f0..048e441 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -77,6 +77,7 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
 	rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
 	if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
 		ret = rte_cryptodev_queue_pair_attach_sym_session(
+				ipsec_ctx->tbl[cdev_id_qp].id,
 				ipsec_ctx->tbl[cdev_id_qp].qp,
 				sa->crypto_session);
 		if (ret < 0) {
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index dd10b99..477e28f 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1075,23 +1075,23 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 }
 
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0);
 	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) {
 		CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
@@ -1099,23 +1099,23 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
 }
 
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0);
 	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) {
 		CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 1afd2d8..d3d2794 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -867,7 +867,8 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id);
 /**
  * Attach queue pair with sym session.
  *
- * @param	qp_id		Queue pair to which session will be attached.
+ * @param	dev_id		Device to which the session will be attached.
+ * @param	qp_id		Queue pair to which the session will be attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
  *
@@ -876,13 +877,14 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id);
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
  * Detach queue pair with sym session.
  *
- * @param	qp_id		Queue pair to which session is attached.
+ * @param	dev_id		Device to which the session is attached.
+ * @param	qp_id		Queue pair to which the session is attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
  *
@@ -891,7 +893,7 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 06/12] cryptodev: remove device id from crypto session
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (4 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 05/12] cryptodev: change attach session to queue pair API Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 07/12] cryptodev: remove driver id from session Pablo de Lara
                       ` (6 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Device id is necessary in the crypto session,
as it was only used for the functions that attach/detach
a session to a queue pair.

Since the session is not going to be attached to a device
anymore, this is field is no longer necessary.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst | 1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 1 -
 lib/librte_cryptodev/rte_cryptodev.h   | 2 --
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index c7e58c6..f401ffb 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -163,6 +163,7 @@ API Changes
   * ``rte_cryptodev_queue_pair_attach_sym_session()`` and
     ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
     the new parameter ``device id``.
+  * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 477e28f..aa35b79 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1026,7 +1026,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->dev_id = dev->data->dev_id;
 	sess->driver_id = dev->driver_id;
 	sess->mp = mp;
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index d3d2794..77a763d 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -798,8 +798,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
 	struct {
-		uint8_t dev_id;
-		/**< Device Id */
 		uint8_t driver_id;
 		/** Crypto driver identifier session created on */
 		struct rte_mempool *mp;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 07/12] cryptodev: remove driver id from session
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (5 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 06/12] cryptodev: remove device id from crypto session Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 08/12] cryptodev: remove mempool " Pablo de Lara
                       ` (5 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Since crypto session will not be attached to a specific
device or driver, the field driver_id is not required
anymore (only used to check that a session was being
handled by the right device).

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst     | 1 +
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 4 ----
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 5 -----
 drivers/crypto/armv8/rte_armv8_pmd.c       | 4 +---
 drivers/crypto/kasumi/rte_kasumi_pmd.c     | 4 ----
 drivers/crypto/null/null_crypto_pmd.c      | 3 +--
 drivers/crypto/openssl/rte_openssl_pmd.c   | 4 +---
 drivers/crypto/qat/qat_crypto.c            | 6 ------
 drivers/crypto/snow3g/rte_snow3g_pmd.c     | 4 ----
 drivers/crypto/zuc/rte_zuc_pmd.c           | 4 ----
 lib/librte_cryptodev/rte_cryptodev.c       | 5 -----
 lib/librte_cryptodev/rte_cryptodev.h       | 2 --
 12 files changed, 4 insertions(+), 42 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index f401ffb..b0657ec 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -164,6 +164,7 @@ API Changes
     ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
     the new parameter ``device id``.
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
+  * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index ef290a3..2774b4e 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -146,10 +146,6 @@ aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_sym_op *op)
 	struct aesni_gcm_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session->driver_id !=
-				cryptodev_driver_id))
-			return sess;
-
 		sess = (struct aesni_gcm_session *)op->session->_private;
 	} else  {
 		void *_sess;
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 4025978..ec348ab 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -348,11 +348,6 @@ 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->driver_id !=
-				cryptodev_driver_id)) {
-			return NULL;
-		}
-
 		sess = (struct aesni_mb_session *)op->sym->session->_private;
 	} else  {
 		void *_sess = NULL;
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index 9fe781b..1ddf6a2 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -549,9 +549,7 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id)) {
+		if (likely(op->sym->session != NULL)) {
 			sess = (struct armv8_crypto_session *)
 				op->sym->session->_private;
 		}
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index a1a33c5..67f0b06 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -146,10 +146,6 @@ kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 	struct kasumi_session *sess;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct kasumi_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 50ede06..9323874 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -97,8 +97,7 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_sym_op *op)
 	struct null_crypto_session *sess;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session == NULL || op->session->driver_id !=
-				cryptodev_driver_id))
+		if (unlikely(op->session == NULL))
 			return NULL;
 
 		sess = (struct null_crypto_session *)op->session->_private;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 4e4394f..3232455 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -450,9 +450,7 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id))
+		if (likely(op->sym->session != NULL))
 			sess = (struct openssl_session *)
 				op->sym->session->_private;
 	} else  {
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index 7c5a9a8..13bd0b5 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -914,12 +914,6 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	if (unlikely(op->sym->session->driver_id !=
-			cryptodev_qat_driver_id)) {
-		PMD_DRV_LOG(ERR, "Session was not created for this device");
-		return -EINVAL;
-	}
-
 	ctx = (struct qat_session *)op->sym->session->_private;
 	qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
 	rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 35a2bcd..677849d 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -146,10 +146,6 @@ snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 	struct snow3g_session *sess;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct snow3g_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index ff8f3b9..385e4e5 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -145,10 +145,6 @@ zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 	struct zuc_session *sess;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct zuc_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index aa35b79..b0b4816 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1026,7 +1026,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->driver_id = dev->driver_id;
 	sess->mp = mp;
 
 	if (dev->dev_ops->session_initialize)
@@ -1133,10 +1132,6 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 
 	dev = &rte_crypto_devices[dev_id];
 
-	/* Check the session belongs to this device type */
-	if (sess->driver_id != dev->driver_id)
-		return sess;
-
 	/* Let device implementation clear session material */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_clear, sess);
 	dev->dev_ops->session_clear(dev, (void *)sess->_private);
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 77a763d..7d574f1 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -798,8 +798,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
 	struct {
-		uint8_t driver_id;
-		/** Crypto driver identifier session created on */
 		struct rte_mempool *mp;
 		/**< Mempool session allocated from */
 	} __rte_aligned(8);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 08/12] cryptodev: remove mempool from session
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (6 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 07/12] cryptodev: remove driver id from session Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 09/12] cryptodev: support device independent sessions Pablo de Lara
                       ` (4 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Mempool pointer can be obtained from the object itself,
which means that it is not required to actually store the pointer
in the session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst | 1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 7 +++----
 lib/librte_cryptodev/rte_cryptodev.h   | 6 ------
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index b0657ec..785489a 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -165,6 +165,7 @@ API Changes
     the new parameter ``device id``.
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
+  * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index b0b4816..5c7191b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1026,8 +1026,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->mp = mp;
-
 	if (dev->dev_ops->session_initialize)
 		(*dev->dev_ops->session_initialize)(mp, sess);
 }
@@ -1065,7 +1063,7 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 				dev_id);
 
 		/* Return session to mempool */
-		rte_mempool_put(sess->mp, _sess);
+		rte_mempool_put(dev->data->session_pool, _sess);
 		return NULL;
 	}
 
@@ -1137,7 +1135,8 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 	dev->dev_ops->session_clear(dev, (void *)sess->_private);
 
 	/* Return session to mempool */
-	rte_mempool_put(sess->mp, (void *)sess);
+	struct rte_mempool *mp = rte_mempool_from_obj(sess);
+	rte_mempool_put(mp, (void *)sess);
 
 	return NULL;
 }
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 7d574f1..044a4aa 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -797,12 +797,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 /** Cryptodev symmetric crypto session */
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
-	struct {
-		struct rte_mempool *mp;
-		/**< Mempool session allocated from */
-	} __rte_aligned(8);
-	/**< Public symmetric session details */
-
 	__extension__ char _private[0];
 	/**< Private session material */
 };
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 09/12] cryptodev: support device independent sessions
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (7 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 08/12] cryptodev: remove mempool " Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 10/12] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
                       ` (3 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Change crypto device's session management to make it
device independent and simplify architecture when session
is intended to be used on more than one device.

Sessions private data is agnostic to underlying device
by adding an indirection in the sessions private data
using the crypto driver identifier.
A single session can contain indirections to multiple device types.

New function rte_cryptodev_sym_session_init has been created,
to initialize the private data per driver to be used on
a same session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/cperf.h                       |   5 +-
 app/test-crypto-perf/cperf_ops.c                   |  30 +-
 app/test-crypto-perf/cperf_ops.h                   |   1 +
 app/test-crypto-perf/cperf_test_latency.c          |   7 +-
 app/test-crypto-perf/cperf_test_latency.h          |   5 +-
 app/test-crypto-perf/cperf_test_throughput.c       |   7 +-
 app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
 app/test-crypto-perf/cperf_test_verify.c           |   7 +-
 app/test-crypto-perf/cperf_test_verify.h           |   5 +-
 app/test-crypto-perf/main.c                        |   8 +-
 doc/guides/rel_notes/release_17_08.rst             |   4 +
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  60 ++--
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  28 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  32 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  27 +-
 drivers/crypto/armv8/rte_armv8_pmd.c               |  37 ++-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  31 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  45 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd.c             |  42 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  28 +-
 drivers/crypto/null/null_crypto_pmd.c              |  41 ++-
 drivers/crypto/null/null_crypto_pmd_ops.c          |  31 +-
 drivers/crypto/openssl/rte_openssl_pmd.c           |  36 ++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  28 +-
 drivers/crypto/qat/qat_crypto.c                    |  68 ++--
 drivers/crypto/qat/qat_crypto.h                    |  12 +-
 drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
 drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
 .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 --
 drivers/crypto/scheduler/scheduler_pmd_ops.c       |  87 +++---
 drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
 drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 ---
 drivers/crypto/snow3g/rte_snow3g_pmd.c             |  42 ++-
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  28 +-
 drivers/crypto/zuc/rte_zuc_pmd.c                   |  38 ++-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  28 +-
 examples/ipsec-secgw/ipsec-secgw.c                 |   3 +-
 examples/ipsec-secgw/ipsec.c                       |   7 +-
 examples/l2fwd-crypto/main.c                       |  17 +-
 lib/librte_cryptodev/rte_cryptodev.c               | 127 ++++----
 lib/librte_cryptodev/rte_cryptodev.h               |  65 ++--
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |  24 +-
 lib/librte_cryptodev/rte_cryptodev_version.map     |   2 +
 test/test/test_cryptodev.c                         | 344 ++++++++++++++-------
 test/test/test_cryptodev_blockcipher.c             |  15 +-
 test/test/test_cryptodev_blockcipher.h             |   1 +
 test/test/test_cryptodev_perf.c                    | 173 +++++++----
 47 files changed, 1106 insertions(+), 634 deletions(-)

diff --git a/app/test-crypto-perf/cperf.h b/app/test-crypto-perf/cperf.h
index 293ba94..c9f7f81 100644
--- a/app/test-crypto-perf/cperf.h
+++ b/app/test-crypto-perf/cperf.h
@@ -41,7 +41,10 @@ struct cperf_options;
 struct cperf_test_vector;
 struct cperf_op_fns;
 
-typedef void  *(*cperf_constructor_t)(uint8_t dev_id, uint16_t qp_id,
+typedef void  *(*cperf_constructor_t)(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *t_vec,
 		const struct cperf_op_fns *op_fns);
diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index 17df2eb..82e5d60 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -331,14 +331,16 @@ cperf_set_ops_aead(struct rte_crypto_op **ops,
 }
 
 static struct rte_cryptodev_sym_session *
-cperf_create_session(uint8_t dev_id,
+cperf_create_session(struct rte_mempool *sess_mp,
+	uint8_t dev_id,
 	const struct cperf_options *options,
 	const struct cperf_test_vector *test_vector)
 {
 	struct rte_crypto_sym_xform cipher_xform;
 	struct rte_crypto_sym_xform auth_xform;
-	struct rte_cryptodev_sym_session *sess = NULL;
+	struct rte_cryptodev_sym_session *sess;
 
+	sess = rte_cryptodev_sym_session_create(sess_mp);
 	/*
 	 * cipher only
 	 */
@@ -359,7 +361,8 @@ cperf_create_session(uint8_t dev_id,
 			cipher_xform.cipher.key.length = 0;
 		}
 		/* create crypto session */
-		sess = rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &cipher_xform,
+				sess_mp);
 	/*
 	 *  auth only
 	 */
@@ -385,7 +388,8 @@ cperf_create_session(uint8_t dev_id,
 			auth_xform.auth.key.data = NULL;
 		}
 		/* create crypto session */
-		sess =  rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &auth_xform,
+				sess_mp);
 	/*
 	 * cipher and auth
 	 */
@@ -449,29 +453,31 @@ cperf_create_session(uint8_t dev_id,
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 				cipher_xform.next = &auth_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-					&cipher_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &cipher_xform, sess_mp);
+
 			} else { /* decrypt */
 				auth_xform.next = &cipher_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-					&auth_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &auth_xform, sess_mp);
 			}
 		} else { /* create crypto session for other */
 			/* cipher then auth */
 			if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
 				cipher_xform.next = &auth_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-						&cipher_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &cipher_xform, sess_mp);
 			} else { /* auth then cipher */
 				auth_xform.next = &cipher_xform;
 				/* create crypto session */
-				sess = rte_cryptodev_sym_session_create(dev_id,
-						&auth_xform);
+				rte_cryptodev_sym_session_init(dev_id,
+						sess, &auth_xform, sess_mp);
 			}
 		}
 	}
+
 	return sess;
 }
 
diff --git a/app/test-crypto-perf/cperf_ops.h b/app/test-crypto-perf/cperf_ops.h
index 1b748da..36daf9d 100644
--- a/app/test-crypto-perf/cperf_ops.h
+++ b/app/test-crypto-perf/cperf_ops.h
@@ -41,6 +41,7 @@
 
 
 typedef struct rte_cryptodev_sym_session *(*cperf_sessions_create_t)(
+		struct rte_mempool *sess_mp,
 		uint8_t dev_id, const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector);
 
diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c
index 4fb7a9a..80b55f3 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -76,7 +76,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -187,7 +187,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -207,7 +208,7 @@ cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_latency.h b/app/test-crypto-perf/cperf_test_latency.h
index 6a2cf61..1bbedb4 100644
--- a/app/test-crypto-perf/cperf_test_latency.h
+++ b/app/test-crypto-perf/cperf_test_latency.h
@@ -43,7 +43,10 @@
 #include "cperf_test_vectors.h"
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 85947a5..a9fbd74 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -65,7 +65,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -175,7 +175,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -195,7 +196,7 @@ cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_throughput.h b/app/test-crypto-perf/cperf_test_throughput.h
index f1b5766..987d0c3 100644
--- a/app/test-crypto-perf/cperf_test_throughput.h
+++ b/app/test-crypto-perf/cperf_test_throughput.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index b19f5e1..655bf08 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -69,7 +69,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx, uint32_t mbuf_nb)
 
 	if (ctx) {
 		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -179,7 +179,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -199,7 +200,7 @@ cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	ctx->options = options;
 	ctx->test_vector = test_vector;
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_verify.h b/app/test-crypto-perf/cperf_test_verify.h
index 3fa78ee..e67b48d 100644
--- a/app/test-crypto-perf/cperf_test_verify.h
+++ b/app/test-crypto-perf/cperf_test_verify.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index e013e82..eb2737e 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -77,8 +77,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
 	for (i = 0; i < enabled_cdev_count &&
 			i < RTE_CRYPTO_MAX_DEVS; i++) {
 		uint8_t cdev_id = enabled_cdevs[i];
-		sess_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(cdev_id);
+		sess_size = rte_cryptodev_get_private_session_size(cdev_id);
 		if (sess_size > max_sess_size)
 			max_sess_size = sess_size;
 	}
@@ -412,7 +411,10 @@ main(int argc, char **argv)
 
 		cdev_id = enabled_cdevs[i];
 
-		ctx[cdev_id] = cperf_testmap[opts.test].constructor(cdev_id, 0,
+		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+
+		ctx[cdev_id] = cperf_testmap[opts.test].constructor(
+				session_pool_socket[socket_id], cdev_id, 0,
 				&opts, t_vec, &op_fns);
 		if (ctx[cdev_id] == NULL) {
 			RTE_LOG(ERR, USER1, "Test run constructor failed\n");
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 785489a..463b616 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -80,6 +80,8 @@ New Features
   * Added helper functions for crypto device driver identification.
   * Moved crypto device driver names definitions to the particular PMDs.
     These names are not public anymore.
+  * Added support for multi-device sessions, so a single session can be
+    used in multiple drivers.
 
 
 Resolved Issues
@@ -166,6 +168,8 @@ API Changes
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
+  * Replaced ``private`` marker with array of pointers to private data sessions
+    ``sess_private_data`` in ``rte_cryptodev_sym_session``
 
 
 ABI Changes
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index 2774b4e..393dfab 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -141,27 +141,44 @@ aesni_gcm_set_session_parameters(struct aesni_gcm_session *sess,
 
 /** Get gcm session */
 static struct aesni_gcm_session *
-aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_sym_op *op)
+aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_op *op)
 {
 	struct aesni_gcm_session *sess = NULL;
 
-	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct aesni_gcm_session *)op->session->_private;
-	} else  {
-		void *_sess;
+	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
+		if (likely(op->sym->session != NULL)) {
+			sess = (struct aesni_gcm_session *)
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+		}
+	} else {
+		/* provide internal session */
+		void *_sess = NULL;
+		void *_sess_private_data = NULL;
 
-		if (rte_mempool_get(qp->sess_mp, &_sess))
-			return sess;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
+			return NULL;
 
-		sess = (struct aesni_gcm_session *)
-			((struct rte_cryptodev_sym_session *)_sess)->_private;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
+			return NULL;
+
+		sess = (struct aesni_gcm_session *)_sess_private_data;
 
 		if (unlikely(aesni_gcm_set_session_parameters(sess,
-				op->xform) != 0)) {
+					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_session_private_data(op->sym->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
+
+	if (sess == NULL)
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
+
 	return sess;
 }
 
@@ -323,17 +340,16 @@ process_gcm_crypto_op(struct rte_crypto_sym_op *op,
  * - Returns NULL on invalid job
  */
 static void
-post_process_gcm_crypto_op(struct rte_crypto_op *op)
+post_process_gcm_crypto_op(struct rte_crypto_op *op,
+		struct aesni_gcm_session *sess)
 {
 	struct rte_mbuf *m = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
 
-	struct aesni_gcm_session *session =
-		(struct aesni_gcm_session *)op->sym->session->_private;
-
 	op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
+
 	/* Verify digest if required */
-	if (session->op == AESNI_GCM_OP_AUTHENTICATED_DECRYPTION) {
+	if (sess->op == AESNI_GCM_OP_AUTHENTICATED_DECRYPTION) {
 
 		uint8_t *tag = rte_pktmbuf_mtod_offset(m, uint8_t *,
 				m->data_len - op->sym->auth.digest.length);
@@ -357,21 +373,21 @@ post_process_gcm_crypto_op(struct rte_crypto_op *op)
 /**
  * Process a completed GCM request
  *
- * @param qp		Queue Pair to process
  * @param job		JOB_AES_HMAC job
  *
  * @return
  * - Number of processed jobs
  */
 static void
-handle_completed_gcm_crypto_op(struct aesni_gcm_qp *qp,
-		struct rte_crypto_op *op)
+handle_completed_gcm_crypto_op(struct rte_crypto_op *op,
+		struct aesni_gcm_session *sess)
 {
-	post_process_gcm_crypto_op(op);
+	post_process_gcm_crypto_op(op, sess);
 
 	/* Free session if a session-less crypto op */
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		memset(op->sym->session, 0, sizeof(struct aesni_gcm_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 }
@@ -391,7 +407,7 @@ aesni_gcm_pmd_dequeue_burst(void *queue_pair,
 
 	for (i = 0; i < nb_dequeued; i++) {
 
-		sess = aesni_gcm_get_session(qp, ops[i]->sym);
+		sess = aesni_gcm_get_session(qp, ops[i]);
 		if (unlikely(sess == NULL)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			qp->qp_stats.dequeue_err_count++;
@@ -405,7 +421,7 @@ aesni_gcm_pmd_dequeue_burst(void *queue_pair,
 			break;
 		}
 
-		handle_completed_gcm_crypto_op(qp, ops[i]);
+		handle_completed_gcm_crypto_op(ops[i], sess);
 	}
 
 	qp->qp_stats.dequeued_count += i;
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 721dbda..0b063fd 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -313,21 +313,37 @@ aesni_gcm_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a aesni gcm session from a crypto xform chain */
-static void *
+static int
 aesni_gcm_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		GCM_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (aesni_gcm_set_session_parameters(sess, xform) != 0) {
+	if (aesni_gcm_set_session_parameters(sess_private_data, xform) != 0) {
 		GCM_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index ec348ab..9d849c9 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -348,24 +348,37 @@ 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) {
-		sess = (struct aesni_mb_session *)op->sym->session->_private;
-	} else  {
+		if (likely(op->sym->session != NULL))
+			sess = (struct aesni_mb_session *)
+					get_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_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;
 }
 
@@ -512,7 +525,7 @@ verify_digest(JOB_AES_HMAC *job, struct rte_crypto_op *op) {
  * - Returns NULL on invalid job
  */
 static inline struct rte_crypto_op *
-post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
+post_process_mb_job(JOB_AES_HMAC *job)
 {
 	struct rte_crypto_op *op = (struct rte_crypto_op *)job->user_data;
 
@@ -525,7 +538,9 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
 
 			if (job->hash_alg != NULL_HASH) {
 				sess = (struct aesni_mb_session *)
-						op->sym->session->_private;
+						get_session_private_data(
+						op->sym->session,
+						cryptodev_driver_id);
 
 				if (sess->auth.operation ==
 						RTE_CRYPTO_AUTH_OP_VERIFY)
@@ -539,7 +554,8 @@ 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) {
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		memset(op->sym->session, 0, sizeof(struct aesni_mb_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
@@ -564,7 +580,7 @@ handle_completed_jobs(struct aesni_mb_qp *qp, JOB_AES_HMAC *job,
 	unsigned processed_jobs = 0;
 
 	while (job != NULL && processed_jobs < nb_ops) {
-		op = post_process_mb_job(qp, job);
+		op = post_process_mb_job(job);
 
 		if (op) {
 			ops[processed_jobs++] = op;
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index 3a2683b..fda8296 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -472,24 +472,39 @@ aesni_mb_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a aesni multi-buffer session from a crypto xform chain */
-static void *
+static int
 aesni_mb_pmd_session_configure(struct rte_cryptodev *dev,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
 	struct aesni_mb_private *internals = dev->data->dev_private;
 
 	if (unlikely(sess == NULL)) {
 		MB_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
 	if (aesni_mb_set_session_parameters(&job_ops[internals->vector_mode],
-			sess, xform) != 0) {
+			sess_private_data, xform) != 0) {
 		MB_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index 1ddf6a2..1b9893e 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -549,26 +549,33 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL)) {
+		if (likely(op->sym->session != NULL))
 			sess = (struct armv8_crypto_session *)
-				op->sym->session->_private;
-		}
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
 	} else {
 		/* provide internal session */
 		void *_sess = NULL;
+		void *_sess_private_data = NULL;
 
-		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
-			sess = (struct armv8_crypto_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
-
-			if (unlikely(armv8_crypto_set_session_parameters(
-					sess, op->sym->xform) != 0)) {
-				rte_mempool_put(qp->sess_mp, _sess);
-				sess = NULL;
-			} else
-				op->sym->session = _sess;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
+			return NULL;
+
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
+			return NULL;
+
+		sess = (struct armv8_crypto_session *)_sess_private_data;
+
+		if (unlikely(armv8_crypto_session_parameters(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_session_private_data(op->sym->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
 
 	if (unlikely(sess == NULL))
@@ -702,7 +709,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) {
 		memset(sess, 0, sizeof(struct armv8_crypto_session));
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 2911417..3db420b 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -316,22 +316,37 @@ armv8_crypto_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure the session from a crypto xform chain */
-static void *
-armv8_crypto_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform, void *sess)
+static int
+armv8_crypto_pmd_session_configure(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		ARMV8_CRYPTO_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (armv8_crypto_set_session_parameters(
-			sess, xform) != 0) {
+	if (armv8_crypto_set_session_parameters(sess_private_data, xform) != 0) {
 		ARMV8_CRYPTO_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 70ad07a..0a85690 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -465,7 +465,9 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
 			/*Clear the unused FD fields before sending*/
 			memset(&fd_arr[loop], 0, sizeof(struct qbman_fd));
 			sess = (dpaa2_sec_session *)
-				(*ops)->sym->session->_private;
+					get_session_private_data(
+					(*ops)->sym->session,
+					cryptodev_driver_id);
 			mb_pool = (*ops)->sym->m_src->pool;
 			bpid = mempool_to_bpid(mb_pool);
 			ret = build_sec_fd(sess, *ops, &fd_arr[loop], bpid);
@@ -1202,18 +1204,14 @@ dpaa2_sec_aead_init(struct rte_cryptodev *dev,
 	return -1;
 }
 
-static void *
-dpaa2_sec_session_configure(struct rte_cryptodev *dev,
+static int
+dpaa2_sec_set_session_parameters(struct rte_cryptodev *dev,
 			    struct rte_crypto_sym_xform *xform,	void *sess)
 {
 	dpaa2_sec_session *session = sess;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if (unlikely(sess == NULL)) {
-		RTE_LOG(ERR, PMD, "invalid session struct");
-		return NULL;
-	}
 	/* Cipher Only */
 	if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next == NULL) {
 		session->ctxt_type = DPAA2_SEC_CIPHER;
@@ -1238,10 +1236,39 @@ dpaa2_sec_session_configure(struct rte_cryptodev *dev,
 		dpaa2_sec_aead_init(dev, xform, session);
 	} else {
 		RTE_LOG(ERR, PMD, "Invalid crypto type");
-		return NULL;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+dpaa2_sec_session_configure(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
+{
+	void *sess_private_data;
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	return session;
+	if (dpaa2_sec_set_session_parameters(dev, xform, sess_private_data) != 0) {
+		PMD_DRV_LOG(ERR, "DPAA2 PMD: failed to configure "
+				"session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
+	}
+
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 67f0b06..9bb309d 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -143,23 +143,40 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
 static struct kasumi_session *
 kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 {
-	struct kasumi_session *sess;
+	struct kasumi_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct kasumi_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct kasumi_session *)
+					get_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;
 
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct kasumi_session *)c_sess->_private;
+		sess = (struct kasumi_session *)_sess_private_data;
 
 		if (unlikely(kasumi_set_session_parameters(sess,
-				op->sym->xform) != 0))
-			return NULL;
+				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_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;
 }
 
@@ -297,7 +314,7 @@ process_kasumi_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = ops[i]->sym->auth.digest.data;
 
 			sso_kasumi_f9_1_buffer_user(&session->pKeySched_hash,
@@ -352,7 +369,9 @@ process_ops(struct rte_crypto_op **ops, struct kasumi_session *session,
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		/* Free session if a session-less crypto op. */
 		if (ops[i]->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
-			rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
+			memset(ops[i]->sym->session, 0,
+					sizeof(struct kasumi_session));
+			rte_cryptodev_sym_session_free(ops[i]->sym->session);
 			ops[i]->sym->session = NULL;
 		}
 	}
@@ -404,7 +423,8 @@ process_op_bit(struct rte_crypto_op *op, struct kasumi_session *session,
 
 	/* Free session if a session-less crypto op. */
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		memset(op->sym->session, 0, sizeof(struct kasumi_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index 343c9b3..d590b91 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -291,21 +291,37 @@ kasumi_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a KASUMI session from a crypto xform chain */
-static void *
+static int
 kasumi_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		KASUMI_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (kasumi_set_session_parameters(sess, xform) != 0) {
+	if (kasumi_set_session_parameters(sess_private_data, xform) != 0) {
 		KASUMI_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 9323874..c4a7219 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -84,6 +84,14 @@ process_op(const struct null_crypto_qp *qp, struct rte_crypto_op *op,
 	/* set status as successful by default */
 	op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
+	/* Free session if a session-less crypto op. */
+	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
+		memset(op->sym->session, 0,
+				sizeof(struct null_crypto_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
+		op->sym->session = NULL;
+	}
+
 	/*
 	 * if crypto session and operation are valid just enqueue the packet
 	 * in the processed ring
@@ -94,23 +102,34 @@ process_op(const struct null_crypto_qp *qp, struct rte_crypto_op *op,
 static struct null_crypto_session *
 get_session(struct null_crypto_qp *qp, struct rte_crypto_sym_op *op)
 {
-	struct null_crypto_session *sess;
+	struct null_crypto_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		if (unlikely(op->session == NULL))
+		if (likely(op->session != NULL))
+			sess = (struct null_crypto_session *)
+					get_session_private_data(
+					op->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 null_crypto_session *)op->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
-
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct null_crypto_session *)c_sess->_private;
-
-		if (null_crypto_set_session_parameters(sess, op->xform)	!= 0)
-			return NULL;
+		sess = (struct null_crypto_session *)_sess_private_data;
+
+		if (unlikely(null_crypto_set_session_parameters(sess,
+				op->xform) != 0)) {
+			rte_mempool_put(qp->sess_mp, _sess);
+			rte_mempool_put(qp->sess_mp, _sess_private_data);
+			sess = NULL;
+		}
+		op->session = (struct rte_cryptodev_sym_session *)_sess;
+		set_session_private_data(op->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
 
 	return sess;
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index a7c891e..04147fe 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -302,24 +302,37 @@ null_crypto_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a null crypto session from a crypto xform chain */
-static void *
+static int
 null_crypto_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform, void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mp)
 {
-	int retval;
+	void *sess_private_data;
 
 	if (unlikely(sess == NULL)) {
 		NULL_CRYPTO_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mp, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
-	retval = null_crypto_set_session_parameters(
-			(struct null_crypto_session *)sess, xform);
-	if (retval != 0) {
+
+	if (null_crypto_set_session_parameters(sess_private_data, xform) != 0) {
 		NULL_CRYPTO_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mp, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 3232455..b519ca2 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -452,23 +452,31 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 		/* get existing session */
 		if (likely(op->sym->session != NULL))
 			sess = (struct openssl_session *)
-				op->sym->session->_private;
-	} else  {
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
 		/* provide internal session */
 		void *_sess = NULL;
+		void *_sess_private_data = NULL;
 
-		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
-			sess = (struct openssl_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
-
-			if (unlikely(openssl_set_session_parameters(
-					sess, op->sym->xform) != 0)) {
-				rte_mempool_put(qp->sess_mp, _sess);
-				sess = NULL;
-			} else
-				op->sym->session = _sess;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
+			return NULL;
+
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
+			return NULL;
+
+		sess = (struct openssl_session *)_sess_private_data;
+
+		if (unlikely(openssl_set_session_parameters(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_session_private_data(op->sym->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
 
 	if (sess == NULL)
@@ -1199,7 +1207,7 @@ process_op(const struct openssl_qp *qp, struct rte_crypto_op *op,
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
 		openssl_reset_session(sess);
 		memset(sess, 0, sizeof(struct openssl_session));
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index f65de53..005855b 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -671,22 +671,38 @@ openssl_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure the session from a crypto xform chain */
-static void *
+static int
 openssl_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		OPENSSL_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
 	if (openssl_set_session_parameters(
-			sess, xform) != 0) {
+			sess_private_data, xform) != 0) {
 		OPENSSL_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index 13bd0b5..845abb4 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -220,7 +220,6 @@ void qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
 		void *session)
 {
 	struct qat_session *sess = session;
-	phys_addr_t cd_paddr;
 
 	PMD_INIT_FUNC_TRACE();
 	if (sess) {
@@ -228,9 +227,7 @@ void qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
 			bpi_cipher_ctx_free(sess->bpi_ctx);
 			sess->bpi_ctx = NULL;
 		}
-		cd_paddr = sess->cd_paddr;
 		memset(sess, 0, qat_crypto_sym_get_session_private_size(dev));
-		sess->cd_paddr = cd_paddr;
 	} else
 		PMD_DRV_LOG(ERR, "NULL session");
 }
@@ -448,9 +445,37 @@ qat_crypto_sym_configure_session_cipher(struct rte_cryptodev *dev,
 	return NULL;
 }
 
-
-void *
+int
 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
+{
+	void *sess_private_data;
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
+	}
+
+	if (qat_crypto_set_session_parameters(dev, xform, sess_private_data) != 0) {
+		PMD_DRV_LOG(ERR, "Crypto QAT PMD: failed to configure "
+				"session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
+	}
+
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
+}
+
+int
+qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
 		struct rte_crypto_sym_xform *xform, void *session_private)
 {
 	struct qat_session *session = session_private;
@@ -458,6 +483,10 @@ qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
 	int qat_cmd_id;
 	PMD_INIT_FUNC_TRACE();
 
+	/* Set context descriptor physical address */
+	session->cd_paddr = rte_mempool_virt2phy(NULL, session) +
+			offsetof(struct qat_session, cd);
+
 	/* Get requested QAT command id */
 	qat_cmd_id = qat_get_cmd_id(xform);
 	if (qat_cmd_id < 0 || qat_cmd_id >= ICP_QAT_FW_LA_CMD_DELIMITER) {
@@ -498,10 +527,10 @@ qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
 		goto error_out;
 	}
 
-	return session;
+	return 0;
 
 error_out:
-	return NULL;
+	return -1;
 }
 
 struct qat_session *
@@ -809,7 +838,10 @@ qat_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops,
 			rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
 		} else {
 			struct qat_session *sess = (struct qat_session *)
-						(rx_op->sym->session->_private);
+					get_session_private_data(
+					rx_op->sym->session,
+					cryptodev_qat_driver_id);
+
 			if (sess->bpi_ctx)
 				qat_bpicipher_postprocess(sess, rx_op);
 			rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
@@ -914,7 +946,14 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	ctx = (struct qat_session *)op->sym->session->_private;
+	ctx = (struct qat_session *)get_session_private_data(
+			op->sym->session, cryptodev_qat_driver_id);
+
+	if (unlikely(ctx == NULL)) {
+		PMD_DRV_LOG(ERR, "Session was not created for this device");
+		return -EINVAL;
+	}
+
 	qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
 	rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
 	qat_req->comn_mid.opaque_data = (uint64_t)(uintptr_t)op;
@@ -1192,17 +1231,6 @@ static inline uint32_t adf_modulo(uint32_t data, uint32_t shift)
 	return data - mult;
 }
 
-void qat_crypto_sym_session_init(struct rte_mempool *mp, void *sym_sess)
-{
-	struct rte_cryptodev_sym_session *sess = sym_sess;
-	struct qat_session *s = (void *)sess->_private;
-
-	PMD_INIT_FUNC_TRACE();
-	s->cd_paddr = rte_mempool_virt2phy(mp, sess) +
-		offsetof(struct qat_session, cd) +
-		offsetof(struct rte_cryptodev_sym_session, _private);
-}
-
 int qat_dev_config(__rte_unused struct rte_cryptodev *dev,
 		__rte_unused struct rte_cryptodev_config *config)
 {
diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h
index ed27e3b..d5466c2 100644
--- a/drivers/crypto/qat/qat_crypto.h
+++ b/drivers/crypto/qat/qat_crypto.h
@@ -114,11 +114,15 @@ qat_pmd_session_mempool_create(struct rte_cryptodev *dev,
 extern unsigned
 qat_crypto_sym_get_session_private_size(struct rte_cryptodev *dev);
 
-extern void
-qat_crypto_sym_session_init(struct rte_mempool *mempool, void *priv_sess);
-
-extern void *
+extern int
 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool);
+
+
+int
+qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
 		struct rte_crypto_sym_xform *xform, void *session_private);
 
 struct qat_session *
diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c
index 1c5ff77..9a710e6 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -73,7 +73,6 @@ static struct rte_cryptodev_ops crypto_qat_ops = {
 		/* Crypto related operations */
 		.session_get_size	= qat_crypto_sym_get_session_private_size,
 		.session_configure	= qat_crypto_sym_configure_session,
-		.session_initialize	= qat_crypto_sym_session_init,
 		.session_clear		= qat_crypto_sym_clear_session
 };
 
diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c
index 162a29b..2aa13f8 100644
--- a/drivers/crypto/scheduler/scheduler_failover.c
+++ b/drivers/crypto/scheduler/scheduler_failover.c
@@ -49,57 +49,18 @@ struct fo_scheduler_qp_ctx {
 };
 
 static __rte_always_inline uint16_t
-failover_slave_enqueue(struct scheduler_slave *slave, uint8_t slave_idx,
+failover_slave_enqueue(struct scheduler_slave *slave,
 		struct rte_crypto_op **ops, uint16_t nb_ops)
 {
 	uint16_t i, processed_ops;
-	struct rte_cryptodev_sym_session *sessions[nb_ops];
-	struct scheduler_session *sess0, *sess1, *sess2, *sess3;
 
 	for (i = 0; i < nb_ops && i < 4; i++)
 		rte_prefetch0(ops[i]->sym->session);
 
-	for (i = 0; (i < (nb_ops - 8)) && (nb_ops > 8); i += 4) {
-		rte_prefetch0(ops[i + 4]->sym->session);
-		rte_prefetch0(ops[i + 5]->sym->session);
-		rte_prefetch0(ops[i + 6]->sym->session);
-		rte_prefetch0(ops[i + 7]->sym->session);
-
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
-		sessions[i] = ops[i]->sym->session;
-		sessions[i + 1] = ops[i + 1]->sym->session;
-		sessions[i + 2] = ops[i + 2]->sym->session;
-		sessions[i + 3] = ops[i + 3]->sym->session;
-
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-		ops[i + 1]->sym->session = sess1->sessions[slave_idx];
-		ops[i + 2]->sym->session = sess2->sessions[slave_idx];
-		ops[i + 3]->sym->session = sess3->sessions[slave_idx];
-	}
-
-	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sessions[i] = ops[i]->sym->session;
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-	}
-
 	processed_ops = rte_cryptodev_enqueue_burst(slave->dev_id,
 			slave->qp_id, ops, nb_ops);
 	slave->nb_inflight_cops += processed_ops;
 
-	if (unlikely(processed_ops < nb_ops))
-		for (i = processed_ops; i < nb_ops; i++)
-			ops[i]->sym->session = sessions[i];
-
 	return processed_ops;
 }
 
@@ -114,11 +75,11 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		return 0;
 
 	enqueued_ops = failover_slave_enqueue(&qp_ctx->primary_slave,
-			PRIMARY_SLAVE_IDX, ops, nb_ops);
+			ops, nb_ops);
 
 	if (enqueued_ops < nb_ops)
 		enqueued_ops += failover_slave_enqueue(&qp_ctx->secondary_slave,
-				SECONDARY_SLAVE_IDX, &ops[enqueued_ops],
+				&ops[enqueued_ops],
 				nb_ops - enqueued_ops);
 
 	return enqueued_ops;
diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
index 6b628df..1dd1bc3 100644
--- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
+++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
@@ -67,7 +67,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	struct scheduler_qp_ctx *qp_ctx = qp;
 	struct psd_scheduler_qp_ctx *psd_qp_ctx = qp_ctx->private_qp_ctx;
 	struct rte_crypto_op *sched_ops[NB_PKT_SIZE_SLAVES][nb_ops];
-	struct scheduler_session *sess;
 	uint32_t in_flight_ops[NB_PKT_SIZE_SLAVES] = {
 			psd_qp_ctx->primary_slave.nb_inflight_cops,
 			psd_qp_ctx->secondary_slave.nb_inflight_cops
@@ -97,8 +96,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		rte_prefetch0(ops[i + 7]->sym);
 		rte_prefetch0(ops[i + 7]->sym->session);
 
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
 		/* job_len is initialized as cipher data length, once
 		 * it is 0, equals to auth data length
 		 */
@@ -118,11 +115,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i];
-		ops[i]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
 		job_len = ops[i+1]->sym->cipher.data.length;
 		job_len += (ops[i+1]->sym->cipher.data.length == 0) *
 				ops[i+1]->sym->auth.data.length;
@@ -135,11 +129,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+1];
-		ops[i+1]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
 		job_len = ops[i+2]->sym->cipher.data.length;
 		job_len += (ops[i+2]->sym->cipher.data.length == 0) *
 				ops[i+2]->sym->auth.data.length;
@@ -152,12 +143,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+2];
-		ops[i+2]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
 		job_len = ops[i+3]->sym->cipher.data.length;
 		job_len += (ops[i+3]->sym->cipher.data.length == 0) *
 				ops[i+3]->sym->auth.data.length;
@@ -170,14 +157,10 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+3];
-		ops[i+3]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 	}
 
 	for (; i < nb_ops; i++) {
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-
 		job_len = ops[i]->sym->cipher.data.length;
 		job_len += (ops[i]->sym->cipher.data.length == 0) *
 				ops[i]->sym->auth.data.length;
@@ -190,7 +173,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i];
-		ops[i]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 	}
 
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index b9d8973..6e37efc 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -85,8 +85,10 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
 /** Configure device */
 static int
 scheduler_pmd_config(struct rte_cryptodev *dev,
-		struct rte_cryptodev_config *config __rte_unused)
+		struct rte_cryptodev_config *config)
 {
+	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint32_t i;
 	int ret;
 
 	/* although scheduler_attach_init_slave presents multiple times,
@@ -96,6 +98,15 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	if (ret < 0)
 		return ret;
 
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
+
+		ret = rte_cryptodev_configure(slave_dev_id, config,
+				dev->data->session_pool);
+		if (ret < 0)
+			break;
+	}
+
 	return ret;
 }
 
@@ -474,67 +485,43 @@ scheduler_pmd_qp_count(struct rte_cryptodev *dev)
 static uint32_t
 scheduler_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 {
-	return sizeof(struct scheduler_session);
-}
-
-static int
-config_slave_sess(struct scheduler_ctx *sched_ctx,
-		struct rte_crypto_sym_xform *xform,
-		struct scheduler_session *sess,
-		uint32_t create)
-{
-	uint32_t i;
+	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint8_t i = 0;
+	uint32_t max_priv_sess_size = 0;
 
+	/* Check what is the maximum private session size for all slaves */
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
-		struct scheduler_slave *slave = &sched_ctx->slaves[i];
+		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
+		struct rte_cryptodev *dev = &rte_cryptodevs[slave_dev_id];
+		uint32_t priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
 
-		if (sess->sessions[i]) {
-			if (create)
-				continue;
-			/* !create */
-			sess->sessions[i] = rte_cryptodev_sym_session_free(
-					slave->dev_id, sess->sessions[i]);
-		} else {
-			if (!create)
-				continue;
-			/* create */
-			sess->sessions[i] =
-					rte_cryptodev_sym_session_create(
-							slave->dev_id, xform);
-			if (!sess->sessions[i]) {
-				config_slave_sess(sched_ctx, NULL, sess, 0);
-				return -1;
-			}
-		}
+		if (max_priv_sess_size < priv_sess_size)
+			max_priv_sess_size = priv_sess_size;
 	}
 
-	return 0;
-}
-
-/** Clear the memory of session so it doesn't leave key material behind */
-static void
-scheduler_pmd_session_clear(struct rte_cryptodev *dev,
-	void *sess)
-{
-	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
-
-	config_slave_sess(sched_ctx, NULL, sess, 0);
-
-	memset(sess, 0, sizeof(struct scheduler_session));
+	return max_priv_sess_size;
 }
 
-static void *
+static int
 scheduler_pmd_session_configure(struct rte_cryptodev *dev,
-	struct rte_crypto_sym_xform *xform, void *sess)
+	struct rte_crypto_sym_xform *xform,
+	struct rte_cryptodev_sym_session *sess,
+	struct rte_mempool *mempool)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint32_t i;
+
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		struct scheduler_slave *slave = &sched_ctx->slaves[i];
 
-	if (config_slave_sess(sched_ctx, xform, sess, 1) < 0) {
-		CS_LOG_ERR("unabled to config sym session");
-		return NULL;
+		if (rte_cryptodev_sym_session_init(slave->dev_id, sess,
+					xform, mempool) < 0) {
+			CS_LOG_ERR("unabled to config sym session");
+			return -1;
+		}
 	}
 
-	return sess;
+	return 0;
 }
 
 struct rte_cryptodev_ops scheduler_pmd_ops = {
@@ -556,7 +543,7 @@ struct rte_cryptodev_ops scheduler_pmd_ops = {
 
 		.session_get_size	= scheduler_pmd_session_get_size,
 		.session_configure	= scheduler_pmd_session_configure,
-		.session_clear		= scheduler_pmd_session_clear,
+		.session_clear		= NULL,
 };
 
 struct rte_cryptodev_ops *rte_crypto_scheduler_pmd_ops = &scheduler_pmd_ops;
diff --git a/drivers/crypto/scheduler/scheduler_pmd_private.h b/drivers/crypto/scheduler/scheduler_pmd_private.h
index a78e9a6..a915ef4 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_private.h
+++ b/drivers/crypto/scheduler/scheduler_pmd_private.h
@@ -103,10 +103,6 @@ struct scheduler_qp_ctx {
 	uint32_t seqn;
 } __rte_cache_aligned;
 
-struct scheduler_session {
-	struct rte_cryptodev_sym_session *sessions[
-			RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES];
-};
 
 extern uint8_t cryptodev_driver_id;
 
diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c
index 0116276..4a84728 100644
--- a/drivers/crypto/scheduler/scheduler_roundrobin.c
+++ b/drivers/crypto/scheduler/scheduler_roundrobin.c
@@ -52,8 +52,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	uint32_t slave_idx = rr_qp_ctx->last_enq_slave_idx;
 	struct scheduler_slave *slave = &rr_qp_ctx->slaves[slave_idx];
 	uint16_t i, processed_ops;
-	struct rte_cryptodev_sym_session *sessions[nb_ops];
-	struct scheduler_session *sess0, *sess1, *sess2, *sess3;
 
 	if (unlikely(nb_ops == 0))
 		return 0;
@@ -61,39 +59,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	for (i = 0; i < nb_ops && i < 4; i++)
 		rte_prefetch0(ops[i]->sym->session);
 
-	for (i = 0; (i < (nb_ops - 8)) && (nb_ops > 8); i += 4) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
-		sessions[i] = ops[i]->sym->session;
-		sessions[i + 1] = ops[i + 1]->sym->session;
-		sessions[i + 2] = ops[i + 2]->sym->session;
-		sessions[i + 3] = ops[i + 3]->sym->session;
-
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-		ops[i + 1]->sym->session = sess1->sessions[slave_idx];
-		ops[i + 2]->sym->session = sess2->sessions[slave_idx];
-		ops[i + 3]->sym->session = sess3->sessions[slave_idx];
-
-		rte_prefetch0(ops[i + 4]->sym->session);
-		rte_prefetch0(ops[i + 5]->sym->session);
-		rte_prefetch0(ops[i + 6]->sym->session);
-		rte_prefetch0(ops[i + 7]->sym->session);
-	}
-
-	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sessions[i] = ops[i]->sym->session;
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-	}
-
 	processed_ops = rte_cryptodev_enqueue_burst(slave->dev_id,
 			slave->qp_id, ops, nb_ops);
 
@@ -102,12 +67,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	rr_qp_ctx->last_enq_slave_idx += 1;
 	rr_qp_ctx->last_enq_slave_idx %= rr_qp_ctx->nb_slaves;
 
-	/* recover session if enqueue is failed */
-	if (unlikely(processed_ops < nb_ops)) {
-		for (i = processed_ops; i < nb_ops; i++)
-			ops[i]->sym->session = sessions[i];
-	}
-
 	return processed_ops;
 }
 
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 677849d..b07718a 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -143,23 +143,40 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
 static struct snow3g_session *
 snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 {
-	struct snow3g_session *sess;
+	struct snow3g_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct snow3g_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct snow3g_session *)
+					get_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;
 
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct snow3g_session *)c_sess->_private;
+		sess = (struct snow3g_session *)_sess_private_data;
 
 		if (unlikely(snow3g_set_session_parameters(sess,
-				op->sym->xform) != 0))
-			return NULL;
+				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_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;
 }
 
@@ -286,7 +303,7 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = ops[i]->sym->auth.digest.data;
 
 			sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
@@ -356,7 +373,9 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		/* Free session if a session-less crypto op. */
 		if (ops[i]->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
-			rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
+			memset(ops[i]->sym->session, 0,
+					sizeof(struct snow3g_session));
+			rte_cryptodev_sym_session_free(ops[i]->sym->session);
 			ops[i]->sym->session = NULL;
 		}
 	}
@@ -408,7 +427,8 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
 
 	/* Free session if a session-less crypto op. */
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		memset(op->sym->session, 0, sizeof(struct snow3g_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index 26cc3e9..1967409 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -289,21 +289,37 @@ snow3g_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a SNOW 3G session from a crypto xform chain */
-static void *
+static int
 snow3g_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		SNOW3G_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (snow3g_set_session_parameters(sess, xform) != 0) {
+	if (snow3g_set_session_parameters(sess_private_data, xform) != 0) {
 		SNOW3G_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 385e4e5..c1d6310 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -142,23 +142,39 @@ zuc_set_session_parameters(struct zuc_session *sess,
 static struct zuc_session *
 zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 {
-	struct zuc_session *sess;
+	struct zuc_session *sess = NULL;
 
 	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
-		sess = (struct zuc_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct zuc_session *)get_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;
 
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct zuc_session *)c_sess->_private;
+		sess = (struct zuc_session *)_sess_private_data;
 
 		if (unlikely(zuc_set_session_parameters(sess,
-				op->sym->xform) != 0))
-			return NULL;
+				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_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;
 }
 
@@ -277,7 +293,7 @@ process_zuc_hash_op(struct rte_crypto_op **ops,
 			/* Trim area used for digest from mbuf. */
 			rte_pktmbuf_trim(ops[i]->sym->m_src,
 					ops[i]->sym->auth.digest.length);
-		} else  {
+		} else {
 			dst = (uint32_t *)ops[i]->sym->auth.digest.data;
 
 			sso_zuc_eia3_1_buffer(session->pKey_hash,
@@ -332,7 +348,9 @@ process_ops(struct rte_crypto_op **ops, struct zuc_session *session,
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		/* Free session if a session-less crypto op. */
 		if (ops[i]->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
-			rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
+			memset(ops[i]->sym->session, 0,
+					sizeof(struct zuc_session));
+			rte_cryptodev_sym_session_free(ops[i]->sym->session);
 			ops[i]->sym->session = NULL;
 		}
 	}
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index 645b80c..cdc783f 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -289,21 +289,37 @@ zuc_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a ZUC session from a crypto xform chain */
-static void *
+static int
 zuc_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		ZUC_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (zuc_set_session_parameters(sess, xform) != 0) {
+	if (zuc_set_session_parameters(sess_private_data, xform) != 0) {
 		ZUC_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 4d6c7ce..708eadd 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1242,8 +1242,7 @@ cryptodevs_init(void)
 
 	uint32_t max_sess_sz = 0, sess_sz;
 	for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
-		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(cdev_id);
+		sess_sz = rte_cryptodev_get_private_session_size(cdev_id);
 		if (sess_sz > max_sess_sz)
 			max_sess_sz = sess_sz;
 	}
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 048e441..c927344 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -45,7 +45,7 @@
 #include "esp.h"
 
 static inline int
-create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
+create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa)
 {
 	struct rte_cryptodev_info cdev_info;
 	unsigned long cdev_id_qp = 0;
@@ -72,7 +72,10 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
 			ipsec_ctx->tbl[cdev_id_qp].qp);
 
 	sa->crypto_session = rte_cryptodev_sym_session_create(
-			ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
+			ipsec_ctx->session_pool);
+	rte_cryptodev_sym_session_init(ipsec_ctx->tbl[cdev_id_qp].id,
+			sa->crypto_session, sa->xforms,
+			ipsec_ctx->session_pool);
 
 	rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
 	if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index add9291..9ec8e6f 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -593,6 +593,9 @@ static struct rte_cryptodev_sym_session *
 initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
 {
 	struct rte_crypto_sym_xform *first_xform;
+	struct rte_cryptodev_sym_session *session;
+	uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+	struct rte_mempool *sess_mp = session_pool_socket[socket_id];
 
 	if (options->xform_chain == L2FWD_CRYPTO_CIPHER_HASH) {
 		first_xform = &options->cipher_xform;
@@ -606,7 +609,16 @@ initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
 		first_xform = &options->auth_xform;
 	}
 
-	return rte_cryptodev_sym_session_create(cdev_id, first_xform);
+	session = rte_cryptodev_sym_session_create(sess_mp);
+
+	if (session == NULL)
+		return NULL;
+
+	if (rte_cryptodev_sym_session_init(cdev_id, session,
+				first_xform, sess_mp) < 0)
+		return NULL;
+
+	return session;
 }
 
 static void
@@ -1564,8 +1576,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 	}
 
 	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
-		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(cdev_id);
+		sess_sz = rte_cryptodev_get_private_session_size(cdev_id);
 		if (sess_sz > max_sess_sz)
 			max_sess_sz = sess_sz;
 	}
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 5c7191b..b304a7b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -69,6 +69,8 @@
 #include "rte_cryptodev.h"
 #include "rte_cryptodev_pmd.h"
 
+static uint8_t nb_drivers;
+
 struct rte_cryptodev rte_crypto_devices[RTE_CRYPTO_MAX_DEVS];
 
 struct rte_cryptodev *rte_cryptodevs = &rte_crypto_devices[0];
@@ -1019,53 +1021,47 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 }
 
 
-static void
-rte_cryptodev_sym_session_init(struct rte_mempool *mp,
-		const struct rte_cryptodev *dev,
-		struct rte_cryptodev_sym_session *sess)
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_crypto_sym_xform *xforms,
+		struct rte_mempool *mp)
 {
-	memset(sess, 0, mp->elt_size);
+	struct rte_cryptodev *dev;
+	uint8_t index;
 
-	if (dev->dev_ops->session_initialize)
-		(*dev->dev_ops->session_initialize)(mp, sess);
-}
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
 
+	if (sess == NULL || xforms == NULL || dev == NULL)
+		return -1;
 
-struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform)
-{
-	struct rte_cryptodev *dev;
-	struct rte_cryptodev_sym_session *sess;
-	void *_sess;
+	index = dev->driver_id;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return NULL;
+	if (sess->sess_private_data[index] == NULL) {
+		if (dev->dev_ops->session_configure(dev, xforms, sess, mp) < 0) {
+			CDEV_LOG_ERR(
+				"dev_id %d failed to configure session details",
+				dev_id);
+			return -1;
+		}
 	}
 
-	dev = &rte_crypto_devices[dev_id];
+	return 0;
+}
+
+struct rte_cryptodev_sym_session *
+rte_cryptodev_sym_session_create(struct rte_mempool *mp)
+{
+	struct rte_cryptodev_sym_session *sess;
 
 	/* Allocate a session structure from the session pool */
-	if (rte_mempool_get(dev->data->session_pool, &_sess)) {
-		CDEV_LOG_ERR("Couldn't get object from session mempool");
+	if (rte_mempool_get(mp, (void *)&sess)) {
+		CDEV_LOG_ERR("couldn't get object from session mempool");
 		return NULL;
 	}
 
-	sess = _sess;
-
-	rte_cryptodev_sym_session_init(dev->data->session_pool, dev,
-					sess);
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL);
-	if (dev->dev_ops->session_configure(dev, xform, sess->_private) ==
-			NULL) {
-		CDEV_LOG_ERR("dev_id %d failed to configure session details",
-				dev_id);
-
-		/* Return session to mempool */
-		rte_mempool_put(dev->data->session_pool, _sess);
-		return NULL;
-	}
+	/* Clear device session pointer */
+	memset(sess, 0, (sizeof(void *) * nb_drivers));
 
 	return sess;
 }
@@ -1085,7 +1081,10 @@ rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0);
-	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) {
+
+	void *sess_priv = get_session_private_data(sess, dev->driver_id);
+
+	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess_priv)) {
 		CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session",
 				dev_id, qp_id);
 		return -EPERM;
@@ -1109,7 +1108,10 @@ rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0);
-	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) {
+
+	void *sess_priv = get_session_private_data(sess, dev->driver_id);
+
+	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess_priv)) {
 		CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session",
 				dev_id, qp_id);
 		return -EPERM;
@@ -1117,34 +1119,45 @@ rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	return 0;
 }
-struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
-		struct rte_cryptodev_sym_session *sess)
+void
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess)
 {
-	struct rte_cryptodev *dev;
+	uint8_t i;
+	struct rte_mempool *sess_mp;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return sess;
-	}
+	if (sess == NULL)
+		return;
 
-	dev = &rte_crypto_devices[dev_id];
+	void *sess_priv;
 
-	/* Let device implementation clear session material */
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_clear, sess);
-	dev->dev_ops->session_clear(dev, (void *)sess->_private);
+	for (i = 0; i < nb_drivers; i++) {
+		if (sess->sess_private_data[i] != NULL) {
+			sess_priv = get_session_private_data(sess, i);
+			sess_mp = rte_mempool_from_obj(sess_priv);
+			rte_mempool_put(sess_mp, sess_priv);
+		}
+	}
 
 	/* Return session to mempool */
-	struct rte_mempool *mp = rte_mempool_from_obj(sess);
-	rte_mempool_put(mp, (void *)sess);
+	sess_mp = rte_mempool_from_obj(sess);
+	rte_mempool_put(sess_mp, sess);
+}
 
-	return NULL;
+unsigned int
+rte_cryptodev_get_header_session_size(void)
+{
+	/*
+	 * Header contains pointers to the private data
+	 * of all registered drivers
+	 */
+	return (sizeof(void *) * nb_drivers);
 }
 
 unsigned int
 rte_cryptodev_get_private_session_size(uint8_t dev_id)
 {
 	struct rte_cryptodev *dev;
+	unsigned int header_size = sizeof(void *) * nb_drivers;
 	unsigned int priv_sess_size;
 
 	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
@@ -1157,6 +1170,14 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id)
 
 	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
 
+	/*
+	 * If size is less than session header size,
+	 * return the latter, as this guarantees that
+	 * sessionless operations will work
+	 */
+	if (priv_sess_size < header_size)
+		return header_size;
+
 	return priv_sess_size;
 
 }
@@ -1272,8 +1293,6 @@ struct cryptodev_driver {
 	uint8_t id;
 };
 
-static uint8_t nb_drivers;
-
 int
 rte_cryptodev_driver_id_get(const char *name)
 {
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 044a4aa..2204982 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -797,50 +797,59 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 /** Cryptodev symmetric crypto session */
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
-	__extension__ char _private[0];
+	__extension__ void *sess_private_data[0];
 	/**< Private session material */
 };
 
 
 /**
- * Initialise a session for symmetric cryptographic operations.
+ * Create symmetric crypto session (generic with no private data)
  *
- * This function is used by the client to initialize immutable
- * parameters of symmetric cryptographic operation.
- * To perform the operation the rte_cryptodev_enqueue_burst function is
- * used.  Each mbuf should contain a reference to the session
- * pointer returned from this function contained within it's crypto_op if a
- * session-based operation is being provisioned. Memory to contain the session
- * information is allocated from within mempool managed by the cryptodev.
- *
- * The rte_cryptodev_session_free must be called to free allocated
- * memory when the session is no longer required.
+ * @param   mempool    Symmetric session mempool to allocate session
+ *                     objects from
+ * @return
+ *  - On success return pointer to sym-session
+ *  - On failure returns NULL
+ */
+struct rte_cryptodev_sym_session *
+rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
+
+/**
+ * Frees symmetric crypto session and all related device type specific
+ * private data objects associated with session
  *
- * @param	dev_id		The device identifier.
- * @param	xform		Crypto transform chain.
+ * @param   session  Session where the private data will be attached to
+ */
+void
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *session);
 
+/**
+ * Fill out private data for the device id, based on its device type
+ *
+ * @param   dev_id   ID of device that we want the session to be used on
+ * @param   sess     Session where the private data will be attached to
+ * @param   xforms   Symmetric crypto transform operations to apply on flow
+ *                   processed with this session
+ * @param   mempool  Mempool where the private data is allocated.
  *
  * @return
- *  Pointer to the created session or NULL
+ *  - On success, zero.
+ *  - On failure, a negative value.
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform);
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+			struct rte_cryptodev_sym_session *sess,
+			struct rte_crypto_sym_xform *xforms,
+			struct rte_mempool *mempool);
 
 /**
- * Free the memory associated with a previously allocated session.
- *
- * @param	dev_id		The device identifier.
- * @param	session		Session pointer previously allocated by
- *				*rte_cryptodev_sym_session_create*.
+ * Get the size of the header session, for all registered drivers.
  *
  * @return
- *   NULL on successful freeing of session.
- *   Session pointer on failure to free session.
+ *   Size of the header session.
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
-		struct rte_cryptodev_sym_session *session);
+unsigned int
+rte_cryptodev_get_header_session_size(void);
 
 /**
  * Get the size of the private session data for a device.
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 5911b83..d7cefd8 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -285,13 +285,16 @@ typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
  * @param	dev		Crypto device pointer
  * @param	xform		Single or chain of crypto xforms
  * @param	priv_sess	Pointer to cryptodev's private session structure
+ * @param	mp		Mempool where the private session is allocated
  *
  * @return
- *  - Returns private session structure on success.
- *  - Returns NULL on failure.
+ *  - Returns 0 if private session structure have been created successfully.
+ *  - Returns -1 on failure.
  */
-typedef void * (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
-		struct rte_crypto_sym_xform *xform, void *session_private);
+typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *session,
+		struct rte_mempool *mp);
 
 /**
  * Free Crypto session.
@@ -413,6 +416,19 @@ void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 int
 rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
 
+static inline void *
+get_session_private_data(const struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id) {
+	return sess->sess_private_data[driver_id];
+}
+
+static inline void
+set_session_private_data(struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id, void *private_data)
+{
+	sess->sess_private_data[driver_id] = private_data;
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 8855a34..c117c4f 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -65,9 +65,11 @@ DPDK_17.08 {
 	rte_cryptodev_device_count_by_driver;
 	rte_cryptodev_driver_id_get;
 	rte_cryptodev_driver_name_get;
+	rte_cryptodev_get_header_session_size;
 	rte_cryptodev_get_private_session_size;
 	rte_cryptodev_pci_generic_probe;
 	rte_cryptodev_pci_generic_remove;
+	rte_cryptodev_sym_session_init;
 	rte_cryptodev_vdev_parse_init_params;
 	rte_cryptodev_vdev_pmd_init;
 
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index cdc1cbf..9d08eb8 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -67,7 +67,6 @@ struct crypto_testsuite_params {
 	struct rte_mempool *large_mbuf_pool;
 	struct rte_mempool *op_mpool;
 	struct rte_mempool *session_mpool;
-	struct rte_mempool *slave_session_mpool;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_qp_conf qp_conf;
 
@@ -384,12 +383,15 @@ testsuite_setup(void)
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
 
-	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-		rte_cryptodev_get_private_session_size(dev_id);
+	unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
 
+	/*
+	 * Create mempool with maximum number of sessions * 2,
+	 * to include the session headers
+	 */
 	ts_params->session_mpool = rte_mempool_create(
 				"test_sess_mp",
-				info.sym.max_nb_sessions,
+				info.sym.max_nb_sessions * 2,
 				session_size,
 				0, 0, NULL, NULL, NULL,
 				NULL, SOCKET_ID_ANY,
@@ -436,11 +438,6 @@ testsuite_teardown(void)
 		rte_mempool_free(ts_params->session_mpool);
 		ts_params->session_mpool = NULL;
 	}
-
-	if (ts_params->slave_session_mpool != NULL) {
-		rte_mempool_free(ts_params->slave_session_mpool);
-		ts_params->slave_session_mpool = NULL;
-	}
 }
 
 static int
@@ -491,8 +488,7 @@ ut_teardown(void)
 
 	/* free crypto session structure */
 	if (ut_params->sess) {
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
-				ut_params->sess);
+		rte_cryptodev_sym_session_free(ut_params->sess);
 		ut_params->sess = NULL;
 	}
 
@@ -1275,10 +1271,13 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
 
-	/* Create crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0],
-			&ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate crypto op data structure */
@@ -1500,7 +1499,9 @@ test_AES_cipheronly_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1517,7 +1518,9 @@ test_AES_docsis_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1534,7 +1537,9 @@ test_AES_docsis_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1551,7 +1556,9 @@ test_DES_docsis_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_DES_DOCSIS_TYPE);
@@ -1568,7 +1575,9 @@ test_authonly_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1585,7 +1594,9 @@ test_AES_chain_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1604,7 +1615,9 @@ test_AES_cipheronly_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1621,7 +1634,9 @@ test_AES_chain_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1638,7 +1653,9 @@ test_authonly_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1657,7 +1674,9 @@ test_AES_chain_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1674,7 +1693,9 @@ test_AES_cipheronly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1691,7 +1712,9 @@ test_AES_chain_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1708,7 +1731,9 @@ test_AES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1725,7 +1750,9 @@ test_AES_chain_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1742,7 +1769,9 @@ test_AES_cipheronly_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1759,7 +1788,9 @@ test_authonly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1776,7 +1807,9 @@ test_AES_chain_armv8_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1796,6 +1829,7 @@ create_wireless_algo_hash_session(uint8_t dev_id,
 {
 	uint8_t hash_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(hash_key, key, key_len);
@@ -1812,8 +1846,12 @@ create_wireless_algo_hash_session(uint8_t dev_id,
 	ut_params->auth_xform.auth.key.data = hash_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
 	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->auth_xform, ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
 }
@@ -1826,6 +1864,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
 {
 	uint8_t cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_key, key, key_len);
@@ -1839,12 +1878,14 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session */
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-						&ut_params->
-						cipher_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->cipher_xform, ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
 }
@@ -1955,6 +1996,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
 {
 	uint8_t cipher_auth_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_auth_key, key, key_len);
@@ -1980,11 +2022,14 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->cipher_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
@@ -2002,6 +2047,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
 	uint8_t cipher_auth_key[key_len];
 
 	struct crypto_unittest_params *ut_params = &unittest_params;
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	const uint8_t *key = tdata->key.data;
 	const uint8_t aad_len = tdata->aad.len;
 	const uint8_t auth_len = tdata->digest.len;
@@ -2029,11 +2075,14 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->cipher_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
@@ -2060,6 +2109,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
 {
 	uint8_t auth_cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(auth_cipher_key, key, key_len);
@@ -2082,11 +2132,14 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -4700,7 +4753,9 @@ test_3DES_chain_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4717,7 +4772,9 @@ test_DES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_DES_CIPHERONLY_TYPE);
@@ -4734,7 +4791,9 @@ test_DES_docsis_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_DES_DOCSIS_TYPE);
@@ -4751,7 +4810,9 @@ test_3DES_chain_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4768,7 +4829,9 @@ test_3DES_cipheronly_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4785,7 +4848,9 @@ test_3DES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4802,7 +4867,9 @@ test_3DES_chain_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4819,7 +4886,9 @@ test_3DES_cipheronly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4839,6 +4908,7 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
 {
 	uint8_t cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_key, key, key_len);
@@ -4866,16 +4936,19 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
 	ut_params->auth_xform.auth.key.length = 0;
 	ut_params->auth_xform.auth.key.data = NULL;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		ut_params->cipher_xform.next = &ut_params->auth_xform;
 
 		/* Create Crypto session*/
-		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->cipher_xform, ts_params->session_mpool);
 	} else {/* Create Crypto session*/
 		ut_params->auth_xform.next = &ut_params->cipher_xform;
-		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform, ts_params->session_mpool);
 	}
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@@ -5773,7 +5846,11 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
 	ut_params->auth_xform.auth.key.data = key;
 
 	ut_params->sess = rte_cryptodev_sym_session_create(
-		ts_params->valid_devs[0], &ut_params->auth_xform);
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
 
 	if (ut_params->sess == NULL)
 		return TEST_FAILED;
@@ -5949,9 +6026,13 @@ test_multi_session(void)
 
 	/* Create multiple crypto sessions*/
 	for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
+
 		sessions[i] = rte_cryptodev_sym_session_create(
-				ts_params->valid_devs[0],
-			&ut_params->auth_xform);
+				ts_params->session_mpool);
+
+		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+				sessions[i], &ut_params->auth_xform,
+				ts_params->session_mpool);
 		TEST_ASSERT_NOT_NULL(sessions[i],
 				"Session creation failed at session number %u",
 				i);
@@ -5987,14 +6068,14 @@ test_multi_session(void)
 	}
 
 	/* Next session create should fail */
-	sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
-			&ut_params->auth_xform);
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			sessions[i], &ut_params->auth_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NULL(sessions[i],
 			"Session creation succeeded unexpectedly!");
 
 	for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
-				sessions[i]);
+		rte_cryptodev_sym_session_free(sessions[i]);
 
 	rte_free(sessions);
 
@@ -6052,6 +6133,9 @@ test_multi_session_random_usage(void)
 					* dev_info.sym.max_nb_sessions) + 1, 0);
 
 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
+		sessions[i] = rte_cryptodev_sym_session_create(
+				ts_params->session_mpool);
+
 		rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
 				sizeof(struct crypto_unittest_params));
 
@@ -6060,9 +6144,11 @@ test_multi_session_random_usage(void)
 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
 
 		/* Create multiple crypto sessions*/
-		sessions[i] = rte_cryptodev_sym_session_create(
+		rte_cryptodev_sym_session_init(
 				ts_params->valid_devs[0],
-				&ut_paramz[i].ut_params.auth_xform);
+				sessions[i],
+				&ut_paramz[i].ut_params.auth_xform,
+				ts_params->session_mpool);
 
 		TEST_ASSERT_NOT_NULL(sessions[i],
 				"Session creation failed at session number %u",
@@ -6106,8 +6192,7 @@ test_multi_session_random_usage(void)
 	}
 
 	for (i = 0; i < MB_SESSION_NUMBER; i++)
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
-				sessions[i]);
+		rte_cryptodev_sym_session_free(sessions[i]);
 
 	rte_free(sessions);
 
@@ -6131,9 +6216,14 @@ test_null_cipher_only_operation(void)
 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+				ut_params->sess,
+				&ut_params->cipher_xform,
+				ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6188,9 +6278,13 @@ test_null_auth_only_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->auth_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6244,9 +6338,13 @@ test_null_cipher_auth_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6310,9 +6408,13 @@ test_null_auth_cipher_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6358,6 +6460,7 @@ test_null_invalid_operation(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
+	int ret;
 
 	/* Setup Cipher Parameters */
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@@ -6366,10 +6469,14 @@ test_null_invalid_operation(void)
 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
-	TEST_ASSERT_NULL(ut_params->sess,
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
+	TEST_ASSERT(ret == -1,
 			"Session creation succeeded unexpectedly");
 
 
@@ -6380,10 +6487,14 @@ test_null_invalid_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->auth_xform);
-	TEST_ASSERT_NULL(ut_params->sess,
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
+	TEST_ASSERT(ret == -1,
 			"Session creation succeeded unexpectedly");
 
 	return TEST_SUCCESS;
@@ -6417,9 +6528,13 @@ test_null_burst_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
@@ -6560,6 +6675,7 @@ static int create_gmac_session(uint8_t dev_id,
 {
 	uint8_t cipher_key[tdata->key.len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_key, tdata->key.data, tdata->key.len);
@@ -6584,8 +6700,12 @@ static int create_gmac_session(uint8_t dev_id,
 
 	ut_params->cipher_xform.next = &ut_params->auth_xform;
 
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-			&ut_params->cipher_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->cipher_xform,
+			ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -6915,6 +7035,7 @@ create_auth_session(struct crypto_unittest_params *ut_params,
 		const struct test_crypto_vector *reference,
 		enum rte_crypto_auth_operation auth_op)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t auth_key[reference->auth_key.len + 1];
 
 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
@@ -6929,9 +7050,13 @@ create_auth_session(struct crypto_unittest_params *ut_params,
 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
 	ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform,
+				ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -6945,6 +7070,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
 		enum rte_crypto_auth_operation auth_op,
 		enum rte_crypto_cipher_operation cipher_op)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t cipher_key[reference->cipher_key.len + 1];
 	uint8_t auth_key[reference->auth_key.len + 1];
 
@@ -6970,9 +7096,13 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
 	ut_params->cipher_xform.cipher.key.data = cipher_key;
 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
 
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform,
+				ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -7864,30 +7994,32 @@ test_scheduler_attach_slave_op(void)
 			continue;
 
 		/*
-		 * Create a separate mempool for the slaves, as they need different
-		 * session size and then configure them to store the pointer
-		 * to this mempool
+		 * Create the session mempool again, since now there are new devices
+		 * to use the mempool.
 		 */
-		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(i);
-
-		if (ts_params->slave_session_mpool == NULL) {
-			ts_params->slave_session_mpool = rte_mempool_create(
-				"test_slave_sess_mp",
-				info.sym.max_nb_sessions,
-				session_size,
-				0, 0, NULL, NULL, NULL, NULL,
-				SOCKET_ID_ANY, 0);
+		if (ts_params->session_mpool) {
+			rte_mempool_free(ts_params->session_mpool);
+			ts_params->session_mpool = NULL;
+		}
+		unsigned int session_size = rte_cryptodev_get_private_session_size(i);
 
-			TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
+		/*
+		 * Create mempool with maximum number of sessions * 2,
+		 * to include the session headers
+		 */
+		if (ts_params->session_mpool == NULL) {
+			ts_params->session_mpool = rte_mempool_create(
+					"test_sess_mp",
+					info.sym.max_nb_sessions * 2,
+					session_size,
+					0, 0, NULL, NULL, NULL,
+					NULL, SOCKET_ID_ANY,
+					0);
+
+			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
 					"session mempool allocation failed");
 		}
 
-		TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
-				&ts_params->conf, ts_params->slave_session_mpool),
-				"Failed to configure cryptodev %u with %u qps",
-				i, ts_params->conf.nb_queue_pairs);
-
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
diff --git a/test/test/test_cryptodev_blockcipher.c b/test/test/test_cryptodev_blockcipher.c
index 4bc370d..b2e600f 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -52,6 +52,7 @@ static int
 test_blockcipher_one_case(const struct blockcipher_test_case *t,
 	struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	char *test_msg)
@@ -64,8 +65,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 	struct rte_crypto_sym_xform *init_xform = NULL;
 	struct rte_crypto_sym_op *sym_op = NULL;
 	struct rte_crypto_op *op = NULL;
-	struct rte_cryptodev_sym_session *sess = NULL;
 	struct rte_cryptodev_info dev_info;
+	struct rte_cryptodev_sym_session *sess = NULL;
 
 	int status = TEST_SUCCESS;
 	const struct blockcipher_test_data *tdata = t->test_data;
@@ -349,8 +350,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 
 	/* create session for sessioned op */
 	if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
-		sess = rte_cryptodev_sym_session_create(dev_id,
-			init_xform);
+		sess = rte_cryptodev_sym_session_create(sess_mpool);
+
+		rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
+				sess_mpool);
 		if (!sess) {
 			snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
 				"FAILED: %s", __LINE__,
@@ -448,7 +451,6 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 		else
 			auth_res = pktmbuf_mtod_offset(iobuf,
 					tdata->ciphertext.len);
-
 		if (memcmp(auth_res, tdata->digest.data, digest_len)) {
 			snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
 				"FAILED: %s", __LINE__, "Generated "
@@ -577,7 +579,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 error_exit:
 	if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
 		if (sess)
-			rte_cryptodev_sym_session_free(dev_id, sess);
+			rte_cryptodev_sym_session_free(sess);
 		if (cipher_xform)
 			rte_free(cipher_xform);
 		if (auth_xform)
@@ -599,6 +601,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 int
 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	enum blockcipher_test_type test_type)
@@ -690,7 +693,7 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 			continue;
 
 		status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
-			dev_id, driver_id, test_msg);
+			sess_mpool, dev_id, driver_id, test_msg);
 
 		printf("  %u) TestCase %s %s\n", test_index ++,
 			tc->test_descr, test_msg);
diff --git a/test/test/test_cryptodev_blockcipher.h b/test/test/test_cryptodev_blockcipher.h
index 22fb420..22b8d20 100644
--- a/test/test/test_cryptodev_blockcipher.h
+++ b/test/test/test_cryptodev_blockcipher.h
@@ -125,6 +125,7 @@ struct blockcipher_test_data {
 int
 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	enum blockcipher_test_type test_type);
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 753667a..68c5fdd 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -100,6 +100,8 @@ struct symmetric_session_attrs {
 	uint32_t digest_len;
 };
 
+static struct rte_cryptodev_sym_session *test_crypto_session;
+
 #define ALIGN_POW2_ROUNDUP(num, align) \
 	(((num) + (align) - 1) & ~((align) - 1))
 
@@ -148,17 +150,17 @@ struct crypto_unittest_params {
 	uint8_t *digest;
 };
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo);
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo);
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
@@ -478,8 +480,7 @@ ut_teardown(void)
 
 	/* free crypto session structure */
 	if (ut_params->sess)
-		rte_cryptodev_sym_session_free(ts_params->dev_id,
-				ut_params->sess);
+		rte_cryptodev_sym_session_free(ut_params->sess);
 
 	/* free crypto operation structure */
 	if (ut_params->op)
@@ -1958,10 +1959,13 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(ts_params->dev_id,
-		&ut_params->cipher_xform);
 
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
+	rte_cryptodev_sym_session_init(ts_params->dev_id, test_crypto_session,
+			&ut_params->cipher_xform, ts_params->sess_mp);
+
+	TEST_ASSERT_NOT_NULL(test_crypto_session, "Session creation failed");
 
 	/* Generate Crypto op data structure(s) */
 	for (i = 0; i < num_to_submit ; i++) {
@@ -1983,7 +1987,7 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
 				rte_crypto_op_alloc(ts_params->op_mpool,
 						RTE_CRYPTO_OP_TYPE_SYMMETRIC);
 
-		rte_crypto_op_attach_sym_session(op, ut_params->sess);
+		rte_crypto_op_attach_sym_session(op, test_crypto_session);
 
 		op->sym->auth.digest.data = ut_params->digest;
 		op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
@@ -2101,9 +2105,12 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_snow3g_session(ts_params->dev_id,
+	if (test_perf_create_snow3g_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2199,7 +2206,7 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
 		rte_pktmbuf_free(c_ops[i]->sym->m_src);
 		rte_crypto_op_free(c_ops[i]);
 	}
-	rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return TEST_SUCCESS;
 }
@@ -2280,9 +2287,13 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_openssl_session(ts_params->dev_id,
+	if (test_perf_create_openssl_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
+
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2403,7 +2414,7 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
 		rte_pktmbuf_free(c_ops[i]->sym->m_src);
 		rte_crypto_op_free(c_ops[i]);
 	}
-	rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return TEST_SUCCESS;
 }
@@ -2432,9 +2443,12 @@ test_perf_armv8_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_armv8_session(ts_params->dev_id,
+	if (test_perf_create_armv8_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2646,12 +2660,13 @@ static uint8_t snow3g_hash_key[] = {
 		0x1E, 0x26, 0x98, 0xD2, 0xE2, 0x2A, 0xD5, 0x7E
 };
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2673,33 +2688,42 @@ test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
 		auth_xform.auth.digest_length =
 					get_auth_digest_length(auth_algo);
 	}
+
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	case CIPHER_ONLY:
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
 #define SNOW3G_CIPHER_IV_LENGTH 16
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo, unsigned cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = {0};
 	struct rte_crypto_sym_xform auth_xform = {0};
 
@@ -2722,36 +2746,46 @@ test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 	auth_xform.auth.key.length =  get_auth_key_max_length(auth_algo);
 	auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	case CIPHER_ONLY:
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_ONLY:
 		auth_xform.next = NULL;
 		/* Create Crypto session */
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2771,7 +2805,7 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		cipher_xform.cipher.key.data = aes_key;
 		break;
 	default:
-		return NULL;
+		return -1;
 	}
 
 	cipher_xform.cipher.key.length = cipher_key_len;
@@ -2789,34 +2823,40 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		auth_xform.auth.key.data = NULL;
 		break;
 	default:
-		return NULL;
+		return -1;
 	}
 
 	auth_xform.auth.key.length =  get_auth_key_max_length(auth_algo);
 	auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2829,7 +2869,7 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		cipher_xform.cipher.key.data = aes_cbc_128_key;
 		break;
 	default:
-		return NULL;
+		return -1;
 	}
 
 	cipher_xform.cipher.key.length = cipher_key_len;
@@ -2841,6 +2881,8 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 
 	auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
 
+	rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
@@ -2848,16 +2890,20 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		/* Encrypt and hash the result */
 		cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Hash encrypted message and decrypt */
 		cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
@@ -3125,9 +3171,12 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_aes_sha_session(ts_params->dev_id,
+	if (test_perf_create_aes_sha_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3223,7 +3272,7 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3259,9 +3308,12 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_snow3g_session(ts_params->dev_id,
+	if (test_perf_create_snow3g_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3388,7 +3440,7 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3445,9 +3497,12 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_openssl_session(ts_params->dev_id,
+	if (test_perf_create_openssl_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3540,7 +3595,7 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3577,9 +3632,12 @@ test_perf_armv8(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_armv8_session(ts_params->dev_id,
+	if (test_perf_create_armv8_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->cipher_key_length, pparams->auth_algo);
+			pparams->cipher_key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -4124,7 +4182,7 @@ test_perf_aes_cbc_vary_burst_size(void)
 static struct rte_cryptodev_sym_session *
 test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
 {
-	static struct rte_cryptodev_sym_session *sess;
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -4153,19 +4211,20 @@ test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
 	auth_xform.auth.digest_length = pparams->session_attrs->digest_len;
 	auth_xform.auth.key.length = pparams->session_attrs->key_auth_len;
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 
 	cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 	if (cipher_xform.cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
 		cipher_xform.next = &auth_xform;
-		sess = rte_cryptodev_sym_session_create(dev_id,
-				&cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, test_crypto_session,
+				&cipher_xform, ts_params->sess_mp);
 	} else {
 		auth_xform.next = &cipher_xform;
-		sess = rte_cryptodev_sym_session_create(dev_id,
-				&auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, test_crypto_session,
+				&auth_xform, ts_params->sess_mp);
 	}
 
-	return sess;
+	return test_crypto_session;
 }
 
 static inline struct rte_crypto_op *
@@ -4407,7 +4466,7 @@ perf_AES_GCM(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < burst; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return 0;
 }
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 10/12] cryptodev: add mempool pointer in queue pair setup
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (8 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 09/12] cryptodev: support device independent sessions Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 11/12] cryptodev: remove session init internal function Pablo de Lara
                       ` (2 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

The session mempool pointer is needed in each queue pair,
if session-less operations are being handled.
Therefore, the API is changed to accept this parameter,
as the session mempool is created outside the
device configuration function, similar to what ethdev
does with the rx queues.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/main.c                    | 18 ++++----
 doc/guides/rel_notes/release_17_08.rst         |  2 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c   |  4 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c |  4 +-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c       |  4 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c    |  3 +-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c     |  4 +-
 drivers/crypto/null/null_crypto_pmd_ops.c      |  4 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c   |  4 +-
 drivers/crypto/qat/qat_crypto.h                |  3 +-
 drivers/crypto/qat/qat_qp.c                    |  2 +-
 drivers/crypto/scheduler/scheduler_pmd_ops.c   | 13 ++++--
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c     |  4 +-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c           |  4 +-
 examples/ipsec-secgw/ipsec-secgw.c             |  6 +--
 examples/l2fwd-crypto/main.c                   |  5 +--
 lib/librte_cryptodev/rte_cryptodev.c           | 11 +++--
 lib/librte_cryptodev/rte_cryptodev.h           |  9 ++--
 lib/librte_cryptodev/rte_cryptodev_pmd.h       |  3 +-
 test/test/test_cryptodev.c                     | 58 +++++++++++++++-----------
 test/test/test_cryptodev_perf.c                |  5 ++-
 21 files changed, 93 insertions(+), 77 deletions(-)

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index eb2737e..f325b11 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -123,20 +123,20 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
 			session_pool_socket[socket_id] = sess_mp;
 		}
 
-		ret = rte_cryptodev_configure(cdev_id, &conf,
-				session_pool_socket[socket_id]);
+		ret = rte_cryptodev_configure(cdev_id, &conf);
 		if (ret < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -EINVAL;
 		}
 
-		ret = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
-				socket_id);
-		if (ret < 0) {
-			printf("Failed to setup queue pair %u on "
-				"cryptodev %u",	0, cdev_id);
-			return -EINVAL;
-		}
+		ret = rte_cryptodev_queue_pair_setup(cdev_id, 0,
+				&qp_conf, socket_id,
+				session_pool_socket[socket_id]);
+			if (ret < 0) {
+				printf("Failed to setup queue pair %u on "
+					"cryptodev %u",	0, cdev_id);
+				return -EINVAL;
+			}
 
 		ret = rte_cryptodev_start(cdev_id);
 		if (ret < 0) {
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 463b616..8630b40 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -170,7 +170,7 @@ API Changes
   * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
   * Replaced ``private`` marker with array of pointers to private data sessions
     ``sess_private_data`` in ``rte_cryptodev_sym_session``
-
+  * Added new field ``session_pool`` to ``rte_cryptodev_queue_pair_setup()``.
 
 ABI Changes
 -----------
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 0b063fd..d47a041 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -244,7 +244,7 @@ aesni_gcm_pmd_qp_create_processed_pkts_ring(struct aesni_gcm_qp *qp,
 static int
 aesni_gcm_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct aesni_gcm_qp *qp = NULL;
 
@@ -269,7 +269,7 @@ aesni_gcm_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_pkts == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index fda8296..1216e56 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -397,7 +397,7 @@ aesni_mb_pmd_qp_create_processed_ops_ring(struct aesni_mb_qp *qp,
 static int
 aesni_mb_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct aesni_mb_qp *qp = NULL;
 	struct aesni_mb_private *internals = dev->data->dev_private;
@@ -426,7 +426,7 @@ aesni_mb_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->ingress_queue == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 3db420b..735116f 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -247,7 +247,7 @@ armv8_crypto_pmd_qp_create_processed_ops_ring(struct armv8_crypto_qp *qp,
 static int
 armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct armv8_crypto_qp *qp = NULL;
 
@@ -272,7 +272,7 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 0a85690..bab2b4e 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -660,7 +660,8 @@ dpaa2_sec_queue_pair_release(struct rte_cryptodev *dev, uint16_t queue_pair_id)
 static int
 dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		__rte_unused const struct rte_cryptodev_qp_conf *qp_conf,
-		__rte_unused int socket_id)
+		__rte_unused int socket_id,
+		__rte_unused struct rte_mempool *session_pool)
 {
 	struct dpaa2_sec_dev_private *priv = dev->data->dev_private;
 	struct dpaa2_sec_qp *qp;
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index d590b91..2805e6f 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -223,7 +223,7 @@ kasumi_pmd_qp_create_processed_ops_ring(struct kasumi_qp *qp,
 static int
 kasumi_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct kasumi_qp *qp = NULL;
 
@@ -248,7 +248,7 @@ kasumi_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index 04147fe..7d0ac2d 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -215,7 +215,7 @@ null_crypto_pmd_qp_create_processed_pkts_ring(struct null_crypto_qp *qp,
 static int
 null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct null_crypto_private *internals = dev->data->dev_private;
 	struct null_crypto_qp *qp;
@@ -258,7 +258,7 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		goto qp_setup_cleanup;
 	}
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 005855b..d8eb335 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -602,7 +602,7 @@ openssl_pmd_qp_create_processed_ops_ring(struct openssl_qp *qp,
 static int
 openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct openssl_qp *qp = NULL;
 
@@ -627,7 +627,7 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h
index d5466c2..65af962 100644
--- a/drivers/crypto/qat/qat_crypto.h
+++ b/drivers/crypto/qat/qat_crypto.h
@@ -103,7 +103,8 @@ void qat_crypto_sym_stats_get(struct rte_cryptodev *dev,
 void qat_crypto_sym_stats_reset(struct rte_cryptodev *dev);
 
 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
-	const struct rte_cryptodev_qp_conf *rx_conf, int socket_id);
+	const struct rte_cryptodev_qp_conf *rx_conf, int socket_id,
+	struct rte_mempool *session_pool);
 int qat_crypto_sym_qp_release(struct rte_cryptodev *dev,
 	uint16_t queue_pair_id);
 
diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c
index 3921c2e..2b2ab42 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -134,7 +134,7 @@ queue_dma_zone_reserve(const char *queue_name, uint32_t queue_size,
 
 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 	const struct rte_cryptodev_qp_conf *qp_conf,
-	int socket_id)
+	int socket_id, struct rte_mempool *session_pool __rte_unused)
 {
 	struct qat_qp *qp;
 	struct rte_pci_device *pci_dev;
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index 6e37efc..b434244 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -101,8 +101,7 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
 
-		ret = rte_cryptodev_configure(slave_dev_id, config,
-				dev->data->session_pool);
+		ret = rte_cryptodev_configure(slave_dev_id, config);
 		if (ret < 0)
 			break;
 	}
@@ -400,7 +399,8 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 /** Setup a queue pair */
 static int
 scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
-	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+	struct rte_mempool *session_pool)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	struct scheduler_qp_ctx *qp_ctx;
@@ -422,8 +422,13 @@ scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_id = sched_ctx->slaves[i].dev_id;
 
+		/*
+		 * All slaves will share the same session mempool
+		 * for session-less operations, so the objects
+		 * must be big enough for all the drivers used.
+		 */
 		ret = rte_cryptodev_queue_pair_setup(slave_id, qp_id,
-				qp_conf, socket_id);
+				qp_conf, socket_id, session_pool);
 		if (ret < 0)
 			return ret;
 	}
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index 1967409..04151bc 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -220,7 +220,7 @@ snow3g_pmd_qp_create_processed_ops_ring(struct snow3g_qp *qp,
 static int
 snow3g_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct snow3g_qp *qp = NULL;
 
@@ -245,7 +245,7 @@ snow3g_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index cdc783f..7cf6542 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -220,7 +220,7 @@ zuc_pmd_qp_create_processed_ops_ring(struct zuc_qp *qp,
 static int
 zuc_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct zuc_qp *qp = NULL;
 
@@ -245,7 +245,7 @@ zuc_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 708eadd..11f0966 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1299,15 +1299,15 @@ cryptodevs_init(void)
 			socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
 		}
 
-		if (rte_cryptodev_configure(cdev_id, &dev_conf,
-				socket_ctx[dev_conf.socket_id].session_pool))
+		if (rte_cryptodev_configure(cdev_id, &dev_conf))
 			rte_panic("Failed to initialize cryptodev %u\n",
 					cdev_id);
 
 		qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
 		for (qp = 0; qp < dev_conf.nb_queue_pairs; qp++)
 			if (rte_cryptodev_queue_pair_setup(cdev_id, qp,
-						&qp_conf, dev_conf.socket_id))
+					&qp_conf, dev_conf.socket_id,
+					socket_ctx[dev_conf.socket_id].session_pool))
 				rte_panic("Failed to setup queue %u for "
 						"cdev_id %u\n",	0, cdev_id);
 
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 9ec8e6f..5dcbab9 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1846,8 +1846,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 						cap->sym.auth.digest_size.min;
 		}
 
-		retval = rte_cryptodev_configure(cdev_id, &conf,
-				session_pool_socket[socket_id]);
+		retval = rte_cryptodev_configure(cdev_id, &conf);
 		if (retval < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -1;
@@ -1856,7 +1855,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		qp_conf.nb_descriptors = 2048;
 
 		retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
-				socket_id);
+				socket_id, session_pool_socket[socket_id]);
 		if (retval < 0) {
 			printf("Failed to setup queue pair %u on cryptodev %u",
 					0, cdev_id);
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index b304a7b..74399bb 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -686,8 +686,7 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
 }
 
 int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
-		struct rte_mempool *session_pool)
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 {
 	struct rte_cryptodev *dev;
 	int diag;
@@ -707,8 +706,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
-	dev->data->session_pool = session_pool;
-
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
 			config->socket_id);
@@ -820,7 +817,9 @@ rte_cryptodev_close(uint8_t dev_id)
 
 int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
-		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+		struct rte_mempool *session_pool)
+
 {
 	struct rte_cryptodev *dev;
 
@@ -844,7 +843,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_pair_setup, -ENOTSUP);
 
 	return (*dev->dev_ops->queue_pair_setup)(dev, queue_pair_id, qp_conf,
-			socket_id);
+			socket_id, session_pool);
 }
 
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 2204982..aa68095 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -439,15 +439,13 @@ struct rte_cryptodev_config {
  *
  * @param	dev_id		The identifier of the device to configure.
  * @param	config		The crypto device configuration structure.
- * @param	session_pool	Pointer to device session mempool
  *
  * @return
  *   - 0: Success, device configured.
  *   - <0: Error code returned by the driver configuration function.
  */
 extern int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
-		struct rte_mempool *session_pool);
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
 
 /**
  * Start an device.
@@ -506,6 +504,8 @@ rte_cryptodev_close(uint8_t dev_id);
  *				*SOCKET_ID_ANY* if there is no NUMA constraint
  *				for the DMA memory allocated for the receive
  *				queue pair.
+ * @param	session_pool	Pointer to device session mempool, used
+ *				for session-less operations.
  *
  * @return
  *   - 0: Success, queue pair correctly set up.
@@ -513,7 +513,8 @@ rte_cryptodev_close(uint8_t dev_id);
  */
 extern int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
-		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
+		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+		struct rte_mempool *session_pool);
 
 /**
  * Start a specified queue pair of a device. It is used
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index d7cefd8..4e49e87 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -207,12 +207,13 @@ typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
  * @param	qp_id		Queue Pair Index
  * @param	qp_conf		Queue configuration structure
  * @param	socket_id	Socket Index
+ * @param	session_pool	Pointer to device session mempool
  *
  * @return	Returns 0 on success.
  */
 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
 		uint16_t qp_id,	const struct rte_cryptodev_qp_conf *qp_conf,
-		int socket_id);
+		int socket_id, struct rte_mempool *session_pool);
 
 /**
  * Release memory resources allocated by given queue pair.
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 9d08eb8..bf117b3 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -401,7 +401,7 @@ testsuite_setup(void)
 			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u with %u qps",
 			dev_id, ts_params->conf.nb_queue_pairs);
 
@@ -410,7 +410,8 @@ testsuite_setup(void)
 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			dev_id, qp_id, &ts_params->qp_conf,
-			rte_cryptodev_socket_id(dev_id)),
+			rte_cryptodev_socket_id(dev_id),
+			ts_params->session_mpool),
 			"Failed to setup queue pair %u on cryptodev %u",
 			qp_id, dev_id);
 	}
@@ -455,7 +456,7 @@ ut_setup(void)
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -463,7 +464,8 @@ ut_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0], qp_id,
 			&ts_params->qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed to setup queue pair %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
 	}
@@ -537,23 +539,20 @@ test_device_configure_invalid_dev_id(void)
 	/* Stop the device in case it's started so it can be configured */
 	rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
 
-	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	/* invalid dev_id values */
 	dev_id = num_devs;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	dev_id = 0xff;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure:"
 			"invalid dev_num %u", dev_id);
 
@@ -573,7 +572,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 1;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
 
@@ -582,7 +581,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0],
 			ts_params->conf.nb_queue_pairs);
@@ -592,7 +591,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 0;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -603,7 +602,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -614,7 +613,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -644,7 +643,7 @@ test_queue_pair_descriptor_setup(void)
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -658,7 +657,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for "
 				"rte_cryptodev_queue_pair_setup: num_inflights "
 				"%u on qp %u on cryptodev %u",
@@ -672,7 +672,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for"
 				" rte_cryptodev_queue_pair_setup: num_inflights"
 				" %u on qp %u on cryptodev %u",
@@ -686,7 +687,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for "
 				"rte_cryptodev_queue_pair_setup: num_inflights"
 				" %u on qp %u on cryptodev %u",
@@ -701,7 +703,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -716,7 +719,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -730,7 +734,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for"
 				" rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -745,7 +750,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -761,7 +767,8 @@ test_queue_pair_descriptor_setup(void)
 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0],
 			qp_id, &qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed test for rte_cryptodev_queue_pair_setup:"
 			"invalid qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
@@ -771,7 +778,8 @@ test_queue_pair_descriptor_setup(void)
 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0],
 			qp_id, &qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed test for rte_cryptodev_queue_pair_setup:"
 			"invalid qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 68c5fdd..8a40381 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -413,7 +413,7 @@ testsuite_setup(void)
 			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
-			&ts_params->conf, ts_params->sess_mp),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->dev_id);
 
@@ -423,7 +423,8 @@ testsuite_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			ts_params->dev_id, qp_id,
 				&ts_params->qp_conf,
-				rte_cryptodev_socket_id(ts_params->dev_id)),
+				rte_cryptodev_socket_id(ts_params->dev_id),
+				ts_params->sess_mp),
 				"Failed to setup queue pair %u on cryptodev %u",
 				qp_id, ts_params->dev_id);
 	}
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 11/12] cryptodev: remove session init internal function
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (9 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 10/12] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-02 15:57     ` [PATCH v3 12/12] doc: add new crypto session information Pablo de Lara
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
  12 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Since now the private session data is initialized after
the session pool is created, there is no need to keep
this PMD function.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 --------
 lib/librte_cryptodev/rte_cryptodev_pmd.h    | 16 ----------------
 2 files changed, 24 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index bab2b4e..0382dc0 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -752,13 +752,6 @@ dpaa2_sec_session_get_size(struct rte_cryptodev *dev __rte_unused)
 	return sizeof(dpaa2_sec_session);
 }
 
-static void
-dpaa2_sec_session_initialize(struct rte_mempool *mp __rte_unused,
-			     void *sess __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-}
-
 static int
 dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
 		      struct rte_crypto_sym_xform *xform,
@@ -1505,7 +1498,6 @@ static struct rte_cryptodev_ops crypto_ops = {
 	.queue_pair_stop      = dpaa2_sec_queue_pair_stop,
 	.queue_pair_count     = dpaa2_sec_queue_pair_count,
 	.session_get_size     = dpaa2_sec_session_get_size,
-	.session_initialize   = dpaa2_sec_session_initialize,
 	.session_configure    = dpaa2_sec_session_configure,
 	.session_clear        = dpaa2_sec_session_clear,
 };
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 4e49e87..0e44451 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -267,20 +267,6 @@ typedef unsigned (*cryptodev_sym_get_session_private_size_t)(
 		struct rte_cryptodev *dev);
 
 /**
- * Initialize a Crypto session on a device.
- *
- * @param	dev		Crypto device pointer
- * @param	xform		Single or chain of crypto xforms
- * @param	priv_sess	Pointer to cryptodev's private session structure
- *
- * @return
- *  - Returns private session structure on success.
- *  - Returns NULL on failure.
- */
-typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
-		void *session_private);
-
-/**
  * Configure a Crypto session on a device.
  *
  * @param	dev		Crypto device pointer
@@ -357,8 +343,6 @@ struct rte_cryptodev_ops {
 
 	cryptodev_sym_get_session_private_size_t session_get_size;
 	/**< Return private session. */
-	cryptodev_sym_initialize_session_t session_initialize;
-	/**< Initialization function for private session data */
 	cryptodev_sym_configure_session_t session_configure;
 	/**< Configure a Crypto session. */
 	cryptodev_sym_free_session_t session_clear;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v3 12/12] doc: add new crypto session information
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (10 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 11/12] cryptodev: remove session init internal function Pablo de Lara
@ 2017-07-02 15:57     ` Pablo de Lara
  2017-07-03 11:18       ` Mcnamara, John
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
  12 siblings, 1 reply; 44+ messages in thread
From: Pablo de Lara @ 2017-07-02 15:57 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara, Slawomir Mrozowicz

Modified cryptodev library section in Programmer's Guide,
with the recent changes in the crypto sessions.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/prog_guide/cryptodev_lib.rst          |  59 ++--
 doc/guides/prog_guide/img/cryptodev_sym_sess.svg | 418 ++++++++++++++++++++---
 2 files changed, 400 insertions(+), 77 deletions(-)

diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst
index 4644802..3d3239d 100644
--- a/doc/guides/prog_guide/cryptodev_lib.rst
+++ b/doc/guides/prog_guide/cryptodev_lib.rst
@@ -114,9 +114,8 @@ The rte_cryptodev_configure API is used to configure a Crypto device.
    int rte_cryptodev_configure(uint8_t dev_id,
                                struct rte_cryptodev_config *config)
 
-The ``rte_cryptodev_config`` structure is used to pass the configuration parameters.
-In contains parameter for socket selection, number of queue pairs and the
-session mempool configuration.
+The ``rte_cryptodev_config`` structure is used to pass the configuration
+parameters for socket selection and number of queue pairs.
 
 .. code-block:: c
 
@@ -125,12 +124,6 @@ session mempool configuration.
         /**< Socket to allocate resources on */
         uint16_t nb_queue_pairs;
         /**< Number of queue pairs to configure on device */
-
-        struct {
-            uint32_t nb_objs;
-            uint32_t cache_size;
-        } session_mp;
-        /**< Session mempool configuration */
     };
 
 
@@ -431,7 +424,7 @@ operations, as well as also supporting AEAD operations.
 Session and Session Management
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Session are used in symmetric cryptographic processing to store the immutable
+Sessions are used in symmetric cryptographic processing to store the immutable
 data defined in a cryptographic transform which is used in the operation
 processing of a packet flow. Sessions are used to manage information such as
 expand cipher keys and HMAC IPADs and OPADs, which need to be calculated for a
@@ -442,27 +435,31 @@ Crypto workloads.
 
 .. figure:: img/cryptodev_sym_sess.*
 
-The Crypto device framework provides a set of session pool management APIs for
-the creation and freeing of the sessions, utilizing the Mempool Library.
-
-The framework also provides hooks so the PMDs can pass the amount of memory
-required for that PMDs private session parameters, as well as initialization
-functions for the configuration of the session parameters and freeing function
-so the PMD can managed the memory on destruction of a session.
-
-**Note**: Sessions created on a particular device can only be used on Crypto
-devices of the same type - the same driver id used by this devices,
-and if you try to use a session on a device different
-to that on which it was created then the Crypto operation will fail.
-
-``rte_cryptodev_sym_session_create()`` is used to create a symmetric session on
-Crypto device. A symmetric transform chain is used to specify the particular
-operation and its parameters. See the section below for details on transforms.
-
-.. code-block:: c
-
-   struct rte_cryptodev_sym_session * rte_cryptodev_sym_session_create(
-          uint8_t dev_id, struct rte_crypto_sym_xform *xform);
+The Crypto device framework provides APIs to allocate and initizalize sessions
+for crypto devices, where sessions are mempool objects.
+It is the application's responsibility to create and manage the session mempools.
+This approach allows for different scenarios such as having a single session
+mempool for all crypto devices (where the mempool object size is big
+enough to hold the private session of any crypto device), as well as having
+multiple session mempools of different sizes for better memory usage.
+
+An application can use ``rte_cryptodev_get_private_session_size()`` to
+get the private session size of given crypto device. This function would allow
+an application to calculate the max device session size of all crypto devices
+to create a single session mempool.
+If instead an application creates multiple session mempools, the Crypto device
+framework also provides ``rte_cryptodev_get_header_session_size`` to get
+the size of an uninitialized session.
+
+Once the session mempools have been created, ``rte_cryptodev_sym_session_create()``
+is used to allocate an uninitialized session from the given mempool.
+The session then must be initialized using ``rte_cryptodev_sym_session_init()``
+for each of the required crypto devices. A symmetric transform chain
+is used to specify the operation and its parameters. See the section below for
+details on transforms.
+
+Unused session should be freed using ``rte_cryptodev_sym_session_free`` which
+returns them to their mempool.
 
 **Note**: For AEAD operations the algorithm selected for authentication and
 ciphering must aligned, eg AES_GCM.
diff --git a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
index e5f41ec..a807ceb 100644
--- a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
+++ b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
@@ -1,10 +1,50 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <!-- Generated by Microsoft Visio, SVG Export cryptodev_sym_sess.svg Page-1 -->
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"
-		width="2.17241in" height="2.8102in" viewBox="0 0 156.413 202.335" xml:space="preserve" color-interpolation-filters="sRGB"
-		class="st10">
-	<style type="text/css">
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="4.8933434in"
+   height="3.8972795in"
+   viewBox="0 0 352.31955 280.60496"
+   xml:space="preserve"
+   class="st10"
+   version="1.1"
+   id="svg70"
+   sodipodi:docname="cryptodev_sym_sess.svg"
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-rule:evenodd;stroke-linecap:square;stroke-miterlimit:3"
+   inkscape:version="0.92.1 r15371"><metadata
+   id="metadata74"><rdf:RDF><cc:Work
+       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+   pagecolor="#ffffff"
+   bordercolor="#666666"
+   borderopacity="1"
+   objecttolerance="10"
+   gridtolerance="10"
+   guidetolerance="10"
+   inkscape:pageopacity="0"
+   inkscape:pageshadow="2"
+   inkscape:window-width="1920"
+   inkscape:window-height="1051"
+   id="namedview72"
+   showgrid="false"
+   inkscape:zoom="1.7495789"
+   inkscape:cx="208.74719"
+   inkscape:cy="216.52777"
+   inkscape:window-x="-9"
+   inkscape:window-y="-9"
+   inkscape:window-maximized="0"
+   inkscape:current-layer="g68-0" />
+	<style
+   type="text/css"
+   id="style2">
 	<![CDATA[
 		.st1 {fill:url(#grad0-4);stroke:#386288;stroke-width:0.75}
 		.st2 {fill:#386288;font-family:Calibri;font-size:0.833336em}
@@ -19,48 +59,334 @@
 	]]>
 	</style>
 
-	<defs id="Patterns_And_Gradients">
-		<linearGradient id="grad0-4" x1="0" y1="0" x2="1" y2="0" gradientTransform="rotate(60 0.5 0.5)">
-			<stop offset="0" stop-color="#e8ebef" stop-opacity="1"/>
-			<stop offset="0.24" stop-color="#f4f5f7" stop-opacity="1"/>
-			<stop offset="0.54" stop-color="#feffff" stop-opacity="1"/>
+	<defs
+   id="Patterns_And_Gradients"><marker
+   inkscape:isstock="true"
+   style="overflow:visible"
+   id="marker5421"
+   refX="0"
+   refY="0"
+   orient="auto"
+   inkscape:stockid="Arrow2Lend"><path
+     transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+     d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+     style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+     id="path5419"
+     inkscape:connector-curvature="0" /></marker><marker
+   inkscape:stockid="Arrow2Lend"
+   orient="auto"
+   refY="0"
+   refX="0"
+   id="Arrow2Lend"
+   style="overflow:visible"
+   inkscape:isstock="true"><path
+     id="path5004"
+     style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+     d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+     transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+     inkscape:connector-curvature="0" /></marker><marker
+   inkscape:stockid="Arrow1Lend"
+   orient="auto"
+   refY="0"
+   refX="0"
+   id="Arrow1Lend"
+   style="overflow:visible"
+   inkscape:isstock="true"><path
+     id="path4986"
+     d="M 0,0 5,-5 -12.5,0 5,5 Z"
+     style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
+     transform="matrix(-0.8,0,0,-0.8,-10,0)"
+     inkscape:connector-curvature="0" /></marker>
+		<linearGradient
+   id="grad0-4"
+   x1="0"
+   y1="0"
+   x2="1"
+   y2="0"
+   gradientTransform="rotate(60,0.5,0.5)">
+			<stop
+   offset="0"
+   stop-color="#e8ebef"
+   stop-opacity="1"
+   id="stop4" />
+			<stop
+   offset="0.24"
+   stop-color="#f4f5f7"
+   stop-opacity="1"
+   id="stop6" />
+			<stop
+   offset="0.54"
+   stop-color="#feffff"
+   stop-opacity="1"
+   id="stop8" />
 		</linearGradient>
-	</defs>
-	<defs id="Filters">
-		<filter id="filter_2">
-			<feGaussianBlur stdDeviation="2"/>
+	<filter
+   id="filter_2-4"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-0" /></filter><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient189"
+   gradientTransform="scale(0.8787489,1.1379815)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /><filter
+   id="filter_2-5"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-8" /></filter><filter
+   id="filter_2-3"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-2" /></filter><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient189-7"
+   gradientTransform="scale(0.8787489,1.1379815)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient500"
+   gradientTransform="matrix(0.8787489,0,0,1.1379815,12.431599,21.739241)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /></defs>
+	<defs
+   id="Filters">
+		<filter
+   id="filter_2">
+			<feGaussianBlur
+   stdDeviation="2"
+   id="feGaussianBlur12" />
 		</filter>
 	</defs>
-	<g>
-		<title>Page-1</title>
-		<g id="shape18-1" transform="translate(0.749889,-0.75)">
-			<title>Rounded Rectangle.12</title>
-			<desc>Crypto Symmetric Session</desc>
-			<path d="M6.78 202.33 L148.14 202.33 A6.77735 6.77735 -180 0 0 154.91 195.56 L154.91 8.28 A6.77735 6.77735 -180 0 0 148.14
-						 1.5 L6.78 1.5 A6.77735 6.77735 -180 0 0 -0 8.28 L0 195.56 A6.77735 6.77735 -180 0 0 6.78 202.33 Z"
-					class="st1"/>
-			<text x="24.76" y="14.5" class="st2">Crypto Symmetric Session</text>		</g>
-		<g id="shape19-6" transform="translate(10.6711,-9.82087)">
-			<title>Rounded Rectangle.13</title>
-			<desc>Private Session Data</desc>
-			<g id="shadow19-7" transform="matrix(1,0,0,1,0.345598,1.97279)" class="st3">
-				<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 103.65 A5.90925 5.90925 -180
-							 0 0 129.16 97.74 L5.91 97.74 A5.90925 5.90925 -180 0 0 -0 103.65 L0 196.43 A5.90925 5.90925 -180 0 0
-							 5.91 202.33 Z" class="st4"/>
-			</g>
-			<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 103.65 A5.90925 5.90925 -180 0 0
-						 129.16 97.74 L5.91 97.74 A5.90925 5.90925 -180 0 0 -0 103.65 L0 196.43 A5.90925 5.90925 -180 0 0 5.91 202.33
-						 Z" class="st5"/>
-			<text x="26.34" y="153.04" class="st6">Private Session Data</text>		</g>
-		<g id="shape20-12" transform="translate(10.6711,-122.923)">
-			<title>Rounded Rectangle.15</title>
-			<desc>General Session Data (struct rte_cryptodev_sym_session)</desc>
-			<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 160.06 A5.90925 5.90925 -180 0 0
-						 129.16 154.15 L5.91 154.15 A5.90925 5.90925 -180 0 0 -0 160.06 L0 196.43 A5.90925 5.90925 -180 0 0 5.91
-						 202.33 Z" class="st7"/>
-			<text x="24.58" y="175.24" class="st6">General Session Data <tspan x="9.16" dy="1.5em" class="st8">(</tspan><tspan
-						class="st9">struct </tspan><tspan class="st8">rte</tspan><tspan class="st8">_</tspan><tspan class="st8">cryptodev</tspan><tspan
-						class="st8">_</tspan><tspan class="st8">sym</tspan><tspan class="st8">_</tspan><tspan class="st8">session</tspan><tspan
-						class="st8">)</tspan></text>		</g>
+	<g
+   id="g68"
+   transform="matrix(1,0,0,0.41409874,-12.807629,-5.4621159)">
+		<title
+   id="title16">Page-1</title>
+		<g
+   id="shape18-1"
+   transform="translate(0.749889,-0.75)">
+			<title
+   id="title18">Rounded Rectangle.12</title>
+			<desc
+   id="desc20">Crypto Symmetric Session</desc>
+			<path
+   d="M 19.211599,224.06924 H 160.5716 a 6.77735,6.77735 0 0 0 6.77,-6.77 V 30.019241 a 6.77735,6.77735 0 0 0 -6.77,-6.78 H 19.211599 a 6.77735,6.77735 0 0 0 -6.78,6.78 V 217.29924 a 6.77735,6.77735 0 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22"
+   style="fill:url(#linearGradient500);stroke:#386288;stroke-width:0.75"
+   inkscape:connector-curvature="0" />
+			<text
+   x="63.123039"
+   y="28.531481"
+   class="st2"
+   id="text24"
+   style="font-size:16.97244835px;font-family:Calibri;fill:#386288;stroke-width:1.69723928"
+   transform="scale(0.58919214,1.6972392)">Crypto Symmetric Session</text>
+
+		</g>
+		<g
+   id="shape19-6"
+   transform="translate(10.6711,-9.82087)">
+			<title
+   id="title27">Rounded Rectangle.13</title>
+			<desc
+   id="desc29">Private Session Data</desc>
+		</g>
+		<g
+   id="shape20-12"
+   transform="matrix(1,0,0,2.5278193,23.531375,-309.78186)">
+			<title
+   id="title39">Rounded Rectangle.15</title>
+			<desc
+   id="desc41">void *sess_private_data[]</desc>
+			<path
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -36.37 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,160.06 v 36.37 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st7"
+   id="path43"
+   inkscape:connector-curvature="0"
+   style="fill:#ffffff;stroke:#41719c;stroke-width:0.75" />
+			<text
+   x="14.072042"
+   y="159.1931"
+   class="st6"
+   id="text65"
+   style="font-size:11.41061592px;font-family:Calibri;fill:#41719c;stroke-width:1.14105785"
+   transform="scale(0.92359087,1.0827305)">void *sess_private_data[] <tspan
+   x="-3.5230706"
+   class="st9"
+   id="tspan47"
+   style="font-weight:bold;font-size:9.12843513px;stroke-width:1.14105785" /></text>
+
+		<rect
+   style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.73305672;stroke-opacity:1"
+   id="rect4604"
+   width="15.968175"
+   height="14.230948"
+   x="13.494645"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7"
+   width="15.968174"
+   height="14.230948"
+   x="29.46282"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6"
+   width="15.968174"
+   height="14.230948"
+   x="45.430992"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9"
+   width="15.968174"
+   height="14.230948"
+   x="61.399166"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8"
+   width="15.968174"
+   height="14.230948"
+   x="77.36734"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8-9"
+   width="15.968174"
+   height="14.230948"
+   x="93.33551"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8-9-6"
+   width="15.968174"
+   height="14.230948"
+   x="109.30369"
+   y="181.68814" /><path
+   style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.72427988px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+   d="m 117.64885,196.01764 0.22164,18.77485 44.6966,-0.0725 -0.22163,-20.00716 16.84434,0.43494"
+   id="path5030"
+   inkscape:connector-curvature="0" /></g>
 	</g>
-</svg>
+<g
+   transform="translate(190.70887,-0.53319281)"
+   id="g68-0"><title
+     id="title16-2">Page-1</title><g
+     id="shape18-1-4"
+     transform="matrix(1,0,0,0.57815109,0.749889,-0.11722686)"><title
+   id="title18-4">Rounded Rectangle.12</title><desc
+   id="desc20-6">Crypto Symmetric Session</desc><path
+   inkscape:connector-curvature="0"
+   d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22-0"
+   style="fill:url(#linearGradient189);stroke:#386288;stroke-width:0.75" /><text
+   x="26.317923"
+   y="17.335487"
+   class="st2"
+   id="text24-5"
+   style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+   transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
+
+</g><g
+     id="shape19-6-5"
+     transform="matrix(1.022976,0,0,0.71529071,9.1114734,-39.403506)"><title
+   id="title27-2">Rounded Rectangle.13</title><desc
+   id="desc29-0">Private Session Data</desc><g
+   id="shadow19-7-1"
+   transform="translate(0.345598,1.97279)"
+   class="st3"
+   style="visibility:visible"><path
+     inkscape:connector-curvature="0"
+     d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+     class="st4"
+     id="path31-8"
+     style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2)" /></g><path
+   inkscape:connector-curvature="0"
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st5"
+   id="path34-8"
+   style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
+   x="34.639763"
+   y="119.96548"
+   class="st6"
+   id="text36-7"
+   style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+   transform="scale(0.76039781,1.3151011)">Private Session Data</text>
+
+</g><g
+     id="shape18-1-4-7"
+     transform="matrix(1,0,0,0.57815109,0.90591369,163.94402)"><title
+   id="title18-4-3">Rounded Rectangle.12</title><desc
+   id="desc20-6-5">Crypto Symmetric Session</desc><path
+   inkscape:connector-curvature="0"
+   d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22-0-8"
+   style="fill:url(#linearGradient189-7);stroke:#386288;stroke-width:0.75" /><text
+   x="26.317923"
+   y="17.335487"
+   class="st2"
+   id="text24-5-1"
+   style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+   transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
+
+</g><g
+     id="shape19-6-5-1"
+     transform="matrix(1.022976,0,0,0.71529071,9.2675037,124.65774)"><title
+   id="title27-2-4">Rounded Rectangle.13</title><desc
+   id="desc29-0-9">Private Session Data</desc><g
+   id="shadow19-7-1-8"
+   transform="translate(0.345598,1.97279)"
+   class="st3"
+   style="visibility:visible"><path
+     inkscape:connector-curvature="0"
+     d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+     class="st4"
+     id="path31-8-4"
+     style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2-3)" /></g><path
+   inkscape:connector-curvature="0"
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st5"
+   id="path34-8-3"
+   style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
+   x="34.639763"
+   y="119.96548"
+   class="st6"
+   id="text36-7-6"
+   style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+   transform="scale(0.76039781,1.3151011)">Private Session Data</text>
+
+</g><text
+     xml:space="preserve"
+     style="font-style:normal;font-weight:normal;font-size:30.00008774px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
+     x="57.540585"
+     y="145.94679"
+     id="text5070"><tspan
+       sodipodi:role="line"
+       id="tspan5068"
+       x="57.540585"
+       y="173.31679"
+       style="stroke-width:0.75000221"></tspan></text>
+<text
+     xml:space="preserve"
+     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
+     x="60.571766"
+     y="143.21872"
+     id="text5074"><tspan
+       sodipodi:role="line"
+       id="tspan5072"
+       x="60.571766"
+       y="143.21872"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.75000221">...</tspan></text>
+<path
+     style="fill:none;stroke:#41719c;stroke-width:0.74499911px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker5421)"
+     d="M -158.57624,71.371238 -157.38,232.04055 -1.1215065,232.19212"
+     id="path5076"
+     inkscape:connector-curvature="0" /></g></svg>
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 11/11] doc: add new crypto session information
  2017-06-30 17:09   ` [PATCH v2 11/11] doc: add new crypto session information Pablo de Lara
@ 2017-07-02 20:15     ` Mcnamara, John
  0 siblings, 0 replies; 44+ messages in thread
From: Mcnamara, John @ 2017-07-02 20:15 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, Doherty, Declan, zbigniew.bodek,
	jerin.jacob, akhil.goyal, hemant.agrawal, Trahe, Fiona, Griffin,
	John, Jain, Deepak K
  Cc: dev, De Lara Guarch, Pablo, Mrozowicz, SlawomirX



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Friday, June 30, 2017 6:10 PM
> To: Doherty, Declan <declan.doherty@intel.com>;
> zbigniew.bodek@caviumnetworks.com; jerin.jacob@caviumnetworks.com;
> akhil.goyal@nxp.com; hemant.agrawal@nxp.com; Trahe, Fiona
> <fiona.trahe@intel.com>; Griffin, John <john.griffin@intel.com>; Jain,
> Deepak K <deepak.k.jain@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> Mrozowicz, SlawomirX <slawomirx.mrozowicz@intel.com>
> Subject: [dpdk-dev] [PATCH v2 11/11] doc: add new crypto session
> information
> 
> Modified cryptodev library section in Programmer's Guide, with the recent
> changes in the rypto sessions.


s/rypto/crypto/




> 
> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

> ...

> +The Crypto device framework provides APIs to allocate and initizalize
> +sessions for crypto devices, where sessions are mempool objects.
> +It is the application responsability to create and manage the session
> mempools.

s/application/application's/
s/responsability/responsibility/

> +This approach allows for different scenarios such as having a single
> +session mempool for all crypto devices (where the the mempool object

s/the the/the/

> +size is big enough to hold the private session of any crypto device),
> +as well as having multiple session mempools of different sizes for better
> memory usage.
> +


> +An application could use ``rte_cryptodev_get_private_session_size()``
> +to get the private session size of given crypto device. This function

s/could/can/ is probably better.
s/given/a given/

> +would allow an application to calculate the max device session size of
> +all crypto devices to create a single session mempool.
> +If instead an application creates multiple session mempools, the Crypto
> +device framework also provides
> +``rte_cryptodev_get_header_session_size`` to get the size of an
> uninitialized session.
> +
> +Once the session mempools have been created,
> +``rte_cryptodev_sym_session_create()``
> +is used to allocate an uninitialized session from the given mempool.
> +The session then must be initialized ``rte_cryptodev_sym_session_init()``
> +for each of the crypto devices to be used with. A symmetric transform

Probably better as: 

    The session then must be initialized using ``rte_cryptodev_sym_session_init()``
    for each of the required crypto devices. A symmetric transform

> +chain is used to specify the operation and its parameters. See the
> +section below for details on transforms.
> +
> +Unused session should be free using ``rte_cryptodev_sym_session_free``
> +which returns them to their mempool.

s/free/freed/


Apart from these small changes which could be made inline:

Acked-by: John McNamara <john.mcnamara@intel.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v3 12/12] doc: add new crypto session information
  2017-07-02 15:57     ` [PATCH v3 12/12] doc: add new crypto session information Pablo de Lara
@ 2017-07-03 11:18       ` Mcnamara, John
  0 siblings, 0 replies; 44+ messages in thread
From: Mcnamara, John @ 2017-07-03 11:18 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, Doherty, Declan, zbigniew.bodek,
	jerin.jacob, akhil.goyal, hemant.agrawal, Trahe, Fiona, Griffin,
	John, Jain, Deepak K
  Cc: dev, De Lara Guarch, Pablo, Mrozowicz, SlawomirX



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Sunday, July 2, 2017 4:57 PM
> To: Doherty, Declan <declan.doherty@intel.com>;
> zbigniew.bodek@caviumnetworks.com; jerin.jacob@caviumnetworks.com;
> akhil.goyal@nxp.com; hemant.agrawal@nxp.com; Trahe, Fiona
> <fiona.trahe@intel.com>; Griffin, John <john.griffin@intel.com>; Jain,
> Deepak K <deepak.k.jain@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> Mrozowicz, SlawomirX <slawomirx.mrozowicz@intel.com>
> Subject: [dpdk-dev] [PATCH v3 12/12] doc: add new crypto session
> information
> 
> Modified cryptodev library section in Programmer's Guide, with the recent
> changes in the crypto sessions.
> 
> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Acked-by: John McNamara <john.mcnamara@intel.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v4 00/12] Device independent crypto sessions
  2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
                       ` (11 preceding siblings ...)
  2017-07-02 15:57     ` [PATCH v3 12/12] doc: add new crypto session information Pablo de Lara
@ 2017-07-05  5:26     ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
                         ` (14 more replies)
  12 siblings, 15 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Currently, the cryptodev library requires the session mempools to be created inside each device.
This can be a waste of memory, as several devices with the same driver could be using the same session.

This patchset makes changes in the library to allow session to contain multiple driver private data, so it can be used by multiple devices (no need to be the same driver).

                                  SESSION MEMPOOL <---|---> DEVICE INSTANCES
                                 --------------------------------------------

.-------------.      .----------------------------.
|   Crypto    |.     |         mempool obj        |
| sym-session |<--.  | .--------------------------+
|   mempool   ||  |  | | rte_cryptodev_session    |             .-------------.
`-------------'|  |  | |                          |             |   DEVICE    |
 `-----|-------'  |  | |                          |             |  INSTANCE   |
       |          `-----                          |             | - device id |
       +------------>| | - private data[type idx] |          .--| - session   |
       |             `-+=================|..|====='          |  |   mempool   |
       |                                 |  |                |  `-------------'
       |                                 |  |                |
       |     .----------------------.    |  |                |  .-------------.
       +---->|      mempool obj     |    |  |   .--------.   |  |   DEVICE    |
       |     | .--------------------+    |  |   | DRIVER |   |  |  INSTANCE   |
       |     | | PMD's private data |<---+------| - type |<--+--|             |
       |     +-+====================+       |   `--------'      |     ...     |
       |                                    |                   |             |
       |                                    |                   `-------------'
       |                                    |
       |     .----------------------.       |                   .-------------.
       `---->|      mempool obj     |       |   .--------.      |   DEVICE    |
             | .--------------------+       |   | DRIVER |      |  INSTANCE   |
             | | PMD's private data |<------+---| - type |<-----|             |
             `-+===================='           `--------'      |     ...     |
                                                                |             |
                                                                `-------------'
Crypto sym-session mempool

   Mempool created to store rte_cryptodev_session objects as well as
   private data for supported device types.

   This mempool replaces existing session mempools in device
   instances to ease session management and improve consistency
   (especially if the session is intended to be used for operations
   performed on different devices).

rte_crypto_session

   New rte_cryptodev_session structure is taken from crypto session
   mempool and can store more than one PMD's private data object (one
   for each device type supported by sesion).

   Crypto operations will use device type id (unique for each driver) to
   retrieve private data from rte_crypto_session right for the device
   type they are performed on.

This patchset was based on the changes proposed in RFC
(http://dpdk.org/ml/archives/dev/2017-May/065259.html)

This patchset depends on:
http://dpdk.org/dev/patchwork/patch/26156/

Changes in v4:

- Introduced new rte_cryptodev_sym_session_clear() function,
  which frees device private session data.
  This needs to be called before calling rte_cryptodev_sym_session_free().

- Rebased on top of dpdk-next-crypto

Changes in v3:

- Removed internal PMD's session initialize function

- Created session mempool in the right socket in
  the sample apps

- Get two objects (header and private data) from mempool
  when using sessionless operations, to get a complete
  session

- Fixed commit message (check-git-log failed)

- Added note of removed session_mp from rte_cryptodev_config
  in documentation

- Fixed minor issues in documentation


Changes in v2:

- Split the patch in multiple smaller patches to
  facilitate the review

- Removed new API to create the session mempool,
  since mempool can be created directly withe mempool_create

- Session headers and device private sessions can be
  allocated from different mempools, for better memory
  efficiency.

- Added a cover letter (partially extracted from RFC)
  for better clarification on the intention of this patchset

Pablo de Lara (5):
  cryptodev: remove unused cryptodev session structure
  cryptodev: move session init out of session pool creation
  cryptodev: add mempool pointer in queue pair setup
  cryptodev: remove session init internal function
  doc: add new crypto session information

Slawomir Mrozowicz (7):
  cryptodev: add private session size retrieval function
  cryptodev: do not create session mempool internally
  cryptodev: change attach session to queue pair API
  cryptodev: remove device id from crypto session
  cryptodev: remove driver id from session
  cryptodev: remove mempool from session
  cryptodev: support device independent sessions

 app/test-crypto-perf/cperf.h                       |   5 +-
 app/test-crypto-perf/cperf_ops.c                   |  21 +-
 app/test-crypto-perf/cperf_ops.h                   |   1 +
 app/test-crypto-perf/cperf_test_latency.c          |  12 +-
 app/test-crypto-perf/cperf_test_latency.h          |   5 +-
 app/test-crypto-perf/cperf_test_throughput.c       |  12 +-
 app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
 app/test-crypto-perf/cperf_test_verify.c           |  12 +-
 app/test-crypto-perf/cperf_test_verify.h           |   5 +-
 app/test-crypto-perf/main.c                        |  85 ++++-
 doc/guides/prog_guide/cryptodev_lib.rst            |  61 ++-
 doc/guides/prog_guide/img/cryptodev_sym_sess.svg   | 418 ++++++++++++++++++---
 doc/guides/rel_notes/release_17_08.rst             |  19 +
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  51 ++-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  49 ++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  43 ++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  50 ++-
 drivers/crypto/armv8/rte_armv8_pmd.c               |  39 +-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  49 ++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  66 +++-
 drivers/crypto/kasumi/rte_kasumi_pmd.c             |  42 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  51 ++-
 drivers/crypto/null/null_crypto_pmd.c              |  43 ++-
 drivers/crypto/null/null_crypto_pmd_ops.c          |  51 ++-
 drivers/crypto/openssl/rte_openssl_pmd.c           |  41 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  52 ++-
 drivers/crypto/qat/qat_crypto.c                    |  93 +++--
 drivers/crypto/qat/qat_crypto.h                    |  19 +-
 drivers/crypto/qat/qat_qp.c                        |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
 drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
 .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 -
 drivers/crypto/scheduler/scheduler_pmd_ops.c       |  78 ++--
 drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
 drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 --
 drivers/crypto/snow3g/rte_snow3g_pmd.c             |  43 ++-
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  51 ++-
 drivers/crypto/zuc/rte_zuc_pmd.c                   |  39 +-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  51 ++-
 examples/ipsec-secgw/ipsec-secgw.c                 |  41 +-
 examples/ipsec-secgw/ipsec.c                       |   8 +-
 examples/ipsec-secgw/ipsec.h                       |   3 +-
 examples/l2fwd-crypto/main.c                       |  77 +++-
 lib/librte_cryptodev/rte_cryptodev.c               | 252 ++++++-------
 lib/librte_cryptodev/rte_cryptodev.h               | 122 +++---
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |  60 ++-
 lib/librte_cryptodev/rte_cryptodev_version.map     |   4 +
 test/test/test_cryptodev.c                         | 388 ++++++++++++++-----
 test/test/test_cryptodev_blockcipher.c             |  18 +-
 test/test/test_cryptodev_blockcipher.h             |   1 +
 test/test/test_cryptodev_perf.c                    | 216 ++++++++---
 51 files changed, 2008 insertions(+), 955 deletions(-)

-- 
2.9.4

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v4 01/12] cryptodev: remove unused cryptodev session structure
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 02/12] cryptodev: move session init out of session pool creation Pablo de Lara
                         ` (13 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Cryptodev session structure was a duplication of the
cryptodev symmetric structure.
It was used by some PMDs that should use the symmetric
structure instead.

Since this structure was internal, there is no deprecation
notice required.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/kasumi/rte_kasumi_pmd.c   |  2 +-
 drivers/crypto/null/null_crypto_pmd.c    |  2 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c   |  2 +-
 drivers/crypto/zuc/rte_zuc_pmd.c         |  2 +-
 examples/ipsec-secgw/ipsec.h             |  1 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 11 -----------
 6 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 6c8da17..37ca2cc 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -172,7 +172,7 @@ kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct kasumi_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 84280ae..da62592 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -105,7 +105,7 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct null_crypto_session *)sym_op->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 18b6f86..0c65b2d 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -172,7 +172,7 @@ snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct snow3g_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 7d2e37c..82710d3 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -171,7 +171,7 @@ zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 
 		sess = (struct zuc_session *)op->sym->session->_private;
 	} else  {
-		struct rte_cryptodev_session *c_sess = NULL;
+		struct rte_cryptodev_sym_session *c_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
 			return NULL;
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index 0ef68ed..ccd0aa8 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -75,7 +75,6 @@
 
 struct rte_crypto_xform;
 struct ipsec_xform;
-struct rte_cryptodev_session;
 struct rte_mbuf;
 
 struct ipsec_sa;
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index f6aa84d..5911b83 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -56,17 +56,6 @@ extern "C" {
 #include "rte_crypto.h"
 #include "rte_cryptodev.h"
 
-struct rte_cryptodev_session {
-	RTE_STD_C11
-	struct {
-		uint8_t dev_id;
-		uint8_t driver_id;
-		struct rte_mempool *mp;
-	} __rte_aligned(8);
-
-	__extension__ char _private[0];
-};
-
 /** Global structure used for maintaining state of allocated crypto devices */
 struct rte_cryptodev_global {
 	struct rte_cryptodev *devs;	/**< Device information array */
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 02/12] cryptodev: move session init out of session pool creation
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 03/12] cryptodev: add private session size retrieval function Pablo de Lara
                         ` (12 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Prior to removing the session pool creation from cryptodev
configure function, session init function needs to be
separated from the pool creation.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 107632b..cf444c0 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1091,13 +1091,9 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 
 static void
 rte_cryptodev_sym_session_init(struct rte_mempool *mp,
-		void *opaque_arg,
-		void *_sess,
-		__rte_unused unsigned i)
+		const struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	struct rte_cryptodev_sym_session *sess = _sess;
-	struct rte_cryptodev *dev = opaque_arg;
-
 	memset(sess, 0, mp->elt_size);
 
 	sess->dev_id = dev->data->dev_id;
@@ -1154,8 +1150,7 @@ rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
 				0, /* private data size */
 				NULL, /* obj initialization constructor */
 				NULL, /* obj initialization constructor arg */
-				rte_cryptodev_sym_session_init,
-				/**< obj constructor*/
+				NULL, /**< obj constructor*/
 				dev, /* obj constructor arg */
 				socket_id, /* socket id */
 				0); /* flags */
@@ -1193,6 +1188,8 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 
 	sess = _sess;
 
+	rte_cryptodev_sym_session_init(dev->data->session_pool, dev,
+					sess);
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL);
 	if (dev->dev_ops->session_configure(dev, xform, sess->_private) ==
 			NULL) {
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 03/12] cryptodev: add private session size retrieval function
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 02/12] cryptodev: move session init out of session pool creation Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 04/12] cryptodev: do not create session mempool internally Pablo de Lara
                         ` (11 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Provide a function to get the private session size
of any crypto device (specifically, to its crypto driver).

This will be useful once the session mempool is created
outside the library.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c           | 20 ++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 12 ++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 +
 3 files changed, 33 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index cf444c0..5e9f823 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1278,6 +1278,26 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 	return NULL;
 }
 
+unsigned int
+rte_cryptodev_get_private_session_size(uint8_t dev_id)
+{
+	struct rte_cryptodev *dev;
+	unsigned int priv_sess_size;
+
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+		return 0;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+	if (*dev->dev_ops->session_get_size == NULL)
+		return 0;
+
+	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
+
+	return priv_sess_size;
+
+}
+
 /** Initialise rte_crypto_op mempool element */
 static void
 rte_crypto_op_init(struct rte_mempool *mempool,
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 972a308..f7d248b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -942,6 +942,18 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
+ * Get the size of the private session data for a device.
+ *
+ * @param	dev_id		The device identifier.
+ *
+ * @return
+ *   - Size of the private data, if successful
+ *   - 0 if device is invalid or does not have private session
+ */
+unsigned int
+rte_cryptodev_get_private_session_size(uint8_t dev_id);
+
+/**
  * Attach queue pair with sym session.
  *
  * @param	qp_id		Queue pair to which session will be attached.
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 3ad7581..d817421 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -66,6 +66,7 @@ DPDK_17.08 {
 	rte_cryptodev_driver_id_get;
 	rte_cryptodev_driver_name_get;
 	rte_cryptodev_get_aead_algo_enum;
+	rte_cryptodev_get_private_session_size;
 	rte_cryptodev_pci_generic_probe;
 	rte_cryptodev_pci_generic_remove;
 	rte_cryptodev_sym_capability_check_aead;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 04/12] cryptodev: do not create session mempool internally
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (2 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 03/12] cryptodev: add private session size retrieval function Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 05/12] cryptodev: change attach session to queue pair API Pablo de Lara
                         ` (10 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Instead of creating the session mempool while configuring
the crypto device, apps will create the mempool themselves.
This way, it gives flexibility to the user to have a single
mempool for all devices (as long as the objects are big
enough to contain the biggest private session size) or
separate mempools for different drivers.

Also, since the mempool is now created outside the
device configuration function, now it needs to be passed
through this function, which will be eventually passed
when setting up the queue pairs, as ethernet devices do.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/main.c                  | 91 +++++++++++++++++++++-------
 doc/guides/rel_notes/release_17_08.rst       |  3 +
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 12 +---
 examples/ipsec-secgw/ipsec-secgw.c           | 42 +++++++++++--
 examples/ipsec-secgw/ipsec.h                 |  2 +
 examples/l2fwd-crypto/main.c                 | 67 +++++++++++++++-----
 lib/librte_cryptodev/rte_cryptodev.c         | 77 ++---------------------
 lib/librte_cryptodev/rte_cryptodev.h         |  9 +--
 test/test/test_cryptodev.c                   | 85 ++++++++++++++++++++------
 test/test/test_cryptodev_perf.c              | 24 +++++++-
 10 files changed, 261 insertions(+), 151 deletions(-)

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 4dea6d7..45524ad 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -43,6 +43,9 @@
 #include "cperf_test_latency.h"
 #include "cperf_test_verify.h"
 
+#define NUM_SESSIONS 2048
+#define SESS_MEMPOOL_CACHE_SIZE 64
+
 const char *cperf_test_type_strs[] = {
 	[CPERF_TEST_TYPE_THROUGHPUT] = "throughput",
 	[CPERF_TEST_TYPE_LATENCY] = "latency",
@@ -76,9 +79,11 @@ const struct cperf_test cperf_testmap[] = {
 };
 
 static int
-cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
+cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
+			struct rte_mempool *session_pool_socket[])
 {
-	uint8_t cdev_id, enabled_cdev_count = 0, nb_lcores;
+	uint8_t enabled_cdev_count = 0, nb_lcores;
+	unsigned int i;
 	int ret;
 
 	enabled_cdev_count = rte_cryptodev_devices_get(opts->device_type,
@@ -98,40 +103,78 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		return -EINVAL;
 	}
 
-	for (cdev_id = 0; cdev_id < enabled_cdev_count &&
-			cdev_id < RTE_CRYPTO_MAX_DEVS; cdev_id++) {
+	/* Create a mempool shared by all the devices */
+	uint32_t max_sess_size = 0, sess_size;
+
+	for (i = 0; i < enabled_cdev_count &&
+			i < RTE_CRYPTO_MAX_DEVS; i++) {
+		uint8_t cdev_id = enabled_cdevs[i];
+		sess_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_size > max_sess_size)
+			max_sess_size = sess_size;
+	}
+
+
+	for (i = 0; i < enabled_cdev_count &&
+			i < RTE_CRYPTO_MAX_DEVS; i++) {
+		uint8_t cdev_id = enabled_cdevs[i];
+		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
 
 		struct rte_cryptodev_config conf = {
 				.nb_queue_pairs = 1,
-				.socket_id = SOCKET_ID_ANY,
-				.session_mp = {
-					.nb_objs = 2048,
-					.cache_size = 64
-				}
-			};
+				.socket_id = socket_id
+		};
+
 		struct rte_cryptodev_qp_conf qp_conf = {
 				.nb_descriptors = 2048
 		};
 
-		ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf);
+
+		if (session_pool_socket[socket_id] == NULL) {
+			char mp_name[RTE_MEMPOOL_NAMESIZE];
+			struct rte_mempool *sess_mp;
+
+			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+				"sess_mp_%u", socket_id);
+
+			sess_mp = rte_mempool_create(mp_name,
+						NUM_SESSIONS,
+						max_sess_size,
+						SESS_MEMPOOL_CACHE_SIZE,
+						0, NULL, NULL, NULL,
+						NULL, socket_id,
+						0);
+
+			if (sess_mp == NULL) {
+				printf("Cannot create session pool on socket %d\n",
+					socket_id);
+				return -ENOMEM;
+			}
+
+			printf("Allocated session pool on socket %d\n", socket_id);
+			session_pool_socket[socket_id] = sess_mp;
+		}
+
+		ret = rte_cryptodev_configure(cdev_id, &conf,
+				session_pool_socket[socket_id]);
 		if (ret < 0) {
-			printf("Failed to configure cryptodev %u",
-					enabled_cdevs[cdev_id]);
+			printf("Failed to configure cryptodev %u", cdev_id);
 			return -EINVAL;
 		}
 
-		ret = rte_cryptodev_queue_pair_setup(enabled_cdevs[cdev_id], 0,
-				&qp_conf, SOCKET_ID_ANY);
-			if (ret < 0) {
-				printf("Failed to setup queue pair %u on "
-					"cryptodev %u",	0, cdev_id);
-				return -EINVAL;
-			}
+		ret = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
+				socket_id);
+		if (ret < 0) {
+			printf("Failed to setup queue pair %u on "
+				"cryptodev %u",	0, cdev_id);
+			return -EINVAL;
+		}
 
-		ret = rte_cryptodev_start(enabled_cdevs[cdev_id]);
+		ret = rte_cryptodev_start(cdev_id);
 		if (ret < 0) {
 			printf("Failed to start device %u: error %d\n",
-					enabled_cdevs[cdev_id], ret);
+					cdev_id, ret);
 			return -EPERM;
 		}
 	}
@@ -339,6 +382,7 @@ main(int argc, char **argv)
 	struct cperf_op_fns op_fns;
 
 	void *ctx[RTE_MAX_LCORE] = { };
+	struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 };
 
 	int nb_cryptodevs = 0;
 	uint8_t cdev_id, i;
@@ -374,7 +418,8 @@ main(int argc, char **argv)
 	if (!opts.silent)
 		cperf_options_dump(&opts);
 
-	nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs);
+	nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs,
+			session_pool_socket);
 	if (nb_cryptodevs < 1) {
 		RTE_LOG(ERR, USER1, "Failed to initialise requested crypto "
 				"device type\n");
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index f7aca8e..06c5e4e 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -202,6 +202,9 @@ API Changes
     replacing the previous device type enumeration.
   * Moved crypto device driver names definitions to the particular PMDs.
     These names are not public anymore.
+  * ``rte_cryptodev_configure()`` does not create the session mempool
+    for the device anymore.
+  * Removed ``session_mp`` from ``rte_cryptodev_config``.
 
 
 ABI Changes
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index 90e3734..b9d8973 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -85,10 +85,8 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
 /** Configure device */
 static int
 scheduler_pmd_config(struct rte_cryptodev *dev,
-		struct rte_cryptodev_config *config)
+		struct rte_cryptodev_config *config __rte_unused)
 {
-	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
-	uint32_t i;
 	int ret;
 
 	/* although scheduler_attach_init_slave presents multiple times,
@@ -98,14 +96,6 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	if (ret < 0)
 		return ret;
 
-	for (i = 0; i < sched_ctx->nb_slaves; i++) {
-		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
-
-		ret = rte_cryptodev_configure(slave_dev_id, config);
-		if (ret < 0)
-			break;
-	}
-
 	return ret;
 }
 
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 8cbf6ac..4d6c7ce 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -710,10 +710,12 @@ main_loop(__attribute__((unused)) void *dummy)
 	qconf->inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in;
 	qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
 	qconf->inbound.cdev_map = cdev_map_in;
+	qconf->inbound.session_pool = socket_ctx[socket_id].session_pool;
 	qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
 	qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
 	qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
 	qconf->outbound.cdev_map = cdev_map_out;
+	qconf->outbound.session_pool = socket_ctx[socket_id].session_pool;
 
 	if (qconf->nb_rx_queue == 0) {
 		RTE_LOG(INFO, IPSEC, "lcore %u has nothing to do\n", lcore_id);
@@ -1238,6 +1240,14 @@ cryptodevs_init(void)
 
 	printf("lcore/cryptodev/qp mappings:\n");
 
+	uint32_t max_sess_sz = 0, sess_sz;
+	for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
+		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_sz > max_sess_sz)
+			max_sess_sz = sess_sz;
+	}
+
 	idx = 0;
 	/* Start from last cdev id to give HW priority */
 	for (cdev_id = rte_cryptodev_count() - 1; cdev_id >= 0; cdev_id--) {
@@ -1266,11 +1276,33 @@ cryptodevs_init(void)
 
 		dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
 		dev_conf.nb_queue_pairs = qp;
-		dev_conf.session_mp.nb_objs = CDEV_MP_NB_OBJS;
-		dev_conf.session_mp.cache_size = CDEV_MP_CACHE_SZ;
 
-		if (rte_cryptodev_configure(cdev_id, &dev_conf))
-			rte_panic("Failed to initialize crypodev %u\n",
+		if (!socket_ctx[dev_conf.socket_id].session_pool) {
+			char mp_name[RTE_MEMPOOL_NAMESIZE];
+			struct rte_mempool *sess_mp;
+
+			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+					"sess_mp_%u", dev_conf.socket_id);
+			sess_mp = rte_mempool_create(mp_name,
+					CDEV_MP_NB_OBJS,
+					max_sess_sz,
+					CDEV_MP_CACHE_SZ,
+					0, NULL, NULL, NULL,
+					NULL, dev_conf.socket_id,
+					0);
+			if (sess_mp == NULL)
+				rte_exit(EXIT_FAILURE,
+					"Cannot create session pool on socket %d\n",
+					dev_conf.socket_id);
+			else
+				printf("Allocated session pool on socket %d\n",
+					dev_conf.socket_id);
+			socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
+		}
+
+		if (rte_cryptodev_configure(cdev_id, &dev_conf,
+				socket_ctx[dev_conf.socket_id].session_pool))
+			rte_panic("Failed to initialize cryptodev %u\n",
 					cdev_id);
 
 		qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
@@ -1433,7 +1465,7 @@ main(int32_t argc, char **argv)
 
 	nb_lcores = rte_lcore_count();
 
-	/* Replicate each contex per socket */
+	/* Replicate each context per socket */
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
 		if (rte_lcore_is_enabled(lcore_id) == 0)
 			continue;
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index ccd0aa8..da1fb1b 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -143,6 +143,7 @@ struct ipsec_ctx {
 	uint16_t nb_qps;
 	uint16_t last_qp;
 	struct cdev_qp tbl[MAX_QP_PER_LCORE];
+	struct rte_mempool *session_pool;
 };
 
 struct cdev_key {
@@ -161,6 +162,7 @@ struct socket_ctx {
 	struct rt_ctx *rt_ip4;
 	struct rt_ctx *rt_ip6;
 	struct rte_mempool *mbuf_pool;
+	struct rte_mempool *session_pool;
 };
 
 struct cnt_blk {
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 01f6dfe..9b24e51 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -88,6 +88,8 @@ enum cdev_type {
 #define MAX_KEY_SIZE 128
 #define MAX_PKT_BURST 32
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
+#define MAX_SESSIONS 32
+#define SESSION_POOL_CACHE_SIZE 0
 
 #define MAXIMUM_IV_LENGTH	16
 #define IV_OFFSET		(sizeof(struct rte_crypto_op) + \
@@ -249,6 +251,7 @@ static const struct rte_eth_conf port_conf = {
 
 struct rte_mempool *l2fwd_pktmbuf_pool;
 struct rte_mempool *l2fwd_crypto_op_pool;
+struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 };
 
 /* Per-port statistics struct */
 struct l2fwd_port_statistics {
@@ -643,8 +646,7 @@ generate_random_key(uint8_t *key, unsigned length)
 }
 
 static struct rte_cryptodev_sym_session *
-initialize_crypto_session(struct l2fwd_crypto_options *options,
-		uint8_t cdev_id)
+initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
 {
 	struct rte_crypto_sym_xform *first_xform;
 
@@ -662,7 +664,6 @@ initialize_crypto_session(struct l2fwd_crypto_options *options,
 		first_xform = &options->auth_xform;
 	}
 
-	/* Setup Cipher Parameters */
 	return rte_cryptodev_sym_session_create(cdev_id, first_xform);
 }
 
@@ -684,6 +685,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 			US_PER_S * BURST_TX_DRAIN_US;
 	struct l2fwd_crypto_params *cparams;
 	struct l2fwd_crypto_params port_cparams[qconf->nb_crypto_devs];
+	struct rte_cryptodev_sym_session *session;
 
 	if (qconf->nb_rx_ports == 0) {
 		RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id);
@@ -786,11 +788,13 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 						options->cipher_iv.length;
 		}
 
-		port_cparams[i].session = initialize_crypto_session(options,
+		session = initialize_crypto_session(options,
 				port_cparams[i].dev_id);
+		if (session == NULL)
+			rte_exit(EXIT_FAILURE, "Failed to initialize crypto session\n");
+
+		port_cparams[i].session = session;
 
-		if (port_cparams[i].session == NULL)
-			return;
 		RTE_LOG(INFO, L2FWD, " -- lcoreid=%u cryptoid=%u\n", lcore_id,
 				port_cparams[i].dev_id);
 	}
@@ -1921,6 +1925,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 {
 	unsigned int cdev_id, cdev_count, enabled_cdev_count = 0;
 	const struct rte_cryptodev_capabilities *cap;
+	unsigned int sess_sz, max_sess_sz = 0;
 	int retval;
 
 	cdev_count = rte_cryptodev_count();
@@ -1929,18 +1934,22 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		return -1;
 	}
 
+	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
+		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(cdev_id);
+		if (sess_sz > max_sess_sz)
+			max_sess_sz = sess_sz;
+	}
+
 	for (cdev_id = 0; cdev_id < cdev_count && enabled_cdev_count < nb_ports;
 			cdev_id++) {
 		struct rte_cryptodev_qp_conf qp_conf;
 		struct rte_cryptodev_info dev_info;
+		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
 
 		struct rte_cryptodev_config conf = {
 			.nb_queue_pairs = 1,
-			.socket_id = SOCKET_ID_ANY,
-			.session_mp = {
-				.nb_objs = 2048,
-				.cache_size = 64
-			}
+			.socket_id = socket_id,
 		};
 
 		if (check_cryptodev_mask(options, (uint8_t)cdev_id))
@@ -1948,6 +1957,35 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 
 		rte_cryptodev_info_get(cdev_id, &dev_info);
 
+		if (session_pool_socket[socket_id] == NULL) {
+			char mp_name[RTE_MEMPOOL_NAMESIZE];
+			struct rte_mempool *sess_mp;
+
+			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+				"sess_mp_%u", socket_id);
+
+			/*
+			 * Create enough objects for session headers and
+			 * device private data
+			 */
+			sess_mp = rte_mempool_create(mp_name,
+						MAX_SESSIONS * 2,
+						max_sess_sz,
+						SESSION_POOL_CACHE_SIZE,
+						0, NULL, NULL, NULL,
+						NULL, socket_id,
+						0);
+
+			if (sess_mp == NULL) {
+				printf("Cannot create session pool on socket %d\n",
+					socket_id);
+				return -ENOMEM;
+			}
+
+			printf("Allocated session pool on socket %d\n", socket_id);
+			session_pool_socket[socket_id] = sess_mp;
+		}
+
 		/* Set AEAD parameters */
 		if (options->xform_chain == L2FWD_CRYPTO_AEAD) {
 			/* Check if device supports AEAD algo */
@@ -2183,7 +2221,8 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 						cap->sym.auth.digest_size.min;
 		}
 
-		retval = rte_cryptodev_configure(cdev_id, &conf);
+		retval = rte_cryptodev_configure(cdev_id, &conf,
+				session_pool_socket[socket_id]);
 		if (retval < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -1;
@@ -2192,7 +2231,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		qp_conf.nb_descriptors = 2048;
 
 		retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
-				SOCKET_ID_ANY);
+				socket_id);
 		if (retval < 0) {
 			printf("Failed to setup queue pair %u on cryptodev %u",
 					0, cdev_id);
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 5e9f823..0778d5f 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -744,12 +744,9 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
 
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id);
-
 int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
+		struct rte_mempool *session_pool)
 {
 	struct rte_cryptodev *dev;
 	int diag;
@@ -769,6 +766,8 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
+	dev->data->session_pool = session_pool;
+
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
 			config->socket_id);
@@ -778,14 +777,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		return diag;
 	}
 
-	/* Setup Session mempool for device */
-	diag = rte_cryptodev_sym_session_pool_create(dev,
-			config->session_mp.nb_objs,
-			config->session_mp.cache_size,
-			config->socket_id);
-	if (diag != 0)
-		return diag;
-
 	return (*dev->dev_ops->dev_configure)(dev, config);
 }
 
@@ -1104,66 +1095,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 		(*dev->dev_ops->session_initialize)(mp, sess);
 }
 
-static int
-rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
-		unsigned nb_objs, unsigned obj_cache_size, int socket_id)
-{
-	char mp_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-	unsigned priv_sess_size;
-
-	unsigned n = snprintf(mp_name, sizeof(mp_name), "cdev_%d_sess_mp",
-			dev->data->dev_id);
-	if (n > sizeof(mp_name)) {
-		CDEV_LOG_ERR("Unable to create unique name for session mempool");
-		return -ENOMEM;
-	}
-
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_get_size, -ENOTSUP);
-	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
-	if (priv_sess_size == 0) {
-		CDEV_LOG_ERR("%s returned and invalid private session size ",
-						dev->data->name);
-		return -ENOMEM;
-	}
-
-	unsigned elt_size = sizeof(struct rte_cryptodev_sym_session) +
-			priv_sess_size;
-
-	dev->data->session_pool = rte_mempool_lookup(mp_name);
-	if (dev->data->session_pool != NULL) {
-		if ((dev->data->session_pool->elt_size != elt_size) ||
-				(dev->data->session_pool->cache_size <
-				obj_cache_size) ||
-				(dev->data->session_pool->size < nb_objs)) {
-
-			CDEV_LOG_ERR("%s mempool already exists with different"
-					" initialization parameters", mp_name);
-			dev->data->session_pool = NULL;
-			return -ENOMEM;
-		}
-	} else {
-		dev->data->session_pool = rte_mempool_create(
-				mp_name, /* mempool name */
-				nb_objs, /* number of elements*/
-				elt_size, /* element size*/
-				obj_cache_size, /* Cache size*/
-				0, /* private data size */
-				NULL, /* obj initialization constructor */
-				NULL, /* obj initialization constructor arg */
-				NULL, /**< obj constructor*/
-				dev, /* obj constructor arg */
-				socket_id, /* socket id */
-				0); /* flags */
-
-		if (dev->data->session_pool == NULL) {
-			CDEV_LOG_ERR("%s mempool allocation failed", mp_name);
-			return -ENOMEM;
-		}
-	}
-
-	CDEV_LOG_DEBUG("%s mempool created!", mp_name);
-	return 0;
-}
 
 struct rte_cryptodev_sym_session *
 rte_cryptodev_sym_session_create(uint8_t dev_id,
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index f7d248b..33842f9 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -514,11 +514,6 @@ struct rte_cryptodev_config {
 	int socket_id;			/**< Socket to allocate resources on */
 	uint16_t nb_queue_pairs;
 	/**< Number of queue pairs to configure on device */
-
-	struct {
-		uint32_t nb_objs;	/**< Number of objects in mempool */
-		uint32_t cache_size;	/**< l-core object cache size */
-	} session_mp;		/**< Session mempool configuration */
 };
 
 /**
@@ -530,13 +525,15 @@ struct rte_cryptodev_config {
  *
  * @param	dev_id		The identifier of the device to configure.
  * @param	config		The crypto device configuration structure.
+ * @param	session_pool	Pointer to device session mempool
  *
  * @return
  *   - 0: Success, device configured.
  *   - <0: Error code returned by the driver configuration function.
  */
 extern int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
+		struct rte_mempool *session_pool);
 
 /**
  * Start an device.
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 2a71f72..e5d6c07 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -67,6 +67,8 @@ struct crypto_testsuite_params {
 	struct rte_mempool *mbuf_pool;
 	struct rte_mempool *large_mbuf_pool;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *session_mpool;
+	struct rte_mempool *slave_session_mpool;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_qp_conf qp_conf;
 
@@ -384,10 +386,23 @@ testsuite_setup(void)
 
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
+
+	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+		rte_cryptodev_get_private_session_size(dev_id);
+
+	ts_params->session_mpool = rte_mempool_create(
+				"test_sess_mp",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
+			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev %u with %u qps",
 			dev_id, ts_params->conf.nb_queue_pairs);
 
@@ -419,6 +434,16 @@ testsuite_teardown(void)
 		rte_mempool_avail_count(ts_params->op_mpool));
 	}
 
+	/* Free session mempools */
+	if (ts_params->session_mpool != NULL) {
+		rte_mempool_free(ts_params->session_mpool);
+		ts_params->session_mpool = NULL;
+	}
+
+	if (ts_params->slave_session_mpool != NULL) {
+		rte_mempool_free(ts_params->slave_session_mpool);
+		ts_params->slave_session_mpool = NULL;
+	}
 }
 
 static int
@@ -434,10 +459,9 @@ ut_setup(void)
 
 	/* Reconfigure device to default parameters */
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -520,20 +544,23 @@ test_device_configure_invalid_dev_id(void)
 	/* Stop the device in case it's started so it can be configured */
 	rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
 
-	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	/* invalid dev_id values */
 	dev_id = num_devs;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	dev_id = 0xff;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
+				ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure:"
 			"invalid dev_num %u", dev_id);
 
@@ -553,7 +580,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 1;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
 
@@ -562,16 +589,17 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
-			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
+			ts_params->valid_devs[0],
+			ts_params->conf.nb_queue_pairs);
 
 
 	/* invalid - zero queue pairs */
 	ts_params->conf.nb_queue_pairs = 0;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -582,7 +610,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -593,7 +621,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf),
+			&ts_params->conf, ts_params->session_mpool),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -622,13 +650,11 @@ test_queue_pair_descriptor_setup(void)
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
 
-	ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
-
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf), "Failed to configure cryptodev %u",
+			&ts_params->conf, ts_params->session_mpool),
+			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
-
 	/*
 	 * Test various ring sizes on this device. memzones can't be
 	 * freed so are re-used if ring is released and re-created.
@@ -7683,6 +7709,31 @@ test_scheduler_attach_slave_op(void)
 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
 			continue;
 
+		/*
+		 * Create a separate mempool for the slaves, as they need different
+		 * session size and then configure them to store the pointer
+		 * to this mempool
+		 */
+		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+			rte_cryptodev_get_private_session_size(i);
+
+		if (ts_params->slave_session_mpool == NULL) {
+			ts_params->slave_session_mpool = rte_mempool_create(
+				"test_slave_sess_mp",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL, NULL,
+				SOCKET_ID_ANY, 0);
+
+			TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
+					"session mempool allocation failed");
+		}
+
+		TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
+				&ts_params->conf, ts_params->slave_session_mpool),
+				"Failed to configure cryptodev %u with %u qps",
+				i, ts_params->conf.nb_queue_pairs);
+
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 7193d18..9caba87 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -53,6 +53,7 @@
 struct crypto_testsuite_params {
 	struct rte_mempool *mbuf_mp;
 	struct rte_mempool *op_mpool;
+	struct rte_mempool *sess_mp;
 
 	uint16_t nb_queue_pairs;
 
@@ -404,10 +405,23 @@ testsuite_setup(void)
 
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
-	ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
+
+	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
+		rte_cryptodev_get_private_session_size(ts_params->dev_id);
+
+	ts_params->sess_mp = rte_mempool_create(
+				"test_sess_mp_perf",
+				info.sym.max_nb_sessions,
+				session_size,
+				0, 0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	TEST_ASSERT_NOT_NULL(ts_params->sess_mp,
+			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
-			&ts_params->conf),
+			&ts_params->conf, ts_params->sess_mp),
 			"Failed to configure cryptodev %u",
 			ts_params->dev_id);
 
@@ -436,6 +450,12 @@ testsuite_teardown(void)
 	if (ts_params->op_mpool != NULL)
 		RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_OP POOL count %u\n",
 		rte_mempool_avail_count(ts_params->op_mpool));
+	/* Free session mempool */
+	if (ts_params->sess_mp != NULL) {
+		rte_mempool_free(ts_params->sess_mp);
+		ts_params->sess_mp = NULL;
+	}
+
 }
 
 static int
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 05/12] cryptodev: change attach session to queue pair API
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (3 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 04/12] cryptodev: do not create session mempool internally Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 06/12] cryptodev: remove device id from crypto session Pablo de Lara
                         ` (9 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Device id is going to be removed from session,
as the session will be device independent.
Therefore, the functions that attach/dettach a session
to a queue pair need to be updated, to accept the device id
as a parameter, apart from the queue pair id and the session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst |  3 +++
 examples/ipsec-secgw/ipsec.c           |  1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 20 ++++++++++----------
 lib/librte_cryptodev/rte_cryptodev.h   | 10 ++++++----
 4 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 06c5e4e..9b0b4d4 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -205,6 +205,9 @@ API Changes
   * ``rte_cryptodev_configure()`` does not create the session mempool
     for the device anymore.
   * Removed ``session_mp`` from ``rte_cryptodev_config``.
+  * ``rte_cryptodev_queue_pair_attach_sym_session()`` and
+    ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
+    the new parameter ``device id``.
 
 
 ABI Changes
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index ecfd4e8..f09dce9 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -77,6 +77,7 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
 	rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
 	if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
 		ret = rte_cryptodev_queue_pair_attach_sym_session(
+				ipsec_ctx->tbl[cdev_id_qp].id,
 				ipsec_ctx->tbl[cdev_id_qp].qp,
 				sa->crypto_session);
 		if (ret < 0) {
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 0778d5f..078e26b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1136,23 +1136,23 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 }
 
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0);
 	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) {
 		CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
@@ -1160,23 +1160,23 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
 }
 
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id);
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
 		return -EINVAL;
 	}
 
-	dev = &rte_crypto_devices[sess->dev_id];
+	dev = &rte_crypto_devices[dev_id];
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0);
 	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) {
 		CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session",
-				sess->dev_id, qp_id);
+				dev_id, qp_id);
 		return -EPERM;
 	}
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 33842f9..0ade05e 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -953,7 +953,8 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id);
 /**
  * Attach queue pair with sym session.
  *
- * @param	qp_id		Queue pair to which session will be attached.
+ * @param	dev_id		Device to which the session will be attached.
+ * @param	qp_id		Queue pair to which the session will be attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
  *
@@ -962,13 +963,14 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id);
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
  * Detach queue pair with sym session.
  *
- * @param	qp_id		Queue pair to which session is attached.
+ * @param	dev_id		Device to which the session is attached.
+ * @param	qp_id		Queue pair to which the session is attached.
  * @param	session		Session pointer previously allocated by
  *				*rte_cryptodev_sym_session_create*.
  *
@@ -977,7 +979,7 @@ rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id,
  *  - On failure, a negative value.
  */
 int
-rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id,
+rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *session);
 
 /**
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 06/12] cryptodev: remove device id from crypto session
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (4 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 05/12] cryptodev: change attach session to queue pair API Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 07/12] cryptodev: remove driver id from session Pablo de Lara
                         ` (8 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Device id is necessary in the crypto session,
as it was only used for the functions that attach/detach
a session to a queue pair.

Since the session is not going to be attached to a device
anymore, this is field is no longer necessary.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst | 1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 1 -
 lib/librte_cryptodev/rte_cryptodev.h   | 2 --
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 9b0b4d4..d5fcb74 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -208,6 +208,7 @@ API Changes
   * ``rte_cryptodev_queue_pair_attach_sym_session()`` and
     ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
     the new parameter ``device id``.
+  * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 078e26b..cb773c7 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1087,7 +1087,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->dev_id = dev->data->dev_id;
 	sess->driver_id = dev->driver_id;
 	sess->mp = mp;
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 0ade05e..d1e7c2f 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -884,8 +884,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
 	struct {
-		uint8_t dev_id;
-		/**< Device Id */
 		uint8_t driver_id;
 		/** Crypto driver identifier session created on */
 		struct rte_mempool *mp;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 07/12] cryptodev: remove driver id from session
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (5 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 06/12] cryptodev: remove device id from crypto session Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 08/12] cryptodev: remove mempool " Pablo de Lara
                         ` (7 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Since crypto session will not be attached to a specific
device or driver, the field driver_id is not required
anymore (only used to check that a session was being
handled by the right device).

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst     | 1 +
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 4 ----
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 9 ++-------
 drivers/crypto/armv8/rte_armv8_pmd.c       | 4 +---
 drivers/crypto/kasumi/rte_kasumi_pmd.c     | 4 ----
 drivers/crypto/null/null_crypto_pmd.c      | 4 +---
 drivers/crypto/openssl/rte_openssl_pmd.c   | 4 +---
 drivers/crypto/qat/qat_crypto.c            | 6 ------
 drivers/crypto/snow3g/rte_snow3g_pmd.c     | 4 ----
 drivers/crypto/zuc/rte_zuc_pmd.c           | 4 ----
 lib/librte_cryptodev/rte_cryptodev.c       | 5 -----
 lib/librte_cryptodev/rte_cryptodev.h       | 2 --
 12 files changed, 6 insertions(+), 45 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index d5fcb74..c3d3b34 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -209,6 +209,7 @@ API Changes
     ``rte_cryptodev_queue_pair_dettach_sym_session()`` functions require
     the new parameter ``device id``.
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
+  * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index 1ef83fa..d226c23 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -155,10 +155,6 @@ aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_op *op)
 	struct rte_crypto_sym_op *sym_op = op->sym;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		if (unlikely(sym_op->session->driver_id !=
-				cryptodev_driver_id))
-			return sess;
-
 		sess = (struct aesni_gcm_session *)sym_op->session->_private;
 	} else  {
 		void *_sess;
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 4dab849..699779a 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -354,14 +354,9 @@ get_session(struct aesni_mb_qp *qp, struct rte_crypto_op *op)
 {
 	struct aesni_mb_session *sess = NULL;
 
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id)) {
-			return NULL;
-		}
-
+	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
 		sess = (struct aesni_mb_session *)op->sym->session->_private;
-	} else  {
+	else  {
 		void *_sess = NULL;
 
 		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index 7cce09f..590803a 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -555,9 +555,7 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id)) {
+		if (likely(op->sym->session != NULL)) {
 			sess = (struct armv8_crypto_session *)
 				op->sym->session->_private;
 		}
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 37ca2cc..35afa99 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -166,10 +166,6 @@ kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 	struct kasumi_session *sess;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct kasumi_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index da62592..27cb9a2 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -98,9 +98,7 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_op *op)
 	struct rte_crypto_sym_op *sym_op = op->sym;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		if (unlikely(sym_op->session == NULL ||
-				sym_op->session->driver_id !=
-					cryptodev_driver_id))
+		if (unlikely(sym_op->session == NULL))
 			return NULL;
 
 		sess = (struct null_crypto_session *)sym_op->session->_private;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index d497a27..6f5937d 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -558,9 +558,7 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 		/* get existing session */
-		if (likely(op->sym->session != NULL &&
-				op->sym->session->driver_id ==
-				cryptodev_driver_id))
+		if (likely(op->sym->session != NULL))
 			sess = (struct openssl_session *)
 				op->sym->session->_private;
 	} else  {
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index e2c8e43..d0638a2 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -1072,12 +1072,6 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	if (unlikely(op->sym->session->driver_id !=
-			cryptodev_qat_driver_id)) {
-		PMD_DRV_LOG(ERR, "Session was not created for this device");
-		return -EINVAL;
-	}
-
 	ctx = (struct qat_session *)op->sym->session->_private;
 	qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
 	rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 0c65b2d..f28b8d6 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -166,10 +166,6 @@ snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 	struct snow3g_session *sess;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct snow3g_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 82710d3..951f1f4 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -165,10 +165,6 @@ zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 	struct zuc_session *sess;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		if (unlikely(op->sym->session->driver_id !=
-				cryptodev_driver_id))
-			return NULL;
-
 		sess = (struct zuc_session *)op->sym->session->_private;
 	} else  {
 		struct rte_cryptodev_sym_session *c_sess = NULL;
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index cb773c7..c2123cd 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1087,7 +1087,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->driver_id = dev->driver_id;
 	sess->mp = mp;
 
 	if (dev->dev_ops->session_initialize)
@@ -1194,10 +1193,6 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 
 	dev = &rte_crypto_devices[dev_id];
 
-	/* Check the session belongs to this device type */
-	if (sess->driver_id != dev->driver_id)
-		return sess;
-
 	/* Let device implementation clear session material */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_clear, sess);
 	dev->dev_ops->session_clear(dev, (void *)sess->_private);
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index d1e7c2f..0fb5608 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -884,8 +884,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
 	struct {
-		uint8_t driver_id;
-		/** Crypto driver identifier session created on */
 		struct rte_mempool *mp;
 		/**< Mempool session allocated from */
 	} __rte_aligned(8);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 08/12] cryptodev: remove mempool from session
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (6 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 07/12] cryptodev: remove driver id from session Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 09/12] cryptodev: support device independent sessions Pablo de Lara
                         ` (6 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Mempool pointer can be obtained from the object itself,
which means that it is not required to actually store the pointer
in the session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_17_08.rst | 1 +
 lib/librte_cryptodev/rte_cryptodev.c   | 7 +++----
 lib/librte_cryptodev/rte_cryptodev.h   | 6 ------
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index c3d3b34..74275e0 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -210,6 +210,7 @@ API Changes
     the new parameter ``device id``.
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
+  * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
 
 
 ABI Changes
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index c2123cd..dfced85 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1087,8 +1087,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
 {
 	memset(sess, 0, mp->elt_size);
 
-	sess->mp = mp;
-
 	if (dev->dev_ops->session_initialize)
 		(*dev->dev_ops->session_initialize)(mp, sess);
 }
@@ -1126,7 +1124,7 @@ rte_cryptodev_sym_session_create(uint8_t dev_id,
 				dev_id);
 
 		/* Return session to mempool */
-		rte_mempool_put(sess->mp, _sess);
+		rte_mempool_put(dev->data->session_pool, _sess);
 		return NULL;
 	}
 
@@ -1198,7 +1196,8 @@ rte_cryptodev_sym_session_free(uint8_t dev_id,
 	dev->dev_ops->session_clear(dev, (void *)sess->_private);
 
 	/* Return session to mempool */
-	rte_mempool_put(sess->mp, (void *)sess);
+	struct rte_mempool *mp = rte_mempool_from_obj(sess);
+	rte_mempool_put(mp, (void *)sess);
 
 	return NULL;
 }
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 0fb5608..508c672 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -883,12 +883,6 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 /** Cryptodev symmetric crypto session */
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
-	struct {
-		struct rte_mempool *mp;
-		/**< Mempool session allocated from */
-	} __rte_aligned(8);
-	/**< Public symmetric session details */
-
 	__extension__ char _private[0];
 	/**< Private session material */
 };
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 09/12] cryptodev: support device independent sessions
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (7 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 08/12] cryptodev: remove mempool " Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 10/12] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
                         ` (5 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Slawomir Mrozowicz, Pablo de Lara

From: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>

Change crypto device's session management to make it
device independent and simplify architecture when session
is intended to be used on more than one device.

Sessions private data is agnostic to underlying device
by adding an indirection in the sessions private data
using the crypto driver identifier.
A single session can contain indirections to multiple device types.

New function rte_cryptodev_sym_session_init has been created,
to initialize the private data per driver to be used on
a same session.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/cperf.h                       |   5 +-
 app/test-crypto-perf/cperf_ops.c                   |  21 +-
 app/test-crypto-perf/cperf_ops.h                   |   1 +
 app/test-crypto-perf/cperf_test_latency.c          |  12 +-
 app/test-crypto-perf/cperf_test_latency.h          |   5 +-
 app/test-crypto-perf/cperf_test_throughput.c       |  12 +-
 app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
 app/test-crypto-perf/cperf_test_verify.c           |  12 +-
 app/test-crypto-perf/cperf_test_verify.h           |   5 +-
 app/test-crypto-perf/main.c                        |   8 +-
 doc/guides/rel_notes/release_17_08.rst             |   9 +
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  47 ++-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  45 ++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  40 ++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  46 ++-
 drivers/crypto/armv8/rte_armv8_pmd.c               |  35 ++-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  45 ++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  55 +++-
 drivers/crypto/kasumi/rte_kasumi_pmd.c             |  40 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  47 ++-
 drivers/crypto/null/null_crypto_pmd.c              |  41 ++-
 drivers/crypto/null/null_crypto_pmd_ops.c          |  47 ++-
 drivers/crypto/openssl/rte_openssl_pmd.c           |  37 ++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  48 ++-
 drivers/crypto/qat/qat_crypto.c                    |  95 ++++--
 drivers/crypto/qat/qat_crypto.h                    |  16 +-
 drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
 drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
 .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 --
 drivers/crypto/scheduler/scheduler_pmd_ops.c       |  81 ++---
 drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
 drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 ---
 drivers/crypto/snow3g/rte_snow3g_pmd.c             |  41 ++-
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  47 ++-
 drivers/crypto/zuc/rte_zuc_pmd.c                   |  37 ++-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  47 ++-
 examples/ipsec-secgw/ipsec-secgw.c                 |   3 +-
 examples/ipsec-secgw/ipsec.c                       |   7 +-
 examples/l2fwd-crypto/main.c                       |  17 +-
 lib/librte_cryptodev/rte_cryptodev.c               | 140 ++++++---
 lib/librte_cryptodev/rte_cryptodev.h               |  82 +++--
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |  32 +-
 lib/librte_cryptodev/rte_cryptodev_version.map     |   3 +
 test/test/test_cryptodev.c                         | 347 +++++++++++++++------
 test/test/test_cryptodev_blockcipher.c             |  18 +-
 test/test/test_cryptodev_blockcipher.h             |   1 +
 test/test/test_cryptodev_perf.c                    | 191 ++++++++----
 47 files changed, 1315 insertions(+), 667 deletions(-)

diff --git a/app/test-crypto-perf/cperf.h b/app/test-crypto-perf/cperf.h
index 293ba94..c9f7f81 100644
--- a/app/test-crypto-perf/cperf.h
+++ b/app/test-crypto-perf/cperf.h
@@ -41,7 +41,10 @@ struct cperf_options;
 struct cperf_test_vector;
 struct cperf_op_fns;
 
-typedef void  *(*cperf_constructor_t)(uint8_t dev_id, uint16_t qp_id,
+typedef void  *(*cperf_constructor_t)(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *t_vec,
 		const struct cperf_op_fns *op_fns);
diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index d718278..a5bf09b 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -367,7 +367,8 @@ cperf_set_ops_aead(struct rte_crypto_op **ops,
 }
 
 static struct rte_cryptodev_sym_session *
-cperf_create_session(uint8_t dev_id,
+cperf_create_session(struct rte_mempool *sess_mp,
+	uint8_t dev_id,
 	const struct cperf_options *options,
 	const struct cperf_test_vector *test_vector,
 	uint16_t iv_offset)
@@ -377,6 +378,7 @@ cperf_create_session(uint8_t dev_id,
 	struct rte_crypto_sym_xform aead_xform;
 	struct rte_cryptodev_sym_session *sess = NULL;
 
+	sess = rte_cryptodev_sym_session_create(sess_mp);
 	/*
 	 * cipher only
 	 */
@@ -401,7 +403,8 @@ cperf_create_session(uint8_t dev_id,
 			cipher_xform.cipher.iv.length = 0;
 		}
 		/* create crypto session */
-		sess = rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &cipher_xform,
+				sess_mp);
 	/*
 	 *  auth only
 	 */
@@ -427,7 +430,8 @@ cperf_create_session(uint8_t dev_id,
 			auth_xform.auth.iv.length = 0;
 		}
 		/* create crypto session */
-		sess =  rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+		rte_cryptodev_sym_session_init(dev_id, sess, &auth_xform,
+				sess_mp);
 	/*
 	 * cipher and auth
 	 */
@@ -483,13 +487,13 @@ cperf_create_session(uint8_t dev_id,
 		if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
 			cipher_xform.next = &auth_xform;
 			/* create crypto session */
-			sess = rte_cryptodev_sym_session_create(dev_id,
-						&cipher_xform);
+			rte_cryptodev_sym_session_init(dev_id,
+					sess, &cipher_xform, sess_mp);
 		} else { /* auth then cipher */
 			auth_xform.next = &cipher_xform;
 			/* create crypto session */
-			sess = rte_cryptodev_sym_session_create(dev_id,
-					&auth_xform);
+			rte_cryptodev_sym_session_init(dev_id,
+					sess, &auth_xform, sess_mp);
 		}
 	} else { /* options->op_type == CPERF_AEAD */
 		aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
@@ -509,7 +513,8 @@ cperf_create_session(uint8_t dev_id,
 					options->aead_aad_sz;
 
 		/* Create crypto session */
-		sess = rte_cryptodev_sym_session_create(dev_id, &aead_xform);
+		rte_cryptodev_sym_session_init(dev_id,
+					sess, &aead_xform, sess_mp);
 	}
 
 	return sess;
diff --git a/app/test-crypto-perf/cperf_ops.h b/app/test-crypto-perf/cperf_ops.h
index bb83cd5..1f8fa93 100644
--- a/app/test-crypto-perf/cperf_ops.h
+++ b/app/test-crypto-perf/cperf_ops.h
@@ -41,6 +41,7 @@
 
 
 typedef struct rte_cryptodev_sym_session *(*cperf_sessions_create_t)(
+		struct rte_mempool *sess_mp,
 		uint8_t dev_id, const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		uint16_t iv_offset);
diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c
index 8841d39..1a42602 100644
--- a/app/test-crypto-perf/cperf_test_latency.c
+++ b/app/test-crypto-perf/cperf_test_latency.c
@@ -79,8 +79,10 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx, uint32_t mbuf_nb)
 	uint32_t i;
 
 	if (ctx) {
-		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+		if (ctx->sess) {
+			rte_cryptodev_sym_session_clear(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
+		}
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -191,7 +193,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -216,7 +219,8 @@ cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
 		sizeof(struct rte_crypto_sym_op) +
 		sizeof(struct cperf_op_result *);
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector, iv_offset);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector,
+			iv_offset);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_latency.h b/app/test-crypto-perf/cperf_test_latency.h
index 6a2cf61..1bbedb4 100644
--- a/app/test-crypto-perf/cperf_test_latency.h
+++ b/app/test-crypto-perf/cperf_test_latency.h
@@ -43,7 +43,10 @@
 #include "cperf_test_vectors.h"
 
 void *
-cperf_latency_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_latency_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index 87fac0f..3025044 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -64,8 +64,10 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx, uint32_t mbuf_nb)
 	uint32_t i;
 
 	if (ctx) {
-		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+		if (ctx->sess) {
+			rte_cryptodev_sym_session_clear(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
+		}
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -175,7 +177,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -199,7 +202,8 @@ cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	uint16_t iv_offset = sizeof(struct rte_crypto_op) +
 		sizeof(struct rte_crypto_sym_op);
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector, iv_offset);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector,
+					iv_offset);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_throughput.h b/app/test-crypto-perf/cperf_test_throughput.h
index f1b5766..987d0c3 100644
--- a/app/test-crypto-perf/cperf_test_throughput.h
+++ b/app/test-crypto-perf/cperf_test_throughput.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_throughput_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_throughput_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 3ee0560..9c37954 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -68,8 +68,10 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx, uint32_t mbuf_nb)
 	uint32_t i;
 
 	if (ctx) {
-		if (ctx->sess)
-			rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
+		if (ctx->sess) {
+			rte_cryptodev_sym_session_clear(ctx->dev_id, ctx->sess);
+			rte_cryptodev_sym_session_free(ctx->sess);
+		}
 
 		if (ctx->mbufs_in) {
 			for (i = 0; i < mbuf_nb; i++)
@@ -179,7 +181,8 @@ cperf_mbuf_create(struct rte_mempool *mempool,
 }
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(struct rte_mempool *sess_mp,
+		uint8_t dev_id, uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *op_fns)
@@ -203,7 +206,8 @@ cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
 	uint16_t iv_offset = sizeof(struct rte_crypto_op) +
 		sizeof(struct rte_crypto_sym_op);
 
-	ctx->sess = op_fns->sess_create(dev_id, options, test_vector, iv_offset);
+	ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector,
+			iv_offset);
 	if (ctx->sess == NULL)
 		goto err;
 
diff --git a/app/test-crypto-perf/cperf_test_verify.h b/app/test-crypto-perf/cperf_test_verify.h
index 3fa78ee..e67b48d 100644
--- a/app/test-crypto-perf/cperf_test_verify.h
+++ b/app/test-crypto-perf/cperf_test_verify.h
@@ -44,7 +44,10 @@
 
 
 void *
-cperf_verify_test_constructor(uint8_t dev_id, uint16_t qp_id,
+cperf_verify_test_constructor(
+		struct rte_mempool *sess_mp,
+		uint8_t dev_id,
+		uint16_t qp_id,
 		const struct cperf_options *options,
 		const struct cperf_test_vector *test_vector,
 		const struct cperf_op_fns *ops_fn);
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 45524ad..90edb24 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -109,8 +109,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
 	for (i = 0; i < enabled_cdev_count &&
 			i < RTE_CRYPTO_MAX_DEVS; i++) {
 		uint8_t cdev_id = enabled_cdevs[i];
-		sess_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(cdev_id);
+		sess_size = rte_cryptodev_get_private_session_size(cdev_id);
 		if (sess_size > max_sess_size)
 			max_sess_size = sess_size;
 	}
@@ -477,7 +476,10 @@ main(int argc, char **argv)
 
 		cdev_id = enabled_cdevs[i];
 
-		ctx[cdev_id] = cperf_testmap[opts.test].constructor(cdev_id, 0,
+		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+
+		ctx[cdev_id] = cperf_testmap[opts.test].constructor(
+				session_pool_socket[socket_id], cdev_id, 0,
 				&opts, t_vec, &op_fns);
 		if (ctx[cdev_id] == NULL) {
 			RTE_LOG(ERR, USER1, "Test run constructor failed\n");
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 74275e0..4fae766 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -81,6 +81,10 @@ New Features
     necessary to use a combination of cipher and authentication
     structures anymore.
   * Added helper functions for crypto device driver identification.
+  * Added support for multi-device sessions, so a single session can be
+    used in multiple drivers.
+  * Added functions to initialize and free individual driver private data
+    with a same session.
 
 * **Updated dpaa2_sec crypto PMD.**
 
@@ -211,6 +215,11 @@ API Changes
   * ``dev_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * ``driver_id`` field has been removed from ``rte_cryptodev_sym_session`` structure.
   * Mempool pointer ``mp`` has been removed from ``rte_cryptodev_sym_session`` structure.
+  * Replaced ``private`` marker with array of pointers to private data sessions
+    ``sess_private_data`` in ``rte_cryptodev_sym_session``
+  * Modified parameters of ``rte_cryptodev_sym_session_create()``, to accept
+    ``mempool``, instead of ``device id`` and ``rte_crypto_sym_xform``.
+  * Remove ``device id`` parameter from ``rte_cryptodev_sym_session_free()``.
 
 
 ABI Changes
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index d226c23..91c3801 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -155,22 +155,37 @@ aesni_gcm_get_session(struct aesni_gcm_qp *qp, struct rte_crypto_op *op)
 	struct rte_crypto_sym_op *sym_op = op->sym;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		sess = (struct aesni_gcm_session *)sym_op->session->_private;
+		if (likely(sym_op->session != NULL))
+			sess = (struct aesni_gcm_session *)
+					get_session_private_data(
+					sym_op->session,
+					cryptodev_driver_id);
 	} else  {
 		void *_sess;
+		void *_sess_private_data = NULL;
 
-		if (rte_mempool_get(qp->sess_mp, &_sess))
-			return sess;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
+			return NULL;
 
-		sess = (struct aesni_gcm_session *)
-			((struct rte_cryptodev_sym_session *)_sess)->_private;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
+			return NULL;
 
-		if (unlikely(aesni_gcm_set_session_parameters(qp->ops, sess,
-				sym_op->xform) != 0)) {
+		sess = (struct aesni_gcm_session *)_sess_private_data;
+
+		if (unlikely(aesni_gcm_set_session_parameters(qp->ops,
+				sess, sym_op->xform) != 0)) {
 			rte_mempool_put(qp->sess_mp, _sess);
+			rte_mempool_put(qp->sess_mp, _sess_private_data);
 			sess = NULL;
 		}
+		sym_op->session = (struct rte_cryptodev_sym_session *)_sess;
+		set_session_private_data(sym_op->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
+
+	if (unlikely(sess == NULL))
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
+
 	return sess;
 }
 
@@ -370,13 +385,11 @@ process_gcm_crypto_op(struct aesni_gcm_qp *qp, struct rte_crypto_op *op,
  * - Returns NULL on invalid job
  */
 static void
-post_process_gcm_crypto_op(struct rte_crypto_op *op)
+post_process_gcm_crypto_op(struct rte_crypto_op *op,
+		struct aesni_gcm_session *session)
 {
 	struct rte_mbuf *m = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;
 
-	struct aesni_gcm_session *session =
-		(struct aesni_gcm_session *)op->sym->session->_private;
-
 	op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
 	/* Verify digest if required */
@@ -411,6 +424,7 @@ post_process_gcm_crypto_op(struct rte_crypto_op *op)
  * Process a completed GCM request
  *
  * @param qp		Queue Pair to process
+ * @param op		Crypto operation
  * @param job		JOB_AES_HMAC job
  *
  * @return
@@ -418,12 +432,17 @@ post_process_gcm_crypto_op(struct rte_crypto_op *op)
  */
 static void
 handle_completed_gcm_crypto_op(struct aesni_gcm_qp *qp,
-		struct rte_crypto_op *op)
+		struct rte_crypto_op *op,
+		struct aesni_gcm_session *sess)
 {
-	post_process_gcm_crypto_op(op);
+	post_process_gcm_crypto_op(op, sess);
 
 	/* Free session if a session-less crypto op */
 	if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
+		memset(sess, 0, sizeof(struct aesni_gcm_session));
+		memset(op->sym->session, 0,
+				rte_cryptodev_get_header_session_size());
+		rte_mempool_put(qp->sess_mp, sess);
 		rte_mempool_put(qp->sess_mp, op->sym->session);
 		op->sym->session = NULL;
 	}
@@ -458,7 +477,7 @@ aesni_gcm_pmd_dequeue_burst(void *queue_pair,
 			break;
 		}
 
-		handle_completed_gcm_crypto_op(qp, ops[i]);
+		handle_completed_gcm_crypto_op(qp, ops[i], sess);
 	}
 
 	qp->qp_stats.dequeued_count += i;
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 85c7485..21052cd 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
+ *   Copyright(c) 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
@@ -302,32 +302,55 @@ aesni_gcm_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a aesni gcm session from a crypto xform chain */
-static void *
-aesni_gcm_pmd_session_configure(struct rte_cryptodev *dev,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+static int
+aesni_gcm_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
 	struct aesni_gcm_private *internals = dev->data->dev_private;
 
 	if (unlikely(sess == NULL)) {
 		GCM_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
 	}
 
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
+	}
 	if (aesni_gcm_set_session_parameters(gcm_ops[internals->vector_mode],
-			sess, xform) != 0) {
+				sess_private_data, xform) != 0) {
 		GCM_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-aesni_gcm_pmd_session_clear(struct rte_cryptodev *dev __rte_unused, void *sess)
+aesni_gcm_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	if (sess)
-		memset(sess, 0, sizeof(struct aesni_gcm_session));
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		memset(sess_priv, 0, sizeof(struct aesni_gcm_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 struct rte_cryptodev_ops aesni_gcm_pmd_ops = {
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 699779a..3aaa070 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -354,25 +354,38 @@ get_session(struct aesni_mb_qp *qp, struct rte_crypto_op *op)
 {
 	struct aesni_mb_session *sess = NULL;
 
-	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
-		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_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_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;
 }
 
@@ -512,19 +525,21 @@ verify_digest(JOB_AES_HMAC *job, struct rte_crypto_op *op) {
 /**
  * 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 which mbuf is trimmed of output digest
+ *   used in verification of supplied digest.
  * - 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;
+	struct aesni_mb_session *sess = get_session_private_data(
+							op->sym->session,
+							cryptodev_driver_id);
 
 	if (unlikely(op->status == RTE_CRYPTO_OP_STATUS_ENQUEUED)) {
 		switch (job->status) {
@@ -532,9 +547,6 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
 			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);
@@ -547,6 +559,10 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
 
 	/* Free session if a session-less crypto op */
 	if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
+		memset(sess, 0, sizeof(struct aesni_mb_session));
+		memset(op->sym->session, 0,
+				rte_cryptodev_get_header_session_size());
+		rte_mempool_put(qp->sess_mp, sess);
 		rte_mempool_put(qp->sess_mp, op->sym->session);
 		op->sym->session = NULL;
 	}
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index b5abb6c..ae74ae3 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -479,36 +479,56 @@ aesni_mb_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a aesni multi-buffer session from a crypto xform chain */
-static void *
+static int
 aesni_mb_pmd_session_configure(struct rte_cryptodev *dev,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
 	struct aesni_mb_private *internals = dev->data->dev_private;
 
 	if (unlikely(sess == NULL)) {
 		MB_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
 	if (aesni_mb_set_session_parameters(&job_ops[internals->vector_mode],
-			sess, xform) != 0) {
+			sess_private_data, xform) != 0) {
 		MB_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-aesni_mb_pmd_session_clear(struct rte_cryptodev *dev __rte_unused, void *sess)
+aesni_mb_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	/*
-	 * Current just resetting the whole data structure, need to investigate
-	 * whether a more selective reset of key would be more performant
-	 */
-	if (sess)
-		memset(sess, 0, sizeof(struct aesni_mb_session));
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		memset(sess_priv, 0, sizeof(struct aesni_mb_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 struct rte_cryptodev_ops aesni_mb_pmd_ops = {
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index 590803a..eeeaab7 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -557,24 +557,32 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 		/* get existing session */
 		if (likely(op->sym->session != NULL)) {
 			sess = (struct armv8_crypto_session *)
-				op->sym->session->_private;
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
 		}
 	} else {
 		/* provide internal session */
 		void *_sess = NULL;
+		void *_sess_private_data = NULL;
 
-		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
-			sess = (struct armv8_crypto_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
-
-			if (unlikely(armv8_crypto_set_session_parameters(
-					sess, op->sym->xform) != 0)) {
-				rte_mempool_put(qp->sess_mp, _sess);
-				sess = NULL;
-			} else
-				op->sym->session = _sess;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
+			return NULL;
+
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
+			return NULL;
+
+		sess = (struct armv8_crypto_session *)_sess_private_data;
+
+		if (unlikely(armv8_crypto_set_session_parameters(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_session_private_data(op->sym->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
 
 	if (unlikely(sess == NULL))
@@ -704,6 +712,9 @@ process_op(const struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
 	/* Free session if a session-less crypto op */
 	if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
 		memset(sess, 0, sizeof(struct armv8_crypto_session));
+		memset(op->sym->session, 0,
+				rte_cryptodev_get_header_session_size());
+		rte_mempool_put(qp->sess_mp, sess);
 		rte_mempool_put(qp->sess_mp, op->sym->session);
 		op->sym->session = NULL;
 	}
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index 1bce2ea..e14b68c 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -318,33 +318,54 @@ armv8_crypto_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure the session from a crypto xform chain */
-static void *
-armv8_crypto_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform, void *sess)
+static int
+armv8_crypto_pmd_session_configure(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		ARMV8_CRYPTO_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (armv8_crypto_set_session_parameters(
-			sess, xform) != 0) {
+	if (armv8_crypto_set_session_parameters(sess_private_data, xform) != 0) {
 		ARMV8_CRYPTO_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-armv8_crypto_pmd_session_clear(struct rte_cryptodev *dev __rte_unused,
-				void *sess)
+armv8_crypto_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
 
 	/* Zero out the whole structure */
-	if (sess)
-		memset(sess, 0, sizeof(struct armv8_crypto_session));
+	if (sess_priv) {
+		memset(sess_priv, 0, sizeof(struct armv8_crypto_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 struct rte_cryptodev_ops armv8_crypto_pmd_ops = {
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 9d1c266..b764f33 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -619,7 +619,9 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
 			/*Clear the unused FD fields before sending*/
 			memset(&fd_arr[loop], 0, sizeof(struct qbman_fd));
 			sess = (dpaa2_sec_session *)
-				(*ops)->sym->session->_private;
+					get_session_private_data(
+					(*ops)->sym->session,
+					cryptodev_driver_id);
 			mb_pool = (*ops)->sym->m_src->pool;
 			bpid = mempool_to_bpid(mb_pool);
 			ret = build_sec_fd(sess, *ops, &fd_arr[loop], bpid);
@@ -1498,8 +1500,8 @@ dpaa2_sec_aead_chain_init(struct rte_cryptodev *dev,
 	return -1;
 }
 
-static void *
-dpaa2_sec_session_configure(struct rte_cryptodev *dev,
+static int
+dpaa2_sec_set_session_parameters(struct rte_cryptodev *dev,
 			    struct rte_crypto_sym_xform *xform,	void *sess)
 {
 	dpaa2_sec_session *session = sess;
@@ -1508,7 +1510,7 @@ dpaa2_sec_session_configure(struct rte_cryptodev *dev,
 
 	if (unlikely(sess == NULL)) {
 		RTE_LOG(ERR, PMD, "invalid session struct");
-		return NULL;
+		return -1;
 	}
 
 	/* Default IV length = 0 */
@@ -1544,24 +1546,59 @@ dpaa2_sec_session_configure(struct rte_cryptodev *dev,
 
 	} else {
 		RTE_LOG(ERR, PMD, "Invalid crypto type");
-		return NULL;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+dpaa2_sec_session_configure(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
+{
+	void *sess_private_data;
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	return session;
+	if (dpaa2_sec_set_session_parameters(dev, xform, sess_private_data) != 0) {
+		PMD_DRV_LOG(ERR, "DPAA2 PMD: failed to configure "
+				"session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
+	}
+
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-dpaa2_sec_session_clear(struct rte_cryptodev *dev __rte_unused, void *sess)
+dpaa2_sec_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
 	PMD_INIT_FUNC_TRACE();
-	dpaa2_sec_session *s = (dpaa2_sec_session *)sess;
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+	dpaa2_sec_session *s = (dpaa2_sec_session *)sess_priv;
 
-	if (s) {
+	if (sess_priv) {
 		rte_free(s->ctxt);
 		rte_free(s->cipher_key.data);
 		rte_free(s->auth_key.data);
 		memset(sess, 0, sizeof(dpaa2_sec_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
 	}
 }
 
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 35afa99..cff40fb 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -163,23 +163,40 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
 static struct kasumi_session *
 kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
 {
-	struct kasumi_session *sess;
+	struct kasumi_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		sess = (struct kasumi_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct kasumi_session *)
+					get_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;
 
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct kasumi_session *)c_sess->_private;
+		sess = (struct kasumi_session *)_sess_private_data;
 
 		if (unlikely(kasumi_set_session_parameters(sess,
-				op->sym->xform) != 0))
-			return NULL;
+				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_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;
 }
 
@@ -354,6 +371,10 @@ process_ops(struct rte_crypto_op **ops, struct kasumi_session *session,
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		/* Free session if a session-less crypto op. */
 		if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
+			memset(session, 0, sizeof(struct kasumi_session));
+			memset(ops[i]->sym->session, 0,
+					rte_cryptodev_get_header_session_size());
+			rte_mempool_put(qp->sess_mp, session);
 			rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
 			ops[i]->sym->session = NULL;
 		}
@@ -406,7 +427,8 @@ process_op_bit(struct rte_crypto_op *op, struct kasumi_session *session,
 
 	/* Free session if a session-less crypto op. */
 	if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		memset(op->sym->session, 0, sizeof(struct kasumi_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index 5cb0024..e7bbc29 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -292,33 +292,54 @@ kasumi_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a KASUMI session from a crypto xform chain */
-static void *
+static int
 kasumi_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		KASUMI_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (kasumi_set_session_parameters(sess, xform) != 0) {
+	if (kasumi_set_session_parameters(sess_private_data, xform) != 0) {
 		KASUMI_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-kasumi_pmd_session_clear(struct rte_cryptodev *dev __rte_unused, void *sess)
+kasumi_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	/*
-	 * Current just resetting the whole data structure, need to investigate
-	 * whether a more selective reset of key would be more performant
-	 */
-	if (sess)
-		memset(sess, 0, sizeof(struct kasumi_session));
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		memset(sess_priv, 0, sizeof(struct kasumi_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 struct rte_cryptodev_ops kasumi_pmd_ops = {
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 27cb9a2..7f7dee6 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -84,6 +84,14 @@ process_op(const struct null_crypto_qp *qp, struct rte_crypto_op *op,
 	/* set status as successful by default */
 	op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
+	/* Free session if a session-less crypto op. */
+	if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
+		memset(op->sym->session, 0,
+				sizeof(struct null_crypto_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
+		op->sym->session = NULL;
+	}
+
 	/*
 	 * if crypto session and operation are valid just enqueue the packet
 	 * in the processed ring
@@ -94,24 +102,35 @@ process_op(const struct null_crypto_qp *qp, struct rte_crypto_op *op,
 static struct null_crypto_session *
 get_session(struct null_crypto_qp *qp, struct rte_crypto_op *op)
 {
-	struct null_crypto_session *sess;
+	struct null_crypto_session *sess = NULL;
 	struct rte_crypto_sym_op *sym_op = op->sym;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		if (unlikely(sym_op->session == NULL))
+		if (likely(sym_op->session != NULL))
+			sess = (struct null_crypto_session *)
+					get_session_private_data(
+					sym_op->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 null_crypto_session *)sym_op->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
-
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct null_crypto_session *)c_sess->_private;
-
-		if (null_crypto_set_session_parameters(sess, sym_op->xform) != 0)
-			return NULL;
+		sess = (struct null_crypto_session *)_sess_private_data;
+
+		if (unlikely(null_crypto_set_session_parameters(sess,
+				sym_op->xform) != 0)) {
+			rte_mempool_put(qp->sess_mp, _sess);
+			rte_mempool_put(qp->sess_mp, _sess_private_data);
+			sess = NULL;
+		}
+		sym_op->session = (struct rte_cryptodev_sym_session *)_sess;
+		set_session_private_data(sym_op->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
 
 	return sess;
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index a3f2e4c..d57644d 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -299,33 +299,54 @@ null_crypto_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a null crypto session from a crypto xform chain */
-static void *
+static int
 null_crypto_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform, void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mp)
 {
-	int retval;
+	void *sess_private_data;
 
 	if (unlikely(sess == NULL)) {
 		NULL_CRYPTO_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mp, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
-	retval = null_crypto_set_session_parameters(
-			(struct null_crypto_session *)sess, xform);
-	if (retval != 0) {
+
+	if (null_crypto_set_session_parameters(sess_private_data, xform) != 0) {
 		NULL_CRYPTO_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mp, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-null_crypto_pmd_session_clear(struct rte_cryptodev *dev __rte_unused,
-		void *sess)
+null_crypto_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	if (sess)
-		memset(sess, 0, sizeof(struct null_crypto_session));
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		memset(sess_priv, 0, sizeof(struct null_crypto_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 struct rte_cryptodev_ops pmd_ops = {
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 6f5937d..d943d72 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -560,23 +560,31 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 		/* get existing session */
 		if (likely(op->sym->session != NULL))
 			sess = (struct openssl_session *)
-				op->sym->session->_private;
-	} else  {
+					get_session_private_data(
+					op->sym->session,
+					cryptodev_driver_id);
+	} else {
 		/* provide internal session */
 		void *_sess = NULL;
+		void *_sess_private_data = NULL;
 
-		if (!rte_mempool_get(qp->sess_mp, (void **)&_sess)) {
-			sess = (struct openssl_session *)
-				((struct rte_cryptodev_sym_session *)_sess)
-				->_private;
-
-			if (unlikely(openssl_set_session_parameters(
-					sess, op->sym->xform) != 0)) {
-				rte_mempool_put(qp->sess_mp, _sess);
-				sess = NULL;
-			} else
-				op->sym->session = _sess;
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
+			return NULL;
+
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
+			return NULL;
+
+		sess = (struct openssl_session *)_sess_private_data;
+
+		if (unlikely(openssl_set_session_parameters(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_session_private_data(op->sym->session, cryptodev_driver_id,
+			_sess_private_data);
 	}
 
 	if (sess == NULL)
@@ -1318,6 +1326,9 @@ process_op(const struct openssl_qp *qp, struct rte_crypto_op *op,
 	if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
 		openssl_reset_session(sess);
 		memset(sess, 0, sizeof(struct openssl_session));
+		memset(op->sym->session, 0,
+				rte_cryptodev_get_header_session_size());
+		rte_mempool_put(qp->sess_mp, sess);
 		rte_mempool_put(qp->sess_mp, op->sym->session);
 		op->sym->session = NULL;
 	}
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 6093b61..1f8a011 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -668,36 +668,56 @@ openssl_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure the session from a crypto xform chain */
-static void *
+static int
 openssl_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		OPENSSL_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
 	if (openssl_set_session_parameters(
-			sess, xform) != 0) {
+			sess_private_data, xform) != 0) {
 		OPENSSL_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+			sess_private_data);
+
+	return 0;
 }
 
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-openssl_pmd_session_clear(struct rte_cryptodev *dev __rte_unused, void *sess)
+openssl_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	/*
-	 * Current just resetting the whole data structure, need to investigate
-	 * whether a more selective reset of key would be more performant
-	 */
-	if (sess) {
-		openssl_reset_session(sess);
-		memset(sess, 0, sizeof(struct openssl_session));
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		openssl_reset_session(sess_priv);
+		memset(sess_priv, 0, sizeof(struct openssl_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
 	}
 }
 
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index d0638a2..3e621c5 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -216,23 +216,23 @@ static inline int
 qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		struct qat_crypto_op_cookie *qat_op_cookie);
 
-void qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
-		void *session)
+void
+qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	struct qat_session *sess = session;
-	phys_addr_t cd_paddr;
-
 	PMD_INIT_FUNC_TRACE();
-	if (sess) {
-		if (sess->bpi_ctx) {
-			bpi_cipher_ctx_free(sess->bpi_ctx);
-			sess->bpi_ctx = NULL;
-		}
-		cd_paddr = sess->cd_paddr;
-		memset(sess, 0, qat_crypto_sym_get_session_private_size(dev));
-		sess->cd_paddr = cd_paddr;
-	} else
-		PMD_DRV_LOG(ERR, "NULL session");
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+	struct qat_session *s = (struct qat_session *)sess_priv;
+
+	if (sess_priv) {
+		if (s->bpi_ctx)
+			bpi_cipher_ctx_free(s->bpi_ctx);
+		memset(s, 0, qat_crypto_sym_get_session_private_size(dev));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 static int
@@ -450,9 +450,37 @@ qat_crypto_sym_configure_session_cipher(struct rte_cryptodev *dev,
 	return NULL;
 }
 
-
-void *
+int
 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
+{
+	void *sess_private_data;
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
+	}
+
+	if (qat_crypto_set_session_parameters(dev, xform, sess_private_data) != 0) {
+		PMD_DRV_LOG(ERR, "Crypto QAT PMD: failed to configure "
+				"session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
+	}
+
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
+}
+
+int
+qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
 		struct rte_crypto_sym_xform *xform, void *session_private)
 {
 	struct qat_session *session = session_private;
@@ -460,6 +488,10 @@ qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
 	int qat_cmd_id;
 	PMD_INIT_FUNC_TRACE();
 
+	/* Set context descriptor physical address */
+	session->cd_paddr = rte_mempool_virt2phy(NULL, session) +
+			offsetof(struct qat_session, cd);
+
 	/* Get requested QAT command id */
 	qat_cmd_id = qat_get_cmd_id(xform);
 	if (qat_cmd_id < 0 || qat_cmd_id >= ICP_QAT_FW_LA_CMD_DELIMITER) {
@@ -514,10 +546,10 @@ qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
 		goto error_out;
 	}
 
-	return session;
+	return 0;
 
 error_out:
-	return NULL;
+	return -1;
 }
 
 struct qat_session *
@@ -946,7 +978,10 @@ qat_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops,
 			rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
 		} else {
 			struct qat_session *sess = (struct qat_session *)
-						(rx_op->sym->session->_private);
+					get_session_private_data(
+					rx_op->sym->session,
+					cryptodev_qat_driver_id);
+
 			if (sess->bpi_ctx)
 				qat_bpicipher_postprocess(sess, rx_op);
 			rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
@@ -1072,7 +1107,14 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
 		return -EINVAL;
 	}
 
-	ctx = (struct qat_session *)op->sym->session->_private;
+	ctx = (struct qat_session *)get_session_private_data(
+			op->sym->session, cryptodev_qat_driver_id);
+
+	if (unlikely(ctx == NULL)) {
+		PMD_DRV_LOG(ERR, "Session was not created for this device");
+		return -EINVAL;
+	}
+
 	qat_req = (struct icp_qat_fw_la_bulk_req *)out_msg;
 	rte_mov128((uint8_t *)qat_req, (const uint8_t *)&(ctx->fw_req));
 	qat_req->comn_mid.opaque_data = (uint64_t)(uintptr_t)op;
@@ -1371,17 +1413,6 @@ static inline uint32_t adf_modulo(uint32_t data, uint32_t shift)
 	return data - mult;
 }
 
-void qat_crypto_sym_session_init(struct rte_mempool *mp, void *sym_sess)
-{
-	struct rte_cryptodev_sym_session *sess = sym_sess;
-	struct qat_session *s = (void *)sess->_private;
-
-	PMD_INIT_FUNC_TRACE();
-	s->cd_paddr = rte_mempool_virt2phy(mp, sess) +
-		offsetof(struct qat_session, cd) +
-		offsetof(struct rte_cryptodev_sym_session, _private);
-}
-
 int qat_dev_config(__rte_unused struct rte_cryptodev *dev,
 		__rte_unused struct rte_cryptodev_config *config)
 {
diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h
index 1258b6d..d9d8887 100644
--- a/drivers/crypto/qat/qat_crypto.h
+++ b/drivers/crypto/qat/qat_crypto.h
@@ -114,11 +114,15 @@ qat_pmd_session_mempool_create(struct rte_cryptodev *dev,
 extern unsigned
 qat_crypto_sym_get_session_private_size(struct rte_cryptodev *dev);
 
-extern void
-qat_crypto_sym_session_init(struct rte_mempool *mempool, void *priv_sess);
-
-extern void *
+extern int
 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool);
+
+
+int
+qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
 		struct rte_crypto_sym_xform *xform, void *session_private);
 
 struct qat_session *
@@ -136,8 +140,8 @@ qat_crypto_sym_configure_session_cipher(struct rte_cryptodev *dev,
 
 
 extern void
-qat_crypto_sym_clear_session(struct rte_cryptodev *dev, void *session);
-
+qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *session);
 
 extern uint16_t
 qat_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c
index 1c5ff77..9a710e6 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -73,7 +73,6 @@ static struct rte_cryptodev_ops crypto_qat_ops = {
 		/* Crypto related operations */
 		.session_get_size	= qat_crypto_sym_get_session_private_size,
 		.session_configure	= qat_crypto_sym_configure_session,
-		.session_initialize	= qat_crypto_sym_session_init,
 		.session_clear		= qat_crypto_sym_clear_session
 };
 
diff --git a/drivers/crypto/scheduler/scheduler_failover.c b/drivers/crypto/scheduler/scheduler_failover.c
index 162a29b..2aa13f8 100644
--- a/drivers/crypto/scheduler/scheduler_failover.c
+++ b/drivers/crypto/scheduler/scheduler_failover.c
@@ -49,57 +49,18 @@ struct fo_scheduler_qp_ctx {
 };
 
 static __rte_always_inline uint16_t
-failover_slave_enqueue(struct scheduler_slave *slave, uint8_t slave_idx,
+failover_slave_enqueue(struct scheduler_slave *slave,
 		struct rte_crypto_op **ops, uint16_t nb_ops)
 {
 	uint16_t i, processed_ops;
-	struct rte_cryptodev_sym_session *sessions[nb_ops];
-	struct scheduler_session *sess0, *sess1, *sess2, *sess3;
 
 	for (i = 0; i < nb_ops && i < 4; i++)
 		rte_prefetch0(ops[i]->sym->session);
 
-	for (i = 0; (i < (nb_ops - 8)) && (nb_ops > 8); i += 4) {
-		rte_prefetch0(ops[i + 4]->sym->session);
-		rte_prefetch0(ops[i + 5]->sym->session);
-		rte_prefetch0(ops[i + 6]->sym->session);
-		rte_prefetch0(ops[i + 7]->sym->session);
-
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
-		sessions[i] = ops[i]->sym->session;
-		sessions[i + 1] = ops[i + 1]->sym->session;
-		sessions[i + 2] = ops[i + 2]->sym->session;
-		sessions[i + 3] = ops[i + 3]->sym->session;
-
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-		ops[i + 1]->sym->session = sess1->sessions[slave_idx];
-		ops[i + 2]->sym->session = sess2->sessions[slave_idx];
-		ops[i + 3]->sym->session = sess3->sessions[slave_idx];
-	}
-
-	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sessions[i] = ops[i]->sym->session;
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-	}
-
 	processed_ops = rte_cryptodev_enqueue_burst(slave->dev_id,
 			slave->qp_id, ops, nb_ops);
 	slave->nb_inflight_cops += processed_ops;
 
-	if (unlikely(processed_ops < nb_ops))
-		for (i = processed_ops; i < nb_ops; i++)
-			ops[i]->sym->session = sessions[i];
-
 	return processed_ops;
 }
 
@@ -114,11 +75,11 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		return 0;
 
 	enqueued_ops = failover_slave_enqueue(&qp_ctx->primary_slave,
-			PRIMARY_SLAVE_IDX, ops, nb_ops);
+			ops, nb_ops);
 
 	if (enqueued_ops < nb_ops)
 		enqueued_ops += failover_slave_enqueue(&qp_ctx->secondary_slave,
-				SECONDARY_SLAVE_IDX, &ops[enqueued_ops],
+				&ops[enqueued_ops],
 				nb_ops - enqueued_ops);
 
 	return enqueued_ops;
diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
index 6b628df..1dd1bc3 100644
--- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
+++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c
@@ -67,7 +67,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	struct scheduler_qp_ctx *qp_ctx = qp;
 	struct psd_scheduler_qp_ctx *psd_qp_ctx = qp_ctx->private_qp_ctx;
 	struct rte_crypto_op *sched_ops[NB_PKT_SIZE_SLAVES][nb_ops];
-	struct scheduler_session *sess;
 	uint32_t in_flight_ops[NB_PKT_SIZE_SLAVES] = {
 			psd_qp_ctx->primary_slave.nb_inflight_cops,
 			psd_qp_ctx->secondary_slave.nb_inflight_cops
@@ -97,8 +96,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		rte_prefetch0(ops[i + 7]->sym);
 		rte_prefetch0(ops[i + 7]->sym->session);
 
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
 		/* job_len is initialized as cipher data length, once
 		 * it is 0, equals to auth data length
 		 */
@@ -118,11 +115,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i];
-		ops[i]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
 		job_len = ops[i+1]->sym->cipher.data.length;
 		job_len += (ops[i+1]->sym->cipher.data.length == 0) *
 				ops[i+1]->sym->auth.data.length;
@@ -135,11 +129,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+1];
-		ops[i+1]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
 		job_len = ops[i+2]->sym->cipher.data.length;
 		job_len += (ops[i+2]->sym->cipher.data.length == 0) *
 				ops[i+2]->sym->auth.data.length;
@@ -152,12 +143,8 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+2];
-		ops[i+2]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 
-		sess = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
 		job_len = ops[i+3]->sym->cipher.data.length;
 		job_len += (ops[i+3]->sym->cipher.data.length == 0) *
 				ops[i+3]->sym->auth.data.length;
@@ -170,14 +157,10 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i+3];
-		ops[i+3]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 	}
 
 	for (; i < nb_ops; i++) {
-		sess = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-
 		job_len = ops[i]->sym->cipher.data.length;
 		job_len += (ops[i]->sym->cipher.data.length == 0) *
 				ops[i]->sym->auth.data.length;
@@ -190,7 +173,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		}
 
 		sched_ops[p_enq_op->slave_idx][p_enq_op->pos] = ops[i];
-		ops[i]->sym->session = sess->sessions[p_enq_op->slave_idx];
 		p_enq_op->pos++;
 	}
 
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index b9d8973..c450f6a 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -85,8 +85,10 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
 /** Configure device */
 static int
 scheduler_pmd_config(struct rte_cryptodev *dev,
-		struct rte_cryptodev_config *config __rte_unused)
+		struct rte_cryptodev_config *config)
 {
+	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint32_t i;
 	int ret;
 
 	/* although scheduler_attach_init_slave presents multiple times,
@@ -96,6 +98,15 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	if (ret < 0)
 		return ret;
 
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
+
+		ret = rte_cryptodev_configure(slave_dev_id, config,
+				dev->data->session_pool);
+		if (ret < 0)
+			break;
+	}
+
 	return ret;
 }
 
@@ -474,37 +485,39 @@ scheduler_pmd_qp_count(struct rte_cryptodev *dev)
 static uint32_t
 scheduler_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 {
-	return sizeof(struct scheduler_session);
+	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint8_t i = 0;
+	uint32_t max_priv_sess_size = 0;
+
+	/* Check what is the maximum private session size for all slaves */
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
+		struct rte_cryptodev *dev = &rte_cryptodevs[slave_dev_id];
+		uint32_t priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
+
+		if (max_priv_sess_size < priv_sess_size)
+			max_priv_sess_size = priv_sess_size;
+	}
+
+	return max_priv_sess_size;
 }
 
 static int
-config_slave_sess(struct scheduler_ctx *sched_ctx,
-		struct rte_crypto_sym_xform *xform,
-		struct scheduler_session *sess,
-		uint32_t create)
+scheduler_pmd_session_configure(struct rte_cryptodev *dev,
+	struct rte_crypto_sym_xform *xform,
+	struct rte_cryptodev_sym_session *sess,
+	struct rte_mempool *mempool)
 {
+	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	uint32_t i;
 
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		struct scheduler_slave *slave = &sched_ctx->slaves[i];
 
-		if (sess->sessions[i]) {
-			if (create)
-				continue;
-			/* !create */
-			sess->sessions[i] = rte_cryptodev_sym_session_free(
-					slave->dev_id, sess->sessions[i]);
-		} else {
-			if (!create)
-				continue;
-			/* create */
-			sess->sessions[i] =
-					rte_cryptodev_sym_session_create(
-							slave->dev_id, xform);
-			if (!sess->sessions[i]) {
-				config_slave_sess(sched_ctx, NULL, sess, 0);
-				return -1;
-			}
+		if (rte_cryptodev_sym_session_init(slave->dev_id, sess,
+					xform, mempool) < 0) {
+			CS_LOG_ERR("unabled to config sym session");
+			return -1;
 		}
 	}
 
@@ -514,27 +527,17 @@ config_slave_sess(struct scheduler_ctx *sched_ctx,
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
 scheduler_pmd_session_clear(struct rte_cryptodev *dev,
-	void *sess)
+		struct rte_cryptodev_sym_session *sess)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	uint32_t i;
 
-	config_slave_sess(sched_ctx, NULL, sess, 0);
-
-	memset(sess, 0, sizeof(struct scheduler_session));
-}
-
-static void *
-scheduler_pmd_session_configure(struct rte_cryptodev *dev,
-	struct rte_crypto_sym_xform *xform, void *sess)
-{
-	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
+	/* Clear private data of slaves */
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		struct scheduler_slave *slave = &sched_ctx->slaves[i];
 
-	if (config_slave_sess(sched_ctx, xform, sess, 1) < 0) {
-		CS_LOG_ERR("unabled to config sym session");
-		return NULL;
+		rte_cryptodev_sym_session_clear(slave->dev_id, sess);
 	}
-
-	return sess;
 }
 
 struct rte_cryptodev_ops scheduler_pmd_ops = {
diff --git a/drivers/crypto/scheduler/scheduler_pmd_private.h b/drivers/crypto/scheduler/scheduler_pmd_private.h
index a78e9a6..a915ef4 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_private.h
+++ b/drivers/crypto/scheduler/scheduler_pmd_private.h
@@ -103,10 +103,6 @@ struct scheduler_qp_ctx {
 	uint32_t seqn;
 } __rte_cache_aligned;
 
-struct scheduler_session {
-	struct rte_cryptodev_sym_session *sessions[
-			RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES];
-};
 
 extern uint8_t cryptodev_driver_id;
 
diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c
index 0116276..4a84728 100644
--- a/drivers/crypto/scheduler/scheduler_roundrobin.c
+++ b/drivers/crypto/scheduler/scheduler_roundrobin.c
@@ -52,8 +52,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	uint32_t slave_idx = rr_qp_ctx->last_enq_slave_idx;
 	struct scheduler_slave *slave = &rr_qp_ctx->slaves[slave_idx];
 	uint16_t i, processed_ops;
-	struct rte_cryptodev_sym_session *sessions[nb_ops];
-	struct scheduler_session *sess0, *sess1, *sess2, *sess3;
 
 	if (unlikely(nb_ops == 0))
 		return 0;
@@ -61,39 +59,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	for (i = 0; i < nb_ops && i < 4; i++)
 		rte_prefetch0(ops[i]->sym->session);
 
-	for (i = 0; (i < (nb_ops - 8)) && (nb_ops > 8); i += 4) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sess1 = (struct scheduler_session *)
-				ops[i+1]->sym->session->_private;
-		sess2 = (struct scheduler_session *)
-				ops[i+2]->sym->session->_private;
-		sess3 = (struct scheduler_session *)
-				ops[i+3]->sym->session->_private;
-
-		sessions[i] = ops[i]->sym->session;
-		sessions[i + 1] = ops[i + 1]->sym->session;
-		sessions[i + 2] = ops[i + 2]->sym->session;
-		sessions[i + 3] = ops[i + 3]->sym->session;
-
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-		ops[i + 1]->sym->session = sess1->sessions[slave_idx];
-		ops[i + 2]->sym->session = sess2->sessions[slave_idx];
-		ops[i + 3]->sym->session = sess3->sessions[slave_idx];
-
-		rte_prefetch0(ops[i + 4]->sym->session);
-		rte_prefetch0(ops[i + 5]->sym->session);
-		rte_prefetch0(ops[i + 6]->sym->session);
-		rte_prefetch0(ops[i + 7]->sym->session);
-	}
-
-	for (; i < nb_ops; i++) {
-		sess0 = (struct scheduler_session *)
-				ops[i]->sym->session->_private;
-		sessions[i] = ops[i]->sym->session;
-		ops[i]->sym->session = sess0->sessions[slave_idx];
-	}
-
 	processed_ops = rte_cryptodev_enqueue_burst(slave->dev_id,
 			slave->qp_id, ops, nb_ops);
 
@@ -102,12 +67,6 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	rr_qp_ctx->last_enq_slave_idx += 1;
 	rr_qp_ctx->last_enq_slave_idx %= rr_qp_ctx->nb_slaves;
 
-	/* recover session if enqueue is failed */
-	if (unlikely(processed_ops < nb_ops)) {
-		for (i = processed_ops; i < nb_ops; i++)
-			ops[i]->sym->session = sessions[i];
-	}
-
 	return processed_ops;
 }
 
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index f28b8d6..107e1b4 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -163,23 +163,41 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
 static struct snow3g_session *
 snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
 {
-	struct snow3g_session *sess;
+	struct snow3g_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		sess = (struct snow3g_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct snow3g_session *)
+					get_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;
 
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct snow3g_session *)c_sess->_private;
+		sess = (struct snow3g_session *)_sess_private_data;
 
 		if (unlikely(snow3g_set_session_parameters(sess,
-				op->sym->xform) != 0))
-			return NULL;
+				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_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;
 }
 
@@ -355,6 +373,10 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		/* Free session if a session-less crypto op. */
 		if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
+			memset(session, 0, sizeof(struct snow3g_session));
+			memset(ops[i]->sym->session, 0,
+					rte_cryptodev_get_header_session_size());
+			rte_mempool_put(qp->sess_mp, session);
 			rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
 			ops[i]->sym->session = NULL;
 		}
@@ -407,7 +429,8 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
 
 	/* Free session if a session-less crypto op. */
 	if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
-		rte_mempool_put(qp->sess_mp, op->sym->session);
+		memset(op->sym->session, 0, sizeof(struct snow3g_session));
+		rte_cryptodev_sym_session_free(op->sym->session);
 		op->sym->session = NULL;
 	}
 
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index e3fa0fa..3accba5 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -290,33 +290,54 @@ snow3g_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a SNOW 3G session from a crypto xform chain */
-static void *
+static int
 snow3g_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		SNOW3G_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (snow3g_set_session_parameters(sess, xform) != 0) {
+	if (snow3g_set_session_parameters(sess_private_data, xform) != 0) {
 		SNOW3G_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-snow3g_pmd_session_clear(struct rte_cryptodev *dev __rte_unused, void *sess)
+snow3g_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	/*
-	 * Current just resetting the whole data structure, need to investigate
-	 * whether a more selective reset of key would be more performant
-	 */
-	if (sess)
-		memset(sess, 0, sizeof(struct snow3g_session));
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		memset(sess_priv, 0, sizeof(struct snow3g_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 struct rte_cryptodev_ops snow3g_pmd_ops = {
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 951f1f4..664c58f 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -162,23 +162,40 @@ zuc_set_session_parameters(struct zuc_session *sess,
 static struct zuc_session *
 zuc_get_session(struct zuc_qp *qp, struct rte_crypto_op *op)
 {
-	struct zuc_session *sess;
+	struct zuc_session *sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		sess = (struct zuc_session *)op->sym->session->_private;
-	} else  {
-		struct rte_cryptodev_sym_session *c_sess = NULL;
+		if (likely(op->sym->session != NULL))
+			sess = (struct zuc_session *)get_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;
 
-		if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
+		if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data))
 			return NULL;
 
-		sess = (struct zuc_session *)c_sess->_private;
+		sess = (struct zuc_session *)_sess_private_data;
 
 		if (unlikely(zuc_set_session_parameters(sess,
-				op->sym->xform) != 0))
-			return NULL;
+				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_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;
 }
 
@@ -337,6 +354,10 @@ process_ops(struct rte_crypto_op **ops, struct zuc_session *session,
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		/* Free session if a session-less crypto op. */
 		if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
+			memset(session, 0, sizeof(struct zuc_session));
+			memset(ops[i]->sym->session, 0,
+					rte_cryptodev_get_header_session_size());
+			rte_mempool_put(qp->sess_mp, session);
 			rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
 			ops[i]->sym->session = NULL;
 		}
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index abfa0e2..adef343 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -290,33 +290,54 @@ zuc_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 }
 
 /** Configure a ZUC session from a crypto xform chain */
-static void *
+static int
 zuc_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
-		struct rte_crypto_sym_xform *xform,	void *sess)
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_mempool *mempool)
 {
+	void *sess_private_data;
+
 	if (unlikely(sess == NULL)) {
 		ZUC_LOG_ERR("invalid session struct");
-		return NULL;
+		return -1;
+	}
+
+	if (rte_mempool_get(mempool, &sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -1;
 	}
 
-	if (zuc_set_session_parameters(sess, xform) != 0) {
+	if (zuc_set_session_parameters(sess_private_data, xform) != 0) {
 		ZUC_LOG_ERR("failed configure session parameters");
-		return NULL;
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, sess_private_data);
+		return -1;
 	}
 
-	return sess;
+	set_session_private_data(sess, dev->driver_id,
+		sess_private_data);
+
+	return 0;
 }
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
-zuc_pmd_session_clear(struct rte_cryptodev *dev __rte_unused, void *sess)
+zuc_pmd_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_sym_session *sess)
 {
-	/*
-	 * Current just resetting the whole data structure, need to investigate
-	 * whether a more selective reset of key would be more performant
-	 */
-	if (sess)
-		memset(sess, 0, sizeof(struct zuc_session));
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		memset(sess_priv, 0, sizeof(struct zuc_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
 }
 
 struct rte_cryptodev_ops zuc_pmd_ops = {
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 4d6c7ce..708eadd 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1242,8 +1242,7 @@ cryptodevs_init(void)
 
 	uint32_t max_sess_sz = 0, sess_sz;
 	for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
-		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(cdev_id);
+		sess_sz = rte_cryptodev_get_private_session_size(cdev_id);
 		if (sess_sz > max_sess_sz)
 			max_sess_sz = sess_sz;
 	}
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index f09dce9..0afb9d6 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -45,7 +45,7 @@
 #include "esp.h"
 
 static inline int
-create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
+create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa)
 {
 	struct rte_cryptodev_info cdev_info;
 	unsigned long cdev_id_qp = 0;
@@ -72,7 +72,10 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
 			ipsec_ctx->tbl[cdev_id_qp].qp);
 
 	sa->crypto_session = rte_cryptodev_sym_session_create(
-			ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
+			ipsec_ctx->session_pool);
+	rte_cryptodev_sym_session_init(ipsec_ctx->tbl[cdev_id_qp].id,
+			sa->crypto_session, sa->xforms,
+			ipsec_ctx->session_pool);
 
 	rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
 	if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 9b24e51..cba29ce 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -649,6 +649,9 @@ static struct rte_cryptodev_sym_session *
 initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
 {
 	struct rte_crypto_sym_xform *first_xform;
+	struct rte_cryptodev_sym_session *session;
+	uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+	struct rte_mempool *sess_mp = session_pool_socket[socket_id];
 
 	if (options->xform_chain == L2FWD_CRYPTO_AEAD) {
 		first_xform = &options->aead_xform;
@@ -664,7 +667,16 @@ initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
 		first_xform = &options->auth_xform;
 	}
 
-	return rte_cryptodev_sym_session_create(cdev_id, first_xform);
+	session = rte_cryptodev_sym_session_create(sess_mp);
+
+	if (session == NULL)
+		return NULL;
+
+	if (rte_cryptodev_sym_session_init(cdev_id, session,
+				first_xform, sess_mp) < 0)
+		return NULL;
+
+	return session;
 }
 
 static void
@@ -1935,8 +1947,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 	}
 
 	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
-		sess_sz = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(cdev_id);
+		sess_sz = rte_cryptodev_get_private_session_size(cdev_id);
 		if (sess_sz > max_sess_sz)
 			max_sess_sz = sess_sz;
 	}
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index dfced85..373c05b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -69,6 +69,8 @@
 #include "rte_cryptodev.h"
 #include "rte_cryptodev_pmd.h"
 
+static uint8_t nb_drivers;
+
 struct rte_cryptodev rte_crypto_devices[RTE_CRYPTO_MAX_DEVS];
 
 struct rte_cryptodev *rte_cryptodevs = &rte_crypto_devices[0];
@@ -1080,53 +1082,47 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 }
 
 
-static void
-rte_cryptodev_sym_session_init(struct rte_mempool *mp,
-		const struct rte_cryptodev *dev,
-		struct rte_cryptodev_sym_session *sess)
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+		struct rte_cryptodev_sym_session *sess,
+		struct rte_crypto_sym_xform *xforms,
+		struct rte_mempool *mp)
 {
-	memset(sess, 0, mp->elt_size);
+	struct rte_cryptodev *dev;
+	uint8_t index;
 
-	if (dev->dev_ops->session_initialize)
-		(*dev->dev_ops->session_initialize)(mp, sess);
-}
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
 
+	if (sess == NULL || xforms == NULL || dev == NULL)
+		return -1;
 
-struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform)
-{
-	struct rte_cryptodev *dev;
-	struct rte_cryptodev_sym_session *sess;
-	void *_sess;
+	index = dev->driver_id;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return NULL;
+	if (sess->sess_private_data[index] == NULL) {
+		if (dev->dev_ops->session_configure(dev, xforms, sess, mp) < 0) {
+			CDEV_LOG_ERR(
+				"dev_id %d failed to configure session details",
+				dev_id);
+			return -1;
+		}
 	}
 
-	dev = &rte_crypto_devices[dev_id];
+	return 0;
+}
+
+struct rte_cryptodev_sym_session *
+rte_cryptodev_sym_session_create(struct rte_mempool *mp)
+{
+	struct rte_cryptodev_sym_session *sess;
 
 	/* Allocate a session structure from the session pool */
-	if (rte_mempool_get(dev->data->session_pool, &_sess)) {
-		CDEV_LOG_ERR("Couldn't get object from session mempool");
+	if (rte_mempool_get(mp, (void *)&sess)) {
+		CDEV_LOG_ERR("couldn't get object from session mempool");
 		return NULL;
 	}
 
-	sess = _sess;
-
-	rte_cryptodev_sym_session_init(dev->data->session_pool, dev,
-					sess);
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL);
-	if (dev->dev_ops->session_configure(dev, xform, sess->_private) ==
-			NULL) {
-		CDEV_LOG_ERR("dev_id %d failed to configure session details",
-				dev_id);
-
-		/* Return session to mempool */
-		rte_mempool_put(dev->data->session_pool, _sess);
-		return NULL;
-	}
+	/* Clear device session pointer */
+	memset(sess, 0, (sizeof(void *) * nb_drivers));
 
 	return sess;
 }
@@ -1146,7 +1142,10 @@ rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0);
-	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) {
+
+	void *sess_priv = get_session_private_data(sess, dev->driver_id);
+
+	if (dev->dev_ops->qp_attach_session(dev, qp_id, sess_priv)) {
 		CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session",
 				dev_id, qp_id);
 		return -EPERM;
@@ -1170,7 +1169,10 @@ rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	/* The API is optional, not returning error if driver do not suuport */
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0);
-	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) {
+
+	void *sess_priv = get_session_private_data(sess, dev->driver_id);
+
+	if (dev->dev_ops->qp_detach_session(dev, qp_id, sess_priv)) {
 		CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session",
 				dev_id, qp_id);
 		return -EPERM;
@@ -1178,34 +1180,62 @@ rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
 
 	return 0;
 }
-struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
+
+int
+rte_cryptodev_sym_session_clear(uint8_t dev_id,
 		struct rte_cryptodev_sym_session *sess)
 {
 	struct rte_cryptodev *dev;
 
-	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
-		CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
-		return sess;
-	}
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
 
-	dev = &rte_crypto_devices[dev_id];
+	if (dev == NULL || sess == NULL)
+		return -EINVAL;
+
+	dev->dev_ops->session_clear(dev, sess);
 
-	/* Let device implementation clear session material */
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_clear, sess);
-	dev->dev_ops->session_clear(dev, (void *)sess->_private);
+	return 0;
+}
+
+int
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess)
+{
+	uint8_t i;
+	void *sess_priv;
+	struct rte_mempool *sess_mp;
+
+	if (sess == NULL)
+		return -EINVAL;
+
+	/* Check that all device private data has been freed */
+	for (i = 0; i < nb_drivers; i++) {
+		sess_priv = get_session_private_data(sess, i);
+		if (sess_priv != NULL)
+			return -EBUSY;
+	}
 
 	/* Return session to mempool */
-	struct rte_mempool *mp = rte_mempool_from_obj(sess);
-	rte_mempool_put(mp, (void *)sess);
+	sess_mp = rte_mempool_from_obj(sess);
+	rte_mempool_put(sess_mp, sess);
 
-	return NULL;
+	return 0;
+}
+
+unsigned int
+rte_cryptodev_get_header_session_size(void)
+{
+	/*
+	 * Header contains pointers to the private data
+	 * of all registered drivers
+	 */
+	return (sizeof(void *) * nb_drivers);
 }
 
 unsigned int
 rte_cryptodev_get_private_session_size(uint8_t dev_id)
 {
 	struct rte_cryptodev *dev;
+	unsigned int header_size = sizeof(void *) * nb_drivers;
 	unsigned int priv_sess_size;
 
 	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
@@ -1218,6 +1248,14 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id)
 
 	priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
 
+	/*
+	 * If size is less than session header size,
+	 * return the latter, as this guarantees that
+	 * sessionless operations will work
+	 */
+	if (priv_sess_size < header_size)
+		return header_size;
+
 	return priv_sess_size;
 
 }
@@ -1333,8 +1371,6 @@ struct cryptodev_driver {
 	uint8_t id;
 };
 
-static uint8_t nb_drivers;
-
 int
 rte_cryptodev_driver_id_get(const char *name)
 {
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 508c672..3ba3efb 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -883,50 +883,80 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 /** Cryptodev symmetric crypto session */
 struct rte_cryptodev_sym_session {
 	RTE_STD_C11
-	__extension__ char _private[0];
+	__extension__ void *sess_private_data[0];
 	/**< Private session material */
 };
 
 
 /**
- * Initialise a session for symmetric cryptographic operations.
+ * Create symmetric crypto session header (generic with no private data)
  *
- * This function is used by the client to initialize immutable
- * parameters of symmetric cryptographic operation.
- * To perform the operation the rte_cryptodev_enqueue_burst function is
- * used.  Each mbuf should contain a reference to the session
- * pointer returned from this function contained within it's crypto_op if a
- * session-based operation is being provisioned. Memory to contain the session
- * information is allocated from within mempool managed by the cryptodev.
+ * @param   mempool    Symmetric session mempool to allocate session
+ *                     objects from
+ * @return
+ *  - On success return pointer to sym-session
+ *  - On failure returns NULL
+ */
+struct rte_cryptodev_sym_session *
+rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
+
+/**
+ * Frees symmetric crypto session header, after checking that all
+ * the device private data has been freed, returning it
+ * to its original mempool.
  *
- * The rte_cryptodev_session_free must be called to free allocated
- * memory when the session is no longer required.
+ * @param   sess     Session header to be freed.
  *
- * @param	dev_id		The device identifier.
- * @param	xform		Crypto transform chain.
+ * @return
+ *  - 0 if successful.
+ *  - -EINVAL if session is NULL.
+ *  - -EBUSY if not all device private data has been freed.
+ */
+int
+rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
 
+/**
+ * Fill out private data for the device id, based on its device type.
+ *
+ * @param   dev_id   ID of device that we want the session to be used on
+ * @param   sess     Session where the private data will be attached to
+ * @param   xforms   Symmetric crypto transform operations to apply on flow
+ *                   processed with this session
+ * @param   mempool  Mempool where the private data is allocated.
  *
  * @return
- *  Pointer to the created session or NULL
+ *  - On success, zero.
+ *  - On failure, a negative value.
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_create(uint8_t dev_id,
-		struct rte_crypto_sym_xform *xform);
+int
+rte_cryptodev_sym_session_init(uint8_t dev_id,
+			struct rte_cryptodev_sym_session *sess,
+			struct rte_crypto_sym_xform *xforms,
+			struct rte_mempool *mempool);
 
 /**
- * Free the memory associated with a previously allocated session.
+ * Frees private data for the device id, based on its device type,
+ * returning it to its mempool.
  *
- * @param	dev_id		The device identifier.
- * @param	session		Session pointer previously allocated by
- *				*rte_cryptodev_sym_session_create*.
+ * @param   dev_id   ID of device that uses the session.
+ * @param   sess     Session containing the reference to the private data
  *
  * @return
- *   NULL on successful freeing of session.
- *   Session pointer on failure to free session.
+ *  - 0 if successful.
+ *  - -EINVAL if device is invalid or session is NULL.
  */
-extern struct rte_cryptodev_sym_session *
-rte_cryptodev_sym_session_free(uint8_t dev_id,
-		struct rte_cryptodev_sym_session *session);
+int
+rte_cryptodev_sym_session_clear(uint8_t dev_id,
+			struct rte_cryptodev_sym_session *sess);
+
+/**
+ * Get the size of the header session, for all registered drivers.
+ *
+ * @return
+ *   Size of the header session.
+ */
+unsigned int
+rte_cryptodev_get_header_session_size(void);
 
 /**
  * Get the size of the private session data for a device.
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 5911b83..2896171 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -285,20 +285,25 @@ typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
  * @param	dev		Crypto device pointer
  * @param	xform		Single or chain of crypto xforms
  * @param	priv_sess	Pointer to cryptodev's private session structure
+ * @param	mp		Mempool where the private session is allocated
  *
  * @return
- *  - Returns private session structure on success.
- *  - Returns NULL on failure.
+ *  - Returns 0 if private session structure have been created successfully.
+ *  - Returns -1 on failure.
  */
-typedef void * (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
-		struct rte_crypto_sym_xform *xform, void *session_private);
+typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
+		struct rte_crypto_sym_xform *xform,
+		struct rte_cryptodev_sym_session *session,
+		struct rte_mempool *mp);
 
 /**
- * Free Crypto session.
- * @param	session		Cryptodev session structure to free
+ * Free driver private session data.
+ *
+ * @param	dev		Crypto device pointer
+ * @param	sess		Cryptodev session structure
  */
 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
-		void *session_private);
+		struct rte_cryptodev_sym_session *sess);
 
 /**
  * Optional API for drivers to attach sessions with queue pair.
@@ -413,6 +418,19 @@ void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 int
 rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
 
+static inline void *
+get_session_private_data(const struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id) {
+	return sess->sess_private_data[driver_id];
+}
+
+static inline void
+set_session_private_data(struct rte_cryptodev_sym_session *sess,
+		uint8_t driver_id, void *private_data)
+{
+	sess->sess_private_data[driver_id] = private_data;
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index d817421..e9ba88a 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -66,10 +66,13 @@ DPDK_17.08 {
 	rte_cryptodev_driver_id_get;
 	rte_cryptodev_driver_name_get;
 	rte_cryptodev_get_aead_algo_enum;
+	rte_cryptodev_get_header_session_size;
 	rte_cryptodev_get_private_session_size;
 	rte_cryptodev_pci_generic_probe;
 	rte_cryptodev_pci_generic_remove;
 	rte_cryptodev_sym_capability_check_aead;
+	rte_cryptodev_sym_session_init;
+	rte_cryptodev_sym_session_clear;
 	rte_cryptodev_vdev_parse_init_params;
 	rte_cryptodev_vdev_pmd_init;
 	rte_crypto_aead_algorithm_strings;
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index e5d6c07..745f261 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -68,7 +68,6 @@ struct crypto_testsuite_params {
 	struct rte_mempool *large_mbuf_pool;
 	struct rte_mempool *op_mpool;
 	struct rte_mempool *session_mpool;
-	struct rte_mempool *slave_session_mpool;
 	struct rte_cryptodev_config conf;
 	struct rte_cryptodev_qp_conf qp_conf;
 
@@ -387,12 +386,15 @@ testsuite_setup(void)
 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
 
-	unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-		rte_cryptodev_get_private_session_size(dev_id);
+	unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
 
+	/*
+	 * Create mempool with maximum number of sessions * 2,
+	 * to include the session headers
+	 */
 	ts_params->session_mpool = rte_mempool_create(
 				"test_sess_mp",
-				info.sym.max_nb_sessions,
+				info.sym.max_nb_sessions * 2,
 				session_size,
 				0, 0, NULL, NULL, NULL,
 				NULL, SOCKET_ID_ANY,
@@ -439,11 +441,6 @@ testsuite_teardown(void)
 		rte_mempool_free(ts_params->session_mpool);
 		ts_params->session_mpool = NULL;
 	}
-
-	if (ts_params->slave_session_mpool != NULL) {
-		rte_mempool_free(ts_params->slave_session_mpool);
-		ts_params->slave_session_mpool = NULL;
-	}
 }
 
 static int
@@ -494,8 +491,9 @@ ut_teardown(void)
 
 	/* free crypto session structure */
 	if (ut_params->sess) {
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
+		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
 				ut_params->sess);
+		rte_cryptodev_sym_session_free(ut_params->sess);
 		ut_params->sess = NULL;
 	}
 
@@ -1280,10 +1278,13 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
 
-	/* Create crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0],
-			&ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate crypto op data structure */
@@ -1496,7 +1497,9 @@ test_AES_cipheronly_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1513,7 +1516,9 @@ test_AES_docsis_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1530,7 +1535,9 @@ test_AES_docsis_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1547,7 +1554,9 @@ test_DES_docsis_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_DES_DOCSIS_TYPE);
@@ -1564,7 +1573,9 @@ test_authonly_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1581,7 +1592,9 @@ test_AES_chain_mb_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1600,7 +1613,9 @@ test_AES_cipheronly_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1617,7 +1632,9 @@ test_AES_chain_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1634,7 +1651,9 @@ test_authonly_scheduler_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1653,7 +1672,9 @@ test_AES_chain_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1670,7 +1691,9 @@ test_AES_cipheronly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1687,7 +1710,9 @@ test_AES_chain_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1704,7 +1729,9 @@ test_AES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1721,7 +1748,9 @@ test_AES_chain_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1738,7 +1767,9 @@ test_AES_cipheronly_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1755,7 +1786,9 @@ test_authonly_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(RTE_CRYPTODEV_DPAA2_SEC_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1772,7 +1805,9 @@ test_authonly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_AUTHONLY_TYPE);
@@ -1789,7 +1824,9 @@ test_AES_chain_armv8_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
 		BLKCIPHER_AES_CHAIN_TYPE);
@@ -1809,6 +1846,7 @@ create_wireless_algo_hash_session(uint8_t dev_id,
 {
 	uint8_t hash_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(hash_key, key, key_len);
@@ -1826,8 +1864,11 @@ create_wireless_algo_hash_session(uint8_t dev_id,
 	ut_params->auth_xform.auth.digest_length = auth_len;
 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
 	ut_params->auth_xform.auth.iv.length = iv_len;
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->auth_xform, ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
 }
@@ -1841,6 +1882,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
 {
 	uint8_t cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_key, key, key_len);
@@ -1859,9 +1901,11 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session */
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-						&ut_params->
-						cipher_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->cipher_xform, ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
 }
@@ -1940,6 +1984,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
 {
 	uint8_t cipher_auth_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(cipher_auth_key, key, key_len);
@@ -1972,8 +2017,11 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->cipher_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
@@ -1990,6 +2038,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
 	const uint8_t key_len = tdata->key.len;
 	uint8_t cipher_auth_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 	const uint8_t *key = tdata->key.data;
 	const uint8_t auth_len = tdata->digest.len;
@@ -2027,8 +2076,11 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->cipher_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->cipher_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 	return 0;
@@ -2056,6 +2108,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
 {
 	uint8_t auth_cipher_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(auth_cipher_key, key, key_len);
@@ -2085,8 +2138,11 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->auth_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -4536,7 +4592,9 @@ test_3DES_chain_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4553,7 +4611,9 @@ test_DES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_DES_CIPHERONLY_TYPE);
@@ -4570,7 +4630,9 @@ test_DES_docsis_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_DES_DOCSIS_TYPE);
@@ -4587,7 +4649,9 @@ test_3DES_chain_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4604,7 +4668,9 @@ test_3DES_cipheronly_dpaa2_sec_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4621,7 +4687,9 @@ test_3DES_cipheronly_qat_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4638,7 +4706,9 @@ test_3DES_chain_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4655,7 +4725,9 @@ test_3DES_cipheronly_openssl_all(void)
 	int status;
 
 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
-		ts_params->op_mpool, ts_params->valid_devs[0],
+		ts_params->op_mpool,
+		ts_params->session_mpool,
+		ts_params->valid_devs[0],
 		rte_cryptodev_driver_id_get(
 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4675,6 +4747,7 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
 {
 	uint8_t aead_key[key_len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(aead_key, key, key_len);
@@ -4694,8 +4767,11 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
 	TEST_HEXDUMP(stdout, "key:", key, key_len);
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-			&ut_params->aead_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->aead_xform, ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -5656,7 +5732,11 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
 	ut_params->auth_xform.auth.key.data = key;
 
 	ut_params->sess = rte_cryptodev_sym_session_create(
-		ts_params->valid_devs[0], &ut_params->auth_xform);
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
 
 	if (ut_params->sess == NULL)
 		return TEST_FAILED;
@@ -5831,9 +5911,13 @@ test_multi_session(void)
 
 	/* Create multiple crypto sessions*/
 	for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
+
 		sessions[i] = rte_cryptodev_sym_session_create(
-				ts_params->valid_devs[0],
-			&ut_params->auth_xform);
+				ts_params->session_mpool);
+
+		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+				sessions[i], &ut_params->auth_xform,
+				ts_params->session_mpool);
 		TEST_ASSERT_NOT_NULL(sessions[i],
 				"Session creation failed at session number %u",
 				i);
@@ -5869,14 +5953,17 @@ test_multi_session(void)
 	}
 
 	/* Next session create should fail */
-	sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
-			&ut_params->auth_xform);
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			sessions[i], &ut_params->auth_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NULL(sessions[i],
 			"Session creation succeeded unexpectedly!");
 
-	for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
+	for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
+		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
 				sessions[i]);
+		rte_cryptodev_sym_session_free(sessions[i]);
+	}
 
 	rte_free(sessions);
 
@@ -5934,6 +6021,9 @@ test_multi_session_random_usage(void)
 					* dev_info.sym.max_nb_sessions) + 1, 0);
 
 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
+		sessions[i] = rte_cryptodev_sym_session_create(
+				ts_params->session_mpool);
+
 		rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
 				sizeof(struct crypto_unittest_params));
 
@@ -5942,9 +6032,11 @@ test_multi_session_random_usage(void)
 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
 
 		/* Create multiple crypto sessions*/
-		sessions[i] = rte_cryptodev_sym_session_create(
+		rte_cryptodev_sym_session_init(
 				ts_params->valid_devs[0],
-				&ut_paramz[i].ut_params.auth_xform);
+				sessions[i],
+				&ut_paramz[i].ut_params.auth_xform,
+				ts_params->session_mpool);
 
 		TEST_ASSERT_NOT_NULL(sessions[i],
 				"Session creation failed at session number %u",
@@ -5987,9 +6079,11 @@ test_multi_session_random_usage(void)
 		}
 	}
 
-	for (i = 0; i < MB_SESSION_NUMBER; i++)
-		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
+	for (i = 0; i < MB_SESSION_NUMBER; i++) {
+		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
 				sessions[i]);
+		rte_cryptodev_sym_session_free(sessions[i]);
+	}
 
 	rte_free(sessions);
 
@@ -6013,9 +6107,14 @@ test_null_cipher_only_operation(void)
 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+				ut_params->sess,
+				&ut_params->cipher_xform,
+				ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6070,9 +6169,13 @@ test_null_auth_only_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->auth_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6126,9 +6229,13 @@ test_null_cipher_auth_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6192,9 +6299,13 @@ test_null_auth_cipher_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	/* Generate Crypto op data structure */
@@ -6240,6 +6351,7 @@ test_null_invalid_operation(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
+	int ret;
 
 	/* Setup Cipher Parameters */
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@@ -6248,10 +6360,14 @@ test_null_invalid_operation(void)
 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
-	TEST_ASSERT_NULL(ut_params->sess,
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
+	TEST_ASSERT(ret == -1,
 			"Session creation succeeded unexpectedly");
 
 
@@ -6262,10 +6378,14 @@ test_null_invalid_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->auth_xform);
-	TEST_ASSERT_NULL(ut_params->sess,
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->auth_xform,
+			ts_params->session_mpool);
+	TEST_ASSERT(ret == -1,
 			"Session creation succeeded unexpectedly");
 
 	return TEST_SUCCESS;
@@ -6299,9 +6419,13 @@ test_null_burst_operation(void)
 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
 
-	/* Create Crypto session*/
 	ut_params->sess = rte_cryptodev_sym_session_create(
-			ts_params->valid_devs[0], &ut_params->cipher_xform);
+			ts_params->session_mpool);
+
+	/* Create Crypto session*/
+	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+			ut_params->sess, &ut_params->cipher_xform,
+			ts_params->session_mpool);
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
@@ -6414,6 +6538,7 @@ static int create_gmac_session(uint8_t dev_id,
 {
 	uint8_t auth_key[tdata->key.len];
 
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
 	memcpy(auth_key, tdata->key.data, tdata->key.len);
@@ -6430,8 +6555,12 @@ static int create_gmac_session(uint8_t dev_id,
 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
 
 
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-			&ut_params->auth_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+			&ut_params->auth_xform,
+			ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -6791,6 +6920,7 @@ create_auth_session(struct crypto_unittest_params *ut_params,
 		const struct test_crypto_vector *reference,
 		enum rte_crypto_auth_operation auth_op)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t auth_key[reference->auth_key.len + 1];
 
 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
@@ -6805,8 +6935,12 @@ create_auth_session(struct crypto_unittest_params *ut_params,
 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform,
+				ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -6820,6 +6954,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
 		enum rte_crypto_auth_operation auth_op,
 		enum rte_crypto_cipher_operation cipher_op)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t cipher_key[reference->cipher_key.len + 1];
 	uint8_t auth_key[reference->auth_key.len + 1];
 
@@ -6853,8 +6988,12 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
 	}
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
+	ut_params->sess = rte_cryptodev_sym_session_create(
+			ts_params->session_mpool);
+
+	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+				&ut_params->auth_xform,
+				ts_params->session_mpool);
 
 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
 
@@ -7710,30 +7849,32 @@ test_scheduler_attach_slave_op(void)
 			continue;
 
 		/*
-		 * Create a separate mempool for the slaves, as they need different
-		 * session size and then configure them to store the pointer
-		 * to this mempool
+		 * Create the session mempool again, since now there are new devices
+		 * to use the mempool.
 		 */
-		unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
-			rte_cryptodev_get_private_session_size(i);
+		if (ts_params->session_mpool) {
+			rte_mempool_free(ts_params->session_mpool);
+			ts_params->session_mpool = NULL;
+		}
+		unsigned int session_size = rte_cryptodev_get_private_session_size(i);
 
-		if (ts_params->slave_session_mpool == NULL) {
-			ts_params->slave_session_mpool = rte_mempool_create(
-				"test_slave_sess_mp",
-				info.sym.max_nb_sessions,
-				session_size,
-				0, 0, NULL, NULL, NULL, NULL,
-				SOCKET_ID_ANY, 0);
+		/*
+		 * Create mempool with maximum number of sessions * 2,
+		 * to include the session headers
+		 */
+		if (ts_params->session_mpool == NULL) {
+			ts_params->session_mpool = rte_mempool_create(
+					"test_sess_mp",
+					info.sym.max_nb_sessions * 2,
+					session_size,
+					0, 0, NULL, NULL, NULL,
+					NULL, SOCKET_ID_ANY,
+					0);
 
-			TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
+			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
 					"session mempool allocation failed");
 		}
 
-		TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
-				&ts_params->conf, ts_params->slave_session_mpool),
-				"Failed to configure cryptodev %u with %u qps",
-				i, ts_params->conf.nb_queue_pairs);
-
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
diff --git a/test/test/test_cryptodev_blockcipher.c b/test/test/test_cryptodev_blockcipher.c
index 0b512c2..e822c96 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -53,6 +53,7 @@ static int
 test_blockcipher_one_case(const struct blockcipher_test_case *t,
 	struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	char *test_msg)
@@ -65,8 +66,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 	struct rte_crypto_sym_xform *init_xform = NULL;
 	struct rte_crypto_sym_op *sym_op = NULL;
 	struct rte_crypto_op *op = NULL;
-	struct rte_cryptodev_sym_session *sess = NULL;
 	struct rte_cryptodev_info dev_info;
+	struct rte_cryptodev_sym_session *sess = NULL;
 
 	int status = TEST_SUCCESS;
 	const struct blockcipher_test_data *tdata = t->test_data;
@@ -340,8 +341,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 
 	/* create session for sessioned op */
 	if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
-		sess = rte_cryptodev_sym_session_create(dev_id,
-			init_xform);
+		sess = rte_cryptodev_sym_session_create(sess_mpool);
+
+		rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
+				sess_mpool);
 		if (!sess) {
 			snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
 				"FAILED: %s", __LINE__,
@@ -561,8 +564,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 
 error_exit:
 	if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
-		if (sess)
-			rte_cryptodev_sym_session_free(dev_id, sess);
+		if (sess) {
+			rte_cryptodev_sym_session_clear(dev_id, sess);
+			rte_cryptodev_sym_session_free(sess);
+		}
 		if (cipher_xform)
 			rte_free(cipher_xform);
 		if (auth_xform)
@@ -584,6 +589,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 int
 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	enum blockcipher_test_type test_type)
@@ -675,7 +681,7 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 			continue;
 
 		status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
-			dev_id, driver_id, test_msg);
+			sess_mpool, dev_id, driver_id, test_msg);
 
 		printf("  %u) TestCase %s %s\n", test_index ++,
 			tc->test_descr, test_msg);
diff --git a/test/test/test_cryptodev_blockcipher.h b/test/test/test_cryptodev_blockcipher.h
index 22fb420..22b8d20 100644
--- a/test/test/test_cryptodev_blockcipher.h
+++ b/test/test/test_cryptodev_blockcipher.h
@@ -125,6 +125,7 @@ struct blockcipher_test_data {
 int
 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 	struct rte_mempool *op_mpool,
+	struct rte_mempool *sess_mpool,
 	uint8_t dev_id,
 	int driver_id,
 	enum blockcipher_test_type test_type);
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 9caba87..e21f5e7 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -108,6 +108,8 @@ struct symmetric_session_attrs {
 	uint32_t digest_len;
 };
 
+static struct rte_cryptodev_sym_session *test_crypto_session;
+
 #define ALIGN_POW2_ROUNDUP(num, align) \
 	(((num) + (align) - 1) & ~((align) - 1))
 
@@ -156,18 +158,18 @@ struct crypto_unittest_params {
 	uint8_t *digest;
 };
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo);
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo,
 		enum rte_crypto_aead_algorithm aead_algo);
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
@@ -487,9 +489,11 @@ ut_teardown(void)
 	unsigned i;
 
 	/* free crypto session structure */
-	if (ut_params->sess)
-		rte_cryptodev_sym_session_free(ts_params->dev_id,
+	if (ut_params->sess) {
+		rte_cryptodev_sym_session_clear(ts_params->dev_id,
 				ut_params->sess);
+		rte_cryptodev_sym_session_free(ut_params->sess);
+	}
 
 	/* free crypto operation structure */
 	if (ut_params->op)
@@ -1969,10 +1973,13 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
 
 	/* Create Crypto session*/
-	ut_params->sess = rte_cryptodev_sym_session_create(ts_params->dev_id,
-		&ut_params->cipher_xform);
 
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
+	rte_cryptodev_sym_session_init(ts_params->dev_id, test_crypto_session,
+			&ut_params->cipher_xform, ts_params->sess_mp);
+
+	TEST_ASSERT_NOT_NULL(test_crypto_session, "Session creation failed");
 
 	/* Generate Crypto op data structure(s) */
 	for (i = 0; i < num_to_submit ; i++) {
@@ -1994,7 +2001,7 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
 				rte_crypto_op_alloc(ts_params->op_mpool,
 						RTE_CRYPTO_OP_TYPE_SYMMETRIC);
 
-		rte_crypto_op_attach_sym_session(op, ut_params->sess);
+		rte_crypto_op_attach_sym_session(op, test_crypto_session);
 
 		op->sym->auth.digest.data = ut_params->digest;
 		op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
@@ -2105,9 +2112,12 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_snow3g_session(ts_params->dev_id,
+	if (test_perf_create_snow3g_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->key_length, pparams->auth_algo);
+			pparams->key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2211,7 +2221,10 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
 		rte_pktmbuf_free(c_ops[i]->sym->m_src);
 		rte_crypto_op_free(c_ops[i]);
 	}
-	rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+
+	rte_cryptodev_sym_session_clear(ts_params->dev_id,
+				sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return TEST_SUCCESS;
 }
@@ -2290,10 +2303,13 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_openssl_session(ts_params->dev_id,
+	if (test_perf_create_openssl_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
 			pparams->key_length, pparams->auth_algo,
-			pparams->aead_algo);
+			pparams->aead_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate Crypto op data structure(s)*/
@@ -2425,7 +2441,9 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
 		rte_pktmbuf_free(c_ops[i]->sym->m_src);
 		rte_crypto_op_free(c_ops[i]);
 	}
-	rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+
+	rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return TEST_SUCCESS;
 }
@@ -2452,10 +2470,12 @@ test_perf_armv8_optimise_cyclecount(struct perf_test_params *pparams)
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_armv8_session(ts_params->dev_id,
+	if (test_perf_create_armv8_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->key_length, pparams->auth_algo);
-	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
+			pparams->key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 
 	/* Generate Crypto op data structure(s)*/
 	for (i = 0; i < num_to_submit ; i++) {
@@ -2672,12 +2692,13 @@ static uint8_t snow3g_hash_key[] = {
 		0x1E, 0x26, 0x98, 0xD2, 0xE2, 0x2A, 0xD5, 0x7E
 };
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2701,33 +2722,42 @@ test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
 		auth_xform.auth.digest_length =
 					get_auth_digest_length(auth_algo);
 	}
+
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	case CIPHER_ONLY:
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
 #define SNOW3G_CIPHER_IV_LENGTH 16
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo, unsigned cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = {0};
 	struct rte_crypto_sym_xform auth_xform = {0};
 
@@ -2755,37 +2785,47 @@ test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
 	auth_xform.auth.iv.offset = IV_OFFSET + SNOW3G_CIPHER_IV_LENGTH;
 	auth_xform.auth.iv.length = SNOW3G_CIPHER_IV_LENGTH;
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	case CIPHER_ONLY:
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_ONLY:
 		auth_xform.next = NULL;
 		/* Create Crypto session */
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int key_len,
 		enum rte_crypto_auth_algorithm auth_algo,
 		enum rte_crypto_aead_algorithm aead_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 	struct rte_crypto_sym_xform aead_xform = { 0 };
@@ -2809,7 +2849,7 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 			cipher_xform.cipher.iv.length = AES_CIPHER_IV_LENGTH;
 			break;
 		default:
-			return NULL;
+			return -1;
 		}
 
 		cipher_xform.cipher.key.length = key_len;
@@ -2824,7 +2864,7 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 			auth_xform.auth.key.data = hmac_sha_key;
 			break;
 		default:
-			return NULL;
+			return -1;
 		}
 
 		auth_xform.auth.key.length =  get_auth_key_max_length(auth_algo);
@@ -2844,37 +2884,45 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 			aead_xform.aead.digest_length = get_aead_digest_length(aead_algo);
 			break;
 		default:
-			return NULL;
+			return -1;
 		}
 
 		aead_xform.aead.key.length = key_len;
 	}
 
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
 		auth_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	case AEAD:
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&aead_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &aead_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
-static struct rte_cryptodev_sym_session *
+static int
 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		enum rte_crypto_cipher_algorithm cipher_algo,
 		unsigned int cipher_key_len,
 		enum rte_crypto_auth_algorithm auth_algo)
 {
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform cipher_xform = { 0 };
 	struct rte_crypto_sym_xform auth_xform = { 0 };
 
@@ -2887,7 +2935,7 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		cipher_xform.cipher.key.data = aes_cbc_128_key;
 		break;
 	default:
-		return NULL;
+		return -1;
 	}
 
 	cipher_xform.cipher.key.length = cipher_key_len;
@@ -2901,6 +2949,8 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 
 	auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
 
+	rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
 	switch (chain) {
 	case CIPHER_HASH:
 		cipher_xform.next = &auth_xform;
@@ -2908,16 +2958,20 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
 		/* Encrypt and hash the result */
 		cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&cipher_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &cipher_xform,
+				ts_params->sess_mp);
 	case HASH_CIPHER:
 		auth_xform.next = &cipher_xform;
 		cipher_xform.next = NULL;
 		/* Hash encrypted message and decrypt */
 		cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
 		/* Create Crypto session*/
-		return rte_cryptodev_sym_session_create(dev_id,	&auth_xform);
+		return rte_cryptodev_sym_session_init(dev_id,
+				test_crypto_session, &auth_xform,
+				ts_params->sess_mp);
 	default:
-		return NULL;
+		return -1;
 	}
 }
 
@@ -3167,9 +3221,12 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_aes_sha_session(ts_params->dev_id,
+	if (test_perf_create_aes_sha_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->key_length, pparams->auth_algo);
+			pparams->key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3264,7 +3321,9 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+
+	rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3300,9 +3359,12 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_snow3g_session(ts_params->dev_id,
+	if (test_perf_create_snow3g_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->key_length, pparams->auth_algo);
+			pparams->key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3429,7 +3491,9 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+
+	rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3486,10 +3550,13 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_openssl_session(ts_params->dev_id,
+	if (test_perf_create_openssl_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
 			pparams->key_length, pparams->auth_algo,
-			pparams->aead_algo);
+			pparams->aead_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -3582,7 +3649,9 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+
+	rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	printf("\n");
 	return TEST_SUCCESS;
@@ -3617,9 +3686,12 @@ test_perf_armv8(uint8_t dev_id, uint16_t queue_id,
 	}
 
 	/* Create Crypto session*/
-	sess = test_perf_create_armv8_session(ts_params->dev_id,
+	if (test_perf_create_armv8_session(ts_params->dev_id,
 			pparams->chain, pparams->cipher_algo,
-			pparams->key_length, pparams->auth_algo);
+			pparams->key_length, pparams->auth_algo) == 0)
+		sess = test_crypto_session;
+	else
+		sess = NULL;
 	TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
 
 	/* Generate a burst of crypto operations */
@@ -4177,7 +4249,7 @@ test_perf_aes_cbc_vary_burst_size(void)
 static struct rte_cryptodev_sym_session *
 test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
 {
-	static struct rte_cryptodev_sym_session *sess;
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_crypto_sym_xform aead_xform = { 0 };
 
 	uint8_t aead_key[pparams->session_attrs->key_aead_len];
@@ -4197,9 +4269,12 @@ test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
 	aead_xform.aead.add_auth_data_length = pparams->session_attrs->aad_len;
 	aead_xform.aead.digest_length = pparams->session_attrs->digest_len;
 
-	sess = rte_cryptodev_sym_session_create(dev_id,	&aead_xform);
+	test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
+	rte_cryptodev_sym_session_init(dev_id, test_crypto_session,
+				&aead_xform, ts_params->sess_mp);
 
-	return sess;
+	return test_crypto_session;
 }
 
 static inline struct rte_crypto_op *
@@ -4418,7 +4493,9 @@ perf_AES_GCM(uint8_t dev_id, uint16_t queue_id,
 
 	for (i = 0; i < burst; i++)
 		rte_pktmbuf_free(mbufs[i]);
-	rte_cryptodev_sym_session_free(dev_id, sess);
+
+	rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+	rte_cryptodev_sym_session_free(sess);
 
 	return 0;
 }
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 10/12] cryptodev: add mempool pointer in queue pair setup
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (8 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 09/12] cryptodev: support device independent sessions Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 11/12] cryptodev: remove session init internal function Pablo de Lara
                         ` (4 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

The session mempool pointer is needed in each queue pair,
if session-less operations are being handled.
Therefore, the API is changed to accept this parameter,
as the session mempool is created outside the
device configuration function, similar to what ethdev
does with the rx queues.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/main.c                    | 18 ++++----
 doc/guides/rel_notes/release_17_08.rst         |  1 +
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c   |  4 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c |  4 +-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c       |  4 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c    |  3 +-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c     |  4 +-
 drivers/crypto/null/null_crypto_pmd_ops.c      |  4 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c   |  4 +-
 drivers/crypto/qat/qat_crypto.h                |  3 +-
 drivers/crypto/qat/qat_qp.c                    |  2 +-
 drivers/crypto/scheduler/scheduler_pmd_ops.c   | 13 ++++--
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c     |  4 +-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c           |  4 +-
 examples/ipsec-secgw/ipsec-secgw.c             |  6 +--
 examples/l2fwd-crypto/main.c                   |  5 +--
 lib/librte_cryptodev/rte_cryptodev.c           | 11 +++--
 lib/librte_cryptodev/rte_cryptodev.h           |  9 ++--
 lib/librte_cryptodev/rte_cryptodev_pmd.h       |  3 +-
 test/test/test_cryptodev.c                     | 58 +++++++++++++++-----------
 test/test/test_cryptodev_perf.c                |  5 ++-
 21 files changed, 93 insertions(+), 76 deletions(-)

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 90edb24..d300704 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -155,20 +155,20 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
 			session_pool_socket[socket_id] = sess_mp;
 		}
 
-		ret = rte_cryptodev_configure(cdev_id, &conf,
-				session_pool_socket[socket_id]);
+		ret = rte_cryptodev_configure(cdev_id, &conf);
 		if (ret < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -EINVAL;
 		}
 
-		ret = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
-				socket_id);
-		if (ret < 0) {
-			printf("Failed to setup queue pair %u on "
-				"cryptodev %u",	0, cdev_id);
-			return -EINVAL;
-		}
+		ret = rte_cryptodev_queue_pair_setup(cdev_id, 0,
+				&qp_conf, socket_id,
+				session_pool_socket[socket_id]);
+			if (ret < 0) {
+				printf("Failed to setup queue pair %u on "
+					"cryptodev %u",	0, cdev_id);
+				return -EINVAL;
+			}
 
 		ret = rte_cryptodev_start(cdev_id);
 		if (ret < 0) {
diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst
index 4fae766..638b582 100644
--- a/doc/guides/rel_notes/release_17_08.rst
+++ b/doc/guides/rel_notes/release_17_08.rst
@@ -220,6 +220,7 @@ API Changes
   * Modified parameters of ``rte_cryptodev_sym_session_create()``, to accept
     ``mempool``, instead of ``device id`` and ``rte_crypto_sym_xform``.
   * Remove ``device id`` parameter from ``rte_cryptodev_sym_session_free()``.
+  * Added new field ``session_pool`` to ``rte_cryptodev_queue_pair_setup()``.
 
 
 ABI Changes
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
index 21052cd..6d24a32 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c
@@ -230,7 +230,7 @@ aesni_gcm_pmd_qp_create_processed_pkts_ring(struct aesni_gcm_qp *qp,
 static int
 aesni_gcm_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct aesni_gcm_qp *qp = NULL;
 	struct aesni_gcm_private *internals = dev->data->dev_private;
@@ -258,7 +258,7 @@ aesni_gcm_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_pkts == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
index ae74ae3..e3a6ef5 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c
@@ -404,7 +404,7 @@ aesni_mb_pmd_qp_create_processed_ops_ring(struct aesni_mb_qp *qp,
 static int
 aesni_mb_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct aesni_mb_qp *qp = NULL;
 	struct aesni_mb_private *internals = dev->data->dev_private;
@@ -433,7 +433,7 @@ aesni_mb_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->ingress_queue == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
index e14b68c..3aa4888 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c
@@ -249,7 +249,7 @@ armv8_crypto_pmd_qp_create_processed_ops_ring(struct armv8_crypto_qp *qp,
 static int
 armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct armv8_crypto_qp *qp = NULL;
 
@@ -274,7 +274,7 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index b764f33..e5bfcf2 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -816,7 +816,8 @@ dpaa2_sec_queue_pair_release(struct rte_cryptodev *dev, uint16_t queue_pair_id)
 static int
 dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		__rte_unused const struct rte_cryptodev_qp_conf *qp_conf,
-		__rte_unused int socket_id)
+		__rte_unused int socket_id,
+		__rte_unused struct rte_mempool *session_pool)
 {
 	struct dpaa2_sec_dev_private *priv = dev->data->dev_private;
 	struct dpaa2_sec_qp *qp;
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
index e7bbc29..1d9c0fc 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
@@ -224,7 +224,7 @@ kasumi_pmd_qp_create_processed_ops_ring(struct kasumi_qp *qp,
 static int
 kasumi_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct kasumi_qp *qp = NULL;
 
@@ -249,7 +249,7 @@ kasumi_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index d57644d..c618e6b 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -212,7 +212,7 @@ null_crypto_pmd_qp_create_processed_pkts_ring(struct null_crypto_qp *qp,
 static int
 null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct null_crypto_private *internals = dev->data->dev_private;
 	struct null_crypto_qp *qp;
@@ -255,7 +255,7 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		goto qp_setup_cleanup;
 	}
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 1f8a011..1db4d14 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -599,7 +599,7 @@ openssl_pmd_qp_create_processed_ops_ring(struct openssl_qp *qp,
 static int
 openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct openssl_qp *qp = NULL;
 
@@ -624,7 +624,7 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->stats, 0, sizeof(qp->stats));
 
diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h
index d9d8887..915f960 100644
--- a/drivers/crypto/qat/qat_crypto.h
+++ b/drivers/crypto/qat/qat_crypto.h
@@ -103,7 +103,8 @@ void qat_crypto_sym_stats_get(struct rte_cryptodev *dev,
 void qat_crypto_sym_stats_reset(struct rte_cryptodev *dev);
 
 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
-	const struct rte_cryptodev_qp_conf *rx_conf, int socket_id);
+	const struct rte_cryptodev_qp_conf *rx_conf, int socket_id,
+	struct rte_mempool *session_pool);
 int qat_crypto_sym_qp_release(struct rte_cryptodev *dev,
 	uint16_t queue_pair_id);
 
diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c
index 3921c2e..2b2ab42 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -134,7 +134,7 @@ queue_dma_zone_reserve(const char *queue_name, uint32_t queue_size,
 
 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 	const struct rte_cryptodev_qp_conf *qp_conf,
-	int socket_id)
+	int socket_id, struct rte_mempool *session_pool __rte_unused)
 {
 	struct qat_qp *qp;
 	struct rte_pci_device *pci_dev;
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index c450f6a..e7f796c 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -101,8 +101,7 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
 
-		ret = rte_cryptodev_configure(slave_dev_id, config,
-				dev->data->session_pool);
+		ret = rte_cryptodev_configure(slave_dev_id, config);
 		if (ret < 0)
 			break;
 	}
@@ -400,7 +399,8 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 /** Setup a queue pair */
 static int
 scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
-	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+	struct rte_mempool *session_pool)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	struct scheduler_qp_ctx *qp_ctx;
@@ -422,8 +422,13 @@ scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_id = sched_ctx->slaves[i].dev_id;
 
+		/*
+		 * All slaves will share the same session mempool
+		 * for session-less operations, so the objects
+		 * must be big enough for all the drivers used.
+		 */
 		ret = rte_cryptodev_queue_pair_setup(slave_id, qp_id,
-				qp_conf, socket_id);
+				qp_conf, socket_id, session_pool);
 		if (ret < 0)
 			return ret;
 	}
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
index 3accba5..108f251 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
@@ -221,7 +221,7 @@ snow3g_pmd_qp_create_processed_ops_ring(struct snow3g_qp *qp,
 static int
 snow3g_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct snow3g_qp *qp = NULL;
 
@@ -246,7 +246,7 @@ snow3g_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
index adef343..7cb3f1c 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c
@@ -221,7 +221,7 @@ zuc_pmd_qp_create_processed_ops_ring(struct zuc_qp *qp,
 static int
 zuc_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-		 int socket_id)
+		int socket_id, struct rte_mempool *session_pool)
 {
 	struct zuc_qp *qp = NULL;
 
@@ -246,7 +246,7 @@ zuc_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (qp->processed_ops == NULL)
 		goto qp_setup_cleanup;
 
-	qp->sess_mp = dev->data->session_pool;
+	qp->sess_mp = session_pool;
 
 	memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
 
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 708eadd..11f0966 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1299,15 +1299,15 @@ cryptodevs_init(void)
 			socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
 		}
 
-		if (rte_cryptodev_configure(cdev_id, &dev_conf,
-				socket_ctx[dev_conf.socket_id].session_pool))
+		if (rte_cryptodev_configure(cdev_id, &dev_conf))
 			rte_panic("Failed to initialize cryptodev %u\n",
 					cdev_id);
 
 		qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
 		for (qp = 0; qp < dev_conf.nb_queue_pairs; qp++)
 			if (rte_cryptodev_queue_pair_setup(cdev_id, qp,
-						&qp_conf, dev_conf.socket_id))
+					&qp_conf, dev_conf.socket_id,
+					socket_ctx[dev_conf.socket_id].session_pool))
 				rte_panic("Failed to setup queue %u for "
 						"cdev_id %u\n",	0, cdev_id);
 
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index cba29ce..2a71feb 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -2232,8 +2232,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 						cap->sym.auth.digest_size.min;
 		}
 
-		retval = rte_cryptodev_configure(cdev_id, &conf,
-				session_pool_socket[socket_id]);
+		retval = rte_cryptodev_configure(cdev_id, &conf);
 		if (retval < 0) {
 			printf("Failed to configure cryptodev %u", cdev_id);
 			return -1;
@@ -2242,7 +2241,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 		qp_conf.nb_descriptors = 2048;
 
 		retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
-				socket_id);
+				socket_id, session_pool_socket[socket_id]);
 		if (retval < 0) {
 			printf("Failed to setup queue pair %u on cryptodev %u",
 					0, cdev_id);
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 373c05b..8ee5d47 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -747,8 +747,7 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
 }
 
 int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
-		struct rte_mempool *session_pool)
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 {
 	struct rte_cryptodev *dev;
 	int diag;
@@ -768,8 +767,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
 
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
-	dev->data->session_pool = session_pool;
-
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
 			config->socket_id);
@@ -881,7 +878,9 @@ rte_cryptodev_close(uint8_t dev_id)
 
 int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
-		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+		struct rte_mempool *session_pool)
+
 {
 	struct rte_cryptodev *dev;
 
@@ -905,7 +904,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_pair_setup, -ENOTSUP);
 
 	return (*dev->dev_ops->queue_pair_setup)(dev, queue_pair_id, qp_conf,
-			socket_id);
+			socket_id, session_pool);
 }
 
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 3ba3efb..ca7cbdd 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -525,15 +525,13 @@ struct rte_cryptodev_config {
  *
  * @param	dev_id		The identifier of the device to configure.
  * @param	config		The crypto device configuration structure.
- * @param	session_pool	Pointer to device session mempool
  *
  * @return
  *   - 0: Success, device configured.
  *   - <0: Error code returned by the driver configuration function.
  */
 extern int
-rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
-		struct rte_mempool *session_pool);
+rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
 
 /**
  * Start an device.
@@ -592,6 +590,8 @@ rte_cryptodev_close(uint8_t dev_id);
  *				*SOCKET_ID_ANY* if there is no NUMA constraint
  *				for the DMA memory allocated for the receive
  *				queue pair.
+ * @param	session_pool	Pointer to device session mempool, used
+ *				for session-less operations.
  *
  * @return
  *   - 0: Success, queue pair correctly set up.
@@ -599,7 +599,8 @@ rte_cryptodev_close(uint8_t dev_id);
  */
 extern int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
-		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
+		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
+		struct rte_mempool *session_pool);
 
 /**
  * Start a specified queue pair of a device. It is used
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 2896171..82ad1f7 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -207,12 +207,13 @@ typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
  * @param	qp_id		Queue Pair Index
  * @param	qp_conf		Queue configuration structure
  * @param	socket_id	Socket Index
+ * @param	session_pool	Pointer to device session mempool
  *
  * @return	Returns 0 on success.
  */
 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
 		uint16_t qp_id,	const struct rte_cryptodev_qp_conf *qp_conf,
-		int socket_id);
+		int socket_id, struct rte_mempool *session_pool);
 
 /**
  * Release memory resources allocated by given queue pair.
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 745f261..b068609 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -404,7 +404,7 @@ testsuite_setup(void)
 			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u with %u qps",
 			dev_id, ts_params->conf.nb_queue_pairs);
 
@@ -413,7 +413,8 @@ testsuite_setup(void)
 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			dev_id, qp_id, &ts_params->qp_conf,
-			rte_cryptodev_socket_id(dev_id)),
+			rte_cryptodev_socket_id(dev_id),
+			ts_params->session_mpool),
 			"Failed to setup queue pair %u on cryptodev %u",
 			qp_id, dev_id);
 	}
@@ -458,7 +459,7 @@ ut_setup(void)
 	ts_params->conf.socket_id = SOCKET_ID_ANY;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -466,7 +467,8 @@ ut_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0], qp_id,
 			&ts_params->qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed to setup queue pair %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
 	}
@@ -542,23 +544,20 @@ test_device_configure_invalid_dev_id(void)
 	/* Stop the device in case it's started so it can be configured */
 	rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
 
-	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	/* invalid dev_id values */
 	dev_id = num_devs;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure: "
 			"invalid dev_num %u", dev_id);
 
 	dev_id = 0xff;
 
-	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
-				ts_params->session_mpool),
+	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
 			"Failed test for rte_cryptodev_configure:"
 			"invalid dev_num %u", dev_id);
 
@@ -578,7 +577,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 1;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
 
@@ -587,7 +586,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
 			ts_params->valid_devs[0],
 			ts_params->conf.nb_queue_pairs);
@@ -597,7 +596,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = 0;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -608,7 +607,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -619,7 +618,7 @@ test_device_configure_invalid_queue_pair_ids(void)
 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
 
 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed test for rte_cryptodev_configure, dev_id %u,"
 			" invalid qps: %u",
 			ts_params->valid_devs[0],
@@ -649,7 +648,7 @@ test_queue_pair_descriptor_setup(void)
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
-			&ts_params->conf, ts_params->session_mpool),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->valid_devs[0]);
 
@@ -663,7 +662,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for "
 				"rte_cryptodev_queue_pair_setup: num_inflights "
 				"%u on qp %u on cryptodev %u",
@@ -677,7 +677,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for"
 				" rte_cryptodev_queue_pair_setup: num_inflights"
 				" %u on qp %u on cryptodev %u",
@@ -691,7 +692,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for "
 				"rte_cryptodev_queue_pair_setup: num_inflights"
 				" %u on qp %u on cryptodev %u",
@@ -706,7 +708,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -721,7 +724,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -735,7 +739,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Failed test for"
 				" rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -750,7 +755,8 @@ test_queue_pair_descriptor_setup(void)
 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 				ts_params->valid_devs[0], qp_id, &qp_conf,
 				rte_cryptodev_socket_id(
-						ts_params->valid_devs[0])),
+						ts_params->valid_devs[0]),
+				ts_params->session_mpool),
 				"Unexpectedly passed test for "
 				"rte_cryptodev_queue_pair_setup:"
 				"num_inflights %u on qp %u on cryptodev %u",
@@ -766,7 +772,8 @@ test_queue_pair_descriptor_setup(void)
 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0],
 			qp_id, &qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed test for rte_cryptodev_queue_pair_setup:"
 			"invalid qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
@@ -776,7 +783,8 @@ test_queue_pair_descriptor_setup(void)
 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
 			ts_params->valid_devs[0],
 			qp_id, &qp_conf,
-			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
 			"Failed test for rte_cryptodev_queue_pair_setup:"
 			"invalid qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index e21f5e7..8cddaa7 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -423,7 +423,7 @@ testsuite_setup(void)
 			"session mempool allocation failed");
 
 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
-			&ts_params->conf, ts_params->sess_mp),
+			&ts_params->conf),
 			"Failed to configure cryptodev %u",
 			ts_params->dev_id);
 
@@ -433,7 +433,8 @@ testsuite_setup(void)
 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
 			ts_params->dev_id, qp_id,
 				&ts_params->qp_conf,
-				rte_cryptodev_socket_id(ts_params->dev_id)),
+				rte_cryptodev_socket_id(ts_params->dev_id),
+				ts_params->sess_mp),
 				"Failed to setup queue pair %u on cryptodev %u",
 				qp_id, ts_params->dev_id);
 	}
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 11/12] cryptodev: remove session init internal function
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (9 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 10/12] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05  5:26       ` [PATCH v4 12/12] doc: add new crypto session information Pablo de Lara
                         ` (3 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara

Since now the private session data is initialized after
the session pool is created, there is no need to keep
this PMD function.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 --------
 lib/librte_cryptodev/rte_cryptodev_pmd.h    | 16 ----------------
 2 files changed, 24 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index e5bfcf2..769a139 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -908,13 +908,6 @@ dpaa2_sec_session_get_size(struct rte_cryptodev *dev __rte_unused)
 	return sizeof(dpaa2_sec_session);
 }
 
-static void
-dpaa2_sec_session_initialize(struct rte_mempool *mp __rte_unused,
-			     void *sess __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-}
-
 static int
 dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
 		      struct rte_crypto_sym_xform *xform,
@@ -1821,7 +1814,6 @@ static struct rte_cryptodev_ops crypto_ops = {
 	.queue_pair_stop      = dpaa2_sec_queue_pair_stop,
 	.queue_pair_count     = dpaa2_sec_queue_pair_count,
 	.session_get_size     = dpaa2_sec_session_get_size,
-	.session_initialize   = dpaa2_sec_session_initialize,
 	.session_configure    = dpaa2_sec_session_configure,
 	.session_clear        = dpaa2_sec_session_clear,
 };
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 82ad1f7..af1aaeb 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -267,20 +267,6 @@ typedef unsigned (*cryptodev_sym_get_session_private_size_t)(
 		struct rte_cryptodev *dev);
 
 /**
- * Initialize a Crypto session on a device.
- *
- * @param	dev		Crypto device pointer
- * @param	xform		Single or chain of crypto xforms
- * @param	priv_sess	Pointer to cryptodev's private session structure
- *
- * @return
- *  - Returns private session structure on success.
- *  - Returns NULL on failure.
- */
-typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
-		void *session_private);
-
-/**
  * Configure a Crypto session on a device.
  *
  * @param	dev		Crypto device pointer
@@ -359,8 +345,6 @@ struct rte_cryptodev_ops {
 
 	cryptodev_sym_get_session_private_size_t session_get_size;
 	/**< Return private session. */
-	cryptodev_sym_initialize_session_t session_initialize;
-	/**< Initialization function for private session data */
 	cryptodev_sym_configure_session_t session_configure;
 	/**< Configure a Crypto session. */
 	cryptodev_sym_free_session_t session_clear;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v4 12/12] doc: add new crypto session information
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (10 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 11/12] cryptodev: remove session init internal function Pablo de Lara
@ 2017-07-05  5:26       ` Pablo de Lara
  2017-07-05 15:21       ` [PATCH v4 00/12] Device independent crypto sessions Declan Doherty
                         ` (2 subsequent siblings)
  14 siblings, 0 replies; 44+ messages in thread
From: Pablo de Lara @ 2017-07-05  5:26 UTC (permalink / raw)
  To: declan.doherty, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev, Pablo de Lara, Slawomir Mrozowicz

Modified cryptodev library section in Programmer's Guide,
with the recent changes in the crypto sessions.

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
---
 doc/guides/prog_guide/cryptodev_lib.rst          |  61 ++--
 doc/guides/prog_guide/img/cryptodev_sym_sess.svg | 418 ++++++++++++++++++++---
 2 files changed, 402 insertions(+), 77 deletions(-)

diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst
index 8feaece..bfef7cc 100644
--- a/doc/guides/prog_guide/cryptodev_lib.rst
+++ b/doc/guides/prog_guide/cryptodev_lib.rst
@@ -114,9 +114,8 @@ The rte_cryptodev_configure API is used to configure a Crypto device.
    int rte_cryptodev_configure(uint8_t dev_id,
                                struct rte_cryptodev_config *config)
 
-The ``rte_cryptodev_config`` structure is used to pass the configuration parameters.
-In contains parameter for socket selection, number of queue pairs and the
-session mempool configuration.
+The ``rte_cryptodev_config`` structure is used to pass the configuration
+parameters for socket selection and number of queue pairs.
 
 .. code-block:: c
 
@@ -125,12 +124,6 @@ session mempool configuration.
         /**< Socket to allocate resources on */
         uint16_t nb_queue_pairs;
         /**< Number of queue pairs to configure on device */
-
-        struct {
-            uint32_t nb_objs;
-            uint32_t cache_size;
-        } session_mp;
-        /**< Session mempool configuration */
     };
 
 
@@ -432,7 +425,7 @@ operations, as well as also supporting AEAD operations.
 
 Session and Session Management
 
-Session are used in symmetric cryptographic processing to store the immutable
+Sessions are used in symmetric cryptographic processing to store the immutable
 data defined in a cryptographic transform which is used in the operation
 processing of a packet flow. Sessions are used to manage information such as
 expand cipher keys and HMAC IPADs and OPADs, which need to be calculated for a
@@ -443,27 +436,33 @@ Crypto workloads.
 
 .. figure:: img/cryptodev_sym_sess.*
 
-The Crypto device framework provides a set of session pool management APIs for
-the creation and freeing of the sessions, utilizing the Mempool Library.
-
-The framework also provides hooks so the PMDs can pass the amount of memory
-required for that PMDs private session parameters, as well as initialization
-functions for the configuration of the session parameters and freeing function
-so the PMD can managed the memory on destruction of a session.
-
-**Note**: Sessions created on a particular device can only be used on Crypto
-devices of the same type - the same driver id used by this devices,
-and if you try to use a session on a device different
-to that on which it was created then the Crypto operation will fail.
-
-``rte_cryptodev_sym_session_create()`` is used to create a symmetric session on
-Crypto device. A symmetric transform chain is used to specify the particular
-operation and its parameters. See the section below for details on transforms.
-
-.. code-block:: c
-
-   struct rte_cryptodev_sym_session * rte_cryptodev_sym_session_create(
-          uint8_t dev_id, struct rte_crypto_sym_xform *xform);
+The Crypto device framework provides APIs to allocate and initizalize sessions
+for crypto devices, where sessions are mempool objects.
+It is the application's responsibility to create and manage the session mempools.
+This approach allows for different scenarios such as having a single session
+mempool for all crypto devices (where the mempool object size is big
+enough to hold the private session of any crypto device), as well as having
+multiple session mempools of different sizes for better memory usage.
+
+An application can use ``rte_cryptodev_get_private_session_size()`` to
+get the private session size of given crypto device. This function would allow
+an application to calculate the max device session size of all crypto devices
+to create a single session mempool.
+If instead an application creates multiple session mempools, the Crypto device
+framework also provides ``rte_cryptodev_get_header_session_size`` to get
+the size of an uninitialized session.
+
+Once the session mempools have been created, ``rte_cryptodev_sym_session_create()``
+is used to allocate an uninitialized session from the given mempool.
+The session then must be initialized using ``rte_cryptodev_sym_session_init()``
+for each of the required crypto devices. A symmetric transform chain
+is used to specify the operation and its parameters. See the section below for
+details on transforms.
+
+When a session is no longer used, user must call ``rte_cryptodev_sym_session_clear()``
+for each of the crypto devices that are using the session, to free all driver
+private session data. Once this is done, session should be freed using
+``rte_cryptodev_sym_session_free`` which returns them to their mempool.
 
 
 Transforms and Transform Chaining
diff --git a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
index e5f41ec..a807ceb 100644
--- a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
+++ b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
@@ -1,10 +1,50 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <!-- Generated by Microsoft Visio, SVG Export cryptodev_sym_sess.svg Page-1 -->
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"
-		width="2.17241in" height="2.8102in" viewBox="0 0 156.413 202.335" xml:space="preserve" color-interpolation-filters="sRGB"
-		class="st10">
-	<style type="text/css">
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="4.8933434in"
+   height="3.8972795in"
+   viewBox="0 0 352.31955 280.60496"
+   xml:space="preserve"
+   class="st10"
+   version="1.1"
+   id="svg70"
+   sodipodi:docname="cryptodev_sym_sess.svg"
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-rule:evenodd;stroke-linecap:square;stroke-miterlimit:3"
+   inkscape:version="0.92.1 r15371"><metadata
+   id="metadata74"><rdf:RDF><cc:Work
+       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+   pagecolor="#ffffff"
+   bordercolor="#666666"
+   borderopacity="1"
+   objecttolerance="10"
+   gridtolerance="10"
+   guidetolerance="10"
+   inkscape:pageopacity="0"
+   inkscape:pageshadow="2"
+   inkscape:window-width="1920"
+   inkscape:window-height="1051"
+   id="namedview72"
+   showgrid="false"
+   inkscape:zoom="1.7495789"
+   inkscape:cx="208.74719"
+   inkscape:cy="216.52777"
+   inkscape:window-x="-9"
+   inkscape:window-y="-9"
+   inkscape:window-maximized="0"
+   inkscape:current-layer="g68-0" />
+	<style
+   type="text/css"
+   id="style2">
 	<![CDATA[
 		.st1 {fill:url(#grad0-4);stroke:#386288;stroke-width:0.75}
 		.st2 {fill:#386288;font-family:Calibri;font-size:0.833336em}
@@ -19,48 +59,334 @@
 	]]>
 	</style>
 
-	<defs id="Patterns_And_Gradients">
-		<linearGradient id="grad0-4" x1="0" y1="0" x2="1" y2="0" gradientTransform="rotate(60 0.5 0.5)">
-			<stop offset="0" stop-color="#e8ebef" stop-opacity="1"/>
-			<stop offset="0.24" stop-color="#f4f5f7" stop-opacity="1"/>
-			<stop offset="0.54" stop-color="#feffff" stop-opacity="1"/>
+	<defs
+   id="Patterns_And_Gradients"><marker
+   inkscape:isstock="true"
+   style="overflow:visible"
+   id="marker5421"
+   refX="0"
+   refY="0"
+   orient="auto"
+   inkscape:stockid="Arrow2Lend"><path
+     transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+     d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+     style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+     id="path5419"
+     inkscape:connector-curvature="0" /></marker><marker
+   inkscape:stockid="Arrow2Lend"
+   orient="auto"
+   refY="0"
+   refX="0"
+   id="Arrow2Lend"
+   style="overflow:visible"
+   inkscape:isstock="true"><path
+     id="path5004"
+     style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+     d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+     transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+     inkscape:connector-curvature="0" /></marker><marker
+   inkscape:stockid="Arrow1Lend"
+   orient="auto"
+   refY="0"
+   refX="0"
+   id="Arrow1Lend"
+   style="overflow:visible"
+   inkscape:isstock="true"><path
+     id="path4986"
+     d="M 0,0 5,-5 -12.5,0 5,5 Z"
+     style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
+     transform="matrix(-0.8,0,0,-0.8,-10,0)"
+     inkscape:connector-curvature="0" /></marker>
+		<linearGradient
+   id="grad0-4"
+   x1="0"
+   y1="0"
+   x2="1"
+   y2="0"
+   gradientTransform="rotate(60,0.5,0.5)">
+			<stop
+   offset="0"
+   stop-color="#e8ebef"
+   stop-opacity="1"
+   id="stop4" />
+			<stop
+   offset="0.24"
+   stop-color="#f4f5f7"
+   stop-opacity="1"
+   id="stop6" />
+			<stop
+   offset="0.54"
+   stop-color="#feffff"
+   stop-opacity="1"
+   id="stop8" />
 		</linearGradient>
-	</defs>
-	<defs id="Filters">
-		<filter id="filter_2">
-			<feGaussianBlur stdDeviation="2"/>
+	<filter
+   id="filter_2-4"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-0" /></filter><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient189"
+   gradientTransform="scale(0.8787489,1.1379815)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /><filter
+   id="filter_2-5"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-8" /></filter><filter
+   id="filter_2-3"><feGaussianBlur
+     stdDeviation="2"
+     id="feGaussianBlur12-2" /></filter><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient189-7"
+   gradientTransform="scale(0.8787489,1.1379815)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /><linearGradient
+   inkscape:collect="always"
+   xlink:href="#grad0-4"
+   id="linearGradient500"
+   gradientTransform="matrix(0.8787489,0,0,1.1379815,12.431599,21.739241)"
+   x1="-0.42674366"
+   y1="0.98859203"
+   x2="176.71146"
+   y2="0.98859203"
+   gradientUnits="userSpaceOnUse" /></defs>
+	<defs
+   id="Filters">
+		<filter
+   id="filter_2">
+			<feGaussianBlur
+   stdDeviation="2"
+   id="feGaussianBlur12" />
 		</filter>
 	</defs>
-	<g>
-		<title>Page-1</title>
-		<g id="shape18-1" transform="translate(0.749889,-0.75)">
-			<title>Rounded Rectangle.12</title>
-			<desc>Crypto Symmetric Session</desc>
-			<path d="M6.78 202.33 L148.14 202.33 A6.77735 6.77735 -180 0 0 154.91 195.56 L154.91 8.28 A6.77735 6.77735 -180 0 0 148.14
-						 1.5 L6.78 1.5 A6.77735 6.77735 -180 0 0 -0 8.28 L0 195.56 A6.77735 6.77735 -180 0 0 6.78 202.33 Z"
-					class="st1"/>
-			<text x="24.76" y="14.5" class="st2">Crypto Symmetric Session</text>		</g>
-		<g id="shape19-6" transform="translate(10.6711,-9.82087)">
-			<title>Rounded Rectangle.13</title>
-			<desc>Private Session Data</desc>
-			<g id="shadow19-7" transform="matrix(1,0,0,1,0.345598,1.97279)" class="st3">
-				<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 103.65 A5.90925 5.90925 -180
-							 0 0 129.16 97.74 L5.91 97.74 A5.90925 5.90925 -180 0 0 -0 103.65 L0 196.43 A5.90925 5.90925 -180 0 0
-							 5.91 202.33 Z" class="st4"/>
-			</g>
-			<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 103.65 A5.90925 5.90925 -180 0 0
-						 129.16 97.74 L5.91 97.74 A5.90925 5.90925 -180 0 0 -0 103.65 L0 196.43 A5.90925 5.90925 -180 0 0 5.91 202.33
-						 Z" class="st5"/>
-			<text x="26.34" y="153.04" class="st6">Private Session Data</text>		</g>
-		<g id="shape20-12" transform="translate(10.6711,-122.923)">
-			<title>Rounded Rectangle.15</title>
-			<desc>General Session Data (struct rte_cryptodev_sym_session)</desc>
-			<path d="M5.91 202.33 L129.16 202.33 A5.90925 5.90925 -180 0 0 135.07 196.43 L135.07 160.06 A5.90925 5.90925 -180 0 0
-						 129.16 154.15 L5.91 154.15 A5.90925 5.90925 -180 0 0 -0 160.06 L0 196.43 A5.90925 5.90925 -180 0 0 5.91
-						 202.33 Z" class="st7"/>
-			<text x="24.58" y="175.24" class="st6">General Session Data <tspan x="9.16" dy="1.5em" class="st8">(</tspan><tspan
-						class="st9">struct </tspan><tspan class="st8">rte</tspan><tspan class="st8">_</tspan><tspan class="st8">cryptodev</tspan><tspan
-						class="st8">_</tspan><tspan class="st8">sym</tspan><tspan class="st8">_</tspan><tspan class="st8">session</tspan><tspan
-						class="st8">)</tspan></text>		</g>
+	<g
+   id="g68"
+   transform="matrix(1,0,0,0.41409874,-12.807629,-5.4621159)">
+		<title
+   id="title16">Page-1</title>
+		<g
+   id="shape18-1"
+   transform="translate(0.749889,-0.75)">
+			<title
+   id="title18">Rounded Rectangle.12</title>
+			<desc
+   id="desc20">Crypto Symmetric Session</desc>
+			<path
+   d="M 19.211599,224.06924 H 160.5716 a 6.77735,6.77735 0 0 0 6.77,-6.77 V 30.019241 a 6.77735,6.77735 0 0 0 -6.77,-6.78 H 19.211599 a 6.77735,6.77735 0 0 0 -6.78,6.78 V 217.29924 a 6.77735,6.77735 0 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22"
+   style="fill:url(#linearGradient500);stroke:#386288;stroke-width:0.75"
+   inkscape:connector-curvature="0" />
+			<text
+   x="63.123039"
+   y="28.531481"
+   class="st2"
+   id="text24"
+   style="font-size:16.97244835px;font-family:Calibri;fill:#386288;stroke-width:1.69723928"
+   transform="scale(0.58919214,1.6972392)">Crypto Symmetric Session</text>
+
+		</g>
+		<g
+   id="shape19-6"
+   transform="translate(10.6711,-9.82087)">
+			<title
+   id="title27">Rounded Rectangle.13</title>
+			<desc
+   id="desc29">Private Session Data</desc>
+		</g>
+		<g
+   id="shape20-12"
+   transform="matrix(1,0,0,2.5278193,23.531375,-309.78186)">
+			<title
+   id="title39">Rounded Rectangle.15</title>
+			<desc
+   id="desc41">void *sess_private_data[]</desc>
+			<path
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -36.37 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,160.06 v 36.37 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st7"
+   id="path43"
+   inkscape:connector-curvature="0"
+   style="fill:#ffffff;stroke:#41719c;stroke-width:0.75" />
+			<text
+   x="14.072042"
+   y="159.1931"
+   class="st6"
+   id="text65"
+   style="font-size:11.41061592px;font-family:Calibri;fill:#41719c;stroke-width:1.14105785"
+   transform="scale(0.92359087,1.0827305)">void *sess_private_data[] <tspan
+   x="-3.5230706"
+   class="st9"
+   id="tspan47"
+   style="font-weight:bold;font-size:9.12843513px;stroke-width:1.14105785" /></text>
+
+		<rect
+   style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.73305672;stroke-opacity:1"
+   id="rect4604"
+   width="15.968175"
+   height="14.230948"
+   x="13.494645"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7"
+   width="15.968174"
+   height="14.230948"
+   x="29.46282"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6"
+   width="15.968174"
+   height="14.230948"
+   x="45.430992"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9"
+   width="15.968174"
+   height="14.230948"
+   x="61.399166"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8"
+   width="15.968174"
+   height="14.230948"
+   x="77.36734"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8-9"
+   width="15.968174"
+   height="14.230948"
+   x="93.33551"
+   y="181.68814" /><rect
+   style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
+   id="rect4604-7-6-9-8-9-6"
+   width="15.968174"
+   height="14.230948"
+   x="109.30369"
+   y="181.68814" /><path
+   style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.72427988px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+   d="m 117.64885,196.01764 0.22164,18.77485 44.6966,-0.0725 -0.22163,-20.00716 16.84434,0.43494"
+   id="path5030"
+   inkscape:connector-curvature="0" /></g>
 	</g>
-</svg>
+<g
+   transform="translate(190.70887,-0.53319281)"
+   id="g68-0"><title
+     id="title16-2">Page-1</title><g
+     id="shape18-1-4"
+     transform="matrix(1,0,0,0.57815109,0.749889,-0.11722686)"><title
+   id="title18-4">Rounded Rectangle.12</title><desc
+   id="desc20-6">Crypto Symmetric Session</desc><path
+   inkscape:connector-curvature="0"
+   d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22-0"
+   style="fill:url(#linearGradient189);stroke:#386288;stroke-width:0.75" /><text
+   x="26.317923"
+   y="17.335487"
+   class="st2"
+   id="text24-5"
+   style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+   transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
+
+</g><g
+     id="shape19-6-5"
+     transform="matrix(1.022976,0,0,0.71529071,9.1114734,-39.403506)"><title
+   id="title27-2">Rounded Rectangle.13</title><desc
+   id="desc29-0">Private Session Data</desc><g
+   id="shadow19-7-1"
+   transform="translate(0.345598,1.97279)"
+   class="st3"
+   style="visibility:visible"><path
+     inkscape:connector-curvature="0"
+     d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+     class="st4"
+     id="path31-8"
+     style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2)" /></g><path
+   inkscape:connector-curvature="0"
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st5"
+   id="path34-8"
+   style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
+   x="34.639763"
+   y="119.96548"
+   class="st6"
+   id="text36-7"
+   style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+   transform="scale(0.76039781,1.3151011)">Private Session Data</text>
+
+</g><g
+     id="shape18-1-4-7"
+     transform="matrix(1,0,0,0.57815109,0.90591369,163.94402)"><title
+   id="title18-4-3">Rounded Rectangle.12</title><desc
+   id="desc20-6-5">Crypto Symmetric Session</desc><path
+   inkscape:connector-curvature="0"
+   d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+   class="st1"
+   id="path22-0-8"
+   style="fill:url(#linearGradient189-7);stroke:#386288;stroke-width:0.75" /><text
+   x="26.317923"
+   y="17.335487"
+   class="st2"
+   id="text24-5-1"
+   style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+   transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
+
+</g><g
+     id="shape19-6-5-1"
+     transform="matrix(1.022976,0,0,0.71529071,9.2675037,124.65774)"><title
+   id="title27-2-4">Rounded Rectangle.13</title><desc
+   id="desc29-0-9">Private Session Data</desc><g
+   id="shadow19-7-1-8"
+   transform="translate(0.345598,1.97279)"
+   class="st3"
+   style="visibility:visible"><path
+     inkscape:connector-curvature="0"
+     d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+     class="st4"
+     id="path31-8-4"
+     style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2-3)" /></g><path
+   inkscape:connector-curvature="0"
+   d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+   class="st5"
+   id="path34-8-3"
+   style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
+   x="34.639763"
+   y="119.96548"
+   class="st6"
+   id="text36-7-6"
+   style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+   transform="scale(0.76039781,1.3151011)">Private Session Data</text>
+
+</g><text
+     xml:space="preserve"
+     style="font-style:normal;font-weight:normal;font-size:30.00008774px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
+     x="57.540585"
+     y="145.94679"
+     id="text5070"><tspan
+       sodipodi:role="line"
+       id="tspan5068"
+       x="57.540585"
+       y="173.31679"
+       style="stroke-width:0.75000221"></tspan></text>
+<text
+     xml:space="preserve"
+     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
+     x="60.571766"
+     y="143.21872"
+     id="text5074"><tspan
+       sodipodi:role="line"
+       id="tspan5072"
+       x="60.571766"
+       y="143.21872"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.75000221">...</tspan></text>
+<path
+     style="fill:none;stroke:#41719c;stroke-width:0.74499911px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker5421)"
+     d="M -158.57624,71.371238 -157.38,232.04055 -1.1215065,232.19212"
+     id="path5076"
+     inkscape:connector-curvature="0" /></g></svg>
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 00/12] Device independent crypto sessions
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (11 preceding siblings ...)
  2017-07-05  5:26       ` [PATCH v4 12/12] doc: add new crypto session information Pablo de Lara
@ 2017-07-05 15:21       ` Declan Doherty
  2017-07-05 16:26       ` Akhil Goyal
  2017-07-06 11:05       ` De Lara Guarch, Pablo
  14 siblings, 0 replies; 44+ messages in thread
From: Declan Doherty @ 2017-07-05 15:21 UTC (permalink / raw)
  To: Pablo de Lara, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev

On 05/07/2017 6:26 AM, Pablo de Lara wrote:
> Currently, the cryptodev library requires the session mempools to be created inside each device.
> This can be a waste of memory, as several devices with the same driver could be using the same session.
>
> This patchset makes changes in the library to allow session to contain multiple driver private data, so it can be used by multiple devices (no need to be the same driver).
>
>                                   SESSION MEMPOOL <---|---> DEVICE INSTANCES
>                                  --------------------------------------------
>
> .-------------.      .----------------------------.
> |   Crypto    |.     |         mempool obj        |
> | sym-session |<--.  | .--------------------------+
> |   mempool   ||  |  | | rte_cryptodev_session    |             .-------------.
> `-------------'|  |  | |                          |             |   DEVICE    |
>  `-----|-------'  |  | |                          |             |  INSTANCE   |
>        |          `-----                          |             | - device id |
>        +------------>| | - private data[type idx] |          .--| - session   |
>        |             `-+=================|..|====='          |  |   mempool   |
>        |                                 |  |                |  `-------------'
>        |                                 |  |                |
>        |     .----------------------.    |  |                |  .-------------.
>        +---->|      mempool obj     |    |  |   .--------.   |  |   DEVICE    |
>        |     | .--------------------+    |  |   | DRIVER |   |  |  INSTANCE   |
>        |     | | PMD's private data |<---+------| - type |<--+--|             |
>        |     +-+====================+       |   `--------'      |     ...     |
>        |                                    |                   |             |
>        |                                    |                   `-------------'
>        |                                    |
>        |     .----------------------.       |                   .-------------.
>        `---->|      mempool obj     |       |   .--------.      |   DEVICE    |
>              | .--------------------+       |   | DRIVER |      |  INSTANCE   |
>              | | PMD's private data |<------+---| - type |<-----|             |
>              `-+===================='           `--------'      |     ...     |
>                                                                 |             |
>                                                                 `-------------'
> Crypto sym-session mempool
>
>    Mempool created to store rte_cryptodev_session objects as well as
>    private data for supported device types.
>
>    This mempool replaces existing session mempools in device
>    instances to ease session management and improve consistency
>    (especially if the session is intended to be used for operations
>    performed on different devices).
>
> rte_crypto_session
>
>    New rte_cryptodev_session structure is taken from crypto session
>    mempool and can store more than one PMD's private data object (one
>    for each device type supported by sesion).
>
>    Crypto operations will use device type id (unique for each driver) to
>    retrieve private data from rte_crypto_session right for the device
>    type they are performed on.
>
> This patchset was based on the changes proposed in RFC
> (http://dpdk.org/ml/archives/dev/2017-May/065259.html)
>
> This patchset depends on:
> http://dpdk.org/dev/patchwork/patch/26156/
>
> Changes in v4:
>
> - Introduced new rte_cryptodev_sym_session_clear() function,
>   which frees device private session data.
>   This needs to be called before calling rte_cryptodev_sym_session_free().
>
> - Rebased on top of dpdk-next-crypto
>
> Changes in v3:
>
> - Removed internal PMD's session initialize function
>
> - Created session mempool in the right socket in
>   the sample apps
>
> - Get two objects (header and private data) from mempool
>   when using sessionless operations, to get a complete
>   session
>
> - Fixed commit message (check-git-log failed)
>
> - Added note of removed session_mp from rte_cryptodev_config
>   in documentation
>
> - Fixed minor issues in documentation
>
>
> Changes in v2:
>
> - Split the patch in multiple smaller patches to
>   facilitate the review
>
> - Removed new API to create the session mempool,
>   since mempool can be created directly withe mempool_create
>
> - Session headers and device private sessions can be
>   allocated from different mempools, for better memory
>   efficiency.
>
> - Added a cover letter (partially extracted from RFC)
>   for better clarification on the intention of this patchset
>
> Pablo de Lara (5):
>   cryptodev: remove unused cryptodev session structure
>   cryptodev: move session init out of session pool creation
>   cryptodev: add mempool pointer in queue pair setup
>   cryptodev: remove session init internal function
>   doc: add new crypto session information
>
> Slawomir Mrozowicz (7):
>   cryptodev: add private session size retrieval function
>   cryptodev: do not create session mempool internally
>   cryptodev: change attach session to queue pair API
>   cryptodev: remove device id from crypto session
>   cryptodev: remove driver id from session
>   cryptodev: remove mempool from session
>   cryptodev: support device independent sessions
>
>  app/test-crypto-perf/cperf.h                       |   5 +-
>  app/test-crypto-perf/cperf_ops.c                   |  21 +-
>  app/test-crypto-perf/cperf_ops.h                   |   1 +
>  app/test-crypto-perf/cperf_test_latency.c          |  12 +-
>  app/test-crypto-perf/cperf_test_latency.h          |   5 +-
>  app/test-crypto-perf/cperf_test_throughput.c       |  12 +-
>  app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
>  app/test-crypto-perf/cperf_test_verify.c           |  12 +-
>  app/test-crypto-perf/cperf_test_verify.h           |   5 +-
>  app/test-crypto-perf/main.c                        |  85 ++++-
>  doc/guides/prog_guide/cryptodev_lib.rst            |  61 ++-
>  doc/guides/prog_guide/img/cryptodev_sym_sess.svg   | 418 ++++++++++++++++++---
>  doc/guides/rel_notes/release_17_08.rst             |  19 +
>  drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  51 ++-
>  drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  49 ++-
>  drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  43 ++-
>  drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  50 ++-
>  drivers/crypto/armv8/rte_armv8_pmd.c               |  39 +-
>  drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  49 ++-
>  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  66 +++-
>  drivers/crypto/kasumi/rte_kasumi_pmd.c             |  42 ++-
>  drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  51 ++-
>  drivers/crypto/null/null_crypto_pmd.c              |  43 ++-
>  drivers/crypto/null/null_crypto_pmd_ops.c          |  51 ++-
>  drivers/crypto/openssl/rte_openssl_pmd.c           |  41 +-
>  drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  52 ++-
>  drivers/crypto/qat/qat_crypto.c                    |  93 +++--
>  drivers/crypto/qat/qat_crypto.h                    |  19 +-
>  drivers/crypto/qat/qat_qp.c                        |   2 +-
>  drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
>  drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
>  .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 -
>  drivers/crypto/scheduler/scheduler_pmd_ops.c       |  78 ++--
>  drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
>  drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 --
>  drivers/crypto/snow3g/rte_snow3g_pmd.c             |  43 ++-
>  drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  51 ++-
>  drivers/crypto/zuc/rte_zuc_pmd.c                   |  39 +-
>  drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  51 ++-
>  examples/ipsec-secgw/ipsec-secgw.c                 |  41 +-
>  examples/ipsec-secgw/ipsec.c                       |   8 +-
>  examples/ipsec-secgw/ipsec.h                       |   3 +-
>  examples/l2fwd-crypto/main.c                       |  77 +++-
>  lib/librte_cryptodev/rte_cryptodev.c               | 252 ++++++-------
>  lib/librte_cryptodev/rte_cryptodev.h               | 122 +++---
>  lib/librte_cryptodev/rte_cryptodev_pmd.h           |  60 ++-
>  lib/librte_cryptodev/rte_cryptodev_version.map     |   4 +
>  test/test/test_cryptodev.c                         | 388 ++++++++++++++-----
>  test/test/test_cryptodev_blockcipher.c             |  18 +-
>  test/test/test_cryptodev_blockcipher.h             |   1 +
>  test/test/test_cryptodev_perf.c                    | 216 ++++++++---
>  51 files changed, 2008 insertions(+), 955 deletions(-)
>

Series Acked-by: Declan Doherty <declan.doherty@intel.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 00/12] Device independent crypto sessions
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (12 preceding siblings ...)
  2017-07-05 15:21       ` [PATCH v4 00/12] Device independent crypto sessions Declan Doherty
@ 2017-07-05 16:26       ` Akhil Goyal
  2017-07-06 11:05       ` De Lara Guarch, Pablo
  14 siblings, 0 replies; 44+ messages in thread
From: Akhil Goyal @ 2017-07-05 16:26 UTC (permalink / raw)
  To: Pablo de Lara, declan.doherty, zbigniew.bodek, jerin.jacob,
	hemant.agrawal, fiona.trahe, john.griffin, deepak.k.jain
  Cc: dev

On 7/5/2017 10:56 AM, Pablo de Lara wrote:
> Currently, the cryptodev library requires the session mempools to be created inside each device.
> This can be a waste of memory, as several devices with the same driver could be using the same session.
> 
> This patchset makes changes in the library to allow session to contain multiple driver private data, so it can be used by multiple devices (no need to be the same driver).
> 
>                                    SESSION MEMPOOL <---|---> DEVICE INSTANCES
>                                   --------------------------------------------
> 
> .-------------.      .----------------------------.
> |   Crypto    |.     |         mempool obj        |
> | sym-session |<--.  | .--------------------------+
> |   mempool   ||  |  | | rte_cryptodev_session    |             .-------------.
> `-------------'|  |  | |                          |             |   DEVICE    |
>   `-----|-------'  |  | |                          |             |  INSTANCE   |
>         |          `-----                          |             | - device id |
>         +------------>| | - private data[type idx] |          .--| - session   |
>         |             `-+=================|..|====='          |  |   mempool   |
>         |                                 |  |                |  `-------------'
>         |                                 |  |                |
>         |     .----------------------.    |  |                |  .-------------.
>         +---->|      mempool obj     |    |  |   .--------.   |  |   DEVICE    |
>         |     | .--------------------+    |  |   | DRIVER |   |  |  INSTANCE   |
>         |     | | PMD's private data |<---+------| - type |<--+--|             |
>         |     +-+====================+       |   `--------'      |     ...     |
>         |                                    |                   |             |
>         |                                    |                   `-------------'
>         |                                    |
>         |     .----------------------.       |                   .-------------.
>         `---->|      mempool obj     |       |   .--------.      |   DEVICE    |
>               | .--------------------+       |   | DRIVER |      |  INSTANCE   |
>               | | PMD's private data |<------+---| - type |<-----|             |
>               `-+===================='           `--------'      |     ...     |
>                                                                  |             |
>                                                                  `-------------'
> Crypto sym-session mempool
> 
>     Mempool created to store rte_cryptodev_session objects as well as
>     private data for supported device types.
> 
>     This mempool replaces existing session mempools in device
>     instances to ease session management and improve consistency
>     (especially if the session is intended to be used for operations
>     performed on different devices).
> 
> rte_crypto_session
> 
>     New rte_cryptodev_session structure is taken from crypto session
>     mempool and can store more than one PMD's private data object (one
>     for each device type supported by sesion).
> 
>     Crypto operations will use device type id (unique for each driver) to
>     retrieve private data from rte_crypto_session right for the device
>     type they are performed on.
> 
> This patchset was based on the changes proposed in RFC
> (http://dpdk.org/ml/archives/dev/2017-May/065259.html)
> 
> This patchset depends on:
> http://dpdk.org/dev/patchwork/patch/26156/
> 
> Changes in v4:
> 
> - Introduced new rte_cryptodev_sym_session_clear() function,
>    which frees device private session data.
>    This needs to be called before calling rte_cryptodev_sym_session_free().
> 
> - Rebased on top of dpdk-next-crypto
> 
> Changes in v3:
> 
> - Removed internal PMD's session initialize function
> 
> - Created session mempool in the right socket in
>    the sample apps
> 
> - Get two objects (header and private data) from mempool
>    when using sessionless operations, to get a complete
>    session
> 
> - Fixed commit message (check-git-log failed)
> 
> - Added note of removed session_mp from rte_cryptodev_config
>    in documentation
> 
> - Fixed minor issues in documentation
> 
> 
> Changes in v2:
> 
> - Split the patch in multiple smaller patches to
>    facilitate the review
> 
> - Removed new API to create the session mempool,
>    since mempool can be created directly withe mempool_create
> 
> - Session headers and device private sessions can be
>    allocated from different mempools, for better memory
>    efficiency.
> 
> - Added a cover letter (partially extracted from RFC)
>    for better clarification on the intention of this patchset
> 
> Pablo de Lara (5):
>    cryptodev: remove unused cryptodev session structure
>    cryptodev: move session init out of session pool creation
>    cryptodev: add mempool pointer in queue pair setup
>    cryptodev: remove session init internal function
>    doc: add new crypto session information
> 
> Slawomir Mrozowicz (7):
>    cryptodev: add private session size retrieval function
>    cryptodev: do not create session mempool internally
>    cryptodev: change attach session to queue pair API
>    cryptodev: remove device id from crypto session
>    cryptodev: remove driver id from session
>    cryptodev: remove mempool from session
>    cryptodev: support device independent sessions
> 
>   app/test-crypto-perf/cperf.h                       |   5 +-
>   app/test-crypto-perf/cperf_ops.c                   |  21 +-
>   app/test-crypto-perf/cperf_ops.h                   |   1 +
>   app/test-crypto-perf/cperf_test_latency.c          |  12 +-
>   app/test-crypto-perf/cperf_test_latency.h          |   5 +-
>   app/test-crypto-perf/cperf_test_throughput.c       |  12 +-
>   app/test-crypto-perf/cperf_test_throughput.h       |   5 +-
>   app/test-crypto-perf/cperf_test_verify.c           |  12 +-
>   app/test-crypto-perf/cperf_test_verify.h           |   5 +-
>   app/test-crypto-perf/main.c                        |  85 ++++-
>   doc/guides/prog_guide/cryptodev_lib.rst            |  61 ++-
>   doc/guides/prog_guide/img/cryptodev_sym_sess.svg   | 418 ++++++++++++++++++---
>   doc/guides/rel_notes/release_17_08.rst             |  19 +
>   drivers/crypto/aesni_gcm/aesni_gcm_pmd.c           |  51 ++-
>   drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c       |  49 ++-
>   drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c         |  43 ++-
>   drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c     |  50 ++-
>   drivers/crypto/armv8/rte_armv8_pmd.c               |  39 +-
>   drivers/crypto/armv8/rte_armv8_pmd_ops.c           |  49 ++-
>   drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c        |  66 +++-
>   drivers/crypto/kasumi/rte_kasumi_pmd.c             |  42 ++-
>   drivers/crypto/kasumi/rte_kasumi_pmd_ops.c         |  51 ++-
>   drivers/crypto/null/null_crypto_pmd.c              |  43 ++-
>   drivers/crypto/null/null_crypto_pmd_ops.c          |  51 ++-
>   drivers/crypto/openssl/rte_openssl_pmd.c           |  41 +-
>   drivers/crypto/openssl/rte_openssl_pmd_ops.c       |  52 ++-
>   drivers/crypto/qat/qat_crypto.c                    |  93 +++--
>   drivers/crypto/qat/qat_crypto.h                    |  19 +-
>   drivers/crypto/qat/qat_qp.c                        |   2 +-
>   drivers/crypto/qat/rte_qat_cryptodev.c             |   1 -
>   drivers/crypto/scheduler/scheduler_failover.c      |  45 +--
>   .../crypto/scheduler/scheduler_pkt_size_distr.c    |  18 -
>   drivers/crypto/scheduler/scheduler_pmd_ops.c       |  78 ++--
>   drivers/crypto/scheduler/scheduler_pmd_private.h   |   4 -
>   drivers/crypto/scheduler/scheduler_roundrobin.c    |  41 --
>   drivers/crypto/snow3g/rte_snow3g_pmd.c             |  43 ++-
>   drivers/crypto/snow3g/rte_snow3g_pmd_ops.c         |  51 ++-
>   drivers/crypto/zuc/rte_zuc_pmd.c                   |  39 +-
>   drivers/crypto/zuc/rte_zuc_pmd_ops.c               |  51 ++-
>   examples/ipsec-secgw/ipsec-secgw.c                 |  41 +-
>   examples/ipsec-secgw/ipsec.c                       |   8 +-
>   examples/ipsec-secgw/ipsec.h                       |   3 +-
>   examples/l2fwd-crypto/main.c                       |  77 +++-
>   lib/librte_cryptodev/rte_cryptodev.c               | 252 ++++++-------
>   lib/librte_cryptodev/rte_cryptodev.h               | 122 +++---
>   lib/librte_cryptodev/rte_cryptodev_pmd.h           |  60 ++-
>   lib/librte_cryptodev/rte_cryptodev_version.map     |   4 +
>   test/test/test_cryptodev.c                         | 388 ++++++++++++++-----
>   test/test/test_cryptodev_blockcipher.c             |  18 +-
>   test/test/test_cryptodev_blockcipher.h             |   1 +
>   test/test/test_cryptodev_perf.c                    | 216 ++++++++---
>   51 files changed, 2008 insertions(+), 955 deletions(-)
> 
Tested for dpaa2_sec
Series Acked-by: Akhil Goyal <akhil.goyal@nxp.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 00/12] Device independent crypto sessions
  2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
                         ` (13 preceding siblings ...)
  2017-07-05 16:26       ` Akhil Goyal
@ 2017-07-06 11:05       ` De Lara Guarch, Pablo
  14 siblings, 0 replies; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2017-07-06 11:05 UTC (permalink / raw)
  To: Doherty, Declan, zbigniew.bodek, jerin.jacob, akhil.goyal,
	hemant.agrawal, Trahe, Fiona, Griffin, John, Jain, Deepak K
  Cc: dev



> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Wednesday, July 5, 2017 6:26 AM
> To: Doherty, Declan <declan.doherty@intel.com>;
> zbigniew.bodek@caviumnetworks.com; jerin.jacob@caviumnetworks.com;
> akhil.goyal@nxp.com; hemant.agrawal@nxp.com; Trahe, Fiona
> <fiona.trahe@intel.com>; Griffin, John <john.griffin@intel.com>; Jain,
> Deepak K <deepak.k.jain@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH v4 00/12] Device independent crypto sessions
> 
...
 
Applied to dpdk-next-crypto.
Thanks,

Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2017-07-06 11:07 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 18:45 [PATCH] cryptodev: make crypto session device independent Michal Jastrzebski
2017-06-30 17:09 ` [PATCH v2 00/11] Device independent crypto sessions Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 01/11] cryptodev: remove unused cryptodev session structure Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 02/11] cryptodev: move session init out of session pool creation Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 03/11] cryptodev: add private session size retrieval function Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 04/11] cryptodev: do not create session mempool internally Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 05/11] cryptodev: change attach session to queue pair API Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 06/11] cryptodev: remove dev_id from crypto session Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 07/11] cryptodev: remove driver id from session Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 08/11] cryptodev: remove mempool " Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 09/11] cryptodev: support device independent sessions Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 10/11] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
2017-06-30 17:09   ` [PATCH v2 11/11] doc: add new crypto session information Pablo de Lara
2017-07-02 20:15     ` Mcnamara, John
2017-07-02 15:57   ` [PATCH v3 00/12] Device independent crypto sessions Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 02/12] cryptodev: move session init out of session pool creation Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 03/12] cryptodev: add private session size retrieval function Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 04/12] cryptodev: do not create session mempool internally Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 05/12] cryptodev: change attach session to queue pair API Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 06/12] cryptodev: remove device id from crypto session Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 07/12] cryptodev: remove driver id from session Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 08/12] cryptodev: remove mempool " Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 09/12] cryptodev: support device independent sessions Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 10/12] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 11/12] cryptodev: remove session init internal function Pablo de Lara
2017-07-02 15:57     ` [PATCH v3 12/12] doc: add new crypto session information Pablo de Lara
2017-07-03 11:18       ` Mcnamara, John
2017-07-05  5:26     ` [PATCH v4 00/12] Device independent crypto sessions Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 01/12] cryptodev: remove unused cryptodev session structure Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 02/12] cryptodev: move session init out of session pool creation Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 03/12] cryptodev: add private session size retrieval function Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 04/12] cryptodev: do not create session mempool internally Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 05/12] cryptodev: change attach session to queue pair API Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 06/12] cryptodev: remove device id from crypto session Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 07/12] cryptodev: remove driver id from session Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 08/12] cryptodev: remove mempool " Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 09/12] cryptodev: support device independent sessions Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 10/12] cryptodev: add mempool pointer in queue pair setup Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 11/12] cryptodev: remove session init internal function Pablo de Lara
2017-07-05  5:26       ` [PATCH v4 12/12] doc: add new crypto session information Pablo de Lara
2017-07-05 15:21       ` [PATCH v4 00/12] Device independent crypto sessions Declan Doherty
2017-07-05 16:26       ` Akhil Goyal
2017-07-06 11:05       ` De Lara Guarch, Pablo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.