Signed-off-by: Robbie King <[email protected]>
---
 example/ipsec/odp_ipsec.c                            | 15 +++++++++------
 platform/linux-generic/include/odp_buffer_internal.h |  8 ++++++++
 platform/linux-generic/odp_buffer.c                  |  7 +++++++
 platform/linux-generic/odp_crypto.c                  |  5 +++++
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index b578f63..338abb3 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1057,10 +1057,15 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
                ev = SCHEDULE(&dispatchq, ODP_SCHED_WAIT);
 
                /* Determine new work versus completion or sequence number */
-               if (seqnumq == dispatchq) {
+               if (ODP_EVENT_PACKET == odp_event_type(ev)) {
                        pkt = odp_packet_from_event(ev);
-                       ctx = get_pkt_ctx_from_pkt(pkt);
-               } else if (completionq == dispatchq) {
+                       if (seqnumq == dispatchq) {
+                               ctx = get_pkt_ctx_from_pkt(pkt);
+                       } else {
+                               ctx = alloc_pkt_ctx(pkt);
+                               ctx->state = PKT_STATE_INPUT_VERIFY;
+                       }
+               } else if (ODP_EVENT_CRYPTO_COMPL == odp_event_type(ev)) {
                        odp_crypto_compl_t compl;
 
                        compl = odp_crypto_compl_from_event(ev);
@@ -1069,9 +1074,7 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
                        pkt = result.pkt;
                        ctx = result.ctx;
                } else {
-                       pkt = odp_packet_from_event(ev);
-                       ctx = alloc_pkt_ctx(pkt);
-                       ctx->state = PKT_STATE_INPUT_VERIFY;
+                       abort();
                }
 
                /*
diff --git a/platform/linux-generic/include/odp_buffer_internal.h 
b/platform/linux-generic/include/odp_buffer_internal.h
index 5a42653..1f3f69f 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -164,6 +164,14 @@ odp_buffer_t buffer_alloc(odp_pool_t pool, size_t size);
  */
 int _odp_buffer_type(odp_buffer_t buf);
 
+/*
+ * Buffer type set
+ *
+ * @param buf      Buffer handle
+ * @param type     New type value
+ *
+ */
+       void _odp_buffer_type_set(odp_buffer_t buf, int type);
 
 #ifdef __cplusplus
 }
diff --git a/platform/linux-generic/odp_buffer.c 
b/platform/linux-generic/odp_buffer.c
index e657e00..18e8162 100644
--- a/platform/linux-generic/odp_buffer.c
+++ b/platform/linux-generic/odp_buffer.c
@@ -47,6 +47,13 @@ int _odp_buffer_type(odp_buffer_t buf)
        return hdr->type;
 }
 
+void _odp_buffer_type_set(odp_buffer_t buf, int type)
+{
+       odp_buffer_hdr_t *hdr = odp_buf_to_hdr(buf);
+
+       hdr->type = type;
+}
+
 
 int odp_buffer_is_valid(odp_buffer_t buf)
 {
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 2f2d701..154789b 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -400,6 +400,8 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
 
                /* Linux generic will always use packet for completion event */
                completion_event = odp_packet_to_event(params->out_pkt);
+               _odp_buffer_type_set(odp_buffer_from_event(completion_event),
+                                    ODP_EVENT_CRYPTO_COMPL);
 
                /* Asynchronous, build result (no HW so no errors) and send it*/
                op_result = get_op_result_from_event(completion_event);
@@ -454,6 +456,9 @@ odp_hw_random_get(uint8_t *buf, size_t *len, odp_bool_t 
use_entropy ODP_UNUSED)
 
 odp_crypto_compl_t odp_crypto_compl_from_event(odp_event_t ev)
 {
+       /* This check not mandated by the API specification */
+       if (odp_event_type(ev) != ODP_EVENT_CRYPTO_COMPL)
+               ODP_ABORT("Event not a crypto completion");
        return (odp_crypto_compl_t)ev;
 }
 
-- 
1.9.1


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

Reply via email to