From patchwork Fri Jan 23 11:42:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 43620 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0A03240D9 for ; Fri, 23 Jan 2015 11:43:55 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id m14sf3927075wev.3 for ; Fri, 23 Jan 2015 03:43:55 -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=i7Y7FTEYEhoTxD1ej/46VRLCccskNXEZs7oyK2fGvjpOjV8Aq3iIjHhXZSouuz0cQf q/5dkaVX0Yld9kF+KUSQ0cfH3K8WE5ZZDogwIKeIHnbIImjCKIedPfwxEuLLaF0Jh/mj 8PfRqPRYsRx0MWy3wIP7+mvpkOHJuY51HwITGPzU5J8ezI6DdicCBypX6H4YGl+uqTIW Gdp4yLy7U3d6UVn3Kzc/OnqJl0bJb0WvZVSoHNqtVnzuXfi/r4d5jCDgkMJMbJ9DFi+z MrqqtgS9CvrevrAGHKA5Uem23+kTQ/9CQxz5xbKG+3VKKvvc2snZIrflHBdVtalzdFz0 b82A== X-Gm-Message-State: ALoCoQlY0nlQvG+d9NhXmpnB6CIbWJXFfaclSro35Zio0QKYNki4Dwjm3nM9OPWqX2wqCmvqYtNB X-Received: by 10.152.121.65 with SMTP id li1mr930886lab.0.1422013435117; Fri, 23 Jan 2015 03:43:55 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.202.198 with SMTP id kk6ls248862lac.103.gmail; Fri, 23 Jan 2015 03:43:54 -0800 (PST) X-Received: by 10.112.235.67 with SMTP id uk3mr6865553lbc.48.1422013434897; Fri, 23 Jan 2015 03:43:54 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id g1si1173518lag.18.2015.01.23.03.43.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 03:43:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id s18so908341lam.3 for ; Fri, 23 Jan 2015 03:43:54 -0800 (PST) X-Received: by 10.152.44.228 with SMTP id h4mr5756653lam.31.1422013434821; Fri, 23 Jan 2015 03:43:54 -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 c8csp220984lbb; Fri, 23 Jan 2015 03:43:53 -0800 (PST) X-Received: by 10.229.249.137 with SMTP id mk9mr13156701qcb.4.1422013431683; Fri, 23 Jan 2015 03:43:51 -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 z5si1692331qab.9.2015.01.23.03.43.48 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Jan 2015 03:43:51 -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 1YEceR-0003SO-6d; Fri, 23 Jan 2015 11:43:47 +0000 Received: from mail-qg0-f42.google.com ([209.85.192.42]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YEcdx-0003Mh-CS for lng-odp@lists.linaro.org; Fri, 23 Jan 2015 11:43:17 +0000 Received: by mail-qg0-f42.google.com with SMTP id q107so5613309qgd.1 for ; Fri, 23 Jan 2015 03:43:12 -0800 (PST) X-Received: by 10.140.100.234 with SMTP id s97mr12503786qge.96.1422013392094; Fri, 23 Jan 2015 03:43:12 -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 f7sm1182892qaq.42.2015.01.23.03.43.10 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Jan 2015 03:43:11 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Fri, 23 Jan 2015 13:42:18 +0200 Message-Id: <1422013344-6655-11-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422013344-6655-1-git-send-email-petri.savolainen@linaro.org> References: <1422013344-6655-1-git-send-email-petri.savolainen@linaro.org> X-Topics: crypto patch Subject: [lng-odp] [PATCH v4 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.215.44 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);