1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_malloc.h>
11 #include <cmdline_parse.h>
12 #include <cmdline_parse_string.h>
13 #include <cmdline_socket.h>
17 #include "pipeline_master_be.h"
19 struct pipeline_master {
20 struct app_params *app;
24 } __rte_cache_aligned;
27 pipeline_init(__rte_unused struct pipeline_params *params, void *arg)
29 struct app_params *app = (struct app_params *) arg;
30 struct pipeline_master *p;
33 /* Check input arguments */
37 /* Memory allocation */
38 size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_master));
39 p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
46 p->cl = cmdline_stdin_new(app->cmds, "pipeline> ");
52 p->post_init_done = 0;
53 p->script_file_done = 0;
54 if (app->script_file == NULL)
55 p->script_file_done = 1;
61 pipeline_free(void *pipeline)
63 struct pipeline_master *p = (struct pipeline_master *) pipeline;
68 cmdline_stdin_exit(p->cl);
75 pipeline_run(void *pipeline)
77 struct pipeline_master *p = (struct pipeline_master *) pipeline;
78 struct app_params *app = p->app;
82 #endif /* RTE_LIBRTE_KNI */
84 /* Application post-init phase */
85 if (p->post_init_done == 0) {
88 p->post_init_done = 1;
91 /* Run startup script file */
92 if (p->script_file_done == 0) {
93 struct app_params *app = p->app;
94 int fd = open(app->script_file, O_RDONLY);
97 printf("Cannot open CLI script file \"%s\"\n",
100 struct cmdline *file_cl;
102 printf("Running CLI script file \"%s\" ...\n",
104 file_cl = cmdline_new(p->cl->ctx, "", fd, 1);
105 cmdline_interact(file_cl);
109 p->script_file_done = 1;
112 /* Command Line Interface (CLI) */
113 status = cmdline_poll(p->cl);
115 rte_panic("CLI poll error (%" PRId32 ")\n", status);
116 else if (status == RDLINE_EXITED) {
117 cmdline_stdin_exit(p->cl);
118 rte_exit(0, "Bye!\n");
121 #ifdef RTE_LIBRTE_KNI
122 /* Handle KNI requests from Linux kernel */
123 for (i = 0; i < app->n_pktq_kni; i++)
124 rte_kni_handle_request(app->kni[i]);
125 #endif /* RTE_LIBRTE_KNI */
131 pipeline_timer(__rte_unused void *pipeline)
136 struct pipeline_be_ops pipeline_master_be_ops = {
137 .f_init = pipeline_init,
138 .f_free = pipeline_free,
139 .f_run = pipeline_run,
140 .f_timer = pipeline_timer,