1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
11 #include <rte_launch.h>
25 static const char usage[] =
26 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
28 static const char welcome[] =
30 "Welcome to IP Pipeline!\n"
33 static const char prompt[] = "pipeline> ";
35 static struct app_params {
36 struct conn_params conn;
44 .buf_size = 1024 * 1024,
45 .msg_in_len_max = 1024,
46 .msg_out_len_max = 1024 * 1024,
47 .msg_handle = cli_process,
53 parse_args(int argc, char **argv)
55 char *app_name = argv[0];
56 struct option lgopts[] = {
59 int opt, option_index;
60 int h_present, p_present, s_present, n_args, i;
62 /* Skip EAL input args */
64 for (i = 0; i < n_args; i++)
65 if (strcmp(argv[i], "--") == 0) {
79 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
84 printf("Error: Multiple -h arguments\n");
89 if (!strlen(optarg)) {
90 printf("Error: Argument for -h not provided\n");
94 app.conn.addr = strdup(optarg);
95 if (app.conn.addr == NULL) {
96 printf("Error: Not enough memory\n");
103 printf("Error: Multiple -p arguments\n");
108 if (!strlen(optarg)) {
109 printf("Error: Argument for -p not provided\n");
113 app.conn.port = (uint16_t) atoi(optarg);
118 printf("Error: Multiple -s arguments\n");
123 if (!strlen(optarg)) {
124 printf("Error: Argument for -s not provided\n");
128 app.script_name = strdup(optarg);
129 if (app.script_name == NULL) {
130 printf("Error: Not enough memory\n");
136 printf(usage, app_name);
140 optind = 1; /* reset getopt lib */
146 main(int argc, char **argv)
151 /* Parse application arguments */
152 status = parse_args(argc, argv);
157 status = rte_eal_init(argc, argv);
159 printf("Error: EAL initialization failed (%d)\n", status);
164 conn = conn_init(&app.conn);
166 printf("Error: Connectivity initialization failed (%d)\n",
172 status = mempool_init();
174 printf("Error: Mempool initialization failed (%d)\n", status);
179 status = link_init();
181 printf("Error: Link initialization failed (%d)\n", status);
188 printf("Error: SWQ initialization failed (%d)\n", status);
192 /* Traffic Manager */
193 status = tmgr_init();
195 printf("Error: TMGR initialization failed (%d)\n", status);
202 printf("Error: TAP initialization failed (%d)\n", status);
209 printf("Error: KNI initialization failed (%d)\n", status);
214 status = port_in_action_profile_init();
216 printf("Error: Input port action profile initialization failed (%d)\n", status);
220 status = table_action_profile_init();
222 printf("Error: Action profile initialization failed (%d)\n",
228 status = pipeline_init();
230 printf("Error: Pipeline initialization failed (%d)\n", status);
235 status = thread_init();
237 printf("Error: Thread initialization failed (%d)\n", status);
241 rte_eal_mp_remote_launch(
248 cli_script_process(app.script_name,
249 app.conn.msg_in_len_max,
250 app.conn.msg_out_len_max);
254 conn_poll_for_conn(conn);
256 conn_poll_for_msg(conn);
258 kni_handle_request();