[v2,1/9] app/testpmd: fix Tx preparation in checksum engine
Checks
Commit Message
"unprepared" packets could get to the wire in the retry loop.
Split packets freeing in two stages: one for preparation failure, and
one for transmission failure.
Adjust dropped counter update accordingly.
Fixes: 6b520d54ebfe ("app/testpmd: use Tx preparation in checksum engine")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
app/test-pmd/csumonly.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
@@ -1168,10 +1168,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
nb_prep = rte_eth_tx_prepare(fs->tx_port, fs->tx_queue,
tx_pkts_burst, nb_rx);
- if (nb_prep != nb_rx)
+ if (nb_prep != nb_rx) {
fprintf(stderr,
"Preparing packet burst to transmit failed: %s\n",
rte_strerror(rte_errno));
+ fs->fwd_dropped += (nb_rx - nb_prep);
+ rte_pktmbuf_free_bulk(&tx_pkts_burst[nb_prep], nb_rx - nb_prep);
+ }
nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, tx_pkts_burst,
nb_prep);
@@ -1179,12 +1182,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
/*
* Retry if necessary
*/
- if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) {
+ if (unlikely(nb_tx < nb_prep) && fs->retry_enabled) {
retry = 0;
- while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) {
+ while (nb_tx < nb_prep && retry++ < burst_tx_retry_num) {
rte_delay_us(burst_tx_delay_time);
nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
- &tx_pkts_burst[nb_tx], nb_rx - nb_tx);
+ &tx_pkts_burst[nb_tx], nb_prep - nb_tx);
}
}
fs->tx_packets += nb_tx;
@@ -1194,11 +1197,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
fs->rx_bad_outer_ip_csum += rx_bad_outer_ip_csum;
inc_tx_burst_stats(fs, nb_tx);
- if (unlikely(nb_tx < nb_rx)) {
- fs->fwd_dropped += (nb_rx - nb_tx);
+ if (unlikely(nb_tx < nb_prep)) {
+ fs->fwd_dropped += (nb_prep - nb_tx);
do {
rte_pktmbuf_free(tx_pkts_burst[nb_tx]);
- } while (++nb_tx < nb_rx);
+ } while (++nb_tx < nb_prep);
}
get_end_cycles(fs, start_tsc);