Skip to contentSkip to conversation

rte_pktmbuf_mtod_offset usage

PATCH Superseded Stephen Hemminger 9 participants 84 messages May 5, 2023 – Jan 24, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover rte_pktmbuf_mtod_offset usage

Run the coccinelle script for rte_pktmbuf_mtod_offset against current main branch.

Stephen Hemminger (14):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset
test: cryptodev use rte_pktmbuf_mtod_offset
examples: use rte_pktmbuf_mtod_offset
net/tap: use rte_pktmbuf_mtod_offset
net/nfp: use rte_pktmbuf_mtod_offset
crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
crypto/qat: use rte_pktmbuf_mtod_offset
crypto/cnxk: use rte_ptkmbuf_mtod_offset
common/cpt: use rte_pktmbuf_mtod_offset
crypto/caam_jr: use rte_pktmbuf_mtod_offset
net/mlx4: use rte_pktmbuf_mtod_offset
baseband/fpga_5gnr: use rte_pktmbu_mtod_offset

 app/test-pmd/ieee1588fwd.c                    |  4 +-
 app/test/test_cryptodev.c                     | 66 ++++++++++---------
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         |  7 +-
 drivers/common/cpt/cpt_ucode.h                | 10 ++-
 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          | 16 ++---
 drivers/crypto/ipsec_mb/pmd_snow3g.c          | 35 ++++------
 drivers/crypto/ipsec_mb/pmd_zuc.c             | 16 ++---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h  |  9 +--
 drivers/crypto/qat/qat_sym.h                  |  9 +--
 drivers/net/mlx4/mlx4_rxtx.c                  |  6 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  4 +-
 drivers/net/tap/rte_eth_tap.c                 |  3 +-
 examples/l2fwd-crypto/main.c                  | 16 +++--
 examples/ptpclient/ptpclient.c                | 18 ++---
 lib/gro/gro_tcp4.c                            |  4 +-
 lib/gro/gro_tcp4.h                            |  4 +-
 lib/gro/gro_udp4.c                            |  4 +-
 lib/gro/gro_vxlan_tcp4.c                      |  4 +-
 lib/gro/gro_vxlan_udp4.c                      |  4 +-
 lib/gso/gso_common.h                          | 12 ++--
 lib/gso/gso_tcp4.c                            |  8 +--
 lib/gso/gso_tunnel_tcp4.c                     | 12 ++--
 lib/gso/gso_tunnel_udp4.c                     | 18 ++---
 27 files changed, 153 insertions(+), 154 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/14 gro: use rte_pktmbuf_mtod_offset

Use rte_pktmbuf_mtod_offset. Change was automatically generated by cocci/mtod-offset.cocci.

---
 lib/gro/gro_tcp4.c       | 4 ++--
 lib/gro/gro_tcp4.h       | 4 ++--
 lib/gro/gro_udp4.c       | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
lib/gro/gro_tcp4.c +2 -2
index 0014096e6332..6f8466e70211 100644
@@ -182,8 +182,8 @@ update_header(struct gro_tcp4_item *item)
 	struct rte_ipv4_hdr *ipv4_hdr;
 	struct rte_mbuf *pkt = item->firstseg;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 }
lib/gro/gro_tcp4.h +2 -2
index 212f97a0427c..c76f1f5686d1 100644
@@ -272,8 +272,8 @@ check_seq_option(struct gro_tcp4_item *item,
 	struct rte_tcp_hdr *tcph_orig;
 	uint16_t len, tcp_hl_orig;
 
-	iph_orig = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt_orig, char *) +
-			l2_offset + pkt_orig->l2_len);
+	iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, struct rte_ipv4_hdr *,
+					   l2_offset + pkt_orig->l2_len);
 	tcph_orig = (struct rte_tcp_hdr *)((char *)iph_orig + pkt_orig->l3_len);
 	tcp_hl_orig = pkt_orig->l4_len;
 
lib/gro/gro_udp4.c +2 -2
index 42596d33b6dc..019e05bcdea5 100644
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
 	struct rte_mbuf *pkt = item->firstseg;
 	uint16_t frag_offset;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 
lib/gro/gro_vxlan_tcp4.c +2 -2
index 3be4deb7c76f..b93a02c149cc 100644
@@ -269,8 +269,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
lib/gro/gro_vxlan_udp4.c +2 -2
index b78a7ae89eef..ca8cee270d3d 100644
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/14 gso: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Use the rte_pktmbuf_mtod_offset macro.
Change was automatically generated by cocci/mtod-offset.cocci.

---
 lib/gso/gso_common.h      | 12 ++++++------
 lib/gso/gso_tcp4.c        |  8 ++++----
 lib/gso/gso_tunnel_tcp4.c | 12 ++++++------
 lib/gso/gso_tunnel_udp4.c | 18 +++++++++---------
 4 files changed, 25 insertions(+), 25 deletions(-)
lib/gso/gso_common.h +6 -6
index 9456d596d3c5..4100765f2355 100644
@@ -52,8 +52,8 @@ update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)
 {
 	struct rte_udp_hdr *udp_hdr;
 
-	udp_hdr = (struct rte_udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			udp_offset);
+	udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *,
+					  udp_offset);
 	udp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);
 }
 
@@ -77,8 +77,8 @@ update_tcp_header(struct rte_mbuf *pkt, uint16_t l4_offset, uint32_t sent_seq,
 {
 	struct rte_tcp_hdr *tcp_hdr;
 
-	tcp_hdr = (struct rte_tcp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l4_offset);
+	tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *,
+				          l4_offset);
 	tcp_hdr->sent_seq = rte_cpu_to_be_32(sent_seq);
 	if (likely(non_tail))
 		tcp_hdr->tcp_flags &= (~(TCP_HDR_PSH_MASK |
@@ -104,8 +104,8 @@ update_ipv4_header(struct rte_mbuf *pkt, uint16_t l3_offset, uint16_t id)
 {
 	struct rte_ipv4_hdr *ipv4_hdr;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - l3_offset);
 	ipv4_hdr->packet_id = rte_cpu_to_be_16(id);
 }
lib/gso/gso_tcp4.c +4 -4
index d31feaff95cd..e2ae4aaf6c5a 100644
@@ -16,8 +16,8 @@ update_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	uint16_t l3_offset = pkt->l2_len;
 	uint16_t l4_offset = l3_offset + pkt->l3_len;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char*) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
 	id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 	sent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);
@@ -46,8 +46,8 @@ gso_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	/* Don't process the fragmented packet */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
 	if (unlikely(IS_FRAGMENTED(frag_off))) {
 		return 0;
lib/gso/gso_tunnel_tcp4.c +6 -6
index 1a7ef30ddebf..3a9159774b27 100644
@@ -23,13 +23,13 @@ update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	tcp_offset = inner_ipv4_offset + pkt->l3_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
@@ -65,8 +65,8 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
lib/gso/gso_tunnel_udp4.c +9 -9
index 1fc7a8dbc5aa..4fb275484ca8 100644
@@ -22,13 +22,13 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 	inner_ipv4_offset = outer_udp_offset + pkt->l2_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tail_idx = nb_segs - 1;
@@ -42,9 +42,9 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 		 *
 		 * Set IP fragment offset for inner IP header.
 		 */
-		ipv4_hdr = (struct rte_ipv4_hdr *)
-			(rte_pktmbuf_mtod(segs[i], char *) +
-				inner_ipv4_offset);
+		ipv4_hdr = rte_pktmbuf_mtod_offset(segs[i],
+						   struct rte_ipv4_hdr *,
+						   inner_ipv4_offset);
 		is_mf = i < tail_idx ? IPV4_HDR_MF_BIT : 0;
 		ipv4_hdr->fragment_offset =
 			rte_cpu_to_be_16(frag_offset | is_mf);
@@ -67,8 +67,8 @@ gso_tunnel_udp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/14 testpmd: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Use helper macro.

---
 app/test-pmd/ieee1588fwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/ieee1588fwd.c +2 -2
index 386d9f10e642..3371771751dd 100644
@@ -138,8 +138,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 	 * Check that the received PTP packet is a PTP V2 packet of type
 	 * PTP_SYNC_MESSAGE.
 	 */
-	ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
+					  sizeof(struct rte_ether_hdr));
 	if (ptp_hdr->version != 0x02) {
 		printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
 		       " protocol version 0x%x (should be 0x02)\n",
Signature · 1 line
2.39.2
#4 lore raw

PATCH 4/14 test: cryptodev use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically genertged by cocci/mtod-offset.cocci.

---
 app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 30 deletions(-)
app/test/test_cryptodev.c +36 -30
index 9c670e9a3554..2eebeaac9ef4 100644
@@ -3151,8 +3151,9 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3243,8 +3244,9 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3331,8 +3333,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3417,8 +3420,9 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4851,8 +4855,9 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"ZUC Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4963,8 +4968,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"SNOW 3G Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5129,9 +5135,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ (tdata->digest.offset_bytes == 0 ?
-		plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest.offset_bytes == 0 ? plaintext_pad_len : tdata->digest.offset_bytes));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5537,10 +5543,9 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest.offset_bytes == 0 ? plaintext_pad_len : tdata->digest.offset_bytes));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5878,8 +5883,9 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
 				tdata->validCipherOffsetInBits.len >> 3);
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
 				(tdata->validCipherOffsetInBits.len >> 3);
@@ -6292,8 +6298,9 @@ test_zuc_authentication(const struct wireless_test_data *tdata,
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
 		/* Validate obuf */
@@ -6476,10 +6483,9 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest.offset_bytes == 0 ? plaintext_pad_len : tdata->digest.offset_bytes));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -7897,9 +7903,9 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
 				tdata->ciphertext.data,
 				tdata->ciphertext.len_bits >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ (tdata->digest_enc.offset == 0 ?
-		plaintext_pad_len : tdata->digest_enc.offset);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest_enc.offset == 0 ? plaintext_pad_len : tdata->digest_enc.offset));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 				tdata->digest_enc.len);
Signature · 1 line
2.39.2
#5 lore raw

PATCH 5/14 examples: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated from cocci/mtod-offset.cocci

---
 examples/l2fwd-crypto/main.c   | 16 +++++++++-------
 examples/ptpclient/ptpclient.c | 18 +++++++++---------
 2 files changed, 18 insertions(+), 16 deletions(-)
examples/l2fwd-crypto/main.c +9 -7
index efe7eea2a768..981b449710a7 100644
@@ -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,9 @@ 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 +541,9 @@ 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 +633,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];
 
examples/ptpclient/ptpclient.c +9 -9
index cdf2da64dfee..2535d848a1e9 100644
@@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx)
 {
 	struct ptp_header *ptp_hdr;
 
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
 	if (ptp_data->ptpset == 0) {
@@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
 	int ret;
 
 	eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	if (memcmp(&ptp_data->master_clock_id,
 			&ptp_hdr->source_port_id.clock_id,
 			sizeof(struct clock_id)) != 0)
 		return;
 
 	ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id);
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
 					  sizeof(struct rte_ether_hdr));
 
 	origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp;
