1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
17 static const char usage[] =
18 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
20 static const char welcome[] =
22 "Welcome to IP Pipeline!\n"
25 static const char prompt[] = "pipeline> ";
27 static struct app_params {
28 struct conn_params conn;
36 .buf_size = 1024 * 1024,
37 .msg_in_len_max = 1024,
38 .msg_out_len_max = 1024 * 1024,
39 .msg_handle = cli_process,
45 parse_args(int argc, char **argv)
47 char *app_name = argv[0];
48 struct option lgopts[] = {
51 int opt, option_index;
52 int h_present, p_present, s_present, n_args, i;
54 /* Skip EAL input args */
56 for (i = 0; i < n_args; i++)
57 if (strcmp(argv[i], "--") == 0) {
71 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
76 printf("Error: Multiple -h arguments\n");
81 if (!strlen(optarg)) {
82 printf("Error: Argument for -h not provided\n");
86 app.conn.addr = strdup(optarg);
87 if (app.conn.addr == NULL) {
88 printf("Error: Not enough memory\n");
95 printf("Error: Multiple -p arguments\n");
100 if (!strlen(optarg)) {
101 printf("Error: Argument for -p not provided\n");
105 app.conn.port = (uint16_t) atoi(optarg);
110 printf("Error: Multiple -s arguments\n");
115 if (!strlen(optarg)) {
116 printf("Error: Argument for -s not provided\n");
120 app.script_name = strdup(optarg);
121 if (app.script_name == NULL) {
122 printf("Error: Not enough memory\n");
128 printf(usage, app_name);
132 optind = 1; /* reset getopt lib */
138 main(int argc, char **argv)
143 /* Parse application arguments */
144 status = parse_args(argc, argv);
149 status = rte_eal_init(argc, argv);
151 printf("Error: EAL initialization failed (%d)\n", status);
156 conn = conn_init(&app.conn);
158 printf("Error: Connectivity initialization failed (%d)\n",
164 status = mempool_init();
166 printf("Error: Mempool initialization failed (%d)\n", status);
172 cli_script_process(app.script_name,
173 app.conn.msg_in_len_max,
174 app.conn.msg_out_len_max);
178 conn_poll_for_conn(conn);
180 conn_poll_for_msg(conn);