1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #include <rte_byteorder.h>
6 #include <rte_hexdump.h>
7 #include <rte_string_fns.h>
11 #ifdef RTE_EXEC_ENV_WINDOWS
15 printf("table not supported on Windows, skipping test\n");
20 #include "test_table.h"
21 #include "test_table_pipeline.h"
22 #include "test_table_ports.h"
23 #include "test_table_tables.h"
24 #include "test_table_combined.h"
25 #include "test_table_acl.h"
27 /* Global variables */
28 struct rte_pipeline *p;
29 struct rte_ring *rings_rx[N_PORTS];
30 struct rte_ring *rings_tx[N_PORTS];
31 struct rte_mempool *pool = NULL;
33 uint32_t port_in_id[N_PORTS];
34 uint32_t port_out_id[N_PORTS];
35 uint32_t port_out_id_type[3];
36 uint32_t table_id[N_PORTS*2];
37 uint64_t override_hit_mask = 0xFFFFFFFF;
38 uint64_t override_miss_mask = 0xFFFFFFFF;
39 uint64_t non_reserved_actions_hit = 0;
40 uint64_t non_reserved_actions_miss = 0;
41 uint8_t connect_miss_action_to_port_out = 0;
42 uint8_t connect_miss_action_to_table = 0;
43 uint32_t table_entry_default_action = RTE_PIPELINE_ACTION_DROP;
44 uint32_t table_entry_hit_action = RTE_PIPELINE_ACTION_PORT;
45 uint32_t table_entry_miss_action = RTE_PIPELINE_ACTION_DROP;
46 rte_pipeline_port_in_action_handler port_in_action = NULL;
47 rte_pipeline_port_out_action_handler port_out_action = NULL;
48 rte_pipeline_table_action_handler_hit action_handler_hit = NULL;
49 rte_pipeline_table_action_handler_miss action_handler_miss = NULL;
51 /* Function prototypes */
52 static void app_init_rings(void);
53 static void app_init_mbuf_pools(void);
55 uint64_t pipeline_test_hash(void *key,
56 __rte_unused void *key_mask,
57 __rte_unused uint32_t key_size,
58 __rte_unused uint64_t seed)
61 uint32_t ip_dst = rte_be_to_cpu_32(k32[0]);
62 uint64_t signature = ip_dst;
67 uint32_t pipeline_test_hash_cuckoo(const void *key,
68 __rte_unused uint32_t key_size,
69 __rte_unused uint32_t seed)
71 const uint32_t *k32 = key;
72 uint32_t ip_dst = rte_be_to_cpu_32(k32[0]);
73 uint32_t signature = ip_dst;
79 app_free_resources(void) {
81 for (i = 0; i < N_PORTS; i++)
82 rte_ring_free(rings_rx[i]);
83 rte_mempool_free(pool);
87 app_init_mbuf_pools(void)
89 /* Init the buffer pool */
90 printf("Getting/Creating the mempool ...\n");
91 pool = rte_mempool_lookup("mempool");
93 pool = rte_pktmbuf_pool_create(
96 POOL_CACHE_SIZE, 0, POOL_BUFFER_SIZE,
99 rte_panic("Cannot create mbuf pool\n");
108 for (i = 0; i < N_PORTS; i++) {
111 snprintf(name, sizeof(name), "app_ring_rx_%u", i);
112 rings_rx[i] = rte_ring_lookup(name);
113 if (rings_rx[i] == NULL) {
114 rings_rx[i] = rte_ring_create(
118 RING_F_SP_ENQ | RING_F_SC_DEQ);
120 if (rings_rx[i] == NULL)
121 rte_panic("Cannot create RX ring %u\n", i);
124 for (i = 0; i < N_PORTS; i++) {
127 snprintf(name, sizeof(name), "app_ring_tx_%u", i);
128 rings_tx[i] = rte_ring_lookup(name);
129 if (rings_tx[i] == NULL) {
130 rings_tx[i] = rte_ring_create(
134 RING_F_SP_ENQ | RING_F_SC_DEQ);
136 if (rings_tx[i] == NULL)
137 rte_panic("Cannot create TX ring %u\n", i);
151 app_init_mbuf_pools();
153 printf("\n\n\n\n************Pipeline tests************\n");
155 if (test_table_pipeline() < 0) {
160 printf("\n\n\n\n************Port tests************\n");
161 for (i = 0; i < n_port_tests; i++) {
162 status = port_tests[i]();
164 printf("\nPort test number %d failed (%d).\n", i,
171 printf("\n\n\n\n************Table tests************\n");
172 for (i = 0; i < n_table_tests; i++) {
173 status = table_tests[i]();
175 printf("\nTable test number %d failed (%d).\n", i,
182 printf("\n\n\n\n************Table tests************\n");
183 for (i = 0; i < n_table_tests_combined; i++) {
184 status = table_tests_combined[i]();
186 printf("\nCombined table test number %d failed with "
187 "reason number %d.\n", i, status);
194 printf("\n\n\n\n************ACL tests************\n");
195 if (test_table_acl() < 0) {
202 app_free_resources();
207 #endif /* !RTE_EXEC_ENV_WINDOWS */
209 REGISTER_TEST_COMMAND(table_autotest, test_table);