net/fm10k: remove unused constant
[dpdk.git] / app / test-pmd / iofwd.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #include <stdarg.h>
6 #include <stdio.h>
7 #include <string.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_launch.h>
23 #include <rte_eal.h>
24 #include <rte_per_lcore.h>
25 #include <rte_lcore.h>
26 #include <rte_atomic.h>
27 #include <rte_branch_prediction.h>
28 #include <rte_memcpy.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_flow.h>
37
38 #include "testpmd.h"
39
40 /*
41  * Forwarding of packets in I/O mode.
42  * Forward packets "as-is".
43  * This is the fastest possible forwarding operation, as it does not access
44  * to packets data.
45  */
46 static void
47 pkt_burst_io_forward(struct fwd_stream *fs)
48 {
49         struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
50         uint16_t nb_rx;
51         uint16_t nb_tx;
52         uint32_t retry;
53
54 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
55         uint64_t start_tsc;
56         uint64_t end_tsc;
57         uint64_t core_cycles;
58 #endif
59
60 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
61         start_tsc = rte_rdtsc();
62 #endif
63
64         /*
65          * Receive a burst of packets and forward them.
66          */
67         nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue,
68                         pkts_burst, nb_pkt_per_burst);
69         if (unlikely(nb_rx == 0))
70                 return;
71         fs->rx_packets += nb_rx;
72
73 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
74         fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
75 #endif
76         nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
77                         pkts_burst, nb_rx);
78         /*
79          * Retry if necessary
80          */
81         if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) {
82                 retry = 0;
83                 while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) {
84                         rte_delay_us(burst_tx_delay_time);
85                         nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
86                                         &pkts_burst[nb_tx], nb_rx - nb_tx);
87                 }
88         }
89         fs->tx_packets += nb_tx;
90 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
91         fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
92 #endif
93         if (unlikely(nb_tx < nb_rx)) {
94                 fs->fwd_dropped += (nb_rx - nb_tx);
95                 do {
96                         rte_pktmbuf_free(pkts_burst[nb_tx]);
97                 } while (++nb_tx < nb_rx);
98         }
99 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
100         end_tsc = rte_rdtsc();
101         core_cycles = (end_tsc - start_tsc);
102         fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles);
103 #endif
104 }
105
106 struct fwd_engine io_fwd_engine = {
107         .fwd_mode_name  = "io",
108         .port_fwd_begin = NULL,
109         .port_fwd_end   = NULL,
110         .packet_fwd     = pkt_burst_io_forward,
111 };