ethdev: enhance burst mode information API
[dpdk.git] / app / test-pmd / rxonly.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #include <stdarg.h>
6 #include <string.h>
7 #include <stdio.h>
8 #include <errno.h>
9 #include <stdint.h>
10 #include <unistd.h>
11 #include <inttypes.h>
12
13 #include <sys/queue.h>
14 #include <sys/stat.h>
15
16 #include <rte_common.h>
17 #include <rte_byteorder.h>
18 #include <rte_log.h>
19 #include <rte_debug.h>
20 #include <rte_cycles.h>
21 #include <rte_memory.h>
22 #include <rte_memcpy.h>
23 #include <rte_launch.h>
24 #include <rte_eal.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_atomic.h>
28 #include <rte_branch_prediction.h>
29 #include <rte_mempool.h>
30 #include <rte_mbuf.h>
31 #include <rte_interrupts.h>
32 #include <rte_pci.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_ip.h>
37 #include <rte_udp.h>
38 #include <rte_net.h>
39 #include <rte_flow.h>
40
41 #include "testpmd.h"
42
43 /*
44  * Received a burst of packets.
45  */
46 static void
47 pkt_burst_receive(struct fwd_stream *fs)
48 {
49         struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
50         uint16_t nb_rx;
51         uint16_t i;
52
53 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
54         uint64_t start_tsc;
55         uint64_t end_tsc;
56         uint64_t core_cycles;
57
58         start_tsc = rte_rdtsc();
59 #endif
60
61         /*
62          * Receive a burst of packets.
63          */
64         nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
65                                  nb_pkt_per_burst);
66         if (unlikely(nb_rx == 0))
67                 return;
68
69 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
70         fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
71 #endif
72         fs->rx_packets += nb_rx;
73         for (i = 0; i < nb_rx; i++)
74                 rte_pktmbuf_free(pkts_burst[i]);
75
76 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
77         end_tsc = rte_rdtsc();
78         core_cycles = (end_tsc - start_tsc);
79         fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles);
80 #endif
81 }
82
83 struct fwd_engine rx_only_engine = {
84         .fwd_mode_name  = "rxonly",
85         .port_fwd_begin = NULL,
86         .port_fwd_end   = NULL,
87         .packet_fwd     = pkt_burst_receive,
88 };