From patchwork Wed Jun 21 11:48:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Eremin-Solenikov X-Patchwork-Id: 106070 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1884374qgd; Wed, 21 Jun 2017 04:48:44 -0700 (PDT) X-Received: by 10.55.131.132 with SMTP id f126mr40347026qkd.212.1498045724581; Wed, 21 Jun 2017 04:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498045724; cv=none; d=google.com; s=arc-20160816; b=XQBMW0xmmRkd+MsDJPTIqbG3YK5J3BVkqffDnmKANgM7MJY1L+7bq1bK7Sehi2fTnT gRh9mS/S3M9s17FyhmGXburSUPE+h2jDbGYiWPapSuZvDnnujZRWgTw60k5aoFT3JBQ7 1B6rHIref8ax/AP9d2YJapoVeP2+TYRLRNHE6t23+SoJ0yMyjTfUKBSxvBwj2NNBK30t zxOK0XkNVd4mJV0aYfaCJ+SYG81uDI+5RXW/Sv+AaXuUcG7qzOcDTTPa3DhTBJmk58Lb 66ToRdfHeXnbb5jt+20aaFlBffdYBecqIRWwP+utR4mIHiWJGCPNyQX2Zzt52NInAmaK OiQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from :delivered-to:arc-authentication-results; bh=kgI83BJWvjMxD+9D29dNSWb17KJ0HGAlzSSn9lGr5dA=; b=pCR28tXoH/L9R1PEPBDHbs1r2ec/yczGWMPEp4YWJ2fTeaNgwmAIczw/GwkrKA90Ey 8Jl14Ey8OwjuJgzvC8HX/QVjrptCqQFSnTmnQfwunKwC9X2SGmY5jNIE3SMaF1uWRIM7 Jmi6LppOKoEuhv5lwPI3TTTN6w9bc+OT6tf3Yh3xMGYLg4cIhHcB7lP5XX6gLOjdi4c/ b2mJF67IhzbTH4R/FCN4++2S1J890EGlvRzSVMMB3c0pet3yblRHJYFhoUSilDrji5hd Cq4F70ltqzMRD/64Ad6ddVNKT5VzUkUH6joq4EivO764I4ahHJc/HztSq9kmtnYWYrtz luYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d11si14550019qke.262.2017.06.21.04.48.44; Wed, 21 Jun 2017 04:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 15BCC60949; Wed, 21 Jun 2017 11:48:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 467B760826; Wed, 21 Jun 2017 11:48:36 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 99CF560833; Wed, 21 Jun 2017 11:48:33 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 1BA5160791 for ; Wed, 21 Jun 2017 11:48:32 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id p189so93341146lfe.2 for ; Wed, 21 Jun 2017 04:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=kgI83BJWvjMxD+9D29dNSWb17KJ0HGAlzSSn9lGr5dA=; b=ZI0g1cWJnjYiiM3Alq8Yvlko2pOsSqngOH1hV6fEOSHuKP6Iwag7EqFupQVzLafxlQ iuXC0Iexrx+J0tpj8lWOSF5aDinJjVFnwcUWTnZLtGjUCT0qbsa//XnlGTqgsmFnPQeO iIBqKRVgsDyp8Yk88HzQqZiMKRzge4y5t+7FQd+sUzAmWwCpQlWgCQa9NiuEDSRatRSl D1t0rflDAvsDWBvumm/EeiCoCezWzTO9vCCvi3MDgElT+C7KqynMQLBLYAygpLEpbNbv 3D2yocVGJMXGzA6motMf0syEmZgqPUBMrHWGE/ItvT4T8CbmZGgqQ45VXViJYd9bVAgD d4iQ== X-Gm-Message-State: AKS2vOx2GvsbKLgj30m0Qtq3XWa2jDUCjQSxCYgw9noXPKr7es0xrVYG B0bJVJ8/wJwFjFbo+zyMcAsz X-Received: by 10.46.9.213 with SMTP id 204mr10109636ljj.120.1498045710365; Wed, 21 Jun 2017 04:48:30 -0700 (PDT) Received: from forlindon.lumag.auriga.ru ([94.25.229.10]) by smtp.gmail.com with ESMTPSA id h98sm3746208ljh.57.2017.06.21.04.48.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 04:48:29 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Wed, 21 Jun 2017 14:48:26 +0300 Message-Id: <20170621114826.21389-1-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [lng-odp] [RFC API-NEXT] api: crypto: change crypto result to packet X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" 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 --- 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(-) -- 2.11.0 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_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 } 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; /**