mbuf: use pktmbuf helper to create the pool
[dpdk.git] / examples / ip_pipeline / init.c
index 4fed474..c7f9470 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <netinet/in.h>
+#ifdef RTE_EXEC_ENV_LINUXAPP
 #include <linux/if.h>
 #include <linux/if_tun.h>
+#endif
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
@@ -76,11 +78,14 @@ app_init_core_map(struct app_params *app)
                cpu_core_map_print(app->core_map);
 }
 
+/* Core Mask String in Hex Representation */
+#define APP_CORE_MASK_STRING_SIZE ((64 * APP_CORE_MASK_SIZE) / 8 * 2 + 1)
+
 static void
 app_init_core_mask(struct app_params *app)
 {
-       uint64_t mask = 0;
        uint32_t i;
+       char core_mask_str[APP_CORE_MASK_STRING_SIZE];
 
        for (i = 0; i < app->n_pipelines; i++) {
                struct app_pipeline_params *p = &app->pipeline_params[i];
@@ -94,17 +99,18 @@ app_init_core_mask(struct app_params *app)
                if (lcore_id < 0)
                        rte_panic("Cannot create CPU core mask\n");
 
-               mask |= 1LLU << lcore_id;
+               app_core_enable_in_core_mask(app, lcore_id);
        }
 
-       app->core_mask = mask;
-       APP_LOG(app, HIGH, "CPU core mask = 0x%016" PRIx64, app->core_mask);
+       app_core_build_core_mask_string(app, core_mask_str);
+       APP_LOG(app, HIGH, "CPU core mask = 0x%s", core_mask_str);
 }
 
 static void
 app_init_eal(struct app_params *app)
 {
        char buffer[256];
+       char core_mask_str[APP_CORE_MASK_STRING_SIZE];
        struct app_eal_params *p = &app->eal_params;
        uint32_t n_args = 0;
        uint32_t i;
@@ -112,7 +118,8 @@ app_init_eal(struct app_params *app)
 
        app->eal_argv[n_args++] = strdup(app->app_name);
 
-       snprintf(buffer, sizeof(buffer), "-c%" PRIx64, app->core_mask);
+       app_core_build_core_mask_string(app, core_mask_str);
+       snprintf(buffer, sizeof(buffer), "-c%s", core_mask_str);
        app->eal_argv[n_args++] = strdup(buffer);
 
        if (p->coremap) {
@@ -322,16 +329,14 @@ app_init_mempool(struct app_params *app)
                struct app_mempool_params *p = &app->mempool_params[i];
 
                APP_LOG(app, HIGH, "Initializing %s ...", p->name);
-               app->mempool[i] = rte_mempool_create(
-                               p->name,
-                               p->pool_size,
-                               p->buffer_size,
-                               p->cache_size,
-                               sizeof(struct rte_pktmbuf_pool_private),
-                               rte_pktmbuf_pool_init, NULL,
-                               rte_pktmbuf_init, NULL,
-                               p->cpu_socket_id,
-                               0);
+               app->mempool[i] = rte_pktmbuf_pool_create(
+                       p->name,
+                       p->pool_size,
+                       p->cache_size,
+                       0, /* priv_size */
+                       p->buffer_size -
+                               sizeof(struct rte_mbuf), /* mbuf data size */
+                       p->cpu_socket_id);
 
                if (app->mempool[i] == NULL)
                        rte_panic("%s init error\n", p->name);
@@ -1160,6 +1165,15 @@ app_init_tm(struct app_params *app)
        }
 }
 
+#ifndef RTE_EXEC_ENV_LINUXAPP
+static void
+app_init_tap(struct app_params *app) {
+       if (app->n_pktq_tap == 0)
+               return;
+
+       rte_panic("TAP device not supported.\n");
+}
+#else
 static void
 app_init_tap(struct app_params *app)
 {
@@ -1187,6 +1201,7 @@ app_init_tap(struct app_params *app)
                app->tap[i] = fd;
        }
 }
+#endif
 
 #ifdef RTE_LIBRTE_KNI
 static int
@@ -1404,6 +1419,7 @@ void app_pipeline_params_get(struct app_params *app,
                        out->burst_size = app->tm_params[in->id].burst_read;
                        break;
                }
+#ifdef RTE_EXEC_ENV_LINUXAPP
                case APP_PKTQ_IN_TAP:
                {
                        struct app_pktq_tap_params *tap_params =
@@ -1420,6 +1436,7 @@ void app_pipeline_params_get(struct app_params *app,
                        out->burst_size = app->tap_params[in->id].burst_read;
                        break;
                }
+#endif
 #ifdef RTE_LIBRTE_KNI
                case APP_PKTQ_IN_KNI:
                {
@@ -1564,6 +1581,7 @@ void app_pipeline_params_get(struct app_params *app,
                                app->tm_params[in->id].burst_write;
                        break;
                }
+#ifdef RTE_EXEC_ENV_LINUXAPP
                case APP_PKTQ_OUT_TAP:
                {
                        struct rte_port_fd_writer_params *params =
@@ -1575,6 +1593,7 @@ void app_pipeline_params_get(struct app_params *app,
                                app->tap_params[in->id].burst_write;
                        break;
                }
+#endif
 #ifdef RTE_LIBRTE_KNI
                case APP_PKTQ_OUT_KNI:
                {