@@ -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,
@@ -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;
@@ -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);
@@ -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))
@@ -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.
@@ -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);
@@ -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)
@@ -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);
@@ -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);
@@ -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;
@@ -857,6 +857,18 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)
if (record_burst_stats)
fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
}
+static inline uint16_t
+common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst,
+ unsigned int count)
+{
+ uint16_t nb_rx;
+
+ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, count);
+ inc_rx_burst_stats(fs, nb_rx);
+ if (likely(nb_rx != 0))
+ fs->rx_packets += nb_rx;
+ return nb_rx;
+}
/* Prototypes */
unsigned int parse_item_list(const char *str, const char *item_name,