#include "pipeline_common.h"
worker_fwd_event(
struct rte_event *ev, uint8_t sched)
{
}
worker_event_enqueue(const uint8_t dev, const uint8_t port,
{
}
worker_event_enqueue_burst(const uint8_t dev, const uint8_t port,
{
uint16_t enq;
while (enq < nb_rx) {
ev + enq, nb_rx - enq);
}
}
worker_tx_pkt(
const uint8_t dev,
const uint8_t port,
struct rte_event *ev)
{
}
static int
worker_do_tx_single(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
const uint8_t dev = data->dev_id;
const uint8_t port = data->port_id;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
continue;
}
received++;
worker_tx_pkt(dev, port, &ev);
tx++;
} else {
work();
worker_event_enqueue(dev, port, &ev);
fwd++;
}
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
worker_do_tx_single_atq(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
const uint8_t dev = data->dev_id;
const uint8_t port = data->port_id;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
continue;
}
received++;
worker_tx_pkt(dev, port, &ev);
tx++;
} else {
work();
worker_event_enqueue(dev, port, &ev);
fwd++;
}
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
worker_do_tx_single_burst(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
const uint8_t dev = data->dev_id;
const uint8_t port = data->port_id;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
uint16_t i;
BATCH_SIZE, 0);
if (!nb_rx) {
continue;
}
received += nb_rx;
for (i = 0; i < nb_rx; i++) {
worker_tx_pkt(dev, port, &ev[i]);
tx++;
} else {
}
work();
}
worker_event_enqueue_burst(dev, port, ev, nb_rx);
fwd += nb_rx;
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
worker_do_tx_single_burst_atq(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
const uint8_t dev = data->dev_id;
const uint8_t port = data->port_id;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
uint16_t i;
BATCH_SIZE, 0);
if (!nb_rx) {
continue;
}
received += nb_rx;
for (i = 0; i < nb_rx; i++) {
worker_tx_pkt(dev, port, &ev[i]);
tx++;
} else
work();
}
worker_event_enqueue_burst(dev, port, ev, nb_rx);
fwd += nb_rx;
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
worker_do_tx(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
const uint8_t dev = data->dev_id;
const uint8_t port = data->port_id;
const uint8_t lst_qid = cdata.num_stages - 1;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
continue;
}
received++;
const uint8_t cq_id = ev.
queue_id % cdata.num_stages;
if (cq_id >= lst_qid) {
worker_tx_pkt(dev, port, &ev);
tx++;
continue;
}
} else {
worker_fwd_event(&ev, cdata.queue_type);
}
work();
worker_event_enqueue(dev, port, &ev);
fwd++;
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
worker_do_tx_atq(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
const uint8_t dev = data->dev_id;
const uint8_t port = data->port_id;
const uint8_t lst_qid = cdata.num_stages - 1;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
continue;
}
received++;
if (cq_id == lst_qid) {
worker_tx_pkt(dev, port, &ev);
tx++;
continue;
}
} else {
worker_fwd_event(&ev, cdata.queue_type);
}
work();
worker_event_enqueue(dev, port, &ev);
fwd++;
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
worker_do_tx_burst(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
uint8_t dev = data->dev_id;
uint8_t port = data->port_id;
uint8_t lst_qid = cdata.num_stages - 1;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
uint16_t i;
ev, BATCH_SIZE, 0);
if (nb_rx == 0) {
continue;
}
received += nb_rx;
for (i = 0; i < nb_rx; i++) {
const uint8_t cq_id = ev[i].
queue_id % cdata.num_stages;
if (cq_id >= lst_qid) {
worker_tx_pkt(dev, port, &ev[i]);
tx++;
continue;
}
cdata.next_qid[ev[i].queue_id] :
ev[i].queue_id;
} else {
worker_fwd_event(&ev[i], cdata.queue_type);
}
work();
}
worker_event_enqueue_burst(dev, port, ev, nb_rx);
fwd += nb_rx;
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
worker_do_tx_burst_atq(void *arg)
{
struct worker_data *data = (struct worker_data *)arg;
uint8_t dev = data->dev_id;
uint8_t port = data->port_id;
uint8_t lst_qid = cdata.num_stages - 1;
size_t fwd = 0, received = 0, tx = 0;
while (!fdata->done) {
uint16_t i;
ev, BATCH_SIZE, 0);
if (nb_rx == 0) {
continue;
}
received += nb_rx;
for (i = 0; i < nb_rx; i++) {
cdata.num_stages;
if (cq_id == lst_qid) {
worker_tx_pkt(dev, port, &ev[i]);
tx++;
continue;
}
} else {
worker_fwd_event(&ev[i], cdata.queue_type);
}
work();
}
worker_event_enqueue_burst(dev, port, ev, nb_rx);
fwd += nb_rx;
}
if (!cdata.quiet)
printf(" worker %u thread done. RX=%zu FWD=%zu TX=%zu\n",
return 0;
}
static int
setup_eventdev_worker_tx_enq(struct worker_data *worker_data)
{
uint8_t i;
const uint8_t atq = cdata.all_type_queues ? 1 : 0;
const uint8_t dev_id = 0;
const uint8_t nb_ports = cdata.num_workers;
uint8_t nb_slots = 0;
if (!atq) {
nb_queues *= cdata.num_stages;
}
.nb_event_ports = nb_ports,
.nb_single_link_event_port_queues = 0,
.nb_events_limit = 4096,
.nb_event_queue_flows = 1024,
.nb_event_port_dequeue_depth = 128,
.nb_event_port_enqueue_depth = 128,
};
.enqueue_depth = 64,
.new_event_threshold = 4096,
};
.nb_atomic_flows = 1024,
.nb_atomic_order_sequences = 1024,
};
if (ndev < 1) {
printf("%d: No Eventdev Devices Found\n", __LINE__);
return -1;
}
printf("\tEventdev %d: %s\n", dev_id, dev_info.driver_name);
if (dev_info.max_event_port_dequeue_depth <
dev_info.max_event_port_dequeue_depth;
if (dev_info.max_event_port_enqueue_depth <
dev_info.max_event_port_enqueue_depth;
if (ret < 0) {
printf("%d: Error configuring device\n", __LINE__);
return -1;
}
printf(" Stages:\n");
for (i = 0; i < nb_queues; i++) {
if (atq) {
nb_slots = cdata.num_stages;
} else {
uint8_t slot;
nb_slots = cdata.num_stages + 1;
slot = i % nb_slots;
}
printf("%d: error creating qid %d\n", __LINE__, i);
return -1;
}
cdata.qid[i] = i;
cdata.next_qid[i] = i+1;
if (cdata.enable_queue_priorities) {
const uint32_t prio_delta =
nb_slots;
(i % nb_slots);
}
const char *type_str = "Atomic";
type_str = "Ordered";
break;
type_str = "Parallel";
break;
}
printf("\tStage %d, Type %s\tPriority = %d\n", i, type_str,
}
printf("\n");
for (i = 0; i < cdata.num_workers; i++) {
struct worker_data *w = &worker_data[i];
w->dev_id = dev_id;
printf("Error setting up port %d\n", i);
return -1;
}
!= nb_queues) {
printf("%d: error creating link for port %d\n",
__LINE__, i);
return -1;
}
w->port_id = i;
}
cdata.rx_stride = atq ? 1 : nb_slots;
&fdata->evdev_service_id);
if (ret != -ESRCH && ret != 0) {
printf("Error getting the service ID\n");
return -1;
}
rte_exit(EXIT_FAILURE,
"Error starting eventdev");
return dev_id;
}
struct rx_adptr_services {
uint16_t nb_rx_adptrs;
uint32_t *rx_adpt_arr;
};
static int32_t
service_rx_adapter(void *arg)
{
int i;
struct rx_adptr_services *adptr_services = arg;
for (i = 0; i < adptr_services->nb_rx_adptrs; i++)
adptr_services->rx_adpt_arr[i], 1);
return 0;
}
static inline int
{
},
.rx_adv_conf = {
.rss_conf = {
.rss_hf = RTE_ETH_RSS_IP |
RTE_ETH_RSS_TCP |
RTE_ETH_RSS_UDP,
}
}
};
const uint16_t rx_rings = 1, tx_rings = 1;
const uint16_t rx_ring_size = 512, tx_ring_size = 512;
int retval;
uint16_t q;
return -1;
if (retval != 0) {
printf("Error during getting device (port %u) info: %s\n",
port, strerror(-retval));
return retval;
}
rx_conf = dev_info.default_rxconf;
dev_info.flow_type_rss_offloads;
printf("Port %u modified RSS hash function based on hardware support,"
"requested:%#"PRIx64" configured:%#"PRIx64"\n",
port,
}
if (retval != 0)
return retval;
for (q = 0; q < rx_rings; q++) {
mbuf_pool);
if (retval < 0)
return retval;
}
txconf = dev_info.default_txconf;
for (q = 0; q < tx_rings; q++) {
if (retval < 0)
return retval;
}
if (retval != 0) {
printf("Failed to get MAC address (port %u): %s\n",
return retval;
}
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
if (retval != 0)
return retval;
return 0;
}
static int
init_ports(uint16_t num_ports)
{
uint16_t portid;
if (!cdata.num_mbuf)
cdata.num_mbuf = 16384 * num_ports;
cdata.num_mbuf,
512,
0,
RTE_MBUF_DEFAULT_BUF_SIZE,
if (port_init(portid, mp) != 0)
rte_exit(EXIT_FAILURE,
"Cannot init port %"PRIu16
"\n",
portid);
return 0;
}
static void
init_adapters(uint16_t nb_ports)
{
int i;
int ret;
uint8_t evdev_id = 0;
struct rx_adptr_services *adptr_services = NULL;
adptr_services =
rte_zmalloc(NULL,
sizeof(
struct rx_adptr_services), 0);
.enqueue_depth = 64,
.new_event_threshold = 4096,
};
init_ports(nb_ports);
if (adptr_p_conf.
dequeue_depth > dev_info.max_event_port_dequeue_depth)
dev_info.max_event_port_dequeue_depth;
if (adptr_p_conf.
enqueue_depth > dev_info.max_event_port_enqueue_depth)
dev_info.max_event_port_enqueue_depth;
memset(&queue_conf, 0, sizeof(queue_conf));
queue_conf.ev.sched_type = cdata.queue_type;
for (i = 0; i < nb_ports; i++) {
uint32_t cap;
uint32_t service_id;
&adptr_p_conf);
if (ret)
"failed to create rx adapter[%d]", i);
if (ret)
"failed to get event rx adapter "
"capabilities");
queue_conf.ev.queue_id = cdata.rx_stride ?
(i * cdata.rx_stride)
: (uint8_t)cdata.qid[0];
if (ret)
"Failed to add queues to Rx adapter");
&service_id);
if (ret != -ESRCH && ret != 0) {
"Error getting the service ID for rx adptr\n");
}
adptr_services->nb_rx_adptrs++;
adptr_services->rx_adpt_arr,
adptr_services->nb_rx_adptrs *
sizeof(uint32_t), 0);
adptr_services->rx_adpt_arr[
adptr_services->nb_rx_adptrs - 1] =
service_id;
}
if (ret)
rte_exit(EXIT_FAILURE,
"Rx adapter[%d] start failed",
i);
}
&adptr_p_conf);
if (ret)
rte_exit(EXIT_FAILURE,
"failed to create tx adapter[%d]",
cdata.tx_adapter_id);
for (i = 0; i < nb_ports; i++) {
-1);
if (ret)
"Failed to add queues to Tx adapter");
}
if (ret)
rte_exit(EXIT_FAILURE,
"Tx adapter[%d] start failed",
cdata.tx_adapter_id);
if (adptr_services->nb_rx_adptrs) {
snprintf(service.name, sizeof(service.name), "rx_service");
service.callback = service_rx_adapter;
service.callback_userdata = (void *)adptr_services;
int32_t ret = rte_service_component_register(&service,
&fdata->rxadptr_service_id);
if (ret)
"Rx adapter service register failed");
rte_service_component_runstate_set(fdata->rxadptr_service_id,
1);
0);
} else {
memset(fdata->rx_core, 0, sizeof(unsigned int) * MAX_NUM_CORE);
}
if (!adptr_services->nb_rx_adptrs && (dev_info.event_dev_cap &
fdata->cap.scheduler = NULL;
}
static void
worker_tx_enq_opt_check(void)
{
int i;
int ret;
uint32_t cap = 0;
uint8_t rx_needed = 0;
uint8_t sched_needed = 0;
if (cdata.all_type_queues && !(eventdev_info.event_dev_cap &
"Event dev doesn't support all type queues\n");
sched_needed = !(eventdev_info.event_dev_cap &
if (ret)
"failed to get event rx adapter capabilities");
rx_needed |=
}
if (cdata.worker_lcore_mask == 0 ||
(rx_needed && cdata.rx_lcore_mask == 0) ||
(sched_needed && cdata.sched_lcore_mask == 0)) {
printf("Core part of pipeline was not assigned any cores. "
"This will stall the pipeline, please check core masks "
"(use -h for details on setting core masks):\n"
"\trx: %"PRIu64"\n\tsched: %"PRIu64
"\n\tworkers: %"PRIu64"\n", cdata.rx_lcore_mask,
cdata.sched_lcore_mask, cdata.worker_lcore_mask);
}
if (!sched_needed)
memset(fdata->sched_core, 0,
sizeof(unsigned int) * MAX_NUM_CORE);
if (!rx_needed)
memset(fdata->rx_core, 0,
sizeof(unsigned int) * MAX_NUM_CORE);
memset(fdata->tx_core, 0, sizeof(unsigned int) * MAX_NUM_CORE);
}
static worker_loop
get_worker_loop_single_burst(uint8_t atq)
{
if (atq)
return worker_do_tx_single_burst_atq;
return worker_do_tx_single_burst;
}
static worker_loop
get_worker_loop_single_non_burst(uint8_t atq)
{
if (atq)
return worker_do_tx_single_atq;
return worker_do_tx_single;
}
static worker_loop
get_worker_loop_burst(uint8_t atq)
{
if (atq)
return worker_do_tx_burst_atq;
return worker_do_tx_burst;
}
static worker_loop
get_worker_loop_non_burst(uint8_t atq)
{
if (atq)
return worker_do_tx_atq;
return worker_do_tx;
}
static worker_loop
get_worker_single_stage(bool burst)
{
uint8_t atq = cdata.all_type_queues ? 1 : 0;
if (burst)
return get_worker_loop_single_burst(atq);
return get_worker_loop_single_non_burst(atq);
}
static worker_loop
get_worker_multi_stage(bool burst)
{
uint8_t atq = cdata.all_type_queues ? 1 : 0;
if (burst)
return get_worker_loop_burst(atq);
return get_worker_loop_non_burst(atq);
}
void
set_worker_tx_enq_setup_data(struct setup_data *caps, bool burst)
{
if (cdata.num_stages == 1)
caps->worker = get_worker_single_stage(burst);
else
caps->worker = get_worker_multi_stage(burst);
caps->check_opt = worker_tx_enq_opt_check;
caps->scheduler = schedule_devices;
caps->evdev_setup = setup_eventdev_worker_tx_enq;
caps->adptr_setup = init_adapters;
}
__rte_noreturn void rte_exit(int exit_code, const char *format,...) __rte_format_printf(2
#define __rte_always_inline
const char * rte_strerror(int errnum)
int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf)
int rte_eth_dev_is_valid_port(uint16_t port_id)
int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mb_pool)
#define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE
int rte_eth_promiscuous_enable(uint16_t port_id)
int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc, unsigned int socket_id, const struct rte_eth_txconf *tx_conf)
int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr)
uint16_t rte_eth_dev_count_avail(void)
int rte_eth_dev_socket_id(uint16_t port_id)
#define RTE_ETH_FOREACH_DEV(p)
#define RTE_ETHER_ADDR_BYTES(mac_addrs)
int rte_event_eth_rx_adapter_service_id_get(uint8_t id, uint32_t *service_id)
int rte_event_eth_rx_adapter_start(uint8_t id)
int rte_event_eth_rx_adapter_create(uint8_t id, uint8_t dev_id, struct rte_event_port_conf *port_config)
int rte_event_eth_rx_adapter_queue_add(uint8_t id, uint16_t eth_dev_id, int32_t rx_queue_id, const struct rte_event_eth_rx_adapter_queue_conf *conf)
static __rte_always_inline void rte_event_eth_tx_adapter_txq_set(struct rte_mbuf *pkt, uint16_t queue)
int rte_event_eth_tx_adapter_create(uint8_t id, uint8_t dev_id, struct rte_event_port_conf *port_config)
int rte_event_eth_tx_adapter_queue_add(uint8_t id, uint16_t eth_dev_id, int32_t queue)
static uint16_t rte_event_eth_tx_adapter_enqueue(uint8_t dev_id, uint8_t port_id, struct rte_event ev[], uint16_t nb_events, const uint8_t flags)
int rte_event_eth_tx_adapter_start(uint8_t id)
#define RTE_EVENT_DEV_PRIORITY_NORMAL
#define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT
int rte_event_port_link(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links)
static uint16_t rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks)
#define RTE_EVENT_PORT_CFG_HINT_PRODUCER
int rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id)
#define RTE_SCHED_TYPE_ORDERED
#define RTE_SCHED_TYPE_ATOMIC
#define RTE_EVENT_OP_FORWARD
int rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id, uint32_t *caps)
int rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf)
int rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
uint8_t rte_event_dev_count(void)
#define RTE_EVENT_QUEUE_CFG_ALL_TYPES
#define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES
int rte_event_dev_start(uint8_t dev_id)
#define RTE_EVENT_OP_RELEASE
#define RTE_EVENT_DEV_PRIORITY_LOWEST
int rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf)
#define RTE_EVENT_TYPE_CPU
#define RTE_SCHED_TYPE_PARALLEL
#define RTE_EVENT_PORT_CFG_HINT_WORKER
int rte_event_dev_configure(uint8_t dev_id, const struct rte_event_dev_config *dev_conf)
#define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED
static uint16_t rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, const struct rte_event ev[], uint16_t nb_events)
unsigned int rte_socket_id(void)
static unsigned rte_lcore_id(void)
void * rte_zmalloc(const char *type, size_t size, unsigned align) __rte_alloc_size(2)
void void rte_free(void *ptr)
void void * rte_realloc(void *ptr, size_t size, unsigned int align) __rte_alloc_size(2)
struct rte_mempool * rte_pktmbuf_pool_create(const char *name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id)
static void rte_pause(void)
static void rte_prefetch0(const volatile void *p)
int32_t rte_service_run_iter_on_app_lcore(uint32_t id, uint32_t serialize_multithread_unsafe)
int32_t rte_service_set_runstate_mapped_check(uint32_t id, int32_t enable)
int32_t rte_service_runstate_set(uint32_t id, uint32_t runstate)
struct rte_eth_txmode txmode
struct rte_eth_rxmode rxmode
struct rte_eth_conf::@147 rx_adv_conf
struct rte_eth_rss_conf rss_conf
enum rte_eth_rx_mq_mode mq_mode
uint32_t nb_event_port_enqueue_depth
uint32_t nb_event_port_dequeue_depth
int32_t new_event_threshold