From patchwork Tue Jul 11 14:00:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107374 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4918348qge; Tue, 11 Jul 2017 07:04:01 -0700 (PDT) X-Received: by 10.55.5.135 with SMTP id 129mr82036qkf.184.1499781841501; Tue, 11 Jul 2017 07:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499781841; cv=none; d=google.com; s=arc-20160816; b=ZSrGSUYESD2N7YDyRg+6btpAa7WuN2xY3QcKZLd8DwpzKMOz0VZTmDni3DQjfn480G nCGT0tQUR91JrBV/jPSNwgLvDLvVEori8O/MiMOf1gHAn/BnMQkpETbYroowxkleKZEi TBgEAt+d8tChb1y2k9OA+7+lS4UU9oKMZussZ7THpzL8gUzMM3FvmXkdncW76bBkO4aZ QUfZuC/VfYi7wFF2YX2wGgqrTkuaQ6H1s82Pz1H0ZEuzhF4pP+eE/vsHi3aTySZvtxaQ cbPrwo1x52Owbt66rMreYYdIX9Lt50/ueGkE7VQaHL/yYgKTgL+twjXMuMRgxeb+wuWw Gc/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=x+xLgvDk+ibqGlW6cNKQeCUZpTG46KFHrTaXOBxte0c=; b=W5SUq2N0UH2K/XZrDx+HByw9ef6sDLIBPFURTsbrHQMTLSAEVQkdPqVZ2GgDLBnpvS sHDoXSdgS1ZMdHG0aFm4Sp1y/Cdz2TiuSBi1+Zg/gz5qZ+v3unvFfGpx6jM7rQQU8RS0 IyO5CY5gl4SlvCuNU0eHvPOHfN7Y7rxFILZSKaiaM2vDjN+zA7Vf351AgSNk48s+xKuz IGHTDGEPCp36cWzHajDOntJ2SeqUFFyTAHsstfblNvztZLGCehIek6Ijhi61wk6po8Cj L5NoAKRxqTuK1oLfSGXiblGzMteZNNQnhFIldFbzAH2n0S36ClPBzSYVIMK6flgNniPb pRbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u65si18879qkh.220.2017.07.11.07.04.01; Tue, 11 Jul 2017 07:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 2E3C960D6F; Tue, 11 Jul 2017 14:04:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id F396660CE4; Tue, 11 Jul 2017 14:03:48 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 75C9A60D74; Tue, 11 Jul 2017 14:03:41 +0000 (UTC) Received: from forward1o.cmail.yandex.net (forward1o.cmail.yandex.net [37.9.109.84]) by lists.linaro.org (Postfix) with ESMTPS id 42C2160A49 for ; Tue, 11 Jul 2017 14:02:53 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward1o.cmail.yandex.net (Yandex) with ESMTP id D1E292148A for ; Tue, 11 Jul 2017 17:02:51 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id C0A323EC35A5 for ; Tue, 11 Jul 2017 17:00:49 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OI4ujX4Yll-0mLmafMR; Tue, 11 Jul 2017 17:00:48 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 11 Jul 2017 17:00:28 +0300 Message-Id: <1499781629-30670-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> References: <1499781629-30670-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v9 9/10] test: rewrite odp_crypto using Crypto packet API X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: c7718962c6633c80eb71a0400d89c31f11f88045 ** Merge commit sha: 6b4b95ac299d32801f55cf75ba31016675ac1afb **/ test/common_plat/performance/odp_crypto.c | 169 ++++++++++++++++++------------ 1 file changed, 104 insertions(+), 65 deletions(-) diff --git a/test/common_plat/performance/odp_crypto.c b/test/common_plat/performance/odp_crypto.c index bc29a888..a129ec98 100644 --- a/test/common_plat/performance/odp_crypto.c +++ b/test/common_plat/performance/odp_crypto.c @@ -443,9 +443,10 @@ create_session_from_config(odp_crypto_session_t *session, return -1; } params.compl_queue = out_queue; - + params.packet_op_mode = ODP_CRYPTO_ASYNC; } else { params.compl_queue = ODP_QUEUE_INVALID; + params.packet_op_mode = ODP_CRYPTO_SYNC; } if (odp_crypto_session_create(¶ms, session, &ses_create_rc)) { @@ -456,6 +457,24 @@ create_session_from_config(odp_crypto_session_t *session, return 0; } +static odp_packet_t +make_packet(odp_pool_t pkt_pool, unsigned int payload_length) +{ + odp_packet_t pkt; + + pkt = odp_packet_alloc(pkt_pool, payload_length); + if (pkt == ODP_PACKET_INVALID) { + app_err("failed to allocate buffer\n"); + return pkt; + } + + void *mem = odp_packet_data(pkt); + + memset(mem, 1, payload_length); + + return pkt; +} + /** * Run measurement iterations for given config and payload size. * Result of run returned in 'result' out parameter. @@ -467,15 +486,13 @@ run_measure_one(crypto_args_t *cargs, unsigned int payload_length, crypto_run_result_t *result) { - odp_crypto_op_param_t params; + odp_crypto_packet_op_param_t params; odp_pool_t pkt_pool; odp_queue_t out_queue; - odp_packet_t pkt; + odp_packet_t pkt = ODP_PACKET_INVALID; int rc = 0; - odp_bool_t posted = 0; - pkt_pool = odp_pool_lookup("packet_pool"); if (pkt_pool == ODP_POOL_INVALID) { app_err("pkt_pool not found\n"); @@ -490,16 +507,12 @@ run_measure_one(crypto_args_t *cargs, } } - pkt = odp_packet_alloc(pkt_pool, payload_length); - if (pkt == ODP_PACKET_INVALID) { - app_err("failed to allocate buffer\n"); - return -1; + if (cargs->reuse_packet) { + pkt = make_packet(pkt_pool, payload_length); + if (ODP_PACKET_INVALID == pkt) + return -1; } - void *mem = odp_packet_data(pkt); - - memset(mem, 1, payload_length); - time_record_t start, end; int packets_sent = 0; int packets_received = 0; @@ -515,77 +528,102 @@ run_measure_one(crypto_args_t *cargs, params.auth_range.length = payload_length; params.hash_result_offset = payload_length; - if (cargs->reuse_packet) { - params.pkt = pkt; - params.out_pkt = cargs->in_place ? pkt : - ODP_PACKET_INVALID; - } - fill_time_record(&start); while ((packets_sent < cargs->iteration_count) || (packets_received < cargs->iteration_count)) { void *mem; - odp_crypto_op_result_t result; if ((packets_sent < cargs->iteration_count) && (packets_sent - packets_received < cargs->in_flight)) { + odp_packet_t out_pkt; + if (!cargs->reuse_packet) { - /* - * For in place test we use just one - * statically allocated buffer. - * For now in place test we have to - * allocate and initialize packet - * every time. - * Note we leaked one packet here. - */ - odp_packet_t newpkt; - - newpkt = odp_packet_alloc(pkt_pool, - payload_length); - if (newpkt == ODP_PACKET_INVALID) { - app_err("failed to allocate buffer\n"); + pkt = make_packet(pkt_pool, payload_length); + if (ODP_PACKET_INVALID == pkt) return -1; - } - mem = odp_packet_data(newpkt); - memset(mem, 1, payload_length); - params.pkt = newpkt; - params.out_pkt = cargs->in_place ? newpkt : - ODP_PACKET_INVALID; } + out_pkt = cargs->in_place ? pkt : ODP_PACKET_INVALID; + if (cargs->debug_packets) { - mem = odp_packet_data(params.pkt); + mem = odp_packet_data(pkt); print_mem("Packet before encryption:", mem, payload_length); } - rc = odp_crypto_operation(¶ms, &posted, - &result); - if (rc) - app_err("failed odp_crypto_operation: rc = %d\n", - rc); - else - packets_sent++; + if (cargs->schedule || cargs->poll) { + rc = odp_crypto_packet_op_enq(&pkt, &out_pkt, + ¶ms, 1); + if (rc <= 0) { + app_err("failed odp_crypto_packet_op_enq: rc = %d\n", + rc); + break; + } + packets_sent += rc; + } else { + rc = odp_crypto_packet_op(&pkt, &out_pkt, + ¶ms, 1); + if (rc <= 0) { + app_err("failed odp_crypto_packet_op: rc = %d\n", + rc); + break; + } + packets_sent += rc; + packets_received++; + if (cargs->debug_packets) { + mem = odp_packet_data(out_pkt); + print_mem("Immediately encrypted " + "packet", + mem, + payload_length + + config->session. + auth_digest_len); + } + if (!cargs->in_place) { + if (cargs->reuse_packet) + pkt = out_pkt; + else + odp_packet_free(out_pkt); + } + } } - if (1) { - packets_received++; - if (cargs->debug_packets) { - mem = odp_packet_data(params.out_pkt); - print_mem("Immediately encrypted packet", mem, - payload_length + - config->session.auth_digest_len); - } - if (!cargs->in_place) { - if (cargs->reuse_packet) { - params.pkt = params.out_pkt; - params.out_pkt = ODP_PACKET_INVALID; - } else { - odp_packet_free(params.out_pkt); + if (out_queue != ODP_QUEUE_INVALID) { + odp_event_t ev; + odp_crypto_packet_result_t result; + odp_packet_t out_pkt; + + if (cargs->schedule) + ev = odp_schedule(NULL, + ODP_SCHED_NO_WAIT); + else + ev = odp_queue_deq(out_queue); + + while (ev != ODP_EVENT_INVALID) { + out_pkt = odp_crypto_packet_from_event(ev); + odp_crypto_packet_result(&result, out_pkt); + + if (cargs->debug_packets) { + mem = odp_packet_data(out_pkt); + print_mem("Receieved encrypted packet", + mem, + payload_length + + config-> + session.auth_digest_len); } - } + if (cargs->reuse_packet) + pkt = out_pkt; + else + odp_packet_free(out_pkt); + packets_received++; + if (cargs->schedule) + ev = odp_schedule(NULL, + ODP_SCHED_NO_WAIT); + else + ev = odp_queue_deq(out_queue); + }; } } @@ -607,9 +645,10 @@ run_measure_one(crypto_args_t *cargs, cargs->iteration_count; } - odp_packet_free(pkt); + if (ODP_PACKET_INVALID != pkt) + odp_packet_free(pkt); - return rc; + return rc < 0 ? rc : 0; } /**