examples/ip_pipeline: add master pipeline

Master pipeline is responsible for command line handling and
communicationg with all other pipelines via message queues. Removed
cmdline.c file, as its functionality will be split over multiple
pipeline files.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
Jasvinder Singh 2015-07-07 10:09:29 +02:00 committed by Thomas Monjalon
parent bff54484b2
commit ea0908c4ab
11 changed files with 2219 additions and 1976 deletions

View File

@ -55,6 +55,11 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_be.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_fe.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master_be.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master.c
CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS) -Wno-error=unused-function -Wno-error=unused-variable

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,8 @@
#include "app.h"
#include "pipeline.h"
#include "pipeline_common_fe.h"
#include "pipeline_master.h"
#define APP_NAME_SIZE 32
@ -1281,6 +1283,9 @@ int app_init(struct app_params *app)
app_init_tm(app);
app_init_msgq(app);
app_pipeline_common_cmd_push(app);
app_pipeline_type_register(app, &pipeline_master);
app_init_pipelines(app);
app_init_threads(app);

View File

@ -0,0 +1,206 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <rte_common.h>
#include <rte_ring.h>
#include <rte_malloc.h>
#include "pipeline_common_be.h"
void *
pipeline_msg_req_ping_handler(__rte_unused struct pipeline *p,
void *msg)
{
struct pipeline_msg_rsp *rsp = msg;
rsp->status = 0; /* OK */
return rsp;
}
void *
pipeline_msg_req_stats_port_in_handler(struct pipeline *p,
void *msg)
{
struct pipeline_stats_msg_req *req = msg;
struct pipeline_stats_port_in_msg_rsp *rsp = msg;
uint32_t port_id;
/* Check request */
if (req->id >= p->n_ports_in) {
rsp->status = -1;
return rsp;
}
port_id = p->port_in_id[req->id];
/* Process request */
rsp->status = rte_pipeline_port_in_stats_read(p->p,
port_id,
&rsp->stats,
1);
return rsp;
}
void *
pipeline_msg_req_stats_port_out_handler(struct pipeline *p,
void *msg)
{
struct pipeline_stats_msg_req *req = msg;
struct pipeline_stats_port_out_msg_rsp *rsp = msg;
uint32_t port_id;
/* Check request */
if (req->id >= p->n_ports_out) {
rsp->status = -1;
return rsp;
}
port_id = p->port_out_id[req->id];
/* Process request */
rsp->status = rte_pipeline_port_out_stats_read(p->p,
port_id,
&rsp->stats,
1);
return rsp;
}
void *
pipeline_msg_req_stats_table_handler(struct pipeline *p,
void *msg)
{
struct pipeline_stats_msg_req *req = msg;
struct pipeline_stats_table_msg_rsp *rsp = msg;
uint32_t table_id;
/* Check request */
if (req->id >= p->n_tables) {
rsp->status = -1;
return rsp;
}
table_id = p->table_id[req->id];
/* Process request */
rsp->status = rte_pipeline_table_stats_read(p->p,
table_id,
&rsp->stats,
1);
return rsp;
}
void *
pipeline_msg_req_port_in_enable_handler(struct pipeline *p,
void *msg)
{
struct pipeline_port_in_msg_req *req = msg;
struct pipeline_msg_rsp *rsp = msg;
uint32_t port_id;
/* Check request */
if (req->port_id >= p->n_ports_in) {
rsp->status = -1;
return rsp;
}
port_id = p->port_in_id[req->port_id];
/* Process request */
rsp->status = rte_pipeline_port_in_enable(p->p,
port_id);
return rsp;
}
void *
pipeline_msg_req_port_in_disable_handler(struct pipeline *p,
void *msg)
{
struct pipeline_port_in_msg_req *req = msg;
struct pipeline_msg_rsp *rsp = msg;
uint32_t port_id;
/* Check request */
if (req->port_id >= p->n_ports_in) {
rsp->status = -1;
return rsp;
}
port_id = p->port_in_id[req->port_id];
/* Process request */
rsp->status = rte_pipeline_port_in_disable(p->p,
port_id);
return rsp;
}
void *
pipeline_msg_req_invalid_handler(__rte_unused struct pipeline *p,
void *msg)
{
struct pipeline_msg_rsp *rsp = msg;
rsp->status = -1; /* Error */
return rsp;
}
int
pipeline_msg_req_handle(struct pipeline *p)
{
uint32_t msgq_id;
for (msgq_id = 0; msgq_id < p->n_msgq; msgq_id++) {
for ( ; ; ) {
struct pipeline_msg_req *req;
pipeline_msg_req_handler f_handle;
req = pipeline_msg_recv(p, msgq_id);
if (req == NULL)
break;
f_handle = (req->type < PIPELINE_MSG_REQS) ?
p->handlers[req->type] :
pipeline_msg_req_invalid_handler;
if (f_handle == NULL)
f_handle = pipeline_msg_req_invalid_handler;
pipeline_msg_send(p,
msgq_id,
f_handle(p, (void *) req));
}
}
return 0;
}

