1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
10 #include <rte_common.h>
11 #include <rte_cycles.h>
24 #ifndef CMD_MAX_TOKENS
25 #define CMD_MAX_TOKENS 256
28 #define MSG_OUT_OF_MEMORY "Not enough memory.\n"
29 #define MSG_CMD_UNKNOWN "Unknown command \"%s\".\n"
30 #define MSG_CMD_UNIMPLEM "Command \"%s\" not implemented.\n"
31 #define MSG_ARG_NOT_ENOUGH "Not enough arguments for command \"%s\".\n"
32 #define MSG_ARG_TOO_MANY "Too many arguments for command \"%s\".\n"
33 #define MSG_ARG_MISMATCH "Wrong number of arguments for command \"%s\".\n"
34 #define MSG_ARG_NOT_FOUND "Argument \"%s\" not found.\n"
35 #define MSG_ARG_INVALID "Invalid value for argument \"%s\".\n"
36 #define MSG_FILE_ERR "Error in file \"%s\" at line %u.\n"
37 #define MSG_FILE_NOT_ENOUGH "Not enough rules in file \"%s\".\n"
38 #define MSG_CMD_FAIL "Command \"%s\" failed.\n"
43 if ((strlen(in) && index("!#%;", in[0])) ||
44 (strncmp(in, "//", 2) == 0) ||
45 (strncmp(in, "--", 2) == 0))
52 * mempool <mempool_name>
53 * buffer <buffer_size>
59 cmd_mempool(char **tokens,
64 struct mempool_params p;
66 struct mempool *mempool;
69 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
75 if (strcmp(tokens[2], "buffer") != 0) {
76 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buffer");
80 if (parser_read_uint32(&p.buffer_size, tokens[3]) != 0) {
81 snprintf(out, out_size, MSG_ARG_INVALID, "buffer_size");
85 if (strcmp(tokens[4], "pool") != 0) {
86 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pool");
90 if (parser_read_uint32(&p.pool_size, tokens[5]) != 0) {
91 snprintf(out, out_size, MSG_ARG_INVALID, "pool_size");
95 if (strcmp(tokens[6], "cache") != 0) {
96 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cache");
100 if (parser_read_uint32(&p.cache_size, tokens[7]) != 0) {
101 snprintf(out, out_size, MSG_ARG_INVALID, "cache_size");
105 if (strcmp(tokens[8], "cpu") != 0) {
106 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
110 if (parser_read_uint32(&p.cpu_id, tokens[9]) != 0) {
111 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
115 mempool = mempool_create(name, &p);
116 if (mempool == NULL) {
117 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
124 * dev <device_name> | port <port_id>
125 * rxq <n_queues> <queue_size> <mempool_name>
126 * txq <n_queues> <queue_size>
127 * promiscuous on | off
128 * [rss <qid_0> ... <qid_n>]
131 cmd_link(char **tokens,
136 struct link_params p;
137 struct link_params_rss rss;
141 if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) {
142 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
147 if (strcmp(tokens[2], "dev") == 0)
148 p.dev_name = tokens[3];
149 else if (strcmp(tokens[2], "port") == 0) {
152 if (parser_read_uint16(&p.port_id, tokens[3]) != 0) {
153 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
157 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dev or port");
161 if (strcmp(tokens[4], "rxq") != 0) {
162 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
166 if (parser_read_uint32(&p.rx.n_queues, tokens[5]) != 0) {
167 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
170 if (parser_read_uint32(&p.rx.queue_size, tokens[6]) != 0) {
171 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
175 p.rx.mempool_name = tokens[7];
177 if (strcmp(tokens[8], "txq") != 0) {
178 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
182 if (parser_read_uint32(&p.tx.n_queues, tokens[9]) != 0) {
183 snprintf(out, out_size, MSG_ARG_INVALID, "n_queues");
187 if (parser_read_uint32(&p.tx.queue_size, tokens[10]) != 0) {
188 snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
192 if (strcmp(tokens[11], "promiscuous") != 0) {
193 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "promiscuous");
197 if (strcmp(tokens[12], "on") == 0)
199 else if (strcmp(tokens[12], "off") == 0)
202 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "on or off");
209 uint32_t queue_id, i;
211 if (strcmp(tokens[13], "rss") != 0) {
212 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rss");
219 for (i = 14; i < n_tokens; i++) {
220 if (parser_read_uint32(&queue_id, tokens[i]) != 0) {
221 snprintf(out, out_size, MSG_ARG_INVALID,
226 rss.queue_id[rss.n_queues] = queue_id;
231 link = link_create(name, &p);
233 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
244 cmd_swq(char **tokens,
254 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
260 if (strcmp(tokens[2], "size") != 0) {
261 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
265 if (parser_read_uint32(&p.size, tokens[3]) != 0) {
266 snprintf(out, out_size, MSG_ARG_INVALID, "size");
270 if (strcmp(tokens[4], "cpu") != 0) {
271 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
275 if (parser_read_uint32(&p.cpu_id, tokens[5]) != 0) {
276 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
280 swq = swq_create(name, &p);
282 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
288 * tmgr subport profile
289 * <tb_rate> <tb_size>
290 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
294 cmd_tmgr_subport_profile(char **tokens,
299 struct rte_sched_subport_params p;
302 if (n_tokens != 10) {
303 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
307 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
308 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
312 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
313 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
317 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
318 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
319 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
323 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
324 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
328 status = tmgr_subport_profile_add(&p);
330 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
337 * <tb_rate> <tb_size>
338 * <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>
344 cmd_tmgr_pipe_profile(char **tokens,
349 struct rte_sched_pipe_params p;
352 if (n_tokens != 27) {
353 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
357 if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
358 snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
362 if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
363 snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
367 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
368 if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
369 snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
373 if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
374 snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
378 #ifdef RTE_SCHED_SUBPORT_TC_OV
379 if (parser_read_uint8(&p.tc_ov_weight, tokens[10]) != 0) {
380 snprintf(out, out_size, MSG_ARG_INVALID, "tc_ov_weight");
385 for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++)
386 if (parser_read_uint8(&p.wrr_weights[i], tokens[11 + i]) != 0) {
387 snprintf(out, out_size, MSG_ARG_INVALID, "wrr_weights");
391 status = tmgr_pipe_profile_add(&p);
393 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
401 * spp <n_subports_per_port>
402 * pps <n_pipes_per_subport>
403 * qsize <qsize_tc0> <qsize_tc1> <qsize_tc2> <qsize_tc3>
404 * fo <frame_overhead>
409 cmd_tmgr(char **tokens,
414 struct tmgr_port_params p;
416 struct tmgr_port *tmgr_port;
419 if (n_tokens != 19) {
420 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
426 if (strcmp(tokens[2], "rate") != 0) {
427 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rate");
431 if (parser_read_uint32(&p.rate, tokens[3]) != 0) {
432 snprintf(out, out_size, MSG_ARG_INVALID, "rate");
436 if (strcmp(tokens[4], "spp") != 0) {
437 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
441 if (parser_read_uint32(&p.n_subports_per_port, tokens[5]) != 0) {
442 snprintf(out, out_size, MSG_ARG_INVALID, "n_subports_per_port");
446 if (strcmp(tokens[6], "pps") != 0) {
447 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
451 if (parser_read_uint32(&p.n_pipes_per_subport, tokens[7]) != 0) {
452 snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport");
456 if (strcmp(tokens[8], "qsize") != 0) {
457 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "qsize");
461 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
462 if (parser_read_uint16(&p.qsize[i], tokens[9 + i]) != 0) {
463 snprintf(out, out_size, MSG_ARG_INVALID, "qsize");
467 if (strcmp(tokens[13], "fo") != 0) {
468 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fo");
472 if (parser_read_uint32(&p.frame_overhead, tokens[14]) != 0) {
473 snprintf(out, out_size, MSG_ARG_INVALID, "frame_overhead");
477 if (strcmp(tokens[15], "mtu") != 0) {
478 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mtu");
482 if (parser_read_uint32(&p.mtu, tokens[16]) != 0) {
483 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
487 if (strcmp(tokens[17], "cpu") != 0) {
488 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
492 if (parser_read_uint32(&p.cpu_id, tokens[18]) != 0) {
493 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
497 tmgr_port = tmgr_port_create(name, &p);
498 if (tmgr_port == NULL) {
499 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
505 * tmgr <tmgr_name> subport <subport_id>
506 * profile <subport_profile_id>
509 cmd_tmgr_subport(char **tokens,
514 uint32_t subport_id, subport_profile_id;
519 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
525 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
526 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
530 if (parser_read_uint32(&subport_profile_id, tokens[5]) != 0) {
531 snprintf(out, out_size, MSG_ARG_INVALID, "subport_profile_id");
535 status = tmgr_subport_config(name, subport_id, subport_profile_id);
537 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
543 * tmgr <tmgr_name> subport <subport_id> pipe
544 * from <pipe_id_first> to <pipe_id_last>
545 * profile <pipe_profile_id>
548 cmd_tmgr_subport_pipe(char **tokens,
553 uint32_t subport_id, pipe_id_first, pipe_id_last, pipe_profile_id;
557 if (n_tokens != 11) {
558 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
564 if (parser_read_uint32(&subport_id, tokens[3]) != 0) {
565 snprintf(out, out_size, MSG_ARG_INVALID, "subport_id");
569 if (strcmp(tokens[4], "pipe") != 0) {
570 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipe");
574 if (strcmp(tokens[5], "from") != 0) {
575 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "from");
579 if (parser_read_uint32(&pipe_id_first, tokens[6]) != 0) {
580 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_first");
584 if (strcmp(tokens[7], "to") != 0) {
585 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "to");
589 if (parser_read_uint32(&pipe_id_last, tokens[8]) != 0) {
590 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_id_last");
594 if (strcmp(tokens[9], "profile") != 0) {
595 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
599 if (parser_read_uint32(&pipe_profile_id, tokens[10]) != 0) {
600 snprintf(out, out_size, MSG_ARG_INVALID, "pipe_profile_id");
604 status = tmgr_pipe_config(name, subport_id, pipe_id_first,
605 pipe_id_last, pipe_profile_id);
607 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
616 cmd_tap(char **tokens,
625 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
631 tap = tap_create(name);
633 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
641 * mempool <mempool_name>
642 * [thread <thread_id>]
645 cmd_kni(char **tokens,
654 if ((n_tokens != 6) && (n_tokens != 8)) {
655 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
661 if (strcmp(tokens[2], "link") != 0) {
662 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "link");
666 p.link_name = tokens[3];
668 if (strcmp(tokens[4], "mempool") != 0) {
669 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool");
673 p.mempool_name = tokens[5];
676 if (strcmp(tokens[6], "thread") != 0) {
677 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "thread");
681 if (parser_read_uint32(&p.thread_id, tokens[7]) != 0) {
682 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
690 kni = kni_create(name, &p);
692 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
698 * port in action profile <profile_name>
699 * [filter match | mismatch offset <key_offset> mask <key_mask> key <key_value> port <port_id>]
700 * [balance offset <key_offset> mask <key_mask> port <port_id0> ... <port_id15>]
703 cmd_port_in_action_profile(char **tokens,
708 struct port_in_action_profile_params p;
709 struct port_in_action_profile *ap;
713 memset(&p, 0, sizeof(p));
716 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
720 if (strcmp(tokens[1], "in") != 0) {
721 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
725 if (strcmp(tokens[2], "action") != 0) {
726 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
730 if (strcmp(tokens[3], "profile") != 0) {
731 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
739 if ((t0 < n_tokens) && (strcmp(tokens[t0], "filter") == 0)) {
742 if (n_tokens < t0 + 10) {
743 snprintf(out, out_size, MSG_ARG_MISMATCH, "port in action profile filter");
747 if (strcmp(tokens[t0 + 1], "match") == 0)
748 p.fltr.filter_on_match = 1;
749 else if (strcmp(tokens[t0 + 1], "mismatch") == 0)
750 p.fltr.filter_on_match = 0;
752 snprintf(out, out_size, MSG_ARG_INVALID, "match or mismatch");
756 if (strcmp(tokens[t0 + 2], "offset") != 0) {
757 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
761 if (parser_read_uint32(&p.fltr.key_offset, tokens[t0 + 3]) != 0) {
762 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
766 if (strcmp(tokens[t0 + 4], "mask") != 0) {
767 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
771 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
772 if ((parse_hex_string(tokens[t0 + 5], p.fltr.key_mask, &size) != 0) ||
773 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
774 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
778 if (strcmp(tokens[t0 + 6], "key") != 0) {
779 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
783 size = RTE_PORT_IN_ACTION_FLTR_KEY_SIZE;
784 if ((parse_hex_string(tokens[t0 + 7], p.fltr.key, &size) != 0) ||
785 (size != RTE_PORT_IN_ACTION_FLTR_KEY_SIZE)) {
786 snprintf(out, out_size, MSG_ARG_INVALID, "key_value");
790 if (strcmp(tokens[t0 + 8], "port") != 0) {
791 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
795 if (parser_read_uint32(&p.fltr.port_id, tokens[t0 + 9]) != 0) {
796 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
800 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_FLTR;
804 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
807 if (n_tokens < t0 + 22) {
808 snprintf(out, out_size, MSG_ARG_MISMATCH,
809 "port in action profile balance");
813 if (strcmp(tokens[t0 + 1], "offset") != 0) {
814 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
818 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
819 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
823 if (strcmp(tokens[t0 + 3], "mask") != 0) {
824 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
828 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
829 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
830 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
834 if (strcmp(tokens[t0 + 5], "port") != 0) {
835 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
839 for (i = 0; i < 16; i++)
840 if (parser_read_uint32(&p.lb.port_id[i], tokens[t0 + 6 + i]) != 0) {
841 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
845 p.action_mask |= 1LLU << RTE_PORT_IN_ACTION_LB;
850 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
854 ap = port_in_action_profile_create(name, &p);
856 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
862 * table action profile <profile_name>
866 * [balance offset <key_offset> mask <key_mask> outoffset <out_offset>]
867 * [meter srtcm | trtcm
869 * stats none | pkts | bytes | both]
870 * [tm spp <n_subports_per_port> pps <n_pipes_per_subport>]
871 * [encap ether | vlan | qinq | mpls | pppoe]
876 * [stats pkts | bytes | both]
880 cmd_table_action_profile(char **tokens,
885 struct table_action_profile_params p;
886 struct table_action_profile *ap;
890 memset(&p, 0, sizeof(p));
893 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
897 if (strcmp(tokens[1], "action") != 0) {
898 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "action");
902 if (strcmp(tokens[2], "profile") != 0) {
903 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
909 if (strcmp(tokens[4], "ipv4") == 0)
910 p.common.ip_version = 1;
911 else if (strcmp(tokens[4], "ipv6") == 0)
912 p.common.ip_version = 0;
914 snprintf(out, out_size, MSG_ARG_INVALID, "ipv4 or ipv6");
918 if (strcmp(tokens[5], "offset") != 0) {
919 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
923 if (parser_read_uint32(&p.common.ip_offset, tokens[6]) != 0) {
924 snprintf(out, out_size, MSG_ARG_INVALID, "ip_offset");
928 if (strcmp(tokens[7], "fwd") != 0) {
929 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fwd");
933 p.action_mask |= 1LLU << RTE_TABLE_ACTION_FWD;
936 if ((t0 < n_tokens) && (strcmp(tokens[t0], "balance") == 0)) {
937 if (n_tokens < t0 + 7) {
938 snprintf(out, out_size, MSG_ARG_MISMATCH, "table action profile balance");
942 if (strcmp(tokens[t0 + 1], "offset") != 0) {
943 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
947 if (parser_read_uint32(&p.lb.key_offset, tokens[t0 + 2]) != 0) {
948 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
952 if (strcmp(tokens[t0 + 3], "mask") != 0) {
953 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
957 p.lb.key_size = RTE_PORT_IN_ACTION_LB_KEY_SIZE_MAX;
958 if (parse_hex_string(tokens[t0 + 4], p.lb.key_mask, &p.lb.key_size) != 0) {
959 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
963 if (strcmp(tokens[t0 + 5], "outoffset") != 0) {
964 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "outoffset");
968 if (parser_read_uint32(&p.lb.out_offset, tokens[t0 + 6]) != 0) {
969 snprintf(out, out_size, MSG_ARG_INVALID, "out_offset");
973 p.action_mask |= 1LLU << RTE_TABLE_ACTION_LB;
977 if ((t0 < n_tokens) && (strcmp(tokens[t0], "meter") == 0)) {
978 if (n_tokens < t0 + 6) {
979 snprintf(out, out_size, MSG_ARG_MISMATCH,
980 "table action profile meter");
984 if (strcmp(tokens[t0 + 1], "srtcm") == 0)
985 p.mtr.alg = RTE_TABLE_ACTION_METER_SRTCM;
986 else if (strcmp(tokens[t0 + 1], "trtcm") == 0)
987 p.mtr.alg = RTE_TABLE_ACTION_METER_TRTCM;
989 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
994 if (strcmp(tokens[t0 + 2], "tc") != 0) {
995 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc");
999 if (parser_read_uint32(&p.mtr.n_tc, tokens[t0 + 3]) != 0) {
1000 snprintf(out, out_size, MSG_ARG_INVALID, "n_tc");
1004 if (strcmp(tokens[t0 + 4], "stats") != 0) {
1005 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1009 if (strcmp(tokens[t0 + 5], "none") == 0) {
1010 p.mtr.n_packets_enabled = 0;
1011 p.mtr.n_bytes_enabled = 0;
1012 } else if (strcmp(tokens[t0 + 5], "pkts") == 0) {
1013 p.mtr.n_packets_enabled = 1;
1014 p.mtr.n_bytes_enabled = 0;
1015 } else if (strcmp(tokens[t0 + 5], "bytes") == 0) {
1016 p.mtr.n_packets_enabled = 0;
1017 p.mtr.n_bytes_enabled = 1;
1018 } else if (strcmp(tokens[t0 + 5], "both") == 0) {
1019 p.mtr.n_packets_enabled = 1;
1020 p.mtr.n_bytes_enabled = 1;
1022 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1023 "none or pkts or bytes or both");
1027 p.action_mask |= 1LLU << RTE_TABLE_ACTION_MTR;
1031 if ((t0 < n_tokens) && (strcmp(tokens[t0], "tm") == 0)) {
1032 if (n_tokens < t0 + 5) {
1033 snprintf(out, out_size, MSG_ARG_MISMATCH,
1034 "table action profile tm");
1038 if (strcmp(tokens[t0 + 1], "spp") != 0) {
1039 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp");
1043 if (parser_read_uint32(&p.tm.n_subports_per_port,
1044 tokens[t0 + 2]) != 0) {
1045 snprintf(out, out_size, MSG_ARG_INVALID,
1046 "n_subports_per_port");
1050 if (strcmp(tokens[t0 + 3], "pps") != 0) {
1051 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
1055 if (parser_read_uint32(&p.tm.n_pipes_per_subport,
1056 tokens[t0 + 4]) != 0) {
1057 snprintf(out, out_size, MSG_ARG_INVALID,
1058 "n_pipes_per_subport");
1062 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TM;
1066 if ((t0 < n_tokens) && (strcmp(tokens[t0], "encap") == 0)) {
1067 if (n_tokens < t0 + 2) {
1068 snprintf(out, out_size, MSG_ARG_MISMATCH,
1069 "action profile encap");
1073 if (strcmp(tokens[t0 + 1], "ether") == 0)
1074 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER;
1075 else if (strcmp(tokens[t0 + 1], "vlan") == 0)
1076 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN;
1077 else if (strcmp(tokens[t0 + 1], "qinq") == 0)
1078 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ;
1079 else if (strcmp(tokens[t0 + 1], "mpls") == 0)
1080 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS;
1081 else if (strcmp(tokens[t0 + 1], "pppoe") == 0)
1082 p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE;
1084 snprintf(out, out_size, MSG_ARG_MISMATCH, "encap");
1088 p.action_mask |= 1LLU << RTE_TABLE_ACTION_ENCAP;
1092 if ((t0 < n_tokens) && (strcmp(tokens[t0], "nat") == 0)) {
1093 if (n_tokens < t0 + 4) {
1094 snprintf(out, out_size, MSG_ARG_MISMATCH,
1095 "table action profile nat");
1099 if (strcmp(tokens[t0 + 1], "src") == 0)
1100 p.nat.source_nat = 1;
1101 else if (strcmp(tokens[t0 + 1], "dst") == 0)
1102 p.nat.source_nat = 0;
1104 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1109 if (strcmp(tokens[t0 + 2], "proto") != 0) {
1110 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "proto");
1114 if (strcmp(tokens[t0 + 3], "tcp") == 0)
1116 else if (strcmp(tokens[t0 + 3], "udp") == 0)
1119 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1124 p.action_mask |= 1LLU << RTE_TABLE_ACTION_NAT;
1128 if ((t0 < n_tokens) && (strcmp(tokens[t0], "ttl") == 0)) {
1129 if (n_tokens < t0 + 4) {
1130 snprintf(out, out_size, MSG_ARG_MISMATCH,
1131 "table action profile ttl");
1135 if (strcmp(tokens[t0 + 1], "drop") == 0)
1137 else if (strcmp(tokens[t0 + 1], "fwd") == 0)
1140 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1145 if (strcmp(tokens[t0 + 2], "stats") != 0) {
1146 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
1150 if (strcmp(tokens[t0 + 3], "none") == 0)
1151 p.ttl.n_packets_enabled = 0;
1152 else if (strcmp(tokens[t0 + 3], "pkts") == 0)
1153 p.ttl.n_packets_enabled = 1;
1155 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1160 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TTL;
1164 if ((t0 < n_tokens) && (strcmp(tokens[t0], "stats") == 0)) {
1165 if (n_tokens < t0 + 2) {
1166 snprintf(out, out_size, MSG_ARG_MISMATCH,
1167 "table action profile stats");
1171 if (strcmp(tokens[t0 + 1], "pkts") == 0) {
1172 p.stats.n_packets_enabled = 1;
1173 p.stats.n_bytes_enabled = 0;
1174 } else if (strcmp(tokens[t0 + 1], "bytes") == 0) {
1175 p.stats.n_packets_enabled = 0;
1176 p.stats.n_bytes_enabled = 1;
1177 } else if (strcmp(tokens[t0 + 1], "both") == 0) {
1178 p.stats.n_packets_enabled = 1;
1179 p.stats.n_bytes_enabled = 1;
1181 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1182 "pkts or bytes or both");
1186 p.action_mask |= 1LLU << RTE_TABLE_ACTION_STATS;
1190 if ((t0 < n_tokens) && (strcmp(tokens[t0], "time") == 0)) {
1191 p.action_mask |= 1LLU << RTE_TABLE_ACTION_TIME;
1195 if (t0 < n_tokens) {
1196 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1200 ap = table_action_profile_create(name, &p);
1202 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1208 * pipeline <pipeline_name>
1209 * period <timer_period_ms>
1210 * offset_port_id <offset_port_id>
1214 cmd_pipeline(char **tokens,
1219 struct pipeline_params p;
1221 struct pipeline *pipeline;
1223 if (n_tokens != 8) {
1224 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1230 if (strcmp(tokens[2], "period") != 0) {
1231 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "period");
1235 if (parser_read_uint32(&p.timer_period_ms, tokens[3]) != 0) {
1236 snprintf(out, out_size, MSG_ARG_INVALID, "timer_period_ms");
1240 if (strcmp(tokens[4], "offset_port_id") != 0) {
1241 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset_port_id");
1245 if (parser_read_uint32(&p.offset_port_id, tokens[5]) != 0) {
1246 snprintf(out, out_size, MSG_ARG_INVALID, "offset_port_id");
1250 if (strcmp(tokens[6], "cpu") != 0) {
1251 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
1255 if (parser_read_uint32(&p.cpu_id, tokens[7]) != 0) {
1256 snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
1260 pipeline = pipeline_create(name, &p);
1261 if (pipeline == NULL) {
1262 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1268 * pipeline <pipeline_name> port in
1270 * link <link_name> rxq <queue_id>
1272 * | tmgr <tmgr_name>
1273 * | tap <tap_name> mempool <mempool_name> mtu <mtu>
1275 * | source mempool <mempool_name> file <file_name> bpp <n_bytes_per_pkt>
1276 * [action <port_in_action_profile_name>]
1280 cmd_pipeline_port_in(char **tokens,
1285 struct port_in_params p;
1286 char *pipeline_name;
1288 int enabled, status;
1291 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1295 pipeline_name = tokens[1];
1297 if (strcmp(tokens[2], "port") != 0) {
1298 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1302 if (strcmp(tokens[3], "in") != 0) {
1303 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1307 if (strcmp(tokens[4], "bsz") != 0) {
1308 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1312 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1313 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1319 if (strcmp(tokens[t0], "link") == 0) {
1320 if (n_tokens < t0 + 4) {
1321 snprintf(out, out_size, MSG_ARG_MISMATCH,
1322 "pipeline port in link");
1326 p.type = PORT_IN_RXQ;
1328 p.dev_name = tokens[t0 + 1];
1330 if (strcmp(tokens[t0 + 2], "rxq") != 0) {
1331 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
1335 if (parser_read_uint16(&p.rxq.queue_id, tokens[t0 + 3]) != 0) {
1336 snprintf(out, out_size, MSG_ARG_INVALID,
1341 } else if (strcmp(tokens[t0], "swq") == 0) {
1342 if (n_tokens < t0 + 2) {
1343 snprintf(out, out_size, MSG_ARG_MISMATCH,
1344 "pipeline port in swq");
1348 p.type = PORT_IN_SWQ;
1350 p.dev_name = tokens[t0 + 1];
1353 } else if (strcmp(tokens[t0], "tmgr") == 0) {
1354 if (n_tokens < t0 + 2) {
1355 snprintf(out, out_size, MSG_ARG_MISMATCH,
1356 "pipeline port in tmgr");
1360 p.type = PORT_IN_TMGR;
1362 p.dev_name = tokens[t0 + 1];
1365 } else if (strcmp(tokens[t0], "tap") == 0) {
1366 if (n_tokens < t0 + 6) {
1367 snprintf(out, out_size, MSG_ARG_MISMATCH,
1368 "pipeline port in tap");
1372 p.type = PORT_IN_TAP;
1374 p.dev_name = tokens[t0 + 1];
1376 if (strcmp(tokens[t0 + 2], "mempool") != 0) {
1377 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1382 p.tap.mempool_name = tokens[t0 + 3];
1384 if (strcmp(tokens[t0 + 4], "mtu") != 0) {
1385 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1390 if (parser_read_uint32(&p.tap.mtu, tokens[t0 + 5]) != 0) {
1391 snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
1396 } else if (strcmp(tokens[t0], "kni") == 0) {
1397 if (n_tokens < t0 + 2) {
1398 snprintf(out, out_size, MSG_ARG_MISMATCH,
1399 "pipeline port in kni");
1403 p.type = PORT_IN_KNI;
1405 p.dev_name = tokens[t0 + 1];
1408 } else if (strcmp(tokens[t0], "source") == 0) {
1409 if (n_tokens < t0 + 6) {
1410 snprintf(out, out_size, MSG_ARG_MISMATCH,
1411 "pipeline port in source");
1415 p.type = PORT_IN_SOURCE;
1419 if (strcmp(tokens[t0 + 1], "mempool") != 0) {
1420 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1425 p.source.mempool_name = tokens[t0 + 2];
1427 if (strcmp(tokens[t0 + 3], "file") != 0) {
1428 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1433 p.source.file_name = tokens[t0 + 4];
1435 if (strcmp(tokens[t0 + 5], "bpp") != 0) {
1436 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1441 if (parser_read_uint32(&p.source.n_bytes_per_pkt, tokens[t0 + 6]) != 0) {
1442 snprintf(out, out_size, MSG_ARG_INVALID,
1449 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1453 p.action_profile_name = NULL;
1454 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1455 if (n_tokens < t0 + 2) {
1456 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1460 p.action_profile_name = tokens[t0 + 1];
1466 if ((n_tokens > t0) &&
1467 (strcmp(tokens[t0], "disabled") == 0)) {
1473 if (n_tokens != t0) {
1474 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1478 status = pipeline_port_in_create(pipeline_name,
1481 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1487 * pipeline <pipeline_name> port out
1489 * link <link_name> txq <txq_id>
1491 * | tmgr <tmgr_name>
1494 * | sink [file <file_name> pkts <max_n_pkts>]
1497 cmd_pipeline_port_out(char **tokens,
1502 struct port_out_params p;
1503 char *pipeline_name;
1506 memset(&p, 0, sizeof(p));
1509 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1513 pipeline_name = tokens[1];
1515 if (strcmp(tokens[2], "port") != 0) {
1516 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1520 if (strcmp(tokens[3], "out") != 0) {
1521 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
1525 if (strcmp(tokens[4], "bsz") != 0) {
1526 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz");
1530 if (parser_read_uint32(&p.burst_size, tokens[5]) != 0) {
1531 snprintf(out, out_size, MSG_ARG_INVALID, "burst_size");
1535 if (strcmp(tokens[6], "link") == 0) {
1536 if (n_tokens != 10) {
1537 snprintf(out, out_size, MSG_ARG_MISMATCH,
1538 "pipeline port out link");
1542 p.type = PORT_OUT_TXQ;
1544 p.dev_name = tokens[7];
1546 if (strcmp(tokens[8], "txq") != 0) {
1547 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq");
1551 if (parser_read_uint16(&p.txq.queue_id, tokens[9]) != 0) {
1552 snprintf(out, out_size, MSG_ARG_INVALID, "queue_id");
1555 } else if (strcmp(tokens[6], "swq") == 0) {
1556 if (n_tokens != 8) {
1557 snprintf(out, out_size, MSG_ARG_MISMATCH,
1558 "pipeline port out swq");
1562 p.type = PORT_OUT_SWQ;
1564 p.dev_name = tokens[7];
1565 } else if (strcmp(tokens[6], "tmgr") == 0) {
1566 if (n_tokens != 8) {
1567 snprintf(out, out_size, MSG_ARG_MISMATCH,
1568 "pipeline port out tmgr");
1572 p.type = PORT_OUT_TMGR;
1574 p.dev_name = tokens[7];
1575 } else if (strcmp(tokens[6], "tap") == 0) {
1576 if (n_tokens != 8) {
1577 snprintf(out, out_size, MSG_ARG_MISMATCH,
1578 "pipeline port out tap");
1582 p.type = PORT_OUT_TAP;
1584 p.dev_name = tokens[7];
1585 } else if (strcmp(tokens[6], "kni") == 0) {
1586 if (n_tokens != 8) {
1587 snprintf(out, out_size, MSG_ARG_MISMATCH,
1588 "pipeline port out kni");
1592 p.type = PORT_OUT_KNI;
1594 p.dev_name = tokens[7];
1595 } else if (strcmp(tokens[6], "sink") == 0) {
1596 if ((n_tokens != 7) && (n_tokens != 11)) {
1597 snprintf(out, out_size, MSG_ARG_MISMATCH,
1598 "pipeline port out sink");
1602 p.type = PORT_OUT_SINK;
1606 if (n_tokens == 7) {
1607 p.sink.file_name = NULL;
1608 p.sink.max_n_pkts = 0;
1610 if (strcmp(tokens[7], "file") != 0) {
1611 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1616 p.sink.file_name = tokens[8];
1618 if (strcmp(tokens[9], "pkts") != 0) {
1619 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pkts");
1623 if (parser_read_uint32(&p.sink.max_n_pkts, tokens[10]) != 0) {
1624 snprintf(out, out_size, MSG_ARG_INVALID, "max_n_pkts");
1629 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1633 status = pipeline_port_out_create(pipeline_name, &p);
1635 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1641 * pipeline <pipeline_name> table
1645 * offset <ip_header_offset>
1648 * offset <key_offset>
1654 * offset <key_offset>
1655 * buckets <n_buckets>
1659 * offset <ip_header_offset>
1662 * [action <table_action_profile_name>]
1665 cmd_pipeline_table(char **tokens,
1670 uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX];
1671 struct table_params p;
1672 char *pipeline_name;
1677 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1681 pipeline_name = tokens[1];
1683 if (strcmp(tokens[2], "table") != 0) {
1684 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1688 if (strcmp(tokens[3], "match") != 0) {
1689 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
1694 if (strcmp(tokens[t0], "acl") == 0) {
1695 if (n_tokens < t0 + 6) {
1696 snprintf(out, out_size, MSG_ARG_MISMATCH,
1697 "pipeline table acl");
1701 p.match_type = TABLE_ACL;
1703 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1704 p.match.acl.ip_version = 1;
1705 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1706 p.match.acl.ip_version = 0;
1708 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1713 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1714 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1718 if (parser_read_uint32(&p.match.acl.ip_header_offset,
1719 tokens[t0 + 3]) != 0) {
1720 snprintf(out, out_size, MSG_ARG_INVALID,
1721 "ip_header_offset");
1725 if (strcmp(tokens[t0 + 4], "size") != 0) {
1726 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1730 if (parser_read_uint32(&p.match.acl.n_rules,
1731 tokens[t0 + 5]) != 0) {
1732 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1737 } else if (strcmp(tokens[t0], "array") == 0) {
1738 if (n_tokens < t0 + 5) {
1739 snprintf(out, out_size, MSG_ARG_MISMATCH,
1740 "pipeline table array");
1744 p.match_type = TABLE_ARRAY;
1746 if (strcmp(tokens[t0 + 1], "offset") != 0) {
1747 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1751 if (parser_read_uint32(&p.match.array.key_offset,
1752 tokens[t0 + 2]) != 0) {
1753 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1757 if (strcmp(tokens[t0 + 3], "size") != 0) {
1758 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1762 if (parser_read_uint32(&p.match.array.n_keys,
1763 tokens[t0 + 4]) != 0) {
1764 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1769 } else if (strcmp(tokens[t0], "hash") == 0) {
1770 uint32_t key_mask_size = TABLE_RULE_MATCH_SIZE_MAX;
1772 if (n_tokens < t0 + 12) {
1773 snprintf(out, out_size, MSG_ARG_MISMATCH,
1774 "pipeline table hash");
1778 p.match_type = TABLE_HASH;
1780 if (strcmp(tokens[t0 + 1], "ext") == 0)
1781 p.match.hash.extendable_bucket = 1;
1782 else if (strcmp(tokens[t0 + 1], "lru") == 0)
1783 p.match.hash.extendable_bucket = 0;
1785 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1790 if (strcmp(tokens[t0 + 2], "key") != 0) {
1791 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "key");
1795 if ((parser_read_uint32(&p.match.hash.key_size,
1796 tokens[t0 + 3]) != 0) ||
1797 (p.match.hash.key_size == 0) ||
1798 (p.match.hash.key_size > TABLE_RULE_MATCH_SIZE_MAX)) {
1799 snprintf(out, out_size, MSG_ARG_INVALID, "key_size");
1803 if (strcmp(tokens[t0 + 4], "mask") != 0) {
1804 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mask");
1808 if ((parse_hex_string(tokens[t0 + 5],
1809 key_mask, &key_mask_size) != 0) ||
1810 (key_mask_size != p.match.hash.key_size)) {
1811 snprintf(out, out_size, MSG_ARG_INVALID, "key_mask");
1814 p.match.hash.key_mask = key_mask;
1816 if (strcmp(tokens[t0 + 6], "offset") != 0) {
1817 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1821 if (parser_read_uint32(&p.match.hash.key_offset,
1822 tokens[t0 + 7]) != 0) {
1823 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1827 if (strcmp(tokens[t0 + 8], "buckets") != 0) {
1828 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buckets");
1832 if (parser_read_uint32(&p.match.hash.n_buckets,
1833 tokens[t0 + 9]) != 0) {
1834 snprintf(out, out_size, MSG_ARG_INVALID, "n_buckets");
1838 if (strcmp(tokens[t0 + 10], "size") != 0) {
1839 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1843 if (parser_read_uint32(&p.match.hash.n_keys,
1844 tokens[t0 + 11]) != 0) {
1845 snprintf(out, out_size, MSG_ARG_INVALID, "n_keys");
1850 } else if (strcmp(tokens[t0], "lpm") == 0) {
1851 if (n_tokens < t0 + 6) {
1852 snprintf(out, out_size, MSG_ARG_MISMATCH,
1853 "pipeline table lpm");
1857 p.match_type = TABLE_LPM;
1859 if (strcmp(tokens[t0 + 1], "ipv4") == 0)
1860 p.match.lpm.key_size = 4;
1861 else if (strcmp(tokens[t0 + 1], "ipv6") == 0)
1862 p.match.lpm.key_size = 16;
1864 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
1869 if (strcmp(tokens[t0 + 2], "offset") != 0) {
1870 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset");
1874 if (parser_read_uint32(&p.match.lpm.key_offset,
1875 tokens[t0 + 3]) != 0) {
1876 snprintf(out, out_size, MSG_ARG_INVALID, "key_offset");
1880 if (strcmp(tokens[t0 + 4], "size") != 0) {
1881 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
1885 if (parser_read_uint32(&p.match.lpm.n_rules,
1886 tokens[t0 + 5]) != 0) {
1887 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
1892 } else if (strcmp(tokens[t0], "stub") == 0) {
1893 if (n_tokens < t0 + 1) {
1894 snprintf(out, out_size, MSG_ARG_MISMATCH,
1895 "pipeline table stub");
1899 p.match_type = TABLE_STUB;
1903 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
1907 p.action_profile_name = NULL;
1908 if ((n_tokens > t0) && (strcmp(tokens[t0], "action") == 0)) {
1909 if (n_tokens < t0 + 2) {
1910 snprintf(out, out_size, MSG_ARG_MISMATCH, "action");
1914 p.action_profile_name = tokens[t0 + 1];
1919 if (n_tokens > t0) {
1920 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1924 status = pipeline_table_create(pipeline_name, &p);
1926 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1932 * pipeline <pipeline_name> port in <port_id> table <table_id>
1935 cmd_pipeline_port_in_table(char **tokens,
1940 char *pipeline_name;
1941 uint32_t port_id, table_id;
1944 if (n_tokens != 7) {
1945 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
1949 pipeline_name = tokens[1];
1951 if (strcmp(tokens[2], "port") != 0) {
1952 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
1956 if (strcmp(tokens[3], "in") != 0) {
1957 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
1961 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
1962 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
1966 if (strcmp(tokens[5], "table") != 0) {
1967 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
1971 if (parser_read_uint32(&table_id, tokens[6]) != 0) {
1972 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
1976 status = pipeline_port_in_connect_to_table(pipeline_name,
1980 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
1986 * pipeline <pipeline_name> port in <port_id> stats read [clear]
1989 #define MSG_PIPELINE_PORT_IN_STATS \
1990 "Pkts in: %" PRIu64 "\n" \
1991 "Pkts dropped by AH: %" PRIu64 "\n" \
1992 "Pkts dropped by other: %" PRIu64 "\n"
1995 cmd_pipeline_port_in_stats(char **tokens,
2000 struct rte_pipeline_port_in_stats stats;
2001 char *pipeline_name;
2005 if ((n_tokens != 7) && (n_tokens != 8)) {
2006 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2010 pipeline_name = tokens[1];
2012 if (strcmp(tokens[2], "port") != 0) {
2013 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2017 if (strcmp(tokens[3], "in") != 0) {
2018 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2022 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2023 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2027 if (strcmp(tokens[5], "stats") != 0) {
2028 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2032 if (strcmp(tokens[6], "read") != 0) {
2033 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2038 if (n_tokens == 8) {
2039 if (strcmp(tokens[7], "clear") != 0) {
2040 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2047 status = pipeline_port_in_stats_read(pipeline_name,
2052 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2056 snprintf(out, out_size, MSG_PIPELINE_PORT_IN_STATS,
2057 stats.stats.n_pkts_in,
2058 stats.n_pkts_dropped_by_ah,
2059 stats.stats.n_pkts_drop);
2063 * pipeline <pipeline_name> port in <port_id> enable
2066 cmd_pipeline_port_in_enable(char **tokens,
2071 char *pipeline_name;
2075 if (n_tokens != 6) {
2076 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2080 pipeline_name = tokens[1];
2082 if (strcmp(tokens[2], "port") != 0) {
2083 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2087 if (strcmp(tokens[3], "in") != 0) {
2088 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2092 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2093 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2097 if (strcmp(tokens[5], "enable") != 0) {
2098 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
2102 status = pipeline_port_in_enable(pipeline_name, port_id);
2104 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2110 * pipeline <pipeline_name> port in <port_id> disable
2113 cmd_pipeline_port_in_disable(char **tokens,
2118 char *pipeline_name;
2122 if (n_tokens != 6) {
2123 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2127 pipeline_name = tokens[1];
2129 if (strcmp(tokens[2], "port") != 0) {
2130 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2134 if (strcmp(tokens[3], "in") != 0) {
2135 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
2139 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2140 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2144 if (strcmp(tokens[5], "disable") != 0) {
2145 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
2149 status = pipeline_port_in_disable(pipeline_name, port_id);
2151 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2157 * pipeline <pipeline_name> port out <port_id> stats read [clear]
2159 #define MSG_PIPELINE_PORT_OUT_STATS \
2160 "Pkts in: %" PRIu64 "\n" \
2161 "Pkts dropped by AH: %" PRIu64 "\n" \
2162 "Pkts dropped by other: %" PRIu64 "\n"
2165 cmd_pipeline_port_out_stats(char **tokens,
2170 struct rte_pipeline_port_out_stats stats;
2171 char *pipeline_name;
2175 if ((n_tokens != 7) && (n_tokens != 8)) {
2176 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2180 pipeline_name = tokens[1];
2182 if (strcmp(tokens[2], "port") != 0) {
2183 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2187 if (strcmp(tokens[3], "out") != 0) {
2188 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
2192 if (parser_read_uint32(&port_id, tokens[4]) != 0) {
2193 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
2197 if (strcmp(tokens[5], "stats") != 0) {
2198 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2202 if (strcmp(tokens[6], "read") != 0) {
2203 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2208 if (n_tokens == 8) {
2209 if (strcmp(tokens[7], "clear") != 0) {
2210 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2217 status = pipeline_port_out_stats_read(pipeline_name,
2222 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2226 snprintf(out, out_size, MSG_PIPELINE_PORT_OUT_STATS,
2227 stats.stats.n_pkts_in,
2228 stats.n_pkts_dropped_by_ah,
2229 stats.stats.n_pkts_drop);
2233 * pipeline <pipeline_name> table <table_id> stats read [clear]
2235 #define MSG_PIPELINE_TABLE_STATS \
2236 "Pkts in: %" PRIu64 "\n" \
2237 "Pkts in with lookup miss: %" PRIu64 "\n" \
2238 "Pkts in with lookup hit dropped by AH: %" PRIu64 "\n" \
2239 "Pkts in with lookup hit dropped by others: %" PRIu64 "\n" \
2240 "Pkts in with lookup miss dropped by AH: %" PRIu64 "\n" \
2241 "Pkts in with lookup miss dropped by others: %" PRIu64 "\n"
2244 cmd_pipeline_table_stats(char **tokens,
2249 struct rte_pipeline_table_stats stats;
2250 char *pipeline_name;
2254 if ((n_tokens != 6) && (n_tokens != 7)) {
2255 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2259 pipeline_name = tokens[1];
2261 if (strcmp(tokens[2], "table") != 0) {
2262 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
2266 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
2267 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
2271 if (strcmp(tokens[4], "stats") != 0) {
2272 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
2276 if (strcmp(tokens[5], "read") != 0) {
2277 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
2282 if (n_tokens == 7) {
2283 if (strcmp(tokens[6], "clear") != 0) {
2284 snprintf(out, out_size, MSG_ARG_INVALID, "clear");
2291 status = pipeline_table_stats_read(pipeline_name,
2296 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
2300 snprintf(out, out_size, MSG_PIPELINE_TABLE_STATS,
2301 stats.stats.n_pkts_in,
2302 stats.stats.n_pkts_lookup_miss,
2303 stats.n_pkts_dropped_by_lkp_hit_ah,
2304 stats.n_pkts_dropped_lkp_hit,
2305 stats.n_pkts_dropped_by_lkp_miss_ah,
2306 stats.n_pkts_dropped_lkp_miss);
2314 * priority <priority>
2315 * ipv4 | ipv6 <sa> <sa_depth> <da> <da_depth>
2316 * <sp0> <sp1> <dp0> <dp1> <proto>
2320 * | ipv4_5tuple <sa> <da> <sp> <dp> <proto>
2321 * | ipv6_5tuple <sa> <da> <sp> <dp> <proto>
2322 * | ipv4_addr <addr>
2323 * | ipv6_addr <addr>
2324 * | qinq <svlan> <cvlan>
2326 * ipv4 | ipv6 <addr> <depth>
2328 struct pkt_key_qinq {
2329 uint16_t ethertype_svlan;
2331 uint16_t ethertype_cvlan;
2333 } __attribute__((__packed__));
2335 struct pkt_key_ipv4_5tuple {
2336 uint8_t time_to_live;
2338 uint16_t hdr_checksum;
2343 } __attribute__((__packed__));
2345 struct pkt_key_ipv6_5tuple {
2346 uint16_t payload_length;
2353 } __attribute__((__packed__));
2355 struct pkt_key_ipv4_addr {
2357 } __attribute__((__packed__));
2359 struct pkt_key_ipv6_addr {
2361 } __attribute__((__packed__));
2364 parse_match(char **tokens,
2368 struct table_rule_match *m)
2370 memset(m, 0, sizeof(*m));
2375 if (strcmp(tokens[0], "match") != 0) {
2376 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
2380 if (strcmp(tokens[1], "acl") == 0) {
2381 if (n_tokens < 14) {
2382 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2386 m->match_type = TABLE_ACL;
2388 if (strcmp(tokens[2], "priority") != 0) {
2389 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority");
2393 if (parser_read_uint32(&m->match.acl.priority,
2395 snprintf(out, out_size, MSG_ARG_INVALID, "priority");
2399 if (strcmp(tokens[4], "ipv4") == 0) {
2400 struct in_addr saddr, daddr;
2402 m->match.acl.ip_version = 1;
2404 if (parse_ipv4_addr(tokens[5], &saddr) != 0) {
2405 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2408 m->match.acl.ipv4.sa = rte_be_to_cpu_32(saddr.s_addr);
2410 if (parse_ipv4_addr(tokens[7], &daddr) != 0) {
2411 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2414 m->match.acl.ipv4.da = rte_be_to_cpu_32(daddr.s_addr);
2415 } else if (strcmp(tokens[4], "ipv6") == 0) {
2416 struct in6_addr saddr, daddr;
2418 m->match.acl.ip_version = 0;
2420 if (parse_ipv6_addr(tokens[5], &saddr) != 0) {
2421 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2424 memcpy(m->match.acl.ipv6.sa, saddr.s6_addr, 16);
2426 if (parse_ipv6_addr(tokens[7], &daddr) != 0) {
2427 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2430 memcpy(m->match.acl.ipv6.da, daddr.s6_addr, 16);
2432 snprintf(out, out_size, MSG_ARG_NOT_FOUND,
2437 if (parser_read_uint32(&m->match.acl.sa_depth,
2439 snprintf(out, out_size, MSG_ARG_INVALID, "sa_depth");
2443 if (parser_read_uint32(&m->match.acl.da_depth,
2445 snprintf(out, out_size, MSG_ARG_INVALID, "da_depth");
2449 if (parser_read_uint16(&m->match.acl.sp0, tokens[9]) != 0) {
2450 snprintf(out, out_size, MSG_ARG_INVALID, "sp0");
2454 if (parser_read_uint16(&m->match.acl.sp1, tokens[10]) != 0) {
2455 snprintf(out, out_size, MSG_ARG_INVALID, "sp1");
2459 if (parser_read_uint16(&m->match.acl.dp0, tokens[11]) != 0) {
2460 snprintf(out, out_size, MSG_ARG_INVALID, "dp0");
2464 if (parser_read_uint16(&m->match.acl.dp1, tokens[12]) != 0) {
2465 snprintf(out, out_size, MSG_ARG_INVALID, "dp1");
2469 if (parser_read_uint8(&m->match.acl.proto, tokens[13]) != 0) {
2470 snprintf(out, out_size, MSG_ARG_INVALID, "proto");
2474 m->match.acl.proto_mask = 0xff;
2479 if (strcmp(tokens[1], "array") == 0) {
2481 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2485 m->match_type = TABLE_ARRAY;
2487 if (parser_read_uint32(&m->match.array.pos, tokens[2]) != 0) {
2488 snprintf(out, out_size, MSG_ARG_INVALID, "pos");
2495 if (strcmp(tokens[1], "hash") == 0) {
2497 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2501 m->match_type = TABLE_HASH;
2503 if (strcmp(tokens[2], "raw") == 0) {
2504 uint32_t key_size = TABLE_RULE_MATCH_SIZE_MAX;
2507 snprintf(out, out_size, MSG_ARG_MISMATCH,
2512 if (parse_hex_string(tokens[3],
2513 m->match.hash.key, &key_size) != 0) {
2514 snprintf(out, out_size, MSG_ARG_INVALID, "key");
2521 if (strcmp(tokens[2], "ipv4_5tuple") == 0) {
2522 struct pkt_key_ipv4_5tuple *ipv4 =
2523 (struct pkt_key_ipv4_5tuple *) m->match.hash.key;
2524 struct in_addr saddr, daddr;
2529 snprintf(out, out_size, MSG_ARG_MISMATCH,
2534 if (parse_ipv4_addr(tokens[3], &saddr) != 0) {
2535 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2539 if (parse_ipv4_addr(tokens[4], &daddr) != 0) {
2540 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2544 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2545 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2549 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2550 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2554 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2555 snprintf(out, out_size, MSG_ARG_INVALID,
2560 ipv4->sa = saddr.s_addr;
2561 ipv4->da = daddr.s_addr;
2562 ipv4->sp = rte_cpu_to_be_16(sp);
2563 ipv4->dp = rte_cpu_to_be_16(dp);
2564 ipv4->proto = proto;
2567 } /* hash ipv4_5tuple */
2569 if (strcmp(tokens[2], "ipv6_5tuple") == 0) {
2570 struct pkt_key_ipv6_5tuple *ipv6 =
2571 (struct pkt_key_ipv6_5tuple *) m->match.hash.key;
2572 struct in6_addr saddr, daddr;
2577 snprintf(out, out_size, MSG_ARG_MISMATCH,
2582 if (parse_ipv6_addr(tokens[3], &saddr) != 0) {
2583 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2587 if (parse_ipv6_addr(tokens[4], &daddr) != 0) {
2588 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2592 if (parser_read_uint16(&sp, tokens[5]) != 0) {
2593 snprintf(out, out_size, MSG_ARG_INVALID, "sp");
2597 if (parser_read_uint16(&dp, tokens[6]) != 0) {
2598 snprintf(out, out_size, MSG_ARG_INVALID, "dp");
2602 if (parser_read_uint8(&proto, tokens[7]) != 0) {
2603 snprintf(out, out_size, MSG_ARG_INVALID,
2608 memcpy(ipv6->sa, saddr.s6_addr, 16);
2609 memcpy(ipv6->da, daddr.s6_addr, 16);
2610 ipv6->sp = rte_cpu_to_be_16(sp);
2611 ipv6->dp = rte_cpu_to_be_16(dp);
2612 ipv6->proto = proto;
2615 } /* hash ipv6_5tuple */
2617 if (strcmp(tokens[2], "ipv4_addr") == 0) {
2618 struct pkt_key_ipv4_addr *ipv4_addr =
2619 (struct pkt_key_ipv4_addr *) m->match.hash.key;
2620 struct in_addr addr;
2623 snprintf(out, out_size, MSG_ARG_MISMATCH,
2628 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2629 snprintf(out, out_size, MSG_ARG_INVALID,
2634 ipv4_addr->addr = addr.s_addr;
2637 } /* hash ipv4_addr */
2639 if (strcmp(tokens[2], "ipv6_addr") == 0) {
2640 struct pkt_key_ipv6_addr *ipv6_addr =
2641 (struct pkt_key_ipv6_addr *) m->match.hash.key;
2642 struct in6_addr addr;
2645 snprintf(out, out_size, MSG_ARG_MISMATCH,
2650 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2651 snprintf(out, out_size, MSG_ARG_INVALID,
2656 memcpy(ipv6_addr->addr, addr.s6_addr, 16);
2659 } /* hash ipv6_5tuple */
2661 if (strcmp(tokens[2], "qinq") == 0) {
2662 struct pkt_key_qinq *qinq =
2663 (struct pkt_key_qinq *) m->match.hash.key;
2664 uint16_t svlan, cvlan;
2667 snprintf(out, out_size, MSG_ARG_MISMATCH,
2672 if ((parser_read_uint16(&svlan, tokens[3]) != 0) ||
2674 snprintf(out, out_size, MSG_ARG_INVALID,
2679 if ((parser_read_uint16(&cvlan, tokens[4]) != 0) ||
2681 snprintf(out, out_size, MSG_ARG_INVALID,
2686 qinq->svlan = rte_cpu_to_be_16(svlan);
2687 qinq->cvlan = rte_cpu_to_be_16(cvlan);
2692 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2696 if (strcmp(tokens[1], "lpm") == 0) {
2698 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2702 m->match_type = TABLE_LPM;
2704 if (strcmp(tokens[2], "ipv4") == 0) {
2705 struct in_addr addr;
2707 m->match.lpm.ip_version = 1;
2709 if (parse_ipv4_addr(tokens[3], &addr) != 0) {
2710 snprintf(out, out_size, MSG_ARG_INVALID,
2715 m->match.lpm.ipv4 = rte_be_to_cpu_32(addr.s_addr);
2716 } else if (strcmp(tokens[2], "ipv6") == 0) {
2717 struct in6_addr addr;
2719 m->match.lpm.ip_version = 0;
2721 if (parse_ipv6_addr(tokens[3], &addr) != 0) {
2722 snprintf(out, out_size, MSG_ARG_INVALID,
2727 memcpy(m->match.lpm.ipv6, addr.s6_addr, 16);
2729 snprintf(out, out_size, MSG_ARG_MISMATCH,
2734 if (parser_read_uint8(&m->match.lpm.depth, tokens[4]) != 0) {
2735 snprintf(out, out_size, MSG_ARG_INVALID, "depth");
2742 snprintf(out, out_size, MSG_ARG_MISMATCH,
2743 "acl or array or hash or lpm");
2755 * | table <table_id>
2756 * [balance <out0> ... <out7>]
2758 * tc0 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2759 * [tc1 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2760 * tc2 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
2761 * tc3 meter <meter_profile_id> policer g <pa> y <pa> r <pa>]]
2762 * [tm subport <subport_id> pipe <pipe_id>]
2765 * | vlan <da> <sa> <pcp> <dei> <vid>
2766 * | qinq <da> <sa> <pcp> <dei> <vid> <pcp> <dei> <vid>
2767 * | mpls unicast | multicast
2769 * label0 <label> <tc> <ttl>
2770 * [label1 <label> <tc> <ttl>
2771 * [label2 <label> <tc> <ttl>
2772 * [label3 <label> <tc> <ttl>]]]
2773 * | pppoe <da> <sa> <session_id>]
2774 * [nat ipv4 | ipv6 <addr> <port>]
2780 * <pa> ::= g | y | r | drop
2783 parse_table_action_fwd(char **tokens,
2785 struct table_rule_action *a)
2787 if ((n_tokens == 0) || (strcmp(tokens[0], "fwd") != 0))
2793 if (n_tokens && (strcmp(tokens[0], "drop") == 0)) {
2794 a->fwd.action = RTE_PIPELINE_ACTION_DROP;
2795 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2799 if (n_tokens && (strcmp(tokens[0], "port") == 0)) {
2802 if ((n_tokens < 2) ||
2803 parser_read_uint32(&id, tokens[1]))
2806 a->fwd.action = RTE_PIPELINE_ACTION_PORT;
2808 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2812 if (n_tokens && (strcmp(tokens[0], "meta") == 0)) {
2813 a->fwd.action = RTE_PIPELINE_ACTION_PORT_META;
2814 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2818 if (n_tokens && (strcmp(tokens[0], "table") == 0)) {
2821 if ((n_tokens < 2) ||
2822 parser_read_uint32(&id, tokens[1]))
2825 a->fwd.action = RTE_PIPELINE_ACTION_TABLE;
2827 a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
2835 parse_table_action_balance(char **tokens,
2837 struct table_rule_action *a)
2841 if ((n_tokens == 0) || (strcmp(tokens[0], "balance") != 0))
2847 if (n_tokens < RTE_TABLE_ACTION_LB_TABLE_SIZE)
2850 for (i = 0; i < RTE_TABLE_ACTION_LB_TABLE_SIZE; i++)
2851 if (parser_read_uint32(&a->lb.out[i], tokens[i]) != 0)
2854 a->action_mask |= 1 << RTE_TABLE_ACTION_LB;
2855 return 1 + RTE_TABLE_ACTION_LB_TABLE_SIZE;
2860 parse_policer_action(char *token, enum rte_table_action_policer *a)
2862 if (strcmp(token, "g") == 0) {
2863 *a = RTE_TABLE_ACTION_POLICER_COLOR_GREEN;
2867 if (strcmp(token, "y") == 0) {
2868 *a = RTE_TABLE_ACTION_POLICER_COLOR_YELLOW;
2872 if (strcmp(token, "r") == 0) {
2873 *a = RTE_TABLE_ACTION_POLICER_COLOR_RED;
2877 if (strcmp(token, "drop") == 0) {
2878 *a = RTE_TABLE_ACTION_POLICER_DROP;
2886 parse_table_action_meter_tc(char **tokens,
2888 struct rte_table_action_mtr_tc_params *mtr)
2890 if ((n_tokens < 9) ||
2891 strcmp(tokens[0], "meter") ||
2892 parser_read_uint32(&mtr->meter_profile_id, tokens[1]) ||
2893 strcmp(tokens[2], "policer") ||
2894 strcmp(tokens[3], "g") ||
2895 parse_policer_action(tokens[4], &mtr->policer[e_RTE_METER_GREEN]) ||
2896 strcmp(tokens[5], "y") ||
2897 parse_policer_action(tokens[6], &mtr->policer[e_RTE_METER_YELLOW]) ||
2898 strcmp(tokens[7], "r") ||
2899 parse_policer_action(tokens[8], &mtr->policer[e_RTE_METER_RED]))
2906 parse_table_action_meter(char **tokens,
2908 struct table_rule_action *a)
2910 if ((n_tokens == 0) || strcmp(tokens[0], "meter"))
2916 if ((n_tokens < 10) ||
2917 strcmp(tokens[0], "tc0") ||
2918 (parse_table_action_meter_tc(tokens + 1,
2920 &a->mtr.mtr[0]) == 0))
2926 if ((n_tokens == 0) || strcmp(tokens[0], "tc1")) {
2928 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
2932 if ((n_tokens < 30) ||
2933 (parse_table_action_meter_tc(tokens + 1,
2934 n_tokens - 1, &a->mtr.mtr[1]) == 0) ||
2935 strcmp(tokens[10], "tc2") ||
2936 (parse_table_action_meter_tc(tokens + 11,
2937 n_tokens - 11, &a->mtr.mtr[2]) == 0) ||
2938 strcmp(tokens[20], "tc3") ||
2939 (parse_table_action_meter_tc(tokens + 21,
2940 n_tokens - 21, &a->mtr.mtr[3]) == 0))
2943 a->mtr.tc_mask = 0xF;
2944 a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
2945 return 1 + 10 + 3 * 10;
2949 parse_table_action_tm(char **tokens,
2951 struct table_rule_action *a)
2953 uint32_t subport_id, pipe_id;
2955 if ((n_tokens < 5) ||
2956 strcmp(tokens[0], "tm") ||
2957 strcmp(tokens[1], "subport") ||
2958 parser_read_uint32(&subport_id, tokens[2]) ||
2959 strcmp(tokens[3], "pipe") ||
2960 parser_read_uint32(&pipe_id, tokens[4]))
2963 a->tm.subport_id = subport_id;
2964 a->tm.pipe_id = pipe_id;
2965 a->action_mask |= 1 << RTE_TABLE_ACTION_TM;
2970 parse_table_action_encap(char **tokens,
2972 struct table_rule_action *a)
2974 if ((n_tokens == 0) || strcmp(tokens[0], "encap"))
2981 if (n_tokens && (strcmp(tokens[0], "ether") == 0)) {
2982 if ((n_tokens < 3) ||
2983 parse_mac_addr(tokens[1], &a->encap.ether.ether.da) ||
2984 parse_mac_addr(tokens[2], &a->encap.ether.ether.sa))
2987 a->encap.type = RTE_TABLE_ACTION_ENCAP_ETHER;
2988 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
2993 if (n_tokens && (strcmp(tokens[0], "vlan") == 0)) {
2994 uint32_t pcp, dei, vid;
2996 if ((n_tokens < 6) ||
2997 parse_mac_addr(tokens[1], &a->encap.vlan.ether.da) ||
2998 parse_mac_addr(tokens[2], &a->encap.vlan.ether.sa) ||
2999 parser_read_uint32(&pcp, tokens[3]) ||
3001 parser_read_uint32(&dei, tokens[4]) ||
3003 parser_read_uint32(&vid, tokens[5]) ||
3007 a->encap.vlan.vlan.pcp = pcp & 0x7;
3008 a->encap.vlan.vlan.dei = dei & 0x1;
3009 a->encap.vlan.vlan.vid = vid & 0xFFF;
3010 a->encap.type = RTE_TABLE_ACTION_ENCAP_VLAN;
3011 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3016 if (n_tokens && (strcmp(tokens[0], "qinq") == 0)) {
3017 uint32_t svlan_pcp, svlan_dei, svlan_vid;
3018 uint32_t cvlan_pcp, cvlan_dei, cvlan_vid;
3020 if ((n_tokens < 9) ||
3021 parse_mac_addr(tokens[1], &a->encap.qinq.ether.da) ||
3022 parse_mac_addr(tokens[2], &a->encap.qinq.ether.sa) ||
3023 parser_read_uint32(&svlan_pcp, tokens[3]) ||
3024 (svlan_pcp > 0x7) ||
3025 parser_read_uint32(&svlan_dei, tokens[4]) ||
3026 (svlan_dei > 0x1) ||
3027 parser_read_uint32(&svlan_vid, tokens[5]) ||
3028 (svlan_vid > 0xFFF) ||
3029 parser_read_uint32(&cvlan_pcp, tokens[6]) ||
3030 (cvlan_pcp > 0x7) ||
3031 parser_read_uint32(&cvlan_dei, tokens[7]) ||
3032 (cvlan_dei > 0x1) ||
3033 parser_read_uint32(&cvlan_vid, tokens[8]) ||
3034 (cvlan_vid > 0xFFF))
3037 a->encap.qinq.svlan.pcp = svlan_pcp & 0x7;
3038 a->encap.qinq.svlan.dei = svlan_dei & 0x1;
3039 a->encap.qinq.svlan.vid = svlan_vid & 0xFFF;
3040 a->encap.qinq.cvlan.pcp = cvlan_pcp & 0x7;
3041 a->encap.qinq.cvlan.dei = cvlan_dei & 0x1;
3042 a->encap.qinq.cvlan.vid = cvlan_vid & 0xFFF;
3043 a->encap.type = RTE_TABLE_ACTION_ENCAP_QINQ;
3044 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3049 if (n_tokens && (strcmp(tokens[0], "mpls") == 0)) {
3050 uint32_t label, tc, ttl;
3055 if (strcmp(tokens[1], "unicast") == 0)
3056 a->encap.mpls.unicast = 1;
3057 else if (strcmp(tokens[1], "multicast") == 0)
3058 a->encap.mpls.unicast = 0;
3062 if (parse_mac_addr(tokens[2], &a->encap.mpls.ether.da) ||
3063 parse_mac_addr(tokens[3], &a->encap.mpls.ether.sa) ||
3064 strcmp(tokens[4], "label0") ||
3065 parser_read_uint32(&label, tokens[5]) ||
3066 (label > 0xFFFFF) ||
3067 parser_read_uint32(&tc, tokens[6]) ||
3069 parser_read_uint32(&ttl, tokens[7]) ||
3073 a->encap.mpls.mpls[0].label = label;
3074 a->encap.mpls.mpls[0].tc = tc;
3075 a->encap.mpls.mpls[0].ttl = ttl;
3080 if ((n_tokens == 0) || strcmp(tokens[0], "label1")) {
3081 a->encap.mpls.mpls_count = 1;
3082 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3083 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3087 if ((n_tokens < 4) ||
3088 parser_read_uint32(&label, tokens[1]) ||
3089 (label > 0xFFFFF) ||
3090 parser_read_uint32(&tc, tokens[2]) ||
3092 parser_read_uint32(&ttl, tokens[3]) ||
3096 a->encap.mpls.mpls[1].label = label;
3097 a->encap.mpls.mpls[1].tc = tc;
3098 a->encap.mpls.mpls[1].ttl = ttl;
3103 if ((n_tokens == 0) || strcmp(tokens[0], "label2")) {
3104 a->encap.mpls.mpls_count = 2;
3105 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3106 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3110 if ((n_tokens < 4) ||
3111 parser_read_uint32(&label, tokens[1]) ||
3112 (label > 0xFFFFF) ||
3113 parser_read_uint32(&tc, tokens[2]) ||
3115 parser_read_uint32(&ttl, tokens[3]) ||
3119 a->encap.mpls.mpls[2].label = label;
3120 a->encap.mpls.mpls[2].tc = tc;
3121 a->encap.mpls.mpls[2].ttl = ttl;
3126 if ((n_tokens == 0) || strcmp(tokens[0], "label3")) {
3127 a->encap.mpls.mpls_count = 3;
3128 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3129 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3130 return 1 + 8 + 4 + 4;
3133 if ((n_tokens < 4) ||
3134 parser_read_uint32(&label, tokens[1]) ||
3135 (label > 0xFFFFF) ||
3136 parser_read_uint32(&tc, tokens[2]) ||
3138 parser_read_uint32(&ttl, tokens[3]) ||
3142 a->encap.mpls.mpls[3].label = label;
3143 a->encap.mpls.mpls[3].tc = tc;
3144 a->encap.mpls.mpls[3].ttl = ttl;
3146 a->encap.mpls.mpls_count = 4;
3147 a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
3148 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3149 return 1 + 8 + 4 + 4 + 4;
3153 if (n_tokens && (strcmp(tokens[0], "pppoe") == 0)) {
3154 if ((n_tokens < 4) ||
3155 parse_mac_addr(tokens[1], &a->encap.pppoe.ether.da) ||
3156 parse_mac_addr(tokens[2], &a->encap.pppoe.ether.sa) ||
3157 parser_read_uint16(&a->encap.pppoe.pppoe.session_id,
3161 a->encap.type = RTE_TABLE_ACTION_ENCAP_PPPOE;
3162 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3170 parse_table_action_nat(char **tokens,
3172 struct table_rule_action *a)
3174 if ((n_tokens < 4) ||
3175 strcmp(tokens[0], "nat"))
3178 if (strcmp(tokens[1], "ipv4") == 0) {
3179 struct in_addr addr;
3182 if (parse_ipv4_addr(tokens[2], &addr) ||
3183 parser_read_uint16(&port, tokens[3]))
3186 a->nat.ip_version = 1;
3187 a->nat.addr.ipv4 = rte_be_to_cpu_32(addr.s_addr);
3189 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3193 if (strcmp(tokens[1], "ipv6") == 0) {
3194 struct in6_addr addr;
3197 if (parse_ipv6_addr(tokens[2], &addr) ||
3198 parser_read_uint16(&port, tokens[3]))
3201 a->nat.ip_version = 0;
3202 memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
3204 a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
3212 parse_table_action_ttl(char **tokens,
3214 struct table_rule_action *a)
3216 if ((n_tokens < 2) ||
3217 strcmp(tokens[0], "ttl"))
3220 if (strcmp(tokens[1], "dec") == 0)
3221 a->ttl.decrement = 1;
3222 else if (strcmp(tokens[1], "keep") == 0)
3223 a->ttl.decrement = 0;
3227 a->action_mask |= 1 << RTE_TABLE_ACTION_TTL;
3232 parse_table_action_stats(char **tokens,
3234 struct table_rule_action *a)
3236 if ((n_tokens < 1) ||
3237 strcmp(tokens[0], "stats"))
3240 a->stats.n_packets = 0;
3241 a->stats.n_bytes = 0;
3242 a->action_mask |= 1 << RTE_TABLE_ACTION_STATS;
3247 parse_table_action_time(char **tokens,
3249 struct table_rule_action *a)
3251 if ((n_tokens < 1) ||
3252 strcmp(tokens[0], "time"))
3255 a->time.time = rte_rdtsc();
3256 a->action_mask |= 1 << RTE_TABLE_ACTION_TIME;
3261 parse_table_action(char **tokens,
3265 struct table_rule_action *a)
3267 uint32_t n_tokens0 = n_tokens;
3269 memset(a, 0, sizeof(*a));
3271 if ((n_tokens < 2) ||
3272 strcmp(tokens[0], "action"))
3278 if (n_tokens && (strcmp(tokens[0], "fwd") == 0)) {
3281 n = parse_table_action_fwd(tokens, n_tokens, a);
3283 snprintf(out, out_size, MSG_ARG_INVALID,
3292 if (n_tokens && (strcmp(tokens[0], "balance") == 0)) {
3295 n = parse_table_action_balance(tokens, n_tokens, a);
3297 snprintf(out, out_size, MSG_ARG_INVALID,
3306 if (n_tokens && (strcmp(tokens[0], "meter") == 0)) {
3309 n = parse_table_action_meter(tokens, n_tokens, a);
3311 snprintf(out, out_size, MSG_ARG_INVALID,
3320 if (n_tokens && (strcmp(tokens[0], "tm") == 0)) {
3323 n = parse_table_action_tm(tokens, n_tokens, a);
3325 snprintf(out, out_size, MSG_ARG_INVALID,
3334 if (n_tokens && (strcmp(tokens[0], "encap") == 0)) {
3337 n = parse_table_action_encap(tokens, n_tokens, a);
3339 snprintf(out, out_size, MSG_ARG_INVALID,
3348 if (n_tokens && (strcmp(tokens[0], "nat") == 0)) {
3351 n = parse_table_action_nat(tokens, n_tokens, a);
3353 snprintf(out, out_size, MSG_ARG_INVALID,
3362 if (n_tokens && (strcmp(tokens[0], "ttl") == 0)) {
3365 n = parse_table_action_ttl(tokens, n_tokens, a);
3367 snprintf(out, out_size, MSG_ARG_INVALID,
3376 if (n_tokens && (strcmp(tokens[0], "stats") == 0)) {
3379 n = parse_table_action_stats(tokens, n_tokens, a);
3381 snprintf(out, out_size, MSG_ARG_INVALID,
3390 if (n_tokens && (strcmp(tokens[0], "time") == 0)) {
3393 n = parse_table_action_time(tokens, n_tokens, a);
3395 snprintf(out, out_size, MSG_ARG_INVALID,
3404 if (n_tokens0 - n_tokens == 1) {
3405 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3409 return n_tokens0 - n_tokens;
3413 * pipeline <pipeline_name> table <table_id> rule add
3415 * action <table_action>
3418 cmd_pipeline_table_rule_add(char **tokens,
3423 struct table_rule_match m;
3424 struct table_rule_action a;
3425 char *pipeline_name;
3427 uint32_t table_id, t0, n_tokens_parsed;
3431 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3435 pipeline_name = tokens[1];
3437 if (strcmp(tokens[2], "table") != 0) {
3438 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3442 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3443 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3447 if (strcmp(tokens[4], "rule") != 0) {
3448 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3452 if (strcmp(tokens[5], "add") != 0) {
3453 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3460 n_tokens_parsed = parse_match(tokens + t0,
3465 if (n_tokens_parsed == 0)
3467 t0 += n_tokens_parsed;
3470 n_tokens_parsed = parse_table_action(tokens + t0,
3475 if (n_tokens_parsed == 0)
3477 t0 += n_tokens_parsed;
3479 if (t0 != n_tokens) {
3480 snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
3484 status = pipeline_table_rule_add(pipeline_name, table_id,
3487 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3493 * pipeline <pipeline_name> table <table_id> rule add
3501 * | table <table_id>
3504 cmd_pipeline_table_rule_add_default(char **tokens,
3509 struct table_rule_action action;
3511 char *pipeline_name;
3515 if ((n_tokens != 11) && (n_tokens != 12)) {
3516 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3520 pipeline_name = tokens[1];
3522 if (strcmp(tokens[2], "table") != 0) {
3523 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3527 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3528 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3532 if (strcmp(tokens[4], "rule") != 0) {
3533 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3537 if (strcmp(tokens[5], "add") != 0) {
3538 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3542 if (strcmp(tokens[6], "match") != 0) {
3543 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3547 if (strcmp(tokens[7], "default") != 0) {
3548 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3552 if (strcmp(tokens[8], "action") != 0) {
3553 snprintf(out, out_size, MSG_ARG_INVALID, "action");
3557 if (strcmp(tokens[9], "fwd") != 0) {
3558 snprintf(out, out_size, MSG_ARG_INVALID, "fwd");
3562 action.action_mask = 1 << RTE_TABLE_ACTION_FWD;
3564 if (strcmp(tokens[10], "drop") == 0) {
3565 if (n_tokens != 11) {
3566 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3570 action.fwd.action = RTE_PIPELINE_ACTION_DROP;
3571 } else if (strcmp(tokens[10], "port") == 0) {
3574 if (n_tokens != 12) {
3575 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3579 if (parser_read_uint32(&id, tokens[11]) != 0) {
3580 snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
3584 action.fwd.action = RTE_PIPELINE_ACTION_PORT;
3586 } else if (strcmp(tokens[10], "meta") == 0) {
3587 if (n_tokens != 11) {
3588 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3592 action.fwd.action = RTE_PIPELINE_ACTION_PORT_META;
3593 } else if (strcmp(tokens[10], "table") == 0) {
3596 if (n_tokens != 12) {
3597 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3601 if (parser_read_uint32(&id, tokens[11]) != 0) {
3602 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3606 action.fwd.action = RTE_PIPELINE_ACTION_TABLE;
3609 snprintf(out, out_size, MSG_ARG_INVALID,
3610 "drop or port or meta or table");
3614 status = pipeline_table_rule_add_default(pipeline_name,
3619 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3625 * pipeline <pipeline_name> table <table_id> rule add bulk <file_name> <n_rules>
3628 * - line format: match <match> action <action>
3631 cli_rule_file_process(const char *file_name,
3632 size_t line_len_max,
3633 struct table_rule_match *m,
3634 struct table_rule_action *a,
3636 uint32_t *line_number,
3641 cmd_pipeline_table_rule_add_bulk(char **tokens,
3646 struct table_rule_match *match;
3647 struct table_rule_action *action;
3649 char *pipeline_name, *file_name;
3650 uint32_t table_id, n_rules, n_rules_parsed, line_number;
3653 if (n_tokens != 9) {
3654 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3658 pipeline_name = tokens[1];
3660 if (strcmp(tokens[2], "table") != 0) {
3661 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3665 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3666 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3670 if (strcmp(tokens[4], "rule") != 0) {
3671 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3675 if (strcmp(tokens[5], "add") != 0) {
3676 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3680 if (strcmp(tokens[6], "bulk") != 0) {
3681 snprintf(out, out_size, MSG_ARG_INVALID, "bulk");
3685 file_name = tokens[7];
3687 if ((parser_read_uint32(&n_rules, tokens[8]) != 0) ||
3689 snprintf(out, out_size, MSG_ARG_INVALID, "n_rules");
3693 /* Memory allocation. */
3694 match = calloc(n_rules, sizeof(struct table_rule_match));
3695 action = calloc(n_rules, sizeof(struct table_rule_action));
3696 data = calloc(n_rules, sizeof(void *));
3697 if ((match == NULL) || (action == NULL) || (data == NULL)) {
3698 snprintf(out, out_size, MSG_OUT_OF_MEMORY);
3705 /* Load rule file */
3706 n_rules_parsed = n_rules;
3707 status = cli_rule_file_process(file_name,
3716 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
3722 if (n_rules_parsed != n_rules) {
3723 snprintf(out, out_size, MSG_FILE_NOT_ENOUGH, file_name);
3731 status = pipeline_table_rule_add_bulk(pipeline_name,
3738 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3752 * pipeline <pipeline_name> table <table_id> rule delete
3756 cmd_pipeline_table_rule_delete(char **tokens,
3761 struct table_rule_match m;
3762 char *pipeline_name;
3763 uint32_t table_id, n_tokens_parsed, t0;
3767 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3771 pipeline_name = tokens[1];
3773 if (strcmp(tokens[2], "table") != 0) {
3774 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3778 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3779 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3783 if (strcmp(tokens[4], "rule") != 0) {
3784 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3788 if (strcmp(tokens[5], "delete") != 0) {
3789 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3796 n_tokens_parsed = parse_match(tokens + t0,
3801 if (n_tokens_parsed == 0)
3803 t0 += n_tokens_parsed;
3805 if (n_tokens != t0) {
3806 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3810 status = pipeline_table_rule_delete(pipeline_name,
3814 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3820 * pipeline <pipeline_name> table <table_id> rule delete
3825 cmd_pipeline_table_rule_delete_default(char **tokens,
3830 char *pipeline_name;
3834 if (n_tokens != 8) {
3835 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3839 pipeline_name = tokens[1];
3841 if (strcmp(tokens[2], "table") != 0) {
3842 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
3846 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3847 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3851 if (strcmp(tokens[4], "rule") != 0) {
3852 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
3856 if (strcmp(tokens[5], "delete") != 0) {
3857 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
3861 if (strcmp(tokens[6], "match") != 0) {
3862 snprintf(out, out_size, MSG_ARG_INVALID, "match");
3866 if (strcmp(tokens[7], "default") != 0) {
3867 snprintf(out, out_size, MSG_ARG_INVALID, "default");
3871 status = pipeline_table_rule_delete_default(pipeline_name,
3874 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
3880 * pipeline <pipeline_name> table <table_id> rule read stats [clear]
3883 cmd_pipeline_table_rule_stats_read(char **tokens,
3884 uint32_t n_tokens __rte_unused,
3888 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
3892 * pipeline <pipeline_name> table <table_id> meter profile <meter_profile_id>
3893 * add srtcm cir <cir> cbs <cbs> ebs <ebs>
3894 * | trtcm cir <cir> pir <pir> cbs <cbs> pbs <pbs>
3897 cmd_pipeline_table_meter_profile_add(char **tokens,
3902 struct rte_table_action_meter_profile p;
3903 char *pipeline_name;
3904 uint32_t table_id, meter_profile_id;
3908 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3912 pipeline_name = tokens[1];
3914 if (strcmp(tokens[2], "table") != 0) {
3915 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
3919 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
3920 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
3924 if (strcmp(tokens[4], "meter") != 0) {
3925 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
3929 if (strcmp(tokens[5], "profile") != 0) {
3930 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
3934 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
3935 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
3939 if (strcmp(tokens[7], "add") != 0) {
3940 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
3944 if (strcmp(tokens[8], "srtcm") == 0) {
3945 if (n_tokens != 15) {
3946 snprintf(out, out_size, MSG_ARG_MISMATCH,
3951 p.alg = RTE_TABLE_ACTION_METER_SRTCM;
3953 if (strcmp(tokens[9], "cir") != 0) {
3954 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
3958 if (parser_read_uint64(&p.srtcm.cir, tokens[10]) != 0) {
3959 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
3963 if (strcmp(tokens[11], "cbs") != 0) {
3964 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
3968 if (parser_read_uint64(&p.srtcm.cbs, tokens[12]) != 0) {
3969 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
3973 if (strcmp(tokens[13], "ebs") != 0) {
3974 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "ebs");
3978 if (parser_read_uint64(&p.srtcm.ebs, tokens[14]) != 0) {
3979 snprintf(out, out_size, MSG_ARG_INVALID, "ebs");
3982 } else if (strcmp(tokens[8], "trtcm") == 0) {
3983 if (n_tokens != 17) {
3984 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
3988 p.alg = RTE_TABLE_ACTION_METER_TRTCM;
3990 if (strcmp(tokens[9], "cir") != 0) {
3991 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
3995 if (parser_read_uint64(&p.trtcm.cir, tokens[10]) != 0) {
3996 snprintf(out, out_size, MSG_ARG_INVALID, "cir");
4000 if (strcmp(tokens[11], "pir") != 0) {
4001 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pir");
4005 if (parser_read_uint64(&p.trtcm.pir, tokens[12]) != 0) {
4006 snprintf(out, out_size, MSG_ARG_INVALID, "pir");
4009 if (strcmp(tokens[13], "cbs") != 0) {
4010 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
4014 if (parser_read_uint64(&p.trtcm.cbs, tokens[14]) != 0) {
4015 snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
4019 if (strcmp(tokens[15], "pbs") != 0) {
4020 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pbs");
4024 if (parser_read_uint64(&p.trtcm.pbs, tokens[16]) != 0) {
4025 snprintf(out, out_size, MSG_ARG_INVALID, "pbs");
4029 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4033 status = pipeline_table_mtr_profile_add(pipeline_name,
4038 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4044 * pipeline <pipeline_name> table <table_id>
4045 * meter profile <meter_profile_id> delete
4048 cmd_pipeline_table_meter_profile_delete(char **tokens,
4053 char *pipeline_name;
4054 uint32_t table_id, meter_profile_id;
4057 if (n_tokens != 8) {
4058 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4062 pipeline_name = tokens[1];
4064 if (strcmp(tokens[2], "table") != 0) {
4065 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4069 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4070 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4074 if (strcmp(tokens[4], "meter") != 0) {
4075 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
4079 if (strcmp(tokens[5], "profile") != 0) {
4080 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
4084 if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
4085 snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
4089 if (strcmp(tokens[7], "delete") != 0) {
4090 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
4094 status = pipeline_table_mtr_profile_delete(pipeline_name,
4098 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4104 * pipeline <pipeline_name> table <table_id> rule read meter [clear]
4107 cmd_pipeline_table_rule_meter_read(char **tokens,
4108 uint32_t n_tokens __rte_unused,
4112 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4116 * pipeline <pipeline_name> table <table_id> dscp <file_name>
4119 * - exactly 64 lines
4120 * - line format: <tc_id> <tc_queue_id> <color>, with <color> as: g | y | r
4123 load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
4124 const char *file_name,
4125 uint32_t *line_number)
4130 /* Check input arguments */
4131 if ((dscp_table == NULL) ||
4132 (file_name == NULL) ||
4133 (line_number == NULL)) {
4139 /* Open input file */
4140 f = fopen(file_name, "r");
4147 for (dscp = 0, l = 1; ; l++) {
4150 enum rte_meter_color color;
4151 uint32_t tc_id, tc_queue_id, n_tokens = RTE_DIM(tokens);
4153 if (fgets(line, sizeof(line), f) == NULL)
4156 if (is_comment(line))
4159 if (parse_tokenize_string(line, tokens, &n_tokens)) {
4167 if ((dscp >= RTE_DIM(dscp_table->entry)) ||
4168 (n_tokens != RTE_DIM(tokens)) ||
4169 parser_read_uint32(&tc_id, tokens[0]) ||
4170 (tc_id >= RTE_TABLE_ACTION_TC_MAX) ||
4171 parser_read_uint32(&tc_queue_id, tokens[1]) ||
4172 (tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) ||
4173 (strlen(tokens[2]) != 1)) {
4178 switch (tokens[2][0]) {
4181 color = e_RTE_METER_GREEN;
4186 color = e_RTE_METER_YELLOW;
4191 color = e_RTE_METER_RED;
4199 dscp_table->entry[dscp].tc_id = tc_id;
4200 dscp_table->entry[dscp].tc_queue_id = tc_queue_id;
4201 dscp_table->entry[dscp].color = color;
4211 cmd_pipeline_table_dscp(char **tokens,
4216 struct rte_table_action_dscp_table dscp_table;
4217 char *pipeline_name, *file_name;
4218 uint32_t table_id, line_number;
4221 if (n_tokens != 6) {
4222 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4226 pipeline_name = tokens[1];
4228 if (strcmp(tokens[2], "table") != 0) {
4229 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
4233 if (parser_read_uint32(&table_id, tokens[3]) != 0) {
4234 snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
4238 if (strcmp(tokens[4], "dscp") != 0) {
4239 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dscp");
4243 file_name = tokens[5];
4245 status = load_dscp_table(&dscp_table, file_name, &line_number);
4247 snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
4251 status = pipeline_table_dscp_table_update(pipeline_name,
4256 snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
4262 * pipeline <pipeline_name> table <table_id> rule read ttl [clear]
4265 cmd_pipeline_table_rule_ttl_read(char **tokens,
4266 uint32_t n_tokens __rte_unused,
4270 snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
4274 * thread <thread_id> pipeline <pipeline_name> enable
4277 cmd_thread_pipeline_enable(char **tokens,
4282 char *pipeline_name;
4286 if (n_tokens != 5) {
4287 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4291 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4292 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4296 if (strcmp(tokens[2], "pipeline") != 0) {
4297 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4301 pipeline_name = tokens[3];
4303 if (strcmp(tokens[4], "enable") != 0) {
4304 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
4308 status = thread_pipeline_enable(thread_id, pipeline_name);
4310 snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable");
4316 * thread <thread_id> pipeline <pipeline_name> disable
4319 cmd_thread_pipeline_disable(char **tokens,
4324 char *pipeline_name;
4328 if (n_tokens != 5) {
4329 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
4333 if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
4334 snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
4338 if (strcmp(tokens[2], "pipeline") != 0) {
4339 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
4343 pipeline_name = tokens[3];
4345 if (strcmp(tokens[4], "disable") != 0) {
4346 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
4350 status = thread_pipeline_disable(thread_id, pipeline_name);
4352 snprintf(out, out_size, MSG_CMD_FAIL,
4353 "thread pipeline disable");
4359 cli_process(char *in, char *out, size_t out_size)
4361 char *tokens[CMD_MAX_TOKENS];
4362 uint32_t n_tokens = RTE_DIM(tokens);
4368 status = parse_tokenize_string(in, tokens, &n_tokens);
4370 snprintf(out, out_size, MSG_ARG_TOO_MANY, "");
4377 if (strcmp(tokens[0], "mempool") == 0) {
4378 cmd_mempool(tokens, n_tokens, out, out_size);
4382 if (strcmp(tokens[0], "link") == 0) {
4383 cmd_link(tokens, n_tokens, out, out_size);
4387 if (strcmp(tokens[0], "swq") == 0) {
4388 cmd_swq(tokens, n_tokens, out, out_size);
4392 if (strcmp(tokens[0], "tmgr") == 0) {
4393 if ((n_tokens >= 3) &&
4394 (strcmp(tokens[1], "subport") == 0) &&
4395 (strcmp(tokens[2], "profile") == 0)) {
4396 cmd_tmgr_subport_profile(tokens, n_tokens,
4401 if ((n_tokens >= 3) &&
4402 (strcmp(tokens[1], "pipe") == 0) &&
4403 (strcmp(tokens[2], "profile") == 0)) {
4404 cmd_tmgr_pipe_profile(tokens, n_tokens, out, out_size);
4408 if ((n_tokens >= 5) &&
4409 (strcmp(tokens[2], "subport") == 0) &&
4410 (strcmp(tokens[4], "profile") == 0)) {
4411 cmd_tmgr_subport(tokens, n_tokens, out, out_size);
4415 if ((n_tokens >= 5) &&
4416 (strcmp(tokens[2], "subport") == 0) &&
4417 (strcmp(tokens[4], "pipe") == 0)) {
4418 cmd_tmgr_subport_pipe(tokens, n_tokens, out, out_size);
4422 cmd_tmgr(tokens, n_tokens, out, out_size);
4426 if (strcmp(tokens[0], "tap") == 0) {
4427 cmd_tap(tokens, n_tokens, out, out_size);
4431 if (strcmp(tokens[0], "kni") == 0) {
4432 cmd_kni(tokens, n_tokens, out, out_size);
4436 if (strcmp(tokens[0], "port") == 0) {
4437 cmd_port_in_action_profile(tokens, n_tokens, out, out_size);
4441 if (strcmp(tokens[0], "table") == 0) {
4442 cmd_table_action_profile(tokens, n_tokens, out, out_size);
4446 if (strcmp(tokens[0], "pipeline") == 0) {
4447 if ((n_tokens >= 3) &&
4448 (strcmp(tokens[2], "period") == 0)) {
4449 cmd_pipeline(tokens, n_tokens, out, out_size);
4453 if ((n_tokens >= 5) &&
4454 (strcmp(tokens[2], "port") == 0) &&
4455 (strcmp(tokens[3], "in") == 0) &&
4456 (strcmp(tokens[4], "bsz") == 0)) {
4457 cmd_pipeline_port_in(tokens, n_tokens, out, out_size);
4461 if ((n_tokens >= 5) &&
4462 (strcmp(tokens[2], "port") == 0) &&
4463 (strcmp(tokens[3], "out") == 0) &&
4464 (strcmp(tokens[4], "bsz") == 0)) {
4465 cmd_pipeline_port_out(tokens, n_tokens, out, out_size);
4469 if ((n_tokens >= 4) &&
4470 (strcmp(tokens[2], "table") == 0) &&
4471 (strcmp(tokens[3], "match") == 0)) {
4472 cmd_pipeline_table(tokens, n_tokens, out, out_size);
4476 if ((n_tokens >= 6) &&
4477 (strcmp(tokens[2], "port") == 0) &&
4478 (strcmp(tokens[3], "in") == 0) &&
4479 (strcmp(tokens[5], "table") == 0)) {
4480 cmd_pipeline_port_in_table(tokens, n_tokens,
4485 if ((n_tokens >= 6) &&
4486 (strcmp(tokens[2], "port") == 0) &&
4487 (strcmp(tokens[3], "in") == 0) &&
4488 (strcmp(tokens[5], "stats") == 0)) {
4489 cmd_pipeline_port_in_stats(tokens, n_tokens,
4494 if ((n_tokens >= 6) &&
4495 (strcmp(tokens[2], "port") == 0) &&
4496 (strcmp(tokens[3], "in") == 0) &&
4497 (strcmp(tokens[5], "enable") == 0)) {
4498 cmd_pipeline_port_in_enable(tokens, n_tokens,
4503 if ((n_tokens >= 6) &&
4504 (strcmp(tokens[2], "port") == 0) &&
4505 (strcmp(tokens[3], "in") == 0) &&
4506 (strcmp(tokens[5], "disable") == 0)) {
4507 cmd_pipeline_port_in_disable(tokens, n_tokens,
4512 if ((n_tokens >= 6) &&
4513 (strcmp(tokens[2], "port") == 0) &&
4514 (strcmp(tokens[3], "out") == 0) &&
4515 (strcmp(tokens[5], "stats") == 0)) {
4516 cmd_pipeline_port_out_stats(tokens, n_tokens,
4521 if ((n_tokens >= 5) &&
4522 (strcmp(tokens[2], "table") == 0) &&
4523 (strcmp(tokens[4], "stats") == 0)) {
4524 cmd_pipeline_table_stats(tokens, n_tokens,
4529 if ((n_tokens >= 7) &&
4530 (strcmp(tokens[2], "table") == 0) &&
4531 (strcmp(tokens[4], "rule") == 0) &&
4532 (strcmp(tokens[5], "add") == 0) &&
4533 (strcmp(tokens[6], "match") == 0)) {
4534 if ((n_tokens >= 8) &&
4535 (strcmp(tokens[7], "default") == 0)) {
4536 cmd_pipeline_table_rule_add_default(tokens,
4537 n_tokens, out, out_size);
4541 cmd_pipeline_table_rule_add(tokens, n_tokens,
4546 if ((n_tokens >= 7) &&
4547 (strcmp(tokens[2], "table") == 0) &&
4548 (strcmp(tokens[4], "rule") == 0) &&
4549 (strcmp(tokens[5], "add") == 0) &&
4550 (strcmp(tokens[6], "bulk") == 0)) {
4551 cmd_pipeline_table_rule_add_bulk(tokens,
4552 n_tokens, out, out_size);
4556 if ((n_tokens >= 7) &&
4557 (strcmp(tokens[2], "table") == 0) &&
4558 (strcmp(tokens[4], "rule") == 0) &&
4559 (strcmp(tokens[5], "delete") == 0) &&
4560 (strcmp(tokens[6], "match") == 0)) {
4561 if ((n_tokens >= 8) &&
4562 (strcmp(tokens[7], "default") == 0)) {
4563 cmd_pipeline_table_rule_delete_default(tokens,
4564 n_tokens, out, out_size);
4568 cmd_pipeline_table_rule_delete(tokens, n_tokens,
4573 if ((n_tokens >= 7) &&
4574 (strcmp(tokens[2], "table") == 0) &&
4575 (strcmp(tokens[4], "rule") == 0) &&
4576 (strcmp(tokens[5], "read") == 0) &&
4577 (strcmp(tokens[6], "stats") == 0)) {
4578 cmd_pipeline_table_rule_stats_read(tokens, n_tokens,
4583 if ((n_tokens >= 8) &&
4584 (strcmp(tokens[2], "table") == 0) &&
4585 (strcmp(tokens[4], "meter") == 0) &&
4586 (strcmp(tokens[5], "profile") == 0) &&
4587 (strcmp(tokens[7], "add") == 0)) {
4588 cmd_pipeline_table_meter_profile_add(tokens, n_tokens,
4593 if ((n_tokens >= 8) &&
4594 (strcmp(tokens[2], "table") == 0) &&
4595 (strcmp(tokens[4], "meter") == 0) &&
4596 (strcmp(tokens[5], "profile") == 0) &&
4597 (strcmp(tokens[7], "delete") == 0)) {
4598 cmd_pipeline_table_meter_profile_delete(tokens,
4599 n_tokens, out, out_size);
4603 if ((n_tokens >= 7) &&
4604 (strcmp(tokens[2], "table") == 0) &&
4605 (strcmp(tokens[4], "rule") == 0) &&
4606 (strcmp(tokens[5], "read") == 0) &&
4607 (strcmp(tokens[6], "meter") == 0)) {
4608 cmd_pipeline_table_rule_meter_read(tokens, n_tokens,
4613 if ((n_tokens >= 5) &&
4614 (strcmp(tokens[2], "table") == 0) &&
4615 (strcmp(tokens[4], "dscp") == 0)) {
4616 cmd_pipeline_table_dscp(tokens, n_tokens,
4621 if ((n_tokens >= 7) &&
4622 (strcmp(tokens[2], "table") == 0) &&
4623 (strcmp(tokens[4], "rule") == 0) &&
4624 (strcmp(tokens[5], "read") == 0) &&
4625 (strcmp(tokens[6], "ttl") == 0)) {
4626 cmd_pipeline_table_rule_ttl_read(tokens, n_tokens,
4632 if (strcmp(tokens[0], "thread") == 0) {
4633 if ((n_tokens >= 5) &&
4634 (strcmp(tokens[4], "enable") == 0)) {
4635 cmd_thread_pipeline_enable(tokens, n_tokens,
4640 if ((n_tokens >= 5) &&
4641 (strcmp(tokens[4], "disable") == 0)) {
4642 cmd_thread_pipeline_disable(tokens, n_tokens,
4648 snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
4652 cli_script_process(const char *file_name,
4653 size_t msg_in_len_max,
4654 size_t msg_out_len_max)
4656 char *msg_in = NULL, *msg_out = NULL;
4659 /* Check input arguments */
4660 if ((file_name == NULL) ||
4661 (strlen(file_name) == 0) ||
4662 (msg_in_len_max == 0) ||
4663 (msg_out_len_max == 0))
4666 msg_in = malloc(msg_in_len_max + 1);
4667 msg_out = malloc(msg_out_len_max + 1);
4668 if ((msg_in == NULL) ||
4669 (msg_out == NULL)) {
4675 /* Open input file */
4676 f = fopen(file_name, "r");
4685 if (fgets(msg_in, msg_in_len_max + 1, f) == NULL)
4688 printf("%s", msg_in);
4695 if (strlen(msg_out))
4696 printf("%s", msg_out);
4707 cli_rule_file_process(const char *file_name,
4708 size_t line_len_max,
4709 struct table_rule_match *m,
4710 struct table_rule_action *a,
4712 uint32_t *line_number,
4718 uint32_t rule_id, line_id;
4721 /* Check input arguments */
4722 if ((file_name == NULL) ||
4723 (strlen(file_name) == 0) ||
4724 (line_len_max == 0)) {
4729 /* Memory allocation */
4730 line = malloc(line_len_max + 1);
4737 f = fopen(file_name, "r");
4745 for (line_id = 1, rule_id = 0; rule_id < *n_rules; line_id++) {
4746 char *tokens[CMD_MAX_TOKENS];
4747 uint32_t n_tokens, n_tokens_parsed, t0;
4749 /* Read next line from file. */
4750 if (fgets(line, line_len_max + 1, f) == NULL)
4754 if (is_comment(line))
4758 n_tokens = RTE_DIM(tokens);
4759 status = parse_tokenize_string(line, tokens, &n_tokens);
4771 n_tokens_parsed = parse_match(tokens + t0,
4776 if (n_tokens_parsed == 0) {
4780 t0 += n_tokens_parsed;
4783 n_tokens_parsed = parse_table_action(tokens + t0,
4788 if (n_tokens_parsed == 0) {
4792 t0 += n_tokens_parsed;
4794 /* Line completed. */
4795 if (t0 < n_tokens) {
4800 /* Increment rule count */
4811 *line_number = line_id;