[ovs-dev,v3,01/19] dpdk: Add helper functions for DPDK datapath keepalive.

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

Commit Message

Bodireddy, Bhanuprakash Aug. 4, 2017, 8:07 a.m.
Introduce helper functions in 'dpdk' module that are needed for
DPDK keepalive functionality. Also add dummy functions in 'dpdk-stub' module
that are needed when DPDK datapath is not available.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
---
 lib/dpdk-stub.c | 24 ++++++++++++++++++++++++
 lib/dpdk.c      | 31 +++++++++++++++++++++++++++++++
 lib/dpdk.h      |  7 +++++++
 3 files changed, 62 insertions(+)

Patch

diff --git a/lib/dpdk-stub.c b/lib/dpdk-stub.c
index daef729..d7fb19b 100644
--- a/lib/dpdk-stub.c
+++ b/lib/dpdk-stub.c
@@ -48,3 +48,27 @@  dpdk_get_vhost_sock_dir(void)
 {
     return NULL;
 }
+
+void
+dpdk_register_pmd_core(unsigned core_id OVS_UNUSED)
+{
+    /* Nothing */
+}
+
+void
+dpdk_unregister_pmd_core(unsigned core_id OVS_UNUSED)
+{
+    /* Nothing */
+}
+
+void
+dpdk_mark_pmd_core_alive(void)
+{
+    /* Nothing */
+}
+
+void
+dpdk_mark_pmd_core_sleep(void)
+{
+    /* Nothing */
+}
diff --git a/lib/dpdk.c b/lib/dpdk.c
index 8da6c32..8db63bf 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -22,6 +22,7 @@ 
 #include <sys/stat.h>
 #include <getopt.h>
 
+#include <rte_keepalive.h>
 #include <rte_log.h>
 #include <rte_memzone.h>
 #ifdef DPDK_PDUMP
@@ -489,3 +490,33 @@  dpdk_set_lcore_id(unsigned cpu)
     ovs_assert(cpu != NON_PMD_CORE_ID);
     RTE_PER_LCORE(_lcore_id) = cpu;
 }
+
+/* Register packet processing core 'core_id' for liveness checks. */
+void
+dpdk_register_pmd_core(unsigned core)
+{
+    rte_keepalive_register_core(rte_global_keepalive_info, core);
+}
+
+void
+dpdk_unregister_pmd_core(unsigned core OVS_UNUSED)
+{
+    /* XXX: DPDK unfortunately hasn't implemented unregister API
+     * This will be fixed later, instead use sleep API now.
+     */
+    rte_keepalive_mark_sleep(rte_global_keepalive_info);
+}
+
+/* Mark packet processing core alive. */
+void
+dpdk_mark_pmd_core_alive(void)
+{
+    rte_keepalive_mark_alive(rte_global_keepalive_info);
+}
+
+/* Mark packet processing core as idle. */
+void
+dpdk_mark_pmd_core_sleep(void)
+{
+    rte_keepalive_mark_sleep(rte_global_keepalive_info);
+}
diff --git a/lib/dpdk.h b/lib/dpdk.h
index 673a1f1..3f31211 100644
--- a/lib/dpdk.h
+++ b/lib/dpdk.h
@@ -32,8 +32,15 @@ 
 
 struct smap;
 
+struct rte_keepalive *rte_global_keepalive_info;
 void dpdk_init(const struct smap *ovs_other_config);
 void dpdk_set_lcore_id(unsigned cpu);
 const char *dpdk_get_vhost_sock_dir(void);
 
+/* Keepalive APIs */
+void dpdk_register_pmd_core(unsigned core_id);
+void dpdk_unregister_pmd_core(unsigned core_id);
+void dpdk_mark_pmd_core_alive(void);
+void dpdk_mark_pmd_core_sleep(void);
+
 #endif /* dpdk.h */