Re: [dpdk-dev] [PATCH v3 6/8] app/testpmd: add common fwd wrapper
From: Jerin Jacob <hidden>
Date: 2021-09-17 11:24:46
On Fri, Sep 17, 2021 at 1:33 PM Xueming Li [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Xiaoyu Min <redacted> Added common forwarding wrapper function for all fwd engines which do the following in common: - record core cycles - call rte_eth_rx_burst(...,nb_pkt_per_burst) - update received packets - handle received mbufs with callback function For better performance, the function is defined as macro. Signed-off-by: Xiaoyu Min <redacted> Signed-off-by: Xueming Li <redacted> --- app/test-pmd/5tswap.c | 25 +++++-------------------- app/test-pmd/csumonly.c | 25 ++++++------------------- app/test-pmd/flowgen.c | 20 +++++--------------- app/test-pmd/icmpecho.c | 30 ++++++++---------------------- app/test-pmd/iofwd.c | 24 +++++------------------- app/test-pmd/macfwd.c | 24 +++++------------------- app/test-pmd/macswap.c | 23 +++++------------------ app/test-pmd/rxonly.c | 32 ++++++++------------------------ app/test-pmd/testpmd.h | 19 +++++++++++++++++++ 9 files changed, 66 insertions(+), 156 deletions(-)diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index e8cef9623b..8fe940294f 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c@@ -82,18 +82,16 @@ swap_udp(struct rte_udp_hdr *udp_hdr) * Parses each layer and swaps it. When the next layer doesn't match it stops. */
+PKT_BURST_FWD(_5tuple_swap_stream);
Please make _5tuple_swap_stream aka "cb" as inline function to make sure compiler doesn't generate yet another function pointer.
struct fwd_engine mac_swap_engine = {
.fwd_mode_name = "macswap",
.port_fwd_begin = NULL,
.port_fwd_end = NULL,
- .packet_fwd = pkt_burst_mac_swap,See below
+ .packet_fwd = pkt_burst_fwd, +#define PKT_BURST_FWD(cb) \
Probably it can pass prefix too like PKT_BURST_FWD(cb, prefix) to make a unique function and call PKT_BURST_FWD(_5tuple_swap_stream, mac_swap) for better readability and avoid diff above section.
+static void \ +pkt_burst_fwd(struct fwd_stream *fs)
pkt_burst_fwd##prefix(struct fwd_stream *fs)
\+{ \
+ struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; \
+ uint16_t nb_rx; \
+ uint64_t start_tsc = 0; \
+ \
+ get_start_cycles(&start_tsc); \
+ 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); \
+ if (unlikely(nb_rx == 0)) \
+ return; \
+ fs->rx_packets += nb_rx; \
+ cb(fs, nb_rx, pkts_burst); \
+ get_end_cycles(fs, start_tsc); \
+}
+
/*
* Work-around of a compilation error with ICC on invocations of the
* rte_be_to_cpu_16() function.
--
2.33.0