examples: always initialize mbuf pool private area
authorOlivier Matz <olivier.matz@6wind.com>
Wed, 22 Apr 2015 09:57:19 +0000 (11:57 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 27 Apr 2015 21:06:51 +0000 (23:06 +0200)
The mbuf pool private area must always be populated in a mbuf pool.
The applications or drivers may expect that for a mbuf pool, the mbuf
pool private area (mbuf_data_room_size and mbuf_priv_size) are
properly filled.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
examples/ip_fragmentation/main.c
examples/ip_pipeline/init.c
examples/ipv4_multicast/main.c

index 93ea2a1..cf63718 100644 (file)
@@ -764,8 +764,8 @@ init_mem(void)
 
                        mp = rte_mempool_create(buf, NB_MBUF,
                                                           sizeof(struct rte_mbuf), 32,
-                                                          0,
-                                                          NULL, NULL,
+                                                          sizeof(struct rte_pktmbuf_pool_private),
+                                                          rte_pktmbuf_pool_init, NULL,
                                                           rte_pktmbuf_init, NULL,
                                                           socket, 0);
                        if (mp == NULL) {
index 96aee2b..61d71c3 100644 (file)
@@ -363,6 +363,8 @@ 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(
@@ -380,13 +382,15 @@ app_init_mbuf_pools(void)
 
        /* 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,
-               0,
-               NULL, NULL,
+               sizeof(struct rte_pktmbuf_pool_private),
+               rte_pktmbuf_pool_init, &indirect_mbp_priv,
                rte_pktmbuf_init, NULL,
                rte_socket_id(),
                0);
index eed5611..19832d8 100644 (file)
@@ -699,14 +699,16 @@ main(int argc, char **argv)
                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,
+           HDR_MBUF_SIZE, 32, sizeof(struct rte_pktmbuf_pool_private),
+           rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
            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,
+           CLONE_MBUF_SIZE, 32, sizeof(struct rte_pktmbuf_pool_private),
+           rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
            rte_socket_id(), 0);
 
        if (clone_pool == NULL)