From patchwork Sat May 6 16:03:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 126737 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6FA9642A7F; Sat, 6 May 2023 18:05:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 118E242D3A; Sat, 6 May 2023 18:04:18 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id 2E0C242D49 for ; Sat, 6 May 2023 18:04:15 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-644d9bf05b7so72317b3a.3 for ; Sat, 06 May 2023 09:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1683389054; x=1685981054; 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=QvRhXk3rillMcSGpDtB3lskZp5ZIwq//FgzWohZ426M=; b=hUMwvzgE+TKxPCddFleXjj94e4NhFc7LfO+H8Gq9Y+MNB95VTTNOdrDOozv/MBMBu1 ZOdD+WJgWlR5hN8BhdQTR5+GFsZskwGONWox0Hzda0oEgsbk7ftYRRNwRB1z0tFjvE0I Q6k2mWvx7Nv3lyVfhF4vebg8ei4rEAsKbCg3ONGHep/9O7PqcKcDMtZS+kUEXLTYTTmn r2jJ3dHJt5GA3lc+NDZwXPldYReUpMbXwl4zrBgQTBU07gjwOga7yxnLaFb67pajt1eG p4SmPIn9fwQS2wXl44DVGsinXE0W4DQuTsSlSErquB2RED2KnbC0kyOfgDkFCIYNwDxy zJXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683389054; x=1685981054; 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=QvRhXk3rillMcSGpDtB3lskZp5ZIwq//FgzWohZ426M=; b=RytdY8zPQJ254L9e7wWU0aE67CWzs1br6Fp4ArW2R/EqfAsxDKC/WmRpzTWDwLFMZe VBl2EJ26edWtw1cB4Cqsqtq0Fu36EXVSqckjE8G3i9MMPdmmi3ek6OcbrGAbZp9ELBKX VjF4Pgqv6/iDUH+ua0q0oCORLjIPBVKIQlepSVuvBXS6KRO82Muh7icwtcD19wl71BND c03VulFgSv39MHc/KQ7GECXP1UGfD7Mbl2/KbQ+jESS6vaLjbocIvOGPZ4rETg2quy1i ndrfjeSOxHJbjqZo6651Vif6csXpV0sogiSuU1Xf49NjXq5bboyUVaAcVn54GPZBYsEn ALAA== X-Gm-Message-State: AC+VfDz1CovbAxjwXafa71llib3rGTAtM39ie/tyKIPWWFDppkjsz8rr oE9KiL0IqpGWQTbu6fGUFLlBqPzPc/QQFXAz/SlXkA== X-Google-Smtp-Source: ACHHUZ6CqmF3OWJzj1N0nucr4dhTtWMaabsEI8IKmhthEztmXjz2h4LJNBe97woGya2pK3LoWA21gQ== X-Received: by 2002:aa7:88c4:0:b0:643:958e:f75 with SMTP id k4-20020aa788c4000000b00643958e0f75mr6887212pff.31.1683389054096; Sat, 06 May 2023 09:04:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 May 2023 09:04:13 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Kai Ji , Pablo de Lara Subject: [PATCH v2 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset Date: Sat, 6 May 2023 09:03:57 -0700 Message-Id: <20230506160404.7423-9-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 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 Initial patch generated with cocci/mtod-offset. Additional manual cleanups to indentation and remove unnecessary parenthesis. Signed-off-by: Stephen Hemminger Acked-by: Pablo de Lara --- 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 8ed069f42860..f6e51916e1fd 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);