1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
11 #include <rte_launch.h>
18 static const char usage[] =
19 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
21 static struct app_params {
22 struct conn_params conn;
26 .welcome = "\nWelcome!\n\n",
27 .prompt = "pipeline> ",
30 .buf_size = 1024 * 1024,
31 .msg_in_len_max = 1024,
32 .msg_out_len_max = 1024 * 1024,
34 .msg_handle_arg = NULL, /* set later. */
40 parse_args(int argc, char **argv)
42 char *app_name = argv[0];
43 struct option lgopts[] = {
46 int opt, option_index;
47 int h_present, p_present, s_present, n_args, i;
49 /* Skip EAL input args */
51 for (i = 0; i < n_args; i++)
52 if (strcmp(argv[i], "--") == 0) {
66 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
71 printf("Error: Multiple -h arguments\n");
76 if (!strlen(optarg)) {
77 printf("Error: Argument for -h not provided\n");
81 app.conn.addr = strdup(optarg);
82 if (app.conn.addr == NULL) {
83 printf("Error: Not enough memory\n");
90 printf("Error: Multiple -p arguments\n");
95 if (!strlen(optarg)) {
96 printf("Error: Argument for -p not provided\n");
100 app.conn.port = (uint16_t) atoi(optarg);
105 printf("Error: Multiple -s arguments\n");
110 if (!strlen(optarg)) {
111 printf("Error: Argument for -s not provided\n");
115 app.script_name = strdup(optarg);
116 if (app.script_name == NULL) {
117 printf("Error: Not enough memory\n");
123 printf(usage, app_name);
127 optind = 1; /* reset getopt lib */
133 main(int argc, char **argv)
139 /* Parse application arguments */
140 status = parse_args(argc, argv);
145 status = rte_eal_init(argc, argv);
147 printf("Error: EAL initialization failed (%d)\n", status);
154 printf("Error: Obj initialization failed (%d)\n", status);
159 status = thread_init();
161 printf("Error: Thread initialization failed (%d)\n", status);
165 rte_eal_mp_remote_launch(
171 app.conn.msg_handle_arg = obj;
172 conn = conn_init(&app.conn);
174 printf("Error: Connectivity initialization failed (%d)\n",
181 conn_poll_for_conn(conn);
183 conn_poll_for_msg(conn);