From e60f71ebd68f8b841bda43f210861e010ad5eb61 Mon Sep 17 00:00:00 2001 From: Intel Date: Mon, 3 Jun 2013 00:00:00 +0000 Subject: [PATCH] examples: numa updates Signed-off-by: Intel --- examples/dpdk_qat/main.c | 2 -- examples/exception_path/main.c | 12 +++++------- examples/ipv4_frag/main.c | 12 +++++------- examples/ipv4_multicast/main.c | 15 +++++++-------- examples/l2fwd/main.c | 8 +++----- examples/l3fwd/main.c | 6 ++---- examples/link_status_interrupt/main.c | 8 +++----- .../client_server_mp/mp_server/init.c | 14 +++++++++----- .../client_server_mp/mp_server/main.h | 3 --- examples/multi_process/simple_mp/main.c | 8 +++----- examples/multi_process/symmetric_mp/main.c | 8 +++----- examples/vmdq_dcb/main.c | 9 +++------ 12 files changed, 43 insertions(+), 62 deletions(-) diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c index 38f55a1c84..f4c388c6b0 100644 --- a/examples/dpdk_qat/main.c +++ b/examples/dpdk_qat/main.c @@ -98,8 +98,6 @@ #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 diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index 70c1009e63..55bf58d1b1 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -79,9 +79,6 @@ #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) @@ -457,13 +454,14 @@ init_port(uint8_t port) 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); @@ -557,7 +555,7 @@ main(int argc, char** argv) 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; diff --git a/examples/ipv4_frag/main.c b/examples/ipv4_frag/main.c index f5285d8bd2..a9d17058cf 100644 --- a/examples/ipv4_frag/main.c +++ b/examples/ipv4_frag/main.c @@ -115,8 +115,6 @@ #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 @@ -597,7 +595,7 @@ MAIN(int argc, char **argv) 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"); @@ -607,7 +605,7 @@ MAIN(int argc, char **argv) 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"); @@ -671,7 +669,7 @@ MAIN(int argc, char **argv) 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: " @@ -686,7 +684,7 @@ MAIN(int argc, char **argv) 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); @@ -712,7 +710,7 @@ MAIN(int argc, char **argv) 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"); diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 856dfa1cbf..620197835e 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -115,8 +115,6 @@ #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 @@ -205,7 +203,7 @@ static struct rte_fbk_hash_params mcast_hash_params = { .name = "MCAST_HASH", .entries = 1024, .entries_per_bucket = 4, - .socket_id = SOCKET0, + .socket_id = 0, .hash_func = NULL, .init_val = 0, }; @@ -638,6 +636,7 @@ init_mcast_hash(void) { 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; @@ -735,21 +734,21 @@ MAIN(int argc, char **argv) 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"); @@ -815,7 +814,7 @@ MAIN(int argc, char **argv) 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", @@ -830,7 +829,7 @@ MAIN(int argc, char **argv) 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); diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 9f5ba4ba17..13e7271e61 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -102,8 +102,6 @@ #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 */ @@ -609,7 +607,7 @@ MAIN(int argc, char **argv) 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"); @@ -709,10 +707,10 @@ MAIN(int argc, char **argv) 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); diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 998093f8b2..fae1d40e87 100755 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -152,8 +152,6 @@ #define NB_SOCKETS 8 -#define SOCKET0 0 - /* Configure how many packets ahead to prefetch, when reading packets */ #define PREFETCH_OFFSET 3 @@ -323,7 +321,7 @@ struct rte_hash_parameters ipv4_l3fwd_hash_params = { .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 = { @@ -333,7 +331,7 @@ 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 \ diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index aec84ea18d..0ac276fcff 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -103,8 +103,6 @@ #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 */ @@ -663,7 +661,7 @@ MAIN(int argc, char **argv) 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"); @@ -762,7 +760,7 @@ MAIN(int argc, char **argv) /* 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", @@ -771,7 +769,7 @@ MAIN(int argc, char **argv) /* 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); diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c index 505ca6d30c..2abdfc0050 100644 --- a/examples/multi_process/client_server_mp/mp_server/init.c +++ b/examples/multi_process/client_server_mp/mp_server/init.c @@ -146,7 +146,7 @@ init_mbuf_pools(void) 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 */ } @@ -185,13 +185,13 @@ init_port(uint8_t port_num) 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; } @@ -214,6 +214,8 @@ static int init_shm_rings(void) { unsigned i; + unsigned socket_id; + const char * q_name; const unsigned ringsize = CLIENT_QUEUE_RINGSIZE; clients = rte_malloc("client details", @@ -223,8 +225,10 @@ init_shm_rings(void) 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); diff --git a/examples/multi_process/client_server_mp/mp_server/main.h b/examples/multi_process/client_server_mp/mp_server/main.h index eef8974474..d7ee4e4b93 100644 --- a/examples/multi_process/client_server_mp/mp_server/main.h +++ b/examples/multi_process/client_server_mp/mp_server/main.h @@ -35,9 +35,6 @@ #ifndef _MAIN_H_ #define _MAIN_H_ -#define SOCKET0 0 -#define SOCKET1 1 - #ifdef RTE_EXEC_ENV_BAREMETAL #define MAIN _main #else diff --git a/examples/multi_process/simple_mp/main.c b/examples/multi_process/simple_mp/main.c index d018d9bd8b..585b43abc4 100644 --- a/examples/multi_process/simple_mp/main.c +++ b/examples/multi_process/simple_mp/main.c @@ -75,8 +75,6 @@ #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"; @@ -122,12 +120,12 @@ main(int argc, char **argv) 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); diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c index efd6a47804..4f1946bda6 100644 --- a/examples/multi_process/symmetric_mp/main.c +++ b/examples/multi_process/symmetric_mp/main.c @@ -80,8 +80,6 @@ #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 @@ -280,7 +278,7 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, uint16_t num_queues) 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; @@ -288,7 +286,7 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, uint16_t num_queues) 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; } @@ -482,7 +480,7 @@ main(int argc, char **argv) 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"); diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c index 0b17875846..7c744ef4a5 100644 --- a/examples/vmdq_dcb/main.c +++ b/examples/vmdq_dcb/main.c @@ -74,9 +74,6 @@ #include "main.h" /* basic constants used in application */ -#define SOCKET0 0 -#define SOCKET1 1 - #define NUM_QUEUES 128 #define NUM_MBUFS 64*1024 @@ -211,7 +208,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool) 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; @@ -219,7 +216,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool) 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; } @@ -388,7 +385,7 @@ MAIN(int argc, char *argv[]) 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"); -- 2.20.1