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