View File

@ -0,0 +1,163 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __INCLUDE_PIPELINE_COMMON_BE_H__
#define __INCLUDE_PIPELINE_COMMON_BE_H__
#include <rte_common.h>
#include <rte_ring.h>
#include <rte_pipeline.h>
#include "pipeline_be.h"
struct pipeline;
enum pipeline_msg_req_type {
PIPELINE_MSG_REQ_PING = 0,
PIPELINE_MSG_REQ_STATS_PORT_IN,
PIPELINE_MSG_REQ_STATS_PORT_OUT,
PIPELINE_MSG_REQ_STATS_TABLE,
PIPELINE_MSG_REQ_PORT_IN_ENABLE,
PIPELINE_MSG_REQ_PORT_IN_DISABLE,
PIPELINE_MSG_REQ_CUSTOM,
PIPELINE_MSG_REQS
};
typedef void *(*pipeline_msg_req_handler)(struct pipeline *p, void *msg);
struct pipeline {
struct rte_pipeline *p;
uint32_t port_in_id[PIPELINE_MAX_PORT_IN];
uint32_t port_out_id[PIPELINE_MAX_PORT_OUT];
uint32_t table_id[PIPELINE_MAX_TABLES];
struct rte_ring *msgq_in[PIPELINE_MAX_MSGQ_IN];
struct rte_ring *msgq_out[PIPELINE_MAX_MSGQ_OUT];
uint32_t n_ports_in;
uint32_t n_ports_out;
uint32_t n_tables;
uint32_t n_msgq;
pipeline_msg_req_handler handlers[PIPELINE_MSG_REQS];
char name[PIPELINE_NAME_SIZE];
uint32_t log_level;
};
enum pipeline_log_level {
PIPELINE_LOG_LEVEL_HIGH = 1,
PIPELINE_LOG_LEVEL_LOW,
PIPELINE_LOG_LEVELS
};
#define PLOG(p, level, fmt, ...) \
do { \
if (p->log_level >= PIPELINE_LOG_LEVEL_ ## level) \
fprintf(stdout, "[%s] " fmt "\n", p->name, ## __VA_ARGS__);\
} while (0)
static inline void *
pipeline_msg_recv(struct pipeline *p,
uint32_t msgq_id)
{
struct rte_ring *r = p->msgq_in[msgq_id];
void *msg;
int status = rte_ring_sc_dequeue(r, &msg);
if (status != 0)
return NULL;
return msg;
}
static inline void
pipeline_msg_send(struct pipeline *p,
uint32_t msgq_id,
void *msg)
{
struct rte_ring *r = p->msgq_out[msgq_id];
int status;
do {
status = rte_ring_sp_enqueue(r, msg);
} while (status == -ENOBUFS);
}
struct pipeline_msg_req {
enum pipeline_msg_req_type type;
};
struct pipeline_stats_msg_req {
enum pipeline_msg_req_type type;
uint32_t id;
};
struct pipeline_port_in_msg_req {
enum pipeline_msg_req_type type;
uint32_t port_id;
};
struct pipeline_custom_msg_req {
enum pipeline_msg_req_type type;
uint32_t subtype;
};
struct pipeline_msg_rsp {
int status;
};
struct pipeline_stats_port_in_msg_rsp {
int status;
struct rte_pipeline_port_in_stats stats;
};
struct pipeline_stats_port_out_msg_rsp {
int status;
struct rte_pipeline_port_out_stats stats;
};
struct pipeline_stats_table_msg_rsp {
int status;
struct rte_pipeline_table_stats stats;
};
void *pipeline_msg_req_ping_handler(struct pipeline *p, void *msg);
void *pipeline_msg_req_stats_port_in_handler(struct pipeline *p, void *msg);
void *pipeline_msg_req_stats_port_out_handler(struct pipeline *p, void *msg);
void *pipeline_msg_req_stats_table_handler(struct pipeline *p, void *msg);
void *pipeline_msg_req_port_in_enable_handler(struct pipeline *p, void *msg);
void *pipeline_msg_req_port_in_disable_handler(struct pipeline *p, void *msg);
void *pipeline_msg_req_invalid_handler(struct pipeline *p, void *msg);
int pipeline_msg_req_handle(struct pipeline *p);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,228 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __INCLUDE_PIPELINE_COMMON_FE_H__
#define __INCLUDE_PIPELINE_COMMON_FE_H__
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_malloc.h>
#include <cmdline_parse.h>
#include "pipeline_common_be.h"
#include "pipeline.h"
#include "app.h"
#ifndef MSG_TIMEOUT_DEFAULT
#define MSG_TIMEOUT_DEFAULT 1000
#endif
static inline struct app_pipeline_data *
app_pipeline_data(struct app_params *app, uint32_t id)
{
struct app_pipeline_params *params;
APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", id, params);
if (params == NULL)
return NULL;
return &app->pipeline_data[params - app->pipeline_params];
}
static inline void *
app_pipeline_data_fe(struct app_params *app, uint32_t id)
{
struct app_pipeline_data *pipeline_data;
pipeline_data = app_pipeline_data(app, id);
if (pipeline_data == NULL)
return NULL;
return pipeline_data->fe;
}
static inline struct rte_ring *
app_pipeline_msgq_in_get(struct app_params *app,
uint32_t pipeline_id)
{
struct app_msgq_params *p;
APP_PARAM_FIND_BY_ID(app->msgq_params,
"MSGQ-REQ-PIPELINE",
pipeline_id,
p);
if (p == NULL)
return NULL;
return app->msgq[p - app->msgq_params];
}
static inline struct rte_ring *
app_pipeline_msgq_out_get(struct app_params *app,
uint32_t pipeline_id)
{
struct app_msgq_params *p;
APP_PARAM_FIND_BY_ID(app->msgq_params,
"MSGQ-RSP-PIPELINE",
pipeline_id,
p);
if (p == NULL)
return NULL;
return app->msgq[p - app->msgq_params];
}
static inline void *
app_msg_alloc(__rte_unused struct app_params *app)
{
return rte_malloc(NULL, 2048, RTE_CACHE_LINE_SIZE);
}
static inline void
app_msg_free(__rte_unused struct app_params *app,
void *msg)
{
rte_free(msg);
}
static inline void
app_msg_send(struct app_params *app,
uint32_t pipeline_id,
void *msg)
{
struct rte_ring *r = app_pipeline_msgq_in_get(app, pipeline_id);
int status;
do {
status = rte_ring_sp_enqueue(r, msg);
} while (status == -ENOBUFS);
}
static inline void *
app_msg_recv(struct app_params *app,
uint32_t pipeline_id)
{
struct rte_ring *r = app_pipeline_msgq_out_get(app, pipeline_id);
void *msg;
int status = rte_ring_sc_dequeue(r, &msg);
if (status != 0)
return NULL;
return msg;
}
static inline void *
app_msg_send_recv(struct app_params *app,
uint32_t pipeline_id,
void *msg,
uint32_t timeout_ms)
{
struct rte_ring *r_req = app_pipeline_msgq_in_get(app, pipeline_id);
struct rte_ring *r_rsp = app_pipeline_msgq_out_get(app, pipeline_id);
uint64_t hz = rte_get_tsc_hz();
void *msg_recv;
uint64_t deadline;
int status;
/* send */
do {
status = rte_ring_sp_enqueue(r_req, (void *) msg);
} while (status == -ENOBUFS);
/* recv */
deadline = (timeout_ms) ?
(rte_rdtsc() + ((hz * timeout_ms) / 1000)) :
UINT64_MAX;
do {
if (rte_rdtsc() > deadline)
return NULL;
status = rte_ring_sc_dequeue(r_rsp, &msg_recv);
} while (status != 0);
return msg_recv;
}
int
app_pipeline_ping(struct app_params *app,
uint32_t pipeline_id);
int
app_pipeline_stats_port_in(struct app_params *app,
uint32_t pipeline_id,
uint32_t port_id,
struct rte_pipeline_port_in_stats *stats);
int
app_pipeline_stats_port_out(struct app_params *app,
uint32_t pipeline_id,
uint32_t port_id,
struct rte_pipeline_port_out_stats *stats);
int
app_pipeline_stats_table(struct app_params *app,
uint32_t pipeline_id,
uint32_t table_id,
struct rte_pipeline_table_stats *stats);
int
app_pipeline_port_in_enable(struct app_params *app,
uint32_t pipeline_id,
uint32_t port_id);
int
app_pipeline_port_in_disable(struct app_params *app,
uint32_t pipeline_id,
uint32_t port_id);
int
app_link_config(struct app_params *app,
uint32_t link_id,
uint32_t ip,
uint32_t depth);
int
app_link_up(struct app_params *app,
uint32_t link_id);
int
app_link_down(struct app_params *app,
uint32_t link_id);
int
app_pipeline_common_cmd_push(struct app_params *app);
#endif

View File

@ -0,0 +1,47 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "pipeline_master.h"
#include "pipeline_master_be.h"
static struct pipeline_fe_ops pipeline_master_fe_ops = {
.f_init = NULL,
.f_free = NULL,
.cmds = NULL,
};
struct pipeline_type pipeline_master = {
.name = "MASTER",
.be_ops = &pipeline_master_be_ops,
.fe_ops = &pipeline_master_fe_ops,
};

View File

@ -0,0 +1,41 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __INCLUDE_PIPELINE_MASTER_H__
#define __INCLUDE_PIPELINE_MASTER_H__
#include "pipeline.h"
extern struct pipeline_type pipeline_master;
#endif

View File

@ -0,0 +1,150 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fcntl.h>
#include <unistd.h>
#include <rte_common.h>
#include <rte_malloc.h>
#include <cmdline_parse.h>
#include <cmdline_parse_string.h>
#include <cmdline_socket.h>
#include <cmdline.h>
#include "app.h"
#include "pipeline_master_be.h"
struct pipeline_master {
struct app_params *app;
struct cmdline *cl;
int script_file_done;
} __rte_cache_aligned;
static void*
pipeline_init(__rte_unused struct pipeline_params *params, void *arg)
{
struct app_params *app = (struct app_params *) arg;
struct pipeline_master *p;
uint32_t size;
/* Check input arguments */
if (app == NULL)
return NULL;
/* Memory allocation */
size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_master));
p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
if (p == NULL)
return NULL;
/* Initialization */
p->app = app;
p->cl = cmdline_stdin_new(app->cmds, "pipeline> ");
if (p->cl == NULL) {
rte_free(p);
return NULL;
}
p->script_file_done = 0;
if (app->script_file == NULL)
p->script_file_done = 1;
return (void *) p;
}
static int
pipeline_free(void *pipeline)
{
struct pipeline_master *p = (struct pipeline_master *) pipeline;
if (p == NULL)
return -EINVAL;
cmdline_stdin_exit(p->cl);
rte_free(p);
return 0;
}
static int
pipeline_run(void *pipeline)
{
struct pipeline_master *p = (struct pipeline_master *) pipeline;
int status;
if (p->script_file_done == 0) {
struct app_params *app = p->app;
int fd = open(app->script_file, O_RDONLY);
if (fd < 0)
printf("Cannot open CLI script file \"%s\"\n",
app->script_file);
else {
struct cmdline *file_cl;
printf("Running CLI script file \"%s\" ...\n",
app->script_file);
file_cl = cmdline_new(p->cl->ctx, "", fd, 1);
cmdline_interact(file_cl);
close(fd);
}
p->script_file_done = 1;
}
status = cmdline_poll(p->cl);
if (status < 0)
rte_panic("CLI poll error (%" PRId32 ")\n", status);
else if (status == RDLINE_EXITED) {
cmdline_stdin_exit(p->cl);
rte_exit(0, "Bye!\n");
}
return 0;
}
static int
pipeline_timer(__rte_unused void *pipeline)
{
return 0;
}
struct pipeline_be_ops pipeline_master_be_ops = {
.f_init = pipeline_init,
.f_free = pipeline_free,
.f_run = pipeline_run,
.f_timer = pipeline_timer,
.f_track = NULL,
};

View File

@ -0,0 +1,41 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __INCLUDE_PIPELINE_MASTER_BE_H__
#define __INCLUDE_PIPELINE_MASTER_BE_H__
#include "pipeline_common_be.h"
extern struct pipeline_be_ops pipeline_master_be_ops;
#endif