struct rte_crypto_sym_xform aead_xform;
struct rte_cryptodev_sym_session *sess = NULL;
struct rte_crypto_asym_xform xform = {0};
- int rc;
if (options->op_type == CPERF_ASYM_MODEX) {
xform.next = NULL;
xform.modex.exponent.data = perf_mod_e;
xform.modex.exponent.length = sizeof(perf_mod_e);
- sess = (void *)rte_cryptodev_asym_session_create(sess_mp);
+ sess = (void *)rte_cryptodev_asym_session_create(dev_id, &xform, sess_mp);
if (sess == NULL)
return NULL;
- rc = rte_cryptodev_asym_session_init(dev_id, (void *)sess,
- &xform, priv_mp);
- if (rc < 0) {
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id,
- (void *)sess);
- rte_cryptodev_asym_session_free((void *)sess);
- }
- return NULL;
- }
+
return sess;
}
#ifdef RTE_LIB_SECURITY
if (!ctx)
return;
if (ctx->sess) {
- if (ctx->options->op_type == CPERF_ASYM_MODEX) {
- rte_cryptodev_asym_session_clear(ctx->dev_id,
- (void *)ctx->sess);
- rte_cryptodev_asym_session_free((void *)ctx->sess);
- }
+ if (ctx->options->op_type == CPERF_ASYM_MODEX)
+ rte_cryptodev_asym_session_free(ctx->dev_id,
+ (void *)ctx->sess);
#ifdef RTE_LIB_SECURITY
else if (ctx->options->op_type == CPERF_PDCP ||
ctx->options->op_type == CPERF_DOCSIS ||
};
static int
-create_asym_op_pool_socket(uint8_t dev_id, int32_t socket_id,
- uint32_t nb_sessions)
+create_asym_op_pool_socket(int32_t socket_id, uint32_t nb_sessions)
{
char mp_name[RTE_MEMPOOL_NAMESIZE];
struct rte_mempool *mpool = NULL;
- unsigned int session_size =
- RTE_MAX(rte_cryptodev_asym_get_private_session_size(dev_id),
- rte_cryptodev_asym_get_header_session_size());
-
- if (session_pool_socket[socket_id].priv_mp == NULL) {
- snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "perf_asym_priv_pool%u",
- socket_id);
-
- mpool = rte_mempool_create(mp_name, nb_sessions, session_size,
- 0, 0, NULL, NULL, NULL, NULL,
- socket_id, 0);
- if (mpool == NULL) {
- printf("Cannot create pool \"%s\" on socket %d\n",
- mp_name, socket_id);
- return -ENOMEM;
- }
- printf("Allocated pool \"%s\" on socket %d\n", mp_name,
- socket_id);
- session_pool_socket[socket_id].priv_mp = mpool;
- }
if (session_pool_socket[socket_id].sess_mp == NULL) {
-
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "perf_asym_sess_pool%u",
socket_id);
- mpool = rte_mempool_create(mp_name, nb_sessions,
- session_size, 0, 0, NULL, NULL, NULL,
- NULL, socket_id, 0);
+ mpool = rte_cryptodev_asym_session_pool_create(mp_name,
+ nb_sessions, 0, socket_id);
if (mpool == NULL) {
printf("Cannot create pool \"%s\" on socket %d\n",
mp_name, socket_id);
}
if (opts->op_type == CPERF_ASYM_MODEX)
- ret = create_asym_op_pool_socket(cdev_id, socket_id,
+ ret = create_asym_op_pool_socket(socket_id,
sessions_needed);
else
ret = fill_session_pool_socket(socket_id, max_sess_size,
}
if (!sessionless) {
- sess = rte_cryptodev_asym_session_create(ts_params->session_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &xform_tc,
+ ts_params->session_mpool);
if (!sess) {
snprintf(test_msg, ASYM_TEST_MSG_LEN,
"line %u "
goto error_exit;
}
- if (rte_cryptodev_asym_session_init(dev_id, sess, &xform_tc,
- ts_params->session_mpool) < 0) {
- snprintf(test_msg, ASYM_TEST_MSG_LEN,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
- status = TEST_FAILED;
- goto error_exit;
- }
-
rte_crypto_op_attach_asym_session(op, sess);
} else {
asym_op->xform = &xform_tc;
snprintf(test_msg, ASYM_TEST_MSG_LEN, "SESSIONLESS PASS");
error_exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
return TEST_SKIPPED;
}
- sess = rte_cryptodev_asym_session_create(sess_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool);
if (!sess) {
RTE_LOG(ERR, USER1, "Session creation failed for "
"sign_verify\n");
- return TEST_FAILED;
- }
-
- if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
- sess_mpool) < 0) {
- RTE_LOG(ERR, USER1, "Unable to config asym session for "
- "sign_verify\n");
status = TEST_FAILED;
goto error_exit;
}
status = queue_ops_rsa_sign_verify(sess);
error_exit:
-
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
+ rte_cryptodev_asym_session_free(dev_id, sess);
TEST_ASSERT_EQUAL(status, 0, "Test failed");
return TEST_SKIPPED;
}
- sess = rte_cryptodev_asym_session_create(sess_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool);
if (!sess) {
RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n");
- return TEST_FAILED;
- }
-
- if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
- sess_mpool) < 0) {
- RTE_LOG(ERR, USER1, "Unable to config asym session for "
- "enc_dec\n");
status = TEST_FAILED;
goto error_exit;
}
error_exit:
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
+ rte_cryptodev_asym_session_free(dev_id, sess);
TEST_ASSERT_EQUAL(status, 0, "Test failed");
return TEST_SKIPPED;
}
- sess = rte_cryptodev_asym_session_create(sess_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &rsa_xform_crt, sess_mpool);
if (!sess) {
RTE_LOG(ERR, USER1, "Session creation failed for "
"sign_verify_crt\n");
status = TEST_FAILED;
- return status;
- }
-
- if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
- sess_mpool) < 0) {
- RTE_LOG(ERR, USER1, "Unable to config asym session for "
- "sign_verify_crt\n");
- status = TEST_FAILED;
goto error_exit;
}
+
status = queue_ops_rsa_sign_verify(sess);
error_exit:
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
+ rte_cryptodev_asym_session_free(dev_id, sess);
TEST_ASSERT_EQUAL(status, 0, "Test failed");
return TEST_SKIPPED;
}
- sess = rte_cryptodev_asym_session_create(sess_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &rsa_xform_crt, sess_mpool);
if (!sess) {
RTE_LOG(ERR, USER1, "Session creation failed for "
"enc_dec_crt\n");
- return TEST_FAILED;
- }
-
- if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
- sess_mpool) < 0) {
- RTE_LOG(ERR, USER1, "Unable to config asym session for "
- "enc_dec_crt\n");
status = TEST_FAILED;
goto error_exit;
}
+
status = queue_ops_rsa_enc_dec(sess);
error_exit:
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
+ rte_cryptodev_asym_session_free(dev_id, sess);
TEST_ASSERT_EQUAL(status, 0, "Test failed");
/* configure qp */
ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
ts_params->qp_conf.mp_session = ts_params->session_mpool;
- ts_params->qp_conf.mp_session_private = ts_params->session_mpool;
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,
qp_id, dev_id);
}
- /* setup asym session pool */
- unsigned int session_size = RTE_MAX(
- rte_cryptodev_asym_get_private_session_size(dev_id),
- rte_cryptodev_asym_get_header_session_size());
- /*
- * Create mempool with TEST_NUM_SESSIONS * 2,
- * to include the session headers
- */
- ts_params->session_mpool = rte_mempool_create(
- "test_asym_sess_mp",
- TEST_NUM_SESSIONS * 2,
- session_size,
- 0, 0, NULL, NULL, NULL,
- NULL, SOCKET_ID_ANY,
- 0);
+ ts_params->session_mpool = rte_cryptodev_asym_session_pool_create(
+ "test_asym_sess_mp", TEST_NUM_SESSIONS, 0,
+ SOCKET_ID_ANY);
TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
"session mempool allocation failed");
struct rte_crypto_asym_xform xform = *xfrm;
uint8_t peer[] = "01234567890123456789012345678901234567890123456789";
- sess = rte_cryptodev_asym_session_create(sess_mpool);
- if (sess == NULL) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s", __LINE__,
- "Session creation failed");
- status = TEST_FAILED;
- goto error_exit;
- }
/* set up crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
if (!op) {
asym_op->dh.shared_secret.data = output;
asym_op->dh.shared_secret.length = sizeof(output);
- if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
- sess_mpool) < 0) {
+ sess = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool);
+ if (sess == NULL) {
RTE_LOG(ERR, USER1,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
+ "line %u FAILED: %s", __LINE__,
+ "Session creation failed");
status = TEST_FAILED;
goto error_exit;
}
asym_op->dh.shared_secret.length);
error_exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
return status;
uint8_t output[TEST_DH_MOD_LEN];
struct rte_crypto_asym_xform xform = *xfrm;
- sess = rte_cryptodev_asym_session_create(sess_mpool);
- if (sess == NULL) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s", __LINE__,
- "Session creation failed");
- status = TEST_FAILED;
- goto error_exit;
- }
/* set up crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
if (!op) {
asym_op->dh.priv_key.data = output;
asym_op->dh.priv_key.length = sizeof(output);
- if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
- sess_mpool) < 0) {
+ sess = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool);
+ if (sess == NULL) {
RTE_LOG(ERR, USER1,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
+ "line %u FAILED: %s", __LINE__,
+ "Session creation failed");
status = TEST_FAILED;
goto error_exit;
}
error_exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
uint8_t output[TEST_DH_MOD_LEN];
struct rte_crypto_asym_xform xform = *xfrm;
- sess = rte_cryptodev_asym_session_create(sess_mpool);
- if (sess == NULL) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s", __LINE__,
- "Session creation failed");
- status = TEST_FAILED;
- goto error_exit;
- }
/* set up crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
if (!op) {
0);
asym_op->dh.priv_key = dh_test_params.priv_key;
- if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
- sess_mpool) < 0) {
+ sess = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool);
+ if (sess == NULL) {
RTE_LOG(ERR, USER1,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
+ "line %u FAILED: %s", __LINE__,
+ "Session creation failed");
status = TEST_FAILED;
goto error_exit;
}
asym_op->dh.priv_key.data, asym_op->dh.priv_key.length);
error_exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
struct rte_crypto_asym_xform pub_key_xform;
struct rte_crypto_asym_xform xform = *xfrm;
- sess = rte_cryptodev_asym_session_create(sess_mpool);
- if (sess == NULL) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s", __LINE__,
- "Session creation failed");
- status = TEST_FAILED;
- goto error_exit;
- }
-
/* set up crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
if (!op) {
asym_op->dh.pub_key.length = sizeof(out_pub_key);
asym_op->dh.priv_key.data = out_prv_key;
asym_op->dh.priv_key.length = sizeof(out_prv_key);
- if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
- sess_mpool) < 0) {
+
+ sess = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool);
+ if (sess == NULL) {
RTE_LOG(ERR, USER1,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
+ "line %u FAILED: %s", __LINE__,
+ "Session creation failed");
status = TEST_FAILED;
goto error_exit;
}
out_pub_key, asym_op->dh.pub_key.length);
error_exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
return TEST_SKIPPED;
}
- sess = rte_cryptodev_asym_session_create(sess_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &modinv_xform, sess_mpool);
if (!sess) {
RTE_LOG(ERR, USER1, "line %u "
"FAILED: %s", __LINE__,
goto error_exit;
}
- if (rte_cryptodev_asym_session_init(dev_id, sess, &modinv_xform,
- sess_mpool) < 0) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
- status = TEST_FAILED;
- goto error_exit;
- }
-
/* generate crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
if (!op) {
}
error_exit:
- if (sess) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op)
rte_crypto_op_free(op);
goto error_exit;
}
- sess = rte_cryptodev_asym_session_create(sess_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &modex_xform, sess_mpool);
if (!sess) {
RTE_LOG(ERR, USER1,
"line %u "
goto error_exit;
}
- if (rte_cryptodev_asym_session_init(dev_id, sess, &modex_xform,
- sess_mpool) < 0) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
- status = TEST_FAILED;
- goto error_exit;
- }
-
asym_op = op->asym;
memcpy(input, base, sizeof(base));
asym_op->modex.base.data = input;
}
error_exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
uint8_t s[TEST_DH_MOD_LEN];
uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
- sess = rte_cryptodev_asym_session_create(sess_mpool);
+ sess = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool);
if (sess == NULL) {
RTE_LOG(ERR, USER1,
"line %u FAILED: %s", __LINE__,
debug_hexdump(stdout, "priv_key: ", dsa_xform.dsa.x.data,
dsa_xform.dsa.x.length);
- if (rte_cryptodev_asym_session_init(dev_id, sess, &dsa_xform,
- sess_mpool) < 0) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s",
- __LINE__, "unabled to config sym session");
- status = TEST_FAILED;
- goto error_exit;
- }
-
/* attach asymmetric crypto session to crypto operations */
rte_crypto_op_attach_asym_session(op, sess);
asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
status = TEST_FAILED;
}
error_exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
return status;
rte_cryptodev_info_get(dev_id, &dev_info);
- sess = rte_cryptodev_asym_session_create(sess_mpool);
- if (sess == NULL) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s", __LINE__,
- "Session creation failed\n");
- status = TEST_FAILED;
- goto exit;
- }
-
/* Setup crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
if (op == NULL) {
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
xform.ec.curve_id = input_params.curve;
- if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
- sess_mpool) < 0) {
+ sess = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool);
+ if (sess == NULL) {
RTE_LOG(ERR, USER1,
"line %u FAILED: %s", __LINE__,
- "Unable to config asym session\n");
+ "Session creation failed\n");
status = TEST_FAILED;
goto exit;
}
}
exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
return status;
rte_cryptodev_info_get(dev_id, &dev_info);
- sess = rte_cryptodev_asym_session_create(sess_mpool);
- if (sess == NULL) {
- RTE_LOG(ERR, USER1,
- "line %u FAILED: %s", __LINE__,
- "Session creation failed\n");
- status = TEST_FAILED;
- goto exit;
- }
-
/* Setup crypto op data structure */
op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
if (op == NULL) {
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECPM;
xform.ec.curve_id = input_params.curve;
- if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
- sess_mpool) < 0) {
+ sess = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool);
+ if (sess == NULL) {
RTE_LOG(ERR, USER1,
"line %u FAILED: %s", __LINE__,
- "Unable to config asym session\n");
+ "Session creation failed\n");
status = TEST_FAILED;
goto exit;
}
}
exit:
- if (sess != NULL) {
- rte_cryptodev_asym_session_clear(dev_id, sess);
- rte_cryptodev_asym_session_free(sess);
- }
+ if (sess != NULL)
+ rte_cryptodev_asym_session_free(dev_id, sess);
if (op != NULL)
rte_crypto_op_free(op);
return status;
Application using both symmetric and asymmetric sessions should allocate and maintain
different sessions pools for each type.
-An application can use ``rte_cryptodev_get_asym_session_private_size()`` to
-get the private size of asymmetric session on a given crypto device. This
-function would allow an application to calculate the max device asymmetric
-session size of all crypto devices to create a single session mempool.
-If instead an application creates multiple asymmetric session mempools,
-the Crypto device framework also provides ``rte_cryptodev_asym_get_header_session_size()`` to get
-the size of an uninitialized session.
+An application can use ``rte_cryptodev_asym_session_pool_create()`` to create a mempool
+with a specified number of elements. The element size will allow for the session header,
+and the max private session size.
+The max private session size is chosen based on available crypto devices,
+the biggest private session size is used. This means any of those devices can be used,
+and the mempool element will have available space for its private session data.
Once the session mempools have been created, ``rte_cryptodev_asym_session_create()``
-is used to allocate an uninitialized asymmetric session from the given mempool.
-The session then must be initialized using ``rte_cryptodev_asym_session_init()``
-for each of the required crypto devices. An asymmetric transform chain
-is used to specify the operation and its parameters. See the section below for
-details on transforms.
+is used to allocate and initialize an asymmetric session from the given mempool.
+An asymmetric 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_asym_session_clear()``
for each of the crypto devices that are using the session, to free all driver
* ethdev: Old public macros and enumeration constants without ``RTE_ETH_`` prefix,
which are kept for backward compatibility, are marked as deprecated.
+* cryptodev: The asymmetric session handling was modified to use a single
+ mempool object. An API ``rte_cryptodev_asym_session_pool_create`` was added
+ to create a mempool with element size big enough to hold the generic asymmetric
+ session header and max size for a device private session data.
+ The API ``rte_cryptodev_asym_session_init`` was removed as the initialization
+ is now moved to ``rte_cryptodev_asym_session_create``.
+
ABI Changes
-----------
if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
asym_op = op->asym;
- ae_sess = get_asym_session_private_data(
- asym_op->session, cn10k_cryptodev_driver_id);
+ ae_sess = (struct cnxk_ae_sess *)
+ asym_op->session->sess_private_data;
ret = cnxk_ae_enqueue(qp, op, infl_req, &inst[0],
ae_sess);
if (unlikely(ret))
uintptr_t *mdata = infl_req->mdata;
struct cnxk_ae_sess *sess;
- sess = get_asym_session_private_data(
- op->session, cn10k_cryptodev_driver_id);
+ sess = (struct cnxk_ae_sess *)
+ op->session->sess_private_data;
cnxk_ae_post_process(cop, sess, (uint8_t *)mdata[0]);
}
if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
asym_op = op->asym;
- sess = get_asym_session_private_data(
- asym_op->session, cn9k_cryptodev_driver_id);
+ sess = (struct cnxk_ae_sess *)
+ asym_op->session->sess_private_data;
ret = cnxk_ae_enqueue(qp, op, infl_req, inst, sess);
inst->w7.u64 = sess->cpt_inst_w7;
} else {
uintptr_t *mdata = infl_req->mdata;
struct cnxk_ae_sess *sess;
- sess = get_asym_session_private_data(
- op->session, cn9k_cryptodev_driver_id);
+ sess = (struct cnxk_ae_sess *)
+ op->session->sess_private_data;
cnxk_ae_post_process(cop, sess, (uint8_t *)mdata[0]);
}
cnxk_ae_session_clear(struct rte_cryptodev *dev,
struct rte_cryptodev_asym_session *sess)
{
- struct rte_mempool *sess_mp;
struct cnxk_ae_sess *priv;
- priv = get_asym_session_private_data(sess, dev->driver_id);
+ priv = (struct cnxk_ae_sess *) sess->sess_private_data;
if (priv == NULL)
return;
/* Reset and free object back to pool */
memset(priv, 0, cnxk_ae_session_size_get(dev));
- sess_mp = rte_mempool_from_obj(priv);
- set_asym_session_private_data(sess, dev->driver_id, NULL);
- rte_mempool_put(sess_mp, priv);
}
int
cnxk_ae_session_cfg(struct rte_cryptodev *dev,
struct rte_crypto_asym_xform *xform,
- struct rte_cryptodev_asym_session *sess,
- struct rte_mempool *pool)
+ struct rte_cryptodev_asym_session *sess)
{
+ struct cnxk_ae_sess *priv =
+ (struct cnxk_ae_sess *) sess->sess_private_data;
struct cnxk_cpt_vf *vf = dev->data->dev_private;
struct roc_cpt *roc_cpt = &vf->cpt;
- struct cnxk_ae_sess *priv;
union cpt_inst_w7 w7;
int ret;
- if (rte_mempool_get(pool, (void **)&priv))
- return -ENOMEM;
-
- memset(priv, 0, sizeof(struct cnxk_ae_sess));
-
ret = cnxk_ae_fill_session_parameters(priv, xform);
- if (ret) {
- rte_mempool_put(pool, priv);
+ if (ret)
return ret;
- }
w7.u64 = 0;
w7.s.egrp = roc_cpt->eng_grp[CPT_ENG_TYPE_AE];
priv->cpt_inst_w7 = w7.u64;
priv->cnxk_fpm_iova = vf->cnxk_fpm_iova;
priv->ec_grp = vf->ec_grp;
- set_asym_session_private_data(sess, dev->driver_id, priv);
return 0;
}
struct rte_cryptodev_asym_session *sess);
int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
struct rte_crypto_asym_xform *xform,
- struct rte_cryptodev_asym_session *sess,
- struct rte_mempool *pool);
+ struct rte_cryptodev_asym_session *sess);
void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp);
static inline union rte_event_crypto_metadata *
}
static int
-otx_cpt_asym_session_cfg(struct rte_cryptodev *dev,
+otx_cpt_asym_session_cfg(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_asym_xform *xform __rte_unused,
- struct rte_cryptodev_asym_session *sess,
- struct rte_mempool *pool)
+ struct rte_cryptodev_asym_session *sess)
{
- struct cpt_asym_sess_misc *priv;
+ struct cpt_asym_sess_misc *priv = (struct cpt_asym_sess_misc *)
+ sess->sess_private_data;
int ret;
CPT_PMD_INIT_FUNC_TRACE();
- if (rte_mempool_get(pool, (void **)&priv)) {
- CPT_LOG_ERR("Could not allocate session private data");
- return -ENOMEM;
- }
-
- memset(priv, 0, sizeof(struct cpt_asym_sess_misc));
-
ret = cpt_fill_asym_session_parameters(priv, xform);
if (ret) {
CPT_LOG_ERR("Could not configure session parameters");
-
- /* Return session to mempool */
- rte_mempool_put(pool, priv);
return ret;
}
priv->cpt_inst_w7 = 0;
- set_asym_session_private_data(sess, dev->driver_id, priv);
return 0;
}
struct rte_cryptodev_asym_session *sess)
{
struct cpt_asym_sess_misc *priv;
- struct rte_mempool *sess_mp;
CPT_PMD_INIT_FUNC_TRACE();
- priv = get_asym_session_private_data(sess, dev->driver_id);
+ priv = (struct cpt_asym_sess_misc *) sess->sess_private_data;
if (priv == NULL)
return;
/* Free resources allocated during session configure */
cpt_free_asym_session_parameters(priv);
memset(priv, 0, otx_cpt_asym_session_size_get(dev));
- sess_mp = rte_mempool_from_obj(priv);
- set_asym_session_private_data(sess, dev->driver_id, NULL);
- rte_mempool_put(sess_mp, priv);
}
static __rte_always_inline void * __rte_hot
return NULL;
}
- sess = get_asym_session_private_data(asym_op->session,
- otx_cryptodev_driver_id);
+ sess = (struct cpt_asym_sess_misc *)
+ asym_op->session->sess_private_data;
/* Store phys_addr of the mdata to meta_buf */
params.meta_buf = rte_mempool_virt2iova(mdata);
struct rte_crypto_asym_op *op = cop->asym;
struct cpt_asym_sess_misc *sess;
- sess = get_asym_session_private_data(op->session,
- otx_cryptodev_driver_id);
+ sess = (struct cpt_asym_sess_misc *) op->session->sess_private_data;
switch (sess->xfrm_type) {
case RTE_CRYPTO_ASYM_XFORM_RSA:
} else {
if (likely(op->asym->session != NULL))
asym_sess = (struct openssl_asym_session *)
- get_asym_session_private_data(
- op->asym->session,
- cryptodev_driver_id);
+ op->asym->session->sess_private_data;
if (asym_sess == NULL)
op->status =
RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
static int
openssl_pmd_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_asym_xform *xform,
- struct rte_cryptodev_asym_session *sess,
- struct rte_mempool *mempool)
+ struct rte_cryptodev_asym_session *sess)
{
void *asym_sess_private_data;
int ret;
return -EINVAL;
}
- if (rte_mempool_get(mempool, &asym_sess_private_data)) {
- CDEV_LOG_ERR(
- "Couldn't get object from session mempool");
- return -ENOMEM;
- }
-
+ asym_sess_private_data = sess->sess_private_data;
ret = openssl_set_asym_session_parameters(asym_sess_private_data,
xform);
if (ret != 0) {
OPENSSL_LOG(ERR, "failed configure session parameters");
-
- /* Return session to mempool */
- rte_mempool_put(mempool, asym_sess_private_data);
return ret;
}
- set_asym_session_private_data(sess, dev->driver_id,
- asym_sess_private_data);
-
return 0;
}
* so it doesn't leave key material behind
*/
static void
-openssl_pmd_asym_session_clear(struct rte_cryptodev *dev,
+openssl_pmd_asym_session_clear(struct rte_cryptodev *dev __rte_unused,
struct rte_cryptodev_asym_session *sess)
{
- uint8_t index = dev->driver_id;
- void *sess_priv = get_asym_session_private_data(sess, index);
+ void *sess_priv = sess->sess_private_data;
/* Zero out the whole structure */
if (sess_priv) {
openssl_reset_asym_session(sess_priv);
memset(sess_priv, 0, sizeof(struct openssl_asym_session));
- struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
- set_asym_session_private_data(sess, index, NULL);
- rte_mempool_put(sess_mp, sess_priv);
}
}
op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
ctx = (struct qat_asym_session *)
- get_asym_session_private_data(
- op->asym->session, qat_asym_driver_id);
+ op->asym->session->sess_private_data;
if (unlikely(ctx == NULL)) {
QAT_LOG(ERR, "Session has not been created for this device");
goto error;
}
if (rx_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
- ctx = (struct qat_asym_session *)get_asym_session_private_data(
- rx_op->asym->session, qat_asym_driver_id);
+ ctx = (struct qat_asym_session *)
+ rx_op->asym->session->sess_private_data;
qat_asym_collect_response(rx_op, cookie, ctx->xform);
} else if (rx_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
qat_asym_collect_response(rx_op, cookie, rx_op->asym->xform);
}
int
-qat_asym_session_configure(struct rte_cryptodev *dev,
+qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_asym_xform *xform,
- struct rte_cryptodev_asym_session *sess,
- struct rte_mempool *mempool)
+ struct rte_cryptodev_asym_session *sess)
{
- int err = 0;
- void *sess_private_data;
struct qat_asym_session *session;
- if (rte_mempool_get(mempool, &sess_private_data)) {
- QAT_LOG(ERR,
- "Couldn't get object from session mempool");
- return -ENOMEM;
- }
-
- session = sess_private_data;
+ session = (struct qat_asym_session *) sess->sess_private_data;
if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) {
if (xform->modex.exponent.length == 0 ||
xform->modex.modulus.length == 0) {
QAT_LOG(ERR, "Invalid mod exp input parameter");
- err = -EINVAL;
- goto error;
+ return -EINVAL;
}
} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {
if (xform->modinv.modulus.length == 0) {
QAT_LOG(ERR, "Invalid mod inv input parameter");
- err = -EINVAL;
- goto error;
+ return -EINVAL;
}
} else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {
if (xform->rsa.n.length == 0) {
QAT_LOG(ERR, "Invalid rsa input parameter");
- err = -EINVAL;
- goto error;
+ return -EINVAL;
}
} else if (xform->xform_type >= RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END
|| xform->xform_type <= RTE_CRYPTO_ASYM_XFORM_NONE) {
QAT_LOG(ERR, "Invalid asymmetric crypto xform");
- err = -EINVAL;
- goto error;
+ return -EINVAL;
} else {
QAT_LOG(ERR, "Asymmetric crypto xform not implemented");
- err = -EINVAL;
- goto error;
+ return -EINVAL;
}
session->xform = xform;
- qat_asym_build_req_tmpl(sess_private_data);
- set_asym_session_private_data(sess, dev->driver_id,
- sess_private_data);
+ qat_asym_build_req_tmpl(session);
return 0;
-error:
- rte_mempool_put(mempool, sess_private_data);
- return err;
}
unsigned int qat_asym_session_get_private_size(
qat_asym_session_clear(struct rte_cryptodev *dev,
struct rte_cryptodev_asym_session *sess)
{
- uint8_t index = dev->driver_id;
- void *sess_priv = get_asym_session_private_data(sess, index);
+ void *sess_priv = sess->sess_private_data;
struct qat_asym_session *s = (struct qat_asym_session *)sess_priv;
- if (sess_priv) {
+ if (sess_priv)
memset(s, 0, qat_asym_session_get_private_size(dev));
- struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
-
- set_asym_session_private_data(sess, index, NULL);
- rte_mempool_put(sess_mp, sess_priv);
- }
}
};
int
-qat_asym_session_configure(struct rte_cryptodev *dev,
+qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_asym_xform *xform,
- struct rte_cryptodev_asym_session *sess,
- struct rte_mempool *mempool);
+ struct rte_cryptodev_asym_session *sess);
unsigned int
qat_asym_session_get_private_size(struct rte_cryptodev *dev);
* @param dev Crypto device pointer
* @param xform Single or chain of crypto xforms
* @param session Pointer to cryptodev's private session structure
- * @param mp Mempool where the private session is allocated
*
* @return
* - Returns 0 if private session structure have been created successfully.
*/
typedef int (*cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev,
struct rte_crypto_asym_xform *xform,
- struct rte_cryptodev_asym_session *session,
- struct rte_mempool *mp);
+ struct rte_cryptodev_asym_session *session);
/**
* Free driver private session data.
*
typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
struct rte_cryptodev_sym_session *sess);
/**
- * Free asymmetric session private data.
+ * Clear asymmetric session private data.
*
* @param dev Crypto device pointer
* @param sess Cryptodev session structure
*/
-typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *dev,
+typedef void (*cryptodev_asym_clear_session_t)(struct rte_cryptodev *dev,
struct rte_cryptodev_asym_session *sess);
/**
* Perform actual crypto processing (encrypt/digest or auth/decrypt)
/**< Configure asymmetric Crypto session. */
cryptodev_sym_free_session_t sym_session_clear;
/**< Clear a Crypto sessions private data. */
- cryptodev_asym_free_session_t asym_session_clear;
+ cryptodev_asym_clear_session_t asym_session_clear;
/**< Clear a Crypto sessions private data. */
union {
cryptodev_sym_cpu_crypto_process_t sym_cpu_process;
sess->sess_data[driver_id].data = private_data;
}
-static inline void *
-get_asym_session_private_data(const struct rte_cryptodev_asym_session *sess,
- uint8_t driver_id) {
- return sess->sess_private_data[driver_id];
-}
-
-static inline void
-set_asym_session_private_data(struct rte_cryptodev_asym_session *sess,
- uint8_t driver_id, void *private_data)
-{
- sess->sess_private_data[driver_id] = private_data;
-}
-
#endif /* _CRYPTODEV_PMD_H_ */
RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_pool_create,
lib.cryptodev.sym.pool.create)
+RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_pool_create,
+ lib.cryptodev.asym.pool.create)
+
RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_create,
lib.cryptodev.sym.create)
RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_init,
lib.cryptodev.sym.init)
-RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_init,
- lib.cryptodev.asym.init)
-
RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_clear,
lib.cryptodev.sym.clear)
-RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_clear,
- lib.cryptodev.asym.clear)
-
RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_enqueue_burst,
lib.cryptodev.enq.burst)
};
/**
- * The private data structure stored in the session mempool private data.
+ * The private data structure stored in the sym session mempool private data.
*/
struct rte_cryptodev_sym_session_pool_private_data {
uint16_t nb_drivers;
/**< session user data will be placed after sess_data */
};
+/**
+ * The private data structure stored in the asym session mempool private data.
+ */
+struct rte_cryptodev_asym_session_pool_private_data {
+ uint16_t max_priv_session_sz;
+ /**< Size of private session data used when creating mempool */
+};
+
int
rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
const char *algo_string)
return 0;
}
-int
-rte_cryptodev_asym_session_init(uint8_t dev_id,
- struct rte_cryptodev_asym_session *sess,
- struct rte_crypto_asym_xform *xforms,
- struct rte_mempool *mp)
-{
- struct rte_cryptodev *dev;
- uint8_t index;
- int ret;
-
- if (!rte_cryptodev_is_valid_dev(dev_id)) {
- CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
- return -EINVAL;
- }
-
- dev = rte_cryptodev_pmd_get_dev(dev_id);
-
- if (sess == NULL || xforms == NULL || dev == NULL)
- return -EINVAL;
-
- index = dev->driver_id;
-
- RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_configure,
- -ENOTSUP);
-
- if (sess->sess_private_data[index] == NULL) {
- ret = dev->dev_ops->asym_session_configure(dev,
- xforms,
- sess, mp);
- if (ret < 0) {
- CDEV_LOG_ERR(
- "dev_id %d failed to configure session details",
- dev_id);
- return ret;
- }
- }
-
- rte_cryptodev_trace_asym_session_init(dev_id, sess, xforms, mp);
- return 0;
-}
-
struct rte_mempool *
rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts,
uint32_t elt_size, uint32_t cache_size, uint16_t user_data_size,
return mp;
}
+struct rte_mempool *
+rte_cryptodev_asym_session_pool_create(const char *name, uint32_t nb_elts,
+ uint32_t cache_size, int socket_id)
+{
+ struct rte_mempool *mp;
+ struct rte_cryptodev_asym_session_pool_private_data *pool_priv;
+ uint32_t obj_sz, obj_sz_aligned;
+ uint8_t dev_id, priv_sz, max_priv_sz = 0;
+
+ for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+ if (rte_cryptodev_is_valid_dev(dev_id)) {
+ priv_sz = rte_cryptodev_asym_get_private_session_size(dev_id);
+ if (priv_sz > max_priv_sz)
+ max_priv_sz = priv_sz;
+ }
+ if (max_priv_sz == 0) {
+ CDEV_LOG_INFO("Could not set max private session size\n");
+ return NULL;
+ }
+
+ obj_sz = rte_cryptodev_asym_get_header_session_size() + max_priv_sz;
+ obj_sz_aligned = RTE_ALIGN_CEIL(obj_sz, RTE_CACHE_LINE_SIZE);
+
+ mp = rte_mempool_create(name, nb_elts, obj_sz_aligned, cache_size,
+ (uint32_t)(sizeof(*pool_priv)),
+ NULL, NULL, NULL, NULL,
+ socket_id, 0);
+ if (mp == NULL) {
+ CDEV_LOG_ERR("%s(name=%s) failed, rte_errno=%d\n",
+ __func__, name, rte_errno);
+ return NULL;
+ }
+
+ pool_priv = rte_mempool_get_priv(mp);
+ if (!pool_priv) {
+ CDEV_LOG_ERR("%s(name=%s) failed to get private data\n",
+ __func__, name);
+ rte_mempool_free(mp);
+ return NULL;
+ }
+ pool_priv->max_priv_session_sz = max_priv_sz;
+
+ rte_cryptodev_trace_asym_session_pool_create(name, nb_elts,
+ cache_size, mp);
+ return mp;
+}
+
static unsigned int
rte_cryptodev_sym_session_data_size(struct rte_cryptodev_sym_session *sess)
{
}
struct rte_cryptodev_asym_session *
-rte_cryptodev_asym_session_create(struct rte_mempool *mp)
+rte_cryptodev_asym_session_create(uint8_t dev_id,
+ struct rte_crypto_asym_xform *xforms, struct rte_mempool *mp)
{
struct rte_cryptodev_asym_session *sess;
- unsigned int session_size =
+ uint32_t session_priv_data_sz;
+ struct rte_cryptodev_asym_session_pool_private_data *pool_priv;
+ unsigned int session_header_size =
rte_cryptodev_asym_get_header_session_size();
+ struct rte_cryptodev *dev;
+ int ret;
+
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
+ CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
+ return NULL;
+ }
+
+ dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+ if (dev == NULL)
+ return NULL;
if (!mp) {
CDEV_LOG_ERR("invalid mempool\n");
return NULL;
}
+ session_priv_data_sz = rte_cryptodev_asym_get_private_session_size(
+ dev_id);
+ pool_priv = rte_mempool_get_priv(mp);
+
+ if (pool_priv->max_priv_session_sz < session_priv_data_sz) {
+ CDEV_LOG_DEBUG(
+ "The private session data size used when creating the mempool is smaller than this device's private session data.");
+ return NULL;
+ }
+
/* Verify if provided mempool can hold elements big enough. */
- if (mp->elt_size < session_size) {
+ if (mp->elt_size < session_header_size + session_priv_data_sz) {
CDEV_LOG_ERR(
"mempool elements too small to hold session objects");
return NULL;
return NULL;
}
- /* Clear device session pointer.
- * Include the flag indicating presence of private data
- */
- memset(sess, 0, session_size);
+ sess->driver_id = dev->driver_id;
+ sess->max_priv_data_sz = pool_priv->max_priv_session_sz;
+
+ /* Clear device session pointer.*/
+ memset(sess->sess_private_data, 0, session_priv_data_sz);
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_configure, NULL);
- rte_cryptodev_trace_asym_session_create(mp, sess);
+ if (sess->sess_private_data[0] == 0) {
+ ret = dev->dev_ops->asym_session_configure(dev, xforms, sess);
+ if (ret < 0) {
+ CDEV_LOG_ERR(
+ "dev_id %d failed to configure session details",
+ dev_id);
+ return NULL;
+ }
+ }
+
+ rte_cryptodev_trace_asym_session_create(dev_id, xforms, mp);
return sess;
}
return 0;
}
-int
-rte_cryptodev_asym_session_clear(uint8_t dev_id,
- struct rte_cryptodev_asym_session *sess)
-{
- struct rte_cryptodev *dev;
-
- if (!rte_cryptodev_is_valid_dev(dev_id)) {
- CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
- return -EINVAL;
- }
-
- dev = rte_cryptodev_pmd_get_dev(dev_id);
-
- if (dev == NULL || sess == NULL)
- return -EINVAL;
-
- RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_clear, -ENOTSUP);
-
- dev->dev_ops->asym_session_clear(dev, sess);
-
- rte_cryptodev_trace_sym_session_clear(dev_id, sess);
- return 0;
-}
-
int
rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess)
{
}
int
-rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess)
+rte_cryptodev_asym_session_free(uint8_t dev_id,
+ struct rte_cryptodev_asym_session *sess)
{
- uint8_t i;
- void *sess_priv;
struct rte_mempool *sess_mp;
+ struct rte_cryptodev *dev;
- if (sess == NULL)
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
+ CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
-
- /* Check that all device private data has been freed */
- for (i = 0; i < nb_drivers; i++) {
- sess_priv = get_asym_session_private_data(sess, i);
- if (sess_priv != NULL)
- return -EBUSY;
}
+ dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+ if (dev == NULL || sess == NULL)
+ return -EINVAL;
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_clear, -ENOTSUP);
+
+ dev->dev_ops->asym_session_clear(dev, sess);
+
/* Return session to mempool */
sess_mp = rte_mempool_from_obj(sess);
rte_mempool_put(sess_mp, sess);
- rte_cryptodev_trace_asym_session_free(sess);
+ rte_cryptodev_trace_asym_session_free(dev_id, sess);
return 0;
}
unsigned int
rte_cryptodev_asym_get_header_session_size(void)
{
- /*
- * Header contains pointers to the private data
- * of all registered drivers, and a flag which
- * indicates presence of private data
- */
- return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t));
+ return sizeof(struct rte_cryptodev_asym_session);
}
unsigned int
rte_cryptodev_asym_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_is_valid_dev(dev_id))
return 0;
priv_sess_size = (*dev->dev_ops->asym_session_get_size)(dev);
- if (priv_sess_size < header_size)
- return header_size;
return priv_sess_size;
-
}
int
};
/** Cryptodev asymmetric crypto session */
-struct rte_cryptodev_asym_session {
- __extension__ void *sess_private_data[0];
- /**< Private asymmetric session material */
+RTE_STD_C11 struct rte_cryptodev_asym_session {
+ uint8_t driver_id;
+ /**< Session driver ID. */
+ uint16_t max_priv_data_sz;
+ /**< Size of private data used when creating mempool */
+ uint8_t padding[5];
+ uint8_t sess_private_data[0];
};
/**
uint32_t elt_size, uint32_t cache_size, uint16_t priv_size,
int socket_id);
+/**
+ * Create an asymmetric session mempool.
+ *
+ * @param name
+ * The unique mempool name.
+ * @param nb_elts
+ * The number of elements in the mempool.
+ * @param cache_size
+ * The number of per-lcore cache elements
+ * @param socket_id
+ * The *socket_id* argument is the socket identifier in the case of
+ * NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA
+ * constraint for the reserved zone.
+ *
+ * @return
+ * - On success return mempool
+ * - On failure returns NULL
+ */
+__rte_experimental
+struct rte_mempool *
+rte_cryptodev_asym_session_pool_create(const char *name, uint32_t nb_elts,
+ uint32_t cache_size, int socket_id);
+
/**
* Create symmetric crypto session header (generic with no private data)
*
rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
/**
- * Create asymmetric crypto session header (generic with no private data)
+ * Create and initialise an asymmetric crypto session structure.
+ * Calls the PMD to configure the private session data.
*
- * @param mempool mempool to allocate asymmetric session
- * objects from
+ * @param dev_id ID of device that we want the session to be used on
+ * @param xforms Asymmetric crypto transform operations to apply on flow
+ * processed with this session
+ * @param mp mempool to allocate asymmetric session
+ * objects from
* @return
* - On success return pointer to asym-session
* - On failure returns NULL
*/
__rte_experimental
struct rte_cryptodev_asym_session *
-rte_cryptodev_asym_session_create(struct rte_mempool *mempool);
+rte_cryptodev_asym_session_create(uint8_t dev_id,
+ struct rte_crypto_asym_xform *xforms, struct rte_mempool *mp);
/**
* Frees symmetric crypto session header, after checking that all
rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
/**
- * Frees asymmetric crypto session header, after checking that all
- * the device private data has been freed, returning it
- * to its original mempool.
+ * Clears and frees asymmetric crypto session header and private data,
+ * returning it to its original mempool.
*
+ * @param dev_id ID of device that uses the asymmetric session.
* @param sess Session header to be freed.
*
* @return
* - 0 if successful.
- * - -EINVAL if session is NULL.
- * - -EBUSY if not all device private data has been freed.
+ * - -EINVAL if device is invalid or session is NULL.
*/
__rte_experimental
int
-rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess);
+rte_cryptodev_asym_session_free(uint8_t dev_id,
+ struct rte_cryptodev_asym_session *sess);
/**
* Fill out private data for the device id, based on its device type.
struct rte_crypto_sym_xform *xforms,
struct rte_mempool *mempool);
-/**
- * Initialize asymmetric session on a device with specific asymmetric xform
- *
- * @param dev_id ID of device that we want the session to be used on
- * @param sess Session to be set up on a device
- * @param xforms Asymmetric crypto transform operations to apply on flow
- * processed with this session
- * @param mempool Mempool to be used for internal allocation.
- *
- * @return
- * - On success, zero.
- * - -EINVAL if input parameters are invalid.
- * - -ENOTSUP if crypto device does not support the crypto transform.
- * - -ENOMEM if the private session could not be allocated.
- */
-__rte_experimental
-int
-rte_cryptodev_asym_session_init(uint8_t dev_id,
- struct rte_cryptodev_asym_session *sess,
- struct rte_crypto_asym_xform *xforms,
- struct rte_mempool *mempool);
-
/**
* Frees private data for the device id, based on its device type,
* returning it to its mempool. It is the application's responsibility
rte_cryptodev_sym_session_clear(uint8_t dev_id,
struct rte_cryptodev_sym_session *sess);
-/**
- * Frees resources held by asymmetric session during rte_cryptodev_session_init
- *
- * @param dev_id ID of device that uses the asymmetric session.
- * @param sess Asymmetric session setup on device using
- * rte_cryptodev_session_init
- * @return
- * - 0 if successful.
- * - -EINVAL if device is invalid or session is NULL.
- */
-__rte_experimental
-int
-rte_cryptodev_asym_session_clear(uint8_t dev_id,
- struct rte_cryptodev_asym_session *sess);
-
/**
* Get the size of the header session, for all registered drivers excluding
* the user data size.
struct rte_cryptodev_sym_session *sess);
/**
- * Get the size of the asymmetric session header, for all registered drivers.
+ * Get the size of the asymmetric session header.
*
* @return
* Size of the asymmetric header session.
rte_trace_point_emit_u16(sess->user_data_sz);
)
+RTE_TRACE_POINT(
+ rte_cryptodev_trace_asym_session_pool_create,
+ RTE_TRACE_POINT_ARGS(const char *name, uint32_t nb_elts,
+ uint32_t cache_size, void *mempool),
+ rte_trace_point_emit_string(name);
+ rte_trace_point_emit_u32(nb_elts);
+ rte_trace_point_emit_u32(cache_size);
+ rte_trace_point_emit_ptr(mempool);
+)
+
RTE_TRACE_POINT(
rte_cryptodev_trace_asym_session_create,
- RTE_TRACE_POINT_ARGS(void *mempool,
- struct rte_cryptodev_asym_session *sess),
+ RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *xforms, void *mempool),
+ rte_trace_point_emit_u8(dev_id);
+ rte_trace_point_emit_ptr(xforms);
rte_trace_point_emit_ptr(mempool);
- rte_trace_point_emit_ptr(sess);
)
RTE_TRACE_POINT(
RTE_TRACE_POINT(
rte_cryptodev_trace_asym_session_free,
- RTE_TRACE_POINT_ARGS(struct rte_cryptodev_asym_session *sess),
+ RTE_TRACE_POINT_ARGS(uint8_t dev_id,
+ struct rte_cryptodev_asym_session *sess),
+ rte_trace_point_emit_u8(dev_id);
rte_trace_point_emit_ptr(sess);
)
rte_trace_point_emit_ptr(mempool);
)
-RTE_TRACE_POINT(
- rte_cryptodev_trace_asym_session_init,
- RTE_TRACE_POINT_ARGS(uint8_t dev_id,
- struct rte_cryptodev_asym_session *sess, void *xforms,
- void *mempool),
- rte_trace_point_emit_u8(dev_id);
- rte_trace_point_emit_ptr(sess);
- rte_trace_point_emit_ptr(xforms);
- rte_trace_point_emit_ptr(mempool);
-)
-
RTE_TRACE_POINT(
rte_cryptodev_trace_sym_session_clear,
RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess),
rte_trace_point_emit_ptr(sess);
)
-RTE_TRACE_POINT(
- rte_cryptodev_trace_asym_session_clear,
- RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess),
- rte_trace_point_emit_u8(dev_id);
- rte_trace_point_emit_ptr(sess);
-)
-
#ifdef __cplusplus
}
#endif
rte_cryptodev_asym_get_header_session_size;
rte_cryptodev_asym_get_private_session_size;
rte_cryptodev_asym_get_xform_enum;
- rte_cryptodev_asym_session_clear;
rte_cryptodev_asym_session_create;
rte_cryptodev_asym_session_free;
- rte_cryptodev_asym_session_init;
rte_cryptodev_asym_xform_capability_check_modlen;
rte_cryptodev_asym_xform_capability_check_optype;
rte_cryptodev_sym_cpu_crypto_process;
__rte_cryptodev_trace_sym_session_free;
__rte_cryptodev_trace_asym_session_free;
__rte_cryptodev_trace_sym_session_init;
- __rte_cryptodev_trace_asym_session_init;
__rte_cryptodev_trace_sym_session_clear;
- __rte_cryptodev_trace_asym_session_clear;
__rte_cryptodev_trace_dequeue_burst;
__rte_cryptodev_trace_enqueue_burst;
rte_cryptodev_remove_deq_callback;
rte_cryptodev_remove_enq_callback;
+ # added 22.03
+ rte_cryptodev_asym_session_pool_create;
+ __rte_cryptodev_trace_asym_session_pool_create;
};
INTERNAL {