@@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data)
 	struct tstamp *rx_tstamp;
 	uint16_t seq_id;
 
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
+					  sizeof(struct rte_ether_hdr));
 	seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id);
 	if (memcmp(&ptp_data->client_clock_id,
 		   &ptp_msg->delay_resp.req_port_id.clock_id,
@@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
 	if (eth_type == PTP_PROTOCOL) {
 		ptp_data.m = m;
 		ptp_data.portid = portid;
-		ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-					+ sizeof(struct rte_ether_hdr));
+		ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+						  sizeof(struct rte_ether_hdr));
 
 		switch (ptp_hdr->msg_type) {
 		case SYNC:
Signature · 1 line
2.39.2
#6 lore raw

PATCH 6/14 net/tap: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated by cocci/mbuf-offset.cocci

---
 drivers/net/tap/rte_eth_tap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +1 -2
index 089ac202fad2..ca2c8da5c289 100644
@@ -672,8 +672,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 			if (seg_len > l234_hlen) {
 				iovecs[k].iov_len = seg_len - l234_hlen;
 				iovecs[k].iov_base =
-					rte_pktmbuf_mtod(seg, char *) +
-						l234_hlen;
+					rte_pktmbuf_mtod_offset(seg, char *, l234_hlen);
 				tap_tx_l4_add_rcksum(iovecs[k].iov_base,
 					iovecs[k].iov_len, l4_cksum,
 					&l4_raw_cksum);
Signature · 1 line
2.39.2
#7 lore raw

PATCH 7/14 net/nfp: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated by cocci/mtod-offset.cocci.

---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +2 -1
index 96e080a8e956..5ae0e8be1d67 100644
@@ -380,7 +380,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+	return rte_pktmbuf_mtod_offset(m, char *,
+				       4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
drivers/net/nfp/flower/nfp_flower_ctrl.c +2 -2
index 3e083d948edf..9a8e464a1d18 100644
@@ -234,7 +234,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
 	uint32_t ctx_id;
 	struct nfp_flower_stats_frame *stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 	msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
 	count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -257,7 +257,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 	struct nfp_mtr *mtr;
 	struct nfp_mtr_stats_reply *mtr_stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
 	mtr_stats = (struct nfp_mtr_stats_reply *)msg;
 	profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
Signature · 1 line
2.39.2
#8 lore raw

PATCH 8/14 crypto/ipsec_mb: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Initial patch generated with cocci/mtod-offset. Additional manual cleanups to indentation and remove unnecessary parenthesis.

---
 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(-)
drivers/crypto/ipsec_mb/pmd_kasumi.c +8 -8
index 5db9c523cd9a..5b1694276468 100644
@@ -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;
 
drivers/crypto/ipsec_mb/pmd_snow3g.c +14 -21
index 8ed069f42860..f6e51916e1fd 100644
@@ -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,
drivers/crypto/ipsec_mb/pmd_zuc.c +8 -8
index 92fd9d180894..65b00e80390e 100644
@@ -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);
 
Signature · 1 line
2.39.2
#9 lore raw

PATCH 9/14 crypto/qat: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Auto generated with cocci/mtod-offset.cocci

---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 9 +++++----
 drivers/crypto/qat/qat_sym.h                 | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h +5 -4
index 524c291340da..11f468a9fdc0 100644
@@ -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;
 
drivers/crypto/qat/qat_sym.h +5 -4
index 9a4251e08b47..615e92f01803 100644
@@ -181,13 +181,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;
 
Signature · 1 line
2.39.2
#10 lore raw

PATCH 10/14 crypto/cnxk: use rte_ptkmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci

---
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 +-
 drivers/crypto/cnxk/cnxk_se.h            | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -1
index 34d40b07d4c6..8b91d11b79cc 100644
@@ -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);
drivers/crypto/cnxk/cnxk_se.h +2 -3
index 69cd343eea1b..d493e1b1880c 100644
@@ -2275,7 +2275,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;
@@ -2310,8 +2310,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;
Signature · 1 line
2.39.2
#11 lore raw

PATCH 11/14 common/cpt: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci

---
 drivers/common/cpt/cpt_ucode.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/common/cpt/cpt_ucode.h +4 -6
index b393be4cf661..87a3ac80b9da 100644
@@ -3167,9 +3167,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 				m = m_src;
 
 			/* hmac immediately following data is best case */
-			if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			    (uint8_t *)sym_op->aead.digest.data)) {
+			if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+				     (uint8_t *)sym_op->aead.digest.data)) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size = sess_misc->mac_len;
 				fc_params.mac_buf.vaddr =
@@ -3211,9 +3210,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 
 			/* hmac immediately following data is best case */
 			if (!ctx->dec_auth && !ctx->auth_enc &&
-				 (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			     (uint8_t *)sym_op->auth.digest.data))) {
+				 (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+					   (uint8_t *)sym_op->auth.digest.data))) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size =
 					sess_misc->mac_len;
Signature · 1 line
2.39.2
#12 lore raw

PATCH 12/14 crypto/caam_jr: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/crypto/caam_jr/caam_jr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/caam_jr/caam_jr.c +4 -4
index b55258689b49..9c96fd21a48d 100644
@@ -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 =
Signature · 1 line
2.39.2
#14 lore raw

PATCH 13/14 net/mlx4: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/mlx4/mlx4_rxtx.c +3 -3
index 059e432a63fc..d5feeb7f7e6d 100644
@@ -1014,9 +1014,9 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			 * loopback in eSwitch, so that VFs and PF can
 			 * communicate with each other.
 			 */
-			srcrb.flags16[0] = *(rte_pktmbuf_mtod(buf, uint16_t *));
-			ctrl->imm = *(rte_pktmbuf_mtod_offset(buf, uint32_t *,
-					      sizeof(uint16_t)));
+			srcrb.flags16[0] = *rte_pktmbuf_mtod(buf, uint16_t *);
+			ctrl->imm = *rte_pktmbuf_mtod_offset(buf, uint32_t *,
+							     sizeof(uint16_t));
 		} else {
 			ctrl->imm = 0;
 		}
Signature · 1 line
2.39.2
#15 lore raw

PATCH 14/14 baseband/fpga_5gnr: use rte_pktmbu_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +3 -4
index f29565af8cca..465a65f3dca2 100644
@@ -1543,8 +1543,7 @@ fpga_harq_write_loopback(struct fpga_queue *q,
 		rte_bbdev_log(ERR, "HARQ in length > HARQ buffer size\n");
 	}
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_input,
-			uint8_t *, in_offset);
+	input = rte_pktmbuf_mtod_offset(harq_input, uint64_t *, in_offset);
 
 	while (left_length > 0) {
 		if (fpga_reg_read_8(q->d->mmio_base,
@@ -1621,8 +1620,8 @@ fpga_harq_read_loopback(struct fpga_queue *q,
 	}
 	left_length = harq_in_length;
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_output,
-			uint8_t *, harq_out_offset);
+	input = rte_pktmbuf_mtod_offset(harq_output, uint64_t *,
+					harq_out_offset);
 
 	while (left_length > 0) {
 		fpga_reg_write_32(q->d->mmio_base,
Signature · 1 line
2.39.2
#16 lore raw

v2 cover rte_pktmbuf_mtod_offset usage

In reply to Stephen Hemminger

Run the coccinelle script for rte_pktmbuf_mtod_offset against current main branch.

v2 - fix checkpatch warnings about long lines

Stephen Hemminger (14):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset
test: cryptodev use rte_pktmbuf_mtod_offset
examples: use rte_pktmbuf_mtod_offset
net/tap: use rte_pktmbuf_mtod_offset
net/nfp: use rte_pktmbuf_mtod_offset
crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
crypto/qat: use rte_pktmbuf_mtod_offset
crypto/cnxk: use rte_ptkmbuf_mtod_offset
common/cpt: use rte_pktmbuf_mtod_offset
crypto/caam_jr: use rte_pktmbuf_mtod_offset
net/mlx4: use rte_pktmbuf_mtod_offset
baseband/fpga_5gnr: use rte_pktmbu_mtod_offset

 app/test-pmd/ieee1588fwd.c                    |  4 +-
 app/test/test_cryptodev.c                     | 66 ++++++++++---------
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         |  7 +-
 drivers/common/cpt/cpt_ucode.h                | 10 ++-
 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          | 16 ++---
 drivers/crypto/ipsec_mb/pmd_snow3g.c          | 35 ++++------
 drivers/crypto/ipsec_mb/pmd_zuc.c             | 16 ++---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h  |  9 +--
 drivers/crypto/qat/qat_sym.h                  |  9 +--
 drivers/net/mlx4/mlx4_rxtx.c                  |  6 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  4 +-
 drivers/net/tap/rte_eth_tap.c                 |  3 +-
 examples/l2fwd-crypto/main.c                  | 16 +++--
 examples/ptpclient/ptpclient.c                | 18 ++---
 lib/gro/gro_tcp4.c                            |  4 +-
 lib/gro/gro_tcp4.h                            |  4 +-
 lib/gro/gro_udp4.c                            |  4 +-
 lib/gro/gro_vxlan_tcp4.c                      |  4 +-
 lib/gro/gro_vxlan_udp4.c                      |  4 +-
 lib/gso/gso_common.h                          | 11 ++--
 lib/gso/gso_tcp4.c                            |  8 +--
 lib/gso/gso_tunnel_tcp4.c                     | 12 ++--
 lib/gso/gso_tunnel_udp4.c                     | 18 ++---
 27 files changed, 152 insertions(+), 154 deletions(-)
Signature · 1 line
2.39.2
#17 lore raw

PATCH v2 1/14 gro: use rte_pktmbuf_mtod_offset

Use rte_pktmbuf_mtod_offset. Change was automatically generated by cocci/mtod-offset.cocci.

---
 lib/gro/gro_tcp4.c       | 4 ++--
 lib/gro/gro_tcp4.h       | 4 ++--
 lib/gro/gro_udp4.c       | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
lib/gro/gro_tcp4.c +2 -2
index 0014096e6332..6f8466e70211 100644
@@ -182,8 +182,8 @@ update_header(struct gro_tcp4_item *item)
 	struct rte_ipv4_hdr *ipv4_hdr;
 	struct rte_mbuf *pkt = item->firstseg;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 }
lib/gro/gro_tcp4.h +2 -2
index 212f97a0427c..c76f1f5686d1 100644
@@ -272,8 +272,8 @@ check_seq_option(struct gro_tcp4_item *item,
 	struct rte_tcp_hdr *tcph_orig;
 	uint16_t len, tcp_hl_orig;
 
-	iph_orig = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt_orig, char *) +
-			l2_offset + pkt_orig->l2_len);
+	iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, struct rte_ipv4_hdr *,
+					   l2_offset + pkt_orig->l2_len);
 	tcph_orig = (struct rte_tcp_hdr *)((char *)iph_orig + pkt_orig->l3_len);
 	tcp_hl_orig = pkt_orig->l4_len;
 
lib/gro/gro_udp4.c +2 -2
index 42596d33b6dc..019e05bcdea5 100644
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
 	struct rte_mbuf *pkt = item->firstseg;
 	uint16_t frag_offset;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 
lib/gro/gro_vxlan_tcp4.c +2 -2
index 3be4deb7c76f..b93a02c149cc 100644
@@ -269,8 +269,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
lib/gro/gro_vxlan_udp4.c +2 -2
index b78a7ae89eef..ca8cee270d3d 100644
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
Signature · 1 line
2.39.2
#18 lore raw

PATCH v2 2/14 gso: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Use the rte_pktmbuf_mtod_offset macro.
Change was automatically generated by cocci/mtod-offset.cocci.

---
 lib/gso/gso_common.h      | 11 +++++------
 lib/gso/gso_tcp4.c        |  8 ++++----
 lib/gso/gso_tunnel_tcp4.c | 12 ++++++------
 lib/gso/gso_tunnel_udp4.c | 18 +++++++++---------
 4 files changed, 24 insertions(+), 25 deletions(-)
lib/gso/gso_common.h +5 -6
index 9456d596d3c5..8987e368605c 100644
@@ -52,8 +52,8 @@ update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)
 {
 	struct rte_udp_hdr *udp_hdr;
 
-	udp_hdr = (struct rte_udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			udp_offset);
+	udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *,
+					  udp_offset);
 	udp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);
 }
 
@@ -77,8 +77,7 @@ update_tcp_header(struct rte_mbuf *pkt, uint16_t l4_offset, uint32_t sent_seq,
 {
 	struct rte_tcp_hdr *tcp_hdr;
 
-	tcp_hdr = (struct rte_tcp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l4_offset);
+	tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, l4_offset);
 	tcp_hdr->sent_seq = rte_cpu_to_be_32(sent_seq);
 	if (likely(non_tail))
 		tcp_hdr->tcp_flags &= (~(TCP_HDR_PSH_MASK |
@@ -104,8 +103,8 @@ update_ipv4_header(struct rte_mbuf *pkt, uint16_t l3_offset, uint16_t id)
 {
 	struct rte_ipv4_hdr *ipv4_hdr;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - l3_offset);
 	ipv4_hdr->packet_id = rte_cpu_to_be_16(id);
 }
lib/gso/gso_tcp4.c +4 -4
index d31feaff95cd..e2ae4aaf6c5a 100644
@@ -16,8 +16,8 @@ update_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	uint16_t l3_offset = pkt->l2_len;
 	uint16_t l4_offset = l3_offset + pkt->l3_len;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char*) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
 	id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 	sent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);
