4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
39 #include <rte_mempool.h>
42 #include <rte_ethdev.h>
45 #include <rte_table_acl.h>
51 uint8_t ttl; /* needs to be set to 0 */
53 uint16_t header_checksum; /* needs to be set to 0 */
67 } __attribute__((__packed__));
72 } __attribute__((__packed__));
74 struct app_pkt_metadata {
76 uint8_t reserved1[28];
78 struct app_flow_key flow_key;
80 struct app_arp_key arp_key;
81 struct ether_addr nh_arp;
84 } __attribute__((__packed__));
86 #ifndef APP_MBUF_ARRAY_SIZE
87 #define APP_MBUF_ARRAY_SIZE 256
90 struct app_mbuf_array {
91 struct rte_mbuf *array[APP_MBUF_ARRAY_SIZE];
96 #define APP_MAX_PORTS 4
99 #ifndef APP_MAX_SWQ_PER_CORE
100 #define APP_MAX_SWQ_PER_CORE 8
103 #define APP_SWQ_INVALID ((uint32_t)(-1))
105 #define APP_SWQ_IN_REQ (APP_MAX_SWQ_PER_CORE - 1)
107 #define APP_SWQ_OUT_RESP (APP_MAX_SWQ_PER_CORE - 1)
110 APP_CORE_NONE = 0, /* Unused */
111 APP_CORE_MASTER, /* Management */
112 APP_CORE_RX, /* Reception */
113 APP_CORE_TX, /* Transmission */
114 APP_CORE_PT, /* Pass-through */
115 APP_CORE_FC, /* Flow Classification */
116 APP_CORE_FW, /* Firewall */
117 APP_CORE_RT, /* Routing */
118 APP_CORE_TM, /* Traffic Management */
119 APP_CORE_IPV4_FRAG,/* IPv4 Fragmentation */
120 APP_CORE_IPV4_RAS, /* IPv4 Reassembly */
123 struct app_core_params {
125 enum app_core_type core_type;
128 uint32_t swq_in[APP_MAX_SWQ_PER_CORE];
129 uint32_t swq_out[APP_MAX_SWQ_PER_CORE];
130 } __rte_cache_aligned;
134 struct app_core_params cores[RTE_MAX_LCORE];
138 uint32_t ports[APP_MAX_PORTS];
144 struct rte_eth_conf port_conf;
145 struct rte_eth_rxconf rx_conf;
146 struct rte_eth_txconf tx_conf;
148 /* SW Queues (SWQs) */
149 struct rte_ring **rings;
155 struct rte_mempool *pool;
156 struct rte_mempool *indirect_pool;
157 uint32_t pool_buffer_size;
159 uint32_t pool_cache_size;
161 /* Message buffer pool */
162 struct rte_mempool *msg_pool;
163 uint32_t msg_pool_buffer_size;
164 uint32_t msg_pool_size;
165 uint32_t msg_pool_cache_size;
168 uint32_t max_arp_rules;
169 uint32_t max_routing_rules;
170 uint32_t max_firewall_rules;
171 uint32_t max_flow_rules;
174 uint32_t ether_hdr_pop_push;
175 } __rte_cache_aligned;
177 extern struct app_params app;
179 const char *app_core_type_id_to_string(enum app_core_type id);
180 int app_core_type_string_to_id(const char *string, enum app_core_type *id);
181 void app_cores_config_print(void);
183 void app_check_core_params(void);
184 struct app_core_params *app_get_core_params(uint32_t core_id);
185 uint32_t app_get_first_core_id(enum app_core_type core_type);
186 struct rte_ring *app_get_ring_req(uint32_t core_id);
187 struct rte_ring *app_get_ring_resp(uint32_t core_id);
189 int app_parse_args(int argc, char **argv);
190 void app_print_usage(char *prgname);
193 int app_lcore_main_loop(void *arg);
196 uint64_t test_hash(void *key, uint32_t key_size, uint64_t seed);
197 uint32_t rte_jhash2_16(uint32_t *k, uint32_t initval);
198 #if defined(__x86_64__)
199 uint32_t rte_aeshash_16(uint64_t *k, uint64_t seed);
200 uint32_t rte_crchash_16(uint64_t *k, uint64_t seed);
203 /* I/O with no pipeline */
204 void app_main_loop_rx(void);
205 void app_main_loop_tx(void);
206 void app_main_loop_passthrough(void);
209 void app_main_loop_pipeline_rx(void);
210 void app_main_loop_pipeline_rx_frag(void);
211 void app_main_loop_pipeline_tx(void);
212 void app_main_loop_pipeline_tx_ras(void);
213 void app_main_loop_pipeline_flow_classification(void);
214 void app_main_loop_pipeline_firewall(void);
215 void app_main_loop_pipeline_routing(void);
216 void app_main_loop_pipeline_passthrough(void);
217 void app_main_loop_pipeline_ipv4_frag(void);
218 void app_main_loop_pipeline_ipv4_ras(void);
220 /* Command Line Interface (CLI) */
221 void app_main_loop_cmdline(void);
224 enum app_msg_req_type {
228 APP_MSG_REQ_FC_ADD_ALL,
235 APP_MSG_REQ_RX_PORT_ENABLE,
236 APP_MSG_REQ_RX_PORT_DISABLE,
240 enum app_msg_req_type type;
255 struct ether_addr nh_arp;
264 struct app_flow_key key;
271 struct app_flow_key key;
274 #ifdef RTE_LIBRTE_ACL
276 struct rte_table_acl_rule_add_params add_params;
280 struct rte_table_acl_rule_delete_params delete_params;
292 struct app_msg_resp {
296 #define APP_FLUSH 0xFF
298 #ifdef RTE_EXEC_ENV_BAREMETAL
304 int MAIN(int argc, char **argv);
306 #endif /* _MAIN_H_ */