examples/ip_pipeline: remove master pipeline

remove master pipeline.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
This commit is contained in:
Jasvinder Singh 2018-03-29 19:31:37 +01:00 committed by Cristian Dumitrescu
parent 998eab3001
commit b5e408acd1
18 changed files with 3 additions and 3566 deletions

View File

@ -12,14 +12,8 @@ SRCS-y += config_parse_tm.c
SRCS-y += config_check.c
SRCS-y += init.c
SRCS-y += thread.c
SRCS-y += thread_fe.c
SRCS-y += cpu_core_map.c
SRCS-y += pipeline_common_be.c
SRCS-y += pipeline_common_fe.c
SRCS-y += pipeline_master_be.c
SRCS-y += pipeline_master.c
# Build using pkg-config variables if possible
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)

View File

@ -1359,10 +1359,6 @@ app_core_build_core_mask_string(struct app_params *app, char *mask_buffer)
}
}
void app_pipeline_params_get(struct app_params *app,
struct app_pipeline_params *p_in,
struct pipeline_params *p_out);
int app_config_init(struct app_params *app);
int app_config_args(struct app_params *app,
@ -1382,16 +1378,8 @@ int app_config_check(struct app_params *app);
int app_init(struct app_params *app);
int app_post_init(struct app_params *app);
int app_thread(void *arg);
int app_pipeline_type_register(struct app_params *app,
struct pipeline_type *ptype);
struct pipeline_type *app_pipeline_type_find(struct app_params *app,
char *name);
void app_link_up_internal(struct app_params *app,
struct app_link_params *cp);

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
* Copyright(c) 2010-2018 Intel Corporation
*/
#ifndef __INCLUDE_HASH_FUNC_H__
#define __INCLUDE_HASH_FUNC_H__

View File

@ -24,9 +24,6 @@
#include "app.h"
#include "pipeline.h"
#include "pipeline_common_fe.h"
#include "pipeline_master.h"
#include "thread_fe.h"
#define APP_NAME_SIZE 32
@ -1328,478 +1325,6 @@ app_init_msgq(struct app_params *app)
}
}
void app_pipeline_params_get(struct app_params *app,
struct app_pipeline_params *p_in,
struct pipeline_params *p_out)
{
uint32_t i;
snprintf(p_out->name, PIPELINE_NAME_SIZE, "%s", p_in->name);
snprintf(p_out->type, PIPELINE_TYPE_SIZE, "%s", p_in->type);
p_out->socket_id = (int) p_in->socket_id;
p_out->log_level = app->log_level;
/* pktq_in */
p_out->n_ports_in = p_in->n_pktq_in;
for (i = 0; i < p_in->n_pktq_in; i++) {
struct app_pktq_in_params *in = &p_in->pktq_in[i];
struct pipeline_port_in_params *out = &p_out->port_in[i];
switch (in->type) {
case APP_PKTQ_IN_HWQ:
{
struct app_pktq_hwq_in_params *p_hwq_in =
&app->hwq_in_params[in->id];
struct app_link_params *p_link =
app_get_link_for_rxq(app, p_hwq_in);
uint32_t rxq_link_id, rxq_queue_id;
sscanf(p_hwq_in->name, "RXQ%" SCNu32 ".%" SCNu32,
&rxq_link_id,
&rxq_queue_id);
out->type = PIPELINE_PORT_IN_ETHDEV_READER;
out->params.ethdev.port_id = p_link->pmd_id;
out->params.ethdev.queue_id = rxq_queue_id;
out->burst_size = p_hwq_in->burst;
break;
}
case APP_PKTQ_IN_SWQ:
{
struct app_pktq_swq_params *swq_params = &app->swq_params[in->id];
if ((swq_params->ipv4_frag == 0) && (swq_params->ipv6_frag == 0)) {
if (app_swq_get_readers(app, swq_params) == 1) {
out->type = PIPELINE_PORT_IN_RING_READER;
out->params.ring.ring = app->swq[in->id];
out->burst_size = app->swq_params[in->id].burst_read;
} else {
out->type = PIPELINE_PORT_IN_RING_MULTI_READER;
out->params.ring_multi.ring = app->swq[in->id];
out->burst_size = swq_params->burst_read;
}
} else {
if (swq_params->ipv4_frag == 1) {
struct rte_port_ring_reader_ipv4_frag_params *params =
&out->params.ring_ipv4_frag;
out->type = PIPELINE_PORT_IN_RING_READER_IPV4_FRAG;
params->ring = app->swq[in->id];
params->mtu = swq_params->mtu;
params->metadata_size = swq_params->metadata_size;
params->pool_direct =
app->mempool[swq_params->mempool_direct_id];
params->pool_indirect =
app->mempool[swq_params->mempool_indirect_id];
out->burst_size = swq_params->burst_read;
} else {
struct rte_port_ring_reader_ipv6_frag_params *params =
&out->params.ring_ipv6_frag;
out->type = PIPELINE_PORT_IN_RING_READER_IPV6_FRAG;
params->ring = app->swq[in->id];
params->mtu = swq_params->mtu;
params->metadata_size = swq_params->metadata_size;
params->pool_direct =
app->mempool[swq_params->mempool_direct_id];
params->pool_indirect =
app->mempool[swq_params->mempool_indirect_id];
out->burst_size = swq_params->burst_read;
}
}
break;
}
case APP_PKTQ_IN_TM:
{
out->type = PIPELINE_PORT_IN_SCHED_READER;
out->params.sched.sched = app->tm[in->id];
out->burst_size = app->tm_params[in->id].burst_read;
break;
}
#ifdef RTE_EXEC_ENV_LINUXAPP
case APP_PKTQ_IN_TAP:
{
struct app_pktq_tap_params *tap_params =
&app->tap_params[in->id];
struct app_mempool_params *mempool_params =
&app->mempool_params[tap_params->mempool_id];
struct rte_mempool *mempool =
app->mempool[tap_params->mempool_id];
out->type = PIPELINE_PORT_IN_FD_READER;
out->params.fd.fd = app->tap[in->id];
out->params.fd.mtu = mempool_params->buffer_size;
out->params.fd.mempool = mempool;
out->burst_size = app->tap_params[in->id].burst_read;
break;
}
#endif
#ifdef RTE_LIBRTE_KNI
case APP_PKTQ_IN_KNI:
{
out->type = PIPELINE_PORT_IN_KNI_READER;
out->params.kni.kni = app->kni[in->id];
out->burst_size = app->kni_params[in->id].burst_read;
break;
}
#endif /* RTE_LIBRTE_KNI */
case APP_PKTQ_IN_SOURCE:
{
uint32_t mempool_id =
app->source_params[in->id].mempool_id;
out->type = PIPELINE_PORT_IN_SOURCE;
out->params.source.mempool = app->mempool[mempool_id];
out->burst_size = app->source_params[in->id].burst;
out->params.source.file_name =
app->source_params[in->id].file_name;
out->params.source.n_bytes_per_pkt =
app->source_params[in->id].n_bytes_per_pkt;
break;
}
default:
break;
}
}
/* pktq_out */
p_out->n_ports_out = p_in->n_pktq_out;
for (i = 0; i < p_in->n_pktq_out; i++) {
struct app_pktq_out_params *in = &p_in->pktq_out[i];
struct pipeline_port_out_params *out = &p_out->port_out[i];
switch (in->type) {
case APP_PKTQ_OUT_HWQ:
{
struct app_pktq_hwq_out_params *p_hwq_out =
&app->hwq_out_params[in->id];
struct app_link_params *p_link =
app_get_link_for_txq(app, p_hwq_out);
uint32_t txq_link_id, txq_queue_id;
sscanf(p_hwq_out->name,
"TXQ%" SCNu32 ".%" SCNu32,
&txq_link_id,
&txq_queue_id);
if (p_hwq_out->dropless == 0) {
struct rte_port_ethdev_writer_params *params =
&out->params.ethdev;
out->type = PIPELINE_PORT_OUT_ETHDEV_WRITER;
params->port_id = p_link->pmd_id;
params->queue_id = txq_queue_id;
params->tx_burst_sz =
app->hwq_out_params[in->id].burst;
} else {
struct rte_port_ethdev_writer_nodrop_params
*params = &out->params.ethdev_nodrop;
out->type =
PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP;
params->port_id = p_link->pmd_id;
params->queue_id = txq_queue_id;
params->tx_burst_sz = p_hwq_out->burst;
params->n_retries = p_hwq_out->n_retries;
}
break;
}
case APP_PKTQ_OUT_SWQ:
{
struct app_pktq_swq_params *swq_params = &app->swq_params[in->id];
if ((swq_params->ipv4_ras == 0) && (swq_params->ipv6_ras == 0)) {
if (app_swq_get_writers(app, swq_params) == 1) {
if (app->swq_params[in->id].dropless == 0) {
struct rte_port_ring_writer_params *params =
&out->params.ring;
out->type = PIPELINE_PORT_OUT_RING_WRITER;
params->ring = app->swq[in->id];
params->tx_burst_sz =
app->swq_params[in->id].burst_write;
} else {
struct rte_port_ring_writer_nodrop_params
*params = &out->params.ring_nodrop;
out->type =
PIPELINE_PORT_OUT_RING_WRITER_NODROP;
params->ring = app->swq[in->id];
params->tx_burst_sz =
app->swq_params[in->id].burst_write;
params->n_retries =
app->swq_params[in->id].n_retries;
}
} else {
if (swq_params->dropless == 0) {
struct rte_port_ring_multi_writer_params *params =
&out->params.ring_multi;
out->type = PIPELINE_PORT_OUT_RING_MULTI_WRITER;
params->ring = app->swq[in->id];
params->tx_burst_sz = swq_params->burst_write;
} else {
struct rte_port_ring_multi_writer_nodrop_params
*params = &out->params.ring_multi_nodrop;
out->type = PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP;
params->ring = app->swq[in->id];
params->tx_burst_sz = swq_params->burst_write;
params->n_retries = swq_params->n_retries;
}
}
} else {
if (swq_params->ipv4_ras == 1) {
struct rte_port_ring_writer_ipv4_ras_params *params =
&out->params.ring_ipv4_ras;
out->type = PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS;
params->ring = app->swq[in->id];
params->tx_burst_sz = swq_params->burst_write;
} else {
struct rte_port_ring_writer_ipv6_ras_params *params =
&out->params.ring_ipv6_ras;
out->type = PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS;
params->ring = app->swq[in->id];
params->tx_burst_sz = swq_params->burst_write;
}
}
break;
}
case APP_PKTQ_OUT_TM:
{
struct rte_port_sched_writer_params *params =
&out->params.sched;
out->type = PIPELINE_PORT_OUT_SCHED_WRITER;
params->sched = app->tm[in->id];
params->tx_burst_sz =
app->tm_params[in->id].burst_write;
break;
}
#ifdef RTE_EXEC_ENV_LINUXAPP
case APP_PKTQ_OUT_TAP:
{
struct rte_port_fd_writer_params *params =
&out->params.fd;
out->type = PIPELINE_PORT_OUT_FD_WRITER;
params->fd = app->tap[in->id];
params->tx_burst_sz =
app->tap_params[in->id].burst_write;
break;
}
#endif
#ifdef RTE_LIBRTE_KNI
case APP_PKTQ_OUT_KNI:
{
struct app_pktq_kni_params *p_kni =
&app->kni_params[in->id];
if (p_kni->dropless == 0) {
struct rte_port_kni_writer_params *params =
&out->params.kni;
out->type = PIPELINE_PORT_OUT_KNI_WRITER;
params->kni = app->kni[in->id];
params->tx_burst_sz =
app->kni_params[in->id].burst_write;
} else {
struct rte_port_kni_writer_nodrop_params
*params = &out->params.kni_nodrop;
out->type = PIPELINE_PORT_OUT_KNI_WRITER_NODROP;
params->kni = app->kni[in->id];
params->tx_burst_sz =
app->kni_params[in->id].burst_write;
params->n_retries =
app->kni_params[in->id].n_retries;
}
break;
}
#endif /* RTE_LIBRTE_KNI */
case APP_PKTQ_OUT_SINK:
{
out->type = PIPELINE_PORT_OUT_SINK;
out->params.sink.file_name =
app->sink_params[in->id].file_name;
out->params.sink.max_n_pkts =
app->sink_params[in->id].
n_pkts_to_dump;
break;
}
default:
break;
}
}
/* msgq */
p_out->n_msgq = p_in->n_msgq_in;
for (i = 0; i < p_in->n_msgq_in; i++)
p_out->msgq_in[i] = app->msgq[p_in->msgq_in[i]];
for (i = 0; i < p_in->n_msgq_out; i++)
p_out->msgq_out[i] = app->msgq[p_in->msgq_out[i]];
/* args */
p_out->n_args = p_in->n_args;
for (i = 0; i < p_in->n_args; i++) {
p_out->args_name[i] = p_in->args_name[i];
p_out->args_value[i] = p_in->args_value[i];
}
}
static void
app_init_pipelines(struct app_params *app)
{
uint32_t p_id;
for (p_id = 0; p_id < app->n_pipelines; p_id++) {
struct app_pipeline_params *params =
&app->pipeline_params[p_id];
struct app_pipeline_data *data = &app->pipeline_data[p_id];
struct pipeline_type *ptype;
struct pipeline_params pp;
APP_LOG(app, HIGH, "Initializing %s ...", params->name);
ptype = app_pipeline_type_find(app, params->type);
if (ptype == NULL)
rte_panic("Init error: Unknown pipeline type \"%s\"\n",
params->type);
app_pipeline_params_get(app, params, &pp);
/* Back-end */
data->be = NULL;
if (ptype->be_ops->f_init) {
data->be = ptype->be_ops->f_init(&pp, (void *) app);
if (data->be == NULL)
rte_panic("Pipeline instance \"%s\" back-end "
"init error\n", params->name);
}
/* Front-end */
data->fe = NULL;
if (ptype->fe_ops->f_init) {
data->fe = ptype->fe_ops->f_init(&pp, (void *) app);
if (data->fe == NULL)
rte_panic("Pipeline instance \"%s\" front-end "
"init error\n", params->name);
}
data->ptype = ptype;
data->timer_period = (rte_get_tsc_hz() *
params->timer_period) / 1000;
}
}
static void
app_post_init_pipelines(struct app_params *app)
{
uint32_t p_id;
for (p_id = 0; p_id < app->n_pipelines; p_id++) {
struct app_pipeline_params *params =
&app->pipeline_params[p_id];
struct app_pipeline_data *data = &app->pipeline_data[p_id];
int status;
if (data->ptype->fe_ops->f_post_init == NULL)
continue;
status = data->ptype->fe_ops->f_post_init(data->fe);
if (status)
rte_panic("Pipeline instance \"%s\" front-end "
"post-init error\n", params->name);
}
}
static void
app_init_threads(struct app_params *app)
{
uint64_t time = rte_get_tsc_cycles();
uint32_t p_id;
for (p_id = 0; p_id < app->n_pipelines; p_id++) {
struct app_pipeline_params *params =
&app->pipeline_params[p_id];
struct app_pipeline_data *data = &app->pipeline_data[p_id];
struct pipeline_type *ptype;
struct app_thread_data *t;
struct app_thread_pipeline_data *p;
int lcore_id;
lcore_id = cpu_core_map_get_lcore_id(app->core_map,
params->socket_id,
params->core_id,
params->hyper_th_id);
if (lcore_id < 0)
rte_panic("Invalid core s%" PRIu32 "c%" PRIu32 "%s\n",
params->socket_id,
params->core_id,
(params->hyper_th_id) ? "h" : "");
t = &app->thread_data[lcore_id];
t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) / 1000;
t->thread_req_deadline = time + t->timer_period;
t->headroom_cycles = 0;
t->headroom_time = rte_get_tsc_cycles();
t->headroom_ratio = 0.0;
t->msgq_in = app_thread_msgq_in_get(app,
params->socket_id,
params->core_id,
params->hyper_th_id);
if (t->msgq_in == NULL)
rte_panic("Init error: Cannot find MSGQ_IN for thread %" PRId32,
lcore_id);
t->msgq_out = app_thread_msgq_out_get(app,
params->socket_id,
params->core_id,
params->hyper_th_id);
if (t->msgq_out == NULL)
rte_panic("Init error: Cannot find MSGQ_OUT for thread %" PRId32,
lcore_id);
ptype = app_pipeline_type_find(app, params->type);
if (ptype == NULL)
rte_panic("Init error: Unknown pipeline "
"type \"%s\"\n", params->type);
p = (ptype->be_ops->f_run == NULL) ?
&t->regular[t->n_regular] :
&t->custom[t->n_custom];
p->pipeline_id = p_id;
p->be = data->be;
p->f_run = ptype->be_ops->f_run;
p->f_timer = ptype->be_ops->f_timer;
p->timer_period = data->timer_period;
p->deadline = time + data->timer_period;
data->enabled = 1;
if (ptype->be_ops->f_run == NULL)
t->n_regular++;
else
t->n_custom++;
}
}
int app_init(struct app_params *app)
{
app_init_core_map(app);
@ -1814,104 +1339,5 @@ int app_init(struct app_params *app)
app_init_kni(app);
app_init_msgq(app);
app_pipeline_common_cmd_push(app);
app_pipeline_thread_cmd_push(app);
app_pipeline_type_register(app, &pipeline_master);
app_init_pipelines(app);
app_init_threads(app);
return 0;
}
int app_post_init(struct app_params *app)
{
app_post_init_pipelines(app);
return 0;
}
static int
app_pipeline_type_cmd_push(struct app_params *app,
struct pipeline_type *ptype)
{
cmdline_parse_ctx_t *cmds;
uint32_t n_cmds, i;
/* Check input arguments */
if ((app == NULL) ||
(ptype == NULL))
return -EINVAL;
n_cmds = pipeline_type_cmds_count(ptype);
if (n_cmds == 0)
return 0;
cmds = ptype->fe_ops->cmds;
/* Check for available slots in the application commands array */
if (n_cmds > APP_MAX_CMDS - app->n_cmds)
return -ENOMEM;
/* Push pipeline commands into the application */
memcpy(&app->cmds[app->n_cmds],
cmds,
n_cmds * sizeof(cmdline_parse_ctx_t));
for (i = 0; i < n_cmds; i++)
app->cmds[app->n_cmds + i]->data = app;
app->n_cmds += n_cmds;
app->cmds[app->n_cmds] = NULL;
return 0;
}
int
app_pipeline_type_register(struct app_params *app, struct pipeline_type *ptype)
{
uint32_t n_cmds, i;
/* Check input arguments */
if ((app == NULL) ||
(ptype == NULL) ||
(ptype->name == NULL) ||
(strlen(ptype->name) == 0) ||
(ptype->be_ops->f_init == NULL) ||
(ptype->be_ops->f_timer == NULL))
return -EINVAL;
/* Check for duplicate entry */
for (i = 0; i < app->n_pipeline_types; i++)
if (strcmp(app->pipeline_type[i].name, ptype->name) == 0)
return -EEXIST;
/* Check for resource availability */
n_cmds = pipeline_type_cmds_count(ptype);
if ((app->n_pipeline_types == APP_MAX_PIPELINE_TYPES) ||
(n_cmds > APP_MAX_CMDS - app->n_cmds))
return -ENOMEM;
/* Copy pipeline type */
memcpy(&app->pipeline_type[app->n_pipeline_types++],
ptype,
sizeof(struct pipeline_type));
/* Copy CLI commands */
if (n_cmds)
app_pipeline_type_cmd_push(app, ptype);
return 0;
}
struct
pipeline_type *app_pipeline_type_find(struct app_params *app, char *name)
{
uint32_t i;
for (i = 0; i < app->n_pipeline_types; i++)
if (strcmp(app->pipeline_type[i].name, name) == 0)
return &app->pipeline_type[i];
return NULL;
}