@@ -46,8 +46,8 @@ gso_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	/* Don't process the fragmented packet */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
 	if (unlikely(IS_FRAGMENTED(frag_off))) {
 		return 0;
lib/gso/gso_tunnel_tcp4.c +6 -6
index 1a7ef30ddebf..3a9159774b27 100644
@@ -23,13 +23,13 @@ update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	tcp_offset = inner_ipv4_offset + pkt->l3_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
@@ -65,8 +65,8 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
lib/gso/gso_tunnel_udp4.c +9 -9
index 1fc7a8dbc5aa..4fb275484ca8 100644
@@ -22,13 +22,13 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 	inner_ipv4_offset = outer_udp_offset + pkt->l2_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tail_idx = nb_segs - 1;
@@ -42,9 +42,9 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 		 *
 		 * Set IP fragment offset for inner IP header.
 		 */
-		ipv4_hdr = (struct rte_ipv4_hdr *)
-			(rte_pktmbuf_mtod(segs[i], char *) +
-				inner_ipv4_offset);
+		ipv4_hdr = rte_pktmbuf_mtod_offset(segs[i],
+						   struct rte_ipv4_hdr *,
+						   inner_ipv4_offset);
 		is_mf = i < tail_idx ? IPV4_HDR_MF_BIT : 0;
 		ipv4_hdr->fragment_offset =
 			rte_cpu_to_be_16(frag_offset | is_mf);
@@ -67,8 +67,8 @@ gso_tunnel_udp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
Signature · 1 line
2.39.2
#19 lore raw

PATCH v2 3/14 testpmd: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Use helper macro.

---
 app/test-pmd/ieee1588fwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/ieee1588fwd.c +2 -2
index 386d9f10e642..3371771751dd 100644
@@ -138,8 +138,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 	 * Check that the received PTP packet is a PTP V2 packet of type
 	 * PTP_SYNC_MESSAGE.
 	 */
-	ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
+					  sizeof(struct rte_ether_hdr));
 	if (ptp_hdr->version != 0x02) {
 		printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
 		       " protocol version 0x%x (should be 0x02)\n",
Signature · 1 line
2.39.2
#20 lore raw

PATCH v2 4/14 test: cryptodev use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Based off patch generated by cocci/mtod-offset.cocci. With some cleanup to shorten lines by using conditional with ommited operand.

---
 app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 30 deletions(-)
app/test/test_cryptodev.c +36 -30
index 9c670e9a3554..b4cddcd55f59 100644
@@ -3151,8 +3151,9 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3243,8 +3244,9 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3331,8 +3333,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3417,8 +3420,9 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4851,8 +4855,9 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"ZUC Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4963,8 +4968,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"SNOW 3G Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5129,9 +5135,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ (tdata->digest.offset_bytes == 0 ?
-		plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5537,10 +5543,9 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5878,8 +5883,9 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
 				tdata->validCipherOffsetInBits.len >> 3);
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
 				(tdata->validCipherOffsetInBits.len >> 3);
@@ -6292,8 +6298,9 @@ test_zuc_authentication(const struct wireless_test_data *tdata,
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
 		/* Validate obuf */
@@ -6476,10 +6483,9 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -7897,9 +7903,9 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
 				tdata->ciphertext.data,
 				tdata->ciphertext.len_bits >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ (tdata->digest_enc.offset == 0 ?
-		plaintext_pad_len : tdata->digest_enc.offset);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest_enc.offset ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 				tdata->digest_enc.len);
Signature · 1 line
2.39.2
#21 lore raw

PATCH v2 5/14 examples: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated from cocci/mtod-offset.cocci

---
 examples/l2fwd-crypto/main.c   | 16 +++++++++-------
 examples/ptpclient/ptpclient.c | 18 +++++++++---------
 2 files changed, 18 insertions(+), 16 deletions(-)
examples/l2fwd-crypto/main.c +9 -7
index efe7eea2a768..403ed6b44de9 100644
@@ -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,9 @@ 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 +541,9 @@ 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 +633,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];
 
examples/ptpclient/ptpclient.c +9 -9
index cdf2da64dfee..2535d848a1e9 100644
@@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx)
 {
 	struct ptp_header *ptp_hdr;
 
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
 	if (ptp_data->ptpset == 0) {
@@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
 	int ret;
 
 	eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	if (memcmp(&ptp_data->master_clock_id,
 			&ptp_hdr->source_port_id.clock_id,
 			sizeof(struct clock_id)) != 0)
 		return;
 
 	ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id);
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
 					  sizeof(struct rte_ether_hdr));
 
 	origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp;
@@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data)
 	struct tstamp *rx_tstamp;
 	uint16_t seq_id;
 
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
+					  sizeof(struct rte_ether_hdr));
 	seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id);
 	if (memcmp(&ptp_data->client_clock_id,
 		   &ptp_msg->delay_resp.req_port_id.clock_id,
@@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
 	if (eth_type == PTP_PROTOCOL) {
 		ptp_data.m = m;
 		ptp_data.portid = portid;
-		ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-					+ sizeof(struct rte_ether_hdr));
+		ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+						  sizeof(struct rte_ether_hdr));
 
 		switch (ptp_hdr->msg_type) {
 		case SYNC:
Signature · 1 line
2.39.2
#22 lore raw

PATCH v2 6/14 net/tap: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated by cocci/mbuf-offset.cocci

---
 drivers/net/tap/rte_eth_tap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +1 -2
index 089ac202fad2..ca2c8da5c289 100644
@@ -672,8 +672,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 			if (seg_len > l234_hlen) {
 				iovecs[k].iov_len = seg_len - l234_hlen;
 				iovecs[k].iov_base =
-					rte_pktmbuf_mtod(seg, char *) +
-						l234_hlen;
+					rte_pktmbuf_mtod_offset(seg, char *, l234_hlen);
 				tap_tx_l4_add_rcksum(iovecs[k].iov_base,
 					iovecs[k].iov_len, l4_cksum,
 					&l4_raw_cksum);
Signature · 1 line
2.39.2
#23 lore raw

PATCH v2 7/14 net/nfp: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated by cocci/mtod-offset.cocci.

---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +2 -1
index 96e080a8e956..5ae0e8be1d67 100644
@@ -380,7 +380,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+	return rte_pktmbuf_mtod_offset(m, char *,
+				       4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
drivers/net/nfp/flower/nfp_flower_ctrl.c +2 -2
index 3e083d948edf..9a8e464a1d18 100644
@@ -234,7 +234,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
 	uint32_t ctx_id;
 	struct nfp_flower_stats_frame *stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 	msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
 	count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -257,7 +257,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 	struct nfp_mtr *mtr;
 	struct nfp_mtr_stats_reply *mtr_stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
 	mtr_stats = (struct nfp_mtr_stats_reply *)msg;
 	profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
Signature · 1 line
2.39.2
Reviewed-by on v2 7/14
#24 lore raw

Re: [PATCH v2 07/14] net/nfp: use rte_pktmbuf_mtod_offset

Hi Stephen,

Thanks for your work.

Quoted 3 lines · Stephen Hemminger

Automatically generated by cocci/mtod-offset.cocci.

Quoted 44 lines
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +2 -1
index 96e080a8e956..5ae0e8be1d67 100644
@@ -380,7 +380,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+	return rte_pktmbuf_mtod_offset(m, char *,
+				       4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
drivers/net/nfp/flower/nfp_flower_ctrl.c +2 -2
index 3e083d948edf..9a8e464a1d18 100644
@@ -234,7 +234,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
 	uint32_t ctx_id;
 	struct nfp_flower_stats_frame *stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 	msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
 	count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -257,7 +257,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 	struct nfp_mtr *mtr;
 	struct nfp_mtr_stats_reply *mtr_stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
 	mtr_stats = (struct nfp_mtr_stats_reply *)msg;
 	profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
Signature · 1 line
2.39.2
Signature · 2 lines
Kind Regards,
Niklas Söderlund
#25 lore raw

PATCH v2 8/14 crypto/ipsec_mb: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Initial patch generated with cocci/mtod-offset. Additional manual cleanups to indentation and remove unnecessary parenthesis.

---
 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(-)
drivers/crypto/ipsec_mb/pmd_kasumi.c +8 -8
index 5db9c523cd9a..5b1694276468 100644
@@ -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;
 
drivers/crypto/ipsec_mb/pmd_snow3g.c +14 -21
index 8ed069f42860..f6e51916e1fd 100644
@@ -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,
drivers/crypto/ipsec_mb/pmd_zuc.c +8 -8
index 92fd9d180894..65b00e80390e 100644
@@ -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);
 
Signature · 1 line
2.39.2
Acked-by on v2 8/14
#26 lore raw

RE: [PATCH v2 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset

Quoted 10 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Saturday, May 6, 2023 5:04 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: [PATCH v2 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset

Quoted 5 lines

Initial patch generated with cocci/mtod-offset. Additional manual cleanups to indentation and remove unnecessary parenthesis.

#27 lore raw

PATCH v2 9/14 crypto/qat: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Auto generated with cocci/mtod-offset.cocci

---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 9 +++++----
 drivers/crypto/qat/qat_sym.h                 | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h +5 -4
index 524c291340da..11f468a9fdc0 100644
@@ -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;
 
drivers/crypto/qat/qat_sym.h +5 -4
index 9a4251e08b47..615e92f01803 100644
@@ -181,13 +181,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;
 
Signature · 1 line
2.39.2
#28 lore raw

PATCH v2 10/14 crypto/cnxk: use rte_ptkmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci

---
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 +-
 drivers/crypto/cnxk/cnxk_se.h            | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -1
index 34d40b07d4c6..8b91d11b79cc 100644
@@ -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);
drivers/crypto/cnxk/cnxk_se.h +2 -3
index 69cd343eea1b..d493e1b1880c 100644
@@ -2275,7 +2275,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;
@@ -2310,8 +2310,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;
Signature · 1 line
2.39.2
#29 lore raw

PATCH v2 11/14 common/cpt: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci

---
 drivers/common/cpt/cpt_ucode.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/common/cpt/cpt_ucode.h +4 -6
index b393be4cf661..87a3ac80b9da 100644
@@ -3167,9 +3167,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 				m = m_src;
 
 			/* hmac immediately following data is best case */
-			if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			    (uint8_t *)sym_op->aead.digest.data)) {
+			if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+				     (uint8_t *)sym_op->aead.digest.data)) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size = sess_misc->mac_len;
 				fc_params.mac_buf.vaddr =
@@ -3211,9 +3210,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 
 			/* hmac immediately following data is best case */
 			if (!ctx->dec_auth && !ctx->auth_enc &&
-				 (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			     (uint8_t *)sym_op->auth.digest.data))) {
+				 (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+					   (uint8_t *)sym_op->auth.digest.data))) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size =
 					sess_misc->mac_len;
Signature · 1 line
2.39.2
#30 lore raw

PATCH v2 12/14 crypto/caam_jr: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/crypto/caam_jr/caam_jr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/caam_jr/caam_jr.c +4 -4
index b55258689b49..9c96fd21a48d 100644
@@ -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 =
Signature · 1 line
2.39.2
#31 lore raw

PATCH v2 13/14 net/mlx4: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/mlx4/mlx4_rxtx.c +3 -3
index 059e432a63fc..d5feeb7f7e6d 100644
@@ -1014,9 +1014,9 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			 * loopback in eSwitch, so that VFs and PF can
 			 * communicate with each other.
 			 */
-			srcrb.flags16[0] = *(rte_pktmbuf_mtod(buf, uint16_t *));
-			ctrl->imm = *(rte_pktmbuf_mtod_offset(buf, uint32_t *,
-					      sizeof(uint16_t)));
+			srcrb.flags16[0] = *rte_pktmbuf_mtod(buf, uint16_t *);
+			ctrl->imm = *rte_pktmbuf_mtod_offset(buf, uint32_t *,
+							     sizeof(uint16_t));
 		} else {
 			ctrl->imm = 0;
 		}
Signature · 1 line
2.39.2
#32 lore raw

