From: Olivier Matz Date: Wed, 22 Apr 2015 09:57:24 +0000 (+0200) Subject: apps: use helper to create mbuf pools X-Git-Tag: spdx-start~9264 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ea0c20ea95fd;p=dpdk.git apps: use helper to create mbuf pools When it's possible, use the new helper to create the mbuf pools. Most of the patch is trivial, except for the following files that have some specifics (indirect mbufs): - ip_fragmentation - ip_pipeline - ipv4_multicast - vhost Signed-off-by: Olivier Matz Acked-by: Neil Horman Acked-by: Konstantin Ananyev --- diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c index 05f4503eec..db2196bfc0 100644 --- a/app/test-pipeline/init.c +++ b/app/test-pipeline/init.c @@ -85,8 +85,7 @@ struct app_params app = { .ring_tx_size = 128, /* Buffer pool */ - .pool_buffer_size = 2048 + sizeof(struct rte_mbuf) + - RTE_PKTMBUF_HEADROOM, + .pool_buffer_size = 2048 + RTE_PKTMBUF_HEADROOM, .pool_size = 32 * 1024, .pool_cache_size = 256, @@ -144,16 +143,8 @@ app_init_mbuf_pools(void) { /* Init the buffer pool */ RTE_LOG(INFO, USER1, "Creating the mbuf pool ...\n"); - app.pool = rte_mempool_create( - "mempool", - app.pool_size, - app.pool_buffer_size, - app.pool_cache_size, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), - 0); + app.pool = rte_pktmbuf_pool_create("mempool", app.pool_size, + app.pool_cache_size, 0, app.pool_buffer_size, rte_socket_id()); if (app.pool == NULL) rte_panic("Cannot create mbuf pool\n"); } diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 1f2445e4ca..83a3d74a1b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -406,11 +406,11 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, #ifdef RTE_LIBRTE_PMD_XENVIRT rte_mp = rte_mempool_gntalloc_create(pool_name, nb_mbuf, mb_size, - (unsigned) mb_mempool_cache, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socket_id, 0); + (unsigned) mb_mempool_cache, + sizeof(struct rte_pktmbuf_pool_private), + rte_pktmbuf_pool_init, NULL, + rte_pktmbuf_init, NULL, + socket_id, 0); @@ -423,12 +423,9 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, rte_pktmbuf_init, NULL, socket_id, 0); else - rte_mp = rte_mempool_create(pool_name, nb_mbuf, mb_size, - (unsigned) mb_mempool_cache, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socket_id, 0); + /* wrapper to rte_mempool_create() */ + rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf, + mb_mempool_cache, 0, mbuf_seg_size, socket_id); #endif diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 9e8c06dcb1..ad4698763f 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -500,7 +500,7 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p) worker_idx = 0; } -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) static int test_distributor(void) @@ -528,12 +528,8 @@ test_distributor(void) const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ? (BIG_BATCH * 2) - 1 : (511 * rte_lcore_count()); if (p == NULL) { - p = rte_mempool_create("DT_MBUF_POOL", nb_bufs, - MBUF_SIZE, BURST, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + p = rte_pktmbuf_pool_create("DT_MBUF_POOL", nb_bufs, BURST, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (p == NULL) { printf("Error creating mempool\n"); return -1; diff --git a/app/test/test_distributor_perf.c b/app/test/test_distributor_perf.c index 31431bb171..f04cb156d6 100644 --- a/app/test/test_distributor_perf.c +++ b/app/test/test_distributor_perf.c @@ -209,7 +209,7 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p) worker_idx = 0; } -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) static int test_distributor_perf(void) @@ -240,12 +240,8 @@ test_distributor_perf(void) const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ? (BIG_BATCH * 2) - 1 : (511 * rte_lcore_count()); if (p == NULL) { - p = rte_mempool_create("DPT_MBUF_POOL", nb_bufs, - MBUF_SIZE, BURST, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + p = rte_pktmbuf_pool_create("DPT_MBUF_POOL", nb_bufs, BURST, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (p == NULL) { printf("Error creating mempool\n"); return -1; diff --git a/app/test/test_kni.c b/app/test/test_kni.c index 608901d3ca..506b543a68 100644 --- a/app/test/test_kni.c +++ b/app/test/test_kni.c @@ -47,8 +47,7 @@ #define NB_MBUF 8192 #define MAX_PACKET_SZ 2048 -#define MBUF_SZ \ - (MAX_PACKET_SZ + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SZ (MAX_PACKET_SZ + RTE_PKTMBUF_HEADROOM) #define PKT_BURST_SZ 32 #define MEMPOOL_CACHE_SZ PKT_BURST_SZ #define SOCKET 0 @@ -118,17 +117,10 @@ test_kni_create_mempool(void) mp = rte_mempool_lookup("kni_mempool"); if (!mp) - mp = rte_mempool_create("kni_mempool", + mp = rte_pktmbuf_pool_create("kni_mempool", NB_MBUF, - MBUF_SZ, - MEMPOOL_CACHE_SZ, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, - NULL, - rte_pktmbuf_init, - NULL, - SOCKET, - 0); + MEMPOOL_CACHE_SZ, 0, MBUF_DATA_SZ, + SOCKET); return mp; } diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c index 8c24314393..674d8ddb37 100644 --- a/app/test/test_link_bonding.c +++ b/app/test/test_link_bonding.c @@ -75,8 +75,7 @@ ETH_TXQ_FLAGS_NOXSUMSCTP | ETH_TXQ_FLAGS_NOXSUMUDP | \ ETH_TXQ_FLAGS_NOXSUMTCP) -#define MBUF_PAYLOAD_SIZE (2048) -#define MBUF_SIZE (MBUF_PAYLOAD_SIZE + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define MBUF_CACHE_SIZE (250) #define BURST_SIZE (32) @@ -280,10 +279,9 @@ test_setup(void) nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + DEF_PKT_BURST + RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST; if (test_params->mbuf_pool == NULL) { - test_params->mbuf_pool = rte_mempool_create("MBUF_POOL", nb_mbuf_per_pool, - MBUF_SIZE, MBUF_CACHE_SIZE, sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + test_params->mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", + nb_mbuf_per_pool, MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, + rte_socket_id()); TEST_ASSERT_NOT_NULL(test_params->mbuf_pool, "rte_mempool_create failed"); } diff --git a/app/test/test_link_bonding_mode4.c b/app/test/test_link_bonding_mode4.c index 02380f9330..590daad7fc 100644 --- a/app/test/test_link_bonding_mode4.c +++ b/app/test/test_link_bonding_mode4.c @@ -65,9 +65,7 @@ #define RX_RING_SIZE 128 #define TX_RING_SIZE 512 -#define MBUF_PAYLOAD_SIZE (2048) -#define MBUF_SIZE (MBUF_PAYLOAD_SIZE + sizeof(struct rte_mbuf) + \ - RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define MBUF_CACHE_SIZE (250) #define BURST_SIZE (32) @@ -390,11 +388,9 @@ test_setup(void) if (test_params.mbuf_pool == NULL) { nb_mbuf_per_pool = TEST_RX_DESC_MAX + DEF_PKT_BURST + TEST_TX_DESC_MAX + MAX_PKT_BURST; - test_params.mbuf_pool = rte_mempool_create("TEST_MODE4", - nb_mbuf_per_pool, MBUF_SIZE, MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, - socket_id, 0); + test_params.mbuf_pool = rte_pktmbuf_pool_create("TEST_MODE4", + nb_mbuf_per_pool, MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, + socket_id); TEST_ASSERT(test_params.mbuf_pool != NULL, "rte_mempool_create failed\n"); diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index 1ff66cb6a1..477426316e 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -61,7 +61,7 @@ #include "test.h" -#define MBUF_SIZE 2048 +#define MBUF_DATA_SIZE 2048 #define NB_MBUF 128 #define MBUF_TEST_DATA_LEN 1464 #define MBUF_TEST_DATA_LEN2 50 @@ -73,7 +73,6 @@ #define REFCNT_MAX_TIMEOUT 10 #define REFCNT_MAX_REF (RTE_MAX_LCORE) #define REFCNT_MBUF_NUM 64 -#define REFCNT_MBUF_SIZE (sizeof (struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) #define REFCNT_RING_SIZE (REFCNT_MBUF_NUM * REFCNT_MAX_REF) #define MAKE_STRING(x) # x @@ -622,12 +621,10 @@ test_refcnt_mbuf(void) /* create refcnt pool & ring if they don't exist */ if (refcnt_pool == NULL && - (refcnt_pool = rte_mempool_create( - MAKE_STRING(refcnt_pool), - REFCNT_MBUF_NUM, REFCNT_MBUF_SIZE, 0, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, - SOCKET_ID_ANY, 0)) == NULL) { + (refcnt_pool = rte_pktmbuf_pool_create( + MAKE_STRING(refcnt_pool), + REFCNT_MBUF_NUM, 0, 0, 0, + SOCKET_ID_ANY)) == NULL) { printf("%s: cannot allocate " MAKE_STRING(refcnt_pool) "\n", __func__); return (-1); @@ -764,13 +761,8 @@ test_mbuf(void) /* create pktmbuf pool if it does not exist */ if (pktmbuf_pool == NULL) { - pktmbuf_pool = - rte_mempool_create("test_pktmbuf_pool", NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - SOCKET_ID_ANY, 0); + pktmbuf_pool = rte_pktmbuf_pool_create("test_pktmbuf_pool", + NB_MBUF, 32, 0, MBUF_DATA_SIZE, SOCKET_ID_ANY); } if (pktmbuf_pool == NULL) { diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index d6a4a45a19..49a494de05 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -47,7 +47,7 @@ #define NB_ETHPORTS_USED (1) #define NB_SOCKETS (2) #define MEMPOOL_CACHE_SIZE 250 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define MAX_PKT_BURST (32) #define RTE_TEST_RX_DESC_DEFAULT (128) #define RTE_TEST_TX_DESC_DEFAULT (512) @@ -289,12 +289,9 @@ init_mbufpool(unsigned nb_mbuf) if (mbufpool[socketid] == NULL) { snprintf(s, sizeof(s), "mbuf_pool_%d", socketid); mbufpool[socketid] = - rte_mempool_create(s, nb_mbuf, MBUF_SIZE, - MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socketid, 0); + rte_pktmbuf_pool_create(s, nb_mbuf, + MEMPOOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, + socketid); if (mbufpool[socketid] == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool on socket %d\n", diff --git a/app/test/test_pmd_ring.c b/app/test/test_pmd_ring.c index 7490112ca3..53897f755d 100644 --- a/app/test/test_pmd_ring.c +++ b/app/test/test_pmd_ring.c @@ -48,7 +48,7 @@ static struct rte_mempool *mp; #define RING_SIZE 256 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUF 512 static int @@ -406,12 +406,8 @@ test_pmd_ring_pair_create_attach(void) static int test_pmd_ring(void) { - mp = rte_mempool_create("mbuf_pool", NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mp = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, 32, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (mp == NULL) return -1; diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index 61cf8d31a1..91fbe9aa98 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -50,7 +50,7 @@ #define REORDER_BUFFER_SIZE 16384 #define NUM_MBUFS (2*REORDER_BUFFER_SIZE) #define REORDER_BUFFER_SIZE_INVALID 2049 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) struct reorder_unittest_params { struct rte_mempool *p; @@ -351,12 +351,8 @@ test_setup(void) /* mempool creation */ if (test_params->p == NULL) { - test_params->p = rte_mempool_create("RO_MBUF_POOL", NUM_MBUFS, - MBUF_SIZE, BURST, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + test_params->p = rte_pktmbuf_pool_create("RO_MBUF_POOL", + NUM_MBUFS, BURST, 0, MBUF_DATA_SIZE, rte_socket_id()); if (test_params->p == NULL) { printf("%s: Error creating mempool\n", __func__); return -1; diff --git a/app/test/test_sched.c b/app/test/test_sched.c index 60c62de34a..c7239f80ab 100644 --- a/app/test/test_sched.c +++ b/app/test/test_sched.c @@ -86,8 +86,7 @@ static struct rte_sched_port_params port_param = { }; #define NB_MBUF 32 -#define MAX_PACKET_SZ 2048 -#define MBUF_SZ (MAX_PACKET_SZ + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SZ (2048 + RTE_PKTMBUF_HEADROOM) #define PKT_BURST_SZ 32 #define MEMPOOL_CACHE_SZ PKT_BURST_SZ #define SOCKET 0 @@ -100,17 +99,8 @@ create_mempool(void) mp = rte_mempool_lookup("test_sched"); if (!mp) - mp = rte_mempool_create("test_sched", - NB_MBUF, - MBUF_SZ, - MEMPOOL_CACHE_SZ, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, - NULL, - rte_pktmbuf_init, - NULL, - SOCKET, - 0); + mp = rte_pktmbuf_pool_create("test_sched", NB_MBUF, + MEMPOOL_CACHE_SZ, 0, MBUF_DATA_SZ, SOCKET); return mp; } diff --git a/app/test/test_table.c b/app/test/test_table.c index c3093cce74..de6c27dc65 100644 --- a/app/test/test_table.c +++ b/app/test/test_table.c @@ -89,15 +89,10 @@ app_init_mbuf_pools(void) printf("Getting/Creating the mempool ...\n"); pool = rte_mempool_lookup("mempool"); if (!pool) { - pool = rte_mempool_create( + pool = rte_pktmbuf_pool_create( "mempool", POOL_SIZE, - POOL_BUFFER_SIZE, - POOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - 0, + POOL_CACHE_SIZE, 0, POOL_BUFFER_SIZE, 0); if (pool == NULL) rte_panic("Cannot create mbuf pool\n"); diff --git a/app/test/test_table.h b/app/test/test_table.h index 64e9427e33..be331c0c9c 100644 --- a/app/test/test_table.h +++ b/app/test/test_table.h @@ -65,7 +65,7 @@ #define PORT_TX_RING_SIZE 512 #define RING_RX_SIZE 128 #define RING_TX_SIZE 128 -#define POOL_BUFFER_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define POOL_BUFFER_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define POOL_SIZE (32 * 1024) #define POOL_CACHE_SIZE 256 #define BURST_SIZE 8 @@ -73,7 +73,6 @@ #define MAX_DUMMY_PORTS 2 #define MP_NAME "dummy_port_mempool" #define MBUF_COUNT (8000 * MAX_DUMMY_PORTS) -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) #define MP_CACHE_SZ 256 #define MP_SOCKET 0 #define MP_FLAGS 0 diff --git a/examples/bond/main.c b/examples/bond/main.c index 67c283d0b6..fcb4c4e99c 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -96,7 +96,7 @@ #define RTE_LOGTYPE_DCB RTE_LOGTYPE_USER1 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUF (1024*8) #define MAX_PKT_BURST 32 @@ -738,12 +738,8 @@ main(int argc, char *argv[]) else if (nb_ports > MAX_PORTS) rte_exit(EXIT_FAILURE, "You can have max 4 ports\n"); - mbuf_pool = rte_mempool_create("MBUF_POOL", NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NB_MBUF, 32, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); diff --git a/examples/distributor/main.c b/examples/distributor/main.c index 13fb04d679..78fe3e9042 100644 --- a/examples/distributor/main.c +++ b/examples/distributor/main.c @@ -47,7 +47,7 @@ #define RX_RING_SIZE 256 #define TX_RING_SIZE 512 #define NUM_MBUFS ((64*1024)-1) -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 #define RTE_RING_SZ 1024 @@ -528,12 +528,9 @@ main(int argc, char *argv[]) rte_exit(EXIT_FAILURE, "Error: number of ports must be even, except " "when using a single port\n"); - mbuf_pool = rte_mempool_create("MBUF_POOL", NUM_MBUFS * nb_ports, - MBUF_SIZE, MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", + NUM_MBUFS * nb_ports, MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, + rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); nb_ports_available = nb_ports; diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c index 20e78bc166..053be91bee 100644 --- a/examples/dpdk_qat/main.c +++ b/examples/dpdk_qat/main.c @@ -70,7 +70,7 @@ #include "crypto.h" -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUF (32 * 1024) #define MAX_PKT_BURST 32 @@ -598,7 +598,6 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr) static int init_mem(void) { - const unsigned flags = 0; int socketid; unsigned lcoreid; char s[64]; @@ -613,11 +612,8 @@ init_mem(void) if (pktmbuf_pool[socketid] == NULL) { snprintf(s, sizeof(s), "mbuf_pool_%d", socketid); pktmbuf_pool[socketid] = - rte_mempool_create(s, NB_MBUF, MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socketid, flags); + rte_pktmbuf_pool_create(s, NB_MBUF, 32, 0, + MBUF_DATA_SIZE, socketid); if (pktmbuf_pool[socketid] == NULL) { printf("Cannot init mbuf pool on socket %d\n", socketid); return -1; diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index 14582de030..b3fe17038c 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -81,11 +81,10 @@ #define MAX_PORTS (RTE_MAX_LCORE / 2) /* Max size of a single packet */ -#define MAX_PACKET_SZ 2048 +#define MAX_PACKET_SZ (2048) -/* Number of bytes needed for each mbuf */ -#define MBUF_SZ \ - (MAX_PACKET_SZ + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +/* Size of the data buffer in each mbuf */ +#define MBUF_DATA_SZ (MAX_PACKET_SZ + RTE_PKTMBUF_HEADROOM) /* Number of mbufs in mempool that is created */ #define NB_MBUF 8192 @@ -532,11 +531,8 @@ main(int argc, char** argv) parse_args(argc, argv); /* Create the mbuf pool */ - pktmbuf_pool = rte_mempool_create("mbuf_pool", NB_MBUF, MBUF_SZ, - MEMPOOL_CACHE_SZ, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, + MEMPOOL_CACHE_SZ, 0, MBUF_DATA_SZ, rte_socket_id()); if (pktmbuf_pool == NULL) { FATAL_ERROR("Could not initialise mbuf pool"); return -1; diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index cf63718632..c702fdd23b 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -76,7 +76,7 @@ #define RTE_LOGTYPE_IP_FRAG RTE_LOGTYPE_USER1 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_SIZE (2048 + RTE_PKTMBUF_HEADROOM) /* allow max jumbo frame 9.5 KB */ #define JUMBO_FRAME_MAX_SIZE 0x2600 @@ -744,12 +744,8 @@ init_mem(void) socket); snprintf(buf, sizeof(buf), "pool_direct_%i", socket); - mp = rte_mempool_create(buf, NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socket, 0); + mp = rte_pktmbuf_pool_create(buf, NB_MBUF, 32, + 0, MBUF_DATA_SIZE, socket); if (mp == NULL) { RTE_LOG(ERR, IP_FRAG, "Cannot create direct mempool\n"); return -1; @@ -762,12 +758,8 @@ init_mem(void) socket); snprintf(buf, sizeof(buf), "pool_indirect_%i", socket); - mp = rte_mempool_create(buf, NB_MBUF, - sizeof(struct rte_mbuf), 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socket, 0); + mp = rte_pktmbuf_pool_create(buf, NB_MBUF, 32, 0, 0, + socket); if (mp == NULL) { RTE_LOG(ERR, IP_FRAG, "Cannot create indirect mempool\n"); return -1; diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 61d71c3ef7..275fb35a05 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -146,8 +146,7 @@ struct app_params app = { .bsz_swq_wr = 64, /* Buffer pool */ - .pool_buffer_size = 2048 + sizeof(struct rte_mbuf) + - RTE_PKTMBUF_HEADROOM, + .pool_buffer_size = 2048 + RTE_PKTMBUF_HEADROOM, .pool_size = 32 * 1024, .pool_cache_size = 256, @@ -363,37 +362,18 @@ app_get_ring_resp(uint32_t core_id) static void app_init_mbuf_pools(void) { - struct rte_pktmbuf_pool_private indirect_mbp_priv; - /* Init the buffer pool */ RTE_LOG(INFO, USER1, "Creating the mbuf pool ...\n"); - app.pool = rte_mempool_create( - "mempool", - app.pool_size, - app.pool_buffer_size, - app.pool_cache_size, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), - 0); + app.pool = rte_pktmbuf_pool_create("mempool", app.pool_size, + app.pool_cache_size, 0, app.pool_buffer_size, rte_socket_id()); if (app.pool == NULL) rte_panic("Cannot create mbuf pool\n"); /* Init the indirect buffer pool */ RTE_LOG(INFO, USER1, "Creating the indirect mbuf pool ...\n"); - indirect_mbp_priv.mbuf_data_room_size = 0; - indirect_mbp_priv.mbuf_priv_size = sizeof(struct app_pkt_metadata); - app.indirect_pool = rte_mempool_create( - "indirect mempool", - app.pool_size, - sizeof(struct rte_mbuf) + sizeof(struct app_pkt_metadata), - app.pool_cache_size, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, &indirect_mbp_priv, - rte_pktmbuf_init, NULL, - rte_socket_id(), - 0); + app.indirect_pool = rte_pktmbuf_pool_create("indirect mempool", + app.pool_size, app.pool_cache_size, + sizeof(struct app_pkt_metadata), 0, rte_socket_id()); if (app.indirect_pool == NULL) rte_panic("Cannot create mbuf pool\n"); diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 19832d85ff..575e98919f 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -77,13 +77,12 @@ #define MCAST_CLONE_PORTS 2 #define MCAST_CLONE_SEGS 2 -#define PKT_MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define PKT_MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_PKT_MBUF 8192 -#define HDR_MBUF_SIZE (sizeof(struct rte_mbuf) + 2 * RTE_PKTMBUF_HEADROOM) +#define HDR_MBUF_DATA_SIZE (2 * RTE_PKTMBUF_HEADROOM) #define NB_HDR_MBUF (NB_PKT_MBUF * MAX_PORTS) -#define CLONE_MBUF_SIZE (sizeof(struct rte_mbuf)) #define NB_CLONE_MBUF (NB_PKT_MBUF * MCAST_CLONE_PORTS * MCAST_CLONE_SEGS * 2) /* allow max jumbo frame 9.5 KB */ @@ -690,26 +689,20 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Invalid IPV4_MULTICAST parameters\n"); /* create the mbuf pools */ - 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, - rte_socket_id(), 0); + packet_pool = rte_pktmbuf_pool_create("packet_pool", NB_PKT_MBUF, 32, + 0, PKT_MBUF_DATA_SIZE, rte_socket_id()); 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, sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + header_pool = rte_pktmbuf_pool_create("header_pool", NB_HDR_MBUF, 32, + 0, HDR_MBUF_DATA_SIZE, rte_socket_id()); 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, sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + clone_pool = rte_pktmbuf_pool_create("clone_pool", NB_CLONE_MBUF, 32, + 0, 0, rte_socket_id()); if (clone_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot init clone mbuf pool\n"); diff --git a/examples/kni/main.c b/examples/kni/main.c index 19d25d48ac..96ca473082 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -80,9 +80,8 @@ /* Max size of a single packet */ #define MAX_PACKET_SZ 2048 -/* Number of bytes needed for each mbuf */ -#define MBUF_SZ \ - (MAX_PACKET_SZ + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +/* Size of the data buffer in each mbuf */ +#define MBUF_DATA_SZ (MAX_PACKET_SZ + RTE_PKTMBUF_HEADROOM) /* Number of mbufs in mempool that is created */ #define NB_MBUF (8192 * 16) @@ -867,11 +866,8 @@ main(int argc, char** argv) rte_exit(EXIT_FAILURE, "Could not parse input parameters\n"); /* Create the mbuf pool */ - pktmbuf_pool = rte_mempool_create("mbuf_pool", NB_MBUF, MBUF_SZ, - MEMPOOL_CACHE_SZ, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, + MEMPOOL_CACHE_SZ, 0, MBUF_DATA_SZ, rte_socket_id()); if (pktmbuf_pool == NULL) { rte_exit(EXIT_FAILURE, "Could not initialise mbuf pool\n"); return -1; diff --git a/examples/l2fwd-ivshmem/host/host.c b/examples/l2fwd-ivshmem/host/host.c index 4f8d23edb0..197f22ba2b 100644 --- a/examples/l2fwd-ivshmem/host/host.c +++ b/examples/l2fwd-ivshmem/host/host.c @@ -71,7 +71,7 @@ static uint32_t l2fwd_ivshmem_enabled_port_mask = 0; static struct ether_addr l2fwd_ivshmem_ports_eth_addr[RTE_MAX_ETHPORTS]; #define NB_MBUF 8192 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define MAX_RX_QUEUE_PER_LCORE 16 #define MAX_TX_QUEUE_PER_PORT 16 @@ -670,12 +670,8 @@ int main(int argc, char **argv) /* create a shared mbuf pool */ l2fwd_ivshmem_pktmbuf_pool = - rte_mempool_create(MBUF_MP_NAME, NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + rte_pktmbuf_pool_create(MBUF_MP_NAME, NB_MBUF, 32, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (l2fwd_ivshmem_pktmbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c index f990045fe3..fcebbda0ec 100644 --- a/examples/l2fwd-jobstats/main.c +++ b/examples/l2fwd-jobstats/main.c @@ -70,7 +70,7 @@ #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUF 8192 #define MAX_PKT_BURST 32 @@ -833,12 +833,8 @@ main(int argc, char **argv) /* create the mbuf pool */ l2fwd_pktmbuf_pool = - rte_mempool_create("mbuf_pool", NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, 32, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (l2fwd_pktmbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 17621ee8c3..d0a1ec8d95 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -71,7 +71,7 @@ #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUF 8192 #define MAX_PKT_BURST 32 @@ -560,13 +560,8 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Invalid L2FWD arguments\n"); /* create the mbuf pool */ - l2fwd_pktmbuf_pool = - rte_mempool_create("mbuf_pool", NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + l2fwd_pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, 32, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (l2fwd_pktmbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index fce55f37a4..1a04004816 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -80,7 +80,7 @@ #define MEMPOOL_CACHE_SIZE 256 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) /* * This expression is used to calculate the number of mbufs needed @@ -1848,12 +1848,9 @@ init_mem(unsigned nb_mbuf) if (pktmbuf_pool[socketid] == NULL) { snprintf(s, sizeof(s), "mbuf_pool_%d", socketid); pktmbuf_pool[socketid] = - rte_mempool_create(s, nb_mbuf, MBUF_SIZE, - MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socketid, 0); + rte_pktmbuf_pool_create(s, nb_mbuf, + MEMPOOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, + socketid); if (pktmbuf_pool[socketid] == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool on socket %d\n", diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 4221239725..bb0b66f50d 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -121,7 +121,7 @@ #define MEMPOOL_CACHE_SIZE 256 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) /* * This expression is used to calculate the number of mbufs needed depending on @@ -1379,12 +1379,9 @@ init_mem(unsigned nb_mbuf) if (pktmbuf_pool[socketid] == NULL) { snprintf(s, sizeof(s), "mbuf_pool_%d", socketid); pktmbuf_pool[socketid] = - rte_mempool_create(s, nb_mbuf, - MBUF_SIZE, MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socketid, 0); + rte_pktmbuf_pool_create(s, nb_mbuf, + MEMPOOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, + socketid); if (pktmbuf_pool[socketid] == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool on socket %d\n", diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c index 20ba03aa58..f007bc1255 100644 --- a/examples/l3fwd-vf/main.c +++ b/examples/l3fwd-vf/main.c @@ -94,7 +94,7 @@ #define MEMPOOL_CACHE_SIZE 256 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) /* * This expression is used to calculate the number of mbufs needed depending on user input, taking @@ -924,13 +924,9 @@ init_mem(unsigned nb_mbuf) } if (pktmbuf_pool[socketid] == NULL) { snprintf(s, sizeof(s), "mbuf_pool_%d", socketid); - pktmbuf_pool[socketid] = - rte_mempool_create(s, nb_mbuf, MBUF_SIZE, - MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socketid, 0); + pktmbuf_pool[socketid] = rte_pktmbuf_pool_create(s, + nb_mbuf, MEMPOOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, + socketid); if (pktmbuf_pool[socketid] == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool on socket %d\n", socketid); else diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 90e177f3b3..78710386ab 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -119,7 +119,7 @@ #define MEMPOOL_CACHE_SIZE 256 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) /* * This expression is used to calculate the number of mbufs needed depending on user input, taking @@ -2315,11 +2315,9 @@ init_mem(unsigned nb_mbuf) if (pktmbuf_pool[socketid] == NULL) { snprintf(s, sizeof(s), "mbuf_pool_%d", socketid); pktmbuf_pool[socketid] = - rte_mempool_create(s, nb_mbuf, MBUF_SIZE, MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socketid, 0); + rte_pktmbuf_pool_create(s, nb_mbuf, + MEMPOOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, + socketid); if (pktmbuf_pool[socketid] == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool on socket %d\n", socketid); diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index e6fb218573..6adbd7936e 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -72,7 +72,7 @@ #define RTE_LOGTYPE_LSI RTE_LOGTYPE_USER1 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUF 8192 #define MAX_PKT_BURST 32 @@ -614,12 +614,8 @@ main(int argc, char **argv) /* create the mbuf pool */ lsi_pktmbuf_pool = - rte_mempool_create("mbuf_pool", NB_MBUF, - MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, 32, 0, + MBUF_DATA_SIZE, rte_socket_id()); if (lsi_pktmbuf_pool == NULL) rte_panic("Cannot init mbuf pool\n"); diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c index b35f797fd6..5a560786f7 100644 --- a/examples/load_balancer/init.c +++ b/examples/load_balancer/init.c @@ -127,16 +127,10 @@ app_init_mbuf_pools(void) snprintf(name, sizeof(name), "mbuf_pool_%u", socket); printf("Creating the mbuf pool for socket %u ...\n", socket); - app.pools[socket] = rte_mempool_create( - name, - APP_DEFAULT_MEMPOOL_BUFFERS, - APP_DEFAULT_MBUF_SIZE, + app.pools[socket] = rte_pktmbuf_pool_create( + name, APP_DEFAULT_MEMPOOL_BUFFERS, APP_DEFAULT_MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socket, - 0); + 0, APP_DEFAULT_MBUF_DATA_SIZE, socket); if (app.pools[socket] == NULL) { rte_panic("Cannot create mbuf pool on socket %u\n", socket); } diff --git a/examples/load_balancer/main.h b/examples/load_balancer/main.h index d9f878b669..17c0f7702f 100644 --- a/examples/load_balancer/main.h +++ b/examples/load_balancer/main.h @@ -82,8 +82,8 @@ /* Mempools */ -#ifndef APP_DEFAULT_MBUF_SIZE -#define APP_DEFAULT_MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#ifndef APP_DEFAULT_MBUF_DATA_SIZE +#define APP_DEFAULT_MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #endif #ifndef APP_DEFAULT_MEMPOOL_BUFFERS 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 aadee76b46..dc3647d1a0 100644 --- a/examples/multi_process/client_server_mp/mp_server/init.c +++ b/examples/multi_process/client_server_mp/mp_server/init.c @@ -71,9 +71,7 @@ #define MBUFS_PER_CLIENT 1536 #define MBUFS_PER_PORT 1536 #define MBUF_CACHE_SIZE 512 -#define MBUF_OVERHEAD (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) -#define RX_MBUF_DATA_SIZE 2048 -#define MBUF_SIZE (RX_MBUF_DATA_SIZE + MBUF_OVERHEAD) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define RTE_MP_RX_DESC_DEFAULT 512 #define RTE_MP_TX_DESC_DEFAULT 512 @@ -104,10 +102,8 @@ init_mbuf_pools(void) * seems faster to use a cache instead */ printf("Creating mbuf pool '%s' [%u mbufs] ...\n", PKTMBUF_POOL_NAME, num_mbufs); - 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, rte_socket_id(), NO_FLAGS ); + pktmbuf_pool = rte_pktmbuf_pool_create(PKTMBUF_POOL_NAME, num_mbufs, + MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, rte_socket_id()); return (pktmbuf_pool == NULL); /* 0 on success */ } diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c index 48448b4adc..7829c86fd5 100644 --- a/examples/multi_process/symmetric_mp/main.c +++ b/examples/multi_process/symmetric_mp/main.c @@ -78,7 +78,7 @@ #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUFS 64*1024 /* use 64k mbufs */ #define MBUF_CACHE_SIZE 256 #define PKT_BURST 32 @@ -446,11 +446,9 @@ main(int argc, char **argv) proc_type = rte_eal_process_type(); mp = (proc_type == RTE_PROC_SECONDARY) ? rte_mempool_lookup(_SMP_MBUF_POOL) : - rte_mempool_create(_SMP_MBUF_POOL, NB_MBUFS, MBUF_SIZE, - MBUF_CACHE_SIZE, sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + rte_pktmbuf_pool_create(_SMP_MBUF_POOL, NB_MBUFS, + MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, + rte_socket_id()); if (mp == NULL) rte_exit(EXIT_FAILURE, "Cannot get memory pool for buffers\n"); diff --git a/examples/netmap_compat/bridge/bridge.c b/examples/netmap_compat/bridge/bridge.c index 0a8efbebc5..2d935cb5bd 100644 --- a/examples/netmap_compat/bridge/bridge.c +++ b/examples/netmap_compat/bridge/bridge.c @@ -47,9 +47,8 @@ #include "compat_netmap.h" -#define BUF_SIZE 2048 -#define MBUF_SIZE (BUF_SIZE + sizeof(struct rte_mbuf) + \ - RTE_PKTMBUF_HEADROOM) +#define BUF_SIZE (2048) +#define MBUF_DATA_SIZE (BUF_SIZE + RTE_PKTMBUF_HEADROOM) #define MBUF_PER_POOL 8192 @@ -272,11 +271,8 @@ int main(int argc, char *argv[]) if (rte_eth_dev_count() < 1) rte_exit(EXIT_FAILURE, "Not enough ethernet ports available\n"); - pool = rte_mempool_create("mbuf_pool", MBUF_PER_POOL, MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_PER_POOL, 32, 0, + MBUF_DATA_SIZE, rte_socket_id()); if (pool == NULL) rte_exit(EXIT_FAILURE, "Couldn't create mempool\n"); diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c index f0a1b5a645..5403c3303f 100644 --- a/examples/packet_ordering/main.c +++ b/examples/packet_ordering/main.c @@ -50,7 +50,7 @@ #define MAX_PKTS_BURST 32 #define REORDER_BUFFER_SIZE 8192 #define MBUF_PER_POOL 65535 -#define MBUF_SIZE (1600 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (1600 + RTE_PKTMBUF_HEADROOM) #define MBUF_POOL_CACHE_SIZE 250 #define RING_SIZE 16384 @@ -622,12 +622,9 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Error: number of ports must be even, except " "when using a single port\n"); - mbuf_pool = rte_mempool_create("mbuf_pool", MBUF_PER_POOL, MBUF_SIZE, - MBUF_POOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_PER_POOL, + MBUF_POOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, + rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c index 4a981c65e6..a5e25103a7 100644 --- a/examples/qos_meter/main.c +++ b/examples/qos_meter/main.c @@ -70,7 +70,7 @@ * Buffer pool configuration * ***/ -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define NB_MBUF 8192 #define MEMPOOL_CACHE_SIZE 256 @@ -360,9 +360,8 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Invalid input arguments\n"); /* Buffer pool init */ - pool = rte_mempool_create("pool", NB_MBUF, MBUF_SIZE, MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, rte_socket_id(), 0); + pool = rte_pktmbuf_pool_create("pool", NB_MBUF, MEMPOOL_CACHE_SIZE, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (pool == NULL) rte_exit(EXIT_FAILURE, "Buffer pool creation error\n"); diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c index f38802e125..aaf3466588 100644 --- a/examples/qos_sched/init.c +++ b/examples/qos_sched/init.c @@ -335,13 +335,9 @@ int app_init(void) /* create the mbuf pools for each RX Port */ snprintf(pool_name, MAX_NAME_LEN, "mbuf_pool%u", i); - qos_conf[i].mbuf_pool = rte_mempool_create(pool_name, mp_size, MBUF_SIZE, - burst_conf.rx_burst * 4, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_eth_dev_socket_id(qos_conf[i].rx_port), - 0); + qos_conf[i].mbuf_pool = rte_pktmbuf_pool_create(pool_name, + mp_size, burst_conf.rx_burst * 4, 0, MBUF_DATA_SIZE, + rte_eth_dev_socket_id(qos_conf[i].rx_port)); if (qos_conf[i].mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool for socket %u\n", i); diff --git a/examples/qos_sched/main.h b/examples/qos_sched/main.h index 971ec273ea..0e6f264f3d 100644 --- a/examples/qos_sched/main.h +++ b/examples/qos_sched/main.h @@ -50,7 +50,7 @@ extern "C" { #define APP_RX_DESC_DEFAULT 128 #define APP_TX_DESC_DEFAULT 256 -#define MBUF_SIZE (1528 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (1528 + RTE_PKTMBUF_HEADROOM) #define APP_RING_SIZE (8*1024) #define NB_MBUF (2*1024*1024) diff --git a/examples/quota_watermark/include/conf.h b/examples/quota_watermark/include/conf.h index 8d95aaab4f..e80aca58d4 100644 --- a/examples/quota_watermark/include/conf.h +++ b/examples/quota_watermark/include/conf.h @@ -40,7 +40,7 @@ #define RX_DESC_PER_QUEUE 128 #define TX_DESC_PER_QUEUE 512 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define MBUF_PER_POOL 8192 #define QUOTA_WATERMARK_MEMZONE_NAME "qw_global_vars" diff --git a/examples/quota_watermark/qw/main.c b/examples/quota_watermark/qw/main.c index f2695461fa..8ed021480e 100644 --- a/examples/quota_watermark/qw/main.c +++ b/examples/quota_watermark/qw/main.c @@ -335,11 +335,8 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Invalid quota/watermark argument(s)\n"); /* Create a pool of mbuf to store packets */ - mbuf_pool = rte_mempool_create("mbuf_pool", MBUF_PER_POOL, MBUF_SIZE, 32, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_PER_POOL, 32, 0, + MBUF_DATA_SIZE, rte_socket_id()); if (mbuf_pool == NULL) rte_panic("%s\n", rte_strerror(rte_errno)); diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index 21117ce7d5..fb8da5184c 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -43,7 +43,7 @@ #define TX_RING_SIZE 512 #define NUM_MBUFS 8191 -#define MBUF_SIZE (1600 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (1600 + RTE_PKTMBUF_HEADROOM) #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 @@ -204,12 +204,9 @@ main(int argc, char *argv[]) if (nb_ports < 2 || (nb_ports & 1)) rte_exit(EXIT_FAILURE, "Error: number of ports must be even\n"); - mbuf_pool = rte_mempool_create("MBUF_POOL", NUM_MBUFS * nb_ports, - MBUF_SIZE, MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", + NUM_MBUFS * nb_ports, MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, + rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c index 1bce6e779f..ae606bf45a 100644 --- a/examples/skeleton/basicfwd.c +++ b/examples/skeleton/basicfwd.c @@ -43,7 +43,7 @@ #define TX_RING_SIZE 512 #define NUM_MBUFS 8191 -#define MBUF_SIZE (1600 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (1600 + RTE_PKTMBUF_HEADROOM) #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 @@ -190,15 +190,8 @@ main(int argc, char *argv[]) rte_exit(EXIT_FAILURE, "Error: number of ports must be even\n"); /* Creates a new mempool in memory to hold the mbufs. */ - mbuf_pool = rte_mempool_create("MBUF_POOL", - NUM_MBUFS * nb_ports, - MBUF_SIZE, - MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), - 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUFS * nb_ports, + MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); diff --git a/examples/vhost/main.c b/examples/vhost/main.c index fc73d1e432..22d6a4b92a 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -67,7 +67,7 @@ (num_switching_cores*MBUF_CACHE_SIZE)) #define MBUF_CACHE_SIZE 128 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) /* * No frame data buffer allocated from host are required for zero copy @@ -75,8 +75,7 @@ * directly use it. */ #define VIRTIO_DESCRIPTOR_LEN_ZCP 1518 -#define MBUF_SIZE_ZCP (VIRTIO_DESCRIPTOR_LEN_ZCP + sizeof(struct rte_mbuf) \ - + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE_ZCP (VIRTIO_DESCRIPTOR_LEN_ZCP + RTE_PKTMBUF_HEADROOM) #define MBUF_CACHE_SIZE_ZCP 0 #define MAX_PKT_BURST 32 /* Max burst size for RX/TX */ @@ -2844,11 +2843,8 @@ static void setup_mempool_tbl(int socket, uint32_t index, char *pool_name, char *ring_name, uint32_t nb_mbuf) { - vpool_array[index].pool - = rte_mempool_create(pool_name, nb_mbuf, MBUF_SIZE_ZCP, - MBUF_CACHE_SIZE_ZCP, sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, socket, 0); + vpool_array[index].pool = rte_pktmbuf_pool_create(pool_name, nb_mbuf, + MBUF_CACHE_SIZE_ZCP, 0, MBUF_DATA_SIZE_ZCP, socket); if (vpool_array[index].pool != NULL) { vpool_array[index].ring = rte_ring_create(ring_name, @@ -2932,15 +2928,9 @@ main(int argc, char *argv[]) if (zero_copy == 0) { /* Create the mbuf pool. */ - mbuf_pool = rte_mempool_create( - "MBUF_POOL", - NUM_MBUFS_PER_PORT - * valid_num_ports, - MBUF_SIZE, MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", + NUM_MBUFS_PER_PORT * valid_num_ports, MBUF_CACHE_SIZE, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c index b4a86e3ce3..b672bf3ea3 100644 --- a/examples/vhost_xen/main.c +++ b/examples/vhost_xen/main.c @@ -67,7 +67,7 @@ (num_switching_cores*MBUF_CACHE_SIZE)) #define MBUF_CACHE_SIZE 64 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) /* * RX and TX Prefetch, Host, and Write-back threshold values should be @@ -1474,12 +1474,9 @@ main(int argc, char *argv[]) } /* Create the mbuf pool. */ - mbuf_pool = rte_mempool_create("MBUF_POOL", NUM_MBUFS_PER_PORT * valid_num_ports, - MBUF_SIZE, MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", + NUM_MBUFS_PER_PORT * valid_num_ports, MBUF_CACHE_SIZE, 0, + MBUF_DATA_SIZE, rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c index 700186067f..7596bac3ce 100644 --- a/examples/vmdq/main.c +++ b/examples/vmdq/main.c @@ -76,7 +76,7 @@ */ #define NUM_MBUFS_PER_PORT (128*512) #define MBUF_CACHE_SIZE 64 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define MAX_PKT_BURST 32 @@ -613,12 +613,9 @@ main(int argc, char *argv[]) rte_exit(EXIT_FAILURE, "Error with valid ports number is not even or less than 2\n"); } - mbuf_pool = rte_mempool_create("MBUF_POOL", NUM_MBUFS_PER_PORT * nb_ports, - MBUF_SIZE, MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", + NUM_MBUFS_PER_PORT * nb_ports, MBUF_CACHE_SIZE, + 0, MBUF_DATA_SIZE, rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c index 048c1679af..3c7f2b381d 100644 --- a/examples/vmdq_dcb/main.c +++ b/examples/vmdq_dcb/main.c @@ -74,7 +74,7 @@ #define NUM_MBUFS 64*1024 #define MBUF_CACHE_SIZE 64 -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM) #define INVALID_PORT_ID 0xFF @@ -441,12 +441,8 @@ main(int argc, char *argv[]) rte_exit(EXIT_FAILURE, "Error with valid ports number is not even or less than 2\n"); } - mbuf_pool = rte_mempool_create("MBUF_POOL", NUM_MBUFS * nb_ports, - MBUF_SIZE, MBUF_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - rte_socket_id(), 0); + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUFS * nb_ports, + MBUF_CACHE_SIZE, 0, MBUF_DATA_SIZE, rte_socket_id()); if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); diff --git a/lib/librte_pmd_bond/rte_eth_bond_alb.c b/lib/librte_pmd_bond/rte_eth_bond_alb.c index 5778b25a9b..6df318e2d7 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_alb.c +++ b/lib/librte_pmd_bond/rte_eth_bond_alb.c @@ -63,7 +63,7 @@ bond_mode_alb_enable(struct rte_eth_dev *bond_dev) struct bond_dev_private *internals = bond_dev->data->dev_private; struct client_data *hash_table = internals->mode6.client_table; - uint16_t element_size; + uint16_t data_size; char mem_name[RTE_ETH_NAME_MAX_LEN]; int socket_id = bond_dev->pci_dev->numa_node; @@ -79,15 +79,13 @@ bond_mode_alb_enable(struct rte_eth_dev *bond_dev) * 256 is size of ETH header, ARP header and nested VLAN headers. * The value is chosen to be cache aligned. */ - element_size = 256 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM; + data_size = 256 + RTE_PKTMBUF_HEADROOM; snprintf(mem_name, sizeof(mem_name), "%s_MODE6", bond_dev->data->name); - internals->mode6.mempool = rte_mempool_create(mem_name, - 512 * RTE_MAX_ETHPORTS, - element_size, - RTE_MEMPOOL_CACHE_MAX_SIZE >= 32 ? - 32 : RTE_MEMPOOL_CACHE_MAX_SIZE, - sizeof(struct rte_pktmbuf_pool_private), rte_pktmbuf_pool_init, - NULL, rte_pktmbuf_init, NULL, socket_id, 0); + internals->mode6.mempool = rte_pktmbuf_pool_create(mem_name, + 512 * RTE_MAX_ETHPORTS, + RTE_MEMPOOL_CACHE_MAX_SIZE >= 32 ? + 32 : RTE_MEMPOOL_CACHE_MAX_SIZE, + 0, data_size, socket_id); if (internals->mode6.mempool == NULL) { RTE_LOG(ERR, PMD, "%s: Failed to initialize ALB mempool.\n",