1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
24 static const char usage[] =
25 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
27 static const char welcome[] =
29 "Welcome to IP Pipeline!\n"
32 static const char prompt[] = "pipeline> ";
34 static struct app_params {
35 struct conn_params conn;
43 .buf_size = 1024 * 1024,
44 .msg_in_len_max = 1024,
45 .msg_out_len_max = 1024 * 1024,
46 .msg_handle = cli_process,
52 parse_args(int argc, char **argv)
54 char *app_name = argv[0];
55 struct option lgopts[] = {
58 int opt, option_index;
59 int h_present, p_present, s_present, n_args, i;
61 /* Skip EAL input args */
63 for (i = 0; i < n_args; i++)
64 if (strcmp(argv[i], "--") == 0) {
78 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
83 printf("Error: Multiple -h arguments\n");
88 if (!strlen(optarg)) {
89 printf("Error: Argument for -h not provided\n");
93 app.conn.addr = strdup(optarg);
94 if (app.conn.addr == NULL) {
95 printf("Error: Not enough memory\n");
102 printf("Error: Multiple -p arguments\n");
107 if (!strlen(optarg)) {
108 printf("Error: Argument for -p not provided\n");
112 app.conn.port = (uint16_t) atoi(optarg);
117 printf("Error: Multiple -s arguments\n");
122 if (!strlen(optarg)) {
123 printf("Error: Argument for -s not provided\n");
127 app.script_name = strdup(optarg);
128 if (app.script_name == NULL) {
129 printf("Error: Not enough memory\n");
135 printf(usage, app_name);
139 optind = 1; /* reset getopt lib */
145 main(int argc, char **argv)
150 /* Parse application arguments */
151 status = parse_args(argc, argv);
156 status = rte_eal_init(argc, argv);
158 printf("Error: EAL initialization failed (%d)\n", status);
163 conn = conn_init(&app.conn);
165 printf("Error: Connectivity initialization failed (%d)\n",
171 status = mempool_init();
173 printf("Error: Mempool initialization failed (%d)\n", status);
178 status = link_init();
180 printf("Error: Link initialization failed (%d)\n", status);
187 printf("Error: SWQ initialization failed (%d)\n", status);
191 /* Traffic Manager */
192 status = tmgr_init();
194 printf("Error: TMGR initialization failed (%d)\n", status);
201 printf("Error: TAP initialization failed (%d)\n", status);
208 printf("Error: KNI initialization failed (%d)\n", status);
213 status = port_in_action_profile_init();
215 printf("Error: Input port action profile initialization failed (%d)\n", status);
219 status = table_action_profile_init();
221 printf("Error: Action profile initialization failed (%d)\n",
227 status = pipeline_init();
229 printf("Error: Pipeline initialization failed (%d)\n", status);
234 status = thread_init();
236 printf("Error: Thread initialization failed (%d)\n", status);
242 cli_script_process(app.script_name,
243 app.conn.msg_in_len_max,
244 app.conn.msg_out_len_max);
248 conn_poll_for_conn(conn);
250 conn_poll_for_msg(conn);
252 kni_handle_request();