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