1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
18 static const char usage[] =
19 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
21 static const char welcome[] =
23 "Welcome to IP Pipeline!\n"
26 static const char prompt[] = "pipeline> ";
28 static struct app_params {
29 struct conn_params conn;
37 .buf_size = 1024 * 1024,
38 .msg_in_len_max = 1024,
39 .msg_out_len_max = 1024 * 1024,
40 .msg_handle = cli_process,
46 parse_args(int argc, char **argv)
48 char *app_name = argv[0];
49 struct option lgopts[] = {
52 int opt, option_index;
53 int h_present, p_present, s_present, n_args, i;
55 /* Skip EAL input args */
57 for (i = 0; i < n_args; i++)
58 if (strcmp(argv[i], "--") == 0) {
72 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
77 printf("Error: Multiple -h arguments\n");
82 if (!strlen(optarg)) {
83 printf("Error: Argument for -h not provided\n");
87 app.conn.addr = strdup(optarg);
88 if (app.conn.addr == NULL) {
89 printf("Error: Not enough memory\n");
96 printf("Error: Multiple -p arguments\n");
101 if (!strlen(optarg)) {
102 printf("Error: Argument for -p not provided\n");
106 app.conn.port = (uint16_t) atoi(optarg);
111 printf("Error: Multiple -s arguments\n");
116 if (!strlen(optarg)) {
117 printf("Error: Argument for -s not provided\n");
121 app.script_name = strdup(optarg);
122 if (app.script_name == NULL) {
123 printf("Error: Not enough memory\n");
129 printf(usage, app_name);
133 optind = 1; /* reset getopt lib */
139 main(int argc, char **argv)
144 /* Parse application arguments */
145 status = parse_args(argc, argv);
150 status = rte_eal_init(argc, argv);
152 printf("Error: EAL initialization failed (%d)\n", status);
157 conn = conn_init(&app.conn);
159 printf("Error: Connectivity initialization failed (%d)\n",
165 status = mempool_init();
167 printf("Error: Mempool initialization failed (%d)\n", status);
172 status = link_init();
174 printf("Error: Link initialization failed (%d)\n", status);
180 cli_script_process(app.script_name,
181 app.conn.msg_in_len_max,
182 app.conn.msg_out_len_max);
186 conn_poll_for_conn(conn);
188 conn_poll_for_msg(conn);