This commit adds heartbeat mechanism support for DPDK datapath. Heartbeats
are sent to registered PMD threads at predefined intervals (as set in ovsdb
with 'keepalive-interval').

The heartbeats are only enabled when there is atleast one port added to
the bridge and with active PMD thread polling the port.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodire...@intel.com>
---
 lib/dpif-netdev.c |  9 ++++++++-
 lib/keepalive.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 lib/keepalive.h   |  1 +
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 84c7ffd..67ee424 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -980,11 +980,18 @@ sorted_poll_thread_list(struct dp_netdev *dp,
 }
 
 static void *
-ovs_keepalive(void *f_ OVS_UNUSED)
+ovs_keepalive(void *f_)
 {
+    struct dp_netdev *dp = f_;
+
     pthread_detach(pthread_self());
 
     for (;;) {
+        int n_pmds = cmap_count(&dp->poll_threads) - 1;
+        if (n_pmds > 0) {
+            dispatch_heartbeats();
+        }
+
         xusleep(get_ka_interval() * 1000);
     }
 
diff --git a/lib/keepalive.c b/lib/keepalive.c
index dfafaeb..4ee89c0 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -211,6 +211,47 @@ ka_get_timer_interval(const struct smap *ovs_other_config 
OVS_UNUSED)
     return ka_interval;
 }
 
+/* Dispatch heartbeats. */
+void
+dispatch_heartbeats(void)
+{
+    for (int core_id = 0; core_id < KA_DP_MAXCORES; core_id++) {
+        if (ka_info->active_cores[core_id] == 0) {
+            continue;
+        }
+
+        switch (ka_info->state_flags[core_id]) {
+            case KA_STATE_UNUSED:
+                break;
+            case KA_STATE_ALIVE: /* Alive */
+                ka_info->state_flags[core_id] = KA_STATE_MISSING;
+                ka_info->last_alive[core_id] = time_wall_msec();
+                break;
+            case KA_STATE_MISSING: /* MIA */
+                ka_info->state_flags[core_id] = KA_STATE_DEAD;
+                break;
+            case KA_STATE_DEAD: /* Dead */
+                ka_info->state_flags[core_id] = KA_STATE_GONE;
+                VLOG_DBG("Core %d died. ", core_id);
+                break;
+            case KA_STATE_GONE: /* Buried */
+                break;
+            case KA_STATE_DOZING: /* Core going idle */
+                ka_info->state_flags[core_id] = KA_STATE_SLEEP;
+                ka_info->last_alive[core_id] = time_wall_msec();
+                break;
+            case KA_STATE_SLEEP: /* Idled core */
+                break;
+        }
+
+        if (ka_info->relay_cb) {
+            ka_info->relay_cb(core_id, ka_info->state_flags[core_id],
+                              ka_info->last_alive[core_id],
+                              ka_info->relay_cb_data);
+        }
+    }
+}
+
 /*
  * This function shall be invoked periodically to write the core status and
  * last seen timestamp of the cores in to keepalive info structure.
diff --git a/lib/keepalive.h b/lib/keepalive.h
index 607ee3b..a344006 100644
--- a/lib/keepalive.h
+++ b/lib/keepalive.h
@@ -101,4 +101,5 @@ int get_ka_init_status(void);
 int ka_alloc_portstats(unsigned, int);
 void ka_destroy_portstats(void);
 
+void dispatch_heartbeats(void);
 #endif /* keepalive.h */
-- 
2.4.11

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to