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 04EFF42DFC; Sat, 8 Jul 2023 03:57:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CF8442BFE; Sat, 8 Jul 2023 03:57:27 +0200 (CEST) Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) by mails.dpdk.org (Postfix) with ESMTP id 9C4164111C for ; Sat, 8 Jul 2023 03:57:24 +0200 (CEST) Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-1b3ff2460ecso2415672fac.0 for ; Fri, 07 Jul 2023 18:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688781443; x=1691373443; 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=pVMuYYiXPDWiOv2Z+Jz+R2cT4LitVH5X/rhmxyaEYlY=; b=yg93lInOtp1UxZt3JcpLufzyi8JWatlNnw07rxGbb6DVTUg+5qveqUgakELOhLbSNL KEe26FJAAxKc0H0uqlnEoIo0QilviNKh+1sEyAspZ0WU2g63WfpRmmES2fET6QT3/mco Uvlie9jD/7mg0mTBU8QP8f2qYb1NuhVvLg7eBJ5peqxlvwm2hZLGLcKBh7pef0Rr46Y9 MhfP9LiZ+c1mVgmrbWBAZPbVgsFhQKhaqrafnEDmExL0iw42pQacQAYO51SWrdK8+8PL bBlou6Nw7JdZxv670uv5mN1d3EaOr8oDDf7CmA/CGCFuwYDoiutwEo+fpL3AfQZw23lH GacA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688781443; x=1691373443; 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=pVMuYYiXPDWiOv2Z+Jz+R2cT4LitVH5X/rhmxyaEYlY=; b=Xy1hO/YKmdNxGjKT2ine/oZpkmfE/X1TIiR/OgyIrJ8SUsKBLCSVoM3yhAtAFSJyjT hIPTZzcz4JpTkUfILM6S9zEpa+NDlna6axO0HqYTBbg6gZQZlfThsBM4uCeQ0HtrfZhP lNLLPM+gB4nBU0iA4vp7n3Vsq5rqbD8lWRypvRtz5JocOOY08oVxOhUIpfOeTd2jh4x6 KiL5OQAR58M4JrSiLG8NIYKsNk6MvLlkmdvA1E0+HdHqVCTY94sQ25ivRjBJwrwuGYfm KQPyvOLa58K6/Bv6FPtS/7BgelxD603Ue0Z0C1f+MWtPQSbipOqe2SO15UQlDSgOOtDi rVtQ== X-Gm-Message-State: ABy/qLZzGZiw/s6by6idJghOng+ZBLorKg91ElaN5qkI0YV2s4Gg2aPc CtcCooKkilykfcmo/LXYrMPeGzkmu+wN6D80EHoQRkJJ X-Google-Smtp-Source: APBJJlF5SYQ6RsDbDV3xcUHjog1jhgCCLr7xQ6gwYyQzbKLu3OuDZh+u6viZp5o9Ttv6/ALGvULKvg== X-Received: by 2002:a05:6870:e410:b0:1b4:624a:105b with SMTP id n16-20020a056870e41000b001b4624a105bmr2843735oag.10.1688781443697; Fri, 07 Jul 2023 18:57:23 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id 24-20020a17090a035800b00263f5ac814esm2260269pjf.38.2023.07.07.18.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 18:57:23 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Akhil Goyal , Fan Zhang Subject: [PATCH v5 03/11] test/crypto_dev: use rte_pktmbuf_mtod_offset Date: Fri, 7 Jul 2023 18:57:10 -0700 Message-Id: <20230708015718.75565-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230708015718.75565-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> <20230708015718.75565-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 Replace explicit packet offset computations with rte_pktmbuf_mtod_offset(). Signed-off-by: Stephen Hemminger --- app/test/test_cryptodev.c | 83 +++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index fb2af40b99ee..549afe252d54 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -3153,8 +3153,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( @@ -3247,8 +3248,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) @@ -3337,8 +3339,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( @@ -3425,8 +3428,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) @@ -4879,8 +4883,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( @@ -4994,8 +4999,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( @@ -5020,6 +5026,7 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata, unsigned int plaintext_len; unsigned int ciphertext_pad_len; unsigned int ciphertext_len; + unsigned int digest_offset; struct rte_cryptodev_info dev_info; @@ -5163,9 +5170,12 @@ 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); + if (tdata->digest.offset_bytes == 0) + digest_offset = plaintext_pad_len; + else + digest_offset = tdata->digest.offset_bytes; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, digest_offset); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len); @@ -5432,6 +5442,7 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata, unsigned int plaintext_len; unsigned int ciphertext_pad_len; unsigned int ciphertext_len; + unsigned int digest_offset; struct rte_cryptodev_info dev_info; @@ -5577,10 +5588,12 @@ 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); + if (tdata->digest.offset_bytes == 0) + digest_offset = plaintext_pad_len; + else + digest_offset = tdata->digest.offset_bytes; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, digest_offset); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len); @@ -5924,8 +5937,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); @@ -6344,8 +6358,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 */ @@ -6380,6 +6395,7 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata, unsigned int plaintext_len; unsigned int ciphertext_pad_len; unsigned int ciphertext_len; + unsigned int digest_offset; struct rte_cryptodev_info dev_info; @@ -6531,10 +6547,12 @@ 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); + if (tdata->digest.offset_bytes == 0) + digest_offset = plaintext_pad_len; + else + digest_offset = tdata->digest.offset_bytes; + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, digest_offset); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len); @@ -7819,6 +7837,7 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, unsigned int plaintext_len; unsigned int ciphertext_pad_len; unsigned int ciphertext_len; + unsigned int digest_offset; struct rte_cryptodev_info dev_info; struct rte_crypto_op *op; @@ -7959,9 +7978,13 @@ 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); + if (tdata->digest_enc.offset == 0) + digest_offset = plaintext_pad_len; + else + digest_offset = tdata->digest_enc.offset; + + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf, + uint8_t *, digest_offset); debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest_enc.len); -- 2.39.2