From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@amd.com>,
Aman Singh <aman.deep.singh@intel.com>,
Yuying Zhang <yuying.zhang@intel.com>,
Robin Jarry <rjarry@redhat.com>
Subject: [PATCH v2 8/9] app/testpmd: factorize fwd engine Rx
Date: Mon, 20 Feb 2023 17:41:02 +0100 [thread overview]
Message-ID: <20230220164103.3041538-9-david.marchand@redhat.com> (raw)
In-Reply-To: <20230220164103.3041538-1-david.marchand@redhat.com>
Reduce code duplication by introducing a helper that takes care of
receiving packets and incrementing rx counter.
inc_rx_burst_stats() is then unneeded and removed.
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
Changes since v1:
- updated shared_rxq fwd engine,
- removed inc_rx_burst_stats helper,
- removed likely() around rx stats update,
---
app/test-pmd/5tswap.c | 5 +----
app/test-pmd/csumonly.c | 5 +----
app/test-pmd/flowgen.c | 5 +----
app/test-pmd/icmpecho.c | 5 +----
app/test-pmd/ieee1588fwd.c | 4 +---
app/test-pmd/iofwd.c | 5 +----
app/test-pmd/macfwd.c | 5 +----
app/test-pmd/macswap.c | 5 +----
app/test-pmd/noisy_vnf.c | 5 +----
app/test-pmd/rxonly.c | 5 +----
app/test-pmd/shared_rxq_fwd.c | 4 +---
app/test-pmd/testpmd.h | 10 ++++++++--
12 files changed, 19 insertions(+), 44 deletions(-)
diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c
index 7b5f58f4d4..27da867d7f 100644
--- a/app/test-pmd/5tswap.c
+++ b/app/test-pmd/5tswap.c
@@ -108,13 +108,10 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
/*
* Receive a burst of packets and forward them.
*/
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
- fs->rx_packets += nb_rx;
txp = &ports[fs->tx_port];
ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);
vlan_qinq_set(pkts_burst, nb_rx, ol_flags,
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index f72e2d74c7..d758ae0ac6 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -860,13 +860,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct testpmd_offload_info info;
/* receive a burst of packet */
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
- fs->rx_packets += nb_rx;
rx_bad_ip_csum = 0;
rx_bad_l4_csum = 0;
rx_bad_outer_l4_csum = 0;
diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c
index 6f42019353..3705cc60c5 100644
--- a/app/test-pmd/flowgen.c
+++ b/app/test-pmd/flowgen.c
@@ -80,10 +80,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
int next_flow = RTE_PER_LCORE(_next_flow);
/* Receive a burst of packets and discard them. */
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
- fs->rx_packets += nb_rx;
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
rte_pktmbuf_free_bulk(pkts_burst, nb_rx);
diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c
index eba8b99f1e..48f8fe0bf1 100644
--- a/app/test-pmd/icmpecho.c
+++ b/app/test-pmd/icmpecho.c
@@ -296,13 +296,10 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
/*
* First, receive a burst of packets.
*/
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
- fs->rx_packets += nb_rx;
nb_replies = 0;
for (i = 0; i < nb_rx; i++) {
if (likely(i < nb_rx - 1))
diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index fd8ba27b2f..1d51ebfe9d 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -102,11 +102,9 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
/*
* Receive 1 packet at a time.
*/
- if (rte_eth_rx_burst(fs->rx_port, fs->rx_queue, &mb, 1) == 0)
+ if (common_fwd_stream_receive(fs, &mb, 1) == 0)
return false;
- fs->rx_packets += 1;
-
/*
* Check that the received packet is a PTP packet that was detected
* by the hardware.
diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c
index 12be06fa79..69b583cb5b 100644
--- a/app/test-pmd/iofwd.c
+++ b/app/test-pmd/iofwd.c
@@ -52,12 +52,9 @@ pkt_burst_io_forward(struct fwd_stream *fs)
/*
* Receive a burst of packets and forward them.
*/
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue,
- pkts_burst, nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
- fs->rx_packets += nb_rx;
nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
pkts_burst, nb_rx);
diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c
index 953d9ea089..a72f5ccb75 100644
--- a/app/test-pmd/macfwd.c
+++ b/app/test-pmd/macfwd.c
@@ -58,13 +58,10 @@ pkt_burst_mac_forward(struct fwd_stream *fs)
/*
* Receive a burst of packets and forward them.
*/
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
- fs->rx_packets += nb_rx;
txp = &ports[fs->tx_port];
tx_offloads = txp->dev_conf.txmode.offloads;
if (tx_offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT)
diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c
index 062542dc53..ab37123404 100644
--- a/app/test-pmd/macswap.c
+++ b/app/test-pmd/macswap.c
@@ -59,13 +59,10 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
/*
* Receive a burst of packets and forward them.
*/
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
- fs->rx_packets += nb_rx;
txp = &ports[fs->tx_port];
do_macswap(pkts_burst, nb_rx, txp);
diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c
index 7bcab84db3..e543adc865 100644
--- a/app/test-pmd/noisy_vnf.c
+++ b/app/test-pmd/noisy_vnf.c
@@ -150,12 +150,9 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs)
bool needs_flush = false;
uint64_t now;
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue,
- pkts_burst, nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
goto flush;
- fs->rx_packets += nb_rx;
if (!ncf->do_buffering) {
sim_memory_lookups(ncf, nb_rx);
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index d4bff9b5ea..315f9286cd 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -50,13 +50,10 @@ pkt_burst_receive(struct fwd_stream *fs)
/*
* Receive a burst of packets.
*/
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
- fs->rx_packets += nb_rx;
rte_pktmbuf_free_bulk(pkts_burst, nb_rx);
return true;
diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c
index 67e5494735..623d62da88 100644
--- a/app/test-pmd/shared_rxq_fwd.c
+++ b/app/test-pmd/shared_rxq_fwd.c
@@ -95,9 +95,7 @@ shared_rxq_fwd(struct fwd_stream *fs)
struct rte_mbuf *pkts_burst[nb_pkt_per_burst];
uint16_t nb_rx;
- nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
- nb_pkt_per_burst);
- inc_rx_burst_stats(fs, nb_rx);
+ nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
if (unlikely(nb_rx == 0))
return false;
forward_shared_rxq(fs, nb_rx, pkts_burst);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 4b28cd0d0d..6c82cbab45 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -839,11 +839,17 @@ mbuf_pool_find(unsigned int sock_id, uint16_t idx)
return rte_mempool_lookup((const char *)pool_name);
}
-static inline void
-inc_rx_burst_stats(struct fwd_stream *fs, uint16_t nb_rx)
+static inline uint16_t
+common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst,
+ unsigned int nb_pkts)
{
+ uint16_t nb_rx;
+
+ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, nb_pkts);
if (record_burst_stats)
fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
+ fs->rx_packets += nb_rx;
+ return nb_rx;
}
static inline void
--
2.39.2
next prev parent reply other threads:[~2023-02-20 16:42 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-24 10:47 [PATCH 0/6] Testpmd code cleanup David Marchand
2023-01-24 10:47 ` [PATCH 1/6] app/testpmd: factorize core cycles record David Marchand
2023-02-14 18:14 ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 2/6] app/testpmd: don't send unprepared packets David Marchand
2023-02-14 18:14 ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 3/6] app/testpmd: bulk free mbufs David Marchand
2023-02-14 18:14 ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 4/6] app/testpmd: factorize fwd engine init David Marchand
2023-02-14 18:14 ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 5/6] app/testpmd: factorize fwd engine Rx David Marchand
2023-02-14 18:15 ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 6/6] app/testpmd: factorize fwd engine Tx David Marchand
2023-02-14 11:03 ` Singh, Aman Deep
2023-02-14 18:17 ` Ferruh Yigit
2023-02-16 8:01 ` Singh, Aman Deep
2023-02-16 10:07 ` Ferruh Yigit
2023-02-14 18:16 ` Ferruh Yigit
2023-02-20 16:33 ` David Marchand
2023-01-25 13:50 ` [PATCH 0/6] Testpmd code cleanup Robin Jarry
2023-02-14 18:22 ` Ferruh Yigit
2023-02-20 15:02 ` David Marchand
2023-02-20 16:40 ` [PATCH v2 0/9] " David Marchand
2023-02-20 16:40 ` [PATCH v2 1/9] app/testpmd: fix Tx preparation in checksum engine David Marchand
2023-02-20 16:40 ` [PATCH v2 2/9] app/testpmd: fix packet count in ieee15888 engine David Marchand
2023-02-20 16:40 ` [PATCH v2 3/9] app/testpmd: rework ieee1588 engine fwd configuration David Marchand
2023-02-24 9:11 ` Singh, Aman Deep
2023-02-20 16:40 ` [PATCH v2 4/9] app/testpmd: fix packet transmission in noisy VNF engine David Marchand
2023-02-20 16:40 ` [PATCH v2 5/9] app/testpmd: bulk free mbufs David Marchand
2023-02-20 16:41 ` [PATCH v2 6/9] app/testpmd: factorize core cycles record David Marchand
2023-02-20 16:41 ` [PATCH v2 7/9] app/testpmd: factorize fwd engine init David Marchand
2023-02-20 16:41 ` David Marchand [this message]
2023-02-20 16:41 ` [PATCH v2 9/9] app/testpmd: factorize fwd engine Tx David Marchand
2023-02-20 18:34 ` [PATCH v3 0/9] Testpmd code cleanup David Marchand
2023-02-20 18:34 ` [PATCH v3 1/9] app/testpmd: fix Tx preparation in checksum engine David Marchand
2023-02-20 18:34 ` [PATCH v3 2/9] app/testpmd: fix packet count in ieee15888 engine David Marchand
2023-02-24 8:24 ` Singh, Aman Deep
2023-02-20 18:34 ` [PATCH v3 3/9] app/testpmd: rework ieee1588 engine fwd configuration David Marchand
2023-02-28 18:50 ` Ferruh Yigit
2023-02-20 18:34 ` [PATCH v3 4/9] app/testpmd: fix packet transmission in noisy VNF engine David Marchand
2023-02-28 18:51 ` Ferruh Yigit
2023-02-20 18:34 ` [PATCH v3 5/9] app/testpmd: bulk free mbufs David Marchand
2023-02-20 18:45 ` Stephen Hemminger
2023-02-20 18:34 ` [PATCH v3 6/9] app/testpmd: factorize core cycles record David Marchand
2023-02-20 18:35 ` [PATCH v3 7/9] app/testpmd: factorize fwd engine init David Marchand
2023-02-20 18:35 ` [PATCH v3 8/9] app/testpmd: factorize fwd engine Rx David Marchand
2023-02-20 18:35 ` [PATCH v3 9/9] app/testpmd: factorize fwd engine Tx David Marchand
2023-02-28 18:35 ` Ferruh Yigit
2023-02-28 18:54 ` [PATCH v3 0/9] Testpmd code cleanup Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230220164103.3041538-9-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=rjarry@redhat.com \
--cc=yuying.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).