On 2014-08-11 14:23, Robbie King wrote:
> Signed-off-by: Robbie King <[email protected]>
> ---
>  include/odp_crypto.h |  366 
> ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 366 insertions(+), 0 deletions(-)
>  create mode 100644 include/odp_crypto.h

[...]

> +/**
> + * Crypto API per packet operation parameters
> + *
> + * @todo Clarify who zero's ICV and how this relates to "hash_result_offset"
> + */
> +typedef struct odp_crypto_op_params {
> +     odp_crypto_session_t session;   /**< Session handle from creation */
> +     odp_packet_t pkt;               /**< Input packet buffer */
> +     odp_packet_t out_pkt;           /**< Output packet buffer */
> +     uint8_t *override_iv_ptr;       /**< Override session IV pointer */
> +     uint32_t hash_result_offset;    /**< Offset from start of packet buffer 
> for hash result */
> +     odp_crypto_data_range_t cipher_range;   /**< Data range to apply cipher 
> */
> +     odp_crypto_data_range_t auth_range;     /**< Data range to authenticate 
> */
> +} odp_crypto_op_params_t;
> +
> +/**
> + * @var odp_crypto_op_params_t::pkt
> + *   Specifies the input packet buffer for the crypto operation.  When the
> + *   @c out_pkt variable is set to @c ODP_PACKET_INVALID (indicating a new
> + *   buffer should be allocated for the resulting packet), the #define TBD

Nit: 
doxygen prints out a warning
/home/anders/src/odp/include/odp_crypto.h:151: warning: explicit link
request to 'define' could not be resolved

Need to add this: \#define TBD

Cheers,
Anders

> + *   indicates whether the implementation will free the input packet buffer
> + *   or if it becomes the responsibility of the caller.
> + *
> + * @var odp_crypto_op_params_t::out_pkt
> + *
> + *   The API supports both "in place" (the original packet "pkt" is
> + *   modified) and "copy" (the packet is replicated to a new buffer
> + *   which contains the modified data).
> + *
> + *   The "in place" mode of operation is indicated by setting @c out_pkt
> + *   equal to @c pkt.  For the copy mode of operation, setting @c out_pkt
> + *   to a valid packet buffer value indicates the caller wishes to specify
> + *   the destination buffer.  Setting @c out_pkt to @c ODP_PACKET_INVALID
> + *   indicates the caller wishes the destination packet buffer be allocated
> + *   from the output pool specified during session creation.
> + *
> + *   @sa odp_crypto_session_params_t::output_pool.
> + */
> +
> +/**
> + * Crypto API session creation return code
> + */
> +enum odp_crypto_ses_create_err {
> +     ODP_CRYPTO_SES_CREATE_ERR_NONE,       /**< Session created */
> +     ODP_CRYPTO_SES_CREATE_ERR_ENOMEM,     /**< Creation failed, no 
> resources */
> +     ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER, /**< Creation failed, bad cipher 
> params */
> +     ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH,   /**< Creation failed, bad auth 
> params */
> +};
> +
> +/**
> + * Crypto API algorithm return code
> + */
> +enum crypto_alg_err {
> +     ODP_CRYPTO_ALG_ERR_NONE,      /**< Algorithm successful */
> +     ODP_CRYPTO_ALG_ERR_DATA_SIZE, /**< Invalid data block size */
> +     ODP_CRYPTO_ALG_ERR_KEY_SIZE,  /**< Key size invalid for algorithm */
> +     ODP_CRYPTO_ALG_ERR_ICV_CHECK, /**< Computed ICV value mismatch */
> +};
> +
> +/**
> + * Crypto API hardware centric return code
> + */
> +enum crypto_hw_err {
> +     ODP_CRYPTO_HW_ERR_NONE,         /**< Operation completed successfully */
> +     ODP_CRYPTO_HW_ERR_DMA,          /**< Error detected during DMA of data 
> */
> +     ODP_CRYPTO_HW_ERR_BP_DEPLETED,  /**< Operation failed due to buffer 
> pool depletion */
> +};
> +
> +/**
> + * Cryto API per packet operation completion status
> + */
> +typedef struct odp_crypto_compl_status {
> +     enum crypto_alg_err alg_err;  /**< Algorithm specific return code */
> +     enum crypto_hw_err  hw_err;   /**< Hardware specific return code */
> +} odp_crypto_compl_status_t;
> +
> +
> +/**
> + * Crypto session creation (synchronous)
> + *
> + * @param params            Session parameters
> + * @param session           Created session else ODP_CRYPTO_SESSION_INVALID
> + * @param status            Failure code if unsuccessful
> + *
> + * @return 0 if successful else -1
> + */
> +int
> +odp_crypto_session_create(odp_crypto_session_params_t *params,
> +                       odp_crypto_session_t *session,
> +                       enum odp_crypto_ses_create_err *status);
> +
> +/**
> + * Crypto session creation (asynchronous)
> + *
> + * Initiate crypto session creation.  Results are delivered using
> + * the completion event via the completion queue.
> + *
> + * @param params            Session parameters
> + * @param completion_event  Event by which the session creation results are
> + *                          delivered.
> + * @param completion_queue  Queue by which the completion event will be
> + *                          delivered.
> + *
> + * @return 0 if successful else -1
> + *
> + */
> +int
> +odp_crypto_session_create_async(odp_crypto_session_params_t *params,
> +                             odp_buffer_t completion_event,
> +                             odp_queue_t completion_queue);
> +
> +
> +/**
> + * Crypto session creation completion status
> + *
> + * Accessor function for obtaining creation status from the completion event.
> + *
> + * @param completion_event  Event containing operation results
> + * @param status            Pointer to store creation return code
> + */
> +void
> +odp_crypto_get_ses_create_compl_status(odp_buffer_t completion_event,
> +                                    enum odp_crypto_ses_create_err *status);
> +
> +/**
> + * Crypto session creation completion return value
> + *
> + * Accessor function for obtaining handle for newly created session.
> + *
> + * @param completion_event  Event containing operation results
> + * @param session           Pointer to store session handle
> + */
> +void
> +odp_crypto_get_ses_create_compl_session(odp_buffer_t completion_event,
> +                                     odp_crypto_session_t *session);
> +
> +/**
> + * 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
> + * in the completion event.  If "posted" returns TRUE the result will be
> + * delivered via the completion queue specified when the session was created.
> + *
> + * @todo Resolve if completion_event is necessary, can/should the output
> + *       packet buffer always be used instead.
> + *
> + * @param params            Operation parameters
> + * @param posted            Pointer to return posted, TRUE for async 
> operation
> + * @param completion_event  Event by which the operation results are 
> delivered.
> + *
> + * @return 0 if successful else -1
> + */
> +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);
> +
> +/**
> + * Crypto per packet operation completion status
> + *
> + * Accessor function for obtaining operation status from the completion 
> event.
> + *
> + * @param completion_event  Event containing operation results
> + * @param auth              Pointer to store authentication results
> + * @param cipher            Pointer to store cipher results
> + */
> +void
> +odp_crypto_get_operation_compl_status(odp_buffer_t completion_event,
> +                                   odp_crypto_compl_status_t *auth,
> +                                   odp_crypto_compl_status_t *cipher);
> +
> +/**
> + * Crypto per packet operation query completed operation packet
> + *
> + * Accessor function for obtaining current packet buffer, can be
> + * different from input packet buffer on some systems
> + *
> + * @param completion_event  Event containing operation results
> + *
> + * @return Packet structure where data now resides
> + */
> +odp_packet_t
> +odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event);
> +
> +/**
> + * Crypto per packet operation query user context in completion event
> + *
> + * @param completion_event  Event containing operation results
> + *
> + * @return User data
> + */
> +void *
> +odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event);
> +
> +/**
> + * Generate random byte string
> + *
> + * @param buf          Pointer to store result
> + * @param len          Pointer to input length value as well as return value
> + * @param use_entropy  Use entropy
> + *
> + * @todo Define the implication of the use_entropy parameter
> + *
> + * @return 0 if succesful
> + */
> +int
> +odp_hw_random_get(uint8_t *buf, size_t *len, bool use_entropy);
> +
> +/**
> + * Initialize the crypto subsystem, called once from main thread
> + *
> + * @param max_sessions  Maximum number of sessions to support
> + *
> + * @return 0 if succesful
> + */
> +int
> +odp_crypto_init(uint32_t max_sessions);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> -- 
> 1.7.7.6
> 
> 
> _______________________________________________
> lng-odp mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/lng-odp

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

Reply via email to