View File

@ -6,9 +6,7 @@
# To build this example as a standalone application with an already-installed
# DPDK instance, use 'make'
deps += ['cfgfile', 'pipeline', 'bus_pci']
allow_experimental_apis = true
includes += include_directories('pipeline')
deps += ['cfgfile', 'bus_pci']
sources = files(
'config_check.c',
'config_parse.c',
@ -18,9 +16,4 @@ sources = files(
'main.c',
'parser.c',
'thread.c',
'thread_fe.c',
'pipeline/pipeline_common_be.c',
'pipeline/pipeline_common_fe.c',
'pipeline/pipeline_master_be.c',
'pipeline/pipeline_master.c',
)

View File

@ -1,202 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2016 Intel Corporation
*/
#ifndef __INCLUDE_PIPELINE_ACTIONS_COMMON_H__
#define __INCLUDE_PIPELINE_ACTIONS_COMMON_H__
#include <stdint.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_mbuf.h>
#include <rte_pipeline.h>
#define PIPELINE_PORT_IN_AH(f_ah, f_pkt_work, f_pkt4_work) \
static int \
f_ah( \
__rte_unused struct rte_pipeline *p, \
struct rte_mbuf **pkts, \
uint32_t n_pkts, \
void *arg) \
{ \
uint32_t i; \
\
for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
f_pkt4_work(&pkts[i], arg); \
\
for ( ; i < n_pkts; i++) \
f_pkt_work(pkts[i], arg); \
\
return 0; \
}
#define PIPELINE_PORT_IN_AH_HIJACK_ALL(f_ah, f_pkt_work, f_pkt4_work) \
static int \
f_ah( \
struct rte_pipeline *p, \
struct rte_mbuf **pkts, \
uint32_t n_pkts, \
void *arg) \
{ \
uint64_t pkt_mask = RTE_LEN2MASK(n_pkts, uint64_t); \
uint32_t i; \
\
rte_pipeline_ah_packet_hijack(p, pkt_mask); \
\
for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
f_pkt4_work(&pkts[i], arg); \
\
for ( ; i < n_pkts; i++) \
f_pkt_work(pkts[i], arg); \
\
return 0; \
}
#define PIPELINE_TABLE_AH_HIT(f_ah, f_pkt_work, f_pkt4_work) \
static int \
f_ah( \
__rte_unused struct rte_pipeline *p, \
struct rte_mbuf **pkts, \
uint64_t pkts_in_mask, \
struct rte_pipeline_table_entry **entries, \
void *arg) \
{ \
if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
uint32_t i; \
\
for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
f_pkt4_work(&pkts[i], &entries[i], arg); \
\
for ( ; i < n_pkts; i++) \
f_pkt_work(pkts[i], entries[i], arg); \
} else \
for ( ; pkts_in_mask; ) { \
uint32_t pos = __builtin_ctzll(pkts_in_mask); \
uint64_t pkt_mask = 1LLU << pos; \
\
pkts_in_mask &= ~pkt_mask; \
f_pkt_work(pkts[pos], entries[pos], arg); \
} \
\
return 0; \
}
#define PIPELINE_TABLE_AH_MISS(f_ah, f_pkt_work, f_pkt4_work) \
static int \
f_ah( \
__rte_unused struct rte_pipeline *p, \
struct rte_mbuf **pkts, \
uint64_t pkts_in_mask, \
struct rte_pipeline_table_entry *entry, \
void *arg) \
{ \
if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
uint32_t i; \
\
for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
f_pkt4_work(&pkts[i], entry, arg); \
\
for ( ; i < n_pkts; i++) \
f_pkt_work(pkts[i], entry, arg); \
} else \
for ( ; pkts_in_mask; ) { \
uint32_t pos = __builtin_ctzll(pkts_in_mask); \
uint64_t pkt_mask = 1LLU << pos; \
\
pkts_in_mask &= ~pkt_mask; \
f_pkt_work(pkts[pos], entry, arg); \
} \
\
return 0; \
}
#define PIPELINE_TABLE_AH_HIT_DROP_TIME(f_ah, f_pkt_work, f_pkt4_work) \
static int \
f_ah( \
struct rte_pipeline *p, \
struct rte_mbuf **pkts, \
uint64_t pkts_mask, \
struct rte_pipeline_table_entry **entries, \
void *arg) \
{ \
uint64_t pkts_in_mask = pkts_mask; \
uint64_t pkts_out_mask = pkts_mask; \
uint64_t time = rte_rdtsc(); \
\
if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
uint32_t i; \
\
for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) { \
uint64_t mask = f_pkt4_work(&pkts[i], \
&entries[i], arg, time); \
pkts_out_mask ^= mask << i; \
} \
\
for ( ; i < n_pkts; i++) { \
uint64_t mask = f_pkt_work(pkts[i], \
entries[i], arg, time); \
pkts_out_mask ^= mask << i; \
} \
} else \
for ( ; pkts_in_mask; ) { \
uint32_t pos = __builtin_ctzll(pkts_in_mask); \
uint64_t pkt_mask = 1LLU << pos; \
uint64_t mask = f_pkt_work(pkts[pos], \
entries[pos], arg, time); \
\
pkts_in_mask &= ~pkt_mask; \
pkts_out_mask ^= mask << pos; \
} \
\
rte_pipeline_ah_packet_drop(p, pkts_out_mask ^ pkts_mask); \
\
return 0; \
}
#define PIPELINE_TABLE_AH_MISS_DROP_TIME(f_ah, f_pkt_work, f_pkt4_work) \
static int \
f_ah( \
struct rte_pipeline *p, \
struct rte_mbuf **pkts, \
uint64_t pkts_mask, \
struct rte_pipeline_table_entry *entry, \
void *arg) \
{ \
uint64_t pkts_in_mask = pkts_mask; \
uint64_t pkts_out_mask = pkts_mask; \
uint64_t time = rte_rdtsc(); \
\
if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
uint32_t i; \
\
for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) { \
uint64_t mask = f_pkt4_work(&pkts[i], \
entry, arg, time); \
pkts_out_mask ^= mask << i; \
} \
\
for ( ; i < n_pkts; i++) { \
uint64_t mask = f_pkt_work(pkts[i], entry, arg, time);\
pkts_out_mask ^= mask << i; \
} \
} else \
for ( ; pkts_in_mask; ) { \
uint32_t pos = __builtin_ctzll(pkts_in_mask); \
uint64_t pkt_mask = 1LLU << pos; \
uint64_t mask = f_pkt_work(pkts[pos], \
entry, arg, time); \
\
pkts_in_mask &= ~pkt_mask; \
pkts_out_mask ^= mask << pos; \
} \
\
rte_pipeline_ah_packet_drop(p, pkts_out_mask ^ pkts_mask); \
\
return 0; \
}
#endif

