From patchwork Thu Jul 6 17:59:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 129358 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 5C58042DEC; Thu, 6 Jul 2023 20:00:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3394C43025; Thu, 6 Jul 2023 19:59:53 +0200 (CEST) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id A839943013 for ; Thu, 6 Jul 2023 19:59:49 +0200 (CEST) Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2633fe9b6c0so1562399a91.1 for ; Thu, 06 Jul 2023 10:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688666388; x=1691258388; 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=yFo23NqGGV1OFDtS9nAxYN+AigYTvhxy3IyacoRh6Xs=; b=SrMSMaRgjqeFIwS3xAJM/YMne13LILcc9Ms/7l361U1GSULnyRW4iUyc8rcGL0/nHa eT22nu+I4pKBC9RTyqHqZMh9IZco6sEHp63mIPikqGjBn6XtISaW8bFJath70+85xEr2 FBABjGUIqdrAkuJFWGL2DoWcYTp+8BNlAZUs9qLFljTAxdrvl9Hjwcyb/lJmt7O0h61k mOiRtrtpARVkUWfhw2RyEDUPzp9IYe6+2Gg1oWhGp1UlJBr/Dmk9sJje+U0AbdSeblD0 Hq1UahXHj3M0b//KtLXJpFlsGeelZzP44KB0ReJ/gsXmUcXNy9Jxm6ufU/IQKpkOl7zZ rQlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688666388; x=1691258388; 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=yFo23NqGGV1OFDtS9nAxYN+AigYTvhxy3IyacoRh6Xs=; b=EvpbDUmLC+VwYi5XhjJVFqYX7CeAGzaUUaXT6HZf/xQiPdSIGmq0zRutFLpXp9n3RW 0FL1qyjkuJvjgfUPgBFiPDYmcxb2f8BYy2sMYrUaoD/g0Alf2bqujrFw3fKaDdpQeBRb wJoSshXDiI122la7yErWw3WRh13MjJE7vfDvj+EKyh1OSu/wJxT4BzInjOtnftE4YiKQ 99WD1Z4/KH6o7GUQDgRlSmgcj+yA8/kzlzGocQDYAhe7fau+e/LbE8BNatZ/vh7KNLcN izDUB/WhILX4FV5MWUZepHBcgA5oSfejGN+uXvUIZAYbkKcRq1nbQRJtaJLMa8KG6l8J YXEg== X-Gm-Message-State: ABy/qLZ2pMjPCi/AXgkySWM1Ld3rxq4KNVuKQU2O3vFFOxAKaoDXWcg3 kGUb0Dy5hMHwJ6JSswcl+lNZLTKiConJ67Z68Lg= X-Google-Smtp-Source: APBJJlHtd2jGwG1z7uvoqqiUbRPAFvxtxg81/CpyFMl14i94SIAkPCGXEd9v/XwDNekOFYfGsyUGtw== X-Received: by 2002:a17:90a:f40a:b0:263:f674:490e with SMTP id ch10-20020a17090af40a00b00263f674490emr7592288pjb.3.1688666388226; Thu, 06 Jul 2023 10:59:48 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id nh8-20020a17090b364800b00256bbfbabcfsm76464pjb.48.2023.07.06.10.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jul 2023 10:59:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Kai Ji , Pablo de Lara Subject: [PATCH v3 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset Date: Thu, 6 Jul 2023 10:59:32 -0700 Message-Id: <20230706175938.62721-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230706175938.62721-1-stephen@networkplumber.org> References: <20230505174813.133894-1-stephen@networkplumber.org> <20230706175938.62721-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 --- 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);