4 * Copyright(c) 2010-2016 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.
35 #include "test_table_combined.h"
36 #include "test_table.h"
37 #include <rte_table_lpm_ipv6.h>
39 #define MAX_TEST_KEYS 128
42 enum check_table_result
{
44 CHECK_TABLE_PORT_CONFIG
,
45 CHECK_TABLE_PORT_ENABLE
,
46 CHECK_TABLE_TABLE_CONFIG
,
47 CHECK_TABLE_ENTRY_ADD
,
48 CHECK_TABLE_DEFAULT_ENTRY_ADD
,
50 CHECK_TABLE_MANAGE_ERROR
,
51 CHECK_TABLE_CONSISTENCY
,
52 CHECK_TABLE_NO_TRAFFIC
,
53 CHECK_TABLE_INVALID_PARAMETER
,
56 struct table_packets
{
57 uint32_t hit_packet
[MAX_TEST_KEYS
];
58 uint32_t miss_packet
[MAX_TEST_KEYS
];
59 uint32_t n_hit_packets
;
60 uint32_t n_miss_packets
;
63 combined_table_test table_tests_combined
[] = {
64 test_table_lpm_combined
,
65 test_table_lpm_ipv6_combined
,
72 test_table_hash_cuckoo_combined
,
75 unsigned n_table_tests_combined
= RTE_DIM(table_tests_combined
);
77 /* Generic port tester function */
79 test_table_type(struct rte_table_ops
*table_ops
, void *table_args
,
80 void *key
, struct table_packets
*table_packets
,
81 struct manage_ops
*manage_ops
, unsigned n_ops
)
83 uint32_t ring_in_id
, table_id
, ring_out_id
, ring_out_2_id
;
86 RTE_SET_USED(manage_ops
);
89 struct rte_pipeline_params pipeline_params
= {
94 struct rte_pipeline
*pipeline
= rte_pipeline_create(&pipeline_params
);
96 /* Create input ring */
97 struct rte_port_ring_reader_params ring_params_rx
= {
101 struct rte_port_ring_writer_params ring_params_tx
= {
103 .tx_burst_sz
= RTE_PORT_IN_BURST_SIZE_MAX
,
106 struct rte_pipeline_port_in_params ring_in_params
= {
107 .ops
= &rte_port_ring_reader_ops
,
108 .arg_create
= (void *)&ring_params_rx
,
110 .burst_size
= RTE_PORT_IN_BURST_SIZE_MAX
,
113 if (rte_pipeline_port_in_create(pipeline
, &ring_in_params
,
115 rte_pipeline_free(pipeline
);
116 return -CHECK_TABLE_PORT_CONFIG
;
120 struct rte_pipeline_table_params table_params
= {
122 .arg_create
= table_args
,
123 .f_action_hit
= NULL
,
124 .f_action_miss
= NULL
,
126 .action_data_size
= 0,
129 if (rte_pipeline_table_create(pipeline
, &table_params
,
131 rte_pipeline_free(pipeline
);
132 return -CHECK_TABLE_TABLE_CONFIG
;
135 /* Create output ports */
136 ring_params_tx
.ring
= RING_TX
;
138 struct rte_pipeline_port_out_params ring_out_params
= {
139 .ops
= &rte_port_ring_writer_ops
,
140 .arg_create
= (void *)&ring_params_tx
,
144 if (rte_pipeline_port_out_create(pipeline
, &ring_out_params
,
145 &ring_out_id
) != 0) {
146 rte_pipeline_free(pipeline
);
147 return -CHECK_TABLE_PORT_CONFIG
;
150 ring_params_tx
.ring
= RING_TX_2
;
152 if (rte_pipeline_port_out_create(pipeline
, &ring_out_params
,
153 &ring_out_2_id
) != 0) {
154 rte_pipeline_free(pipeline
);
155 return -CHECK_TABLE_PORT_CONFIG
;
158 /* Add entry to the table */
159 struct rte_pipeline_table_entry default_entry
= {
160 .action
= RTE_PIPELINE_ACTION_DROP
,
161 {.table_id
= ring_out_id
},
164 struct rte_pipeline_table_entry table_entry
= {
165 .action
= RTE_PIPELINE_ACTION_PORT
,
166 {.table_id
= ring_out_id
},
169 struct rte_pipeline_table_entry
*default_entry_ptr
, *entry_ptr
;
173 if (rte_pipeline_table_default_entry_add(pipeline
, table_id
,
174 &default_entry
, &default_entry_ptr
) != 0) {
175 rte_pipeline_free(pipeline
);
176 return -CHECK_TABLE_DEFAULT_ENTRY_ADD
;
179 if (rte_pipeline_table_entry_add(pipeline
, table_id
,
180 key
? key
: &table_entry
, &table_entry
, &key_found
,
182 rte_pipeline_free(pipeline
);
183 return -CHECK_TABLE_ENTRY_ADD
;
186 /* Create connections and check consistency */
187 if (rte_pipeline_port_in_connect_to_table(pipeline
, ring_in_id
,
189 rte_pipeline_free(pipeline
);
190 return -CHECK_TABLE_CONNECT
;
193 if (rte_pipeline_port_in_enable(pipeline
, ring_in_id
) != 0) {
194 rte_pipeline_free(pipeline
);
195 return -CHECK_TABLE_PORT_ENABLE
;
198 if (rte_pipeline_check(pipeline
) != 0) {
199 rte_pipeline_free(pipeline
);
200 return -CHECK_TABLE_CONSISTENCY
;
205 /* Flow test - All hits */
206 if (table_packets
->n_hit_packets
) {
207 for (i
= 0; i
< table_packets
->n_hit_packets
; i
++)
208 RING_ENQUEUE(RING_RX
, table_packets
->hit_packet
[i
]);
210 RUN_PIPELINE(pipeline
);
212 VERIFY_TRAFFIC(RING_TX
, table_packets
->n_hit_packets
,
213 table_packets
->n_hit_packets
);
216 /* Flow test - All misses */
217 if (table_packets
->n_miss_packets
) {
218 for (i
= 0; i
< table_packets
->n_miss_packets
; i
++)
219 RING_ENQUEUE(RING_RX
, table_packets
->miss_packet
[i
]);
221 RUN_PIPELINE(pipeline
);
223 VERIFY_TRAFFIC(RING_TX
, table_packets
->n_miss_packets
, 0);
226 /* Flow test - Half hits, half misses */
227 if (table_packets
->n_hit_packets
&& table_packets
->n_miss_packets
) {
228 for (i
= 0; i
< (table_packets
->n_hit_packets
) / 2; i
++)
229 RING_ENQUEUE(RING_RX
, table_packets
->hit_packet
[i
]);
231 for (i
= 0; i
< (table_packets
->n_miss_packets
) / 2; i
++)
232 RING_ENQUEUE(RING_RX
, table_packets
->miss_packet
[i
]);
234 RUN_PIPELINE(pipeline
);
235 VERIFY_TRAFFIC(RING_TX
, table_packets
->n_hit_packets
,
236 table_packets
->n_hit_packets
/ 2);
239 /* Flow test - Single packet */
240 if (table_packets
->n_hit_packets
) {
241 RING_ENQUEUE(RING_RX
, table_packets
->hit_packet
[0]);
242 RUN_PIPELINE(pipeline
);
243 VERIFY_TRAFFIC(RING_TX
, table_packets
->n_hit_packets
, 1);
245 if (table_packets
->n_miss_packets
) {
246 RING_ENQUEUE(RING_RX
, table_packets
->miss_packet
[0]);
247 RUN_PIPELINE(pipeline
);
248 VERIFY_TRAFFIC(RING_TX
, table_packets
->n_miss_packets
, 0);
252 /* Change table entry action */
253 printf("Change entry action\n");
254 table_entry
.table_id
= ring_out_2_id
;
256 if (rte_pipeline_table_default_entry_add(pipeline
, table_id
,
257 &default_entry
, &default_entry_ptr
) != 0) {
258 rte_pipeline_free(pipeline
);
259 return -CHECK_TABLE_ENTRY_ADD
;
262 if (rte_pipeline_table_entry_add(pipeline
, table_id
,
263 key
? key
: &table_entry
, &table_entry
, &key_found
,
265 rte_pipeline_free(pipeline
);
266 return -CHECK_TABLE_ENTRY_ADD
;
269 /* Check that traffic destination has changed */
270 if (table_packets
->n_hit_packets
) {
271 for (i
= 0; i
< table_packets
->n_hit_packets
; i
++)
272 RING_ENQUEUE(RING_RX
, table_packets
->hit_packet
[i
]);
274 RUN_PIPELINE(pipeline
);
275 VERIFY_TRAFFIC(RING_TX
, table_packets
->n_hit_packets
, 0);
276 VERIFY_TRAFFIC(RING_TX_2
, table_packets
->n_hit_packets
,
277 table_packets
->n_hit_packets
);
280 printf("delete entry\n");
281 /* Delete table entry */
282 rte_pipeline_table_entry_delete(pipeline
, table_id
,
283 key
? key
: &table_entry
, &key_found
, NULL
);
285 rte_pipeline_free(pipeline
);
292 test_table_stub_combined(void)
295 struct table_packets table_packets
;
297 printf("--------------\n");
298 printf("RUNNING TEST - %s\n", __func__
);
299 printf("--------------\n");
300 for (i
= 0; i
< N_PACKETS
; i
++)
301 table_packets
.hit_packet
[i
] = i
;
303 table_packets
.n_hit_packets
= N_PACKETS
;
304 table_packets
.n_miss_packets
= 0;
306 status
= test_table_type(&rte_table_stub_ops
, NULL
, NULL
,
307 &table_packets
, NULL
, 1);
308 VERIFY(status
, CHECK_TABLE_OK
);
314 test_table_lpm_combined(void)
319 struct rte_table_lpm_params lpm_params
= {
322 .number_tbl8s
= 1 << 8,
324 .entry_unique_size
= 8,
325 .offset
= APP_METADATA_OFFSET(0),
328 struct rte_table_lpm_key lpm_key
= {
333 struct table_packets table_packets
;
335 printf("--------------\n");
336 printf("RUNNING TEST - %s\n", __func__
);
337 printf("--------------\n");
339 for (i
= 0; i
< N_PACKETS
; i
++)
340 table_packets
.hit_packet
[i
] = 0xadadadad;
342 for (i
= 0; i
< N_PACKETS
; i
++)
343 table_packets
.miss_packet
[i
] = 0xfefefefe;
345 table_packets
.n_hit_packets
= N_PACKETS
;
346 table_packets
.n_miss_packets
= N_PACKETS
;
348 status
= test_table_type(&rte_table_lpm_ops
, (void *)&lpm_params
,
349 (void *)&lpm_key
, &table_packets
, NULL
, 0);
350 VERIFY(status
, CHECK_TABLE_OK
);
352 /* Invalid parameters */
353 lpm_params
.n_rules
= 0;
355 status
= test_table_type(&rte_table_lpm_ops
, (void *)&lpm_params
,
356 (void *)&lpm_key
, &table_packets
, NULL
, 0);
357 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
359 lpm_params
.n_rules
= 1 << 24;
362 status
= test_table_type(&rte_table_lpm_ops
, (void *)&lpm_params
,
363 (void *)&lpm_key
, &table_packets
, NULL
, 0);
364 VERIFY(status
, CHECK_TABLE_ENTRY_ADD
);
368 status
= test_table_type(&rte_table_lpm_ops
, (void *)&lpm_params
,
369 (void *)&lpm_key
, &table_packets
, NULL
, 0);
370 VERIFY(status
, CHECK_TABLE_ENTRY_ADD
);
376 test_table_lpm_ipv6_combined(void)
381 struct rte_table_lpm_ipv6_params lpm_ipv6_params
= {
384 .number_tbl8s
= 1 << 13,
385 .entry_unique_size
= 8,
386 .offset
= APP_METADATA_OFFSET(32),
389 struct rte_table_lpm_ipv6_key lpm_ipv6_key
= {
392 memset(lpm_ipv6_key
.ip
, 0xad, 16);
394 struct table_packets table_packets
;
396 printf("--------------\n");
397 printf("RUNNING TEST - %s\n", __func__
);
398 printf("--------------\n");
399 for (i
= 0; i
< N_PACKETS
; i
++)
400 table_packets
.hit_packet
[i
] = 0xadadadad;
402 for (i
= 0; i
< N_PACKETS
; i
++)
403 table_packets
.miss_packet
[i
] = 0xadadadab;
405 table_packets
.n_hit_packets
= N_PACKETS
;
406 table_packets
.n_miss_packets
= N_PACKETS
;
408 status
= test_table_type(&rte_table_lpm_ipv6_ops
,
409 (void *)&lpm_ipv6_params
,
410 (void *)&lpm_ipv6_key
, &table_packets
, NULL
, 0);
411 VERIFY(status
, CHECK_TABLE_OK
);
413 /* Invalid parameters */
414 lpm_ipv6_params
.n_rules
= 0;
416 status
= test_table_type(&rte_table_lpm_ipv6_ops
,
417 (void *)&lpm_ipv6_params
,
418 (void *)&lpm_ipv6_key
, &table_packets
, NULL
, 0);
419 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
421 lpm_ipv6_params
.n_rules
= 1 << 24;
422 lpm_ipv6_key
.depth
= 0;
424 status
= test_table_type(&rte_table_lpm_ipv6_ops
,
425 (void *)&lpm_ipv6_params
,
426 (void *)&lpm_ipv6_key
, &table_packets
, NULL
, 0);
427 VERIFY(status
, CHECK_TABLE_ENTRY_ADD
);
429 lpm_ipv6_key
.depth
= 129;
430 status
= test_table_type(&rte_table_lpm_ipv6_ops
,
431 (void *)&lpm_ipv6_params
,
432 (void *)&lpm_ipv6_key
, &table_packets
, NULL
, 0);
433 VERIFY(status
, CHECK_TABLE_ENTRY_ADD
);
439 test_table_hash8lru(void)
444 struct rte_table_hash_key8_lru_params key8lru_params
= {
446 .f_hash
= pipeline_test_hash
,
447 .signature_offset
= APP_METADATA_OFFSET(0),
448 .key_offset
= APP_METADATA_OFFSET(32),
453 uint32_t *k8lru
= (uint32_t *) key8lru
;
455 memset(key8lru
, 0, sizeof(key8lru
));
456 k8lru
[0] = 0xadadadad;
458 struct table_packets table_packets
;
460 printf("--------------\n");
461 printf("RUNNING TEST - %s\n", __func__
);
462 printf("--------------\n");
463 for (i
= 0; i
< 50; i
++)
464 table_packets
.hit_packet
[i
] = 0xadadadad;
466 for (i
= 0; i
< 50; i
++)
467 table_packets
.miss_packet
[i
] = 0xfefefefe;
469 table_packets
.n_hit_packets
= 50;
470 table_packets
.n_miss_packets
= 50;
472 status
= test_table_type(&rte_table_hash_key8_lru_ops
,
473 (void *)&key8lru_params
, (void *)key8lru
, &table_packets
,
475 VERIFY(status
, CHECK_TABLE_OK
);
477 /* Invalid parameters */
478 key8lru_params
.n_entries
= 0;
480 status
= test_table_type(&rte_table_hash_key8_lru_ops
,
481 (void *)&key8lru_params
, (void *)key8lru
, &table_packets
,
483 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
485 key8lru_params
.n_entries
= 1<<16;
486 key8lru_params
.f_hash
= NULL
;
488 status
= test_table_type(&rte_table_hash_key8_lru_ops
,
489 (void *)&key8lru_params
, (void *)key8lru
, &table_packets
,
491 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
497 test_table_hash16lru(void)
502 struct rte_table_hash_key16_lru_params key16lru_params
= {
504 .f_hash
= pipeline_test_hash
,
506 .signature_offset
= APP_METADATA_OFFSET(0),
507 .key_offset
= APP_METADATA_OFFSET(32),
511 uint8_t key16lru
[16];
512 uint32_t *k16lru
= (uint32_t *) key16lru
;
514 memset(key16lru
, 0, sizeof(key16lru
));
515 k16lru
[0] = 0xadadadad;
517 struct table_packets table_packets
;
519 printf("--------------\n");
520 printf("RUNNING TEST - %s\n", __func__
);
521 printf("--------------\n");
522 for (i
= 0; i
< 50; i
++)
523 table_packets
.hit_packet
[i
] = 0xadadadad;
525 for (i
= 0; i
< 50; i
++)
526 table_packets
.miss_packet
[i
] = 0xfefefefe;
528 table_packets
.n_hit_packets
= 50;
529 table_packets
.n_miss_packets
= 50;
531 status
= test_table_type(&rte_table_hash_key16_lru_ops
,
532 (void *)&key16lru_params
, (void *)key16lru
, &table_packets
,
534 VERIFY(status
, CHECK_TABLE_OK
);
536 /* Invalid parameters */
537 key16lru_params
.n_entries
= 0;
539 status
= test_table_type(&rte_table_hash_key16_lru_ops
,
540 (void *)&key16lru_params
, (void *)key16lru
, &table_packets
,
542 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
544 key16lru_params
.n_entries
= 1<<16;
545 key16lru_params
.f_hash
= NULL
;
547 status
= test_table_type(&rte_table_hash_key16_lru_ops
,
548 (void *)&key16lru_params
, (void *)key16lru
, &table_packets
,
550 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
556 test_table_hash32lru(void)
561 struct rte_table_hash_key32_lru_params key32lru_params
= {
563 .f_hash
= pipeline_test_hash
,
565 .signature_offset
= APP_METADATA_OFFSET(0),
566 .key_offset
= APP_METADATA_OFFSET(32),
569 uint8_t key32lru
[32];
570 uint32_t *k32lru
= (uint32_t *) key32lru
;
572 memset(key32lru
, 0, sizeof(key32lru
));
573 k32lru
[0] = 0xadadadad;
575 struct table_packets table_packets
;
577 printf("--------------\n");
578 printf("RUNNING TEST - %s\n", __func__
);
579 printf("--------------\n");
580 for (i
= 0; i
< 50; i
++)
581 table_packets
.hit_packet
[i
] = 0xadadadad;
583 for (i
= 0; i
< 50; i
++)
584 table_packets
.miss_packet
[i
] = 0xbdadadad;
586 table_packets
.n_hit_packets
= 50;
587 table_packets
.n_miss_packets
= 50;
589 status
= test_table_type(&rte_table_hash_key32_lru_ops
,
590 (void *)&key32lru_params
, (void *)key32lru
, &table_packets
,
592 VERIFY(status
, CHECK_TABLE_OK
);
594 /* Invalid parameters */
595 key32lru_params
.n_entries
= 0;
597 status
= test_table_type(&rte_table_hash_key32_lru_ops
,
598 (void *)&key32lru_params
, (void *)key32lru
, &table_packets
,
600 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
602 key32lru_params
.n_entries
= 1<<16;
603 key32lru_params
.f_hash
= NULL
;
605 status
= test_table_type(&rte_table_hash_key32_lru_ops
,
606 (void *)&key32lru_params
, (void *)key32lru
, &table_packets
,
608 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
614 test_table_hash8ext(void)
619 struct rte_table_hash_key8_ext_params key8ext_params
= {
621 .n_entries_ext
= 1<<15,
622 .f_hash
= pipeline_test_hash
,
624 .signature_offset
= APP_METADATA_OFFSET(0),
625 .key_offset
= APP_METADATA_OFFSET(32),
630 uint32_t *k8ext
= (uint32_t *) key8ext
;
632 memset(key8ext
, 0, sizeof(key8ext
));
633 k8ext
[0] = 0xadadadad;
635 struct table_packets table_packets
;
637 printf("--------------\n");
638 printf("RUNNING TEST - %s\n", __func__
);
639 printf("--------------\n");
640 for (i
= 0; i
< 50; i
++)
641 table_packets
.hit_packet
[i
] = 0xadadadad;
643 for (i
= 0; i
< 50; i
++)
644 table_packets
.miss_packet
[i
] = 0xbdadadad;
646 table_packets
.n_hit_packets
= 50;
647 table_packets
.n_miss_packets
= 50;
649 status
= test_table_type(&rte_table_hash_key8_ext_ops
,
650 (void *)&key8ext_params
, (void *)key8ext
, &table_packets
,
652 VERIFY(status
, CHECK_TABLE_OK
);
654 /* Invalid parameters */
655 key8ext_params
.n_entries
= 0;
657 status
= test_table_type(&rte_table_hash_key8_ext_ops
,
658 (void *)&key8ext_params
, (void *)key8ext
, &table_packets
,
660 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
662 key8ext_params
.n_entries
= 1<<16;
663 key8ext_params
.f_hash
= NULL
;
665 status
= test_table_type(&rte_table_hash_key8_ext_ops
,
666 (void *)&key8ext_params
, (void *)key8ext
, &table_packets
,
668 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
670 key8ext_params
.f_hash
= pipeline_test_hash
;
671 key8ext_params
.n_entries_ext
= 0;
673 status
= test_table_type(&rte_table_hash_key8_ext_ops
,
674 (void *)&key8ext_params
, (void *)key8ext
, &table_packets
, NULL
, 0);
675 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
681 test_table_hash16ext(void)
686 struct rte_table_hash_key16_ext_params key16ext_params
= {
688 .n_entries_ext
= 1<<15,
689 .f_hash
= pipeline_test_hash
,
691 .signature_offset
= APP_METADATA_OFFSET(0),
692 .key_offset
= APP_METADATA_OFFSET(32),
696 uint8_t key16ext
[16];
697 uint32_t *k16ext
= (uint32_t *) key16ext
;
699 memset(key16ext
, 0, sizeof(key16ext
));
700 k16ext
[0] = 0xadadadad;
702 struct table_packets table_packets
;
704 printf("--------------\n");
705 printf("RUNNING TEST - %s\n", __func__
);
706 printf("--------------\n");
707 for (i
= 0; i
< 50; i
++)
708 table_packets
.hit_packet
[i
] = 0xadadadad;
710 for (i
= 0; i
< 50; i
++)
711 table_packets
.miss_packet
[i
] = 0xbdadadad;
713 table_packets
.n_hit_packets
= 50;
714 table_packets
.n_miss_packets
= 50;
716 status
= test_table_type(&rte_table_hash_key16_ext_ops
,
717 (void *)&key16ext_params
, (void *)key16ext
, &table_packets
,
719 VERIFY(status
, CHECK_TABLE_OK
);
721 /* Invalid parameters */
722 key16ext_params
.n_entries
= 0;
724 status
= test_table_type(&rte_table_hash_key16_ext_ops
,
725 (void *)&key16ext_params
, (void *)key16ext
, &table_packets
,
727 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
729 key16ext_params
.n_entries
= 1<<16;
730 key16ext_params
.f_hash
= NULL
;
732 status
= test_table_type(&rte_table_hash_key16_ext_ops
,
733 (void *)&key16ext_params
, (void *)key16ext
, &table_packets
,
735 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
737 key16ext_params
.f_hash
= pipeline_test_hash
;
738 key16ext_params
.n_entries_ext
= 0;
740 status
= test_table_type(&rte_table_hash_key16_ext_ops
,
741 (void *)&key16ext_params
, (void *)key16ext
, &table_packets
, NULL
, 0);
742 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
748 test_table_hash32ext(void)
753 struct rte_table_hash_key32_ext_params key32ext_params
= {
755 .n_entries_ext
= 1<<15,
756 .f_hash
= pipeline_test_hash
,
758 .signature_offset
= APP_METADATA_OFFSET(0),
759 .key_offset
= APP_METADATA_OFFSET(32),
762 uint8_t key32ext
[32];
763 uint32_t *k32ext
= (uint32_t *) key32ext
;
765 memset(key32ext
, 0, sizeof(key32ext
));
766 k32ext
[0] = 0xadadadad;
768 struct table_packets table_packets
;
770 printf("--------------\n");
771 printf("RUNNING TEST - %s\n", __func__
);
772 printf("--------------\n");
773 for (i
= 0; i
< 50; i
++)
774 table_packets
.hit_packet
[i
] = 0xadadadad;
776 for (i
= 0; i
< 50; i
++)
777 table_packets
.miss_packet
[i
] = 0xbdadadad;
779 table_packets
.n_hit_packets
= 50;
780 table_packets
.n_miss_packets
= 50;
782 status
= test_table_type(&rte_table_hash_key32_ext_ops
,
783 (void *)&key32ext_params
, (void *)key32ext
, &table_packets
,
785 VERIFY(status
, CHECK_TABLE_OK
);
787 /* Invalid parameters */
788 key32ext_params
.n_entries
= 0;
790 status
= test_table_type(&rte_table_hash_key32_ext_ops
,
791 (void *)&key32ext_params
, (void *)key32ext
, &table_packets
,
793 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
795 key32ext_params
.n_entries
= 1<<16;
796 key32ext_params
.f_hash
= NULL
;
798 status
= test_table_type(&rte_table_hash_key32_ext_ops
,
799 (void *)&key32ext_params
, (void *)key32ext
, &table_packets
,
801 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
803 key32ext_params
.f_hash
= pipeline_test_hash
;
804 key32ext_params
.n_entries_ext
= 0;
806 status
= test_table_type(&rte_table_hash_key32_ext_ops
,
807 (void *)&key32ext_params
, (void *)key32ext
, &table_packets
,
809 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
815 test_table_hash_cuckoo_combined(void)
820 struct rte_table_hash_cuckoo_params cuckoo_params
= {
823 .f_hash
= pipeline_test_hash
,
825 .signature_offset
= APP_METADATA_OFFSET(0),
826 .key_offset
= APP_METADATA_OFFSET(32),
827 .name
= "CUCKOO_HASH",
830 uint8_t key_cuckoo
[32];
831 uint32_t *kcuckoo
= (uint32_t *) key_cuckoo
;
833 memset(key_cuckoo
, 0, sizeof(key_cuckoo
));
834 kcuckoo
[0] = 0xadadadad;
836 struct table_packets table_packets
;
838 printf("--------------\n");
839 printf("RUNNING TEST - %s\n", __func__
);
840 printf("--------------\n");
841 for (i
= 0; i
< 50; i
++)
842 table_packets
.hit_packet
[i
] = 0xadadadad;
844 for (i
= 0; i
< 50; i
++)
845 table_packets
.miss_packet
[i
] = 0xbdadadad;
847 table_packets
.n_hit_packets
= 50;
848 table_packets
.n_miss_packets
= 50;
850 status
= test_table_type(&rte_table_hash_cuckoo_dosig_ops
,
851 (void *)&cuckoo_params
, (void *)key_cuckoo
, &table_packets
,
853 VERIFY(status
, CHECK_TABLE_OK
);
855 /* Invalid parameters */
856 cuckoo_params
.key_size
= 0;
858 status
= test_table_type(&rte_table_hash_cuckoo_dosig_ops
,
859 (void *)&cuckoo_params
, (void *)key_cuckoo
, &table_packets
,
861 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
863 cuckoo_params
.key_size
= 32;
864 cuckoo_params
.n_keys
= 0;
866 status
= test_table_type(&rte_table_hash_cuckoo_dosig_ops
,
867 (void *)&cuckoo_params
, (void *)key_cuckoo
, &table_packets
,
869 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);
871 cuckoo_params
.n_keys
= 1<<16;
872 cuckoo_params
.f_hash
= NULL
;
874 status
= test_table_type(&rte_table_hash_cuckoo_dosig_ops
,
875 (void *)&cuckoo_params
, (void *)key_cuckoo
, &table_packets
,
877 VERIFY(status
, CHECK_TABLE_TABLE_CONFIG
);