From patchwork Tue Jul 11 14:00:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107378 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4924559qge; Tue, 11 Jul 2017 07:08:41 -0700 (PDT) X-Received: by 10.55.160.14 with SMTP id j14mr118587qke.196.1499782121261; Tue, 11 Jul 2017 07:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499782121; cv=none; d=google.com; s=arc-20160816; b=B8DbTb+zQ6uRyuAkJzVt0nxrYMF5lYhXXMQEhVzKY8HNYKadrqbswzqpNAU43w+5eC gzRmE2wkYox8rzCgN78j0zTFFHX85pxdFr6jfgA2roBMCc4xzAOy0bFtJbe8LjSU7YoW u8R5ZxB22oxD8SI3zbbBsAQdhcBOAP5KfNnikaTWbGvmrdVbYgGhDMapB9N5nr9vrod4 wxmappv6sicEyLIPrDHSiV7AVpO8HkJAtO6cumFYUOlFzVNCRWqKlI7XICYwaxPH2FTl o3h96g9nQqB0EJBOvw0o1queNO0aBURYMTiYfIIk3smV0a/yPGLrocrRATJadP65n4qK 9mBg== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=2B2sHRhm/S0v/7gm+AjuoEQJ3adomWKJlrnsCh6c3Qg=; b=S+r4iUerDwEdh8/+RRyYxgMapWapmEEHp4YfqNdW9mkH+C4NaqOX8qKxuMdbmel6nR 4mN4VMslu9U4MqI6HwT3iYFsEvnte4VYhS1sOhcckZEQd4H7bqZzK7BKvZPEFPoV2Cfd WoIMllucnCUpYeWqHlUJIzptOsHPtW8wpuw7+29SX1L6LL2FYmDo60i8Un+0HaViHzDq pfbJbkOM7chme2ejsOmuULyYH007ZqsuE6xOBRaTTNsom/mAXleyn7DSb9S7AfkCELOs ZDYh2LtdplFhciXLi4LV397dOnvLliBkgBFEAM15QpGUEYkpYTDV+S/FyBhUJhQrXw/U 12Ew== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c126si32104qkf.188.2017.07.11.07.08.40; Tue, 11 Jul 2017 07:08:41 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id AB9AC608D5; Tue, 11 Jul 2017 14:08:40 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 DBB9860CA4; Tue, 11 Jul 2017 14:08:35 +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 731AC60A51; Tue, 11 Jul 2017 14:08:31 +0000 (UTC) Received: from forward3o.cmail.yandex.net (forward3o.cmail.yandex.net [37.9.109.247]) by lists.linaro.org (Postfix) with ESMTPS id CE8C46081D for ; Tue, 11 Jul 2017 14:08:29 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [IPv6:2a02:6b8:0:801::ac]) by forward3o.cmail.yandex.net (Yandex) with ESMTP id 7096120FD1 for ; Tue, 11 Jul 2017 17:08:28 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 233923EC34C3 for ; Tue, 11 Jul 2017 17:00:36 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0ZL497RF; Tue, 11 Jul 2017 17:00:35 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:20 +0300 Message-Id: <1499781629-30670-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 1/10] linux-generic: events subtype implementation 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" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ platform/linux-generic/include/odp_buffer_inlines.h | 2 ++ platform/linux-generic/include/odp_buffer_internal.h | 3 +++ platform/linux-generic/odp_crypto.c | 15 +++++++++------ platform/linux-generic/odp_event.c | 15 +++++++++++++++ platform/linux-generic/odp_packet.c | 1 + platform/linux-generic/odp_pool.c | 11 +++++++++++ 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h index cf817d90..4c0e7339 100644 --- a/platform/linux-generic/include/odp_buffer_inlines.h +++ b/platform/linux-generic/include/odp_buffer_inlines.h @@ -21,6 +21,8 @@ extern "C" { odp_event_type_t _odp_buffer_event_type(odp_buffer_t buf); void _odp_buffer_event_type_set(odp_buffer_t buf, int ev); +odp_event_subtype_t _odp_buffer_event_subtype(odp_buffer_t buf); +void _odp_buffer_event_subtype_set(odp_buffer_t buf, int ev); int odp_buffer_snprint(char *str, uint32_t n, odp_buffer_t buf); static inline odp_buffer_t odp_hdr_to_buf(odp_buffer_hdr_t *hdr) diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index 076abe96..dadf285e 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -96,6 +96,9 @@ struct odp_buffer_hdr_t { /* Event type. Maybe different than pool type (crypto compl event) */ int8_t event_type; + /* Event subtype. Should be ODP_EVENT_NO_SUBTYPE except packets. */ + int8_t event_subtype; + /* Burst table */ struct odp_buffer_hdr_t *burst[BUFFER_BURST_SIZE]; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 68fc5658..0e2adad1 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -907,12 +907,13 @@ odp_crypto_operation(odp_crypto_op_param_t *param, if (ODP_QUEUE_INVALID != session->p.compl_queue) { odp_event_t completion_event; odp_crypto_generic_op_result_t *op_result; + odp_buffer_t buf; /* Linux generic will always use packet for completion event */ completion_event = odp_packet_to_event(param->out_pkt); - _odp_buffer_event_type_set( - odp_buffer_from_event(completion_event), - ODP_EVENT_CRYPTO_COMPL); + buf = odp_buffer_from_event(completion_event); + _odp_buffer_event_type_set(buf, ODP_EVENT_CRYPTO_COMPL); + _odp_buffer_event_subtype_set(buf, ODP_EVENT_NO_SUBTYPE); /* Asynchronous, build result (no HW so no errors) and send it*/ op_result = get_op_result_from_event(completion_event); op_result->magic = OP_RESULT_MAGIC; @@ -1106,9 +1107,11 @@ odp_crypto_compl_result(odp_crypto_compl_t completion_event, void odp_crypto_compl_free(odp_crypto_compl_t completion_event) { - _odp_buffer_event_type_set( - odp_buffer_from_event((odp_event_t)completion_event), - ODP_EVENT_PACKET); + odp_buffer_t buf = + odp_buffer_from_event((odp_event_t)completion_event); + + _odp_buffer_event_type_set(buf, ODP_EVENT_PACKET); + _odp_buffer_event_subtype_set(buf, ODP_EVENT_PACKET_BASIC); } void odp_crypto_session_param_init(odp_crypto_session_param_t *param) diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c index d71f4464..23b410d8 100644 --- a/platform/linux-generic/odp_event.c +++ b/platform/linux-generic/odp_event.c @@ -19,6 +19,21 @@ odp_event_type_t odp_event_type(odp_event_t event) return _odp_buffer_event_type(odp_buffer_from_event(event)); } +odp_event_subtype_t odp_event_subtype(odp_event_t event) +{ + return _odp_buffer_event_subtype(odp_buffer_from_event(event)); +} + +odp_event_type_t odp_event_types(odp_event_t event, + odp_event_subtype_t *subtype) +{ + odp_buffer_t buf = odp_buffer_from_event(event); + + *subtype = _odp_buffer_event_subtype(buf); + + return _odp_buffer_event_type(buf); +} + void odp_event_free(odp_event_t event) { switch (odp_event_type(event)) { diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index eb66af2d..3789feca 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -268,6 +268,7 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len) CONFIG_PACKET_TAILROOM; pkt_hdr->input = ODP_PKTIO_INVALID; + pkt_hdr->buf_hdr.event_subtype = ODP_EVENT_PACKET_BASIC; } static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 9dba7341..23b80698 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -259,6 +259,7 @@ static void init_buffers(pool_t *pool) buf_hdr->size = seg_size; buf_hdr->type = type; buf_hdr->event_type = type; + buf_hdr->event_subtype = ODP_EVENT_NO_SUBTYPE; buf_hdr->pool_hdl = pool->pool_hdl; buf_hdr->uarea_addr = uarea; /* Show user requested size through API */ @@ -566,6 +567,16 @@ void _odp_buffer_event_type_set(odp_buffer_t buf, int ev) buf_hdl_to_hdr(buf)->event_type = ev; } +odp_event_subtype_t _odp_buffer_event_subtype(odp_buffer_t buf) +{ + return buf_hdl_to_hdr(buf)->event_subtype; +} + +void _odp_buffer_event_subtype_set(odp_buffer_t buf, int ev) +{ + buf_hdl_to_hdr(buf)->event_subtype = ev; +} + odp_pool_t odp_pool_lookup(const char *name) { uint32_t i; From patchwork Tue Jul 11 14:00:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107373 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4916587qge; Tue, 11 Jul 2017 07:02:54 -0700 (PDT) X-Received: by 10.237.46.225 with SMTP id k88mr63437qtd.5.1499781773970; Tue, 11 Jul 2017 07:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499781773; cv=none; d=google.com; s=arc-20160816; b=AeSUawrpLpbsgGjMCmm2poD9RXQaEuDUvBo5xJ3QNOG3CiCBQSpqA/U3PX1xb3P3df 62hJDs0dp3AQx851xhcL1jPdNo1Bc4kNkM8Y9fGZe+Rk22BAiCcnUy2vLqb9sQ5tX8+S 1Cbyti100/m6ALR4tFMpOXESriH5NFVS77t+zdTnSw7VJpu8ZLJk0VmvFQ+D4lHMIbj8 RE9ZXv5yy4axAObizwMTn1AVSLVE+iGAKjIPeVG915OxT9q0aCfr+9yJpnKX2zZff8yJ M5dMIboMheF8wKuL3L2Gf+EBDlINwHhOvOTkNyV6MGiFBfYJQ3yZHKNqeBVOEJwoe3qp F5kA== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=XOO38+LB3l2oLydc50aihXM/NpVUK66Y6Y9GDAcHRUQ=; b=xTXT0+vp7Hkcg+8DKM3j5xzY9rAt1mXHjOYvOioRwnC44ERQhDqkz0SjXmF0i5RGZN RFWtQfOqg58t+6VMyKr0WFMV+CxKZGVfnq1KKHfpDfyvGRi0Q2xlpnv98euQ74sYo1wp jZnwDWbny3AqTl0UFBrFJqgAtDKOqZ+pWLuxtmixlSUgSzYbjgP2RiIhfd7+jxu2B8ye KPM8N/7nXm3QFEuQ1/8k+sMij9ccFlwcgNf27NfbDFRYiGyUgMXx1a/VXebx639jM87a n8zfxPWqw5vXVvzlQkZ5ZQKv494WUlAjBhRGjr2nfXKbqJNm6Ynq1v+Nu5B4qlGcQU4y OBUw== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v206si34991qkb.60.2017.07.11.07.02.53; Tue, 11 Jul 2017 07:02:53 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 991AE60D6F; Tue, 11 Jul 2017 14:02:53 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 E927B60CA4; Tue, 11 Jul 2017 14:02:40 +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 6349360CE4; Tue, 11 Jul 2017 14:02:34 +0000 (UTC) Received: from forward4h.cmail.yandex.net (forward4h.cmail.yandex.net [87.250.230.101]) by lists.linaro.org (Postfix) with ESMTPS id 767DB60A49 for ; Tue, 11 Jul 2017 14:02:08 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward4h.cmail.yandex.net (Yandex) with ESMTP id AE0DD20A37 for ; Tue, 11 Jul 2017 17:02:05 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id CA2163EC34E3 for ; Tue, 11 Jul 2017 17:00:38 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0bLCEeAe; Tue, 11 Jul 2017 17:00:37 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:21 +0300 Message-Id: <1499781629-30670-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 2/10] validation: test correctness of events subtype implementation 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" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ test/common_plat/validation/api/buffer/buffer.c | 50 ++++++++++++++++------ .../validation/api/crypto/odp_crypto_test_inp.c | 14 ++++++ test/common_plat/validation/api/packet/packet.c | 21 ++++++++- test/common_plat/validation/api/timer/timer.c | 32 ++++++++++++-- 4 files changed, 99 insertions(+), 18 deletions(-) diff --git a/test/common_plat/validation/api/buffer/buffer.c b/test/common_plat/validation/api/buffer/buffer.c index 7c723d4f..66d00ab7 100644 --- a/test/common_plat/validation/api/buffer/buffer.c +++ b/test/common_plat/validation/api/buffer/buffer.c @@ -48,7 +48,8 @@ void buffer_test_pool_alloc(void) odp_buffer_t buffer[num]; odp_event_t ev; int index; - char wrong_type = 0, wrong_size = 0, wrong_align = 0; + odp_bool_t wrong_type = false, wrong_subtype = false; + odp_bool_t wrong_size = false, wrong_align = false; odp_pool_param_t params; odp_pool_param_init(¶ms); @@ -63,6 +64,7 @@ void buffer_test_pool_alloc(void) /* Try to allocate num items from the pool */ for (index = 0; index < num; index++) { uintptr_t addr; + odp_event_subtype_t subtype; buffer[index] = odp_buffer_alloc(pool); @@ -71,14 +73,20 @@ void buffer_test_pool_alloc(void) ev = odp_buffer_to_event(buffer[index]); if (odp_event_type(ev) != ODP_EVENT_BUFFER) - wrong_type = 1; + wrong_type = true; + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; + if (odp_event_types(ev, &subtype) != ODP_EVENT_BUFFER) + wrong_type = true; + if (subtype != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; if (odp_buffer_size(buffer[index]) < BUF_SIZE) - wrong_size = 1; + wrong_size = true; addr = (uintptr_t)odp_buffer_addr(buffer[index]); if ((addr % BUF_ALIGN) != 0) - wrong_align = 1; + wrong_align = true; if (wrong_type || wrong_size || wrong_align) odp_buffer_print(buffer[index]); @@ -90,9 +98,10 @@ void buffer_test_pool_alloc(void) index--; /* Check that the pool had correct buffers */ - CU_ASSERT(wrong_type == 0); - CU_ASSERT(wrong_size == 0); - CU_ASSERT(wrong_align == 0); + CU_ASSERT(!wrong_type); + CU_ASSERT(!wrong_subtype); + CU_ASSERT(!wrong_size); + CU_ASSERT(!wrong_align); for (; index >= 0; index--) odp_buffer_free(buffer[index]); @@ -123,7 +132,8 @@ void buffer_test_pool_alloc_multi(void) odp_buffer_t buffer[num + 1]; odp_event_t ev; int index; - char wrong_type = 0, wrong_size = 0, wrong_align = 0; + odp_bool_t wrong_type = false, wrong_subtype = false; + odp_bool_t wrong_size = false, wrong_align = false; odp_pool_param_t params; odp_pool_param_init(¶ms); @@ -140,20 +150,27 @@ void buffer_test_pool_alloc_multi(void) for (index = 0; index < num; index++) { uintptr_t addr; + odp_event_subtype_t subtype; if (buffer[index] == ODP_BUFFER_INVALID) break; ev = odp_buffer_to_event(buffer[index]); if (odp_event_type(ev) != ODP_EVENT_BUFFER) - wrong_type = 1; + wrong_type = true; + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; + if (odp_event_types(ev, &subtype) != ODP_EVENT_BUFFER) + wrong_type = true; + if (subtype != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; if (odp_buffer_size(buffer[index]) < BUF_SIZE) - wrong_size = 1; + wrong_size = true; addr = (uintptr_t)odp_buffer_addr(buffer[index]); if ((addr % BUF_ALIGN) != 0) - wrong_align = 1; + wrong_align = true; if (wrong_type || wrong_size || wrong_align) odp_buffer_print(buffer[index]); @@ -163,9 +180,10 @@ void buffer_test_pool_alloc_multi(void) CU_ASSERT(index == num); /* Check that the pool had correct buffers */ - CU_ASSERT(wrong_type == 0); - CU_ASSERT(wrong_size == 0); - CU_ASSERT(wrong_align == 0); + CU_ASSERT(!wrong_type); + CU_ASSERT(!wrong_subtype); + CU_ASSERT(!wrong_size); + CU_ASSERT(!wrong_align); odp_buffer_free_multi(buffer, num); @@ -244,10 +262,14 @@ void buffer_test_pool_free_multi(void) void buffer_test_management_basic(void) { odp_event_t ev = odp_buffer_to_event(raw_buffer); + odp_event_subtype_t subtype; CU_ASSERT(odp_buffer_is_valid(raw_buffer) == 1); CU_ASSERT(odp_buffer_pool(raw_buffer) != ODP_POOL_INVALID); CU_ASSERT(odp_event_type(ev) == ODP_EVENT_BUFFER); + CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_NO_SUBTYPE); + CU_ASSERT(odp_event_types(ev, &subtype) == ODP_EVENT_BUFFER); + CU_ASSERT(subtype == ODP_EVENT_NO_SUBTYPE); CU_ASSERT(odp_buffer_size(raw_buffer) >= BUF_SIZE); CU_ASSERT(odp_buffer_addr(raw_buffer) != NULL); odp_buffer_print(raw_buffer); diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index ae600e23..1d7d49a2 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -103,6 +103,7 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; int num, i; int found; + odp_event_subtype_t subtype; rc = odp_crypto_capability(&capa); CU_ASSERT(!rc); @@ -263,6 +264,12 @@ static void alg_test(odp_crypto_op_t op, event = odp_queue_deq(suite_context.queue); } while (event == ODP_EVENT_INVALID); + CU_ASSERT(ODP_EVENT_CRYPTO_COMPL == odp_event_type(event)); + CU_ASSERT(ODP_EVENT_NO_SUBTYPE == odp_event_subtype(event)); + CU_ASSERT(ODP_EVENT_CRYPTO_COMPL == + odp_event_types(event, &subtype)); + CU_ASSERT(ODP_EVENT_NO_SUBTYPE == subtype); + compl_event = odp_crypto_compl_from_event(event); CU_ASSERT(odp_crypto_compl_to_u64(compl_event) == odp_crypto_compl_to_u64(odp_crypto_compl_from_event(event))); @@ -272,6 +279,13 @@ static void alg_test(odp_crypto_op_t op, CU_ASSERT(result.pkt == pkt); CU_ASSERT(result.ctx == (void *)0xdeadbeef); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_type(odp_packet_to_event(result.pkt))); + CU_ASSERT(ODP_EVENT_PACKET_BASIC == + odp_event_subtype(odp_packet_to_event(result.pkt))); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_types(odp_packet_to_event(result.pkt), &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_BASIC == subtype); if (should_fail) { CU_ASSERT(!result.ok); diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c index 284aaeb5..fa6f4afd 100644 --- a/test/common_plat/validation/api/packet/packet.c +++ b/test/common_plat/validation/api/packet/packet.c @@ -241,6 +241,7 @@ void packet_test_alloc_free(void) odp_packet_t packet; odp_pool_param_t params; odp_pool_capability_t capa; + odp_event_subtype_t subtype; CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); @@ -259,7 +260,12 @@ void packet_test_alloc_free(void) CU_ASSERT_FATAL(packet != ODP_PACKET_INVALID); CU_ASSERT(odp_packet_len(packet) == packet_len); CU_ASSERT(odp_event_type(odp_packet_to_event(packet)) == - ODP_EVENT_PACKET); + ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) == + ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(odp_packet_to_event(packet), &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); CU_ASSERT(odp_packet_to_u64(packet) != odp_packet_to_u64(ODP_PACKET_INVALID)); @@ -329,9 +335,17 @@ void packet_test_alloc_free_multi(void) CU_ASSERT_FATAL(ret == num_pkt); for (i = 0; i < 2 * num_pkt; ++i) { + odp_event_subtype_t subtype; + CU_ASSERT(odp_packet_len(packet[i]) == packet_len); CU_ASSERT(odp_event_type(odp_packet_to_event(packet[i])) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet[i])) == + ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(odp_packet_to_event(packet[i]), + &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); CU_ASSERT(odp_packet_to_u64(packet[i]) != odp_packet_to_u64(ODP_PACKET_INVALID)); } @@ -449,10 +463,15 @@ void packet_test_event_conversion(void) odp_packet_t pkt = test_packet; odp_packet_t tmp_pkt; odp_event_t ev; + odp_event_subtype_t subtype; ev = odp_packet_to_event(pkt); CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); CU_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(ev, &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); tmp_pkt = odp_packet_from_event(ev); CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID); diff --git a/test/common_plat/validation/api/timer/timer.c b/test/common_plat/validation/api/timer/timer.c index b7d84c64..88135160 100644 --- a/test/common_plat/validation/api/timer/timer.c +++ b/test/common_plat/validation/api/timer/timer.c @@ -59,7 +59,7 @@ void timer_test_timeout_pool_alloc(void) odp_timeout_t tmo[num]; odp_event_t ev; int index; - char wrong_type = 0; + odp_bool_t wrong_type = false, wrong_subtype = false; odp_pool_param_t params; odp_pool_param_init(¶ms); @@ -73,6 +73,8 @@ void timer_test_timeout_pool_alloc(void) /* Try to allocate num items from the pool */ for (index = 0; index < num; index++) { + odp_event_subtype_t subtype; + tmo[index] = odp_timeout_alloc(pool); if (tmo[index] == ODP_TIMEOUT_INVALID) @@ -80,7 +82,13 @@ void timer_test_timeout_pool_alloc(void) ev = odp_timeout_to_event(tmo[index]); if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) - wrong_type = 1; + wrong_type = true; + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; + if (odp_event_types(ev, &subtype) != ODP_EVENT_TIMEOUT) + wrong_type = true; + if (subtype != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; } /* Check that the pool had at least num items */ @@ -89,7 +97,8 @@ void timer_test_timeout_pool_alloc(void) index--; /* Check that the pool had correct buffers */ - CU_ASSERT(wrong_type == 0); + CU_ASSERT(!wrong_type); + CU_ASSERT(!wrong_subtype); for (; index >= 0; index--) odp_timeout_free(tmo[index]); @@ -219,12 +228,29 @@ void timer_test_odp_timer_cancel(void) /* @private Handle a received (timeout) event */ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) { + odp_event_subtype_t subtype; + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); /* Internal error */ if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) { /* Not a timeout event */ CU_FAIL("Unexpected event type received"); return; } + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) { + /* Not a timeout event */ + CU_FAIL("Unexpected event subtype received"); + return; + } + if (odp_event_types(ev, &subtype) != ODP_EVENT_TIMEOUT) { + /* Not a timeout event */ + CU_FAIL("Unexpected event type received"); + return; + } + if (subtype != ODP_EVENT_NO_SUBTYPE) { + /* Not a timeout event */ + CU_FAIL("Unexpected event subtype received"); + return; + } /* Read the metadata from the timeout */ odp_timeout_t tmo = odp_timeout_from_event(ev); odp_timer_t tim = odp_timeout_timer(tmo); From patchwork Tue Jul 11 14:00:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107385 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4936610qge; Tue, 11 Jul 2017 07:18:33 -0700 (PDT) X-Received: by 10.200.37.98 with SMTP id 31mr204852qtn.92.1499782713414; Tue, 11 Jul 2017 07:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499782713; cv=none; d=google.com; s=arc-20160816; b=lkyPk4+pD/htJa85KMc+B1qiCO8vYICm309mOT+UWA2JsXo/W1KqxjKp622wkxFgDP ODsq24oZFJH+iNTmAxTQdY5M7yiMnLC22CTk8+qFtJk4qFHZmljOtkAOjrM0RY5ORYgR RRK88rNN4XCUzJxP33uMTDXGbsH6mmgBU0lac/ZeSWyaMyifZsgA2S4uIwdk0uSS9VlG cvuNXlAg5Nkni2SF8fKI/Cpb8WfechVAHBaTXqn82lhI51oCoEqcaPLjw0o4Zu6/vELW GQL5NC07ZD3t12bNxiLE0J7UfIIkSfZa5DLKJxkiRvi1Uo3MHDU5wZEGwsb+NOXm71NM t3DA== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=JUshrwkbsxNJuRrNLhlxCw2UYoa7r49dC/5s5q4Z2F0=; b=WPEPpDjgTJisdexvyHyTF7NM+AhWJw8AWvKljttfvSLGjZXfe/mtyO+RYROeJ4k56B KCpSscK4pHy4GjXNSzh01nbTvU1ntxOgtKbPP52WsToSY2m+Qai8fxbbqe8WsXeBticC uDHu2aIwWGcm9yzICFExD1qzyWQj2fUwUxi1mhmmvpRNM2nYRCqQos+E3WP3nc1dH0sg 6cLOi0Iw1xKk88IdYfb8ePli+7TmnKfti6afCsBqXfs+kkQ6LvIdrtslpO+az5FOi2wO V/gK2vnPFfPO4J0dNVt5PvqB+fhJe4S7z/TESav3XUZuaRglPl6IcYsGeaA7YxyizZps dH/A== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q7si53400qtd.274.2017.07.11.07.18.33; Tue, 11 Jul 2017 07:18:33 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 12F0764479; Tue, 11 Jul 2017 14:18:33 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 B992660D87; Tue, 11 Jul 2017 14:17:02 +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 E13956447B; Tue, 11 Jul 2017 14:16:47 +0000 (UTC) Received: from forward1p.cmail.yandex.net (forward1p.cmail.yandex.net [77.88.31.16]) by lists.linaro.org (Postfix) with ESMTPS id B1D8460D75 for ; Tue, 11 Jul 2017 14:09:55 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward1p.cmail.yandex.net (Yandex) with ESMTP id 6B419211E9 for ; Tue, 11 Jul 2017 17:09:53 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 755C03EC3491 for ; Tue, 11 Jul 2017 17:00:39 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0dLmDFCQ; Tue, 11 Jul 2017 17:00:39 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:22 +0300 Message-Id: <1499781629-30670-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 3/10] linux-gen: drop crypto async mode implementation 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" From: Dmitry Eremin-Solenikov Currently even if application asks odp_crypto to use ASYNC mode via pref_mode, implemetation can still return packets syncrhonously. In preparation of forthcoming changes, make linux-generic implementation always return packets in sync way. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ .../linux-generic/include/odp_crypto_internal.h | 8 --- .../linux-generic/include/odp_packet_internal.h | 4 -- platform/linux-generic/odp_crypto.c | 61 +++++----------------- platform/linux-generic/odp_packet.c | 1 - 4 files changed, 12 insertions(+), 62 deletions(-) diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index c3b70b23..52b94d07 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -56,14 +56,6 @@ struct odp_crypto_generic_session { }; /** - * Per packet operation result - */ -typedef struct odp_crypto_generic_op_result { - uint32_t magic; - odp_crypto_op_result_t result; -} odp_crypto_generic_op_result_t; - -/** * Per session creation operation result */ typedef struct odp_crypto_generic_session_result { diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index cdd139bb..9f28fc05 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -128,9 +128,6 @@ typedef struct { /* Classifier destination queue */ odp_queue_t dst_queue; - /* Result for crypto */ - odp_crypto_generic_op_result_t op_result; - /* Packet data storage */ uint8_t data[0]; } odp_packet_hdr_t; @@ -171,7 +168,6 @@ static inline void copy_packet_cls_metadata(odp_packet_hdr_t *src_hdr, dst_hdr->dst_queue = src_hdr->dst_queue; dst_hdr->flow_hash = src_hdr->flow_hash; dst_hdr->timestamp = src_hdr->timestamp; - dst_hdr->op_result = src_hdr->op_result; } static inline void pull_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 0e2adad1..b23b5b6b 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -88,14 +88,6 @@ struct odp_crypto_global_s { static odp_crypto_global_t *global; static -odp_crypto_generic_op_result_t *get_op_result_from_event(odp_event_t ev) -{ - odp_packet_hdr_t *hdr = odp_packet_hdr(odp_packet_from_event(ev)); - - return &hdr->op_result; -} - -static odp_crypto_generic_session_t *alloc_session(void) { odp_crypto_generic_session_t *session = NULL; @@ -903,37 +895,14 @@ odp_crypto_operation(odp_crypto_op_param_t *param, (rc_cipher == ODP_CRYPTO_ALG_ERR_NONE) && (rc_auth == ODP_CRYPTO_ALG_ERR_NONE); - /* If specified during creation post event to completion queue */ - if (ODP_QUEUE_INVALID != session->p.compl_queue) { - odp_event_t completion_event; - odp_crypto_generic_op_result_t *op_result; - odp_buffer_t buf; - - /* Linux generic will always use packet for completion event */ - completion_event = odp_packet_to_event(param->out_pkt); - buf = odp_buffer_from_event(completion_event); - _odp_buffer_event_type_set(buf, ODP_EVENT_CRYPTO_COMPL); - _odp_buffer_event_subtype_set(buf, ODP_EVENT_NO_SUBTYPE); - /* Asynchronous, build result (no HW so no errors) and send it*/ - op_result = get_op_result_from_event(completion_event); - op_result->magic = OP_RESULT_MAGIC; - op_result->result = local_result; - if (odp_queue_enq(session->p.compl_queue, completion_event)) { - odp_event_free(completion_event); - goto err; - } + /* Synchronous, simply return results */ + if (!result) + goto err; + *result = local_result; - /* Indicate to caller operation was async */ - *posted = 1; - } else { - /* Synchronous, simply return results */ - if (!result) - goto err; - *result = local_result; + /* Indicate to caller operation was sync */ + *posted = 0; - /* Indicate to caller operation was sync */ - *posted = 0; - } return 0; err: @@ -1093,25 +1062,19 @@ void odp_crypto_compl_result(odp_crypto_compl_t completion_event, odp_crypto_op_result_t *result) { - odp_event_t ev = odp_crypto_compl_to_event(completion_event); - odp_crypto_generic_op_result_t *op_result; + (void)completion_event; + (void)result; - op_result = get_op_result_from_event(ev); - - if (OP_RESULT_MAGIC != op_result->magic) - ODP_ABORT(); - - memcpy(result, &op_result->result, sizeof(*result)); + /* We won't get such events anyway, so there can be no result */ + ODP_ASSERT(0); } void odp_crypto_compl_free(odp_crypto_compl_t completion_event) { - odp_buffer_t buf = - odp_buffer_from_event((odp_event_t)completion_event); + odp_event_t ev = odp_crypto_compl_to_event(completion_event); - _odp_buffer_event_type_set(buf, ODP_EVENT_PACKET); - _odp_buffer_event_subtype_set(buf, ODP_EVENT_PACKET_BASIC); + odp_buffer_free(odp_buffer_from_event(ev)); } void odp_crypto_session_param_init(odp_crypto_session_param_t *param) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 3789feca..22358438 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -166,7 +166,6 @@ static inline void packet_seg_copy_md(odp_packet_hdr_t *dst, dst->dst_queue = src->dst_queue; dst->flow_hash = src->flow_hash; dst->timestamp = src->timestamp; - dst->op_result = src->op_result; /* buffer header side packet metadata */ dst->buf_hdr.buf_u64 = src->buf_hdr.buf_u64; From patchwork Tue Jul 11 14:00:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107391 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4941190qge; Tue, 11 Jul 2017 07:22:25 -0700 (PDT) X-Received: by 10.55.181.71 with SMTP id e68mr168041qkf.91.1499782945254; Tue, 11 Jul 2017 07:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499782945; cv=none; d=google.com; s=arc-20160816; b=apGqltKh5jBruv6k9PFGmUwjol1U6/PoqCCGSXuK13txTbiMkbX+K6KrIiXb7HAQfc S0IMWgcw0urXRS4TgcnOeVLSbhBHY720Lgfoyerfto2kLMHaOefrZZavzuorejNdRXuu 8Pt+uziBDVJmZ6q1+KLcgvfxZyF1k2GCKpOhJ6Xs0P12t9NZpkWS7D0VkowFH6ZXh7dP oO3ECwIJR5r9HTI1FbpPbEZgSiVqvcieOyDfI7cQw9EA5ySHqEruMdqfpA/tuZtzAJzI vc31nlMi9hOouexcHW5W5pS3VDJDMcJobmwpdIGEi0+lU90c2FwXYcrzVZ/wzP/5RGzx qfFQ== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=otoWp6aw1e57nmbOWtpjI2Xh8wmaa9IxMJcotYrXuxs=; b=BVicnqDzhwWvuILZ5odyPal4spYfCcWZ3hHrmsbiDIfMUURC888589p/VTjB4cQDZ9 eFIvyPGU6uXqOOB1KuAqMnPvK/NtVGWa/F3CMKV7XAjJrv4Ni5Uu/JWagHphwYhY/4Ne 7GE+1ikB64+nf9szBljgP4cfcWCyfwMInKKezb0TEciT0RCXsZcwyTAkpjpuT3enXONA a/x6xIdQCDiSb7a27pG5Zw9tAVUwz3SPC8upMHjc3hVUxJJQGpdoGcbmubAom7Pa6rRO 54cc3VKEeFMxLLUoZaNOoKA+6G1C8xAE9+Cu6Lp3wdGorssoAkGHEx2A6qldVsuIXWqe eh5g== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t187si62635qkh.150.2017.07.11.07.22.25; Tue, 11 Jul 2017 07:22:25 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id EB0A660D83; Tue, 11 Jul 2017 14:22:24 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 EA0FB60D87; Tue, 11 Jul 2017 14:18:38 +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 CFE0E60D86; Tue, 11 Jul 2017 14:18:28 +0000 (UTC) Received: from forward4j.cmail.yandex.net (forward4j.cmail.yandex.net [5.255.227.22]) by lists.linaro.org (Postfix) with ESMTPS id 0A76D60D42 for ; Tue, 11 Jul 2017 14:14:31 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward4j.cmail.yandex.net (Yandex) with ESMTP id A983221285 for ; Tue, 11 Jul 2017 17:14:29 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id DB7BE3EC350B for ; Tue, 11 Jul 2017 17:00:41 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0eLSwr2U; Tue, 11 Jul 2017 17:00:40 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:23 +0300 Message-Id: <1499781629-30670-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 4/10] linux-gen: fix ODP_HANDLE_T expansion with c++ if type is compound 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" From: Dmitry Eremin-Solenikov Currently expansion of ODP_HANDLE_T defined in strong_types.h would result in concatenating undercrore with 'type'. If type defined using macro, this can result in underscore being concatenated with macro name, resulting in further errors. Use two-stage ODP_HANDLE_T expansion in C++ case so that macro params are expanded first, before being concatenated with underscore. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ platform/linux-generic/include/odp/api/plat/strong_types.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/include/odp/api/plat/strong_types.h b/platform/linux-generic/include/odp/api/plat/strong_types.h index a53d7635..2e3070f8 100644 --- a/platform/linux-generic/include/odp/api/plat/strong_types.h +++ b/platform/linux-generic/include/odp/api/plat/strong_types.h @@ -17,7 +17,9 @@ /** Use strong typing for ODP types */ #ifdef __cplusplus -#define ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +/* Allow type to be expanded before concatenation with underscore */ +#define _ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +#define ODP_HANDLE_T(type) _ODP_HANDLE_T(type) #else #define odp_handle_t struct { uint8_t unused_dummy_var; } * /** C/C++ helper macro for strong typing */ From patchwork Tue Jul 11 14:00:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107381 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4934794qge; Tue, 11 Jul 2017 07:17:01 -0700 (PDT) X-Received: by 10.200.57.162 with SMTP id v31mr154334qte.57.1499782621042; Tue, 11 Jul 2017 07:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499782621; cv=none; d=google.com; s=arc-20160816; b=yKwp+aQBnRdPede7Q5HxPxNLwkvOc5uH0J8gVUG0S0KsCyC+vl3OGia65c7ryD7pWb MU0ezGVUIIh4eoXkeHAk5bA6MiXYyLxvX2tVGJpqGhtzKVoWk0gbVLgoebDfG1iFFTcw ZQEpy3/NOGsy2I7n4qORYIZYp2XZVO4Ga4SqS50yF/Ox44OLuj8naEXOpisdX7xsvte2 1NsampBY4FNt7tpuouWgaKMY2D7yNRWeBxWm7XRiFbLxszmc3BomUYk7Ic+8AUnQhvs3 AuQytC2vmEq9t9FCa46/JDrs6gUrZIeC0Bfngo4mjVi2VnH6u8lARmMEI2I4VXSWr5Lg rIGw== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=DasOjdsYEoZakMRtX1hoYzrfftLeNrz1skC90JL/XC8=; b=g7fkT7yHxz5l9U6hMcg6apTn9SMkhILsYCbgdA53zJeoaYBCIEZXqtiehUf9qfmrXR +ndn0Ouo/aLVISAhLUmneYKc5ap4Utu9amQ2qa+f/zvFMQfvwcI0Jh2ce1Xk3nL2OQHf /elp+55AB2cUcVThvM1J68eXcHpABOIzB7gaX8Zj3GCdeOOLrcWrVL8DjnLAJLmZMp9W QvjOPMOBH55J4l0VW6Vl478oUSE/nQ0PHUppJG+RZoD3rSag9r22TA84JvxzR6GWpMZk wpZ2BQew7r7oSBJX0mabWTS7EZbrgrEWp+T6AX4wrCvMaitj1caQVRiQ4a0dWlc2SE+S PmxA== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n68si62185qkn.62.2017.07.11.07.17.00; Tue, 11 Jul 2017 07:17:01 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 9BEA760D75; Tue, 11 Jul 2017 14:17:00 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 831666064A; Tue, 11 Jul 2017 14:10:34 +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 092B960CD1; Tue, 11 Jul 2017 14:10:14 +0000 (UTC) Received: from forward1h.cmail.yandex.net (forward1h.cmail.yandex.net [87.250.230.16]) by lists.linaro.org (Postfix) with ESMTPS id 013856081D for ; Tue, 11 Jul 2017 14:09:33 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward1h.cmail.yandex.net (Yandex) with ESMTP id B618621303 for ; Tue, 11 Jul 2017 17:09:31 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 78C0E3EC3520 for ; Tue, 11 Jul 2017 17:00:42 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0gLeOi22; Tue, 11 Jul 2017 17:00:42 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:24 +0300 Message-Id: <1499781629-30670-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 5/10] api: crypto: deprecate ASYNC mode and odp_crypto_compl_t 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" From: Dmitry Eremin-Solenikov Setting pref_mode to ASYNC now results in SYNC behaviour, so let's deprecate all ASYNC-related crypto items: pref_mode, odp_crypto_compl_t and related functions. Passing context through param/result is also deprecated, as odp_crypto_operation now works only in sync mode, thus there is no need to pass additional data around it. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ example/ipsec/odp_ipsec.c | 14 +------- example/ipsec/odp_ipsec_cache.c | 15 ++------ example/ipsec/odp_ipsec_cache.h | 6 +--- include/odp/api/spec/crypto.h | 31 ++++++++++------ include/odp/arch/default/api/abi/crypto.h | 4 ++- include/odp/arch/default/api/abi/event.h | 4 ++- .../include/odp/api/plat/crypto_types.h | 3 +- .../include/odp/api/plat/event_types.h | 3 +- platform/linux-generic/odp_crypto.c | 14 +++++--- platform/linux-generic/odp_event.c | 2 ++ test/common_plat/performance/odp_crypto.c | 42 +--------------------- test/common_plat/validation/api/crypto/crypto.c | 2 -- .../validation/api/crypto/odp_crypto_test_inp.c | 40 +-------------------- .../validation/api/crypto/odp_crypto_test_inp.h | 2 -- 14 files changed, 49 insertions(+), 133 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 9ed3aa20..1ed03585 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -393,9 +393,7 @@ void ipsec_init_post(crypto_api_mode_e api_mode) auth_sa, tun, api_mode, - entry->input, - completionq, - out_pool)) { + entry->input)) { EXAMPLE_ERR("Error: IPSec cache entry failed.\n" ); exit(EXIT_FAILURE); @@ -662,7 +660,6 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt, /* Initialize parameters block */ memset(¶ms, 0, sizeof(params)); - params.ctx = ctx; params.session = entry->state.session; params.pkt = pkt; params.out_pkt = entry->in_place ? pkt : ODP_PACKET_INVALID; @@ -843,7 +840,6 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt, /* Initialize parameters block */ memset(¶ms, 0, sizeof(params)); params.session = entry->state.session; - params.ctx = ctx; params.pkt = pkt; params.out_pkt = entry->in_place ? pkt : ODP_PACKET_INVALID; @@ -1085,14 +1081,6 @@ int pktio_thread(void *arg EXAMPLE_UNUSED) } ctx->state = PKT_STATE_INPUT_VERIFY; } - } else if (ODP_EVENT_CRYPTO_COMPL == odp_event_type(ev)) { - odp_crypto_compl_t compl; - - compl = odp_crypto_compl_from_event(ev); - odp_crypto_compl_result(compl, &result); - odp_crypto_compl_free(compl); - pkt = result.pkt; - ctx = result.ctx; } else { abort(); } diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c index dba0ea0a..e4150336 100644 --- a/example/ipsec/odp_ipsec_cache.c +++ b/example/ipsec/odp_ipsec_cache.c @@ -40,9 +40,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, sa_db_entry_t *auth_sa, tun_db_entry_t *tun, crypto_api_mode_e api_mode, - odp_bool_t in, - odp_queue_t completionq, - odp_pool_t out_pool) + odp_bool_t in) { odp_crypto_session_param_t params; ipsec_cache_entry_t *entry; @@ -65,15 +63,8 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, /* Setup parameters and call crypto library to create session */ params.op = (in) ? ODP_CRYPTO_OP_DECODE : ODP_CRYPTO_OP_ENCODE; params.auth_cipher_text = TRUE; - if (CRYPTO_API_SYNC == api_mode) { - params.pref_mode = ODP_CRYPTO_SYNC; - params.compl_queue = ODP_QUEUE_INVALID; - params.output_pool = ODP_POOL_INVALID; - } else { - params.pref_mode = ODP_CRYPTO_ASYNC; - params.compl_queue = completionq; - params.output_pool = out_pool; - } + params.compl_queue = ODP_QUEUE_INVALID; + params.output_pool = ODP_POOL_INVALID; if (CRYPTO_API_ASYNC_NEW_BUFFER == api_mode) entry->in_place = FALSE; diff --git a/example/ipsec/odp_ipsec_cache.h b/example/ipsec/odp_ipsec_cache.h index 7a4b95cd..ce37ccce 100644 --- a/example/ipsec/odp_ipsec_cache.h +++ b/example/ipsec/odp_ipsec_cache.h @@ -85,8 +85,6 @@ void init_ipsec_cache(void); * @param tun Tunnel DB entry pointer * @param api_mode Crypto API mode for testing * @param in Direction (input versus output) - * @param completionq Completion queue - * @param out_pool Output buffer pool * * @return 0 if successful else -1 */ @@ -94,9 +92,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, sa_db_entry_t *auth_sa, tun_db_entry_t *tun, crypto_api_mode_e api_mode, - odp_bool_t in, - odp_queue_t completionq, - odp_pool_t out_pool); + odp_bool_t in); /** * Find a matching IPsec cache entry for input packet diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index 470cba05..b9d42937 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -270,8 +270,11 @@ typedef struct odp_crypto_session_param_t { */ odp_bool_t auth_cipher_text; - /** Preferred sync vs. async */ - odp_crypto_op_mode_t pref_mode; + /** Preferred sync vs. async + * + * @deprecated no-op now, odp_crypto_operation() will always process + * data in non-posted mode */ + odp_crypto_op_mode_t ODP_DEPRECATE(pref_mode); /** Cipher algorithm * @@ -334,8 +337,11 @@ typedef struct odp_crypto_op_param_t { /** Session handle from creation */ odp_crypto_session_t session; - /** User context */ - void *ctx; + /** User context + * + * @deprecated No need to pass context around sync calls + * */ + void *ODP_DEPRECATE(ctx); /** Input packet * @@ -618,7 +624,8 @@ int odp_crypto_session_destroy(odp_crypto_session_t session); * * @return crypto completion handle */ -odp_crypto_compl_t odp_crypto_compl_from_event(odp_event_t ev); +ODP_DEPRECATE(odp_crypto_compl_t) ODP_DEPRECATE(odp_crypto_compl_from_event)( + odp_event_t ev); /** * Convert crypto completion handle to event handle @@ -627,14 +634,16 @@ odp_crypto_compl_t odp_crypto_compl_from_event(odp_event_t ev); * * @return Event handle */ -odp_event_t odp_crypto_compl_to_event(odp_crypto_compl_t completion_event); +odp_event_t ODP_DEPRECATE(odp_crypto_compl_to_event)( + ODP_DEPRECATE(odp_crypto_compl_t) completion_event); /** * Release crypto completion event * * @param completion_event Completion event we are done accessing */ -void odp_crypto_compl_free(odp_crypto_compl_t completion_event); +void ODP_DEPRECATE(odp_crypto_compl_free)( + ODP_DEPRECATE(odp_crypto_compl_t) completion_event); /** * Crypto per packet operation @@ -662,8 +671,9 @@ int odp_crypto_operation(odp_crypto_op_param_t *param, * @param completion_event Event containing operation results * @param result Pointer to result structure */ -void odp_crypto_compl_result(odp_crypto_compl_t completion_event, - odp_crypto_op_result_t *result); +void ODP_DEPRECATE(odp_crypto_compl_result)( + ODP_DEPRECATE(odp_crypto_compl_t) completion_event, + odp_crypto_op_result_t *result); /** * Get printable value for an odp_crypto_session_t @@ -689,7 +699,8 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl); * 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); +uint64_t ODP_DEPRECATE(odp_crypto_compl_to_u64)( + ODP_DEPRECATE(odp_crypto_compl_t) hdl); /** * Initialize crypto session parameters diff --git a/include/odp/arch/default/api/abi/crypto.h b/include/odp/arch/default/api/abi/crypto.h index f0793a19..2d02eee6 100644 --- a/include/odp/arch/default/api/abi/crypto.h +++ b/include/odp/arch/default/api/abi/crypto.h @@ -11,6 +11,8 @@ extern "C" { #endif +#include + #include /** @internal Dummy type for strong typing */ @@ -23,7 +25,7 @@ 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; +typedef _odp_abi_crypto_compl_t *ODP_DEPRECATE(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 ab3c0f75..23b16efd 100644 --- a/include/odp/arch/default/api/abi/event.h +++ b/include/odp/arch/default/api/abi/event.h @@ -11,6 +11,8 @@ extern "C" { #endif +#include + #include /** @internal Dummy type for strong typing */ @@ -28,7 +30,7 @@ typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, ODP_EVENT_PACKET = 2, ODP_EVENT_TIMEOUT = 3, - ODP_EVENT_CRYPTO_COMPL = 4, + ODP_DEPRECATE(ODP_EVENT_CRYPTO_COMPL) = 4, ODP_EVENT_IPSEC_STATUS = 5 } odp_event_type_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 2cc747eb..23e1cc42 100644 --- a/platform/linux-generic/include/odp/api/plat/crypto_types.h +++ b/platform/linux-generic/include/odp/api/plat/crypto_types.h @@ -22,6 +22,7 @@ extern "C" { #if ODP_ABI_COMPAT == 1 #include #else +#include /** @ingroup odp_crypto * @{ @@ -30,7 +31,7 @@ extern "C" { #define ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL) typedef uint64_t odp_crypto_session_t; -typedef ODP_HANDLE_T(odp_crypto_compl_t); +typedef ODP_HANDLE_T(ODP_DEPRECATE(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 5b3a07e3..1987bc8b 100644 --- a/platform/linux-generic/include/odp/api/plat/event_types.h +++ b/platform/linux-generic/include/odp/api/plat/event_types.h @@ -23,6 +23,7 @@ extern "C" { #include #else +#include #include #include @@ -38,7 +39,7 @@ typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, ODP_EVENT_PACKET = 2, ODP_EVENT_TIMEOUT = 3, - ODP_EVENT_CRYPTO_COMPL = 4, + ODP_DEPRECATE(ODP_EVENT_CRYPTO_COMPL) = 4, ODP_EVENT_IPSEC_STATUS = 5 } odp_event_type_t; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index b23b5b6b..075bb02b 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -885,7 +885,9 @@ odp_crypto_operation(odp_crypto_op_param_t *param, } /* Fill in result */ +#if ODP_DEPRECATED_API local_result.ctx = param->ctx; +#endif local_result.pkt = param->out_pkt; local_result.cipher_status.alg_err = rc_cipher; local_result.cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE; @@ -1045,6 +1047,7 @@ int32_t odp_random_test_data(uint8_t *buf, uint32_t len, uint64_t *seed) return len; } +#if ODP_DEPRECATED_API odp_crypto_compl_t odp_crypto_compl_from_event(odp_event_t ev) { /* This check not mandated by the API specification */ @@ -1077,6 +1080,12 @@ odp_crypto_compl_free(odp_crypto_compl_t completion_event) odp_buffer_free(odp_buffer_from_event(ev)); } +uint64_t odp_crypto_compl_to_u64(odp_crypto_compl_t hdl) +{ + return _odp_pri(hdl); +} +#endif + void odp_crypto_session_param_init(odp_crypto_session_param_t *param) { memset(param, 0, sizeof(odp_crypto_session_param_t)); @@ -1086,8 +1095,3 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl) { return (uint64_t)hdl; } - -uint64_t odp_crypto_compl_to_u64(odp_crypto_compl_t hdl) -{ - return _odp_pri(hdl); -} diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c index 23b410d8..56cc90b0 100644 --- a/platform/linux-generic/odp_event.c +++ b/platform/linux-generic/odp_event.c @@ -46,9 +46,11 @@ void odp_event_free(odp_event_t event) case ODP_EVENT_TIMEOUT: odp_timeout_free(odp_timeout_from_event(event)); break; +#if ODP_DEPRECATED_API case ODP_EVENT_CRYPTO_COMPL: odp_crypto_compl_free(odp_crypto_compl_from_event(event)); break; +#endif default: ODP_ABORT("Invalid event type: %d\n", odp_event_type(event)); } diff --git a/test/common_plat/performance/odp_crypto.c b/test/common_plat/performance/odp_crypto.c index c3dd6d38..bc29a888 100644 --- a/test/common_plat/performance/odp_crypto.c +++ b/test/common_plat/performance/odp_crypto.c @@ -427,7 +427,6 @@ create_session_from_config(odp_crypto_session_t *session, odp_crypto_session_param_init(¶ms); memcpy(¶ms, &config->session, sizeof(odp_crypto_session_param_t)); params.op = ODP_CRYPTO_OP_ENCODE; - params.pref_mode = ODP_CRYPTO_SYNC; /* Lookup the packet pool */ pkt_pool = odp_pool_lookup("packet_pool"); @@ -571,7 +570,7 @@ run_measure_one(crypto_args_t *cargs, packets_sent++; } - if (!posted) { + if (1) { packets_received++; if (cargs->debug_packets) { mem = odp_packet_data(params.out_pkt); @@ -587,45 +586,6 @@ run_measure_one(crypto_args_t *cargs, odp_packet_free(params.out_pkt); } } - } else { - odp_event_t ev; - odp_crypto_compl_t compl; - odp_crypto_op_result_t result; - odp_packet_t out_pkt; - - if (cargs->schedule) - ev = odp_schedule(NULL, - ODP_SCHED_NO_WAIT); - else - ev = odp_queue_deq(out_queue); - - while (ev != ODP_EVENT_INVALID) { - compl = odp_crypto_compl_from_event(ev); - odp_crypto_compl_result(compl, &result); - odp_crypto_compl_free(compl); - out_pkt = result.pkt; - - if (cargs->debug_packets) { - mem = odp_packet_data(out_pkt); - print_mem("Receieved encrypted packet", - mem, - payload_length + - config-> - session.auth_digest_len); - } - if (cargs->reuse_packet) { - params.pkt = out_pkt; - params.out_pkt = ODP_PACKET_INVALID; - } else { - odp_packet_free(out_pkt); - } - packets_received++; - if (cargs->schedule) - ev = odp_schedule(NULL, - ODP_SCHED_NO_WAIT); - else - ev = odp_queue_deq(out_queue); - }; } } diff --git a/test/common_plat/validation/api/crypto/crypto.c b/test/common_plat/validation/api/crypto/crypto.c index 94beb2f1..fde95ab7 100644 --- a/test/common_plat/validation/api/crypto/crypto.c +++ b/test/common_plat/validation/api/crypto/crypto.c @@ -15,8 +15,6 @@ odp_suiteinfo_t crypto_suites[] = { {ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, crypto_suite_term, crypto_suite}, - {ODP_CRYPTO_ASYNC_INP, crypto_suite_async_init, crypto_suite_term, - crypto_suite}, ODP_SUITE_INFO_NULL, }; diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index 1d7d49a2..d42ecb68 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -14,7 +14,6 @@ #define MAX_ALG_CAPA 32 struct suite_context_s { - odp_crypto_op_mode_t pref_mode; odp_pool_t pool; odp_queue_t queue; }; @@ -92,8 +91,6 @@ static void alg_test(odp_crypto_op_t op, int rc; odp_crypto_ses_create_err_t status; odp_bool_t posted; - odp_event_t event; - odp_crypto_compl_t compl_event; odp_crypto_op_result_t result; odp_crypto_session_param_t ses_params; odp_crypto_op_param_t op_params; @@ -196,7 +193,6 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_session_param_init(&ses_params); ses_params.op = op; ses_params.auth_cipher_text = false; - ses_params.pref_mode = suite_context.pref_mode; ses_params.cipher_alg = cipher_alg; ses_params.auth_alg = auth_alg; ses_params.compl_queue = suite_context.queue; @@ -225,7 +221,6 @@ static void alg_test(odp_crypto_op_t op, op_params.session = session; op_params.pkt = pkt; op_params.out_pkt = pkt; - op_params.ctx = (void *)0xdeadbeef; if (cipher_range) { op_params.cipher_range = *cipher_range; @@ -258,27 +253,8 @@ static void alg_test(odp_crypto_op_t op, goto cleanup; } - if (posted) { - /* Poll completion queue for results */ - do { - event = odp_queue_deq(suite_context.queue); - } while (event == ODP_EVENT_INVALID); - - CU_ASSERT(ODP_EVENT_CRYPTO_COMPL == odp_event_type(event)); - CU_ASSERT(ODP_EVENT_NO_SUBTYPE == odp_event_subtype(event)); - CU_ASSERT(ODP_EVENT_CRYPTO_COMPL == - odp_event_types(event, &subtype)); - CU_ASSERT(ODP_EVENT_NO_SUBTYPE == subtype); - - compl_event = odp_crypto_compl_from_event(event); - CU_ASSERT(odp_crypto_compl_to_u64(compl_event) == - odp_crypto_compl_to_u64(odp_crypto_compl_from_event(event))); - odp_crypto_compl_result(compl_event, &result); - odp_crypto_compl_free(compl_event); - } - + CU_ASSERT(posted == 0); CU_ASSERT(result.pkt == pkt); - CU_ASSERT(result.ctx == (void *)0xdeadbeef); CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(odp_packet_to_event(result.pkt))); CU_ASSERT(ODP_EVENT_PACKET_BASIC == @@ -1519,20 +1495,6 @@ int crypto_suite_sync_init(void) return -1; suite_context.queue = ODP_QUEUE_INVALID; - suite_context.pref_mode = ODP_CRYPTO_SYNC; - return 0; -} - -int crypto_suite_async_init(void) -{ - suite_context.pool = odp_pool_lookup("packet_pool"); - if (suite_context.pool == ODP_POOL_INVALID) - return -1; - suite_context.queue = odp_queue_lookup("crypto-out"); - if (suite_context.queue == ODP_QUEUE_INVALID) - return -1; - - suite_context.pref_mode = ODP_CRYPTO_ASYNC; return 0; } diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h index 0f693379..86ecce8e 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h @@ -9,14 +9,12 @@ #include /* Suite names */ -#define ODP_CRYPTO_ASYNC_INP "odp_crypto_async_inp" #define ODP_CRYPTO_SYNC_INP "odp_crypto_sync_inp" /* Suite test array */ extern odp_testinfo_t crypto_suite[]; int crypto_suite_sync_init(void); -int crypto_suite_async_init(void); int crypto_suite_term(void); #endif From patchwork Tue Jul 11 14:00:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107375 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4919700qge; Tue, 11 Jul 2017 07:04:55 -0700 (PDT) X-Received: by 10.237.56.40 with SMTP id j37mr72578qte.45.1499781895494; Tue, 11 Jul 2017 07:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499781895; cv=none; d=google.com; s=arc-20160816; b=izFPewMqq7X8crvMhImGmG/LmEsPCX9EYR1jL+Fhd0D6k4t97sjoWZdqP1x2icN/yB DVNbJgaxXNGRo+DqNXTke9muZcXSfVsI3dR1+vXMJBOHyM6LeqMx+al2uZ0HA0f/1uQi 9lPfWZqrQpflShjMGWRuZvqwm6kgqFVage+dKc8y6yI/EjrLrVm0JdHAgBpK+j4m4fIV BkZKasvCyR+GpaPJ7IF75/ImzAjDfUAU3KdctyuXbqXl1xb8VlbN68k+4qYW1YdqNepr b22c3z8BQCSC03p+wnxinoqZeD1/TEacC9kgqFpECVi0BD+4kXwfhKXPWkSUMcIRkzKp JE8A== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=C9XDquyOerAwJ7PTjU1q55uHMl9Tf4bOoFfS3sOCYhM=; b=nPCJmWxVjNPU6zrfKSvg/FngLBmRk+74lviVTS/QjbuEUzWSiO9y35Zt6ovZA/Z46j qcnScJGtJe7owXZmCu7AiNi3QW/BUz1gmWlosd4AKSDiLsakgc9yiraJOxm1/1aju6Lz UL16RTNlrr3wF5z15R/9JsaICHeWZurj9Jp1fs/a3wJbHU6PdYzz3dkGK5ixG05bJ5+R /W376xfjdo77Y7CKFwUHyFV8tfWYfRqHgZ5iNIKB7mZHpLxA1TcR8Fo/S2fAU/QPuKiA cI7emil2SUaJfKhMnm7HoMTPFTZVW0hXegViQHT9DacqeKSGB7CKTb/Ch9fZ9aJh9UPh 79Ig== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p41si50632qta.19.2017.07.11.07.04.55; Tue, 11 Jul 2017 07:04:55 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 25DB864478; Tue, 11 Jul 2017 14:04:55 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 AAE4860CA4; Tue, 11 Jul 2017 14:04:44 +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 45E2360CD1; Tue, 11 Jul 2017 14:04:37 +0000 (UTC) Received: from forward4o.cmail.yandex.net (forward4o.cmail.yandex.net [37.9.109.248]) by lists.linaro.org (Postfix) with ESMTPS id 3510360CE4 for ; Tue, 11 Jul 2017 14:04:03 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [IPv6:2a02:6b8:0:801::ac]) by forward4o.cmail.yandex.net (Yandex) with ESMTP id E9DD221497 for ; Tue, 11 Jul 2017 17:04:01 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 0A5A53EC354D for ; Tue, 11 Jul 2017 17:00:44 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0hL4ajaA; Tue, 11 Jul 2017 17:00:43 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:25 +0300 Message-Id: <1499781629-30670-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 6/10] api: crypto: add crypto packet operation interface 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" From: Dmitry Eremin-Solenikov 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 created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ example/ipsec/odp_ipsec.c | 8 +- example/ipsec/odp_ipsec_misc.h | 4 +- include/odp/api/spec/crypto.h | 176 +++++++++++++++++++-- include/odp/arch/default/api/abi/event.h | 3 +- .../include/odp/api/plat/event_types.h | 3 +- 5 files changed, 176 insertions(+), 18 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 1ed03585..c618cc46 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -724,9 +724,9 @@ pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt, /* Check crypto result */ if (!result->ok) { - if (!is_crypto_compl_status_ok(&result->cipher_status)) + if (!is_crypto_op_status_ok(&result->cipher_status)) return PKT_DROP; - if (!is_crypto_compl_status_ok(&result->auth_status)) + if (!is_crypto_op_status_ok(&result->auth_status)) return PKT_DROP; } ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); @@ -1011,9 +1011,9 @@ pkt_disposition_e do_ipsec_out_finish(odp_packet_t pkt, /* Check crypto result */ if (!result->ok) { - if (!is_crypto_compl_status_ok(&result->cipher_status)) + if (!is_crypto_op_status_ok(&result->cipher_status)) return PKT_DROP; - if (!is_crypto_compl_status_ok(&result->auth_status)) + if (!is_crypto_op_status_ok(&result->auth_status)) return PKT_DROP; } ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h index 45cb022e..20ebe9fc 100644 --- a/example/ipsec/odp_ipsec_misc.h +++ b/example/ipsec/odp_ipsec_misc.h @@ -321,12 +321,12 @@ void ipv4_adjust_len(odph_ipv4hdr_t *ip, int adj) /** * Verify crypto operation completed successfully * - * @param status Pointer to cryto completion structure + * @param status Pointer to crypto op status structure * * @return TRUE if all OK else FALSE */ static inline -odp_bool_t is_crypto_compl_status_ok(odp_crypto_compl_status_t *status) +odp_bool_t is_crypto_op_status_ok(odp_crypto_op_status_t *status) { if (status->alg_err != ODP_CRYPTO_ALG_ERR_NONE) return FALSE; diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index b9d42937..013507f9 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -16,6 +16,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -276,6 +277,9 @@ typedef struct odp_crypto_session_param_t { * data in non-posted mode */ odp_crypto_op_mode_t ODP_DEPRECATE(pref_mode); + /** Operation mode when using packet interface: sync or async */ + odp_crypto_op_mode_t packet_op_mode; + /** Cipher algorithm * * Use odp_crypto_capability() for supported algorithms. @@ -311,16 +315,15 @@ typedef struct odp_crypto_session_param_t { /** Async mode completion event queue * - * When odp_crypto_operation() is asynchronous, the completion queue is - * used to return the completion status of the operation to the - * application. + * The completion queue is used to return odp_crypto_packet_op_enq() + * results to the application. */ odp_queue_t compl_queue; /** Output pool * * When the output packet is not specified during the call to - * odp_crypto_operation(), the output packet will be allocated + * crypto operation, the output packet will be allocated * from this pool. */ odp_pool_t output_pool; @@ -400,6 +403,44 @@ typedef struct odp_crypto_op_param_t { typedef odp_crypto_op_param_t ODP_DEPRECATE(odp_crypto_op_params_t); /** + * Crypto packet API per packet operation parameters + */ +typedef struct odp_crypto_packet_op_param_t { + /** Session handle from creation */ + odp_crypto_session_t session; + + /** Override session IV pointer */ + uint8_t *override_iv_ptr; + + /** Offset from start of packet for hash result + * + * Specifies the offset where the hash result is to be stored. In case + * of decode sessions, input hash values will be read from this offset, + * and overwritten with hash results. If this offset lies within + * specified 'auth_range', implementation will mute this field before + * calculating the hash result. + */ + uint32_t hash_result_offset; + + /** Additional Authenticated Data (AAD) */ + struct { + /** Pointer to ADD */ + uint8_t *ptr; + + /** AAD length in bytes. Use odp_crypto_auth_capability() for + * supported AAD lengths. */ + uint32_t length; + } aad; + + /** Data range to apply cipher */ + odp_packet_data_range_t cipher_range; + + /** Data range to authenticate */ + odp_packet_data_range_t auth_range; + +} odp_crypto_packet_op_param_t; + +/** * Crypto API session creation return code */ typedef enum { @@ -444,14 +485,17 @@ 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; + +/** @deprecated Use ODP_DEPRECATE(odp_crypto_op_status_t) instead */ +typedef odp_crypto_op_status_t ODP_DEPRECATE(odp_crypto_compl_status_t); /** * Crypto API operation result @@ -460,27 +504,51 @@ typedef struct odp_crypto_op_result { /** Request completed successfully */ odp_bool_t ok; - /** User context from request */ - void *ctx; + /** User context from request + * + * @deprecated No need to pass context around sync calls + * */ + void *ODP_DEPRECATE(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; /** + * Crypto packet API operation result + */ +typedef struct odp_crypto_packet_result_t { + /** Request completed successfully */ + odp_bool_t ok; + + /** Cipher status */ + odp_crypto_op_status_t cipher_status; + + /** Authentication status */ + odp_crypto_op_status_t auth_status; + +} odp_crypto_packet_result_t; + +/** * Crypto capabilities */ typedef struct odp_crypto_capability_t { /** Maximum number of crypto sessions */ uint32_t max_sessions; + /** Supported packet operation in SYNC mode */ + odp_support_t packet_sync_mode; + + /** Supported packet operation in ASYNC mode */ + odp_support_t packet_async_mode; + /** Supported cipher algorithms */ odp_crypto_cipher_algos_t ciphers; @@ -713,6 +781,94 @@ uint64_t ODP_DEPRECATE(odp_crypto_compl_to_u64)( void odp_crypto_session_param_init(odp_crypto_session_param_t *param); /** + * Return crypto processed packet that is associated with event + * + * Get packet handle to an crypto processed packet event. Event subtype must be + * ODP_EVENT_PACKET_CRYPTO. Crypto operation results can be examined with + * odp_crypto_packet_result(). + * + * Note: any invalid parameters will cause undefined behavior and may cause + * the application to abort or crash. + * + * @param ev Event handle + * + * @return Packet handle + */ +odp_packet_t odp_crypto_packet_from_event(odp_event_t ev); + +/** + * Convert crypto packet handle to event + * + * The packet handle must be an output of an crypto operation. + * + * @param pkt Packet handle from crypto operation + * + * @return Event handle + */ +odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt); + +/** + * 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 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 + */ +int odp_crypto_packet_result(odp_crypto_packet_result_t *result, + odp_packet_t packet); + +/** + * Crypto packet operation + * + * Performs the SYNC cryptographic operations specified during session creation + * on the packets. Caller should initialize pkt_out either with desired output + * packet handles or with ODP_PACKET_INVALID to make ODP allocate new packets + * from provided pool. All arrays should be of num_pkt size. + * + * @param pkt_in Packets to be processed + * @param[in,out] pkt_out Packet handle array specifyint resulting packets + * @param param Operation parameters array + * @param num_pkt Number of packets to be processed + * + * @return Number of input packets consumed (0 ... num_pkt) + * @retval <0 on failure + */ +int odp_crypto_packet_op(const odp_packet_t pkt_in[], + odp_packet_t pkt_out[], + const odp_crypto_packet_op_param_t param[], + int num_pkt); + +/** + * Crypto packet operation + * + * Performs the ASYNC cryptographic operations specified during session creation + * on the packets. Caller should initialize pkt_out either with desired output + * packet handles or with ODP_PACKET_INVALID to make ODP allocate new packets + * from provided pool. All arrays should be of num_pkt size. Resulting packets + * are returned through events. + * + * @param pkt_in Packets to be processed + * @param pkt_out Packet handle array specifying resulting packets + * @param param Operation parameters array + * @param num_pkt Number of packets to be processed + * + * @return Number of input packets consumed (0 ... num_pkt) + * @retval <0 on failure + */ +int odp_crypto_packet_op_enq(const odp_packet_t pkt_in[], + const odp_packet_t pkt_out[], + const odp_crypto_packet_op_param_t param[], + int num_pkt); + +/** * @} */ diff --git a/include/odp/arch/default/api/abi/event.h b/include/odp/arch/default/api/abi/event.h index 23b16efd..871d2cf9 100644 --- a/include/odp/arch/default/api/abi/event.h +++ b/include/odp/arch/default/api/abi/event.h @@ -37,7 +37,8 @@ typedef enum 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_CRYPTO = 2, + ODP_EVENT_PACKET_IPSEC = 3 } odp_event_subtype_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 1987bc8b..58ce0a8b 100644 --- a/platform/linux-generic/include/odp/api/plat/event_types.h +++ b/platform/linux-generic/include/odp/api/plat/event_types.h @@ -46,7 +46,8 @@ typedef enum 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_CRYPTO = 2, + ODP_EVENT_PACKET_IPSEC = 3 } odp_event_subtype_t; /** From patchwork Tue Jul 11 14:00:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107395 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4942685qge; Tue, 11 Jul 2017 07:23:38 -0700 (PDT) X-Received: by 10.55.19.152 with SMTP id 24mr230969qkt.78.1499783018096; Tue, 11 Jul 2017 07:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499783018; cv=none; d=google.com; s=arc-20160816; b=UZr1CTIWYab8INprIwjWCkgxFQq5AstmGTqu/POJLfBBQqlxbAeSmNPnMDYYacHfBl n7VUBoyQCYbxDv7J1m61i4F8r7qu3QtCH8v61AJ2cHUuvfgUiEIn0+v9GT3jxsBt46Ep uOhGW4ymlcY3KEwpGai3ZQkbH2zuyrCgJ4hiGwFppATLW+RBS4kkE9pyCURkhWWWctud CrCD11gMrSJ4PcXFENx4BIed6lQ+p94gy6o079WUJCcZqPlexBbQbOv3/NUeQ8C/hlgf /TMVn+ez+kYLX96SqCr6mKtliZXt4swsp7WQh5oSTZW1P4Gw9FjLlL3p9dyePv2peLzR bckg== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=zGFHBFN0P2HTMKNJkLh4QDZZL74Ubptq7LCkfW+8DE8=; b=AuoDw50574NKMY68aerOyHziaf87gno1BB1Wdea0EQWOIDsmqqLlZGveuc1NKWA6hR d/I5Io71gQWQO9DstNwh1uIoNsBJH1bDoUYoSoonw8XNJjsQiWui6RWIP+Kl7x9OITOz DL9Rk2cN0W8qv2rxURcRun33+An0dOTJ1OW9hvLepO+0NRFxL+vE8fs9Sec/QZ8TSTH4 cyphd9/m/+MJnAT1eQB+5q/cDsd1ILLzrCM0DoJWM0KjNWjcSWpBtO3hExMjZvPKXOuE lEzKDpPNUcU7DM65EhJRoaAJfvdpEIJzRUNW5LS5DAHPibRmJkSNgVMXhz2DQyfLzfkK dtzw== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u124si62227qkf.129.2017.07.11.07.23.37; Tue, 11 Jul 2017 07:23:38 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id B487B60D86; Tue, 11 Jul 2017 14:23:37 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 92E3D60638; Tue, 11 Jul 2017 14:23:27 +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 C2AC160D7E; Tue, 11 Jul 2017 14:23:22 +0000 (UTC) Received: from forward3h.cmail.yandex.net (forward3h.cmail.yandex.net [87.250.230.18]) by lists.linaro.org (Postfix) with ESMTPS id 3932860638 for ; Tue, 11 Jul 2017 14:22:46 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [IPv6:2a02:6b8:0:801::ac]) by forward3h.cmail.yandex.net (Yandex) with ESMTP id BC9D8210B3 for ; Tue, 11 Jul 2017 17:22:44 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 4C6633EC355C for ; Tue, 11 Jul 2017 17:00:45 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0jLm2inm; Tue, 11 Jul 2017 17:00:45 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:26 +0300 Message-Id: <1499781629-30670-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 7/10] linux-gen: crypto: provide packet API implementation 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" From: Dmitry Eremin-Solenikov Provide implementation for new crypto API using packets as first grade objects. Reimplement odp_crypto_operation using new functions. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ .../linux-generic/include/odp_crypto_internal.h | 3 +- .../linux-generic/include/odp_packet_internal.h | 3 + platform/linux-generic/odp_crypto.c | 329 +++++++++++++++------ 3 files changed, 245 insertions(+), 90 deletions(-) diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index 52b94d07..12d1720b 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -23,7 +23,8 @@ typedef struct odp_crypto_generic_session odp_crypto_generic_session_t; * Algorithm handler function prototype */ typedef -odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param, +odp_crypto_alg_err_t (*crypto_func_t)(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session); /** diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 9f28fc05..a90ec477 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -128,6 +128,9 @@ typedef struct { /* Classifier destination queue */ odp_queue_t dst_queue; + /* Result for crypto packet op */ + odp_crypto_packet_result_t crypto_op_result; + /* Packet data storage */ uint8_t data[0]; } odp_packet_hdr_t; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 075bb02b..792c2eca 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -113,7 +113,8 @@ void free_session(odp_crypto_generic_session_t *session) } static odp_crypto_alg_err_t -null_crypto_routine(odp_crypto_op_param_t *param ODP_UNUSED, +null_crypto_routine(odp_packet_t pkt ODP_UNUSED, + const odp_crypto_packet_op_param_t *param ODP_UNUSED, odp_crypto_generic_session_t *session ODP_UNUSED) { return ODP_CRYPTO_ALG_ERR_NONE; @@ -121,11 +122,11 @@ null_crypto_routine(odp_crypto_op_param_t *param ODP_UNUSED, static void packet_hmac_calculate(HMAC_CTX *ctx, - odp_crypto_op_param_t *param, + odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session, uint8_t *hash) { - odp_packet_t pkt = param->out_pkt; uint32_t offset = param->auth_range.offset; uint32_t len = param->auth_range.length; @@ -152,7 +153,8 @@ void packet_hmac_calculate(HMAC_CTX *ctx, #if OPENSSL_VERSION_NUMBER < 0x10100000L static -void packet_hmac(odp_crypto_op_param_t *param, +void packet_hmac(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session, uint8_t *hash) { @@ -160,12 +162,13 @@ void packet_hmac(odp_crypto_op_param_t *param, /* Hash it */ HMAC_CTX_init(&ctx); - packet_hmac_calculate(&ctx, param, session, hash); + packet_hmac_calculate(&ctx, pkt, param, session, hash); HMAC_CTX_cleanup(&ctx); } #else static -void packet_hmac(odp_crypto_op_param_t *param, +void packet_hmac(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session, uint8_t *hash) { @@ -173,22 +176,23 @@ void packet_hmac(odp_crypto_op_param_t *param, /* Hash it */ ctx = HMAC_CTX_new(); - packet_hmac_calculate(ctx, param, session, hash); + packet_hmac_calculate(ctx, pkt, param, session, hash); HMAC_CTX_free(ctx); } #endif static -odp_crypto_alg_err_t auth_gen(odp_crypto_op_param_t *param, +odp_crypto_alg_err_t auth_gen(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session) { uint8_t hash[EVP_MAX_MD_SIZE]; /* Hash it */ - packet_hmac(param, session, hash); + packet_hmac(pkt, param, session, hash); /* Copy to the output location */ - odp_packet_copy_from_mem(param->out_pkt, + odp_packet_copy_from_mem(pkt, param->hash_result_offset, session->auth.bytes, hash); @@ -197,7 +201,8 @@ odp_crypto_alg_err_t auth_gen(odp_crypto_op_param_t *param, } static -odp_crypto_alg_err_t auth_check(odp_crypto_op_param_t *param, +odp_crypto_alg_err_t auth_check(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session) { uint32_t bytes = session->auth.bytes; @@ -205,14 +210,14 @@ odp_crypto_alg_err_t auth_check(odp_crypto_op_param_t *param, uint8_t hash_out[EVP_MAX_MD_SIZE]; /* Copy current value out and clear it before authentication */ - odp_packet_copy_to_mem(param->out_pkt, param->hash_result_offset, + odp_packet_copy_to_mem(pkt, param->hash_result_offset, bytes, hash_in); - _odp_packet_set_data(param->out_pkt, param->hash_result_offset, + _odp_packet_set_data(pkt, param->hash_result_offset, 0, bytes); /* Hash it */ - packet_hmac(param, session, hash_out); + packet_hmac(pkt, param, session, hash_out); /* Verify match */ if (0 != memcmp(hash_in, hash_out, bytes)) @@ -223,9 +228,10 @@ odp_crypto_alg_err_t auth_check(odp_crypto_op_param_t *param, } static -int internal_encrypt(EVP_CIPHER_CTX *ctx, odp_crypto_op_param_t *param) +int internal_encrypt(EVP_CIPHER_CTX *ctx, + odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param) { - odp_packet_t pkt = param->out_pkt; unsigned in_pos = param->cipher_range.offset; unsigned out_pos = param->cipher_range.offset; unsigned in_len = param->cipher_range.length; @@ -278,9 +284,10 @@ int internal_encrypt(EVP_CIPHER_CTX *ctx, odp_crypto_op_param_t *param) } static -int internal_decrypt(EVP_CIPHER_CTX *ctx, odp_crypto_op_param_t *param) +int internal_decrypt(EVP_CIPHER_CTX *ctx, + odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param) { - odp_packet_t pkt = param->out_pkt; unsigned in_pos = param->cipher_range.offset; unsigned out_pos = param->cipher_range.offset; unsigned in_len = param->cipher_range.length; @@ -333,7 +340,8 @@ int internal_decrypt(EVP_CIPHER_CTX *ctx, odp_crypto_op_param_t *param) } static -odp_crypto_alg_err_t cipher_encrypt(odp_crypto_op_param_t *param, +odp_crypto_alg_err_t cipher_encrypt(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session) { EVP_CIPHER_CTX *ctx; @@ -354,7 +362,7 @@ odp_crypto_alg_err_t cipher_encrypt(odp_crypto_op_param_t *param, EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); EVP_CIPHER_CTX_set_padding(ctx, 0); - ret = internal_encrypt(ctx, param); + ret = internal_encrypt(ctx, pkt, param); EVP_CIPHER_CTX_free(ctx); @@ -363,7 +371,8 @@ odp_crypto_alg_err_t cipher_encrypt(odp_crypto_op_param_t *param, } static -odp_crypto_alg_err_t cipher_decrypt(odp_crypto_op_param_t *param, +odp_crypto_alg_err_t cipher_decrypt(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session) { EVP_CIPHER_CTX *ctx; @@ -384,7 +393,7 @@ odp_crypto_alg_err_t cipher_decrypt(odp_crypto_op_param_t *param, EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); EVP_CIPHER_CTX_set_padding(ctx, 0); - ret = internal_decrypt(ctx, param); + ret = internal_decrypt(ctx, pkt, param); EVP_CIPHER_CTX_free(ctx); @@ -420,7 +429,8 @@ static int process_cipher_param(odp_crypto_generic_session_t *session, } static -odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, +odp_crypto_alg_err_t aes_gcm_encrypt(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session) { EVP_CIPHER_CTX *ctx; @@ -452,11 +462,11 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, EVP_EncryptUpdate(ctx, NULL, &dummy_len, aad_head, aad_len); - ret = internal_encrypt(ctx, param); + ret = internal_encrypt(ctx, pkt, param); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, session->p.auth_digest_len, block); - odp_packet_copy_from_mem(param->out_pkt, param->hash_result_offset, + odp_packet_copy_from_mem(pkt, param->hash_result_offset, session->p.auth_digest_len, block); EVP_CIPHER_CTX_free(ctx); @@ -466,7 +476,8 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, } static -odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, +odp_crypto_alg_err_t aes_gcm_decrypt(odp_packet_t pkt, + const odp_crypto_packet_op_param_t *param, odp_crypto_generic_session_t *session) { EVP_CIPHER_CTX *ctx; @@ -493,7 +504,7 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); EVP_CIPHER_CTX_set_padding(ctx, 0); - odp_packet_copy_to_mem(param->out_pkt, param->hash_result_offset, + odp_packet_copy_to_mem(pkt, param->hash_result_offset, session->p.auth_digest_len, block); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, session->p.auth_digest_len, block); @@ -503,7 +514,7 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, EVP_DecryptUpdate(ctx, NULL, &dummy_len, aad_head, aad_len); - ret = internal_decrypt(ctx, param); + ret = internal_decrypt(ctx, pkt, param); EVP_CIPHER_CTX_free(ctx); @@ -833,87 +844,59 @@ int odp_crypto_session_destroy(odp_crypto_session_t session) return 0; } +/* + * Shim function around packet operation, can be used by other implementations. + */ int odp_crypto_operation(odp_crypto_op_param_t *param, odp_bool_t *posted, odp_crypto_op_result_t *result) { - odp_crypto_alg_err_t rc_cipher = ODP_CRYPTO_ALG_ERR_NONE; - odp_crypto_alg_err_t rc_auth = ODP_CRYPTO_ALG_ERR_NONE; - odp_crypto_generic_session_t *session; + odp_crypto_packet_op_param_t packet_param; + odp_packet_t out_pkt = param->out_pkt; + odp_crypto_packet_result_t packet_result; odp_crypto_op_result_t local_result; - odp_bool_t allocated = false; - - session = (odp_crypto_generic_session_t *)(intptr_t)param->session; + int rc; - /* Resolve output buffer */ - if (ODP_PACKET_INVALID == param->out_pkt && - ODP_POOL_INVALID != session->p.output_pool) { - param->out_pkt = odp_packet_alloc(session->p.output_pool, - odp_packet_len(param->pkt)); - allocated = true; - } + packet_param.session = param->session; + packet_param.override_iv_ptr = param->override_iv_ptr; + packet_param.hash_result_offset = param->hash_result_offset; + packet_param.aad.ptr = param->aad.ptr; + packet_param.aad.length = param->aad.length; + packet_param.cipher_range = param->cipher_range; + packet_param.auth_range = param->auth_range; - if (odp_unlikely(ODP_PACKET_INVALID == param->out_pkt)) { - ODP_DBG("Alloc failed.\n"); - return -1; - } + rc = odp_crypto_packet_op(¶m->pkt, &out_pkt, &packet_param, 1); + if (rc < 0) + return rc; - if (param->pkt != param->out_pkt) { - int ret; + rc = odp_crypto_packet_result(&packet_result, out_pkt); + if (rc < 0) + return rc; - ret = odp_packet_copy_from_pkt(param->out_pkt, - 0, - param->pkt, - 0, - odp_packet_len(param->pkt)); - if (odp_unlikely(ret < 0)) - goto err; + /* Indicate to caller operation was sync */ + *posted = 0; - _odp_packet_copy_md_to_packet(param->pkt, param->out_pkt); - odp_packet_free(param->pkt); - param->pkt = ODP_PACKET_INVALID; - } - - /* Invoke the functions */ - if (session->do_cipher_first) { - rc_cipher = session->cipher.func(param, session); - rc_auth = session->auth.func(param, session); - } else { - rc_auth = session->auth.func(param, session); - rc_cipher = session->cipher.func(param, session); - } + _odp_buffer_event_subtype_set(_odp_packet_to_buffer(out_pkt), + ODP_EVENT_PACKET_BASIC); /* Fill in result */ #if ODP_DEPRECATED_API local_result.ctx = param->ctx; #endif - local_result.pkt = param->out_pkt; - local_result.cipher_status.alg_err = rc_cipher; - local_result.cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE; - local_result.auth_status.alg_err = rc_auth; - local_result.auth_status.hw_err = ODP_CRYPTO_HW_ERR_NONE; - local_result.ok = - (rc_cipher == ODP_CRYPTO_ALG_ERR_NONE) && - (rc_auth == ODP_CRYPTO_ALG_ERR_NONE); + local_result.pkt = out_pkt; + local_result.cipher_status = packet_result.cipher_status; + local_result.auth_status = packet_result.auth_status; + local_result.ok = packet_result.ok; - /* Synchronous, simply return results */ - if (!result) - goto err; - *result = local_result; + /* + * Be bug-to-bug compatible. Return output packet also through params. + */ + param->out_pkt = out_pkt; - /* Indicate to caller operation was sync */ - *posted = 0; + *result = local_result; return 0; - -err: - if (allocated) { - odp_packet_free(param->out_pkt); - param->out_pkt = ODP_PACKET_INVALID; - } - - return -1; } static void ODP_UNUSED openssl_thread_id(CRYPTO_THREADID ODP_UNUSED *id) @@ -1095,3 +1078,171 @@ uint64_t odp_crypto_session_to_u64(odp_crypto_session_t hdl) { return (uint64_t)hdl; } + +odp_packet_t odp_crypto_packet_from_event(odp_event_t ev) +{ + /* This check not mandated by the API specification */ + ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); + ODP_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_CRYPTO); + + return odp_packet_from_event(ev); +} + +odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt) +{ + return odp_packet_to_event(pkt); +} + +static +odp_crypto_packet_result_t *get_op_result_from_packet(odp_packet_t pkt) +{ + odp_packet_hdr_t *hdr = odp_packet_hdr(pkt); + + return &hdr->crypto_op_result; +} + +int odp_crypto_packet_result(odp_crypto_packet_result_t *result, + odp_packet_t packet) +{ + odp_crypto_packet_result_t *op_result; + + ODP_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) == + ODP_EVENT_PACKET_CRYPTO); + + op_result = get_op_result_from_packet(packet); + + memcpy(result, op_result, sizeof(*result)); + + return 0; +} + +static +int odp_crypto_op(odp_packet_t pkt_in, + odp_packet_t *pkt_out, + const odp_crypto_packet_op_param_t *param) +{ + odp_crypto_alg_err_t rc_cipher = ODP_CRYPTO_ALG_ERR_NONE; + odp_crypto_alg_err_t rc_auth = ODP_CRYPTO_ALG_ERR_NONE; + odp_crypto_generic_session_t *session; + odp_crypto_packet_result_t local_result; + odp_bool_t allocated = false; + odp_packet_t out_pkt = *pkt_out; + odp_crypto_packet_result_t *op_result; + + session = (odp_crypto_generic_session_t *)(intptr_t)param->session; + + /* Resolve output buffer */ + if (ODP_PACKET_INVALID == out_pkt && + ODP_POOL_INVALID != session->p.output_pool) { + out_pkt = odp_packet_alloc(session->p.output_pool, + odp_packet_len(pkt_in)); + allocated = true; + } + + if (odp_unlikely(ODP_PACKET_INVALID == out_pkt)) { + ODP_DBG("Alloc failed.\n"); + return -1; + } + + if (pkt_in != out_pkt) { + int ret; + + ret = odp_packet_copy_from_pkt(out_pkt, + 0, + pkt_in, + 0, + odp_packet_len(pkt_in)); + if (odp_unlikely(ret < 0)) + goto err; + + _odp_packet_copy_md_to_packet(pkt_in, out_pkt); + odp_packet_free(pkt_in); + pkt_in = ODP_PACKET_INVALID; + } + + /* Invoke the functions */ + if (session->do_cipher_first) { + rc_cipher = session->cipher.func(out_pkt, param, session); + rc_auth = session->auth.func(out_pkt, param, session); + } else { + rc_auth = session->auth.func(out_pkt, param, session); + rc_cipher = session->cipher.func(out_pkt, param, session); + } + + /* Fill in result */ + local_result.cipher_status.alg_err = rc_cipher; + local_result.cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE; + local_result.auth_status.alg_err = rc_auth; + local_result.auth_status.hw_err = ODP_CRYPTO_HW_ERR_NONE; + local_result.ok = + (rc_cipher == ODP_CRYPTO_ALG_ERR_NONE) && + (rc_auth == ODP_CRYPTO_ALG_ERR_NONE); + + _odp_buffer_event_subtype_set(_odp_packet_to_buffer(out_pkt), + ODP_EVENT_PACKET_CRYPTO); + op_result = get_op_result_from_packet(out_pkt); + *op_result = local_result; + + /* Synchronous, simply return results */ + *pkt_out = out_pkt; + + return 0; + +err: + if (allocated) { + odp_packet_free(out_pkt); + out_pkt = ODP_PACKET_INVALID; + } + + return -1; +} + +int odp_crypto_packet_op(const odp_packet_t pkt_in[], + odp_packet_t pkt_out[], + const odp_crypto_packet_op_param_t param[], + int num_pkt) +{ + int i, rc; + odp_crypto_generic_session_t *session; + + session = (odp_crypto_generic_session_t *)(intptr_t)param->session; + ODP_ASSERT(ODP_CRYPTO_SYNC == session->p.packet_op_mode); + + for (i = 0; i < num_pkt; i++) { + rc = odp_crypto_op(pkt_in[i], &pkt_out[i], ¶m[i]); + if (rc < 0) + break; + } + + return i; +} + +int odp_crypto_packet_op_enq(const odp_packet_t pkt_in[], + const odp_packet_t pkt_out[], + const odp_crypto_packet_op_param_t param[], + int num_pkt) +{ + odp_packet_t pkt; + odp_event_t event; + odp_crypto_generic_session_t *session; + int i, rc; + + session = (odp_crypto_generic_session_t *)(intptr_t)param->session; + ODP_ASSERT(ODP_CRYPTO_ASYNC == session->p.packet_op_mode); + ODP_ASSERT(ODP_QUEUE_INVALID != session->p.compl_queue); + + for (i = 0; i < num_pkt; i++) { + pkt = pkt_out[i]; + rc = odp_crypto_op(pkt_in[i], &pkt, ¶m[i]); + if (rc < 0) + break; + + event = odp_packet_to_event(pkt); + if (odp_queue_enq(session->p.compl_queue, event)) { + odp_event_free(event); + break; + } + } + + return i; +} From patchwork Tue Jul 11 14:00:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107386 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4937590qge; Tue, 11 Jul 2017 07:19:24 -0700 (PDT) X-Received: by 10.237.50.103 with SMTP id y94mr202975qtd.116.1499782764120; Tue, 11 Jul 2017 07:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499782764; cv=none; d=google.com; s=arc-20160816; b=fOJ5rZZFjJfiXrsx6SVaY0BxPo2i+4cU0WXYdeqqYOsTYbVkZYyp5D92gCpL+UpHqa Sjfletng4IMsRez48PqwQw4jwTGU/bGljhgAFDlmW00xHzO8IXL0UP29776AZHQkLSam wDzv1syLeoog87SEH6HYHY0e3apQ9PAQkFt/6CHdiJs4GZMHaVbhUPTfDqGpRkNm5xHx lU5xEzXRvLAuOW2CgJZ9yC2PYkbf2i0Wn/DH2Cl/gYPA8liURXE1B8x578+quiqJneG2 zHzL7lCZzZrSQI4rAhUdFeDdK+rrXCne1WdzxKoSNZc3FHWotiGy8ryMIaPxYKN6Z2TM CvMw== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=85lkoFZV8yUWb0TLpcKjViahV5cDc0KSbIJIFs3cjV0=; b=Hi9N6dXjNtxN2DeF6fElcQdqTnq+uj7Tvvo9ZY3RSknVYMS46teYZDb/oo358dHQWw LuZfO0FD+cdAifMDk+Yd9ASmGA3ps9xSY47fYKJySzHI8vZZqcyYCy4aKuTfXXLfDtOI W8CL5WDnwddJofbe87ralrdAWAP5ZG/5kKV+DYa542n205IB9CRIA8XyNzLoPSLM5jwh oGw3Q5Pg3hldXB4DtPBru57LhhGW/pR2Gq6ua4+KWWP9aQxOwLmBUr254RJjMjliRgu8 HGNU3uyHOEFMr8fvvzkd4MhRSgf2/QwgGxhHccmkZj/Gd/onrtLFnvMRIFGdlg/081dF rc/Q== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m15si54313qtm.325.2017.07.11.07.19.23; Tue, 11 Jul 2017 07:19:24 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id C8D3264486; Tue, 11 Jul 2017 14:19:23 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 7285860D88; Tue, 11 Jul 2017 14:18:02 +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 A560060D88; Tue, 11 Jul 2017 14:17:53 +0000 (UTC) Received: from forward2j.cmail.yandex.net (forward2j.cmail.yandex.net [5.255.227.20]) by lists.linaro.org (Postfix) with ESMTPS id 4BCB860CD1 for ; Tue, 11 Jul 2017 14:10:46 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward2j.cmail.yandex.net (Yandex) with ESMTP id D67FD2114E for ; Tue, 11 Jul 2017 17:10:44 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id B003A3EC359A for ; Tue, 11 Jul 2017 17:00:47 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0lLScWwY; Tue, 11 Jul 2017 17:00:47 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:27 +0300 Message-Id: <1499781629-30670-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 8/10] validation: crypto: tests for Crypto packet API 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" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ test/common_plat/validation/api/crypto/crypto.c | 8 +- .../validation/api/crypto/odp_crypto_test_inp.c | 309 +++++++++++++++++---- .../validation/api/crypto/odp_crypto_test_inp.h | 6 +- 3 files changed, 271 insertions(+), 52 deletions(-) diff --git a/test/common_plat/validation/api/crypto/crypto.c b/test/common_plat/validation/api/crypto/crypto.c index fde95ab7..8a6c20ec 100644 --- a/test/common_plat/validation/api/crypto/crypto.c +++ b/test/common_plat/validation/api/crypto/crypto.c @@ -13,8 +13,12 @@ #define PKT_POOL_LEN (1 * 1024) odp_suiteinfo_t crypto_suites[] = { - {ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, crypto_suite_term, - crypto_suite}, + {ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, + crypto_suite_term, crypto_suite}, + {ODP_CRYPTO_PACKET_SYNC_INP, crypto_suite_packet_sync_init, + crypto_suite_term, crypto_suite}, + {ODP_CRYPTO_PACKET_ASYNC_INP, crypto_suite_packet_async_init, + crypto_suite_term, crypto_suite}, ODP_SUITE_INFO_NULL, }; diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index d42ecb68..d5549493 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -14,6 +14,8 @@ #define MAX_ALG_CAPA 32 struct suite_context_s { + odp_bool_t packet; + odp_crypto_op_mode_t packet_op_mode; odp_pool_t pool; odp_queue_t queue; }; @@ -58,6 +60,217 @@ static const char *cipher_alg_name(odp_cipher_alg_t cipher) } } +static int alg_op(odp_packet_t pkt, + odp_bool_t *ok, + odp_crypto_session_t session, + uint8_t *op_iv_ptr, + odp_packet_data_range_t *cipher_range, + odp_packet_data_range_t *auth_range, + uint8_t *aad, + uint32_t aad_len, + unsigned int plaintext_len) +{ + int data_off = 0, rc; + odp_crypto_op_result_t result; + odp_crypto_op_param_t op_params; + odp_bool_t posted; + odp_event_subtype_t subtype; + + /* Prepare input/output params */ + memset(&op_params, 0, sizeof(op_params)); + op_params.session = session; + op_params.pkt = pkt; + op_params.out_pkt = pkt; + + if (cipher_range) { + op_params.cipher_range = *cipher_range; + data_off = cipher_range->offset; + } else { + op_params.cipher_range.offset = data_off; + op_params.cipher_range.length = plaintext_len; + } + if (auth_range) { + op_params.auth_range = *auth_range; + } else { + op_params.auth_range.offset = data_off; + op_params.auth_range.length = plaintext_len; + } + if (op_iv_ptr) + op_params.override_iv_ptr = op_iv_ptr; + + op_params.aad.ptr = aad; + op_params.aad.length = aad_len; + + op_params.hash_result_offset = plaintext_len; + + rc = odp_crypto_operation(&op_params, &posted, &result); + if (rc < 0) { + CU_FAIL("Failed odp_crypto_operation()"); + return rc; + } + + CU_ASSERT(posted == 0); + CU_ASSERT(result.pkt == pkt); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_type(odp_packet_to_event(result.pkt))); + CU_ASSERT(ODP_EVENT_PACKET_BASIC == + odp_event_subtype(odp_packet_to_event(result.pkt))); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_types(odp_packet_to_event(result.pkt), &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_BASIC == subtype); + + *ok = result.ok; + + return 0; +} + +static int alg_packet_op(odp_packet_t pkt, + odp_bool_t *ok, + odp_crypto_session_t session, + uint8_t *op_iv_ptr, + odp_packet_data_range_t *cipher_range, + odp_packet_data_range_t *auth_range, + uint8_t *aad, + uint32_t aad_len, + unsigned int plaintext_len) +{ + int data_off = 0, rc; + odp_crypto_packet_result_t result; + odp_crypto_packet_op_param_t op_params; + odp_event_subtype_t subtype; + odp_packet_t out_pkt = pkt; + + /* Prepare input/output params */ + memset(&op_params, 0, sizeof(op_params)); + op_params.session = session; + + if (cipher_range) { + op_params.cipher_range = *cipher_range; + data_off = cipher_range->offset; + } else { + op_params.cipher_range.offset = data_off; + op_params.cipher_range.length = plaintext_len; + } + if (auth_range) { + op_params.auth_range = *auth_range; + } else { + op_params.auth_range.offset = data_off; + op_params.auth_range.length = plaintext_len; + } + if (op_iv_ptr) + op_params.override_iv_ptr = op_iv_ptr; + + op_params.aad.ptr = aad; + op_params.aad.length = aad_len; + + op_params.hash_result_offset = plaintext_len; + + rc = odp_crypto_packet_op(&pkt, &out_pkt, &op_params, 1); + if (rc < 0) { + CU_FAIL("Failed odp_crypto_packet_op()"); + return rc; + } + + CU_ASSERT(out_pkt == pkt); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_type(odp_packet_to_event(pkt))); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == + odp_event_subtype(odp_packet_to_event(pkt))); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_types(odp_packet_to_event(pkt), &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype); + + rc = odp_crypto_packet_result(&result, pkt); + if (rc < 0) { + CU_FAIL("Failed odp_crypto_packet_result()"); + return rc; + } + + *ok = result.ok; + + return 0; +} + +static int alg_packet_op_enq(odp_packet_t pkt, + odp_bool_t *ok, + odp_crypto_session_t session, + uint8_t *op_iv_ptr, + odp_packet_data_range_t *cipher_range, + odp_packet_data_range_t *auth_range, + uint8_t *aad, + uint32_t aad_len, + unsigned int plaintext_len) +{ + int data_off = 0, rc; + odp_event_t event; + odp_crypto_packet_result_t result; + odp_crypto_packet_op_param_t op_params; + odp_event_subtype_t subtype; + odp_packet_t out_pkt = pkt; + + /* Prepare input/output params */ + memset(&op_params, 0, sizeof(op_params)); + op_params.session = session; + + if (cipher_range) { + op_params.cipher_range = *cipher_range; + data_off = cipher_range->offset; + } else { + op_params.cipher_range.offset = data_off; + op_params.cipher_range.length = plaintext_len; + } + if (auth_range) { + op_params.auth_range = *auth_range; + } else { + op_params.auth_range.offset = data_off; + op_params.auth_range.length = plaintext_len; + } + if (op_iv_ptr) + op_params.override_iv_ptr = op_iv_ptr; + + op_params.aad.ptr = aad; + op_params.aad.length = aad_len; + + op_params.hash_result_offset = plaintext_len; + + rc = odp_crypto_packet_op_enq(&pkt, &pkt, &op_params, 1); + if (rc < 0) { + CU_FAIL("Failed odp_crypto_op_enq()"); + return rc; + } + + /* Poll completion queue for results */ + do { + event = odp_queue_deq(suite_context.queue); + } while (event == ODP_EVENT_INVALID); + + CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(event)); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == odp_event_subtype(event)); + CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype); + + pkt = odp_crypto_packet_from_event(event); + + CU_ASSERT(out_pkt == pkt); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_type(odp_packet_to_event(pkt))); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == + odp_event_subtype(odp_packet_to_event(pkt))); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_types(odp_packet_to_event(pkt), &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype); + + rc = odp_crypto_packet_result(&result, pkt); + if (rc < 0) { + CU_FAIL("Failed odp_crypto_packet_result()"); + return rc; + } + + *ok = result.ok; + + return 0; +} + /* Basic algorithm run function for async inplace mode. * Creates a session from input parameters and runs one operation * on input_vec. Checks the output of the crypto operation against @@ -90,17 +303,13 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_capability_t capa; int rc; odp_crypto_ses_create_err_t status; - odp_bool_t posted; - odp_crypto_op_result_t result; + odp_bool_t ok; odp_crypto_session_param_t ses_params; - odp_crypto_op_param_t op_params; uint8_t *data_addr; - int data_off; odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; int num, i; int found; - odp_event_subtype_t subtype; rc = odp_crypto_capability(&capa); CU_ASSERT(!rc); @@ -193,6 +402,7 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_session_param_init(&ses_params); ses_params.op = op; ses_params.auth_cipher_text = false; + ses_params.packet_op_mode = suite_context.packet_op_mode; ses_params.cipher_alg = cipher_alg; ses_params.auth_alg = auth_alg; ses_params.compl_queue = suite_context.queue; @@ -214,67 +424,40 @@ static void alg_test(odp_crypto_op_t op, CU_ASSERT(pkt != ODP_PACKET_INVALID); data_addr = odp_packet_data(pkt); memcpy(data_addr, plaintext, plaintext_len); - data_off = 0; - - /* Prepare input/output params */ - memset(&op_params, 0, sizeof(op_params)); - op_params.session = session; - op_params.pkt = pkt; - op_params.out_pkt = pkt; - - if (cipher_range) { - op_params.cipher_range = *cipher_range; - data_off = cipher_range->offset; - } else { - op_params.cipher_range.offset = data_off; - op_params.cipher_range.length = plaintext_len; - } - if (auth_range) { - op_params.auth_range = *auth_range; - } else { - op_params.auth_range.offset = data_off; - op_params.auth_range.length = plaintext_len; - } - if (op_iv_ptr) - op_params.override_iv_ptr = op_iv_ptr; - - op_params.aad.ptr = aad; - op_params.aad.length = aad_len; - - op_params.hash_result_offset = plaintext_len; if (0 != digest_len) { - memcpy(data_addr + op_params.hash_result_offset, + memcpy(data_addr + plaintext_len, digest, digest_len); } - rc = odp_crypto_operation(&op_params, &posted, &result); + if (!suite_context.packet) + rc = alg_op(pkt, &ok, session, op_iv_ptr, + cipher_range, auth_range, aad, aad_len, + plaintext_len); + else if (ODP_CRYPTO_ASYNC == suite_context.packet_op_mode) + rc = alg_packet_op_enq(pkt, &ok, session, op_iv_ptr, + cipher_range, auth_range, aad, aad_len, + plaintext_len); + else + rc = alg_packet_op(pkt, &ok, session, op_iv_ptr, + cipher_range, auth_range, aad, aad_len, + plaintext_len); if (rc < 0) { - CU_FAIL("Failed odp_crypto_operation()"); goto cleanup; } - CU_ASSERT(posted == 0); - CU_ASSERT(result.pkt == pkt); - CU_ASSERT(ODP_EVENT_PACKET == - odp_event_type(odp_packet_to_event(result.pkt))); - CU_ASSERT(ODP_EVENT_PACKET_BASIC == - odp_event_subtype(odp_packet_to_event(result.pkt))); - CU_ASSERT(ODP_EVENT_PACKET == - odp_event_types(odp_packet_to_event(result.pkt), &subtype)); - CU_ASSERT(ODP_EVENT_PACKET_BASIC == subtype); - if (should_fail) { - CU_ASSERT(!result.ok); + CU_ASSERT(!ok); goto cleanup; } - CU_ASSERT(result.ok); + CU_ASSERT(ok); + data_addr = odp_packet_data(pkt); if (cipher_alg != ODP_CIPHER_ALG_NULL) CU_ASSERT(!memcmp(data_addr, ciphertext, ciphertext_len)); if (op == ODP_CRYPTO_OP_ENCODE && auth_alg != ODP_AUTH_ALG_NULL) - CU_ASSERT(!memcmp(data_addr + op_params.hash_result_offset, + CU_ASSERT(!memcmp(data_addr + plaintext_len, digest, digest_len)); cleanup: rc = odp_crypto_session_destroy(session); @@ -1498,6 +1681,34 @@ int crypto_suite_sync_init(void) return 0; } +int crypto_suite_packet_sync_init(void) +{ + suite_context.packet = true; + suite_context.packet_op_mode = ODP_CRYPTO_SYNC; + + suite_context.pool = odp_pool_lookup("packet_pool"); + if (suite_context.pool == ODP_POOL_INVALID) + return -1; + + suite_context.queue = ODP_QUEUE_INVALID; + return 0; +} + +int crypto_suite_packet_async_init(void) +{ + suite_context.packet = true; + suite_context.packet_op_mode = ODP_CRYPTO_ASYNC; + + suite_context.pool = odp_pool_lookup("packet_pool"); + if (suite_context.pool == ODP_POOL_INVALID) + return -1; + + suite_context.queue = odp_queue_lookup("crypto-out"); + if (suite_context.queue == ODP_QUEUE_INVALID) + return -1; + return 0; +} + odp_testinfo_t crypto_suite[] = { ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_null, check_alg_null), diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h index 86ecce8e..2bc77a94 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.h @@ -9,12 +9,16 @@ #include /* Suite names */ -#define ODP_CRYPTO_SYNC_INP "odp_crypto_sync_inp" +#define ODP_CRYPTO_SYNC_INP "odp_crypto_sync_inp" +#define ODP_CRYPTO_PACKET_SYNC_INP "odp_crypto_packet_sync_inp" +#define ODP_CRYPTO_PACKET_ASYNC_INP "odp_crypto_packet_async_inp" /* Suite test array */ extern odp_testinfo_t crypto_suite[]; int crypto_suite_sync_init(void); +int crypto_suite_packet_sync_init(void); +int crypto_suite_packet_async_init(void); int crypto_suite_term(void); #endif From patchwork Tue Jul 11 14:00:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107374 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4918348qge; Tue, 11 Jul 2017 07:04:01 -0700 (PDT) X-Received: by 10.55.5.135 with SMTP id 129mr82036qkf.184.1499781841501; Tue, 11 Jul 2017 07:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499781841; cv=none; d=google.com; s=arc-20160816; b=ZSrGSUYESD2N7YDyRg+6btpAa7WuN2xY3QcKZLd8DwpzKMOz0VZTmDni3DQjfn480G nCGT0tQUR91JrBV/jPSNwgLvDLvVEori8O/MiMOf1gHAn/BnMQkpETbYroowxkleKZEi TBgEAt+d8tChb1y2k9OA+7+lS4UU9oKMZussZ7THpzL8gUzMM3FvmXkdncW76bBkO4aZ QUfZuC/VfYi7wFF2YX2wGgqrTkuaQ6H1s82Pz1H0ZEuzhF4pP+eE/vsHi3aTySZvtxaQ cbPrwo1x52Owbt66rMreYYdIX9Lt50/ueGkE7VQaHL/yYgKTgL+twjXMuMRgxeb+wuWw Gc/Q== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=x+xLgvDk+ibqGlW6cNKQeCUZpTG46KFHrTaXOBxte0c=; b=W5SUq2N0UH2K/XZrDx+HByw9ef6sDLIBPFURTsbrHQMTLSAEVQkdPqVZ2GgDLBnpvS sHDoXSdgS1ZMdHG0aFm4Sp1y/Cdz2TiuSBi1+Zg/gz5qZ+v3unvFfGpx6jM7rQQU8RS0 IyO5CY5gl4SlvCuNU0eHvPOHfN7Y7rxFILZSKaiaM2vDjN+zA7Vf351AgSNk48s+xKuz IGHTDGEPCp36cWzHajDOntJ2SeqUFFyTAHsstfblNvztZLGCehIek6Ijhi61wk6po8Cj L5NoAKRxqTuK1oLfSGXiblGzMteZNNQnhFIldFbzAH2n0S36ClPBzSYVIMK6flgNniPb pRbw== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u65si18879qkh.220.2017.07.11.07.04.01; Tue, 11 Jul 2017 07:04:01 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 2E3C960D6F; Tue, 11 Jul 2017 14:04:01 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 F396660CE4; Tue, 11 Jul 2017 14:03:48 +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 75C9A60D74; Tue, 11 Jul 2017 14:03:41 +0000 (UTC) Received: from forward1o.cmail.yandex.net (forward1o.cmail.yandex.net [37.9.109.84]) by lists.linaro.org (Postfix) with ESMTPS id 42C2160A49 for ; Tue, 11 Jul 2017 14:02:53 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward1o.cmail.yandex.net (Yandex) with ESMTP id D1E292148A for ; Tue, 11 Jul 2017 17:02:51 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id C0A323EC35A5 for ; Tue, 11 Jul 2017 17:00:49 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0mLmafMR; Tue, 11 Jul 2017 17:00:48 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:28 +0300 Message-Id: <1499781629-30670-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 9/10] test: rewrite odp_crypto using Crypto packet API 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" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ test/common_plat/performance/odp_crypto.c | 169 ++++++++++++++++++------------ 1 file changed, 104 insertions(+), 65 deletions(-) diff --git a/test/common_plat/performance/odp_crypto.c b/test/common_plat/performance/odp_crypto.c index bc29a888..a129ec98 100644 --- a/test/common_plat/performance/odp_crypto.c +++ b/test/common_plat/performance/odp_crypto.c @@ -443,9 +443,10 @@ create_session_from_config(odp_crypto_session_t *session, return -1; } params.compl_queue = out_queue; - + params.packet_op_mode = ODP_CRYPTO_ASYNC; } else { params.compl_queue = ODP_QUEUE_INVALID; + params.packet_op_mode = ODP_CRYPTO_SYNC; } if (odp_crypto_session_create(¶ms, session, &ses_create_rc)) { @@ -456,6 +457,24 @@ create_session_from_config(odp_crypto_session_t *session, return 0; } +static odp_packet_t +make_packet(odp_pool_t pkt_pool, unsigned int payload_length) +{ + odp_packet_t pkt; + + pkt = odp_packet_alloc(pkt_pool, payload_length); + if (pkt == ODP_PACKET_INVALID) { + app_err("failed to allocate buffer\n"); + return pkt; + } + + void *mem = odp_packet_data(pkt); + + memset(mem, 1, payload_length); + + return pkt; +} + /** * Run measurement iterations for given config and payload size. * Result of run returned in 'result' out parameter. @@ -467,15 +486,13 @@ run_measure_one(crypto_args_t *cargs, unsigned int payload_length, crypto_run_result_t *result) { - odp_crypto_op_param_t params; + odp_crypto_packet_op_param_t params; odp_pool_t pkt_pool; odp_queue_t out_queue; - odp_packet_t pkt; + odp_packet_t pkt = ODP_PACKET_INVALID; int rc = 0; - odp_bool_t posted = 0; - pkt_pool = odp_pool_lookup("packet_pool"); if (pkt_pool == ODP_POOL_INVALID) { app_err("pkt_pool not found\n"); @@ -490,16 +507,12 @@ run_measure_one(crypto_args_t *cargs, } } - pkt = odp_packet_alloc(pkt_pool, payload_length); - if (pkt == ODP_PACKET_INVALID) { - app_err("failed to allocate buffer\n"); - return -1; + if (cargs->reuse_packet) { + pkt = make_packet(pkt_pool, payload_length); + if (ODP_PACKET_INVALID == pkt) + return -1; } - void *mem = odp_packet_data(pkt); - - memset(mem, 1, payload_length); - time_record_t start, end; int packets_sent = 0; int packets_received = 0; @@ -515,77 +528,102 @@ run_measure_one(crypto_args_t *cargs, params.auth_range.length = payload_length; params.hash_result_offset = payload_length; - if (cargs->reuse_packet) { - params.pkt = pkt; - params.out_pkt = cargs->in_place ? pkt : - ODP_PACKET_INVALID; - } - fill_time_record(&start); while ((packets_sent < cargs->iteration_count) || (packets_received < cargs->iteration_count)) { void *mem; - odp_crypto_op_result_t result; if ((packets_sent < cargs->iteration_count) && (packets_sent - packets_received < cargs->in_flight)) { + odp_packet_t out_pkt; + if (!cargs->reuse_packet) { - /* - * For in place test we use just one - * statically allocated buffer. - * For now in place test we have to - * allocate and initialize packet - * every time. - * Note we leaked one packet here. - */ - odp_packet_t newpkt; - - newpkt = odp_packet_alloc(pkt_pool, - payload_length); - if (newpkt == ODP_PACKET_INVALID) { - app_err("failed to allocate buffer\n"); + pkt = make_packet(pkt_pool, payload_length); + if (ODP_PACKET_INVALID == pkt) return -1; - } - mem = odp_packet_data(newpkt); - memset(mem, 1, payload_length); - params.pkt = newpkt; - params.out_pkt = cargs->in_place ? newpkt : - ODP_PACKET_INVALID; } + out_pkt = cargs->in_place ? pkt : ODP_PACKET_INVALID; + if (cargs->debug_packets) { - mem = odp_packet_data(params.pkt); + mem = odp_packet_data(pkt); print_mem("Packet before encryption:", mem, payload_length); } - rc = odp_crypto_operation(¶ms, &posted, - &result); - if (rc) - app_err("failed odp_crypto_operation: rc = %d\n", - rc); - else - packets_sent++; + if (cargs->schedule || cargs->poll) { + rc = odp_crypto_packet_op_enq(&pkt, &out_pkt, + ¶ms, 1); + if (rc <= 0) { + app_err("failed odp_crypto_packet_op_enq: rc = %d\n", + rc); + break; + } + packets_sent += rc; + } else { + rc = odp_crypto_packet_op(&pkt, &out_pkt, + ¶ms, 1); + if (rc <= 0) { + app_err("failed odp_crypto_packet_op: rc = %d\n", + rc); + break; + } + packets_sent += rc; + packets_received++; + if (cargs->debug_packets) { + mem = odp_packet_data(out_pkt); + print_mem("Immediately encrypted " + "packet", + mem, + payload_length + + config->session. + auth_digest_len); + } + if (!cargs->in_place) { + if (cargs->reuse_packet) + pkt = out_pkt; + else + odp_packet_free(out_pkt); + } + } } - if (1) { - packets_received++; - if (cargs->debug_packets) { - mem = odp_packet_data(params.out_pkt); - print_mem("Immediately encrypted packet", mem, - payload_length + - config->session.auth_digest_len); - } - if (!cargs->in_place) { - if (cargs->reuse_packet) { - params.pkt = params.out_pkt; - params.out_pkt = ODP_PACKET_INVALID; - } else { - odp_packet_free(params.out_pkt); + if (out_queue != ODP_QUEUE_INVALID) { + odp_event_t ev; + odp_crypto_packet_result_t result; + odp_packet_t out_pkt; + + if (cargs->schedule) + ev = odp_schedule(NULL, + ODP_SCHED_NO_WAIT); + else + ev = odp_queue_deq(out_queue); + + while (ev != ODP_EVENT_INVALID) { + out_pkt = odp_crypto_packet_from_event(ev); + odp_crypto_packet_result(&result, out_pkt); + + if (cargs->debug_packets) { + mem = odp_packet_data(out_pkt); + print_mem("Receieved encrypted packet", + mem, + payload_length + + config-> + session.auth_digest_len); } - } + if (cargs->reuse_packet) + pkt = out_pkt; + else + odp_packet_free(out_pkt); + packets_received++; + if (cargs->schedule) + ev = odp_schedule(NULL, + ODP_SCHED_NO_WAIT); + else + ev = odp_queue_deq(out_queue); + }; } } @@ -607,9 +645,10 @@ run_measure_one(crypto_args_t *cargs, cargs->iteration_count; } - odp_packet_free(pkt); + if (ODP_PACKET_INVALID != pkt) + odp_packet_free(pkt); - return rc; + return rc < 0 ? rc : 0; } /** From patchwork Tue Jul 11 14:00:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107376 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4921071qge; Tue, 11 Jul 2017 07:05:54 -0700 (PDT) X-Received: by 10.200.58.65 with SMTP id w59mr106243qte.136.1499781954792; Tue, 11 Jul 2017 07:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499781954; cv=none; d=google.com; s=arc-20160816; b=XaYzUJEdhtvXcp7zd+cm+11xh41fQWZnBvGEW/PoO7V/gHfvujz8jFOVP3qGWsMjmW kGrN6EanPTIEdCzOl59X8g7wpbInvRBLjZMd4Rxoce8RoH/ymDwbUHXuRp5nwNwhLkKs t9MGcdyMzcPz/NUMt2oY+SQGMMznyHFwp9WQ7t/oLQlAp6CShzn0VleNkOkrd9444qsL 0QyuX7VAUTv2p0zP8WP7pTstq/hfIxVK3n8xl9Zr8IcPi5oKr0Mit/862AJ8dXUUzLBv LotFXTNcsu7Q9Pxx04IRRj3nnSxG+mjB/Qzt6pGi0vyXODgwt6kwsGl8C7/9i1Ww3zJH 9BBA== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=IkZJygbjwxyiw2yLmrPzqAPGA7/HpDfkjoh51OzoRyI=; b=YGR2XKrH9sD2ZrE7+1rfDVg7S+3qbOGuLcrFb7oYAdfKZhzozzYWwLY5//GDjc3Av6 MbVJ4TjOoo6oUowklxaB95NZ9x3a1m0a31H8tWBCmdp0jQbLUqcpbNKWGb+qvPJsr0t5 G/GxVo0KS0Gm7l5bciXrqlUWBuVuJM4ImeWeumtqwsfnQcdR8zX09iqFlHMGHeM32Vla 4hpXRFtJsd88R5g3aeAbp7KWkIsKDS0XIXDVl7t9sTvwvAGBR/1YrrNV2Jw9LaYD4SdM H07SvNU+beHPeI1qQxY7qoxxlY2sLXmK1nqNN3DhqwP6QtXDkrlVL5uEipI2TRpMY/Kd T56A== 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a7si33521qtb.208.2017.07.11.07.05.54; Tue, 11 Jul 2017 07:05:54 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 22BFB60CD1; Tue, 11 Jul 2017 14:05:54 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 0CC4160D69; Tue, 11 Jul 2017 14:04:46 +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 3932160CD1; Tue, 11 Jul 2017 14:04:40 +0000 (UTC) Received: from forward1j.cmail.yandex.net (forward1j.cmail.yandex.net [5.255.227.19]) by lists.linaro.org (Postfix) with ESMTPS id E4C1560A49 for ; Tue, 11 Jul 2017 14:03:52 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward1j.cmail.yandex.net (Yandex) with ESMTP id 9963021199 for ; Tue, 11 Jul 2017 17:03:51 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 0EA573EC35B7 for ; Tue, 11 Jul 2017 17:00:50 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0oLmJCbu; Tue, 11 Jul 2017 17:00:50 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:29 +0300 Message-Id: <1499781629-30670-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 10/10] example: ipsec: rewrite using Crypto packet API 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" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ example/ipsec/odp_ipsec.c | 118 ++++++++++++++++++++++++---------------- example/ipsec/odp_ipsec_cache.c | 17 +++++- example/ipsec/odp_ipsec_cache.h | 7 ++- example/ipsec/odp_ipsec_misc.h | 2 +- 4 files changed, 91 insertions(+), 53 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index c618cc46..5df8f154 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -144,7 +144,7 @@ typedef struct { uint32_t dst_ip; /**< SA dest IP address */ /* Output only */ - odp_crypto_op_param_t params; /**< Parameters for crypto call */ + odp_crypto_packet_op_param_t params; /**< Parameters for crypto call */ uint32_t *ah_seq; /**< AH sequence number location */ uint32_t *esp_seq; /**< ESP sequence number location */ uint16_t *tun_hdr_id; /**< Tunnel header ID > */ @@ -393,7 +393,9 @@ void ipsec_init_post(crypto_api_mode_e api_mode) auth_sa, tun, api_mode, - entry->input)) { + entry->input, + completionq, + out_pool)) { EXAMPLE_ERR("Error: IPSec cache entry failed.\n" ); exit(EXIT_FAILURE); @@ -627,19 +629,18 @@ pkt_disposition_e do_route_fwd_db(odp_packet_t pkt, pkt_ctx_t *ctx) * @return PKT_CONTINUE if done else PKT_POSTED */ static -pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt, +pkt_disposition_e do_ipsec_in_classify(odp_packet_t *pkt, pkt_ctx_t *ctx, - odp_bool_t *skip, - odp_crypto_op_result_t *result) + odp_bool_t *skip) { - uint8_t *buf = odp_packet_data(pkt); - odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); + uint8_t *buf = odp_packet_data(*pkt); + odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(*pkt, NULL); int hdr_len; odph_ahhdr_t *ah = NULL; odph_esphdr_t *esp = NULL; ipsec_cache_entry_t *entry; - odp_crypto_op_param_t params; - odp_bool_t posted = 0; + odp_crypto_packet_op_param_t params; + odp_packet_t out_pkt; /* Default to skip IPsec */ *skip = TRUE; @@ -661,8 +662,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt, /* Initialize parameters block */ memset(¶ms, 0, sizeof(params)); params.session = entry->state.session; - params.pkt = pkt; - params.out_pkt = entry->in_place ? pkt : ODP_PACKET_INVALID; + out_pkt = entry->in_place ? *pkt : ODP_PACKET_INVALID; /*Save everything to context */ ctx->ipsec.ip_tos = ip->tos; @@ -697,12 +697,17 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt, /* Issue crypto request */ *skip = FALSE; ctx->state = PKT_STATE_IPSEC_IN_FINISH; - if (odp_crypto_operation(¶ms, - &posted, - result)) { - abort(); + if (entry->async) { + if (odp_crypto_packet_op_enq(pkt, &out_pkt, ¶ms, 1)) + abort(); + return PKT_POSTED; } - return (posted) ? PKT_POSTED : PKT_CONTINUE; + + if (odp_crypto_packet_op(pkt, &out_pkt, ¶ms, 1)) + abort(); + *pkt = out_pkt; + + return PKT_CONTINUE; } /** @@ -715,18 +720,20 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt, */ static pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt, - pkt_ctx_t *ctx, - odp_crypto_op_result_t *result) + pkt_ctx_t *ctx) { odph_ipv4hdr_t *ip; + odp_crypto_packet_result_t result; int hdr_len = ctx->ipsec.hdr_len; int trl_len = 0; + odp_crypto_packet_result(&result, pkt); + /* Check crypto result */ - if (!result->ok) { - if (!is_crypto_op_status_ok(&result->cipher_status)) + if (!result.ok) { + if (!is_crypto_op_status_ok(&result.cipher_status)) return PKT_DROP; - if (!is_crypto_op_status_ok(&result->auth_status)) + if (!is_crypto_op_status_ok(&result.auth_status)) return PKT_DROP; } ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); @@ -816,7 +823,7 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt, uint16_t ip_data_len = ipv4_data_len(ip); uint8_t *ip_data = ipv4_data_p(ip); ipsec_cache_entry_t *entry; - odp_crypto_op_param_t params; + odp_crypto_packet_op_param_t params; int hdr_len = 0; int trl_len = 0; odph_ahhdr_t *ah = NULL; @@ -840,8 +847,6 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt, /* Initialize parameters block */ memset(¶ms, 0, sizeof(params)); params.session = entry->state.session; - params.pkt = pkt; - params.out_pkt = entry->in_place ? pkt : ODP_PACKET_INVALID; if (entry->mode == IPSEC_SA_MODE_TUNNEL) { hdr_len += sizeof(odph_ipv4hdr_t); @@ -949,12 +954,19 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt, * @return PKT_CONTINUE if done else PKT_POSTED */ static -pkt_disposition_e do_ipsec_out_seq(odp_packet_t pkt, - pkt_ctx_t *ctx, - odp_crypto_op_result_t *result) +pkt_disposition_e do_ipsec_out_seq(odp_packet_t *pkt, + pkt_ctx_t *ctx) { - uint8_t *buf = odp_packet_data(pkt); - odp_bool_t posted = 0; + uint8_t *buf = odp_packet_data(*pkt); + odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(*pkt, NULL); + odp_packet_t out_pkt; + ipsec_cache_entry_t *entry; + + entry = find_ipsec_cache_entry_out(odp_be_to_cpu_32(ip->src_addr), + odp_be_to_cpu_32(ip->dst_addr), + ip->proto); + if (!entry) + return PKT_DROP; /* We were dispatched from atomic queue, assign sequence numbers */ if (ctx->ipsec.ah_offset) { @@ -985,13 +997,22 @@ pkt_disposition_e do_ipsec_out_seq(odp_packet_t pkt, } } + out_pkt = entry->in_place ? *pkt : ODP_PACKET_INVALID; + /* Issue crypto request */ - if (odp_crypto_operation(&ctx->ipsec.params, - &posted, - result)) { - abort(); + if (entry->async) { + if (odp_crypto_packet_op_enq(pkt, &out_pkt, + &ctx->ipsec.params, 1)) + abort(); + return PKT_POSTED; } - return (posted) ? PKT_POSTED : PKT_CONTINUE; + + if (odp_crypto_packet_op(pkt, &out_pkt, + &ctx->ipsec.params, 1)) + abort(); + *pkt = out_pkt; + + return PKT_CONTINUE; } /** @@ -1004,16 +1025,18 @@ pkt_disposition_e do_ipsec_out_seq(odp_packet_t pkt, */ static pkt_disposition_e do_ipsec_out_finish(odp_packet_t pkt, - pkt_ctx_t *ctx, - odp_crypto_op_result_t *result) + pkt_ctx_t *ctx) { odph_ipv4hdr_t *ip; + odp_crypto_packet_result_t result; + + odp_crypto_packet_result(&result, pkt); /* Check crypto result */ - if (!result->ok) { - if (!is_crypto_op_status_ok(&result->cipher_status)) + if (!result.ok) { + if (!is_crypto_op_status_ok(&result.cipher_status)) return PKT_DROP; - if (!is_crypto_op_status_ok(&result->auth_status)) + if (!is_crypto_op_status_ok(&result.auth_status)) return PKT_DROP; } ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); @@ -1063,15 +1086,15 @@ int pktio_thread(void *arg EXAMPLE_UNUSED) pkt_disposition_e rc; pkt_ctx_t *ctx; odp_queue_t dispatchq; - odp_crypto_op_result_t result; + odp_event_subtype_t subtype; /* Use schedule to get event from any input queue */ ev = schedule(&dispatchq); /* Determine new work versus completion or sequence number */ - if (ODP_EVENT_PACKET == odp_event_type(ev)) { + if (ODP_EVENT_PACKET == odp_event_types(ev, &subtype)) { pkt = odp_packet_from_event(ev); - if (seqnumq == dispatchq) { + if (seqnumq == dispatchq || completionq == dispatchq) { ctx = get_pkt_ctx_from_pkt(pkt); } else { ctx = alloc_pkt_ctx(pkt); @@ -1110,15 +1133,14 @@ int pktio_thread(void *arg EXAMPLE_UNUSED) case PKT_STATE_IPSEC_IN_CLASSIFY: ctx->state = PKT_STATE_ROUTE_LOOKUP; - rc = do_ipsec_in_classify(pkt, + rc = do_ipsec_in_classify(&pkt, ctx, - &skip, - &result); + &skip); break; case PKT_STATE_IPSEC_IN_FINISH: - rc = do_ipsec_in_finish(pkt, ctx, &result); + rc = do_ipsec_in_finish(pkt, ctx); ctx->state = PKT_STATE_ROUTE_LOOKUP; break; @@ -1145,12 +1167,12 @@ int pktio_thread(void *arg EXAMPLE_UNUSED) case PKT_STATE_IPSEC_OUT_SEQ: ctx->state = PKT_STATE_IPSEC_OUT_FINISH; - rc = do_ipsec_out_seq(pkt, ctx, &result); + rc = do_ipsec_out_seq(&pkt, ctx); break; case PKT_STATE_IPSEC_OUT_FINISH: - rc = do_ipsec_out_finish(pkt, ctx, &result); + rc = do_ipsec_out_finish(pkt, ctx); ctx->state = PKT_STATE_TRANSMIT; break; diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c index e4150336..18a98a29 100644 --- a/example/ipsec/odp_ipsec_cache.c +++ b/example/ipsec/odp_ipsec_cache.c @@ -40,7 +40,9 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, sa_db_entry_t *auth_sa, tun_db_entry_t *tun, crypto_api_mode_e api_mode, - odp_bool_t in) + odp_bool_t in, + odp_queue_t completionq, + odp_pool_t out_pool) { odp_crypto_session_param_t params; ipsec_cache_entry_t *entry; @@ -63,8 +65,17 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, /* Setup parameters and call crypto library to create session */ params.op = (in) ? ODP_CRYPTO_OP_DECODE : ODP_CRYPTO_OP_ENCODE; params.auth_cipher_text = TRUE; - params.compl_queue = ODP_QUEUE_INVALID; - params.output_pool = ODP_POOL_INVALID; + if (CRYPTO_API_SYNC == api_mode) { + params.packet_op_mode = ODP_CRYPTO_SYNC; + params.compl_queue = ODP_QUEUE_INVALID; + params.output_pool = ODP_POOL_INVALID; + entry->async = FALSE; + } else { + params.packet_op_mode = ODP_CRYPTO_ASYNC; + params.compl_queue = completionq; + params.output_pool = out_pool; + entry->async = TRUE; + } if (CRYPTO_API_ASYNC_NEW_BUFFER == api_mode) entry->in_place = FALSE; diff --git a/example/ipsec/odp_ipsec_cache.h b/example/ipsec/odp_ipsec_cache.h index ce37ccce..45010249 100644 --- a/example/ipsec/odp_ipsec_cache.h +++ b/example/ipsec/odp_ipsec_cache.h @@ -32,6 +32,7 @@ typedef enum { typedef struct ipsec_cache_entry_s { struct ipsec_cache_entry_s *next; /**< Next entry on list */ odp_bool_t in_place; /**< Crypto API mode */ + odp_bool_t async; /**< ASYNC or SYNC mode */ uint32_t src_ip; /**< Source v4 address */ uint32_t dst_ip; /**< Destination v4 address */ sa_mode_t mode; /**< SA mode - transport/tun */ @@ -85,6 +86,8 @@ void init_ipsec_cache(void); * @param tun Tunnel DB entry pointer * @param api_mode Crypto API mode for testing * @param in Direction (input versus output) + * @param completionq Completion queue + * @param out_pool Output buffer pool * * @return 0 if successful else -1 */ @@ -92,7 +95,9 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, sa_db_entry_t *auth_sa, tun_db_entry_t *tun, crypto_api_mode_e api_mode, - odp_bool_t in); + odp_bool_t in, + odp_queue_t completionq, + odp_pool_t out_pool); /** * Find a matching IPsec cache entry for input packet diff --git a/example/ipsec/odp_ipsec_misc.h b/example/ipsec/odp_ipsec_misc.h index 20ebe9fc..346cc1c2 100644 --- a/example/ipsec/odp_ipsec_misc.h +++ b/example/ipsec/odp_ipsec_misc.h @@ -321,7 +321,7 @@ void ipv4_adjust_len(odph_ipv4hdr_t *ip, int adj) /** * Verify crypto operation completed successfully * - * @param status Pointer to crypto op status structure + * @param status Pointer to cryto completion structure * * @return TRUE if all OK else FALSE */