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.bodire...@intel.com> --- lib/dpdk-stub.c | 24 ++++++++++++++++++++++++ lib/dpdk.c | 31 +++++++++++++++++++++++++++++++ lib/dpdk.h | 10 ++++++++++ 3 files changed, 65 insertions(+) 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..9c764b9 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..bdbb51b 100644 --- a/lib/dpdk.h +++ b/lib/dpdk.h @@ -17,6 +17,7 @@ #ifndef DPDK_H #define DPDK_H +#include <stdbool.h> #ifdef DPDK_NETDEV #include <rte_config.h> @@ -26,14 +27,23 @@ #else +#include <stdint.h> + #define NON_PMD_CORE_ID UINT32_MAX #endif /* DPDK_NETDEV */ 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 */ -- 2.4.11 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev