summaryrefslogtreecommitdiff
path: root/examples/l2fwd-crypto
diff options
context:
space:
mode:
authorSlawomir Mrozowicz <slawomirx.mrozowicz@intel.com>2017-07-05 06:26:17 +0100
committerPablo de Lara <pablo.de.lara.guarch@intel.com>2017-07-06 22:34:55 +0200
commitb3bbd9e5f265937164ed8c9c61d12f7543a745ea (patch)
treeb3a914718abcee6d937436c942f89b308aedf439 /examples/l2fwd-crypto
parent7c110ce7aa4e8b9c48a64343c040367dca411602 (diff)
downloaddpdk-b3bbd9e5f265937164ed8c9c61d12f7543a745ea.zip
dpdk-b3bbd9e5f265937164ed8c9c61d12f7543a745ea.tar.gz
dpdk-b3bbd9e5f265937164ed8c9c61d12f7543a745ea.tar.xz
cryptodev: support device independent sessions
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 driver private session data per driver to be used on a same session, and rte_cryptodev_sym_session_clear to clear this data before calling rte_cryptodev_sym_session_free. Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Acked-by: Declan Doherty <declan.doherty@intel.com> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Diffstat (limited to 'examples/l2fwd-crypto')
-rw-r--r--examples/l2fwd-crypto/main.c17
1 files changed, 14 insertions, 3 deletions
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;
}