[PATCH v3 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
Stephen Hemminger
stephen at networkplumber.org
Thu Jul 6 19:59:32 CEST 2023
Initial patch generated with cocci/mtod-offset.
Additional manual cleanups to indentation and remove unnecessary
parenthesis.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/crypto/ipsec_mb/pmd_kasumi.c | 16 ++++++-------
drivers/crypto/ipsec_mb/pmd_snow3g.c | 35 +++++++++++-----------------
drivers/crypto/ipsec_mb/pmd_zuc.c | 16 ++++++-------
3 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..5b1694276468 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -83,13 +83,13 @@ process_kasumi_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
uint32_t num_bytes[num_ops];
for (i = 0; i < num_ops; i++) {
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst
- ? rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3)
- : rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ ? rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3)
+ : rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
iv[i] = *((uint64_t *)(iv_ptr));
@@ -155,8 +155,8 @@ process_kasumi_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
/* Direction from next bit after end of message */
num_bytes = length_in_bits >> 3;
diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index e64df1a462e3..90b8d80c2c56 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -111,14 +111,12 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off = ops[i]->sym->cipher.data.offset >> 3;
cipher_len = ops[i]->sym->cipher.data.length >> 3;
- src[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *, cipher_off);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *, cipher_off);
/* If out-of-place operation */
if (ops[i]->sym->m_dst &&
ops[i]->sym->m_src != ops[i]->sym->m_dst) {
- dst[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *, cipher_off);
/* In case of out-of-place, auth-cipher operation
* with partial encryption of the digest, copy
@@ -133,16 +131,14 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off - cipher_len;
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
cipher_off + cipher_len),
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
cipher_off + cipher_len),
unencrypted_bytes);
} else
- dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src,
- uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ cipher_off);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
@@ -205,13 +201,11 @@ process_snow3g_cipher_op_bit(struct ipsec_mb_qp *qp,
(length_in_bits >> 3);
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- op->sym->m_dst, uint8_t *,
- (length_in_bits >> 3)),
- rte_pktmbuf_mtod_offset(
- op->sym->m_src, uint8_t *,
- (length_in_bits >> 3)),
- unencrypted_bytes);
+ rte_pktmbuf_mtod_offset(op->sym->m_dst, uint8_t *,
+ length_in_bits >> 3),
+ rte_pktmbuf_mtod_offset(op->sym->m_src, uint8_t *,
+ length_in_bits >> 3),
+ unencrypted_bytes);
iv = rte_crypto_op_ctod_offset(op, uint8_t *,
session->cipher_iv_offset);
@@ -248,8 +242,8 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->auth_iv_offset);
@@ -261,8 +255,7 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
session->op ==
IPSEC_MB_OP_DECRYPT_THEN_HASH_VERIFY) &&
ops[i]->sym->m_dst != NULL)
- src = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
ops[i]->sym->auth.data.offset >> 3);
IMB_SNOW3G_F9_1_BUFFER(qp->mb_mgr,
diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c
index 92fd9d180894..65b00e80390e 100644
--- a/drivers/crypto/ipsec_mb/pmd_zuc.c
+++ b/drivers/crypto/ipsec_mb/pmd_zuc.c
@@ -107,13 +107,13 @@ process_zuc_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
}
#endif
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst ?
- rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3) :
- rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3) :
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->cipher_iv_offset);
num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
@@ -159,8 +159,8 @@ process_zuc_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits[i] = ops[i]->sym->auth.data.length;
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->auth_iv_offset);
--
2.39.2
More information about the dev
mailing list