From patchwork Wed Jan 21 15:15:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 43454 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0C51218DB for ; Wed, 21 Jan 2015 15:18:04 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf826496lab.3 for ; Wed, 21 Jan 2015 07:18:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=7WUrgVfaOjqIBfL/XCoIdfE2pDVhYlJpTz69+30MpeU=; b=CztfzI9ABMmRn315VSWFrgovK/qVPbJCMBE2UVzEfvBuz7l40oGHQMYOipMI7kcUhn xWJxN09MoR4ggj9ms7DcMvfiZxAqPnGSuuv5i3LuCA+gwIoMcjhvAPn4lrLij1CAGji5 DdF00U5K84+K3OmCmESOVqZQ6L45EllaEqdVgdKJQpnMplIeUye8jwBDGryVASqfoVpj YI4vcSiieDzQdzGgEXz60lfBNOkN2m6dxjflqSvceBqQ4gkvJZJX9fjewBRNFjO4lBKh xfhNMvdThxBSooLVx2TJJegaGcWjCDBujeHvPFo7Qph6eKuFPeuRM5fE55NDI4wHfBtD zTUA== X-Gm-Message-State: ALoCoQnkS8VKuDzHled9Tcuq3YG3IXkqB/79QUdMXBOlx1MzCggRQX/2ONLmlAr7a7l+xrhWfSh6 X-Received: by 10.180.94.134 with SMTP id dc6mr1525883wib.2.1421853482532; Wed, 21 Jan 2015 07:18:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.112 with SMTP id jv16ls51162lab.101.gmail; Wed, 21 Jan 2015 07:18:02 -0800 (PST) X-Received: by 10.112.8.41 with SMTP id o9mr44245011lba.40.1421853482369; Wed, 21 Jan 2015 07:18:02 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id lb3si19613411lab.20.2015.01.21.07.18.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 07:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id w7so1051628lbi.1 for ; Wed, 21 Jan 2015 07:18:02 -0800 (PST) X-Received: by 10.152.180.136 with SMTP id do8mr18464884lac.31.1421853482243; Wed, 21 Jan 2015 07:18:02 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1810361lbb; Wed, 21 Jan 2015 07:18:01 -0800 (PST) X-Received: by 10.140.34.177 with SMTP id l46mr46228517qgl.37.1421853478684; Wed, 21 Jan 2015 07:17:58 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id d2si4915893qar.35.2015.01.21.07.17.56 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 21 Jan 2015 07:17:58 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDx2Y-00084z-P4; Wed, 21 Jan 2015 15:17:54 +0000 Received: from mail-qc0-f182.google.com ([209.85.216.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDx26-0007wx-HQ for lng-odp@lists.linaro.org; Wed, 21 Jan 2015 15:17:26 +0000 Received: by mail-qc0-f182.google.com with SMTP id l6so32322304qcy.13 for ; Wed, 21 Jan 2015 07:17:21 -0800 (PST) X-Received: by 10.140.96.132 with SMTP id k4mr31455704qge.102.1421853441355; Wed, 21 Jan 2015 07:17:21 -0800 (PST) Received: from mcpro03.emea.nsn-net.net (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id 91sm415056qgf.1.2015.01.21.07.17.19 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 07:17:20 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Wed, 21 Jan 2015 17:15:37 +0200 Message-Id: <1421853343-22138-11-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421853343-22138-1-git-send-email-petri.savolainen@linaro.org> References: <1421853343-22138-1-git-send-email-petri.savolainen@linaro.org> X-Topics: crypto patch Subject: [lng-odp] [PATCH v3 10/16] api: crypto: Use odp_event_t instead of odp_buffer_t X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: petri.savolainen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Changed crypto API to use odp_event_t instead of odp_buffer_t. Signed-off-by: Petri Savolainen --- example/ipsec/odp_ipsec.c | 12 ++++---- platform/linux-generic/include/api/odp_crypto.h | 12 ++++---- platform/linux-generic/odp_crypto.c | 34 ++++++++++++---------- test/validation/crypto/odp_crypto_test_async_inp.c | 34 ++++++++++------------ test/validation/crypto/odp_crypto_test_sync_inp.c | 3 +- 5 files changed, 49 insertions(+), 46 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 9fdaeab..e375396 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -740,7 +740,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt, *skip = FALSE; if (odp_crypto_operation(¶ms, &posted, - odp_buffer_from_event(odp_packet_to_event(pkt)))) { + odp_packet_to_event(pkt))) { abort(); } return (posted) ? PKT_POSTED : PKT_CONTINUE; @@ -758,7 +758,7 @@ static pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt, pkt_ctx_t *ctx) { - odp_buffer_t event; + odp_event_t event; odp_crypto_compl_status_t cipher_rc; odp_crypto_compl_status_t auth_rc; odph_ipv4hdr_t *ip; @@ -766,7 +766,7 @@ pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt, int trl_len = 0; /* Check crypto result */ - event = odp_buffer_from_event(odp_packet_to_event(pkt)); + event = odp_packet_to_event(pkt); odp_crypto_get_operation_compl_status(event, &auth_rc, &cipher_rc); if (!is_crypto_compl_status_ok(&cipher_rc)) return PKT_DROP; @@ -974,7 +974,7 @@ pkt_disposition_e do_ipsec_out_seq(odp_packet_t pkt, /* Issue crypto request */ if (odp_crypto_operation(&ctx->ipsec.params, &posted, - odp_buffer_from_event(odp_packet_to_event(pkt)))) { + odp_packet_to_event(pkt))) { abort(); } return (posted) ? PKT_POSTED : PKT_CONTINUE; @@ -992,13 +992,13 @@ static pkt_disposition_e do_ipsec_out_finish(odp_packet_t pkt, pkt_ctx_t *ctx) { - odp_buffer_t event; + odp_event_t event; odp_crypto_compl_status_t cipher_rc; odp_crypto_compl_status_t auth_rc; odph_ipv4hdr_t *ip; /* Check crypto result */ - event = odp_buffer_from_event(odp_packet_to_event(pkt)); + event = odp_packet_to_event(pkt); odp_crypto_get_operation_compl_status(event, &auth_rc, &cipher_rc); if (!is_crypto_compl_status_ok(&cipher_rc)) return PKT_DROP; diff --git a/platform/linux-generic/include/api/odp_crypto.h b/platform/linux-generic/include/api/odp_crypto.h index 337e7cf..00a0090 100644 --- a/platform/linux-generic/include/api/odp_crypto.h +++ b/platform/linux-generic/include/api/odp_crypto.h @@ -19,7 +19,7 @@ extern "C" { #endif #include -#include +#include #include #include #include @@ -247,7 +247,7 @@ odp_crypto_session_create(odp_crypto_session_params_t *params, int odp_crypto_operation(odp_crypto_op_params_t *params, bool *posted, - odp_buffer_t completion_event); + odp_event_t completion_event); /** * Crypto per packet operation set user context in completion event @@ -256,7 +256,7 @@ odp_crypto_operation(odp_crypto_op_params_t *params, * @param ctx User data */ void -odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event, +odp_crypto_set_operation_compl_ctx(odp_event_t completion_event, void *ctx); /** @@ -269,7 +269,7 @@ odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event, * @param cipher Pointer to store cipher results */ void -odp_crypto_get_operation_compl_status(odp_buffer_t completion_event, +odp_crypto_get_operation_compl_status(odp_event_t completion_event, odp_crypto_compl_status_t *auth, odp_crypto_compl_status_t *cipher); @@ -284,7 +284,7 @@ odp_crypto_get_operation_compl_status(odp_buffer_t completion_event, * @return Packet structure where data now resides */ odp_packet_t -odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event); +odp_crypto_get_operation_compl_packet(odp_event_t completion_event); /** * Crypto per packet operation query user context in completion event @@ -294,7 +294,7 @@ odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event); * @return User data */ void * -odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event); +odp_crypto_get_operation_compl_ctx(odp_event_t completion_event); /** * Generate random byte string diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 74fac5c..0a37878 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -41,10 +41,15 @@ static odp_crypto_global_t *global; * of packets versus events on completion queues is closed. */ static -odp_crypto_generic_op_result_t *get_op_result_from_buffer(odp_buffer_t buf) +odp_crypto_generic_op_result_t *get_op_result_from_event(odp_event_t ev) { uint8_t *temp; odp_crypto_generic_op_result_t *result; + odp_buffer_t buf; + + /* HACK: Buffer is not packet any more in the API. + * Implementation still works that way. */ + buf = odp_buffer_from_event(ev); temp = odp_buffer_addr(buf); temp += odp_buffer_size(buf); @@ -344,7 +349,7 @@ odp_crypto_session_create(odp_crypto_session_params_t *params, int odp_crypto_operation(odp_crypto_op_params_t *params, bool *posted, - odp_buffer_t completion_event) + odp_event_t completion_event) { enum crypto_alg_err rc_cipher = ODP_CRYPTO_ALG_ERR_NONE; enum crypto_alg_err rc_auth = ODP_CRYPTO_ALG_ERR_NONE; @@ -364,9 +369,9 @@ odp_crypto_operation(odp_crypto_op_params_t *params, ODP_ABORT(); _odp_packet_copy_to_packet(params->pkt, 0, params->out_pkt, 0, odp_packet_len(params->pkt)); - if (completion_event == _odp_packet_to_buffer(params->pkt)) + if (completion_event == odp_packet_to_event(params->pkt)) completion_event = - _odp_packet_to_buffer(params->out_pkt); + odp_packet_to_event(params->out_pkt); odp_packet_free(params->pkt); params->pkt = ODP_PACKET_INVALID; } @@ -381,7 +386,7 @@ odp_crypto_operation(odp_crypto_op_params_t *params, } /* Build Result (no HW so no errors) */ - result = get_op_result_from_buffer(completion_event); + result = get_op_result_from_event(completion_event); result->magic = OP_RESULT_MAGIC; result->cipher.alg_err = rc_cipher; result->cipher.hw_err = ODP_CRYPTO_HW_ERR_NONE; @@ -391,8 +396,7 @@ odp_crypto_operation(odp_crypto_op_params_t *params, /* If specified during creation post event to completion queue */ if (ODP_QUEUE_INVALID != session->compl_queue) { - odp_queue_enq(session->compl_queue, - odp_buffer_to_event(completion_event)); + odp_queue_enq(session->compl_queue, completion_event); *posted = 1; } return 0; @@ -432,13 +436,13 @@ odp_hw_random_get(uint8_t *buf, size_t *len, bool use_entropy ODP_UNUSED) } void -odp_crypto_get_operation_compl_status(odp_buffer_t completion_event, +odp_crypto_get_operation_compl_status(odp_event_t completion_event, odp_crypto_compl_status_t *auth, odp_crypto_compl_status_t *cipher) { odp_crypto_generic_op_result_t *result; - result = get_op_result_from_buffer(completion_event); + result = get_op_result_from_event(completion_event); if (OP_RESULT_MAGIC != result->magic) ODP_ABORT(); @@ -449,12 +453,12 @@ odp_crypto_get_operation_compl_status(odp_buffer_t completion_event, void -odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event, +odp_crypto_set_operation_compl_ctx(odp_event_t completion_event, void *ctx) { odp_crypto_generic_op_result_t *result; - result = get_op_result_from_buffer(completion_event); + result = get_op_result_from_event(completion_event); /* * Completion event magic can't be checked here, because it is filled * later in odp_crypto_operation() function. @@ -464,22 +468,22 @@ odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event, } void -*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event) +*odp_crypto_get_operation_compl_ctx(odp_event_t completion_event) { odp_crypto_generic_op_result_t *result; - result = get_op_result_from_buffer(completion_event); + result = get_op_result_from_event(completion_event); ODP_ASSERT(OP_RESULT_MAGIC == result->magic, "Bad completion magic"); return result->op_context; } odp_packet_t -odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event) +odp_crypto_get_operation_compl_packet(odp_event_t completion_event) { odp_crypto_generic_op_result_t *result; - result = get_op_result_from_buffer(completion_event); + result = get_op_result_from_event(completion_event); ODP_ASSERT(OP_RESULT_MAGIC == result->magic, "Bad completion magic"); return result->out_pkt; diff --git a/test/validation/crypto/odp_crypto_test_async_inp.c b/test/validation/crypto/odp_crypto_test_async_inp.c index b5d257d..5cc1131 100644 --- a/test/validation/crypto/odp_crypto_test_async_inp.c +++ b/test/validation/crypto/odp_crypto_test_async_inp.c @@ -25,7 +25,7 @@ static void alg_test(enum odp_crypto_op op, odp_crypto_key_t cipher_key, enum odp_auth_alg auth_alg, odp_crypto_key_t auth_key, - odp_buffer_t compl_new, + odp_event_t compl_new, uint8_t *input_vec, unsigned int input_vec_len, uint8_t *output_vec, @@ -88,12 +88,10 @@ static void alg_test(enum odp_crypto_op op, CU_FAIL("%s : not implemented for combined alg mode\n"); } - if (compl_new == ODP_BUFFER_INVALID) { - /* hack: buf is removed after crypto API update tp events */ - odp_buffer_t buf; - buf = odp_buffer_from_event(odp_packet_to_event(pkt)); - odp_crypto_set_operation_compl_ctx(buf, (void *)0xdeadbeef); - rc = odp_crypto_operation(&op_params, &posted, buf); + if (compl_new == ODP_EVENT_INVALID) { + odp_event_t ev = odp_packet_to_event(pkt); + odp_crypto_set_operation_compl_ctx(ev, (void *)0xdeadbeef); + rc = odp_crypto_operation(&op_params, &posted, ev); } else { odp_crypto_set_operation_compl_ctx(compl_new, (void *)0xdeadbeef); @@ -106,13 +104,13 @@ static void alg_test(enum odp_crypto_op op, compl_event = odp_queue_deq(compl_queue); } while (compl_event == ODP_EVENT_INVALID); - if (compl_new == ODP_BUFFER_INVALID) + if (compl_new == ODP_EVENT_INVALID) CU_ASSERT(compl_event == odp_packet_to_event(pkt)) else - CU_ASSERT(odp_buffer_from_event(compl_event) == compl_new) + CU_ASSERT(compl_event == compl_new) struct odp_crypto_compl_status auth_status, cipher_status; - odp_crypto_get_operation_compl_status(odp_buffer_from_event(compl_event), + odp_crypto_get_operation_compl_status(compl_event, &auth_status, &cipher_status); CU_ASSERT(auth_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE); CU_ASSERT(auth_status.hw_err == ODP_CRYPTO_HW_ERR_NONE); @@ -120,12 +118,12 @@ static void alg_test(enum odp_crypto_op op, CU_ASSERT(cipher_status.hw_err == ODP_CRYPTO_HW_ERR_NONE); odp_packet_t out_pkt; - out_pkt = odp_crypto_get_operation_compl_packet(odp_buffer_from_event(compl_event)); + out_pkt = odp_crypto_get_operation_compl_packet(compl_event); CU_ASSERT(out_pkt == pkt); CU_ASSERT(!memcmp(data_addr, output_vec, output_vec_len)); - void *ctx = odp_crypto_get_operation_compl_ctx(odp_buffer_from_event(compl_event)); + void *ctx = odp_crypto_get_operation_compl_ctx(compl_event); CU_ASSERT(ctx == (void *)0xdeadbeef); odp_packet_free(pkt); @@ -158,7 +156,7 @@ static void enc_alg_3des_cbc(void) cipher_key, ODP_AUTH_ALG_NULL, auth_key, - ODP_BUFFER_INVALID, + ODP_EVENT_INVALID, tdes_cbc_reference_plaintext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_ciphertext[i], @@ -190,7 +188,7 @@ static void enc_alg_3des_cbc_ovr_iv(void) cipher_key, ODP_AUTH_ALG_NULL, auth_key, - ODP_BUFFER_INVALID, + ODP_EVENT_INVALID, tdes_cbc_reference_plaintext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_ciphertext[i], @@ -227,7 +225,7 @@ static void dec_alg_3des_cbc(void) cipher_key, ODP_AUTH_ALG_NULL, auth_key, - ODP_BUFFER_INVALID, + ODP_EVENT_INVALID, tdes_cbc_reference_ciphertext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_plaintext[i], @@ -261,7 +259,7 @@ static void dec_alg_3des_cbc_ovr_iv(void) cipher_key, ODP_AUTH_ALG_NULL, auth_key, - ODP_BUFFER_INVALID, + ODP_EVENT_INVALID, tdes_cbc_reference_ciphertext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_plaintext[i], @@ -299,7 +297,7 @@ static void alg_hmac_md5(void) cipher_key, ODP_AUTH_ALG_MD5_96, auth_key, - ODP_BUFFER_INVALID, + ODP_EVENT_INVALID, hmac_md5_reference_plaintext[i], hmac_md5_reference_length[i], hmac_md5_reference_digest[i], @@ -341,7 +339,7 @@ static void enc_alg_3des_cbc_compl_new(void) cipher_key, ODP_AUTH_ALG_NULL, auth_key, - compl_new, + odp_buffer_to_event(compl_new), tdes_cbc_reference_plaintext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_ciphertext[i], diff --git a/test/validation/crypto/odp_crypto_test_sync_inp.c b/test/validation/crypto/odp_crypto_test_sync_inp.c index c527b90..08f501b 100644 --- a/test/validation/crypto/odp_crypto_test_sync_inp.c +++ b/test/validation/crypto/odp_crypto_test_sync_inp.c @@ -78,7 +78,8 @@ static void alg_test(enum odp_crypto_op op, } /* TEST : odp_crypto_operation */ - rc = odp_crypto_operation(&op_params, &posted, odp_buffer_from_event(odp_packet_to_event(pkt))); + rc = odp_crypto_operation(&op_params, &posted, + odp_packet_to_event(pkt)); CU_ASSERT(!rc); /* indication that the operation completed */ CU_ASSERT(!posted);