#include <stdint.h>
#include "main.h"
#define SUBPORT_OFFSET 7
#define PIPE_OFFSET 9
#define QUEUE_OFFSET 20
#define COLOR_OFFSET 19
static inline int
get_pkt_sched(
struct rte_mbuf *m, uint32_t *subport, uint32_t *pipe,
uint32_t *traffic_class, uint32_t *queue, uint32_t *color)
{
uint16_t pipe_queue;
(port_params.n_subports_per_port - 1);
(subport_params[*subport].n_pipes_per_subport_enabled - 1);
pipe_queue = active_queues[(pdata[QUEUE_OFFSET] >> 8) % n_active_queues];
*queue = pipe_queue - *traffic_class;
*color = pdata[COLOR_OFFSET] & 0x03;
return 0;
}
void
app_rx_thread(struct thread_conf **confs)
{
uint32_t i, nb_rx;
struct thread_conf *conf;
int conf_idx = 0;
uint32_t subport;
uint32_t pipe;
uint32_t traffic_class;
uint32_t queue;
uint32_t color;
while ((conf = confs[conf_idx])) {
burst_conf.rx_burst);
APP_STATS_ADD(conf->stat.nb_rx, nb_rx);
for(i = 0; i < nb_rx; i++) {
get_pkt_sched(rx_mbufs[i],
&subport, &pipe, &traffic_class, &queue, &color);
rx_mbufs[i],
subport, pipe,
traffic_class, queue,
}
(void **)rx_mbufs, nb_rx, NULL) == 0)) {
for(i = 0; i < nb_rx; i++) {
APP_STATS_ADD(conf->stat.nb_drop, 1);
}
}
}
conf_idx++;
if (confs[conf_idx] == NULL)
conf_idx = 0;
}
}
static inline void
app_send_burst(struct thread_conf *qconf)
{
uint32_t n, ret;
mbufs = (
struct rte_mbuf **)qconf->m_table;
n = qconf->n_mbufs;
do {
n -= ret;
mbufs = (
struct rte_mbuf **)&mbufs[ret];
} while (n);
}
static void
app_send_packets(
struct thread_conf *qconf,
struct rte_mbuf **mbufs, uint32_t nb_pkt)
{
uint32_t i, len;
len = qconf->n_mbufs;
for(i = 0; i < nb_pkt; i++) {
qconf->m_table[len] = mbufs[i];
len++;
if (
unlikely(len == burst_conf.tx_burst)) {
qconf->n_mbufs = len;
app_send_burst(qconf);
len = 0;
}
}
qconf->n_mbufs = len;
}
void
app_tx_thread(struct thread_conf **confs)
{
struct rte_mbuf *mbufs[burst_conf.qos_dequeue];
struct thread_conf *conf;
int conf_idx = 0;
int retval;
const uint64_t drain_tsc = (
rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US;
while ((conf = confs[conf_idx])) {
burst_conf.qos_dequeue, NULL);
app_send_packets(conf, mbufs, burst_conf.qos_dequeue);
conf->counter = 0;
}
conf->counter++;
if (
unlikely(conf->counter > drain_tsc)) {
if (conf->n_mbufs != 0) {
app_send_burst(conf);
conf->n_mbufs = 0;
}
conf->counter = 0;
}
conf_idx++;
if (confs[conf_idx] == NULL)
conf_idx = 0;
}
}
void
app_worker_thread(struct thread_conf **confs)
{
struct rte_mbuf *mbufs[burst_conf.ring_burst];
struct thread_conf *conf;
int conf_idx = 0;
while ((conf = confs[conf_idx])) {
uint32_t nb_pkt;
burst_conf.ring_burst, NULL);
nb_pkt);
APP_STATS_ADD(conf->stat.nb_drop, nb_pkt - nb_sent);
APP_STATS_ADD(conf->stat.nb_rx, nb_pkt);
}
burst_conf.qos_dequeue);
(void **)mbufs, nb_pkt, NULL) == 0)
;
conf_idx++;
if (confs[conf_idx] == NULL)
conf_idx = 0;
}
}
void
app_mixed_thread(struct thread_conf **confs)
{
struct rte_mbuf *mbufs[burst_conf.ring_burst];
struct thread_conf *conf;
int conf_idx = 0;
const uint64_t drain_tsc = (
rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US;
while ((conf = confs[conf_idx])) {
uint32_t nb_pkt;
burst_conf.ring_burst, NULL);
nb_pkt);
APP_STATS_ADD(conf->stat.nb_drop, nb_pkt - nb_sent);
APP_STATS_ADD(conf->stat.nb_rx, nb_pkt);
}
burst_conf.qos_dequeue);
app_send_packets(conf, mbufs, nb_pkt);
conf->counter = 0;
}
conf->counter++;
if (
unlikely(conf->counter > drain_tsc)) {
if (conf->n_mbufs != 0) {
app_send_burst(conf);
conf->n_mbufs = 0;
}
conf->counter = 0;
}
conf_idx++;
if (confs[conf_idx] == NULL)
conf_idx = 0;
}
}
static uint16_t rte_be_to_cpu_16(rte_be16_t x)
#define __rte_cache_aligned
uint64_t rte_get_tsc_hz(void)
static uint16_t rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
static uint16_t rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
static void rte_pktmbuf_free(struct rte_mbuf *m)
#define rte_pktmbuf_mtod(m, t)
static __rte_always_inline unsigned int rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
static __rte_always_inline unsigned int rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
static __rte_always_inline unsigned int rte_ring_sp_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
int rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
void rte_sched_port_pkt_write(struct rte_sched_port *port, struct rte_mbuf *pkt, uint32_t subport, uint32_t pipe, uint32_t traffic_class, uint32_t queue, enum rte_color color)
#define RTE_SCHED_TRAFFIC_CLASS_BE
int rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)