Multiple changes for June release
[samplevnf.git] / VNFs / DPPD-PROX / run.c
index 971d714..bed0c75 100644 (file)
@@ -37,6 +37,7 @@
 #include "input.h"
 #include "input_curses.h"
 #include "input_conn.h"
+#include "handle_master.h"
 
 static int needs_refresh;
 static uint64_t update_interval;
@@ -77,8 +78,11 @@ static void update_link_states(void)
 
                port_cfg  = &prox_port_cfg[portid];
                rte_eth_link_get_nowait(portid, &link);
-               port_cfg->link_up = link.link_status;
                port_cfg->link_speed = link.link_speed;
+               if (port_cfg->link_up != link.link_status) {
+                       port_cfg->link_up = link.link_status;
+                       plog_info("port %d: Link speed now %d Mbps\n", portid, link.link_speed);
+               }
        }
 }
 
@@ -127,7 +131,10 @@ static void busy_wait_until(uint64_t deadline)
 
 static void multiplexed_input_stats(uint64_t deadline)
 {
-       input_proc_until(deadline);
+       if (deadline)
+               input_proc_until(deadline);
+       else
+               input_proc();
 
        if (needs_refresh) {
                needs_refresh = 0;
@@ -164,6 +171,7 @@ void __attribute__((noreturn)) run(uint32_t flags)
        uint64_t cur_tsc;
        uint64_t next_update;
        uint64_t stop_tsc = 0;
+       int ret = 0;
        const uint64_t update_interval_threshold = usec_to_tsc(1);
 
        if (flags & DSF_LISTEN_TCP)
@@ -209,20 +217,43 @@ void __attribute__((noreturn)) run(uint32_t flags)
        cmd_rx_tx_info();
        print_warnings();
 
-       while (stop_prox == 0) {
+       struct task_master *task = (struct task_master *)lcore_cfg[prox_cfg.master].tasks_all[0];
+       if (handle_ctrl_plane) {
+               while (stop_prox == 0) {
+                       ret = 1;
+                       // Run ctrl plane for max 10 msec to let screen and keyboard updates
+                       if (prox_cfg.flags & DSF_CTRL_PLANE_ENABLED) {
+                               uint64_t ctrl_plane_update = rte_rdtsc() + msec_to_tsc(10);
+                               while ((ret) && (rte_rdtsc() < ctrl_plane_update))
+                                       ret = handle_ctrl_plane(lcore_cfg[prox_cfg.master].tasks_all[0], NULL, 0);
+                       }
+                       multiplexed_input_stats(0);
+                       if (rte_rdtsc() < next_update)
+                               continue;
+                       next_update += update_interval;
+                       stats_update(stats_cons_flags);
+                       stats_cons_notify();
+
+                       if (stop_tsc && rte_rdtsc() >= stop_tsc) {
+                               stop_prox = 1;
+                       }
+               }
+       } else {
+               while (stop_prox == 0) {
 
-               if (update_interval < update_interval_threshold)
-                       busy_wait_until(next_update);
-               else
-                       multiplexed_input_stats(next_update);
+                       if (update_interval < update_interval_threshold)
+                               busy_wait_until(next_update);
+                       else
+                               multiplexed_input_stats(next_update);
 
-               next_update += update_interval;
+                       next_update += update_interval;
 
-               stats_update(stats_cons_flags);
-               stats_cons_notify();
+                       stats_update(stats_cons_flags);
+                       stats_cons_notify();
 
-               if (stop_tsc && rte_rdtsc() >= stop_tsc) {
-                       stop_prox = 1;
+                       if (stop_tsc && rte_rdtsc() >= stop_tsc) {
+                               stop_prox = 1;
+                       }
                }
        }