From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4060042A7F; Sat, 6 May 2023 18:04:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F60442D41; Sat, 6 May 2023 18:04:13 +0200 (CEST) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id 9839742D35 for ; Sat, 6 May 2023 18:04:11 +0200 (CEST) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-64388cf3263so2110846b3a.3 for ; Sat, 06 May 2023 09:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1683389050; x=1685981050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=obfMzlWi3rDn2TWW4nI66lcFKACyZD5u0VfdfRYEOtY=; b=b/YpGyWkGPJK0JNV+0mrMI/8mquTnJc5rS6S1ZcYk1IP0FnEZn6ELjaIeLW+aqjTwI MiabzY4i6XQeKBfV1CUHRd2pem8BZzZh1V/xrRN1+Su8EeniTOwys4MXJEHBfqW2M8hT 4NKRIG96P2n2S0X/cPiSTb5VHo/MX/wm+znQYbKvRK5BGxnEbLZfupnF+vUKGaQvou7G 05+9WY1AWovM+TH/MMwPoO5BLypHizlMFGpN/k7ovy+usHjkZSG6f+hg2VhS7XHQp/Nz fBrt+cUIZ0Y4V8YT+ROtOUQCDEyCRuCeuml7UYnvktNPIUrQYgIHwKsR78grJwRcw+NY 3R5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683389050; x=1685981050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=obfMzlWi3rDn2TWW4nI66lcFKACyZD5u0VfdfRYEOtY=; b=LRs1f/E0AcP0LyKA3caV8Pca7sVyopjKFVMswlHKkHhF0NLK+0wv9mQOD88uK8IVuA DyAwUExrlXfGlYwqbRLMTYwRhenuhjqFSPNlM8S8tfgiTRzv3Mu07WMygVFc2qdwtCCz o+sgl7ogySlwI/t4QVlZhVGa20xqcf/LyZ1tN8lS2PeJz6qju1fBNhM1NzS1Q6unNbIm ie4f5EZhuu0agAJXKtozUdzB2C1xpBB1U1ecWAugx6UXh+wU/I1ssDqXtzPZHSzZEFJg msVZ8osSKXy54A85nT2v/gA2VryqKaFDfJpsYGhgVDYmuuXdYvt2lOIMWecjKqeTLEzu to4g== X-Gm-Message-State: AC+VfDyJNLXSS8tBWM37ft8RAYJfGTudHDA6ah1bF3dfgEzoVq4nTQup HtYqGw2GjlBKGTbZSU/dtIhzDN5qB9rwK3fPV9AtKg== X-Google-Smtp-Source: ACHHUZ6AueJVxwHeWmOvDm3DN3nSQaUnql1RAuFq132iROONeSYTKyu+WW5sQQTtwKXuLrNrLu84Zg== X-Received: by 2002:a05:6a21:3296:b0:f5:9975:5044 with SMTP id yt22-20020a056a21329600b000f599755044mr6760884pzb.4.1683389050285; Sat, 06 May 2023 09:04:10 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id e14-20020a62ee0e000000b006436ffa3dc4sm3369890pfi.24.2023.05.06.09.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 May 2023 09:04:09 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Akhil Goyal , Fan Zhang Subject: [PATCH v2 04/14] test: cryptodev use rte_pktmbuf_mtod_offset Date: Sat, 6 May 2023 09:03:53 -0700 Message-Id: <20230506160404.7423-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230506160404.7423-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> <20230506160404.7423-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Based off patch generated by cocci/mtod-offset.cocci. With some cleanup to shorten lines by using conditional with ommited operand. Signed-off-by: Stephen Hemminger --- app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 9c670e9a3554..b4cddcd55f59 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -3151,8 +3151,9 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata) ut_params->op); ut_params->obuf = ut_params->op->sym->m_src; TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -3243,8 +3244,9 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata) ut_params->op); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); ut_params->obuf = ut_params->op->sym->m_src; - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); /* Validate obuf */ if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) @@ -3331,8 +3333,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata) ut_params->obuf = ut_params->op->sym->m_src; TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -3417,8 +3420,9 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata) ut_params->op); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); ut_params->obuf = ut_params->op->sym->m_src; - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); /* Validate obuf */ if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) @@ -4851,8 +4855,9 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata) tdata->validDataLenInBits.len, "ZUC Ciphertext data not as expected"); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -4963,8 +4968,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata) tdata->validDataLenInBits.len, "SNOW 3G Ciphertext data not as expected"); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -5129,9 +5135,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata, debug_hexdump(stdout, "ciphertext expected:", tdata->ciphertext.data, tdata->ciphertext.len >> 3); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + (tdata->digest.offset_bytes == 0 ? - plaintext_pad_len : tdata->digest.offset_bytes); + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + tdata->digest.offset_bytes ? : plaintext_pad_len); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len); @@ -5537,10 +5543,9 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata, debug_hexdump(stdout, "ciphertext expected:", tdata->ciphertext.data, tdata->ciphertext.len >> 3); - ut_params->digest = rte_pktmbuf_mtod( - ut_params->obuf, uint8_t *) + - (tdata->digest.offset_bytes == 0 ? - plaintext_pad_len : tdata->digest.offset_bytes); + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + tdata->digest.offset_bytes ? : plaintext_pad_len); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len); @@ -5878,8 +5883,9 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata) ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *, tdata->validCipherOffsetInBits.len >> 3); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); const uint8_t *reference_ciphertext = tdata->ciphertext.data + (tdata->validCipherOffsetInBits.len >> 3); @@ -6292,8 +6298,9 @@ test_zuc_authentication(const struct wireless_test_data *tdata, ut_params->op); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); ut_params->obuf = ut_params->op->sym->m_src; - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + plaintext_pad_len; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + plaintext_pad_len); if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) { /* Validate obuf */ @@ -6476,10 +6483,9 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata, debug_hexdump(stdout, "ciphertext expected:", tdata->ciphertext.data, tdata->ciphertext.len >> 3); - ut_params->digest = rte_pktmbuf_mtod( - ut_params->obuf, uint8_t *) + - (tdata->digest.offset_bytes == 0 ? - plaintext_pad_len : tdata->digest.offset_bytes); + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + tdata->digest.offset_bytes ? : plaintext_pad_len); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len); @@ -7897,9 +7903,9 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, tdata->ciphertext.data, tdata->ciphertext.len_bits >> 3); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) - + (tdata->digest_enc.offset == 0 ? - plaintext_pad_len : tdata->digest_enc.offset); + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, + tdata->digest_enc.offset ? : plaintext_pad_len); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest_enc.len); -- 2.39.2