[ovs-dev,v3,08/19] dpif-netdev: Enable heartbeats for DPDK datapath.

Submitted by Bhanuprakash Bodireddy on Aug. 4, 2017, 8:07 a.m.

Details

Message ID 1501834086-31829-9-git-send-email-bhanuprakash.bodireddy@intel.com
State New
Headers show

Commit Message

Bhanuprakash Bodireddy Aug. 4, 2017, 8:07 a.m.
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.bodireddy@intel.com>
---
 lib/dpdk-stub.c   | 6 ++++++
 lib/dpdk.c        | 7 +++++++
 lib/dpdk.h        | 2 ++
 lib/dpif-netdev.c | 9 ++++++++-
 lib/keepalive.c   | 9 +++++++++
 lib/keepalive.h   | 1 +
 6 files changed, 33 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/lib/dpdk-stub.c b/lib/dpdk-stub.c
index b4f111a..740ec11 100644
--- a/lib/dpdk-stub.c
+++ b/lib/dpdk-stub.c
@@ -78,3 +78,9 @@  dpdk_mark_pmd_core_sleep(void)
 {
     /* Nothing */
 }
+
+void
+dpdk_dispatch_pmd_hb(void)
+{
+    /* Nothing */
+}
diff --git a/lib/dpdk.c b/lib/dpdk.c
index 250cc2f..59ac035 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -542,3 +542,10 @@  dpdk_mark_pmd_core_sleep(void)
 {
     rte_keepalive_mark_sleep(rte_global_keepalive_info);
 }
+
+/* Dispatch pings */
+void
+dpdk_dispatch_pmd_hb(void)
+{
+    rte_keepalive_dispatch_pings(NULL, rte_global_keepalive_info);
+}
diff --git a/lib/dpdk.h b/lib/dpdk.h
index 7619730..2532cb7 100644
--- a/lib/dpdk.h
+++ b/lib/dpdk.h
@@ -47,4 +47,6 @@  void dpdk_unregister_pmd_core(unsigned core_id);
 void dpdk_mark_pmd_core_alive(void);
 void dpdk_mark_pmd_core_sleep(void);
 
+void dpdk_dispatch_pmd_hb(void);
+
 #endif /* dpdk.h */
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 5737223..009ee24 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -981,11 +981,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 eeaa25a..3022789 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -248,6 +248,15 @@  ka_destroy_portstats(void)
     }
 }
 
+/* Dispatch pings */
+void
+dispatch_heartbeats(void)
+{
+#ifdef DPDK_NETDEV
+    dpdk_dispatch_pmd_hb();
+#endif
+}
+
 static struct keepalive_info *
 keepalive_info_create(void)
 {
diff --git a/lib/keepalive.h b/lib/keepalive.h
index 605e41c..31ee34c 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 */