[1/3] app/crypto-perf: use right API to free session
Checks
Commit Message
Use the right API for session freeing. Sessions can be asymmetric,
symmetric or security.
Fixes: 28dde5da503e ("app/crypto-perf: support lookaside IPsec")
Fixes: a538d1d2d01e ("test/crypto-perf: extend asymmetric crypto throughput test")
Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
app/test-crypto-perf/cperf_test_latency.c | 27 +++++++++++++++++------
app/test-crypto-perf/cperf_test_verify.c | 25 ++++++++++++++++-----
2 files changed, 39 insertions(+), 13 deletions(-)
@@ -43,15 +43,28 @@ struct priv_op_data {
static void
cperf_latency_test_free(struct cperf_latency_ctx *ctx)
{
- if (ctx) {
- if (ctx->sess)
- rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
-
- rte_mempool_free(ctx->pool);
+ if (ctx == NULL)
+ return;
- rte_free(ctx->res);
- rte_free(ctx);
+ if (ctx->sess != NULL) {
+ if (ctx->options->op_type == CPERF_ASYM_MODEX)
+ rte_cryptodev_asym_session_free(ctx->dev_id, ctx->sess);
+#ifdef RTE_LIB_SECURITY
+ else if (ctx->options->op_type == CPERF_PDCP ||
+ ctx->options->op_type == CPERF_DOCSIS ||
+ ctx->options->op_type == CPERF_IPSEC) {
+ struct rte_security_ctx *sec_ctx =
+ rte_cryptodev_get_sec_ctx(ctx->dev_id);
+ rte_security_session_destroy(sec_ctx, ctx->sess);
+ }
+#endif
+ else
+ rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
}
+
+ rte_mempool_free(ctx->pool);
+ rte_free(ctx->res);
+ rte_free(ctx);
}
void *
@@ -38,14 +38,27 @@ struct cperf_op_result {
static void
cperf_verify_test_free(struct cperf_verify_ctx *ctx)
{
- if (ctx) {
- if (ctx->sess)
- rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
-
- rte_mempool_free(ctx->pool);
+ if (ctx == NULL)
+ return;
- rte_free(ctx);
+ if (ctx->sess != NULL) {
+ if (ctx->options->op_type == CPERF_ASYM_MODEX)
+ rte_cryptodev_asym_session_free(ctx->dev_id, ctx->sess);
+#ifdef RTE_LIB_SECURITY
+ else if (ctx->options->op_type == CPERF_PDCP ||
+ ctx->options->op_type == CPERF_DOCSIS ||
+ ctx->options->op_type == CPERF_IPSEC) {
+ struct rte_security_ctx *sec_ctx =
+ rte_cryptodev_get_sec_ctx(ctx->dev_id);
+ rte_security_session_destroy(sec_ctx, ctx->sess);
+ }
+#endif
+ else
+ rte_cryptodev_sym_session_free(ctx->dev_id, ctx->sess);
}
+
+ rte_mempool_free(ctx->pool);
+ rte_free(ctx);
}
void *