examples/eventdev: add info output for main core
authorFeifei Wang <feifei.wang2@arm.com>
Thu, 14 Jan 2021 10:31:00 +0000 (18:31 +0800)
committerJerin Jacob <jerinj@marvell.com>
Tue, 26 Jan 2021 12:44:06 +0000 (13:44 +0100)
When the main core is set as tx/rx/sched/worker core, it also needs to
print some information to show this. Thus, add info output for the main
core, and add a "dump" function to print core information for the sake
of code simplicity and easy maintenance.

In the meanwhile, fix the count error. For the variable "worker_idx", it
should be incremented when the core is set as worker core. However, when
the main core is set as rx/tx/sched core, the worker_idx is also
incremented. Though this error may not have a substantial impact due to
that the main core is the last launched core, but it should be corrected
from the perspective of code correctness.

Fixes: 1094ca96689c ("doc: add SW eventdev pipeline to sample app guide")
Cc: stable@dpdk.org
Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
examples/eventdev_pipeline/main.c

index ae50591..9982d5b 100644 (file)
@@ -22,6 +22,32 @@ struct config_data cdata = {
        .worker_cq_depth = 16
 };
 
+static void
+dump_core_info(unsigned int lcore_id, struct worker_data *data,
+               unsigned int worker_idx)
+{
+       if (fdata->rx_core[lcore_id])
+               printf(
+                       "[%s()] lcore %d executing NIC Rx\n",
+                       __func__, lcore_id);
+
+       if (fdata->tx_core[lcore_id])
+               printf(
+                       "[%s()] lcore %d executing NIC Tx\n",
+                       __func__, lcore_id);
+
+       if (fdata->sched_core[lcore_id])
+               printf(
+                       "[%s()] lcore %d executing scheduler\n",
+                       __func__, lcore_id);
+
+       if (fdata->worker_core[lcore_id])
+               printf(
+                       "[%s()] lcore %d executing worker, using eventdev port %u\n",
+                       __func__, lcore_id,
+                       data[worker_idx].port_id);
+}
+
 static bool
 core_in_use(unsigned int lcore_id) {
        return (fdata->rx_core[lcore_id] || fdata->sched_core[lcore_id] ||
@@ -413,25 +439,7 @@ main(int argc, char **argv)
                        !fdata->sched_core[lcore_id])
                        continue;
 
-               if (fdata->rx_core[lcore_id])
-                       printf(
-                               "[%s()] lcore %d executing NIC Rx\n",
-                               __func__, lcore_id);
-
-               if (fdata->tx_core[lcore_id])
-                       printf(
-                               "[%s()] lcore %d executing NIC Tx\n",
-                               __func__, lcore_id);
-
-               if (fdata->sched_core[lcore_id])
-                       printf("[%s()] lcore %d executing scheduler\n",
-                                       __func__, lcore_id);
-
-               if (fdata->worker_core[lcore_id])
-                       printf(
-                               "[%s()] lcore %d executing worker, using eventdev port %u\n",
-                               __func__, lcore_id,
-                               worker_data[worker_idx].port_id);
+               dump_core_info(lcore_id, worker_data, worker_idx);
 
                err = rte_eal_remote_launch(fdata->cap.worker,
                                &worker_data[worker_idx], lcore_id);
@@ -446,8 +454,13 @@ main(int argc, char **argv)
 
        lcore_id = rte_lcore_id();
 
-       if (core_in_use(lcore_id))
-               fdata->cap.worker(&worker_data[worker_idx++]);
+       if (core_in_use(lcore_id)) {
+               dump_core_info(lcore_id, worker_data, worker_idx);
+               fdata->cap.worker(&worker_data[worker_idx]);
+
+               if (fdata->worker_core[lcore_id])
+                       worker_idx++;
+       }
 
        rte_eal_mp_wait_lcore();