1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
10 #include <rte_common.h>
22 #ifndef CMD_MAX_TOKENS
23 #define CMD_MAX_TOKENS 256
26 #define MSG_OUT_OF_MEMORY "Not enough memory.\n"
27 #define MSG_CMD_UNKNOWN "Unknown command \"%s\".\n"
28 #define MSG_CMD_UNIMPLEM "Command \"%s\" not implemented.\n"
29 #define MSG_ARG_NOT_ENOUGH "Not enough arguments for command \"%s\".\n"
30 #define MSG_ARG_TOO_MANY "Too many arguments for command \"%s\".\n"
31 #define MSG_ARG_MISMATCH "Wrong number of arguments for command \"%s\".\n"
32 #define MSG_ARG_NOT_FOUND "Argument \"%s\" not found.\n"
33 #define MSG_ARG_INVALID "Invalid value for argument \"%s\".\n"
34 #define MSG_FILE_ERR "Error in file \"%s\" at line %u.\n"
35 #define MSG_CMD_FAIL "Command \"%s\" failed.\n"
40 if ((strlen(in) && index("!#%;", in[0])) ||
41 (strncmp(in, "//", 2) == 0) ||
42 (strncmp(in, "--", 2) == 0))
49 * mempool <mempool_name>
50 * buffer <buffer_size>
56 cmd_mempool(char **tokens,
61 struct mempool_params p;
63 struct mempool *mempool;
66 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
72 if (strcmp(tokens[2], "buffer") != 0) {
73 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buffer");
77 if (parser_read_uint32(&p.buffer_size, tokens[3]) != 0) {
78 snprintf(out, out_size, MSG_ARG_INVALID, "buffer_size");
82 if (strcmp(tokens[4], "pool") != 0) {
83 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pool");
87 if (parser_read_uint32(&p.pool_size, tokens[5]) != 0) {
88 snprintf(out, out_size, MSG_ARG_INVALID, "pool_size");
92 if (strcmp(tokens[6], "cache") != 0) {
93 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cache");
97 if (parser_read_uint32(&p.cache_size, tokens[7]) != 0) {
98 snprintf(out, out_size, MSG_ARG_INVALID, "cache_size");
102 if (strcmp(tokens[8], "cpu") != 0) {
103 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
107 if (parser_read_uint32(&p.cpu_id, tokens[9]) != 0) {
108 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
112 mempool = mempool_create(name, &p);
113 if (mempool == NULL) {
114 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
121 * dev <device_name> | port <port_id>
122 * rxq <n_queues> <queue_size> <mempool_name>
123 * txq <n_queues> <queue_size>
124 * promiscuous on | off
125 * [rss <qid_0> ... <qid_n>]
128 cmd_link(char **tokens,
133 struct link_params p;
134 struct link_params_rss rss;
138 if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) {
139 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
144 if (strcmp(tokens[2], "dev") == 0)
145 p.dev_name = tokens[3];
146 else if (strcmp(tokens[2], "port") == 0) {
149 if (parser_read_uint16(&p.port_id, tokens[3]) != 0) {
150 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
154 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dev or port");
158 if (strcmp(tokens[4], "rxq") != 0) {
159 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
163 if (parser_read_uint32(&p.rx.n_queues, tokens[5]) != 0) {
164 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
167 if (parser_read_uint32(&p.rx.queue_size, tokens[6]) != 0) {
168 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
172 p.rx.mempool_name = tokens[7];
174 if (strcmp(tokens[8], "txq") != 0) {
175 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
179 if (parser_read_uint32(&p.tx.n_queues, tokens[9]) != 0) {
180 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
184 if (parser_read_uint32(&p.tx.queue_size, tokens[10]) != 0) {
185 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
189 if (strcmp(tokens[11], "promiscuous") != 0) {
190 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "promiscuous");
194 if (strcmp(tokens[12], "on") == 0)
196 else if (strcmp(tokens[12], "off") == 0)
199 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "on or off");
206 uint32_t queue_id, i;
208 if (strcmp(tokens[13], "rss") != 0) {
209 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rss");
216 for (i = 14; i < n_tokens; i++) {
217 if (parser_read_uint32(&queue_id, tokens[i]) != 0) {
218 snprintf(out, out_size, MSG_ARG_INVALID,
223 rss.queue_id[rss.n_queues] = queue_id;
228 link = link_create(name, &p);
230 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
241 cmd_swq(char **tokens,
251 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
257 if (strcmp(tokens[2], "size") != 0) {
258 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
262 if (parser_read_uint32(&p.size, tokens[3]) != 0) {
263 snprintf(out, out_size, MSG_ARG_INVALID, "size");
267 if (strcmp(tokens[4], "cpu") != 0) {
268 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
272 if (parser_read_uint32(&p.cpu_id, tokens[5]) != 0) {
273 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
277 swq = swq_create(name, &p);
279 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
285 * tmgr subport profile
286 * <tb_rate> <tb_size>
287 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
291 cmd_tmgr_subport_profile(char **tokens,
296 struct rte_sched_subport_params p;
299 if (n_tokens != 10) {
300 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
304 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
305 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
309 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
310 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
314 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
315 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
316 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
320 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
321 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
325 status = tmgr_subport_profile_add(&p);
327 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
334 * <tb_rate> <tb_size>
335 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
341 cmd_tmgr_pipe_profile(char **tokens,
346 struct rte_sched_pipe_params p;
349 if (n_tokens != 27) {
350 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
354 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
355 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
359 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
360 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
364 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
365 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
366 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
370 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
371 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
375 #ifdef RTE_SCHED_SUBPORT_TC_OV
376 if (parser_read_uint8(&p.tc_ov_weight, tokens[10]) != 0) {
377 snprintf(out, out_size, MSG_ARG_INVALID, "tc_ov_weight");
382 for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++)
383 if (parser_read_uint8(&p.wrr_weights[i], tokens[11 + i]) != 0) {
384 snprintf(out, out_size, MSG_ARG_INVALID, "wrr_weights");
388 status = tmgr_pipe_profile_add(&p);
390 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
398 * spp <n_subports_per_port>
399 * pps <n_pipes_per_subport>
400 * qsize <qsize_tc0> <qsize_tc1> <qsize_tc2> <qsize_tc3>
401 * fo <frame_overhead>
406 cmd_tmgr(char **tokens,
411 struct tmgr_port_params p;
413 struct tmgr_port *tmgr_port;
416 if (n_tokens != 19) {
417 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
423 if (strcmp(tokens[2], "rate") != 0) {
424 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rate");
428 if (parser_read_uint32(&p.rate, tokens[3]) != 0) {
429 snprintf(out, out_size, MSG_ARG_INVALID, "rate");
433 if (strcmp(tokens[4], "spp") != 0) {
434 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
438 if (parser_read_uint32(&p.n_subports_per_port, tokens[5]) != 0) {
439 snprintf(out, out_size, MSG_ARG_INVALID, "n_subports_per_port");
443 if (strcmp(tokens[6], "pps") != 0) {
444 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
448 if (parser_read_uint32(&p.n_pipes_per_subport, tokens[7]) != 0) {
449 snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport");
453 if (strcmp(tokens[8], "qsize") != 0) {
454 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "qsize");
458 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
459 if (parser_read_uint16(&p.qsize[i], tokens[9 + i]) != 0) {
460 snprintf(out, out_size, MSG_ARG_INVALID, "qsize");
464 if (strcmp(tokens[13], "fo") != 0) {
465 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fo");
469 if (parser_read_uint32(&p.frame_overhead, tokens[14]) != 0) {
470 snprintf(out, out_size, MSG_ARG_INVALID, "frame_overhead");
474 if (strcmp(tokens[15], "mtu") != 0) {
475 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mtu");
479 if (parser_read_uint32(&p.mtu, tokens[16]) != 0) {
480 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
484 if (strcmp(tokens[17], "cpu") != 0) {
485 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
489 if (parser_read_uint32(&p.cpu_id, tokens[18]) != 0) {
490 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
494 tmgr_port = tmgr_port_create(name, &p);
495 if (tmgr_port == NULL) {
496 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
502 * tmgr <tmgr_name> subport <subport_id>
503 * profile <subport_profile_id>
506 cmd_tmgr_subport(char **tokens,
511 uint32_t subport_id, subport_profile_id;
516 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
522 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
523 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
527 if (parser_read_uint32(&subport_profile_id, tokens[5]) != 0) {
528 snprintf(out, out_size, MSG_ARG_INVALID, "subport_profile_id");
532 status = tmgr_subport_config(name, subport_id, subport_profile_id);
534 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
540 * tmgr <tmgr_name> subport <subport_id> pipe
541 * from <pipe_id_first> to <pipe_id_last>
542 * profile <pipe_profile_id>
545 cmd_tmgr_subport_pipe(char **tokens,
550 uint32_t subport_id, pipe_id_first, pipe_id_last, pipe_profile_id;
554 if (n_tokens != 11) {
555 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
561 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
562 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
566 if (strcmp(tokens[4], "pipe") != 0) {
567 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipe");
571 if (strcmp(tokens[5], "from") != 0) {
572 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "from");
576 if (parser_read_uint32(&pipe_id_first, tokens[6]) != 0) {
577 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_first");
581 if (strcmp(tokens[7], "to") != 0) {
582 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "to");
586 if (parser_read_uint32(&pipe_id_last, tokens[8]) != 0) {
587 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_last");
591 if (strcmp(tokens[9], "profile") != 0) {
592 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
596 if (parser_read_uint32(&pipe_profile_id, tokens[10]) != 0) {
597 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_profile_id");
601 status = tmgr_pipe_config(name, subport_id, pipe_id_first,
602 pipe_id_last, pipe_profile_id);
604 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
613 cmd_tap(char **tokens,
622 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
628 tap = tap_create(name);
630 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
638 * mempool <mempool_name>
639 * [thread <thread_id>]
642 cmd_kni(char **tokens,
651 if ((n_tokens != 6) && (n_tokens != 8)) {
652 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
658 if (strcmp(tokens[2], "link") != 0) {
659 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "link");
663 p.link_name = tokens[3];
665 if (strcmp(tokens[4], "mempool") != 0) {
666 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool");
670 p.mempool_name = tokens[5];
673 if (strcmp(tokens[6], "thread") != 0) {
674 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "thread");
678 if (parser_read_uint32(&p.thread_id, tokens[7]) != 0) {
679 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
687 kni = kni_create(name, &p);
689 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
695 * port in action profile <profile_name>
696 * [filter match | mismatch offset <key_offset> mask <key_mask> key <key_value> port <port_id>]
697 * [balance offset <key_offset> mask <key_mask> port <port_id0> ... <port_id15>]
700 cmd_port_in_action_profile(char **tokens,
705 struct port_in_action_profile_params p;
706 struct port_in_action_profile *ap;
710 memset(&p, 0, sizeof(p));
713 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
717 if (strcmp(tokens[1], "in") != 0) {
718 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
722 if (strcmp(tokens[2], "action") != 0) {
723 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
727 if (strcmp(tokens[3], "profile") != 0) {
728 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
736 if ((t0 < n_tokens) && (strcmp(tokens[t0], "filter") == 0)) {
739 if (n_tokens < t0 + 10) {
740 snprintf(out, out_size, MSG_ARG_MISMATCH, "port in action profile filter");
744 if (strcmp(tokens[t0 + 1], "match") == 0)
745 p.fltr.filter_on_match = 1;
746 else if (strcmp(tokens[t0 + 1], "mismatch") == 0)
747 p.fltr.filter_on_match = 0;
749 snprintf(out, out_size, MSG_ARG_INVALID, "match or mismatch");
753 if (strcmp(tokens[t0 + 2], "offset") != 0) {
754 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
758 if (parser_read_uint32(&p.fltr.key_offset, tokens[t0 + 3]) != 0) {
759 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
763 if (strcmp(tokens[t0 + 4], "mask") != 0) {
764 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
768 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
769 if ((parse_hex_string(tokens[t0 + 5], p.fltr.key_mask, &size) != 0) ||
770 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
771 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
775 if (strcmp(tokens[t0 + 6], "key") != 0) {
776 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
780 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
781 if ((parse_hex_string(tokens[t0 + 7], p.fltr.key, &size) != 0) ||
782 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
783 snprintf(out, out_size, MSG_ARG_INVALID, "key_value");
787 if (strcmp(tokens[t0 + 8], "port") != 0) {
788 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
792 if (parser_read_uint32(&p.fltr.port_id, tokens[t0 + 9]) != 0) {
793 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
797 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_FLTR;
801 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
804 if (n_tokens < t0 + 22) {
805 snprintf(out, out_size, MSG_ARG_MISMATCH, "port in action profile balance");
809 if (strcmp(tokens[t0 + 1], "offset") != 0) {
810 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
814 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
815 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
819 if (strcmp(tokens[t0 + 3], "mask") != 0) {
820 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
824 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
825 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
826 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
830 if (strcmp(tokens[t0 + 5], "port") != 0) {
831 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
835 for (i = 0; i < 16; i++)
836 if (parser_read_uint32(&p.lb.port_id[i], tokens[t0 + 6 + i]) != 0) {
837 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
841 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_LB;
846 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
850 ap = port_in_action_profile_create(name, &p);
852 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
858 * table action profile <profile_name>
862 * [meter srtcm | trtcm
864 * stats none | pkts | bytes | both]
865 * [tm spp <n_subports_per_port> pps <n_pipes_per_subport>]
866 * [encap ether | vlan | qinq | mpls | pppoe]
871 * [stats pkts | bytes | both]
875 cmd_table_action_profile(char **tokens,
880 struct table_action_profile_params p;
881 struct table_action_profile *ap;
885 memset(&p, 0, sizeof(p));
888 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
892 if (strcmp(tokens[1], "action") != 0) {
893 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
897 if (strcmp(tokens[2], "profile") != 0) {
898 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
904 if (strcmp(tokens[4], "ipv4") == 0)
905 p.common.ip_version = 1;
906 else if (strcmp(tokens[4], "ipv6") == 0)
907 p.common.ip_version = 0;
909 snprintf(out, out_size, MSG_ARG_INVALID, "ipv4 or ipv6");
913 if (strcmp(tokens[5], "offset") != 0) {
914 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
918 if (parser_read_uint32(&p.common.ip_offset, tokens[6]) != 0) {
919 snprintf(out, out_size, MSG_ARG_INVALID, "ip_offset");
923 if (strcmp(tokens[7], "fwd") != 0) {
924 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fwd");
928 p.action_mask |= 1LLU << RTE_TABLE_ACTION_FWD;
931 if ((t0 < n_tokens) && (strcmp(tokens[t0], "meter") == 0)) {
932 if (n_tokens < t0 + 6) {
933 snprintf(out, out_size, MSG_ARG_MISMATCH,
934 "table action profile meter");
938 if (strcmp(tokens[t0 + 1], "srtcm") == 0)
939 p.mtr.alg = RTE_TABLE_ACTION_METER_SRTCM;
940 else if (strcmp(tokens[t0 + 1], "trtcm") == 0)
941 p.mtr.alg = RTE_TABLE_ACTION_METER_TRTCM;
943 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
948 if (strcmp(tokens[t0 + 2], "tc") != 0) {
949 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc");
953 if (parser_read_uint32(&p.mtr.n_tc, tokens[t0 + 3]) != 0) {
954 snprintf(out, out_size, MSG_ARG_INVALID, "n_tc");
958 if (strcmp(tokens[t0 + 4], "stats") != 0) {
959 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
963 if (strcmp(tokens[t0 + 5], "none") == 0) {
964 p.mtr.n_packets_enabled = 0;
965 p.mtr.n_bytes_enabled = 0;
966 } else if (strcmp(tokens[t0 + 5], "pkts") == 0) {
967 p.mtr.n_packets_enabled = 1;
968 p.mtr.n_bytes_enabled = 0;
969 } else if (strcmp(tokens[t0 + 5], "bytes") == 0) {
970 p.mtr.n_packets_enabled = 0;
971 p.mtr.n_bytes_enabled = 1;
972 } else if (strcmp(tokens[t0 + 5], "both") == 0) {
973 p.mtr.n_packets_enabled = 1;
974 p.mtr.n_bytes_enabled = 1;
976 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
977 "none or pkts or bytes or both");
981 p.action_mask |= 1LLU << RTE_TABLE_ACTION_MTR;
985 if ((t0 < n_tokens) && (strcmp(tokens[t0], "tm") == 0)) {
986 if (n_tokens < t0 + 5) {
987 snprintf(out, out_size, MSG_ARG_MISMATCH,
988 "table action profile tm");
992 if (strcmp(tokens[t0 + 1], "spp") != 0) {
993 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
997 if (parser_read_uint32(&p.tm.n_subports_per_port,
998 tokens[t0 + 2]) != 0) {
999 snprintf(out, out_size, MSG_ARG_INVALID,
1000 "n_subports_per_port");
1004 if (strcmp(tokens[t0 + 3], "pps") != 0) {
1005 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
1009 if (parser_read_uint32(&p.tm.n_pipes_per_subport,
1010 tokens[t0 + 4]) != 0) {
1011 snprintf(out, out_size, MSG_ARG_INVALID,
1012 "n_pipes_per_subport");
1016 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TM;
1020 if ((t0 < n_tokens) && (strcmp(tokens[t0], "encap") == 0)) {
1021 if (n_tokens < t0 + 2) {
1022 snprintf(out, out_size, MSG_ARG_MISMATCH,
1023 "action profile encap");
1027 if (strcmp(tokens[t0 + 1], "ether") == 0)
1028 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER;
1029 else if (strcmp(tokens[t0 + 1], "vlan") == 0)
1030 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN;
1031 else if (strcmp(tokens[t0 + 1], "qinq") == 0)
1032 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ;
1033 else if (strcmp(tokens[t0 + 1], "mpls") == 0)
1034 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS;
1035 else if (strcmp(tokens[t0 + 1], "pppoe") == 0)
1036 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE;
1038 snprintf(out, out_size, MSG_ARG_MISMATCH, "encap");
1042 p.action_mask |= 1LLU << RTE_TABLE_ACTION_ENCAP;
1046 if ((t0 < n_tokens) && (strcmp(tokens[t0], "nat") == 0)) {
1047 if (n_tokens < t0 + 4) {
1048 snprintf(out, out_size, MSG_ARG_MISMATCH,
1049 "table action profile nat");
1053 if (strcmp(tokens[t0 + 1], "src") == 0)
1054 p.nat.source_nat = 1;
1055 else if (strcmp(tokens[t0 + 1], "dst") == 0)
1056 p.nat.source_nat = 0;
1058 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1063 if (strcmp(tokens[t0 + 2], "proto") != 0) {
1064 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "proto");
1068 if (strcmp(tokens[t0 + 3], "tcp") == 0)
1070 else if (strcmp(tokens[t0 + 3], "udp") == 0)
1073 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1078 p.action_mask |= 1LLU << RTE_TABLE_ACTION_NAT;
1082 if ((t0 < n_tokens) && (strcmp(tokens[t0], "ttl") == 0)) {
1083 if (n_tokens < t0 + 4) {
1084 snprintf(out, out_size, MSG_ARG_MISMATCH,
1085 "table action profile ttl");
1089 if (strcmp(tokens[t0 + 1], "drop") == 0)
1091 else if (strcmp(tokens[t0 + 1], "fwd") == 0)
1094 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1099 if (strcmp(tokens[t0 + 2], "stats") != 0) {
1100 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1104 if (strcmp(tokens[t0 + 3], "none") == 0)
1105 p.ttl.n_packets_enabled = 0;
1106 else if (strcmp(tokens[t0 + 3], "pkts") == 0)
1107 p.ttl.n_packets_enabled = 1;
1109 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1114 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TTL;
1118 if ((t0 < n_tokens) && (strcmp(tokens[t0], "stats") == 0)) {
1119 if (n_tokens < t0 + 2) {
1120 snprintf(out, out_size, MSG_ARG_MISMATCH,
1121 "table action profile stats");
1125 if (strcmp(tokens[t0 + 1], "pkts") == 0) {
1126 p.stats.n_packets_enabled = 1;
1127 p.stats.n_bytes_enabled = 0;
1128 } else if (strcmp(tokens[t0 + 1], "bytes") == 0) {
1129 p.stats.n_packets_enabled = 0;
1130 p.stats.n_bytes_enabled = 1;
1131 } else if (strcmp(tokens[t0 + 1], "both") == 0) {
1132 p.stats.n_packets_enabled = 1;
1133 p.stats.n_bytes_enabled = 1;
1135 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1136 "pkts or bytes or both");
1140 p.action_mask |= 1LLU << RTE_TABLE_ACTION_STATS;
1144 if ((t0 < n_tokens) && (strcmp(tokens[t0], "time") == 0)) {
1145 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TIME;
1149 if (t0 < n_tokens) {
1150 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1154 ap = table_action_profile_create(name, &p);
1156 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1162 * pipeline <pipeline_name>
1163 * period <timer_period_ms>
1164 * offset_port_id <offset_port_id>
1168 cmd_pipeline(char **tokens,
1173 struct pipeline_params p;
1175 struct pipeline *pipeline;
1177 if (n_tokens != 8) {
1178 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1184 if (strcmp(tokens[2], "period") != 0) {
1185 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "period");
1189 if (parser_read_uint32(&p.timer_period_ms, tokens[3]) != 0) {
1190 snprintf(out, out_size, MSG_ARG_INVALID, "timer_period_ms");
1194 if (strcmp(tokens[4], "offset_port_id") != 0) {
1195 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset_port_id");
1199 if (parser_read_uint32(&p.offset_port_id, tokens[5]) != 0) {
1200 snprintf(out, out_size, MSG_ARG_INVALID, "offset_port_id");
1204 if (strcmp(tokens[6], "cpu") != 0) {
1205 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
1209 if (parser_read_uint32(&p.cpu_id, tokens[7]) != 0) {
1210 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
1214 pipeline = pipeline_create(name, &p);
1215 if (pipeline == NULL) {
1216 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1222 * pipeline <pipeline_name> port in
1224 * link <link_name> rxq <queue_id>
1226 * | tmgr <tmgr_name>
1227 * | tap <tap_name> mempool <mempool_name> mtu <mtu>
1229 * | source mempool <mempool_name> file <file_name> bpp <n_bytes_per_pkt>
1230 * [action <port_in_action_profile_name>]
1234 cmd_pipeline_port_in(char **tokens,
1239 struct port_in_params p;
1240 char *pipeline_name;
1242 int enabled, status;
1245 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1249 pipeline_name = tokens[1];
1251 if (strcmp(tokens[2], "port") != 0) {
1252 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1256 if (strcmp(tokens[3], "in") != 0) {
1257 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1261 if (strcmp(tokens[4], "bsz") != 0) {
1262 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1266 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1267 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1273 if (strcmp(tokens[t0], "link") == 0) {
1274 if (n_tokens < t0 + 4) {
1275 snprintf(out, out_size, MSG_ARG_MISMATCH,
1276 "pipeline port in link");
1280 p.type = PORT_IN_RXQ;
1282 p.dev_name = tokens[t0 + 1];
1284 if (strcmp(tokens[t0 + 2], "rxq") != 0) {
1285 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
1289 if (parser_read_uint16(&p.rxq.queue_id, tokens[t0 + 3]) != 0) {
1290 snprintf(out, out_size, MSG_ARG_INVALID,
1295 } else if (strcmp(tokens[t0], "swq") == 0) {
1296 if (n_tokens < t0 + 2) {
1297 snprintf(out, out_size, MSG_ARG_MISMATCH,
1298 "pipeline port in swq");
1302 p.type = PORT_IN_SWQ;
1304 p.dev_name = tokens[t0 + 1];
1307 } else if (strcmp(tokens[t0], "tmgr") == 0) {
1308 if (n_tokens < t0 + 2) {
1309 snprintf(out, out_size, MSG_ARG_MISMATCH,
1310 "pipeline port in tmgr");
1314 p.type = PORT_IN_TMGR;
1316 p.dev_name = tokens[t0 + 1];
1319 } else if (strcmp(tokens[t0], "tap") == 0) {
1320 if (n_tokens < t0 + 6) {
1321 snprintf(out, out_size, MSG_ARG_MISMATCH,
1322 "pipeline port in tap");
1326 p.type = PORT_IN_TAP;
1328 p.dev_name = tokens[t0 + 1];
1330 if (strcmp(tokens[t0 + 2], "mempool") != 0) {
1331 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1336 p.tap.mempool_name = tokens[t0 + 3];
1338 if (strcmp(tokens[t0 + 4], "mtu") != 0) {
1339 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1344 if (parser_read_uint32(&p.tap.mtu, tokens[t0 + 5]) != 0) {
1345 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
1350 } else if (strcmp(tokens[t0], "kni") == 0) {
1351 if (n_tokens < t0 + 2) {
1352 snprintf(out, out_size, MSG_ARG_MISMATCH,
1353 "pipeline port in kni");
1357 p.type = PORT_IN_KNI;
1359 p.dev_name = tokens[t0 + 1];
1362 } else if (strcmp(tokens[t0], "source") == 0) {
1363 if (n_tokens < t0 + 6) {
1364 snprintf(out, out_size, MSG_ARG_MISMATCH,
1365 "pipeline port in source");
1369 p.type = PORT_IN_SOURCE;
1373 if (strcmp(tokens[t0 + 1], "mempool") != 0) {
1374 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1379 p.source.mempool_name = tokens[t0 + 2];
1381 if (strcmp(tokens[t0 + 3], "file") != 0) {
1382 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1387 p.source.file_name = tokens[t0 + 4];
1389 if (strcmp(tokens[t0 + 5], "bpp") != 0) {
1390 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1395 if (parser_read_uint32(&p.source.n_bytes_per_pkt, tokens[t0 + 6]) != 0) {
1396 snprintf(out, out_size, MSG_ARG_INVALID,
1403 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1407 p.action_profile_name = NULL;
1408 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1409 if (n_tokens < t0 + 2) {
1410 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1414 p.action_profile_name = tokens[t0 + 1];
1420 if ((n_tokens > t0) &&
1421 (strcmp(tokens[t0], "disabled") == 0)) {
1427 if (n_tokens != t0) {
1428 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1432 status = pipeline_port_in_create(pipeline_name,
1435 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1441 * pipeline <pipeline_name> port out
1443 * link <link_name> txq <txq_id>
1445 * | tmgr <tmgr_name>
1448 * | sink [file <file_name> pkts <max_n_pkts>]
1451 cmd_pipeline_port_out(char **tokens,
1456 struct port_out_params p;
1457 char *pipeline_name;
1460 memset(&p, 0, sizeof(p));
1463 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1467 pipeline_name = tokens[1];
1469 if (strcmp(tokens[2], "port") != 0) {
1470 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1474 if (strcmp(tokens[3], "out") != 0) {
1475 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
1479 if (strcmp(tokens[4], "bsz") != 0) {
1480 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1484 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1485 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1489 if (strcmp(tokens[6], "link") == 0) {
1490 if (n_tokens != 10) {
1491 snprintf(out, out_size, MSG_ARG_MISMATCH,
1492 "pipeline port out link");
1496 p.type = PORT_OUT_TXQ;
1498 p.dev_name = tokens[7];
1500 if (strcmp(tokens[8], "txq") != 0) {
1501 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
1505 if (parser_read_uint16(&p.txq.queue_id, tokens[9]) != 0) {
1506 snprintf(out, out_size, MSG_ARG_INVALID, "queue_id");
1509 } else if (strcmp(tokens[6], "swq") == 0) {
1510 if (n_tokens != 8) {
1511 snprintf(out, out_size, MSG_ARG_MISMATCH,
1512 "pipeline port out swq");
1516 p.type = PORT_OUT_SWQ;
1518 p.dev_name = tokens[7];
1519 } else if (strcmp(tokens[6], "tmgr") == 0) {
1520 if (n_tokens != 8) {
1521 snprintf(out, out_size, MSG_ARG_MISMATCH,
1522 "pipeline port out tmgr");
1526 p.type = PORT_OUT_TMGR;
1528 p.dev_name = tokens[7];
1529 } else if (strcmp(tokens[6], "tap") == 0) {
1530 if (n_tokens != 8) {
1531 snprintf(out, out_size, MSG_ARG_MISMATCH,
1532 "pipeline port out tap");
1536 p.type = PORT_OUT_TAP;
1538 p.dev_name = tokens[7];
1539 } else if (strcmp(tokens[6], "kni") == 0) {
1540 if (n_tokens != 8) {
1541 snprintf(out, out_size, MSG_ARG_MISMATCH,
1542 "pipeline port out kni");
1546 p.type = PORT_OUT_KNI;
1548 p.dev_name = tokens[7];
1549 } else if (strcmp(tokens[6], "sink") == 0) {
1550 if ((n_tokens != 7) && (n_tokens != 11)) {
1551 snprintf(out, out_size, MSG_ARG_MISMATCH,
1552 "pipeline port out sink");
1556 p.type = PORT_OUT_SINK;
1560 if (n_tokens == 7) {
1561 p.sink.file_name = NULL;
1562 p.sink.max_n_pkts = 0;
1564 if (strcmp(tokens[7], "file") != 0) {
1565 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1570 p.sink.file_name = tokens[8];
1572 if (strcmp(tokens[9], "pkts") != 0) {
1573 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pkts");
1577 if (parser_read_uint32(&p.sink.max_n_pkts, tokens[10]) != 0) {
1578 snprintf(out, out_size, MSG_ARG_INVALID, "max_n_pkts");
1583 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1587 status = pipeline_port_out_create(pipeline_name, &p);
1589 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1595 * pipeline <pipeline_name> table
1599 * offset <ip_header_offset>
1602 * offset <key_offset>
1608 * offset <key_offset>
1609 * buckets <n_buckets>
1613 * offset <ip_header_offset>
1616 * [action <table_action_profile_name>]
1619 cmd_pipeline_table(char **tokens,
1624 uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
1625 struct table_params p;
1626 char *pipeline_name;
1631 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1635 pipeline_name = tokens[1];
1637 if (strcmp(tokens[2], "table") != 0) {
1638 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1642 if (strcmp(tokens[3], "match") != 0) {
1643 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
1648 if (strcmp(tokens[t0], "acl") == 0) {
1649 if (n_tokens < t0 + 6) {
1650 snprintf(out, out_size, MSG_ARG_MISMATCH,
1651 "pipeline table acl");
1655 p.match_type = TABLE_ACL;
1657 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1658 p.match.acl.ip_version = 1;
1659 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1660 p.match.acl.ip_version = 0;
1662 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1667 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1668 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1672 if (parser_read_uint32(&p.match.acl.ip_header_offset,
1673 tokens[t0 + 3]) != 0) {
1674 snprintf(out, out_size, MSG_ARG_INVALID,
1675 "ip_header_offset");
1679 if (strcmp(tokens[t0 + 4], "size") != 0) {
1680 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1684 if (parser_read_uint32(&p.match.acl.n_rules,
1685 tokens[t0 + 5]) != 0) {
1686 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1691 } else if (strcmp(tokens[t0], "array") == 0) {
1692 if (n_tokens < t0 + 5) {
1693 snprintf(out, out_size, MSG_ARG_MISMATCH,
1694 "pipeline table array");
1698 p.match_type = TABLE_ARRAY;
1700 if (strcmp(tokens[t0 + 1], "offset") != 0) {
1701 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1705 if (parser_read_uint32(&p.match.array.key_offset,
1706 tokens[t0 + 2]) != 0) {
1707 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1711 if (strcmp(tokens[t0 + 3], "size") != 0) {
1712 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1716 if (parser_read_uint32(&p.match.array.n_keys,
1717 tokens[t0 + 4]) != 0) {
1718 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1723 } else if (strcmp(tokens[t0], "hash") == 0) {
1724 uint32_t key_mask_size = TABLE_RULE_MATCH_SIZE_MAX;
1726 if (n_tokens < t0 + 12) {
1727 snprintf(out, out_size, MSG_ARG_MISMATCH,
1728 "pipeline table hash");
1732 p.match_type = TABLE_HASH;
1734 if (strcmp(tokens[t0 + 1], "ext") == 0)
1735 p.match.hash.extendable_bucket = 1;
1736 else if (strcmp(tokens[t0 + 1], "lru") == 0)
1737 p.match.hash.extendable_bucket = 0;
1739 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1744 if (strcmp(tokens[t0 + 2], "key") != 0) {
1745 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
1749 if ((parser_read_uint32(&p.match.hash.key_size,
1750 tokens[t0 + 3]) != 0) ||
1751 (p.match.hash.key_size == 0) ||
1752 (p.match.hash.key_size > TABLE_RULE_MATCH_SIZE_MAX)) {
1753 snprintf(out, out_size, MSG_ARG_INVALID, "key_size");
1757 if (strcmp(tokens[t0 + 4], "mask") != 0) {
1758 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
1762 if ((parse_hex_string(tokens[t0 + 5],
1763 key_mask, &key_mask_size) != 0) ||
1764 (key_mask_size != p.match.hash.key_size)) {
1765 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
1768 p.match.hash.key_mask = key_mask;
1770 if (strcmp(tokens[t0 + 6], "offset") != 0) {
1771 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1775 if (parser_read_uint32(&p.match.hash.key_offset,
1776 tokens[t0 + 7]) != 0) {
1777 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1781 if (strcmp(tokens[t0 + 8], "buckets") != 0) {
1782 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buckets");
1786 if (parser_read_uint32(&p.match.hash.n_buckets,
1787 tokens[t0 + 9]) != 0) {
1788 snprintf(out, out_size, MSG_ARG_INVALID, "n_buckets");
1792 if (strcmp(tokens[t0 + 10], "size") != 0) {
1793 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1797 if (parser_read_uint32(&p.match.hash.n_keys,
1798 tokens[t0 + 11]) != 0) {
1799 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1804 } else if (strcmp(tokens[t0], "lpm") == 0) {
1805 if (n_tokens < t0 + 6) {
1806 snprintf(out, out_size, MSG_ARG_MISMATCH,
1807 "pipeline table lpm");
1811 p.match_type = TABLE_LPM;
1813 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1814 p.match.lpm.key_size = 4;
1815 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1816 p.match.lpm.key_size = 16;
1818 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1823 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1824 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1828 if (parser_read_uint32(&p.match.lpm.key_offset,
1829 tokens[t0 + 3]) != 0) {
1830 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1834 if (strcmp(tokens[t0 + 4], "size") != 0) {
1835 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1839 if (parser_read_uint32(&p.match.lpm.n_rules,
1840 tokens[t0 + 5]) != 0) {
1841 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1846 } else if (strcmp(tokens[t0], "stub") == 0) {
1847 if (n_tokens < t0 + 1) {
1848 snprintf(out, out_size, MSG_ARG_MISMATCH,
1849 "pipeline table stub");
1853 p.match_type = TABLE_STUB;
1857 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1861 p.action_profile_name = NULL;
1862 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1863 if (n_tokens < t0 + 2) {
1864 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1868 p.action_profile_name = tokens[t0 + 1];
1873 if (n_tokens > t0) {
1874 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1878 status = pipeline_table_create(pipeline_name, &p);
1880 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1886 * pipeline <pipeline_name> port in <port_id> table <table_id>
1889 cmd_pipeline_port_in_table(char **tokens,
1894 char *pipeline_name;
1895 uint32_t port_id, table_id;
1898 if (n_tokens != 7) {
1899 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1903 pipeline_name = tokens[1];
1905 if (strcmp(tokens[2], "port") != 0) {
1906 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1910 if (strcmp(tokens[3], "in") != 0) {
1911 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1915 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
1916 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
1920 if (strcmp(tokens[5], "table") != 0) {
1921 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1925 if (parser_read_uint32(&table_id, tokens[6]) != 0) {
1926 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
1930 status = pipeline_port_in_connect_to_table(pipeline_name,
1934 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1940 cli_process(char *in, char *out, size_t out_size)
1942 char *tokens[CMD_MAX_TOKENS];
1943 uint32_t n_tokens = RTE_DIM(tokens);
1949 status = parse_tokenize_string(in, tokens, &n_tokens);
1951 snprintf(out, out_size, MSG_ARG_TOO_MANY, "");
1958 if (strcmp(tokens[0], "mempool") == 0) {
1959 cmd_mempool(tokens, n_tokens, out, out_size);
1963 if (strcmp(tokens[0], "link") == 0) {
1964 cmd_link(tokens, n_tokens, out, out_size);
1968 if (strcmp(tokens[0], "swq") == 0) {
1969 cmd_swq(tokens, n_tokens, out, out_size);
1973 if (strcmp(tokens[0], "tmgr") == 0) {
1974 if ((n_tokens >= 3) &&
1975 (strcmp(tokens[1], "subport") == 0) &&
1976 (strcmp(tokens[2], "profile") == 0)) {
1977 cmd_tmgr_subport_profile(tokens, n_tokens,
1982 if ((n_tokens >= 3) &&
1983 (strcmp(tokens[1], "pipe") == 0) &&
1984 (strcmp(tokens[2], "profile") == 0)) {
1985 cmd_tmgr_pipe_profile(tokens, n_tokens, out, out_size);
1989 if ((n_tokens >= 5) &&
1990 (strcmp(tokens[2], "subport") == 0) &&
1991 (strcmp(tokens[4], "profile") == 0)) {
1992 cmd_tmgr_subport(tokens, n_tokens, out, out_size);
1996 if ((n_tokens >= 5) &&
1997 (strcmp(tokens[2], "subport") == 0) &&
1998 (strcmp(tokens[4], "pipe") == 0)) {
1999 cmd_tmgr_subport_pipe(tokens, n_tokens, out, out_size);
2003 cmd_tmgr(tokens, n_tokens, out, out_size);
2007 if (strcmp(tokens[0], "tap") == 0) {
2008 cmd_tap(tokens, n_tokens, out, out_size);
2012 if (strcmp(tokens[0], "kni") == 0) {
2013 cmd_kni(tokens, n_tokens, out, out_size);
2017 if (strcmp(tokens[0], "port") == 0) {
2018 cmd_port_in_action_profile(tokens, n_tokens, out, out_size);
2022 if (strcmp(tokens[0], "table") == 0) {
2023 cmd_table_action_profile(tokens, n_tokens, out, out_size);
2027 if (strcmp(tokens[0], "pipeline") == 0) {
2028 if ((n_tokens >= 3) &&
2029 (strcmp(tokens[2], "period") == 0)) {
2030 cmd_pipeline(tokens, n_tokens, out, out_size);
2034 if ((n_tokens >= 5) &&
2035 (strcmp(tokens[2], "port") == 0) &&
2036 (strcmp(tokens[3], "in") == 0) &&
2037 (strcmp(tokens[4], "bsz") == 0)) {
2038 cmd_pipeline_port_in(tokens, n_tokens, out, out_size);
2042 if ((n_tokens >= 5) &&
2043 (strcmp(tokens[2], "port") == 0) &&
2044 (strcmp(tokens[3], "out") == 0) &&
2045 (strcmp(tokens[4], "bsz") == 0)) {
2046 cmd_pipeline_port_out(tokens, n_tokens, out, out_size);
2050 if ((n_tokens >= 4) &&
2051 (strcmp(tokens[2], "table") == 0) &&
2052 (strcmp(tokens[3], "match") == 0)) {
2053 cmd_pipeline_table(tokens, n_tokens, out, out_size);
2057 if ((n_tokens >= 6) &&
2058 (strcmp(tokens[2], "port") == 0) &&
2059 (strcmp(tokens[3], "in") == 0) &&
2060 (strcmp(tokens[5], "table") == 0)) {
2061 cmd_pipeline_port_in_table(tokens, n_tokens,
2067 snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
2071 cli_script_process(const char *file_name,
2072 size_t msg_in_len_max,
2073 size_t msg_out_len_max)
2075 char *msg_in = NULL, *msg_out = NULL;
2078 /* Check input arguments */
2079 if ((file_name == NULL) ||
2080 (strlen(file_name) == 0) ||
2081 (msg_in_len_max == 0) ||
2082 (msg_out_len_max == 0))
2085 msg_in = malloc(msg_in_len_max + 1);
2086 msg_out = malloc(msg_out_len_max + 1);
2087 if ((msg_in == NULL) ||
2088 (msg_out == NULL)) {
2094 /* Open input file */
2095 f = fopen(file_name, "r");
2104 if (fgets(msg_in, msg_in_len_max + 1, f) == NULL)
2107 printf("%s", msg_in);
2114 if (strlen(msg_out))
2115 printf("%s", msg_out);