remove extra blank lines at end of files
[dpdk.git] / app / test / test_table_combined.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation
3  */
4
5 #include <string.h>
6 #include "test_table_combined.h"
7 #include "test_table.h"
8 #include <rte_table_lpm_ipv6.h>
9
10 #define MAX_TEST_KEYS 128
11 #define N_PACKETS 50
12
13 enum check_table_result {
14         CHECK_TABLE_OK,
15         CHECK_TABLE_PORT_CONFIG,
16         CHECK_TABLE_PORT_ENABLE,
17         CHECK_TABLE_TABLE_CONFIG,
18         CHECK_TABLE_ENTRY_ADD,
19         CHECK_TABLE_DEFAULT_ENTRY_ADD,
20         CHECK_TABLE_CONNECT,
21         CHECK_TABLE_MANAGE_ERROR,
22         CHECK_TABLE_CONSISTENCY,
23         CHECK_TABLE_NO_TRAFFIC,
24         CHECK_TABLE_INVALID_PARAMETER,
25 };
26
27 struct table_packets {
28         uint32_t hit_packet[MAX_TEST_KEYS];
29         uint32_t miss_packet[MAX_TEST_KEYS];
30         uint32_t n_hit_packets;
31         uint32_t n_miss_packets;
32 };
33
34 combined_table_test table_tests_combined[] = {
35         test_table_lpm_combined,
36         test_table_lpm_ipv6_combined,
37         test_table_hash8lru,
38         test_table_hash8ext,
39         test_table_hash16lru,
40         test_table_hash16ext,
41         test_table_hash32lru,
42         test_table_hash32ext,
43         test_table_hash_cuckoo_combined,
44 };
45
46 unsigned n_table_tests_combined = RTE_DIM(table_tests_combined);
47
48 /* Generic port tester function */
49 static int
50 test_table_type(struct rte_table_ops *table_ops, void *table_args,
51         void *key, struct table_packets *table_packets,
52         struct manage_ops *manage_ops, unsigned n_ops)
53 {
54         uint32_t ring_in_id, table_id, ring_out_id, ring_out_2_id;
55         unsigned i;
56
57         RTE_SET_USED(manage_ops);
58         RTE_SET_USED(n_ops);
59         /* Create pipeline */
60         struct rte_pipeline_params pipeline_params = {
61                 .name = "pipeline",
62                 .socket_id = 0,
63         };
64
65         struct rte_pipeline *pipeline = rte_pipeline_create(&pipeline_params);
66
67         /* Create input ring */
68         struct rte_port_ring_reader_params ring_params_rx = {
69                 .ring = RING_RX,
70         };
71
72         struct rte_port_ring_writer_params ring_params_tx = {
73                 .ring = RING_RX,
74                 .tx_burst_sz = RTE_PORT_IN_BURST_SIZE_MAX,
75         };
76
77         struct rte_pipeline_port_in_params ring_in_params = {
78                 .ops = &rte_port_ring_reader_ops,
79                 .arg_create = (void *)&ring_params_rx,
80                 .f_action = NULL,
81                 .burst_size = RTE_PORT_IN_BURST_SIZE_MAX,
82         };
83
84         if (rte_pipeline_port_in_create(pipeline, &ring_in_params,
85                 &ring_in_id) != 0) {
86                 rte_pipeline_free(pipeline);
87                 return -CHECK_TABLE_PORT_CONFIG;
88         }
89
90         /* Create table */
91         struct rte_pipeline_table_params table_params = {
92                 .ops = table_ops,
93                 .arg_create = table_args,
94                 .f_action_hit = NULL,
95                 .f_action_miss = NULL,
96                 .arg_ah = NULL,
97                 .action_data_size = 0,
98         };
99
100         if (rte_pipeline_table_create(pipeline, &table_params,
101                 &table_id) != 0) {
102                 rte_pipeline_free(pipeline);
103                 return -CHECK_TABLE_TABLE_CONFIG;
104         }
105
106         /* Create output ports */
107         ring_params_tx.ring = RING_TX;
108
109         struct rte_pipeline_port_out_params ring_out_params = {
110                 .ops = &rte_port_ring_writer_ops,
111                 .arg_create = (void *)&ring_params_tx,
112                 .f_action = NULL,
113         };
114
115         if (rte_pipeline_port_out_create(pipeline, &ring_out_params,
116                 &ring_out_id) != 0) {
117                 rte_pipeline_free(pipeline);
118                 return -CHECK_TABLE_PORT_CONFIG;
119         }
120
121         ring_params_tx.ring = RING_TX_2;
122
123         if (rte_pipeline_port_out_create(pipeline, &ring_out_params,
124                 &ring_out_2_id) != 0) {
125                 rte_pipeline_free(pipeline);
126                 return -CHECK_TABLE_PORT_CONFIG;
127         }
128
129         /* Add entry to the table */
130         struct rte_pipeline_table_entry default_entry = {
131                 .action = RTE_PIPELINE_ACTION_DROP,
132                 {.table_id = ring_out_id},
133         };
134
135         struct rte_pipeline_table_entry table_entry = {
136                 .action = RTE_PIPELINE_ACTION_PORT,
137                 {.table_id = ring_out_id},
138         };
139
140         struct rte_pipeline_table_entry *default_entry_ptr, *entry_ptr;
141
142         int key_found;
143
144         if (rte_pipeline_table_default_entry_add(pipeline, table_id,
145                 &default_entry, &default_entry_ptr) != 0) {
146                 rte_pipeline_free(pipeline);
147                 return -CHECK_TABLE_DEFAULT_ENTRY_ADD;
148         }
149
150         if (rte_pipeline_table_entry_add(pipeline, table_id,
151                 key ? key : &table_entry, &table_entry, &key_found,
152                         &entry_ptr) != 0) {
153                 rte_pipeline_free(pipeline);
154                 return -CHECK_TABLE_ENTRY_ADD;
155         }
156
157         /* Create connections and check consistency */
158         if (rte_pipeline_port_in_connect_to_table(pipeline, ring_in_id,
159                 table_id) != 0) {
160                 rte_pipeline_free(pipeline);
161                 return -CHECK_TABLE_CONNECT;
162         }
163
164         if (rte_pipeline_port_in_enable(pipeline, ring_in_id) != 0) {
165                 rte_pipeline_free(pipeline);
166                 return -CHECK_TABLE_PORT_ENABLE;
167         }
168
169         if (rte_pipeline_check(pipeline) != 0) {
170                 rte_pipeline_free(pipeline);
171                 return -CHECK_TABLE_CONSISTENCY;
172         }
173
174
175
176         /* Flow test - All hits */
177         if (table_packets->n_hit_packets) {
178                 for (i = 0; i < table_packets->n_hit_packets; i++)
179                         RING_ENQUEUE(RING_RX, table_packets->hit_packet[i]);
180
181                 RUN_PIPELINE(pipeline);
182
183                 VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets,
184                                 table_packets->n_hit_packets);
185         }
186
187         /* Flow test - All misses */
188         if (table_packets->n_miss_packets) {
189                 for (i = 0; i < table_packets->n_miss_packets; i++)
190                         RING_ENQUEUE(RING_RX, table_packets->miss_packet[i]);
191
192                 RUN_PIPELINE(pipeline);
193
194                 VERIFY_TRAFFIC(RING_TX, table_packets->n_miss_packets, 0);
195         }
196
197         /* Flow test - Half hits, half misses */
198         if (table_packets->n_hit_packets && table_packets->n_miss_packets) {
199                 for (i = 0; i < (table_packets->n_hit_packets) / 2; i++)
200                         RING_ENQUEUE(RING_RX, table_packets->hit_packet[i]);
201
202                 for (i = 0; i < (table_packets->n_miss_packets) / 2; i++)
203                         RING_ENQUEUE(RING_RX, table_packets->miss_packet[i]);
204
205                 RUN_PIPELINE(pipeline);
206                 VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets,
207                         table_packets->n_hit_packets / 2);
208         }
209
210         /* Flow test - Single packet */
211         if (table_packets->n_hit_packets) {
212                 RING_ENQUEUE(RING_RX, table_packets->hit_packet[0]);
213                 RUN_PIPELINE(pipeline);
214                 VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets, 1);
215         }
216         if (table_packets->n_miss_packets) {
217                 RING_ENQUEUE(RING_RX, table_packets->miss_packet[0]);
218                 RUN_PIPELINE(pipeline);
219                 VERIFY_TRAFFIC(RING_TX, table_packets->n_miss_packets, 0);
220         }
221
222
223         /* Change table entry action */
224         printf("Change entry action\n");
225         table_entry.table_id = ring_out_2_id;
226
227         if (rte_pipeline_table_default_entry_add(pipeline, table_id,
228                 &default_entry, &default_entry_ptr) != 0) {
229                 rte_pipeline_free(pipeline);
230                 return -CHECK_TABLE_ENTRY_ADD;
231         }
232
233         if (rte_pipeline_table_entry_add(pipeline, table_id,
234                 key ? key : &table_entry, &table_entry, &key_found,
235                         &entry_ptr) != 0) {
236                 rte_pipeline_free(pipeline);
237                 return -CHECK_TABLE_ENTRY_ADD;
238         }
239
240         /* Check that traffic destination has changed */
241         if (table_packets->n_hit_packets) {
242                 for (i = 0; i < table_packets->n_hit_packets; i++)
243                         RING_ENQUEUE(RING_RX, table_packets->hit_packet[i]);
244
245                 RUN_PIPELINE(pipeline);
246                 VERIFY_TRAFFIC(RING_TX, table_packets->n_hit_packets, 0);
247                 VERIFY_TRAFFIC(RING_TX_2, table_packets->n_hit_packets,
248                         table_packets->n_hit_packets);
249         }
250
251         printf("delete entry\n");
252         /* Delete table entry */
253         rte_pipeline_table_entry_delete(pipeline, table_id,
254                 key ? key : &table_entry, &key_found, NULL);
255
256         rte_pipeline_free(pipeline);
257
258         return 0;
259 }
260
261 /* Table tests */
262 int
263 test_table_stub_combined(void)
264 {
265         int status, i;
266         struct table_packets table_packets;
267
268         printf("--------------\n");
269         printf("RUNNING TEST - %s\n", __func__);
270         printf("--------------\n");
271         for (i = 0; i < N_PACKETS; i++)
272                 table_packets.hit_packet[i] = i;
273
274         table_packets.n_hit_packets = N_PACKETS;
275         table_packets.n_miss_packets = 0;
276
277         status = test_table_type(&rte_table_stub_ops, NULL, NULL,
278                 &table_packets, NULL, 1);
279         VERIFY(status, CHECK_TABLE_OK);
280
281         return 0;
282 }
283
284 int
285 test_table_lpm_combined(void)
286 {
287         int status, i;
288
289         /* Traffic flow */
290         struct rte_table_lpm_params lpm_params = {
291                 .name = "LPM",
292                 .n_rules = 1 << 16,
293                 .number_tbl8s = 1 << 8,
294                 .flags = 0,
295                 .entry_unique_size = 8,
296                 .offset = APP_METADATA_OFFSET(0),
297         };
298
299         struct rte_table_lpm_key lpm_key = {
300                 .ip = 0xadadadad,
301                 .depth = 16,
302         };
303
304         struct table_packets table_packets;
305
306         printf("--------------\n");
307         printf("RUNNING TEST - %s\n", __func__);
308         printf("--------------\n");
309
310         for (i = 0; i < N_PACKETS; i++)
311                 table_packets.hit_packet[i] = 0xadadadad;
312
313         for (i = 0; i < N_PACKETS; i++)
314                 table_packets.miss_packet[i] = 0xfefefefe;
315
316         table_packets.n_hit_packets = N_PACKETS;
317         table_packets.n_miss_packets = N_PACKETS;
318
319         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
320                 (void *)&lpm_key, &table_packets, NULL, 0);
321         VERIFY(status, CHECK_TABLE_OK);
322
323         /* Invalid parameters */
324         lpm_params.n_rules = 0;
325
326         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
327                 (void *)&lpm_key, &table_packets, NULL, 0);
328         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
329
330         lpm_params.n_rules = 1 << 24;
331         lpm_key.depth = 0;
332
333         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
334                 (void *)&lpm_key, &table_packets, NULL, 0);
335         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
336
337         lpm_key.depth = 33;
338
339         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
340                 (void *)&lpm_key, &table_packets, NULL, 0);
341         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
342
343         return 0;
344 }
345
346 int
347 test_table_lpm_ipv6_combined(void)
348 {
349         int status, i;
350
351         /* Traffic flow */
352         struct rte_table_lpm_ipv6_params lpm_ipv6_params = {
353                 .name = "LPM",
354                 .n_rules = 1 << 16,
355                 .number_tbl8s = 1 << 13,
356                 .entry_unique_size = 8,
357                 .offset = APP_METADATA_OFFSET(32),
358         };
359
360         struct rte_table_lpm_ipv6_key lpm_ipv6_key = {
361                 .depth = 16,
362         };
363         memset(lpm_ipv6_key.ip, 0xad, 16);
364
365         struct table_packets table_packets;
366
367         printf("--------------\n");
368         printf("RUNNING TEST - %s\n", __func__);
369         printf("--------------\n");
370         for (i = 0; i < N_PACKETS; i++)
371                 table_packets.hit_packet[i] = 0xadadadad;
372
373         for (i = 0; i < N_PACKETS; i++)
374                 table_packets.miss_packet[i] = 0xadadadab;
375
376         table_packets.n_hit_packets = N_PACKETS;
377         table_packets.n_miss_packets = N_PACKETS;
378
379         status = test_table_type(&rte_table_lpm_ipv6_ops,
380                 (void *)&lpm_ipv6_params,
381                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
382         VERIFY(status, CHECK_TABLE_OK);
383
384         /* Invalid parameters */
385         lpm_ipv6_params.n_rules = 0;
386
387         status = test_table_type(&rte_table_lpm_ipv6_ops,
388                 (void *)&lpm_ipv6_params,
389                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
390         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
391
392         lpm_ipv6_params.n_rules = 1 << 24;
393         lpm_ipv6_key.depth = 0;
394
395         status = test_table_type(&rte_table_lpm_ipv6_ops,
396                 (void *)&lpm_ipv6_params,
397                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
398         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
399
400         lpm_ipv6_key.depth = 129;
401         status = test_table_type(&rte_table_lpm_ipv6_ops,
402                 (void *)&lpm_ipv6_params,
403                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
404         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
405
406         return 0;
407 }
408
409 int
410 test_table_hash8lru(void)
411 {
412         int status, i;
413
414         /* Traffic flow */
415         struct rte_table_hash_params key8lru_params = {
416                 .name = "TABLE",
417                 .key_size = 8,
418                 .key_offset = APP_METADATA_OFFSET(32),
419                 .key_mask = NULL,
420                 .n_keys = 1 << 16,
421                 .n_buckets = 1 << 16,
422                 .f_hash = pipeline_test_hash,
423                 .seed = 0,
424         };
425
426         uint8_t key8lru[8];
427         uint32_t *k8lru = (uint32_t *) key8lru;
428
429         memset(key8lru, 0, sizeof(key8lru));
430         k8lru[0] = 0xadadadad;
431
432         struct table_packets table_packets;
433
434         printf("--------------\n");
435         printf("RUNNING TEST - %s\n", __func__);
436         printf("--------------\n");
437         for (i = 0; i < 50; i++)
438                 table_packets.hit_packet[i] = 0xadadadad;
439
440         for (i = 0; i < 50; i++)
441                 table_packets.miss_packet[i] = 0xfefefefe;
442
443         table_packets.n_hit_packets = 50;
444         table_packets.n_miss_packets = 50;
445
446         status = test_table_type(&rte_table_hash_key8_lru_ops,
447                 (void *)&key8lru_params, (void *)key8lru, &table_packets,
448                         NULL, 0);
449         VERIFY(status, CHECK_TABLE_OK);
450
451         /* Invalid parameters */
452         key8lru_params.n_keys = 0;
453
454         status = test_table_type(&rte_table_hash_key8_lru_ops,
455                 (void *)&key8lru_params, (void *)key8lru, &table_packets,
456                         NULL, 0);
457         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
458
459         key8lru_params.n_keys = 1<<16;
460         key8lru_params.f_hash = NULL;
461
462         status = test_table_type(&rte_table_hash_key8_lru_ops,
463                 (void *)&key8lru_params, (void *)key8lru, &table_packets,
464                         NULL, 0);
465         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
466
467         return 0;
468 }
469
470 int
471 test_table_hash16lru(void)
472 {
473         int status, i;
474
475         /* Traffic flow */
476         struct rte_table_hash_params key16lru_params = {
477                 .name = "TABLE",
478                 .key_size = 16,
479                 .key_offset = APP_METADATA_OFFSET(32),
480                 .key_mask = NULL,
481                 .n_keys = 1 << 16,
482                 .n_buckets = 1 << 16,
483                 .f_hash = pipeline_test_hash,
484                 .seed = 0,
485         };
486
487         uint8_t key16lru[16];
488         uint32_t *k16lru = (uint32_t *) key16lru;
489
490         memset(key16lru, 0, sizeof(key16lru));
491         k16lru[0] = 0xadadadad;
492
493         struct table_packets table_packets;
494
495         printf("--------------\n");
496         printf("RUNNING TEST - %s\n", __func__);
497         printf("--------------\n");
498         for (i = 0; i < 50; i++)
499                 table_packets.hit_packet[i] = 0xadadadad;
500
501         for (i = 0; i < 50; i++)
502                 table_packets.miss_packet[i] = 0xfefefefe;
503
504         table_packets.n_hit_packets = 50;
505         table_packets.n_miss_packets = 50;
506
507         status = test_table_type(&rte_table_hash_key16_lru_ops,
508                 (void *)&key16lru_params, (void *)key16lru, &table_packets,
509                         NULL, 0);
510         VERIFY(status, CHECK_TABLE_OK);
511
512         /* Invalid parameters */
513         key16lru_params.n_keys = 0;
514
515         status = test_table_type(&rte_table_hash_key16_lru_ops,
516                 (void *)&key16lru_params, (void *)key16lru, &table_packets,
517                         NULL, 0);
518         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
519
520         key16lru_params.n_keys = 1<<16;
521         key16lru_params.f_hash = NULL;
522
523         status = test_table_type(&rte_table_hash_key16_lru_ops,
524                 (void *)&key16lru_params, (void *)key16lru, &table_packets,
525                         NULL, 0);
526         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
527
528         return 0;
529 }
530
531 int
532 test_table_hash32lru(void)
533 {
534         int status, i;
535
536         /* Traffic flow */
537         struct rte_table_hash_params key32lru_params = {
538                 .name = "TABLE",
539                 .key_size = 32,
540                 .key_offset = APP_METADATA_OFFSET(32),
541                 .key_mask = NULL,
542                 .n_keys = 1 << 16,
543                 .n_buckets = 1 << 16,
544                 .f_hash = pipeline_test_hash,
545                 .seed = 0,
546         };
547
548         uint8_t key32lru[32];
549         uint32_t *k32lru = (uint32_t *) key32lru;
550
551         memset(key32lru, 0, sizeof(key32lru));
552         k32lru[0] = 0xadadadad;
553
554         struct table_packets table_packets;
555
556         printf("--------------\n");
557         printf("RUNNING TEST - %s\n", __func__);
558         printf("--------------\n");
559         for (i = 0; i < 50; i++)
560                 table_packets.hit_packet[i] = 0xadadadad;
561
562         for (i = 0; i < 50; i++)
563                 table_packets.miss_packet[i] = 0xbdadadad;
564
565         table_packets.n_hit_packets = 50;
566         table_packets.n_miss_packets = 50;
567
568         status = test_table_type(&rte_table_hash_key32_lru_ops,
569                 (void *)&key32lru_params, (void *)key32lru, &table_packets,
570                 NULL, 0);
571         VERIFY(status, CHECK_TABLE_OK);
572
573         /* Invalid parameters */
574         key32lru_params.n_keys = 0;
575
576         status = test_table_type(&rte_table_hash_key32_lru_ops,
577                 (void *)&key32lru_params, (void *)key32lru, &table_packets,
578                 NULL, 0);
579         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
580
581         key32lru_params.n_keys = 1<<16;
582         key32lru_params.f_hash = NULL;
583
584         status = test_table_type(&rte_table_hash_key32_lru_ops,
585                 (void *)&key32lru_params, (void *)key32lru, &table_packets,
586                 NULL, 0);
587         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
588
589         return 0;
590 }
591
592 int
593 test_table_hash8ext(void)
594 {
595         int status, i;
596
597         /* Traffic flow */
598         struct rte_table_hash_params key8ext_params = {
599                 .name = "TABLE",
600                 .key_size = 8,
601                 .key_offset = APP_METADATA_OFFSET(32),
602                 .key_mask = NULL,
603                 .n_keys = 1 << 16,
604                 .n_buckets = 1 << 16,
605                 .f_hash = pipeline_test_hash,
606                 .seed = 0,
607         };
608
609         uint8_t key8ext[8];
610         uint32_t *k8ext = (uint32_t *) key8ext;
611
612         memset(key8ext, 0, sizeof(key8ext));
613         k8ext[0] = 0xadadadad;
614
615         struct table_packets table_packets;
616
617         printf("--------------\n");
618         printf("RUNNING TEST - %s\n", __func__);
619         printf("--------------\n");
620         for (i = 0; i < 50; i++)
621                 table_packets.hit_packet[i] = 0xadadadad;
622
623         for (i = 0; i < 50; i++)
624                 table_packets.miss_packet[i] = 0xbdadadad;
625
626         table_packets.n_hit_packets = 50;
627         table_packets.n_miss_packets = 50;
628
629         status = test_table_type(&rte_table_hash_key8_ext_ops,
630                 (void *)&key8ext_params, (void *)key8ext, &table_packets,
631                 NULL, 0);
632         VERIFY(status, CHECK_TABLE_OK);
633
634         /* Invalid parameters */
635         key8ext_params.n_keys = 0;
636
637         status = test_table_type(&rte_table_hash_key8_ext_ops,
638                 (void *)&key8ext_params, (void *)key8ext, &table_packets,
639                 NULL, 0);
640         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
641
642         key8ext_params.n_keys = 1<<16;
643         key8ext_params.f_hash = NULL;
644
645         status = test_table_type(&rte_table_hash_key8_ext_ops,
646                 (void *)&key8ext_params, (void *)key8ext, &table_packets,
647                 NULL, 0);
648         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
649
650         return 0;
651 }
652
653 int
654 test_table_hash16ext(void)
655 {
656         int status, i;
657
658         /* Traffic flow */
659         struct rte_table_hash_params key16ext_params = {
660                 .name = "TABLE",
661                 .key_size = 16,
662                 .key_offset = APP_METADATA_OFFSET(32),
663                 .key_mask = NULL,
664                 .n_keys = 1 << 16,
665                 .n_buckets = 1 << 16,
666                 .f_hash = pipeline_test_hash,
667                 .seed = 0,
668         };
669
670         uint8_t key16ext[16];
671         uint32_t *k16ext = (uint32_t *) key16ext;
672
673         memset(key16ext, 0, sizeof(key16ext));
674         k16ext[0] = 0xadadadad;
675
676         struct table_packets table_packets;
677
678         printf("--------------\n");
679         printf("RUNNING TEST - %s\n", __func__);
680         printf("--------------\n");
681         for (i = 0; i < 50; i++)
682                 table_packets.hit_packet[i] = 0xadadadad;
683
684         for (i = 0; i < 50; i++)
685                 table_packets.miss_packet[i] = 0xbdadadad;
686
687         table_packets.n_hit_packets = 50;
688         table_packets.n_miss_packets = 50;
689
690         status = test_table_type(&rte_table_hash_key16_ext_ops,
691                 (void *)&key16ext_params, (void *)key16ext, &table_packets,
692                 NULL, 0);
693         VERIFY(status, CHECK_TABLE_OK);
694
695         /* Invalid parameters */
696         key16ext_params.n_keys = 0;
697
698         status = test_table_type(&rte_table_hash_key16_ext_ops,
699                 (void *)&key16ext_params, (void *)key16ext, &table_packets,
700                 NULL, 0);
701         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
702
703         key16ext_params.n_keys = 1<<16;
704         key16ext_params.f_hash = NULL;
705
706         status = test_table_type(&rte_table_hash_key16_ext_ops,
707                 (void *)&key16ext_params, (void *)key16ext, &table_packets,
708                 NULL, 0);
709         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
710
711         return 0;
712 }
713
714 int
715 test_table_hash32ext(void)
716 {
717         int status, i;
718
719         /* Traffic flow */
720         struct rte_table_hash_params key32ext_params = {
721                 .name = "TABLE",
722                 .key_size = 32,
723                 .key_offset = APP_METADATA_OFFSET(32),
724                 .key_mask = NULL,
725                 .n_keys = 1 << 16,
726                 .n_buckets = 1 << 16,
727                 .f_hash = pipeline_test_hash,
728                 .seed = 0,
729         };
730
731         uint8_t key32ext[32];
732         uint32_t *k32ext = (uint32_t *) key32ext;
733
734         memset(key32ext, 0, sizeof(key32ext));
735         k32ext[0] = 0xadadadad;
736
737         struct table_packets table_packets;
738
739         printf("--------------\n");
740         printf("RUNNING TEST - %s\n", __func__);
741         printf("--------------\n");
742         for (i = 0; i < 50; i++)
743                 table_packets.hit_packet[i] = 0xadadadad;
744
745         for (i = 0; i < 50; i++)
746                 table_packets.miss_packet[i] = 0xbdadadad;
747
748         table_packets.n_hit_packets = 50;
749         table_packets.n_miss_packets = 50;
750
751         status = test_table_type(&rte_table_hash_key32_ext_ops,
752                 (void *)&key32ext_params, (void *)key32ext, &table_packets,
753                 NULL, 0);
754         VERIFY(status, CHECK_TABLE_OK);
755
756         /* Invalid parameters */
757         key32ext_params.n_keys = 0;
758
759         status = test_table_type(&rte_table_hash_key32_ext_ops,
760                 (void *)&key32ext_params, (void *)key32ext, &table_packets,
761                 NULL, 0);
762         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
763
764         key32ext_params.n_keys = 1<<16;
765         key32ext_params.f_hash = NULL;
766
767         status = test_table_type(&rte_table_hash_key32_ext_ops,
768                 (void *)&key32ext_params, (void *)key32ext, &table_packets,
769                 NULL, 0);
770         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
771
772         return 0;
773 }
774
775 int
776 test_table_hash_cuckoo_combined(void)
777 {
778         int status, i;
779
780         /* Traffic flow */
781         struct rte_table_hash_cuckoo_params cuckoo_params = {
782                 .name = "TABLE",
783                 .key_size = 32,
784                 .key_offset = APP_METADATA_OFFSET(32),
785                 .key_mask = NULL,
786                 .n_keys = 1 << 16,
787                 .n_buckets = 1 << 16,
788                 .f_hash = pipeline_test_hash_cuckoo,
789                 .seed = 0,
790         };
791
792         uint8_t key_cuckoo[32];
793         uint32_t *kcuckoo = (uint32_t *) key_cuckoo;
794
795         memset(key_cuckoo, 0, sizeof(key_cuckoo));
796         kcuckoo[0] = 0xadadadad;
797
798         struct table_packets table_packets;
799
800         printf("--------------\n");
801         printf("RUNNING TEST - %s\n", __func__);
802         printf("--------------\n");
803         for (i = 0; i < 50; i++)
804                 table_packets.hit_packet[i] = 0xadadadad;
805
806         for (i = 0; i < 50; i++)
807                 table_packets.miss_packet[i] = 0xbdadadad;
808
809         table_packets.n_hit_packets = 50;
810         table_packets.n_miss_packets = 50;
811
812         status = test_table_type(&rte_table_hash_cuckoo_ops,
813                 (void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
814                 NULL, 0);
815         VERIFY(status, CHECK_TABLE_OK);
816
817         /* Invalid parameters */
818         cuckoo_params.key_size = 0;
819
820         status = test_table_type(&rte_table_hash_cuckoo_ops,
821                 (void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
822                 NULL, 0);
823         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
824
825         cuckoo_params.key_size = 32;
826         cuckoo_params.n_keys = 0;
827
828         status = test_table_type(&rte_table_hash_cuckoo_ops,
829                 (void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
830                 NULL, 0);
831         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
832
833         cuckoo_params.n_keys = 1<<16;
834         cuckoo_params.f_hash = NULL;
835
836         status = test_table_type(&rte_table_hash_cuckoo_ops,
837                 (void *)&cuckoo_params, (void *)key_cuckoo, &table_packets,
838                 NULL, 0);
839         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
840
841         return 0;
842 }