View File

@ -1,176 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#include <rte_common.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

@ -1,134 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#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

@ -1,231 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#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 pipeline_type *ptype)
{
struct app_pipeline_data *pipeline_data;
pipeline_data = app_pipeline_data(app, id);
if (pipeline_data == NULL)
return NULL;
if (strcmp(pipeline_data->ptype->name, ptype->name) != 0)
return NULL;
if (pipeline_data->enabled == 0)
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;
}
struct app_link_params *
app_pipeline_track_pktq_out_to_link(struct app_params *app,
uint32_t pipeline_id,
uint32_t pktq_out_id);
int
app_pipeline_track_default(struct pipeline_params *params,
uint32_t port_in,
uint32_t *port_out);
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_set_op(struct app_params *app,
uint32_t link_id,
uint32_t pipeline_id,
app_link_op op,
void *arg);
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);
#define CMD_MSG_OUT_OF_MEMORY "Not enough memory\n"
#define CMD_MSG_NOT_ENOUGH_ARGS "Not enough arguments for command \"%s\"\n"
#define CMD_MSG_TOO_MANY_ARGS "Too many arguments for command \"%s\"\n"
#define CMD_MSG_MISMATCH_ARGS "Incorrect set of arguments for command \"%s\"\n"
#define CMD_MSG_INVALID_ARG "Invalid value for argument \"%s\"\n"
#define CMD_MSG_ARG_NOT_FOUND "Syntax error: \"%s\" not found\n"
#define CMD_MSG_FILE_ERR "Error in file \"%s\" at line %u\n"
#define CMD_MSG_FAIL "Command \"%s\" failed\n"
#endif

