diff mbox

[ovs-dev,RFC,v2,05/19] keepalive: Add more helper functions to KA framework.

Message ID 1497286187-69287-6-git-send-email-bhanuprakash.bodireddy@intel.com
State Superseded
Headers show

Commit Message

Bodireddy, Bhanuprakash June 12, 2017, 4:49 p.m. UTC
This commit introduces helper functions in 'keepalive' module that are
needed to register/unregister PMD threads to KA framework. Also
introduce APIs to mark the PMD core states.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
---
 lib/keepalive.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/keepalive.h |  9 +++++++++
 2 files changed, 65 insertions(+)
diff mbox

Patch

diff --git a/lib/keepalive.c b/lib/keepalive.c
index 8d2b0a0..267f911 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -48,6 +48,62 @@  get_ka_shm(void)
     return ka_shm;
 }
 
+/* If KA enabled return true, otherwise 'false'. */
+inline bool
+is_ka_enabled(void)
+{
+    return keepalive_enable;
+}
+
+/* Return the Keepalive timer interval. */
+inline uint32_t
+get_ka_interval(void)
+{
+    return keepalive_timer_interval;
+}
+
+inline int
+get_ka_init_status(void)
+{
+    return ka_init_status;
+}
+
+/* Register packet processing core 'core_id' for liveness checks. */
+void
+ka_register_pmd_thread(unsigned core_id)
+{
+    if (is_ka_enabled()) {
+        dpdk_register_pmd_core(core_id);
+    }
+}
+
+/* Register packet processing core 'core_id' for liveness checks. */
+void
+ka_unregister_pmd_thread(unsigned core_id)
+{
+    if (is_ka_enabled()) {
+        dpdk_unregister_pmd_core(core_id);
+    }
+}
+
+/* Mark packet processing core alive. */
+inline void
+ka_mark_pmd_thread_alive(void)
+{
+    if (is_ka_enabled()) {
+        dpdk_mark_pmd_core_alive();
+    }
+}
+
+/* Mark packet processing core as idle. */
+inline void
+ka_mark_pmd_thread_sleep(void)
+{
+    if (is_ka_enabled()) {
+        dpdk_mark_pmd_core_sleep();
+    }
+}
+
 void
 ka_set_pmd_state_ts(unsigned core_id, enum keepalive_state state,
                     uint64_t last_alive)
diff --git a/lib/keepalive.h b/lib/keepalive.h
index 2e844fb..8ec6363 100644
--- a/lib/keepalive.h
+++ b/lib/keepalive.h
@@ -57,4 +57,13 @@  void ka_init(const struct smap *);
 struct keepalive_shm *get_ka_shm(void);
 void ka_set_pmd_state_ts(unsigned, enum keepalive_state, uint64_t);
 
+void ka_register_pmd_thread(unsigned);
+void ka_unregister_pmd_thread(unsigned);
+void ka_mark_pmd_thread_alive(void);
+void ka_mark_pmd_thread_sleep(void);
+
+bool is_ka_enabled(void);
+uint32_t get_ka_interval(void);
+int get_ka_init_status(void);
+
 #endif /* keepalive.h */