4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <rte_common.h>
40 #include <rte_malloc.h>
41 #include <cmdline_rdline.h>
42 #include <cmdline_parse.h>
43 #include <cmdline_parse_num.h>
44 #include <cmdline_parse_string.h>
47 #include "pipeline_common_fe.h"
51 app_pipeline_ping(struct app_params *app,
54 struct app_pipeline_params *p;
55 struct pipeline_msg_req *req;
56 struct pipeline_msg_rsp *rsp;
59 /* Check input arguments */
63 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
67 /* Message buffer allocation */
68 req = app_msg_alloc(app);
73 req->type = PIPELINE_MSG_REQ_PING;
75 /* Send request and wait for response */
76 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
83 /* Message buffer free */
84 app_msg_free(app, rsp);
90 app_pipeline_stats_port_in(struct app_params *app,
93 struct rte_pipeline_port_in_stats *stats)
95 struct app_pipeline_params *p;
96 struct pipeline_stats_msg_req *req;
97 struct pipeline_stats_port_in_msg_rsp *rsp;
100 /* Check input arguments */
105 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
107 (port_id >= p->n_pktq_in))
110 /* Message buffer allocation */
111 req = app_msg_alloc(app);
115 /* Fill in request */
116 req->type = PIPELINE_MSG_REQ_STATS_PORT_IN;
119 /* Send request and wait for response */
120 rsp = (struct pipeline_stats_port_in_msg_rsp *)
121 app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
126 status = rsp->status;
128 memcpy(stats, &rsp->stats, sizeof(rsp->stats));
130 /* Message buffer free */
131 app_msg_free(app, rsp);
137 app_pipeline_stats_port_out(struct app_params *app,
138 uint32_t pipeline_id,
140 struct rte_pipeline_port_out_stats *stats)
142 struct app_pipeline_params *p;
143 struct pipeline_stats_msg_req *req;
144 struct pipeline_stats_port_out_msg_rsp *rsp;
147 /* Check input arguments */
149 (pipeline_id >= app->n_pipelines) ||
153 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
155 (port_id >= p->n_pktq_out))
158 /* Message buffer allocation */
159 req = app_msg_alloc(app);
163 /* Fill in request */
164 req->type = PIPELINE_MSG_REQ_STATS_PORT_OUT;
167 /* Send request and wait for response */
168 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
173 status = rsp->status;
175 memcpy(stats, &rsp->stats, sizeof(rsp->stats));
177 /* Message buffer free */
178 app_msg_free(app, rsp);
184 app_pipeline_stats_table(struct app_params *app,
185 uint32_t pipeline_id,
187 struct rte_pipeline_table_stats *stats)
189 struct app_pipeline_params *p;
190 struct pipeline_stats_msg_req *req;
191 struct pipeline_stats_table_msg_rsp *rsp;
194 /* Check input arguments */
199 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
203 /* Message buffer allocation */
204 req = app_msg_alloc(app);
208 /* Fill in request */
209 req->type = PIPELINE_MSG_REQ_STATS_TABLE;
212 /* Send request and wait for response */
213 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
218 status = rsp->status;
220 memcpy(stats, &rsp->stats, sizeof(rsp->stats));
222 /* Message buffer free */
223 app_msg_free(app, rsp);
229 app_pipeline_port_in_enable(struct app_params *app,
230 uint32_t pipeline_id,
233 struct app_pipeline_params *p;
234 struct pipeline_port_in_msg_req *req;
235 struct pipeline_msg_rsp *rsp;
238 /* Check input arguments */
242 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
244 (port_id >= p->n_pktq_in))
247 /* Message buffer allocation */
248 req = app_msg_alloc(app);
252 /* Fill in request */
253 req->type = PIPELINE_MSG_REQ_PORT_IN_ENABLE;
254 req->port_id = port_id;
256 /* Send request and wait for response */
257 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
262 status = rsp->status;
264 /* Message buffer free */
265 app_msg_free(app, rsp);
271 app_pipeline_port_in_disable(struct app_params *app,
272 uint32_t pipeline_id,
275 struct app_pipeline_params *p;
276 struct pipeline_port_in_msg_req *req;
277 struct pipeline_msg_rsp *rsp;
280 /* Check input arguments */
284 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
286 (port_id >= p->n_pktq_in))
289 /* Message buffer allocation */
290 req = app_msg_alloc(app);
294 /* Fill in request */
295 req->type = PIPELINE_MSG_REQ_PORT_IN_DISABLE;
296 req->port_id = port_id;
298 /* Send request and wait for response */
299 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
304 status = rsp->status;
306 /* Message buffer free */
307 app_msg_free(app, rsp);
313 app_link_config(struct app_params *app,
318 struct app_link_params *p;
319 uint32_t i, netmask, host, bcast;
321 /* Check input arguments */
325 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
327 APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
333 APP_LOG(app, HIGH, "%s is UP, please bring it DOWN first",
338 netmask = (~0U) << (32 - depth);
340 bcast = host | (~netmask);
343 (ip == UINT32_MAX) ||
346 APP_LOG(app, HIGH, "Illegal IP address");
350 for (i = 0; i < app->n_links; i++) {
351 struct app_link_params *link = &app->link_params[i];
353 if (strcmp(p->name, link->name) == 0)
356 if (link->ip == ip) {
358 "%s is already assigned this IP address",
364 if ((depth == 0) || (depth > 32)) {
365 APP_LOG(app, HIGH, "Illegal value for depth parameter "
371 /* Save link parameters */
379 app_link_up(struct app_params *app,
382 struct app_link_params *p;
384 /* Check input arguments */
388 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
390 APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
395 /* Check link state */
397 APP_LOG(app, HIGH, "%s is already UP", p->name);
401 /* Check that IP address is valid */
403 APP_LOG(app, HIGH, "%s IP address is not set", p->name);
407 app_link_up_internal(app, p);
413 app_link_down(struct app_params *app,
416 struct app_link_params *p;
418 /* Check input arguments */
422 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
424 APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
429 /* Check link state */
431 APP_LOG(app, HIGH, "%s is already DOWN", p->name);
435 app_link_down_internal(app, p);
444 struct cmd_ping_result {
445 cmdline_fixed_string_t p_string;
446 uint32_t pipeline_id;
447 cmdline_fixed_string_t ping_string;
453 __rte_unused struct cmdline *cl,
456 struct cmd_ping_result *params = parsed_result;
457 struct app_params *app = data;
460 status = app_pipeline_ping(app, params->pipeline_id);
462 printf("Command failed\n");
465 static cmdline_parse_token_string_t cmd_ping_p_string =
466 TOKEN_STRING_INITIALIZER(struct cmd_ping_result, p_string, "p");
468 static cmdline_parse_token_num_t cmd_ping_pipeline_id =
469 TOKEN_NUM_INITIALIZER(struct cmd_ping_result, pipeline_id, UINT32);
471 static cmdline_parse_token_string_t cmd_ping_ping_string =
472 TOKEN_STRING_INITIALIZER(struct cmd_ping_result, ping_string, "ping");
474 static cmdline_parse_inst_t cmd_ping = {
475 .f = cmd_ping_parsed,
477 .help_str = "Pipeline ping",
479 (void *) &cmd_ping_p_string,
480 (void *) &cmd_ping_pipeline_id,
481 (void *) &cmd_ping_ping_string,
490 struct cmd_stats_port_in_result {
491 cmdline_fixed_string_t p_string;
492 uint32_t pipeline_id;
493 cmdline_fixed_string_t stats_string;
494 cmdline_fixed_string_t port_string;
495 cmdline_fixed_string_t in_string;
501 cmd_stats_port_in_parsed(
503 __rte_unused struct cmdline *cl,
506 struct cmd_stats_port_in_result *params = parsed_result;
507 struct app_params *app = data;
508 struct rte_pipeline_port_in_stats stats;
511 status = app_pipeline_stats_port_in(app,
517 printf("Command failed\n");
522 printf("Pipeline %" PRIu32 " - stats for input port %" PRIu32 ":\n"
523 "\tPkts in: %" PRIu64 "\n"
524 "\tPkts dropped by AH: %" PRIu64 "\n"
525 "\tPkts dropped by other: %" PRIu64 "\n",
528 stats.stats.n_pkts_in,
529 stats.n_pkts_dropped_by_ah,
530 stats.stats.n_pkts_drop);
533 static cmdline_parse_token_string_t cmd_stats_port_in_p_string =
534 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, p_string,
537 static cmdline_parse_token_num_t cmd_stats_port_in_pipeline_id =
538 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, pipeline_id,
541 static cmdline_parse_token_string_t cmd_stats_port_in_stats_string =
542 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, stats_string,
545 static cmdline_parse_token_string_t cmd_stats_port_in_port_string =
546 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, port_string,
549 static cmdline_parse_token_string_t cmd_stats_port_in_in_string =
550 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, in_string,
553 cmdline_parse_token_num_t cmd_stats_port_in_port_in_id =
554 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, port_in_id,
557 static cmdline_parse_inst_t cmd_stats_port_in = {
558 .f = cmd_stats_port_in_parsed,
560 .help_str = "Pipeline input port stats",
562 (void *) &cmd_stats_port_in_p_string,
563 (void *) &cmd_stats_port_in_pipeline_id,
564 (void *) &cmd_stats_port_in_stats_string,
565 (void *) &cmd_stats_port_in_port_string,
566 (void *) &cmd_stats_port_in_in_string,
567 (void *) &cmd_stats_port_in_port_in_id,
576 struct cmd_stats_port_out_result {
577 cmdline_fixed_string_t p_string;
578 uint32_t pipeline_id;
579 cmdline_fixed_string_t stats_string;
580 cmdline_fixed_string_t port_string;
581 cmdline_fixed_string_t out_string;
582 uint32_t port_out_id;
586 cmd_stats_port_out_parsed(
588 __rte_unused struct cmdline *cl,
592 struct cmd_stats_port_out_result *params = parsed_result;
593 struct app_params *app = data;
594 struct rte_pipeline_port_out_stats stats;
597 status = app_pipeline_stats_port_out(app,
603 printf("Command failed\n");
608 printf("Pipeline %" PRIu32 " - stats for output port %" PRIu32 ":\n"
609 "\tPkts in: %" PRIu64 "\n"
610 "\tPkts dropped by AH: %" PRIu64 "\n"
611 "\tPkts dropped by other: %" PRIu64 "\n",
614 stats.stats.n_pkts_in,
615 stats.n_pkts_dropped_by_ah,
616 stats.stats.n_pkts_drop);
619 static cmdline_parse_token_string_t cmd_stats_port_out_p_string =
620 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, p_string,
623 static cmdline_parse_token_num_t cmd_stats_port_out_pipeline_id =
624 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, pipeline_id,
627 static cmdline_parse_token_string_t cmd_stats_port_out_stats_string =
628 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, stats_string,
631 static cmdline_parse_token_string_t cmd_stats_port_out_port_string =
632 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, port_string,
635 static cmdline_parse_token_string_t cmd_stats_port_out_out_string =
636 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, out_string,
639 static cmdline_parse_token_num_t cmd_stats_port_out_port_out_id =
640 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, port_out_id,
643 static cmdline_parse_inst_t cmd_stats_port_out = {
644 .f = cmd_stats_port_out_parsed,
646 .help_str = "Pipeline output port stats",
648 (void *) &cmd_stats_port_out_p_string,
649 (void *) &cmd_stats_port_out_pipeline_id,
650 (void *) &cmd_stats_port_out_stats_string,
651 (void *) &cmd_stats_port_out_port_string,
652 (void *) &cmd_stats_port_out_out_string,
653 (void *) &cmd_stats_port_out_port_out_id,
662 struct cmd_stats_table_result {
663 cmdline_fixed_string_t p_string;
664 uint32_t pipeline_id;
665 cmdline_fixed_string_t stats_string;
666 cmdline_fixed_string_t table_string;
671 cmd_stats_table_parsed(
673 __rte_unused struct cmdline *cl,
676 struct cmd_stats_table_result *params = parsed_result;
677 struct app_params *app = data;
678 struct rte_pipeline_table_stats stats;
681 status = app_pipeline_stats_table(app,
687 printf("Command failed\n");
692 printf("Pipeline %" PRIu32 " - stats for table %" PRIu32 ":\n"
693 "\tPkts in: %" PRIu64 "\n"
694 "\tPkts in with lookup miss: %" PRIu64 "\n"
695 "\tPkts in with lookup hit dropped by AH: %" PRIu64 "\n"
696 "\tPkts in with lookup hit dropped by others: %" PRIu64 "\n"
697 "\tPkts in with lookup miss dropped by AH: %" PRIu64 "\n"
698 "\tPkts in with lookup miss dropped by others: %" PRIu64 "\n",
701 stats.stats.n_pkts_in,
702 stats.stats.n_pkts_lookup_miss,
703 stats.n_pkts_dropped_by_lkp_hit_ah,
704 stats.n_pkts_dropped_lkp_hit,
705 stats.n_pkts_dropped_by_lkp_miss_ah,
706 stats.n_pkts_dropped_lkp_miss);
709 static cmdline_parse_token_string_t cmd_stats_table_p_string =
710 TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, p_string,
713 static cmdline_parse_token_num_t cmd_stats_table_pipeline_id =
714 TOKEN_NUM_INITIALIZER(struct cmd_stats_table_result, pipeline_id,
717 static cmdline_parse_token_string_t cmd_stats_table_stats_string =
718 TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, stats_string,
721 static cmdline_parse_token_string_t cmd_stats_table_table_string =
722 TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, table_string,
725 static cmdline_parse_token_num_t cmd_stats_table_table_id =
726 TOKEN_NUM_INITIALIZER(struct cmd_stats_table_result, table_id, UINT32);
728 static cmdline_parse_inst_t cmd_stats_table = {
729 .f = cmd_stats_table_parsed,
731 .help_str = "Pipeline table stats",
733 (void *) &cmd_stats_table_p_string,
734 (void *) &cmd_stats_table_pipeline_id,
735 (void *) &cmd_stats_table_stats_string,
736 (void *) &cmd_stats_table_table_string,
737 (void *) &cmd_stats_table_table_id,
746 struct cmd_port_in_enable_result {
747 cmdline_fixed_string_t p_string;
748 uint32_t pipeline_id;
749 cmdline_fixed_string_t port_string;
750 cmdline_fixed_string_t in_string;
752 cmdline_fixed_string_t enable_string;
756 cmd_port_in_enable_parsed(
758 __rte_unused struct cmdline *cl,
761 struct cmd_port_in_enable_result *params = parsed_result;
762 struct app_params *app = data;
765 status = app_pipeline_port_in_enable(app,
770 printf("Command failed\n");
773 static cmdline_parse_token_string_t cmd_port_in_enable_p_string =
774 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, p_string,
777 static cmdline_parse_token_num_t cmd_port_in_enable_pipeline_id =
778 TOKEN_NUM_INITIALIZER(struct cmd_port_in_enable_result, pipeline_id,
781 static cmdline_parse_token_string_t cmd_port_in_enable_port_string =
782 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, port_string,
785 static cmdline_parse_token_string_t cmd_port_in_enable_in_string =
786 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, in_string,
789 static cmdline_parse_token_num_t cmd_port_in_enable_port_in_id =
790 TOKEN_NUM_INITIALIZER(struct cmd_port_in_enable_result, port_in_id,
793 static cmdline_parse_token_string_t cmd_port_in_enable_enable_string =
794 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result,
795 enable_string, "enable");
797 static cmdline_parse_inst_t cmd_port_in_enable = {
798 .f = cmd_port_in_enable_parsed,
800 .help_str = "Pipeline input port enable",
802 (void *) &cmd_port_in_enable_p_string,
803 (void *) &cmd_port_in_enable_pipeline_id,
804 (void *) &cmd_port_in_enable_port_string,
805 (void *) &cmd_port_in_enable_in_string,
806 (void *) &cmd_port_in_enable_port_in_id,
807 (void *) &cmd_port_in_enable_enable_string,
816 struct cmd_port_in_disable_result {
817 cmdline_fixed_string_t p_string;
818 uint32_t pipeline_id;
819 cmdline_fixed_string_t port_string;
820 cmdline_fixed_string_t in_string;
822 cmdline_fixed_string_t disable_string;
826 cmd_port_in_disable_parsed(
828 __rte_unused struct cmdline *cl,
831 struct cmd_port_in_disable_result *params = parsed_result;
832 struct app_params *app = data;
835 status = app_pipeline_port_in_disable(app,
840 printf("Command failed\n");
843 static cmdline_parse_token_string_t cmd_port_in_disable_p_string =
844 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, p_string,
847 static cmdline_parse_token_num_t cmd_port_in_disable_pipeline_id =
848 TOKEN_NUM_INITIALIZER(struct cmd_port_in_disable_result, pipeline_id,
851 static cmdline_parse_token_string_t cmd_port_in_disable_port_string =
852 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, port_string,
855 static cmdline_parse_token_string_t cmd_port_in_disable_in_string =
856 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, in_string,
859 static cmdline_parse_token_num_t cmd_port_in_disable_port_in_id =
860 TOKEN_NUM_INITIALIZER(struct cmd_port_in_disable_result, port_in_id,
863 static cmdline_parse_token_string_t cmd_port_in_disable_disable_string =
864 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result,
865 disable_string, "disable");
867 static cmdline_parse_inst_t cmd_port_in_disable = {
868 .f = cmd_port_in_disable_parsed,
870 .help_str = "Pipeline input port disable",
872 (void *) &cmd_port_in_disable_p_string,
873 (void *) &cmd_port_in_disable_pipeline_id,
874 (void *) &cmd_port_in_disable_port_string,
875 (void *) &cmd_port_in_disable_in_string,
876 (void *) &cmd_port_in_disable_port_in_id,
877 (void *) &cmd_port_in_disable_disable_string,
887 print_link_info(struct app_link_params *p)
889 struct rte_eth_stats stats;
890 struct ether_addr *mac_addr;
891 uint32_t netmask = (~0U) << (32 - p->depth);
892 uint32_t host = p->ip & netmask;
893 uint32_t bcast = host | (~netmask);
895 memset(&stats, 0, sizeof(stats));
896 rte_eth_stats_get(p->pmd_id, &stats);
898 mac_addr = (struct ether_addr *) &p->mac_addr;
900 if (strlen(p->pci_bdf))
901 printf("%s(%s): flags=<%s>\n",
904 (p->state) ? "UP" : "DOWN");
906 printf("%s: flags=<%s>\n",
908 (p->state) ? "UP" : "DOWN");
911 printf("\tinet %" PRIu32 ".%" PRIu32
912 ".%" PRIu32 ".%" PRIu32
913 " netmask %" PRIu32 ".%" PRIu32
914 ".%" PRIu32 ".%" PRIu32 " "
915 "broadcast %" PRIu32 ".%" PRIu32
916 ".%" PRIu32 ".%" PRIu32 "\n",
917 (p->ip >> 24) & 0xFF,
918 (p->ip >> 16) & 0xFF,
921 (netmask >> 24) & 0xFF,
922 (netmask >> 16) & 0xFF,
923 (netmask >> 8) & 0xFF,
925 (bcast >> 24) & 0xFF,
926 (bcast >> 16) & 0xFF,
930 printf("\tether %02" PRIx32 ":%02" PRIx32 ":%02" PRIx32
931 ":%02" PRIx32 ":%02" PRIx32 ":%02" PRIx32 "\n",
932 mac_addr->addr_bytes[0],
933 mac_addr->addr_bytes[1],
934 mac_addr->addr_bytes[2],
935 mac_addr->addr_bytes[3],
936 mac_addr->addr_bytes[4],
937 mac_addr->addr_bytes[5]);
939 printf("\tRX packets %" PRIu64
945 printf("\tRX errors %" PRIu64
953 printf("\tTX packets %" PRIu64
954 " bytes %" PRIu64 "\n",
958 printf("\tTX errors %" PRIu64
969 * link <linkid> config <ipaddr> <depth>
981 struct cmd_link_result {
982 cmdline_fixed_string_t link_string;
983 cmdline_multi_string_t multi_string;
989 __attribute__((unused)) struct cmdline *cl,
992 struct cmd_link_result *params = parsed_result;
993 struct app_params *app = data;
996 uint32_t n_tokens = RTE_DIM(tokens);
1001 status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
1003 printf(CMD_MSG_TOO_MANY_ARGS, "link");
1008 if ((n_tokens == 1) && (strcmp(tokens[0], "ls") == 0)) {
1009 for (link_id = 0; link_id < app->n_links; link_id++) {
1010 struct app_link_params *p;
1012 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
1019 printf(CMD_MSG_MISMATCH_ARGS, "link");
1023 if (parser_read_uint32(&link_id, tokens[0])) {
1024 printf(CMD_MSG_INVALID_ARG, "linkid");
1029 if (strcmp(tokens[1], "config") == 0) {
1030 struct in_addr ipaddr_ipv4;
1033 if (n_tokens != 4) {
1034 printf(CMD_MSG_MISMATCH_ARGS, "link config");
1038 if (parse_ipv4_addr(tokens[2], &ipaddr_ipv4)) {
1039 printf(CMD_MSG_INVALID_ARG, "ipaddr");
1043 if (parser_read_uint32(&depth, tokens[3])) {
1044 printf(CMD_MSG_INVALID_ARG, "depth");
1048 status = app_link_config(app,
1050 rte_be_to_cpu_32(ipaddr_ipv4.s_addr),
1053 printf(CMD_MSG_FAIL, "link config");
1059 if (strcmp(tokens[1], "up") == 0) {
1060 if (n_tokens != 2) {
1061 printf(CMD_MSG_MISMATCH_ARGS, "link up");
1065 status = app_link_up(app, link_id);
1067 printf(CMD_MSG_FAIL, "link up");
1073 if (strcmp(tokens[1], "down") == 0) {
1074 if (n_tokens != 2) {
1075 printf(CMD_MSG_MISMATCH_ARGS, "link down");
1079 status = app_link_down(app, link_id);
1081 printf(CMD_MSG_FAIL, "link down");
1086 printf(CMD_MSG_MISMATCH_ARGS, "link");
1089 static cmdline_parse_token_string_t cmd_link_link_string =
1090 TOKEN_STRING_INITIALIZER(struct cmd_link_result, link_string, "link");
1092 static cmdline_parse_token_string_t cmd_link_multi_string =
1093 TOKEN_STRING_INITIALIZER(struct cmd_link_result, multi_string,
1094 TOKEN_STRING_MULTI);
1096 static cmdline_parse_inst_t cmd_link = {
1097 .f = cmd_link_parsed,
1099 .help_str = "link config / up / down / ls",
1101 (void *) &cmd_link_link_string,
1102 (void *) &cmd_link_multi_string,
1111 struct cmd_quit_result {
1112 cmdline_fixed_string_t quit;
1117 __rte_unused void *parsed_result,
1119 __rte_unused void *data)
1124 static cmdline_parse_token_string_t cmd_quit_quit =
1125 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
1127 static cmdline_parse_inst_t cmd_quit = {
1128 .f = cmd_quit_parsed,
1132 (void *) &cmd_quit_quit,
1141 * run <file> [<count> [<interval>]]
1142 <count> default is 1
1143 * <interval> is measured in milliseconds, default is 1 second
1148 cmdline_parse_ctx_t *ctx,
1149 const char *file_name)
1151 struct cmdline *file_cl;
1154 fd = open(file_name, O_RDONLY);
1156 printf("Cannot open file \"%s\"\n", file_name);
1160 file_cl = cmdline_new(ctx, "", fd, 1);
1161 cmdline_interact(file_cl);
1165 struct cmd_run_result {
1166 cmdline_fixed_string_t run_string;
1167 cmdline_multi_string_t multi_string;
1172 void *parsed_result,
1174 __attribute__((unused)) void *data)
1176 struct cmd_run_result *params = parsed_result;
1179 uint32_t n_tokens = RTE_DIM(tokens);
1183 uint32_t count, interval, i;
1185 status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
1187 printf(CMD_MSG_TOO_MANY_ARGS, "run");
1193 printf(CMD_MSG_NOT_ENOUGH_ARGS, "run");
1197 file_name = tokens[0];
1203 file_name = tokens[0];
1205 if (parser_read_uint32(&count, tokens[1]) ||
1207 printf(CMD_MSG_INVALID_ARG, "count");
1215 file_name = tokens[0];
1217 if (parser_read_uint32(&count, tokens[1]) ||
1219 printf(CMD_MSG_INVALID_ARG, "count");
1223 if (parser_read_uint32(&interval, tokens[2]) ||
1225 printf(CMD_MSG_INVALID_ARG, "interval");
1231 printf(CMD_MSG_MISMATCH_ARGS, "run");
1235 for (i = 0; i < count; i++) {
1236 app_run_file(cl->ctx, file_name);
1238 usleep(interval * 1000);
1242 static cmdline_parse_token_string_t cmd_run_run_string =
1243 TOKEN_STRING_INITIALIZER(struct cmd_run_result, run_string, "run");
1245 static cmdline_parse_token_string_t cmd_run_multi_string =
1246 TOKEN_STRING_INITIALIZER(struct cmd_run_result, multi_string,
1247 TOKEN_STRING_MULTI);
1250 static cmdline_parse_inst_t cmd_run = {
1251 .f = cmd_run_parsed,
1253 .help_str = "Run CLI script file",
1255 (void *) &cmd_run_run_string,
1256 (void *) &cmd_run_multi_string,
1261 static cmdline_parse_ctx_t pipeline_common_cmds[] = {
1262 (cmdline_parse_inst_t *) &cmd_quit,
1263 (cmdline_parse_inst_t *) &cmd_run,
1264 (cmdline_parse_inst_t *) &cmd_link,
1265 (cmdline_parse_inst_t *) &cmd_ping,
1266 (cmdline_parse_inst_t *) &cmd_stats_port_in,
1267 (cmdline_parse_inst_t *) &cmd_stats_port_out,
1268 (cmdline_parse_inst_t *) &cmd_stats_table,
1269 (cmdline_parse_inst_t *) &cmd_port_in_enable,
1270 (cmdline_parse_inst_t *) &cmd_port_in_disable,
1275 app_pipeline_common_cmd_push(struct app_params *app)
1279 /* Check for available slots in the application commands array */
1280 n_cmds = RTE_DIM(pipeline_common_cmds) - 1;
1281 if (n_cmds > APP_MAX_CMDS - app->n_cmds)
1284 /* Push pipeline commands into the application */
1285 memcpy(&app->cmds[app->n_cmds],
1286 pipeline_common_cmds,
1287 n_cmds * sizeof(cmdline_parse_ctx_t));
1289 for (i = 0; i < n_cmds; i++)
1290 app->cmds[app->n_cmds + i]->data = app;
1292 app->n_cmds += n_cmds;
1293 app->cmds[app->n_cmds] = NULL;