examples/ip_pipeline: fix CPU socket id
[dpdk.git] / examples / ip_pipeline / init.c
index 28e959b..c4601c9 100644 (file)
@@ -49,7 +49,9 @@
 #include "pipeline_passthrough.h"
 #include "pipeline_firewall.h"
 #include "pipeline_flow_classification.h"
+#include "pipeline_flow_actions.h"
 #include "pipeline_routing.h"
+#include "thread_fe.h"
 
 #define APP_NAME_SIZE  32
 
@@ -833,6 +835,14 @@ app_init_link_frag_ras(struct app_params *app)
        }
 }
 
+static inline int
+app_get_cpu_socket_id(uint32_t pmd_id)
+{
+       int status = rte_eth_dev_socket_id(pmd_id);
+
+       return (status != SOCKET_ID_ANY) ? status : 0;
+}
+
 static void
 app_init_link(struct app_params *app)
 {
@@ -888,7 +898,7 @@ app_init_link(struct app_params *app)
                                p_link->pmd_id,
                                rxq_queue_id,
                                p_rxq->size,
-                               rte_eth_dev_socket_id(p_link->pmd_id),
+                               app_get_cpu_socket_id(p_link->pmd_id),
                                &p_rxq->conf,
                                app->mempool[p_rxq->mempool_id]);
                        if (status < 0)
@@ -915,7 +925,7 @@ app_init_link(struct app_params *app)
                                p_link->pmd_id,
                                txq_queue_id,
                                p_txq->size,
-                               rte_eth_dev_socket_id(p_link->pmd_id),
+                               app_get_cpu_socket_id(p_link->pmd_id),
                                &p_txq->conf);
                        if (status < 0)
                                rte_panic("%s (%" PRIu32 "): "
@@ -987,7 +997,7 @@ app_init_tm(struct app_params *app)
                /* TM */
                p_tm->sched_port_params.name = p_tm->name;
                p_tm->sched_port_params.socket =
-                       rte_eth_dev_socket_id(p_link->pmd_id);
+                       app_get_cpu_socket_id(p_link->pmd_id);
                p_tm->sched_port_params.rate =
                        (uint64_t) link_eth_params.link_speed * 1000 * 1000 / 8;
 
@@ -1066,7 +1076,7 @@ static void app_pipeline_params_get(struct app_params *app,
        uint32_t i;
        uint32_t mempool_id;
 
-       strcpy(p_out->name, p_in->name);
+       snprintf(p_out->name, PIPELINE_NAME_SIZE, "%s", p_in->name);
 
        p_out->socket_id = (int) p_in->socket_id;
 
@@ -1339,6 +1349,8 @@ app_init_pipelines(struct app_params *app)
                                "init error\n", params->name);
                }
 
+               data->ptype = ptype;
+
                data->timer_period = (rte_get_tsc_hz() * params->timer_period)
                        / 1000;
        }
@@ -1372,6 +1384,25 @@ app_init_threads(struct app_params *app)
 
                t = &app->thread_data[lcore_id];
 
+               t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) / 1000;
+               t->thread_req_deadline = time + t->timer_period;
+
+               t->msgq_in = app_thread_msgq_in_get(app,
+                               params->socket_id,
+                               params->core_id,
+                               params->hyper_th_id);
+               if (t->msgq_in == NULL)
+                       rte_panic("Init error: Cannot find MSGQ_IN for thread %" PRId32,
+                               lcore_id);
+
+               t->msgq_out = app_thread_msgq_out_get(app,
+                               params->socket_id,
+                               params->core_id,
+                               params->hyper_th_id);
+               if (t->msgq_out == NULL)
+                       rte_panic("Init error: Cannot find MSGQ_OUT for thread %" PRId32,
+                               lcore_id);
+
                ptype = app_pipeline_type_find(app, params->type);
                if (ptype == NULL)
                        rte_panic("Init error: Unknown pipeline "
@@ -1381,12 +1412,15 @@ app_init_threads(struct app_params *app)
                        &t->regular[t->n_regular] :
                        &t->custom[t->n_custom];
 
+               p->pipeline_id = p_id;
                p->be = data->be;
                p->f_run = ptype->be_ops->f_run;
                p->f_timer = ptype->be_ops->f_timer;
                p->timer_period = data->timer_period;
                p->deadline = time + data->timer_period;
 
+               data->enabled = 1;
+
                if (ptype->be_ops->f_run == NULL)
                        t->n_regular++;
                else
@@ -1407,9 +1441,11 @@ int app_init(struct app_params *app)
        app_init_msgq(app);
 
        app_pipeline_common_cmd_push(app);
+       app_pipeline_thread_cmd_push(app);
        app_pipeline_type_register(app, &pipeline_master);
        app_pipeline_type_register(app, &pipeline_passthrough);
        app_pipeline_type_register(app, &pipeline_flow_classification);
+       app_pipeline_type_register(app, &pipeline_flow_actions);
        app_pipeline_type_register(app, &pipeline_firewall);
        app_pipeline_type_register(app, &pipeline_routing);
 
@@ -1444,7 +1480,7 @@ app_pipeline_type_cmd_push(struct app_params *app,
        /* Push pipeline commands into the application */
        memcpy(&app->cmds[app->n_cmds],
                cmds,
-               n_cmds * sizeof(cmdline_parse_ctx_t *));
+               n_cmds * sizeof(cmdline_parse_ctx_t));
 
        for (i = 0; i < n_cmds; i++)
                app->cmds[app->n_cmds + i]->data = app;