From patchwork Fri May 5 17:48:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 126711 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 E42F642A49; Fri, 5 May 2023 19:49:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A73242D5E; Fri, 5 May 2023 19:48:28 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 74A5D42D56 for ; Fri, 5 May 2023 19:48:26 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6439df6c268so798483b3a.0 for ; Fri, 05 May 2023 10:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1683308906; x=1685900906; 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=QyAcb+/FNo42NhkMF4xf2e96mfx1+o69kny/GCR6mh6D0sgpHK0w6HnLZXewx6vO7/ N78XCMdR+EZl9CFVqUTQd57IsoCA0lAf13poMCdUTHrqkW6Qbkh5P7umNM7yJW/f73gr w6eZGjWcjRj00kwHSEs5j6q9Dh2blNuU8QN7w7dz9G6ycDZBKqIlqGDN7ob+mYSaQrqX LHYsjIuKaXKYbmZc3kGNQh20iCqwRDLnCqWzceHJKYgYjLfMl5VsA9U/xN3Ov5/eDNaf fg3Cy95ujYFLV1mbGwAngZbd9GMPJ76uqWLsjgcywg1wzlptH78g6omrDpUehggzxtQz +yBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683308906; x=1685900906; 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=Z22fBjG+vPQtPIMmJeHSr58wpVrxOc+dTOzeSh3As9kTE8rwD9jaENp61gH6RlkUr5 deULU5XUtt28qDDFqKPXEs4fLO3SxXWdsQv84gwrjMDS4Zmwchm7vWxvZ3Zr3YeylME6 V09VmWEdFcABFNE0Q7KtUnTyluvQ5tpjqrgpHG75i7s1UyZczcdHTcoBQ7iJqm85Dxfw UhXyWTYJIdDWG3+A+U4s4qKPDK5vPDQ/K1db0g/GuOd0QddAv5nTSEgZ6ys65wvQfFpJ HrD72dG/8JRssu6hoIykxEDm68I62IzIE+HfV9QEqMI4kEum6upDmjSNd/N9Yq6se6pF hFVA== X-Gm-Message-State: AC+VfDwUm89dYruc9lt07avQ+H0YV6ss0mRY8reSiIjqT2tmnudVRW7J pfN4IVcaqSpKAXYxUsgEN6KPw7H42/IN2DygVSrYkA== X-Google-Smtp-Source: ACHHUZ7sc9C3ef0c+8g3aHFxqV0hL+RMF9wgwXDxemrpw7Vh/BzrgyxTtUts5xNrh3PKkfithjsh3w== X-Received: by 2002:a05:6a00:10d2:b0:643:96bc:b292 with SMTP id d18-20020a056a0010d200b0064396bcb292mr3220169pfu.5.1683308905707; Fri, 05 May 2023 10:48:25 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id a15-20020aa780cf000000b0063799398eb9sm1895707pfn.58.2023.05.05.10.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 10:48:24 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Kai Ji , Pablo de Lara Subject: [PATCH 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset Date: Fri, 5 May 2023 10:48:07 -0700 Message-Id: <20230505174813.133894-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505174813.133894-1-stephen@networkplumber.org> References: <20230505174813.133894-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 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);