View File

@ -1,20 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#include "pipeline_master.h"
#include "pipeline_master_be.h"
static struct pipeline_fe_ops pipeline_master_fe_ops = {
.f_init = NULL,
.f_post_init = NULL,
.f_free = NULL,
.f_track = NULL,
.cmds = NULL,
};
struct pipeline_type pipeline_master = {
.name = "MASTER",
.be_ops = &pipeline_master_be_ops,
.fe_ops = &pipeline_master_fe_ops,
};

View File

@ -1,12 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#ifndef __INCLUDE_PIPELINE_MASTER_H__
#define __INCLUDE_PIPELINE_MASTER_H__
#include "pipeline.h"
extern struct pipeline_type pipeline_master;
#endif

View File

@ -1,141 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#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 post_init_done;
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->post_init_done = 0;
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;
struct app_params *app = p->app;
int status;
#ifdef RTE_LIBRTE_KNI
uint32_t i;
#endif /* RTE_LIBRTE_KNI */
/* Application post-init phase */
if (p->post_init_done == 0) {
app_post_init(app);
p->post_init_done = 1;
}
/* Run startup script file */
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;
}
/* Command Line Interface (CLI) */
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");
}
#ifdef RTE_LIBRTE_KNI
/* Handle KNI requests from Linux kernel */
for (i = 0; i < app->n_pktq_kni; i++)
rte_kni_handle_request(app->kni[i]);
#endif /* RTE_LIBRTE_KNI */
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,
};

