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 memset(&p, 0, sizeof(p));
657 if ((n_tokens != 6) && (n_tokens != 8)) {
658 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
664 if (strcmp(tokens[2], "link") != 0) {
665 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "link");
669 p.link_name = tokens[3];
671 if (strcmp(tokens[4], "mempool") != 0) {
672 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool");
676 p.mempool_name = tokens[5];
679 if (strcmp(tokens[6], "thread") != 0) {
680 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "thread");
684 if (parser_read_uint32(&p.thread_id, tokens[7]) != 0) {
685 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
693 kni = kni_create(name, &p);
695 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
701 * port in action profile <profile_name>
702 * [filter match | mismatch offset <key_offset> mask <key_mask> key <key_value> port <port_id>]
703 * [balance offset <key_offset> mask <key_mask> port <port_id0> ... <port_id15>]
706 cmd_port_in_action_profile(char **tokens,
711 struct port_in_action_profile_params p;
712 struct port_in_action_profile *ap;
716 memset(&p, 0, sizeof(p));
719 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
723 if (strcmp(tokens[1], "in") != 0) {
724 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
728 if (strcmp(tokens[2], "action") != 0) {
729 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
733 if (strcmp(tokens[3], "profile") != 0) {
734 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
742 if ((t0 < n_tokens) && (strcmp(tokens[t0], "filter") == 0)) {
745 if (n_tokens < t0 + 10) {
746 snprintf(out, out_size, MSG_ARG_MISMATCH, "port in action profile filter");
750 if (strcmp(tokens[t0 + 1], "match") == 0)
751 p.fltr.filter_on_match = 1;
752 else if (strcmp(tokens[t0 + 1], "mismatch") == 0)
753 p.fltr.filter_on_match = 0;
755 snprintf(out, out_size, MSG_ARG_INVALID, "match or mismatch");
759 if (strcmp(tokens[t0 + 2], "offset") != 0) {
760 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
764 if (parser_read_uint32(&p.fltr.key_offset, tokens[t0 + 3]) != 0) {
765 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
769 if (strcmp(tokens[t0 + 4], "mask") != 0) {
770 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
774 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
775 if ((parse_hex_string(tokens[t0 + 5], p.fltr.key_mask, &size) != 0) ||
776 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
777 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
781 if (strcmp(tokens[t0 + 6], "key") != 0) {
782 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
786 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
787 if ((parse_hex_string(tokens[t0 + 7], p.fltr.key, &size) != 0) ||
788 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
789 snprintf(out, out_size, MSG_ARG_INVALID, "key_value");
793 if (strcmp(tokens[t0 + 8], "port") != 0) {
794 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
798 if (parser_read_uint32(&p.fltr.port_id, tokens[t0 + 9]) != 0) {
799 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
803 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_FLTR;
807 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
810 if (n_tokens < t0 + 22) {
811 snprintf(out, out_size, MSG_ARG_MISMATCH,
812 "port in action profile balance");
816 if (strcmp(tokens[t0 + 1], "offset") != 0) {
817 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
821 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
822 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
826 if (strcmp(tokens[t0 + 3], "mask") != 0) {
827 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
831 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
832 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
833 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
837 if (strcmp(tokens[t0 + 5], "port") != 0) {
838 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
842 for (i = 0; i < 16; i++)
843 if (parser_read_uint32(&p.lb.port_id[i], tokens[t0 + 6 + i]) != 0) {
844 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
848 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_LB;
853 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
857 ap = port_in_action_profile_create(name, &p);
859 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
865 * table action profile <profile_name>
869 * [balance offset <key_offset> mask <key_mask> outoffset <out_offset>]
870 * [meter srtcm | trtcm
872 * stats none | pkts | bytes | both]
873 * [tm spp <n_subports_per_port> pps <n_pipes_per_subport>]
874 * [encap ether | vlan | qinq | mpls | pppoe]
879 * [stats pkts | bytes | both]
883 cmd_table_action_profile(char **tokens,
888 struct table_action_profile_params p;
889 struct table_action_profile *ap;
893 memset(&p, 0, sizeof(p));
896 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
900 if (strcmp(tokens[1], "action") != 0) {
901 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
905 if (strcmp(tokens[2], "profile") != 0) {
906 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
912 if (strcmp(tokens[4], "ipv4") == 0)
913 p.common.ip_version = 1;
914 else if (strcmp(tokens[4], "ipv6") == 0)
915 p.common.ip_version = 0;
917 snprintf(out, out_size, MSG_ARG_INVALID, "ipv4 or ipv6");
921 if (strcmp(tokens[5], "offset") != 0) {
922 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
926 if (parser_read_uint32(&p.common.ip_offset, tokens[6]) != 0) {
927 snprintf(out, out_size, MSG_ARG_INVALID, "ip_offset");
931 if (strcmp(tokens[7], "fwd") != 0) {
932 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fwd");
936 p.action_mask |= 1LLU << RTE_TABLE_ACTION_FWD;
939 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
940 if (n_tokens < t0 + 7) {
941 snprintf(out, out_size, MSG_ARG_MISMATCH, "table action profile balance");
945 if (strcmp(tokens[t0 + 1], "offset") != 0) {
946 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
950 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
951 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
955 if (strcmp(tokens[t0 + 3], "mask") != 0) {
956 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
960 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
961 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
962 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
966 if (strcmp(tokens[t0 + 5], "outoffset") != 0) {
967 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "outoffset");
971 if (parser_read_uint32(&p.lb.out_offset, tokens[t0 + 6]) != 0) {
972 snprintf(out, out_size, MSG_ARG_INVALID, "out_offset");
976 p.action_mask |= 1LLU << RTE_TABLE_ACTION_LB;
980 if ((t0 < n_tokens) && (strcmp(tokens[t0], "meter") == 0)) {
981 if (n_tokens < t0 + 6) {
982 snprintf(out, out_size, MSG_ARG_MISMATCH,
983 "table action profile meter");
987 if (strcmp(tokens[t0 + 1], "srtcm") == 0)
988 p.mtr.alg = RTE_TABLE_ACTION_METER_SRTCM;
989 else if (strcmp(tokens[t0 + 1], "trtcm") == 0)
990 p.mtr.alg = RTE_TABLE_ACTION_METER_TRTCM;
992 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
997 if (strcmp(tokens[t0 + 2], "tc") != 0) {
998 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc");
1002 if (parser_read_uint32(&p.mtr.n_tc, tokens[t0 + 3]) != 0) {
1003 snprintf(out, out_size, MSG_ARG_INVALID, "n_tc");
1007 if (strcmp(tokens[t0 + 4], "stats") != 0) {
1008 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1012 if (strcmp(tokens[t0 + 5], "none") == 0) {
1013 p.mtr.n_packets_enabled = 0;
1014 p.mtr.n_bytes_enabled = 0;
1015 } else if (strcmp(tokens[t0 + 5], "pkts") == 0) {
1016 p.mtr.n_packets_enabled = 1;
1017 p.mtr.n_bytes_enabled = 0;
1018 } else if (strcmp(tokens[t0 + 5], "bytes") == 0) {
1019 p.mtr.n_packets_enabled = 0;
1020 p.mtr.n_bytes_enabled = 1;
1021 } else if (strcmp(tokens[t0 + 5], "both") == 0) {
1022 p.mtr.n_packets_enabled = 1;
1023 p.mtr.n_bytes_enabled = 1;
1025 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1026 "none or pkts or bytes or both");
1030 p.action_mask |= 1LLU << RTE_TABLE_ACTION_MTR;
1034 if ((t0 < n_tokens) && (strcmp(tokens[t0], "tm") == 0)) {
1035 if (n_tokens < t0 + 5) {
1036 snprintf(out, out_size, MSG_ARG_MISMATCH,
1037 "table action profile tm");
1041 if (strcmp(tokens[t0 + 1], "spp") != 0) {
1042 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
1046 if (parser_read_uint32(&p.tm.n_subports_per_port,
1047 tokens[t0 + 2]) != 0) {
1048 snprintf(out, out_size, MSG_ARG_INVALID,
1049 "n_subports_per_port");
1053 if (strcmp(tokens[t0 + 3], "pps") != 0) {
1054 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
1058 if (parser_read_uint32(&p.tm.n_pipes_per_subport,
1059 tokens[t0 + 4]) != 0) {
1060 snprintf(out, out_size, MSG_ARG_INVALID,
1061 "n_pipes_per_subport");
1065 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TM;
1069 if ((t0 < n_tokens) && (strcmp(tokens[t0], "encap") == 0)) {
1070 if (n_tokens < t0 + 2) {
1071 snprintf(out, out_size, MSG_ARG_MISMATCH,
1072 "action profile encap");
1076 if (strcmp(tokens[t0 + 1], "ether") == 0)
1077 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER;
1078 else if (strcmp(tokens[t0 + 1], "vlan") == 0)
1079 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN;
1080 else if (strcmp(tokens[t0 + 1], "qinq") == 0)
1081 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ;
1082 else if (strcmp(tokens[t0 + 1], "mpls") == 0)
1083 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS;
1084 else if (strcmp(tokens[t0 + 1], "pppoe") == 0)
1085 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE;
1087 snprintf(out, out_size, MSG_ARG_MISMATCH, "encap");
1091 p.action_mask |= 1LLU << RTE_TABLE_ACTION_ENCAP;
1095 if ((t0 < n_tokens) && (strcmp(tokens[t0], "nat") == 0)) {
1096 if (n_tokens < t0 + 4) {
1097 snprintf(out, out_size, MSG_ARG_MISMATCH,
1098 "table action profile nat");
1102 if (strcmp(tokens[t0 + 1], "src") == 0)
1103 p.nat.source_nat = 1;
1104 else if (strcmp(tokens[t0 + 1], "dst") == 0)
1105 p.nat.source_nat = 0;
1107 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1112 if (strcmp(tokens[t0 + 2], "proto") != 0) {
1113 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "proto");
1117 if (strcmp(tokens[t0 + 3], "tcp") == 0)
1119 else if (strcmp(tokens[t0 + 3], "udp") == 0)
1122 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1127 p.action_mask |= 1LLU << RTE_TABLE_ACTION_NAT;
1131 if ((t0 < n_tokens) && (strcmp(tokens[t0], "ttl") == 0)) {
1132 if (n_tokens < t0 + 4) {
1133 snprintf(out, out_size, MSG_ARG_MISMATCH,
1134 "table action profile ttl");
1138 if (strcmp(tokens[t0 + 1], "drop") == 0)
1140 else if (strcmp(tokens[t0 + 1], "fwd") == 0)
1143 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1148 if (strcmp(tokens[t0 + 2], "stats") != 0) {
1149 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1153 if (strcmp(tokens[t0 + 3], "none") == 0)
1154 p.ttl.n_packets_enabled = 0;
1155 else if (strcmp(tokens[t0 + 3], "pkts") == 0)
1156 p.ttl.n_packets_enabled = 1;
1158 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1163 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TTL;
1167 if ((t0 < n_tokens) && (strcmp(tokens[t0], "stats") == 0)) {
1168 if (n_tokens < t0 + 2) {
1169 snprintf(out, out_size, MSG_ARG_MISMATCH,
1170 "table action profile stats");
1174 if (strcmp(tokens[t0 + 1], "pkts") == 0) {
1175 p.stats.n_packets_enabled = 1;
1176 p.stats.n_bytes_enabled = 0;
1177 } else if (strcmp(tokens[t0 + 1], "bytes") == 0) {
1178 p.stats.n_packets_enabled = 0;
1179 p.stats.n_bytes_enabled = 1;
1180 } else if (strcmp(tokens[t0 + 1], "both") == 0) {
1181 p.stats.n_packets_enabled = 1;
1182 p.stats.n_bytes_enabled = 1;
1184 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1185 "pkts or bytes or both");
1189 p.action_mask |= 1LLU << RTE_TABLE_ACTION_STATS;
1193 if ((t0 < n_tokens) && (strcmp(tokens[t0], "time") == 0)) {
1194 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TIME;
1198 if (t0 < n_tokens) {
1199 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1203 ap = table_action_profile_create(name, &p);
1205 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1211 * pipeline <pipeline_name>
1212 * period <timer_period_ms>
1213 * offset_port_id <offset_port_id>
1217 cmd_pipeline(char **tokens,
1222 struct pipeline_params p;
1224 struct pipeline *pipeline;
1226 if (n_tokens != 8) {
1227 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1233 if (strcmp(tokens[2], "period") != 0) {
1234 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "period");
1238 if (parser_read_uint32(&p.timer_period_ms, tokens[3]) != 0) {
1239 snprintf(out, out_size, MSG_ARG_INVALID, "timer_period_ms");
1243 if (strcmp(tokens[4], "offset_port_id") != 0) {
1244 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset_port_id");
1248 if (parser_read_uint32(&p.offset_port_id, tokens[5]) != 0) {
1249 snprintf(out, out_size, MSG_ARG_INVALID, "offset_port_id");
1253 if (strcmp(tokens[6], "cpu") != 0) {
1254 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
1258 if (parser_read_uint32(&p.cpu_id, tokens[7]) != 0) {
1259 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
1263 pipeline = pipeline_create(name, &p);
1264 if (pipeline == NULL) {
1265 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1271 * pipeline <pipeline_name> port in
1273 * link <link_name> rxq <queue_id>
1275 * | tmgr <tmgr_name>
1276 * | tap <tap_name> mempool <mempool_name> mtu <mtu>
1278 * | source mempool <mempool_name> file <file_name> bpp <n_bytes_per_pkt>
1279 * [action <port_in_action_profile_name>]
1283 cmd_pipeline_port_in(char **tokens,
1288 struct port_in_params p;
1289 char *pipeline_name;
1291 int enabled, status;
1294 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1298 pipeline_name = tokens[1];
1300 if (strcmp(tokens[2], "port") != 0) {
1301 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1305 if (strcmp(tokens[3], "in") != 0) {
1306 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1310 if (strcmp(tokens[4], "bsz") != 0) {
1311 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1315 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1316 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1322 if (strcmp(tokens[t0], "link") == 0) {
1323 if (n_tokens < t0 + 4) {
1324 snprintf(out, out_size, MSG_ARG_MISMATCH,
1325 "pipeline port in link");
1329 p.type = PORT_IN_RXQ;
1331 p.dev_name = tokens[t0 + 1];
1333 if (strcmp(tokens[t0 + 2], "rxq") != 0) {
1334 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
1338 if (parser_read_uint16(&p.rxq.queue_id, tokens[t0 + 3]) != 0) {
1339 snprintf(out, out_size, MSG_ARG_INVALID,
1344 } else if (strcmp(tokens[t0], "swq") == 0) {
1345 if (n_tokens < t0 + 2) {
1346 snprintf(out, out_size, MSG_ARG_MISMATCH,
1347 "pipeline port in swq");
1351 p.type = PORT_IN_SWQ;
1353 p.dev_name = tokens[t0 + 1];
1356 } else if (strcmp(tokens[t0], "tmgr") == 0) {
1357 if (n_tokens < t0 + 2) {
1358 snprintf(out, out_size, MSG_ARG_MISMATCH,
1359 "pipeline port in tmgr");
1363 p.type = PORT_IN_TMGR;
1365 p.dev_name = tokens[t0 + 1];
1368 } else if (strcmp(tokens[t0], "tap") == 0) {
1369 if (n_tokens < t0 + 6) {
1370 snprintf(out, out_size, MSG_ARG_MISMATCH,
1371 "pipeline port in tap");
1375 p.type = PORT_IN_TAP;
1377 p.dev_name = tokens[t0 + 1];
1379 if (strcmp(tokens[t0 + 2], "mempool") != 0) {
1380 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1385 p.tap.mempool_name = tokens[t0 + 3];
1387 if (strcmp(tokens[t0 + 4], "mtu") != 0) {
1388 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1393 if (parser_read_uint32(&p.tap.mtu, tokens[t0 + 5]) != 0) {
1394 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
1399 } else if (strcmp(tokens[t0], "kni") == 0) {
1400 if (n_tokens < t0 + 2) {
1401 snprintf(out, out_size, MSG_ARG_MISMATCH,
1402 "pipeline port in kni");
1406 p.type = PORT_IN_KNI;
1408 p.dev_name = tokens[t0 + 1];
1411 } else if (strcmp(tokens[t0], "source") == 0) {
1412 if (n_tokens < t0 + 6) {
1413 snprintf(out, out_size, MSG_ARG_MISMATCH,
1414 "pipeline port in source");
1418 p.type = PORT_IN_SOURCE;
1422 if (strcmp(tokens[t0 + 1], "mempool") != 0) {
1423 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1428 p.source.mempool_name = tokens[t0 + 2];
1430 if (strcmp(tokens[t0 + 3], "file") != 0) {
1431 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1436 p.source.file_name = tokens[t0 + 4];
1438 if (strcmp(tokens[t0 + 5], "bpp") != 0) {
1439 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1444 if (parser_read_uint32(&p.source.n_bytes_per_pkt, tokens[t0 + 6]) != 0) {
1445 snprintf(out, out_size, MSG_ARG_INVALID,
1452 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1456 p.action_profile_name = NULL;
1457 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1458 if (n_tokens < t0 + 2) {
1459 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1463 p.action_profile_name = tokens[t0 + 1];
1469 if ((n_tokens > t0) &&
1470 (strcmp(tokens[t0], "disabled") == 0)) {
1476 if (n_tokens != t0) {
1477 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1481 status = pipeline_port_in_create(pipeline_name,
1484 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1490 * pipeline <pipeline_name> port out
1492 * link <link_name> txq <txq_id>
1494 * | tmgr <tmgr_name>
1497 * | sink [file <file_name> pkts <max_n_pkts>]
1500 cmd_pipeline_port_out(char **tokens,
1505 struct port_out_params p;
1506 char *pipeline_name;
1509 memset(&p, 0, sizeof(p));
1512 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1516 pipeline_name = tokens[1];
1518 if (strcmp(tokens[2], "port") != 0) {
1519 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1523 if (strcmp(tokens[3], "out") != 0) {
1524 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
1528 if (strcmp(tokens[4], "bsz") != 0) {
1529 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1533 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1534 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1538 if (strcmp(tokens[6], "link") == 0) {
1539 if (n_tokens != 10) {
1540 snprintf(out, out_size, MSG_ARG_MISMATCH,
1541 "pipeline port out link");
1545 p.type = PORT_OUT_TXQ;
1547 p.dev_name = tokens[7];
1549 if (strcmp(tokens[8], "txq") != 0) {
1550 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
1554 if (parser_read_uint16(&p.txq.queue_id, tokens[9]) != 0) {
1555 snprintf(out, out_size, MSG_ARG_INVALID, "queue_id");
1558 } else if (strcmp(tokens[6], "swq") == 0) {
1559 if (n_tokens != 8) {
1560 snprintf(out, out_size, MSG_ARG_MISMATCH,
1561 "pipeline port out swq");
1565 p.type = PORT_OUT_SWQ;
1567 p.dev_name = tokens[7];
1568 } else if (strcmp(tokens[6], "tmgr") == 0) {
1569 if (n_tokens != 8) {
1570 snprintf(out, out_size, MSG_ARG_MISMATCH,
1571 "pipeline port out tmgr");
1575 p.type = PORT_OUT_TMGR;
1577 p.dev_name = tokens[7];
1578 } else if (strcmp(tokens[6], "tap") == 0) {
1579 if (n_tokens != 8) {
1580 snprintf(out, out_size, MSG_ARG_MISMATCH,
1581 "pipeline port out tap");
1585 p.type = PORT_OUT_TAP;
1587 p.dev_name = tokens[7];
1588 } else if (strcmp(tokens[6], "kni") == 0) {
1589 if (n_tokens != 8) {
1590 snprintf(out, out_size, MSG_ARG_MISMATCH,
1591 "pipeline port out kni");
1595 p.type = PORT_OUT_KNI;
1597 p.dev_name = tokens[7];
1598 } else if (strcmp(tokens[6], "sink") == 0) {
1599 if ((n_tokens != 7) && (n_tokens != 11)) {
1600 snprintf(out, out_size, MSG_ARG_MISMATCH,
1601 "pipeline port out sink");
1605 p.type = PORT_OUT_SINK;
1609 if (n_tokens == 7) {
1610 p.sink.file_name = NULL;
1611 p.sink.max_n_pkts = 0;
1613 if (strcmp(tokens[7], "file") != 0) {
1614 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1619 p.sink.file_name = tokens[8];
1621 if (strcmp(tokens[9], "pkts") != 0) {
1622 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pkts");
1626 if (parser_read_uint32(&p.sink.max_n_pkts, tokens[10]) != 0) {
1627 snprintf(out, out_size, MSG_ARG_INVALID, "max_n_pkts");
1632 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1636 status = pipeline_port_out_create(pipeline_name, &p);
1638 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1644 * pipeline <pipeline_name> table
1648 * offset <ip_header_offset>
1651 * offset <key_offset>
1657 * offset <key_offset>
1658 * buckets <n_buckets>
1662 * offset <ip_header_offset>
1665 * [action <table_action_profile_name>]
1668 cmd_pipeline_table(char **tokens,
1673 uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
1674 struct table_params p;
1675 char *pipeline_name;
1680 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1684 pipeline_name = tokens[1];
1686 if (strcmp(tokens[2], "table") != 0) {
1687 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1691 if (strcmp(tokens[3], "match") != 0) {
1692 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
1697 if (strcmp(tokens[t0], "acl") == 0) {
1698 if (n_tokens < t0 + 6) {
1699 snprintf(out, out_size, MSG_ARG_MISMATCH,
1700 "pipeline table acl");
1704 p.match_type = TABLE_ACL;
1706 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1707 p.match.acl.ip_version = 1;
1708 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1709 p.match.acl.ip_version = 0;
1711 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1716 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1717 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1721 if (parser_read_uint32(&p.match.acl.ip_header_offset,
1722 tokens[t0 + 3]) != 0) {
1723 snprintf(out, out_size, MSG_ARG_INVALID,
1724 "ip_header_offset");
1728 if (strcmp(tokens[t0 + 4], "size") != 0) {
1729 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1733 if (parser_read_uint32(&p.match.acl.n_rules,
1734 tokens[t0 + 5]) != 0) {
1735 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1740 } else if (strcmp(tokens[t0], "array") == 0) {
1741 if (n_tokens < t0 + 5) {
1742 snprintf(out, out_size, MSG_ARG_MISMATCH,
1743 "pipeline table array");
1747 p.match_type = TABLE_ARRAY;
1749 if (strcmp(tokens[t0 + 1], "offset") != 0) {
1750 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1754 if (parser_read_uint32(&p.match.array.key_offset,
1755 tokens[t0 + 2]) != 0) {
1756 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1760 if (strcmp(tokens[t0 + 3], "size") != 0) {
1761 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1765 if (parser_read_uint32(&p.match.array.n_keys,
1766 tokens[t0 + 4]) != 0) {
1767 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1772 } else if (strcmp(tokens[t0], "hash") == 0) {
1773 uint32_t key_mask_size = TABLE_RULE_MATCH_SIZE_MAX;
1775 if (n_tokens < t0 + 12) {
1776 snprintf(out, out_size, MSG_ARG_MISMATCH,
1777 "pipeline table hash");
1781 p.match_type = TABLE_HASH;
1783 if (strcmp(tokens[t0 + 1], "ext") == 0)
1784 p.match.hash.extendable_bucket = 1;
1785 else if (strcmp(tokens[t0 + 1], "lru") == 0)
1786 p.match.hash.extendable_bucket = 0;
1788 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1793 if (strcmp(tokens[t0 + 2], "key") != 0) {
1794 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
1798 if ((parser_read_uint32(&p.match.hash.key_size,
1799 tokens[t0 + 3]) != 0) ||
1800 (p.match.hash.key_size == 0) ||
1801 (p.match.hash.key_size > TABLE_RULE_MATCH_SIZE_MAX)) {
1802 snprintf(out, out_size, MSG_ARG_INVALID, "key_size");
1806 if (strcmp(tokens[t0 + 4], "mask") != 0) {
1807 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
1811 if ((parse_hex_string(tokens[t0 + 5],
1812 key_mask, &key_mask_size) != 0) ||
1813 (key_mask_size != p.match.hash.key_size)) {
1814 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
1817 p.match.hash.key_mask = key_mask;
1819 if (strcmp(tokens[t0 + 6], "offset") != 0) {
1820 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1824 if (parser_read_uint32(&p.match.hash.key_offset,
1825 tokens[t0 + 7]) != 0) {
1826 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1830 if (strcmp(tokens[t0 + 8], "buckets") != 0) {
1831 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buckets");
1835 if (parser_read_uint32(&p.match.hash.n_buckets,
1836 tokens[t0 + 9]) != 0) {
1837 snprintf(out, out_size, MSG_ARG_INVALID, "n_buckets");
1841 if (strcmp(tokens[t0 + 10], "size") != 0) {
1842 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1846 if (parser_read_uint32(&p.match.hash.n_keys,
1847 tokens[t0 + 11]) != 0) {
1848 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1853 } else if (strcmp(tokens[t0], "lpm") == 0) {
1854 if (n_tokens < t0 + 6) {
1855 snprintf(out, out_size, MSG_ARG_MISMATCH,
1856 "pipeline table lpm");
1860 p.match_type = TABLE_LPM;
1862 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1863 p.match.lpm.key_size = 4;
1864 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1865 p.match.lpm.key_size = 16;
1867 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1872 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1873 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1877 if (parser_read_uint32(&p.match.lpm.key_offset,
1878 tokens[t0 + 3]) != 0) {
1879 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1883 if (strcmp(tokens[t0 + 4], "size") != 0) {
1884 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1888 if (parser_read_uint32(&p.match.lpm.n_rules,
1889 tokens[t0 + 5]) != 0) {
1890 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1895 } else if (strcmp(tokens[t0], "stub") == 0) {
1896 if (n_tokens < t0 + 1) {
1897 snprintf(out, out_size, MSG_ARG_MISMATCH,
1898 "pipeline table stub");
1902 p.match_type = TABLE_STUB;
1906 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1910 p.action_profile_name = NULL;
1911 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1912 if (n_tokens < t0 + 2) {
1913 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1917 p.action_profile_name = tokens[t0 + 1];
1922 if (n_tokens > t0) {
1923 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1927 status = pipeline_table_create(pipeline_name, &p);
1929 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1935 * pipeline <pipeline_name> port in <port_id> table <table_id>
1938 cmd_pipeline_port_in_table(char **tokens,
1943 char *pipeline_name;
1944 uint32_t port_id, table_id;
1947 if (n_tokens != 7) {
1948 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1952 pipeline_name = tokens[1];
1954 if (strcmp(tokens[2], "port") != 0) {
1955 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1959 if (strcmp(tokens[3], "in") != 0) {
1960 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1964 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
1965 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
1969 if (strcmp(tokens[5], "table") != 0) {
1970 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1974 if (parser_read_uint32(&table_id, tokens[6]) != 0) {
1975 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
1979 status = pipeline_port_in_connect_to_table(pipeline_name,
1983 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1989 * pipeline <pipeline_name> port in <port_id> stats read [clear]
1992 #define MSG_PIPELINE_PORT_IN_STATS \
1993 "Pkts in: %" PRIu64 "\n" \
1994 "Pkts dropped by AH: %" PRIu64 "\n" \
1995 "Pkts dropped by other: %" PRIu64 "\n"
1998 cmd_pipeline_port_in_stats(char **tokens,
2003 struct rte_pipeline_port_in_stats stats;
2004 char *pipeline_name;
2008 if ((n_tokens != 7) && (n_tokens != 8)) {
2009 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2013 pipeline_name = tokens[1];
2015 if (strcmp(tokens[2], "port") != 0) {
2016 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2020 if (strcmp(tokens[3], "in") != 0) {
2021 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2025 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2026 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2030 if (strcmp(tokens[5], "stats") != 0) {
2031 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2035 if (strcmp(tokens[6], "read") != 0) {
2036 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2041 if (n_tokens == 8) {
2042 if (strcmp(tokens[7], "clear") != 0) {
2043 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2050 status = pipeline_port_in_stats_read(pipeline_name,
2055 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2059 snprintf(out, out_size, MSG_PIPELINE_PORT_IN_STATS,
2060 stats.stats.n_pkts_in,
2061 stats.n_pkts_dropped_by_ah,
2062 stats.stats.n_pkts_drop);
2066 * pipeline <pipeline_name> port in <port_id> enable
2069 cmd_pipeline_port_in_enable(char **tokens,
2074 char *pipeline_name;
2078 if (n_tokens != 6) {
2079 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2083 pipeline_name = tokens[1];
2085 if (strcmp(tokens[2], "port") != 0) {
2086 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2090 if (strcmp(tokens[3], "in") != 0) {
2091 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2095 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2096 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2100 if (strcmp(tokens[5], "enable") != 0) {
2101 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
2105 status = pipeline_port_in_enable(pipeline_name, port_id);
2107 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2113 * pipeline <pipeline_name> port in <port_id> disable
2116 cmd_pipeline_port_in_disable(char **tokens,
2121 char *pipeline_name;
2125 if (n_tokens != 6) {
2126 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2130 pipeline_name = tokens[1];
2132 if (strcmp(tokens[2], "port") != 0) {
2133 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2137 if (strcmp(tokens[3], "in") != 0) {
2138 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2142 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2143 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2147 if (strcmp(tokens[5], "disable") != 0) {
2148 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
2152 status = pipeline_port_in_disable(pipeline_name, port_id);
2154 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2160 * pipeline <pipeline_name> port out <port_id> stats read [clear]
2162 #define MSG_PIPELINE_PORT_OUT_STATS \
2163 "Pkts in: %" PRIu64 "\n" \
2164 "Pkts dropped by AH: %" PRIu64 "\n" \
2165 "Pkts dropped by other: %" PRIu64 "\n"
2168 cmd_pipeline_port_out_stats(char **tokens,
2173 struct rte_pipeline_port_out_stats stats;
2174 char *pipeline_name;
2178 if ((n_tokens != 7) && (n_tokens != 8)) {
2179 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2183 pipeline_name = tokens[1];
2185 if (strcmp(tokens[2], "port") != 0) {
2186 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2190 if (strcmp(tokens[3], "out") != 0) {
2191 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
2195 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2196 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2200 if (strcmp(tokens[5], "stats") != 0) {
2201 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2205 if (strcmp(tokens[6], "read") != 0) {
2206 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2211 if (n_tokens == 8) {
2212 if (strcmp(tokens[7], "clear") != 0) {
2213 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2220 status = pipeline_port_out_stats_read(pipeline_name,
2225 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2229 snprintf(out, out_size, MSG_PIPELINE_PORT_OUT_STATS,
2230 stats.stats.n_pkts_in,
2231 stats.n_pkts_dropped_by_ah,
2232 stats.stats.n_pkts_drop);
2236 * pipeline <pipeline_name> table <table_id> stats read [clear]
2238 #define MSG_PIPELINE_TABLE_STATS \
2239 "Pkts in: %" PRIu64 "\n" \
2240 "Pkts in with lookup miss: %" PRIu64 "\n" \
2241 "Pkts in with lookup hit dropped by AH: %" PRIu64 "\n" \
2242 "Pkts in with lookup hit dropped by others: %" PRIu64 "\n" \
2243 "Pkts in with lookup miss dropped by AH: %" PRIu64 "\n" \
2244 "Pkts in with lookup miss dropped by others: %" PRIu64 "\n"
2247 cmd_pipeline_table_stats(char **tokens,
2252 struct rte_pipeline_table_stats stats;
2253 char *pipeline_name;
2257 if ((n_tokens != 6) && (n_tokens != 7)) {
2258 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2262 pipeline_name = tokens[1];
2264 if (strcmp(tokens[2], "table") != 0) {
2265 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2269 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
2270 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
2274 if (strcmp(tokens[4], "stats") != 0) {
2275 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2279 if (strcmp(tokens[5], "read") != 0) {
2280 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2285 if (n_tokens == 7) {
2286 if (strcmp(tokens[6], "clear") != 0) {
2287 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2294 status = pipeline_table_stats_read(pipeline_name,
2299 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2303 snprintf(out, out_size, MSG_PIPELINE_TABLE_STATS,
2304 stats.stats.n_pkts_in,
2305 stats.stats.n_pkts_lookup_miss,
2306 stats.n_pkts_dropped_by_lkp_hit_ah,
2307 stats.n_pkts_dropped_lkp_hit,
2308 stats.n_pkts_dropped_by_lkp_miss_ah,
2309 stats.n_pkts_dropped_lkp_miss);
2317 * priority <priority>
2318 * ipv4 | ipv6 <sa> <sa_depth> <da> <da_depth>
2319 * <sp0> <sp1> <dp0> <dp1> <proto>
2323 * | ipv4_5tuple <sa> <da> <sp> <dp> <proto>
2324 * | ipv6_5tuple <sa> <da> <sp> <dp> <proto>
2325 * | ipv4_addr <addr>
2326 * | ipv6_addr <addr>
2327 * | qinq <svlan> <cvlan>
2329 * ipv4 | ipv6 <addr> <depth>
2331 struct pkt_key_qinq {
2332 uint16_t ethertype_svlan;
2334 uint16_t ethertype_cvlan;
2336 } __attribute__((__packed__));
2338 struct pkt_key_ipv4_5tuple {
2339 uint8_t time_to_live;
2341 uint16_t hdr_checksum;
2346 } __attribute__((__packed__));
2348 struct pkt_key_ipv6_5tuple {
2349 uint16_t payload_length;
2356 } __attribute__((__packed__));
2358 struct pkt_key_ipv4_addr {
2360 } __attribute__((__packed__));
2362 struct pkt_key_ipv6_addr {
2364 } __attribute__((__packed__));
2367 parse_match(char **tokens,
2371 struct table_rule_match *m)
2373 memset(m, 0, sizeof(*m));
2378 if (strcmp(tokens[0], "match") != 0) {
2379 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
2383 if (strcmp(tokens[1], "acl") == 0) {
2384 if (n_tokens < 14) {
2385 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2389 m->match_type = TABLE_ACL;
2391 if (strcmp(tokens[2], "priority") != 0) {
2392 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority");
2396 if (parser_read_uint32(&m->match.acl.priority,
2398 snprintf(out, out_size, MSG_ARG_INVALID, "priority");
2402 if (strcmp(tokens[4], "ipv4") == 0) {
2403 struct in_addr saddr, daddr;
2405 m->match.acl.ip_version = 1;
2407 if (parse_ipv4_addr(tokens[5], &saddr) != 0) {
2408 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2411 m->match.acl.ipv4.sa = rte_be_to_cpu_32(saddr.s_addr);
2413 if (parse_ipv4_addr(tokens[7], &daddr) != 0) {
2414 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2417 m->match.acl.ipv4.da = rte_be_to_cpu_32(daddr.s_addr);
2418 } else if (strcmp(tokens[4], "ipv6") == 0) {
2419 struct in6_addr saddr, daddr;
2421 m->match.acl.ip_version = 0;
2423 if (parse_ipv6_addr(tokens[5], &saddr) != 0) {
2424 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2427 memcpy(m->match.acl.ipv6.sa, saddr.s6_addr, 16);
2429 if (parse_ipv6_addr(tokens[7], &daddr) != 0) {
2430 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2433 memcpy(m->match.acl.ipv6.da, daddr.s6_addr, 16);
2435 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
2440 if (parser_read_uint32(&m->match.acl.sa_depth,
2442 snprintf(out, out_size, MSG_ARG_INVALID, "sa_depth");
2446 if (parser_read_uint32(&m->match.acl.da_depth,
2448 snprintf(out, out_size, MSG_ARG_INVALID, "da_depth");
2452 if (parser_read_uint16(&m->match.acl.sp0, tokens[9]) != 0) {
2453 snprintf(out, out_size, MSG_ARG_INVALID, "sp0");
2457 if (parser_read_uint16(&m->match.acl.sp1, tokens[10]) != 0) {
2458 snprintf(out, out_size, MSG_ARG_INVALID, "sp1");
2462 if (parser_read_uint16(&m->match.acl.dp0, tokens[11]) != 0) {
2463 snprintf(out, out_size, MSG_ARG_INVALID, "dp0");
2467 if (parser_read_uint16(&m->match.acl.dp1, tokens[12]) != 0) {
2468 snprintf(out, out_size, MSG_ARG_INVALID, "dp1");
2472 if (parser_read_uint8(&m->match.acl.proto, tokens[13]) != 0) {
2473 snprintf(out, out_size, MSG_ARG_INVALID, "proto");
2477 m->match.acl.proto_mask = 0xff;
2482 if (strcmp(tokens[1], "array") == 0) {
2484 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2488 m->match_type = TABLE_ARRAY;
2490 if (parser_read_uint32(&m->match.array.pos, tokens[2]) != 0) {
2491 snprintf(out, out_size, MSG_ARG_INVALID, "pos");
2498 if (strcmp(tokens[1], "hash") == 0) {
2500 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2504 m->match_type = TABLE_HASH;
2506 if (strcmp(tokens[2], "raw") == 0) {
2507 uint32_t key_size = TABLE_RULE_MATCH_SIZE_MAX;
2510 snprintf(out, out_size, MSG_ARG_MISMATCH,
2515 if (parse_hex_string(tokens[3],
2516 m->match.hash.key, &key_size) != 0) {
2517 snprintf(out, out_size, MSG_ARG_INVALID, "key");
2524 if (strcmp(tokens[2], "ipv4_5tuple") == 0) {
2525 struct pkt_key_ipv4_5tuple *ipv4 =
2526 (struct pkt_key_ipv4_5tuple *) m->match.hash.key;
2527 struct in_addr saddr, daddr;
2532 snprintf(out, out_size, MSG_ARG_MISMATCH,
2537 if (parse_ipv4_addr(tokens[3], &saddr) != 0) {
2538 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2542 if (parse_ipv4_addr(tokens[4], &daddr) != 0) {
2543 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2547 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2548 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2552 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2553 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2557 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2558 snprintf(out, out_size, MSG_ARG_INVALID,
2563 ipv4->sa = saddr.s_addr;
2564 ipv4->da = daddr.s_addr;
2565 ipv4->sp = rte_cpu_to_be_16(sp);
2566 ipv4->dp = rte_cpu_to_be_16(dp);
2567 ipv4->proto = proto;
2570 } /* hash ipv4_5tuple */
2572 if (strcmp(tokens[2], "ipv6_5tuple") == 0) {
2573 struct pkt_key_ipv6_5tuple *ipv6 =
2574 (struct pkt_key_ipv6_5tuple *) m->match.hash.key;
2575 struct in6_addr saddr, daddr;
2580 snprintf(out, out_size, MSG_ARG_MISMATCH,
2585 if (parse_ipv6_addr(tokens[3], &saddr) != 0) {
2586 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2590 if (parse_ipv6_addr(tokens[4], &daddr) != 0) {
2591 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2595 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2596 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2600 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2601 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2605 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2606 snprintf(out, out_size, MSG_ARG_INVALID,
2611 memcpy(ipv6->sa, saddr.s6_addr, 16);
2612 memcpy(ipv6->da, daddr.s6_addr, 16);
2613 ipv6->sp = rte_cpu_to_be_16(sp);
2614 ipv6->dp = rte_cpu_to_be_16(dp);
2615 ipv6->proto = proto;
2618 } /* hash ipv6_5tuple */
2620 if (strcmp(tokens[2], "ipv4_addr") == 0) {
2621 struct pkt_key_ipv4_addr *ipv4_addr =
2622 (struct pkt_key_ipv4_addr *) m->match.hash.key;
2623 struct in_addr addr;
2626 snprintf(out, out_size, MSG_ARG_MISMATCH,
2631 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2632 snprintf(out, out_size, MSG_ARG_INVALID,
2637 ipv4_addr->addr = addr.s_addr;
2640 } /* hash ipv4_addr */
2642 if (strcmp(tokens[2], "ipv6_addr") == 0) {
2643 struct pkt_key_ipv6_addr *ipv6_addr =
2644 (struct pkt_key_ipv6_addr *) m->match.hash.key;
2645 struct in6_addr addr;
2648 snprintf(out, out_size, MSG_ARG_MISMATCH,
2653 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2654 snprintf(out, out_size, MSG_ARG_INVALID,
2659 memcpy(ipv6_addr->addr, addr.s6_addr, 16);
2662 } /* hash ipv6_5tuple */
2664 if (strcmp(tokens[2], "qinq") == 0) {
2665 struct pkt_key_qinq *qinq =
2666 (struct pkt_key_qinq *) m->match.hash.key;
2667 uint16_t svlan, cvlan;
2670 snprintf(out, out_size, MSG_ARG_MISMATCH,
2675 if ((parser_read_uint16(&svlan, tokens[3]) != 0) ||
2677 snprintf(out, out_size, MSG_ARG_INVALID,
2682 if ((parser_read_uint16(&cvlan, tokens[4]) != 0) ||
2684 snprintf(out, out_size, MSG_ARG_INVALID,
2689 qinq->svlan = rte_cpu_to_be_16(svlan);
2690 qinq->cvlan = rte_cpu_to_be_16(cvlan);
2695 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2699 if (strcmp(tokens[1], "lpm") == 0) {
2701 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2705 m->match_type = TABLE_LPM;
2707 if (strcmp(tokens[2], "ipv4") == 0) {
2708 struct in_addr addr;
2710 m->match.lpm.ip_version = 1;
2712 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2713 snprintf(out, out_size, MSG_ARG_INVALID,
2718 m->match.lpm.ipv4 = rte_be_to_cpu_32(addr.s_addr);
2719 } else if (strcmp(tokens[2], "ipv6") == 0) {
2720 struct in6_addr addr;
2722 m->match.lpm.ip_version = 0;
2724 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2725 snprintf(out, out_size, MSG_ARG_INVALID,
2730 memcpy(m->match.lpm.ipv6, addr.s6_addr, 16);
2732 snprintf(out, out_size, MSG_ARG_MISMATCH,
2737 if (parser_read_uint8(&m->match.lpm.depth, tokens[4]) != 0) {
2738 snprintf(out, out_size, MSG_ARG_INVALID, "depth");
2745 snprintf(out, out_size, MSG_ARG_MISMATCH,
2746 "acl or array or hash or lpm");
2758 * | table <table_id>
2759 * [balance <out0> ... <out7>]
2761 * tc0 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2762 * [tc1 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2763 * tc2 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2764 * tc3 meter <meter_profile_id> policer g <pa> y <pa> r <pa>]]
2765 * [tm subport <subport_id> pipe <pipe_id>]
2768 * | vlan <da> <sa> <pcp> <dei> <vid>
2769 * | qinq <da> <sa> <pcp> <dei> <vid> <pcp> <dei> <vid>
2770 * | mpls unicast | multicast
2772 * label0 <label> <tc> <ttl>
2773 * [label1 <label> <tc> <ttl>
2774 * [label2 <label> <tc> <ttl>
2775 * [label3 <label> <tc> <ttl>]]]
2776 * | pppoe <da> <sa> <session_id>]
2777 * [nat ipv4 | ipv6 <addr> <port>]
2783 * <pa> ::= g | y | r | drop
2786 parse_table_action_fwd(char **tokens,
2788 struct table_rule_action *a)
2790 if ((n_tokens == 0) || (strcmp(tokens[0], "fwd") != 0))
2796 if (n_tokens && (strcmp(tokens[0], "drop") == 0)) {
2797 a->fwd.action = RTE_PIPELINE_ACTION_DROP;
2798 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2802 if (n_tokens && (strcmp(tokens[0], "port") == 0)) {
2805 if ((n_tokens < 2) ||
2806 parser_read_uint32(&id, tokens[1]))
2809 a->fwd.action = RTE_PIPELINE_ACTION_PORT;
2811 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2815 if (n_tokens && (strcmp(tokens[0], "meta") == 0)) {
2816 a->fwd.action = RTE_PIPELINE_ACTION_PORT_META;
2817 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2821 if (n_tokens && (strcmp(tokens[0], "table") == 0)) {
2824 if ((n_tokens < 2) ||
2825 parser_read_uint32(&id, tokens[1]))
2828 a->fwd.action = RTE_PIPELINE_ACTION_TABLE;
2830 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2838 parse_table_action_balance(char **tokens,
2840 struct table_rule_action *a)
2844 if ((n_tokens == 0) || (strcmp(tokens[0], "balance") != 0))
2850 if (n_tokens < RTE_TABLE_ACTION_LB_TABLE_SIZE)
2853 for (i = 0; i < RTE_TABLE_ACTION_LB_TABLE_SIZE; i++)
2854 if (parser_read_uint32(&a->lb.out[i], tokens[i]) != 0)
2857 a->action_mask |= 1 << RTE_TABLE_ACTION_LB;
2858 return 1 + RTE_TABLE_ACTION_LB_TABLE_SIZE;
2863 parse_policer_action(char *token, enum rte_table_action_policer *a)
2865 if (strcmp(token, "g") == 0) {
2866 *a = RTE_TABLE_ACTION_POLICER_COLOR_GREEN;
2870 if (strcmp(token, "y") == 0) {
2871 *a = RTE_TABLE_ACTION_POLICER_COLOR_YELLOW;
2875 if (strcmp(token, "r") == 0) {
2876 *a = RTE_TABLE_ACTION_POLICER_COLOR_RED;
2880 if (strcmp(token, "drop") == 0) {
2881 *a = RTE_TABLE_ACTION_POLICER_DROP;
2889 parse_table_action_meter_tc(char **tokens,
2891 struct rte_table_action_mtr_tc_params *mtr)
2893 if ((n_tokens < 9) ||
2894 strcmp(tokens[0], "meter") ||
2895 parser_read_uint32(&mtr->meter_profile_id, tokens[1]) ||
2896 strcmp(tokens[2], "policer") ||
2897 strcmp(tokens[3], "g") ||
2898 parse_policer_action(tokens[4], &mtr->policer[e_RTE_METER_GREEN]) ||
2899 strcmp(tokens[5], "y") ||
2900 parse_policer_action(tokens[6], &mtr->policer[e_RTE_METER_YELLOW]) ||
2901 strcmp(tokens[7], "r") ||
2902 parse_policer_action(tokens[8], &mtr->policer[e_RTE_METER_RED]))
2909 parse_table_action_meter(char **tokens,
2911 struct table_rule_action *a)
2913 if ((n_tokens == 0) || strcmp(tokens[0], "meter"))
2919 if ((n_tokens < 10) ||
2920 strcmp(tokens[0], "tc0") ||
2921 (parse_table_action_meter_tc(tokens + 1,
2923 &a->mtr.mtr[0]) == 0))
2929 if ((n_tokens == 0) || strcmp(tokens[0], "tc1")) {
2931 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
2935 if ((n_tokens < 30) ||
2936 (parse_table_action_meter_tc(tokens + 1,
2937 n_tokens - 1, &a->mtr.mtr[1]) == 0) ||
2938 strcmp(tokens[10], "tc2") ||
2939 (parse_table_action_meter_tc(tokens + 11,
2940 n_tokens - 11, &a->mtr.mtr[2]) == 0) ||
2941 strcmp(tokens[20], "tc3") ||
2942 (parse_table_action_meter_tc(tokens + 21,
2943 n_tokens - 21, &a->mtr.mtr[3]) == 0))
2946 a->mtr.tc_mask = 0xF;
2947 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
2948 return 1 + 10 + 3 * 10;
2952 parse_table_action_tm(char **tokens,
2954 struct table_rule_action *a)
2956 uint32_t subport_id, pipe_id;
2958 if ((n_tokens < 5) ||
2959 strcmp(tokens[0], "tm") ||
2960 strcmp(tokens[1], "subport") ||
2961 parser_read_uint32(&subport_id, tokens[2]) ||
2962 strcmp(tokens[3], "pipe") ||
2963 parser_read_uint32(&pipe_id, tokens[4]))
2966 a->tm.subport_id = subport_id;
2967 a->tm.pipe_id = pipe_id;
2968 a->action_mask |= 1 << RTE_TABLE_ACTION_TM;
2973 parse_table_action_encap(char **tokens,
2975 struct table_rule_action *a)
2977 if ((n_tokens == 0) || strcmp(tokens[0], "encap"))
2984 if (n_tokens && (strcmp(tokens[0], "ether") == 0)) {
2985 if ((n_tokens < 3) ||
2986 parse_mac_addr(tokens[1], &a->encap.ether.ether.da) ||
2987 parse_mac_addr(tokens[2], &a->encap.ether.ether.sa))
2990 a->encap.type = RTE_TABLE_ACTION_ENCAP_ETHER;
2991 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
2996 if (n_tokens && (strcmp(tokens[0], "vlan") == 0)) {
2997 uint32_t pcp, dei, vid;
2999 if ((n_tokens < 6) ||
3000 parse_mac_addr(tokens[1], &a->encap.vlan.ether.da) ||
3001 parse_mac_addr(tokens[2], &a->encap.vlan.ether.sa) ||
3002 parser_read_uint32(&pcp, tokens[3]) ||
3004 parser_read_uint32(&dei, tokens[4]) ||
3006 parser_read_uint32(&vid, tokens[5]) ||
3010 a->encap.vlan.vlan.pcp = pcp & 0x7;
3011 a->encap.vlan.vlan.dei = dei & 0x1;
3012 a->encap.vlan.vlan.vid = vid & 0xFFF;
3013 a->encap.type = RTE_TABLE_ACTION_ENCAP_VLAN;
3014 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3019 if (n_tokens && (strcmp(tokens[0], "qinq") == 0)) {
3020 uint32_t svlan_pcp, svlan_dei, svlan_vid;
3021 uint32_t cvlan_pcp, cvlan_dei, cvlan_vid;
3023 if ((n_tokens < 9) ||
3024 parse_mac_addr(tokens[1], &a->encap.qinq.ether.da) ||
3025 parse_mac_addr(tokens[2], &a->encap.qinq.ether.sa) ||
3026 parser_read_uint32(&svlan_pcp, tokens[3]) ||
3027 (svlan_pcp > 0x7) ||
3028 parser_read_uint32(&svlan_dei, tokens[4]) ||
3029 (svlan_dei > 0x1) ||
3030 parser_read_uint32(&svlan_vid, tokens[5]) ||
3031 (svlan_vid > 0xFFF) ||
3032 parser_read_uint32(&cvlan_pcp, tokens[6]) ||
3033 (cvlan_pcp > 0x7) ||
3034 parser_read_uint32(&cvlan_dei, tokens[7]) ||
3035 (cvlan_dei > 0x1) ||
3036 parser_read_uint32(&cvlan_vid, tokens[8]) ||
3037 (cvlan_vid > 0xFFF))
3040 a->encap.qinq.svlan.pcp = svlan_pcp & 0x7;
3041 a->encap.qinq.svlan.dei = svlan_dei & 0x1;
3042 a->encap.qinq.svlan.vid = svlan_vid & 0xFFF;
3043 a->encap.qinq.cvlan.pcp = cvlan_pcp & 0x7;
3044 a->encap.qinq.cvlan.dei = cvlan_dei & 0x1;
3045 a->encap.qinq.cvlan.vid = cvlan_vid & 0xFFF;
3046 a->encap.type = RTE_TABLE_ACTION_ENCAP_QINQ;
3047 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3052 if (n_tokens && (strcmp(tokens[0], "mpls") == 0)) {
3053 uint32_t label, tc, ttl;
3058 if (strcmp(tokens[1], "unicast") == 0)
3059 a->encap.mpls.unicast = 1;
3060 else if (strcmp(tokens[1], "multicast") == 0)
3061 a->encap.mpls.unicast = 0;
3065 if (parse_mac_addr(tokens[2], &a->encap.mpls.ether.da) ||
3066 parse_mac_addr(tokens[3], &a->encap.mpls.ether.sa) ||
3067 strcmp(tokens[4], "label0") ||
3068 parser_read_uint32(&label, tokens[5]) ||
3069 (label > 0xFFFFF) ||
3070 parser_read_uint32(&tc, tokens[6]) ||
3072 parser_read_uint32(&ttl, tokens[7]) ||
3076 a->encap.mpls.mpls[0].label = label;
3077 a->encap.mpls.mpls[0].tc = tc;
3078 a->encap.mpls.mpls[0].ttl = ttl;
3083 if ((n_tokens == 0) || strcmp(tokens[0], "label1")) {
3084 a->encap.mpls.mpls_count = 1;
3085 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3086 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3090 if ((n_tokens < 4) ||
3091 parser_read_uint32(&label, tokens[1]) ||
3092 (label > 0xFFFFF) ||
3093 parser_read_uint32(&tc, tokens[2]) ||
3095 parser_read_uint32(&ttl, tokens[3]) ||
3099 a->encap.mpls.mpls[1].label = label;
3100 a->encap.mpls.mpls[1].tc = tc;
3101 a->encap.mpls.mpls[1].ttl = ttl;
3106 if ((n_tokens == 0) || strcmp(tokens[0], "label2")) {
3107 a->encap.mpls.mpls_count = 2;
3108 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3109 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3113 if ((n_tokens < 4) ||
3114 parser_read_uint32(&label, tokens[1]) ||
3115 (label > 0xFFFFF) ||
3116 parser_read_uint32(&tc, tokens[2]) ||
3118 parser_read_uint32(&ttl, tokens[3]) ||
3122 a->encap.mpls.mpls[2].label = label;
3123 a->encap.mpls.mpls[2].tc = tc;
3124 a->encap.mpls.mpls[2].ttl = ttl;
3129 if ((n_tokens == 0) || strcmp(tokens[0], "label3")) {
3130 a->encap.mpls.mpls_count = 3;
3131 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3132 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3133 return 1 + 8 + 4 + 4;
3136 if ((n_tokens < 4) ||
3137 parser_read_uint32(&label, tokens[1]) ||
3138 (label > 0xFFFFF) ||
3139 parser_read_uint32(&tc, tokens[2]) ||
3141 parser_read_uint32(&ttl, tokens[3]) ||
3145 a->encap.mpls.mpls[3].label = label;
3146 a->encap.mpls.mpls[3].tc = tc;
3147 a->encap.mpls.mpls[3].ttl = ttl;
3149 a->encap.mpls.mpls_count = 4;
3150 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3151 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3152 return 1 + 8 + 4 + 4 + 4;
3156 if (n_tokens && (strcmp(tokens[0], "pppoe") == 0)) {
3157 if ((n_tokens < 4) ||
3158 parse_mac_addr(tokens[1], &a->encap.pppoe.ether.da) ||
3159 parse_mac_addr(tokens[2], &a->encap.pppoe.ether.sa) ||
3160 parser_read_uint16(&a->encap.pppoe.pppoe.session_id,
3164 a->encap.type = RTE_TABLE_ACTION_ENCAP_PPPOE;
3165 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3173 parse_table_action_nat(char **tokens,
3175 struct table_rule_action *a)
3177 if ((n_tokens < 4) ||
3178 strcmp(tokens[0], "nat"))
3181 if (strcmp(tokens[1], "ipv4") == 0) {
3182 struct in_addr addr;
3185 if (parse_ipv4_addr(tokens[2], &addr) ||
3186 parser_read_uint16(&port, tokens[3]))
3189 a->nat.ip_version = 1;
3190 a->nat.addr.ipv4 = rte_be_to_cpu_32(addr.s_addr);
3192 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3196 if (strcmp(tokens[1], "ipv6") == 0) {
3197 struct in6_addr addr;
3200 if (parse_ipv6_addr(tokens[2], &addr) ||
3201 parser_read_uint16(&port, tokens[3]))
3204 a->nat.ip_version = 0;
3205 memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
3207 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3215 parse_table_action_ttl(char **tokens,
3217 struct table_rule_action *a)
3219 if ((n_tokens < 2) ||
3220 strcmp(tokens[0], "ttl"))
3223 if (strcmp(tokens[1], "dec") == 0)
3224 a->ttl.decrement = 1;
3225 else if (strcmp(tokens[1], "keep") == 0)
3226 a->ttl.decrement = 0;
3230 a->action_mask |= 1 << RTE_TABLE_ACTION_TTL;
3235 parse_table_action_stats(char **tokens,
3237 struct table_rule_action *a)
3239 if ((n_tokens < 1) ||
3240 strcmp(tokens[0], "stats"))
3243 a->stats.n_packets = 0;
3244 a->stats.n_bytes = 0;
3245 a->action_mask |= 1 << RTE_TABLE_ACTION_STATS;
3250 parse_table_action_time(char **tokens,
3252 struct table_rule_action *a)
3254 if ((n_tokens < 1) ||
3255 strcmp(tokens[0], "time"))
3258 a->time.time = rte_rdtsc();
3259 a->action_mask |= 1 << RTE_TABLE_ACTION_TIME;
3264 parse_table_action(char **tokens,
3268 struct table_rule_action *a)
3270 uint32_t n_tokens0 = n_tokens;
3272 memset(a, 0, sizeof(*a));
3274 if ((n_tokens < 2) ||
3275 strcmp(tokens[0], "action"))
3281 if (n_tokens && (strcmp(tokens[0], "fwd") == 0)) {
3284 n = parse_table_action_fwd(tokens, n_tokens, a);
3286 snprintf(out, out_size, MSG_ARG_INVALID,
3295 if (n_tokens && (strcmp(tokens[0], "balance") == 0)) {
3298 n = parse_table_action_balance(tokens, n_tokens, a);
3300 snprintf(out, out_size, MSG_ARG_INVALID,
3309 if (n_tokens && (strcmp(tokens[0], "meter") == 0)) {
3312 n = parse_table_action_meter(tokens, n_tokens, a);
3314 snprintf(out, out_size, MSG_ARG_INVALID,
3323 if (n_tokens && (strcmp(tokens[0], "tm") == 0)) {
3326 n = parse_table_action_tm(tokens, n_tokens, a);
3328 snprintf(out, out_size, MSG_ARG_INVALID,
3337 if (n_tokens && (strcmp(tokens[0], "encap") == 0)) {
3340 n = parse_table_action_encap(tokens, n_tokens, a);
3342 snprintf(out, out_size, MSG_ARG_INVALID,
3351 if (n_tokens && (strcmp(tokens[0], "nat") == 0)) {
3354 n = parse_table_action_nat(tokens, n_tokens, a);
3356 snprintf(out, out_size, MSG_ARG_INVALID,
3365 if (n_tokens && (strcmp(tokens[0], "ttl") == 0)) {
3368 n = parse_table_action_ttl(tokens, n_tokens, a);
3370 snprintf(out, out_size, MSG_ARG_INVALID,
3379 if (n_tokens && (strcmp(tokens[0], "stats") == 0)) {
3382 n = parse_table_action_stats(tokens, n_tokens, a);
3384 snprintf(out, out_size, MSG_ARG_INVALID,
3393 if (n_tokens && (strcmp(tokens[0], "time") == 0)) {
3396 n = parse_table_action_time(tokens, n_tokens, a);
3398 snprintf(out, out_size, MSG_ARG_INVALID,
3407 if (n_tokens0 - n_tokens == 1) {
3408 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3412 return n_tokens0 - n_tokens;
3416 * pipeline <pipeline_name> table <table_id> rule add
3418 * action <table_action>
3421 cmd_pipeline_table_rule_add(char **tokens,
3426 struct table_rule_match m;
3427 struct table_rule_action a;
3428 char *pipeline_name;
3430 uint32_t table_id, t0, n_tokens_parsed;
3434 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3438 pipeline_name = tokens[1];
3440 if (strcmp(tokens[2], "table") != 0) {
3441 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3445 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3446 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3450 if (strcmp(tokens[4], "rule") != 0) {
3451 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3455 if (strcmp(tokens[5], "add") != 0) {
3456 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3463 n_tokens_parsed = parse_match(tokens + t0,
3468 if (n_tokens_parsed == 0)
3470 t0 += n_tokens_parsed;
3473 n_tokens_parsed = parse_table_action(tokens + t0,
3478 if (n_tokens_parsed == 0)
3480 t0 += n_tokens_parsed;
3482 if (t0 != n_tokens) {
3483 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
3487 status = pipeline_table_rule_add(pipeline_name, table_id,
3490 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3496 * pipeline <pipeline_name> table <table_id> rule add
3504 * | table <table_id>
3507 cmd_pipeline_table_rule_add_default(char **tokens,
3512 struct table_rule_action action;
3514 char *pipeline_name;
3518 if ((n_tokens != 11) && (n_tokens != 12)) {
3519 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3523 pipeline_name = tokens[1];
3525 if (strcmp(tokens[2], "table") != 0) {
3526 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3530 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3531 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3535 if (strcmp(tokens[4], "rule") != 0) {
3536 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3540 if (strcmp(tokens[5], "add") != 0) {
3541 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3545 if (strcmp(tokens[6], "match") != 0) {
3546 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3550 if (strcmp(tokens[7], "default") != 0) {
3551 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3555 if (strcmp(tokens[8], "action") != 0) {
3556 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3560 if (strcmp(tokens[9], "fwd") != 0) {
3561 snprintf(out, out_size, MSG_ARG_INVALID, "fwd");
3565 action.action_mask = 1 << RTE_TABLE_ACTION_FWD;
3567 if (strcmp(tokens[10], "drop") == 0) {
3568 if (n_tokens != 11) {
3569 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3573 action.fwd.action = RTE_PIPELINE_ACTION_DROP;
3574 } else if (strcmp(tokens[10], "port") == 0) {
3577 if (n_tokens != 12) {
3578 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3582 if (parser_read_uint32(&id, tokens[11]) != 0) {
3583 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
3587 action.fwd.action = RTE_PIPELINE_ACTION_PORT;
3589 } else if (strcmp(tokens[10], "meta") == 0) {
3590 if (n_tokens != 11) {
3591 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3595 action.fwd.action = RTE_PIPELINE_ACTION_PORT_META;
3596 } else if (strcmp(tokens[10], "table") == 0) {
3599 if (n_tokens != 12) {
3600 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3604 if (parser_read_uint32(&id, tokens[11]) != 0) {
3605 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3609 action.fwd.action = RTE_PIPELINE_ACTION_TABLE;
3612 snprintf(out, out_size, MSG_ARG_INVALID,
3613 "drop or port or meta or table");
3617 status = pipeline_table_rule_add_default(pipeline_name,
3622 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3628 * pipeline <pipeline_name> table <table_id> rule add bulk <file_name> <n_rules>
3631 * - line format: match <match> action <action>
3634 cli_rule_file_process(const char *file_name,
3635 size_t line_len_max,
3636 struct table_rule_match *m,
3637 struct table_rule_action *a,
3639 uint32_t *line_number,
3644 cmd_pipeline_table_rule_add_bulk(char **tokens,
3649 struct table_rule_match *match;
3650 struct table_rule_action *action;
3652 char *pipeline_name, *file_name;
3653 uint32_t table_id, n_rules, n_rules_parsed, line_number;
3656 if (n_tokens != 9) {
3657 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3661 pipeline_name = tokens[1];
3663 if (strcmp(tokens[2], "table") != 0) {
3664 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3668 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3669 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3673 if (strcmp(tokens[4], "rule") != 0) {
3674 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3678 if (strcmp(tokens[5], "add") != 0) {
3679 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3683 if (strcmp(tokens[6], "bulk") != 0) {
3684 snprintf(out, out_size, MSG_ARG_INVALID, "bulk");
3688 file_name = tokens[7];
3690 if ((parser_read_uint32(&n_rules, tokens[8]) != 0) ||
3692 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
3696 /* Memory allocation. */
3697 match = calloc(n_rules, sizeof(struct table_rule_match));
3698 action = calloc(n_rules, sizeof(struct table_rule_action));
3699 data = calloc(n_rules, sizeof(void *));
3700 if ((match == NULL) || (action == NULL) || (data == NULL)) {
3701 snprintf(out, out_size, MSG_OUT_OF_MEMORY);
3708 /* Load rule file */
3709 n_rules_parsed = n_rules;
3710 status = cli_rule_file_process(file_name,
3719 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
3725 if (n_rules_parsed != n_rules) {
3726 snprintf(out, out_size, MSG_FILE_NOT_ENOUGH, file_name);
3734 status = pipeline_table_rule_add_bulk(pipeline_name,
3741 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3755 * pipeline <pipeline_name> table <table_id> rule delete
3759 cmd_pipeline_table_rule_delete(char **tokens,
3764 struct table_rule_match m;
3765 char *pipeline_name;
3766 uint32_t table_id, n_tokens_parsed, t0;
3770 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3774 pipeline_name = tokens[1];
3776 if (strcmp(tokens[2], "table") != 0) {
3777 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3781 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3782 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3786 if (strcmp(tokens[4], "rule") != 0) {
3787 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3791 if (strcmp(tokens[5], "delete") != 0) {
3792 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3799 n_tokens_parsed = parse_match(tokens + t0,
3804 if (n_tokens_parsed == 0)
3806 t0 += n_tokens_parsed;
3808 if (n_tokens != t0) {
3809 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3813 status = pipeline_table_rule_delete(pipeline_name,
3817 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3823 * pipeline <pipeline_name> table <table_id> rule delete
3828 cmd_pipeline_table_rule_delete_default(char **tokens,
3833 char *pipeline_name;
3837 if (n_tokens != 8) {
3838 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3842 pipeline_name = tokens[1];
3844 if (strcmp(tokens[2], "table") != 0) {
3845 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3849 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3850 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3854 if (strcmp(tokens[4], "rule") != 0) {
3855 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3859 if (strcmp(tokens[5], "delete") != 0) {
3860 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3864 if (strcmp(tokens[6], "match") != 0) {
3865 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3869 if (strcmp(tokens[7], "default") != 0) {
3870 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3874 status = pipeline_table_rule_delete_default(pipeline_name,
3877 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3883 * pipeline <pipeline_name> table <table_id> rule read stats [clear]
3886 cmd_pipeline_table_rule_stats_read(char **tokens,
3887 uint32_t n_tokens __rte_unused,
3891 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
3895 * pipeline <pipeline_name> table <table_id> meter profile <meter_profile_id>
3896 * add srtcm cir <cir> cbs <cbs> ebs <ebs>
3897 * | trtcm cir <cir> pir <pir> cbs <cbs> pbs <pbs>
3900 cmd_pipeline_table_meter_profile_add(char **tokens,
3905 struct rte_table_action_meter_profile p;
3906 char *pipeline_name;
3907 uint32_t table_id, meter_profile_id;
3911 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3915 pipeline_name = tokens[1];
3917 if (strcmp(tokens[2], "table") != 0) {
3918 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
3922 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3923 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3927 if (strcmp(tokens[4], "meter") != 0) {
3928 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
3932 if (strcmp(tokens[5], "profile") != 0) {
3933 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
3937 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
3938 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
3942 if (strcmp(tokens[7], "add") != 0) {
3943 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3947 if (strcmp(tokens[8], "srtcm") == 0) {
3948 if (n_tokens != 15) {
3949 snprintf(out, out_size, MSG_ARG_MISMATCH,
3954 p.alg = RTE_TABLE_ACTION_METER_SRTCM;
3956 if (strcmp(tokens[9], "cir") != 0) {
3957 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
3961 if (parser_read_uint64(&p.srtcm.cir, tokens[10]) != 0) {
3962 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
3966 if (strcmp(tokens[11], "cbs") != 0) {
3967 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
3971 if (parser_read_uint64(&p.srtcm.cbs, tokens[12]) != 0) {
3972 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
3976 if (strcmp(tokens[13], "ebs") != 0) {
3977 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "ebs");
3981 if (parser_read_uint64(&p.srtcm.ebs, tokens[14]) != 0) {
3982 snprintf(out, out_size, MSG_ARG_INVALID, "ebs");
3985 } else if (strcmp(tokens[8], "trtcm") == 0) {
3986 if (n_tokens != 17) {
3987 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3991 p.alg = RTE_TABLE_ACTION_METER_TRTCM;
3993 if (strcmp(tokens[9], "cir") != 0) {
3994 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
3998 if (parser_read_uint64(&p.trtcm.cir, tokens[10]) != 0) {
3999 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
4003 if (strcmp(tokens[11], "pir") != 0) {
4004 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pir");
4008 if (parser_read_uint64(&p.trtcm.pir, tokens[12]) != 0) {
4009 snprintf(out, out_size, MSG_ARG_INVALID, "pir");
4012 if (strcmp(tokens[13], "cbs") != 0) {
4013 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
4017 if (parser_read_uint64(&p.trtcm.cbs, tokens[14]) != 0) {
4018 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
4022 if (strcmp(tokens[15], "pbs") != 0) {
4023 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pbs");
4027 if (parser_read_uint64(&p.trtcm.pbs, tokens[16]) != 0) {
4028 snprintf(out, out_size, MSG_ARG_INVALID, "pbs");
4032 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4036 status = pipeline_table_mtr_profile_add(pipeline_name,
4041 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4047 * pipeline <pipeline_name> table <table_id>
4048 * meter profile <meter_profile_id> delete
4051 cmd_pipeline_table_meter_profile_delete(char **tokens,
4056 char *pipeline_name;
4057 uint32_t table_id, meter_profile_id;
4060 if (n_tokens != 8) {
4061 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4065 pipeline_name = tokens[1];
4067 if (strcmp(tokens[2], "table") != 0) {
4068 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4072 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4073 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4077 if (strcmp(tokens[4], "meter") != 0) {
4078 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
4082 if (strcmp(tokens[5], "profile") != 0) {
4083 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
4087 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
4088 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
4092 if (strcmp(tokens[7], "delete") != 0) {
4093 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
4097 status = pipeline_table_mtr_profile_delete(pipeline_name,
4101 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4107 * pipeline <pipeline_name> table <table_id> rule read meter [clear]
4110 cmd_pipeline_table_rule_meter_read(char **tokens,
4111 uint32_t n_tokens __rte_unused,
4115 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4119 * pipeline <pipeline_name> table <table_id> dscp <file_name>
4122 * - exactly 64 lines
4123 * - line format: <tc_id> <tc_queue_id> <color>, with <color> as: g | y | r
4126 load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
4127 const char *file_name,
4128 uint32_t *line_number)
4133 /* Check input arguments */
4134 if ((dscp_table == NULL) ||
4135 (file_name == NULL) ||
4136 (line_number == NULL)) {
4142 /* Open input file */
4143 f = fopen(file_name, "r");
4150 for (dscp = 0, l = 1; ; l++) {
4153 enum rte_meter_color color;
4154 uint32_t tc_id, tc_queue_id, n_tokens = RTE_DIM(tokens);
4156 if (fgets(line, sizeof(line), f) == NULL)
4159 if (is_comment(line))
4162 if (parse_tokenize_string(line, tokens, &n_tokens)) {
4171 if ((dscp >= RTE_DIM(dscp_table->entry)) ||
4172 (n_tokens != RTE_DIM(tokens)) ||
4173 parser_read_uint32(&tc_id, tokens[0]) ||
4174 (tc_id >= RTE_TABLE_ACTION_TC_MAX) ||
4175 parser_read_uint32(&tc_queue_id, tokens[1]) ||
4176 (tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) ||
4177 (strlen(tokens[2]) != 1)) {
4183 switch (tokens[2][0]) {
4186 color = e_RTE_METER_GREEN;
4191 color = e_RTE_METER_YELLOW;
4196 color = e_RTE_METER_RED;
4205 dscp_table->entry[dscp].tc_id = tc_id;
4206 dscp_table->entry[dscp].tc_queue_id = tc_queue_id;
4207 dscp_table->entry[dscp].color = color;
4217 cmd_pipeline_table_dscp(char **tokens,
4222 struct rte_table_action_dscp_table dscp_table;
4223 char *pipeline_name, *file_name;
4224 uint32_t table_id, line_number;
4227 if (n_tokens != 6) {
4228 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4232 pipeline_name = tokens[1];
4234 if (strcmp(tokens[2], "table") != 0) {
4235 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4239 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4240 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4244 if (strcmp(tokens[4], "dscp") != 0) {
4245 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dscp");
4249 file_name = tokens[5];
4251 status = load_dscp_table(&dscp_table, file_name, &line_number);
4253 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
4257 status = pipeline_table_dscp_table_update(pipeline_name,
4262 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4268 * pipeline <pipeline_name> table <table_id> rule read ttl [clear]
4271 cmd_pipeline_table_rule_ttl_read(char **tokens,
4272 uint32_t n_tokens __rte_unused,
4276 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4280 * thread <thread_id> pipeline <pipeline_name> enable
4283 cmd_thread_pipeline_enable(char **tokens,
4288 char *pipeline_name;
4292 if (n_tokens != 5) {
4293 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4297 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4298 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4302 if (strcmp(tokens[2], "pipeline") != 0) {
4303 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4307 pipeline_name = tokens[3];
4309 if (strcmp(tokens[4], "enable") != 0) {
4310 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
4314 status = thread_pipeline_enable(thread_id, pipeline_name);
4316 snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable");
4322 * thread <thread_id> pipeline <pipeline_name> disable
4325 cmd_thread_pipeline_disable(char **tokens,
4330 char *pipeline_name;
4334 if (n_tokens != 5) {
4335 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4339 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4340 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4344 if (strcmp(tokens[2], "pipeline") != 0) {
4345 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4349 pipeline_name = tokens[3];
4351 if (strcmp(tokens[4], "disable") != 0) {
4352 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
4356 status = thread_pipeline_disable(thread_id, pipeline_name);
4358 snprintf(out, out_size, MSG_CMD_FAIL,
4359 "thread pipeline disable");
4365 cli_process(char *in, char *out, size_t out_size)
4367 char *tokens[CMD_MAX_TOKENS];
4368 uint32_t n_tokens = RTE_DIM(tokens);
4374 status = parse_tokenize_string(in, tokens, &n_tokens);
4376 snprintf(out, out_size, MSG_ARG_TOO_MANY, "");
4383 if (strcmp(tokens[0], "mempool") == 0) {
4384 cmd_mempool(tokens, n_tokens, out, out_size);
4388 if (strcmp(tokens[0], "link") == 0) {
4389 cmd_link(tokens, n_tokens, out, out_size);
4393 if (strcmp(tokens[0], "swq") == 0) {
4394 cmd_swq(tokens, n_tokens, out, out_size);
4398 if (strcmp(tokens[0], "tmgr") == 0) {
4399 if ((n_tokens >= 3) &&
4400 (strcmp(tokens[1], "subport") == 0) &&
4401 (strcmp(tokens[2], "profile") == 0)) {
4402 cmd_tmgr_subport_profile(tokens, n_tokens,
4407 if ((n_tokens >= 3) &&
4408 (strcmp(tokens[1], "pipe") == 0) &&
4409 (strcmp(tokens[2], "profile") == 0)) {
4410 cmd_tmgr_pipe_profile(tokens, n_tokens, out, out_size);
4414 if ((n_tokens >= 5) &&
4415 (strcmp(tokens[2], "subport") == 0) &&
4416 (strcmp(tokens[4], "profile") == 0)) {
4417 cmd_tmgr_subport(tokens, n_tokens, out, out_size);
4421 if ((n_tokens >= 5) &&
4422 (strcmp(tokens[2], "subport") == 0) &&
4423 (strcmp(tokens[4], "pipe") == 0)) {
4424 cmd_tmgr_subport_pipe(tokens, n_tokens, out, out_size);
4428 cmd_tmgr(tokens, n_tokens, out, out_size);
4432 if (strcmp(tokens[0], "tap") == 0) {
4433 cmd_tap(tokens, n_tokens, out, out_size);
4437 if (strcmp(tokens[0], "kni") == 0) {
4438 cmd_kni(tokens, n_tokens, out, out_size);
4442 if (strcmp(tokens[0], "port") == 0) {
4443 cmd_port_in_action_profile(tokens, n_tokens, out, out_size);
4447 if (strcmp(tokens[0], "table") == 0) {
4448 cmd_table_action_profile(tokens, n_tokens, out, out_size);
4452 if (strcmp(tokens[0], "pipeline") == 0) {
4453 if ((n_tokens >= 3) &&
4454 (strcmp(tokens[2], "period") == 0)) {
4455 cmd_pipeline(tokens, n_tokens, out, out_size);
4459 if ((n_tokens >= 5) &&
4460 (strcmp(tokens[2], "port") == 0) &&
4461 (strcmp(tokens[3], "in") == 0) &&
4462 (strcmp(tokens[4], "bsz") == 0)) {
4463 cmd_pipeline_port_in(tokens, n_tokens, out, out_size);
4467 if ((n_tokens >= 5) &&
4468 (strcmp(tokens[2], "port") == 0) &&
4469 (strcmp(tokens[3], "out") == 0) &&
4470 (strcmp(tokens[4], "bsz") == 0)) {
4471 cmd_pipeline_port_out(tokens, n_tokens, out, out_size);
4475 if ((n_tokens >= 4) &&
4476 (strcmp(tokens[2], "table") == 0) &&
4477 (strcmp(tokens[3], "match") == 0)) {
4478 cmd_pipeline_table(tokens, n_tokens, out, out_size);
4482 if ((n_tokens >= 6) &&
4483 (strcmp(tokens[2], "port") == 0) &&
4484 (strcmp(tokens[3], "in") == 0) &&
4485 (strcmp(tokens[5], "table") == 0)) {
4486 cmd_pipeline_port_in_table(tokens, n_tokens,
4491 if ((n_tokens >= 6) &&
4492 (strcmp(tokens[2], "port") == 0) &&
4493 (strcmp(tokens[3], "in") == 0) &&
4494 (strcmp(tokens[5], "stats") == 0)) {
4495 cmd_pipeline_port_in_stats(tokens, n_tokens,
4500 if ((n_tokens >= 6) &&
4501 (strcmp(tokens[2], "port") == 0) &&
4502 (strcmp(tokens[3], "in") == 0) &&
4503 (strcmp(tokens[5], "enable") == 0)) {
4504 cmd_pipeline_port_in_enable(tokens, n_tokens,
4509 if ((n_tokens >= 6) &&
4510 (strcmp(tokens[2], "port") == 0) &&
4511 (strcmp(tokens[3], "in") == 0) &&
4512 (strcmp(tokens[5], "disable") == 0)) {
4513 cmd_pipeline_port_in_disable(tokens, n_tokens,
4518 if ((n_tokens >= 6) &&
4519 (strcmp(tokens[2], "port") == 0) &&
4520 (strcmp(tokens[3], "out") == 0) &&
4521 (strcmp(tokens[5], "stats") == 0)) {
4522 cmd_pipeline_port_out_stats(tokens, n_tokens,
4527 if ((n_tokens >= 5) &&
4528 (strcmp(tokens[2], "table") == 0) &&
4529 (strcmp(tokens[4], "stats") == 0)) {
4530 cmd_pipeline_table_stats(tokens, n_tokens,
4535 if ((n_tokens >= 7) &&
4536 (strcmp(tokens[2], "table") == 0) &&
4537 (strcmp(tokens[4], "rule") == 0) &&
4538 (strcmp(tokens[5], "add") == 0) &&
4539 (strcmp(tokens[6], "match") == 0)) {
4540 if ((n_tokens >= 8) &&
4541 (strcmp(tokens[7], "default") == 0)) {
4542 cmd_pipeline_table_rule_add_default(tokens,
4543 n_tokens, out, out_size);
4547 cmd_pipeline_table_rule_add(tokens, n_tokens,
4552 if ((n_tokens >= 7) &&
4553 (strcmp(tokens[2], "table") == 0) &&
4554 (strcmp(tokens[4], "rule") == 0) &&
4555 (strcmp(tokens[5], "add") == 0) &&
4556 (strcmp(tokens[6], "bulk") == 0)) {
4557 cmd_pipeline_table_rule_add_bulk(tokens,
4558 n_tokens, out, out_size);
4562 if ((n_tokens >= 7) &&
4563 (strcmp(tokens[2], "table") == 0) &&
4564 (strcmp(tokens[4], "rule") == 0) &&
4565 (strcmp(tokens[5], "delete") == 0) &&
4566 (strcmp(tokens[6], "match") == 0)) {
4567 if ((n_tokens >= 8) &&
4568 (strcmp(tokens[7], "default") == 0)) {
4569 cmd_pipeline_table_rule_delete_default(tokens,
4570 n_tokens, out, out_size);
4574 cmd_pipeline_table_rule_delete(tokens, n_tokens,
4579 if ((n_tokens >= 7) &&
4580 (strcmp(tokens[2], "table") == 0) &&
4581 (strcmp(tokens[4], "rule") == 0) &&
4582 (strcmp(tokens[5], "read") == 0) &&
4583 (strcmp(tokens[6], "stats") == 0)) {
4584 cmd_pipeline_table_rule_stats_read(tokens, n_tokens,
4589 if ((n_tokens >= 8) &&
4590 (strcmp(tokens[2], "table") == 0) &&
4591 (strcmp(tokens[4], "meter") == 0) &&
4592 (strcmp(tokens[5], "profile") == 0) &&
4593 (strcmp(tokens[7], "add") == 0)) {
4594 cmd_pipeline_table_meter_profile_add(tokens, n_tokens,
4599 if ((n_tokens >= 8) &&
4600 (strcmp(tokens[2], "table") == 0) &&
4601 (strcmp(tokens[4], "meter") == 0) &&
4602 (strcmp(tokens[5], "profile") == 0) &&
4603 (strcmp(tokens[7], "delete") == 0)) {
4604 cmd_pipeline_table_meter_profile_delete(tokens,
4605 n_tokens, out, out_size);
4609 if ((n_tokens >= 7) &&
4610 (strcmp(tokens[2], "table") == 0) &&
4611 (strcmp(tokens[4], "rule") == 0) &&
4612 (strcmp(tokens[5], "read") == 0) &&
4613 (strcmp(tokens[6], "meter") == 0)) {
4614 cmd_pipeline_table_rule_meter_read(tokens, n_tokens,
4619 if ((n_tokens >= 5) &&
4620 (strcmp(tokens[2], "table") == 0) &&
4621 (strcmp(tokens[4], "dscp") == 0)) {
4622 cmd_pipeline_table_dscp(tokens, n_tokens,
4627 if ((n_tokens >= 7) &&
4628 (strcmp(tokens[2], "table") == 0) &&
4629 (strcmp(tokens[4], "rule") == 0) &&
4630 (strcmp(tokens[5], "read") == 0) &&
4631 (strcmp(tokens[6], "ttl") == 0)) {
4632 cmd_pipeline_table_rule_ttl_read(tokens, n_tokens,
4638 if (strcmp(tokens[0], "thread") == 0) {
4639 if ((n_tokens >= 5) &&
4640 (strcmp(tokens[4], "enable") == 0)) {
4641 cmd_thread_pipeline_enable(tokens, n_tokens,
4646 if ((n_tokens >= 5) &&
4647 (strcmp(tokens[4], "disable") == 0)) {
4648 cmd_thread_pipeline_disable(tokens, n_tokens,
4654 snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
4658 cli_script_process(const char *file_name,
4659 size_t msg_in_len_max,
4660 size_t msg_out_len_max)
4662 char *msg_in = NULL, *msg_out = NULL;
4665 /* Check input arguments */
4666 if ((file_name == NULL) ||
4667 (strlen(file_name) == 0) ||
4668 (msg_in_len_max == 0) ||
4669 (msg_out_len_max == 0))
4672 msg_in = malloc(msg_in_len_max + 1);
4673 msg_out = malloc(msg_out_len_max + 1);
4674 if ((msg_in == NULL) ||
4675 (msg_out == NULL)) {
4681 /* Open input file */
4682 f = fopen(file_name, "r");
4691 if (fgets(msg_in, msg_in_len_max + 1, f) == NULL)
4694 printf("%s", msg_in);
4701 if (strlen(msg_out))
4702 printf("%s", msg_out);
4713 cli_rule_file_process(const char *file_name,
4714 size_t line_len_max,
4715 struct table_rule_match *m,
4716 struct table_rule_action *a,
4718 uint32_t *line_number,
4724 uint32_t rule_id, line_id;
4727 /* Check input arguments */
4728 if ((file_name == NULL) ||
4729 (strlen(file_name) == 0) ||
4730 (line_len_max == 0)) {
4735 /* Memory allocation */
4736 line = malloc(line_len_max + 1);
4743 f = fopen(file_name, "r");
4751 for (line_id = 1, rule_id = 0; rule_id < *n_rules; line_id++) {
4752 char *tokens[CMD_MAX_TOKENS];
4753 uint32_t n_tokens, n_tokens_parsed, t0;
4755 /* Read next line from file. */
4756 if (fgets(line, line_len_max + 1, f) == NULL)
4760 if (is_comment(line))
4764 n_tokens = RTE_DIM(tokens);
4765 status = parse_tokenize_string(line, tokens, &n_tokens);
4777 n_tokens_parsed = parse_match(tokens + t0,
4782 if (n_tokens_parsed == 0) {
4786 t0 += n_tokens_parsed;
4789 n_tokens_parsed = parse_table_action(tokens + t0,
4794 if (n_tokens_parsed == 0) {
4798 t0 += n_tokens_parsed;
4800 /* Line completed. */
4801 if (t0 < n_tokens) {
4806 /* Increment rule count */
4817 *line_number = line_id;