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 4DF5142DFC; Fri, 7 Jul 2023 22:39:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2907B42D0E; Fri, 7 Jul 2023 22:39:19 +0200 (CEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id 78968411F3 for ; Fri, 7 Jul 2023 22:39:16 +0200 (CEST) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1b9cd6a0051so1167225ad.1 for ; Fri, 07 Jul 2023 13:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688762355; x=1691354355; 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=AlLKomwYSQSLF+t+bBhNWFBQ+maS7GUN7rYNCJ7Iq7I=; b=CINj1QbqCPuBDmPAO9N1s6YuTWpBrxxKPWhhDY7micARu/3XrCImmQB+pvICMmwfbN +JV0nt6IcjTHx1DztEpgJTCR0oij92N4dzNZPToVup9Drd1eKHpqxxdk8pQRPtL8Qe7D AMv0gPz3TKt16q7oYk/4Q/88wxpyEu6R7q74TJAiLuQ9PjvNC1ooyKRCiwINDGzkB4iS rvOkcATBMrC7WOtdnfKACJ/4QffNRe1xnk/jISisLuw/Te68Uxf2dTuq6+rfxpwVbbNo Pd2/pzwpuHwMxcIf6hA4CIcOVw7woHauspj4epW6+X0rbTrO4955T2FaLuV0kxx7J5My 7JoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762355; x=1691354355; 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=AlLKomwYSQSLF+t+bBhNWFBQ+maS7GUN7rYNCJ7Iq7I=; b=b66Z1d44SbEHbBaovYze+rCFshGdA/EwLWmGh7dNOP1oE32VdITqpW6igyPaxQHbLH D0R1SCLRJnx/vmQ5JLKDtYQjJ9vFTB75iHFXQoCEQLeqeafX+uOfgQs0+guDW9iCWGOI zHmbHK0TQ9ru7F9TnUYS3+LLOM9HyCybuaDwbNgSZchVx4QLvxVkgnJI4NCC/v3YC1CP E6o38SFnN/tmweNxyo6jNTEVKumn4ZpAvav6Ec94/d+fOJoll/cxT03CkCpsWDlFX1Z3 lhMSYj/ICo024REq+SZRbqDqyefUmOQCGLZxUvZcBkVsYx6385/S0TIsEnUjm+56nXeV SmDA== X-Gm-Message-State: ABy/qLYTzVvzxT/Zp0MngikFLn4UGE1FfO2BLOpvdh4MDobXdHAi2SEc QhN/a9ZrwkPH5XGOi1HkJt/SIFJVbLZk+fo5rGqgxziz X-Google-Smtp-Source: APBJJlEyKHm4O6bIxFp4Uopx8Ob595V/lOF+2ReP5a3eVSAObnFAYc0hdcmOBuf2BTwguKeD0EdTkw== X-Received: by 2002:a17:902:c20c:b0:1b0:6c3e:363 with SMTP id 12-20020a170902c20c00b001b06c3e0363mr5159643pll.0.1688762355342; Fri, 07 Jul 2023 13:39:15 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id t15-20020a170902b20f00b001b83db0bcf2sm3640493plr.141.2023.07.07.13.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:39:14 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Gagandeep Singh , Hemant Agrawal , Ankur Dwivedi , Anoob Joseph , Tejasree Kondoj , Kai Ji , Pablo de Lara Subject: [PATCH v4 04/11] drivers/crypto: use rte_pktmbuf_mtod_offset Date: Fri, 7 Jul 2023 13:39:01 -0700 Message-Id: <20230707203908.64371-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230707203908.64371-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> <20230707203908.64371-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 --- drivers/crypto/caam_jr/caam_jr.c | 8 ++++---- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 +- drivers/crypto/cnxk/cnxk_se.h | 5 ++--- drivers/crypto/ipsec_mb/pmd_kasumi.c | 19 +++++++++++-------- drivers/crypto/ipsec_mb/pmd_snow3g.c | 4 ++-- drivers/crypto/ipsec_mb/pmd_zuc.c | 18 ++++++++++-------- drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 9 +++++---- drivers/crypto/qat/qat_sym.h | 9 +++++---- 8 files changed, 40 insertions(+), 34 deletions(-) diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c index b55258689b49..9c96fd21a48d 100644 --- a/drivers/crypto/caam_jr/caam_jr.c +++ b/drivers/crypto/caam_jr/caam_jr.c @@ -631,15 +631,15 @@ hw_poll_job_ring(struct sec_job_ring_t *job_ring, if (ctx->op->sym->m_dst) { /*TODO check for ip header or other*/ - ip4_hdr = (struct ip *) - rte_pktmbuf_mtod(ctx->op->sym->m_dst, char*); + ip4_hdr = rte_pktmbuf_mtod(ctx->op->sym->m_dst, + struct ip *); ctx->op->sym->m_dst->pkt_len = rte_be_to_cpu_16(ip4_hdr->ip_len); ctx->op->sym->m_dst->data_len = rte_be_to_cpu_16(ip4_hdr->ip_len); } else { - ip4_hdr = (struct ip *) - rte_pktmbuf_mtod(ctx->op->sym->m_src, char*); + ip4_hdr = rte_pktmbuf_mtod(ctx->op->sym->m_src, + struct ip *); ctx->op->sym->m_src->pkt_len = rte_be_to_cpu_16(ip4_hdr->ip_len); ctx->op->sym->m_src->data_len = diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c index 34d40b07d4c6..8b91d11b79cc 100644 --- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c @@ -520,7 +520,7 @@ cn9k_cpt_sec_post_process(struct rte_crypto_op *cop, if (infl_req->op_flags & CPT_OP_FLAGS_IPSEC_DIR_INBOUND) { - hdr = (struct roc_ie_on_inb_hdr *)rte_pktmbuf_mtod(m, char *); + hdr = rte_pktmbuf_mtod(m, struct roc_ie_on_inb_hdr *); if (likely(m->next == NULL)) { ip = PLT_PTR_ADD(hdr, ROC_IE_ON_INB_RPTR_HDR); diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index 75c1dce231bf..1392af5833d1 100644 --- a/drivers/crypto/cnxk/cnxk_se.h +++ b/drivers/crypto/cnxk/cnxk_se.h @@ -2724,7 +2724,7 @@ fill_fc_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, m = cpt_m_dst_get(cpt_op, m_src, m_dst); /* Digest immediately following data is best case */ - if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) + mc_hash_off != + if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) != (uint8_t *)sym_op->aead.digest.data)) { flags |= ROC_SE_VALID_MAC_BUF; fc_params.mac_buf.size = sess->mac_len; @@ -2759,8 +2759,7 @@ fill_fc_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, /* hmac immediately following data is best case */ if (!(op_minor & ROC_SE_FC_MINOR_OP_HMAC_FIRST) && - (unlikely(rte_pktmbuf_mtod(m, uint8_t *) + - mc_hash_off != + (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) != (uint8_t *)sym_op->auth.digest.data))) { flags |= ROC_SE_VALID_MAC_BUF; fc_params.mac_buf.size = sess->mac_len; diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c index 5db9c523cd9a..70536ec3dc2a 100644 --- a/drivers/crypto/ipsec_mb/pmd_kasumi.c +++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c @@ -83,13 +83,16 @@ 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 +158,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..a96779f05942 100644 --- a/drivers/crypto/ipsec_mb/pmd_snow3g.c +++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c @@ -248,8 +248,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); diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c index 92fd9d180894..44781be1d107 100644 --- a/drivers/crypto/ipsec_mb/pmd_zuc.c +++ b/drivers/crypto/ipsec_mb/pmd_zuc.c @@ -107,13 +107,14 @@ 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 +160,9 @@ 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); diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h index 1bafeb4a53e8..3e0dfea94c87 100644 --- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h +++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h @@ -56,14 +56,15 @@ qat_bpicipher_preprocess(struct qat_sym_session *ctx, uint8_t *last_block, *dst, *iv; uint32_t last_block_offset = sym_op->cipher.data.offset + sym_op->cipher.data.length - last_block_len; - last_block = (uint8_t *) rte_pktmbuf_mtod_offset(sym_op->m_src, - uint8_t *, last_block_offset); + last_block = rte_pktmbuf_mtod_offset(sym_op->m_src, uint8_t *, + last_block_offset); if (unlikely((sym_op->m_dst != NULL) && (sym_op->m_dst != sym_op->m_src))) /* out-of-place operation (OOP) */ - dst = (uint8_t *) rte_pktmbuf_mtod_offset(sym_op->m_dst, - uint8_t *, last_block_offset); + dst = rte_pktmbuf_mtod_offset(sym_op->m_dst, + uint8_t *, + last_block_offset); else dst = last_block; diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h index 193281cd9135..d7ceb13b29cd 100644 --- a/drivers/crypto/qat/qat_sym.h +++ b/drivers/crypto/qat/qat_sym.h @@ -192,13 +192,14 @@ qat_bpicipher_postprocess(struct qat_sym_session *ctx, last_block_offset = sym_op->cipher.data.offset + sym_op->cipher.data.length - last_block_len; - last_block = (uint8_t *) rte_pktmbuf_mtod_offset(sym_op->m_src, - uint8_t *, last_block_offset); + last_block = rte_pktmbuf_mtod_offset(sym_op->m_src, uint8_t *, + last_block_offset); if (unlikely(sym_op->m_dst != NULL)) /* out-of-place operation (OOP) */ - dst = (uint8_t *) rte_pktmbuf_mtod_offset(sym_op->m_dst, - uint8_t *, last_block_offset); + dst = rte_pktmbuf_mtod_offset(sym_op->m_dst, + uint8_t *, + last_block_offset); else dst = last_block; -- 2.39.2