net/bnxt: fix headroom initialization
[dpdk.git] / test / test / test_flow_classify.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #include <string.h>
6 #include <errno.h>
7
8 #include "test.h"
9
10 #include <rte_string_fns.h>
11 #include <rte_mbuf.h>
12 #include <rte_byteorder.h>
13 #include <rte_ip.h>
14 #include <rte_acl.h>
15 #include <rte_common.h>
16 #include <rte_table_acl.h>
17 #include <rte_flow.h>
18 #include <rte_flow_classify.h>
19
20 #include "packet_burst_generator.h"
21 #include "test_flow_classify.h"
22
23
24 #define FLOW_CLASSIFY_MAX_RULE_NUM 100
25 struct flow_classifier_acl *cls;
26
27 struct flow_classifier_acl {
28         struct rte_flow_classifier *cls;
29 } __rte_cache_aligned;
30
31 /*
32  * test functions by passing invalid or
33  * non-workable parameters.
34  */
35 static int
36 test_invalid_parameters(void)
37 {
38         struct rte_flow_classify_rule *rule;
39         int ret;
40
41         ret = rte_flow_classify_validate(NULL, NULL, NULL, NULL, NULL);
42         if (!ret) {
43                 printf("Line %i: rte_flow_classify_validate",
44                         __LINE__);
45                 printf(" with NULL param should have failed!\n");
46                 return -1;
47         }
48
49         rule = rte_flow_classify_table_entry_add(NULL, NULL, NULL, NULL,
50                         NULL, NULL);
51         if (rule) {
52                 printf("Line %i: flow_classifier_table_entry_add", __LINE__);
53                 printf(" with NULL param should have failed!\n");
54                 return -1;
55         }
56
57         ret = rte_flow_classify_table_entry_delete(NULL, NULL);
58         if (!ret) {
59                 printf("Line %i: rte_flow_classify_table_entry_delete",
60                         __LINE__);
61                 printf(" with NULL param should have failed!\n");
62                 return -1;
63         }
64
65         ret = rte_flow_classifier_query(NULL, NULL, 0, NULL, NULL);
66         if (!ret) {
67                 printf("Line %i: flow_classifier_query", __LINE__);
68                 printf(" with NULL param should have failed!\n");
69                 return -1;
70         }
71
72         rule = rte_flow_classify_table_entry_add(NULL, NULL, NULL, NULL,
73                 NULL, &error);
74         if (rule) {
75                 printf("Line %i: flow_classify_table_entry_add ", __LINE__);
76                 printf("with NULL param should have failed!\n");
77                 return -1;
78         }
79
80         ret = rte_flow_classify_table_entry_delete(NULL, NULL);
81         if (!ret) {
82                 printf("Line %i: rte_flow_classify_table_entry_delete",
83                         __LINE__);
84                 printf("with NULL param should have failed!\n");
85                 return -1;
86         }
87
88         ret = rte_flow_classifier_query(NULL, NULL, 0, NULL, NULL);
89         if (!ret) {
90                 printf("Line %i: flow_classifier_query", __LINE__);
91                 printf(" with NULL param should have failed!\n");
92                 return -1;
93         }
94         return 0;
95 }
96
97 static int
98 test_valid_parameters(void)
99 {
100         struct rte_flow_classify_rule *rule;
101         int ret;
102         int key_found;
103
104         /*
105          * set up parameters for rte_flow_classify_validate,
106          * rte_flow_classify_table_entry_add and
107          * rte_flow_classify_table_entry_delete
108          */
109
110         attr.ingress = 1;
111         attr.priority = 1;
112         pattern[0] = eth_item;
113         pattern[1] = ipv4_udp_item_1;
114         pattern[2] = udp_item_1;
115         pattern[3] = end_item;
116         actions[0] = count_action;
117         actions[1] = end_action;
118
119         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
120                         actions, &error);
121         if (ret) {
122                 printf("Line %i: rte_flow_classify_validate",
123                         __LINE__);
124                 printf(" should not have failed!\n");
125                 return -1;
126         }
127         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
128                         actions, &key_found, &error);
129
130         if (!rule) {
131                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
132                 printf(" should not have failed!\n");
133                 return -1;
134         }
135
136         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
137         if (ret) {
138                 printf("Line %i: rte_flow_classify_table_entry_delete",
139                         __LINE__);
140                 printf(" should not have failed!\n");
141                 return -1;
142         }
143         return 0;
144 }
145
146 static int
147 test_invalid_patterns(void)
148 {
149         struct rte_flow_classify_rule *rule;
150         int ret;
151         int key_found;
152
153         /*
154          * set up parameters for rte_flow_classify_validate,
155          * rte_flow_classify_table_entry_add and
156          * rte_flow_classify_table_entry_delete
157          */
158
159         attr.ingress = 1;
160         attr.priority = 1;
161         pattern[0] = eth_item_bad;
162         pattern[1] = ipv4_udp_item_1;
163         pattern[2] = udp_item_1;
164         pattern[3] = end_item;
165         actions[0] = count_action;
166         actions[1] = end_action;
167
168         pattern[0] = eth_item;
169         pattern[1] = ipv4_udp_item_bad;
170
171         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
172                         actions, &error);
173         if (!ret) {
174                 printf("Line %i: rte_flow_classify_validate", __LINE__);
175                 printf(" should have failed!\n");
176                 return -1;
177         }
178
179         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
180                         actions, &key_found, &error);
181         if (rule) {
182                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
183                 printf(" should have failed!\n");
184                 return -1;
185         }
186
187         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
188         if (!ret) {
189                 printf("Line %i: rte_flow_classify_table_entry_delete",
190                         __LINE__);
191                 printf(" should have failed!\n");
192                 return -1;
193         }
194
195         pattern[1] = ipv4_udp_item_1;
196         pattern[2] = udp_item_bad;
197         pattern[3] = end_item_bad;
198
199         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
200                         actions, &error);
201         if (!ret) {
202                 printf("Line %i: rte_flow_classify_validate", __LINE__);
203                 printf(" should have failed!\n");
204                 return -1;
205         }
206
207         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
208                         actions, &key_found, &error);
209         if (rule) {
210                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
211                 printf(" should have failed!\n");
212                 return -1;
213         }
214
215         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
216         if (!ret) {
217                 printf("Line %i: rte_flow_classify_table_entry_delete",
218                         __LINE__);
219                 printf(" should have failed!\n");
220                 return -1;
221         }
222         return 0;
223 }
224
225 static int
226 test_invalid_actions(void)
227 {
228         struct rte_flow_classify_rule *rule;
229         int ret;
230         int key_found;
231
232         /*
233          * set up parameters for rte_flow_classify_validate,
234          * rte_flow_classify_table_entry_add and
235          * rte_flow_classify_table_entry_delete
236          */
237
238         attr.ingress = 1;
239         attr.priority = 1;
240         pattern[0] = eth_item;
241         pattern[1] = ipv4_udp_item_1;
242         pattern[2] = udp_item_1;
243         pattern[3] = end_item;
244         actions[0] = count_action_bad;
245         actions[1] = end_action;
246
247         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
248                         actions, &error);
249         if (!ret) {
250                 printf("Line %i: rte_flow_classify_validate", __LINE__);
251                 printf(" should have failed!\n");
252                 return -1;
253         }
254
255         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
256                         actions, &key_found, &error);
257         if (rule) {
258                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
259                 printf(" should have failed!\n");
260                 return -1;
261         }
262
263         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
264         if (!ret) {
265                 printf("Line %i: rte_flow_classify_table_entry_delete",
266                         __LINE__);
267                 printf(" should have failed!\n");
268                 return -1;
269         }
270
271         actions[0] = count_action;
272         actions[1] = end_action_bad;
273
274         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
275                         actions, &error);
276         if (!ret) {
277                 printf("Line %i: rte_flow_classify_validate", __LINE__);
278                 printf(" should have failed!\n");
279                 return -1;
280         }
281
282         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
283                         actions, &key_found, &error);
284         if (rule) {
285                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
286                 printf(" should have failed!\n");
287                 return -1;
288         }
289
290         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
291         if (!ret) {
292                 printf("Line %i: rte_flow_classify_table_entry_delete",
293                         __LINE__);
294                 printf("should have failed!\n");
295                 return -1;
296         }
297         return 0;
298 }
299
300 static int
301 init_ipv4_udp_traffic(struct rte_mempool *mp,
302              struct rte_mbuf **pkts_burst, uint32_t burst_size)
303 {
304         struct ether_hdr pkt_eth_hdr;
305         struct ipv4_hdr pkt_ipv4_hdr;
306         struct udp_hdr pkt_udp_hdr;
307         uint32_t src_addr = IPV4_ADDR(2, 2, 2, 3);
308         uint32_t dst_addr = IPV4_ADDR(2, 2, 2, 7);
309         uint16_t src_port = 32;
310         uint16_t dst_port = 33;
311         uint16_t pktlen;
312
313         static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
314         static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
315
316         printf("Set up IPv4 UDP traffic\n");
317         initialize_eth_header(&pkt_eth_hdr,
318                 (struct ether_addr *)src_mac,
319                 (struct ether_addr *)dst_mac, ETHER_TYPE_IPv4, 0, 0);
320         pktlen = (uint16_t)(sizeof(struct ether_hdr));
321         printf("ETH  pktlen %u\n", pktlen);
322
323         pktlen = initialize_ipv4_header(&pkt_ipv4_hdr, src_addr, dst_addr,
324                                         pktlen);
325         printf("ETH + IPv4 pktlen %u\n", pktlen);
326
327         pktlen = initialize_udp_header(&pkt_udp_hdr, src_port, dst_port,
328                                         pktlen);
329         printf("ETH + IPv4 + UDP pktlen %u\n\n", pktlen);
330
331         return generate_packet_burst(mp, pkts_burst, &pkt_eth_hdr,
332                                      0, &pkt_ipv4_hdr, 1,
333                                      &pkt_udp_hdr, burst_size,
334                                      PACKET_BURST_GEN_PKT_LEN, 1);
335 }
336
337 static int
338 init_ipv4_tcp_traffic(struct rte_mempool *mp,
339              struct rte_mbuf **pkts_burst, uint32_t burst_size)
340 {
341         struct ether_hdr pkt_eth_hdr;
342         struct ipv4_hdr pkt_ipv4_hdr;
343         struct tcp_hdr pkt_tcp_hdr;
344         uint32_t src_addr = IPV4_ADDR(1, 2, 3, 4);
345         uint32_t dst_addr = IPV4_ADDR(5, 6, 7, 8);
346         uint16_t src_port = 16;
347         uint16_t dst_port = 17;
348         uint16_t pktlen;
349
350         static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
351         static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
352
353         printf("Set up IPv4 TCP traffic\n");
354         initialize_eth_header(&pkt_eth_hdr,
355                 (struct ether_addr *)src_mac,
356                 (struct ether_addr *)dst_mac, ETHER_TYPE_IPv4, 0, 0);
357         pktlen = (uint16_t)(sizeof(struct ether_hdr));
358         printf("ETH  pktlen %u\n", pktlen);
359
360         pktlen = initialize_ipv4_header_proto(&pkt_ipv4_hdr, src_addr,
361                                         dst_addr, pktlen, IPPROTO_TCP);
362         printf("ETH + IPv4 pktlen %u\n", pktlen);
363
364         pktlen = initialize_tcp_header(&pkt_tcp_hdr, src_port, dst_port,
365                                         pktlen);
366         printf("ETH + IPv4 + TCP pktlen %u\n\n", pktlen);
367
368         return generate_packet_burst_proto(mp, pkts_burst, &pkt_eth_hdr,
369                                         0, &pkt_ipv4_hdr, 1, IPPROTO_TCP,
370                                         &pkt_tcp_hdr, burst_size,
371                                         PACKET_BURST_GEN_PKT_LEN, 1);
372 }
373
374 static int
375 init_ipv4_sctp_traffic(struct rte_mempool *mp,
376              struct rte_mbuf **pkts_burst, uint32_t burst_size)
377 {
378         struct ether_hdr pkt_eth_hdr;
379         struct ipv4_hdr pkt_ipv4_hdr;
380         struct sctp_hdr pkt_sctp_hdr;
381         uint32_t src_addr = IPV4_ADDR(11, 12, 13, 14);
382         uint32_t dst_addr = IPV4_ADDR(15, 16, 17, 18);
383         uint16_t src_port = 10;
384         uint16_t dst_port = 11;
385         uint16_t pktlen;
386
387         static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
388         static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
389
390         printf("Set up IPv4 SCTP traffic\n");
391         initialize_eth_header(&pkt_eth_hdr,
392                 (struct ether_addr *)src_mac,
393                 (struct ether_addr *)dst_mac, ETHER_TYPE_IPv4, 0, 0);
394         pktlen = (uint16_t)(sizeof(struct ether_hdr));
395         printf("ETH  pktlen %u\n", pktlen);
396
397         pktlen = initialize_ipv4_header_proto(&pkt_ipv4_hdr, src_addr,
398                                         dst_addr, pktlen, IPPROTO_SCTP);
399         printf("ETH + IPv4 pktlen %u\n", pktlen);
400
401         pktlen = initialize_sctp_header(&pkt_sctp_hdr, src_port, dst_port,
402                                         pktlen);
403         printf("ETH + IPv4 + SCTP pktlen %u\n\n", pktlen);
404
405         return generate_packet_burst_proto(mp, pkts_burst, &pkt_eth_hdr,
406                                         0, &pkt_ipv4_hdr, 1, IPPROTO_SCTP,
407                                         &pkt_sctp_hdr, burst_size,
408                                         PACKET_BURST_GEN_PKT_LEN, 1);
409 }
410
411 static int
412 init_mbufpool(void)
413 {
414         int socketid;
415         int ret = 0;
416         unsigned int lcore_id;
417         char s[64];
418
419         for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
420                 if (rte_lcore_is_enabled(lcore_id) == 0)
421                         continue;
422
423                 socketid = rte_lcore_to_socket_id(lcore_id);
424                 if (socketid >= NB_SOCKETS) {
425                         printf(
426                                 "Socket %d of lcore %u is out of range %d\n",
427                                 socketid, lcore_id, NB_SOCKETS);
428                         ret = -1;
429                         break;
430                 }
431                 if (mbufpool[socketid] == NULL) {
432                         snprintf(s, sizeof(s), "mbuf_pool_%d", socketid);
433                         mbufpool[socketid] =
434                                 rte_pktmbuf_pool_create(s, NB_MBUF,
435                                         MEMPOOL_CACHE_SIZE, 0, MBUF_SIZE,
436                                         socketid);
437                         if (mbufpool[socketid]) {
438                                 printf("Allocated mbuf pool on socket %d\n",
439                                         socketid);
440                         } else {
441                                 printf("Cannot init mbuf pool on socket %d\n",
442                                         socketid);
443                                 ret = -ENOMEM;
444                                 break;
445                         }
446                 }
447         }
448         return ret;
449 }
450
451 static int
452 test_query_udp(void)
453 {
454         struct rte_flow_error error;
455         struct rte_flow_classify_rule *rule;
456         int ret;
457         int i;
458         int key_found;
459
460         ret = init_ipv4_udp_traffic(mbufpool[0], bufs, MAX_PKT_BURST);
461         if (ret != MAX_PKT_BURST) {
462                 printf("Line %i: init_udp_ipv4_traffic has failed!\n",
463                                 __LINE__);
464                 return -1;
465         }
466
467         for (i = 0; i < MAX_PKT_BURST; i++)
468                 bufs[i]->packet_type = RTE_PTYPE_L3_IPV4;
469
470         /*
471          * set up parameters for rte_flow_classify_validate,
472          * rte_flow_classify_table_entry_add and
473          * rte_flow_classify_table_entry_delete
474          */
475
476         attr.ingress = 1;
477         attr.priority = 1;
478         pattern[0] = eth_item;
479         pattern[1] = ipv4_udp_item_1;
480         pattern[2] = udp_item_1;
481         pattern[3] = end_item;
482         actions[0] = count_action;
483         actions[1] = end_action;
484
485         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
486                         actions, &error);
487         if (ret) {
488                 printf("Line %i: rte_flow_classify_validate", __LINE__);
489                 printf(" should not have failed!\n");
490                 return -1;
491         }
492
493         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
494                         actions, &key_found, &error);
495         if (!rule) {
496                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
497                 printf(" should not have failed!\n");
498                 return -1;
499         }
500
501         ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST,
502                         rule, &udp_classify_stats);
503         if (ret) {
504                 printf("Line %i: flow_classifier_query", __LINE__);
505                 printf(" should not have failed!\n");
506                 return -1;
507         }
508
509         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
510         if (ret) {
511                 printf("Line %i: rte_flow_classify_table_entry_delete",
512                         __LINE__);
513                 printf(" should not have failed!\n");
514                 return -1;
515         }
516         return 0;
517 }
518
519 static int
520 test_query_tcp(void)
521 {
522         struct rte_flow_classify_rule *rule;
523         int ret;
524         int i;
525         int key_found;
526
527         ret = init_ipv4_tcp_traffic(mbufpool[0], bufs, MAX_PKT_BURST);
528         if (ret != MAX_PKT_BURST) {
529                 printf("Line %i: init_ipv4_tcp_traffic has failed!\n",
530                                 __LINE__);
531                 return -1;
532         }
533
534         for (i = 0; i < MAX_PKT_BURST; i++)
535                 bufs[i]->packet_type = RTE_PTYPE_L3_IPV4;
536
537         /*
538          * set up parameters for rte_flow_classify_validate,
539          * rte_flow_classify_table_entry_add and
540          * rte_flow_classify_table_entry_delete
541          */
542
543         attr.ingress = 1;
544         attr.priority = 1;
545         pattern[0] = eth_item;
546         pattern[1] = ipv4_tcp_item_1;
547         pattern[2] = tcp_item_1;
548         pattern[3] = end_item;
549         actions[0] = count_action;
550         actions[1] = end_action;
551
552         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
553                         actions, &error);
554         if (ret) {
555                 printf("Line %i: flow_classifier_query", __LINE__);
556                 printf(" should not have failed!\n");
557                 return -1;
558         }
559
560         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
561                         actions, &key_found, &error);
562         if (!rule) {
563                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
564                 printf(" should not have failed!\n");
565                 return -1;
566         }
567
568         ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST,
569                         rule, &tcp_classify_stats);
570         if (ret) {
571                 printf("Line %i: flow_classifier_query", __LINE__);
572                 printf(" should not have failed!\n");
573                 return -1;
574         }
575
576         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
577         if (ret) {
578                 printf("Line %i: rte_flow_classify_table_entry_delete",
579                         __LINE__);
580                 printf(" should not have failed!\n");
581                 return -1;
582         }
583         return 0;
584 }
585
586 static int
587 test_query_sctp(void)
588 {
589         struct rte_flow_classify_rule *rule;
590         int ret;
591         int i;
592         int key_found;
593
594         ret = init_ipv4_sctp_traffic(mbufpool[0], bufs, MAX_PKT_BURST);
595         if (ret != MAX_PKT_BURST) {
596                 printf("Line %i: init_ipv4_tcp_traffic has failed!\n",
597                         __LINE__);
598                 return -1;
599         }
600
601         for (i = 0; i < MAX_PKT_BURST; i++)
602                 bufs[i]->packet_type = RTE_PTYPE_L3_IPV4;
603
604         /*
605          * set up parameters rte_flow_classify_validate,
606          * rte_flow_classify_table_entry_add and
607          * rte_flow_classify_table_entry_delete
608          */
609
610         attr.ingress = 1;
611         attr.priority = 1;
612         pattern[0] = eth_item;
613         pattern[1] = ipv4_sctp_item_1;
614         pattern[2] = sctp_item_1;
615         pattern[3] = end_item;
616         actions[0] = count_action;
617         actions[1] = end_action;
618
619         ret = rte_flow_classify_validate(cls->cls, &attr, pattern,
620                         actions, &error);
621         if (ret) {
622                 printf("Line %i: flow_classifier_query", __LINE__);
623                 printf(" should not have failed!\n");
624                 return -1;
625         }
626
627         rule = rte_flow_classify_table_entry_add(cls->cls, &attr, pattern,
628                         actions, &key_found, &error);
629         if (!rule) {
630                 printf("Line %i: flow_classify_table_entry_add", __LINE__);
631                 printf(" should not have failed!\n");
632                 return -1;
633         }
634
635         ret = rte_flow_classifier_query(cls->cls, bufs, MAX_PKT_BURST,
636                         rule, &sctp_classify_stats);
637         if (ret) {
638                 printf("Line %i: flow_classifier_query", __LINE__);
639                 printf(" should not have failed!\n");
640                 return -1;
641         }
642
643         ret = rte_flow_classify_table_entry_delete(cls->cls, rule);
644         if (ret) {
645                 printf("Line %i: rte_flow_classify_table_entry_delete",
646                         __LINE__);
647                 printf(" should not have failed!\n");
648                 return -1;
649         }
650         return 0;
651 }
652
653 static int
654 test_flow_classify(void)
655 {
656         struct rte_table_acl_params table_acl_params;
657         struct rte_flow_classify_table_params cls_table_params;
658         struct rte_flow_classifier_params cls_params;
659         int socket_id;
660         int ret;
661         uint32_t size;
662
663         socket_id = rte_eth_dev_socket_id(0);
664
665         /* Memory allocation */
666         size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct flow_classifier_acl));
667         cls = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
668
669         cls_params.name = "flow_classifier";
670         cls_params.socket_id = socket_id;
671         cls->cls = rte_flow_classifier_create(&cls_params);
672
673         /* initialise ACL table params */
674         table_acl_params.n_rule_fields = RTE_DIM(ipv4_defs);
675         table_acl_params.name = "table_acl_ipv4_5tuple";
676         table_acl_params.n_rules = FLOW_CLASSIFY_MAX_RULE_NUM;
677         memcpy(table_acl_params.field_format, ipv4_defs, sizeof(ipv4_defs));
678
679         /* initialise table create params */
680         cls_table_params.ops = &rte_table_acl_ops;
681         cls_table_params.arg_create = &table_acl_params;
682         cls_table_params.type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE;
683
684         ret = rte_flow_classify_table_create(cls->cls, &cls_table_params);
685         if (ret) {
686                 printf("Line %i: f_create has failed!\n", __LINE__);
687                 rte_flow_classifier_free(cls->cls);
688                 rte_free(cls);
689                 return -1;
690         }
691         printf("Created table_acl for for IPv4 five tuple packets\n");
692
693         ret = init_mbufpool();
694         if (ret) {
695                 printf("Line %i: init_mbufpool has failed!\n", __LINE__);
696                 return -1;
697         }
698
699         if (test_invalid_parameters() < 0)
700                 return -1;
701         if (test_valid_parameters() < 0)
702                 return -1;
703         if (test_invalid_patterns() < 0)
704                 return -1;
705         if (test_invalid_actions() < 0)
706                 return -1;
707         if (test_query_udp() < 0)
708                 return -1;
709         if (test_query_tcp() < 0)
710                 return -1;
711         if (test_query_sctp() < 0)
712                 return -1;
713
714         return 0;
715 }
716
717 REGISTER_TEST_COMMAND(flow_classify_autotest, test_flow_classify);