Skip to content

Commit

Permalink
linux-gen: crypto: implement ODP_CRYPTO_TYPE_BASIC_AND_OOP
Browse files Browse the repository at this point in the history
Implement the BASIC_AND_OOP crypto op type which allows both basic
and out-of-place operations with the same session. Add the support
only for the openssl crypto module as that is now the only one which
supports out-of-place crypto.

Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
  • Loading branch information
JannePeltonen authored and MatiasElo committed Oct 20, 2023
1 parent 68baf7c commit cf95c7e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
3 changes: 2 additions & 1 deletion platform/linux-generic/arch/aarch64/odp_crypto_armv8.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
}
if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) {
if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP ||
param->op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) {
*status = ODP_CRYPTO_SES_ERR_PARAMS;
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
Expand Down
3 changes: 2 additions & 1 deletion platform/linux-generic/odp_crypto_ipsecmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
}
if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) {
if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP ||
param->op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) {
*status = ODP_CRYPTO_SES_ERR_PARAMS;
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
Expand Down
3 changes: 2 additions & 1 deletion platform/linux-generic/odp_crypto_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ odp_crypto_session_create(const odp_crypto_session_param_t *param,
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
}
if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) {
if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP ||
param->op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) {
*status = ODP_CRYPTO_SES_ERR_PARAMS;
*session_out = ODP_CRYPTO_SESSION_INVALID;
return -1;
Expand Down
33 changes: 27 additions & 6 deletions platform/linux-generic/odp_crypto_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,9 @@ int crypto_int(odp_packet_t pkt_in,

if (odp_likely(session->p.op_type == ODP_CRYPTO_OP_TYPE_BASIC)) {
out_pkt = pkt_in;
} else if (session->p.op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP &&
*pkt_out == ODP_PACKET_INVALID) {
out_pkt = pkt_in;
} else {
out_pkt = get_output_packet(session, pkt_in, *pkt_out);
if (odp_unlikely(out_pkt == ODP_PACKET_INVALID))
Expand Down Expand Up @@ -2762,10 +2765,19 @@ int odp_crypto_op(const odp_packet_t pkt_in[],
session = (odp_crypto_generic_session_t *)(intptr_t)param[i].session;
_ODP_ASSERT(ODP_CRYPTO_SYNC == session->p.op_mode);

if (odp_unlikely(session->p.op_type == ODP_CRYPTO_OP_TYPE_OOP))
if (odp_likely(session->p.op_type == ODP_CRYPTO_OP_TYPE_BASIC)) {
rc = crypto_int(pkt_in[i], &pkt_out[i], &param[i]);
} else if (session->p.op_type == ODP_CRYPTO_OP_TYPE_OOP) {
rc = crypto_int_oop(pkt_in[i], &pkt_out[i], &param[i]);
else
} else if (session->p.op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) {
if (pkt_out[i] == ODP_PACKET_INVALID) /* basic */
rc = crypto_int(pkt_in[i], &pkt_out[i], &param[i]);
else /* oop */
rc = crypto_int_oop(pkt_in[i], &pkt_out[i], &param[i]);
} else {
_ODP_ASSERT(session->p.op_type == ODP_CRYPTO_OP_TYPE_LEGACY);
rc = crypto_int(pkt_in[i], &pkt_out[i], &param[i]);
}
if (rc < 0)
break;
}
Expand All @@ -2788,13 +2800,22 @@ int odp_crypto_op_enq(const odp_packet_t pkt_in[],
_ODP_ASSERT(ODP_CRYPTO_ASYNC == session->p.op_mode);
_ODP_ASSERT(ODP_QUEUE_INVALID != session->p.compl_queue);

if (session->p.op_type != ODP_CRYPTO_OP_TYPE_BASIC)
if (odp_likely(session->p.op_type == ODP_CRYPTO_OP_TYPE_BASIC)) {
rc = crypto_int(pkt_in[i], &pkt, &param[i]);
} else if (session->p.op_type == ODP_CRYPTO_OP_TYPE_OOP) {
pkt = pkt_out[i];

if (odp_unlikely(session->p.op_type == ODP_CRYPTO_OP_TYPE_OOP))
rc = crypto_int_oop(pkt_in[i], &pkt, &param[i]);
else
} else if (session->p.op_type == ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP) {
pkt = pkt_out[i];
if (pkt_out[i] == ODP_PACKET_INVALID) /* basic */
rc = crypto_int(pkt_in[i], &pkt, &param[i]);
else /* oop */
rc = crypto_int_oop(pkt_in[i], &pkt, &param[i]);
} else {
_ODP_ASSERT(session->p.op_type == ODP_CRYPTO_OP_TYPE_LEGACY);
pkt = pkt_out[i];
rc = crypto_int(pkt_in[i], &pkt, &param[i]);
}
if (rc < 0)
break;

Expand Down

0 comments on commit cf95c7e

Please sign in to comment.