@@ -982,6 +982,7 @@ ovs_keepalive(void *f_)
int n_pmds = cmap_count(&dp->poll_threads) - 1;
if (n_pmds > 0) {
dispatch_heartbeats();
+ get_ka_stats();
}
ovsrcu_quiesce_start();
@@ -25,6 +25,7 @@
#include "keepalive.h"
#include "lib/vswitch-idl.h"
#include "openvswitch/vlog.h"
+#include "ovs-thread.h"
#include "process.h"
VLOG_DEFINE_THIS_MODULE(keepalive);
@@ -34,6 +35,9 @@ static bool ka_init_status = ka_init_failure; /* Keepalive initialization */
static uint32_t keepalive_timer_interval; /* keepalive timer interval */
static struct keepalive_info *ka_info = NULL;
+static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
+static struct smap *keepalive_stats OVS_GUARDED_BY(mutex);
+
inline bool
ka_is_enabled(void)
{
@@ -257,6 +261,75 @@ keepalive_info_create(void)
return ka_info;
}
+static void
+get_pmd_status(struct smap *ka_pmd_stats)
+ OVS_REQUIRES(ka_info->proclist_mutex)
+{
+ if (OVS_UNLIKELY(!ka_info)) {
+ return;
+ }
+
+ struct ka_process_info *pinfo, *pinfo_next;
+ HMAP_FOR_EACH_SAFE (pinfo, pinfo_next, node, &ka_info->process_list) {
+ int core_id = pinfo->core_id;
+ char *state = NULL;
+ if (pinfo->core_state == KA_STATE_UNUSED ||
+ pinfo->core_state == KA_STATE_SLEEP ) {
+ continue;
+ }
+
+ switch (pinfo->core_state) {
+ case KA_STATE_ALIVE:
+ state = "ALIVE";
+ break;
+ case KA_STATE_MISSING:
+ state = "MISSING";
+ break;
+ case KA_STATE_DEAD:
+ state = "DEAD";
+ break;
+ case KA_STATE_GONE:
+ state = "GONE";
+ break;
+ case KA_STATE_DOZING:
+ state = "DOZING";
+ break;
+ case KA_STATE_SLEEP:
+ state = "SLEEP";
+ break;
+ case KA_STATE_CHECK:
+ state = "HEALTH_CHECK_RUNNING";
+ break;
+ case KA_STATE_UNUSED:
+ break;
+ }
+
+ smap_add_format(ka_pmd_stats, pinfo->name, "%s,%d,%ld",
+ state, core_id, pinfo->core_last_seen_times);
+ }
+}
+
+void
+get_ka_stats(void)
+{
+ struct smap *ka_pmd_stats;
+ ka_pmd_stats = xmalloc(sizeof *ka_pmd_stats);
+ smap_init(ka_pmd_stats);
+
+ ovs_mutex_lock(&ka_info->proclist_mutex);
+ get_pmd_status(ka_pmd_stats);
+ ovs_mutex_unlock(&ka_info->proclist_mutex);
+
+ ovs_mutex_lock(&mutex);
+ if (keepalive_stats) {
+ smap_destroy(keepalive_stats);
+ free(keepalive_stats);
+ keepalive_stats = NULL;
+ }
+ keepalive_stats = ka_pmd_stats;
+ ovs_mutex_unlock(&mutex);
+}
+
static int
ka_init__(void)
{
@@ -101,6 +101,7 @@ int get_ka_init_status(void);
int ka_get_pmd_tid(unsigned core);
int ka_alloc_portstats(unsigned, int);
void ka_destroy_portstats(void);
+void get_ka_stats(void);
void dispatch_heartbeats(void);
#endif /* keepalive.h */
This commit implements APIs to retrieve the PMD thread status and return the status in the below format for each PMD thread. Format: PMDID="STATUS,core id,last_seen_timestamp" eg: PMD62="ALIVE,2,9220698256784207" PMD63="GONE,3,9220698256786231" The status is periodically retrieved by keepalive thread and stored in keepalive_stats struc which later shall be retrieved by vswitchd thread. In case of four PMD threads the status is as below: "PMD62"="ALIVE,0,9220698256784207" "PMD63"="ALIVE,1,9220698256784913" "PMD64"="ALIVE,2,9220698256785902" "PMD65"="ALIVE,3,9220698256786231" Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> --- lib/dpif-netdev.c | 1 + lib/keepalive.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/keepalive.h | 1 + 3 files changed, 75 insertions(+)