View File

@ -1,12 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#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

View File

@ -6,47 +6,9 @@
#include <rte_cycles.h>
#include <rte_pipeline.h>
#include "pipeline_common_be.h"
#include "app.h"
#include "thread.h"
#if APP_THREAD_HEADROOM_STATS_COLLECT
#define PIPELINE_RUN_REGULAR(thread, pipeline) \
do { \
uint64_t t0 = rte_rdtsc_precise(); \
int n_pkts = rte_pipeline_run(pipeline->p); \
\
if (n_pkts == 0) { \
uint64_t t1 = rte_rdtsc_precise(); \
\
thread->headroom_cycles += t1 - t0; \
} \
} while (0)
#define PIPELINE_RUN_CUSTOM(thread, data) \
do { \
uint64_t t0 = rte_rdtsc_precise(); \
int n_pkts = data->f_run(data->be); \
\
if (n_pkts == 0) { \
uint64_t t1 = rte_rdtsc_precise(); \
\
thread->headroom_cycles += t1 - t0; \
} \
} while (0)
#else
#define PIPELINE_RUN_REGULAR(thread, pipeline) \
rte_pipeline_run(pipeline->p)
#define PIPELINE_RUN_CUSTOM(thread, data) \
data->f_run(data->be)
#endif
static inline void *
thread_msg_recv(struct rte_ring *r)
{
@ -214,21 +176,6 @@ app_thread(void *arg)
uint32_t n_regular = RTE_MIN(t->n_regular, RTE_DIM(t->regular));
uint32_t n_custom = RTE_MIN(t->n_custom, RTE_DIM(t->custom));
/* Run regular pipelines */
for (j = 0; j < n_regular; j++) {
struct app_thread_pipeline_data *data = &t->regular[j];
struct pipeline *p = data->be;
PIPELINE_RUN_REGULAR(t, p);
}
/* Run custom pipelines */
for (j = 0; j < n_custom; j++) {
struct app_thread_pipeline_data *data = &t->custom[j];
PIPELINE_RUN_CUSTOM(t, data);
}
/* Timer */
if ((i & 0xF) == 0) {
uint64_t time = rte_get_tsc_cycles();

View File

@ -1,457 +0,0 @@
#include <rte_common.h>
#include <rte_ring.h>
#include <rte_malloc.h>
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
#include <cmdline_parse_num.h>
#include <cmdline_parse_string.h>
#include "thread.h"
#include "thread_fe.h"
#include "pipeline.h"
#include "pipeline_common_fe.h"
#include "app.h"
static inline void *
thread_msg_send_recv(struct app_params *app,
uint32_t socket_id, uint32_t core_id, uint32_t ht_id,
void *msg,
uint32_t timeout_ms)
{
struct rte_ring *r_req = app_thread_msgq_in_get(app,
socket_id, core_id, ht_id);
struct rte_ring *r_rsp = app_thread_msgq_out_get(app,
socket_id, core_id, ht_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_enable(struct app_params *app,
uint32_t socket_id,
uint32_t core_id,
uint32_t hyper_th_id,
uint32_t pipeline_id)
{
struct thread_pipeline_enable_msg_req *req;
struct thread_pipeline_enable_msg_rsp *rsp;
int thread_id;
struct app_pipeline_data *p;
struct app_pipeline_params *p_params;
struct pipeline_type *p_type;
int status;
if (app == NULL)
return -1;
thread_id = cpu_core_map_get_lcore_id(app->core_map,
socket_id,
core_id,
hyper_th_id);
if ((thread_id < 0) || !app_core_is_enabled(app, thread_id))
return -1;
if (app_pipeline_data(app, pipeline_id) == NULL)
return -1;
p = &app->pipeline_data[pipeline_id];
p_params = &app->pipeline_params[pipeline_id];
p_type = app_pipeline_type_find(app, p_params->type);
if (p_type == NULL)
return -1;
if (p->enabled == 1)
return -1;
req = app_msg_alloc(app);
if (req == NULL)
return -1;
req->type = THREAD_MSG_REQ_PIPELINE_ENABLE;
req->pipeline_id = pipeline_id;
req->be = p->be;
req->f_run = p_type->be_ops->f_run;
req->f_timer = p_type->be_ops->f_timer;
req->timer_period = p->timer_period;
rsp = thread_msg_send_recv(app,
socket_id, core_id, hyper_th_id, req, MSG_TIMEOUT_DEFAULT);
if (rsp == NULL)
return -1;
status = rsp->status;
app_msg_free(app, rsp);
if (status != 0)
return -1;
p->enabled = 1;
return 0;
}
int
app_pipeline_disable(struct app_params *app,
uint32_t socket_id,
uint32_t core_id,
uint32_t hyper_th_id,
uint32_t pipeline_id)
{
struct thread_pipeline_disable_msg_req *req;
struct thread_pipeline_disable_msg_rsp *rsp;
int thread_id;
struct app_pipeline_data *p;
int status;
if (app == NULL)
return -1;
thread_id = cpu_core_map_get_lcore_id(app->core_map,
socket_id,
core_id,
hyper_th_id);
if ((thread_id < 0) || !app_core_is_enabled(app, thread_id))
return -1;
if (app_pipeline_data(app, pipeline_id) == NULL)
return -1;
p = &app->pipeline_data[pipeline_id];
if (p->enabled == 0)
return -1;
req = app_msg_alloc(app);
if (req == NULL)
return -1;
req->type = THREAD_MSG_REQ_PIPELINE_DISABLE;
req->pipeline_id = pipeline_id;
rsp = thread_msg_send_recv(app,
socket_id, core_id, hyper_th_id, req, MSG_TIMEOUT_DEFAULT);
if (rsp == NULL)
return -1;
status = rsp->status;
app_msg_free(app, rsp);
if (status != 0)
return -1;
p->enabled = 0;
return 0;
}
int
app_thread_headroom(struct app_params *app,
uint32_t socket_id,
uint32_t core_id,
uint32_t hyper_th_id)
{
struct thread_headroom_read_msg_req *req;
struct thread_headroom_read_msg_rsp *rsp;
int thread_id;
int status;
if (app == NULL)
return -1;
thread_id = cpu_core_map_get_lcore_id(app->core_map,
socket_id,
core_id,
hyper_th_id);
if ((thread_id < 0) || !app_core_is_enabled(app, thread_id))
return -1;
req = app_msg_alloc(app);
if (req == NULL)
return -1;
req->type = THREAD_MSG_REQ_HEADROOM_READ;
rsp = thread_msg_send_recv(app,
socket_id, core_id, hyper_th_id, req, MSG_TIMEOUT_DEFAULT);
if (rsp == NULL)
return -1;
status = rsp->status;
if (status != 0)
return -1;
printf("%.3f%%\n", rsp->headroom_ratio * 100);
app_msg_free(app, rsp);
return 0;
}
/*
* pipeline enable
*/
struct cmd_pipeline_enable_result {
cmdline_fixed_string_t t_string;
cmdline_fixed_string_t t_id_string;
cmdline_fixed_string_t pipeline_string;
uint32_t pipeline_id;
cmdline_fixed_string_t enable_string;
};
static void
cmd_pipeline_enable_parsed(
void *parsed_result,
__rte_unused struct cmdline *cl,
void *data)
{
struct cmd_pipeline_enable_result *params = parsed_result;
struct app_params *app = data;
int status;
uint32_t core_id, socket_id, hyper_th_id;
if (parse_pipeline_core(&socket_id,
&core_id,
&hyper_th_id,
params->t_id_string) != 0) {
printf("Command failed\n");
return;
}
status = app_pipeline_enable(app,
socket_id,
core_id,
hyper_th_id,
params->pipeline_id);
if (status != 0)
printf("Command failed\n");
}
static cmdline_parse_token_string_t cmd_pipeline_enable_t_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_enable_result, t_string, "t");
static cmdline_parse_token_string_t cmd_pipeline_enable_t_id_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_enable_result, t_id_string,
NULL);
static cmdline_parse_token_string_t cmd_pipeline_enable_pipeline_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_enable_result, pipeline_string,
"pipeline");
static cmdline_parse_token_num_t cmd_pipeline_enable_pipeline_id =
TOKEN_NUM_INITIALIZER(struct cmd_pipeline_enable_result, pipeline_id,
UINT32);
static cmdline_parse_token_string_t cmd_pipeline_enable_enable_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_enable_result, enable_string,
"enable");
static cmdline_parse_inst_t cmd_pipeline_enable = {
.f = cmd_pipeline_enable_parsed,
.data = NULL,
.help_str = "Enable pipeline on specified core",
.tokens = {
(void *)&cmd_pipeline_enable_t_string,
(void *)&cmd_pipeline_enable_t_id_string,
(void *)&cmd_pipeline_enable_pipeline_string,
(void *)&cmd_pipeline_enable_pipeline_id,
(void *)&cmd_pipeline_enable_enable_string,
NULL,
},
};
/*
* pipeline disable
*/
struct cmd_pipeline_disable_result {
cmdline_fixed_string_t t_string;
cmdline_fixed_string_t t_id_string;
cmdline_fixed_string_t pipeline_string;
uint32_t pipeline_id;
cmdline_fixed_string_t disable_string;
};
static void
cmd_pipeline_disable_parsed(
void *parsed_result,
__rte_unused struct cmdline *cl,
void *data)
{
struct cmd_pipeline_disable_result *params = parsed_result;
struct app_params *app = data;
int status;
uint32_t core_id, socket_id, hyper_th_id;
if (parse_pipeline_core(&socket_id,
&core_id,
&hyper_th_id,
params->t_id_string) != 0) {
printf("Command failed\n");
return;
}
status = app_pipeline_disable(app,
socket_id,
core_id,
hyper_th_id,
params->pipeline_id);
if (status != 0)
printf("Command failed\n");
}
static cmdline_parse_token_string_t cmd_pipeline_disable_t_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_disable_result, t_string, "t");
static cmdline_parse_token_string_t cmd_pipeline_disable_t_id_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_disable_result, t_id_string,
NULL);
static cmdline_parse_token_string_t cmd_pipeline_disable_pipeline_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_disable_result,
pipeline_string, "pipeline");
static cmdline_parse_token_num_t cmd_pipeline_disable_pipeline_id =
TOKEN_NUM_INITIALIZER(struct cmd_pipeline_disable_result, pipeline_id,
UINT32);
static cmdline_parse_token_string_t cmd_pipeline_disable_disable_string =
TOKEN_STRING_INITIALIZER(struct cmd_pipeline_disable_result, disable_string,
"disable");
static cmdline_parse_inst_t cmd_pipeline_disable = {
.f = cmd_pipeline_disable_parsed,
.data = NULL,
.help_str = "Disable pipeline on specified core",
.tokens = {
(void *)&cmd_pipeline_disable_t_string,
(void *)&cmd_pipeline_disable_t_id_string,
(void *)&cmd_pipeline_disable_pipeline_string,
(void *)&cmd_pipeline_disable_pipeline_id,
(void *)&cmd_pipeline_disable_disable_string,
NULL,
},
};
/*
* thread headroom
*/
struct cmd_thread_headroom_result {
cmdline_fixed_string_t t_string;
cmdline_fixed_string_t t_id_string;
cmdline_fixed_string_t headroom_string;
};
static void
cmd_thread_headroom_parsed(
void *parsed_result,
__rte_unused struct cmdline *cl,
void *data)
{
struct cmd_thread_headroom_result *params = parsed_result;
struct app_params *app = data;
int status;
uint32_t core_id, socket_id, hyper_th_id;
if (parse_pipeline_core(&socket_id,
&core_id,
&hyper_th_id,
params->t_id_string) != 0) {
printf("Command failed\n");
return;
}
status = app_thread_headroom(app,
socket_id,
core_id,
hyper_th_id);
if (status != 0)
printf("Command failed\n");
}
static cmdline_parse_token_string_t cmd_thread_headroom_t_string =
TOKEN_STRING_INITIALIZER(struct cmd_thread_headroom_result,
t_string, "t");
static cmdline_parse_token_string_t cmd_thread_headroom_t_id_string =
TOKEN_STRING_INITIALIZER(struct cmd_thread_headroom_result,
t_id_string, NULL);
static cmdline_parse_token_string_t cmd_thread_headroom_headroom_string =
TOKEN_STRING_INITIALIZER(struct cmd_thread_headroom_result,
headroom_string, "headroom");
static cmdline_parse_inst_t cmd_thread_headroom = {
.f = cmd_thread_headroom_parsed,
.data = NULL,
.help_str = "Display thread headroom",
.tokens = {
(void *)&cmd_thread_headroom_t_string,
(void *)&cmd_thread_headroom_t_id_string,
(void *)&cmd_thread_headroom_headroom_string,
NULL,
},
};
static cmdline_parse_ctx_t thread_cmds[] = {
(cmdline_parse_inst_t *) &cmd_pipeline_enable,
(cmdline_parse_inst_t *) &cmd_pipeline_disable,
(cmdline_parse_inst_t *) &cmd_thread_headroom,
NULL,
};
int
app_pipeline_thread_cmd_push(struct app_params *app)
{
uint32_t n_cmds, i;
/* Check for available slots in the application commands array */
n_cmds = RTE_DIM(thread_cmds) - 1;
if (n_cmds > APP_MAX_CMDS - app->n_cmds)
return -ENOMEM;
/* Push thread commands into the application */
memcpy(&app->cmds[app->n_cmds], thread_cmds,
n_cmds * sizeof(cmdline_parse_ctx_t));
for (i = 0; i < n_cmds; i++)
app->cmds[app->n_cmds + i]->data = app;
app->n_cmds += n_cmds;
app->cmds[app->n_cmds] = NULL;
return 0;
}

