4 * Copyright(c) 2010-2015 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>
45 #include <cmdline_parse_ipaddr.h>
46 #include <cmdline_parse_etheraddr.h>
47 #include <cmdline_socket.h>
50 #include "pipeline_common_fe.h"
53 app_pipeline_ping(struct app_params *app,
56 struct app_pipeline_params *p;
57 struct pipeline_msg_req *req;
58 struct pipeline_msg_rsp *rsp;
61 /* Check input arguments */
65 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
69 /* Message buffer allocation */
70 req = app_msg_alloc(app);
75 req->type = PIPELINE_MSG_REQ_PING;
77 /* Send request and wait for response */
78 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
85 /* Message buffer free */
86 app_msg_free(app, rsp);
92 app_pipeline_stats_port_in(struct app_params *app,
95 struct rte_pipeline_port_in_stats *stats)
97 struct app_pipeline_params *p;
98 struct pipeline_stats_msg_req *req;
99 struct pipeline_stats_port_in_msg_rsp *rsp;
102 /* Check input arguments */
107 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
109 (port_id >= p->n_pktq_in))
112 /* Message buffer allocation */
113 req = app_msg_alloc(app);
117 /* Fill in request */
118 req->type = PIPELINE_MSG_REQ_STATS_PORT_IN;
121 /* Send request and wait for response */
122 rsp = (struct pipeline_stats_port_in_msg_rsp *)
123 app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
128 status = rsp->status;
130 memcpy(stats, &rsp->stats, sizeof(rsp->stats));
132 /* Message buffer free */
133 app_msg_free(app, rsp);
139 app_pipeline_stats_port_out(struct app_params *app,
140 uint32_t pipeline_id,
142 struct rte_pipeline_port_out_stats *stats)
144 struct app_pipeline_params *p;
145 struct pipeline_stats_msg_req *req;
146 struct pipeline_stats_port_out_msg_rsp *rsp;
149 /* Check input arguments */
151 (pipeline_id >= app->n_pipelines) ||
155 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
157 (port_id >= p->n_pktq_out))
160 /* Message buffer allocation */
161 req = app_msg_alloc(app);
165 /* Fill in request */
166 req->type = PIPELINE_MSG_REQ_STATS_PORT_OUT;
169 /* Send request and wait for response */
170 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
175 status = rsp->status;
177 memcpy(stats, &rsp->stats, sizeof(rsp->stats));
179 /* Message buffer free */
180 app_msg_free(app, rsp);
186 app_pipeline_stats_table(struct app_params *app,
187 uint32_t pipeline_id,
189 struct rte_pipeline_table_stats *stats)
191 struct app_pipeline_params *p;
192 struct pipeline_stats_msg_req *req;
193 struct pipeline_stats_table_msg_rsp *rsp;
196 /* Check input arguments */
201 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
205 /* Message buffer allocation */
206 req = app_msg_alloc(app);
210 /* Fill in request */
211 req->type = PIPELINE_MSG_REQ_STATS_TABLE;
214 /* Send request and wait for response */
215 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
220 status = rsp->status;
222 memcpy(stats, &rsp->stats, sizeof(rsp->stats));
224 /* Message buffer free */
225 app_msg_free(app, rsp);
231 app_pipeline_port_in_enable(struct app_params *app,
232 uint32_t pipeline_id,
235 struct app_pipeline_params *p;
236 struct pipeline_port_in_msg_req *req;
237 struct pipeline_msg_rsp *rsp;
240 /* Check input arguments */
244 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
246 (port_id >= p->n_pktq_in))
249 /* Message buffer allocation */
250 req = app_msg_alloc(app);
254 /* Fill in request */
255 req->type = PIPELINE_MSG_REQ_PORT_IN_ENABLE;
256 req->port_id = port_id;
258 /* Send request and wait for response */
259 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
264 status = rsp->status;
266 /* Message buffer free */
267 app_msg_free(app, rsp);
273 app_pipeline_port_in_disable(struct app_params *app,
274 uint32_t pipeline_id,
277 struct app_pipeline_params *p;
278 struct pipeline_port_in_msg_req *req;
279 struct pipeline_msg_rsp *rsp;
282 /* Check input arguments */
286 APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
288 (port_id >= p->n_pktq_in))
291 /* Message buffer allocation */
292 req = app_msg_alloc(app);
296 /* Fill in request */
297 req->type = PIPELINE_MSG_REQ_PORT_IN_DISABLE;
298 req->port_id = port_id;
300 /* Send request and wait for response */
301 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
306 status = rsp->status;
308 /* Message buffer free */
309 app_msg_free(app, rsp);
315 app_link_config(struct app_params *app,
320 struct app_link_params *p;
321 uint32_t i, netmask, host, bcast;
323 /* Check input arguments */
327 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
329 APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
335 APP_LOG(app, HIGH, "%s is UP, please bring it DOWN first",
340 netmask = (~0) << (32 - depth);
342 bcast = host | (~netmask);
345 (ip == UINT32_MAX) ||
348 APP_LOG(app, HIGH, "Illegal IP address");
352 for (i = 0; i < app->n_links; i++) {
353 struct app_link_params *link = &app->link_params[i];
355 if (strcmp(p->name, link->name) == 0)
358 if (link->ip == ip) {
360 "%s is already assigned this IP address",
366 if ((depth == 0) || (depth > 32)) {
367 APP_LOG(app, HIGH, "Illegal value for depth parameter "
373 /* Save link parameters */
381 app_link_up(struct app_params *app,
384 struct app_link_params *p;
386 /* Check input arguments */
390 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
392 APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
397 /* Check link state */
399 APP_LOG(app, HIGH, "%s is already UP", p->name);
403 /* Check that IP address is valid */
405 APP_LOG(app, HIGH, "%s IP address is not set", p->name);
409 app_link_up_internal(app, p);
415 app_link_down(struct app_params *app,
418 struct app_link_params *p;
420 /* Check input arguments */
424 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
426 APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
431 /* Check link state */
433 APP_LOG(app, HIGH, "%s is already DOWN", p->name);
437 app_link_down_internal(app, p);
446 struct cmd_ping_result {
447 cmdline_fixed_string_t p_string;
448 uint32_t pipeline_id;
449 cmdline_fixed_string_t ping_string;
455 __rte_unused struct cmdline *cl,
458 struct cmd_ping_result *params = parsed_result;
459 struct app_params *app = data;
462 status = app_pipeline_ping(app, params->pipeline_id);
464 printf("Command failed\n");
467 cmdline_parse_token_string_t cmd_ping_p_string =
468 TOKEN_STRING_INITIALIZER(struct cmd_ping_result, p_string, "p");
470 cmdline_parse_token_num_t cmd_ping_pipeline_id =
471 TOKEN_NUM_INITIALIZER(struct cmd_ping_result, pipeline_id, UINT32);
473 cmdline_parse_token_string_t cmd_ping_ping_string =
474 TOKEN_STRING_INITIALIZER(struct cmd_ping_result, ping_string, "ping");
476 cmdline_parse_inst_t cmd_ping = {
477 .f = cmd_ping_parsed,
479 .help_str = "Pipeline ping",
481 (void *) &cmd_ping_p_string,
482 (void *) &cmd_ping_pipeline_id,
483 (void *) &cmd_ping_ping_string,
492 struct cmd_stats_port_in_result {
493 cmdline_fixed_string_t p_string;
494 uint32_t pipeline_id;
495 cmdline_fixed_string_t stats_string;
496 cmdline_fixed_string_t port_string;
497 cmdline_fixed_string_t in_string;
502 cmd_stats_port_in_parsed(
504 __rte_unused struct cmdline *cl,
507 struct cmd_stats_port_in_result *params = parsed_result;
508 struct app_params *app = data;
509 struct rte_pipeline_port_in_stats stats;
512 status = app_pipeline_stats_port_in(app,
518 printf("Command failed\n");
523 printf("Pipeline %" PRIu32 " - stats for input port %" PRIu32 ":\n"
524 "\tPkts in: %" PRIu64 "\n"
525 "\tPkts dropped by AH: %" PRIu64 "\n"
526 "\tPkts dropped by other: %" PRIu64 "\n",
529 stats.stats.n_pkts_in,
530 stats.n_pkts_dropped_by_ah,
531 stats.stats.n_pkts_drop);
534 cmdline_parse_token_string_t cmd_stats_port_in_p_string =
535 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, p_string,
538 cmdline_parse_token_num_t cmd_stats_port_in_pipeline_id =
539 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, pipeline_id,
542 cmdline_parse_token_string_t cmd_stats_port_in_stats_string =
543 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, stats_string,
546 cmdline_parse_token_string_t cmd_stats_port_in_port_string =
547 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, port_string,
550 cmdline_parse_token_string_t cmd_stats_port_in_in_string =
551 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, in_string,
554 cmdline_parse_token_num_t cmd_stats_port_in_port_in_id =
555 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, port_in_id,
558 cmdline_parse_inst_t cmd_stats_port_in = {
559 .f = cmd_stats_port_in_parsed,
561 .help_str = "Pipeline input port stats",
563 (void *) &cmd_stats_port_in_p_string,
564 (void *) &cmd_stats_port_in_pipeline_id,
565 (void *) &cmd_stats_port_in_stats_string,
566 (void *) &cmd_stats_port_in_port_string,
567 (void *) &cmd_stats_port_in_in_string,
568 (void *) &cmd_stats_port_in_port_in_id,
577 struct cmd_stats_port_out_result {
578 cmdline_fixed_string_t p_string;
579 uint32_t pipeline_id;
580 cmdline_fixed_string_t stats_string;
581 cmdline_fixed_string_t port_string;
582 cmdline_fixed_string_t out_string;
583 uint32_t port_out_id;
587 cmd_stats_port_out_parsed(
589 __rte_unused struct cmdline *cl,
593 struct cmd_stats_port_out_result *params = parsed_result;
594 struct app_params *app = data;
595 struct rte_pipeline_port_out_stats stats;
598 status = app_pipeline_stats_port_out(app,
604 printf("Command failed\n");
609 printf("Pipeline %" PRIu32 " - stats for output port %" PRIu32 ":\n"
610 "\tPkts in: %" PRIu64 "\n"
611 "\tPkts dropped by AH: %" PRIu64 "\n"
612 "\tPkts dropped by other: %" PRIu64 "\n",
615 stats.stats.n_pkts_in,
616 stats.n_pkts_dropped_by_ah,
617 stats.stats.n_pkts_drop);
620 cmdline_parse_token_string_t cmd_stats_port_out_p_string =
621 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, p_string,
624 cmdline_parse_token_num_t cmd_stats_port_out_pipeline_id =
625 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, pipeline_id,
628 cmdline_parse_token_string_t cmd_stats_port_out_stats_string =
629 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, stats_string,
632 cmdline_parse_token_string_t cmd_stats_port_out_port_string =
633 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, port_string,
636 cmdline_parse_token_string_t cmd_stats_port_out_out_string =
637 TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, out_string,
640 cmdline_parse_token_num_t cmd_stats_port_out_port_out_id =
641 TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, port_out_id,
644 cmdline_parse_inst_t cmd_stats_port_out = {
645 .f = cmd_stats_port_out_parsed,
647 .help_str = "Pipeline output port stats",
649 (void *) &cmd_stats_port_out_p_string,
650 (void *) &cmd_stats_port_out_pipeline_id,
651 (void *) &cmd_stats_port_out_stats_string,
652 (void *) &cmd_stats_port_out_port_string,
653 (void *) &cmd_stats_port_out_out_string,
654 (void *) &cmd_stats_port_out_port_out_id,
663 struct cmd_stats_table_result {
664 cmdline_fixed_string_t p_string;
665 uint32_t pipeline_id;
666 cmdline_fixed_string_t stats_string;
667 cmdline_fixed_string_t table_string;
672 cmd_stats_table_parsed(
674 __rte_unused struct cmdline *cl,
677 struct cmd_stats_table_result *params = parsed_result;
678 struct app_params *app = data;
679 struct rte_pipeline_table_stats stats;
682 status = app_pipeline_stats_table(app,
688 printf("Command failed\n");
693 printf("Pipeline %" PRIu32 " - stats for table %" PRIu32 ":\n"
694 "\tPkts in: %" PRIu64 "\n"
695 "\tPkts in with lookup miss: %" PRIu64 "\n"
696 "\tPkts in with lookup hit dropped by AH: %" PRIu64 "\n"
697 "\tPkts in with lookup hit dropped by others: %" PRIu64 "\n"
698 "\tPkts in with lookup miss dropped by AH: %" PRIu64 "\n"
699 "\tPkts in with lookup miss dropped by others: %" PRIu64 "\n",
702 stats.stats.n_pkts_in,
703 stats.stats.n_pkts_lookup_miss,
704 stats.n_pkts_dropped_by_lkp_hit_ah,
705 stats.n_pkts_dropped_lkp_hit,
706 stats.n_pkts_dropped_by_lkp_miss_ah,
707 stats.n_pkts_dropped_lkp_miss);
710 cmdline_parse_token_string_t cmd_stats_table_p_string =
711 TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, p_string,
714 cmdline_parse_token_num_t cmd_stats_table_pipeline_id =
715 TOKEN_NUM_INITIALIZER(struct cmd_stats_table_result, pipeline_id,
718 cmdline_parse_token_string_t cmd_stats_table_stats_string =
719 TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, stats_string,
722 cmdline_parse_token_string_t cmd_stats_table_table_string =
723 TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, table_string,
726 cmdline_parse_token_num_t cmd_stats_table_table_id =
727 TOKEN_NUM_INITIALIZER(struct cmd_stats_table_result, table_id, UINT32);
729 cmdline_parse_inst_t cmd_stats_table = {
730 .f = cmd_stats_table_parsed,
732 .help_str = "Pipeline table stats",
734 (void *) &cmd_stats_table_p_string,
735 (void *) &cmd_stats_table_pipeline_id,
736 (void *) &cmd_stats_table_stats_string,
737 (void *) &cmd_stats_table_table_string,
738 (void *) &cmd_stats_table_table_id,
747 struct cmd_port_in_enable_result {
748 cmdline_fixed_string_t p_string;
749 uint32_t pipeline_id;
750 cmdline_fixed_string_t port_string;
751 cmdline_fixed_string_t in_string;
753 cmdline_fixed_string_t enable_string;
757 cmd_port_in_enable_parsed(
759 __rte_unused struct cmdline *cl,
762 struct cmd_port_in_enable_result *params = parsed_result;
763 struct app_params *app = data;
766 status = app_pipeline_port_in_enable(app,
771 printf("Command failed\n");
774 cmdline_parse_token_string_t cmd_port_in_enable_p_string =
775 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, p_string,
778 cmdline_parse_token_num_t cmd_port_in_enable_pipeline_id =
779 TOKEN_NUM_INITIALIZER(struct cmd_port_in_enable_result, pipeline_id,
782 cmdline_parse_token_string_t cmd_port_in_enable_port_string =
783 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, port_string,
786 cmdline_parse_token_string_t cmd_port_in_enable_in_string =
787 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, in_string,
790 cmdline_parse_token_num_t cmd_port_in_enable_port_in_id =
791 TOKEN_NUM_INITIALIZER(struct cmd_port_in_enable_result, port_in_id,
794 cmdline_parse_token_string_t cmd_port_in_enable_enable_string =
795 TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result,
796 enable_string, "enable");
798 cmdline_parse_inst_t cmd_port_in_enable = {
799 .f = cmd_port_in_enable_parsed,
801 .help_str = "Pipeline input port enable",
803 (void *) &cmd_port_in_enable_p_string,
804 (void *) &cmd_port_in_enable_pipeline_id,
805 (void *) &cmd_port_in_enable_port_string,
806 (void *) &cmd_port_in_enable_in_string,
807 (void *) &cmd_port_in_enable_port_in_id,
808 (void *) &cmd_port_in_enable_enable_string,
817 struct cmd_port_in_disable_result {
818 cmdline_fixed_string_t p_string;
819 uint32_t pipeline_id;
820 cmdline_fixed_string_t port_string;
821 cmdline_fixed_string_t in_string;
823 cmdline_fixed_string_t disable_string;
827 cmd_port_in_disable_parsed(
829 __rte_unused struct cmdline *cl,
832 struct cmd_port_in_disable_result *params = parsed_result;
833 struct app_params *app = data;
836 status = app_pipeline_port_in_disable(app,
841 printf("Command failed\n");
844 cmdline_parse_token_string_t cmd_port_in_disable_p_string =
845 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, p_string,
848 cmdline_parse_token_num_t cmd_port_in_disable_pipeline_id =
849 TOKEN_NUM_INITIALIZER(struct cmd_port_in_disable_result, pipeline_id,
852 cmdline_parse_token_string_t cmd_port_in_disable_port_string =
853 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, port_string,
856 cmdline_parse_token_string_t cmd_port_in_disable_in_string =
857 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, in_string,
860 cmdline_parse_token_num_t cmd_port_in_disable_port_in_id =
861 TOKEN_NUM_INITIALIZER(struct cmd_port_in_disable_result, port_in_id,
864 cmdline_parse_token_string_t cmd_port_in_disable_disable_string =
865 TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result,
866 disable_string, "disable");
868 cmdline_parse_inst_t cmd_port_in_disable = {
869 .f = cmd_port_in_disable_parsed,
871 .help_str = "Pipeline input port disable",
873 (void *) &cmd_port_in_disable_p_string,
874 (void *) &cmd_port_in_disable_pipeline_id,
875 (void *) &cmd_port_in_disable_port_string,
876 (void *) &cmd_port_in_disable_in_string,
877 (void *) &cmd_port_in_disable_port_in_id,
878 (void *) &cmd_port_in_disable_disable_string,
888 print_link_info(struct app_link_params *p)
890 struct rte_eth_stats stats;
891 struct ether_addr *mac_addr;
892 uint32_t netmask = (~0) << (32 - p->depth);
893 uint32_t host = p->ip & netmask;
894 uint32_t bcast = host | (~netmask);
896 memset(&stats, 0, sizeof(stats));
897 rte_eth_stats_get(p->pmd_id, &stats);
899 mac_addr = (struct ether_addr *) &p->mac_addr;
901 printf("%s: flags=<%s>\n",
903 (p->state) ? "UP" : "DOWN");
906 printf("\tinet %" PRIu32 ".%" PRIu32
907 ".%" PRIu32 ".%" PRIu32
908 " netmask %" PRIu32 ".%" PRIu32
909 ".%" PRIu32 ".%" PRIu32 " "
910 "broadcast %" PRIu32 ".%" PRIu32
911 ".%" PRIu32 ".%" PRIu32 "\n",
912 (p->ip >> 24) & 0xFF,
913 (p->ip >> 16) & 0xFF,
916 (netmask >> 24) & 0xFF,
917 (netmask >> 16) & 0xFF,
918 (netmask >> 8) & 0xFF,
920 (bcast >> 24) & 0xFF,
921 (bcast >> 16) & 0xFF,
925 printf("\tether %02" PRIx32 ":%02" PRIx32 ":%02" PRIx32
926 ":%02" PRIx32 ":%02" PRIx32 ":%02" PRIx32 "\n",
927 mac_addr->addr_bytes[0],
928 mac_addr->addr_bytes[1],
929 mac_addr->addr_bytes[2],
930 mac_addr->addr_bytes[3],
931 mac_addr->addr_bytes[4],
932 mac_addr->addr_bytes[5]);
934 printf("\tRX packets %" PRIu64
940 printf("\tRX errors %" PRIu64
948 printf("\tTX packets %" PRIu64
949 " bytes %" PRIu64 "\n",
953 printf("\tTX errors %" PRIu64
960 struct cmd_link_config_result {
961 cmdline_fixed_string_t link_string;
963 cmdline_fixed_string_t config_string;
969 cmd_link_config_parsed(
971 __attribute__((unused)) struct cmdline *cl,
974 struct cmd_link_config_result *params = parsed_result;
975 struct app_params *app = data;
978 uint32_t link_id = params->link_id;
979 uint32_t ip = rte_bswap32((uint32_t) params->ip.addr.ipv4.s_addr);
980 uint32_t depth = params->depth;
982 status = app_link_config(app, link_id, ip, depth);
984 printf("Command failed\n");
986 struct app_link_params *p;
988 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
993 cmdline_parse_token_string_t cmd_link_config_link_string =
994 TOKEN_STRING_INITIALIZER(struct cmd_link_config_result, link_string,
997 cmdline_parse_token_num_t cmd_link_config_link_id =
998 TOKEN_NUM_INITIALIZER(struct cmd_link_config_result, link_id, UINT32);
1000 cmdline_parse_token_string_t cmd_link_config_config_string =
1001 TOKEN_STRING_INITIALIZER(struct cmd_link_config_result, config_string,
1004 cmdline_parse_token_ipaddr_t cmd_link_config_ip =
1005 TOKEN_IPV4_INITIALIZER(struct cmd_link_config_result, ip);
1007 cmdline_parse_token_num_t cmd_link_config_depth =
1008 TOKEN_NUM_INITIALIZER(struct cmd_link_config_result, depth, UINT32);
1010 cmdline_parse_inst_t cmd_link_config = {
1011 .f = cmd_link_config_parsed,
1013 .help_str = "Link configuration",
1015 (void *)&cmd_link_config_link_string,
1016 (void *)&cmd_link_config_link_id,
1017 (void *)&cmd_link_config_config_string,
1018 (void *)&cmd_link_config_ip,
1019 (void *)&cmd_link_config_depth,
1028 struct cmd_link_up_result {
1029 cmdline_fixed_string_t link_string;
1031 cmdline_fixed_string_t up_string;
1036 void *parsed_result,
1037 __attribute__((unused)) struct cmdline *cl,
1040 struct cmd_link_up_result *params = parsed_result;
1041 struct app_params *app = data;
1044 status = app_link_up(app, params->link_id);
1046 printf("Command failed\n");
1048 struct app_link_params *p;
1050 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", params->link_id,
1056 cmdline_parse_token_string_t cmd_link_up_link_string =
1057 TOKEN_STRING_INITIALIZER(struct cmd_link_up_result, link_string,
1060 cmdline_parse_token_num_t cmd_link_up_link_id =
1061 TOKEN_NUM_INITIALIZER(struct cmd_link_up_result, link_id, UINT32);
1063 cmdline_parse_token_string_t cmd_link_up_up_string =
1064 TOKEN_STRING_INITIALIZER(struct cmd_link_up_result, up_string, "up");
1066 cmdline_parse_inst_t cmd_link_up = {
1067 .f = cmd_link_up_parsed,
1069 .help_str = "Link UP",
1071 (void *)&cmd_link_up_link_string,
1072 (void *)&cmd_link_up_link_id,
1073 (void *)&cmd_link_up_up_string,
1082 struct cmd_link_down_result {
1083 cmdline_fixed_string_t link_string;
1085 cmdline_fixed_string_t down_string;
1089 cmd_link_down_parsed(
1090 void *parsed_result,
1091 __attribute__((unused)) struct cmdline *cl,
1094 struct cmd_link_down_result *params = parsed_result;
1095 struct app_params *app = data;
1098 status = app_link_down(app, params->link_id);
1100 printf("Command failed\n");
1102 struct app_link_params *p;
1104 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", params->link_id,
1110 cmdline_parse_token_string_t cmd_link_down_link_string =
1111 TOKEN_STRING_INITIALIZER(struct cmd_link_down_result, link_string,
1114 cmdline_parse_token_num_t cmd_link_down_link_id =
1115 TOKEN_NUM_INITIALIZER(struct cmd_link_down_result, link_id, UINT32);
1117 cmdline_parse_token_string_t cmd_link_down_down_string =
1118 TOKEN_STRING_INITIALIZER(struct cmd_link_down_result, down_string,
1121 cmdline_parse_inst_t cmd_link_down = {
1122 .f = cmd_link_down_parsed,
1124 .help_str = "Link DOWN",
1126 (void *) &cmd_link_down_link_string,
1127 (void *) &cmd_link_down_link_id,
1128 (void *) &cmd_link_down_down_string,
1137 struct cmd_link_ls_result {
1138 cmdline_fixed_string_t link_string;
1139 cmdline_fixed_string_t ls_string;
1144 __attribute__((unused)) void *parsed_result,
1145 __attribute__((unused)) struct cmdline *cl,
1148 struct app_params *app = data;
1151 for (link_id = 0; link_id < app->n_links; link_id++) {
1152 struct app_link_params *p;
1154 APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
1159 cmdline_parse_token_string_t cmd_link_ls_link_string =
1160 TOKEN_STRING_INITIALIZER(struct cmd_link_ls_result, link_string,
1163 cmdline_parse_token_string_t cmd_link_ls_ls_string =
1164 TOKEN_STRING_INITIALIZER(struct cmd_link_ls_result, ls_string, "ls");
1166 cmdline_parse_inst_t cmd_link_ls = {
1167 .f = cmd_link_ls_parsed,
1169 .help_str = "Link list",
1171 (void *)&cmd_link_ls_link_string,
1172 (void *)&cmd_link_ls_ls_string,
1181 struct cmd_quit_result {
1182 cmdline_fixed_string_t quit;
1187 __rte_unused void *parsed_result,
1189 __rte_unused void *data)
1194 static cmdline_parse_token_string_t cmd_quit_quit =
1195 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
1197 static cmdline_parse_inst_t cmd_quit = {
1198 .f = cmd_quit_parsed,
1202 (void *) &cmd_quit_quit,
1213 cmdline_parse_ctx_t *ctx,
1214 const char *file_name)
1216 struct cmdline *file_cl;
1219 fd = open(file_name, O_RDONLY);
1221 printf("Cannot open file \"%s\"\n", file_name);
1225 file_cl = cmdline_new(ctx, "", fd, 1);
1226 cmdline_interact(file_cl);
1230 struct cmd_run_file_result {
1231 cmdline_fixed_string_t run_string;
1232 char file_name[APP_FILE_NAME_SIZE];
1237 void *parsed_result,
1239 __attribute__((unused)) void *data)
1241 struct cmd_run_file_result *params = parsed_result;
1243 app_run_file(cl->ctx, params->file_name);
1246 cmdline_parse_token_string_t cmd_run_run_string =
1247 TOKEN_STRING_INITIALIZER(struct cmd_run_file_result, run_string,
1250 cmdline_parse_token_string_t cmd_run_file_name =
1251 TOKEN_STRING_INITIALIZER(struct cmd_run_file_result, file_name, NULL);
1253 cmdline_parse_inst_t cmd_run = {
1254 .f = cmd_run_parsed,
1256 .help_str = "Run CLI script file",
1258 (void *) &cmd_run_run_string,
1259 (void *) &cmd_run_file_name,
1264 static cmdline_parse_ctx_t pipeline_common_cmds[] = {
1265 (cmdline_parse_inst_t *) &cmd_quit,
1266 (cmdline_parse_inst_t *) &cmd_run,
1268 (cmdline_parse_inst_t *) &cmd_link_config,
1269 (cmdline_parse_inst_t *) &cmd_link_up,
1270 (cmdline_parse_inst_t *) &cmd_link_down,
1271 (cmdline_parse_inst_t *) &cmd_link_ls,
1273 (cmdline_parse_inst_t *) &cmd_ping,
1274 (cmdline_parse_inst_t *) &cmd_stats_port_in,
1275 (cmdline_parse_inst_t *) &cmd_stats_port_out,
1276 (cmdline_parse_inst_t *) &cmd_stats_table,
1277 (cmdline_parse_inst_t *) &cmd_port_in_enable,
1278 (cmdline_parse_inst_t *) &cmd_port_in_disable,
1283 app_pipeline_common_cmd_push(struct app_params *app)
1287 /* Check for available slots in the application commands array */
1288 n_cmds = RTE_DIM(pipeline_common_cmds) - 1;
1289 if (n_cmds > APP_MAX_CMDS - app->n_cmds)
1292 /* Push pipeline commands into the application */
1293 memcpy(&app->cmds[app->n_cmds],
1294 pipeline_common_cmds,
1295 n_cmds * sizeof(cmdline_parse_ctx_t *));
1297 for (i = 0; i < n_cmds; i++)
1298 app->cmds[app->n_cmds + i]->data = app;
1300 app->n_cmds += n_cmds;
1301 app->cmds[app->n_cmds] = NULL;