1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
19 static const char usage[] =
20 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
22 static const char welcome[] =
24 "Welcome to IP Pipeline!\n"
27 static const char prompt[] = "pipeline> ";
29 static struct app_params {
30 struct conn_params conn;
38 .buf_size = 1024 * 1024,
39 .msg_in_len_max = 1024,
40 .msg_out_len_max = 1024 * 1024,
41 .msg_handle = cli_process,
47 parse_args(int argc, char **argv)
49 char *app_name = argv[0];
50 struct option lgopts[] = {
53 int opt, option_index;
54 int h_present, p_present, s_present, n_args, i;
56 /* Skip EAL input args */
58 for (i = 0; i < n_args; i++)
59 if (strcmp(argv[i], "--") == 0) {
73 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
78 printf("Error: Multiple -h arguments\n");
83 if (!strlen(optarg)) {
84 printf("Error: Argument for -h not provided\n");
88 app.conn.addr = strdup(optarg);
89 if (app.conn.addr == NULL) {
90 printf("Error: Not enough memory\n");
97 printf("Error: Multiple -p arguments\n");
102 if (!strlen(optarg)) {
103 printf("Error: Argument for -p not provided\n");
107 app.conn.port = (uint16_t) atoi(optarg);
112 printf("Error: Multiple -s arguments\n");
117 if (!strlen(optarg)) {
118 printf("Error: Argument for -s not provided\n");
122 app.script_name = strdup(optarg);
123 if (app.script_name == NULL) {
124 printf("Error: Not enough memory\n");
130 printf(usage, app_name);
134 optind = 1; /* reset getopt lib */
140 main(int argc, char **argv)
145 /* Parse application arguments */
146 status = parse_args(argc, argv);
151 status = rte_eal_init(argc, argv);
153 printf("Error: EAL initialization failed (%d)\n", status);
158 conn = conn_init(&app.conn);
160 printf("Error: Connectivity initialization failed (%d)\n",
166 status = mempool_init();
168 printf("Error: Mempool initialization failed (%d)\n", status);
173 status = link_init();
175 printf("Error: Link initialization failed (%d)\n", status);
182 printf("Error: SWQ initialization failed (%d)\n", status);
188 cli_script_process(app.script_name,
189 app.conn.msg_in_len_max,
190 app.conn.msg_out_len_max);
194 conn_poll_for_conn(conn);
196 conn_poll_for_msg(conn);