#include <stdint.h>
#include <inttypes.h>
#include "cat.h"
#define RX_RING_SIZE 128
#define TX_RING_SIZE 512
#define NUM_MBUFS 8191
#define MBUF_CACHE_SIZE 250
#define BURST_SIZE 32
static inline int
port_init(uint16_t port,
struct rte_mempool *mbuf_pool)
{
const uint16_t rx_rings = 1, tx_rings = 1;
int retval;
uint16_t q;
uint16_t nb_rxd = RX_RING_SIZE;
uint16_t nb_txd = TX_RING_SIZE;
return -1;
if (retval != 0)
return retval;
if (retval != 0)
return retval;
for (q = 0; q < rx_rings; q++) {
if (retval < 0)
return retval;
}
for (q = 0; q < tx_rings; q++) {
if (retval < 0)
return retval;
}
if (retval < 0)
return retval;
if (retval < 0)
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;
}
lcore_main(void)
{
uint16_t port;
printf("WARNING, port %u is on remote NUMA node to "
"polling thread.\n\tPerformance will "
"not be optimal.\n", port);
printf("\nCore %u forwarding packets. [Ctrl+C to quit]\n",
for (;;) {
bufs, BURST_SIZE);
continue;
bufs, nb_rx);
uint16_t buf;
for (buf = nb_tx; buf < nb_rx; buf++)
}
}
}
}
int
main(int argc, char *argv[])
{
unsigned nb_ports;
uint16_t portid;
if (ret < 0)
rte_exit(EXIT_FAILURE,
"Error with EAL initialization\n");
argc -= ret;
argv += ret;
ret = cat_init(argc, argv);
if (ret < 0)
rte_exit(EXIT_FAILURE,
"PQOS: L3CA init failed!\n");
argc -= ret;
argv += ret;
if (nb_ports < 2 || (nb_ports & 1))
rte_exit(EXIT_FAILURE,
"Error: number of ports must be even\n");
if (mbuf_pool == NULL)
rte_exit(EXIT_FAILURE,
"Cannot create mbuf pool\n");
if (port_init(portid, mbuf_pool) != 0)
rte_exit(EXIT_FAILURE,
"Cannot init port %"PRIu16
"\n",
portid);
printf("\nWARNING: Too many lcores enabled. Only 1 used.\n");
lcore_main();
return 0;
}
__rte_noreturn void rte_exit(int exit_code, const char *format,...) __rte_format_printf(2
int rte_eal_init(int argc, char **argv)
int rte_eal_cleanup(void)
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)
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)
int rte_eth_promiscuous_enable(uint16_t port_id)
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)
static uint16_t rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
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)
int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id, uint16_t *nb_rx_desc, uint16_t *nb_tx_desc)
#define RTE_ETH_FOREACH_DEV(p)
int rte_eth_dev_start(uint16_t port_id)
#define RTE_ETHER_ADDR_BYTES(mac_addrs)
unsigned int rte_lcore_count(void)
unsigned int rte_socket_id(void)
static unsigned rte_lcore_id(void)
static void rte_pktmbuf_free(struct rte_mbuf *m)
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)