PATCH v2 14/14 baseband/fpga_5gnr: use rte_pktmbu_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +3 -4
index f29565af8cca..465a65f3dca2 100644
@@ -1543,8 +1543,7 @@ fpga_harq_write_loopback(struct fpga_queue *q,
 		rte_bbdev_log(ERR, "HARQ in length > HARQ buffer size\n");
 	}
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_input,
-			uint8_t *, in_offset);
+	input = rte_pktmbuf_mtod_offset(harq_input, uint64_t *, in_offset);
 
 	while (left_length > 0) {
 		if (fpga_reg_read_8(q->d->mmio_base,
@@ -1621,8 +1620,8 @@ fpga_harq_read_loopback(struct fpga_queue *q,
 	}
 	left_length = harq_in_length;
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_output,
-			uint8_t *, harq_out_offset);
+	input = rte_pktmbuf_mtod_offset(harq_output, uint64_t *,
+					harq_out_offset);
 
 	while (left_length > 0) {
 		fpga_reg_write_32(q->d->mmio_base,
Signature · 1 line
2.39.2
#33 lore raw

v3 cover Use rte_pktmbuf_mtod_offset() where possible

In reply to Stephen Hemminger

Run the coccinelle script for rte_pktmbuf_mtod_offset against current main branch.

v3 - rebase to cover gro changes

Stephen Hemminger (14):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset
test: cryptodev use rte_pktmbuf_mtod_offset
examples: use rte_pktmbuf_mtod_offset
net/tap: use rte_pktmbuf_mtod_offset
net/nfp: use rte_pktmbuf_mtod_offset
crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
crypto/qat: use rte_pktmbuf_mtod_offset
crypto/cnxk: use rte_ptkmbuf_mtod_offset
common/cpt: use rte_pktmbuf_mtod_offset
crypto/caam_jr: use rte_pktmbuf_mtod_offset
net/mlx4: use rte_pktmbuf_mtod_offset
baseband/fpga_5gnr: use rte_pktmbu_mtod_offset

 app/test-pmd/ieee1588fwd.c                    |  4 +-
 app/test/test_cryptodev.c                     | 66 ++++++++++---------
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         |  7 +-
 drivers/common/cpt/cpt_ucode.h                | 10 ++-
 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          | 16 ++---
 drivers/crypto/ipsec_mb/pmd_snow3g.c          | 35 ++++------
 drivers/crypto/ipsec_mb/pmd_zuc.c             | 16 ++---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h  |  9 +--
 drivers/crypto/qat/qat_sym.h                  |  9 +--
 drivers/net/mlx4/mlx4_rxtx.c                  |  6 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  4 +-
 drivers/net/tap/rte_eth_tap.c                 |  3 +-
 examples/l2fwd-crypto/main.c                  | 16 +++--
 examples/ptpclient/ptpclient.c                | 18 ++---
 lib/gro/gro_tcp.h                             |  2 +-
 lib/gro/gro_tcp4.c                            |  2 +-
 lib/gro/gro_udp4.c                            |  4 +-
 lib/gro/gro_vxlan_tcp4.c                      |  4 +-
 lib/gro/gro_vxlan_udp4.c                      |  4 +-
 lib/gso/gso_common.h                          | 11 ++--
 lib/gso/gso_tcp4.c                            |  8 +--
 lib/gso/gso_tunnel_tcp4.c                     | 12 ++--
 lib/gso/gso_tunnel_udp4.c                     | 18 ++---
 27 files changed, 150 insertions(+), 152 deletions(-)
Signature · 1 line
2.39.2
#34 lore raw

PATCH v3 1/14 gro: use rte_pktmbuf_mtod_offset

Use rte_pktmbuf_mtod_offset. Change was automatically generated by cocci/mtod-offset.cocci.

---
 lib/gro/gro_tcp.h        | 2 +-
 lib/gro/gro_tcp4.c       | 2 +-
 lib/gro/gro_udp4.c       | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)
lib/gro/gro_tcp.h +1 -1
index d926c4b8cc71..2c825413c261 100644
@@ -150,7 +150,7 @@ check_seq_option(struct gro_tcp_item *item,
 	struct rte_tcp_hdr *tcph_orig;
 	uint16_t len, tcp_hl_orig;
 
-	iph_orig = (char *)(rte_pktmbuf_mtod(pkt_orig, char *) +
+	iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, char *,
 			l2_offset + pkt_orig->l2_len);
 	tcph_orig = (struct rte_tcp_hdr *)(iph_orig + pkt_orig->l3_len);
 	tcp_hl_orig = pkt_orig->l4_len;
lib/gro/gro_tcp4.c +1 -1
index 6645de592b63..f8cd92950c63 100644
@@ -223,7 +223,7 @@ update_header(struct gro_tcp_item *item)
 	struct rte_ipv4_hdr *ipv4_hdr;
 	struct rte_mbuf *pkt = item->firstseg;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
 			pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
lib/gro/gro_udp4.c +2 -2
index 42596d33b6dc..019e05bcdea5 100644
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
 	struct rte_mbuf *pkt = item->firstseg;
 	uint16_t frag_offset;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 
lib/gro/gro_vxlan_tcp4.c +2 -2
index 6ab700192261..2752650389a4 100644
@@ -263,8 +263,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
lib/gro/gro_vxlan_udp4.c +2 -2
index b78a7ae89eef..ca8cee270d3d 100644
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
Signature · 1 line
2.39.2
#35 lore raw

PATCH v3 2/14 gso: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Use the rte_pktmbuf_mtod_offset macro.
Change was automatically generated by cocci/mtod-offset.cocci.

---
 lib/gso/gso_common.h      | 11 +++++------
 lib/gso/gso_tcp4.c        |  8 ++++----
 lib/gso/gso_tunnel_tcp4.c | 12 ++++++------
 lib/gso/gso_tunnel_udp4.c | 18 +++++++++---------
 4 files changed, 24 insertions(+), 25 deletions(-)
lib/gso/gso_common.h +5 -6
index 9456d596d3c5..8987e368605c 100644
@@ -52,8 +52,8 @@ update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)
 {
 	struct rte_udp_hdr *udp_hdr;
 
-	udp_hdr = (struct rte_udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			udp_offset);
+	udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *,
+					  udp_offset);
 	udp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);
 }
 
@@ -77,8 +77,7 @@ update_tcp_header(struct rte_mbuf *pkt, uint16_t l4_offset, uint32_t sent_seq,
 {
 	struct rte_tcp_hdr *tcp_hdr;
 
-	tcp_hdr = (struct rte_tcp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l4_offset);
+	tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, l4_offset);
 	tcp_hdr->sent_seq = rte_cpu_to_be_32(sent_seq);
 	if (likely(non_tail))
 		tcp_hdr->tcp_flags &= (~(TCP_HDR_PSH_MASK |
@@ -104,8 +103,8 @@ update_ipv4_header(struct rte_mbuf *pkt, uint16_t l3_offset, uint16_t id)
 {
 	struct rte_ipv4_hdr *ipv4_hdr;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - l3_offset);
 	ipv4_hdr->packet_id = rte_cpu_to_be_16(id);
 }
lib/gso/gso_tcp4.c +4 -4
index d31feaff95cd..e2ae4aaf6c5a 100644
@@ -16,8 +16,8 @@ update_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	uint16_t l3_offset = pkt->l2_len;
 	uint16_t l4_offset = l3_offset + pkt->l3_len;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char*) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
 	id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 	sent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);
@@ -46,8 +46,8 @@ gso_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	/* Don't process the fragmented packet */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
 	if (unlikely(IS_FRAGMENTED(frag_off))) {
 		return 0;
lib/gso/gso_tunnel_tcp4.c +6 -6
index 1a7ef30ddebf..3a9159774b27 100644
@@ -23,13 +23,13 @@ update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	tcp_offset = inner_ipv4_offset + pkt->l3_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
@@ -65,8 +65,8 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
lib/gso/gso_tunnel_udp4.c +9 -9
index 1fc7a8dbc5aa..4fb275484ca8 100644
@@ -22,13 +22,13 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 	inner_ipv4_offset = outer_udp_offset + pkt->l2_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tail_idx = nb_segs - 1;
@@ -42,9 +42,9 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 		 *
 		 * Set IP fragment offset for inner IP header.
 		 */
-		ipv4_hdr = (struct rte_ipv4_hdr *)
-			(rte_pktmbuf_mtod(segs[i], char *) +
-				inner_ipv4_offset);
+		ipv4_hdr = rte_pktmbuf_mtod_offset(segs[i],
+						   struct rte_ipv4_hdr *,
+						   inner_ipv4_offset);
 		is_mf = i < tail_idx ? IPV4_HDR_MF_BIT : 0;
 		ipv4_hdr->fragment_offset =
 			rte_cpu_to_be_16(frag_offset | is_mf);
@@ -67,8 +67,8 @@ gso_tunnel_udp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
Signature · 1 line
2.39.2
#36 lore raw

PATCH v3 3/14 testpmd: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Use helper macro.

---
 app/test-pmd/ieee1588fwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/ieee1588fwd.c +2 -2
index 386d9f10e642..3371771751dd 100644
@@ -138,8 +138,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 	 * Check that the received PTP packet is a PTP V2 packet of type
 	 * PTP_SYNC_MESSAGE.
 	 */
-	ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
+					  sizeof(struct rte_ether_hdr));
 	if (ptp_hdr->version != 0x02) {
 		printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
 		       " protocol version 0x%x (should be 0x02)\n",
Signature · 1 line
2.39.2
#37 lore raw

PATCH v3 4/14 test: cryptodev use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Based off patch generated by cocci/mtod-offset.cocci. With some cleanup to shorten lines by using conditional with omitted operand.

---
 app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 30 deletions(-)
app/test/test_cryptodev.c +36 -30
index fb2af40b99ee..5072b3b6ece5 100644
@@ -3153,8 +3153,9 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3247,8 +3248,9 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3337,8 +3339,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3425,8 +3428,9 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4879,8 +4883,9 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"ZUC Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4994,8 +4999,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"SNOW 3G Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5163,9 +5169,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ (tdata->digest.offset_bytes == 0 ?
-		plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5577,10 +5583,9 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5924,8 +5929,9 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
 				tdata->validCipherOffsetInBits.len >> 3);
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
 				(tdata->validCipherOffsetInBits.len >> 3);
@@ -6344,8 +6350,9 @@ test_zuc_authentication(const struct wireless_test_data *tdata,
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
 		/* Validate obuf */
@@ -6531,10 +6538,9 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -7959,9 +7965,9 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
 				tdata->ciphertext.data,
 				tdata->ciphertext.len_bits >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ (tdata->digest_enc.offset == 0 ?
-		plaintext_pad_len : tdata->digest_enc.offset);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest_enc.offset ? : plaintext_pad_len);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 				tdata->digest_enc.len);
Signature · 1 line
2.39.2
#38 lore raw

Re: [PATCH v3 04/14] test: cryptodev use rte_pktmbuf_mtod_offset

Quoted 5 lines · Stephen Hemminger

Based off patch generated by cocci/mtod-offset.cocci. With some cleanup to shorten lines by using conditional with omitted operand.

<...>

app/test/test_cryptodev.c test_snow3g_auth_cipher(const struct snow3g_test_data *tdata, · line 5175

Quoted 11 lines
app/test/test_cryptodev.c +3 -3
@@ -5163,9 +5169,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ (tdata->digest.offset_bytes == 0 ?
-		plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 

As far as I know "x ?: y" support is gcc extention, what about sticking to standard syntax?

#39 lore raw

Re: [PATCH v3 04/14] test: cryptodev use rte_pktmbuf_mtod_offset

Quoted 13 lines · On Fri, 7 Jul 2023 13:46:07 +0100 Ferruh Yigit <[email protected]> wrote:
Quoted 5 lines · Stephen Hemminger

Based off patch generated by cocci/mtod-offset.cocci. With some cleanup to shorten lines by using conditional with omitted operand.

<...>

Quoted 4 lines
app/test/test_cryptodev.c +0 -0
@@ -5163,9 +5169,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
Quoted 10 lines

app/test/test_cryptodev.c test_snow3g_auth_cipher(const struct snow3g_test_data *tdata, · line 5175

Quoted 7 lines
app/test/test_cryptodev.c +3 -3
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ (tdata->digest.offset_bytes == 0 ?
-		plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					uint8_t *,
+					tdata->digest.offset_bytes ? : plaintext_pad_len);
 

As far as I know "x ?: y" support is gcc extention, what about sticking to standard syntax?

Already used five places in DPDK, so didn't seem like a problem.

#40 lore raw

PATCH v3 5/14 examples: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated from cocci/mtod-offset.cocci

---
 examples/l2fwd-crypto/main.c   | 16 +++++++++-------
 examples/ptpclient/ptpclient.c | 18 +++++++++---------
 2 files changed, 18 insertions(+), 16 deletions(-)
examples/l2fwd-crypto/main.c +9 -7
index efe7eea2a768..403ed6b44de9 100644
@@ -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,9 @@ 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 +541,9 @@ 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 +633,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];
 
examples/ptpclient/ptpclient.c +9 -9
index cdf2da64dfee..2535d848a1e9 100644
@@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx)
 {
 	struct ptp_header *ptp_hdr;
 
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
 	if (ptp_data->ptpset == 0) {
@@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
 	int ret;
 
 	eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	if (memcmp(&ptp_data->master_clock_id,
 			&ptp_hdr->source_port_id.clock_id,
 			sizeof(struct clock_id)) != 0)
 		return;
 
 	ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id);
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
 					  sizeof(struct rte_ether_hdr));
 
 	origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp;
@@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data)
 	struct tstamp *rx_tstamp;
 	uint16_t seq_id;
 
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
+					  sizeof(struct rte_ether_hdr));
 	seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id);
 	if (memcmp(&ptp_data->client_clock_id,
 		   &ptp_msg->delay_resp.req_port_id.clock_id,
@@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
 	if (eth_type == PTP_PROTOCOL) {
 		ptp_data.m = m;
 		ptp_data.portid = portid;
-		ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-					+ sizeof(struct rte_ether_hdr));
+		ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+						  sizeof(struct rte_ether_hdr));
 
 		switch (ptp_hdr->msg_type) {
 		case SYNC:
Signature · 1 line
2.39.2
#41 lore raw

PATCH v3 6/14 net/tap: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated by cocci/mbuf-offset.cocci

---
 drivers/net/tap/rte_eth_tap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +1 -2
index bf98f7555990..ebddbae9fe9f 100644
@@ -672,8 +672,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 			if (seg_len > l234_hlen) {
 				iovecs[k].iov_len = seg_len - l234_hlen;
 				iovecs[k].iov_base =
-					rte_pktmbuf_mtod(seg, char *) +
-						l234_hlen;
+					rte_pktmbuf_mtod_offset(seg, char *, l234_hlen);
 				tap_tx_l4_add_rcksum(iovecs[k].iov_base,
 					iovecs[k].iov_len, l4_cksum,
 					&l4_raw_cksum);
Signature · 1 line
2.39.2
#42 lore raw

PATCH v3 7/14 net/nfp: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Automatically generated by cocci/mtod-offset.cocci.

---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +2 -1
index f643d54d39a4..787a38dc9aa0 100644
@@ -381,7 +381,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+	return rte_pktmbuf_mtod_offset(m, char *,
+				       4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
drivers/net/nfp/flower/nfp_flower_ctrl.c +2 -2
index 4cb2c2f99e04..18823a97887d 100644
@@ -389,7 +389,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
 	uint32_t ctx_id;
 	struct nfp_flower_stats_frame *stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 	msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
 	count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -412,7 +412,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 	struct nfp_mtr *mtr;
 	struct nfp_mtr_stats_reply *mtr_stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
 	mtr_stats = (struct nfp_mtr_stats_reply *)msg;
 	profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
Signature · 1 line
2.39.2
#43 lore raw

PATCH v3 8/14 crypto/ipsec_mb: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Initial patch generated with cocci/mtod-offset. Additional manual cleanups to indentation and remove unnecessary parenthesis.

---
 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(-)
drivers/crypto/ipsec_mb/pmd_kasumi.c +8 -8
index 5db9c523cd9a..5b1694276468 100644
@@ -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;
 
drivers/crypto/ipsec_mb/pmd_snow3g.c +14 -21
index e64df1a462e3..90b8d80c2c56 100644
@@ -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,
drivers/crypto/ipsec_mb/pmd_zuc.c +8 -8
index 92fd9d180894..65b00e80390e 100644
@@ -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);
 
Signature · 1 line
2.39.2
#44 lore raw

PATCH v3 9/14 crypto/qat: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Auto generated with cocci/mtod-offset.cocci

---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 9 +++++----
 drivers/crypto/qat/qat_sym.h                 | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h +5 -4
index 1bafeb4a53e8..3e0dfea94c87 100644
@@ -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;
 
drivers/crypto/qat/qat_sym.h +5 -4
index 193281cd9135..d7ceb13b29cd 100644
@@ -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;
 
Signature · 1 line
2.39.2
#45 lore raw

PATCH v3 10/14 crypto/cnxk: use rte_ptkmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci

---
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 +-
 drivers/crypto/cnxk/cnxk_se.h            | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -1
index 34d40b07d4c6..8b91d11b79cc 100644
@@ -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);
drivers/crypto/cnxk/cnxk_se.h +2 -3
index 75c1dce231bf..1392af5833d1 100644
@@ -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;
Signature · 1 line
2.39.2
#46 lore raw

PATCH v3 11/14 common/cpt: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci

---
 drivers/common/cpt/cpt_ucode.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/common/cpt/cpt_ucode.h +4 -6
index b393be4cf661..87a3ac80b9da 100644
@@ -3167,9 +3167,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 				m = m_src;
 
 			/* hmac immediately following data is best case */
-			if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			    (uint8_t *)sym_op->aead.digest.data)) {
+			if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+				     (uint8_t *)sym_op->aead.digest.data)) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size = sess_misc->mac_len;
 				fc_params.mac_buf.vaddr =
