From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Akhil Goyal <gakhil@marvell.com>,
Fan Zhang <fanzhang.oss@gmail.com>
Subject: [PATCH v5 03/11] test/crypto_dev: use rte_pktmbuf_mtod_offset
Date: Fri, 7 Jul 2023 18:57:10 -0700 [thread overview]
Message-ID: <20230708015718.75565-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20230708015718.75565-1-stephen@networkplumber.org>
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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
next prev parent reply other threads:[~2023-07-08 1:57 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-05 17:48 ` [PATCH 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-05 17:48 ` [PATCH 02/14] gso: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 03/14] testpmd: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 04/14] test: cryptodev " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 05/14] examples: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 06/14] net/tap: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 07/14] net/nfp: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 08/14] crypto/ipsec_mb: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 09/14] crypto/qat: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
2023-05-05 17:48 ` [PATCH 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-05 17:48 ` [PATCH 12/14] crypto/caam_jr: " Stephen Hemminger
2023-05-09 11:43 ` Hemant Agrawal
2023-05-05 17:48 ` [PATCH 13/14] net/mlx4: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 02/14] gso: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 03/14] testpmd: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 04/14] test: cryptodev " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 05/14] examples: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 06/14] net/tap: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 07/14] net/nfp: " Stephen Hemminger
2023-05-09 13:35 ` Niklas Söderlund
2023-05-06 16:03 ` [PATCH v2 08/14] crypto/ipsec_mb: " Stephen Hemminger
2023-05-29 12:47 ` De Lara Guarch, Pablo
2023-05-06 16:03 ` [PATCH v2 09/14] crypto/qat: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 12/14] crypto/caam_jr: " Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 13/14] net/mlx4: " Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 02/14] gso: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 03/14] testpmd: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 04/14] test: cryptodev " Stephen Hemminger
2023-07-07 12:46 ` Ferruh Yigit
2023-07-07 20:32 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 05/14] examples: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 06/14] net/tap: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 07/14] net/nfp: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 08/14] crypto/ipsec_mb: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 09/14] crypto/qat: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 12/14] crypto/caam_jr: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 13/14] net/mlx4: " Stephen Hemminger
2023-07-07 12:46 ` Ferruh Yigit
2023-07-06 17:59 ` [PATCH v3 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
2023-07-07 12:47 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Ferruh Yigit
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 02/11] gso: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 03/11] test: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 04/11] drivers/crypto: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 05/11] net/nfp: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 09/11] testpmd: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 10/11] examples/ptpclient: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 11/11] examples/l2fwd-crypto: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 02/11] gso: " Stephen Hemminger
2023-07-08 1:57 ` Stephen Hemminger [this message]
2023-07-08 1:57 ` [PATCH v5 04/11] drivers/crypto: " Stephen Hemminger
2023-07-11 5:34 ` [EXT] " Anoob Joseph
2023-07-12 14:56 ` Hemant Agrawal
2023-07-08 1:57 ` [PATCH v5 05/11] net/nfp: " Stephen Hemminger
2023-07-10 12:19 ` Niklas Söderlund
2024-01-24 13:44 ` Thomas Monjalon
2023-07-08 1:57 ` [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
2024-01-24 13:47 ` Thomas Monjalon
2023-07-08 1:57 ` [PATCH v5 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-11 5:35 ` [EXT] " Anoob Joseph
2023-07-08 1:57 ` [PATCH v5 09/11] testpmd: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 10/11] examples/ptpclient: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 11/11] examples/l2fwd-crypto: " Stephen Hemminger
2023-07-09 3:54 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset fengchengwen
2024-01-24 14:55 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230708015718.75565-4-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=fanzhang.oss@gmail.com \
--cc=gakhil@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).