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
;
53 } __rte_cache_aligned
;
56 pipeline_init(__rte_unused
struct pipeline_params
*params
, void *arg
)
58 struct app_params
*app
= (struct app_params
*) arg
;
59 struct pipeline_master
*p
;
62 /* Check input arguments */
66 /* Memory allocation */
67 size
= RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_master
));
68 p
= rte_zmalloc(NULL
, size
, RTE_CACHE_LINE_SIZE
);
75 p
->cl
= cmdline_stdin_new(app
->cmds
, "pipeline> ");
81 p
->post_init_done
= 0;
82 p
->script_file_done
= 0;
83 if (app
->script_file
== NULL
)
84 p
->script_file_done
= 1;
90 pipeline_free(void *pipeline
)
92 struct pipeline_master
*p
= (struct pipeline_master
*) pipeline
;
97 cmdline_stdin_exit(p
->cl
);
104 pipeline_run(void *pipeline
)
106 struct pipeline_master
*p
= (struct pipeline_master
*) pipeline
;
107 struct app_params
*app
= p
->app
;
109 #ifdef RTE_LIBRTE_KNI
111 #endif /* RTE_LIBRTE_KNI */
113 /* Application post-init phase */
114 if (p
->post_init_done
== 0) {
117 p
->post_init_done
= 1;
120 /* Run startup script file */
121 if (p
->script_file_done
== 0) {
122 struct app_params
*app
= p
->app
;
123 int fd
= open(app
->script_file
, O_RDONLY
);
126 printf("Cannot open CLI script file \"%s\"\n",
129 struct cmdline
*file_cl
;
131 printf("Running CLI script file \"%s\" ...\n",
133 file_cl
= cmdline_new(p
->cl
->ctx
, "", fd
, 1);
134 cmdline_interact(file_cl
);
138 p
->script_file_done
= 1;
141 /* Command Line Interface (CLI) */
142 status
= cmdline_poll(p
->cl
);
144 rte_panic("CLI poll error (%" PRId32
")\n", status
);
145 else if (status
== RDLINE_EXITED
) {
146 cmdline_stdin_exit(p
->cl
);
147 rte_exit(0, "Bye!\n");
150 #ifdef RTE_LIBRTE_KNI
151 /* Handle KNI requests from Linux kernel */
152 for (i
= 0; i
< app
->n_pktq_kni
; i
++)
153 rte_kni_handle_request(app
->kni
[i
]);
154 #endif /* RTE_LIBRTE_KNI */
160 pipeline_timer(__rte_unused
void *pipeline
)
165 struct pipeline_be_ops pipeline_master_be_ops
= {
166 .f_init
= pipeline_init
,
167 .f_free
= pipeline_free
,
168 .f_run
= pipeline_run
,
169 .f_timer
= pipeline_timer
,