4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
36 #include <sys/queue.h>
37 #include <netinet/in.h>
39 #include <rte_common.h>
40 #include <rte_hexdump.h>
41 #include <rte_malloc.h>
42 #include <cmdline_rdline.h>
43 #include <cmdline_parse.h>
44 #include <cmdline_parse_num.h>
45 #include <cmdline_parse_string.h>
46 #include <cmdline_parse_ipaddr.h>
47 #include <cmdline_parse_etheraddr.h>
50 #include "pipeline_common_fe.h"
51 #include "pipeline_flow_classification.h"
52 #include "hash_func.h"
59 uint16_t ethertype_svlan;
61 uint16_t ethertype_cvlan;
63 } __attribute__((__packed__));
65 struct pkt_key_ipv4_5tuple {
73 } __attribute__((__packed__));
75 struct pkt_key_ipv6_5tuple {
76 uint16_t payload_length;
83 } __attribute__((__packed__));
86 app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in,
90 uint8_t buffer[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
91 void *key_buffer = (key_out) ? key_out : buffer;
93 switch (key_in->type) {
96 struct pkt_key_qinq *qinq = key_buffer;
98 qinq->ethertype_svlan = 0;
99 qinq->svlan = rte_bswap16(key_in->key.qinq.svlan);
100 qinq->ethertype_cvlan = 0;
101 qinq->cvlan = rte_bswap16(key_in->key.qinq.cvlan);
104 *signature = (uint32_t) hash_default_key8(qinq, 8, 0);
108 case FLOW_KEY_IPV4_5TUPLE:
110 struct pkt_key_ipv4_5tuple *ipv4 = key_buffer;
113 ipv4->proto = key_in->key.ipv4_5tuple.proto;
115 ipv4->ip_src = rte_bswap32(key_in->key.ipv4_5tuple.ip_src);
116 ipv4->ip_dst = rte_bswap32(key_in->key.ipv4_5tuple.ip_dst);
117 ipv4->port_src = rte_bswap16(key_in->key.ipv4_5tuple.port_src);
118 ipv4->port_dst = rte_bswap16(key_in->key.ipv4_5tuple.port_dst);
121 *signature = (uint32_t) hash_default_key16(ipv4, 16, 0);
125 case FLOW_KEY_IPV6_5TUPLE:
127 struct pkt_key_ipv6_5tuple *ipv6 = key_buffer;
130 ipv6->payload_length = 0;
131 ipv6->proto = key_in->key.ipv6_5tuple.proto;
133 memcpy(&ipv6->ip_src, &key_in->key.ipv6_5tuple.ip_src, 16);
134 memcpy(&ipv6->ip_dst, &key_in->key.ipv6_5tuple.ip_dst, 16);
135 ipv6->port_src = rte_bswap16(key_in->key.ipv6_5tuple.port_src);
136 ipv6->port_dst = rte_bswap16(key_in->key.ipv6_5tuple.port_dst);
139 *signature = (uint32_t) hash_default_key64(ipv6, 64, 0);
149 * Flow classification pipeline
152 struct app_pipeline_fc_flow {
153 struct pipeline_fc_key key;
158 TAILQ_ENTRY(app_pipeline_fc_flow) node;
161 #define N_BUCKETS 65536
163 struct app_pipeline_fc {
166 uint32_t n_ports_out;
169 TAILQ_HEAD(, app_pipeline_fc_flow) flows[N_BUCKETS];
173 uint32_t default_flow_present;
174 uint32_t default_flow_port_id;
175 void *default_flow_entry_ptr;
178 static struct app_pipeline_fc_flow *
179 app_pipeline_fc_flow_find(struct app_pipeline_fc *p,
180 struct pipeline_fc_key *key)
182 struct app_pipeline_fc_flow *f;
183 uint32_t signature, bucket_id;
185 app_pipeline_fc_key_convert(key, NULL, &signature);
186 bucket_id = signature & (N_BUCKETS - 1);
188 TAILQ_FOREACH(f, &p->flows[bucket_id], node)
189 if ((signature == f->signature) &&
192 sizeof(struct pipeline_fc_key)) == 0))
199 app_pipeline_fc_init(struct pipeline_params *params,
200 __rte_unused void *arg)
202 struct app_pipeline_fc *p;
205 /* Check input arguments */
206 if ((params == NULL) ||
207 (params->n_ports_in == 0) ||
208 (params->n_ports_out == 0))
211 /* Memory allocation */
212 size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct app_pipeline_fc));
213 p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
218 p->n_ports_in = params->n_ports_in;
219 p->n_ports_out = params->n_ports_out;
221 for (i = 0; i < N_BUCKETS; i++)
222 TAILQ_INIT(&p->flows[i]);
229 app_pipeline_fc_free(void *pipeline)
231 struct app_pipeline_fc *p = pipeline;
234 /* Check input arguments */
239 for (i = 0; i < N_BUCKETS; i++)
240 while (!TAILQ_EMPTY(&p->flows[i])) {
241 struct app_pipeline_fc_flow *flow;
243 flow = TAILQ_FIRST(&p->flows[i]);
244 TAILQ_REMOVE(&p->flows[i], flow, node);
253 app_pipeline_fc_key_check(struct pipeline_fc_key *key)
258 uint16_t svlan = key->key.qinq.svlan;
259 uint16_t cvlan = key->key.qinq.cvlan;
261 if ((svlan & 0xF000) ||
268 case FLOW_KEY_IPV4_5TUPLE:
271 case FLOW_KEY_IPV6_5TUPLE:
280 app_pipeline_fc_add(struct app_params *app,
281 uint32_t pipeline_id,
282 struct pipeline_fc_key *key,
285 struct app_pipeline_fc *p;
286 struct app_pipeline_fc_flow *flow;
288 struct pipeline_fc_add_msg_req *req;
289 struct pipeline_fc_add_msg_rsp *rsp;
294 /* Check input arguments */
299 p = app_pipeline_data_fe(app, pipeline_id);
303 if (port_id >= p->n_ports_out)
306 if (app_pipeline_fc_key_check(key) != 0)
309 /* Find existing flow or allocate new flow */
310 flow = app_pipeline_fc_flow_find(p, key);
311 new_flow = (flow == NULL);
313 flow = rte_malloc(NULL, sizeof(*flow), RTE_CACHE_LINE_SIZE);
319 /* Allocate and write request */
320 req = app_msg_alloc(app);
324 req->type = PIPELINE_MSG_REQ_CUSTOM;
325 req->subtype = PIPELINE_FC_MSG_REQ_FLOW_ADD;
326 app_pipeline_fc_key_convert(key, req->key, &signature);
327 req->port_id = port_id;
329 /* Send request and wait for response */
330 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
337 /* Read response and write flow */
339 (rsp->entry_ptr == NULL) ||
340 ((new_flow == 0) && (rsp->key_found == 0)) ||
341 ((new_flow == 1) && (rsp->key_found == 1))) {
342 app_msg_free(app, rsp);
348 memset(&flow->key, 0, sizeof(flow->key));
349 memcpy(&flow->key, key, sizeof(flow->key));
350 flow->port_id = port_id;
351 flow->signature = signature;
352 flow->entry_ptr = rsp->entry_ptr;
356 uint32_t bucket_id = signature & (N_BUCKETS - 1);
358 TAILQ_INSERT_TAIL(&p->flows[bucket_id], flow, node);
363 app_msg_free(app, rsp);
369 app_pipeline_fc_add_bulk(struct app_params *app,
370 uint32_t pipeline_id,
371 struct pipeline_fc_key *key,
375 struct app_pipeline_fc *p;
376 struct pipeline_fc_add_bulk_msg_req *req;
377 struct pipeline_fc_add_bulk_msg_rsp *rsp;
379 struct app_pipeline_fc_flow **flow;
382 struct pipeline_fc_add_bulk_flow_req *flow_req;
383 struct pipeline_fc_add_bulk_flow_rsp *flow_rsp;
388 /* Check input arguments */
395 p = app_pipeline_data_fe(app, pipeline_id);
399 for (i = 0; i < n_keys; i++)
400 if (port_id[i] >= p->n_ports_out)
403 for (i = 0; i < n_keys; i++)
404 if (app_pipeline_fc_key_check(&key[i]) != 0)
407 /* Memory allocation */
408 flow = rte_malloc(NULL,
409 n_keys * sizeof(struct app_pipeline_fc_flow *),
410 RTE_CACHE_LINE_SIZE);
414 signature = rte_malloc(NULL,
415 n_keys * sizeof(uint32_t),
416 RTE_CACHE_LINE_SIZE);
417 if (signature == NULL) {
422 new_flow = rte_malloc(
424 n_keys * sizeof(int),
425 RTE_CACHE_LINE_SIZE);
426 if (new_flow == NULL) {
432 flow_req = rte_malloc(NULL,
433 n_keys * sizeof(struct pipeline_fc_add_bulk_flow_req),
434 RTE_CACHE_LINE_SIZE);
435 if (flow_req == NULL) {
442 flow_rsp = rte_malloc(NULL,
443 n_keys * sizeof(struct pipeline_fc_add_bulk_flow_rsp),
444 RTE_CACHE_LINE_SIZE);
445 if (flow_req == NULL) {
453 /* Find existing flow or allocate new flow */
454 for (i = 0; i < n_keys; i++) {
455 flow[i] = app_pipeline_fc_flow_find(p, &key[i]);
456 new_flow[i] = (flow[i] == NULL);
457 if (flow[i] == NULL) {
458 flow[i] = rte_zmalloc(NULL,
459 sizeof(struct app_pipeline_fc_flow),
460 RTE_CACHE_LINE_SIZE);
462 if (flow[i] == NULL) {
465 for (j = 0; j < i; j++)
479 /* Allocate and write request */
480 req = app_msg_alloc(app);
482 for (i = 0; i < n_keys; i++)
494 for (i = 0; i < n_keys; i++) {
495 app_pipeline_fc_key_convert(&key[i],
498 flow_req[i].port_id = port_id[i];
501 req->type = PIPELINE_MSG_REQ_CUSTOM;
502 req->subtype = PIPELINE_FC_MSG_REQ_FLOW_ADD_BULK;
505 req->n_keys = n_keys;
507 /* Send request and wait for response */
508 rsp = app_msg_send_recv(app, pipeline_id, req, 10000);
510 for (i = 0; i < n_keys; i++)
525 for (i = 0; i < rsp->n_keys; i++)
526 if ((flow_rsp[i].entry_ptr == NULL) ||
527 ((new_flow[i] == 0) && (flow_rsp[i].key_found == 0)) ||
528 ((new_flow[i] == 1) && (flow_rsp[i].key_found == 1)))
531 if (rsp->n_keys < n_keys)
535 for (i = 0; i < rsp->n_keys; i++) {
536 memcpy(&flow[i]->key, &key[i], sizeof(flow[i]->key));
537 flow[i]->port_id = port_id[i];
538 flow[i]->signature = signature[i];
539 flow[i]->entry_ptr = flow_rsp[i].entry_ptr;
542 uint32_t bucket_id = signature[i] & (N_BUCKETS - 1);
544 TAILQ_INSERT_TAIL(&p->flows[bucket_id], flow[i], node);
550 app_msg_free(app, rsp);
552 for (i = rsp->n_keys; i < n_keys; i++)
566 app_pipeline_fc_del(struct app_params *app,
567 uint32_t pipeline_id,
568 struct pipeline_fc_key *key)
570 struct app_pipeline_fc *p;
571 struct app_pipeline_fc_flow *flow;
573 struct pipeline_fc_del_msg_req *req;
574 struct pipeline_fc_del_msg_rsp *rsp;
576 uint32_t signature, bucket_id;
578 /* Check input arguments */
583 p = app_pipeline_data_fe(app, pipeline_id);
587 if (app_pipeline_fc_key_check(key) != 0)
591 flow = app_pipeline_fc_flow_find(p, key);
595 /* Allocate and write request */
596 req = app_msg_alloc(app);
600 req->type = PIPELINE_MSG_REQ_CUSTOM;
601 req->subtype = PIPELINE_FC_MSG_REQ_FLOW_DEL;
602 app_pipeline_fc_key_convert(key, req->key, &signature);
604 /* Send request and wait for response */
605 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
610 if (rsp->status || !rsp->key_found) {
611 app_msg_free(app, rsp);
616 bucket_id = signature & (N_BUCKETS - 1);
617 TAILQ_REMOVE(&p->flows[bucket_id], flow, node);
622 app_msg_free(app, rsp);
628 app_pipeline_fc_add_default(struct app_params *app,
629 uint32_t pipeline_id,
632 struct app_pipeline_fc *p;
634 struct pipeline_fc_add_default_msg_req *req;
635 struct pipeline_fc_add_default_msg_rsp *rsp;
637 /* Check input arguments */
641 p = app_pipeline_data_fe(app, pipeline_id);
645 if (port_id >= p->n_ports_out)
648 /* Allocate and write request */
649 req = app_msg_alloc(app);
653 req->type = PIPELINE_MSG_REQ_CUSTOM;
654 req->subtype = PIPELINE_FC_MSG_REQ_FLOW_ADD_DEFAULT;
655 req->port_id = port_id;
657 /* Send request and wait for response */
658 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
662 /* Read response and write flow */
663 if (rsp->status || (rsp->entry_ptr == NULL)) {
664 app_msg_free(app, rsp);
668 p->default_flow_port_id = port_id;
669 p->default_flow_entry_ptr = rsp->entry_ptr;
672 p->default_flow_present = 1;
675 app_msg_free(app, rsp);
681 app_pipeline_fc_del_default(struct app_params *app,
682 uint32_t pipeline_id)
684 struct app_pipeline_fc *p;
686 struct pipeline_fc_del_default_msg_req *req;
687 struct pipeline_fc_del_default_msg_rsp *rsp;
689 /* Check input arguments */
693 p = app_pipeline_data_fe(app, pipeline_id);
697 /* Allocate and write request */
698 req = app_msg_alloc(app);
702 req->type = PIPELINE_MSG_REQ_CUSTOM;
703 req->subtype = PIPELINE_FC_MSG_REQ_FLOW_DEL_DEFAULT;
705 /* Send request and wait for response */
706 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
712 app_msg_free(app, rsp);
717 p->default_flow_present = 0;
720 app_msg_free(app, rsp);
730 print_fc_qinq_flow(struct app_pipeline_fc_flow *flow)
732 printf("(SVLAN = %" PRIu32 ", "
733 "CVLAN = %" PRIu32 ") => "
734 "Port = %" PRIu32 " "
735 "(signature = 0x%08" PRIx32 ", "
738 flow->key.key.qinq.svlan,
739 flow->key.key.qinq.cvlan,
746 print_fc_ipv4_5tuple_flow(struct app_pipeline_fc_flow *flow)
748 printf("(SA = %" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32 ", "
749 "DA = %" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32 ", "
752 "Proto = %" PRIu32 ") => "
753 "Port = %" PRIu32 " "
754 "(signature = 0x%08" PRIx32 ", "
757 (flow->key.key.ipv4_5tuple.ip_src >> 24) & 0xFF,
758 (flow->key.key.ipv4_5tuple.ip_src >> 16) & 0xFF,
759 (flow->key.key.ipv4_5tuple.ip_src >> 8) & 0xFF,
760 flow->key.key.ipv4_5tuple.ip_src & 0xFF,
762 (flow->key.key.ipv4_5tuple.ip_dst >> 24) & 0xFF,
763 (flow->key.key.ipv4_5tuple.ip_dst >> 16) & 0xFF,
764 (flow->key.key.ipv4_5tuple.ip_dst >> 8) & 0xFF,
765 flow->key.key.ipv4_5tuple.ip_dst & 0xFF,
767 flow->key.key.ipv4_5tuple.port_src,
768 flow->key.key.ipv4_5tuple.port_dst,
770 flow->key.key.ipv4_5tuple.proto,
778 print_fc_ipv6_5tuple_flow(struct app_pipeline_fc_flow *flow) {
779 printf("(SA = %02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
780 ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
781 ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
782 ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32 ", "
783 "DA = %02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
784 ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
785 ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
786 ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32 ", "
789 "Proto = %" PRIu32 " "
790 "=> Port = %" PRIu32 " "
791 "(signature = 0x%08" PRIx32 ", "
794 flow->key.key.ipv6_5tuple.ip_src[0],
795 flow->key.key.ipv6_5tuple.ip_src[1],
796 flow->key.key.ipv6_5tuple.ip_src[2],
797 flow->key.key.ipv6_5tuple.ip_src[3],
798 flow->key.key.ipv6_5tuple.ip_src[4],
799 flow->key.key.ipv6_5tuple.ip_src[5],
800 flow->key.key.ipv6_5tuple.ip_src[6],
801 flow->key.key.ipv6_5tuple.ip_src[7],
802 flow->key.key.ipv6_5tuple.ip_src[8],
803 flow->key.key.ipv6_5tuple.ip_src[9],
804 flow->key.key.ipv6_5tuple.ip_src[10],
805 flow->key.key.ipv6_5tuple.ip_src[11],
806 flow->key.key.ipv6_5tuple.ip_src[12],
807 flow->key.key.ipv6_5tuple.ip_src[13],
808 flow->key.key.ipv6_5tuple.ip_src[14],
809 flow->key.key.ipv6_5tuple.ip_src[15],
811 flow->key.key.ipv6_5tuple.ip_dst[0],
812 flow->key.key.ipv6_5tuple.ip_dst[1],
813 flow->key.key.ipv6_5tuple.ip_dst[2],
814 flow->key.key.ipv6_5tuple.ip_dst[3],
815 flow->key.key.ipv6_5tuple.ip_dst[4],
816 flow->key.key.ipv6_5tuple.ip_dst[5],
817 flow->key.key.ipv6_5tuple.ip_dst[6],
818 flow->key.key.ipv6_5tuple.ip_dst[7],
819 flow->key.key.ipv6_5tuple.ip_dst[8],
820 flow->key.key.ipv6_5tuple.ip_dst[9],
821 flow->key.key.ipv6_5tuple.ip_dst[10],
822 flow->key.key.ipv6_5tuple.ip_dst[11],
823 flow->key.key.ipv6_5tuple.ip_dst[12],
824 flow->key.key.ipv6_5tuple.ip_dst[13],
825 flow->key.key.ipv6_5tuple.ip_dst[14],
826 flow->key.key.ipv6_5tuple.ip_dst[15],
828 flow->key.key.ipv6_5tuple.port_src,
829 flow->key.key.ipv6_5tuple.port_dst,
831 flow->key.key.ipv6_5tuple.proto,
839 print_fc_flow(struct app_pipeline_fc_flow *flow)
841 switch (flow->key.type) {
843 print_fc_qinq_flow(flow);
846 case FLOW_KEY_IPV4_5TUPLE:
847 print_fc_ipv4_5tuple_flow(flow);
850 case FLOW_KEY_IPV6_5TUPLE:
851 print_fc_ipv6_5tuple_flow(flow);
857 app_pipeline_fc_ls(struct app_params *app,
858 uint32_t pipeline_id)
860 struct app_pipeline_fc *p;
861 struct app_pipeline_fc_flow *flow;
864 /* Check input arguments */
868 p = app_pipeline_data_fe(app, pipeline_id);
872 for (i = 0; i < N_BUCKETS; i++)
873 TAILQ_FOREACH(flow, &p->flows[i], node)
876 if (p->default_flow_present)
877 printf("Default flow: port %" PRIu32 " (entry ptr = %p)\n",
878 p->default_flow_port_id,
879 p->default_flow_entry_ptr);
881 printf("Default: DROP\n");
890 struct cmd_fc_add_qinq_result {
891 cmdline_fixed_string_t p_string;
892 uint32_t pipeline_id;
893 cmdline_fixed_string_t flow_string;
894 cmdline_fixed_string_t add_string;
895 cmdline_fixed_string_t qinq_string;
902 cmd_fc_add_qinq_parsed(
904 __rte_unused struct cmdline *cl,
907 struct cmd_fc_add_qinq_result *params = parsed_result;
908 struct app_params *app = data;
909 struct pipeline_fc_key key;
912 memset(&key, 0, sizeof(key));
913 key.type = FLOW_KEY_QINQ;
914 key.key.qinq.svlan = params->svlan;
915 key.key.qinq.cvlan = params->cvlan;
917 status = app_pipeline_fc_add(app,
922 printf("Command failed\n");
925 cmdline_parse_token_string_t cmd_fc_add_qinq_p_string =
926 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_result, p_string, "p");
928 cmdline_parse_token_num_t cmd_fc_add_qinq_pipeline_id =
929 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_qinq_result, pipeline_id,
932 cmdline_parse_token_string_t cmd_fc_add_qinq_flow_string =
933 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_result, flow_string,
936 cmdline_parse_token_string_t cmd_fc_add_qinq_add_string =
937 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_result, add_string,
940 cmdline_parse_token_string_t cmd_fc_add_qinq_qinq_string =
941 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_result, qinq_string,
944 cmdline_parse_token_num_t cmd_fc_add_qinq_svlan =
945 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_qinq_result, svlan, UINT16);
947 cmdline_parse_token_num_t cmd_fc_add_qinq_cvlan =
948 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_qinq_result, cvlan, UINT16);
950 cmdline_parse_token_num_t cmd_fc_add_qinq_port =
951 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_qinq_result, port, UINT32);
953 cmdline_parse_inst_t cmd_fc_add_qinq = {
954 .f = cmd_fc_add_qinq_parsed,
956 .help_str = "Flow add (Q-in-Q)",
958 (void *) &cmd_fc_add_qinq_p_string,
959 (void *) &cmd_fc_add_qinq_pipeline_id,
960 (void *) &cmd_fc_add_qinq_flow_string,
961 (void *) &cmd_fc_add_qinq_add_string,
962 (void *) &cmd_fc_add_qinq_qinq_string,
963 (void *) &cmd_fc_add_qinq_svlan,
964 (void *) &cmd_fc_add_qinq_cvlan,
965 (void *) &cmd_fc_add_qinq_port,
974 struct cmd_fc_add_qinq_all_result {
975 cmdline_fixed_string_t p_string;
976 uint32_t pipeline_id;
977 cmdline_fixed_string_t flow_string;
978 cmdline_fixed_string_t add_string;
979 cmdline_fixed_string_t qinq_string;
980 cmdline_fixed_string_t all_string;
986 #define N_FLOWS_BULK 4096
990 cmd_fc_add_qinq_all_parsed(
992 __rte_unused struct cmdline *cl,
995 struct cmd_fc_add_qinq_all_result *params = parsed_result;
996 struct app_params *app = data;
997 struct pipeline_fc_key *key;
1001 key = rte_zmalloc(NULL,
1002 N_FLOWS_BULK * sizeof(*key),
1003 RTE_CACHE_LINE_SIZE);
1005 printf("Memory allocation failed\n");
1009 port_id = rte_malloc(NULL,
1010 N_FLOWS_BULK * sizeof(*port_id),
1011 RTE_CACHE_LINE_SIZE);
1012 if (port_id == NULL) {
1014 printf("Memory allocation failed\n");
1018 for (flow_id = 0; flow_id < params->n_flows; flow_id++) {
1019 uint32_t pos = flow_id & (N_FLOWS_BULK - 1);
1021 key[pos].type = FLOW_KEY_QINQ;
1022 key[pos].key.qinq.svlan = flow_id >> 12;
1023 key[pos].key.qinq.cvlan = flow_id & 0xFFF;
1025 port_id[pos] = flow_id % params->n_ports;
1027 if ((pos == N_FLOWS_BULK - 1) ||
1028 (flow_id == params->n_flows - 1)) {
1031 status = app_pipeline_fc_add_bulk(app,
1032 params->pipeline_id,
1038 printf("Command failed\n");
1049 cmdline_parse_token_string_t cmd_fc_add_qinq_all_p_string =
1050 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_all_result, p_string,
1053 cmdline_parse_token_num_t cmd_fc_add_qinq_all_pipeline_id =
1054 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_qinq_all_result, pipeline_id,
1057 cmdline_parse_token_string_t cmd_fc_add_qinq_all_flow_string =
1058 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_all_result, flow_string,
1061 cmdline_parse_token_string_t cmd_fc_add_qinq_all_add_string =
1062 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_all_result, add_string,
1065 cmdline_parse_token_string_t cmd_fc_add_qinq_all_qinq_string =
1066 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_all_result, qinq_string,
1069 cmdline_parse_token_string_t cmd_fc_add_qinq_all_all_string =
1070 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_qinq_all_result, all_string,
1073 cmdline_parse_token_num_t cmd_fc_add_qinq_all_n_flows =
1074 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_qinq_all_result, n_flows,
1077 cmdline_parse_token_num_t cmd_fc_add_qinq_all_n_ports =
1078 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_qinq_all_result, n_ports,
1081 cmdline_parse_inst_t cmd_fc_add_qinq_all = {
1082 .f = cmd_fc_add_qinq_all_parsed,
1084 .help_str = "Flow add all (Q-in-Q)",
1086 (void *) &cmd_fc_add_qinq_all_p_string,
1087 (void *) &cmd_fc_add_qinq_all_pipeline_id,
1088 (void *) &cmd_fc_add_qinq_all_flow_string,
1089 (void *) &cmd_fc_add_qinq_all_add_string,
1090 (void *) &cmd_fc_add_qinq_all_qinq_string,
1091 (void *) &cmd_fc_add_qinq_all_all_string,
1092 (void *) &cmd_fc_add_qinq_all_n_flows,
1093 (void *) &cmd_fc_add_qinq_all_n_ports,
1099 * flow add ipv4_5tuple
1102 struct cmd_fc_add_ipv4_5tuple_result {
1103 cmdline_fixed_string_t p_string;
1104 uint32_t pipeline_id;
1105 cmdline_fixed_string_t flow_string;
1106 cmdline_fixed_string_t add_string;
1107 cmdline_fixed_string_t ipv4_5tuple_string;
1108 cmdline_ipaddr_t ip_src;
1109 cmdline_ipaddr_t ip_dst;
1117 cmd_fc_add_ipv4_5tuple_parsed(
1118 void *parsed_result,
1119 __rte_unused struct cmdline *cl,
1122 struct cmd_fc_add_ipv4_5tuple_result *params = parsed_result;
1123 struct app_params *app = data;
1124 struct pipeline_fc_key key;
1127 memset(&key, 0, sizeof(key));
1128 key.type = FLOW_KEY_IPV4_5TUPLE;
1129 key.key.ipv4_5tuple.ip_src = rte_bswap32(
1130 params->ip_src.addr.ipv4.s_addr);
1131 key.key.ipv4_5tuple.ip_dst = rte_bswap32(
1132 params->ip_dst.addr.ipv4.s_addr);
1133 key.key.ipv4_5tuple.port_src = params->port_src;
1134 key.key.ipv4_5tuple.port_dst = params->port_dst;
1135 key.key.ipv4_5tuple.proto = params->proto;
1137 status = app_pipeline_fc_add(app,
1138 params->pipeline_id,
1142 printf("Command failed\n");
1145 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_p_string =
1146 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, p_string,
1149 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_pipeline_id =
1150 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, pipeline_id,
1153 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_flow_string =
1154 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result,
1155 flow_string, "flow");
1157 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_add_string =
1158 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result,
1161 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_ipv4_5tuple_string =
1162 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result,
1163 ipv4_5tuple_string, "ipv4_5tuple");
1165 cmdline_parse_token_ipaddr_t cmd_fc_add_ipv4_5tuple_ip_src =
1166 TOKEN_IPV4_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, ip_src);
1168 cmdline_parse_token_ipaddr_t cmd_fc_add_ipv4_5tuple_ip_dst =
1169 TOKEN_IPV4_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, ip_dst);
1171 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_port_src =
1172 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, port_src,
1175 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_port_dst =
1176 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, port_dst,
1179 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_proto =
1180 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, proto,
1183 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_port =
1184 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_result, port,
1187 cmdline_parse_inst_t cmd_fc_add_ipv4_5tuple = {
1188 .f = cmd_fc_add_ipv4_5tuple_parsed,
1190 .help_str = "Flow add (IPv4 5-tuple)",
1192 (void *) &cmd_fc_add_ipv4_5tuple_p_string,
1193 (void *) &cmd_fc_add_ipv4_5tuple_pipeline_id,
1194 (void *) &cmd_fc_add_ipv4_5tuple_flow_string,
1195 (void *) &cmd_fc_add_ipv4_5tuple_add_string,
1196 (void *) &cmd_fc_add_ipv4_5tuple_ipv4_5tuple_string,
1197 (void *) &cmd_fc_add_ipv4_5tuple_ip_src,
1198 (void *) &cmd_fc_add_ipv4_5tuple_ip_dst,
1199 (void *) &cmd_fc_add_ipv4_5tuple_port_src,
1200 (void *) &cmd_fc_add_ipv4_5tuple_port_dst,
1201 (void *) &cmd_fc_add_ipv4_5tuple_proto,
1202 (void *) &cmd_fc_add_ipv4_5tuple_port,
1208 * flow add ipv4_5tuple all
1211 struct cmd_fc_add_ipv4_5tuple_all_result {
1212 cmdline_fixed_string_t p_string;
1213 uint32_t pipeline_id;
1214 cmdline_fixed_string_t flow_string;
1215 cmdline_fixed_string_t add_string;
1216 cmdline_fixed_string_t ipv4_5tuple_string;
1217 cmdline_fixed_string_t all_string;
1223 cmd_fc_add_ipv4_5tuple_all_parsed(
1224 void *parsed_result,
1225 __rte_unused struct cmdline *cl,
1228 struct cmd_fc_add_ipv4_5tuple_all_result *params = parsed_result;
1229 struct app_params *app = data;
1230 struct pipeline_fc_key *key;
1234 key = rte_zmalloc(NULL,
1235 N_FLOWS_BULK * sizeof(*key),
1236 RTE_CACHE_LINE_SIZE);
1238 printf("Memory allocation failed\n");
1242 port_id = rte_malloc(NULL,
1243 N_FLOWS_BULK * sizeof(*port_id),
1244 RTE_CACHE_LINE_SIZE);
1245 if (port_id == NULL) {
1247 printf("Memory allocation failed\n");
1251 for (flow_id = 0; flow_id < params->n_flows; flow_id++) {
1252 uint32_t pos = flow_id & (N_FLOWS_BULK - 1);
1254 key[pos].type = FLOW_KEY_IPV4_5TUPLE;
1255 key[pos].key.ipv4_5tuple.ip_src = 0;
1256 key[pos].key.ipv4_5tuple.ip_dst = flow_id;
1257 key[pos].key.ipv4_5tuple.port_src = 0;
1258 key[pos].key.ipv4_5tuple.port_dst = 0;
1259 key[pos].key.ipv4_5tuple.proto = 6;
1261 port_id[pos] = flow_id % params->n_ports;
1263 if ((pos == N_FLOWS_BULK - 1) ||
1264 (flow_id == params->n_flows - 1)) {
1267 status = app_pipeline_fc_add_bulk(app,
1268 params->pipeline_id,
1274 printf("Command failed\n");
1285 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_all_p_string =
1286 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1289 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_all_pipeline_id =
1290 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1291 pipeline_id, UINT32);
1293 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_all_flow_string =
1294 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1295 flow_string, "flow");
1297 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_all_add_string =
1298 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1301 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_all_ipv4_5tuple_string =
1302 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1303 ipv4_5tuple_string, "ipv4_5tuple");
1305 cmdline_parse_token_string_t cmd_fc_add_ipv4_5tuple_all_all_string =
1306 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1309 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_all_n_flows =
1310 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1313 cmdline_parse_token_num_t cmd_fc_add_ipv4_5tuple_all_n_ports =
1314 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv4_5tuple_all_result,
1317 cmdline_parse_inst_t cmd_fc_add_ipv4_5tuple_all = {
1318 .f = cmd_fc_add_ipv4_5tuple_all_parsed,
1320 .help_str = "Flow add all (IPv4 5-tuple)",
1322 (void *) &cmd_fc_add_ipv4_5tuple_all_p_string,
1323 (void *) &cmd_fc_add_ipv4_5tuple_all_pipeline_id,
1324 (void *) &cmd_fc_add_ipv4_5tuple_all_flow_string,
1325 (void *) &cmd_fc_add_ipv4_5tuple_all_add_string,
1326 (void *) &cmd_fc_add_ipv4_5tuple_all_ipv4_5tuple_string,
1327 (void *) &cmd_fc_add_ipv4_5tuple_all_all_string,
1328 (void *) &cmd_fc_add_ipv4_5tuple_all_n_flows,
1329 (void *) &cmd_fc_add_ipv4_5tuple_all_n_ports,
1335 * flow add ipv6_5tuple
1338 struct cmd_fc_add_ipv6_5tuple_result {
1339 cmdline_fixed_string_t p_string;
1340 uint32_t pipeline_id;
1341 cmdline_fixed_string_t flow_string;
1342 cmdline_fixed_string_t add_string;
1343 cmdline_fixed_string_t ipv6_5tuple_string;
1344 cmdline_ipaddr_t ip_src;
1345 cmdline_ipaddr_t ip_dst;
1353 cmd_fc_add_ipv6_5tuple_parsed(
1354 void *parsed_result,
1355 __rte_unused struct cmdline *cl,
1358 struct cmd_fc_add_ipv6_5tuple_result *params = parsed_result;
1359 struct app_params *app = data;
1360 struct pipeline_fc_key key;
1363 memset(&key, 0, sizeof(key));
1364 key.type = FLOW_KEY_IPV6_5TUPLE;
1365 memcpy(key.key.ipv6_5tuple.ip_src,
1366 params->ip_src.addr.ipv6.s6_addr,
1368 memcpy(key.key.ipv6_5tuple.ip_dst,
1369 params->ip_dst.addr.ipv6.s6_addr,
1371 key.key.ipv6_5tuple.port_src = params->port_src;
1372 key.key.ipv6_5tuple.port_dst = params->port_dst;
1373 key.key.ipv6_5tuple.proto = params->proto;
1375 status = app_pipeline_fc_add(app,
1376 params->pipeline_id,
1380 printf("Command failed\n");
1383 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_p_string =
1384 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result,
1387 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_pipeline_id =
1388 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result, pipeline_id,
1391 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_flow_string =
1392 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result,
1393 flow_string, "flow");
1395 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_add_string =
1396 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result,
1399 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_ipv6_5tuple_string =
1400 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result,
1401 ipv6_5tuple_string, "ipv6_5tuple");
1403 cmdline_parse_token_ipaddr_t cmd_fc_add_ipv6_5tuple_ip_src =
1404 TOKEN_IPV6_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result, ip_src);
1406 cmdline_parse_token_ipaddr_t cmd_fc_add_ipv6_5tuple_ip_dst =
1407 TOKEN_IPV6_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result, ip_dst);
1409 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_port_src =
1410 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result, port_src,
1413 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_port_dst =
1414 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result, port_dst,
1417 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_proto =
1418 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result, proto,
1421 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_port =
1422 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_result, port,
1425 cmdline_parse_inst_t cmd_fc_add_ipv6_5tuple = {
1426 .f = cmd_fc_add_ipv6_5tuple_parsed,
1428 .help_str = "Flow add (IPv6 5-tuple)",
1430 (void *) &cmd_fc_add_ipv6_5tuple_p_string,
1431 (void *) &cmd_fc_add_ipv6_5tuple_pipeline_id,
1432 (void *) &cmd_fc_add_ipv6_5tuple_flow_string,
1433 (void *) &cmd_fc_add_ipv6_5tuple_add_string,
1434 (void *) &cmd_fc_add_ipv6_5tuple_ipv6_5tuple_string,
1435 (void *) &cmd_fc_add_ipv6_5tuple_ip_src,
1436 (void *) &cmd_fc_add_ipv6_5tuple_ip_dst,
1437 (void *) &cmd_fc_add_ipv6_5tuple_port_src,
1438 (void *) &cmd_fc_add_ipv6_5tuple_port_dst,
1439 (void *) &cmd_fc_add_ipv6_5tuple_proto,
1440 (void *) &cmd_fc_add_ipv6_5tuple_port,
1446 * flow add ipv6_5tuple all
1449 struct cmd_fc_add_ipv6_5tuple_all_result {
1450 cmdline_fixed_string_t p_string;
1451 uint32_t pipeline_id;
1452 cmdline_fixed_string_t flow_string;
1453 cmdline_fixed_string_t add_string;
1454 cmdline_fixed_string_t ipv6_5tuple_string;
1455 cmdline_fixed_string_t all_string;
1461 cmd_fc_add_ipv6_5tuple_all_parsed(
1462 void *parsed_result,
1463 __rte_unused struct cmdline *cl,
1466 struct cmd_fc_add_ipv6_5tuple_all_result *params = parsed_result;
1467 struct app_params *app = data;
1468 struct pipeline_fc_key *key;
1472 key = rte_zmalloc(NULL,
1473 N_FLOWS_BULK * sizeof(*key),
1474 RTE_CACHE_LINE_SIZE);
1476 printf("Memory allocation failed\n");
1480 port_id = rte_malloc(NULL,
1481 N_FLOWS_BULK * sizeof(*port_id),
1482 RTE_CACHE_LINE_SIZE);
1483 if (port_id == NULL) {
1485 printf("Memory allocation failed\n");
1489 for (flow_id = 0; flow_id < params->n_flows; flow_id++) {
1490 uint32_t pos = flow_id & (N_FLOWS_BULK - 1);
1493 key[pos].type = FLOW_KEY_IPV6_5TUPLE;
1494 x = (uint32_t *) key[pos].key.ipv6_5tuple.ip_dst;
1495 *x = rte_bswap32(flow_id);
1496 key[pos].key.ipv6_5tuple.proto = 6;
1498 port_id[pos] = flow_id % params->n_ports;
1500 if ((pos == N_FLOWS_BULK - 1) ||
1501 (flow_id == params->n_flows - 1)) {
1504 status = app_pipeline_fc_add_bulk(app,
1505 params->pipeline_id,
1511 printf("Command failed\n");
1522 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_all_p_string =
1523 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1526 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_all_pipeline_id =
1527 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1528 pipeline_id, UINT32);
1530 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_all_flow_string =
1531 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1532 flow_string, "flow");
1534 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_all_add_string =
1535 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1538 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_all_ipv6_5tuple_string =
1539 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1540 ipv6_5tuple_string, "ipv6_5tuple");
1542 cmdline_parse_token_string_t cmd_fc_add_ipv6_5tuple_all_all_string =
1543 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1546 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_all_n_flows =
1547 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1550 cmdline_parse_token_num_t cmd_fc_add_ipv6_5tuple_all_n_ports =
1551 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_ipv6_5tuple_all_result,
1554 cmdline_parse_inst_t cmd_fc_add_ipv6_5tuple_all = {
1555 .f = cmd_fc_add_ipv6_5tuple_all_parsed,
1557 .help_str = "Flow add all (ipv6 5-tuple)",
1559 (void *) &cmd_fc_add_ipv6_5tuple_all_p_string,
1560 (void *) &cmd_fc_add_ipv6_5tuple_all_pipeline_id,
1561 (void *) &cmd_fc_add_ipv6_5tuple_all_flow_string,
1562 (void *) &cmd_fc_add_ipv6_5tuple_all_add_string,
1563 (void *) &cmd_fc_add_ipv6_5tuple_all_ipv6_5tuple_string,
1564 (void *) &cmd_fc_add_ipv6_5tuple_all_all_string,
1565 (void *) &cmd_fc_add_ipv6_5tuple_all_n_flows,
1566 (void *) &cmd_fc_add_ipv6_5tuple_all_n_ports,
1574 struct cmd_fc_del_qinq_result {
1575 cmdline_fixed_string_t p_string;
1576 uint32_t pipeline_id;
1577 cmdline_fixed_string_t flow_string;
1578 cmdline_fixed_string_t del_string;
1579 cmdline_fixed_string_t qinq_string;
1585 cmd_fc_del_qinq_parsed(
1586 void *parsed_result,
1587 __rte_unused struct cmdline *cl,
1590 struct cmd_fc_del_qinq_result *params = parsed_result;
1591 struct app_params *app = data;
1592 struct pipeline_fc_key key;
1595 memset(&key, 0, sizeof(key));
1596 key.type = FLOW_KEY_QINQ;
1597 key.key.qinq.svlan = params->svlan;
1598 key.key.qinq.cvlan = params->cvlan;
1599 status = app_pipeline_fc_del(app, params->pipeline_id, &key);
1602 printf("Command failed\n");
1605 cmdline_parse_token_string_t cmd_fc_del_qinq_p_string =
1606 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_qinq_result, p_string, "p");
1608 cmdline_parse_token_num_t cmd_fc_del_qinq_pipeline_id =
1609 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_qinq_result, pipeline_id,
1612 cmdline_parse_token_string_t cmd_fc_del_qinq_flow_string =
1613 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_qinq_result, flow_string,
1616 cmdline_parse_token_string_t cmd_fc_del_qinq_del_string =
1617 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_qinq_result, del_string,
1620 cmdline_parse_token_string_t cmd_fc_del_qinq_qinq_string =
1621 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_qinq_result, qinq_string,
1624 cmdline_parse_token_num_t cmd_fc_del_qinq_svlan =
1625 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_qinq_result, svlan, UINT16);
1627 cmdline_parse_token_num_t cmd_fc_del_qinq_cvlan =
1628 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_qinq_result, cvlan, UINT16);
1630 cmdline_parse_inst_t cmd_fc_del_qinq = {
1631 .f = cmd_fc_del_qinq_parsed,
1633 .help_str = "Flow delete (Q-in-Q)",
1635 (void *) &cmd_fc_del_qinq_p_string,
1636 (void *) &cmd_fc_del_qinq_pipeline_id,
1637 (void *) &cmd_fc_del_qinq_flow_string,
1638 (void *) &cmd_fc_del_qinq_del_string,
1639 (void *) &cmd_fc_del_qinq_qinq_string,
1640 (void *) &cmd_fc_del_qinq_svlan,
1641 (void *) &cmd_fc_del_qinq_cvlan,
1647 * flow del ipv4_5tuple
1650 struct cmd_fc_del_ipv4_5tuple_result {
1651 cmdline_fixed_string_t p_string;
1652 uint32_t pipeline_id;
1653 cmdline_fixed_string_t flow_string;
1654 cmdline_fixed_string_t del_string;
1655 cmdline_fixed_string_t ipv4_5tuple_string;
1656 cmdline_ipaddr_t ip_src;
1657 cmdline_ipaddr_t ip_dst;
1664 cmd_fc_del_ipv4_5tuple_parsed(
1665 void *parsed_result,
1666 __rte_unused struct cmdline *cl,
1669 struct cmd_fc_del_ipv4_5tuple_result *params = parsed_result;
1670 struct app_params *app = data;
1671 struct pipeline_fc_key key;
1674 memset(&key, 0, sizeof(key));
1675 key.type = FLOW_KEY_IPV4_5TUPLE;
1676 key.key.ipv4_5tuple.ip_src = rte_bswap32(
1677 params->ip_src.addr.ipv4.s_addr);
1678 key.key.ipv4_5tuple.ip_dst = rte_bswap32(
1679 params->ip_dst.addr.ipv4.s_addr);
1680 key.key.ipv4_5tuple.port_src = params->port_src;
1681 key.key.ipv4_5tuple.port_dst = params->port_dst;
1682 key.key.ipv4_5tuple.proto = params->proto;
1684 status = app_pipeline_fc_del(app, params->pipeline_id, &key);
1686 printf("Command failed\n");
1689 cmdline_parse_token_string_t cmd_fc_del_ipv4_5tuple_p_string =
1690 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1693 cmdline_parse_token_num_t cmd_fc_del_ipv4_5tuple_pipeline_id =
1694 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1695 pipeline_id, UINT32);
1697 cmdline_parse_token_string_t cmd_fc_del_ipv4_5tuple_flow_string =
1698 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1699 flow_string, "flow");
1701 cmdline_parse_token_string_t cmd_fc_del_ipv4_5tuple_del_string =
1702 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1705 cmdline_parse_token_string_t cmd_fc_del_ipv4_5tuple_ipv4_5tuple_string =
1706 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1707 ipv4_5tuple_string, "ipv4_5tuple");
1709 cmdline_parse_token_ipaddr_t cmd_fc_del_ipv4_5tuple_ip_src =
1710 TOKEN_IPV4_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1713 cmdline_parse_token_ipaddr_t cmd_fc_del_ipv4_5tuple_ip_dst =
1714 TOKEN_IPV4_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result, ip_dst);
1716 cmdline_parse_token_num_t cmd_fc_del_ipv4_5tuple_port_src =
1717 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1720 cmdline_parse_token_num_t cmd_fc_del_ipv4_5tuple_port_dst =
1721 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1724 cmdline_parse_token_num_t cmd_fc_del_ipv4_5tuple_proto =
1725 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv4_5tuple_result,
1728 cmdline_parse_inst_t cmd_fc_del_ipv4_5tuple = {
1729 .f = cmd_fc_del_ipv4_5tuple_parsed,
1731 .help_str = "Flow delete (IPv4 5-tuple)",
1733 (void *) &cmd_fc_del_ipv4_5tuple_p_string,
1734 (void *) &cmd_fc_del_ipv4_5tuple_pipeline_id,
1735 (void *) &cmd_fc_del_ipv4_5tuple_flow_string,
1736 (void *) &cmd_fc_del_ipv4_5tuple_del_string,
1737 (void *) &cmd_fc_del_ipv4_5tuple_ipv4_5tuple_string,
1738 (void *) &cmd_fc_del_ipv4_5tuple_ip_src,
1739 (void *) &cmd_fc_del_ipv4_5tuple_ip_dst,
1740 (void *) &cmd_fc_del_ipv4_5tuple_port_src,
1741 (void *) &cmd_fc_del_ipv4_5tuple_port_dst,
1742 (void *) &cmd_fc_del_ipv4_5tuple_proto,
1748 * flow del ipv6_5tuple
1751 struct cmd_fc_del_ipv6_5tuple_result {
1752 cmdline_fixed_string_t p_string;
1753 uint32_t pipeline_id;
1754 cmdline_fixed_string_t flow_string;
1755 cmdline_fixed_string_t del_string;
1756 cmdline_fixed_string_t ipv6_5tuple_string;
1757 cmdline_ipaddr_t ip_src;
1758 cmdline_ipaddr_t ip_dst;
1765 cmd_fc_del_ipv6_5tuple_parsed(
1766 void *parsed_result,
1767 __rte_unused struct cmdline *cl,
1770 struct cmd_fc_del_ipv6_5tuple_result *params = parsed_result;
1771 struct app_params *app = data;
1772 struct pipeline_fc_key key;
1775 memset(&key, 0, sizeof(key));
1776 key.type = FLOW_KEY_IPV6_5TUPLE;
1777 memcpy(key.key.ipv6_5tuple.ip_src,
1778 params->ip_src.addr.ipv6.s6_addr,
1780 memcpy(key.key.ipv6_5tuple.ip_dst,
1781 params->ip_dst.addr.ipv6.s6_addr,
1783 key.key.ipv6_5tuple.port_src = params->port_src;
1784 key.key.ipv6_5tuple.port_dst = params->port_dst;
1785 key.key.ipv6_5tuple.proto = params->proto;
1787 status = app_pipeline_fc_del(app, params->pipeline_id, &key);
1789 printf("Command failed\n");
1792 cmdline_parse_token_string_t cmd_fc_del_ipv6_5tuple_p_string =
1793 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result,
1796 cmdline_parse_token_num_t cmd_fc_del_ipv6_5tuple_pipeline_id =
1797 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result,
1798 pipeline_id, UINT32);
1800 cmdline_parse_token_string_t cmd_fc_del_ipv6_5tuple_flow_string =
1801 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result,
1802 flow_string, "flow");
1804 cmdline_parse_token_string_t cmd_fc_del_ipv6_5tuple_del_string =
1805 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result,
1808 cmdline_parse_token_string_t cmd_fc_del_ipv6_5tuple_ipv6_5tuple_string =
1809 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result,
1810 ipv6_5tuple_string, "ipv6_5tuple");
1812 cmdline_parse_token_ipaddr_t cmd_fc_del_ipv6_5tuple_ip_src =
1813 TOKEN_IPV6_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result, ip_src);
1815 cmdline_parse_token_ipaddr_t cmd_fc_del_ipv6_5tuple_ip_dst =
1816 TOKEN_IPV6_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result, ip_dst);
1818 cmdline_parse_token_num_t cmd_fc_del_ipv6_5tuple_port_src =
1819 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result, port_src,
1822 cmdline_parse_token_num_t cmd_fc_del_ipv6_5tuple_port_dst =
1823 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result, port_dst,
1826 cmdline_parse_token_num_t cmd_fc_del_ipv6_5tuple_proto =
1827 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_ipv6_5tuple_result, proto,
1830 cmdline_parse_inst_t cmd_fc_del_ipv6_5tuple = {
1831 .f = cmd_fc_del_ipv6_5tuple_parsed,
1833 .help_str = "Flow delete (IPv6 5-tuple)",
1835 (void *) &cmd_fc_del_ipv6_5tuple_p_string,
1836 (void *) &cmd_fc_del_ipv6_5tuple_pipeline_id,
1837 (void *) &cmd_fc_del_ipv6_5tuple_flow_string,
1838 (void *) &cmd_fc_del_ipv6_5tuple_del_string,
1839 (void *) &cmd_fc_del_ipv6_5tuple_ipv6_5tuple_string,
1840 (void *) &cmd_fc_del_ipv6_5tuple_ip_src,
1841 (void *) &cmd_fc_del_ipv6_5tuple_ip_dst,
1842 (void *) &cmd_fc_del_ipv6_5tuple_port_src,
1843 (void *) &cmd_fc_del_ipv6_5tuple_port_dst,
1844 (void *) &cmd_fc_del_ipv6_5tuple_proto,
1853 struct cmd_fc_add_default_result {
1854 cmdline_fixed_string_t p_string;
1855 uint32_t pipeline_id;
1856 cmdline_fixed_string_t flow_string;
1857 cmdline_fixed_string_t add_string;
1858 cmdline_fixed_string_t default_string;
1863 cmd_fc_add_default_parsed(
1864 void *parsed_result,
1865 __rte_unused struct cmdline *cl,
1868 struct cmd_fc_add_default_result *params = parsed_result;
1869 struct app_params *app = data;
1872 status = app_pipeline_fc_add_default(app, params->pipeline_id,
1876 printf("Command failed\n");
1879 cmdline_parse_token_string_t cmd_fc_add_default_p_string =
1880 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_default_result, p_string,
1883 cmdline_parse_token_num_t cmd_fc_add_default_pipeline_id =
1884 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_default_result, pipeline_id,
1887 cmdline_parse_token_string_t cmd_fc_add_default_flow_string =
1888 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_default_result, flow_string,
1891 cmdline_parse_token_string_t cmd_fc_add_default_add_string =
1892 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_default_result, add_string,
1895 cmdline_parse_token_string_t cmd_fc_add_default_default_string =
1896 TOKEN_STRING_INITIALIZER(struct cmd_fc_add_default_result,
1897 default_string, "default");
1899 cmdline_parse_token_num_t cmd_fc_add_default_port =
1900 TOKEN_NUM_INITIALIZER(struct cmd_fc_add_default_result, port, UINT32);
1902 cmdline_parse_inst_t cmd_fc_add_default = {
1903 .f = cmd_fc_add_default_parsed,
1905 .help_str = "Flow add default",
1907 (void *) &cmd_fc_add_default_p_string,
1908 (void *) &cmd_fc_add_default_pipeline_id,
1909 (void *) &cmd_fc_add_default_flow_string,
1910 (void *) &cmd_fc_add_default_add_string,
1911 (void *) &cmd_fc_add_default_default_string,
1912 (void *) &cmd_fc_add_default_port,
1921 struct cmd_fc_del_default_result {
1922 cmdline_fixed_string_t p_string;
1923 uint32_t pipeline_id;
1924 cmdline_fixed_string_t flow_string;
1925 cmdline_fixed_string_t del_string;
1926 cmdline_fixed_string_t default_string;
1930 cmd_fc_del_default_parsed(
1931 void *parsed_result,
1932 __rte_unused struct cmdline *cl,
1935 struct cmd_fc_del_default_result *params = parsed_result;
1936 struct app_params *app = data;
1939 status = app_pipeline_fc_del_default(app, params->pipeline_id);
1941 printf("Command failed\n");
1944 cmdline_parse_token_string_t cmd_fc_del_default_p_string =
1945 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_default_result, p_string,
1948 cmdline_parse_token_num_t cmd_fc_del_default_pipeline_id =
1949 TOKEN_NUM_INITIALIZER(struct cmd_fc_del_default_result, pipeline_id,
1952 cmdline_parse_token_string_t cmd_fc_del_default_flow_string =
1953 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_default_result, flow_string,
1956 cmdline_parse_token_string_t cmd_fc_del_default_del_string =
1957 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_default_result, del_string,
1960 cmdline_parse_token_string_t cmd_fc_del_default_default_string =
1961 TOKEN_STRING_INITIALIZER(struct cmd_fc_del_default_result,
1962 default_string, "default");
1964 cmdline_parse_inst_t cmd_fc_del_default = {
1965 .f = cmd_fc_del_default_parsed,
1967 .help_str = "Flow delete default",
1969 (void *) &cmd_fc_del_default_p_string,
1970 (void *) &cmd_fc_del_default_pipeline_id,
1971 (void *) &cmd_fc_del_default_flow_string,
1972 (void *) &cmd_fc_del_default_del_string,
1973 (void *) &cmd_fc_del_default_default_string,
1982 struct cmd_fc_ls_result {
1983 cmdline_fixed_string_t p_string;
1984 uint32_t pipeline_id;
1985 cmdline_fixed_string_t flow_string;
1986 cmdline_fixed_string_t ls_string;
1991 void *parsed_result,
1992 __attribute__((unused)) struct cmdline *cl,
1995 struct cmd_fc_ls_result *params = parsed_result;
1996 struct app_params *app = data;
1999 status = app_pipeline_fc_ls(app, params->pipeline_id);
2001 printf("Command failed\n");
2004 cmdline_parse_token_string_t cmd_fc_ls_p_string =
2005 TOKEN_STRING_INITIALIZER(struct cmd_fc_ls_result, p_string, "p");
2007 cmdline_parse_token_num_t cmd_fc_ls_pipeline_id =
2008 TOKEN_NUM_INITIALIZER(struct cmd_fc_ls_result, pipeline_id, UINT32);
2010 cmdline_parse_token_string_t cmd_fc_ls_flow_string =
2011 TOKEN_STRING_INITIALIZER(struct cmd_fc_ls_result,
2012 flow_string, "flow");
2014 cmdline_parse_token_string_t cmd_fc_ls_ls_string =
2015 TOKEN_STRING_INITIALIZER(struct cmd_fc_ls_result, ls_string,
2018 cmdline_parse_inst_t cmd_fc_ls = {
2019 .f = cmd_fc_ls_parsed,
2021 .help_str = "Flow list",
2023 (void *) &cmd_fc_ls_p_string,
2024 (void *) &cmd_fc_ls_pipeline_id,
2025 (void *) &cmd_fc_ls_flow_string,
2026 (void *) &cmd_fc_ls_ls_string,
2031 static cmdline_parse_ctx_t pipeline_cmds[] = {
2032 (cmdline_parse_inst_t *) &cmd_fc_add_qinq,
2033 (cmdline_parse_inst_t *) &cmd_fc_add_ipv4_5tuple,
2034 (cmdline_parse_inst_t *) &cmd_fc_add_ipv6_5tuple,
2036 (cmdline_parse_inst_t *) &cmd_fc_del_qinq,
2037 (cmdline_parse_inst_t *) &cmd_fc_del_ipv4_5tuple,
2038 (cmdline_parse_inst_t *) &cmd_fc_del_ipv6_5tuple,
2040 (cmdline_parse_inst_t *) &cmd_fc_add_default,
2041 (cmdline_parse_inst_t *) &cmd_fc_del_default,
2043 (cmdline_parse_inst_t *) &cmd_fc_add_qinq_all,
2044 (cmdline_parse_inst_t *) &cmd_fc_add_ipv4_5tuple_all,
2045 (cmdline_parse_inst_t *) &cmd_fc_add_ipv6_5tuple_all,
2047 (cmdline_parse_inst_t *) &cmd_fc_ls,
2051 static struct pipeline_fe_ops pipeline_flow_classification_fe_ops = {
2052 .f_init = app_pipeline_fc_init,
2053 .f_free = app_pipeline_fc_free,
2054 .cmds = pipeline_cmds,
2057 struct pipeline_type pipeline_flow_classification = {
2058 .name = "FLOW_CLASSIFICATION",
2059 .be_ops = &pipeline_flow_classification_be_ops,
2060 .fe_ops = &pipeline_flow_classification_fe_ops,