@@ -3211,9 +3210,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 
 			/* hmac immediately following data is best case */
 			if (!ctx->dec_auth && !ctx->auth_enc &&
-				 (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			     (uint8_t *)sym_op->auth.digest.data))) {
+				 (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+					   (uint8_t *)sym_op->auth.digest.data))) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size =
 					sess_misc->mac_len;
Signature · 1 line
2.39.2
#47 lore raw

PATCH v3 12/14 crypto/caam_jr: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/crypto/caam_jr/caam_jr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/caam_jr/caam_jr.c +4 -4
index b55258689b49..9c96fd21a48d 100644
@@ -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 =
Signature · 1 line
2.39.2
#48 lore raw

PATCH v3 13/14 net/mlx4: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/mlx4/mlx4_rxtx.c +3 -3
index 059e432a63fc..d5feeb7f7e6d 100644
@@ -1014,9 +1014,9 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			 * loopback in eSwitch, so that VFs and PF can
 			 * communicate with each other.
 			 */
-			srcrb.flags16[0] = *(rte_pktmbuf_mtod(buf, uint16_t *));
-			ctrl->imm = *(rte_pktmbuf_mtod_offset(buf, uint32_t *,
-					      sizeof(uint16_t)));
+			srcrb.flags16[0] = *rte_pktmbuf_mtod(buf, uint16_t *);
+			ctrl->imm = *rte_pktmbuf_mtod_offset(buf, uint32_t *,
+							     sizeof(uint16_t));
 		} else {
 			ctrl->imm = 0;
 		}
Signature · 1 line
2.39.2
#49 lore raw

Re: [PATCH v3 13/14] net/mlx4: use rte_pktmbuf_mtod_offset

Quoted 14 lines · Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/mlx4/mlx4_rxtx.c +0 -0
index 059e432a63fc..d5feeb7f7e6d 100644
@@ -1014,9 +1014,9 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			 * loopback in eSwitch, so that VFs and PF can
 			 * communicate with each other.

drivers/net/mlx4/mlx4_rxtx.c mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) · line 1022

Quoted 10 lines
drivers/net/mlx4/mlx4_rxtx.c +3 -3
 			 */
-			srcrb.flags16[0] = *(rte_pktmbuf_mtod(buf, uint16_t *));
-			ctrl->imm = *(rte_pktmbuf_mtod_offset(buf, uint32_t *,
-					      sizeof(uint16_t)));
+			srcrb.flags16[0] = *rte_pktmbuf_mtod(buf, uint16_t *);
+			ctrl->imm = *rte_pktmbuf_mtod_offset(buf, uint32_t *,
+							     sizeof(uint16_t));
 		} else {
 			ctrl->imm = 0;
 		}

Although parenthesis may not be required, keeping them looks more clear to me; personal preferences.

And patch title is not accurate for this patch.

#50 lore raw

PATCH v3 14/14 baseband/fpga_5gnr: use rte_pktmbu_mtod_offset

In reply to Stephen Hemminger

Autogenerated with cocci/mtod-offset.cocci.

---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +3 -4
index f29565af8cca..465a65f3dca2 100644
@@ -1543,8 +1543,7 @@ fpga_harq_write_loopback(struct fpga_queue *q,
 		rte_bbdev_log(ERR, "HARQ in length > HARQ buffer size\n");
 	}
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_input,
-			uint8_t *, in_offset);
+	input = rte_pktmbuf_mtod_offset(harq_input, uint64_t *, in_offset);
 
 	while (left_length > 0) {
 		if (fpga_reg_read_8(q->d->mmio_base,
@@ -1621,8 +1620,8 @@ fpga_harq_read_loopback(struct fpga_queue *q,
 	}
 	left_length = harq_in_length;
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_output,
-			uint8_t *, harq_out_offset);
+	input = rte_pktmbuf_mtod_offset(harq_output, uint64_t *,
+					harq_out_offset);
 
 	while (left_length > 0) {
 		fpga_reg_write_32(q->d->mmio_base,
Signature · 1 line
2.39.2
Reviewed-by on the v3 series
#51 lore raw

Re: [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible

In reply to Stephen Hemminger
Quoted 5 lines · Stephen Hemminger

Run the coccinelle script for rte_pktmbuf_mtod_offset against current main branch.

v3 - rebase to cover gro changes

There is one more instance in 'gro_tcp6.c'

```
$ ag -s 'rte_pktmbuf_mtod\(.*\).*\+' lib/
lib/gro/gro_tcp6.c
121:    ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
```
Quoted 7 lines

Stephen Hemminger (14):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset
test: cryptodev use rte_pktmbuf_mtod_offset
examples: use rte_pktmbuf_mtod_offset
net/tap: use rte_pktmbuf_mtod_offset

Quoted 8 lines

net/nfp: use rte_pktmbuf_mtod_offset
crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
crypto/qat: use rte_pktmbuf_mtod_offset
crypto/cnxk: use rte_ptkmbuf_mtod_offset
common/cpt: use rte_pktmbuf_mtod_offset
crypto/caam_jr: use rte_pktmbuf_mtod_offset
net/mlx4: use rte_pktmbuf_mtod_offset
baseband/fpga_5gnr: use rte_pktmbu_mtod_offset

For series,

There are a few minor issues commented on individual patches.

#52 lore raw

v4 cover Use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

v4 - drop mlx4 change not needed
- add some new ones in gro

Stephen Hemminger (11):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset
test: use rte_pktmbuf_mtod_offset drivers/crypto: use rte_pktmbuf_mtod_offset net/nfp: use rte_pktmbuf_mtod_offset net/tap: use rte_pktmbuf_motd_offset baseband/fpga: use rte_pktmbuf_offset
cpt: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset examples/ptpclient: use rte_pktmbuf_mtod_offset examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

 app/test-pmd/ieee1588fwd.c                    |  4 +-
 app/test/test_cryptodev.c                     | 66 ++++++++++---------
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         |  7 +-
 drivers/common/cpt/cpt_ucode.h                | 10 ++-
 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 +--
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  4 +-
 drivers/net/tap/rte_eth_tap.c                 |  4 +-
 examples/l2fwd-crypto/main.c                  | 16 +++--
 examples/ptpclient/ptpclient.c                | 18 ++---
 lib/gro/gro_tcp.h                             |  4 +-
 lib/gro/gro_tcp4.c                            |  4 +-
 lib/gro/gro_tcp6.c                            |  4 +-
 lib/gro/gro_udp4.c                            |  4 +-
 lib/gro/gro_vxlan_tcp4.c                      |  4 +-
 lib/gro/gro_vxlan_udp4.c                      |  4 +-
 lib/gso/gso_common.h                          | 12 ++--
 lib/gso/gso_tcp4.c                            |  8 +--
 lib/gso/gso_tunnel_tcp4.c                     | 12 ++--
 lib/gso/gso_tunnel_udp4.c                     | 18 ++---
 27 files changed, 146 insertions(+), 134 deletions(-)
Signature · 1 line
2.39.2
#53 lore raw

PATCH v4 1/11 gro: use rte_pktmbuf_mtod_offset

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 lib/gro/gro_tcp.h        | 4 ++--
 lib/gro/gro_tcp4.c       | 4 ++--
 lib/gro/gro_tcp6.c       | 4 ++--
 lib/gro/gro_udp4.c       | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)
lib/gro/gro_tcp.h +2 -2
index d926c4b8cc71..bbd2f9c16a00 100644
@@ -150,8 +150,8 @@ check_seq_option(struct gro_tcp_item *item,
 	struct rte_tcp_hdr *tcph_orig;
 	uint16_t len, tcp_hl_orig;
 
-	iph_orig = (char *)(rte_pktmbuf_mtod(pkt_orig, char *) +
-			l2_offset + pkt_orig->l2_len);
+	iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, char *,
+					   l2_offset + pkt_orig->l2_len);
 	tcph_orig = (struct rte_tcp_hdr *)(iph_orig + pkt_orig->l3_len);
 	tcp_hl_orig = pkt_orig->l4_len;
 
lib/gro/gro_tcp4.c +2 -2
index 6645de592b63..d6c0f9182d45 100644
@@ -223,8 +223,8 @@ update_header(struct gro_tcp_item *item)
 	struct rte_ipv4_hdr *ipv4_hdr;
 	struct rte_mbuf *pkt = item->firstseg;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 }
lib/gro/gro_tcp6.c +2 -2
index 5aa39801e132..6edfb6045cf6 100644
@@ -118,8 +118,8 @@ update_header(struct gro_tcp_item *item)
 	struct rte_ipv6_hdr *ipv6_hdr;
 	struct rte_mbuf *pkt = item->firstseg;
 
-	ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv6_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv6_hdr *,
+					   pkt->l2_len);
 	ipv6_hdr->payload_len = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len - pkt->l3_len);
 }
