1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
11 #include <rte_launch.h>
19 static const char usage[] =
20 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
22 static struct app_params {
23 struct conn_params conn;
27 .welcome = "\nWelcome!\n\n",
28 .prompt = "pipeline> ",
31 .buf_size = 1024 * 1024,
32 .msg_in_len_max = 1024,
33 .msg_out_len_max = 1024 * 1024,
34 .msg_handle = cli_process,
35 .msg_handle_arg = NULL, /* set later. */
41 parse_args(int argc, char **argv)
43 char *app_name = argv[0];
44 struct option lgopts[] = {
47 int opt, option_index;
48 int h_present, p_present, s_present, n_args, i;
50 /* Skip EAL input args */
52 for (i = 0; i < n_args; i++)
53 if (strcmp(argv[i], "--") == 0) {
67 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
72 printf("Error: Multiple -h arguments\n");
77 if (!strlen(optarg)) {
78 printf("Error: Argument for -h not provided\n");
82 app.conn.addr = strdup(optarg);
83 if (app.conn.addr == NULL) {
84 printf("Error: Not enough memory\n");
91 printf("Error: Multiple -p arguments\n");
96 if (!strlen(optarg)) {
97 printf("Error: Argument for -p not provided\n");
101 app.conn.port = (uint16_t) atoi(optarg);
106 printf("Error: Multiple -s arguments\n");
111 if (!strlen(optarg)) {
112 printf("Error: Argument for -s not provided\n");
116 app.script_name = strdup(optarg);
117 if (app.script_name == NULL) {
118 printf("Error: Not enough memory\n");
124 printf(usage, app_name);
128 optind = 1; /* reset getopt lib */
134 main(int argc, char **argv)
140 /* Parse application arguments */
141 status = parse_args(argc, argv);
146 status = rte_eal_init(argc, argv);
148 printf("Error: EAL initialization failed (%d)\n", status);
155 printf("Error: Obj initialization failed (%d)\n", status);
160 status = thread_init();
162 printf("Error: Thread initialization failed (%d)\n", status);
166 rte_eal_mp_remote_launch(
173 cli_script_process(app.script_name,
174 app.conn.msg_in_len_max,
175 app.conn.msg_out_len_max,
179 app.conn.msg_handle_arg = obj;
180 conn = conn_init(&app.conn);
182 printf("Error: Connectivity initialization failed (%d)\n",
189 conn_poll_for_conn(conn);
191 conn_poll_for_msg(conn);
194 /* clean up the EAL */