diff mbox

[2/3] linux-generic: crypto: implement completion event context

Message ID 1418424026-4526-3-git-send-email-taras.kondratiuk@linaro.org
State New
Headers show

Commit Message

Taras Kondratiuk Dec. 12, 2014, 10:40 p.m. UTC
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
 .../linux-generic/include/odp_crypto_internal.h    |  1 +
 platform/linux-generic/odp_crypto.c                | 28 +++++++++++++++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)

Comments

Taras Kondratiuk Dec. 15, 2014, 4 p.m. UTC | #1
On 12/15/2014 05:25 PM, Robbie King (robking) wrote:
> see [rk] inline, I think one of your assert checks needs some 
> more parentheses.
> 
> -----Original Message-----
> From: Taras Kondratiuk [mailto:taras.kondratiuk@linaro.org] 
> Sent: Friday, December 12, 2014 5:40 PM
> To: lng-odp@lists.linaro.org; Robbie King (robking)
> Cc: Taras Kondratiuk
> Subject: [PATCH 2/3] linux-generic: crypto: implement completion event context
> 
> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> ---
>  .../linux-generic/include/odp_crypto_internal.h    |  1 +
>  platform/linux-generic/odp_crypto.c                | 28 +++++++++++++++++-----
>  2 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h
> index 04db333..6ecfe80 100644
> --- a/platform/linux-generic/include/odp_crypto_internal.h
> +++ b/platform/linux-generic/include/odp_crypto_internal.h
> @@ -69,6 +69,7 @@ typedef struct odp_crypto_generic_op_result {
>  	uint32_t magic;
>  	odp_crypto_compl_status_t cipher;
>  	odp_crypto_compl_status_t auth;
> +	void* op_context;
>  } odp_crypto_generic_op_result_t;
>  
>  /**
> diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
> index a2d4ab8..e605d59 100644
> --- a/platform/linux-generic/odp_crypto.c
> +++ b/platform/linux-generic/odp_crypto.c
> @@ -446,17 +446,33 @@ 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_buffer_t completion_event,
> +				   void *ctx)
>  {
> -	ODP_UNIMPLEMENTED();
> +	odp_crypto_generic_op_result_t *result;
> +
> +	result = get_op_result_from_buffer(completion_event);
> +	/*
> +	 * Completion event magic can't be checked here, because it is filled
> +	 * later in odp_crypto_operation() function.
> +	 */
> +	ODP_ASSERT(odp_buffer_type(completion_event == ODP_BUFFER_TYPE_PACKET),
> +			"Completion is not a packet");
> 
> [rk] Should this be:
> 
> 	ODP_ASSERT((odp_buffer_type(completion_event) == ODP_BUFFER_TYPE_PACKET),
> 			"Completion is not a packet");

Thanks. Will fix it.
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h
index 04db333..6ecfe80 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -69,6 +69,7 @@  typedef struct odp_crypto_generic_op_result {
 	uint32_t magic;
 	odp_crypto_compl_status_t cipher;
 	odp_crypto_compl_status_t auth;
+	void* op_context;
 } odp_crypto_generic_op_result_t;
 
 /**
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index a2d4ab8..e605d59 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -446,17 +446,33 @@  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_buffer_t completion_event,
+				   void *ctx)
 {
-	ODP_UNIMPLEMENTED();
+	odp_crypto_generic_op_result_t *result;
+
+	result = get_op_result_from_buffer(completion_event);
+	/*
+	 * Completion event magic can't be checked here, because it is filled
+	 * later in odp_crypto_operation() function.
+	 */
+	ODP_ASSERT(odp_buffer_type(completion_event == ODP_BUFFER_TYPE_PACKET),
+			"Completion is not a packet");
+
+	result->op_context = ctx;
 }
 
 void
-*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event ODP_UNUSED)
+*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event)
 {
-	ODP_UNIMPLEMENTED();
-	return NULL;
+	odp_crypto_generic_op_result_t *result;
+
+	result = get_op_result_from_buffer(completion_event);
+	ODP_ASSERT(OP_RESULT_MAGIC == result->magic, "Bad completion magic");
+	ODP_ASSERT(odp_buffer_type(completion_event == ODP_BUFFER_TYPE_PACKET),
+			"Completion is not a packet");
+
+	return result->op_context;
 }
 
 odp_packet_t