* [PATCH 00/14] rte_pktmbuf_mtod_offset usage
@ 2023-05-05 17:47 Stephen Hemminger
2023-05-05 17:48 ` [PATCH 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (17 more replies)
0 siblings, 18 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:47 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
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(-)
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 01/14] gro: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 02/14] gso: " Stephen Hemminger
` (16 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Use rte_pktmbuf_mtod_offset. Change was automatically generated
by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 0014096e6332..6f8466e70211 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -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);
}
diff --git a/lib/gro/gro_tcp4.h b/lib/gro/gro_tcp4.h
index 212f97a0427c..c76f1f5686d1 100644
--- a/lib/gro/gro_tcp4.h
+++ b/lib/gro/gro_tcp4.h
@@ -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;
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -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);
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 3be4deb7c76f..b93a02c149cc 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -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. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -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. */
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 02/14] gso: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-05 17:48 ` [PATCH 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 03/14] testpmd: " Stephen Hemminger
` (15 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Use the rte_pktmbuf_mtod_offset macro.
Change was automatically generated by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index 9456d596d3c5..4100765f2355 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -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);
}
diff --git a/lib/gso/gso_tcp4.c b/lib/gso/gso_tcp4.c
index d31feaff95cd..e2ae4aaf6c5a 100644
--- a/lib/gso/gso_tcp4.c
+++ b/lib/gso/gso_tcp4.c
@@ -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;
diff --git a/lib/gso/gso_tunnel_tcp4.c b/lib/gso/gso_tunnel_tcp4.c
index 1a7ef30ddebf..3a9159774b27 100644
--- a/lib/gso/gso_tunnel_tcp4.c
+++ b/lib/gso/gso_tunnel_tcp4.c
@@ -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.
diff --git a/lib/gso/gso_tunnel_udp4.c b/lib/gso/gso_tunnel_udp4.c
index 1fc7a8dbc5aa..4fb275484ca8 100644
--- a/lib/gso/gso_tunnel_udp4.c
+++ b/lib/gso/gso_tunnel_udp4.c
@@ -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.
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 03/14] testpmd: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-05 17:48 ` [PATCH 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-05 17:48 ` [PATCH 02/14] gso: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 04/14] test: cryptodev " Stephen Hemminger
` (14 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Aman Singh, Yuying Zhang
Use helper macro.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/ieee1588fwd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 386d9f10e642..3371771751dd 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -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",
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 04/14] test: cryptodev use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (2 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 03/14] testpmd: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 05/14] examples: " Stephen Hemminger
` (13 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang
Automatically genertged by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 30 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 9c670e9a3554..2eebeaac9ef4 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 05/14] examples: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (3 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 04/14] test: cryptodev " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 06/14] net/tap: " Stephen Hemminger
` (12 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang, Kirill Rybalchenko
Automatically generated from cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/l2fwd-crypto/main.c | 16 +++++++++-------
examples/ptpclient/ptpclient.c | 18 +++++++++---------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..981b449710a7 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
ipdata_offset = sizeof(struct rte_ether_hdr);
- ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
- ipdata_offset);
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+ ipdata_offset);
ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,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];
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index cdf2da64dfee..2535d848a1e9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -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:
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 06/14] net/tap: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (4 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 05/14] examples: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 07/14] net/nfp: " Stephen Hemminger
` (11 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Automatically generated by cocci/mbuf-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 089ac202fad2..ca2c8da5c289 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 07/14] net/nfp: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (5 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 06/14] net/tap: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 08/14] crypto/ipsec_mb: " Stephen Hemminger
` (10 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Chaoyong He, Niklas Söderlund
Automatically generated by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 96e080a8e956..5ae0e8be1d67 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -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);
}
/*
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 3e083d948edf..9a8e464a1d18 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (6 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 07/14] net/nfp: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 09/14] crypto/qat: " Stephen Hemminger
` (9 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kai Ji, Pablo de Lara
Initial patch generated with cocci/mtod-offset.
Additional manual cleanups to indentation and remove unnecessary
parenthesis.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/ipsec_mb/pmd_kasumi.c | 16 ++++++-------
drivers/crypto/ipsec_mb/pmd_snow3g.c | 35 +++++++++++-----------------
drivers/crypto/ipsec_mb/pmd_zuc.c | 16 ++++++-------
3 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..5b1694276468 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -83,13 +83,13 @@ process_kasumi_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
uint32_t num_bytes[num_ops];
for (i = 0; i < num_ops; i++) {
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst
- ? rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3)
- : rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ ? rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3)
+ : rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
iv[i] = *((uint64_t *)(iv_ptr));
@@ -155,8 +155,8 @@ process_kasumi_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
/* Direction from next bit after end of message */
num_bytes = length_in_bits >> 3;
diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index 8ed069f42860..f6e51916e1fd 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -111,14 +111,12 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off = ops[i]->sym->cipher.data.offset >> 3;
cipher_len = ops[i]->sym->cipher.data.length >> 3;
- src[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *, cipher_off);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *, cipher_off);
/* If out-of-place operation */
if (ops[i]->sym->m_dst &&
ops[i]->sym->m_src != ops[i]->sym->m_dst) {
- dst[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *, cipher_off);
/* In case of out-of-place, auth-cipher operation
* with partial encryption of the digest, copy
@@ -133,16 +131,14 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off - cipher_len;
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
cipher_off + cipher_len),
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
cipher_off + cipher_len),
unencrypted_bytes);
} else
- dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src,
- uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ cipher_off);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
@@ -205,13 +201,11 @@ process_snow3g_cipher_op_bit(struct ipsec_mb_qp *qp,
(length_in_bits >> 3);
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- op->sym->m_dst, uint8_t *,
- (length_in_bits >> 3)),
- rte_pktmbuf_mtod_offset(
- op->sym->m_src, uint8_t *,
- (length_in_bits >> 3)),
- unencrypted_bytes);
+ rte_pktmbuf_mtod_offset(op->sym->m_dst, uint8_t *,
+ length_in_bits >> 3),
+ rte_pktmbuf_mtod_offset(op->sym->m_src, uint8_t *,
+ length_in_bits >> 3),
+ unencrypted_bytes);
iv = rte_crypto_op_ctod_offset(op, uint8_t *,
session->cipher_iv_offset);
@@ -248,8 +242,8 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->auth_iv_offset);
@@ -261,8 +255,7 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
session->op ==
IPSEC_MB_OP_DECRYPT_THEN_HASH_VERIFY) &&
ops[i]->sym->m_dst != NULL)
- src = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
ops[i]->sym->auth.data.offset >> 3);
IMB_SNOW3G_F9_1_BUFFER(qp->mb_mgr,
diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c
index 92fd9d180894..65b00e80390e 100644
--- a/drivers/crypto/ipsec_mb/pmd_zuc.c
+++ b/drivers/crypto/ipsec_mb/pmd_zuc.c
@@ -107,13 +107,13 @@ process_zuc_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
}
#endif
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst ?
- rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3) :
- rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3) :
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->cipher_iv_offset);
num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
@@ -159,8 +159,8 @@ process_zuc_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits[i] = ops[i]->sym->auth.data.length;
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->auth_iv_offset);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 09/14] crypto/qat: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (7 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 08/14] crypto/ipsec_mb: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
` (8 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kai Ji
Auto generated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 9 +++++----
drivers/crypto/qat/qat_sym.h | 9 +++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index 524c291340da..11f468a9fdc0 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -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;
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 9a4251e08b47..615e92f01803 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (8 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 09/14] crypto/qat: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (7 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj
Autogenerated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 +-
drivers/crypto/cnxk/cnxk_se.h | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 34d40b07d4c6..8b91d11b79cc 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -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);
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 69cd343eea1b..d493e1b1880c 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 11/14] common/cpt: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (9 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 12/14] crypto/caam_jr: " Stephen Hemminger
` (6 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Anoob Joseph
Autogenerated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/common/cpt/cpt_ucode.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index b393be4cf661..87a3ac80b9da 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 12/14] crypto/caam_jr: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (10 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-09 11:43 ` Hemant Agrawal
2023-05-05 17:48 ` [PATCH 13/14] net/mlx4: " Stephen Hemminger
` (5 subsequent siblings)
17 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Gagandeep Singh, Hemant Agrawal
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/caam_jr/caam_jr.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..9c96fd21a48d 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -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 =
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 13/14] net/mlx4: use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (11 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 12/14] crypto/caam_jr: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-05 17:48 ` [PATCH 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
` (4 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c
index 059e432a63fc..d5feeb7f7e6d 100644
--- a/drivers/net/mlx4/mlx4_rxtx.c
+++ b/drivers/net/mlx4/mlx4_rxtx.c
@@ -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;
}
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (12 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 13/14] net/mlx4: " Stephen Hemminger
@ 2023-05-05 17:48 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (3 subsequent siblings)
17 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-05 17:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Nicolas Chautru
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index f29565af8cca..465a65f3dca2 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -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,
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (13 preceding siblings ...)
2023-05-05 17:48 ` [PATCH 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (13 more replies)
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (2 subsequent siblings)
17 siblings, 14 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: 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(-)
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 01/14] gro: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 02/14] gso: " Stephen Hemminger
` (12 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Use rte_pktmbuf_mtod_offset. Change was automatically generated
by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 0014096e6332..6f8466e70211 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -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);
}
diff --git a/lib/gro/gro_tcp4.h b/lib/gro/gro_tcp4.h
index 212f97a0427c..c76f1f5686d1 100644
--- a/lib/gro/gro_tcp4.h
+++ b/lib/gro/gro_tcp4.h
@@ -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;
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -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);
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 3be4deb7c76f..b93a02c149cc 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -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. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -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. */
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 02/14] gso: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 03/14] testpmd: " Stephen Hemminger
` (11 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Use the rte_pktmbuf_mtod_offset macro.
Change was automatically generated by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index 9456d596d3c5..8987e368605c 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -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);
}
diff --git a/lib/gso/gso_tcp4.c b/lib/gso/gso_tcp4.c
index d31feaff95cd..e2ae4aaf6c5a 100644
--- a/lib/gso/gso_tcp4.c
+++ b/lib/gso/gso_tcp4.c
@@ -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;
diff --git a/lib/gso/gso_tunnel_tcp4.c b/lib/gso/gso_tunnel_tcp4.c
index 1a7ef30ddebf..3a9159774b27 100644
--- a/lib/gso/gso_tunnel_tcp4.c
+++ b/lib/gso/gso_tunnel_tcp4.c
@@ -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.
diff --git a/lib/gso/gso_tunnel_udp4.c b/lib/gso/gso_tunnel_udp4.c
index 1fc7a8dbc5aa..4fb275484ca8 100644
--- a/lib/gso/gso_tunnel_udp4.c
+++ b/lib/gso/gso_tunnel_udp4.c
@@ -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.
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 03/14] testpmd: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 02/14] gso: " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 04/14] test: cryptodev " Stephen Hemminger
` (10 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Aman Singh, Yuying Zhang
Use helper macro.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/ieee1588fwd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 386d9f10e642..3371771751dd 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -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",
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 04/14] test: cryptodev use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (2 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 03/14] testpmd: " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 05/14] examples: " Stephen Hemminger
` (9 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang
Based off patch generated by cocci/mtod-offset.cocci.
With some cleanup to shorten lines by using conditional
with ommited operand.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 30 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 9c670e9a3554..b4cddcd55f59 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 05/14] examples: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (3 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 04/14] test: cryptodev " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 06/14] net/tap: " Stephen Hemminger
` (8 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang, Kirill Rybalchenko
Automatically generated from cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/l2fwd-crypto/main.c | 16 +++++++++-------
examples/ptpclient/ptpclient.c | 18 +++++++++---------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..403ed6b44de9 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
ipdata_offset = sizeof(struct rte_ether_hdr);
- ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
- ipdata_offset);
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+ ipdata_offset);
ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,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];
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index cdf2da64dfee..2535d848a1e9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -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:
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 06/14] net/tap: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (4 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 05/14] examples: " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 07/14] net/nfp: " Stephen Hemminger
` (7 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Automatically generated by cocci/mbuf-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 089ac202fad2..ca2c8da5c289 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 07/14] net/nfp: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (5 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 06/14] net/tap: " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-09 13:35 ` Niklas Söderlund
2023-05-06 16:03 ` [PATCH v2 08/14] crypto/ipsec_mb: " Stephen Hemminger
` (6 subsequent siblings)
13 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Chaoyong He, Niklas Söderlund
Automatically generated by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 96e080a8e956..5ae0e8be1d67 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -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);
}
/*
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 3e083d948edf..9a8e464a1d18 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (6 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 07/14] net/nfp: " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-29 12:47 ` De Lara Guarch, Pablo
2023-05-06 16:03 ` [PATCH v2 09/14] crypto/qat: " Stephen Hemminger
` (5 subsequent siblings)
13 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kai Ji, Pablo de Lara
Initial patch generated with cocci/mtod-offset.
Additional manual cleanups to indentation and remove unnecessary
parenthesis.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/ipsec_mb/pmd_kasumi.c | 16 ++++++-------
drivers/crypto/ipsec_mb/pmd_snow3g.c | 35 +++++++++++-----------------
drivers/crypto/ipsec_mb/pmd_zuc.c | 16 ++++++-------
3 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..5b1694276468 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -83,13 +83,13 @@ process_kasumi_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
uint32_t num_bytes[num_ops];
for (i = 0; i < num_ops; i++) {
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst
- ? rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3)
- : rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ ? rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3)
+ : rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
iv[i] = *((uint64_t *)(iv_ptr));
@@ -155,8 +155,8 @@ process_kasumi_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
/* Direction from next bit after end of message */
num_bytes = length_in_bits >> 3;
diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index 8ed069f42860..f6e51916e1fd 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -111,14 +111,12 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off = ops[i]->sym->cipher.data.offset >> 3;
cipher_len = ops[i]->sym->cipher.data.length >> 3;
- src[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *, cipher_off);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *, cipher_off);
/* If out-of-place operation */
if (ops[i]->sym->m_dst &&
ops[i]->sym->m_src != ops[i]->sym->m_dst) {
- dst[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *, cipher_off);
/* In case of out-of-place, auth-cipher operation
* with partial encryption of the digest, copy
@@ -133,16 +131,14 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off - cipher_len;
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
cipher_off + cipher_len),
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
cipher_off + cipher_len),
unencrypted_bytes);
} else
- dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src,
- uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ cipher_off);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
@@ -205,13 +201,11 @@ process_snow3g_cipher_op_bit(struct ipsec_mb_qp *qp,
(length_in_bits >> 3);
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- op->sym->m_dst, uint8_t *,
- (length_in_bits >> 3)),
- rte_pktmbuf_mtod_offset(
- op->sym->m_src, uint8_t *,
- (length_in_bits >> 3)),
- unencrypted_bytes);
+ rte_pktmbuf_mtod_offset(op->sym->m_dst, uint8_t *,
+ length_in_bits >> 3),
+ rte_pktmbuf_mtod_offset(op->sym->m_src, uint8_t *,
+ length_in_bits >> 3),
+ unencrypted_bytes);
iv = rte_crypto_op_ctod_offset(op, uint8_t *,
session->cipher_iv_offset);
@@ -248,8 +242,8 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->auth_iv_offset);
@@ -261,8 +255,7 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
session->op ==
IPSEC_MB_OP_DECRYPT_THEN_HASH_VERIFY) &&
ops[i]->sym->m_dst != NULL)
- src = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
ops[i]->sym->auth.data.offset >> 3);
IMB_SNOW3G_F9_1_BUFFER(qp->mb_mgr,
diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c
index 92fd9d180894..65b00e80390e 100644
--- a/drivers/crypto/ipsec_mb/pmd_zuc.c
+++ b/drivers/crypto/ipsec_mb/pmd_zuc.c
@@ -107,13 +107,13 @@ process_zuc_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
}
#endif
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst ?
- rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3) :
- rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3) :
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->cipher_iv_offset);
num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
@@ -159,8 +159,8 @@ process_zuc_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits[i] = ops[i]->sym->auth.data.length;
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->auth_iv_offset);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 09/14] crypto/qat: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (7 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 08/14] crypto/ipsec_mb: " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
` (4 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kai Ji
Auto generated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 9 +++++----
drivers/crypto/qat/qat_sym.h | 9 +++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index 524c291340da..11f468a9fdc0 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -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;
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 9a4251e08b47..615e92f01803 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (8 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 09/14] crypto/qat: " Stephen Hemminger
@ 2023-05-06 16:03 ` Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (3 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:03 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj
Autogenerated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 +-
drivers/crypto/cnxk/cnxk_se.h | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 34d40b07d4c6..8b91d11b79cc 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -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);
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 69cd343eea1b..d493e1b1880c 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 11/14] common/cpt: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (9 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
@ 2023-05-06 16:04 ` Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 12/14] crypto/caam_jr: " Stephen Hemminger
` (2 subsequent siblings)
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:04 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Anoob Joseph
Autogenerated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/common/cpt/cpt_ucode.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index b393be4cf661..87a3ac80b9da 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 12/14] crypto/caam_jr: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (10 preceding siblings ...)
2023-05-06 16:04 ` [PATCH v2 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-05-06 16:04 ` Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 13/14] net/mlx4: " Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:04 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Gagandeep Singh, Hemant Agrawal
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/caam_jr/caam_jr.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..9c96fd21a48d 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -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 =
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 13/14] net/mlx4: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (11 preceding siblings ...)
2023-05-06 16:04 ` [PATCH v2 12/14] crypto/caam_jr: " Stephen Hemminger
@ 2023-05-06 16:04 ` Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:04 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c
index 059e432a63fc..d5feeb7f7e6d 100644
--- a/drivers/net/mlx4/mlx4_rxtx.c
+++ b/drivers/net/mlx4/mlx4_rxtx.c
@@ -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;
}
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v2 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (12 preceding siblings ...)
2023-05-06 16:04 ` [PATCH v2 13/14] net/mlx4: " Stephen Hemminger
@ 2023-05-06 16:04 ` Stephen Hemminger
13 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-05-06 16:04 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Nicolas Chautru
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index f29565af8cca..465a65f3dca2 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -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,
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* RE: [PATCH 12/14] crypto/caam_jr: use rte_pktmbuf_mtod_offset
2023-05-05 17:48 ` [PATCH 12/14] crypto/caam_jr: " Stephen Hemminger
@ 2023-05-09 11:43 ` Hemant Agrawal
0 siblings, 0 replies; 84+ messages in thread
From: Hemant Agrawal @ 2023-05-09 11:43 UTC (permalink / raw)
To: Stephen Hemminger, dev; +Cc: Gagandeep Singh
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v2 07/14] net/nfp: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 07/14] net/nfp: " Stephen Hemminger
@ 2023-05-09 13:35 ` Niklas Söderlund
0 siblings, 0 replies; 84+ messages in thread
From: Niklas Söderlund @ 2023-05-09 13:35 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Chaoyong He
Hi Stephen,
Thanks for your work.
On 2023-05-06 09:03:56 -0700, Stephen Hemminger wrote:
> Automatically generated by cocci/mtod-offset.cocci.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> ---
> 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(-)
>
> diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
> index 96e080a8e956..5ae0e8be1d67 100644
> --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
> +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
> @@ -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);
> }
>
> /*
> diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
> index 3e083d948edf..9a8e464a1d18 100644
> --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
> +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
> @@ -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);
> --
> 2.39.2
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 84+ messages in thread
* RE: [PATCH v2 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
2023-05-06 16:03 ` [PATCH v2 08/14] crypto/ipsec_mb: " Stephen Hemminger
@ 2023-05-29 12:47 ` De Lara Guarch, Pablo
0 siblings, 0 replies; 84+ messages in thread
From: De Lara Guarch, Pablo @ 2023-05-29 12:47 UTC (permalink / raw)
To: Stephen Hemminger, dev; +Cc: Ji, Kai
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Saturday, May 6, 2023 5:04 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Ji, Kai
> <kai.ji@intel.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH v2 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
>
> Initial patch generated with cocci/mtod-offset.
> Additional manual cleanups to indentation and remove unnecessary
> parenthesis.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (14 preceding siblings ...)
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (14 more replies)
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
17 siblings, 15 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: 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(-)
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 01/14] gro: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 02/14] gso: " Stephen Hemminger
` (13 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Use rte_pktmbuf_mtod_offset. Change was automatically generated
by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h
index d926c4b8cc71..2c825413c261 100644
--- a/lib/gro/gro_tcp.h
+++ b/lib/gro/gro_tcp.h
@@ -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;
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 6645de592b63..f8cd92950c63 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -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);
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -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);
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 6ab700192261..2752650389a4 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -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. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -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. */
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 02/14] gso: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 03/14] testpmd: " Stephen Hemminger
` (12 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Use the rte_pktmbuf_mtod_offset macro.
Change was automatically generated by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index 9456d596d3c5..8987e368605c 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -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);
}
diff --git a/lib/gso/gso_tcp4.c b/lib/gso/gso_tcp4.c
index d31feaff95cd..e2ae4aaf6c5a 100644
--- a/lib/gso/gso_tcp4.c
+++ b/lib/gso/gso_tcp4.c
@@ -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;
diff --git a/lib/gso/gso_tunnel_tcp4.c b/lib/gso/gso_tunnel_tcp4.c
index 1a7ef30ddebf..3a9159774b27 100644
--- a/lib/gso/gso_tunnel_tcp4.c
+++ b/lib/gso/gso_tunnel_tcp4.c
@@ -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.
diff --git a/lib/gso/gso_tunnel_udp4.c b/lib/gso/gso_tunnel_udp4.c
index 1fc7a8dbc5aa..4fb275484ca8 100644
--- a/lib/gso/gso_tunnel_udp4.c
+++ b/lib/gso/gso_tunnel_udp4.c
@@ -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.
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 03/14] testpmd: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 02/14] gso: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 04/14] test: cryptodev " Stephen Hemminger
` (11 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Aman Singh, Yuying Zhang
Use helper macro.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/ieee1588fwd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 386d9f10e642..3371771751dd 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -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",
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 04/14] test: cryptodev use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (2 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 03/14] testpmd: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-07 12:46 ` Ferruh Yigit
2023-07-06 17:59 ` [PATCH v3 05/14] examples: " Stephen Hemminger
` (10 subsequent siblings)
14 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang
Based off patch generated by cocci/mtod-offset.cocci.
With some cleanup to shorten lines by using conditional
with omitted operand.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 30 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index fb2af40b99ee..5072b3b6ece5 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 05/14] examples: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (3 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 04/14] test: cryptodev " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 06/14] net/tap: " Stephen Hemminger
` (9 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang, Kirill Rybalchenko
Automatically generated from cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/l2fwd-crypto/main.c | 16 +++++++++-------
examples/ptpclient/ptpclient.c | 18 +++++++++---------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..403ed6b44de9 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
ipdata_offset = sizeof(struct rte_ether_hdr);
- ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
- ipdata_offset);
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+ ipdata_offset);
ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,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];
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index cdf2da64dfee..2535d848a1e9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -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:
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 06/14] net/tap: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (4 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 05/14] examples: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 07/14] net/nfp: " Stephen Hemminger
` (8 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Automatically generated by cocci/mbuf-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f7555990..ebddbae9fe9f 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 07/14] net/nfp: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (5 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 06/14] net/tap: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 08/14] crypto/ipsec_mb: " Stephen Hemminger
` (7 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Chaoyong He, Niklas Söderlund
Automatically generated by cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index f643d54d39a4..787a38dc9aa0 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -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);
}
/*
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 4cb2c2f99e04..18823a97887d 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 08/14] crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (6 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 07/14] net/nfp: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 09/14] crypto/qat: " Stephen Hemminger
` (6 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kai Ji, Pablo de Lara
Initial patch generated with cocci/mtod-offset.
Additional manual cleanups to indentation and remove unnecessary
parenthesis.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/ipsec_mb/pmd_kasumi.c | 16 ++++++-------
drivers/crypto/ipsec_mb/pmd_snow3g.c | 35 +++++++++++-----------------
drivers/crypto/ipsec_mb/pmd_zuc.c | 16 ++++++-------
3 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..5b1694276468 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -83,13 +83,13 @@ process_kasumi_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
uint32_t num_bytes[num_ops];
for (i = 0; i < num_ops; i++) {
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst
- ? rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3)
- : rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->cipher.data.offset >> 3);
+ ? rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3)
+ : rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
iv[i] = *((uint64_t *)(iv_ptr));
@@ -155,8 +155,8 @@ process_kasumi_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
- + (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
/* Direction from next bit after end of message */
num_bytes = length_in_bits >> 3;
diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index e64df1a462e3..90b8d80c2c56 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -111,14 +111,12 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off = ops[i]->sym->cipher.data.offset >> 3;
cipher_len = ops[i]->sym->cipher.data.length >> 3;
- src[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *, cipher_off);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *, cipher_off);
/* If out-of-place operation */
if (ops[i]->sym->m_dst &&
ops[i]->sym->m_src != ops[i]->sym->m_dst) {
- dst[i] = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *, cipher_off);
/* In case of out-of-place, auth-cipher operation
* with partial encryption of the digest, copy
@@ -133,16 +131,14 @@ process_snow3g_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
cipher_off - cipher_len;
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
cipher_off + cipher_len),
- rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_src, uint8_t *,
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
cipher_off + cipher_len),
unencrypted_bytes);
} else
- dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src,
- uint8_t *, cipher_off);
+ dst[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ cipher_off);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->cipher_iv_offset);
@@ -205,13 +201,11 @@ process_snow3g_cipher_op_bit(struct ipsec_mb_qp *qp,
(length_in_bits >> 3);
if (unencrypted_bytes > 0)
rte_memcpy(
- rte_pktmbuf_mtod_offset(
- op->sym->m_dst, uint8_t *,
- (length_in_bits >> 3)),
- rte_pktmbuf_mtod_offset(
- op->sym->m_src, uint8_t *,
- (length_in_bits >> 3)),
- unencrypted_bytes);
+ rte_pktmbuf_mtod_offset(op->sym->m_dst, uint8_t *,
+ length_in_bits >> 3),
+ rte_pktmbuf_mtod_offset(op->sym->m_src, uint8_t *,
+ length_in_bits >> 3),
+ unencrypted_bytes);
iv = rte_crypto_op_ctod_offset(op, uint8_t *,
session->cipher_iv_offset);
@@ -248,8 +242,8 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits = ops[i]->sym->auth.data.length;
- src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->auth_iv_offset);
@@ -261,8 +255,7 @@ process_snow3g_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
session->op ==
IPSEC_MB_OP_DECRYPT_THEN_HASH_VERIFY) &&
ops[i]->sym->m_dst != NULL)
- src = rte_pktmbuf_mtod_offset(
- ops[i]->sym->m_dst, uint8_t *,
+ src = rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
ops[i]->sym->auth.data.offset >> 3);
IMB_SNOW3G_F9_1_BUFFER(qp->mb_mgr,
diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c
index 92fd9d180894..65b00e80390e 100644
--- a/drivers/crypto/ipsec_mb/pmd_zuc.c
+++ b/drivers/crypto/ipsec_mb/pmd_zuc.c
@@ -107,13 +107,13 @@ process_zuc_cipher_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
}
#endif
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst ?
- rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3) :
- rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->cipher.data.offset >> 3);
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_dst, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3) :
+ rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->cipher.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->cipher_iv_offset);
num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
@@ -159,8 +159,8 @@ process_zuc_hash_op(struct ipsec_mb_qp *qp, struct rte_crypto_op **ops,
length_in_bits[i] = ops[i]->sym->auth.data.length;
- src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
- (ops[i]->sym->auth.data.offset >> 3);
+ src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src, uint8_t *,
+ ops[i]->sym->auth.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
sess->auth_iv_offset);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 09/14] crypto/qat: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (7 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 08/14] crypto/ipsec_mb: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
` (5 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kai Ji
Auto generated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 9 +++++----
drivers/crypto/qat/qat_sym.h | 9 +++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index 1bafeb4a53e8..3e0dfea94c87 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -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;
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 193281cd9135..d7ceb13b29cd 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (8 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 09/14] crypto/qat: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (4 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj
Autogenerated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 +-
drivers/crypto/cnxk/cnxk_se.h | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 34d40b07d4c6..8b91d11b79cc 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -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);
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 75c1dce231bf..1392af5833d1 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 11/14] common/cpt: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (9 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 12/14] crypto/caam_jr: " Stephen Hemminger
` (3 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Anoob Joseph
Autogenerated with cocci/mtod-offset.cocci
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/common/cpt/cpt_ucode.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index b393be4cf661..87a3ac80b9da 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 12/14] crypto/caam_jr: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (10 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 13/14] net/mlx4: " Stephen Hemminger
` (2 subsequent siblings)
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Gagandeep Singh, Hemant Agrawal
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/crypto/caam_jr/caam_jr.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..9c96fd21a48d 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -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 =
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 13/14] net/mlx4: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (11 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 12/14] crypto/caam_jr: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-07 12:46 ` Ferruh Yigit
2023-07-06 17:59 ` [PATCH v3 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
2023-07-07 12:47 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Ferruh Yigit
14 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Matan Azrad, Viacheslav Ovsiienko
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c
index 059e432a63fc..d5feeb7f7e6d 100644
--- a/drivers/net/mlx4/mlx4_rxtx.c
+++ b/drivers/net/mlx4/mlx4_rxtx.c
@@ -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;
}
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v3 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (12 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 13/14] net/mlx4: " Stephen Hemminger
@ 2023-07-06 17:59 ` Stephen Hemminger
2023-07-07 12:47 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Ferruh Yigit
14 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-06 17:59 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Nicolas Chautru
Autogenerated with cocci/mtod-offset.cocci.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index f29565af8cca..465a65f3dca2 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -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,
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v3 04/14] test: cryptodev use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 04/14] test: cryptodev " Stephen Hemminger
@ 2023-07-07 12:46 ` Ferruh Yigit
2023-07-07 20:32 ` Stephen Hemminger
0 siblings, 1 reply; 84+ messages in thread
From: Ferruh Yigit @ 2023-07-07 12:46 UTC (permalink / raw)
To: Stephen Hemminger, dev; +Cc: Akhil Goyal, Fan Zhang
On 7/6/2023 6:59 PM, Stephen Hemminger wrote:
> Based off patch generated by cocci/mtod-offset.cocci.
> With some cleanup to shorten lines by using conditional
> with omitted operand.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
<...>
> @@ -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?
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v3 13/14] net/mlx4: use rte_pktmbuf_mtod_offset
2023-07-06 17:59 ` [PATCH v3 13/14] net/mlx4: " Stephen Hemminger
@ 2023-07-07 12:46 ` Ferruh Yigit
0 siblings, 0 replies; 84+ messages in thread
From: Ferruh Yigit @ 2023-07-07 12:46 UTC (permalink / raw)
To: Stephen Hemminger, dev; +Cc: Matan Azrad, Viacheslav Ovsiienko
On 7/6/2023 6:59 PM, Stephen Hemminger wrote:
> Autogenerated with cocci/mtod-offset.cocci.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c
> index 059e432a63fc..d5feeb7f7e6d 100644
> --- a/drivers/net/mlx4/mlx4_rxtx.c
> +++ b/drivers/net/mlx4/mlx4_rxtx.c
> @@ -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;
> }
Although parenthesis may not be required, keeping them looks more clear
to me; personal preferences.
And patch title is not accurate for this patch.
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
` (13 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
@ 2023-07-07 12:47 ` Ferruh Yigit
14 siblings, 0 replies; 84+ messages in thread
From: Ferruh Yigit @ 2023-07-07 12:47 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
On 7/6/2023 6:59 PM, Stephen Hemminger wrote:
> 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 *) +
```
> 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
For series,
Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>
There are a few minor issues commented on individual patches.
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v3 04/14] test: cryptodev use rte_pktmbuf_mtod_offset
2023-07-07 12:46 ` Ferruh Yigit
@ 2023-07-07 20:32 ` Stephen Hemminger
0 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:32 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Akhil Goyal, Fan Zhang
On Fri, 7 Jul 2023 13:46:07 +0100
Ferruh Yigit <ferruh.yigit@amd.com> wrote:
> On 7/6/2023 6:59 PM, Stephen Hemminger wrote:
> > Based off patch generated by cocci/mtod-offset.cocci.
> > With some cleanup to shorten lines by using conditional
> > with omitted operand.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
> <...>
>
> > @@ -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?
Already used five places in DPDK, so didn't seem like a problem.
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (15 preceding siblings ...)
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
@ 2023-07-07 20:38 ` Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (10 more replies)
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
17 siblings, 11 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:38 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Ferruh Yigit
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(-)
Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-07 20:38 ` Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 02/11] gso: " Stephen Hemminger
` (9 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:38 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h
index d926c4b8cc71..bbd2f9c16a00 100644
--- a/lib/gro/gro_tcp.h
+++ b/lib/gro/gro_tcp.h
@@ -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;
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 6645de592b63..d6c0f9182d45 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -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);
}
diff --git a/lib/gro/gro_tcp6.c b/lib/gro/gro_tcp6.c
index 5aa39801e132..6edfb6045cf6 100644
--- a/lib/gro/gro_tcp6.c
+++ b/lib/gro/gro_tcp6.c
@@ -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);
}
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -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);
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 6ab700192261..2752650389a4 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -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. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -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. */
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 02/11] gso: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-07 20:38 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 03/11] test: " Stephen Hemminger
` (8 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:38 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index 9456d596d3c5..4100765f2355 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -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);
}
diff --git a/lib/gso/gso_tcp4.c b/lib/gso/gso_tcp4.c
index d31feaff95cd..e2ae4aaf6c5a 100644
--- a/lib/gso/gso_tcp4.c
+++ b/lib/gso/gso_tcp4.c
@@ -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;
diff --git a/lib/gso/gso_tunnel_tcp4.c b/lib/gso/gso_tunnel_tcp4.c
index 1a7ef30ddebf..3a9159774b27 100644
--- a/lib/gso/gso_tunnel_tcp4.c
+++ b/lib/gso/gso_tunnel_tcp4.c
@@ -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.
diff --git a/lib/gso/gso_tunnel_udp4.c b/lib/gso/gso_tunnel_udp4.c
index 1fc7a8dbc5aa..4fb275484ca8 100644
--- a/lib/gso/gso_tunnel_udp4.c
+++ b/lib/gso/gso_tunnel_udp4.c
@@ -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.
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 03/11] test: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 02/11] gso: " Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 04/11] drivers/crypto: " Stephen Hemminger
` (7 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_cryptodev.c | 66 +++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 30 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index fb2af40b99ee..c79681255106 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 04/11] drivers/crypto: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (2 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 03/11] test: " Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 05/11] net/nfp: " Stephen Hemminger
` (6 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev
Cc: Stephen Hemminger, Gagandeep Singh, Hemant Agrawal,
Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj, Kai Ji,
Pablo de Lara
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..9c96fd21a48d 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -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 =
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 34d40b07d4c6..8b91d11b79cc 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -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);
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 75c1dce231bf..1392af5833d1 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -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;
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..70536ec3dc2a 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -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;
diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index e64df1a462e3..a96779f05942 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -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);
diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c
index 92fd9d180894..44781be1d107 100644
--- a/drivers/crypto/ipsec_mb/pmd_zuc.c
+++ b/drivers/crypto/ipsec_mb/pmd_zuc.c
@@ -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);
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index 1bafeb4a53e8..3e0dfea94c87 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -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;
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 193281cd9135..d7ceb13b29cd 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 05/11] net/nfp: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (3 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 04/11] drivers/crypto: " Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
` (5 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Chaoyong He, Niklas Söderlund
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index f643d54d39a4..787a38dc9aa0 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -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);
}
/*
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 4cb2c2f99e04..18823a97887d 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 06/11] net/tap: use rte_pktmbuf_motd_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (4 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 05/11] net/nfp: " Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
` (4 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f7555990..968a1b6b45df 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 07/11] baseband/fpga: use rte_pktmbuf_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (5 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (3 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Nicolas Chautru
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index f29565af8cca..465a65f3dca2 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -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,
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 08/11] cpt: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (6 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 09/11] testpmd: " Stephen Hemminger
` (2 subsequent siblings)
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Anoob Joseph
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/common/cpt/cpt_ucode.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index b393be4cf661..87a3ac80b9da 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 09/11] testpmd: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (7 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 10/11] examples/ptpclient: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 11/11] examples/l2fwd-crypto: " Stephen Hemminger
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Aman Singh, Yuying Zhang
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/ieee1588fwd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 386d9f10e642..3371771751dd 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -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",
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 10/11] examples/ptpclient: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (8 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 09/11] testpmd: " Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 11/11] examples/l2fwd-crypto: " Stephen Hemminger
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kirill Rybalchenko
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/ptpclient/ptpclient.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index cdf2da64dfee..2535d848a1e9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -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:
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v4 11/11] examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
` (9 preceding siblings ...)
2023-07-07 20:39 ` [PATCH v4 10/11] examples/ptpclient: " Stephen Hemminger
@ 2023-07-07 20:39 ` Stephen Hemminger
10 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-07 20:39 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/l2fwd-crypto/main.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..981b449710a7 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
ipdata_offset = sizeof(struct rte_ether_hdr);
- ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
- ipdata_offset);
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+ ipdata_offset);
ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,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];
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 00/11] use rte_pktmbuf_mto_offset
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
` (16 preceding siblings ...)
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (11 more replies)
17 siblings, 12 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: 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(-)
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 02/11] gso: " Stephen Hemminger
` (10 subsequent siblings)
11 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h
index d926c4b8cc71..bbd2f9c16a00 100644
--- a/lib/gro/gro_tcp.h
+++ b/lib/gro/gro_tcp.h
@@ -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;
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 6645de592b63..d6c0f9182d45 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -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);
}
diff --git a/lib/gro/gro_tcp6.c b/lib/gro/gro_tcp6.c
index 5aa39801e132..6edfb6045cf6 100644
--- a/lib/gro/gro_tcp6.c
+++ b/lib/gro/gro_tcp6.c
@@ -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);
}
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -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);
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 6ab700192261..2752650389a4 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -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. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -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. */
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 02/11] gso: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 03/11] test/crypto_dev: " Stephen Hemminger
` (9 subsequent siblings)
11 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Jiayu Hu
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index 9456d596d3c5..d1c1b73091e2 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -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);
}
diff --git a/lib/gso/gso_tcp4.c b/lib/gso/gso_tcp4.c
index d31feaff95cd..e2ae4aaf6c5a 100644
--- a/lib/gso/gso_tcp4.c
+++ b/lib/gso/gso_tcp4.c
@@ -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;
diff --git a/lib/gso/gso_tunnel_tcp4.c b/lib/gso/gso_tunnel_tcp4.c
index 1a7ef30ddebf..3a9159774b27 100644
--- a/lib/gso/gso_tunnel_tcp4.c
+++ b/lib/gso/gso_tunnel_tcp4.c
@@ -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.
diff --git a/lib/gso/gso_tunnel_udp4.c b/lib/gso/gso_tunnel_udp4.c
index 1fc7a8dbc5aa..4fb275484ca8 100644
--- a/lib/gso/gso_tunnel_udp4.c
+++ b/lib/gso/gso_tunnel_udp4.c
@@ -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.
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 03/11] test/crypto_dev: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 02/11] gso: " Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 04/11] drivers/crypto: " Stephen Hemminger
` (8 subsequent siblings)
11 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_cryptodev.c | 83 +++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 30 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index fb2af40b99ee..549afe252d54 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 04/11] drivers/crypto: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (2 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 03/11] test/crypto_dev: " Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-11 5:34 ` [EXT] " Anoob Joseph
2023-07-12 14:56 ` Hemant Agrawal
2023-07-08 1:57 ` [PATCH v5 05/11] net/nfp: " Stephen Hemminger
` (7 subsequent siblings)
11 siblings, 2 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev
Cc: Stephen Hemminger, Gagandeep Singh, Hemant Agrawal,
Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj, Kai Ji,
Pablo de Lara
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..9c96fd21a48d 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -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 =
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 34d40b07d4c6..8b91d11b79cc 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -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);
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 75c1dce231bf..1392af5833d1 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -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;
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..70536ec3dc2a 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -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;
diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index e64df1a462e3..a96779f05942 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -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);
diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c
index 92fd9d180894..44781be1d107 100644
--- a/drivers/crypto/ipsec_mb/pmd_zuc.c
+++ b/drivers/crypto/ipsec_mb/pmd_zuc.c
@@ -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);
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index 1bafeb4a53e8..3e0dfea94c87 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -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;
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 193281cd9135..d7ceb13b29cd 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 05/11] net/nfp: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (3 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 04/11] drivers/crypto: " Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-10 12:19 ` Niklas Söderlund
2023-07-08 1:57 ` [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
` (6 subsequent siblings)
11 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Chaoyong He, Niklas Söderlund
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index f643d54d39a4..787a38dc9aa0 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -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);
}
/*
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 4cb2c2f99e04..18823a97887d 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (4 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 05/11] net/nfp: " Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2024-01-24 13:47 ` Thomas Monjalon
2023-07-08 1:57 ` [PATCH v5 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
` (5 subsequent siblings)
11 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f7555990..968a1b6b45df 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -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);
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 07/11] baseband/fpga: use rte_pktmbuf_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (5 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
` (4 subsequent siblings)
11 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Nicolas Chautru
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index f29565af8cca..465a65f3dca2 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -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,
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (6 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-11 5:35 ` [EXT] " Anoob Joseph
2023-07-08 1:57 ` [PATCH v5 09/11] testpmd: " Stephen Hemminger
` (3 subsequent siblings)
11 siblings, 1 reply; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Anoob Joseph
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/common/cpt/cpt_ucode.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index b393be4cf661..87a3ac80b9da 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -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;
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 09/11] testpmd: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (7 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 10/11] examples/ptpclient: " Stephen Hemminger
` (2 subsequent siblings)
11 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Aman Singh, Yuying Zhang
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/ieee1588fwd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 386d9f10e642..3371771751dd 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -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",
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 10/11] examples/ptpclient: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (8 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 09/11] testpmd: " Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 11/11] examples/l2fwd-crypto: " Stephen Hemminger
2023-07-09 3:54 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset fengchengwen
11 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Kirill Rybalchenko
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/ptpclient/ptpclient.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index cdf2da64dfee..2535d848a1e9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -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:
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* [PATCH v5 11/11] examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (9 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 10/11] examples/ptpclient: " Stephen Hemminger
@ 2023-07-08 1:57 ` Stephen Hemminger
2023-07-09 3:54 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset fengchengwen
11 siblings, 0 replies; 84+ messages in thread
From: Stephen Hemminger @ 2023-07-08 1:57 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/l2fwd-crypto/main.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..19db0a280bf0 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
ipdata_offset = sizeof(struct rte_ether_hdr);
- ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
- ipdata_offset);
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+ ipdata_offset);
ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->auth.digest.data = (uint8_t *)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
- op->sym->auth.digest.data = rte_pktmbuf_mtod(m,
- uint8_t *) + ipdata_offset + data_len;
+ op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m,
+ uint8_t *, ipdata_offset + data_len);
}
op->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -540,8 +540,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->aead.digest.data = (uint8_t *)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
- op->sym->aead.digest.data = rte_pktmbuf_mtod(m,
- uint8_t *) + ipdata_offset + data_len;
+ op->sym->aead.digest.data = rte_pktmbuf_mtod_offset(m,
+ uint8_t *, ipdata_offset + data_len);
}
op->sym->aead.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -631,7 +631,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
struct rte_ipv4_hdr *ip_hdr;
uint32_t ipdata_offset = sizeof(struct rte_ether_hdr);
- ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
ipdata_offset);
dst_port = l2fwd_dst_ports[portid];
--
2.39.2
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v5 00/11] use rte_pktmbuf_mto_offset
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
` (10 preceding siblings ...)
2023-07-08 1:57 ` [PATCH v5 11/11] examples/l2fwd-crypto: " Stephen Hemminger
@ 2023-07-09 3:54 ` fengchengwen
2024-01-24 14:55 ` Thomas Monjalon
11 siblings, 1 reply; 84+ messages in thread
From: fengchengwen @ 2023-07-09 3:54 UTC (permalink / raw)
To: Stephen Hemminger, dev
Series-acked-by: Chengwen Feng <fengchengwen@huawei.com>
On 2023/7/8 9:57, Stephen Hemminger wrote:
> 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(-)
>
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v5 05/11] net/nfp: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 05/11] net/nfp: " Stephen Hemminger
@ 2023-07-10 12:19 ` Niklas Söderlund
2024-01-24 13:44 ` Thomas Monjalon
0 siblings, 1 reply; 84+ messages in thread
From: Niklas Söderlund @ 2023-07-10 12:19 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Chaoyong He
On 2023-07-07 18:57:12 -0700, Stephen Hemminger wrote:
> Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> ---
> 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(-)
>
> diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
> index f643d54d39a4..787a38dc9aa0 100644
> --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
> +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
> @@ -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);
> }
>
> /*
> diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
> index 4cb2c2f99e04..18823a97887d 100644
> --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
> +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
> @@ -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);
> --
> 2.39.2
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 84+ messages in thread
* RE: [EXT] [PATCH v5 04/11] drivers/crypto: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 04/11] drivers/crypto: " Stephen Hemminger
@ 2023-07-11 5:34 ` Anoob Joseph
2023-07-12 14:56 ` Hemant Agrawal
1 sibling, 0 replies; 84+ messages in thread
From: Anoob Joseph @ 2023-07-11 5:34 UTC (permalink / raw)
To: Stephen Hemminger, dev
Cc: Gagandeep Singh, Hemant Agrawal, Ankur Dwivedi, Tejasree Kondoj,
Kai Ji, Pablo de Lara
> Replace explicit packet offset computations with
> rte_pktmbuf_mtod_offset().
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anoob Joseph <anoobj@marvell.com>
^ permalink raw reply [flat|nested] 84+ messages in thread
* RE: [EXT] [PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
@ 2023-07-11 5:35 ` Anoob Joseph
0 siblings, 0 replies; 84+ messages in thread
From: Anoob Joseph @ 2023-07-11 5:35 UTC (permalink / raw)
To: Stephen Hemminger, dev
> Replace explicit packet offset computations with
> rte_pktmbuf_mtod_offset().
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anoob Joseph <anoobj@marvell.com>
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v5 04/11] drivers/crypto: use rte_pktmbuf_mtod_offset
2023-07-08 1:57 ` [PATCH v5 04/11] drivers/crypto: " Stephen Hemminger
2023-07-11 5:34 ` [EXT] " Anoob Joseph
@ 2023-07-12 14:56 ` Hemant Agrawal
1 sibling, 0 replies; 84+ messages in thread
From: Hemant Agrawal @ 2023-07-12 14:56 UTC (permalink / raw)
To: Stephen Hemminger, dev
Cc: Gagandeep Singh, Hemant Agrawal, Ankur Dwivedi, Anoob Joseph,
Tejasree Kondoj, Kai Ji, Pablo de Lara
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v5 05/11] net/nfp: use rte_pktmbuf_mtod_offset
2023-07-10 12:19 ` Niklas Söderlund
@ 2024-01-24 13:44 ` Thomas Monjalon
0 siblings, 0 replies; 84+ messages in thread
From: Thomas Monjalon @ 2024-01-24 13:44 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Chaoyong He, Niklas Söderlund
10/07/2023 14:19, Niklas Söderlund:
> On 2023-07-07 18:57:12 -0700, Stephen Hemminger wrote:
> > Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
A similar change by Chaoyong He has been merged in 23.11.
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset
2023-07-08 1:57 ` [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
@ 2024-01-24 13:47 ` Thomas Monjalon
0 siblings, 0 replies; 84+ messages in thread
From: Thomas Monjalon @ 2024-01-24 13:47 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
08/07/2023 03:57, Stephen Hemminger:
> Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
It has been reworked by David Marchand in 23.11.
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [PATCH v5 00/11] use rte_pktmbuf_mto_offset
2023-07-09 3:54 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset fengchengwen
@ 2024-01-24 14:55 ` Thomas Monjalon
0 siblings, 0 replies; 84+ messages in thread
From: Thomas Monjalon @ 2024-01-24 14:55 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, fengchengwen
> > 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
>
> Series-acked-by: Chengwen Feng <fengchengwen@huawei.com>
Applied except 2 patches which are no longer relevant, thanks.
^ permalink raw reply [flat|nested] 84+ messages in thread
end of thread, other threads:[~2024-01-24 14:56 UTC | newest]
Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05 17:47 [PATCH 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-05 17:48 ` [PATCH 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-05 17:48 ` [PATCH 02/14] gso: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 03/14] testpmd: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 04/14] test: cryptodev " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 05/14] examples: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 06/14] net/tap: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 07/14] net/nfp: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 08/14] crypto/ipsec_mb: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 09/14] crypto/qat: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
2023-05-05 17:48 ` [PATCH 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-05 17:48 ` [PATCH 12/14] crypto/caam_jr: " Stephen Hemminger
2023-05-09 11:43 ` Hemant Agrawal
2023-05-05 17:48 ` [PATCH 13/14] net/mlx4: " Stephen Hemminger
2023-05-05 17:48 ` [PATCH 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 00/14] rte_pktmbuf_mtod_offset usage Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 02/14] gso: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 03/14] testpmd: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 04/14] test: cryptodev " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 05/14] examples: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 06/14] net/tap: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 07/14] net/nfp: " Stephen Hemminger
2023-05-09 13:35 ` Niklas Söderlund
2023-05-06 16:03 ` [PATCH v2 08/14] crypto/ipsec_mb: " Stephen Hemminger
2023-05-29 12:47 ` De Lara Guarch, Pablo
2023-05-06 16:03 ` [PATCH v2 09/14] crypto/qat: " Stephen Hemminger
2023-05-06 16:03 ` [PATCH v2 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 12/14] crypto/caam_jr: " Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 13/14] net/mlx4: " Stephen Hemminger
2023-05-06 16:04 ` [PATCH v2 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 01/14] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 02/14] gso: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 03/14] testpmd: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 04/14] test: cryptodev " Stephen Hemminger
2023-07-07 12:46 ` Ferruh Yigit
2023-07-07 20:32 ` Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 05/14] examples: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 06/14] net/tap: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 07/14] net/nfp: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 08/14] crypto/ipsec_mb: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 09/14] crypto/qat: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 10/14] crypto/cnxk: use rte_ptkmbuf_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 11/14] common/cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 12/14] crypto/caam_jr: " Stephen Hemminger
2023-07-06 17:59 ` [PATCH v3 13/14] net/mlx4: " Stephen Hemminger
2023-07-07 12:46 ` Ferruh Yigit
2023-07-06 17:59 ` [PATCH v3 14/14] baseband/fpga_5gnr: use rte_pktmbu_mtod_offset Stephen Hemminger
2023-07-07 12:47 ` [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible Ferruh Yigit
2023-07-07 20:38 ` [PATCH v4 00/11] Use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:38 ` [PATCH v4 02/11] gso: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 03/11] test: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 04/11] drivers/crypto: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 05/11] net/nfp: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 09/11] testpmd: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 10/11] examples/ptpclient: " Stephen Hemminger
2023-07-07 20:39 ` [PATCH v4 11/11] examples/l2fwd-crypto: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 02/11] gso: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 03/11] test/crypto_dev: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 04/11] drivers/crypto: " Stephen Hemminger
2023-07-11 5:34 ` [EXT] " Anoob Joseph
2023-07-12 14:56 ` Hemant Agrawal
2023-07-08 1:57 ` [PATCH v5 05/11] net/nfp: " Stephen Hemminger
2023-07-10 12:19 ` Niklas Söderlund
2024-01-24 13:44 ` Thomas Monjalon
2023-07-08 1:57 ` [PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset Stephen Hemminger
2024-01-24 13:47 ` Thomas Monjalon
2023-07-08 1:57 ` [PATCH v5 07/11] baseband/fpga: use rte_pktmbuf_offset Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset Stephen Hemminger
2023-07-11 5:35 ` [EXT] " Anoob Joseph
2023-07-08 1:57 ` [PATCH v5 09/11] testpmd: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 10/11] examples/ptpclient: " Stephen Hemminger
2023-07-08 1:57 ` [PATCH v5 11/11] examples/l2fwd-crypto: " Stephen Hemminger
2023-07-09 3:54 ` [PATCH v5 00/11] use rte_pktmbuf_mto_offset fengchengwen
2024-01-24 14:55 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).