On 12/10/2014 05:12 PM, Robbie King wrote:
> Signed-off-by: Robbie King <robk...@cisco.com>
> ---
>  platform/linux-generic/include/api/odp_crypto.h | 77 
> ++++++++++++++++++++-----
>  1 file changed, 63 insertions(+), 14 deletions(-)
> 
> diff --git a/platform/linux-generic/include/api/odp_crypto.h 
> b/platform/linux-generic/include/api/odp_crypto.h
> index 337e7cf..7780a09 100644
> --- a/platform/linux-generic/include/api/odp_crypto.h
> +++ b/platform/linux-generic/include/api/odp_crypto.h
> @@ -210,6 +210,16 @@ typedef struct odp_crypto_compl_status {
>       enum crypto_hw_err  hw_err;   /**< Hardware specific return code */
>  } odp_crypto_compl_status_t;
>  
> +/**
> + * Cryto API completion event
> + */
> +typedef struct odp_crypto_compl_event {
> +     bool         is_buffer;
> +     union {
> +             void        *ptr;             /**< Sync, single request 
> outstanding */
> +             odp_buffer_t buffer;          /**< Async and multi sync request 
> */
> +     };
> +} odp_crypto_compl_event_t;
>  
>  /**
>   * Crypto session creation (synchronous)
> @@ -225,6 +235,55 @@ odp_crypto_session_create(odp_crypto_session_params_t 
> *params,
>                         odp_crypto_session_t *session,
>                         enum odp_crypto_ses_create_err *status);
>  
> +/**
> + * Obtain crypto completion event for upcoming request
> + *
> + * Retrieve an appropriate completion event based on the request we are
> + * getting ready to issue.  Getting the event handle ahead of time allows
> + * us to perform any extra initialization (such as set user context).

Actually user context is an attribute of a crypto operation. Completion
event is used only as a transport to be able to obtain the context
after operation is completed. It would be more logical to add operation
user context as an additional field in odp_crypto_op_params_t.
Implementation will store it in a proper place if needed.
So two APIs can be dropped without sacrificing any functionality:
- odp_crypto_get_compl_event()
- odp_crypto_set_operation_compl_ctx()

> + *
> + * @param params            Operation parameters
> + * 
> + * @return completion event (error handling?)
> + */
> +odp_crypto_compl_event_t
> +odp_crypto_get_compl_event(odp_crypto_op_params_t *params);
> +
> +/**
> + * Release crypto completion event
> + *
> + * @param completion_event  Completion event we are done accessing
> + */
> +void
> +odp_crypto_release_compl_event(odp_crypto_compl_event_t completion_event);
> +
> +/**
> + * Reset crypto completion event
> + *
> + * @param completion_event  Completion event we are initializing
> + */
> +void
> +odp_crypto_reset_compl_event(odp_crypto_compl_event_t *completion_event);
> +
> +/**
> + * Convert buffer to completion event
> + *
> + * @param buffer       Generic ODP buffer
> + *
> + * @return Completion event
> + */
> +odp_crypto_compl_event_t
> +odp_crypto_compl_event_from_buffer(odp_buffer_t buffer);
> +
> +/**
> + * Crypto per packet operation set user context in completion event
> + *
> + * @param completion_event  Event containing operation results
> + * @param ctx               User data
> + */
> +void
> +odp_crypto_set_operation_compl_ctx(odp_crypto_compl_event_t completion_event,
> +                                void *ctx);
>  
>  /**
>   * Crypto per packet operation
> @@ -247,17 +306,7 @@ 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);
> -
> -/**
> - * Crypto per packet operation set user context in completion event
> - *
> - * @param completion_event  Event containing operation results
> - * @param ctx               User data
> - */
> -void
> -odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event,
> -                                void *ctx);
> +                  odp_crypto_compl_event_t completion_event);

If my assumption above is correct than we don't need to pass any
completion event on operation submit. Implementation already have all
necessary information that need to be stored in a completion event.
This gives freedom to implementation to handle completion event in an
optimal way.

-- 
Taras Kondratiuk

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to