View File

@ -1,72 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2015 Intel Corporation
*/
#ifndef THREAD_FE_H_
#define THREAD_FE_H_
static inline struct rte_ring *
app_thread_msgq_in_get(struct app_params *app,
uint32_t socket_id, uint32_t core_id, uint32_t ht_id)
{
char msgq_name[32];
ssize_t param_idx;
snprintf(msgq_name, sizeof(msgq_name),
"MSGQ-REQ-CORE-s%" PRIu32 "c%" PRIu32 "%s",
socket_id,
core_id,
(ht_id) ? "h" : "");
param_idx = APP_PARAM_FIND(app->msgq_params, msgq_name);
if (param_idx < 0)
return NULL;
return app->msgq[param_idx];
}
static inline struct rte_ring *
app_thread_msgq_out_get(struct app_params *app,
uint32_t socket_id, uint32_t core_id, uint32_t ht_id)
{
char msgq_name[32];
ssize_t param_idx;
snprintf(msgq_name, sizeof(msgq_name),
"MSGQ-RSP-CORE-s%" PRIu32 "c%" PRIu32 "%s",
socket_id,
core_id,
(ht_id) ? "h" : "");
param_idx = APP_PARAM_FIND(app->msgq_params, msgq_name);
if (param_idx < 0)
return NULL;
return app->msgq[param_idx];
}
int
app_pipeline_thread_cmd_push(struct app_params *app);
int
app_pipeline_enable(struct app_params *app,
uint32_t core_id,
uint32_t socket_id,
uint32_t hyper_th_id,
uint32_t pipeline_id);
int
app_pipeline_disable(struct app_params *app,
uint32_t core_id,
uint32_t socket_id,
uint32_t hyper_th_id,
uint32_t pipeline_id);
int
app_thread_headroom(struct app_params *app,
uint32_t core_id,
uint32_t socket_id,
uint32_t hyper_th_id);
#endif /* THREAD_FE_H_ */