xref: /dpdk/app/test-pipeline/main.h (revision ba92d511ddacf863fafaaa14c0577f30ee57d092)
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 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 #ifndef APP_MBUF_ARRAY_SIZE
38 #define APP_MBUF_ARRAY_SIZE 256
39 #endif
40 
41 struct app_mbuf_array {
42 	struct rte_mbuf *array[APP_MBUF_ARRAY_SIZE];
43 	uint16_t n_mbufs;
44 };
45 
46 #ifndef APP_MAX_PORTS
47 #define APP_MAX_PORTS 4
48 #endif
49 
50 struct app_params {
51 	/* CPU cores */
52 	uint32_t core_rx;
53 	uint32_t core_worker;
54 	uint32_t core_tx;
55 
56 	/* Ports*/
57 	uint32_t ports[APP_MAX_PORTS];
58 	uint32_t n_ports;
59 	uint32_t port_rx_ring_size;
60 	uint32_t port_tx_ring_size;
61 
62 	/* Rings */
63 	struct rte_ring *rings_rx[APP_MAX_PORTS];
64 	struct rte_ring *rings_tx[APP_MAX_PORTS];
65 	uint32_t ring_rx_size;
66 	uint32_t ring_tx_size;
67 
68 	/* Internal buffers */
69 	struct app_mbuf_array mbuf_rx;
70 	struct app_mbuf_array mbuf_tx[APP_MAX_PORTS];
71 
72 	/* Buffer pool */
73 	struct rte_mempool *pool;
74 	uint32_t pool_buffer_size;
75 	uint32_t pool_size;
76 	uint32_t pool_cache_size;
77 
78 	/* Burst sizes */
79 	uint32_t burst_size_rx_read;
80 	uint32_t burst_size_rx_write;
81 	uint32_t burst_size_worker_read;
82 	uint32_t burst_size_worker_write;
83 	uint32_t burst_size_tx_read;
84 	uint32_t burst_size_tx_write;
85 
86 	/* App behavior */
87 	uint32_t pipeline_type;
88 } __rte_cache_aligned;
89 
90 extern struct app_params app;
91 
92 int app_parse_args(int argc, char **argv);
93 void app_print_usage(void);
94 void app_init(void);
95 int app_lcore_main_loop(void *arg);
96 
97 /* Pipeline */
98 enum {
99 	e_APP_PIPELINE_NONE = 0,
100 	e_APP_PIPELINE_STUB,
101 
102 	e_APP_PIPELINE_HASH_KEY8_EXT,
103 	e_APP_PIPELINE_HASH_KEY8_LRU,
104 	e_APP_PIPELINE_HASH_KEY16_EXT,
105 	e_APP_PIPELINE_HASH_KEY16_LRU,
106 	e_APP_PIPELINE_HASH_KEY32_EXT,
107 	e_APP_PIPELINE_HASH_KEY32_LRU,
108 
109 	e_APP_PIPELINE_HASH_SPEC_KEY8_EXT,
110 	e_APP_PIPELINE_HASH_SPEC_KEY8_LRU,
111 	e_APP_PIPELINE_HASH_SPEC_KEY16_EXT,
112 	e_APP_PIPELINE_HASH_SPEC_KEY16_LRU,
113 	e_APP_PIPELINE_HASH_SPEC_KEY32_EXT,
114 	e_APP_PIPELINE_HASH_SPEC_KEY32_LRU,
115 
116 	e_APP_PIPELINE_ACL,
117 	e_APP_PIPELINE_LPM,
118 	e_APP_PIPELINE_LPM_IPV6,
119 	e_APP_PIPELINES
120 };
121 
122 void app_main_loop_rx(void);
123 void app_main_loop_rx_metadata(void);
124 uint64_t test_hash(void *key, uint32_t key_size, uint64_t seed);
125 
126 void app_main_loop_worker(void);
127 void app_main_loop_worker_pipeline_stub(void);
128 void app_main_loop_worker_pipeline_hash(void);
129 void app_main_loop_worker_pipeline_acl(void);
130 void app_main_loop_worker_pipeline_lpm(void);
131 void app_main_loop_worker_pipeline_lpm_ipv6(void);
132 
133 void app_main_loop_tx(void);
134 
135 #define APP_FLUSH 0
136 #ifndef APP_FLUSH
137 #define APP_FLUSH 0x3FF
138 #endif
139 
140 #define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
141 
142 #endif /* _MAIN_H_ */
143