1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
10 #include <rte_common.h>
11 #include <rte_cycles.h>
24 #ifndef CMD_MAX_TOKENS
25 #define CMD_MAX_TOKENS 256
28 #define MSG_OUT_OF_MEMORY "Not enough memory.\n"
29 #define MSG_CMD_UNKNOWN "Unknown command \"%s\".\n"
30 #define MSG_CMD_UNIMPLEM "Command \"%s\" not implemented.\n"
31 #define MSG_ARG_NOT_ENOUGH "Not enough arguments for command \"%s\".\n"
32 #define MSG_ARG_TOO_MANY "Too many arguments for command \"%s\".\n"
33 #define MSG_ARG_MISMATCH "Wrong number of arguments for command \"%s\".\n"
34 #define MSG_ARG_NOT_FOUND "Argument \"%s\" not found.\n"
35 #define MSG_ARG_INVALID "Invalid value for argument \"%s\".\n"
36 #define MSG_FILE_ERR "Error in file \"%s\" at line %u.\n"
37 #define MSG_FILE_NOT_ENOUGH "Not enough rules in file \"%s\".\n"
38 #define MSG_CMD_FAIL "Command \"%s\" failed.\n"
43 if ((strlen(in) && index("!#%;", in[0])) ||
44 (strncmp(in, "//", 2) == 0) ||
45 (strncmp(in, "--", 2) == 0))
52 * mempool <mempool_name>
53 * buffer <buffer_size>
59 cmd_mempool(char **tokens,
64 struct mempool_params p;
66 struct mempool *mempool;
69 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
75 if (strcmp(tokens[2], "buffer") != 0) {
76 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buffer");
80 if (parser_read_uint32(&p.buffer_size, tokens[3]) != 0) {
81 snprintf(out, out_size, MSG_ARG_INVALID, "buffer_size");
85 if (strcmp(tokens[4], "pool") != 0) {
86 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pool");
90 if (parser_read_uint32(&p.pool_size, tokens[5]) != 0) {
91 snprintf(out, out_size, MSG_ARG_INVALID, "pool_size");
95 if (strcmp(tokens[6], "cache") != 0) {
96 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cache");
100 if (parser_read_uint32(&p.cache_size, tokens[7]) != 0) {
101 snprintf(out, out_size, MSG_ARG_INVALID, "cache_size");
105 if (strcmp(tokens[8], "cpu") != 0) {
106 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
110 if (parser_read_uint32(&p.cpu_id, tokens[9]) != 0) {
111 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
115 mempool = mempool_create(name, &p);
116 if (mempool == NULL) {
117 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
124 * dev <device_name> | port <port_id>
125 * rxq <n_queues> <queue_size> <mempool_name>
126 * txq <n_queues> <queue_size>
127 * promiscuous on | off
128 * [rss <qid_0> ... <qid_n>]
131 cmd_link(char **tokens,
136 struct link_params p;
137 struct link_params_rss rss;
141 memset(&p, 0, sizeof(p));
143 if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) {
144 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
149 if (strcmp(tokens[2], "dev") == 0)
150 p.dev_name = tokens[3];
151 else if (strcmp(tokens[2], "port") == 0) {
154 if (parser_read_uint16(&p.port_id, tokens[3]) != 0) {
155 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
159 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dev or port");
163 if (strcmp(tokens[4], "rxq") != 0) {
164 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
168 if (parser_read_uint32(&p.rx.n_queues, tokens[5]) != 0) {
169 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
172 if (parser_read_uint32(&p.rx.queue_size, tokens[6]) != 0) {
173 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
177 p.rx.mempool_name = tokens[7];
179 if (strcmp(tokens[8], "txq") != 0) {
180 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
184 if (parser_read_uint32(&p.tx.n_queues, tokens[9]) != 0) {
185 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
189 if (parser_read_uint32(&p.tx.queue_size, tokens[10]) != 0) {
190 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
194 if (strcmp(tokens[11], "promiscuous") != 0) {
195 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "promiscuous");
199 if (strcmp(tokens[12], "on") == 0)
201 else if (strcmp(tokens[12], "off") == 0)
204 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "on or off");
211 uint32_t queue_id, i;
213 if (strcmp(tokens[13], "rss") != 0) {
214 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rss");
221 for (i = 14; i < n_tokens; i++) {
222 if (parser_read_uint32(&queue_id, tokens[i]) != 0) {
223 snprintf(out, out_size, MSG_ARG_INVALID,
228 rss.queue_id[rss.n_queues] = queue_id;
233 link = link_create(name, &p);
235 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
246 cmd_swq(char **tokens,
256 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
262 if (strcmp(tokens[2], "size") != 0) {
263 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
267 if (parser_read_uint32(&p.size, tokens[3]) != 0) {
268 snprintf(out, out_size, MSG_ARG_INVALID, "size");
272 if (strcmp(tokens[4], "cpu") != 0) {
273 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
277 if (parser_read_uint32(&p.cpu_id, tokens[5]) != 0) {
278 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
282 swq = swq_create(name, &p);
284 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
290 * tmgr subport profile
291 * <tb_rate> <tb_size>
292 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
296 cmd_tmgr_subport_profile(char **tokens,
301 struct rte_sched_subport_params p;
304 if (n_tokens != 10) {
305 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
309 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
310 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
314 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
315 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
319 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
320 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
321 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
325 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
326 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
330 status = tmgr_subport_profile_add(&p);
332 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
339 * <tb_rate> <tb_size>
340 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
346 cmd_tmgr_pipe_profile(char **tokens,
351 struct rte_sched_pipe_params p;
354 if (n_tokens != 27) {
355 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
359 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
360 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
364 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
365 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
369 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
370 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
371 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
375 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
376 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
380 #ifdef RTE_SCHED_SUBPORT_TC_OV
381 if (parser_read_uint8(&p.tc_ov_weight, tokens[10]) != 0) {
382 snprintf(out, out_size, MSG_ARG_INVALID, "tc_ov_weight");
387 for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++)
388 if (parser_read_uint8(&p.wrr_weights[i], tokens[11 + i]) != 0) {
389 snprintf(out, out_size, MSG_ARG_INVALID, "wrr_weights");
393 status = tmgr_pipe_profile_add(&p);
395 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
403 * spp <n_subports_per_port>
404 * pps <n_pipes_per_subport>
405 * qsize <qsize_tc0> <qsize_tc1> <qsize_tc2> <qsize_tc3>
406 * fo <frame_overhead>
411 cmd_tmgr(char **tokens,
416 struct tmgr_port_params p;
418 struct tmgr_port *tmgr_port;
421 if (n_tokens != 19) {
422 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
428 if (strcmp(tokens[2], "rate") != 0) {
429 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rate");
433 if (parser_read_uint32(&p.rate, tokens[3]) != 0) {
434 snprintf(out, out_size, MSG_ARG_INVALID, "rate");
438 if (strcmp(tokens[4], "spp") != 0) {
439 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
443 if (parser_read_uint32(&p.n_subports_per_port, tokens[5]) != 0) {
444 snprintf(out, out_size, MSG_ARG_INVALID, "n_subports_per_port");
448 if (strcmp(tokens[6], "pps") != 0) {
449 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
453 if (parser_read_uint32(&p.n_pipes_per_subport, tokens[7]) != 0) {
454 snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport");
458 if (strcmp(tokens[8], "qsize") != 0) {
459 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "qsize");
463 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
464 if (parser_read_uint16(&p.qsize[i], tokens[9 + i]) != 0) {
465 snprintf(out, out_size, MSG_ARG_INVALID, "qsize");
469 if (strcmp(tokens[13], "fo") != 0) {
470 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fo");
474 if (parser_read_uint32(&p.frame_overhead, tokens[14]) != 0) {
475 snprintf(out, out_size, MSG_ARG_INVALID, "frame_overhead");
479 if (strcmp(tokens[15], "mtu") != 0) {
480 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mtu");
484 if (parser_read_uint32(&p.mtu, tokens[16]) != 0) {
485 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
489 if (strcmp(tokens[17], "cpu") != 0) {
490 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
494 if (parser_read_uint32(&p.cpu_id, tokens[18]) != 0) {
495 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
499 tmgr_port = tmgr_port_create(name, &p);
500 if (tmgr_port == NULL) {
501 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
507 * tmgr <tmgr_name> subport <subport_id>
508 * profile <subport_profile_id>
511 cmd_tmgr_subport(char **tokens,
516 uint32_t subport_id, subport_profile_id;
521 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
527 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
528 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
532 if (parser_read_uint32(&subport_profile_id, tokens[5]) != 0) {
533 snprintf(out, out_size, MSG_ARG_INVALID, "subport_profile_id");
537 status = tmgr_subport_config(name, subport_id, subport_profile_id);
539 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
545 * tmgr <tmgr_name> subport <subport_id> pipe
546 * from <pipe_id_first> to <pipe_id_last>
547 * profile <pipe_profile_id>
550 cmd_tmgr_subport_pipe(char **tokens,
555 uint32_t subport_id, pipe_id_first, pipe_id_last, pipe_profile_id;
559 if (n_tokens != 11) {
560 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
566 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
567 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
571 if (strcmp(tokens[4], "pipe") != 0) {
572 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipe");
576 if (strcmp(tokens[5], "from") != 0) {
577 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "from");
581 if (parser_read_uint32(&pipe_id_first, tokens[6]) != 0) {
582 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_first");
586 if (strcmp(tokens[7], "to") != 0) {
587 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "to");
591 if (parser_read_uint32(&pipe_id_last, tokens[8]) != 0) {
592 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_last");
596 if (strcmp(tokens[9], "profile") != 0) {
597 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
601 if (parser_read_uint32(&pipe_profile_id, tokens[10]) != 0) {
602 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_profile_id");
606 status = tmgr_pipe_config(name, subport_id, pipe_id_first,
607 pipe_id_last, pipe_profile_id);
609 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
618 cmd_tap(char **tokens,
627 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
633 tap = tap_create(name);
635 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
643 * mempool <mempool_name>
644 * [thread <thread_id>]
647 cmd_kni(char **tokens,
656 if ((n_tokens != 6) && (n_tokens != 8)) {
657 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
663 if (strcmp(tokens[2], "link") != 0) {
664 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "link");
668 p.link_name = tokens[3];
670 if (strcmp(tokens[4], "mempool") != 0) {
671 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool");
675 p.mempool_name = tokens[5];
678 if (strcmp(tokens[6], "thread") != 0) {
679 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "thread");
683 if (parser_read_uint32(&p.thread_id, tokens[7]) != 0) {
684 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
692 kni = kni_create(name, &p);
694 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
700 * port in action profile <profile_name>
701 * [filter match | mismatch offset <key_offset> mask <key_mask> key <key_value> port <port_id>]
702 * [balance offset <key_offset> mask <key_mask> port <port_id0> ... <port_id15>]
705 cmd_port_in_action_profile(char **tokens,
710 struct port_in_action_profile_params p;
711 struct port_in_action_profile *ap;
715 memset(&p, 0, sizeof(p));
718 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
722 if (strcmp(tokens[1], "in") != 0) {
723 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
727 if (strcmp(tokens[2], "action") != 0) {
728 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
732 if (strcmp(tokens[3], "profile") != 0) {
733 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
741 if ((t0 < n_tokens) && (strcmp(tokens[t0], "filter") == 0)) {
744 if (n_tokens < t0 + 10) {
745 snprintf(out, out_size, MSG_ARG_MISMATCH, "port in action profile filter");
749 if (strcmp(tokens[t0 + 1], "match") == 0)
750 p.fltr.filter_on_match = 1;
751 else if (strcmp(tokens[t0 + 1], "mismatch") == 0)
752 p.fltr.filter_on_match = 0;
754 snprintf(out, out_size, MSG_ARG_INVALID, "match or mismatch");
758 if (strcmp(tokens[t0 + 2], "offset") != 0) {
759 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
763 if (parser_read_uint32(&p.fltr.key_offset, tokens[t0 + 3]) != 0) {
764 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
768 if (strcmp(tokens[t0 + 4], "mask") != 0) {
769 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
773 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
774 if ((parse_hex_string(tokens[t0 + 5], p.fltr.key_mask, &size) != 0) ||
775 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
776 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
780 if (strcmp(tokens[t0 + 6], "key") != 0) {
781 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
785 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
786 if ((parse_hex_string(tokens[t0 + 7], p.fltr.key, &size) != 0) ||
787 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
788 snprintf(out, out_size, MSG_ARG_INVALID, "key_value");
792 if (strcmp(tokens[t0 + 8], "port") != 0) {
793 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
797 if (parser_read_uint32(&p.fltr.port_id, tokens[t0 + 9]) != 0) {
798 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
802 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_FLTR;
806 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
809 if (n_tokens < t0 + 22) {
810 snprintf(out, out_size, MSG_ARG_MISMATCH,
811 "port in action profile balance");
815 if (strcmp(tokens[t0 + 1], "offset") != 0) {
816 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
820 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
821 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
825 if (strcmp(tokens[t0 + 3], "mask") != 0) {
826 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
830 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
831 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
832 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
836 if (strcmp(tokens[t0 + 5], "port") != 0) {
837 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
841 for (i = 0; i < 16; i++)
842 if (parser_read_uint32(&p.lb.port_id[i], tokens[t0 + 6 + i]) != 0) {
843 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
847 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_LB;
852 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
856 ap = port_in_action_profile_create(name, &p);
858 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
864 * table action profile <profile_name>
868 * [balance offset <key_offset> mask <key_mask> outoffset <out_offset>]
869 * [meter srtcm | trtcm
871 * stats none | pkts | bytes | both]
872 * [tm spp <n_subports_per_port> pps <n_pipes_per_subport>]
873 * [encap ether | vlan | qinq | mpls | pppoe]
878 * [stats pkts | bytes | both]
882 cmd_table_action_profile(char **tokens,
887 struct table_action_profile_params p;
888 struct table_action_profile *ap;
892 memset(&p, 0, sizeof(p));
895 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
899 if (strcmp(tokens[1], "action") != 0) {
900 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
904 if (strcmp(tokens[2], "profile") != 0) {
905 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
911 if (strcmp(tokens[4], "ipv4") == 0)
912 p.common.ip_version = 1;
913 else if (strcmp(tokens[4], "ipv6") == 0)
914 p.common.ip_version = 0;
916 snprintf(out, out_size, MSG_ARG_INVALID, "ipv4 or ipv6");
920 if (strcmp(tokens[5], "offset") != 0) {
921 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
925 if (parser_read_uint32(&p.common.ip_offset, tokens[6]) != 0) {
926 snprintf(out, out_size, MSG_ARG_INVALID, "ip_offset");
930 if (strcmp(tokens[7], "fwd") != 0) {
931 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fwd");
935 p.action_mask |= 1LLU << RTE_TABLE_ACTION_FWD;
938 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
939 if (n_tokens < t0 + 7) {
940 snprintf(out, out_size, MSG_ARG_MISMATCH, "table action profile balance");
944 if (strcmp(tokens[t0 + 1], "offset") != 0) {
945 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
949 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
950 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
954 if (strcmp(tokens[t0 + 3], "mask") != 0) {
955 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
959 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
960 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
961 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
965 if (strcmp(tokens[t0 + 5], "outoffset") != 0) {
966 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "outoffset");
970 if (parser_read_uint32(&p.lb.out_offset, tokens[t0 + 6]) != 0) {
971 snprintf(out, out_size, MSG_ARG_INVALID, "out_offset");
975 p.action_mask |= 1LLU << RTE_TABLE_ACTION_LB;
979 if ((t0 < n_tokens) && (strcmp(tokens[t0], "meter") == 0)) {
980 if (n_tokens < t0 + 6) {
981 snprintf(out, out_size, MSG_ARG_MISMATCH,
982 "table action profile meter");
986 if (strcmp(tokens[t0 + 1], "srtcm") == 0)
987 p.mtr.alg = RTE_TABLE_ACTION_METER_SRTCM;
988 else if (strcmp(tokens[t0 + 1], "trtcm") == 0)
989 p.mtr.alg = RTE_TABLE_ACTION_METER_TRTCM;
991 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
996 if (strcmp(tokens[t0 + 2], "tc") != 0) {
997 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc");
1001 if (parser_read_uint32(&p.mtr.n_tc, tokens[t0 + 3]) != 0) {
1002 snprintf(out, out_size, MSG_ARG_INVALID, "n_tc");
1006 if (strcmp(tokens[t0 + 4], "stats") != 0) {
1007 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1011 if (strcmp(tokens[t0 + 5], "none") == 0) {
1012 p.mtr.n_packets_enabled = 0;
1013 p.mtr.n_bytes_enabled = 0;
1014 } else if (strcmp(tokens[t0 + 5], "pkts") == 0) {
1015 p.mtr.n_packets_enabled = 1;
1016 p.mtr.n_bytes_enabled = 0;
1017 } else if (strcmp(tokens[t0 + 5], "bytes") == 0) {
1018 p.mtr.n_packets_enabled = 0;
1019 p.mtr.n_bytes_enabled = 1;
1020 } else if (strcmp(tokens[t0 + 5], "both") == 0) {
1021 p.mtr.n_packets_enabled = 1;
1022 p.mtr.n_bytes_enabled = 1;
1024 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1025 "none or pkts or bytes or both");
1029 p.action_mask |= 1LLU << RTE_TABLE_ACTION_MTR;
1033 if ((t0 < n_tokens) && (strcmp(tokens[t0], "tm") == 0)) {
1034 if (n_tokens < t0 + 5) {
1035 snprintf(out, out_size, MSG_ARG_MISMATCH,
1036 "table action profile tm");
1040 if (strcmp(tokens[t0 + 1], "spp") != 0) {
1041 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
1045 if (parser_read_uint32(&p.tm.n_subports_per_port,
1046 tokens[t0 + 2]) != 0) {
1047 snprintf(out, out_size, MSG_ARG_INVALID,
1048 "n_subports_per_port");
1052 if (strcmp(tokens[t0 + 3], "pps") != 0) {
1053 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
1057 if (parser_read_uint32(&p.tm.n_pipes_per_subport,
1058 tokens[t0 + 4]) != 0) {
1059 snprintf(out, out_size, MSG_ARG_INVALID,
1060 "n_pipes_per_subport");
1064 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TM;
1068 if ((t0 < n_tokens) && (strcmp(tokens[t0], "encap") == 0)) {
1069 if (n_tokens < t0 + 2) {
1070 snprintf(out, out_size, MSG_ARG_MISMATCH,
1071 "action profile encap");
1075 if (strcmp(tokens[t0 + 1], "ether") == 0)
1076 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER;
1077 else if (strcmp(tokens[t0 + 1], "vlan") == 0)
1078 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN;
1079 else if (strcmp(tokens[t0 + 1], "qinq") == 0)
1080 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ;
1081 else if (strcmp(tokens[t0 + 1], "mpls") == 0)
1082 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS;
1083 else if (strcmp(tokens[t0 + 1], "pppoe") == 0)
1084 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE;
1086 snprintf(out, out_size, MSG_ARG_MISMATCH, "encap");
1090 p.action_mask |= 1LLU << RTE_TABLE_ACTION_ENCAP;
1094 if ((t0 < n_tokens) && (strcmp(tokens[t0], "nat") == 0)) {
1095 if (n_tokens < t0 + 4) {
1096 snprintf(out, out_size, MSG_ARG_MISMATCH,
1097 "table action profile nat");
1101 if (strcmp(tokens[t0 + 1], "src") == 0)
1102 p.nat.source_nat = 1;
1103 else if (strcmp(tokens[t0 + 1], "dst") == 0)
1104 p.nat.source_nat = 0;
1106 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1111 if (strcmp(tokens[t0 + 2], "proto") != 0) {
1112 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "proto");
1116 if (strcmp(tokens[t0 + 3], "tcp") == 0)
1118 else if (strcmp(tokens[t0 + 3], "udp") == 0)
1121 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1126 p.action_mask |= 1LLU << RTE_TABLE_ACTION_NAT;
1130 if ((t0 < n_tokens) && (strcmp(tokens[t0], "ttl") == 0)) {
1131 if (n_tokens < t0 + 4) {
1132 snprintf(out, out_size, MSG_ARG_MISMATCH,
1133 "table action profile ttl");
1137 if (strcmp(tokens[t0 + 1], "drop") == 0)
1139 else if (strcmp(tokens[t0 + 1], "fwd") == 0)
1142 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1147 if (strcmp(tokens[t0 + 2], "stats") != 0) {
1148 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1152 if (strcmp(tokens[t0 + 3], "none") == 0)
1153 p.ttl.n_packets_enabled = 0;
1154 else if (strcmp(tokens[t0 + 3], "pkts") == 0)
1155 p.ttl.n_packets_enabled = 1;
1157 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1162 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TTL;
1166 if ((t0 < n_tokens) && (strcmp(tokens[t0], "stats") == 0)) {
1167 if (n_tokens < t0 + 2) {
1168 snprintf(out, out_size, MSG_ARG_MISMATCH,
1169 "table action profile stats");
1173 if (strcmp(tokens[t0 + 1], "pkts") == 0) {
1174 p.stats.n_packets_enabled = 1;
1175 p.stats.n_bytes_enabled = 0;
1176 } else if (strcmp(tokens[t0 + 1], "bytes") == 0) {
1177 p.stats.n_packets_enabled = 0;
1178 p.stats.n_bytes_enabled = 1;
1179 } else if (strcmp(tokens[t0 + 1], "both") == 0) {
1180 p.stats.n_packets_enabled = 1;
1181 p.stats.n_bytes_enabled = 1;
1183 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1184 "pkts or bytes or both");
1188 p.action_mask |= 1LLU << RTE_TABLE_ACTION_STATS;
1192 if ((t0 < n_tokens) && (strcmp(tokens[t0], "time") == 0)) {
1193 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TIME;
1197 if (t0 < n_tokens) {
1198 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1202 ap = table_action_profile_create(name, &p);
1204 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1210 * pipeline <pipeline_name>
1211 * period <timer_period_ms>
1212 * offset_port_id <offset_port_id>
1216 cmd_pipeline(char **tokens,
1221 struct pipeline_params p;
1223 struct pipeline *pipeline;
1225 if (n_tokens != 8) {
1226 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1232 if (strcmp(tokens[2], "period") != 0) {
1233 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "period");
1237 if (parser_read_uint32(&p.timer_period_ms, tokens[3]) != 0) {
1238 snprintf(out, out_size, MSG_ARG_INVALID, "timer_period_ms");
1242 if (strcmp(tokens[4], "offset_port_id") != 0) {
1243 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset_port_id");
1247 if (parser_read_uint32(&p.offset_port_id, tokens[5]) != 0) {
1248 snprintf(out, out_size, MSG_ARG_INVALID, "offset_port_id");
1252 if (strcmp(tokens[6], "cpu") != 0) {
1253 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
1257 if (parser_read_uint32(&p.cpu_id, tokens[7]) != 0) {
1258 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
1262 pipeline = pipeline_create(name, &p);
1263 if (pipeline == NULL) {
1264 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1270 * pipeline <pipeline_name> port in
1272 * link <link_name> rxq <queue_id>
1274 * | tmgr <tmgr_name>
1275 * | tap <tap_name> mempool <mempool_name> mtu <mtu>
1277 * | source mempool <mempool_name> file <file_name> bpp <n_bytes_per_pkt>
1278 * [action <port_in_action_profile_name>]
1282 cmd_pipeline_port_in(char **tokens,
1287 struct port_in_params p;
1288 char *pipeline_name;
1290 int enabled, status;
1293 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1297 pipeline_name = tokens[1];
1299 if (strcmp(tokens[2], "port") != 0) {
1300 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1304 if (strcmp(tokens[3], "in") != 0) {
1305 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1309 if (strcmp(tokens[4], "bsz") != 0) {
1310 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1314 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1315 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1321 if (strcmp(tokens[t0], "link") == 0) {
1322 if (n_tokens < t0 + 4) {
1323 snprintf(out, out_size, MSG_ARG_MISMATCH,
1324 "pipeline port in link");
1328 p.type = PORT_IN_RXQ;
1330 p.dev_name = tokens[t0 + 1];
1332 if (strcmp(tokens[t0 + 2], "rxq") != 0) {
1333 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
1337 if (parser_read_uint16(&p.rxq.queue_id, tokens[t0 + 3]) != 0) {
1338 snprintf(out, out_size, MSG_ARG_INVALID,
1343 } else if (strcmp(tokens[t0], "swq") == 0) {
1344 if (n_tokens < t0 + 2) {
1345 snprintf(out, out_size, MSG_ARG_MISMATCH,
1346 "pipeline port in swq");
1350 p.type = PORT_IN_SWQ;
1352 p.dev_name = tokens[t0 + 1];
1355 } else if (strcmp(tokens[t0], "tmgr") == 0) {
1356 if (n_tokens < t0 + 2) {
1357 snprintf(out, out_size, MSG_ARG_MISMATCH,
1358 "pipeline port in tmgr");
1362 p.type = PORT_IN_TMGR;
1364 p.dev_name = tokens[t0 + 1];
1367 } else if (strcmp(tokens[t0], "tap") == 0) {
1368 if (n_tokens < t0 + 6) {
1369 snprintf(out, out_size, MSG_ARG_MISMATCH,
1370 "pipeline port in tap");
1374 p.type = PORT_IN_TAP;
1376 p.dev_name = tokens[t0 + 1];
1378 if (strcmp(tokens[t0 + 2], "mempool") != 0) {
1379 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1384 p.tap.mempool_name = tokens[t0 + 3];
1386 if (strcmp(tokens[t0 + 4], "mtu") != 0) {
1387 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1392 if (parser_read_uint32(&p.tap.mtu, tokens[t0 + 5]) != 0) {
1393 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
1398 } else if (strcmp(tokens[t0], "kni") == 0) {
1399 if (n_tokens < t0 + 2) {
1400 snprintf(out, out_size, MSG_ARG_MISMATCH,
1401 "pipeline port in kni");
1405 p.type = PORT_IN_KNI;
1407 p.dev_name = tokens[t0 + 1];
1410 } else if (strcmp(tokens[t0], "source") == 0) {
1411 if (n_tokens < t0 + 6) {
1412 snprintf(out, out_size, MSG_ARG_MISMATCH,
1413 "pipeline port in source");
1417 p.type = PORT_IN_SOURCE;
1421 if (strcmp(tokens[t0 + 1], "mempool") != 0) {
1422 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1427 p.source.mempool_name = tokens[t0 + 2];
1429 if (strcmp(tokens[t0 + 3], "file") != 0) {
1430 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1435 p.source.file_name = tokens[t0 + 4];
1437 if (strcmp(tokens[t0 + 5], "bpp") != 0) {
1438 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1443 if (parser_read_uint32(&p.source.n_bytes_per_pkt, tokens[t0 + 6]) != 0) {
1444 snprintf(out, out_size, MSG_ARG_INVALID,
1451 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1455 p.action_profile_name = NULL;
1456 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1457 if (n_tokens < t0 + 2) {
1458 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1462 p.action_profile_name = tokens[t0 + 1];
1468 if ((n_tokens > t0) &&
1469 (strcmp(tokens[t0], "disabled") == 0)) {
1475 if (n_tokens != t0) {
1476 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1480 status = pipeline_port_in_create(pipeline_name,
1483 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1489 * pipeline <pipeline_name> port out
1491 * link <link_name> txq <txq_id>
1493 * | tmgr <tmgr_name>
1496 * | sink [file <file_name> pkts <max_n_pkts>]
1499 cmd_pipeline_port_out(char **tokens,
1504 struct port_out_params p;
1505 char *pipeline_name;
1508 memset(&p, 0, sizeof(p));
1511 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1515 pipeline_name = tokens[1];
1517 if (strcmp(tokens[2], "port") != 0) {
1518 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1522 if (strcmp(tokens[3], "out") != 0) {
1523 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
1527 if (strcmp(tokens[4], "bsz") != 0) {
1528 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1532 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1533 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1537 if (strcmp(tokens[6], "link") == 0) {
1538 if (n_tokens != 10) {
1539 snprintf(out, out_size, MSG_ARG_MISMATCH,
1540 "pipeline port out link");
1544 p.type = PORT_OUT_TXQ;
1546 p.dev_name = tokens[7];
1548 if (strcmp(tokens[8], "txq") != 0) {
1549 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
1553 if (parser_read_uint16(&p.txq.queue_id, tokens[9]) != 0) {
1554 snprintf(out, out_size, MSG_ARG_INVALID, "queue_id");
1557 } else if (strcmp(tokens[6], "swq") == 0) {
1558 if (n_tokens != 8) {
1559 snprintf(out, out_size, MSG_ARG_MISMATCH,
1560 "pipeline port out swq");
1564 p.type = PORT_OUT_SWQ;
1566 p.dev_name = tokens[7];
1567 } else if (strcmp(tokens[6], "tmgr") == 0) {
1568 if (n_tokens != 8) {
1569 snprintf(out, out_size, MSG_ARG_MISMATCH,
1570 "pipeline port out tmgr");
1574 p.type = PORT_OUT_TMGR;
1576 p.dev_name = tokens[7];
1577 } else if (strcmp(tokens[6], "tap") == 0) {
1578 if (n_tokens != 8) {
1579 snprintf(out, out_size, MSG_ARG_MISMATCH,
1580 "pipeline port out tap");
1584 p.type = PORT_OUT_TAP;
1586 p.dev_name = tokens[7];
1587 } else if (strcmp(tokens[6], "kni") == 0) {
1588 if (n_tokens != 8) {
1589 snprintf(out, out_size, MSG_ARG_MISMATCH,
1590 "pipeline port out kni");
1594 p.type = PORT_OUT_KNI;
1596 p.dev_name = tokens[7];
1597 } else if (strcmp(tokens[6], "sink") == 0) {
1598 if ((n_tokens != 7) && (n_tokens != 11)) {
1599 snprintf(out, out_size, MSG_ARG_MISMATCH,
1600 "pipeline port out sink");
1604 p.type = PORT_OUT_SINK;
1608 if (n_tokens == 7) {
1609 p.sink.file_name = NULL;
1610 p.sink.max_n_pkts = 0;
1612 if (strcmp(tokens[7], "file") != 0) {
1613 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1618 p.sink.file_name = tokens[8];
1620 if (strcmp(tokens[9], "pkts") != 0) {
1621 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pkts");
1625 if (parser_read_uint32(&p.sink.max_n_pkts, tokens[10]) != 0) {
1626 snprintf(out, out_size, MSG_ARG_INVALID, "max_n_pkts");
1631 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1635 status = pipeline_port_out_create(pipeline_name, &p);
1637 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1643 * pipeline <pipeline_name> table
1647 * offset <ip_header_offset>
1650 * offset <key_offset>
1656 * offset <key_offset>
1657 * buckets <n_buckets>
1661 * offset <ip_header_offset>
1664 * [action <table_action_profile_name>]
1667 cmd_pipeline_table(char **tokens,
1672 uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
1673 struct table_params p;
1674 char *pipeline_name;
1679 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1683 pipeline_name = tokens[1];
1685 if (strcmp(tokens[2], "table") != 0) {
1686 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1690 if (strcmp(tokens[3], "match") != 0) {
1691 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
1696 if (strcmp(tokens[t0], "acl") == 0) {
1697 if (n_tokens < t0 + 6) {
1698 snprintf(out, out_size, MSG_ARG_MISMATCH,
1699 "pipeline table acl");
1703 p.match_type = TABLE_ACL;
1705 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1706 p.match.acl.ip_version = 1;
1707 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1708 p.match.acl.ip_version = 0;
1710 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1715 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1716 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1720 if (parser_read_uint32(&p.match.acl.ip_header_offset,
1721 tokens[t0 + 3]) != 0) {
1722 snprintf(out, out_size, MSG_ARG_INVALID,
1723 "ip_header_offset");
1727 if (strcmp(tokens[t0 + 4], "size") != 0) {
1728 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1732 if (parser_read_uint32(&p.match.acl.n_rules,
1733 tokens[t0 + 5]) != 0) {
1734 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1739 } else if (strcmp(tokens[t0], "array") == 0) {
1740 if (n_tokens < t0 + 5) {
1741 snprintf(out, out_size, MSG_ARG_MISMATCH,
1742 "pipeline table array");
1746 p.match_type = TABLE_ARRAY;
1748 if (strcmp(tokens[t0 + 1], "offset") != 0) {
1749 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1753 if (parser_read_uint32(&p.match.array.key_offset,
1754 tokens[t0 + 2]) != 0) {
1755 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1759 if (strcmp(tokens[t0 + 3], "size") != 0) {
1760 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1764 if (parser_read_uint32(&p.match.array.n_keys,
1765 tokens[t0 + 4]) != 0) {
1766 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1771 } else if (strcmp(tokens[t0], "hash") == 0) {
1772 uint32_t key_mask_size = TABLE_RULE_MATCH_SIZE_MAX;
1774 if (n_tokens < t0 + 12) {
1775 snprintf(out, out_size, MSG_ARG_MISMATCH,
1776 "pipeline table hash");
1780 p.match_type = TABLE_HASH;
1782 if (strcmp(tokens[t0 + 1], "ext") == 0)
1783 p.match.hash.extendable_bucket = 1;
1784 else if (strcmp(tokens[t0 + 1], "lru") == 0)
1785 p.match.hash.extendable_bucket = 0;
1787 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1792 if (strcmp(tokens[t0 + 2], "key") != 0) {
1793 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
1797 if ((parser_read_uint32(&p.match.hash.key_size,
1798 tokens[t0 + 3]) != 0) ||
1799 (p.match.hash.key_size == 0) ||
1800 (p.match.hash.key_size > TABLE_RULE_MATCH_SIZE_MAX)) {
1801 snprintf(out, out_size, MSG_ARG_INVALID, "key_size");
1805 if (strcmp(tokens[t0 + 4], "mask") != 0) {
1806 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
1810 if ((parse_hex_string(tokens[t0 + 5],
1811 key_mask, &key_mask_size) != 0) ||
1812 (key_mask_size != p.match.hash.key_size)) {
1813 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
1816 p.match.hash.key_mask = key_mask;
1818 if (strcmp(tokens[t0 + 6], "offset") != 0) {
1819 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1823 if (parser_read_uint32(&p.match.hash.key_offset,
1824 tokens[t0 + 7]) != 0) {
1825 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1829 if (strcmp(tokens[t0 + 8], "buckets") != 0) {
1830 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buckets");
1834 if (parser_read_uint32(&p.match.hash.n_buckets,
1835 tokens[t0 + 9]) != 0) {
1836 snprintf(out, out_size, MSG_ARG_INVALID, "n_buckets");
1840 if (strcmp(tokens[t0 + 10], "size") != 0) {
1841 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1845 if (parser_read_uint32(&p.match.hash.n_keys,
1846 tokens[t0 + 11]) != 0) {
1847 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1852 } else if (strcmp(tokens[t0], "lpm") == 0) {
1853 if (n_tokens < t0 + 6) {
1854 snprintf(out, out_size, MSG_ARG_MISMATCH,
1855 "pipeline table lpm");
1859 p.match_type = TABLE_LPM;
1861 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1862 p.match.lpm.key_size = 4;
1863 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1864 p.match.lpm.key_size = 16;
1866 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1871 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1872 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1876 if (parser_read_uint32(&p.match.lpm.key_offset,
1877 tokens[t0 + 3]) != 0) {
1878 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1882 if (strcmp(tokens[t0 + 4], "size") != 0) {
1883 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1887 if (parser_read_uint32(&p.match.lpm.n_rules,
1888 tokens[t0 + 5]) != 0) {
1889 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1894 } else if (strcmp(tokens[t0], "stub") == 0) {
1895 if (n_tokens < t0 + 1) {
1896 snprintf(out, out_size, MSG_ARG_MISMATCH,
1897 "pipeline table stub");
1901 p.match_type = TABLE_STUB;
1905 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1909 p.action_profile_name = NULL;
1910 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1911 if (n_tokens < t0 + 2) {
1912 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1916 p.action_profile_name = tokens[t0 + 1];
1921 if (n_tokens > t0) {
1922 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1926 status = pipeline_table_create(pipeline_name, &p);
1928 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1934 * pipeline <pipeline_name> port in <port_id> table <table_id>
1937 cmd_pipeline_port_in_table(char **tokens,
1942 char *pipeline_name;
1943 uint32_t port_id, table_id;
1946 if (n_tokens != 7) {
1947 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1951 pipeline_name = tokens[1];
1953 if (strcmp(tokens[2], "port") != 0) {
1954 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1958 if (strcmp(tokens[3], "in") != 0) {
1959 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1963 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
1964 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
1968 if (strcmp(tokens[5], "table") != 0) {
1969 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1973 if (parser_read_uint32(&table_id, tokens[6]) != 0) {
1974 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
1978 status = pipeline_port_in_connect_to_table(pipeline_name,
1982 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1988 * pipeline <pipeline_name> port in <port_id> stats read [clear]
1991 #define MSG_PIPELINE_PORT_IN_STATS \
1992 "Pkts in: %" PRIu64 "\n" \
1993 "Pkts dropped by AH: %" PRIu64 "\n" \
1994 "Pkts dropped by other: %" PRIu64 "\n"
1997 cmd_pipeline_port_in_stats(char **tokens,
2002 struct rte_pipeline_port_in_stats stats;
2003 char *pipeline_name;
2007 if ((n_tokens != 7) && (n_tokens != 8)) {
2008 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2012 pipeline_name = tokens[1];
2014 if (strcmp(tokens[2], "port") != 0) {
2015 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2019 if (strcmp(tokens[3], "in") != 0) {
2020 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2024 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2025 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2029 if (strcmp(tokens[5], "stats") != 0) {
2030 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2034 if (strcmp(tokens[6], "read") != 0) {
2035 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2040 if (n_tokens == 8) {
2041 if (strcmp(tokens[7], "clear") != 0) {
2042 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2049 status = pipeline_port_in_stats_read(pipeline_name,
2054 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2058 snprintf(out, out_size, MSG_PIPELINE_PORT_IN_STATS,
2059 stats.stats.n_pkts_in,
2060 stats.n_pkts_dropped_by_ah,
2061 stats.stats.n_pkts_drop);
2065 * pipeline <pipeline_name> port in <port_id> enable
2068 cmd_pipeline_port_in_enable(char **tokens,
2073 char *pipeline_name;
2077 if (n_tokens != 6) {
2078 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2082 pipeline_name = tokens[1];
2084 if (strcmp(tokens[2], "port") != 0) {
2085 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2089 if (strcmp(tokens[3], "in") != 0) {
2090 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2094 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2095 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2099 if (strcmp(tokens[5], "enable") != 0) {
2100 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
2104 status = pipeline_port_in_enable(pipeline_name, port_id);
2106 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2112 * pipeline <pipeline_name> port in <port_id> disable
2115 cmd_pipeline_port_in_disable(char **tokens,
2120 char *pipeline_name;
2124 if (n_tokens != 6) {
2125 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2129 pipeline_name = tokens[1];
2131 if (strcmp(tokens[2], "port") != 0) {
2132 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2136 if (strcmp(tokens[3], "in") != 0) {
2137 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2141 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2142 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2146 if (strcmp(tokens[5], "disable") != 0) {
2147 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
2151 status = pipeline_port_in_disable(pipeline_name, port_id);
2153 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2159 * pipeline <pipeline_name> port out <port_id> stats read [clear]
2161 #define MSG_PIPELINE_PORT_OUT_STATS \
2162 "Pkts in: %" PRIu64 "\n" \
2163 "Pkts dropped by AH: %" PRIu64 "\n" \
2164 "Pkts dropped by other: %" PRIu64 "\n"
2167 cmd_pipeline_port_out_stats(char **tokens,
2172 struct rte_pipeline_port_out_stats stats;
2173 char *pipeline_name;
2177 if ((n_tokens != 7) && (n_tokens != 8)) {
2178 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2182 pipeline_name = tokens[1];
2184 if (strcmp(tokens[2], "port") != 0) {
2185 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2189 if (strcmp(tokens[3], "out") != 0) {
2190 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
2194 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2195 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2199 if (strcmp(tokens[5], "stats") != 0) {
2200 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2204 if (strcmp(tokens[6], "read") != 0) {
2205 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2210 if (n_tokens == 8) {
2211 if (strcmp(tokens[7], "clear") != 0) {
2212 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2219 status = pipeline_port_out_stats_read(pipeline_name,
2224 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2228 snprintf(out, out_size, MSG_PIPELINE_PORT_OUT_STATS,
2229 stats.stats.n_pkts_in,
2230 stats.n_pkts_dropped_by_ah,
2231 stats.stats.n_pkts_drop);
2235 * pipeline <pipeline_name> table <table_id> stats read [clear]
2237 #define MSG_PIPELINE_TABLE_STATS \
2238 "Pkts in: %" PRIu64 "\n" \
2239 "Pkts in with lookup miss: %" PRIu64 "\n" \
2240 "Pkts in with lookup hit dropped by AH: %" PRIu64 "\n" \
2241 "Pkts in with lookup hit dropped by others: %" PRIu64 "\n" \
2242 "Pkts in with lookup miss dropped by AH: %" PRIu64 "\n" \
2243 "Pkts in with lookup miss dropped by others: %" PRIu64 "\n"
2246 cmd_pipeline_table_stats(char **tokens,
2251 struct rte_pipeline_table_stats stats;
2252 char *pipeline_name;
2256 if ((n_tokens != 6) && (n_tokens != 7)) {
2257 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2261 pipeline_name = tokens[1];
2263 if (strcmp(tokens[2], "table") != 0) {
2264 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2268 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
2269 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
2273 if (strcmp(tokens[4], "stats") != 0) {
2274 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2278 if (strcmp(tokens[5], "read") != 0) {
2279 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2284 if (n_tokens == 7) {
2285 if (strcmp(tokens[6], "clear") != 0) {
2286 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2293 status = pipeline_table_stats_read(pipeline_name,
2298 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2302 snprintf(out, out_size, MSG_PIPELINE_TABLE_STATS,
2303 stats.stats.n_pkts_in,
2304 stats.stats.n_pkts_lookup_miss,
2305 stats.n_pkts_dropped_by_lkp_hit_ah,
2306 stats.n_pkts_dropped_lkp_hit,
2307 stats.n_pkts_dropped_by_lkp_miss_ah,
2308 stats.n_pkts_dropped_lkp_miss);
2316 * priority <priority>
2317 * ipv4 | ipv6 <sa> <sa_depth> <da> <da_depth>
2318 * <sp0> <sp1> <dp0> <dp1> <proto>
2322 * | ipv4_5tuple <sa> <da> <sp> <dp> <proto>
2323 * | ipv6_5tuple <sa> <da> <sp> <dp> <proto>
2324 * | ipv4_addr <addr>
2325 * | ipv6_addr <addr>
2326 * | qinq <svlan> <cvlan>
2328 * ipv4 | ipv6 <addr> <depth>
2330 struct pkt_key_qinq {
2331 uint16_t ethertype_svlan;
2333 uint16_t ethertype_cvlan;
2335 } __attribute__((__packed__));
2337 struct pkt_key_ipv4_5tuple {
2338 uint8_t time_to_live;
2340 uint16_t hdr_checksum;
2345 } __attribute__((__packed__));
2347 struct pkt_key_ipv6_5tuple {
2348 uint16_t payload_length;
2355 } __attribute__((__packed__));
2357 struct pkt_key_ipv4_addr {
2359 } __attribute__((__packed__));
2361 struct pkt_key_ipv6_addr {
2363 } __attribute__((__packed__));
2366 parse_match(char **tokens,
2370 struct table_rule_match *m)
2372 memset(m, 0, sizeof(*m));
2377 if (strcmp(tokens[0], "match") != 0) {
2378 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
2382 if (strcmp(tokens[1], "acl") == 0) {
2383 if (n_tokens < 14) {
2384 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2388 m->match_type = TABLE_ACL;
2390 if (strcmp(tokens[2], "priority") != 0) {
2391 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority");
2395 if (parser_read_uint32(&m->match.acl.priority,
2397 snprintf(out, out_size, MSG_ARG_INVALID, "priority");
2401 if (strcmp(tokens[4], "ipv4") == 0) {
2402 struct in_addr saddr, daddr;
2404 m->match.acl.ip_version = 1;
2406 if (parse_ipv4_addr(tokens[5], &saddr) != 0) {
2407 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2410 m->match.acl.ipv4.sa = rte_be_to_cpu_32(saddr.s_addr);
2412 if (parse_ipv4_addr(tokens[7], &daddr) != 0) {
2413 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2416 m->match.acl.ipv4.da = rte_be_to_cpu_32(daddr.s_addr);
2417 } else if (strcmp(tokens[4], "ipv6") == 0) {
2418 struct in6_addr saddr, daddr;
2420 m->match.acl.ip_version = 0;
2422 if (parse_ipv6_addr(tokens[5], &saddr) != 0) {
2423 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2426 memcpy(m->match.acl.ipv6.sa, saddr.s6_addr, 16);
2428 if (parse_ipv6_addr(tokens[7], &daddr) != 0) {
2429 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2432 memcpy(m->match.acl.ipv6.da, daddr.s6_addr, 16);
2434 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
2439 if (parser_read_uint32(&m->match.acl.sa_depth,
2441 snprintf(out, out_size, MSG_ARG_INVALID, "sa_depth");
2445 if (parser_read_uint32(&m->match.acl.da_depth,
2447 snprintf(out, out_size, MSG_ARG_INVALID, "da_depth");
2451 if (parser_read_uint16(&m->match.acl.sp0, tokens[9]) != 0) {
2452 snprintf(out, out_size, MSG_ARG_INVALID, "sp0");
2456 if (parser_read_uint16(&m->match.acl.sp1, tokens[10]) != 0) {
2457 snprintf(out, out_size, MSG_ARG_INVALID, "sp1");
2461 if (parser_read_uint16(&m->match.acl.dp0, tokens[11]) != 0) {
2462 snprintf(out, out_size, MSG_ARG_INVALID, "dp0");
2466 if (parser_read_uint16(&m->match.acl.dp1, tokens[12]) != 0) {
2467 snprintf(out, out_size, MSG_ARG_INVALID, "dp1");
2471 if (parser_read_uint8(&m->match.acl.proto, tokens[13]) != 0) {
2472 snprintf(out, out_size, MSG_ARG_INVALID, "proto");
2476 m->match.acl.proto_mask = 0xff;
2481 if (strcmp(tokens[1], "array") == 0) {
2483 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2487 m->match_type = TABLE_ARRAY;
2489 if (parser_read_uint32(&m->match.array.pos, tokens[2]) != 0) {
2490 snprintf(out, out_size, MSG_ARG_INVALID, "pos");
2497 if (strcmp(tokens[1], "hash") == 0) {
2499 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2503 m->match_type = TABLE_HASH;
2505 if (strcmp(tokens[2], "raw") == 0) {
2506 uint32_t key_size = TABLE_RULE_MATCH_SIZE_MAX;
2509 snprintf(out, out_size, MSG_ARG_MISMATCH,
2514 if (parse_hex_string(tokens[3],
2515 m->match.hash.key, &key_size) != 0) {
2516 snprintf(out, out_size, MSG_ARG_INVALID, "key");
2523 if (strcmp(tokens[2], "ipv4_5tuple") == 0) {
2524 struct pkt_key_ipv4_5tuple *ipv4 =
2525 (struct pkt_key_ipv4_5tuple *) m->match.hash.key;
2526 struct in_addr saddr, daddr;
2531 snprintf(out, out_size, MSG_ARG_MISMATCH,
2536 if (parse_ipv4_addr(tokens[3], &saddr) != 0) {
2537 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2541 if (parse_ipv4_addr(tokens[4], &daddr) != 0) {
2542 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2546 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2547 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2551 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2552 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2556 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2557 snprintf(out, out_size, MSG_ARG_INVALID,
2562 ipv4->sa = saddr.s_addr;
2563 ipv4->da = daddr.s_addr;
2564 ipv4->sp = rte_cpu_to_be_16(sp);
2565 ipv4->dp = rte_cpu_to_be_16(dp);
2566 ipv4->proto = proto;
2569 } /* hash ipv4_5tuple */
2571 if (strcmp(tokens[2], "ipv6_5tuple") == 0) {
2572 struct pkt_key_ipv6_5tuple *ipv6 =
2573 (struct pkt_key_ipv6_5tuple *) m->match.hash.key;
2574 struct in6_addr saddr, daddr;
2579 snprintf(out, out_size, MSG_ARG_MISMATCH,
2584 if (parse_ipv6_addr(tokens[3], &saddr) != 0) {
2585 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2589 if (parse_ipv6_addr(tokens[4], &daddr) != 0) {
2590 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2594 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2595 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2599 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2600 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2604 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2605 snprintf(out, out_size, MSG_ARG_INVALID,
2610 memcpy(ipv6->sa, saddr.s6_addr, 16);
2611 memcpy(ipv6->da, daddr.s6_addr, 16);
2612 ipv6->sp = rte_cpu_to_be_16(sp);
2613 ipv6->dp = rte_cpu_to_be_16(dp);
2614 ipv6->proto = proto;
2617 } /* hash ipv6_5tuple */
2619 if (strcmp(tokens[2], "ipv4_addr") == 0) {
2620 struct pkt_key_ipv4_addr *ipv4_addr =
2621 (struct pkt_key_ipv4_addr *) m->match.hash.key;
2622 struct in_addr addr;
2625 snprintf(out, out_size, MSG_ARG_MISMATCH,
2630 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2631 snprintf(out, out_size, MSG_ARG_INVALID,
2636 ipv4_addr->addr = addr.s_addr;
2639 } /* hash ipv4_addr */
2641 if (strcmp(tokens[2], "ipv6_addr") == 0) {
2642 struct pkt_key_ipv6_addr *ipv6_addr =
2643 (struct pkt_key_ipv6_addr *) m->match.hash.key;
2644 struct in6_addr addr;
2647 snprintf(out, out_size, MSG_ARG_MISMATCH,
2652 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2653 snprintf(out, out_size, MSG_ARG_INVALID,
2658 memcpy(ipv6_addr->addr, addr.s6_addr, 16);
2661 } /* hash ipv6_5tuple */
2663 if (strcmp(tokens[2], "qinq") == 0) {
2664 struct pkt_key_qinq *qinq =
2665 (struct pkt_key_qinq *) m->match.hash.key;
2666 uint16_t svlan, cvlan;
2669 snprintf(out, out_size, MSG_ARG_MISMATCH,
2674 if ((parser_read_uint16(&svlan, tokens[3]) != 0) ||
2676 snprintf(out, out_size, MSG_ARG_INVALID,
2681 if ((parser_read_uint16(&cvlan, tokens[4]) != 0) ||
2683 snprintf(out, out_size, MSG_ARG_INVALID,
2688 qinq->svlan = rte_cpu_to_be_16(svlan);
2689 qinq->cvlan = rte_cpu_to_be_16(cvlan);
2694 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2698 if (strcmp(tokens[1], "lpm") == 0) {
2700 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2704 m->match_type = TABLE_LPM;
2706 if (strcmp(tokens[2], "ipv4") == 0) {
2707 struct in_addr addr;
2709 m->match.lpm.ip_version = 1;
2711 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2712 snprintf(out, out_size, MSG_ARG_INVALID,
2717 m->match.lpm.ipv4 = rte_be_to_cpu_32(addr.s_addr);
2718 } else if (strcmp(tokens[2], "ipv6") == 0) {
2719 struct in6_addr addr;
2721 m->match.lpm.ip_version = 0;
2723 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2724 snprintf(out, out_size, MSG_ARG_INVALID,
2729 memcpy(m->match.lpm.ipv6, addr.s6_addr, 16);
2731 snprintf(out, out_size, MSG_ARG_MISMATCH,
2736 if (parser_read_uint8(&m->match.lpm.depth, tokens[4]) != 0) {
2737 snprintf(out, out_size, MSG_ARG_INVALID, "depth");
2744 snprintf(out, out_size, MSG_ARG_MISMATCH,
2745 "acl or array or hash or lpm");
2757 * | table <table_id>
2758 * [balance <out0> ... <out7>]
2760 * tc0 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2761 * [tc1 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2762 * tc2 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2763 * tc3 meter <meter_profile_id> policer g <pa> y <pa> r <pa>]]
2764 * [tm subport <subport_id> pipe <pipe_id>]
2767 * | vlan <da> <sa> <pcp> <dei> <vid>
2768 * | qinq <da> <sa> <pcp> <dei> <vid> <pcp> <dei> <vid>
2769 * | mpls unicast | multicast
2771 * label0 <label> <tc> <ttl>
2772 * [label1 <label> <tc> <ttl>
2773 * [label2 <label> <tc> <ttl>
2774 * [label3 <label> <tc> <ttl>]]]
2775 * | pppoe <da> <sa> <session_id>]
2776 * [nat ipv4 | ipv6 <addr> <port>]
2782 * <pa> ::= g | y | r | drop
2785 parse_table_action_fwd(char **tokens,
2787 struct table_rule_action *a)
2789 if ((n_tokens == 0) || (strcmp(tokens[0], "fwd") != 0))
2795 if (n_tokens && (strcmp(tokens[0], "drop") == 0)) {
2796 a->fwd.action = RTE_PIPELINE_ACTION_DROP;
2797 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2801 if (n_tokens && (strcmp(tokens[0], "port") == 0)) {
2804 if ((n_tokens < 2) ||
2805 parser_read_uint32(&id, tokens[1]))
2808 a->fwd.action = RTE_PIPELINE_ACTION_PORT;
2810 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2814 if (n_tokens && (strcmp(tokens[0], "meta") == 0)) {
2815 a->fwd.action = RTE_PIPELINE_ACTION_PORT_META;
2816 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2820 if (n_tokens && (strcmp(tokens[0], "table") == 0)) {
2823 if ((n_tokens < 2) ||
2824 parser_read_uint32(&id, tokens[1]))
2827 a->fwd.action = RTE_PIPELINE_ACTION_TABLE;
2829 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2837 parse_table_action_balance(char **tokens,
2839 struct table_rule_action *a)
2843 if ((n_tokens == 0) || (strcmp(tokens[0], "balance") != 0))
2849 if (n_tokens < RTE_TABLE_ACTION_LB_TABLE_SIZE)
2852 for (i = 0; i < RTE_TABLE_ACTION_LB_TABLE_SIZE; i++)
2853 if (parser_read_uint32(&a->lb.out[i], tokens[i]) != 0)
2856 a->action_mask |= 1 << RTE_TABLE_ACTION_LB;
2857 return 1 + RTE_TABLE_ACTION_LB_TABLE_SIZE;
2862 parse_policer_action(char *token, enum rte_table_action_policer *a)
2864 if (strcmp(token, "g") == 0) {
2865 *a = RTE_TABLE_ACTION_POLICER_COLOR_GREEN;
2869 if (strcmp(token, "y") == 0) {
2870 *a = RTE_TABLE_ACTION_POLICER_COLOR_YELLOW;
2874 if (strcmp(token, "r") == 0) {
2875 *a = RTE_TABLE_ACTION_POLICER_COLOR_RED;
2879 if (strcmp(token, "drop") == 0) {
2880 *a = RTE_TABLE_ACTION_POLICER_DROP;
2888 parse_table_action_meter_tc(char **tokens,
2890 struct rte_table_action_mtr_tc_params *mtr)
2892 if ((n_tokens < 9) ||
2893 strcmp(tokens[0], "meter") ||
2894 parser_read_uint32(&mtr->meter_profile_id, tokens[1]) ||
2895 strcmp(tokens[2], "policer") ||
2896 strcmp(tokens[3], "g") ||
2897 parse_policer_action(tokens[4], &mtr->policer[e_RTE_METER_GREEN]) ||
2898 strcmp(tokens[5], "y") ||
2899 parse_policer_action(tokens[6], &mtr->policer[e_RTE_METER_YELLOW]) ||
2900 strcmp(tokens[7], "r") ||
2901 parse_policer_action(tokens[8], &mtr->policer[e_RTE_METER_RED]))
2908 parse_table_action_meter(char **tokens,
2910 struct table_rule_action *a)
2912 if ((n_tokens == 0) || strcmp(tokens[0], "meter"))
2918 if ((n_tokens < 10) ||
2919 strcmp(tokens[0], "tc0") ||
2920 (parse_table_action_meter_tc(tokens + 1,
2922 &a->mtr.mtr[0]) == 0))
2928 if ((n_tokens == 0) || strcmp(tokens[0], "tc1")) {
2930 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
2934 if ((n_tokens < 30) ||
2935 (parse_table_action_meter_tc(tokens + 1,
2936 n_tokens - 1, &a->mtr.mtr[1]) == 0) ||
2937 strcmp(tokens[10], "tc2") ||
2938 (parse_table_action_meter_tc(tokens + 11,
2939 n_tokens - 11, &a->mtr.mtr[2]) == 0) ||
2940 strcmp(tokens[20], "tc3") ||
2941 (parse_table_action_meter_tc(tokens + 21,
2942 n_tokens - 21, &a->mtr.mtr[3]) == 0))
2945 a->mtr.tc_mask = 0xF;
2946 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
2947 return 1 + 10 + 3 * 10;
2951 parse_table_action_tm(char **tokens,
2953 struct table_rule_action *a)
2955 uint32_t subport_id, pipe_id;
2957 if ((n_tokens < 5) ||
2958 strcmp(tokens[0], "tm") ||
2959 strcmp(tokens[1], "subport") ||
2960 parser_read_uint32(&subport_id, tokens[2]) ||
2961 strcmp(tokens[3], "pipe") ||
2962 parser_read_uint32(&pipe_id, tokens[4]))
2965 a->tm.subport_id = subport_id;
2966 a->tm.pipe_id = pipe_id;
2967 a->action_mask |= 1 << RTE_TABLE_ACTION_TM;
2972 parse_table_action_encap(char **tokens,
2974 struct table_rule_action *a)
2976 if ((n_tokens == 0) || strcmp(tokens[0], "encap"))
2983 if (n_tokens && (strcmp(tokens[0], "ether") == 0)) {
2984 if ((n_tokens < 3) ||
2985 parse_mac_addr(tokens[1], &a->encap.ether.ether.da) ||
2986 parse_mac_addr(tokens[2], &a->encap.ether.ether.sa))
2989 a->encap.type = RTE_TABLE_ACTION_ENCAP_ETHER;
2990 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
2995 if (n_tokens && (strcmp(tokens[0], "vlan") == 0)) {
2996 uint32_t pcp, dei, vid;
2998 if ((n_tokens < 6) ||
2999 parse_mac_addr(tokens[1], &a->encap.vlan.ether.da) ||
3000 parse_mac_addr(tokens[2], &a->encap.vlan.ether.sa) ||
3001 parser_read_uint32(&pcp, tokens[3]) ||
3003 parser_read_uint32(&dei, tokens[4]) ||
3005 parser_read_uint32(&vid, tokens[5]) ||
3009 a->encap.vlan.vlan.pcp = pcp & 0x7;
3010 a->encap.vlan.vlan.dei = dei & 0x1;
3011 a->encap.vlan.vlan.vid = vid & 0xFFF;
3012 a->encap.type = RTE_TABLE_ACTION_ENCAP_VLAN;
3013 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3018 if (n_tokens && (strcmp(tokens[0], "qinq") == 0)) {
3019 uint32_t svlan_pcp, svlan_dei, svlan_vid;
3020 uint32_t cvlan_pcp, cvlan_dei, cvlan_vid;
3022 if ((n_tokens < 9) ||
3023 parse_mac_addr(tokens[1], &a->encap.qinq.ether.da) ||
3024 parse_mac_addr(tokens[2], &a->encap.qinq.ether.sa) ||
3025 parser_read_uint32(&svlan_pcp, tokens[3]) ||
3026 (svlan_pcp > 0x7) ||
3027 parser_read_uint32(&svlan_dei, tokens[4]) ||
3028 (svlan_dei > 0x1) ||
3029 parser_read_uint32(&svlan_vid, tokens[5]) ||
3030 (svlan_vid > 0xFFF) ||
3031 parser_read_uint32(&cvlan_pcp, tokens[6]) ||
3032 (cvlan_pcp > 0x7) ||
3033 parser_read_uint32(&cvlan_dei, tokens[7]) ||
3034 (cvlan_dei > 0x1) ||
3035 parser_read_uint32(&cvlan_vid, tokens[8]) ||
3036 (cvlan_vid > 0xFFF))
3039 a->encap.qinq.svlan.pcp = svlan_pcp & 0x7;
3040 a->encap.qinq.svlan.dei = svlan_dei & 0x1;
3041 a->encap.qinq.svlan.vid = svlan_vid & 0xFFF;
3042 a->encap.qinq.cvlan.pcp = cvlan_pcp & 0x7;
3043 a->encap.qinq.cvlan.dei = cvlan_dei & 0x1;
3044 a->encap.qinq.cvlan.vid = cvlan_vid & 0xFFF;
3045 a->encap.type = RTE_TABLE_ACTION_ENCAP_QINQ;
3046 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3051 if (n_tokens && (strcmp(tokens[0], "mpls") == 0)) {
3052 uint32_t label, tc, ttl;
3057 if (strcmp(tokens[1], "unicast") == 0)
3058 a->encap.mpls.unicast = 1;
3059 else if (strcmp(tokens[1], "multicast") == 0)
3060 a->encap.mpls.unicast = 0;
3064 if (parse_mac_addr(tokens[2], &a->encap.mpls.ether.da) ||
3065 parse_mac_addr(tokens[3], &a->encap.mpls.ether.sa) ||
3066 strcmp(tokens[4], "label0") ||
3067 parser_read_uint32(&label, tokens[5]) ||
3068 (label > 0xFFFFF) ||
3069 parser_read_uint32(&tc, tokens[6]) ||
3071 parser_read_uint32(&ttl, tokens[7]) ||
3075 a->encap.mpls.mpls[0].label = label;
3076 a->encap.mpls.mpls[0].tc = tc;
3077 a->encap.mpls.mpls[0].ttl = ttl;
3082 if ((n_tokens == 0) || strcmp(tokens[0], "label1")) {
3083 a->encap.mpls.mpls_count = 1;
3084 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3085 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3089 if ((n_tokens < 4) ||
3090 parser_read_uint32(&label, tokens[1]) ||
3091 (label > 0xFFFFF) ||
3092 parser_read_uint32(&tc, tokens[2]) ||
3094 parser_read_uint32(&ttl, tokens[3]) ||
3098 a->encap.mpls.mpls[1].label = label;
3099 a->encap.mpls.mpls[1].tc = tc;
3100 a->encap.mpls.mpls[1].ttl = ttl;
3105 if ((n_tokens == 0) || strcmp(tokens[0], "label2")) {
3106 a->encap.mpls.mpls_count = 2;
3107 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3108 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3112 if ((n_tokens < 4) ||
3113 parser_read_uint32(&label, tokens[1]) ||
3114 (label > 0xFFFFF) ||
3115 parser_read_uint32(&tc, tokens[2]) ||
3117 parser_read_uint32(&ttl, tokens[3]) ||
3121 a->encap.mpls.mpls[2].label = label;
3122 a->encap.mpls.mpls[2].tc = tc;
3123 a->encap.mpls.mpls[2].ttl = ttl;
3128 if ((n_tokens == 0) || strcmp(tokens[0], "label3")) {
3129 a->encap.mpls.mpls_count = 3;
3130 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3131 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3132 return 1 + 8 + 4 + 4;
3135 if ((n_tokens < 4) ||
3136 parser_read_uint32(&label, tokens[1]) ||
3137 (label > 0xFFFFF) ||
3138 parser_read_uint32(&tc, tokens[2]) ||
3140 parser_read_uint32(&ttl, tokens[3]) ||
3144 a->encap.mpls.mpls[3].label = label;
3145 a->encap.mpls.mpls[3].tc = tc;
3146 a->encap.mpls.mpls[3].ttl = ttl;
3148 a->encap.mpls.mpls_count = 4;
3149 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3150 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3151 return 1 + 8 + 4 + 4 + 4;
3155 if (n_tokens && (strcmp(tokens[0], "pppoe") == 0)) {
3156 if ((n_tokens < 4) ||
3157 parse_mac_addr(tokens[1], &a->encap.pppoe.ether.da) ||
3158 parse_mac_addr(tokens[2], &a->encap.pppoe.ether.sa) ||
3159 parser_read_uint16(&a->encap.pppoe.pppoe.session_id,
3163 a->encap.type = RTE_TABLE_ACTION_ENCAP_PPPOE;
3164 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3172 parse_table_action_nat(char **tokens,
3174 struct table_rule_action *a)
3176 if ((n_tokens < 4) ||
3177 strcmp(tokens[0], "nat"))
3180 if (strcmp(tokens[1], "ipv4") == 0) {
3181 struct in_addr addr;
3184 if (parse_ipv4_addr(tokens[2], &addr) ||
3185 parser_read_uint16(&port, tokens[3]))
3188 a->nat.ip_version = 1;
3189 a->nat.addr.ipv4 = rte_be_to_cpu_32(addr.s_addr);
3191 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3195 if (strcmp(tokens[1], "ipv6") == 0) {
3196 struct in6_addr addr;
3199 if (parse_ipv6_addr(tokens[2], &addr) ||
3200 parser_read_uint16(&port, tokens[3]))
3203 a->nat.ip_version = 0;
3204 memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
3206 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3214 parse_table_action_ttl(char **tokens,
3216 struct table_rule_action *a)
3218 if ((n_tokens < 2) ||
3219 strcmp(tokens[0], "ttl"))
3222 if (strcmp(tokens[1], "dec") == 0)
3223 a->ttl.decrement = 1;
3224 else if (strcmp(tokens[1], "keep") == 0)
3225 a->ttl.decrement = 0;
3229 a->action_mask |= 1 << RTE_TABLE_ACTION_TTL;
3234 parse_table_action_stats(char **tokens,
3236 struct table_rule_action *a)
3238 if ((n_tokens < 1) ||
3239 strcmp(tokens[0], "stats"))
3242 a->stats.n_packets = 0;
3243 a->stats.n_bytes = 0;
3244 a->action_mask |= 1 << RTE_TABLE_ACTION_STATS;
3249 parse_table_action_time(char **tokens,
3251 struct table_rule_action *a)
3253 if ((n_tokens < 1) ||
3254 strcmp(tokens[0], "time"))
3257 a->time.time = rte_rdtsc();
3258 a->action_mask |= 1 << RTE_TABLE_ACTION_TIME;
3263 parse_table_action(char **tokens,
3267 struct table_rule_action *a)
3269 uint32_t n_tokens0 = n_tokens;
3271 memset(a, 0, sizeof(*a));
3273 if ((n_tokens < 2) ||
3274 strcmp(tokens[0], "action"))
3280 if (n_tokens && (strcmp(tokens[0], "fwd") == 0)) {
3283 n = parse_table_action_fwd(tokens, n_tokens, a);
3285 snprintf(out, out_size, MSG_ARG_INVALID,
3294 if (n_tokens && (strcmp(tokens[0], "balance") == 0)) {
3297 n = parse_table_action_balance(tokens, n_tokens, a);
3299 snprintf(out, out_size, MSG_ARG_INVALID,
3308 if (n_tokens && (strcmp(tokens[0], "meter") == 0)) {
3311 n = parse_table_action_meter(tokens, n_tokens, a);
3313 snprintf(out, out_size, MSG_ARG_INVALID,
3322 if (n_tokens && (strcmp(tokens[0], "tm") == 0)) {
3325 n = parse_table_action_tm(tokens, n_tokens, a);
3327 snprintf(out, out_size, MSG_ARG_INVALID,
3336 if (n_tokens && (strcmp(tokens[0], "encap") == 0)) {
3339 n = parse_table_action_encap(tokens, n_tokens, a);
3341 snprintf(out, out_size, MSG_ARG_INVALID,
3350 if (n_tokens && (strcmp(tokens[0], "nat") == 0)) {
3353 n = parse_table_action_nat(tokens, n_tokens, a);
3355 snprintf(out, out_size, MSG_ARG_INVALID,
3364 if (n_tokens && (strcmp(tokens[0], "ttl") == 0)) {
3367 n = parse_table_action_ttl(tokens, n_tokens, a);
3369 snprintf(out, out_size, MSG_ARG_INVALID,
3378 if (n_tokens && (strcmp(tokens[0], "stats") == 0)) {
3381 n = parse_table_action_stats(tokens, n_tokens, a);
3383 snprintf(out, out_size, MSG_ARG_INVALID,
3392 if (n_tokens && (strcmp(tokens[0], "time") == 0)) {
3395 n = parse_table_action_time(tokens, n_tokens, a);
3397 snprintf(out, out_size, MSG_ARG_INVALID,
3406 if (n_tokens0 - n_tokens == 1) {
3407 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3411 return n_tokens0 - n_tokens;
3415 * pipeline <pipeline_name> table <table_id> rule add
3417 * action <table_action>
3420 cmd_pipeline_table_rule_add(char **tokens,
3425 struct table_rule_match m;
3426 struct table_rule_action a;
3427 char *pipeline_name;
3429 uint32_t table_id, t0, n_tokens_parsed;
3433 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3437 pipeline_name = tokens[1];
3439 if (strcmp(tokens[2], "table") != 0) {
3440 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3444 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3445 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3449 if (strcmp(tokens[4], "rule") != 0) {
3450 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3454 if (strcmp(tokens[5], "add") != 0) {
3455 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3462 n_tokens_parsed = parse_match(tokens + t0,
3467 if (n_tokens_parsed == 0)
3469 t0 += n_tokens_parsed;
3472 n_tokens_parsed = parse_table_action(tokens + t0,
3477 if (n_tokens_parsed == 0)
3479 t0 += n_tokens_parsed;
3481 if (t0 != n_tokens) {
3482 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
3486 status = pipeline_table_rule_add(pipeline_name, table_id,
3489 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3495 * pipeline <pipeline_name> table <table_id> rule add
3503 * | table <table_id>
3506 cmd_pipeline_table_rule_add_default(char **tokens,
3511 struct table_rule_action action;
3513 char *pipeline_name;
3517 if ((n_tokens != 11) && (n_tokens != 12)) {
3518 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3522 pipeline_name = tokens[1];
3524 if (strcmp(tokens[2], "table") != 0) {
3525 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3529 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3530 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3534 if (strcmp(tokens[4], "rule") != 0) {
3535 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3539 if (strcmp(tokens[5], "add") != 0) {
3540 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3544 if (strcmp(tokens[6], "match") != 0) {
3545 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3549 if (strcmp(tokens[7], "default") != 0) {
3550 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3554 if (strcmp(tokens[8], "action") != 0) {
3555 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3559 if (strcmp(tokens[9], "fwd") != 0) {
3560 snprintf(out, out_size, MSG_ARG_INVALID, "fwd");
3564 action.action_mask = 1 << RTE_TABLE_ACTION_FWD;
3566 if (strcmp(tokens[10], "drop") == 0) {
3567 if (n_tokens != 11) {
3568 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3572 action.fwd.action = RTE_PIPELINE_ACTION_DROP;
3573 } else if (strcmp(tokens[10], "port") == 0) {
3576 if (n_tokens != 12) {
3577 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3581 if (parser_read_uint32(&id, tokens[11]) != 0) {
3582 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
3586 action.fwd.action = RTE_PIPELINE_ACTION_PORT;
3588 } else if (strcmp(tokens[10], "meta") == 0) {
3589 if (n_tokens != 11) {
3590 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3594 action.fwd.action = RTE_PIPELINE_ACTION_PORT_META;
3595 } else if (strcmp(tokens[10], "table") == 0) {
3598 if (n_tokens != 12) {
3599 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3603 if (parser_read_uint32(&id, tokens[11]) != 0) {
3604 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3608 action.fwd.action = RTE_PIPELINE_ACTION_TABLE;
3611 snprintf(out, out_size, MSG_ARG_INVALID,
3612 "drop or port or meta or table");
3616 status = pipeline_table_rule_add_default(pipeline_name,
3621 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3627 * pipeline <pipeline_name> table <table_id> rule add bulk <file_name> <n_rules>
3630 * - line format: match <match> action <action>
3633 cli_rule_file_process(const char *file_name,
3634 size_t line_len_max,
3635 struct table_rule_match *m,
3636 struct table_rule_action *a,
3638 uint32_t *line_number,
3643 cmd_pipeline_table_rule_add_bulk(char **tokens,
3648 struct table_rule_match *match;
3649 struct table_rule_action *action;
3651 char *pipeline_name, *file_name;
3652 uint32_t table_id, n_rules, n_rules_parsed, line_number;
3655 if (n_tokens != 9) {
3656 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3660 pipeline_name = tokens[1];
3662 if (strcmp(tokens[2], "table") != 0) {
3663 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3667 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3668 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3672 if (strcmp(tokens[4], "rule") != 0) {
3673 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3677 if (strcmp(tokens[5], "add") != 0) {
3678 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3682 if (strcmp(tokens[6], "bulk") != 0) {
3683 snprintf(out, out_size, MSG_ARG_INVALID, "bulk");
3687 file_name = tokens[7];
3689 if ((parser_read_uint32(&n_rules, tokens[8]) != 0) ||
3691 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
3695 /* Memory allocation. */
3696 match = calloc(n_rules, sizeof(struct table_rule_match));
3697 action = calloc(n_rules, sizeof(struct table_rule_action));
3698 data = calloc(n_rules, sizeof(void *));
3699 if ((match == NULL) || (action == NULL) || (data == NULL)) {
3700 snprintf(out, out_size, MSG_OUT_OF_MEMORY);
3707 /* Load rule file */
3708 n_rules_parsed = n_rules;
3709 status = cli_rule_file_process(file_name,
3718 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
3724 if (n_rules_parsed != n_rules) {
3725 snprintf(out, out_size, MSG_FILE_NOT_ENOUGH, file_name);
3733 status = pipeline_table_rule_add_bulk(pipeline_name,
3740 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3754 * pipeline <pipeline_name> table <table_id> rule delete
3758 cmd_pipeline_table_rule_delete(char **tokens,
3763 struct table_rule_match m;
3764 char *pipeline_name;
3765 uint32_t table_id, n_tokens_parsed, t0;
3769 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3773 pipeline_name = tokens[1];
3775 if (strcmp(tokens[2], "table") != 0) {
3776 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3780 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3781 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3785 if (strcmp(tokens[4], "rule") != 0) {
3786 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3790 if (strcmp(tokens[5], "delete") != 0) {
3791 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3798 n_tokens_parsed = parse_match(tokens + t0,
3803 if (n_tokens_parsed == 0)
3805 t0 += n_tokens_parsed;
3807 if (n_tokens != t0) {
3808 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3812 status = pipeline_table_rule_delete(pipeline_name,
3816 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3822 * pipeline <pipeline_name> table <table_id> rule delete
3827 cmd_pipeline_table_rule_delete_default(char **tokens,
3832 char *pipeline_name;
3836 if (n_tokens != 8) {
3837 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3841 pipeline_name = tokens[1];
3843 if (strcmp(tokens[2], "table") != 0) {
3844 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3848 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3849 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3853 if (strcmp(tokens[4], "rule") != 0) {
3854 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3858 if (strcmp(tokens[5], "delete") != 0) {
3859 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3863 if (strcmp(tokens[6], "match") != 0) {
3864 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3868 if (strcmp(tokens[7], "default") != 0) {
3869 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3873 status = pipeline_table_rule_delete_default(pipeline_name,
3876 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3882 * pipeline <pipeline_name> table <table_id> rule read stats [clear]
3885 cmd_pipeline_table_rule_stats_read(char **tokens,
3886 uint32_t n_tokens __rte_unused,
3890 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
3894 * pipeline <pipeline_name> table <table_id> meter profile <meter_profile_id>
3895 * add srtcm cir <cir> cbs <cbs> ebs <ebs>
3896 * | trtcm cir <cir> pir <pir> cbs <cbs> pbs <pbs>
3899 cmd_pipeline_table_meter_profile_add(char **tokens,
3904 struct rte_table_action_meter_profile p;
3905 char *pipeline_name;
3906 uint32_t table_id, meter_profile_id;
3910 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3914 pipeline_name = tokens[1];
3916 if (strcmp(tokens[2], "table") != 0) {
3917 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
3921 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3922 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3926 if (strcmp(tokens[4], "meter") != 0) {
3927 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
3931 if (strcmp(tokens[5], "profile") != 0) {
3932 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
3936 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
3937 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
3941 if (strcmp(tokens[7], "add") != 0) {
3942 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3946 if (strcmp(tokens[8], "srtcm") == 0) {
3947 if (n_tokens != 15) {
3948 snprintf(out, out_size, MSG_ARG_MISMATCH,
3953 p.alg = RTE_TABLE_ACTION_METER_SRTCM;
3955 if (strcmp(tokens[9], "cir") != 0) {
3956 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
3960 if (parser_read_uint64(&p.srtcm.cir, tokens[10]) != 0) {
3961 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
3965 if (strcmp(tokens[11], "cbs") != 0) {
3966 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
3970 if (parser_read_uint64(&p.srtcm.cbs, tokens[12]) != 0) {
3971 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
3975 if (strcmp(tokens[13], "ebs") != 0) {
3976 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "ebs");
3980 if (parser_read_uint64(&p.srtcm.ebs, tokens[14]) != 0) {
3981 snprintf(out, out_size, MSG_ARG_INVALID, "ebs");
3984 } else if (strcmp(tokens[8], "trtcm") == 0) {
3985 if (n_tokens != 17) {
3986 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3990 p.alg = RTE_TABLE_ACTION_METER_TRTCM;
3992 if (strcmp(tokens[9], "cir") != 0) {
3993 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
3997 if (parser_read_uint64(&p.trtcm.cir, tokens[10]) != 0) {
3998 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
4002 if (strcmp(tokens[11], "pir") != 0) {
4003 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pir");
4007 if (parser_read_uint64(&p.trtcm.pir, tokens[12]) != 0) {
4008 snprintf(out, out_size, MSG_ARG_INVALID, "pir");
4011 if (strcmp(tokens[13], "cbs") != 0) {
4012 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
4016 if (parser_read_uint64(&p.trtcm.cbs, tokens[14]) != 0) {
4017 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
4021 if (strcmp(tokens[15], "pbs") != 0) {
4022 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pbs");
4026 if (parser_read_uint64(&p.trtcm.pbs, tokens[16]) != 0) {
4027 snprintf(out, out_size, MSG_ARG_INVALID, "pbs");
4031 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4035 status = pipeline_table_mtr_profile_add(pipeline_name,
4040 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4046 * pipeline <pipeline_name> table <table_id>
4047 * meter profile <meter_profile_id> delete
4050 cmd_pipeline_table_meter_profile_delete(char **tokens,
4055 char *pipeline_name;
4056 uint32_t table_id, meter_profile_id;
4059 if (n_tokens != 8) {
4060 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4064 pipeline_name = tokens[1];
4066 if (strcmp(tokens[2], "table") != 0) {
4067 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4071 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4072 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4076 if (strcmp(tokens[4], "meter") != 0) {
4077 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
4081 if (strcmp(tokens[5], "profile") != 0) {
4082 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
4086 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
4087 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
4091 if (strcmp(tokens[7], "delete") != 0) {
4092 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
4096 status = pipeline_table_mtr_profile_delete(pipeline_name,
4100 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4106 * pipeline <pipeline_name> table <table_id> rule read meter [clear]
4109 cmd_pipeline_table_rule_meter_read(char **tokens,
4110 uint32_t n_tokens __rte_unused,
4114 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4118 * pipeline <pipeline_name> table <table_id> dscp <file_name>
4121 * - exactly 64 lines
4122 * - line format: <tc_id> <tc_queue_id> <color>, with <color> as: g | y | r
4125 load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
4126 const char *file_name,
4127 uint32_t *line_number)
4132 /* Check input arguments */
4133 if ((dscp_table == NULL) ||
4134 (file_name == NULL) ||
4135 (line_number == NULL)) {
4141 /* Open input file */
4142 f = fopen(file_name, "r");
4149 for (dscp = 0, l = 1; ; l++) {
4152 enum rte_meter_color color;
4153 uint32_t tc_id, tc_queue_id, n_tokens = RTE_DIM(tokens);
4155 if (fgets(line, sizeof(line), f) == NULL)
4158 if (is_comment(line))
4161 if (parse_tokenize_string(line, tokens, &n_tokens)) {
4170 if ((dscp >= RTE_DIM(dscp_table->entry)) ||
4171 (n_tokens != RTE_DIM(tokens)) ||
4172 parser_read_uint32(&tc_id, tokens[0]) ||
4173 (tc_id >= RTE_TABLE_ACTION_TC_MAX) ||
4174 parser_read_uint32(&tc_queue_id, tokens[1]) ||
4175 (tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) ||
4176 (strlen(tokens[2]) != 1)) {
4182 switch (tokens[2][0]) {
4185 color = e_RTE_METER_GREEN;
4190 color = e_RTE_METER_YELLOW;
4195 color = e_RTE_METER_RED;
4204 dscp_table->entry[dscp].tc_id = tc_id;
4205 dscp_table->entry[dscp].tc_queue_id = tc_queue_id;
4206 dscp_table->entry[dscp].color = color;
4216 cmd_pipeline_table_dscp(char **tokens,
4221 struct rte_table_action_dscp_table dscp_table;
4222 char *pipeline_name, *file_name;
4223 uint32_t table_id, line_number;
4226 if (n_tokens != 6) {
4227 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4231 pipeline_name = tokens[1];
4233 if (strcmp(tokens[2], "table") != 0) {
4234 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4238 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4239 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4243 if (strcmp(tokens[4], "dscp") != 0) {
4244 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dscp");
4248 file_name = tokens[5];
4250 status = load_dscp_table(&dscp_table, file_name, &line_number);
4252 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
4256 status = pipeline_table_dscp_table_update(pipeline_name,
4261 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4267 * pipeline <pipeline_name> table <table_id> rule read ttl [clear]
4270 cmd_pipeline_table_rule_ttl_read(char **tokens,
4271 uint32_t n_tokens __rte_unused,
4275 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4279 * thread <thread_id> pipeline <pipeline_name> enable
4282 cmd_thread_pipeline_enable(char **tokens,
4287 char *pipeline_name;
4291 if (n_tokens != 5) {
4292 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4296 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4297 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4301 if (strcmp(tokens[2], "pipeline") != 0) {
4302 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4306 pipeline_name = tokens[3];
4308 if (strcmp(tokens[4], "enable") != 0) {
4309 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
4313 status = thread_pipeline_enable(thread_id, pipeline_name);
4315 snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable");
4321 * thread <thread_id> pipeline <pipeline_name> disable
4324 cmd_thread_pipeline_disable(char **tokens,
4329 char *pipeline_name;
4333 if (n_tokens != 5) {
4334 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4338 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4339 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4343 if (strcmp(tokens[2], "pipeline") != 0) {
4344 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4348 pipeline_name = tokens[3];
4350 if (strcmp(tokens[4], "disable") != 0) {
4351 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
4355 status = thread_pipeline_disable(thread_id, pipeline_name);
4357 snprintf(out, out_size, MSG_CMD_FAIL,
4358 "thread pipeline disable");
4364 cli_process(char *in, char *out, size_t out_size)
4366 char *tokens[CMD_MAX_TOKENS];
4367 uint32_t n_tokens = RTE_DIM(tokens);
4373 status = parse_tokenize_string(in, tokens, &n_tokens);
4375 snprintf(out, out_size, MSG_ARG_TOO_MANY, "");
4382 if (strcmp(tokens[0], "mempool") == 0) {
4383 cmd_mempool(tokens, n_tokens, out, out_size);
4387 if (strcmp(tokens[0], "link") == 0) {
4388 cmd_link(tokens, n_tokens, out, out_size);
4392 if (strcmp(tokens[0], "swq") == 0) {
4393 cmd_swq(tokens, n_tokens, out, out_size);
4397 if (strcmp(tokens[0], "tmgr") == 0) {
4398 if ((n_tokens >= 3) &&
4399 (strcmp(tokens[1], "subport") == 0) &&
4400 (strcmp(tokens[2], "profile") == 0)) {
4401 cmd_tmgr_subport_profile(tokens, n_tokens,
4406 if ((n_tokens >= 3) &&
4407 (strcmp(tokens[1], "pipe") == 0) &&
4408 (strcmp(tokens[2], "profile") == 0)) {
4409 cmd_tmgr_pipe_profile(tokens, n_tokens, out, out_size);
4413 if ((n_tokens >= 5) &&
4414 (strcmp(tokens[2], "subport") == 0) &&
4415 (strcmp(tokens[4], "profile") == 0)) {
4416 cmd_tmgr_subport(tokens, n_tokens, out, out_size);
4420 if ((n_tokens >= 5) &&
4421 (strcmp(tokens[2], "subport") == 0) &&
4422 (strcmp(tokens[4], "pipe") == 0)) {
4423 cmd_tmgr_subport_pipe(tokens, n_tokens, out, out_size);
4427 cmd_tmgr(tokens, n_tokens, out, out_size);
4431 if (strcmp(tokens[0], "tap") == 0) {
4432 cmd_tap(tokens, n_tokens, out, out_size);
4436 if (strcmp(tokens[0], "kni") == 0) {
4437 cmd_kni(tokens, n_tokens, out, out_size);
4441 if (strcmp(tokens[0], "port") == 0) {
4442 cmd_port_in_action_profile(tokens, n_tokens, out, out_size);
4446 if (strcmp(tokens[0], "table") == 0) {
4447 cmd_table_action_profile(tokens, n_tokens, out, out_size);
4451 if (strcmp(tokens[0], "pipeline") == 0) {
4452 if ((n_tokens >= 3) &&
4453 (strcmp(tokens[2], "period") == 0)) {
4454 cmd_pipeline(tokens, n_tokens, out, out_size);
4458 if ((n_tokens >= 5) &&
4459 (strcmp(tokens[2], "port") == 0) &&
4460 (strcmp(tokens[3], "in") == 0) &&
4461 (strcmp(tokens[4], "bsz") == 0)) {
4462 cmd_pipeline_port_in(tokens, n_tokens, out, out_size);
4466 if ((n_tokens >= 5) &&
4467 (strcmp(tokens[2], "port") == 0) &&
4468 (strcmp(tokens[3], "out") == 0) &&
4469 (strcmp(tokens[4], "bsz") == 0)) {
4470 cmd_pipeline_port_out(tokens, n_tokens, out, out_size);
4474 if ((n_tokens >= 4) &&
4475 (strcmp(tokens[2], "table") == 0) &&
4476 (strcmp(tokens[3], "match") == 0)) {
4477 cmd_pipeline_table(tokens, n_tokens, out, out_size);
4481 if ((n_tokens >= 6) &&
4482 (strcmp(tokens[2], "port") == 0) &&
4483 (strcmp(tokens[3], "in") == 0) &&
4484 (strcmp(tokens[5], "table") == 0)) {
4485 cmd_pipeline_port_in_table(tokens, n_tokens,
4490 if ((n_tokens >= 6) &&
4491 (strcmp(tokens[2], "port") == 0) &&
4492 (strcmp(tokens[3], "in") == 0) &&
4493 (strcmp(tokens[5], "stats") == 0)) {
4494 cmd_pipeline_port_in_stats(tokens, n_tokens,
4499 if ((n_tokens >= 6) &&
4500 (strcmp(tokens[2], "port") == 0) &&
4501 (strcmp(tokens[3], "in") == 0) &&
4502 (strcmp(tokens[5], "enable") == 0)) {
4503 cmd_pipeline_port_in_enable(tokens, n_tokens,
4508 if ((n_tokens >= 6) &&
4509 (strcmp(tokens[2], "port") == 0) &&
4510 (strcmp(tokens[3], "in") == 0) &&
4511 (strcmp(tokens[5], "disable") == 0)) {
4512 cmd_pipeline_port_in_disable(tokens, n_tokens,
4517 if ((n_tokens >= 6) &&
4518 (strcmp(tokens[2], "port") == 0) &&
4519 (strcmp(tokens[3], "out") == 0) &&
4520 (strcmp(tokens[5], "stats") == 0)) {
4521 cmd_pipeline_port_out_stats(tokens, n_tokens,
4526 if ((n_tokens >= 5) &&
4527 (strcmp(tokens[2], "table") == 0) &&
4528 (strcmp(tokens[4], "stats") == 0)) {
4529 cmd_pipeline_table_stats(tokens, n_tokens,
4534 if ((n_tokens >= 7) &&
4535 (strcmp(tokens[2], "table") == 0) &&
4536 (strcmp(tokens[4], "rule") == 0) &&
4537 (strcmp(tokens[5], "add") == 0) &&
4538 (strcmp(tokens[6], "match") == 0)) {
4539 if ((n_tokens >= 8) &&
4540 (strcmp(tokens[7], "default") == 0)) {
4541 cmd_pipeline_table_rule_add_default(tokens,
4542 n_tokens, out, out_size);
4546 cmd_pipeline_table_rule_add(tokens, n_tokens,
4551 if ((n_tokens >= 7) &&
4552 (strcmp(tokens[2], "table") == 0) &&
4553 (strcmp(tokens[4], "rule") == 0) &&
4554 (strcmp(tokens[5], "add") == 0) &&
4555 (strcmp(tokens[6], "bulk") == 0)) {
4556 cmd_pipeline_table_rule_add_bulk(tokens,
4557 n_tokens, out, out_size);
4561 if ((n_tokens >= 7) &&
4562 (strcmp(tokens[2], "table") == 0) &&
4563 (strcmp(tokens[4], "rule") == 0) &&
4564 (strcmp(tokens[5], "delete") == 0) &&
4565 (strcmp(tokens[6], "match") == 0)) {
4566 if ((n_tokens >= 8) &&
4567 (strcmp(tokens[7], "default") == 0)) {
4568 cmd_pipeline_table_rule_delete_default(tokens,
4569 n_tokens, out, out_size);
4573 cmd_pipeline_table_rule_delete(tokens, n_tokens,
4578 if ((n_tokens >= 7) &&
4579 (strcmp(tokens[2], "table") == 0) &&
4580 (strcmp(tokens[4], "rule") == 0) &&
4581 (strcmp(tokens[5], "read") == 0) &&
4582 (strcmp(tokens[6], "stats") == 0)) {
4583 cmd_pipeline_table_rule_stats_read(tokens, n_tokens,
4588 if ((n_tokens >= 8) &&
4589 (strcmp(tokens[2], "table") == 0) &&
4590 (strcmp(tokens[4], "meter") == 0) &&
4591 (strcmp(tokens[5], "profile") == 0) &&
4592 (strcmp(tokens[7], "add") == 0)) {
4593 cmd_pipeline_table_meter_profile_add(tokens, n_tokens,
4598 if ((n_tokens >= 8) &&
4599 (strcmp(tokens[2], "table") == 0) &&
4600 (strcmp(tokens[4], "meter") == 0) &&
4601 (strcmp(tokens[5], "profile") == 0) &&
4602 (strcmp(tokens[7], "delete") == 0)) {
4603 cmd_pipeline_table_meter_profile_delete(tokens,
4604 n_tokens, out, out_size);
4608 if ((n_tokens >= 7) &&
4609 (strcmp(tokens[2], "table") == 0) &&
4610 (strcmp(tokens[4], "rule") == 0) &&
4611 (strcmp(tokens[5], "read") == 0) &&
4612 (strcmp(tokens[6], "meter") == 0)) {
4613 cmd_pipeline_table_rule_meter_read(tokens, n_tokens,
4618 if ((n_tokens >= 5) &&
4619 (strcmp(tokens[2], "table") == 0) &&
4620 (strcmp(tokens[4], "dscp") == 0)) {
4621 cmd_pipeline_table_dscp(tokens, n_tokens,
4626 if ((n_tokens >= 7) &&
4627 (strcmp(tokens[2], "table") == 0) &&
4628 (strcmp(tokens[4], "rule") == 0) &&
4629 (strcmp(tokens[5], "read") == 0) &&
4630 (strcmp(tokens[6], "ttl") == 0)) {
4631 cmd_pipeline_table_rule_ttl_read(tokens, n_tokens,
4637 if (strcmp(tokens[0], "thread") == 0) {
4638 if ((n_tokens >= 5) &&
4639 (strcmp(tokens[4], "enable") == 0)) {
4640 cmd_thread_pipeline_enable(tokens, n_tokens,
4645 if ((n_tokens >= 5) &&
4646 (strcmp(tokens[4], "disable") == 0)) {
4647 cmd_thread_pipeline_disable(tokens, n_tokens,
4653 snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
4657 cli_script_process(const char *file_name,
4658 size_t msg_in_len_max,
4659 size_t msg_out_len_max)
4661 char *msg_in = NULL, *msg_out = NULL;
4664 /* Check input arguments */
4665 if ((file_name == NULL) ||
4666 (strlen(file_name) == 0) ||
4667 (msg_in_len_max == 0) ||
4668 (msg_out_len_max == 0))
4671 msg_in = malloc(msg_in_len_max + 1);
4672 msg_out = malloc(msg_out_len_max + 1);
4673 if ((msg_in == NULL) ||
4674 (msg_out == NULL)) {
4680 /* Open input file */
4681 f = fopen(file_name, "r");
4690 if (fgets(msg_in, msg_in_len_max + 1, f) == NULL)
4693 printf("%s", msg_in);
4700 if (strlen(msg_out))
4701 printf("%s", msg_out);
4712 cli_rule_file_process(const char *file_name,
4713 size_t line_len_max,
4714 struct table_rule_match *m,
4715 struct table_rule_action *a,
4717 uint32_t *line_number,
4723 uint32_t rule_id, line_id;
4726 /* Check input arguments */
4727 if ((file_name == NULL) ||
4728 (strlen(file_name) == 0) ||
4729 (line_len_max == 0)) {
4734 /* Memory allocation */
4735 line = malloc(line_len_max + 1);
4742 f = fopen(file_name, "r");
4750 for (line_id = 1, rule_id = 0; rule_id < *n_rules; line_id++) {
4751 char *tokens[CMD_MAX_TOKENS];
4752 uint32_t n_tokens, n_tokens_parsed, t0;
4754 /* Read next line from file. */
4755 if (fgets(line, line_len_max + 1, f) == NULL)
4759 if (is_comment(line))
4763 n_tokens = RTE_DIM(tokens);
4764 status = parse_tokenize_string(line, tokens, &n_tokens);
4776 n_tokens_parsed = parse_match(tokens + t0,
4781 if (n_tokens_parsed == 0) {
4785 t0 += n_tokens_parsed;
4788 n_tokens_parsed = parse_table_action(tokens + t0,
4793 if (n_tokens_parsed == 0) {
4797 t0 += n_tokens_parsed;
4799 /* Line completed. */
4800 if (t0 < n_tokens) {
4805 /* Increment rule count */
4816 *line_number = line_id;