From patchwork Tue Jan 20 11:18:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 43354 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A75222034D for ; Tue, 20 Jan 2015 11:19:58 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf6611286wiv.0 for ; Tue, 20 Jan 2015 03:19:58 -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=xat5J5BpK1IQI+/GFe9Xf2SS2PtxlWVaQOjOi1nE+is=; b=DxeyeXdk4jvO5Rmnl0elxT4XTG7hfwWbpJDWlRxRuA+dZoErUrOk5mRq5kgavMJe+P tsDJQQ0y14Jk66bMMMjkXz3YHENug5pCwgkFQQqhLZiIN1MxclYy/Vo2bntANI3rlk/e hTxwZH9z42DKGO1zCCOTjv0XcA+bKDgTx/jQ4R+VL9bKAscEfPNYMGYMsiAp6N8eeJHI SYjyfTPz5pF1/s8eExZbuVl3jLJOV7PM0ocdGPbG5TIxmZiSxYRldcTBRknNLEjqyK4C y8a+KPJ7S3Wcwh3UNU1cbJVxrBThbsgcLhKdf2l/wqEBmzdWlD5pagDYFnkY+MKUoo+J 6nZQ== X-Gm-Message-State: ALoCoQmGuQ0bhiqZjtljqWjo1MxpyM/qwBMT0MGinHjvwp0LIlkV7IPrhNibdOVRpazNxJHDhpsn X-Received: by 10.112.37.72 with SMTP id w8mr1468128lbj.6.1421752797942; Tue, 20 Jan 2015 03:19:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.220.164 with SMTP id px4ls662193lac.34.gmail; Tue, 20 Jan 2015 03:19:57 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr37302252lac.6.1421752797789; Tue, 20 Jan 2015 03:19:57 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id sg5si14969696lbb.19.2015.01.20.03.19.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 03:19:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id z12so12217936lbi.7 for ; Tue, 20 Jan 2015 03:19:57 -0800 (PST) X-Received: by 10.112.173.202 with SMTP id bm10mr28763579lbc.24.1421752797693; Tue, 20 Jan 2015 03:19:57 -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 c8csp1380891lbb; Tue, 20 Jan 2015 03:19:56 -0800 (PST) X-Received: by 10.224.121.142 with SMTP id h14mr57149504qar.80.1421752795969; Tue, 20 Jan 2015 03:19:55 -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 ee7si1880459qcb.31.2015.01.20.03.19.54 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 20 Jan 2015 03:19:55 -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 1YDWqe-0006LQ-L6; Tue, 20 Jan 2015 11:19:52 +0000 Received: from mail-qa0-f42.google.com ([209.85.216.42]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDWqD-0006F0-Qu for lng-odp@lists.linaro.org; Tue, 20 Jan 2015 11:19:25 +0000 Received: by mail-qa0-f42.google.com with SMTP id dc16so27641048qab.1 for ; Tue, 20 Jan 2015 03:19:20 -0800 (PST) X-Received: by 10.224.64.136 with SMTP id e8mr55136965qai.41.1421752760689; Tue, 20 Jan 2015 03:19:20 -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 t2sm14975907qae.6.2015.01.20.03.19.18 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 03:19:19 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Tue, 20 Jan 2015 13:18:06 +0200 Message-Id: <1421752692-24439-11-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421752692-24439-1-git-send-email-petri.savolainen@linaro.org> References: <1421752692-24439-1-git-send-email-petri.savolainen@linaro.org> X-Topics: crypto patch Subject: [lng-odp] [PATCH v2 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.176 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 | 26 ++++++++--------- test/validation/crypto/odp_crypto_test_async_inp.c | 33 +++++++++++----------- test/validation/crypto/odp_crypto_test_sync_inp.c | 3 +- 5 files changed, 43 insertions(+), 43 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 ab76484..463f7b4 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -344,7 +344,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 +364,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 +381,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_buffer(odp_buffer_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,7 +391,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; @@ -431,13 +431,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_buffer(odp_buffer_from_event(completion_event)); if (OP_RESULT_MAGIC != result->magic) ODP_ABORT(); @@ -448,12 +448,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_buffer(odp_buffer_from_event(completion_event)); /* * Completion event magic can't be checked here, because it is filled * later in odp_crypto_operation() function. @@ -463,22 +463,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_buffer(odp_buffer_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_buffer(odp_buffer_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 e771b2c..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,11 +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 = 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); @@ -105,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); @@ -119,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); @@ -157,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], @@ -189,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], @@ -226,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], @@ -260,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], @@ -298,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], @@ -340,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);