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

diff --git a/platform/linux-generic/include/odp_crypto_internal.h 
b/platform/linux-generic/include/odp_crypto_internal.h
index 04db333..19a7c1e 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -67,6 +67,7 @@ struct odp_crypto_generic_session {
  */
 typedef struct odp_crypto_generic_op_result {
        uint32_t magic;
+       void *ctx;
        odp_crypto_compl_status_t cipher;
        odp_crypto_compl_status_t auth;
 } odp_crypto_generic_op_result_t;
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index d3cdec7..e96e52a 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -338,13 +338,14 @@ odp_crypto_session_create(odp_crypto_session_params_t 
*params,
 int
 odp_crypto_operation(odp_crypto_op_params_t *params,
                     bool *posted,
-                    odp_buffer_t completion_event)
+                    odp_crypto_compl_event_t completion_event)
 {
        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;
-
+       void *ctx = odp_crypto_get_operation_compl_ctx(completion_event);
+       
        *posted = 0;
        session = (odp_crypto_generic_session_t *)(intptr_t)params->session;
 
@@ -357,8 +358,8 @@ 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 =
+               if (completion_event.buffer == 
odp_packet_to_buffer(params->pkt))
+                       completion_event.buffer = 
                                odp_packet_to_buffer(params->out_pkt);
                odph_packet_free(params->pkt);
                params->pkt = ODP_PACKET_INVALID;
@@ -374,8 +375,9 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
        }
 
        /* Build Result (no HW so no errors) */
-       result = get_op_result_from_buffer(completion_event);
+       result = get_op_result_from_buffer(completion_event.buffer);
        result->magic = OP_RESULT_MAGIC;
+       result->ctx = ctx;
        result->cipher.alg_err = rc_cipher;
        result->cipher.hw_err = ODP_CRYPTO_HW_ERR_NONE;
        result->auth.alg_err = rc_auth;
@@ -383,7 +385,7 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
 
        /* If specified during creation post event to completion queue */
        if (ODP_QUEUE_INVALID != session->compl_queue) {
-               odp_queue_enq(session->compl_queue, completion_event);
+               odp_queue_enq(session->compl_queue, completion_event.buffer);
                *posted = 1;
        }
        return 0;
@@ -423,13 +425,13 @@ 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_get_operation_compl_status(odp_crypto_compl_event_t 
completion_event,
                                      odp_crypto_compl_status_t *auth,
                                      odp_crypto_compl_status_t *cipher)
 {
        odp_crypto_generic_op_result_t *result;
-
-       result = get_op_result_from_buffer(completion_event);
+       
+       result = get_op_result_from_buffer(completion_event.buffer);
 
        if (OP_RESULT_MAGIC != result->magic)
                abort();
@@ -440,22 +442,44 @@ odp_crypto_get_operation_compl_status(odp_buffer_t 
completion_event,
 
 
 void
-odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event ODP_UNUSED,
-                                  void *ctx ODP_UNUSED)
+odp_crypto_set_operation_compl_ctx(odp_crypto_compl_event_t completion_event,
+                                  void *ctx)
 {
-       ODP_UNIMPLEMENTED();
+       odp_crypto_generic_op_result_t *result;
+
+       result = get_op_result_from_buffer(completion_event.buffer);    
+       result->ctx = ctx;
 }
 
 void
-*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event ODP_UNUSED)
+*odp_crypto_get_operation_compl_ctx(odp_crypto_compl_event_t completion_event)
 {
-       ODP_UNIMPLEMENTED();
-       return NULL;
+       odp_crypto_generic_op_result_t *result;
+
+       result = get_op_result_from_buffer(completion_event.buffer);
+       
+       return result->ctx;
 }
 
 odp_packet_t
-odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event ODP_UNUSED)
+odp_crypto_get_operation_compl_packet(odp_crypto_compl_event_t 
completion_event)
 {
-       ODP_UNIMPLEMENTED();
-       return ODP_PACKET_INVALID;
+       return odp_packet_from_buffer(completion_event.buffer);
 }
+
+odp_crypto_compl_event_t
+odp_crypto_get_compl_event(odp_crypto_op_params_t *params)
+{      
+       odp_crypto_compl_event_t event;
+
+       event.buffer = odp_packet_to_buffer(params->pkt);
+       return event;
+}
+
+void
+odp_crypto_release_compl_event(odp_crypto_compl_event_t completion_event 
ODP_UNUSED)
+{
+       /* We use the packet as the completion event so nothing to do here */
+}
+
+
-- 
1.9.1


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

Reply via email to