lib/gro/gro_udp4.c +2 -2
index 42596d33b6dc..019e05bcdea5 100644
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
 	struct rte_mbuf *pkt = item->firstseg;
 	uint16_t frag_offset;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 
lib/gro/gro_vxlan_tcp4.c +2 -2
index 6ab700192261..2752650389a4 100644
@@ -263,8 +263,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
lib/gro/gro_vxlan_udp4.c +2 -2
index b78a7ae89eef..ca8cee270d3d 100644
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
Signature · 1 line
2.39.2
#54 lore raw

PATCH v4 2/11 gso: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 lib/gso/gso_common.h      | 12 ++++++------
 lib/gso/gso_tcp4.c        |  8 ++++----
 lib/gso/gso_tunnel_tcp4.c | 12 ++++++------
 lib/gso/gso_tunnel_udp4.c | 18 +++++++++---------
 4 files changed, 25 insertions(+), 25 deletions(-)
lib/gso/gso_common.h +6 -6
index 9456d596d3c5..4100765f2355 100644
@@ -52,8 +52,8 @@ update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)
 {
 	struct rte_udp_hdr *udp_hdr;
 
-	udp_hdr = (struct rte_udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			udp_offset);
+	udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *,
+					  udp_offset);
 	udp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);
 }
 
@@ -77,8 +77,8 @@ update_tcp_header(struct rte_mbuf *pkt, uint16_t l4_offset, uint32_t sent_seq,
 {
 	struct rte_tcp_hdr *tcp_hdr;
 
-	tcp_hdr = (struct rte_tcp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l4_offset);
+	tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *,
+				          l4_offset);
 	tcp_hdr->sent_seq = rte_cpu_to_be_32(sent_seq);
 	if (likely(non_tail))
 		tcp_hdr->tcp_flags &= (~(TCP_HDR_PSH_MASK |
@@ -104,8 +104,8 @@ update_ipv4_header(struct rte_mbuf *pkt, uint16_t l3_offset, uint16_t id)
 {
 	struct rte_ipv4_hdr *ipv4_hdr;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - l3_offset);
 	ipv4_hdr->packet_id = rte_cpu_to_be_16(id);
 }
lib/gso/gso_tcp4.c +4 -4
index d31feaff95cd..e2ae4aaf6c5a 100644
@@ -16,8 +16,8 @@ update_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	uint16_t l3_offset = pkt->l2_len;
 	uint16_t l4_offset = l3_offset + pkt->l3_len;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char*) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
 	id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 	sent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);
@@ -46,8 +46,8 @@ gso_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	/* Don't process the fragmented packet */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
 	if (unlikely(IS_FRAGMENTED(frag_off))) {
 		return 0;
lib/gso/gso_tunnel_tcp4.c +6 -6
index 1a7ef30ddebf..3a9159774b27 100644
@@ -23,13 +23,13 @@ update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	tcp_offset = inner_ipv4_offset + pkt->l3_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
@@ -65,8 +65,8 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
lib/gso/gso_tunnel_udp4.c +9 -9
index 1fc7a8dbc5aa..4fb275484ca8 100644
@@ -22,13 +22,13 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 	inner_ipv4_offset = outer_udp_offset + pkt->l2_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tail_idx = nb_segs - 1;
@@ -42,9 +42,9 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 		 *
 		 * Set IP fragment offset for inner IP header.
 		 */
-		ipv4_hdr = (struct rte_ipv4_hdr *)
-			(rte_pktmbuf_mtod(segs[i], char *) +
-				inner_ipv4_offset);
+		ipv4_hdr = rte_pktmbuf_mtod_offset(segs[i],
+						   struct rte_ipv4_hdr *,
+						   inner_ipv4_offset);
 		is_mf = i < tail_idx ? IPV4_HDR_MF_BIT : 0;
 		ipv4_hdr->fragment_offset =
 			rte_cpu_to_be_16(frag_offset | is_mf);
@@ -67,8 +67,8 @@ gso_tunnel_udp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
Signature · 1 line
2.39.2
#55 lore raw

PATCH v4 3/11 test: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 30 deletions(-)
app/test/test_cryptodev.c +36 -30
index fb2af40b99ee..c79681255106 100644
@@ -3153,8 +3153,9 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3247,8 +3248,9 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3337,8 +3339,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3425,8 +3428,9 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4879,8 +4883,9 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"ZUC Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4994,8 +4999,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"SNOW 3G Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5163,9 +5169,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ (tdata->digest.offset_bytes == 0 ?
-		plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest.offset_bytes == 0 ? plaintext_pad_len : tdata->digest.offset_bytes));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5577,10 +5583,9 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest.offset_bytes == 0 ? plaintext_pad_len : tdata->digest.offset_bytes));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5924,8 +5929,9 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
 				tdata->validCipherOffsetInBits.len >> 3);
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
 				(tdata->validCipherOffsetInBits.len >> 3);
@@ -6344,8 +6350,9 @@ test_zuc_authentication(const struct wireless_test_data *tdata,
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
 		/* Validate obuf */
@@ -6531,10 +6538,9 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest.offset_bytes == 0 ? plaintext_pad_len : tdata->digest.offset_bytes));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -7959,9 +7965,9 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
 				tdata->ciphertext.data,
 				tdata->ciphertext.len_bits >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ (tdata->digest_enc.offset == 0 ?
-		plaintext_pad_len : tdata->digest_enc.offset);
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+							    uint8_t *,
+							    (tdata->digest_enc.offset == 0 ? plaintext_pad_len : tdata->digest_enc.offset));
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 				tdata->digest_enc.len);
Signature · 1 line
2.39.2
#56 lore raw

PATCH v4 4/11 drivers/crypto: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 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(-)
drivers/crypto/caam_jr/caam_jr.c +4 -4
index b55258689b49..9c96fd21a48d 100644
@@ -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 =
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -1
index 34d40b07d4c6..8b91d11b79cc 100644
@@ -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);
drivers/crypto/cnxk/cnxk_se.h +2 -3
index 75c1dce231bf..1392af5833d1 100644
@@ -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;
drivers/crypto/ipsec_mb/pmd_kasumi.c +11 -8
index 5db9c523cd9a..70536ec3dc2a 100644
@@ -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;
 
drivers/crypto/ipsec_mb/pmd_snow3g.c +2 -2
index e64df1a462e3..a96779f05942 100644
@@ -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);
 
drivers/crypto/ipsec_mb/pmd_zuc.c +10 -8
index 92fd9d180894..44781be1d107 100644
@@ -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);
 
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h +5 -4
index 1bafeb4a53e8..3e0dfea94c87 100644
@@ -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;
 
drivers/crypto/qat/qat_sym.h +5 -4
index 193281cd9135..d7ceb13b29cd 100644
@@ -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;
 
Signature · 1 line
2.39.2
#57 lore raw

PATCH v4 5/11 net/nfp: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +2 -1
index f643d54d39a4..787a38dc9aa0 100644
@@ -381,7 +381,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+	return rte_pktmbuf_mtod_offset(m, char *,
+				       4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
drivers/net/nfp/flower/nfp_flower_ctrl.c +2 -2
index 4cb2c2f99e04..18823a97887d 100644
@@ -389,7 +389,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
 	uint32_t ctx_id;
 	struct nfp_flower_stats_frame *stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 	msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
 	count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -412,7 +412,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 	struct nfp_mtr *mtr;
 	struct nfp_mtr_stats_reply *mtr_stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
 	mtr_stats = (struct nfp_mtr_stats_reply *)msg;
 	profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
Signature · 1 line
2.39.2
#58 lore raw

PATCH v4 6/11 net/tap: use rte_pktmbuf_motd_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/net/tap/rte_eth_tap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +2 -2
index bf98f7555990..968a1b6b45df 100644
@@ -672,8 +672,8 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 			if (seg_len > l234_hlen) {
 				iovecs[k].iov_len = seg_len - l234_hlen;
 				iovecs[k].iov_base =
-					rte_pktmbuf_mtod(seg, char *) +
-						l234_hlen;
+					rte_pktmbuf_mtod_offset(seg, char *,
+								l234_hlen);
 				tap_tx_l4_add_rcksum(iovecs[k].iov_base,
 					iovecs[k].iov_len, l4_cksum,
 					&l4_raw_cksum);
Signature · 1 line
2.39.2
#59 lore raw

PATCH v4 7/11 baseband/fpga: use rte_pktmbuf_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +3 -4
index f29565af8cca..465a65f3dca2 100644
@@ -1543,8 +1543,7 @@ fpga_harq_write_loopback(struct fpga_queue *q,
 		rte_bbdev_log(ERR, "HARQ in length > HARQ buffer size\n");
 	}
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_input,
-			uint8_t *, in_offset);
+	input = rte_pktmbuf_mtod_offset(harq_input, uint64_t *, in_offset);
 
 	while (left_length > 0) {
 		if (fpga_reg_read_8(q->d->mmio_base,
@@ -1621,8 +1620,8 @@ fpga_harq_read_loopback(struct fpga_queue *q,
 	}
 	left_length = harq_in_length;
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_output,
-			uint8_t *, harq_out_offset);
+	input = rte_pktmbuf_mtod_offset(harq_output, uint64_t *,
+					harq_out_offset);
 
 	while (left_length > 0) {
 		fpga_reg_write_32(q->d->mmio_base,
Signature · 1 line
2.39.2
#60 lore raw

PATCH v4 8/11 cpt: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/common/cpt/cpt_ucode.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/common/cpt/cpt_ucode.h +4 -6
index b393be4cf661..87a3ac80b9da 100644
@@ -3167,9 +3167,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 				m = m_src;
 
 			/* hmac immediately following data is best case */
-			if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			    (uint8_t *)sym_op->aead.digest.data)) {
+			if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+				     (uint8_t *)sym_op->aead.digest.data)) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size = sess_misc->mac_len;
 				fc_params.mac_buf.vaddr =
@@ -3211,9 +3210,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 
 			/* hmac immediately following data is best case */
 			if (!ctx->dec_auth && !ctx->auth_enc &&
-				 (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			     (uint8_t *)sym_op->auth.digest.data))) {
+				 (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+					   (uint8_t *)sym_op->auth.digest.data))) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size =
 					sess_misc->mac_len;
Signature · 1 line
2.39.2
#61 lore raw

PATCH v4 9/11 testpmd: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 app/test-pmd/ieee1588fwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/ieee1588fwd.c +2 -2
index 386d9f10e642..3371771751dd 100644
@@ -138,8 +138,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 	 * Check that the received PTP packet is a PTP V2 packet of type
 	 * PTP_SYNC_MESSAGE.
 	 */
-	ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
+					  sizeof(struct rte_ether_hdr));
 	if (ptp_hdr->version != 0x02) {
 		printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
 		       " protocol version 0x%x (should be 0x02)\n",
Signature · 1 line
2.39.2
#62 lore raw

PATCH v4 10/11 examples/ptpclient: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 examples/ptpclient/ptpclient.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
examples/ptpclient/ptpclient.c +9 -9
index cdf2da64dfee..2535d848a1e9 100644
@@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx)
 {
 	struct ptp_header *ptp_hdr;
 
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
 	if (ptp_data->ptpset == 0) {
@@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
 	int ret;
 
 	eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	if (memcmp(&ptp_data->master_clock_id,
 			&ptp_hdr->source_port_id.clock_id,
 			sizeof(struct clock_id)) != 0)
 		return;
 
 	ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id);
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
 					  sizeof(struct rte_ether_hdr));
 
 	origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp;
