From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 3FE1042DFC;
	Sat,  8 Jul 2023 03:58:28 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3C8A342D50;
	Sat,  8 Jul 2023 03:57:37 +0200 (CEST)
Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com
 [209.85.161.46]) by mails.dpdk.org (Postfix) with ESMTP id B30EF42D39
 for <dev@dpdk.org>; Sat,  8 Jul 2023 03:57:32 +0200 (CEST)
Received: by mail-oo1-f46.google.com with SMTP id
 006d021491bc7-5634db21a78so1921329eaf.0
 for <dev@dpdk.org>; Fri, 07 Jul 2023 18:57:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688781452;
 x=1691373452; 
 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=39Ya5+TNd9mvRLympPVI5q7OCnpOPGc//DlPeojc5cI=;
 b=XbRXcw4W40Jp3HwvZOZMJP1MEMEslmf75XeaAkGZQAGU7eVLa7p6YRgnW9WDE7QEXR
 VQfSmG4kxIg82u02I9ddIZ6aqTyDlfTxuM9AzJf4I8g/sIv058wAgmoRV/xIQZd6nfUg
 /u7kD+qOcOw2OGxbUL1Zpsrkuu1cArRXQ2Xx8vivbWCacDik8ALmGX3LXNAm5/rXImvc
 8WNfiKHW6JADR/o1qqBdtFauNo7EkIJGl3wK3rB8QpW+z7r0xJRFznc42v+WTo/+JXjO
 gPhz/LcdCDdxM0B6+D+7wVINvgYQemZ6AC6CnjOJqqnmmNtQ/EzZtjN3tUSIPJpynElC
 h8+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1688781452; x=1691373452;
 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=39Ya5+TNd9mvRLympPVI5q7OCnpOPGc//DlPeojc5cI=;
 b=IuZvdKvxITkssl+NkvhNBo2WWRH6g7J2yB1716yqyxePjRKAbiPs/v7Ws6mmYyShnM
 S/mLbbSHUTSBF60YqdbKJ6rrtxHbUbn3hJK2iQJdRQJADpfL89UCwj9pB2ZcRCqH3c2D
 fIHATw1bqTXR0f4eHHxapPbqGQBM4+KKmArz0DidudHqVZ6fcjUTPHgjGEfMKOiUhksg
 I2/AkTO9+Vpa4vDrDmq94XA17WTUy3Pg9FiMz630PqmGPA+vXb3E0esrR/bu8qr3ekD5
 1VjCCN1vUJb35m/q9u9EnmJLl6p6L0PvuEKO9F65tQ7g28/P3dcHIQshcUqOks6FZfNk
 Oygg==
X-Gm-Message-State: ABy/qLYTJPTpI5qj3PM48cB+iqWAqa8dEMuMnOtBSDdu3yb/onCl4Nk8
 pim3qSZCoQMpVWa1Z5Qc8xFIuUb7GNdDph22w91Fukxr
X-Google-Smtp-Source: APBJJlExrVBsHGVobFkMNWbughIoC0j+bO8DeSxJ+2t1Gkqo2YPSPR3En8MzSzqdqIRkp7moKlnm6Q==
X-Received: by 2002:a05:6870:c18d:b0:1b3:f370:79c7 with SMTP id
 h13-20020a056870c18d00b001b3f37079c7mr8467000oad.37.1688781451797; 
 Fri, 07 Jul 2023 18:57:31 -0700 (PDT)
Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218])
 by smtp.gmail.com with ESMTPSA id
 24-20020a17090a035800b00263f5ac814esm2260269pjf.38.2023.07.07.18.57.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jul 2023 18:57:31 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
 Akhil Goyal <gakhil@marvell.com>, Fan Zhang <fanzhang.oss@gmail.com>
Subject: [PATCH v5 11/11] examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset
Date: Fri,  7 Jul 2023 18:57:18 -0700
Message-Id: <20230708015718.75565-12-stephen@networkplumber.org>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20230708015718.75565-1-stephen@networkplumber.org>
References: <20230505174813.133894-1-stephen@networkplumber.org>
 <20230708015718.75565-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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l2fwd-crypto/main.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..19db0a280bf0 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 
 	ipdata_offset = sizeof(struct rte_ether_hdr);
 
-	ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
-			ipdata_offset);
+	ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+					 ipdata_offset);
 
 	ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
 			* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 			op->sym->auth.digest.data = (uint8_t *)rte_pktmbuf_append(m,
 				cparams->digest_length);
 		} else {
-			op->sym->auth.digest.data = rte_pktmbuf_mtod(m,
-				uint8_t *) + ipdata_offset + data_len;
+			op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m,
+				uint8_t *, ipdata_offset + data_len);
 		}
 
 		op->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -540,8 +540,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 			op->sym->aead.digest.data = (uint8_t *)rte_pktmbuf_append(m,
 				cparams->digest_length);
 		} else {
-			op->sym->aead.digest.data = rte_pktmbuf_mtod(m,
-				uint8_t *) + ipdata_offset + data_len;
+			op->sym->aead.digest.data = rte_pktmbuf_mtod_offset(m,
+					uint8_t *, ipdata_offset + data_len);
 		}
 
 		op->sym->aead.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -631,7 +631,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
 	struct rte_ipv4_hdr *ip_hdr;
 	uint32_t ipdata_offset = sizeof(struct rte_ether_hdr);
 
-	ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
+	ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
 					 ipdata_offset);
 	dst_port = l2fwd_dst_ports[portid];
 
-- 
2.39.2