From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 826A5A0540; Mon, 13 Jul 2020 16:28:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7542E1D8D8; Mon, 13 Jul 2020 16:28:18 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7718F1D739 for ; Mon, 13 Jul 2020 16:28:16 +0200 (CEST) IronPort-SDR: ldbpbG1gHIbPaSGNl4AEwyujyezCEUm9qrmfq9stEL3UrlRE9TrRrAbv5eskXFw8A9GjslANuh E+5TgE/V9bHw== X-IronPort-AV: E=McAfee;i="6000,8403,9680"; a="146098594" X-IronPort-AV: E=Sophos;i="5.75,347,1589266800"; d="scan'208";a="146098594" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 07:28:16 -0700 IronPort-SDR: L/tD2yvBI+OdDMaot0D021Pd4LXCdbx54I4WP37f5s4DEg4sixPDmYauiFuaiaT+hYDWehgKq3 1FVtMgnqGC0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,347,1589266800"; d="scan'208";a="429407286" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga004.jf.intel.com with ESMTP; 13 Jul 2020 07:28:13 -0700 From: Ciara Power To: kevin.laatz@intel.com, thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, keith.wiles@intel.com, Ciara Power Date: Mon, 13 Jul 2020 15:23:47 +0100 Message-Id: <20200713142347.31262-3-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713142347.31262-1-ciara.power@intel.com> References: <20200612105344.15383-1-ciara.power@intel.com> <20200713142347.31262-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH v4 2/2] ethdev: add common stats for telemetry X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The ethdev library now registers a telemetry command for common ethdev statistics. An example usage is shown below: Connecting to /var/run/dpdk/rte/dpdk_telemetry.v2 {"version": "DPDK 20.08.0-rc1", "pid": 14119, "max_output_len": 16384} --> /ethdev/stats,0 {"/ethdev/stats": {"ipackets": 0, "opackets": 0, "ibytes": 0, "obytes": \ 0, "imissed": 0, "ierrors": 0, "oerrors": 0, "rx_nombuf": 0, \ "q_ipackets": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], \ "q_opackets": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], \ "q_ibytes": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], \ "q_obytes": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], \ "q_errors": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}} Signed-off-by: Ciara Power Acked-by: Bruce Richardson --- v3: - Updated help text and commit subject line. v2: - Updated to use memory management APIs. --- lib/librte_ethdev/rte_ethdev.c | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 7858ad5f1..8ee14b1b5 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5275,6 +5275,57 @@ handle_port_list(const char *cmd __rte_unused, return 0; } +static void +add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats, + const char *stat_name) +{ + int q; + struct rte_tel_data *q_data = rte_tel_data_alloc(); + rte_tel_data_start_array(q_data, RTE_TEL_U64_VAL); + for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++) + rte_tel_data_add_array_u64(q_data, q_stats[q]); + rte_tel_data_add_dict_container(d, stat_name, q_data, 0); +} + +#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s) + +static int +handle_port_stats(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_eth_stats stats; + int port_id, ret; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + port_id = atoi(params); + if (!rte_eth_dev_is_valid_port(port_id)) + return -1; + + ret = rte_eth_stats_get(port_id, &stats); + if (ret < 0) + return -1; + + rte_tel_data_start_dict(d); + ADD_DICT_STAT(stats, ipackets); + ADD_DICT_STAT(stats, opackets); + ADD_DICT_STAT(stats, ibytes); + ADD_DICT_STAT(stats, obytes); + ADD_DICT_STAT(stats, imissed); + ADD_DICT_STAT(stats, ierrors); + ADD_DICT_STAT(stats, oerrors); + ADD_DICT_STAT(stats, rx_nombuf); + add_port_queue_stats(d, stats.q_ipackets, "q_ipackets"); + add_port_queue_stats(d, stats.q_opackets, "q_opackets"); + add_port_queue_stats(d, stats.q_ibytes, "q_ibytes"); + add_port_queue_stats(d, stats.q_obytes, "q_obytes"); + add_port_queue_stats(d, stats.q_errors, "q_errors"); + + return 0; +} + static int handle_port_xstats(const char *cmd __rte_unused, const char *params, @@ -5361,6 +5412,8 @@ RTE_INIT(ethdev_init_telemetry) { rte_telemetry_register_cmd("/ethdev/list", handle_port_list, "Returns list of available ethdev ports. Takes no parameters"); + rte_telemetry_register_cmd("/ethdev/stats", handle_port_stats, + "Returns the common stats for a port. Parameters: int port_id"); rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats, "Returns the extended stats for a port. Parameters: int port_id"); rte_telemetry_register_cmd("/ethdev/link_status", -- 2.17.1