@@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data)
 	struct tstamp *rx_tstamp;
 	uint16_t seq_id;
 
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
+					  sizeof(struct rte_ether_hdr));
 	seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id);
 	if (memcmp(&ptp_data->client_clock_id,
 		   &ptp_msg->delay_resp.req_port_id.clock_id,
@@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
 	if (eth_type == PTP_PROTOCOL) {
 		ptp_data.m = m;
 		ptp_data.portid = portid;
-		ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-					+ sizeof(struct rte_ether_hdr));
+		ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+						  sizeof(struct rte_ether_hdr));
 
 		switch (ptp_hdr->msg_type) {
 		case SYNC:
Signature · 1 line
2.39.2
#63 lore raw

PATCH v4 11/11 examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 examples/l2fwd-crypto/main.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
examples/l2fwd-crypto/main.c +9 -7
index efe7eea2a768..981b449710a7 100644
@@ -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,9 @@ 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 +541,9 @@ 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 +633,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];
 
Signature · 1 line
2.39.2
#64 lore raw

v5 cover use rte_pktmbuf_mto_offset

In reply to Stephen Hemminger

v5 - fix checkpatch warnings about long lines
split up complex expression in test/crypto_dev

Stephen Hemminger (11):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset test/crypto_dev: use rte_pktmbuf_mtod_offset drivers/crypto: use rte_pktmbuf_mtod_offset net/nfp: use rte_pktmbuf_mtod_offset net/tap: use rte_pktmbuf_motd_offset baseband/fpga: use rte_pktmbuf_offset
cpt: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset examples/ptpclient: use rte_pktmbuf_mtod_offset examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

 app/test-pmd/ieee1588fwd.c                    |  4 +-
 app/test/test_cryptodev.c                     | 83 ++++++++++++-------
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         |  7 +-
 drivers/common/cpt/cpt_ucode.h                | 10 +--
 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 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  4 +-
 drivers/net/tap/rte_eth_tap.c                 |  4 +-
 examples/l2fwd-crypto/main.c                  | 14 ++--
 examples/ptpclient/ptpclient.c                | 18 ++--
 lib/gro/gro_tcp.h                             |  4 +-
 lib/gro/gro_tcp4.c                            |  4 +-
 lib/gro/gro_tcp6.c                            |  4 +-
 lib/gro/gro_udp4.c                            |  4 +-
 lib/gro/gro_vxlan_tcp4.c                      |  4 +-
 lib/gro/gro_vxlan_udp4.c                      |  4 +-
 lib/gso/gso_common.h                          | 12 +--
 lib/gso/gso_tcp4.c                            |  8 +-
 lib/gso/gso_tunnel_tcp4.c                     | 12 +--
 lib/gso/gso_tunnel_udp4.c                     | 18 ++--
 27 files changed, 161 insertions(+), 134 deletions(-)
Signature · 1 line
2.39.2
#65 lore raw

PATCH v5 1/11 gro: use rte_pktmbuf_mtod_offset

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 lib/gro/gro_tcp.h        | 4 ++--
 lib/gro/gro_tcp4.c       | 4 ++--
 lib/gro/gro_tcp6.c       | 4 ++--
 lib/gro/gro_udp4.c       | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)
lib/gro/gro_tcp.h +2 -2
index d926c4b8cc71..bbd2f9c16a00 100644
@@ -150,8 +150,8 @@ check_seq_option(struct gro_tcp_item *item,
 	struct rte_tcp_hdr *tcph_orig;
 	uint16_t len, tcp_hl_orig;
 
-	iph_orig = (char *)(rte_pktmbuf_mtod(pkt_orig, char *) +
-			l2_offset + pkt_orig->l2_len);
+	iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, char *,
+					   l2_offset + pkt_orig->l2_len);
 	tcph_orig = (struct rte_tcp_hdr *)(iph_orig + pkt_orig->l3_len);
 	tcp_hl_orig = pkt_orig->l4_len;
 
lib/gro/gro_tcp4.c +2 -2
index 6645de592b63..d6c0f9182d45 100644
@@ -223,8 +223,8 @@ update_header(struct gro_tcp_item *item)
 	struct rte_ipv4_hdr *ipv4_hdr;
 	struct rte_mbuf *pkt = item->firstseg;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 }
lib/gro/gro_tcp6.c +2 -2
index 5aa39801e132..6edfb6045cf6 100644
@@ -118,8 +118,8 @@ update_header(struct gro_tcp_item *item)
 	struct rte_ipv6_hdr *ipv6_hdr;
 	struct rte_mbuf *pkt = item->firstseg;
 
-	ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv6_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv6_hdr *,
+					   pkt->l2_len);
 	ipv6_hdr->payload_len = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len - pkt->l3_len);
 }
lib/gro/gro_udp4.c +2 -2
index 42596d33b6dc..019e05bcdea5 100644
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
 	struct rte_mbuf *pkt = item->firstseg;
 	uint16_t frag_offset;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
 			pkt->l2_len);
 
lib/gro/gro_vxlan_tcp4.c +2 -2
index 6ab700192261..2752650389a4 100644
@@ -263,8 +263,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
lib/gro/gro_vxlan_udp4.c +2 -2
index b78a7ae89eef..ca8cee270d3d 100644
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
 	/* Update the outer IPv4 header. */
 	len = pkt->pkt_len - pkt->outer_l2_len;
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->outer_l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->outer_l2_len);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
 	/* Update the outer UDP header. */
Signature · 1 line
2.39.2
#66 lore raw

PATCH v5 2/11 gso: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 lib/gso/gso_common.h      | 12 ++++++------
 lib/gso/gso_tcp4.c        |  8 ++++----
 lib/gso/gso_tunnel_tcp4.c | 12 ++++++------
 lib/gso/gso_tunnel_udp4.c | 18 +++++++++---------
 4 files changed, 25 insertions(+), 25 deletions(-)
lib/gso/gso_common.h +6 -6
index 9456d596d3c5..d1c1b73091e2 100644
@@ -52,8 +52,8 @@ update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)
 {
 	struct rte_udp_hdr *udp_hdr;
 
-	udp_hdr = (struct rte_udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			udp_offset);
+	udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *,
+					  udp_offset);
 	udp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);
 }
 
@@ -77,8 +77,8 @@ update_tcp_header(struct rte_mbuf *pkt, uint16_t l4_offset, uint32_t sent_seq,
 {
 	struct rte_tcp_hdr *tcp_hdr;
 
-	tcp_hdr = (struct rte_tcp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l4_offset);
+	tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *,
+					  l4_offset);
 	tcp_hdr->sent_seq = rte_cpu_to_be_32(sent_seq);
 	if (likely(non_tail))
 		tcp_hdr->tcp_flags &= (~(TCP_HDR_PSH_MASK |
@@ -104,8 +104,8 @@ update_ipv4_header(struct rte_mbuf *pkt, uint16_t l3_offset, uint16_t id)
 {
 	struct rte_ipv4_hdr *ipv4_hdr;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - l3_offset);
 	ipv4_hdr->packet_id = rte_cpu_to_be_16(id);
 }
lib/gso/gso_tcp4.c +4 -4
index d31feaff95cd..e2ae4aaf6c5a 100644
@@ -16,8 +16,8 @@ update_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	uint16_t l3_offset = pkt->l2_len;
 	uint16_t l4_offset = l3_offset + pkt->l3_len;
 
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char*) +
-			l3_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   l3_offset);
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
 	id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 	sent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);
@@ -46,8 +46,8 @@ gso_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	/* Don't process the fragmented packet */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			pkt->l2_len);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   pkt->l2_len);
 	frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
 	if (unlikely(IS_FRAGMENTED(frag_off))) {
 		return 0;
lib/gso/gso_tunnel_tcp4.c +6 -6
index 1a7ef30ddebf..3a9159774b27 100644
@@ -23,13 +23,13 @@ update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,
 	tcp_offset = inner_ipv4_offset + pkt->l3_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
@@ -65,8 +65,8 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
lib/gso/gso_tunnel_udp4.c +9 -9
index 1fc7a8dbc5aa..4fb275484ca8 100644
@@ -22,13 +22,13 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 	inner_ipv4_offset = outer_udp_offset + pkt->l2_len;
 
 	/* Outer IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			outer_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   outer_ipv4_offset);
 	outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	/* Inner IPv4 header. */
-	ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			inner_ipv4_offset);
+	ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+					   inner_ipv4_offset);
 	inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
 	tail_idx = nb_segs - 1;
@@ -42,9 +42,9 @@ update_tunnel_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,
 		 *
 		 * Set IP fragment offset for inner IP header.
 		 */
-		ipv4_hdr = (struct rte_ipv4_hdr *)
-			(rte_pktmbuf_mtod(segs[i], char *) +
-				inner_ipv4_offset);
+		ipv4_hdr = rte_pktmbuf_mtod_offset(segs[i],
+						   struct rte_ipv4_hdr *,
+						   inner_ipv4_offset);
 		is_mf = i < tail_idx ? IPV4_HDR_MF_BIT : 0;
 		ipv4_hdr->fragment_offset =
 			rte_cpu_to_be_16(frag_offset | is_mf);
@@ -67,8 +67,8 @@ gso_tunnel_udp4_segment(struct rte_mbuf *pkt,
 	int ret;
 
 	hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-	inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-			hdr_offset);
+	inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+						 hdr_offset);
 	/*
 	 * Don't process the packet whose MF bit or offset in the inner
 	 * IPv4 header are non-zero.
Signature · 1 line
2.39.2
#67 lore raw

PATCH v5 3/11 test/crypto_dev: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 app/test/test_cryptodev.c | 83 +++++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 30 deletions(-)
app/test/test_cryptodev.c +53 -30
index fb2af40b99ee..549afe252d54 100644
@@ -3153,8 +3153,9 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3247,8 +3248,9 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3337,8 +3339,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 
 	ut_params->obuf = ut_params->op->sym->m_src;
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3425,8 +3428,9 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4879,8 +4883,9 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"ZUC Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4994,8 +4999,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
 			tdata->validDataLenInBits.len,
 			"SNOW 3G Ciphertext data not as expected");
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-	    + plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	/* Validate obuf */
 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5020,6 +5026,7 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 	unsigned int plaintext_len;
 	unsigned int ciphertext_pad_len;
 	unsigned int ciphertext_len;
+	unsigned int digest_offset;
 
 	struct rte_cryptodev_info dev_info;
 
@@ -5163,9 +5170,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ (tdata->digest.offset_bytes == 0 ?
-		plaintext_pad_len : tdata->digest.offset_bytes);
+		if (tdata->digest.offset_bytes == 0)
+			digest_offset = plaintext_pad_len;
+		else
+			digest_offset = tdata->digest.offset_bytes;
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *, digest_offset);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5432,6 +5442,7 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
 	unsigned int plaintext_len;
 	unsigned int ciphertext_pad_len;
 	unsigned int ciphertext_len;
+	unsigned int digest_offset;
 
 	struct rte_cryptodev_info dev_info;
 
@@ -5577,10 +5588,12 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		if (tdata->digest.offset_bytes == 0)
+			digest_offset = plaintext_pad_len;
+		else
+			digest_offset = tdata->digest.offset_bytes;
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *, digest_offset);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -5924,8 +5937,9 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
 				tdata->validCipherOffsetInBits.len >> 3);
 
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
 				(tdata->validCipherOffsetInBits.len >> 3);
@@ -6344,8 +6358,9 @@ test_zuc_authentication(const struct wireless_test_data *tdata,
 				ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 	ut_params->obuf = ut_params->op->sym->m_src;
-	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-			+ plaintext_pad_len;
+	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+						    uint8_t *,
+						    plaintext_pad_len);
 
 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
 		/* Validate obuf */
@@ -6380,6 +6395,7 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
 	unsigned int plaintext_len;
 	unsigned int ciphertext_pad_len;
 	unsigned int ciphertext_len;
+	unsigned int digest_offset;
 
 	struct rte_cryptodev_info dev_info;
 
