From patchwork Wed Jul 5 14:00:17 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: 107078 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp879815obb; Wed, 5 Jul 2017 07:03:17 -0700 (PDT) X-Received: by 10.200.57.25 with SMTP id s25mr52272080qtb.141.1499263397013; Wed, 05 Jul 2017 07:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263397; cv=none; d=google.com; s=arc-20160816; b=JvzpjC+5gl5hKQbHCnyFvOWctDCjPKEPKqOvZFMQEP8VRrMDLvpSIsVlSW7xZ04ax8 5jKx/a+sjey+QR0++0UPnUPtTmRZu5g4Rcv5o1ul2zKvbo0UdfqsrocGUOLC2QPDiZro DWLLFZj+f5RQea4PHBN7Il6DKZjTkatwa2qdhmAzWnJV6icVeKgvBlflWT4fAwi5Vdn9 UB2M73DGBUdsQ++q78yoc8xSfBLmEiBibL1GrwlcBB42CMQLaAKabLVDK3fTFdJx6+0P 9bvKmcGKmZKjcOiPVROybUvk2o5itD4gsKVLF/VZ/yWJZcb+r192qp84tP66OPaKXauv bF0A== 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=Yf03e+yx02PZaUTHEj9aQPRdyHhtgdXp41n+3GePcnk=; b=YojMuZfdOEoOuVsr+UWucfJ2SCWlZrZZt8QDY5LZlwSRLCckA8GowK/ptbqZrpCtzH /4u4QsiaDb+1/YmKbJ7f/f0c+k9MgCyT1B3Imrk62mFukwqKybCEa3GDvfwtuBr6qKFs hfdEER31aBx47qp34KMgs/lUeDVMaYFmG2mP+vbi/LpjlJsTgZa/hsIoiHNJCE9FNv3R A+20UO36LUwc1xfJnxZhac1ALvtIWtsRumKGqn2aB/IwtTvKiQ8HV0lkDbz7rFgqseMk 1O9z8dVF3gszA8+PVcsxPZp07SLcDY6OY8euesIM7BAeBmSfl4pmY9SKp+yGGdkKsNqJ 7foA== 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 n188si20606071qkb.292.2017.07.05.07.03.16; Wed, 05 Jul 2017 07:03:16 -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 999BE60D2D; Wed, 5 Jul 2017 14:03:16 +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 E1E5560D35; Wed, 5 Jul 2017 14:01:20 +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 EB83260D48; Wed, 5 Jul 2017 14:01:07 +0000 (UTC) Received: from forward4o.cmail.yandex.net (forward4o.cmail.yandex.net [37.9.109.248]) by lists.linaro.org (Postfix) with ESMTPS id 4B18060D25 for ; Wed, 5 Jul 2017 14:00:40 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [5.45.198.129]) by forward4o.cmail.yandex.net (Yandex) with ESMTP id CBD04214F8 for ; Wed, 5 Jul 2017 17:00:38 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 41EFD32410FD for ; Wed, 5 Jul 2017 17:00:33 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0WEGGv2L; Wed, 05 Jul 2017 17:00:32 +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: Wed, 5 Jul 2017 17:00:17 +0300 Message-Id: <1499263226-5288-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 Wed Jul 5 14:00:18 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: 107077 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp878468obb; Wed, 5 Jul 2017 07:02:13 -0700 (PDT) X-Received: by 10.200.4.7 with SMTP id v7mr50697426qtg.166.1499263333670; Wed, 05 Jul 2017 07:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263333; cv=none; d=google.com; s=arc-20160816; b=pi/RxC1dFmAi9CnLYMzJhMvPQbomCAkOeVaiaCLMaQ/c5y3QvKPui3Mv5gfiXNX5+S a+8ltYpSHlCU9Z5NiZ/h02xkkLE+QqH82wnjIq4FxXaEjWQYRWNlxL7V0jQ9On3uFY3z nNtpa35WN32prL0vbDGugBINQIMwZ+GabtBDF55pASuhQ4QE7Rw5XyBvN/4A9kbD5JLY OB0WzaoKBh8y+BKPAxhHB1QWumNSw99IVuDwOU7xc10bSbV+IC288+S/b1OWQyBXqsd7 cxwEd6zcVNfdkwKxrzE7IaIg+Lz3PVAcK1xCnUUCJ9JfXg66UDJWRgpAN518DXkLFx+P stuw== 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=Yt4yLC5epFZkJTk8mtRf78s5nHUuOPSLE3cRlWlP238=; b=lUk8lU0bNDI2xc6CzRI4EY+N/3xWGOrRZ6pRg/q2ECFtRQM5CrGVjUffDwOY/cuFfa LTwNJQw4a/Qaje+r5mwdnJ3P0Ksh0ZYdrfLLMY7aH477Vvu0y4OGDpy5agHobEiYyVeT AEmHWH7/umQJ3KxpeHNcI/i7OWZMZoTH6Fu93JBzvKPejYzXNGGX75xK83U0KxhKVzHD sehSq7HFoplA7WZtOH9iQCtQWG9Nqdlz4t2+F5Uf56Dmr2zx52amnUGNllAJKDVTDBKs cJbBo1+NW4EZJmuSYBija18S5l5jwoFM0H2ljpAIb5WChz4QpG4R1rDGmGvZIhRP8J0Z 5eBQ== 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 k22si9751894qtc.368.2017.07.05.07.02.13; Wed, 05 Jul 2017 07:02:13 -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 365E160D92; Wed, 5 Jul 2017 14:02:13 +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 B491F60816; Wed, 5 Jul 2017 14:01:16 +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 413CE60D3C; Wed, 5 Jul 2017 14:01:03 +0000 (UTC) Received: from forward1m.cmail.yandex.net (forward1m.cmail.yandex.net [5.255.216.2]) by lists.linaro.org (Postfix) with ESMTPS id 377C160C3E for ; Wed, 5 Jul 2017 14:00:41 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::15:6]) by forward1m.cmail.yandex.net (Yandex) with ESMTP id 7FEA4210A0 for ; Wed, 5 Jul 2017 17:00:39 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id D7EDB3241103 for ; Wed, 5 Jul 2017 17:00:35 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0YEaZpa1; Wed, 05 Jul 2017 17:00:34 +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: Wed, 5 Jul 2017 17:00:18 +0300 Message-Id: <1499263226-5288-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 Wed Jul 5 14:00:19 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: 107079 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp880731obb; Wed, 5 Jul 2017 07:04:03 -0700 (PDT) X-Received: by 10.200.41.172 with SMTP id 41mr36385400qts.85.1499263443873; Wed, 05 Jul 2017 07:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263443; cv=none; d=google.com; s=arc-20160816; b=nKPOa/NJnmC4p8wYjYiGb5mDk/0dYALTulTNfLYX63qtKb7/X/BqCLvyq36ruoo8Qx Qmx2ISsRkUzcayyQeu/Y2jcZsox7s3v1jEH2sZN0hmMv4hnmw2ar81/G0xT+S7CTFNzH 7AF+TQkBMoCkpRCLHvNn10Vy12jZAuBeBahbShnnyCyO3vqQno5Orvt1uCJSlKEFLlfm 4XZOilQhmdfLhxsEfL0ttNa9tHIxncQsdix5evHBipsmCKEnW9rwCfdzc2bSXBIEJwbV H5BwWS5M84PNOK3LCc8GrF8HhROQnPKDCjK5vvc6gwwfE5YY2UyifDXu5mvDrd4AHVn9 i3Iw== 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=6rXP0T/ji8FF4ZxBTXXvWPuetZnMMoleykoAauEwTJc=; b=Y3R3/ufbmnL/J9zi/ulq3Qw1QkmpXHuUFo0u/ST19OKNzsNqrshnbwQHdDRv51wFuE obO1RJn3xzjvugWOpIMuN0rBNuIKQe/dfY9ddHmmUaP9T0y9CMFzbm0piaH9YLw9pGpm LhlyXUwncIBg4Gf+mkhA0+GAdLlnEqwecER71nT3iQMRPxF6sAd2xd/+7Ts8iZtnCI6P 6Ke8qhGmKioVSkt42uktdrIIpqgNtp3SO0ZcQsKA1XBvcGOLLz19dd6JXn5BidAcNdq7 TINNWg3AZ7ShnOsQm8AKDq6ix/Ldz9iN3nCf0HMWzHQDHIYfzl4Jfs02E99+uhPJQxJs oEig== 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 q7si3256674qkl.241.2017.07.05.07.04.03; Wed, 05 Jul 2017 07:04:03 -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 7EAD360D2D; Wed, 5 Jul 2017 14:04:03 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 3201460D2E; Wed, 5 Jul 2017 14:01: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 1018560D25; Wed, 5 Jul 2017 14:01:11 +0000 (UTC) Received: from forward1j.cmail.yandex.net (forward1j.cmail.yandex.net [5.255.227.19]) by lists.linaro.org (Postfix) with ESMTPS id 054FC60D2D for ; Wed, 5 Jul 2017 14:00:43 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [5.45.198.129]) by forward1j.cmail.yandex.net (Yandex) with ESMTP id A1A44206A9 for ; Wed, 5 Jul 2017 17:00:41 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 9A1293240D50 for ; Wed, 5 Jul 2017 17:00:37 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0bEan16K; Wed, 05 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: Wed, 5 Jul 2017 17:00:19 +0300 Message-Id: <1499263226-5288-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 3/10] api: crypto: drop async mode support 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 Current Crypto API provides a way to set the 'preferred' mode of operation, without actually telling if the operation will proceed in sync or async mode. In preparation of reworking crypto API declare that all operations always end up processed in sync mode (posted == FALSE). 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ include/odp/api/spec/crypto.h | 10 ++-- .../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 - 5 files changed, 16 insertions(+), 68 deletions(-) diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index 470cba05..01b15d6b 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -640,14 +640,12 @@ void odp_crypto_compl_free(odp_crypto_compl_t completion_event); * Crypto per packet operation * * Performs the cryptographic operations specified during session creation - * on the packet. If the operation is performed synchronously, "posted" - * will return FALSE and the result of the operation is immediately available. - * If "posted" returns TRUE the result will be delivered via the completion - * queue specified when the session was created. + * on the packet. The operation is performed synchronously, the result of the + * operation is immediately available. * * @param param Operation parameters - * @param posted Pointer to return posted, TRUE for async operation - * @param result Results of operation (when posted returns FALSE) + * @param posted Always returns FALSE + * @param result Results of operation * * @retval 0 on success * @retval <0 on failure 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 Wed Jul 5 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: 107081 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp884023obb; Wed, 5 Jul 2017 07:06:39 -0700 (PDT) X-Received: by 10.237.60.19 with SMTP id t19mr52693558qte.206.1499263598956; Wed, 05 Jul 2017 07:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263598; cv=none; d=google.com; s=arc-20160816; b=WqqS1NYVGpUT0e9MUvDH5MIK2thky9G3SrXcJf+AJTjIKFHIgxWqvXHvP4to4d7LH+ PWe9GZIjDfDU7xRMQXjtfwt1sAUQQPAD8UhhqTE39VxNVKb8KH3r9v2Gjwqaxw8NpaCr PUmzBfhuXGnBalvrJMkwlEsgN2D3udTPyUyGV6PVQs8812KVdQ0+BPDeXFHCZuwcPwlW CWDJUOYxvmrlrlsDCS0yEl/SuF+ilaG9MPRn9OncWibKugwwha2MXUK0zyBTzt3UxLYj ZjBUjSOFRnzAGPJf7MuYnZQHS+qzoUOgbwE08FUAjH+h93pGsD6LkY0c2Fx6XLmcGw2M VIcQ== 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=ctHv8asEDfs4MbAhbQW2e2nwpH4kSwRFfDhFm0iouuA=; b=xol8zCT/+vO3KscmOX4s4GZ90pzC86x92OojtvVMsN4WZ7vuzqmX9yDjZfdSL/r9ax Zw2WJAsNZxRqEQY8eP8rT9ozUNWhI16GNLB9LavaCwMc4eHtVuHWhUvPHVDo2EO4PO3W A/ZRVv6Op9TCdY1FBd9fLEtVjqs3QtJrLzuPA6uPQ0ICRZOK/HW1oRb6XK+7IDeW4C1X jQNTmVGT3GUQRYXgh0BHwbkRjzIGFNcVscXC936LGq9JXoy73AsrEpPb+SXoglSJ5DMJ p8ljo4LU7fKndHPiQ0zgYfK8dGH76m156bN/t0rOxX+TbqlB/WJ8nYnVJA9Q+RUJImlX MOeQ== 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 z4si14965074qtz.117.2017.07.05.07.06.37; Wed, 05 Jul 2017 07:06: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 CFD1E607A3; Wed, 5 Jul 2017 14:06: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 8B11060D70; Wed, 5 Jul 2017 14:01: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 61FC460816; Wed, 5 Jul 2017 14:01:12 +0000 (UTC) Received: from forward3j.cmail.yandex.net (forward3j.cmail.yandex.net [5.255.227.21]) by lists.linaro.org (Postfix) with ESMTPS id DCEF060D2E for ; Wed, 5 Jul 2017 14:00:43 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [5.45.198.129]) by forward3j.cmail.yandex.net (Yandex) with ESMTP id 7729D21042 for ; Wed, 5 Jul 2017 17:00:42 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 3C9B33241117 for ; Wed, 5 Jul 2017 17:00:39 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0cES2VMg; Wed, 05 Jul 2017 17:00:38 +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: Wed, 5 Jul 2017 17:00:20 +0300 Message-Id: <1499263226-5288-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 Wed Jul 5 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: 107080 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp881991obb; Wed, 5 Jul 2017 07:05:01 -0700 (PDT) X-Received: by 10.200.61.130 with SMTP id v2mr47409492qtf.230.1499263501693; Wed, 05 Jul 2017 07:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263501; cv=none; d=google.com; s=arc-20160816; b=Aa2k0ygWHa7ArcsPClYcFJYPR29JWge379oGfRV1ejxqdNUhbuwpgnET4xtOgp4bHD i5VitBZ1HFRcO/wWQsU6a89jgLX1nldOEgStiaEO8fAgavwggVvSOOJQ3+AhZCPHGVVs fQLHLSPqLpx7x6m3sGB7lj8AftJzYGckcJ6llFBuI7VKKb6EfCbuW7KTjg9jFO0t8XdC dUA1EIWDfOZnL2iypa6Bc034avRh6K6rKXD1X4OTYldknzPdTMCmpCB41B7Ug5RAE7qY riYzKyu/RnUuT6QTuIePNS7a0M+TDIEbVj2GUNwqtTVcCy1c/lE+j14yWTrIJyS2zb36 7IGQ== 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=lIV3R6MIUP2+S9hOUw9QkqQg66JUGNxvz8YtEJaCU54=; b=0tGn4nZ2I4yODN/VJMqrsoOxoEY82125gR9KkotLHjGPQc7hO7GVcId+l04qKDy8DO igh2jLDw8irvqP2wfzVna95/aEGSDuYio/lRhxMLHnSbA8WPTynbiyIsnfGv4tZ+2y0X oQpnaEcJExUTOIgYtl6Sv39UXktXhIRoiXLJTUcRShTyFiUyFxYS+24V0jnGN4hQj32x W7XZpOUFavpNFZQdqXCo3MF3UQv17s32POSX+lpFuryVT6UuicKQOypkVsQCVWKWPI6Z 1R9k6BEpvek8DlJbNR+ypTlm2eIddEnOfx/6tqz+hYqegMymJV9Nvt5lM0Tttj8T+hru Orew== 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 p4si17189351qtc.73.2017.07.05.07.05.01; Wed, 05 Jul 2017 07:05: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 5792160D37; Wed, 5 Jul 2017 14:05: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 6085A60D48; Wed, 5 Jul 2017 14:01:33 +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 E010D60816; Wed, 5 Jul 2017 14:01:11 +0000 (UTC) Received: from forward5h.cmail.yandex.net (forward5h.cmail.yandex.net [87.250.230.20]) by lists.linaro.org (Postfix) with ESMTPS id DBE3160D35 for ; Wed, 5 Jul 2017 14:00:45 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::15:6]) by forward5h.cmail.yandex.net (Yandex) with ESMTP id 62E8C21836 for ; Wed, 5 Jul 2017 17:00:44 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 9D5CC3241075 for ; Wed, 5 Jul 2017 17:00:41 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0eEmUGZr; Wed, 05 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: Wed, 5 Jul 2017 17:00:21 +0300 Message-Id: <1499263226-5288-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 01b15d6b..454855ea 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 @@ -660,8 +669,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 @@ -687,7 +697,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 Wed Jul 5 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: 107084 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp888028obb; Wed, 5 Jul 2017 07:09:58 -0700 (PDT) X-Received: by 10.55.121.199 with SMTP id u190mr50522324qkc.216.1499263798024; Wed, 05 Jul 2017 07:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263798; cv=none; d=google.com; s=arc-20160816; b=B2+nYgnVwj1ZX5R2TogveOjbGQf/waykFRMC30iBC6ZzfeqYeNOqq/ZJl8bxZJTMkJ rnyPjl00EYrDrPdcmQ1VPzqEFn9pXf0nj3ANcIMIAkHr2QKps2VA+gXzi7xMK+3W257k 1QX0si4SAf1NZsx1JnHXU5jsBgfkSk5upFhxFfIoxyJ4bNDqNsq/PpD5veIDxq90+SoG kXIspQwWc02l9GcwlAVIqvA8bqoRE9VzsRWTJMHLdQEe6E3JRmSJXfuQ2vxkkpHn+f98 +22uTmu0oK4wcJohfzmVuEuRC/humIqUpEElBKufHHQLj3mYePdsjsjRsp+5Wh6AqkP4 x61A== 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=xqzRG7OilG5NNp+QvmiyupadefXByGqBd5QXBVtXn14=; b=mF68xtHysWzkYP+w9bvyv+Slvts4gfHmJuCR9SxLP6aUDm4zLJqosV8tTAWf/gq5+p CdJ7852KuL0LipfEYaSby+TpPvtgnwd2IYafDS/y3oeI1mq5X6qh0ikpyts2Q+RXpBD4 YP7MNBfog3zTaiPl6uK3NZHRIERffTZhJw+RHXuhZroOD5a09h6d/ppyasQKsNaM3p6P hSzkwXAnV3w6q4cY9RO8MntAGpZBNFc6XDn+AH7PNFZ8ZcHpQc2rRVTuUQ3aDdgvtEM5 BPr0KboA+TV0xD50/Gm7ThF8hdLlcyRQ7TomR0S3Y2gHnDYo+UUFZFRvS8IBR89auRX3 6JHw== 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 u4si20782980qkl.145.2017.07.05.07.09.57; Wed, 05 Jul 2017 07:09:57 -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 83C7760D6F; Wed, 5 Jul 2017 14:09:57 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 5F2ED60D69; Wed, 5 Jul 2017 14:01:58 +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 5E0BF60D35; Wed, 5 Jul 2017 14:01:18 +0000 (UTC) Received: from forward1j.cmail.yandex.net (forward1j.cmail.yandex.net [5.255.227.19]) by lists.linaro.org (Postfix) with ESMTPS id ABF6660D34 for ; Wed, 5 Jul 2017 14:00:45 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::15:6]) by forward1j.cmail.yandex.net (Yandex) with ESMTP id A0C6A206A9 for ; Wed, 5 Jul 2017 17:00:44 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 024DC32410D1 for ; Wed, 5 Jul 2017 17:00:42 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0fE0kmWj; Wed, 05 Jul 2017 17:00:41 +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: Wed, 5 Jul 2017 17:00:22 +0300 Message-Id: <1499263226-5288-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 454855ea..27b12c89 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; @@ -711,6 +779,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 Wed Jul 5 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: 107083 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp886360obb; Wed, 5 Jul 2017 07:08:34 -0700 (PDT) X-Received: by 10.200.38.34 with SMTP id u31mr49660154qtu.127.1499263713937; Wed, 05 Jul 2017 07:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263713; cv=none; d=google.com; s=arc-20160816; b=EjHALFJnUuMgKnKqFYRBpesEIhhwXyq/Dece/aH6B48dVDFBHN1vCWD5lNxVE+L2fq p4jelgzDHvGmr1MBSA+Erir8Tdvc0BZuA9QLocvjXSMiymZbhwVySqaREjBenctL70ut Z/WE6C5o28LL1hXV0aKxSX/Dqc8vD3Ig1PGSXCUekFtqMdQCz3jtbqP/CBSieVO1IjjY 3CN9ZT3WOR/sD5JyIkuDLQnL94mGzC8DuR8XoEgFt9y/DOg+afDYfNJlNJ66uFH9cU3J qSLNP4mAGj8YVr7BAgR3BQfq4riMa0f+TNK6qxy0nP3gUqVP3ghMDUsfp6wP8yd8uMsc 6u5A== 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=uCXixs8ByydYcKj/edcLcYBt2xyVRcc8Omi7JDRLJ6g=; b=USm839SEnv811b1UTlSaH+SHFoH21CKupCpj0y2nQZksmcqW+EbkQFRBtm+7AKhZuu xCM+t+ONfZHW3BF6JdkzwEtv8EPA98ERkxK+bZYpKx38jne4RBLGaR/O4smlhGHV++DG ic8InIYsK7+iz1dBNw0jNPgJYui07SXwyhmkHwdLW5V8AtJLc4/WrNE8lswNo33Ezpkl q8HUB/PGE5SkiLBQ7Owjtl2GkzvnTZRunFV7j3fch/kT+a5dwIS8MRbKZmeHdH5UkWku JBn002gNdjJ+JBl9njvOfJEI60lHWUIPp94oMTjPb6SDyLLxhZgw3ps86sW/EXEZsmVc I2lQ== 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 t18si10512397qke.198.2017.07.05.07.08.33; Wed, 05 Jul 2017 07:08: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 2846D60C3E; Wed, 5 Jul 2017 14:08: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 1FD2460D75; Wed, 5 Jul 2017 14:01: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 E020E60804; Wed, 5 Jul 2017 14:01:14 +0000 (UTC) Received: from forward4p.cmail.yandex.net (forward4p.cmail.yandex.net [77.88.31.19]) by lists.linaro.org (Postfix) with ESMTPS id 7DEDA60D36 for ; Wed, 5 Jul 2017 14:00:47 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [5.45.198.129]) by forward4p.cmail.yandex.net (Yandex) with ESMTP id 4472021147 for ; Wed, 5 Jul 2017 17:00:45 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 8AF153240C1B for ; Wed, 5 Jul 2017 17:00:43 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0hEaH07W; Wed, 05 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: Wed, 5 Jul 2017 17:00:23 +0300 Message-Id: <1499263226-5288-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ .../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 Wed Jul 5 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: 107082 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp885047obb; Wed, 5 Jul 2017 07:07:26 -0700 (PDT) X-Received: by 10.200.35.221 with SMTP id r29mr27916341qtr.169.1499263646666; Wed, 05 Jul 2017 07:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263646; cv=none; d=google.com; s=arc-20160816; b=tqDHDDnFh/2vEtAC7kbQ+BGufNZd5gp1aOZQ2ooSOL+QIdTyN1oHQ6RWOsPWI2JkwJ VZVfcJnc87q3u7OJmIPqmzgwNNghycVL3chs2gAP4ZTo+xUyr+zXEpLKEtcEacJJC/HU OrVX+LT3YKyUW4N/JXpHOCa8qqn4K1axd0X4FEYZ0E3fpe+mmZZX/LviinRShfYCbLSN OIMIiIEpDdBYTlXIkHP9XChZg3smgBCHEC9ts+hyzi5biJeiX+R3Oor9b+3cuK0jWVet o0nFb/9e34zQmLhq/28SNdJHmmvyxh5qCalhdxXARP5BN9UXAnuFOO3s9eD36vpOOygN QY/g== 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=+jr3tHyiEnCoKMXC3CpLy4MibsTJbdN4IYlxU+1n+e8=; b=qO6GtYjCt4CmkcnDm2JKO/D8imF9BdRpxcd9Gq+0bpf5spstR4PiBZ1YNxau5tGJrq o0BZWu1OJEr0OcAh7M21Il9AC72oU/4cAi6I8FWL0xR3SaQ3DPifeyPTPjjKslj1GNZF Tds2J0eVSOhAzMGoHzbL8c0bJTgGoj0ZxtB/lOvRQxYLJDpd7wW5mbGsLROENS+5mvwA 5tGgDN4y4ZW66nWR7xjs7LrRtJm3q7CIyXGJ7bJu4d6PdtadJzMYzjSdj1OQA1LvWsox q7HkipSrJmGcC2ydiIJGuuqnDdaVYCYFEpq7gWP/jbnHtDLXutOmeJhXZ7Lm+jfmR15Z Sccw== 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 q12si18501421qta.14.2017.07.05.07.07.26; Wed, 05 Jul 2017 07:07:26 -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 4D10560D58; Wed, 5 Jul 2017 14:07:26 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 D1DD460D6A; Wed, 5 Jul 2017 14:01:43 +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 DAA6360816; Wed, 5 Jul 2017 14:01:13 +0000 (UTC) Received: from forward1p.cmail.yandex.net (forward1p.cmail.yandex.net [77.88.31.16]) by lists.linaro.org (Postfix) with ESMTPS id 07A1860D37 for ; Wed, 5 Jul 2017 14:00:48 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [5.45.198.129]) by forward1p.cmail.yandex.net (Yandex) with ESMTP id 174A221272 for ; Wed, 5 Jul 2017 17:00:46 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id E62633240FD4 for ; Wed, 5 Jul 2017 17:00:45 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0iEmAZmj; Wed, 05 Jul 2017 17:00:44 +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: Wed, 5 Jul 2017 17:00:24 +0300 Message-Id: <1499263226-5288-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 Wed Jul 5 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: 107085 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp891416obb; Wed, 5 Jul 2017 07:12:50 -0700 (PDT) X-Received: by 10.237.44.65 with SMTP id f59mr4209899qtd.144.1499263970059; Wed, 05 Jul 2017 07:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263970; cv=none; d=google.com; s=arc-20160816; b=p3Z+PsK+1PWdAjtd5LDkNTG15LMKkm2mMYIuIino2DETwJllxXhkjr5ww8xstq8M9C slrw9tfdBskz6UVMOn3RYEUWJgtPXRMkBGvmL/inM1/ZTPbNv7vcLDZ21my5WQIPRU52 uCZL9lAEa7OcGaqMPyotvikuqApDSga/djA2QLNyQBvmJecNx2EB7vCzMB/6AgtjqLrI 8Mn4r/Ud8rw+5yYzaj5QypCRiV1O5xo2Uvqml7JLodJ3evRCPOpGX6ptmoRM7/peaNm4 J6S0XG8jv5z8czkCewmNlTg7p7tFnVDxMrJ7u58i2DiOI+Y1MPq6jChtxQiadIKIAQTU 7RMA== 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=qSORhWeFdn3GelbrDGDzWfOiccifc5bYo4pw9xQI3uo=; b=mZsUrqBX4T/+yjAvdTyvPdSsDl1YV143ipivztgrO8XLi7705c1xR2i2rUHqeatu8Q 4QO4QUX/Y3nmvfA/AiFSh5VSGeqgbYpk1JxLzX4vO0gUhgu7sVJtjlB6cIfFp2Yr2G11 64A3DcJMyWBsq/dX60AKT/yQKfLpoYKKm1TRfiheDw4d89wdNRJ3oZBAhPBVftZX2aAL SAHTrSIMhy2fJEk8CcdihBnLTOOmZmh15mW60pgozDKc8eZd0DJn6jirms2SjYjy+AVe kKJ103fm+e4TVZBIx2RAg2lR0XkjX6VeYL0m9RPYNA9nWf9FtCZr0wSMu6soS7MGIM4Y o6mQ== 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 f19si14574266qtf.43.2017.07.05.07.12.49; Wed, 05 Jul 2017 07:12:50 -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 A98D960D48; Wed, 5 Jul 2017 14:12:49 +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 74B6460D3A; Wed, 5 Jul 2017 14:02:20 +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 0B85860D68; Wed, 5 Jul 2017 14:02:08 +0000 (UTC) Received: from forward2p.cmail.yandex.net (forward2p.cmail.yandex.net [77.88.31.17]) by lists.linaro.org (Postfix) with ESMTPS id 0D0A960D3A for ; Wed, 5 Jul 2017 14:00:49 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::15:6]) by forward2p.cmail.yandex.net (Yandex) with ESMTP id 13C7C212C8 for ; Wed, 5 Jul 2017 17:00:47 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id DCFD93240BD6 for ; Wed, 5 Jul 2017 17:00:46 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0kEOPoTD; Wed, 05 Jul 2017 17:00:46 +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: Wed, 5 Jul 2017 17:00:25 +0300 Message-Id: <1499263226-5288-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 Wed Jul 5 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: 107086 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp892395obb; Wed, 5 Jul 2017 07:13:39 -0700 (PDT) X-Received: by 10.55.201.28 with SMTP id q28mr54957803qki.177.1499264019139; Wed, 05 Jul 2017 07:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499264019; cv=none; d=google.com; s=arc-20160816; b=NFldJQnBKHfXlpuXMKWUD1XTiiziqZfe5SR9LXD6Icg0KmbUkrZxqCAshBT2XoEDOC /CTBOhqsXXkX1k5gufGyiyyRfeIqcoQCrWSSs3rs92NfyrCSFRMQQaw5c7jGcOJZqgCL bNAURPwQRp9DKjgtA6RdXfwUlj+s8azObhb/vXC1ShWWlUXIrLfRA0XbGV9fVJwe0az5 7shZ3dEvYKKsxXlTlVQelXLGsAN/pFjX8nzqvGHP8Fa2XyNc03YJ6GdjuuUr3aHzmzoP FcnrB2j8WiBisgDzAhvDZQsGPFfbj0J7eYNMcSTAJNO7w8LXYguQF99V3o87tuZ8HhTg 2T2g== 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=E+SXI54L1PJUYGvMDBAEWJoTQjNk0FD6ERMjWYSCtfc=; b=fY/PMJPOziBPotkqndhzveJYqJxB95vLTq4P4F0C1IdCoQGP0sluM9gPI12tZ8+gcl /UxlpQOYJtihfhCY+gEa4u6vu7GMyYeg/UmWXp8A+DmapUAb9Qib+hdw/zgBVBWU8EVK bL8zagPsFgyi+ESDH3FyzhKzG+xxr5eD7D2Unzac74utfsMGQPjttcr7NVMOcY6h9P0V suCSyrgrZ00b7oSs3yGqjVXceYUurMGwmhoXtv3w2dPiYh/nIKLWBfQ9AqaGilFDIzxX Zx2HhyBGcGIUVwSKrXkAJ2yfrVltuPnHGgLaK/7iUgfEVMYd2F6IFphpt67y+vYDQ8ec Dldw== 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 r57si20861652qtr.265.2017.07.05.07.13.38; Wed, 05 Jul 2017 07:13:39 -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 C7A5960D3A; Wed, 5 Jul 2017 14:13:38 +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 D2BDE60D94; Wed, 5 Jul 2017 14:02:26 +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 31A5560D3C; Wed, 5 Jul 2017 14:02:14 +0000 (UTC) Received: from forward2m.cmail.yandex.net (forward2m.cmail.yandex.net [5.255.216.20]) by lists.linaro.org (Postfix) with ESMTPS id 4627460D3D for ; Wed, 5 Jul 2017 14:00:50 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [5.45.198.129]) by forward2m.cmail.yandex.net (Yandex) with ESMTP id 9B996210A4 for ; Wed, 5 Jul 2017 17:00:48 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 43EA53241098 for ; Wed, 5 Jul 2017 17:00:47 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0lES6FrG; Wed, 05 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: Wed, 5 Jul 2017 17:00:26 +0300 Message-Id: <1499263226-5288-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 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: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ 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 */