On Wed, Jun 21, 2017 at 6:48 AM, Dmitry Eremin-Solenikov
<[email protected]> wrote:
> Input and output of crypto operations are packets. API is more flexible
> for application and API pipelining when output is packet with additional
> metadata. Application or API pipeline stages which do not care about
> crypto results may work on basic packet metadata.
>
> Crypto result event type changes from ODP_EVENT_CRYPTO_COMPL to
> ODP_EVENT_PACKET. Event subtype (ODP_EVENT_PACKET_CRYPTO) can be
> used to identify packets with crypto metadata.
>
> Signed-off-by: Dmitry Eremin-Solenikov <[email protected]>
> ---
> This depends on all previous patches related to IPsec and event types.
>
>  include/odp/api/spec/crypto.h                      | 120 
> +++++++++------------
>  include/odp/api/spec/event.h                       |   2 -
>  include/odp/arch/default/api/abi/crypto.h          |   1 -
>  include/odp/arch/default/api/abi/event.h           |   6 +-
>  .../include/odp/api/plat/crypto_types.h            |   1 -
>  .../include/odp/api/plat/event_types.h             |   6 +-
>  6 files changed, 54 insertions(+), 82 deletions(-)
>
> diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
> index 470cba05066f..fc2a3b8f0b97 100644
> --- a/include/odp/api/spec/crypto.h
> +++ b/include/odp/api/spec/crypto.h
> @@ -39,11 +39,6 @@ extern "C" {
>   */
>
>  /**
> - * @typedef odp_crypto_compl_t
> -* Crypto API completion event (platform dependent).
> -*/
> -
> -/**
>   * Crypto API operation mode
>   */
>  typedef enum {
> @@ -337,28 +332,6 @@ typedef struct odp_crypto_op_param_t {
>         /** User context */
>         void *ctx;
>
> -       /** Input packet
> -        *
> -        *  Specifies the input packet for the crypto operation. When the
> -        *  'out_pkt' variable is set to ODP_PACKET_INVALID (indicating a new
> -        *  packet should be allocated for the resulting packet).
> -        */
> -       odp_packet_t pkt;
> -
> -       /** Output packet
> -        *
> -        *  Both "in place" (the original packet 'pkt' is modified) and
> -        *  "copy" (the packet is replicated to a new packet which contains
> -        *  the modified data) modes are supported. The "in place" mode of
> -        *  operation is indicated by setting 'out_pkt' equal to 'pkt'.
> -        *  For the copy mode of operation, setting 'out_pkt' to a valid 
> packet
> -        *  value indicates the caller wishes to specify the destination 
> packet.
> -        *  Setting 'out_pkt' to ODP_PACKET_INVALID indicates the caller 
> wishes
> -        *  the destination packet be allocated from the output pool specified
> -        *  during session creation.
> -        */
> -       odp_packet_t out_pkt;
> -
>         /** Override session IV pointer */
>         uint8_t *override_iv_ptr;
>
> @@ -438,14 +411,14 @@ typedef enum {
>  /**
>   * Cryto API per packet operation completion status
>   */
> -typedef struct odp_crypto_compl_status {
> +typedef struct odp_crypto_op_status {
>         /** Algorithm specific return code */
>         odp_crypto_alg_err_t alg_err;
>
>         /** Hardware specific return code */
>         odp_crypto_hw_err_t  hw_err;
>
> -} odp_crypto_compl_status_t;
> +} odp_crypto_op_status_t;
>
>  /**
>   * Crypto API operation result
> @@ -457,14 +430,11 @@ typedef struct odp_crypto_op_result {
>         /** User context from request */
>         void *ctx;
>
> -       /** Output packet */
> -       odp_packet_t pkt;
> -
>         /** Cipher status */
> -       odp_crypto_compl_status_t cipher_status;
> +       odp_crypto_op_status_t cipher_status;
>
>         /** Authentication status */
> -       odp_crypto_compl_status_t auth_status;
> +       odp_crypto_op_status_t auth_status;
>
>  } odp_crypto_op_result_t;
>
> @@ -609,61 +579,80 @@ int 
> odp_crypto_session_create(odp_crypto_session_param_t *param,
>  int odp_crypto_session_destroy(odp_crypto_session_t session);
>
>  /**
> - * Return crypto completion handle that is associated with event
> + * Return crypto processed packet that is associated with event
> + *
> + * Get packet handle to an crypto processed packet event. Event subtype must 
> be
> + * ODP_EVENT_CRYPTO_PACKET. Crypto operation results can be examined with

ODP_EVENT_PACKET_CRYPTO

> + * odp_crypto_result().
>   *
>   * Note: any invalid parameters will cause undefined behavior and may cause
>   * the application to abort or crash.
>   *
> - * @param ev An event of type ODP_EVENT_CRYPTO_COMPL
> + * @param ev       Event handle
>   *
> - * @return crypto completion handle
> + * @return Packet handle
>   */
> -odp_crypto_compl_t odp_crypto_compl_from_event(odp_event_t ev);
> +odp_packet_t odp_crypto_packet_from_event(odp_event_t ev);
>
>  /**
> - * Convert crypto completion handle to event handle
> + * Convert crypto packet handle to event
> + *
> + * The packet handle must be an output of an crypto operation.
>   *
> - * @param completion_event  Completion event to convert to generic event
> + * @param pkt      Packet handle from crypto operation
>   *
>   * @return Event handle
>   */
> -odp_event_t odp_crypto_compl_to_event(odp_crypto_compl_t completion_event);
> +odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt);
>
>  /**
> - * Release crypto completion event
> + * Crypto per packet operation
> + *
> + * Performs the SYNC cryptographic operations specified during session 
> creation
> + * on the packet.
> + *
> + * @param pkt_in            Packet to be processed
> + * @param[in,out] pkt_out   Pointer to packet handle for resulting packets
> + * @param param             Operation parameters
>   *
> - * @param completion_event  Completion event we are done accessing
> + * @retval 0 on success
> + * @retval <0 on failure
>   */
> -void odp_crypto_compl_free(odp_crypto_compl_t completion_event);
> +int odp_crypto_op(odp_packet_t pkt_in,
> +                 odp_packet_t *pkt_out,
> +                 odp_crypto_op_param_t *param);
>
>  /**
>   * Crypto per packet operation
>   *
> - * Performs the cryptographic operations specified during session creation
> - * on the packet.  If the operation is performed synchronously, "posted"
> - * will return FALSE and the result of the operation is immediately 
> available.
> - * If "posted" returns TRUE the result will be delivered via the completion
> - * queue specified when the session was created.
> + * Performs the ASYNC cryptographic operations specified during session 
> creation
> + * on the packet.
>   *
> + * @param pkt_in            Packet to be processed
>   * @param param             Operation parameters
> - * @param posted            Pointer to return posted, TRUE for async 
> operation
> - * @param result            Results of operation (when posted returns FALSE)
>   *
>   * @retval 0 on success
>   * @retval <0 on failure
>   */
> -int odp_crypto_operation(odp_crypto_op_param_t *param,
> -                        odp_bool_t *posted,
> -                        odp_crypto_op_result_t *result);
> +int odp_crypto_op_enq(odp_packet_t pkt_in,
> +                     odp_crypto_op_param_t *param);
>
>  /**
> - * Crypto per packet operation query result from completion event
> + * Get crypto operation results from an crypto processed packet
> + *
> + * Successful crypto operations of all types (SYNC and ASYNC) produce packets
> + * which contain crypto result metadata. This function copies the operation
> + * results from an crypto processed packet. Event subtype of this kind of
> + * packet is ODP_EVENT_PACKET_crypto. Results are undefined if a non-crypto
> + * processed packet is passed as input.
>   *
> - * @param completion_event  Event containing operation results
> - * @param result            Pointer to result structure
> + * @param         packet  An crypto processed packet 
> (ODP_EVENT_PACKET_CRYPTO)
> + * @param[out]    result  Pointer to operation result for output
> + *
> + * @retval  0     On success
> + * @retval <0     On failure
>   */
> -void odp_crypto_compl_result(odp_crypto_compl_t completion_event,
> -                            odp_crypto_op_result_t *result);
> +int odp_crypto_result(odp_crypto_op_result_t *result, odp_packet_t packet);
>
>  /**
>   * Get printable value for an odp_crypto_session_t
> @@ -679,19 +668,6 @@ void odp_crypto_compl_result(odp_crypto_compl_t 
> completion_event,
>  uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl);
>
>  /**
> - * Get printable value for an odp_crypto_compl_t
> - *
> - * @param hdl  odp_crypto_compl_t handle to be printed
> - * @return     uint64_t value that can be used to print/display this
> - *             handle
> - *
> - * @note This routine is intended to be used for diagnostic purposes
> - * to enable applications to generate a printable value that represents
> - * an odp_crypto_compl_t handle.
> - */
> -uint64_t odp_crypto_compl_to_u64(odp_crypto_compl_t hdl);
> -
> -/**
>   * Initialize crypto session parameters
>   *
>   * Initialize an odp_crypto_session_param_t to its default values for
> diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h
> index 2ad3ce84262f..bd30f06d7140 100644
> --- a/include/odp/api/spec/event.h
> +++ b/include/odp/api/spec/event.h
> @@ -54,8 +54,6 @@ extern "C" {
>   *       packet processing related metadata
>   * - ODP_EVENT_TIMEOUT
>   *     - Timeout event (odp_timeout_t) from a timer
> - * - ODP_EVENT_CRYPTO_COMPL
> - *     - Crypto completion event (odp_crypto_compl_t)
>   * - ODP_EVENT_IPSEC_STATUS
>   *     - IPSEC status update event (odp_ipsec_status_t)
>   */
> diff --git a/include/odp/arch/default/api/abi/crypto.h 
> b/include/odp/arch/default/api/abi/crypto.h
> index f0793a198a53..cc6249219ebf 100644
> --- a/include/odp/arch/default/api/abi/crypto.h
> +++ b/include/odp/arch/default/api/abi/crypto.h
> @@ -23,7 +23,6 @@ typedef struct { char dummy; /**< @internal Dummy */ } 
> _odp_abi_crypto_compl_t;
>  #define ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL)
>
>  typedef uint64_t  odp_crypto_session_t;
> -typedef _odp_abi_crypto_compl_t *odp_crypto_compl_t;
>
>  /**
>   * @}
> diff --git a/include/odp/arch/default/api/abi/event.h 
> b/include/odp/arch/default/api/abi/event.h
> index ab3c0f755836..57df8822a132 100644
> --- a/include/odp/arch/default/api/abi/event.h
> +++ b/include/odp/arch/default/api/abi/event.h
> @@ -28,14 +28,14 @@ typedef enum odp_event_type_t {
>         ODP_EVENT_BUFFER       = 1,
>         ODP_EVENT_PACKET       = 2,
>         ODP_EVENT_TIMEOUT      = 3,
> -       ODP_EVENT_CRYPTO_COMPL = 4,
> -       ODP_EVENT_IPSEC_STATUS = 5
> +       ODP_EVENT_IPSEC_STATUS = 4
>  } odp_event_type_t;
>
>  typedef enum odp_event_subtype_t {
>         ODP_EVENT_NO_SUBTYPE   = 0,
>         ODP_EVENT_PACKET_BASIC = 1,
> -       ODP_EVENT_PACKET_IPSEC = 2
> +       ODP_EVENT_PACKET_IPSEC = 2,
> +       ODP_EVENT_PACKET_CRYPTO = 3

Since we're just starting out, do we want to keep these in alphabetical order?

>  } odp_event_subtype_t;
>
>  /**
> diff --git a/platform/linux-generic/include/odp/api/plat/crypto_types.h 
> b/platform/linux-generic/include/odp/api/plat/crypto_types.h
> index 2cc747eb2fde..eb24952c69fe 100644
> --- a/platform/linux-generic/include/odp/api/plat/crypto_types.h
> +++ b/platform/linux-generic/include/odp/api/plat/crypto_types.h
> @@ -30,7 +30,6 @@ extern "C" {
>  #define ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL)
>
>  typedef uint64_t odp_crypto_session_t;
> -typedef ODP_HANDLE_T(odp_crypto_compl_t);
>
>  /**
>   * @}
> diff --git a/platform/linux-generic/include/odp/api/plat/event_types.h 
> b/platform/linux-generic/include/odp/api/plat/event_types.h
> index 5b3a07e3f793..2ef2346860dc 100644
> --- a/platform/linux-generic/include/odp/api/plat/event_types.h
> +++ b/platform/linux-generic/include/odp/api/plat/event_types.h
> @@ -38,14 +38,14 @@ typedef enum odp_event_type_t {
>         ODP_EVENT_BUFFER       = 1,
>         ODP_EVENT_PACKET       = 2,
>         ODP_EVENT_TIMEOUT      = 3,
> -       ODP_EVENT_CRYPTO_COMPL = 4,
> -       ODP_EVENT_IPSEC_STATUS = 5
> +       ODP_EVENT_IPSEC_STATUS = 4
>  } odp_event_type_t;
>
>  typedef enum odp_event_subtype_t {
>         ODP_EVENT_NO_SUBTYPE   = 0,
>         ODP_EVENT_PACKET_BASIC = 1,
> -       ODP_EVENT_PACKET_IPSEC = 2
> +       ODP_EVENT_PACKET_IPSEC = 2,
> +       ODP_EVENT_PACKET_CRYPTO = 3
>  } odp_event_subtype_t;
>
>  /**
> --
> 2.11.0
>

Reply via email to