#define MAX_PKT_BURST 32
#define BURST_TX_DRAIN 200000ULL /* around 100us at 2 Ghz */
-#define SOCKET0 0
-
#define TX_QUEUE_FLUSH_MASK 0xFFFFFFFF
#define TSC_COUNT_LIMIT 1000
#define FATAL_ERROR(fmt, args...) rte_exit(EXIT_FAILURE, fmt "\n", ##args)
#define PRINT_INFO(fmt, args...) RTE_LOG(INFO, APP, fmt "\n", ##args)
-/* NUMA socket to allocate mbuf pool on */
-#define SOCKET 0
-
/* Max ports than can be used (each port is associated with two lcores) */
#define MAX_PORTS (RTE_MAX_LCORE / 2)
FATAL_ERROR("Could not configure port%u (%d)",
(unsigned)port, ret);
- ret = rte_eth_rx_queue_setup(port, 0, NB_RXD, SOCKET, &rx_conf,
- pktmbuf_pool);
+ ret = rte_eth_rx_queue_setup(port, 0, NB_RXD, rte_eth_dev_socket_id(port),
+ &rx_conf, pktmbuf_pool);
if (ret < 0)
FATAL_ERROR("Could not setup up RX queue for port%u (%d)",
(unsigned)port, ret);
- ret = rte_eth_tx_queue_setup(port, 0, NB_TXD, SOCKET, &tx_conf);
+ ret = rte_eth_tx_queue_setup(port, 0, NB_TXD, rte_eth_dev_socket_id(port),
+ &tx_conf);
if (ret < 0)
FATAL_ERROR("Could not setup up TX queue for port%u (%d)",
(unsigned)port, ret);
MEMPOOL_CACHE_SZ,
sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
- SOCKET, 0);
+ rte_socket_id(), 0);
if (pktmbuf_pool == NULL) {
FATAL_ERROR("Could not initialise mbuf pool");
return -1;
#define MAX_PKT_BURST 32
#define BURST_TX_DRAIN 200000ULL /* around 100us at 2 Ghz */
-#define SOCKET0 0
-
/* Configure how many packets ahead to prefetch, when reading packets */
#define PREFETCH_OFFSET 3
sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL,
rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (pool_direct == NULL)
rte_panic("Cannot init direct mbuf pool\n");
0,
NULL, NULL,
rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (pool_indirect == NULL)
rte_panic("Cannot init indirect mbuf pool\n");
printf("rxq=%d ", queueid);
fflush(stdout);
ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
- SOCKET0, &rx_conf,
+ rte_eth_dev_socket_id(portid), &rx_conf,
pool_direct);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: "
printf("txq=%u,%d ", lcore_id, queueid);
fflush(stdout);
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
- SOCKET0, &tx_conf);
+ rte_eth_dev_socket_id(portid), &tx_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: "
"err=%d, port=%d\n", ret, portid);
check_all_ports_link_status((uint8_t)nb_ports, enabled_port_mask);
/* create the LPM table */
- l3fwd_lpm = rte_lpm_create("L3FWD_LPM", SOCKET0, L3FWD_LPM_MAX_RULES, 0);
+ l3fwd_lpm = rte_lpm_create("L3FWD_LPM", rte_socket_id(), L3FWD_LPM_MAX_RULES, 0);
if (l3fwd_lpm == NULL)
rte_panic("Unable to create the l3fwd LPM table\n");
#define MAX_PKT_BURST 32
#define BURST_TX_DRAIN 200000ULL /* around 100us at 2 Ghz */
-#define SOCKET0 0
-
/* Configure how many packets ahead to prefetch, when reading packets */
#define PREFETCH_OFFSET 3
.name = "MCAST_HASH",
.entries = 1024,
.entries_per_bucket = 4,
- .socket_id = SOCKET0,
+ .socket_id = 0,
.hash_func = NULL,
.init_val = 0,
};
{
uint32_t i;
+ mcast_hash_params.socket_id = rte_socket_id();
mcast_hash = rte_fbk_hash_create(&mcast_hash_params);
if (mcast_hash == NULL){
return -1;
packet_pool = rte_mempool_create("packet_pool", NB_PKT_MBUF,
PKT_MBUF_SIZE, 32, sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (packet_pool == NULL)
rte_exit(EXIT_FAILURE, "Cannot init packet mbuf pool\n");
header_pool = rte_mempool_create("header_pool", NB_HDR_MBUF,
HDR_MBUF_SIZE, 32, 0, NULL, NULL, rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (header_pool == NULL)
rte_exit(EXIT_FAILURE, "Cannot init header mbuf pool\n");
clone_pool = rte_mempool_create("clone_pool", NB_CLONE_MBUF,
CLONE_MBUF_SIZE, 32, 0, NULL, NULL, rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (clone_pool == NULL)
rte_exit(EXIT_FAILURE, "Cannot init clone mbuf pool\n");
printf("rxq=%hu ", queueid);
fflush(stdout);
ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
- SOCKET0, &rx_conf,
+ rte_eth_dev_socket_id(portid), &rx_conf,
packet_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, port=%d\n",
printf("txq=%u,%hu ", lcore_id, queueid);
fflush(stdout);
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
- SOCKET0, &tx_conf);
+ rte_lcore_to_socket_id(lcore_id), &tx_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, "
"port=%d\n", ret, portid);
#define MAX_PKT_BURST 32
#define BURST_TX_DRAIN 200000ULL /* around 100us at 2 Ghz */
-#define SOCKET0 0
-
/*
* Configurable number of RX/TX ring descriptors
*/
sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL,
rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (l2fwd_pktmbuf_pool == NULL)
rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n");
rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, port=%u\n",
ret, (unsigned) portid);
- /* init one TX queue logical core on each port */
+ /* init one TX queue on each port */
fflush(stdout);
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
- SOCKET0, &tx_conf);
+ rte_eth_dev_socket_id(portid), &tx_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, port=%u\n",
ret, (unsigned) portid);
#define NB_SOCKETS 8
-#define SOCKET0 0
-
/* Configure how many packets ahead to prefetch, when reading packets */
#define PREFETCH_OFFSET 3
.key_len = sizeof(struct ipv4_5tuple),
.hash_func = DEFAULT_HASH_FUNC,
.hash_func_init_val = 0,
- .socket_id = SOCKET0,
+ .socket_id = 0,
};
struct rte_hash_parameters ipv6_l3fwd_hash_params = {
.key_len = sizeof(struct ipv6_5tuple),
.hash_func = DEFAULT_HASH_FUNC,
.hash_func_init_val = 0,
- .socket_id = SOCKET0,
+ .socket_id = 0,
};
#define IPV4_L3FWD_NUM_ROUTES \
#define MAX_PKT_BURST 32
#define BURST_TX_DRAIN 200000ULL /* around 100us at 2 Ghz */
-#define SOCKET0 0
-
/*
* Configurable number of RX/TX ring descriptors
*/
sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL,
rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (lsi_pktmbuf_pool == NULL)
rte_panic("Cannot init mbuf pool\n");
/* init one RX queue */
fflush(stdout);
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
- SOCKET0, &rx_conf,
+ rte_eth_dev_socket_id(portid), &rx_conf,
lsi_pktmbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup: err=%d, port=%u\n",
/* init one TX queue logical core on each port */
fflush(stdout);
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
- SOCKET0, &tx_conf);
+ rte_eth_dev_socket_id(portid), &tx_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d,port=%u\n",
ret, (unsigned) portid);
pktmbuf_pool = rte_mempool_create(PKTMBUF_POOL_NAME, num_mbufs,
MBUF_SIZE, MBUF_CACHE_SIZE,
sizeof(struct rte_pktmbuf_pool_private), rte_pktmbuf_pool_init,
- NULL, rte_pktmbuf_init, NULL, SOCKET0, NO_FLAGS );
+ NULL, rte_pktmbuf_init, NULL, rte_socket_id(), NO_FLAGS );
return (pktmbuf_pool == NULL); /* 0 on success */
}
for (q = 0; q < rx_rings; q++) {
retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size,
- SOCKET0, &rx_conf_default, pktmbuf_pool);
+ rte_eth_dev_socket_id(port_num), &rx_conf_default, pktmbuf_pool);
if (retval < 0) return retval;
}
for ( q = 0; q < tx_rings; q ++ ) {
retval = rte_eth_tx_queue_setup(port_num, q, tx_ring_size,
- SOCKET0, &tx_conf_default);
+ rte_eth_dev_socket_id(port_num), &tx_conf_default);
if (retval < 0) return retval;
}
init_shm_rings(void)
{
unsigned i;
+ unsigned socket_id;
+ const char * q_name;
const unsigned ringsize = CLIENT_QUEUE_RINGSIZE;
clients = rte_malloc("client details",
for (i = 0; i < num_clients; i++) {
/* Create an RX queue for each client */
- clients[i].rx_q = rte_ring_create(get_rx_queue_name(i),
- ringsize, SOCKET0,
+ socket_id = rte_socket_id();
+ q_name = get_rx_queue_name(i);
+ clients[i].rx_q = rte_ring_create(q_name,
+ ringsize, socket_id,
RING_F_SP_ENQ | RING_F_SC_DEQ ); /* single prod, single cons */
if (clients[i].rx_q == NULL)
rte_exit(EXIT_FAILURE, "Cannot create rx ring queue for client %u\n", i);
#ifndef _MAIN_H_
#define _MAIN_H_
-#define SOCKET0 0
-#define SOCKET1 1
-
#ifdef RTE_EXEC_ENV_BAREMETAL
#define MAIN _main
#else
#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
-#define SOCKET0 0
-
static const char *_MSG_POOL = "MSG_POOL";
static const char *_SEC_2_PRI = "SEC_2_PRI";
static const char *_PRI_2_SEC = "PRI_2_SEC";
rte_exit(EXIT_FAILURE, "Cannot init EAL\n");
if (rte_eal_process_type() == RTE_PROC_PRIMARY){
- send_ring = rte_ring_create(_PRI_2_SEC, ring_size, SOCKET0, flags);
- recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, SOCKET0, flags);
+ send_ring = rte_ring_create(_PRI_2_SEC, ring_size, rte_socket_id(), flags);
+ recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, rte_socket_id(), flags);
message_pool = rte_mempool_create(_MSG_POOL, pool_size,
string_size, pool_cache, priv_data_sz,
NULL, NULL, NULL, NULL,
- SOCKET0, flags);
+ rte_socket_id(), flags);
} else {
recv_ring = rte_ring_lookup(_PRI_2_SEC);
send_ring = rte_ring_lookup(_SEC_2_PRI);
#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
-#define SOCKET0 0
-
#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
#define NB_MBUFS 64*1024 /* use 64k mbufs */
#define MBUF_CACHE_SIZE 256
for (q = 0; q < rx_rings; q ++) {
retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
- SOCKET0, &rx_conf_default,
+ rte_eth_dev_socket_id(port), &rx_conf_default,
mbuf_pool);
if (retval < 0)
return retval;
for (q = 0; q < tx_rings; q ++) {
retval = rte_eth_tx_queue_setup(port, q, RX_RING_SIZE,
- SOCKET0, &tx_conf_default);
+ rte_eth_dev_socket_id(port), &tx_conf_default);
if (retval < 0)
return retval;
}
MBUF_CACHE_SIZE, sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL,
rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (mp == NULL)
rte_exit(EXIT_FAILURE, "Cannot get memory pool for buffers\n");
#include "main.h"
/* basic constants used in application */
-#define SOCKET0 0
-#define SOCKET1 1
-
#define NUM_QUEUES 128
#define NUM_MBUFS 64*1024
for (q = 0; q < rxRings; q ++) {
retval = rte_eth_rx_queue_setup(port, q, rxRingSize,
- SOCKET0, &rx_conf_default,
+ rte_eth_dev_socket_id(port), &rx_conf_default,
mbuf_pool);
if (retval < 0)
return retval;
for (q = 0; q < txRings; q ++) {
retval = rte_eth_tx_queue_setup(port, q, txRingSize,
- SOCKET0, &tx_conf_default);
+ rte_eth_dev_socket_id(port), &tx_conf_default);
if (retval < 0)
return retval;
}
sizeof(struct rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL,
rte_pktmbuf_init, NULL,
- SOCKET0, 0);
+ rte_socket_id(), 0);
if (mbuf_pool == NULL)
rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");