1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
10 #include <rte_common.h>
11 #include <rte_cycles.h>
12 #include <rte_ethdev.h>
25 #ifndef CMD_MAX_TOKENS
26 #define CMD_MAX_TOKENS 256
29 #define MSG_OUT_OF_MEMORY "Not enough memory.\n"
30 #define MSG_CMD_UNKNOWN "Unknown command \"%s\".\n"
31 #define MSG_CMD_UNIMPLEM "Command \"%s\" not implemented.\n"
32 #define MSG_ARG_NOT_ENOUGH "Not enough arguments for command \"%s\".\n"
33 #define MSG_ARG_TOO_MANY "Too many arguments for command \"%s\".\n"
34 #define MSG_ARG_MISMATCH "Wrong number of arguments for command \"%s\".\n"
35 #define MSG_ARG_NOT_FOUND "Argument \"%s\" not found.\n"
36 #define MSG_ARG_INVALID "Invalid value for argument \"%s\".\n"
37 #define MSG_FILE_ERR "Error in file \"%s\" at line %u.\n"
38 #define MSG_FILE_NOT_ENOUGH "Not enough rules in file \"%s\".\n"
39 #define MSG_CMD_FAIL "Command \"%s\" failed.\n"
44 if ((strlen(in) && index("!#%;", in[0])) ||
45 (strncmp(in, "//", 2) == 0) ||
46 (strncmp(in, "--", 2) == 0))
53 * mempool <mempool_name>
54 * buffer <buffer_size>
60 cmd_mempool(char **tokens,
65 struct mempool_params p;
67 struct mempool *mempool;
70 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
76 if (strcmp(tokens[2], "buffer") != 0) {
77 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buffer");
81 if (parser_read_uint32(&p.buffer_size, tokens[3]) != 0) {
82 snprintf(out, out_size, MSG_ARG_INVALID, "buffer_size");
86 if (strcmp(tokens[4], "pool") != 0) {
87 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pool");
91 if (parser_read_uint32(&p.pool_size, tokens[5]) != 0) {
92 snprintf(out, out_size, MSG_ARG_INVALID, "pool_size");
96 if (strcmp(tokens[6], "cache") != 0) {
97 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cache");
101 if (parser_read_uint32(&p.cache_size, tokens[7]) != 0) {
102 snprintf(out, out_size, MSG_ARG_INVALID, "cache_size");
106 if (strcmp(tokens[8], "cpu") != 0) {
107 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
111 if (parser_read_uint32(&p.cpu_id, tokens[9]) != 0) {
112 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
116 mempool = mempool_create(name, &p);
117 if (mempool == NULL) {
118 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
125 * dev <device_name> | port <port_id>
126 * rxq <n_queues> <queue_size> <mempool_name>
127 * txq <n_queues> <queue_size>
128 * promiscuous on | off
129 * [rss <qid_0> ... <qid_n>]
132 cmd_link(char **tokens,
137 struct link_params p;
138 struct link_params_rss rss;
142 memset(&p, 0, sizeof(p));
144 if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) {
145 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
150 if (strcmp(tokens[2], "dev") == 0)
151 p.dev_name = tokens[3];
152 else if (strcmp(tokens[2], "port") == 0) {
155 if (parser_read_uint16(&p.port_id, tokens[3]) != 0) {
156 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
160 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dev or port");
164 if (strcmp(tokens[4], "rxq") != 0) {
165 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
169 if (parser_read_uint32(&p.rx.n_queues, tokens[5]) != 0) {
170 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
173 if (parser_read_uint32(&p.rx.queue_size, tokens[6]) != 0) {
174 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
178 p.rx.mempool_name = tokens[7];
180 if (strcmp(tokens[8], "txq") != 0) {
181 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
185 if (parser_read_uint32(&p.tx.n_queues, tokens[9]) != 0) {
186 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
190 if (parser_read_uint32(&p.tx.queue_size, tokens[10]) != 0) {
191 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
195 if (strcmp(tokens[11], "promiscuous") != 0) {
196 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "promiscuous");
200 if (strcmp(tokens[12], "on") == 0)
202 else if (strcmp(tokens[12], "off") == 0)
205 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "on or off");
212 uint32_t queue_id, i;
214 if (strcmp(tokens[13], "rss") != 0) {
215 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rss");
222 for (i = 14; i < n_tokens; i++) {
223 if (parser_read_uint32(&queue_id, tokens[i]) != 0) {
224 snprintf(out, out_size, MSG_ARG_INVALID,
229 rss.queue_id[rss.n_queues] = queue_id;
234 link = link_create(name, &p);
236 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
241 /* Print the link stats and info */
243 print_link_info(struct link *link, char *out, size_t out_size)
245 struct rte_eth_stats stats;
246 struct ether_addr mac_addr;
247 struct rte_eth_link eth_link;
250 memset(&stats, 0, sizeof(stats));
251 rte_eth_stats_get(link->port_id, &stats);
253 rte_eth_macaddr_get(link->port_id, &mac_addr);
254 rte_eth_link_get(link->port_id, ð_link);
255 rte_eth_dev_get_mtu(link->port_id, &mtu);
257 snprintf(out, out_size,
259 "%s: flags=<%s> mtu %u\n"
260 "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n"
261 "\tport# %u speed %u Mbps\n"
262 "\tRX packets %" PRIu64" bytes %" PRIu64"\n"
263 "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n"
264 "\tTX packets %" PRIu64" bytes %" PRIu64"\n"
265 "\tTX errors %" PRIu64"\n",
267 eth_link.link_status == 0 ? "DOWN" : "UP",
269 mac_addr.addr_bytes[0], mac_addr.addr_bytes[1],
270 mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
271 mac_addr.addr_bytes[4], mac_addr.addr_bytes[5],
287 * link show [<link_name>]
290 cmd_link_show(char **tokens, uint32_t n_tokens, char *out, size_t out_size)
295 if (n_tokens != 2 && n_tokens != 3) {
296 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
301 link = link_next(NULL);
303 while (link != NULL) {
304 out_size = out_size - strlen(out);
305 out = &out[strlen(out)];
307 print_link_info(link, out, out_size);
308 link = link_next(link);
311 out_size = out_size - strlen(out);
312 out = &out[strlen(out)];
314 link_name = tokens[2];
315 link = link_find(link_name);
318 snprintf(out, out_size, MSG_ARG_INVALID,
319 "Link does not exist");
322 print_link_info(link, out, out_size);
332 cmd_swq(char **tokens,
342 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
348 if (strcmp(tokens[2], "size") != 0) {
349 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
353 if (parser_read_uint32(&p.size, tokens[3]) != 0) {
354 snprintf(out, out_size, MSG_ARG_INVALID, "size");
358 if (strcmp(tokens[4], "cpu") != 0) {
359 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
363 if (parser_read_uint32(&p.cpu_id, tokens[5]) != 0) {
364 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
368 swq = swq_create(name, &p);
370 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
376 * tmgr subport profile
377 * <tb_rate> <tb_size>
378 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
382 cmd_tmgr_subport_profile(char **tokens,
387 struct rte_sched_subport_params p;
390 if (n_tokens != 10) {
391 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
395 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
396 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
400 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
401 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
405 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
406 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
407 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
411 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
412 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
416 status = tmgr_subport_profile_add(&p);
418 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
425 * <tb_rate> <tb_size>
426 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
432 cmd_tmgr_pipe_profile(char **tokens,
437 struct rte_sched_pipe_params p;
440 if (n_tokens != 27) {
441 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
445 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
446 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
450 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
451 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
455 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
456 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
457 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
461 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
462 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
466 #ifdef RTE_SCHED_SUBPORT_TC_OV
467 if (parser_read_uint8(&p.tc_ov_weight, tokens[10]) != 0) {
468 snprintf(out, out_size, MSG_ARG_INVALID, "tc_ov_weight");
473 for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++)
474 if (parser_read_uint8(&p.wrr_weights[i], tokens[11 + i]) != 0) {
475 snprintf(out, out_size, MSG_ARG_INVALID, "wrr_weights");
479 status = tmgr_pipe_profile_add(&p);
481 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
489 * spp <n_subports_per_port>
490 * pps <n_pipes_per_subport>
491 * qsize <qsize_tc0> <qsize_tc1> <qsize_tc2> <qsize_tc3>
492 * fo <frame_overhead>
497 cmd_tmgr(char **tokens,
502 struct tmgr_port_params p;
504 struct tmgr_port *tmgr_port;
507 if (n_tokens != 19) {
508 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
514 if (strcmp(tokens[2], "rate") != 0) {
515 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rate");
519 if (parser_read_uint32(&p.rate, tokens[3]) != 0) {
520 snprintf(out, out_size, MSG_ARG_INVALID, "rate");
524 if (strcmp(tokens[4], "spp") != 0) {
525 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
529 if (parser_read_uint32(&p.n_subports_per_port, tokens[5]) != 0) {
530 snprintf(out, out_size, MSG_ARG_INVALID, "n_subports_per_port");
534 if (strcmp(tokens[6], "pps") != 0) {
535 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
539 if (parser_read_uint32(&p.n_pipes_per_subport, tokens[7]) != 0) {
540 snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport");
544 if (strcmp(tokens[8], "qsize") != 0) {
545 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "qsize");
549 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
550 if (parser_read_uint16(&p.qsize[i], tokens[9 + i]) != 0) {
551 snprintf(out, out_size, MSG_ARG_INVALID, "qsize");
555 if (strcmp(tokens[13], "fo") != 0) {
556 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fo");
560 if (parser_read_uint32(&p.frame_overhead, tokens[14]) != 0) {
561 snprintf(out, out_size, MSG_ARG_INVALID, "frame_overhead");
565 if (strcmp(tokens[15], "mtu") != 0) {
566 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mtu");
570 if (parser_read_uint32(&p.mtu, tokens[16]) != 0) {
571 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
575 if (strcmp(tokens[17], "cpu") != 0) {
576 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
580 if (parser_read_uint32(&p.cpu_id, tokens[18]) != 0) {
581 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
585 tmgr_port = tmgr_port_create(name, &p);
586 if (tmgr_port == NULL) {
587 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
593 * tmgr <tmgr_name> subport <subport_id>
594 * profile <subport_profile_id>
597 cmd_tmgr_subport(char **tokens,
602 uint32_t subport_id, subport_profile_id;
607 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
613 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
614 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
618 if (parser_read_uint32(&subport_profile_id, tokens[5]) != 0) {
619 snprintf(out, out_size, MSG_ARG_INVALID, "subport_profile_id");
623 status = tmgr_subport_config(name, subport_id, subport_profile_id);
625 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
631 * tmgr <tmgr_name> subport <subport_id> pipe
632 * from <pipe_id_first> to <pipe_id_last>
633 * profile <pipe_profile_id>
636 cmd_tmgr_subport_pipe(char **tokens,
641 uint32_t subport_id, pipe_id_first, pipe_id_last, pipe_profile_id;
645 if (n_tokens != 11) {
646 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
652 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
653 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
657 if (strcmp(tokens[4], "pipe") != 0) {
658 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipe");
662 if (strcmp(tokens[5], "from") != 0) {
663 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "from");
667 if (parser_read_uint32(&pipe_id_first, tokens[6]) != 0) {
668 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_first");
672 if (strcmp(tokens[7], "to") != 0) {
673 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "to");
677 if (parser_read_uint32(&pipe_id_last, tokens[8]) != 0) {
678 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_last");
682 if (strcmp(tokens[9], "profile") != 0) {
683 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
687 if (parser_read_uint32(&pipe_profile_id, tokens[10]) != 0) {
688 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_profile_id");
692 status = tmgr_pipe_config(name, subport_id, pipe_id_first,
693 pipe_id_last, pipe_profile_id);
695 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
704 cmd_tap(char **tokens,
713 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
719 tap = tap_create(name);
721 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
729 * mempool <mempool_name>
730 * [thread <thread_id>]
733 cmd_kni(char **tokens,
742 memset(&p, 0, sizeof(p));
743 if ((n_tokens != 6) && (n_tokens != 8)) {
744 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
750 if (strcmp(tokens[2], "link") != 0) {
751 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "link");
755 p.link_name = tokens[3];
757 if (strcmp(tokens[4], "mempool") != 0) {
758 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool");
762 p.mempool_name = tokens[5];
765 if (strcmp(tokens[6], "thread") != 0) {
766 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "thread");
770 if (parser_read_uint32(&p.thread_id, tokens[7]) != 0) {
771 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
779 kni = kni_create(name, &p);
781 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
787 * port in action profile <profile_name>
788 * [filter match | mismatch offset <key_offset> mask <key_mask> key <key_value> port <port_id>]
789 * [balance offset <key_offset> mask <key_mask> port <port_id0> ... <port_id15>]
792 cmd_port_in_action_profile(char **tokens,
797 struct port_in_action_profile_params p;
798 struct port_in_action_profile *ap;
802 memset(&p, 0, sizeof(p));
805 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
809 if (strcmp(tokens[1], "in") != 0) {
810 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
814 if (strcmp(tokens[2], "action") != 0) {
815 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
819 if (strcmp(tokens[3], "profile") != 0) {
820 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
828 if ((t0 < n_tokens) && (strcmp(tokens[t0], "filter") == 0)) {
831 if (n_tokens < t0 + 10) {
832 snprintf(out, out_size, MSG_ARG_MISMATCH, "port in action profile filter");
836 if (strcmp(tokens[t0 + 1], "match") == 0)
837 p.fltr.filter_on_match = 1;
838 else if (strcmp(tokens[t0 + 1], "mismatch") == 0)
839 p.fltr.filter_on_match = 0;
841 snprintf(out, out_size, MSG_ARG_INVALID, "match or mismatch");
845 if (strcmp(tokens[t0 + 2], "offset") != 0) {
846 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
850 if (parser_read_uint32(&p.fltr.key_offset, tokens[t0 + 3]) != 0) {
851 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
855 if (strcmp(tokens[t0 + 4], "mask") != 0) {
856 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
860 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
861 if ((parse_hex_string(tokens[t0 + 5], p.fltr.key_mask, &size) != 0) ||
862 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
863 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
867 if (strcmp(tokens[t0 + 6], "key") != 0) {
868 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
872 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
873 if ((parse_hex_string(tokens[t0 + 7], p.fltr.key, &size) != 0) ||
874 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
875 snprintf(out, out_size, MSG_ARG_INVALID, "key_value");
879 if (strcmp(tokens[t0 + 8], "port") != 0) {
880 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
884 if (parser_read_uint32(&p.fltr.port_id, tokens[t0 + 9]) != 0) {
885 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
889 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_FLTR;
893 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
896 if (n_tokens < t0 + 22) {
897 snprintf(out, out_size, MSG_ARG_MISMATCH,
898 "port in action profile balance");
902 if (strcmp(tokens[t0 + 1], "offset") != 0) {
903 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
907 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
908 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
912 if (strcmp(tokens[t0 + 3], "mask") != 0) {
913 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
917 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
918 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
919 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
923 if (strcmp(tokens[t0 + 5], "port") != 0) {
924 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
928 for (i = 0; i < 16; i++)
929 if (parser_read_uint32(&p.lb.port_id[i], tokens[t0 + 6 + i]) != 0) {
930 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
934 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_LB;
939 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
943 ap = port_in_action_profile_create(name, &p);
945 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
951 * table action profile <profile_name>
955 * [balance offset <key_offset> mask <key_mask> outoffset <out_offset>]
956 * [meter srtcm | trtcm
958 * stats none | pkts | bytes | both]
959 * [tm spp <n_subports_per_port> pps <n_pipes_per_subport>]
960 * [encap ether | vlan | qinq | mpls | pppoe]
965 * [stats pkts | bytes | both]
969 cmd_table_action_profile(char **tokens,
974 struct table_action_profile_params p;
975 struct table_action_profile *ap;
979 memset(&p, 0, sizeof(p));
982 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
986 if (strcmp(tokens[1], "action") != 0) {
987 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
991 if (strcmp(tokens[2], "profile") != 0) {
992 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
998 if (strcmp(tokens[4], "ipv4") == 0)
999 p.common.ip_version = 1;
1000 else if (strcmp(tokens[4], "ipv6") == 0)
1001 p.common.ip_version = 0;
1003 snprintf(out, out_size, MSG_ARG_INVALID, "ipv4 or ipv6");
1007 if (strcmp(tokens[5], "offset") != 0) {
1008 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1012 if (parser_read_uint32(&p.common.ip_offset, tokens[6]) != 0) {
1013 snprintf(out, out_size, MSG_ARG_INVALID, "ip_offset");
1017 if (strcmp(tokens[7], "fwd") != 0) {
1018 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fwd");
1022 p.action_mask |= 1LLU << RTE_TABLE_ACTION_FWD;
1025 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
1026 if (n_tokens < t0 + 7) {
1027 snprintf(out, out_size, MSG_ARG_MISMATCH, "table action profile balance");
1031 if (strcmp(tokens[t0 + 1], "offset") != 0) {
1032 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1036 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
1037 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1041 if (strcmp(tokens[t0 + 3], "mask") != 0) {
1042 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
1046 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
1047 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
1048 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
1052 if (strcmp(tokens[t0 + 5], "outoffset") != 0) {
1053 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "outoffset");
1057 if (parser_read_uint32(&p.lb.out_offset, tokens[t0 + 6]) != 0) {
1058 snprintf(out, out_size, MSG_ARG_INVALID, "out_offset");
1062 p.action_mask |= 1LLU << RTE_TABLE_ACTION_LB;
1066 if ((t0 < n_tokens) && (strcmp(tokens[t0], "meter") == 0)) {
1067 if (n_tokens < t0 + 6) {
1068 snprintf(out, out_size, MSG_ARG_MISMATCH,
1069 "table action profile meter");
1073 if (strcmp(tokens[t0 + 1], "srtcm") == 0)
1074 p.mtr.alg = RTE_TABLE_ACTION_METER_SRTCM;
1075 else if (strcmp(tokens[t0 + 1], "trtcm") == 0)
1076 p.mtr.alg = RTE_TABLE_ACTION_METER_TRTCM;
1078 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1083 if (strcmp(tokens[t0 + 2], "tc") != 0) {
1084 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc");
1088 if (parser_read_uint32(&p.mtr.n_tc, tokens[t0 + 3]) != 0) {
1089 snprintf(out, out_size, MSG_ARG_INVALID, "n_tc");
1093 if (strcmp(tokens[t0 + 4], "stats") != 0) {
1094 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1098 if (strcmp(tokens[t0 + 5], "none") == 0) {
1099 p.mtr.n_packets_enabled = 0;
1100 p.mtr.n_bytes_enabled = 0;
1101 } else if (strcmp(tokens[t0 + 5], "pkts") == 0) {
1102 p.mtr.n_packets_enabled = 1;
1103 p.mtr.n_bytes_enabled = 0;
1104 } else if (strcmp(tokens[t0 + 5], "bytes") == 0) {
1105 p.mtr.n_packets_enabled = 0;
1106 p.mtr.n_bytes_enabled = 1;
1107 } else if (strcmp(tokens[t0 + 5], "both") == 0) {
1108 p.mtr.n_packets_enabled = 1;
1109 p.mtr.n_bytes_enabled = 1;
1111 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1112 "none or pkts or bytes or both");
1116 p.action_mask |= 1LLU << RTE_TABLE_ACTION_MTR;
1120 if ((t0 < n_tokens) && (strcmp(tokens[t0], "tm") == 0)) {
1121 if (n_tokens < t0 + 5) {
1122 snprintf(out, out_size, MSG_ARG_MISMATCH,
1123 "table action profile tm");
1127 if (strcmp(tokens[t0 + 1], "spp") != 0) {
1128 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
1132 if (parser_read_uint32(&p.tm.n_subports_per_port,
1133 tokens[t0 + 2]) != 0) {
1134 snprintf(out, out_size, MSG_ARG_INVALID,
1135 "n_subports_per_port");
1139 if (strcmp(tokens[t0 + 3], "pps") != 0) {
1140 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
1144 if (parser_read_uint32(&p.tm.n_pipes_per_subport,
1145 tokens[t0 + 4]) != 0) {
1146 snprintf(out, out_size, MSG_ARG_INVALID,
1147 "n_pipes_per_subport");
1151 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TM;
1155 if ((t0 < n_tokens) && (strcmp(tokens[t0], "encap") == 0)) {
1156 if (n_tokens < t0 + 2) {
1157 snprintf(out, out_size, MSG_ARG_MISMATCH,
1158 "action profile encap");
1162 if (strcmp(tokens[t0 + 1], "ether") == 0)
1163 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER;
1164 else if (strcmp(tokens[t0 + 1], "vlan") == 0)
1165 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN;
1166 else if (strcmp(tokens[t0 + 1], "qinq") == 0)
1167 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ;
1168 else if (strcmp(tokens[t0 + 1], "mpls") == 0)
1169 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS;
1170 else if (strcmp(tokens[t0 + 1], "pppoe") == 0)
1171 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE;
1173 snprintf(out, out_size, MSG_ARG_MISMATCH, "encap");
1177 p.action_mask |= 1LLU << RTE_TABLE_ACTION_ENCAP;
1181 if ((t0 < n_tokens) && (strcmp(tokens[t0], "nat") == 0)) {
1182 if (n_tokens < t0 + 4) {
1183 snprintf(out, out_size, MSG_ARG_MISMATCH,
1184 "table action profile nat");
1188 if (strcmp(tokens[t0 + 1], "src") == 0)
1189 p.nat.source_nat = 1;
1190 else if (strcmp(tokens[t0 + 1], "dst") == 0)
1191 p.nat.source_nat = 0;
1193 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1198 if (strcmp(tokens[t0 + 2], "proto") != 0) {
1199 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "proto");
1203 if (strcmp(tokens[t0 + 3], "tcp") == 0)
1205 else if (strcmp(tokens[t0 + 3], "udp") == 0)
1208 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1213 p.action_mask |= 1LLU << RTE_TABLE_ACTION_NAT;
1217 if ((t0 < n_tokens) && (strcmp(tokens[t0], "ttl") == 0)) {
1218 if (n_tokens < t0 + 4) {
1219 snprintf(out, out_size, MSG_ARG_MISMATCH,
1220 "table action profile ttl");
1224 if (strcmp(tokens[t0 + 1], "drop") == 0)
1226 else if (strcmp(tokens[t0 + 1], "fwd") == 0)
1229 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1234 if (strcmp(tokens[t0 + 2], "stats") != 0) {
1235 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1239 if (strcmp(tokens[t0 + 3], "none") == 0)
1240 p.ttl.n_packets_enabled = 0;
1241 else if (strcmp(tokens[t0 + 3], "pkts") == 0)
1242 p.ttl.n_packets_enabled = 1;
1244 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1249 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TTL;
1253 if ((t0 < n_tokens) && (strcmp(tokens[t0], "stats") == 0)) {
1254 if (n_tokens < t0 + 2) {
1255 snprintf(out, out_size, MSG_ARG_MISMATCH,
1256 "table action profile stats");
1260 if (strcmp(tokens[t0 + 1], "pkts") == 0) {
1261 p.stats.n_packets_enabled = 1;
1262 p.stats.n_bytes_enabled = 0;
1263 } else if (strcmp(tokens[t0 + 1], "bytes") == 0) {
1264 p.stats.n_packets_enabled = 0;
1265 p.stats.n_bytes_enabled = 1;
1266 } else if (strcmp(tokens[t0 + 1], "both") == 0) {
1267 p.stats.n_packets_enabled = 1;
1268 p.stats.n_bytes_enabled = 1;
1270 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1271 "pkts or bytes or both");
1275 p.action_mask |= 1LLU << RTE_TABLE_ACTION_STATS;
1279 if ((t0 < n_tokens) && (strcmp(tokens[t0], "time") == 0)) {
1280 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TIME;
1284 if (t0 < n_tokens) {
1285 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1289 ap = table_action_profile_create(name, &p);
1291 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1297 * pipeline <pipeline_name>
1298 * period <timer_period_ms>
1299 * offset_port_id <offset_port_id>
1303 cmd_pipeline(char **tokens,
1308 struct pipeline_params p;
1310 struct pipeline *pipeline;
1312 if (n_tokens != 8) {
1313 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1319 if (strcmp(tokens[2], "period") != 0) {
1320 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "period");
1324 if (parser_read_uint32(&p.timer_period_ms, tokens[3]) != 0) {
1325 snprintf(out, out_size, MSG_ARG_INVALID, "timer_period_ms");
1329 if (strcmp(tokens[4], "offset_port_id") != 0) {
1330 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset_port_id");
1334 if (parser_read_uint32(&p.offset_port_id, tokens[5]) != 0) {
1335 snprintf(out, out_size, MSG_ARG_INVALID, "offset_port_id");
1339 if (strcmp(tokens[6], "cpu") != 0) {
1340 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
1344 if (parser_read_uint32(&p.cpu_id, tokens[7]) != 0) {
1345 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
1349 pipeline = pipeline_create(name, &p);
1350 if (pipeline == NULL) {
1351 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1357 * pipeline <pipeline_name> port in
1359 * link <link_name> rxq <queue_id>
1361 * | tmgr <tmgr_name>
1362 * | tap <tap_name> mempool <mempool_name> mtu <mtu>
1364 * | source mempool <mempool_name> file <file_name> bpp <n_bytes_per_pkt>
1365 * [action <port_in_action_profile_name>]
1369 cmd_pipeline_port_in(char **tokens,
1374 struct port_in_params p;
1375 char *pipeline_name;
1377 int enabled, status;
1380 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1384 pipeline_name = tokens[1];
1386 if (strcmp(tokens[2], "port") != 0) {
1387 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1391 if (strcmp(tokens[3], "in") != 0) {
1392 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1396 if (strcmp(tokens[4], "bsz") != 0) {
1397 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1401 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1402 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1408 if (strcmp(tokens[t0], "link") == 0) {
1409 if (n_tokens < t0 + 4) {
1410 snprintf(out, out_size, MSG_ARG_MISMATCH,
1411 "pipeline port in link");
1415 p.type = PORT_IN_RXQ;
1417 p.dev_name = tokens[t0 + 1];
1419 if (strcmp(tokens[t0 + 2], "rxq") != 0) {
1420 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
1424 if (parser_read_uint16(&p.rxq.queue_id, tokens[t0 + 3]) != 0) {
1425 snprintf(out, out_size, MSG_ARG_INVALID,
1430 } else if (strcmp(tokens[t0], "swq") == 0) {
1431 if (n_tokens < t0 + 2) {
1432 snprintf(out, out_size, MSG_ARG_MISMATCH,
1433 "pipeline port in swq");
1437 p.type = PORT_IN_SWQ;
1439 p.dev_name = tokens[t0 + 1];
1442 } else if (strcmp(tokens[t0], "tmgr") == 0) {
1443 if (n_tokens < t0 + 2) {
1444 snprintf(out, out_size, MSG_ARG_MISMATCH,
1445 "pipeline port in tmgr");
1449 p.type = PORT_IN_TMGR;
1451 p.dev_name = tokens[t0 + 1];
1454 } else if (strcmp(tokens[t0], "tap") == 0) {
1455 if (n_tokens < t0 + 6) {
1456 snprintf(out, out_size, MSG_ARG_MISMATCH,
1457 "pipeline port in tap");
1461 p.type = PORT_IN_TAP;
1463 p.dev_name = tokens[t0 + 1];
1465 if (strcmp(tokens[t0 + 2], "mempool") != 0) {
1466 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1471 p.tap.mempool_name = tokens[t0 + 3];
1473 if (strcmp(tokens[t0 + 4], "mtu") != 0) {
1474 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1479 if (parser_read_uint32(&p.tap.mtu, tokens[t0 + 5]) != 0) {
1480 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
1485 } else if (strcmp(tokens[t0], "kni") == 0) {
1486 if (n_tokens < t0 + 2) {
1487 snprintf(out, out_size, MSG_ARG_MISMATCH,
1488 "pipeline port in kni");
1492 p.type = PORT_IN_KNI;
1494 p.dev_name = tokens[t0 + 1];
1497 } else if (strcmp(tokens[t0], "source") == 0) {
1498 if (n_tokens < t0 + 6) {
1499 snprintf(out, out_size, MSG_ARG_MISMATCH,
1500 "pipeline port in source");
1504 p.type = PORT_IN_SOURCE;
1508 if (strcmp(tokens[t0 + 1], "mempool") != 0) {
1509 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1514 p.source.mempool_name = tokens[t0 + 2];
1516 if (strcmp(tokens[t0 + 3], "file") != 0) {
1517 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1522 p.source.file_name = tokens[t0 + 4];
1524 if (strcmp(tokens[t0 + 5], "bpp") != 0) {
1525 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1530 if (parser_read_uint32(&p.source.n_bytes_per_pkt, tokens[t0 + 6]) != 0) {
1531 snprintf(out, out_size, MSG_ARG_INVALID,
1538 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1542 p.action_profile_name = NULL;
1543 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1544 if (n_tokens < t0 + 2) {
1545 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1549 p.action_profile_name = tokens[t0 + 1];
1555 if ((n_tokens > t0) &&
1556 (strcmp(tokens[t0], "disabled") == 0)) {
1562 if (n_tokens != t0) {
1563 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1567 status = pipeline_port_in_create(pipeline_name,
1570 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1576 * pipeline <pipeline_name> port out
1578 * link <link_name> txq <txq_id>
1580 * | tmgr <tmgr_name>
1583 * | sink [file <file_name> pkts <max_n_pkts>]
1586 cmd_pipeline_port_out(char **tokens,
1591 struct port_out_params p;
1592 char *pipeline_name;
1595 memset(&p, 0, sizeof(p));
1598 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1602 pipeline_name = tokens[1];
1604 if (strcmp(tokens[2], "port") != 0) {
1605 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1609 if (strcmp(tokens[3], "out") != 0) {
1610 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
1614 if (strcmp(tokens[4], "bsz") != 0) {
1615 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1619 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1620 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1624 if (strcmp(tokens[6], "link") == 0) {
1625 if (n_tokens != 10) {
1626 snprintf(out, out_size, MSG_ARG_MISMATCH,
1627 "pipeline port out link");
1631 p.type = PORT_OUT_TXQ;
1633 p.dev_name = tokens[7];
1635 if (strcmp(tokens[8], "txq") != 0) {
1636 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
1640 if (parser_read_uint16(&p.txq.queue_id, tokens[9]) != 0) {
1641 snprintf(out, out_size, MSG_ARG_INVALID, "queue_id");
1644 } else if (strcmp(tokens[6], "swq") == 0) {
1645 if (n_tokens != 8) {
1646 snprintf(out, out_size, MSG_ARG_MISMATCH,
1647 "pipeline port out swq");
1651 p.type = PORT_OUT_SWQ;
1653 p.dev_name = tokens[7];
1654 } else if (strcmp(tokens[6], "tmgr") == 0) {
1655 if (n_tokens != 8) {
1656 snprintf(out, out_size, MSG_ARG_MISMATCH,
1657 "pipeline port out tmgr");
1661 p.type = PORT_OUT_TMGR;
1663 p.dev_name = tokens[7];
1664 } else if (strcmp(tokens[6], "tap") == 0) {
1665 if (n_tokens != 8) {
1666 snprintf(out, out_size, MSG_ARG_MISMATCH,
1667 "pipeline port out tap");
1671 p.type = PORT_OUT_TAP;
1673 p.dev_name = tokens[7];
1674 } else if (strcmp(tokens[6], "kni") == 0) {
1675 if (n_tokens != 8) {
1676 snprintf(out, out_size, MSG_ARG_MISMATCH,
1677 "pipeline port out kni");
1681 p.type = PORT_OUT_KNI;
1683 p.dev_name = tokens[7];
1684 } else if (strcmp(tokens[6], "sink") == 0) {
1685 if ((n_tokens != 7) && (n_tokens != 11)) {
1686 snprintf(out, out_size, MSG_ARG_MISMATCH,
1687 "pipeline port out sink");
1691 p.type = PORT_OUT_SINK;
1695 if (n_tokens == 7) {
1696 p.sink.file_name = NULL;
1697 p.sink.max_n_pkts = 0;
1699 if (strcmp(tokens[7], "file") != 0) {
1700 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1705 p.sink.file_name = tokens[8];
1707 if (strcmp(tokens[9], "pkts") != 0) {
1708 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pkts");
1712 if (parser_read_uint32(&p.sink.max_n_pkts, tokens[10]) != 0) {
1713 snprintf(out, out_size, MSG_ARG_INVALID, "max_n_pkts");
1718 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1722 status = pipeline_port_out_create(pipeline_name, &p);
1724 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1730 * pipeline <pipeline_name> table
1734 * offset <ip_header_offset>
1737 * offset <key_offset>
1743 * offset <key_offset>
1744 * buckets <n_buckets>
1748 * offset <ip_header_offset>
1751 * [action <table_action_profile_name>]
1754 cmd_pipeline_table(char **tokens,
1759 uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
1760 struct table_params p;
1761 char *pipeline_name;
1766 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1770 pipeline_name = tokens[1];
1772 if (strcmp(tokens[2], "table") != 0) {
1773 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1777 if (strcmp(tokens[3], "match") != 0) {
1778 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
1783 if (strcmp(tokens[t0], "acl") == 0) {
1784 if (n_tokens < t0 + 6) {
1785 snprintf(out, out_size, MSG_ARG_MISMATCH,
1786 "pipeline table acl");
1790 p.match_type = TABLE_ACL;
1792 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1793 p.match.acl.ip_version = 1;
1794 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1795 p.match.acl.ip_version = 0;
1797 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1802 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1803 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1807 if (parser_read_uint32(&p.match.acl.ip_header_offset,
1808 tokens[t0 + 3]) != 0) {
1809 snprintf(out, out_size, MSG_ARG_INVALID,
1810 "ip_header_offset");
1814 if (strcmp(tokens[t0 + 4], "size") != 0) {
1815 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1819 if (parser_read_uint32(&p.match.acl.n_rules,
1820 tokens[t0 + 5]) != 0) {
1821 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1826 } else if (strcmp(tokens[t0], "array") == 0) {
1827 if (n_tokens < t0 + 5) {
1828 snprintf(out, out_size, MSG_ARG_MISMATCH,
1829 "pipeline table array");
1833 p.match_type = TABLE_ARRAY;
1835 if (strcmp(tokens[t0 + 1], "offset") != 0) {
1836 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1840 if (parser_read_uint32(&p.match.array.key_offset,
1841 tokens[t0 + 2]) != 0) {
1842 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1846 if (strcmp(tokens[t0 + 3], "size") != 0) {
1847 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1851 if (parser_read_uint32(&p.match.array.n_keys,
1852 tokens[t0 + 4]) != 0) {
1853 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1858 } else if (strcmp(tokens[t0], "hash") == 0) {
1859 uint32_t key_mask_size = TABLE_RULE_MATCH_SIZE_MAX;
1861 if (n_tokens < t0 + 12) {
1862 snprintf(out, out_size, MSG_ARG_MISMATCH,
1863 "pipeline table hash");
1867 p.match_type = TABLE_HASH;
1869 if (strcmp(tokens[t0 + 1], "ext") == 0)
1870 p.match.hash.extendable_bucket = 1;
1871 else if (strcmp(tokens[t0 + 1], "lru") == 0)
1872 p.match.hash.extendable_bucket = 0;
1874 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1879 if (strcmp(tokens[t0 + 2], "key") != 0) {
1880 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
1884 if ((parser_read_uint32(&p.match.hash.key_size,
1885 tokens[t0 + 3]) != 0) ||
1886 (p.match.hash.key_size == 0) ||
1887 (p.match.hash.key_size > TABLE_RULE_MATCH_SIZE_MAX)) {
1888 snprintf(out, out_size, MSG_ARG_INVALID, "key_size");
1892 if (strcmp(tokens[t0 + 4], "mask") != 0) {
1893 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
1897 if ((parse_hex_string(tokens[t0 + 5],
1898 key_mask, &key_mask_size) != 0) ||
1899 (key_mask_size != p.match.hash.key_size)) {
1900 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
1903 p.match.hash.key_mask = key_mask;
1905 if (strcmp(tokens[t0 + 6], "offset") != 0) {
1906 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1910 if (parser_read_uint32(&p.match.hash.key_offset,
1911 tokens[t0 + 7]) != 0) {
1912 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1916 if (strcmp(tokens[t0 + 8], "buckets") != 0) {
1917 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buckets");
1921 if (parser_read_uint32(&p.match.hash.n_buckets,
1922 tokens[t0 + 9]) != 0) {
1923 snprintf(out, out_size, MSG_ARG_INVALID, "n_buckets");
1927 if (strcmp(tokens[t0 + 10], "size") != 0) {
1928 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1932 if (parser_read_uint32(&p.match.hash.n_keys,
1933 tokens[t0 + 11]) != 0) {
1934 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1939 } else if (strcmp(tokens[t0], "lpm") == 0) {
1940 if (n_tokens < t0 + 6) {
1941 snprintf(out, out_size, MSG_ARG_MISMATCH,
1942 "pipeline table lpm");
1946 p.match_type = TABLE_LPM;
1948 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1949 p.match.lpm.key_size = 4;
1950 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1951 p.match.lpm.key_size = 16;
1953 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1958 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1959 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1963 if (parser_read_uint32(&p.match.lpm.key_offset,
1964 tokens[t0 + 3]) != 0) {
1965 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1969 if (strcmp(tokens[t0 + 4], "size") != 0) {
1970 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1974 if (parser_read_uint32(&p.match.lpm.n_rules,
1975 tokens[t0 + 5]) != 0) {
1976 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1981 } else if (strcmp(tokens[t0], "stub") == 0) {
1982 p.match_type = TABLE_STUB;
1986 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1990 p.action_profile_name = NULL;
1991 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1992 if (n_tokens < t0 + 2) {
1993 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1997 p.action_profile_name = tokens[t0 + 1];
2002 if (n_tokens > t0) {
2003 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2007 status = pipeline_table_create(pipeline_name, &p);
2009 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2015 * pipeline <pipeline_name> port in <port_id> table <table_id>
2018 cmd_pipeline_port_in_table(char **tokens,
2023 char *pipeline_name;
2024 uint32_t port_id, table_id;
2027 if (n_tokens != 7) {
2028 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2032 pipeline_name = tokens[1];
2034 if (strcmp(tokens[2], "port") != 0) {
2035 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2039 if (strcmp(tokens[3], "in") != 0) {
2040 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2044 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2045 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2049 if (strcmp(tokens[5], "table") != 0) {
2050 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
2054 if (parser_read_uint32(&table_id, tokens[6]) != 0) {
2055 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
2059 status = pipeline_port_in_connect_to_table(pipeline_name,
2063 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2069 * pipeline <pipeline_name> port in <port_id> stats read [clear]
2072 #define MSG_PIPELINE_PORT_IN_STATS \
2073 "Pkts in: %" PRIu64 "\n" \
2074 "Pkts dropped by AH: %" PRIu64 "\n" \
2075 "Pkts dropped by other: %" PRIu64 "\n"
2078 cmd_pipeline_port_in_stats(char **tokens,
2083 struct rte_pipeline_port_in_stats stats;
2084 char *pipeline_name;
2088 if ((n_tokens != 7) && (n_tokens != 8)) {
2089 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2093 pipeline_name = tokens[1];
2095 if (strcmp(tokens[2], "port") != 0) {
2096 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2100 if (strcmp(tokens[3], "in") != 0) {
2101 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2105 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2106 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2110 if (strcmp(tokens[5], "stats") != 0) {
2111 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2115 if (strcmp(tokens[6], "read") != 0) {
2116 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2121 if (n_tokens == 8) {
2122 if (strcmp(tokens[7], "clear") != 0) {
2123 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2130 status = pipeline_port_in_stats_read(pipeline_name,
2135 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2139 snprintf(out, out_size, MSG_PIPELINE_PORT_IN_STATS,
2140 stats.stats.n_pkts_in,
2141 stats.n_pkts_dropped_by_ah,
2142 stats.stats.n_pkts_drop);
2146 * pipeline <pipeline_name> port in <port_id> enable
2149 cmd_pipeline_port_in_enable(char **tokens,
2154 char *pipeline_name;
2158 if (n_tokens != 6) {
2159 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2163 pipeline_name = tokens[1];
2165 if (strcmp(tokens[2], "port") != 0) {
2166 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2170 if (strcmp(tokens[3], "in") != 0) {
2171 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2175 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2176 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2180 if (strcmp(tokens[5], "enable") != 0) {
2181 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
2185 status = pipeline_port_in_enable(pipeline_name, port_id);
2187 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2193 * pipeline <pipeline_name> port in <port_id> disable
2196 cmd_pipeline_port_in_disable(char **tokens,
2201 char *pipeline_name;
2205 if (n_tokens != 6) {
2206 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2210 pipeline_name = tokens[1];
2212 if (strcmp(tokens[2], "port") != 0) {
2213 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2217 if (strcmp(tokens[3], "in") != 0) {
2218 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2222 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2223 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2227 if (strcmp(tokens[5], "disable") != 0) {
2228 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
2232 status = pipeline_port_in_disable(pipeline_name, port_id);
2234 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2240 * pipeline <pipeline_name> port out <port_id> stats read [clear]
2242 #define MSG_PIPELINE_PORT_OUT_STATS \
2243 "Pkts in: %" PRIu64 "\n" \
2244 "Pkts dropped by AH: %" PRIu64 "\n" \
2245 "Pkts dropped by other: %" PRIu64 "\n"
2248 cmd_pipeline_port_out_stats(char **tokens,
2253 struct rte_pipeline_port_out_stats stats;
2254 char *pipeline_name;
2258 if ((n_tokens != 7) && (n_tokens != 8)) {
2259 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2263 pipeline_name = tokens[1];
2265 if (strcmp(tokens[2], "port") != 0) {
2266 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2270 if (strcmp(tokens[3], "out") != 0) {
2271 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
2275 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2276 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2280 if (strcmp(tokens[5], "stats") != 0) {
2281 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2285 if (strcmp(tokens[6], "read") != 0) {
2286 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2291 if (n_tokens == 8) {
2292 if (strcmp(tokens[7], "clear") != 0) {
2293 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2300 status = pipeline_port_out_stats_read(pipeline_name,
2305 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2309 snprintf(out, out_size, MSG_PIPELINE_PORT_OUT_STATS,
2310 stats.stats.n_pkts_in,
2311 stats.n_pkts_dropped_by_ah,
2312 stats.stats.n_pkts_drop);
2316 * pipeline <pipeline_name> table <table_id> stats read [clear]
2318 #define MSG_PIPELINE_TABLE_STATS \
2319 "Pkts in: %" PRIu64 "\n" \
2320 "Pkts in with lookup miss: %" PRIu64 "\n" \
2321 "Pkts in with lookup hit dropped by AH: %" PRIu64 "\n" \
2322 "Pkts in with lookup hit dropped by others: %" PRIu64 "\n" \
2323 "Pkts in with lookup miss dropped by AH: %" PRIu64 "\n" \
2324 "Pkts in with lookup miss dropped by others: %" PRIu64 "\n"
2327 cmd_pipeline_table_stats(char **tokens,
2332 struct rte_pipeline_table_stats stats;
2333 char *pipeline_name;
2337 if ((n_tokens != 6) && (n_tokens != 7)) {
2338 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2342 pipeline_name = tokens[1];
2344 if (strcmp(tokens[2], "table") != 0) {
2345 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2349 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
2350 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
2354 if (strcmp(tokens[4], "stats") != 0) {
2355 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2359 if (strcmp(tokens[5], "read") != 0) {
2360 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2365 if (n_tokens == 7) {
2366 if (strcmp(tokens[6], "clear") != 0) {
2367 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2374 status = pipeline_table_stats_read(pipeline_name,
2379 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2383 snprintf(out, out_size, MSG_PIPELINE_TABLE_STATS,
2384 stats.stats.n_pkts_in,
2385 stats.stats.n_pkts_lookup_miss,
2386 stats.n_pkts_dropped_by_lkp_hit_ah,
2387 stats.n_pkts_dropped_lkp_hit,
2388 stats.n_pkts_dropped_by_lkp_miss_ah,
2389 stats.n_pkts_dropped_lkp_miss);
2397 * priority <priority>
2398 * ipv4 | ipv6 <sa> <sa_depth> <da> <da_depth>
2399 * <sp0> <sp1> <dp0> <dp1> <proto>
2403 * | ipv4_5tuple <sa> <da> <sp> <dp> <proto>
2404 * | ipv6_5tuple <sa> <da> <sp> <dp> <proto>
2405 * | ipv4_addr <addr>
2406 * | ipv6_addr <addr>
2407 * | qinq <svlan> <cvlan>
2409 * ipv4 | ipv6 <addr> <depth>
2411 struct pkt_key_qinq {
2412 uint16_t ethertype_svlan;
2414 uint16_t ethertype_cvlan;
2416 } __attribute__((__packed__));
2418 struct pkt_key_ipv4_5tuple {
2419 uint8_t time_to_live;
2421 uint16_t hdr_checksum;
2426 } __attribute__((__packed__));
2428 struct pkt_key_ipv6_5tuple {
2429 uint16_t payload_length;
2436 } __attribute__((__packed__));
2438 struct pkt_key_ipv4_addr {
2440 } __attribute__((__packed__));
2442 struct pkt_key_ipv6_addr {
2444 } __attribute__((__packed__));
2447 parse_match(char **tokens,
2451 struct table_rule_match *m)
2453 memset(m, 0, sizeof(*m));
2458 if (strcmp(tokens[0], "match") != 0) {
2459 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
2463 if (strcmp(tokens[1], "acl") == 0) {
2464 if (n_tokens < 14) {
2465 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2469 m->match_type = TABLE_ACL;
2471 if (strcmp(tokens[2], "priority") != 0) {
2472 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority");
2476 if (parser_read_uint32(&m->match.acl.priority,
2478 snprintf(out, out_size, MSG_ARG_INVALID, "priority");
2482 if (strcmp(tokens[4], "ipv4") == 0) {
2483 struct in_addr saddr, daddr;
2485 m->match.acl.ip_version = 1;
2487 if (parse_ipv4_addr(tokens[5], &saddr) != 0) {
2488 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2491 m->match.acl.ipv4.sa = rte_be_to_cpu_32(saddr.s_addr);
2493 if (parse_ipv4_addr(tokens[7], &daddr) != 0) {
2494 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2497 m->match.acl.ipv4.da = rte_be_to_cpu_32(daddr.s_addr);
2498 } else if (strcmp(tokens[4], "ipv6") == 0) {
2499 struct in6_addr saddr, daddr;
2501 m->match.acl.ip_version = 0;
2503 if (parse_ipv6_addr(tokens[5], &saddr) != 0) {
2504 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2507 memcpy(m->match.acl.ipv6.sa, saddr.s6_addr, 16);
2509 if (parse_ipv6_addr(tokens[7], &daddr) != 0) {
2510 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2513 memcpy(m->match.acl.ipv6.da, daddr.s6_addr, 16);
2515 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
2520 if (parser_read_uint32(&m->match.acl.sa_depth,
2522 snprintf(out, out_size, MSG_ARG_INVALID, "sa_depth");
2526 if (parser_read_uint32(&m->match.acl.da_depth,
2528 snprintf(out, out_size, MSG_ARG_INVALID, "da_depth");
2532 if (parser_read_uint16(&m->match.acl.sp0, tokens[9]) != 0) {
2533 snprintf(out, out_size, MSG_ARG_INVALID, "sp0");
2537 if (parser_read_uint16(&m->match.acl.sp1, tokens[10]) != 0) {
2538 snprintf(out, out_size, MSG_ARG_INVALID, "sp1");
2542 if (parser_read_uint16(&m->match.acl.dp0, tokens[11]) != 0) {
2543 snprintf(out, out_size, MSG_ARG_INVALID, "dp0");
2547 if (parser_read_uint16(&m->match.acl.dp1, tokens[12]) != 0) {
2548 snprintf(out, out_size, MSG_ARG_INVALID, "dp1");
2552 if (parser_read_uint8(&m->match.acl.proto, tokens[13]) != 0) {
2553 snprintf(out, out_size, MSG_ARG_INVALID, "proto");
2557 m->match.acl.proto_mask = 0xff;
2562 if (strcmp(tokens[1], "array") == 0) {
2564 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2568 m->match_type = TABLE_ARRAY;
2570 if (parser_read_uint32(&m->match.array.pos, tokens[2]) != 0) {
2571 snprintf(out, out_size, MSG_ARG_INVALID, "pos");
2578 if (strcmp(tokens[1], "hash") == 0) {
2580 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2584 m->match_type = TABLE_HASH;
2586 if (strcmp(tokens[2], "raw") == 0) {
2587 uint32_t key_size = TABLE_RULE_MATCH_SIZE_MAX;
2590 snprintf(out, out_size, MSG_ARG_MISMATCH,
2595 if (parse_hex_string(tokens[3],
2596 m->match.hash.key, &key_size) != 0) {
2597 snprintf(out, out_size, MSG_ARG_INVALID, "key");
2604 if (strcmp(tokens[2], "ipv4_5tuple") == 0) {
2605 struct pkt_key_ipv4_5tuple *ipv4 =
2606 (struct pkt_key_ipv4_5tuple *) m->match.hash.key;
2607 struct in_addr saddr, daddr;
2612 snprintf(out, out_size, MSG_ARG_MISMATCH,
2617 if (parse_ipv4_addr(tokens[3], &saddr) != 0) {
2618 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2622 if (parse_ipv4_addr(tokens[4], &daddr) != 0) {
2623 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2627 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2628 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2632 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2633 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2637 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2638 snprintf(out, out_size, MSG_ARG_INVALID,
2643 ipv4->sa = saddr.s_addr;
2644 ipv4->da = daddr.s_addr;
2645 ipv4->sp = rte_cpu_to_be_16(sp);
2646 ipv4->dp = rte_cpu_to_be_16(dp);
2647 ipv4->proto = proto;
2650 } /* hash ipv4_5tuple */
2652 if (strcmp(tokens[2], "ipv6_5tuple") == 0) {
2653 struct pkt_key_ipv6_5tuple *ipv6 =
2654 (struct pkt_key_ipv6_5tuple *) m->match.hash.key;
2655 struct in6_addr saddr, daddr;
2660 snprintf(out, out_size, MSG_ARG_MISMATCH,
2665 if (parse_ipv6_addr(tokens[3], &saddr) != 0) {
2666 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2670 if (parse_ipv6_addr(tokens[4], &daddr) != 0) {
2671 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2675 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2676 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2680 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2681 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2685 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2686 snprintf(out, out_size, MSG_ARG_INVALID,
2691 memcpy(ipv6->sa, saddr.s6_addr, 16);
2692 memcpy(ipv6->da, daddr.s6_addr, 16);
2693 ipv6->sp = rte_cpu_to_be_16(sp);
2694 ipv6->dp = rte_cpu_to_be_16(dp);
2695 ipv6->proto = proto;
2698 } /* hash ipv6_5tuple */
2700 if (strcmp(tokens[2], "ipv4_addr") == 0) {
2701 struct pkt_key_ipv4_addr *ipv4_addr =
2702 (struct pkt_key_ipv4_addr *) m->match.hash.key;
2703 struct in_addr addr;
2706 snprintf(out, out_size, MSG_ARG_MISMATCH,
2711 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2712 snprintf(out, out_size, MSG_ARG_INVALID,
2717 ipv4_addr->addr = addr.s_addr;
2720 } /* hash ipv4_addr */
2722 if (strcmp(tokens[2], "ipv6_addr") == 0) {
2723 struct pkt_key_ipv6_addr *ipv6_addr =
2724 (struct pkt_key_ipv6_addr *) m->match.hash.key;
2725 struct in6_addr addr;
2728 snprintf(out, out_size, MSG_ARG_MISMATCH,
2733 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2734 snprintf(out, out_size, MSG_ARG_INVALID,
2739 memcpy(ipv6_addr->addr, addr.s6_addr, 16);
2742 } /* hash ipv6_5tuple */
2744 if (strcmp(tokens[2], "qinq") == 0) {
2745 struct pkt_key_qinq *qinq =
2746 (struct pkt_key_qinq *) m->match.hash.key;
2747 uint16_t svlan, cvlan;
2750 snprintf(out, out_size, MSG_ARG_MISMATCH,
2755 if ((parser_read_uint16(&svlan, tokens[3]) != 0) ||
2757 snprintf(out, out_size, MSG_ARG_INVALID,
2762 if ((parser_read_uint16(&cvlan, tokens[4]) != 0) ||
2764 snprintf(out, out_size, MSG_ARG_INVALID,
2769 qinq->svlan = rte_cpu_to_be_16(svlan);
2770 qinq->cvlan = rte_cpu_to_be_16(cvlan);
2775 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2779 if (strcmp(tokens[1], "lpm") == 0) {
2781 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2785 m->match_type = TABLE_LPM;
2787 if (strcmp(tokens[2], "ipv4") == 0) {
2788 struct in_addr addr;
2790 m->match.lpm.ip_version = 1;
2792 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2793 snprintf(out, out_size, MSG_ARG_INVALID,
2798 m->match.lpm.ipv4 = rte_be_to_cpu_32(addr.s_addr);
2799 } else if (strcmp(tokens[2], "ipv6") == 0) {
2800 struct in6_addr addr;
2802 m->match.lpm.ip_version = 0;
2804 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2805 snprintf(out, out_size, MSG_ARG_INVALID,
2810 memcpy(m->match.lpm.ipv6, addr.s6_addr, 16);
2812 snprintf(out, out_size, MSG_ARG_MISMATCH,
2817 if (parser_read_uint8(&m->match.lpm.depth, tokens[4]) != 0) {
2818 snprintf(out, out_size, MSG_ARG_INVALID, "depth");
2825 snprintf(out, out_size, MSG_ARG_MISMATCH,
2826 "acl or array or hash or lpm");
2838 * | table <table_id>
2839 * [balance <out0> ... <out7>]
2841 * tc0 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2842 * [tc1 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2843 * tc2 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2844 * tc3 meter <meter_profile_id> policer g <pa> y <pa> r <pa>]]
2845 * [tm subport <subport_id> pipe <pipe_id>]
2848 * | vlan <da> <sa> <pcp> <dei> <vid>
2849 * | qinq <da> <sa> <pcp> <dei> <vid> <pcp> <dei> <vid>
2850 * | mpls unicast | multicast
2852 * label0 <label> <tc> <ttl>
2853 * [label1 <label> <tc> <ttl>
2854 * [label2 <label> <tc> <ttl>
2855 * [label3 <label> <tc> <ttl>]]]
2856 * | pppoe <da> <sa> <session_id>]
2857 * [nat ipv4 | ipv6 <addr> <port>]
2863 * <pa> ::= g | y | r | drop
2866 parse_table_action_fwd(char **tokens,
2868 struct table_rule_action *a)
2870 if ((n_tokens == 0) || (strcmp(tokens[0], "fwd") != 0))
2876 if (n_tokens && (strcmp(tokens[0], "drop") == 0)) {
2877 a->fwd.action = RTE_PIPELINE_ACTION_DROP;
2878 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2882 if (n_tokens && (strcmp(tokens[0], "port") == 0)) {
2885 if ((n_tokens < 2) ||
2886 parser_read_uint32(&id, tokens[1]))
2889 a->fwd.action = RTE_PIPELINE_ACTION_PORT;
2891 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2895 if (n_tokens && (strcmp(tokens[0], "meta") == 0)) {
2896 a->fwd.action = RTE_PIPELINE_ACTION_PORT_META;
2897 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2901 if (n_tokens && (strcmp(tokens[0], "table") == 0)) {
2904 if ((n_tokens < 2) ||
2905 parser_read_uint32(&id, tokens[1]))
2908 a->fwd.action = RTE_PIPELINE_ACTION_TABLE;
2910 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2918 parse_table_action_balance(char **tokens,
2920 struct table_rule_action *a)
2924 if ((n_tokens == 0) || (strcmp(tokens[0], "balance") != 0))
2930 if (n_tokens < RTE_TABLE_ACTION_LB_TABLE_SIZE)
2933 for (i = 0; i < RTE_TABLE_ACTION_LB_TABLE_SIZE; i++)
2934 if (parser_read_uint32(&a->lb.out[i], tokens[i]) != 0)
2937 a->action_mask |= 1 << RTE_TABLE_ACTION_LB;
2938 return 1 + RTE_TABLE_ACTION_LB_TABLE_SIZE;
2943 parse_policer_action(char *token, enum rte_table_action_policer *a)
2945 if (strcmp(token, "g") == 0) {
2946 *a = RTE_TABLE_ACTION_POLICER_COLOR_GREEN;
2950 if (strcmp(token, "y") == 0) {
2951 *a = RTE_TABLE_ACTION_POLICER_COLOR_YELLOW;
2955 if (strcmp(token, "r") == 0) {
2956 *a = RTE_TABLE_ACTION_POLICER_COLOR_RED;
2960 if (strcmp(token, "drop") == 0) {
2961 *a = RTE_TABLE_ACTION_POLICER_DROP;
2969 parse_table_action_meter_tc(char **tokens,
2971 struct rte_table_action_mtr_tc_params *mtr)
2973 if ((n_tokens < 9) ||
2974 strcmp(tokens[0], "meter") ||
2975 parser_read_uint32(&mtr->meter_profile_id, tokens[1]) ||
2976 strcmp(tokens[2], "policer") ||
2977 strcmp(tokens[3], "g") ||
2978 parse_policer_action(tokens[4], &mtr->policer[e_RTE_METER_GREEN]) ||
2979 strcmp(tokens[5], "y") ||
2980 parse_policer_action(tokens[6], &mtr->policer[e_RTE_METER_YELLOW]) ||
2981 strcmp(tokens[7], "r") ||
2982 parse_policer_action(tokens[8], &mtr->policer[e_RTE_METER_RED]))
2989 parse_table_action_meter(char **tokens,
2991 struct table_rule_action *a)
2993 if ((n_tokens == 0) || strcmp(tokens[0], "meter"))
2999 if ((n_tokens < 10) ||
3000 strcmp(tokens[0], "tc0") ||
3001 (parse_table_action_meter_tc(tokens + 1,
3003 &a->mtr.mtr[0]) == 0))
3009 if ((n_tokens == 0) || strcmp(tokens[0], "tc1")) {
3011 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
3015 if ((n_tokens < 30) ||
3016 (parse_table_action_meter_tc(tokens + 1,
3017 n_tokens - 1, &a->mtr.mtr[1]) == 0) ||
3018 strcmp(tokens[10], "tc2") ||
3019 (parse_table_action_meter_tc(tokens + 11,
3020 n_tokens - 11, &a->mtr.mtr[2]) == 0) ||
3021 strcmp(tokens[20], "tc3") ||
3022 (parse_table_action_meter_tc(tokens + 21,
3023 n_tokens - 21, &a->mtr.mtr[3]) == 0))
3026 a->mtr.tc_mask = 0xF;
3027 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
3028 return 1 + 10 + 3 * 10;
3032 parse_table_action_tm(char **tokens,
3034 struct table_rule_action *a)
3036 uint32_t subport_id, pipe_id;
3038 if ((n_tokens < 5) ||
3039 strcmp(tokens[0], "tm") ||
3040 strcmp(tokens[1], "subport") ||
3041 parser_read_uint32(&subport_id, tokens[2]) ||
3042 strcmp(tokens[3], "pipe") ||
3043 parser_read_uint32(&pipe_id, tokens[4]))
3046 a->tm.subport_id = subport_id;
3047 a->tm.pipe_id = pipe_id;
3048 a->action_mask |= 1 << RTE_TABLE_ACTION_TM;
3053 parse_table_action_encap(char **tokens,
3055 struct table_rule_action *a)
3057 if ((n_tokens == 0) || strcmp(tokens[0], "encap"))
3064 if (n_tokens && (strcmp(tokens[0], "ether") == 0)) {
3065 if ((n_tokens < 3) ||
3066 parse_mac_addr(tokens[1], &a->encap.ether.ether.da) ||
3067 parse_mac_addr(tokens[2], &a->encap.ether.ether.sa))
3070 a->encap.type = RTE_TABLE_ACTION_ENCAP_ETHER;
3071 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3076 if (n_tokens && (strcmp(tokens[0], "vlan") == 0)) {
3077 uint32_t pcp, dei, vid;
3079 if ((n_tokens < 6) ||
3080 parse_mac_addr(tokens[1], &a->encap.vlan.ether.da) ||
3081 parse_mac_addr(tokens[2], &a->encap.vlan.ether.sa) ||
3082 parser_read_uint32(&pcp, tokens[3]) ||
3084 parser_read_uint32(&dei, tokens[4]) ||
3086 parser_read_uint32(&vid, tokens[5]) ||
3090 a->encap.vlan.vlan.pcp = pcp & 0x7;
3091 a->encap.vlan.vlan.dei = dei & 0x1;
3092 a->encap.vlan.vlan.vid = vid & 0xFFF;
3093 a->encap.type = RTE_TABLE_ACTION_ENCAP_VLAN;
3094 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3099 if (n_tokens && (strcmp(tokens[0], "qinq") == 0)) {
3100 uint32_t svlan_pcp, svlan_dei, svlan_vid;
3101 uint32_t cvlan_pcp, cvlan_dei, cvlan_vid;
3103 if ((n_tokens < 9) ||
3104 parse_mac_addr(tokens[1], &a->encap.qinq.ether.da) ||
3105 parse_mac_addr(tokens[2], &a->encap.qinq.ether.sa) ||
3106 parser_read_uint32(&svlan_pcp, tokens[3]) ||
3107 (svlan_pcp > 0x7) ||
3108 parser_read_uint32(&svlan_dei, tokens[4]) ||
3109 (svlan_dei > 0x1) ||
3110 parser_read_uint32(&svlan_vid, tokens[5]) ||
3111 (svlan_vid > 0xFFF) ||
3112 parser_read_uint32(&cvlan_pcp, tokens[6]) ||
3113 (cvlan_pcp > 0x7) ||
3114 parser_read_uint32(&cvlan_dei, tokens[7]) ||
3115 (cvlan_dei > 0x1) ||
3116 parser_read_uint32(&cvlan_vid, tokens[8]) ||
3117 (cvlan_vid > 0xFFF))
3120 a->encap.qinq.svlan.pcp = svlan_pcp & 0x7;
3121 a->encap.qinq.svlan.dei = svlan_dei & 0x1;
3122 a->encap.qinq.svlan.vid = svlan_vid & 0xFFF;
3123 a->encap.qinq.cvlan.pcp = cvlan_pcp & 0x7;
3124 a->encap.qinq.cvlan.dei = cvlan_dei & 0x1;
3125 a->encap.qinq.cvlan.vid = cvlan_vid & 0xFFF;
3126 a->encap.type = RTE_TABLE_ACTION_ENCAP_QINQ;
3127 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3132 if (n_tokens && (strcmp(tokens[0], "mpls") == 0)) {
3133 uint32_t label, tc, ttl;
3138 if (strcmp(tokens[1], "unicast") == 0)
3139 a->encap.mpls.unicast = 1;
3140 else if (strcmp(tokens[1], "multicast") == 0)
3141 a->encap.mpls.unicast = 0;
3145 if (parse_mac_addr(tokens[2], &a->encap.mpls.ether.da) ||
3146 parse_mac_addr(tokens[3], &a->encap.mpls.ether.sa) ||
3147 strcmp(tokens[4], "label0") ||
3148 parser_read_uint32(&label, tokens[5]) ||
3149 (label > 0xFFFFF) ||
3150 parser_read_uint32(&tc, tokens[6]) ||
3152 parser_read_uint32(&ttl, tokens[7]) ||
3156 a->encap.mpls.mpls[0].label = label;
3157 a->encap.mpls.mpls[0].tc = tc;
3158 a->encap.mpls.mpls[0].ttl = ttl;
3163 if ((n_tokens == 0) || strcmp(tokens[0], "label1")) {
3164 a->encap.mpls.mpls_count = 1;
3165 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3166 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3170 if ((n_tokens < 4) ||
3171 parser_read_uint32(&label, tokens[1]) ||
3172 (label > 0xFFFFF) ||
3173 parser_read_uint32(&tc, tokens[2]) ||
3175 parser_read_uint32(&ttl, tokens[3]) ||
3179 a->encap.mpls.mpls[1].label = label;
3180 a->encap.mpls.mpls[1].tc = tc;
3181 a->encap.mpls.mpls[1].ttl = ttl;
3186 if ((n_tokens == 0) || strcmp(tokens[0], "label2")) {
3187 a->encap.mpls.mpls_count = 2;
3188 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3189 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3193 if ((n_tokens < 4) ||
3194 parser_read_uint32(&label, tokens[1]) ||
3195 (label > 0xFFFFF) ||
3196 parser_read_uint32(&tc, tokens[2]) ||
3198 parser_read_uint32(&ttl, tokens[3]) ||
3202 a->encap.mpls.mpls[2].label = label;
3203 a->encap.mpls.mpls[2].tc = tc;
3204 a->encap.mpls.mpls[2].ttl = ttl;
3209 if ((n_tokens == 0) || strcmp(tokens[0], "label3")) {
3210 a->encap.mpls.mpls_count = 3;
3211 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3212 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3213 return 1 + 8 + 4 + 4;
3216 if ((n_tokens < 4) ||
3217 parser_read_uint32(&label, tokens[1]) ||
3218 (label > 0xFFFFF) ||
3219 parser_read_uint32(&tc, tokens[2]) ||
3221 parser_read_uint32(&ttl, tokens[3]) ||
3225 a->encap.mpls.mpls[3].label = label;
3226 a->encap.mpls.mpls[3].tc = tc;
3227 a->encap.mpls.mpls[3].ttl = ttl;
3229 a->encap.mpls.mpls_count = 4;
3230 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3231 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3232 return 1 + 8 + 4 + 4 + 4;
3236 if (n_tokens && (strcmp(tokens[0], "pppoe") == 0)) {
3237 if ((n_tokens < 4) ||
3238 parse_mac_addr(tokens[1], &a->encap.pppoe.ether.da) ||
3239 parse_mac_addr(tokens[2], &a->encap.pppoe.ether.sa) ||
3240 parser_read_uint16(&a->encap.pppoe.pppoe.session_id,
3244 a->encap.type = RTE_TABLE_ACTION_ENCAP_PPPOE;
3245 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3253 parse_table_action_nat(char **tokens,
3255 struct table_rule_action *a)
3257 if ((n_tokens < 4) ||
3258 strcmp(tokens[0], "nat"))
3261 if (strcmp(tokens[1], "ipv4") == 0) {
3262 struct in_addr addr;
3265 if (parse_ipv4_addr(tokens[2], &addr) ||
3266 parser_read_uint16(&port, tokens[3]))
3269 a->nat.ip_version = 1;
3270 a->nat.addr.ipv4 = rte_be_to_cpu_32(addr.s_addr);
3272 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3276 if (strcmp(tokens[1], "ipv6") == 0) {
3277 struct in6_addr addr;
3280 if (parse_ipv6_addr(tokens[2], &addr) ||
3281 parser_read_uint16(&port, tokens[3]))
3284 a->nat.ip_version = 0;
3285 memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
3287 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3295 parse_table_action_ttl(char **tokens,
3297 struct table_rule_action *a)
3299 if ((n_tokens < 2) ||
3300 strcmp(tokens[0], "ttl"))
3303 if (strcmp(tokens[1], "dec") == 0)
3304 a->ttl.decrement = 1;
3305 else if (strcmp(tokens[1], "keep") == 0)
3306 a->ttl.decrement = 0;
3310 a->action_mask |= 1 << RTE_TABLE_ACTION_TTL;
3315 parse_table_action_stats(char **tokens,
3317 struct table_rule_action *a)
3319 if ((n_tokens < 1) ||
3320 strcmp(tokens[0], "stats"))
3323 a->stats.n_packets = 0;
3324 a->stats.n_bytes = 0;
3325 a->action_mask |= 1 << RTE_TABLE_ACTION_STATS;
3330 parse_table_action_time(char **tokens,
3332 struct table_rule_action *a)
3334 if ((n_tokens < 1) ||
3335 strcmp(tokens[0], "time"))
3338 a->time.time = rte_rdtsc();
3339 a->action_mask |= 1 << RTE_TABLE_ACTION_TIME;
3344 parse_table_action(char **tokens,
3348 struct table_rule_action *a)
3350 uint32_t n_tokens0 = n_tokens;
3352 memset(a, 0, sizeof(*a));
3354 if ((n_tokens < 2) ||
3355 strcmp(tokens[0], "action"))
3361 if (n_tokens && (strcmp(tokens[0], "fwd") == 0)) {
3364 n = parse_table_action_fwd(tokens, n_tokens, a);
3366 snprintf(out, out_size, MSG_ARG_INVALID,
3375 if (n_tokens && (strcmp(tokens[0], "balance") == 0)) {
3378 n = parse_table_action_balance(tokens, n_tokens, a);
3380 snprintf(out, out_size, MSG_ARG_INVALID,
3389 if (n_tokens && (strcmp(tokens[0], "meter") == 0)) {
3392 n = parse_table_action_meter(tokens, n_tokens, a);
3394 snprintf(out, out_size, MSG_ARG_INVALID,
3403 if (n_tokens && (strcmp(tokens[0], "tm") == 0)) {
3406 n = parse_table_action_tm(tokens, n_tokens, a);
3408 snprintf(out, out_size, MSG_ARG_INVALID,
3417 if (n_tokens && (strcmp(tokens[0], "encap") == 0)) {
3420 n = parse_table_action_encap(tokens, n_tokens, a);
3422 snprintf(out, out_size, MSG_ARG_INVALID,
3431 if (n_tokens && (strcmp(tokens[0], "nat") == 0)) {
3434 n = parse_table_action_nat(tokens, n_tokens, a);
3436 snprintf(out, out_size, MSG_ARG_INVALID,
3445 if (n_tokens && (strcmp(tokens[0], "ttl") == 0)) {
3448 n = parse_table_action_ttl(tokens, n_tokens, a);
3450 snprintf(out, out_size, MSG_ARG_INVALID,
3459 if (n_tokens && (strcmp(tokens[0], "stats") == 0)) {
3462 n = parse_table_action_stats(tokens, n_tokens, a);
3464 snprintf(out, out_size, MSG_ARG_INVALID,
3473 if (n_tokens && (strcmp(tokens[0], "time") == 0)) {
3476 n = parse_table_action_time(tokens, n_tokens, a);
3478 snprintf(out, out_size, MSG_ARG_INVALID,
3487 if (n_tokens0 - n_tokens == 1) {
3488 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3492 return n_tokens0 - n_tokens;
3496 * pipeline <pipeline_name> table <table_id> rule add
3498 * action <table_action>
3501 cmd_pipeline_table_rule_add(char **tokens,
3506 struct table_rule_match m;
3507 struct table_rule_action a;
3508 char *pipeline_name;
3510 uint32_t table_id, t0, n_tokens_parsed;
3514 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3518 pipeline_name = tokens[1];
3520 if (strcmp(tokens[2], "table") != 0) {
3521 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3525 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3526 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3530 if (strcmp(tokens[4], "rule") != 0) {
3531 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3535 if (strcmp(tokens[5], "add") != 0) {
3536 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3543 n_tokens_parsed = parse_match(tokens + t0,
3548 if (n_tokens_parsed == 0)
3550 t0 += n_tokens_parsed;
3553 n_tokens_parsed = parse_table_action(tokens + t0,
3558 if (n_tokens_parsed == 0)
3560 t0 += n_tokens_parsed;
3562 if (t0 != n_tokens) {
3563 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
3567 status = pipeline_table_rule_add(pipeline_name, table_id,
3570 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3576 * pipeline <pipeline_name> table <table_id> rule add
3584 * | table <table_id>
3587 cmd_pipeline_table_rule_add_default(char **tokens,
3592 struct table_rule_action action;
3594 char *pipeline_name;
3598 if ((n_tokens != 11) && (n_tokens != 12)) {
3599 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3603 pipeline_name = tokens[1];
3605 if (strcmp(tokens[2], "table") != 0) {
3606 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3610 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3611 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3615 if (strcmp(tokens[4], "rule") != 0) {
3616 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3620 if (strcmp(tokens[5], "add") != 0) {
3621 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3625 if (strcmp(tokens[6], "match") != 0) {
3626 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3630 if (strcmp(tokens[7], "default") != 0) {
3631 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3635 if (strcmp(tokens[8], "action") != 0) {
3636 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3640 if (strcmp(tokens[9], "fwd") != 0) {
3641 snprintf(out, out_size, MSG_ARG_INVALID, "fwd");
3645 action.action_mask = 1 << RTE_TABLE_ACTION_FWD;
3647 if (strcmp(tokens[10], "drop") == 0) {
3648 if (n_tokens != 11) {
3649 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3653 action.fwd.action = RTE_PIPELINE_ACTION_DROP;
3654 } else if (strcmp(tokens[10], "port") == 0) {
3657 if (n_tokens != 12) {
3658 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3662 if (parser_read_uint32(&id, tokens[11]) != 0) {
3663 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
3667 action.fwd.action = RTE_PIPELINE_ACTION_PORT;
3669 } else if (strcmp(tokens[10], "meta") == 0) {
3670 if (n_tokens != 11) {
3671 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3675 action.fwd.action = RTE_PIPELINE_ACTION_PORT_META;
3676 } else if (strcmp(tokens[10], "table") == 0) {
3679 if (n_tokens != 12) {
3680 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3684 if (parser_read_uint32(&id, tokens[11]) != 0) {
3685 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3689 action.fwd.action = RTE_PIPELINE_ACTION_TABLE;
3692 snprintf(out, out_size, MSG_ARG_INVALID,
3693 "drop or port or meta or table");
3697 status = pipeline_table_rule_add_default(pipeline_name,
3702 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3708 * pipeline <pipeline_name> table <table_id> rule add bulk <file_name> <n_rules>
3711 * - line format: match <match> action <action>
3714 cli_rule_file_process(const char *file_name,
3715 size_t line_len_max,
3716 struct table_rule_match *m,
3717 struct table_rule_action *a,
3719 uint32_t *line_number,
3724 cmd_pipeline_table_rule_add_bulk(char **tokens,
3729 struct table_rule_match *match;
3730 struct table_rule_action *action;
3732 char *pipeline_name, *file_name;
3733 uint32_t table_id, n_rules, n_rules_parsed, line_number;
3736 if (n_tokens != 9) {
3737 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3741 pipeline_name = tokens[1];
3743 if (strcmp(tokens[2], "table") != 0) {
3744 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3748 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3749 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3753 if (strcmp(tokens[4], "rule") != 0) {
3754 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3758 if (strcmp(tokens[5], "add") != 0) {
3759 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3763 if (strcmp(tokens[6], "bulk") != 0) {
3764 snprintf(out, out_size, MSG_ARG_INVALID, "bulk");
3768 file_name = tokens[7];
3770 if ((parser_read_uint32(&n_rules, tokens[8]) != 0) ||
3772 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
3776 /* Memory allocation. */
3777 match = calloc(n_rules, sizeof(struct table_rule_match));
3778 action = calloc(n_rules, sizeof(struct table_rule_action));
3779 data = calloc(n_rules, sizeof(void *));
3780 if ((match == NULL) || (action == NULL) || (data == NULL)) {
3781 snprintf(out, out_size, MSG_OUT_OF_MEMORY);
3788 /* Load rule file */
3789 n_rules_parsed = n_rules;
3790 status = cli_rule_file_process(file_name,
3799 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
3805 if (n_rules_parsed != n_rules) {
3806 snprintf(out, out_size, MSG_FILE_NOT_ENOUGH, file_name);
3814 status = pipeline_table_rule_add_bulk(pipeline_name,
3821 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3835 * pipeline <pipeline_name> table <table_id> rule delete
3839 cmd_pipeline_table_rule_delete(char **tokens,
3844 struct table_rule_match m;
3845 char *pipeline_name;
3846 uint32_t table_id, n_tokens_parsed, t0;
3850 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3854 pipeline_name = tokens[1];
3856 if (strcmp(tokens[2], "table") != 0) {
3857 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3861 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3862 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3866 if (strcmp(tokens[4], "rule") != 0) {
3867 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3871 if (strcmp(tokens[5], "delete") != 0) {
3872 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3879 n_tokens_parsed = parse_match(tokens + t0,
3884 if (n_tokens_parsed == 0)
3886 t0 += n_tokens_parsed;
3888 if (n_tokens != t0) {
3889 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3893 status = pipeline_table_rule_delete(pipeline_name,
3897 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3903 * pipeline <pipeline_name> table <table_id> rule delete
3908 cmd_pipeline_table_rule_delete_default(char **tokens,
3913 char *pipeline_name;
3917 if (n_tokens != 8) {
3918 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3922 pipeline_name = tokens[1];
3924 if (strcmp(tokens[2], "table") != 0) {
3925 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3929 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3930 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3934 if (strcmp(tokens[4], "rule") != 0) {
3935 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3939 if (strcmp(tokens[5], "delete") != 0) {
3940 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3944 if (strcmp(tokens[6], "match") != 0) {
3945 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3949 if (strcmp(tokens[7], "default") != 0) {
3950 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3954 status = pipeline_table_rule_delete_default(pipeline_name,
3957 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3963 * pipeline <pipeline_name> table <table_id> rule read stats [clear]
3966 cmd_pipeline_table_rule_stats_read(char **tokens,
3967 uint32_t n_tokens __rte_unused,
3971 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
3975 * pipeline <pipeline_name> table <table_id> meter profile <meter_profile_id>
3976 * add srtcm cir <cir> cbs <cbs> ebs <ebs>
3977 * | trtcm cir <cir> pir <pir> cbs <cbs> pbs <pbs>
3980 cmd_pipeline_table_meter_profile_add(char **tokens,
3985 struct rte_table_action_meter_profile p;
3986 char *pipeline_name;
3987 uint32_t table_id, meter_profile_id;
3991 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3995 pipeline_name = tokens[1];
3997 if (strcmp(tokens[2], "table") != 0) {
3998 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4002 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4003 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4007 if (strcmp(tokens[4], "meter") != 0) {
4008 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
4012 if (strcmp(tokens[5], "profile") != 0) {
4013 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
4017 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
4018 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
4022 if (strcmp(tokens[7], "add") != 0) {
4023 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
4027 if (strcmp(tokens[8], "srtcm") == 0) {
4028 if (n_tokens != 15) {
4029 snprintf(out, out_size, MSG_ARG_MISMATCH,
4034 p.alg = RTE_TABLE_ACTION_METER_SRTCM;
4036 if (strcmp(tokens[9], "cir") != 0) {
4037 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
4041 if (parser_read_uint64(&p.srtcm.cir, tokens[10]) != 0) {
4042 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
4046 if (strcmp(tokens[11], "cbs") != 0) {
4047 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
4051 if (parser_read_uint64(&p.srtcm.cbs, tokens[12]) != 0) {
4052 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
4056 if (strcmp(tokens[13], "ebs") != 0) {
4057 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "ebs");
4061 if (parser_read_uint64(&p.srtcm.ebs, tokens[14]) != 0) {
4062 snprintf(out, out_size, MSG_ARG_INVALID, "ebs");
4065 } else if (strcmp(tokens[8], "trtcm") == 0) {
4066 if (n_tokens != 17) {
4067 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4071 p.alg = RTE_TABLE_ACTION_METER_TRTCM;
4073 if (strcmp(tokens[9], "cir") != 0) {
4074 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
4078 if (parser_read_uint64(&p.trtcm.cir, tokens[10]) != 0) {
4079 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
4083 if (strcmp(tokens[11], "pir") != 0) {
4084 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pir");
4088 if (parser_read_uint64(&p.trtcm.pir, tokens[12]) != 0) {
4089 snprintf(out, out_size, MSG_ARG_INVALID, "pir");
4092 if (strcmp(tokens[13], "cbs") != 0) {
4093 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
4097 if (parser_read_uint64(&p.trtcm.cbs, tokens[14]) != 0) {
4098 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
4102 if (strcmp(tokens[15], "pbs") != 0) {
4103 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pbs");
4107 if (parser_read_uint64(&p.trtcm.pbs, tokens[16]) != 0) {
4108 snprintf(out, out_size, MSG_ARG_INVALID, "pbs");
4112 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4116 status = pipeline_table_mtr_profile_add(pipeline_name,
4121 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4127 * pipeline <pipeline_name> table <table_id>
4128 * meter profile <meter_profile_id> delete
4131 cmd_pipeline_table_meter_profile_delete(char **tokens,
4136 char *pipeline_name;
4137 uint32_t table_id, meter_profile_id;
4140 if (n_tokens != 8) {
4141 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4145 pipeline_name = tokens[1];
4147 if (strcmp(tokens[2], "table") != 0) {
4148 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4152 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4153 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4157 if (strcmp(tokens[4], "meter") != 0) {
4158 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
4162 if (strcmp(tokens[5], "profile") != 0) {
4163 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
4167 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
4168 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
4172 if (strcmp(tokens[7], "delete") != 0) {
4173 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
4177 status = pipeline_table_mtr_profile_delete(pipeline_name,
4181 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4187 * pipeline <pipeline_name> table <table_id> rule read meter [clear]
4190 cmd_pipeline_table_rule_meter_read(char **tokens,
4191 uint32_t n_tokens __rte_unused,
4195 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4199 * pipeline <pipeline_name> table <table_id> dscp <file_name>
4202 * - exactly 64 lines
4203 * - line format: <tc_id> <tc_queue_id> <color>, with <color> as: g | y | r
4206 load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
4207 const char *file_name,
4208 uint32_t *line_number)
4213 /* Check input arguments */
4214 if ((dscp_table == NULL) ||
4215 (file_name == NULL) ||
4216 (line_number == NULL)) {
4222 /* Open input file */
4223 f = fopen(file_name, "r");
4230 for (dscp = 0, l = 1; ; l++) {
4233 enum rte_meter_color color;
4234 uint32_t tc_id, tc_queue_id, n_tokens = RTE_DIM(tokens);
4236 if (fgets(line, sizeof(line), f) == NULL)
4239 if (is_comment(line))
4242 if (parse_tokenize_string(line, tokens, &n_tokens)) {
4251 if ((dscp >= RTE_DIM(dscp_table->entry)) ||
4252 (n_tokens != RTE_DIM(tokens)) ||
4253 parser_read_uint32(&tc_id, tokens[0]) ||
4254 (tc_id >= RTE_TABLE_ACTION_TC_MAX) ||
4255 parser_read_uint32(&tc_queue_id, tokens[1]) ||
4256 (tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) ||
4257 (strlen(tokens[2]) != 1)) {
4263 switch (tokens[2][0]) {
4266 color = e_RTE_METER_GREEN;
4271 color = e_RTE_METER_YELLOW;
4276 color = e_RTE_METER_RED;
4285 dscp_table->entry[dscp].tc_id = tc_id;
4286 dscp_table->entry[dscp].tc_queue_id = tc_queue_id;
4287 dscp_table->entry[dscp].color = color;
4297 cmd_pipeline_table_dscp(char **tokens,
4302 struct rte_table_action_dscp_table dscp_table;
4303 char *pipeline_name, *file_name;
4304 uint32_t table_id, line_number;
4307 if (n_tokens != 6) {
4308 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4312 pipeline_name = tokens[1];
4314 if (strcmp(tokens[2], "table") != 0) {
4315 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4319 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4320 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4324 if (strcmp(tokens[4], "dscp") != 0) {
4325 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dscp");
4329 file_name = tokens[5];
4331 status = load_dscp_table(&dscp_table, file_name, &line_number);
4333 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
4337 status = pipeline_table_dscp_table_update(pipeline_name,
4342 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4348 * pipeline <pipeline_name> table <table_id> rule read ttl [clear]
4351 cmd_pipeline_table_rule_ttl_read(char **tokens,
4352 uint32_t n_tokens __rte_unused,
4356 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4360 * thread <thread_id> pipeline <pipeline_name> enable
4363 cmd_thread_pipeline_enable(char **tokens,
4368 char *pipeline_name;
4372 if (n_tokens != 5) {
4373 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4377 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4378 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4382 if (strcmp(tokens[2], "pipeline") != 0) {
4383 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4387 pipeline_name = tokens[3];
4389 if (strcmp(tokens[4], "enable") != 0) {
4390 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
4394 status = thread_pipeline_enable(thread_id, pipeline_name);
4396 snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable");
4402 * thread <thread_id> pipeline <pipeline_name> disable
4405 cmd_thread_pipeline_disable(char **tokens,
4410 char *pipeline_name;
4414 if (n_tokens != 5) {
4415 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4419 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4420 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4424 if (strcmp(tokens[2], "pipeline") != 0) {
4425 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4429 pipeline_name = tokens[3];
4431 if (strcmp(tokens[4], "disable") != 0) {
4432 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
4436 status = thread_pipeline_disable(thread_id, pipeline_name);
4438 snprintf(out, out_size, MSG_CMD_FAIL,
4439 "thread pipeline disable");
4445 cli_process(char *in, char *out, size_t out_size)
4447 char *tokens[CMD_MAX_TOKENS];
4448 uint32_t n_tokens = RTE_DIM(tokens);
4454 status = parse_tokenize_string(in, tokens, &n_tokens);
4456 snprintf(out, out_size, MSG_ARG_TOO_MANY, "");
4463 if (strcmp(tokens[0], "mempool") == 0) {
4464 cmd_mempool(tokens, n_tokens, out, out_size);
4468 if (strcmp(tokens[0], "link") == 0) {
4469 if (strcmp(tokens[1], "show") == 0) {
4470 cmd_link_show(tokens, n_tokens, out, out_size);
4474 cmd_link(tokens, n_tokens, out, out_size);
4478 if (strcmp(tokens[0], "swq") == 0) {
4479 cmd_swq(tokens, n_tokens, out, out_size);
4483 if (strcmp(tokens[0], "tmgr") == 0) {
4484 if ((n_tokens >= 3) &&
4485 (strcmp(tokens[1], "subport") == 0) &&
4486 (strcmp(tokens[2], "profile") == 0)) {
4487 cmd_tmgr_subport_profile(tokens, n_tokens,
4492 if ((n_tokens >= 3) &&
4493 (strcmp(tokens[1], "pipe") == 0) &&
4494 (strcmp(tokens[2], "profile") == 0)) {
4495 cmd_tmgr_pipe_profile(tokens, n_tokens, out, out_size);
4499 if ((n_tokens >= 5) &&
4500 (strcmp(tokens[2], "subport") == 0) &&
4501 (strcmp(tokens[4], "profile") == 0)) {
4502 cmd_tmgr_subport(tokens, n_tokens, out, out_size);
4506 if ((n_tokens >= 5) &&
4507 (strcmp(tokens[2], "subport") == 0) &&
4508 (strcmp(tokens[4], "pipe") == 0)) {
4509 cmd_tmgr_subport_pipe(tokens, n_tokens, out, out_size);
4513 cmd_tmgr(tokens, n_tokens, out, out_size);
4517 if (strcmp(tokens[0], "tap") == 0) {
4518 cmd_tap(tokens, n_tokens, out, out_size);
4522 if (strcmp(tokens[0], "kni") == 0) {
4523 cmd_kni(tokens, n_tokens, out, out_size);
4527 if (strcmp(tokens[0], "port") == 0) {
4528 cmd_port_in_action_profile(tokens, n_tokens, out, out_size);
4532 if (strcmp(tokens[0], "table") == 0) {
4533 cmd_table_action_profile(tokens, n_tokens, out, out_size);
4537 if (strcmp(tokens[0], "pipeline") == 0) {
4538 if ((n_tokens >= 3) &&
4539 (strcmp(tokens[2], "period") == 0)) {
4540 cmd_pipeline(tokens, n_tokens, out, out_size);
4544 if ((n_tokens >= 5) &&
4545 (strcmp(tokens[2], "port") == 0) &&
4546 (strcmp(tokens[3], "in") == 0) &&
4547 (strcmp(tokens[4], "bsz") == 0)) {
4548 cmd_pipeline_port_in(tokens, n_tokens, out, out_size);
4552 if ((n_tokens >= 5) &&
4553 (strcmp(tokens[2], "port") == 0) &&
4554 (strcmp(tokens[3], "out") == 0) &&
4555 (strcmp(tokens[4], "bsz") == 0)) {
4556 cmd_pipeline_port_out(tokens, n_tokens, out, out_size);
4560 if ((n_tokens >= 4) &&
4561 (strcmp(tokens[2], "table") == 0) &&
4562 (strcmp(tokens[3], "match") == 0)) {
4563 cmd_pipeline_table(tokens, n_tokens, out, out_size);
4567 if ((n_tokens >= 6) &&
4568 (strcmp(tokens[2], "port") == 0) &&
4569 (strcmp(tokens[3], "in") == 0) &&
4570 (strcmp(tokens[5], "table") == 0)) {
4571 cmd_pipeline_port_in_table(tokens, n_tokens,
4576 if ((n_tokens >= 6) &&
4577 (strcmp(tokens[2], "port") == 0) &&
4578 (strcmp(tokens[3], "in") == 0) &&
4579 (strcmp(tokens[5], "stats") == 0)) {
4580 cmd_pipeline_port_in_stats(tokens, n_tokens,
4585 if ((n_tokens >= 6) &&
4586 (strcmp(tokens[2], "port") == 0) &&
4587 (strcmp(tokens[3], "in") == 0) &&
4588 (strcmp(tokens[5], "enable") == 0)) {
4589 cmd_pipeline_port_in_enable(tokens, n_tokens,
4594 if ((n_tokens >= 6) &&
4595 (strcmp(tokens[2], "port") == 0) &&
4596 (strcmp(tokens[3], "in") == 0) &&
4597 (strcmp(tokens[5], "disable") == 0)) {
4598 cmd_pipeline_port_in_disable(tokens, n_tokens,
4603 if ((n_tokens >= 6) &&
4604 (strcmp(tokens[2], "port") == 0) &&
4605 (strcmp(tokens[3], "out") == 0) &&
4606 (strcmp(tokens[5], "stats") == 0)) {
4607 cmd_pipeline_port_out_stats(tokens, n_tokens,
4612 if ((n_tokens >= 5) &&
4613 (strcmp(tokens[2], "table") == 0) &&
4614 (strcmp(tokens[4], "stats") == 0)) {
4615 cmd_pipeline_table_stats(tokens, n_tokens,
4620 if ((n_tokens >= 7) &&
4621 (strcmp(tokens[2], "table") == 0) &&
4622 (strcmp(tokens[4], "rule") == 0) &&
4623 (strcmp(tokens[5], "add") == 0) &&
4624 (strcmp(tokens[6], "match") == 0)) {
4625 if ((n_tokens >= 8) &&
4626 (strcmp(tokens[7], "default") == 0)) {
4627 cmd_pipeline_table_rule_add_default(tokens,
4628 n_tokens, out, out_size);
4632 cmd_pipeline_table_rule_add(tokens, n_tokens,
4637 if ((n_tokens >= 7) &&
4638 (strcmp(tokens[2], "table") == 0) &&
4639 (strcmp(tokens[4], "rule") == 0) &&
4640 (strcmp(tokens[5], "add") == 0) &&
4641 (strcmp(tokens[6], "bulk") == 0)) {
4642 cmd_pipeline_table_rule_add_bulk(tokens,
4643 n_tokens, out, out_size);
4647 if ((n_tokens >= 7) &&
4648 (strcmp(tokens[2], "table") == 0) &&
4649 (strcmp(tokens[4], "rule") == 0) &&
4650 (strcmp(tokens[5], "delete") == 0) &&
4651 (strcmp(tokens[6], "match") == 0)) {
4652 if ((n_tokens >= 8) &&
4653 (strcmp(tokens[7], "default") == 0)) {
4654 cmd_pipeline_table_rule_delete_default(tokens,
4655 n_tokens, out, out_size);
4659 cmd_pipeline_table_rule_delete(tokens, n_tokens,
4664 if ((n_tokens >= 7) &&
4665 (strcmp(tokens[2], "table") == 0) &&
4666 (strcmp(tokens[4], "rule") == 0) &&
4667 (strcmp(tokens[5], "read") == 0) &&
4668 (strcmp(tokens[6], "stats") == 0)) {
4669 cmd_pipeline_table_rule_stats_read(tokens, n_tokens,
4674 if ((n_tokens >= 8) &&
4675 (strcmp(tokens[2], "table") == 0) &&
4676 (strcmp(tokens[4], "meter") == 0) &&
4677 (strcmp(tokens[5], "profile") == 0) &&
4678 (strcmp(tokens[7], "add") == 0)) {
4679 cmd_pipeline_table_meter_profile_add(tokens, n_tokens,
4684 if ((n_tokens >= 8) &&
4685 (strcmp(tokens[2], "table") == 0) &&
4686 (strcmp(tokens[4], "meter") == 0) &&
4687 (strcmp(tokens[5], "profile") == 0) &&
4688 (strcmp(tokens[7], "delete") == 0)) {
4689 cmd_pipeline_table_meter_profile_delete(tokens,
4690 n_tokens, out, out_size);
4694 if ((n_tokens >= 7) &&
4695 (strcmp(tokens[2], "table") == 0) &&
4696 (strcmp(tokens[4], "rule") == 0) &&
4697 (strcmp(tokens[5], "read") == 0) &&
4698 (strcmp(tokens[6], "meter") == 0)) {
4699 cmd_pipeline_table_rule_meter_read(tokens, n_tokens,
4704 if ((n_tokens >= 5) &&
4705 (strcmp(tokens[2], "table") == 0) &&
4706 (strcmp(tokens[4], "dscp") == 0)) {
4707 cmd_pipeline_table_dscp(tokens, n_tokens,
4712 if ((n_tokens >= 7) &&
4713 (strcmp(tokens[2], "table") == 0) &&
4714 (strcmp(tokens[4], "rule") == 0) &&
4715 (strcmp(tokens[5], "read") == 0) &&
4716 (strcmp(tokens[6], "ttl") == 0)) {
4717 cmd_pipeline_table_rule_ttl_read(tokens, n_tokens,
4723 if (strcmp(tokens[0], "thread") == 0) {
4724 if ((n_tokens >= 5) &&
4725 (strcmp(tokens[4], "enable") == 0)) {
4726 cmd_thread_pipeline_enable(tokens, n_tokens,
4731 if ((n_tokens >= 5) &&
4732 (strcmp(tokens[4], "disable") == 0)) {
4733 cmd_thread_pipeline_disable(tokens, n_tokens,
4739 snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
4743 cli_script_process(const char *file_name,
4744 size_t msg_in_len_max,
4745 size_t msg_out_len_max)
4747 char *msg_in = NULL, *msg_out = NULL;
4750 /* Check input arguments */
4751 if ((file_name == NULL) ||
4752 (strlen(file_name) == 0) ||
4753 (msg_in_len_max == 0) ||
4754 (msg_out_len_max == 0))
4757 msg_in = malloc(msg_in_len_max + 1);
4758 msg_out = malloc(msg_out_len_max + 1);
4759 if ((msg_in == NULL) ||
4760 (msg_out == NULL)) {
4766 /* Open input file */
4767 f = fopen(file_name, "r");
4776 if (fgets(msg_in, msg_in_len_max + 1, f) == NULL)
4779 printf("%s", msg_in);
4786 if (strlen(msg_out))
4787 printf("%s", msg_out);
4798 cli_rule_file_process(const char *file_name,
4799 size_t line_len_max,
4800 struct table_rule_match *m,
4801 struct table_rule_action *a,
4803 uint32_t *line_number,
4809 uint32_t rule_id, line_id;
4812 /* Check input arguments */
4813 if ((file_name == NULL) ||
4814 (strlen(file_name) == 0) ||
4815 (line_len_max == 0)) {
4820 /* Memory allocation */
4821 line = malloc(line_len_max + 1);
4828 f = fopen(file_name, "r");
4836 for (line_id = 1, rule_id = 0; rule_id < *n_rules; line_id++) {
4837 char *tokens[CMD_MAX_TOKENS];
4838 uint32_t n_tokens, n_tokens_parsed, t0;
4840 /* Read next line from file. */
4841 if (fgets(line, line_len_max + 1, f) == NULL)
4845 if (is_comment(line))
4849 n_tokens = RTE_DIM(tokens);
4850 status = parse_tokenize_string(line, tokens, &n_tokens);
4862 n_tokens_parsed = parse_match(tokens + t0,
4867 if (n_tokens_parsed == 0) {
4871 t0 += n_tokens_parsed;
4874 n_tokens_parsed = parse_table_action(tokens + t0,
4879 if (n_tokens_parsed == 0) {
4883 t0 += n_tokens_parsed;
4885 /* Line completed. */
4886 if (t0 < n_tokens) {
4891 /* Increment rule count */
4902 *line_number = line_id;