summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Nikhilesh <pbhagavatula@marvell.com>2019-04-02 09:53:36 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2019-04-05 19:28:22 +0200
commit32941b5d52e4ef69b6fcf55765f4f1e8948494ab (patch)
treef58bb0600cba4473ae9442a06b3a70b1ea6dfdce
parent01b645dcff7f5f0c39031ef5c2de14ff0ae1d7cd (diff)
downloaddpdk-32941b5d52e4ef69b6fcf55765f4f1e8948494ab.zip
dpdk-32941b5d52e4ef69b6fcf55765f4f1e8948494ab.tar.gz
dpdk-32941b5d52e4ef69b6fcf55765f4f1e8948494ab.tar.xz
app/testpmd: allocate txonly packets per bulk
Use mempool bulk get ops to alloc burst of packets and process them. If bulk get fails fallback to rte_mbuf_raw_alloc. Tested-by: Yingya Han <yingyax.han@intel.com> Suggested-by: Andrew Rybchenko <arybchenko@solarflare.com> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
-rw-r--r--app/test-pmd/txonly.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index 56ca0ad..66e6378 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -268,16 +268,33 @@ pkt_burst_transmit(struct fwd_stream *fs)
ether_addr_copy(&ports[fs->tx_port].eth_addr, &eth_hdr.s_addr);
eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
- for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
- pkt = rte_mbuf_raw_alloc(mbp);
- if (pkt == NULL)
- break;
- if (unlikely(!pkt_burst_prepare(pkt, mbp, &eth_hdr, vlan_tci,
- vlan_tci_outer, ol_flags))) {
- rte_pktmbuf_free(pkt);
- break;
+ if (rte_mempool_get_bulk(mbp, (void **)pkts_burst,
+ nb_pkt_per_burst) == 0) {
+ for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
+ if (unlikely(!pkt_burst_prepare(pkts_burst[nb_pkt], mbp,
+ &eth_hdr, vlan_tci,
+ vlan_tci_outer,
+ ol_flags))) {
+ rte_mempool_put_bulk(mbp,
+ (void **)&pkts_burst[nb_pkt],
+ nb_pkt_per_burst - nb_pkt);
+ break;
+ }
+ }
+ } else {
+ for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
+ pkt = rte_mbuf_raw_alloc(mbp);
+ if (pkt == NULL)
+ break;
+ if (unlikely(!pkt_burst_prepare(pkt, mbp, &eth_hdr,
+ vlan_tci,
+ vlan_tci_outer,
+ ol_flags))) {
+ rte_pktmbuf_free(pkt);
+ break;
+ }
+ pkts_burst[nb_pkt] = pkt;
}
- pkts_burst[nb_pkt] = pkt;
}
if (nb_pkt == 0)