mbuf: remove rte_ctrlmbuf
[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                 .n_rules = 1 << 16,
297                 .entry_unique_size = 8,
298                 .offset = 0,
299         };
300
301         struct rte_table_lpm_key lpm_key = {
302                 .ip = 0xadadadad,
303                 .depth = 16,
304         };
305
306         struct table_packets table_packets;
307
308         printf("--------------\n");
309         printf("RUNNING TEST - %s\n", __func__);
310         printf("--------------\n");
311
312         for (i = 0; i < N_PACKETS; i++)
313                 table_packets.hit_packet[i] = 0xadadadad;
314
315         for (i = 0; i < N_PACKETS; i++)
316                 table_packets.miss_packet[i] = 0xfefefefe;
317
318         table_packets.n_hit_packets = N_PACKETS;
319         table_packets.n_miss_packets = N_PACKETS;
320
321         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
322                 (void *)&lpm_key, &table_packets, NULL, 0);
323         VERIFY(status, CHECK_TABLE_OK);
324
325         /* Invalid parameters */
326         lpm_params.n_rules = 0;
327
328         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
329                 (void *)&lpm_key, &table_packets, NULL, 0);
330         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
331
332         lpm_params.n_rules = 1 << 24;
333         lpm_key.depth = 0;
334
335         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
336                 (void *)&lpm_key, &table_packets, NULL, 0);
337         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
338
339         lpm_key.depth = 33;
340
341         status = test_table_type(&rte_table_lpm_ops, (void *)&lpm_params,
342                 (void *)&lpm_key, &table_packets, NULL, 0);
343         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
344
345         return 0;
346 }
347
348 int
349 test_table_lpm_ipv6_combined(void)
350 {
351         int status, i;
352
353         /* Traffic flow */
354         struct rte_table_lpm_ipv6_params lpm_ipv6_params = {
355                 .n_rules = 1 << 16,
356                 .number_tbl8s = 1 << 13,
357                 .entry_unique_size = 8,
358                 .offset = 32,
359         };
360
361         struct rte_table_lpm_ipv6_key lpm_ipv6_key = {
362                 .depth = 16,
363         };
364         memset(lpm_ipv6_key.ip, 0xad, 16);
365
366         struct table_packets table_packets;
367
368         printf("--------------\n");
369         printf("RUNNING TEST - %s\n", __func__);
370         printf("--------------\n");
371         for (i = 0; i < N_PACKETS; i++)
372                 table_packets.hit_packet[i] = 0xadadadad;
373
374         for (i = 0; i < N_PACKETS; i++)
375                 table_packets.miss_packet[i] = 0xadadadab;
376
377         table_packets.n_hit_packets = N_PACKETS;
378         table_packets.n_miss_packets = N_PACKETS;
379
380         status = test_table_type(&rte_table_lpm_ipv6_ops,
381                 (void *)&lpm_ipv6_params,
382                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
383         VERIFY(status, CHECK_TABLE_OK);
384
385         /* Invalid parameters */
386         lpm_ipv6_params.n_rules = 0;
387
388         status = test_table_type(&rte_table_lpm_ipv6_ops,
389                 (void *)&lpm_ipv6_params,
390                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
391         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
392
393         lpm_ipv6_params.n_rules = 1 << 24;
394         lpm_ipv6_key.depth = 0;
395
396         status = test_table_type(&rte_table_lpm_ipv6_ops,
397                 (void *)&lpm_ipv6_params,
398                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
399         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
400
401         lpm_ipv6_key.depth = 129;
402         status = test_table_type(&rte_table_lpm_ipv6_ops,
403                 (void *)&lpm_ipv6_params,
404                 (void *)&lpm_ipv6_key, &table_packets, NULL, 0);
405         VERIFY(status, CHECK_TABLE_ENTRY_ADD);
406
407         return 0;
408 }
409
410 int
411 test_table_hash8lru(void)
412 {
413         int status, i;
414
415         /* Traffic flow */
416         struct rte_table_hash_key8_lru_params key8lru_params = {
417                 .n_entries = 1<<24,
418                 .f_hash = pipeline_test_hash,
419                 .seed = 0,
420                 .signature_offset = 0,
421                 .key_offset = 32,
422         };
423
424         uint8_t key8lru[8];
425         uint32_t *k8lru = (uint32_t *) key8lru;
426
427         memset(key8lru, 0, sizeof(key8lru));
428         k8lru[0] = 0xadadadad;
429
430         struct table_packets table_packets;
431
432         printf("--------------\n");
433         printf("RUNNING TEST - %s\n", __func__);
434         printf("--------------\n");
435         for (i = 0; i < 50; i++)
436                 table_packets.hit_packet[i] = 0xadadadad;
437
438         for (i = 0; i < 50; i++)
439                 table_packets.miss_packet[i] = 0xfefefefe;
440
441         table_packets.n_hit_packets = 50;
442         table_packets.n_miss_packets = 50;
443
444         status = test_table_type(&rte_table_hash_key8_lru_ops,
445                 (void *)&key8lru_params, (void *)key8lru, &table_packets,
446                         NULL, 0);
447         VERIFY(status, CHECK_TABLE_OK);
448
449         /* Invalid parameters */
450         key8lru_params.n_entries = 0;
451
452         status = test_table_type(&rte_table_hash_key8_lru_ops,
453                 (void *)&key8lru_params, (void *)key8lru, &table_packets,
454                         NULL, 0);
455         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
456
457         key8lru_params.n_entries = 1<<16;
458         key8lru_params.f_hash = NULL;
459
460         status = test_table_type(&rte_table_hash_key8_lru_ops,
461                 (void *)&key8lru_params, (void *)key8lru, &table_packets,
462                         NULL, 0);
463         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
464
465         return 0;
466 }
467
468 int
469 test_table_hash16lru(void)
470 {
471         int status, i;
472
473         /* Traffic flow */
474         struct rte_table_hash_key16_lru_params key16lru_params = {
475                 .n_entries = 1<<16,
476                 .f_hash = pipeline_test_hash,
477                 .seed = 0,
478                 .signature_offset = 0,
479                 .key_offset = 32,
480         };
481
482         uint8_t key16lru[16];
483         uint32_t *k16lru = (uint32_t *) key16lru;
484
485         memset(key16lru, 0, sizeof(key16lru));
486         k16lru[0] = 0xadadadad;
487
488         struct table_packets table_packets;
489
490         printf("--------------\n");
491         printf("RUNNING TEST - %s\n", __func__);
492         printf("--------------\n");
493         for (i = 0; i < 50; i++)
494                 table_packets.hit_packet[i] = 0xadadadad;
495
496         for (i = 0; i < 50; i++)
497                 table_packets.miss_packet[i] = 0xfefefefe;
498
499         table_packets.n_hit_packets = 50;
500         table_packets.n_miss_packets = 50;
501
502         status = test_table_type(&rte_table_hash_key16_lru_ops,
503                 (void *)&key16lru_params, (void *)key16lru, &table_packets,
504                         NULL, 0);
505         VERIFY(status, CHECK_TABLE_OK);
506
507         /* Invalid parameters */
508         key16lru_params.n_entries = 0;
509
510         status = test_table_type(&rte_table_hash_key16_lru_ops,
511                 (void *)&key16lru_params, (void *)key16lru, &table_packets,
512                         NULL, 0);
513         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
514
515         key16lru_params.n_entries = 1<<16;
516         key16lru_params.f_hash = NULL;
517
518         status = test_table_type(&rte_table_hash_key16_lru_ops,
519                 (void *)&key16lru_params, (void *)key16lru, &table_packets,
520                         NULL, 0);
521         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
522
523         return 0;
524 }
525
526 int
527 test_table_hash32lru(void)
528 {
529         int status, i;
530
531         /* Traffic flow */
532         struct rte_table_hash_key32_lru_params key32lru_params = {
533                 .n_entries = 1<<16,
534                 .f_hash = pipeline_test_hash,
535                 .seed = 0,
536                 .signature_offset = 0,
537                 .key_offset = 32,
538         };
539
540         uint8_t key32lru[32];
541         uint32_t *k32lru = (uint32_t *) key32lru;
542
543         memset(key32lru, 0, sizeof(key32lru));
544         k32lru[0] = 0xadadadad;
545
546         struct table_packets table_packets;
547
548         printf("--------------\n");
549         printf("RUNNING TEST - %s\n", __func__);
550         printf("--------------\n");
551         for (i = 0; i < 50; i++)
552                 table_packets.hit_packet[i] = 0xadadadad;
553
554         for (i = 0; i < 50; i++)
555                 table_packets.miss_packet[i] = 0xbdadadad;
556
557         table_packets.n_hit_packets = 50;
558         table_packets.n_miss_packets = 50;
559
560         status = test_table_type(&rte_table_hash_key32_lru_ops,
561                 (void *)&key32lru_params, (void *)key32lru, &table_packets,
562                 NULL, 0);
563         VERIFY(status, CHECK_TABLE_OK);
564
565         /* Invalid parameters */
566         key32lru_params.n_entries = 0;
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_TABLE_CONFIG);
572
573         key32lru_params.n_entries = 1<<16;
574         key32lru_params.f_hash = NULL;
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         return 0;
582 }
583
584 int
585 test_table_hash8ext(void)
586 {
587         int status, i;
588
589         /* Traffic flow */
590         struct rte_table_hash_key8_ext_params key8ext_params = {
591                 .n_entries = 1<<16,
592                 .n_entries_ext = 1<<15,
593                 .f_hash = pipeline_test_hash,
594                 .seed = 0,
595                 .signature_offset = 0,
596                 .key_offset = 32,
597         };
598
599         uint8_t key8ext[8];
600         uint32_t *k8ext = (uint32_t *) key8ext;
601
602         memset(key8ext, 0, sizeof(key8ext));
603         k8ext[0] = 0xadadadad;
604
605         struct table_packets table_packets;
606
607         printf("--------------\n");
608         printf("RUNNING TEST - %s\n", __func__);
609         printf("--------------\n");
610         for (i = 0; i < 50; i++)
611                 table_packets.hit_packet[i] = 0xadadadad;
612
613         for (i = 0; i < 50; i++)
614                 table_packets.miss_packet[i] = 0xbdadadad;
615
616         table_packets.n_hit_packets = 50;
617         table_packets.n_miss_packets = 50;
618
619         status = test_table_type(&rte_table_hash_key8_ext_ops,
620                 (void *)&key8ext_params, (void *)key8ext, &table_packets,
621                 NULL, 0);
622         VERIFY(status, CHECK_TABLE_OK);
623
624         /* Invalid parameters */
625         key8ext_params.n_entries = 0;
626
627         status = test_table_type(&rte_table_hash_key8_ext_ops,
628                 (void *)&key8ext_params, (void *)key8ext, &table_packets,
629                 NULL, 0);
630         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
631
632         key8ext_params.n_entries = 1<<16;
633         key8ext_params.f_hash = NULL;
634
635         status = test_table_type(&rte_table_hash_key8_ext_ops,
636                 (void *)&key8ext_params, (void *)key8ext, &table_packets,
637                 NULL, 0);
638         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
639
640         key8ext_params.f_hash = pipeline_test_hash;
641         key8ext_params.n_entries_ext = 0;
642
643         status = test_table_type(&rte_table_hash_key8_ext_ops,
644         (void *)&key8ext_params, (void *)key8ext, &table_packets, NULL, 0);
645         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
646
647         return 0;
648 }
649
650 int
651 test_table_hash16ext(void)
652 {
653         int status, i;
654
655         /* Traffic flow */
656         struct rte_table_hash_key16_ext_params key16ext_params = {
657                 .n_entries = 1<<16,
658                 .n_entries_ext = 1<<15,
659                 .f_hash = pipeline_test_hash,
660                 .seed = 0,
661                 .signature_offset = 0,
662                 .key_offset = 32,
663         };
664
665         uint8_t key16ext[16];
666         uint32_t *k16ext = (uint32_t *) key16ext;
667
668         memset(key16ext, 0, sizeof(key16ext));
669         k16ext[0] = 0xadadadad;
670
671         struct table_packets table_packets;
672
673         printf("--------------\n");
674         printf("RUNNING TEST - %s\n", __func__);
675         printf("--------------\n");
676         for (i = 0; i < 50; i++)
677                 table_packets.hit_packet[i] = 0xadadadad;
678
679         for (i = 0; i < 50; i++)
680                 table_packets.miss_packet[i] = 0xbdadadad;
681
682         table_packets.n_hit_packets = 50;
683         table_packets.n_miss_packets = 50;
684
685         status = test_table_type(&rte_table_hash_key16_ext_ops,
686                 (void *)&key16ext_params, (void *)key16ext, &table_packets,
687                 NULL, 0);
688         VERIFY(status, CHECK_TABLE_OK);
689
690         /* Invalid parameters */
691         key16ext_params.n_entries = 0;
692
693         status = test_table_type(&rte_table_hash_key16_ext_ops,
694                 (void *)&key16ext_params, (void *)key16ext, &table_packets,
695                 NULL, 0);
696         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
697
698         key16ext_params.n_entries = 1<<16;
699         key16ext_params.f_hash = NULL;
700
701         status = test_table_type(&rte_table_hash_key16_ext_ops,
702                 (void *)&key16ext_params, (void *)key16ext, &table_packets,
703                 NULL, 0);
704         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
705
706         key16ext_params.f_hash = pipeline_test_hash;
707         key16ext_params.n_entries_ext = 0;
708
709         status = test_table_type(&rte_table_hash_key16_ext_ops,
710         (void *)&key16ext_params, (void *)key16ext, &table_packets, NULL, 0);
711         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
712
713         return 0;
714 }
715
716 int
717 test_table_hash32ext(void)
718 {
719         int status, i;
720
721         /* Traffic flow */
722         struct rte_table_hash_key32_ext_params key32ext_params = {
723                 .n_entries = 1<<16,
724                 .n_entries_ext = 1<<15,
725                 .f_hash = pipeline_test_hash,
726                 .seed = 0,
727                 .signature_offset = 0,
728                 .key_offset = 32,
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_entries = 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_entries = 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         key32ext_params.f_hash = pipeline_test_hash;
773         key32ext_params.n_entries_ext = 0;
774
775         status = test_table_type(&rte_table_hash_key32_ext_ops,
776                 (void *)&key32ext_params, (void *)key32ext, &table_packets,
777                 NULL, 0);
778         VERIFY(status, CHECK_TABLE_TABLE_CONFIG);
779
780         return 0;
781 }