1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
20 static const char usage[] =
21 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
23 static const char welcome[] =
25 "Welcome to IP Pipeline!\n"
28 static const char prompt[] = "pipeline> ";
30 static struct app_params {
31 struct conn_params conn;
39 .buf_size = 1024 * 1024,
40 .msg_in_len_max = 1024,
41 .msg_out_len_max = 1024 * 1024,
42 .msg_handle = cli_process,
48 parse_args(int argc, char **argv)
50 char *app_name = argv[0];
51 struct option lgopts[] = {
54 int opt, option_index;
55 int h_present, p_present, s_present, n_args, i;
57 /* Skip EAL input args */
59 for (i = 0; i < n_args; i++)
60 if (strcmp(argv[i], "--") == 0) {
74 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
79 printf("Error: Multiple -h arguments\n");
84 if (!strlen(optarg)) {
85 printf("Error: Argument for -h not provided\n");
89 app.conn.addr = strdup(optarg);
90 if (app.conn.addr == NULL) {
91 printf("Error: Not enough memory\n");
98 printf("Error: Multiple -p arguments\n");
103 if (!strlen(optarg)) {
104 printf("Error: Argument for -p not provided\n");
108 app.conn.port = (uint16_t) atoi(optarg);
113 printf("Error: Multiple -s arguments\n");
118 if (!strlen(optarg)) {
119 printf("Error: Argument for -s not provided\n");
123 app.script_name = strdup(optarg);
124 if (app.script_name == NULL) {
125 printf("Error: Not enough memory\n");
131 printf(usage, app_name);
135 optind = 1; /* reset getopt lib */
141 main(int argc, char **argv)
146 /* Parse application arguments */
147 status = parse_args(argc, argv);
152 status = rte_eal_init(argc, argv);
154 printf("Error: EAL initialization failed (%d)\n", status);
159 conn = conn_init(&app.conn);
161 printf("Error: Connectivity initialization failed (%d)\n",
167 status = mempool_init();
169 printf("Error: Mempool initialization failed (%d)\n", status);
174 status = link_init();
176 printf("Error: Link initialization failed (%d)\n", status);
183 printf("Error: SWQ initialization failed (%d)\n", status);
187 /* Traffic Manager */
188 status = tmgr_init();
190 printf("Error: TMGR initialization failed (%d)\n", status);
196 cli_script_process(app.script_name,
197 app.conn.msg_in_len_max,
198 app.conn.msg_out_len_max);
202 conn_poll_for_conn(conn);
204 conn_poll_for_msg(conn);