@@ -6531,10 +6547,12 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
 		debug_hexdump(stdout, "ciphertext expected:",
 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(
-			ut_params->obuf, uint8_t *) +
-			(tdata->digest.offset_bytes == 0 ?
-			plaintext_pad_len : tdata->digest.offset_bytes);
+		if (tdata->digest.offset_bytes == 0)
+			digest_offset = plaintext_pad_len;
+		else
+			digest_offset =  tdata->digest.offset_bytes;
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					    uint8_t *, digest_offset);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 			tdata->digest.len);
@@ -7819,6 +7837,7 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
 	unsigned int plaintext_len;
 	unsigned int ciphertext_pad_len;
 	unsigned int ciphertext_len;
+	unsigned int digest_offset;
 
 	struct rte_cryptodev_info dev_info;
 	struct rte_crypto_op *op;
@@ -7959,9 +7978,13 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
 				tdata->ciphertext.data,
 				tdata->ciphertext.len_bits >> 3);
 
-		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-				+ (tdata->digest_enc.offset == 0 ?
-		plaintext_pad_len : tdata->digest_enc.offset);
+		if (tdata->digest_enc.offset == 0)
+			digest_offset = plaintext_pad_len;
+		else
+			digest_offset = tdata->digest_enc.offset;
+
+		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+					    uint8_t *, digest_offset);
 
 		debug_hexdump(stdout, "digest:", ut_params->digest,
 				tdata->digest_enc.len);
Signature · 1 line
2.39.2
#68 lore raw

PATCH v5 4/11 drivers/crypto: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 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(-)
drivers/crypto/caam_jr/caam_jr.c +4 -4
index b55258689b49..9c96fd21a48d 100644
@@ -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 =
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -1
index 34d40b07d4c6..8b91d11b79cc 100644
@@ -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);
drivers/crypto/cnxk/cnxk_se.h +2 -3
index 75c1dce231bf..1392af5833d1 100644
@@ -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;
drivers/crypto/ipsec_mb/pmd_kasumi.c +11 -8
index 5db9c523cd9a..70536ec3dc2a 100644
@@ -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;
 
drivers/crypto/ipsec_mb/pmd_snow3g.c +2 -2
index e64df1a462e3..a96779f05942 100644
@@ -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);
 
drivers/crypto/ipsec_mb/pmd_zuc.c +10 -8
index 92fd9d180894..44781be1d107 100644
@@ -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);
 
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h +5 -4
index 1bafeb4a53e8..3e0dfea94c87 100644
@@ -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;
 
drivers/crypto/qat/qat_sym.h +5 -4
index 193281cd9135..d7ceb13b29cd 100644
@@ -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;
 
Signature · 1 line
2.39.2
#71 lore raw

PATCH v5 5/11 net/nfp: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +2 -1
index f643d54d39a4..787a38dc9aa0 100644
@@ -381,7 +381,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+	return rte_pktmbuf_mtod_offset(m, char *,
+				       4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
drivers/net/nfp/flower/nfp_flower_ctrl.c +2 -2
index 4cb2c2f99e04..18823a97887d 100644
@@ -389,7 +389,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
 	uint32_t ctx_id;
 	struct nfp_flower_stats_frame *stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 	msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
 	count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -412,7 +412,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 	struct nfp_mtr *mtr;
 	struct nfp_mtr_stats_reply *mtr_stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
 	mtr_stats = (struct nfp_mtr_stats_reply *)msg;
 	profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
Signature · 1 line
2.39.2
Reviewed-by on v5 5/11
#72 lore raw

Re: [PATCH v5 05/11] net/nfp: use rte_pktmbuf_mtod_offset

Quoted 3 lines · Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Quoted 44 lines
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +2 -1
index f643d54d39a4..787a38dc9aa0 100644
@@ -381,7 +381,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-	return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+	return rte_pktmbuf_mtod_offset(m, char *,
+				       4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
drivers/net/nfp/flower/nfp_flower_ctrl.c +2 -2
index 4cb2c2f99e04..18823a97887d 100644
@@ -389,7 +389,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
 	uint32_t ctx_id;
 	struct nfp_flower_stats_frame *stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 	msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
 	count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -412,7 +412,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 	struct nfp_mtr *mtr;
 	struct nfp_mtr_stats_reply *mtr_stats;
 
-	msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+	msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
 	mtr_stats = (struct nfp_mtr_stats_reply *)msg;
 	profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
Signature · 1 line
2.39.2
Signature · 2 lines
Kind Regards,
Niklas Söderlund
#74 lore raw

PATCH v5 6/11 net/tap: use rte_pktmbuf_motd_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/net/tap/rte_eth_tap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +2 -2
index bf98f7555990..968a1b6b45df 100644
@@ -672,8 +672,8 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 			if (seg_len > l234_hlen) {
 				iovecs[k].iov_len = seg_len - l234_hlen;
 				iovecs[k].iov_base =
-					rte_pktmbuf_mtod(seg, char *) +
-						l234_hlen;
+					rte_pktmbuf_mtod_offset(seg, char *,
+								l234_hlen);
 				tap_tx_l4_add_rcksum(iovecs[k].iov_base,
 					iovecs[k].iov_len, l4_cksum,
 					&l4_raw_cksum);
Signature · 1 line
2.39.2
#75 lore raw

Re: [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset

08/07/2023 03:57, Stephen Hemminger:

Quoted 3 lines

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

It has been reworked by David Marchand in 23.11.

#76 lore raw

PATCH v5 7/11 baseband/fpga: use rte_pktmbuf_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +3 -4
index f29565af8cca..465a65f3dca2 100644
@@ -1543,8 +1543,7 @@ fpga_harq_write_loopback(struct fpga_queue *q,
 		rte_bbdev_log(ERR, "HARQ in length > HARQ buffer size\n");
 	}
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_input,
-			uint8_t *, in_offset);
+	input = rte_pktmbuf_mtod_offset(harq_input, uint64_t *, in_offset);
 
 	while (left_length > 0) {
 		if (fpga_reg_read_8(q->d->mmio_base,
@@ -1621,8 +1620,8 @@ fpga_harq_read_loopback(struct fpga_queue *q,
 	}
 	left_length = harq_in_length;
 
-	input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_output,
-			uint8_t *, harq_out_offset);
+	input = rte_pktmbuf_mtod_offset(harq_output, uint64_t *,
+					harq_out_offset);
 
 	while (left_length > 0) {
 		fpga_reg_write_32(q->d->mmio_base,
Signature · 1 line
2.39.2
#77 lore raw

PATCH v5 8/11 cpt: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 drivers/common/cpt/cpt_ucode.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/common/cpt/cpt_ucode.h +4 -6
index b393be4cf661..87a3ac80b9da 100644
@@ -3167,9 +3167,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 				m = m_src;
 
 			/* hmac immediately following data is best case */
-			if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			    (uint8_t *)sym_op->aead.digest.data)) {
+			if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+				     (uint8_t *)sym_op->aead.digest.data)) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size = sess_misc->mac_len;
 				fc_params.mac_buf.vaddr =
@@ -3211,9 +3210,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 
 			/* hmac immediately following data is best case */
 			if (!ctx->dec_auth && !ctx->auth_enc &&
-				 (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-			    mc_hash_off !=
-			     (uint8_t *)sym_op->auth.digest.data))) {
+				 (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) !=
+					   (uint8_t *)sym_op->auth.digest.data))) {
 				flags |= VALID_MAC_BUF;
 				fc_params.mac_buf.size =
 					sess_misc->mac_len;
Signature · 1 line
2.39.2
#79 lore raw

PATCH v5 9/11 testpmd: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 app/test-pmd/ieee1588fwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/ieee1588fwd.c +2 -2
index 386d9f10e642..3371771751dd 100644
@@ -138,8 +138,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 	 * Check that the received PTP packet is a PTP V2 packet of type
 	 * PTP_SYNC_MESSAGE.
 	 */
-	ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
+					  sizeof(struct rte_ether_hdr));
 	if (ptp_hdr->version != 0x02) {
 		printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
 		       " protocol version 0x%x (should be 0x02)\n",
Signature · 1 line
2.39.2
#80 lore raw

PATCH v5 10/11 examples/ptpclient: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 examples/ptpclient/ptpclient.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
examples/ptpclient/ptpclient.c +9 -9
index cdf2da64dfee..2535d848a1e9 100644
@@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx)
 {
 	struct ptp_header *ptp_hdr;
 
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
 	if (ptp_data->ptpset == 0) {
@@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
 	int ret;
 
 	eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-	ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-			+ sizeof(struct rte_ether_hdr));
+	ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+					  sizeof(struct rte_ether_hdr));
 	if (memcmp(&ptp_data->master_clock_id,
 			&ptp_hdr->source_port_id.clock_id,
 			sizeof(struct clock_id)) != 0)
 		return;
 
 	ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id);
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
 					  sizeof(struct rte_ether_hdr));
 
 	origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp;
@@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data)
 	struct tstamp *rx_tstamp;
 	uint16_t seq_id;
 
-	ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
-					sizeof(struct rte_ether_hdr));
+	ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
+					  sizeof(struct rte_ether_hdr));
 	seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id);
 	if (memcmp(&ptp_data->client_clock_id,
 		   &ptp_msg->delay_resp.req_port_id.clock_id,
@@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
 	if (eth_type == PTP_PROTOCOL) {
 		ptp_data.m = m;
 		ptp_data.portid = portid;
-		ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-					+ sizeof(struct rte_ether_hdr));
+		ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+						  sizeof(struct rte_ether_hdr));
 
 		switch (ptp_hdr->msg_type) {
 		case SYNC:
Signature · 1 line
2.39.2
#81 lore raw

PATCH v5 11/11 examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

In reply to Stephen Hemminger

Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

---
 examples/l2fwd-crypto/main.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
examples/l2fwd-crypto/main.c +7 -7
index efe7eea2a768..19db0a280bf0 100644
@@ -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];
 
Signature · 1 line
2.39.2
#82 lore raw

Re: [PATCH v5 00/11] use rte_pktmbuf_mto_offset

In reply to Stephen Hemminger
Quoted 45 lines · Stephen Hemminger

v5 - fix checkpatch warnings about long lines
split up complex expression in test/crypto_dev

Stephen Hemminger (11):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset test/crypto_dev: use rte_pktmbuf_mtod_offset drivers/crypto: use rte_pktmbuf_mtod_offset net/nfp: use rte_pktmbuf_mtod_offset net/tap: use rte_pktmbuf_motd_offset baseband/fpga: use rte_pktmbuf_offset
cpt: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset examples/ptpclient: use rte_pktmbuf_mtod_offset examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

 app/test-pmd/ieee1588fwd.c                    |  4 +-
 app/test/test_cryptodev.c                     | 83 ++++++++++++-------
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         |  7 +-
 drivers/common/cpt/cpt_ucode.h                | 10 +--
 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 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  4 +-
 drivers/net/tap/rte_eth_tap.c                 |  4 +-
 examples/l2fwd-crypto/main.c                  | 14 ++--
 examples/ptpclient/ptpclient.c                | 18 ++--
 lib/gro/gro_tcp.h                             |  4 +-
 lib/gro/gro_tcp4.c                            |  4 +-
 lib/gro/gro_tcp6.c                            |  4 +-
 lib/gro/gro_udp4.c                            |  4 +-
 lib/gro/gro_vxlan_tcp4.c                      |  4 +-
 lib/gro/gro_vxlan_udp4.c                      |  4 +-
 lib/gso/gso_common.h                          | 12 +--
 lib/gso/gso_tcp4.c                            |  8 +-
 lib/gso/gso_tunnel_tcp4.c                     | 12 +--
 lib/gso/gso_tunnel_udp4.c                     | 18 ++--
 27 files changed, 161 insertions(+), 134 deletions(-)
#83 lore raw

Re: [PATCH v5 00/11] use rte_pktmbuf_mto_offset

Quoted 13 lines
Quoted 4 lines

Stephen Hemminger (11):
gro: use rte_pktmbuf_mtod_offset
gso: use rte_pktmbuf_mtod_offset
test/crypto_dev: use rte_pktmbuf_mtod_offset

Quoted 8 lines

drivers/crypto: use rte_pktmbuf_mtod_offset net/nfp: use rte_pktmbuf_mtod_offset net/tap: use rte_pktmbuf_motd_offset baseband/fpga: use rte_pktmbuf_offset
cpt: use rte_pktmbuf_mtod_offset
testpmd: use rte_pktmbuf_mtod_offset examples/ptpclient: use rte_pktmbuf_mtod_offset examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

Quoted 1 line

Applied except 2 patches which are no longer relevant, thanks.