examples/ipsec-secgw: fix ESP flow error log
[dpdk.git] / examples / l3fwd-power / main.c
index 20dc765..48b9c85 100644 (file)
@@ -46,9 +46,7 @@
 #include <rte_spinlock.h>
 #include <rte_power_empty_poll.h>
 #include <rte_metrics.h>
-#ifdef RTE_LIBRTE_TELEMETRY
 #include <rte_telemetry.h>
-#endif
 
 #include "perf_core.h"
 #include "main.h"
@@ -826,17 +824,24 @@ power_freq_scaleup_heuristic(unsigned lcore_id,
 static int
 sleep_until_rx_interrupt(int num)
 {
+       /*
+        * we want to track when we are woken up by traffic so that we can go
+        * back to sleep again without log spamming.
+        */
+       static bool timeout;
        struct rte_epoll_event event[num];
        int n, i;
        uint16_t port_id;
        uint8_t queue_id;
        void *data;
 
-       RTE_LOG(INFO, L3FWD_POWER,
-               "lcore %u sleeps until interrupt triggers\n",
-               rte_lcore_id());
+       if (!timeout) {
+               RTE_LOG(INFO, L3FWD_POWER,
+                               "lcore %u sleeps until interrupt triggers\n",
+                               rte_lcore_id());
+       }
 
-       n = rte_epoll_wait(RTE_EPOLL_PER_THREAD, event, num, -1);
+       n = rte_epoll_wait(RTE_EPOLL_PER_THREAD, event, num, 10);
        for (i = 0; i < n; i++) {
                data = event[i].epdata.data;
                port_id = ((uintptr_t)data) >> CHAR_BIT;
@@ -847,6 +852,7 @@ sleep_until_rx_interrupt(int num)
                        " port %d queue %d\n",
                        rte_lcore_id(), port_id, queue_id);
        }
+       timeout = n == 0;
 
        return 0;
 }
@@ -1309,7 +1315,8 @@ start_rx:
                                        /**
                                         * start receiving packets immediately
                                         */
-                                       goto start_rx;
+                                       if (likely(!is_done()))
+                                               goto start_rx;
                                }
                        }
                        stats[lcore_id].sleep_time += lcore_idle_hint;
@@ -2116,7 +2123,7 @@ update_telemetry(__rte_unused struct rte_timer *tim,
        if (ret < 0)
                RTE_LOG(WARNING, POWER, "failed to update metrcis\n");
 }
-#ifdef RTE_LIBRTE_TELEMETRY
+
 static int
 handle_app_stats(const char *cmd __rte_unused,
                const char *params __rte_unused,
@@ -2132,7 +2139,7 @@ handle_app_stats(const char *cmd __rte_unused,
                                values[i]);
        return 0;
 }
-#endif
+
 static void
 telemetry_setup_timer(void)
 {
@@ -2532,11 +2539,9 @@ main(int argc, char **argv)
                        rte_spinlock_init(&stats[lcore_id].telemetry_lock);
                }
                rte_timer_init(&telemetry_timer);
-#ifdef RTE_LIBRTE_TELEMETRY
                rte_telemetry_register_cmd("/l3fwd-power/stats",
                                handle_app_stats,
                                "Returns global power stats. Parameters: None");
-#endif
                rte_eal_mp_remote_launch(main_telemetry_loop, NULL,
                                                SKIP_MASTER);
        }