4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <rte_common.h>
38 #include <rte_malloc.h>
40 #include <cmdline_parse.h>
41 #include <cmdline_parse_string.h>
42 #include <cmdline_socket.h>
46 #include "pipeline_master_be.h"
48 struct pipeline_master {
49 struct app_params *app;
52 } __rte_cache_aligned;
55 pipeline_init(__rte_unused struct pipeline_params *params, void *arg)
57 struct app_params *app = (struct app_params *) arg;
58 struct pipeline_master *p;
61 /* Check input arguments */
65 /* Memory allocation */
66 size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_master));
67 p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
74 p->cl = cmdline_stdin_new(app->cmds, "pipeline> ");
80 p->script_file_done = 0;
81 if (app->script_file == NULL)
82 p->script_file_done = 1;
88 pipeline_free(void *pipeline)
90 struct pipeline_master *p = (struct pipeline_master *) pipeline;
95 cmdline_stdin_exit(p->cl);
102 pipeline_run(void *pipeline)
104 struct pipeline_master *p = (struct pipeline_master *) pipeline;
107 if (p->script_file_done == 0) {
108 struct app_params *app = p->app;
109 int fd = open(app->script_file, O_RDONLY);
112 printf("Cannot open CLI script file \"%s\"\n",
115 struct cmdline *file_cl;
117 printf("Running CLI script file \"%s\" ...\n",
119 file_cl = cmdline_new(p->cl->ctx, "", fd, 1);
120 cmdline_interact(file_cl);
124 p->script_file_done = 1;
127 status = cmdline_poll(p->cl);
129 rte_panic("CLI poll error (%" PRId32 ")\n", status);
130 else if (status == RDLINE_EXITED) {
131 cmdline_stdin_exit(p->cl);
132 rte_exit(0, "Bye!\n");
139 pipeline_timer(__rte_unused void *pipeline)
144 struct pipeline_be_ops pipeline_master_be_ops = {
145 .f_init = pipeline_init,
146 .f_free = pipeline_free,
147 .f_run = pipeline_run,
148 .f_timer = pipeline_timer,