Signed-off-by: Robbie King <[email protected]>
---
 .../linux-generic/include/odp_crypto_internal.h    |  4 +-
 platform/linux-generic/odp_crypto.c                | 75 +++++++++++-----------
 2 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 04db333..237b1e8 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -59,7 +59,6 @@ struct odp_crypto_generic_session {
                } data;
                crypto_func_t func;
        } auth;
-
 };
 
 /**
@@ -67,8 +66,7 @@ struct odp_crypto_generic_session {
  */
 typedef struct odp_crypto_generic_op_result {
        uint32_t magic;
-       odp_crypto_compl_status_t cipher;
-       odp_crypto_compl_status_t auth;
+       odp_crypto_op_result_t result;
 } odp_crypto_generic_op_result_t;
 
 /**
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index d3cdec7..051152c 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -334,18 +334,16 @@ odp_crypto_session_create(odp_crypto_session_params_t 
*params,
        return 0;
 }
 
-
 int
 odp_crypto_operation(odp_crypto_op_params_t *params,
                     bool *posted,
-                    odp_buffer_t completion_event)
+                    odp_crypto_op_result_t *result)
 {
        enum crypto_alg_err rc_cipher = ODP_CRYPTO_ALG_ERR_NONE;
        enum crypto_alg_err rc_auth = ODP_CRYPTO_ALG_ERR_NONE;
        odp_crypto_generic_session_t *session;
-       odp_crypto_generic_op_result_t *result;
+       odp_crypto_op_result_t local_result;
 
-       *posted = 0;
        session = (odp_crypto_generic_session_t *)(intptr_t)params->session;
 
        /* Resolve output buffer */
@@ -357,9 +355,6 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
                if (odp_unlikely(ODP_PACKET_INVALID == params->out_pkt))
                        abort();
                odp_packet_copy(params->out_pkt, params->pkt);
-               if (completion_event == odp_packet_to_buffer(params->pkt))
-                       completion_event =
-                               odp_packet_to_buffer(params->out_pkt);
                odph_packet_free(params->pkt);
                params->pkt = ODP_PACKET_INVALID;
        }
@@ -373,18 +368,36 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
                rc_cipher = session->cipher.func(params, session);
        }
 
-       /* Build Result (no HW so no errors) */
-       result = get_op_result_from_buffer(completion_event);
-       result->magic = OP_RESULT_MAGIC;
-       result->cipher.alg_err = rc_cipher;
-       result->cipher.hw_err = ODP_CRYPTO_HW_ERR_NONE;
-       result->auth.alg_err = rc_auth;
-       result->auth.hw_err = ODP_CRYPTO_HW_ERR_NONE;
+       /* Fill in result */
+       local_result.ctx = params->ctx;
+       local_result.pkt = params->out_pkt;
+       local_result.cipher.alg_err = rc_cipher;
+       local_result.cipher.hw_err = ODP_CRYPTO_HW_ERR_NONE;
+       local_result.auth.alg_err = rc_auth;
+       local_result.auth.hw_err = ODP_CRYPTO_HW_ERR_NONE;
 
        /* If specified during creation post event to completion queue */
        if (ODP_QUEUE_INVALID != session->compl_queue) {
+               odp_crypto_compl_event_t completion_event;
+               odp_crypto_generic_op_result_t *op_result;
+
+               /* Linux generic will always use packet for completion event */
+               completion_event = odp_packet_to_buffer(params->out_pkt);
+
+               /* Asynchronous, build result (no HW so no errors) and send it*/
+               op_result = get_op_result_from_buffer(completion_event);
+               op_result->magic = OP_RESULT_MAGIC;
+               op_result->result = local_result;
                odp_queue_enq(session->compl_queue, completion_event);
+
+               /* Indicate to caller operation was async */
                *posted = 1;
+       } else {
+               /* Synchronous, simply return results */
+               *result = local_result;
+
+               /* Indicate to caller operation was sync */
+               *posted = 0;
        }
        return 0;
 }
@@ -423,39 +436,27 @@ odp_hw_random_get(uint8_t *buf, size_t *len, bool 
use_entropy ODP_UNUSED)
 }
 
 void
-odp_crypto_get_operation_compl_status(odp_buffer_t completion_event,
-                                     odp_crypto_compl_status_t *auth,
-                                     odp_crypto_compl_status_t *cipher)
+odp_crypto_get_compl_event_result(odp_crypto_compl_event_t completion_event,
+                                 odp_crypto_op_result_t *result)
 {
-       odp_crypto_generic_op_result_t *result;
+       odp_crypto_generic_op_result_t *op_result;
 
-       result = get_op_result_from_buffer(completion_event);
+       op_result = get_op_result_from_buffer(completion_event);
 
-       if (OP_RESULT_MAGIC != result->magic)
+       if (OP_RESULT_MAGIC != op_result->magic)
                abort();
 
-       memcpy(auth, &result->auth, sizeof(*auth));
-       memcpy(cipher, &result->cipher, sizeof(*cipher));
-}
-
-
-void
-odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event ODP_UNUSED,
-                                  void *ctx ODP_UNUSED)
-{
-       ODP_UNIMPLEMENTED();
+       memcpy(result, &op_result->result, sizeof(*result));
 }
 
 void
-*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event ODP_UNUSED)
+odp_crypto_release_compl_event(odp_crypto_compl_event_t compl_event ODP_UNUSED)
 {
-       ODP_UNIMPLEMENTED();
-       return NULL;
+       /* We use the packet as the completion event so nothing to do here */
 }
 
-odp_packet_t
-odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event ODP_UNUSED)
+odp_crypto_compl_event_t
+odp_crypto_compl_event_from_buffer(odp_buffer_t buffer)
 {
-       ODP_UNIMPLEMENTED();
-       return ODP_PACKET_INVALID;
+       return (odp_crypto_compl_event_t)buffer;
 }
-- 
1.9.1


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to