diff mbox

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

Message ID 1500621850-3818-9-git-send-email-bhanuprakash.bodireddy@intel.com
State Superseded
Headers show

Commit Message

Bodireddy, Bhanuprakash July 21, 2017, 7:23 a.m. UTC
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(-)
diff mbox

Patch

diff --git a/lib/dpdk-stub.c b/lib/dpdk-stub.c
index 60ea34c..d6e64dd 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 79fdd10..79bc739 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 acc7c17..a06d1fa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -975,11 +975,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();
+        }
+
         ovsrcu_quiesce_start();
         usleep(get_ka_interval() * 1000);
         ovsrcu_quiesce_end();
diff --git a/lib/keepalive.c b/lib/keepalive.c
index 241a236..3270de7 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -249,6 +249,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 */