From patchwork Fri Aug 4 08:08:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 797692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xP0Tx3dXzz9s72 for ; Fri, 4 Aug 2017 18:29:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3A647BED; Fri, 4 Aug 2017 08:18:03 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 8FA28BD0 for ; Fri, 4 Aug 2017 08:18:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 170881C0 for ; Fri, 4 Aug 2017 08:18:00 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Aug 2017 01:18:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,320,1498546800"; d="scan'208";a="295690708" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by fmsmga004.fm.intel.com with ESMTP; 04 Aug 2017 01:17:59 -0700 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Fri, 4 Aug 2017 09:08:05 +0100 Message-Id: <1501834086-31829-19-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1501834086-31829-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1501834086-31829-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v3 18/19] keepalive: Display extended Keepalive status. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This commit adds support to display the extended keepalive status. The status can be displayed as follows. $ ovs-appctl keepalive/pmd-xstats-show keepAlive Status : Enabled keepAlive Interval: 1000 ms PMD threads : 3 pmd64 PMD core_id : 0 PMD thread id : 1269 [ACTIVE] PMD heartbeats : enabled PMD state : ALIVE Last seen timestamp : 9123706507798853 PMD failure count : 0 pmd65 PMD core_id : 1 PMD thread id : 1270 [INACTIVE] PMD heartbeats : enabled PMD state : GONE Last seen timestamp : 9123706507801627 PMD failure count : 1 pmd66 PMD core_id : 2 PMD thread id : 1271 [ACTIVE] PMD heartbeats : enabled PMD state : ALIVE Last seen timestamp : 9125112827794550 PMD failure count : 0 PMD health check : enabled Packet Stats Port dpdk0, Queue: 1, Link status: up rx_packets : 1801284454 tx_packets : 0 Cycle Stats Polling cycles : 35426111637 Processing cycles : 10123697085 For PMD on core 2, on a heartbeat failure, health checks are enabled and additional stats(pkt stats, cpu cycles) are displayed as above. Signed-off-by: Bhanuprakash Bodireddy --- lib/keepalive.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/lib/keepalive.c b/lib/keepalive.c index 2176ada..30a5681 100644 --- a/lib/keepalive.c +++ b/lib/keepalive.c @@ -737,6 +737,116 @@ ka_unixctl_status(struct unixctl_conn *conn, int argc OVS_UNUSED, ds_destroy(&ds); } +static void +ka_unixctl_pmd_xstats_show(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *ka_info_) +{ + struct ds ds = DS_EMPTY_INITIALIZER; + ds_put_format(&ds, + "\n\t\tKeepalive xstats\n\n"); + + ds_put_format(&ds, "keepalive status : %s\n", + ka_is_enabled() ? "Enabled" : "Disabled"); + + if (!ka_is_enabled()) { + goto out; + } + + ds_put_format(&ds, "keepalive interval: %"PRIu32" ms\n", + get_ka_interval()); + + struct keepalive_info *ka_info = (struct keepalive_info *)ka_info_; + if (!ka_info) { + goto out; + } + + ds_put_format(&ds, "PMD threads : %"PRIu32" \n", ka_info->pmd_cnt); + + struct ka_process_info *pinfo, *pinfo_next; + ovs_mutex_lock(&ka_info->proclist_mutex); + HMAP_FOR_EACH_SAFE (pinfo, pinfo_next, node, &ka_info->process_list) { + 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; + } + + ds_put_format(&ds, "\n"); + ds_put_format(&ds, " %s\n", pinfo->name); + ds_put_format(&ds, "\tPMD core_id : %d\n", pinfo->core_id); + ds_put_format(&ds, "\tPMD thread-id : %d [%s]\n", + pinfo->tid, process_is_active(pinfo->tid) ? + "ACTIVE" : "INACTIVE"); + ds_put_format(&ds, "\tPMD heartbeats : %s\n", + ka_is_enabled() ? "enabled" : "disabled"); + ds_put_format(&ds, "\tPMD state : %s\n", state); + ds_put_format(&ds, "\tLast seen timestamp : %"PRIu64"\n", + pinfo->core_last_seen_times); + + ds_put_format(&ds, "\tPMD failure count : %d\n", + pinfo->failures); + + int health_check = pinfo->healthcheck; + if (health_check) { + ds_put_format(&ds, "\tPMD health check : %s\n", + health_check ? "enabled" : "disabled"); + ds_put_format(&ds, "\tPacket Stats\n"); + + int cid = pinfo->core_id; + int n = ka_info->ext_stats[cid].num_poll_ports; + for (int idx = 0; idx < n; idx++) { + ds_put_format(&ds, "\t\tPort %s, Link status: %s\n", + ka_info->ext_stats[cid].port_stats[idx].port, + ka_info->ext_stats[cid].port_stats[idx].link_state); + ds_put_format(&ds, "\t\trx_packets : %"PRIu64"\n", + ka_info->ext_stats[cid]. \ + port_stats[idx].stats.rx_packets); + ds_put_format(&ds, "\t\ttx_packets : %"PRIu64"\n", + ka_info->ext_stats[cid].port_stats[idx]. \ + stats.tx_packets); + } + + ds_put_format(&ds, "\tCycle Stats\n"); + + ds_put_format(&ds, "\t\tPolling cycles : %"PRIu64"\n", + ka_info->ext_stats[cid].cycles[PMD_CYCLES_IDLE]); + ds_put_format(&ds, "\t\tProcessing cycles : %"PRIu64"\n", + ka_info->ext_stats[cid].cycles[PMD_CYCLES_PROCESSING]); + } + } + ovs_mutex_unlock(&ka_info->proclist_mutex); + + ds_put_format(&ds, "\n"); +out: + unixctl_command_reply(conn, ds_cstr(&ds)); + ds_destroy(&ds); +} + static int ka_init__(void) { @@ -783,6 +893,8 @@ ka_init(const struct smap *ovs_other_config) ka_unixctl_pmd_health_show, ka_info); unixctl_command_register("keepalive/status", "", 0, 0, ka_unixctl_status, NULL); + unixctl_command_register("keepalive/pmd-xstats-show", "", 0, 0, + ka_unixctl_pmd_xstats_show, ka_info); ovsthread_once_done(&once_enable); }