diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:48:23 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:48:23 +0200 |
commit | 1b6242fc583a6b871304fb995af6dc211b58f69b (patch) | |
tree | b5d434d90dedae24792906aa304897c23a134386 /recipes-networking/dpdk/files/l2fwd-lpbk | |
download | meta-ip-1b6242fc583a6b871304fb995af6dc211b58f69b.tar.gz |
initial commit for Enea Linux 4.0daisy-enea
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'recipes-networking/dpdk/files/l2fwd-lpbk')
-rw-r--r-- | recipes-networking/dpdk/files/l2fwd-lpbk/Makefile | 51 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/l2fwd-lpbk/main.c | 929 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/l2fwd-lpbk/main.h | 45 |
3 files changed, 1025 insertions, 0 deletions
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile b/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile new file mode 100644 index 0000000..72d56b7 --- /dev/null +++ b/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile | |||
@@ -0,0 +1,51 @@ | |||
1 | # BSD LICENSE | ||
2 | # | ||
3 | # Copyright(c) 2010-2013 Intel Corporation. All rights reserved. | ||
4 | # All rights reserved. | ||
5 | # | ||
6 | # Redistribution and use in source and binary forms, with or without | ||
7 | # modification, are permitted provided that the following conditions | ||
8 | # are met: | ||
9 | # | ||
10 | # * Redistributions of source code must retain the above copyright | ||
11 | # notice, this list of conditions and the following disclaimer. | ||
12 | # * Redistributions in binary form must reproduce the above copyright | ||
13 | # notice, this list of conditions and the following disclaimer in | ||
14 | # the documentation and/or other materials provided with the | ||
15 | # distribution. | ||
16 | # * Neither the name of Intel Corporation nor the names of its | ||
17 | # contributors may be used to endorse or promote products derived | ||
18 | # from this software without specific prior written permission. | ||
19 | # | ||
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | # | ||
32 | |||
33 | ifeq ($(RTE_SDK),) | ||
34 | $(error "Please define RTE_SDK environment variable") | ||
35 | endif | ||
36 | |||
37 | # Default target, can be overriden by command line or environment | ||
38 | RTE_TARGET ?= x86_64-default-linuxapp-gcc | ||
39 | |||
40 | include $(RTE_SDK)/mk/rte.vars.mk | ||
41 | |||
42 | # binary name | ||
43 | APP = l2fwd-lpbk | ||
44 | |||
45 | # all source are stored in SRCS-y | ||
46 | SRCS-y := main.c | ||
47 | |||
48 | CFLAGS += -O3 | ||
49 | CFLAGS += $(WERROR_FLAGS) | ||
50 | |||
51 | include $(RTE_SDK)/mk/rte.extapp.mk | ||
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/main.c b/recipes-networking/dpdk/files/l2fwd-lpbk/main.c new file mode 100644 index 0000000..ff22b66 --- /dev/null +++ b/recipes-networking/dpdk/files/l2fwd-lpbk/main.c | |||
@@ -0,0 +1,929 @@ | |||
1 | /*- | ||
2 | * BSD LICENSE | ||
3 | * | ||
4 | * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * | ||
11 | * * Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in | ||
15 | * the documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * * Neither the name of Intel Corporation nor the names of its | ||
18 | * contributors may be used to endorse or promote products derived | ||
19 | * from this software without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | #include <stdint.h> | ||
38 | #include <inttypes.h> | ||
39 | #include <sys/types.h> | ||
40 | #include <sys/queue.h> | ||
41 | #include <netinet/in.h> | ||
42 | #include <setjmp.h> | ||
43 | #include <stdarg.h> | ||
44 | #include <ctype.h> | ||
45 | #include <errno.h> | ||
46 | #include <getopt.h> | ||
47 | |||
48 | #include <rte_common.h> | ||
49 | #include <rte_log.h> | ||
50 | #include <rte_memory.h> | ||
51 | #include <rte_memcpy.h> | ||
52 | #include <rte_memzone.h> | ||
53 | #include <rte_tailq.h> | ||
54 | #include <rte_eal.h> | ||
55 | #include <rte_per_lcore.h> | ||
56 | #include <rte_launch.h> | ||
57 | #include <rte_atomic.h> | ||
58 | #include <rte_cycles.h> | ||
59 | #include <rte_prefetch.h> | ||
60 | #include <rte_lcore.h> | ||
61 | #include <rte_per_lcore.h> | ||
62 | #include <rte_branch_prediction.h> | ||
63 | #include <rte_interrupts.h> | ||
64 | #include <rte_pci.h> | ||
65 | #include <rte_random.h> | ||
66 | #include <rte_debug.h> | ||
67 | #include <rte_ether.h> | ||
68 | #include <rte_ethdev.h> | ||
69 | #include <rte_ring.h> | ||
70 | #include <rte_mempool.h> | ||
71 | #include <rte_mbuf.h> | ||
72 | #include <rte_byteorder.h> | ||
73 | #include <rte_hexdump.h> | ||
74 | |||
75 | #include "main.h" | ||
76 | |||
77 | #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 | ||
78 | |||
79 | #define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) | ||
80 | #define NB_MBUF 8192 | ||
81 | |||
82 | /* | ||
83 | * RX and TX Prefetch, Host, and Write-back threshold values should be | ||
84 | * carefully set for optimal performance. Consult the network | ||
85 | * controller's datasheet and supporting DPDK documentation for guidance | ||
86 | * on how these parameters should be set. | ||
87 | */ | ||
88 | #define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */ | ||
89 | #define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */ | ||
90 | #define RX_WTHRESH 4 /**< Default values of RX write-back threshold reg. */ | ||
91 | |||
92 | /* | ||
93 | * These default values are optimized for use with the Intel(R) 82599 10 GbE | ||
94 | * Controller and the DPDK ixgbe PMD. Consider using other values for other | ||
95 | * network controllers and/or network drivers. | ||
96 | */ | ||
97 | #define TX_PTHRESH 36 /**< Default values of TX prefetch threshold reg. */ | ||
98 | #define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */ | ||
99 | #define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */ | ||
100 | |||
101 | #define MAX_PKT_BURST 32 | ||
102 | #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ | ||
103 | |||
104 | /* | ||
105 | * Configurable number of RX/TX ring descriptors | ||
106 | */ | ||
107 | #define RTE_TEST_RX_DESC_DEFAULT 128 | ||
108 | #define RTE_TEST_TX_DESC_DEFAULT 512 | ||
109 | static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT; | ||
110 | static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; | ||
111 | |||
112 | /* ethernet addresses of ports */ | ||
113 | static struct ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS]; | ||
114 | |||
115 | /* mask of enabled ports */ | ||
116 | static uint32_t l2fwd_enabled_port_mask = 0; | ||
117 | |||
118 | /* list of enabled ports */ | ||
119 | static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS]; | ||
120 | |||
121 | static unsigned int l2fwd_rx_queue_per_lcore = 1; | ||
122 | |||
123 | #define MIN_TX_SIZE 64 | ||
124 | #define MAX_TX_SIZE 2048 | ||
125 | static int l2fwd_tx_size = MIN_TX_SIZE; | ||
126 | |||
127 | #define MAX_TX_COUNT 128 | ||
128 | static int l2fwd_tx_count = 0; | ||
129 | |||
130 | static int l2fwd_loopback = 0; | ||
131 | |||
132 | struct mbuf_table { | ||
133 | unsigned len; | ||
134 | struct rte_mbuf *m_table[MAX_PKT_BURST]; | ||
135 | }; | ||
136 | |||
137 | #define MAX_RX_QUEUE_PER_LCORE 16 | ||
138 | #define MAX_TX_QUEUE_PER_PORT 16 | ||
139 | struct lcore_queue_conf { | ||
140 | unsigned n_rx_port; | ||
141 | unsigned rx_port_list[MAX_RX_QUEUE_PER_LCORE]; | ||
142 | struct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS]; | ||
143 | |||
144 | } __rte_cache_aligned; | ||
145 | struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE]; | ||
146 | |||
147 | static struct rte_eth_conf port_conf = { | ||
148 | .rxmode = { | ||
149 | .split_hdr_size = 0, | ||
150 | .header_split = 0, /**< Header Split disabled */ | ||
151 | .hw_ip_checksum = 0, /**< IP checksum offload disabled */ | ||
152 | .hw_vlan_filter = 0, /**< VLAN filtering disabled */ | ||
153 | .jumbo_frame = 0, /**< Jumbo Frame Support disabled */ | ||
154 | .hw_strip_crc = 0, /**< CRC stripped by hardware */ | ||
155 | }, | ||
156 | .txmode = { | ||
157 | .mq_mode = ETH_MQ_TX_NONE, | ||
158 | }, | ||
159 | }; | ||
160 | |||
161 | static const struct rte_eth_rxconf rx_conf = { | ||
162 | .rx_thresh = { | ||
163 | .pthresh = RX_PTHRESH, | ||
164 | .hthresh = RX_HTHRESH, | ||
165 | .wthresh = RX_WTHRESH, | ||
166 | }, | ||
167 | }; | ||
168 | |||
169 | static const struct rte_eth_txconf tx_conf = { | ||
170 | .tx_thresh = { | ||
171 | .pthresh = TX_PTHRESH, | ||
172 | .hthresh = TX_HTHRESH, | ||
173 | .wthresh = TX_WTHRESH, | ||
174 | }, | ||
175 | .tx_free_thresh = 0, /* Use PMD default values */ | ||
176 | .tx_rs_thresh = 0, /* Use PMD default values */ | ||
177 | }; | ||
178 | |||
179 | struct rte_mempool * l2fwd_pktmbuf_pool = NULL; | ||
180 | |||
181 | /* Per-port statistics struct */ | ||
182 | struct l2fwd_port_statistics { | ||
183 | uint64_t tx; | ||
184 | uint64_t rx; | ||
185 | uint64_t dropped; | ||
186 | uint64_t loop; | ||
187 | } __rte_cache_aligned; | ||
188 | struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; | ||
189 | |||
190 | /* A tsc-based timer responsible for triggering statistics printout */ | ||
191 | #define MAX_TIMER_PERIOD 86400 /* 1 day max */ | ||
192 | static int64_t timer_period; | ||
193 | static uint64_t tsc_hz; | ||
194 | |||
195 | static void l2fwd_init_time(void) | ||
196 | { | ||
197 | tsc_hz = rte_get_tsc_hz(); | ||
198 | timer_period = 10 * rte_get_tsc_hz(); /* default period is 10 seconds */ | ||
199 | } | ||
200 | |||
201 | /* Print out statistics on packets dropped */ | ||
202 | static void | ||
203 | print_stats(void) | ||
204 | { | ||
205 | uint64_t total_packets_dropped, total_packets_tx, total_packets_rx; | ||
206 | unsigned portid; | ||
207 | static uint64_t count = 0; | ||
208 | const char clr[] = { 27, '[', '2', 'J', '\0' }; | ||
209 | const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' }; | ||
210 | |||
211 | total_packets_dropped = 0; | ||
212 | total_packets_tx = 0; | ||
213 | total_packets_rx = 0; | ||
214 | |||
215 | /* Clear screen and move to top left */ | ||
216 | printf("%s%s", clr, topLeft); | ||
217 | |||
218 | printf("\nPort statistics ===================================="); | ||
219 | |||
220 | for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { | ||
221 | /* skip disabled ports */ | ||
222 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
223 | continue; | ||
224 | printf("\nStatistics for port %u ------------------------------" | ||
225 | "\nPackets sent: %24"PRIu64 | ||
226 | "\nPackets received: %20"PRIu64 | ||
227 | "\nPackets dropped: %21"PRIu64 | ||
228 | "\nLoop count : %21"PRIu64, | ||
229 | portid, | ||
230 | port_statistics[portid].tx, | ||
231 | port_statistics[portid].rx, | ||
232 | port_statistics[portid].dropped, | ||
233 | port_statistics[portid].loop); | ||
234 | |||
235 | total_packets_dropped += port_statistics[portid].dropped; | ||
236 | total_packets_tx += port_statistics[portid].tx; | ||
237 | total_packets_rx += port_statistics[portid].rx; | ||
238 | } | ||
239 | printf("\nAggregate statistics ===============================" | ||
240 | "\nTotal packets sent: %18"PRIu64 | ||
241 | "\nTotal packets received: %14"PRIu64 | ||
242 | "\nTotal packets dropped: %15"PRIu64 | ||
243 | "\nPeriod: %"PRIu64, | ||
244 | total_packets_tx, | ||
245 | total_packets_rx, | ||
246 | total_packets_dropped, | ||
247 | count | ||
248 | ); | ||
249 | printf("\n====================================================\n"); | ||
250 | |||
251 | count++; | ||
252 | } | ||
253 | |||
254 | /* Send the burst of packets on an output interface */ | ||
255 | static int | ||
256 | l2fwd_send_burst(struct lcore_queue_conf *qconf, unsigned n, uint8_t port) | ||
257 | { | ||
258 | struct rte_mbuf **m_table; | ||
259 | unsigned ret; | ||
260 | unsigned queueid =0; | ||
261 | |||
262 | m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table; | ||
263 | |||
264 | ret = rte_eth_tx_burst(port, (uint16_t) queueid, m_table, (uint16_t) n); | ||
265 | port_statistics[port].tx += ret; | ||
266 | if (unlikely(ret < n)) { | ||
267 | port_statistics[port].dropped += (n - ret); | ||
268 | do { | ||
269 | rte_pktmbuf_free(m_table[ret]); | ||
270 | } while (++ret < n); | ||
271 | } | ||
272 | |||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | /* Enqueue packets for TX and prepare them to be sent */ | ||
277 | static int | ||
278 | l2fwd_send_packet(struct rte_mbuf *m, uint8_t port) | ||
279 | { | ||
280 | unsigned lcore_id, len; | ||
281 | struct lcore_queue_conf *qconf; | ||
282 | |||
283 | lcore_id = rte_lcore_id(); | ||
284 | |||
285 | qconf = &lcore_queue_conf[lcore_id]; | ||
286 | len = qconf->tx_mbufs[port].len; | ||
287 | qconf->tx_mbufs[port].m_table[len] = m; | ||
288 | len++; | ||
289 | |||
290 | /* enough pkts to be sent */ | ||
291 | if (unlikely(len == MAX_PKT_BURST)) { | ||
292 | l2fwd_send_burst(qconf, MAX_PKT_BURST, port); | ||
293 | len = 0; | ||
294 | } | ||
295 | |||
296 | qconf->tx_mbufs[port].len = len; | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static void | ||
301 | l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid) | ||
302 | { | ||
303 | struct ether_hdr *eth; | ||
304 | void *tmp; | ||
305 | unsigned dst_port; | ||
306 | |||
307 | dst_port = l2fwd_dst_ports[portid]; | ||
308 | |||
309 | eth = rte_pktmbuf_mtod(m, struct ether_hdr *); | ||
310 | /* 02:00:00:00:00:xx */ | ||
311 | tmp = ð->d_addr.addr_bytes[0]; | ||
312 | *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dst_port << 40); | ||
313 | |||
314 | /* src addr */ | ||
315 | ether_addr_copy(&l2fwd_ports_eth_addr[dst_port], ð->s_addr); | ||
316 | |||
317 | l2fwd_send_packet(m, (uint8_t) dst_port); | ||
318 | } | ||
319 | |||
320 | static inline void | ||
321 | copy_buf_to_pkt(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset) | ||
322 | { | ||
323 | rte_memcpy(((char *) pkt->pkt.data + offset), buf, (size_t) len); | ||
324 | } | ||
325 | |||
326 | static int | ||
327 | l2fwd_tx(void) | ||
328 | { | ||
329 | uint8_t portid; | ||
330 | |||
331 | for (portid = 0; portid < RTE_MAX_ETHPORTS; ++portid) { | ||
332 | struct rte_mbuf *tx_mbuf[MAX_TX_COUNT]; | ||
333 | int pkt; | ||
334 | unsigned queueid = 0; | ||
335 | |||
336 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
337 | continue; | ||
338 | |||
339 | for (pkt = 0; pkt < l2fwd_tx_count; ++pkt) { | ||
340 | |||
341 | tx_mbuf[pkt] = rte_pktmbuf_alloc(l2fwd_pktmbuf_pool); | ||
342 | if (!tx_mbuf[pkt]) | ||
343 | rte_exit(EXIT_FAILURE, | ||
344 | "rte_pktmbuf_alloc failed.\n"); | ||
345 | |||
346 | /* minimum ethernet header | ||
347 | without this the 82599 will drop the packet if IXGBE_FCTRL_SBP is not set | ||
348 | */ | ||
349 | { | ||
350 | struct ether_hdr *eth_hdr; | ||
351 | /*struct ipv4_hdr *ipv4_hdr;*/ | ||
352 | struct ether_addr mac_addr; | ||
353 | |||
354 | eth_hdr = rte_pktmbuf_mtod(tx_mbuf[pkt], struct ether_hdr*); | ||
355 | |||
356 | rte_eth_macaddr_get(portid, &mac_addr); | ||
357 | #if 1 | ||
358 | mac_addr.addr_bytes[0] = 0; | ||
359 | mac_addr.addr_bytes[1] = 2; | ||
360 | #endif | ||
361 | ether_addr_copy(&mac_addr, ð_hdr->s_addr); | ||
362 | ether_addr_copy(&mac_addr, ð_hdr->d_addr); | ||
363 | eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); | ||
364 | |||
365 | /*ipv4_hdr = (struct ipv4_hdr*)ð_hdr[1];*/ | ||
366 | |||
367 | tx_mbuf[pkt]->pkt.data_len = l2fwd_tx_size; | ||
368 | tx_mbuf[pkt]->pkt.pkt_len = l2fwd_tx_size; | ||
369 | #if 0 | ||
370 | rte_hexdump(NULL, rte_pktmbuf_mtod(tx_mbuf[pkt], void*), l2fwd_tx_size); | ||
371 | #endif | ||
372 | } | ||
373 | } | ||
374 | |||
375 | if(rte_eth_tx_burst(portid, queueid, tx_mbuf, l2fwd_tx_count) != l2fwd_tx_count) | ||
376 | rte_exit(EXIT_FAILURE, "Incomplete Tx for port %u\n", portid); | ||
377 | |||
378 | RTE_LOG(INFO, L2FWD, "sent %u packets on port %u\n", l2fwd_tx_count, portid); | ||
379 | } | ||
380 | |||
381 | return 0; | ||
382 | } | ||
383 | |||
384 | /* main processing loop */ | ||
385 | static void | ||
386 | l2fwd_main_loop(void) | ||
387 | { | ||
388 | struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; | ||
389 | struct rte_mbuf *m; | ||
390 | unsigned lcore_id; | ||
391 | uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc; | ||
392 | unsigned i, j, portid, nb_rx; | ||
393 | struct lcore_queue_conf *qconf; | ||
394 | const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US; | ||
395 | |||
396 | prev_tsc = 0; | ||
397 | timer_tsc = 0; | ||
398 | |||
399 | lcore_id = rte_lcore_id(); | ||
400 | qconf = &lcore_queue_conf[lcore_id]; | ||
401 | |||
402 | if (qconf->n_rx_port == 0) { | ||
403 | RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id); | ||
404 | return; | ||
405 | } | ||
406 | |||
407 | RTE_LOG(INFO, L2FWD, "entering main loop on lcore %u\n", lcore_id); | ||
408 | |||
409 | for (i = 0; i < qconf->n_rx_port; i++) { | ||
410 | |||
411 | portid = qconf->rx_port_list[i]; | ||
412 | RTE_LOG(INFO, L2FWD, " -- lcoreid=%u portid=%u\n", lcore_id, | ||
413 | portid); | ||
414 | } | ||
415 | |||
416 | while (1) { | ||
417 | cur_tsc = rte_rdtsc(); | ||
418 | |||
419 | /* | ||
420 | * TX burst queue drain | ||
421 | */ | ||
422 | diff_tsc = cur_tsc - prev_tsc; | ||
423 | if (unlikely(diff_tsc > drain_tsc)) { | ||
424 | for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { | ||
425 | if (qconf->tx_mbufs[portid].len == 0) | ||
426 | continue; | ||
427 | l2fwd_send_burst(&lcore_queue_conf[lcore_id], | ||
428 | qconf->tx_mbufs[portid].len, | ||
429 | (uint8_t) portid); | ||
430 | qconf->tx_mbufs[portid].len = 0; | ||
431 | } | ||
432 | /* if timer is enabled */ | ||
433 | if (timer_period > 0) { | ||
434 | |||
435 | /* advance the timer */ | ||
436 | timer_tsc += diff_tsc; | ||
437 | |||
438 | /* if timer has reached its timeout */ | ||
439 | if (unlikely(timer_tsc >= (uint64_t) timer_period)) { | ||
440 | |||
441 | /* do this only on master core */ | ||
442 | if (lcore_id == rte_get_master_lcore()) { | ||
443 | print_stats(); | ||
444 | /* reset the timer */ | ||
445 | timer_tsc = 0; | ||
446 | } | ||
447 | } | ||
448 | } | ||
449 | |||
450 | prev_tsc = cur_tsc; | ||
451 | } | ||
452 | |||
453 | /* | ||
454 | * Read packet from RX queues | ||
455 | */ | ||
456 | for (i = 0; i < qconf->n_rx_port; i++) { | ||
457 | portid = qconf->rx_port_list[i]; | ||
458 | nb_rx = rte_eth_rx_burst((uint8_t) portid, 0, | ||
459 | pkts_burst, MAX_PKT_BURST); | ||
460 | |||
461 | port_statistics[portid].rx += nb_rx; | ||
462 | port_statistics[portid].loop++; | ||
463 | |||
464 | for (j = 0; j < nb_rx; j++) { | ||
465 | m = pkts_burst[j]; | ||
466 | rte_prefetch0(rte_pktmbuf_mtod(m, void *)); | ||
467 | l2fwd_simple_forward(m, portid); | ||
468 | |||
469 | #if 0 | ||
470 | rte_hexdump(NULL, rte_pktmbuf_mtod(pkts_burst[j], void*), pkts_burst[j]->pkt.data_len); | ||
471 | #endif | ||
472 | |||
473 | } | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | |||
478 | static int | ||
479 | l2fwd_launch_one_lcore(__attribute__((unused)) void *dummy) | ||
480 | { | ||
481 | l2fwd_main_loop(); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | /* display usage */ | ||
486 | static void | ||
487 | l2fwd_usage(const char *prgname) | ||
488 | { | ||
489 | printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" | ||
490 | " -p PORTMASK: hexadecimal bitmask of ports to configure\n" | ||
491 | " -q NQ: number of queue (=ports) per lcore (default is 1)\n" | ||
492 | " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n" | ||
493 | " -t TX: number of packets to send before forwarding (0 to disable, 0 default, 128 maximum)\n" | ||
494 | " -l LOOPBACK: loopback mode \n" | ||
495 | " -s SIZE: size of packets to be sent (64 default/minimum, 2048 maximum)\n", | ||
496 | prgname); | ||
497 | } | ||
498 | |||
499 | static int | ||
500 | l2fwd_parse_portmask(const char *portmask) | ||
501 | { | ||
502 | char *end = NULL; | ||
503 | unsigned long pm; | ||
504 | |||
505 | /* parse hexadecimal string */ | ||
506 | pm = strtoul(portmask, &end, 16); | ||
507 | if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
508 | return -1; | ||
509 | |||
510 | if (pm == 0) | ||
511 | return -1; | ||
512 | |||
513 | return pm; | ||
514 | } | ||
515 | |||
516 | static int | ||
517 | l2fwd_parse_tx_packet_count(const char *q_arg) | ||
518 | { | ||
519 | char *end = NULL; | ||
520 | int n; | ||
521 | |||
522 | /* parse number string */ | ||
523 | n = strtol(q_arg, &end, 10); | ||
524 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
525 | return -1; | ||
526 | if (n > MAX_TX_COUNT) | ||
527 | return -1; | ||
528 | |||
529 | return n; | ||
530 | } | ||
531 | |||
532 | static int | ||
533 | l2fwd_parse_tx_packet_size(const char *q_arg) | ||
534 | { | ||
535 | char *end = NULL; | ||
536 | int n; | ||
537 | |||
538 | /* parse number string */ | ||
539 | n = strtol(q_arg, &end, 10); | ||
540 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
541 | return -1; | ||
542 | if (n < MIN_TX_SIZE) | ||
543 | return -1; | ||
544 | if (n > MAX_TX_SIZE) | ||
545 | return -1; | ||
546 | |||
547 | return n; | ||
548 | } | ||
549 | |||
550 | static unsigned int | ||
551 | l2fwd_parse_nqueue(const char *q_arg) | ||
552 | { | ||
553 | char *end = NULL; | ||
554 | unsigned long n; | ||
555 | |||
556 | /* parse hexadecimal string */ | ||
557 | n = strtoul(q_arg, &end, 10); | ||
558 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
559 | return 0; | ||
560 | if (n == 0) | ||
561 | return 0; | ||
562 | if (n >= MAX_RX_QUEUE_PER_LCORE) | ||
563 | return 0; | ||
564 | |||
565 | return n; | ||
566 | } | ||
567 | |||
568 | static int | ||
569 | l2fwd_parse_timer_period(const char *q_arg) | ||
570 | { | ||
571 | char *end = NULL; | ||
572 | int n; | ||
573 | |||
574 | /* parse number string */ | ||
575 | n = strtol(q_arg, &end, 10); | ||
576 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
577 | return -1; | ||
578 | if (n >= MAX_TIMER_PERIOD) | ||
579 | return -1; | ||
580 | |||
581 | return n; | ||
582 | } | ||
583 | |||
584 | /* Parse the argument given in the command line of the application */ | ||
585 | static int | ||
586 | l2fwd_parse_args(int argc, char **argv) | ||
587 | { | ||
588 | int opt, ret; | ||
589 | char **argvopt; | ||
590 | int option_index; | ||
591 | char *prgname = argv[0]; | ||
592 | static struct option lgopts[] = { | ||
593 | {NULL, 0, 0, 0} | ||
594 | }; | ||
595 | |||
596 | argvopt = argv; | ||
597 | |||
598 | while ((opt = getopt_long(argc, argvopt, "p:q:T:t:s:l", | ||
599 | lgopts, &option_index)) != EOF) { | ||
600 | |||
601 | switch (opt) { | ||
602 | /* portmask */ | ||
603 | case 'p': | ||
604 | l2fwd_enabled_port_mask = l2fwd_parse_portmask(optarg); | ||
605 | if (l2fwd_enabled_port_mask == 0) { | ||
606 | printf("invalid portmask\n"); | ||
607 | l2fwd_usage(prgname); | ||
608 | return -1; | ||
609 | } | ||
610 | break; | ||
611 | |||
612 | /* nqueue */ | ||
613 | case 'q': | ||
614 | l2fwd_rx_queue_per_lcore = l2fwd_parse_nqueue(optarg); | ||
615 | if (l2fwd_rx_queue_per_lcore == 0) { | ||
616 | printf("invalid queue number\n"); | ||
617 | l2fwd_usage(prgname); | ||
618 | return -1; | ||
619 | } | ||
620 | break; | ||
621 | |||
622 | /* timer period */ | ||
623 | case 'T': | ||
624 | timer_period = l2fwd_parse_timer_period(optarg) * tsc_hz; | ||
625 | if (timer_period < 0) { | ||
626 | printf("invalid timer period\n"); | ||
627 | l2fwd_usage(prgname); | ||
628 | return -1; | ||
629 | } | ||
630 | break; | ||
631 | |||
632 | case 't': | ||
633 | l2fwd_tx_count = l2fwd_parse_tx_packet_count(optarg); | ||
634 | if (l2fwd_tx_count < 0) { | ||
635 | printf("invalid tx packet count\n"); | ||
636 | l2fwd_usage(prgname); | ||
637 | return -1; | ||
638 | } | ||
639 | break; | ||
640 | |||
641 | case 's': | ||
642 | l2fwd_tx_size = l2fwd_parse_tx_packet_size(optarg); | ||
643 | if (l2fwd_tx_size < 0) { | ||
644 | printf("invalid tx packet size\n"); | ||
645 | l2fwd_usage(prgname); | ||
646 | return -1; | ||
647 | } | ||
648 | break; | ||
649 | |||
650 | case 'l': | ||
651 | l2fwd_loopback = 1; | ||
652 | break; | ||
653 | |||
654 | /* long options */ | ||
655 | case 0: | ||
656 | l2fwd_usage(prgname); | ||
657 | return -1; | ||
658 | |||
659 | default: | ||
660 | l2fwd_usage(prgname); | ||
661 | return -1; | ||
662 | } | ||
663 | } | ||
664 | |||
665 | if (optind >= 0) | ||
666 | argv[optind-1] = prgname; | ||
667 | |||
668 | ret = optind-1; | ||
669 | optind = 0; /* reset getopt lib */ | ||
670 | return ret; | ||
671 | } | ||
672 | |||
673 | /* Check the link status of all ports in up to 9s, and print them finally */ | ||
674 | static void | ||
675 | check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) | ||
676 | { | ||
677 | #define CHECK_INTERVAL 100 /* 100ms */ | ||
678 | #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ | ||
679 | uint8_t portid, count, all_ports_up, print_flag = 0; | ||
680 | struct rte_eth_link link; | ||
681 | |||
682 | printf("\nChecking link status"); | ||
683 | fflush(stdout); | ||
684 | for (count = 0; count <= MAX_CHECK_TIME; count++) { | ||
685 | all_ports_up = 1; | ||
686 | for (portid = 0; portid < port_num; portid++) { | ||
687 | if ((port_mask & (1 << portid)) == 0) | ||
688 | continue; | ||
689 | memset(&link, 0, sizeof(link)); | ||
690 | rte_eth_link_get_nowait(portid, &link); | ||
691 | /* print link status if flag set */ | ||
692 | if (print_flag == 1) { | ||
693 | if (link.link_status) | ||
694 | printf("Port %d Link Up - speed %u " | ||
695 | "Mbps - %s\n", (uint8_t)portid, | ||
696 | (unsigned)link.link_speed, | ||
697 | (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? | ||
698 | ("full-duplex") : ("half-duplex\n")); | ||
699 | else | ||
700 | printf("Port %d Link Down\n", | ||
701 | (uint8_t)portid); | ||
702 | continue; | ||
703 | } | ||
704 | /* clear all_ports_up flag if any link down */ | ||
705 | if (link.link_status == 0) { | ||
706 | all_ports_up = 0; | ||
707 | break; | ||
708 | } | ||
709 | } | ||
710 | /* after finally printing all link status, get out */ | ||
711 | if (print_flag == 1) | ||
712 | break; | ||
713 | |||
714 | if (all_ports_up == 0) { | ||
715 | printf("."); | ||
716 | fflush(stdout); | ||
717 | rte_delay_ms(CHECK_INTERVAL); | ||
718 | } | ||
719 | |||
720 | /* set the print_flag if all ports up or timeout */ | ||
721 | if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) { | ||
722 | print_flag = 1; | ||
723 | printf("done\n"); | ||
724 | } | ||
725 | } | ||
726 | } | ||
727 | |||
728 | int | ||
729 | MAIN(int argc, char **argv) | ||
730 | { | ||
731 | struct lcore_queue_conf *qconf; | ||
732 | struct rte_eth_dev_info dev_info; | ||
733 | int ret; | ||
734 | uint8_t nb_ports; | ||
735 | uint8_t nb_ports_available; | ||
736 | uint8_t portid, last_port; | ||
737 | unsigned lcore_id, rx_lcore_id; | ||
738 | unsigned nb_ports_in_mask = 0; | ||
739 | |||
740 | setlinebuf(stdout); | ||
741 | setlinebuf(stderr); | ||
742 | |||
743 | /* init EAL */ | ||
744 | ret = rte_eal_init(argc, argv); | ||
745 | if (ret < 0) | ||
746 | rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); | ||
747 | |||
748 | l2fwd_init_time(); | ||
749 | |||
750 | argc -= ret; | ||
751 | argv += ret; | ||
752 | |||
753 | /* parse application arguments (after the EAL ones) */ | ||
754 | ret = l2fwd_parse_args(argc, argv); | ||
755 | if (ret < 0) | ||
756 | rte_exit(EXIT_FAILURE, "Invalid L2FWD arguments\n"); | ||
757 | |||
758 | /* create the mbuf pool */ | ||
759 | l2fwd_pktmbuf_pool = | ||
760 | rte_mempool_create("mbuf_pool", NB_MBUF, | ||
761 | MBUF_SIZE, 32, | ||
762 | sizeof(struct rte_pktmbuf_pool_private), | ||
763 | rte_pktmbuf_pool_init, NULL, | ||
764 | rte_pktmbuf_init, NULL, | ||
765 | rte_socket_id(), 0); | ||
766 | if (l2fwd_pktmbuf_pool == NULL) | ||
767 | rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); | ||
768 | |||
769 | /* init driver(s) */ | ||
770 | if (rte_pmd_init_all() < 0) | ||
771 | rte_exit(EXIT_FAILURE, "Cannot init pmd\n"); | ||
772 | |||
773 | if (rte_eal_pci_probe() < 0) | ||
774 | rte_exit(EXIT_FAILURE, "Cannot probe PCI\n"); | ||
775 | |||
776 | nb_ports = rte_eth_dev_count(); | ||
777 | if (nb_ports == 0) | ||
778 | rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); | ||
779 | |||
780 | if (nb_ports > RTE_MAX_ETHPORTS) | ||
781 | nb_ports = RTE_MAX_ETHPORTS; | ||
782 | |||
783 | /* reset l2fwd_dst_ports */ | ||
784 | for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) | ||
785 | l2fwd_dst_ports[portid] = 0; | ||
786 | last_port = 0; | ||
787 | |||
788 | /* | ||
789 | * Each logical core is assigned a dedicated TX queue on each port. | ||
790 | */ | ||
791 | for (portid = 0; portid < nb_ports; portid++) { | ||
792 | /* skip ports that are not enabled */ | ||
793 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
794 | continue; | ||
795 | |||
796 | if (l2fwd_loopback) { | ||
797 | l2fwd_dst_ports[portid] = portid; | ||
798 | continue; | ||
799 | } | ||
800 | |||
801 | if (nb_ports_in_mask % 2) { | ||
802 | l2fwd_dst_ports[portid] = last_port; | ||
803 | l2fwd_dst_ports[last_port] = portid; | ||
804 | } | ||
805 | else | ||
806 | last_port = portid; | ||
807 | |||
808 | nb_ports_in_mask++; | ||
809 | |||
810 | rte_eth_dev_info_get(portid, &dev_info); | ||
811 | } | ||
812 | if (!l2fwd_loopback && (nb_ports_in_mask % 2)) { | ||
813 | printf("Notice: odd number of ports in portmask.\n"); | ||
814 | l2fwd_dst_ports[last_port] = last_port; | ||
815 | } | ||
816 | |||
817 | rx_lcore_id = 0; | ||
818 | qconf = NULL; | ||
819 | |||
820 | /* Initialize the port/queue configuration of each logical core */ | ||
821 | for (portid = 0; portid < nb_ports; portid++) { | ||
822 | /* skip ports that are not enabled */ | ||
823 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
824 | continue; | ||
825 | |||
826 | /* get the lcore_id for this port */ | ||
827 | while (rte_lcore_is_enabled(rx_lcore_id) == 0 || | ||
828 | lcore_queue_conf[rx_lcore_id].n_rx_port == | ||
829 | l2fwd_rx_queue_per_lcore) { | ||
830 | rx_lcore_id++; | ||
831 | if (rx_lcore_id >= RTE_MAX_LCORE) | ||
832 | rte_exit(EXIT_FAILURE, "Not enough cores\n"); | ||
833 | } | ||
834 | |||
835 | if (qconf != &lcore_queue_conf[rx_lcore_id]) | ||
836 | /* Assigned a new logical core in the loop above. */ | ||
837 | qconf = &lcore_queue_conf[rx_lcore_id]; | ||
838 | |||
839 | qconf->rx_port_list[qconf->n_rx_port] = portid; | ||
840 | qconf->n_rx_port++; | ||
841 | printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid); | ||
842 | } | ||
843 | |||
844 | nb_ports_available = nb_ports; | ||
845 | |||
846 | if (l2fwd_loopback) | ||
847 | port_conf.lpbk_mode = 1; | ||
848 | |||
849 | /* Initialise each port */ | ||
850 | for (portid = 0; portid < nb_ports; portid++) { | ||
851 | /* skip ports that are not enabled */ | ||
852 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) { | ||
853 | printf("Skipping disabled port %u\n", (unsigned) portid); | ||
854 | nb_ports_available--; | ||
855 | continue; | ||
856 | } | ||
857 | /* init port */ | ||
858 | printf("Initializing port %u... ", (unsigned) portid); | ||
859 | fflush(stdout); | ||
860 | |||
861 | ret = rte_eth_dev_configure(portid, 1, 1, &port_conf); | ||
862 | if (ret < 0) | ||
863 | rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n", | ||
864 | ret, (unsigned) portid); | ||
865 | |||
866 | rte_eth_macaddr_get(portid,&l2fwd_ports_eth_addr[portid]); | ||
867 | |||
868 | /* init one RX queue */ | ||
869 | fflush(stdout); | ||
870 | ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd, | ||
871 | rte_eth_dev_socket_id(portid), &rx_conf, | ||
872 | l2fwd_pktmbuf_pool); | ||
873 | if (ret < 0) | ||
874 | rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, port=%u\n", | ||
875 | ret, (unsigned) portid); | ||
876 | |||
877 | /* init one TX queue on each port */ | ||
878 | fflush(stdout); | ||
879 | ret = rte_eth_tx_queue_setup(portid, 0, nb_txd, | ||
880 | rte_eth_dev_socket_id(portid), &tx_conf); | ||
881 | if (ret < 0) | ||
882 | rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, port=%u\n", | ||
883 | ret, (unsigned) portid); | ||
884 | |||
885 | /* Start device */ | ||
886 | ret = rte_eth_dev_start(portid); | ||
887 | if (ret < 0) | ||
888 | rte_exit(EXIT_FAILURE, "rte_eth_dev_start:err=%d, port=%u\n", | ||
889 | ret, (unsigned) portid); | ||
890 | |||
891 | printf("done: \n"); | ||
892 | |||
893 | rte_eth_promiscuous_enable(portid); | ||
894 | |||
895 | printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n", | ||
896 | (unsigned) portid, | ||
897 | l2fwd_ports_eth_addr[portid].addr_bytes[0], | ||
898 | l2fwd_ports_eth_addr[portid].addr_bytes[1], | ||
899 | l2fwd_ports_eth_addr[portid].addr_bytes[2], | ||
900 | l2fwd_ports_eth_addr[portid].addr_bytes[3], | ||
901 | l2fwd_ports_eth_addr[portid].addr_bytes[4], | ||
902 | l2fwd_ports_eth_addr[portid].addr_bytes[5]); | ||
903 | |||
904 | /* initialize port stats */ | ||
905 | memset(&port_statistics, 0, sizeof(port_statistics)); | ||
906 | } | ||
907 | |||
908 | if (!nb_ports_available) { | ||
909 | rte_exit(EXIT_FAILURE, | ||
910 | "All available ports are disabled. Please set portmask.\n"); | ||
911 | } | ||
912 | |||
913 | if(!l2fwd_loopback) | ||
914 | check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask); | ||
915 | |||
916 | if (l2fwd_tx_count) | ||
917 | l2fwd_tx(); | ||
918 | |||
919 | /* launch per-lcore init on every lcore */ | ||
920 | rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, NULL, CALL_MASTER); | ||
921 | |||
922 | RTE_LCORE_FOREACH_SLAVE(lcore_id) { | ||
923 | if (rte_eal_wait_lcore(lcore_id) < 0) | ||
924 | return -1; | ||
925 | } | ||
926 | |||
927 | return 0; | ||
928 | } | ||
929 | |||
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/main.h b/recipes-networking/dpdk/files/l2fwd-lpbk/main.h new file mode 100644 index 0000000..93dca37 --- /dev/null +++ b/recipes-networking/dpdk/files/l2fwd-lpbk/main.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /*- | ||
2 | * BSD LICENSE | ||
3 | * | ||
4 | * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * | ||
11 | * * Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in | ||
15 | * the documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * * Neither the name of Intel Corporation nor the names of its | ||
18 | * contributors may be used to endorse or promote products derived | ||
19 | * from this software without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #ifndef _MAIN_H_ | ||
35 | #define _MAIN_H_ | ||
36 | |||
37 | #ifdef RTE_EXEC_ENV_BAREMETAL | ||
38 | #define MAIN _main | ||
39 | #else | ||
40 | #define MAIN main | ||
41 | #endif | ||
42 | |||
43 | int MAIN(int argc, char **argv); | ||
44 | |||
45 | #endif /* _MAIN_H_ */ | ||