All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ciara Power <ciara.power@intel.com>
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 <ciara.power@intel.com>
Subject: [dpdk-dev] [PATCH v5 3/3] ethdev: add common stats for telemetry
Date: Wed, 15 Jul 2020 13:29:35 +0100	[thread overview]
Message-ID: <20200715122935.1822-4-ciara.power@intel.com> (raw)
In-Reply-To: <20200715122935.1822-1-ciara.power@intel.com>

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 <ciara.power@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

---
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


  parent reply	other threads:[~2020-07-15 12:34 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12 10:53 [dpdk-dev] [RFC 0/2] add basic ethdev stats with data object recursion Ciara Power
2020-06-12 10:53 ` [dpdk-dev] [RFC 1/2] telemetry: support some recursive data objects Ciara Power
2020-06-12 12:58   ` Bruce Richardson
2020-06-12 13:07   ` Bruce Richardson
2020-06-12 13:14     ` Bruce Richardson
2020-06-12 10:53 ` [dpdk-dev] [RFC 2/2] ethdev: add basic stats for telemetry Ciara Power
2020-06-12 13:10   ` Bruce Richardson
2020-06-24 13:48 ` [dpdk-dev] [PATCH v2 0/2] add basic ethdev stats with data object recursion Ciara Power
2020-06-24 13:48   ` [dpdk-dev] [PATCH v2 1/2] telemetry: support array values in data objects Ciara Power
2020-06-24 15:09     ` Bruce Richardson
2020-06-24 15:18     ` Bruce Richardson
2020-06-24 13:48   ` [dpdk-dev] [PATCH v2 2/2] ethdev: add basic stats for telemetry Ciara Power
2020-06-24 15:19     ` Bruce Richardson
2020-07-02 10:19 ` [dpdk-dev] [PATCH v3 0/2] add basic ethdev stats with data object recursion Ciara Power
2020-07-02 10:19   ` [dpdk-dev] [PATCH v3 1/2] telemetry: support array values in data objects Ciara Power
2020-07-07  7:15     ` Thomas Monjalon
2020-07-02 10:19   ` [dpdk-dev] [PATCH v3 2/2] ethdev: add common stats for telemetry Ciara Power
2020-07-13 14:23 ` [dpdk-dev] [PATCH v4 0/2] add basic ethdev stats with data object recursion Ciara Power
2020-07-13 14:23   ` [dpdk-dev] [PATCH v4 1/2] telemetry: support array values in data objects Ciara Power
2020-07-13 14:23   ` [dpdk-dev] [PATCH v4 2/2] ethdev: add common stats for telemetry Ciara Power
2020-07-15 12:29 ` [dpdk-dev] [PATCH v5 0/3] add basic ethdev stats with data object recursion Ciara Power
2020-07-15 12:29   ` [dpdk-dev] [PATCH v5 1/3] telemetry: support array values in data objects Ciara Power
2020-07-15 12:29   ` [dpdk-dev] [PATCH v5 2/3] test/test_telemetry_data: add unit tests for data to JSON Ciara Power
2020-07-17 11:53     ` Bruce Richardson
2020-07-15 12:29   ` Ciara Power [this message]
2020-07-20 11:19 ` [dpdk-dev] [PATCH v6 0/3] add basic ethdev stats with data object recursion Ciara Power
2020-07-20 11:19   ` [dpdk-dev] [PATCH v6 1/3] telemetry: support array values in data objects Ciara Power
2020-07-20 11:19   ` [dpdk-dev] [PATCH v6 2/3] test/test_telemetry_data: add unit tests for data to JSON Ciara Power
2020-07-20 13:08     ` Bruce Richardson
2020-07-20 11:19   ` [dpdk-dev] [PATCH v6 3/3] ethdev: add common stats for telemetry Ciara Power
2020-07-20 14:04 ` [dpdk-dev] [PATCH v7 0/3] add basic ethdev stats with data object recursion Ciara Power
2020-07-20 14:04   ` [dpdk-dev] [PATCH v7 1/3] telemetry: support array values in data objects Ciara Power
2020-07-20 14:04   ` [dpdk-dev] [PATCH v7 2/3] test/test_telemetry_data: add unit tests for data to JSON Ciara Power
2020-07-20 14:32     ` Bruce Richardson
2020-07-20 14:04   ` [dpdk-dev] [PATCH v7 3/3] ethdev: add common stats for telemetry Ciara Power
2020-08-21 12:51 ` [dpdk-dev] [PATCH v8 0/3] add basic ethdev stats with data object recursion Ciara Power
2020-08-21 12:51   ` [dpdk-dev] [PATCH v8 1/3] telemetry: support array values in data objects Ciara Power
2020-08-21 12:51   ` [dpdk-dev] [PATCH v8 2/3] test/test_telemetry_data: add unit tests for data to JSON Ciara Power
2020-08-21 12:51   ` [dpdk-dev] [PATCH v8 3/3] ethdev: add common stats for telemetry Ciara Power
2020-09-23 11:12 ` [dpdk-dev] [PATCH v9 0/3] add basic ethdev stats with data object recursion Ciara Power
2020-09-23 11:12   ` [dpdk-dev] [PATCH v9 1/3] telemetry: support array values in data objects Ciara Power
2020-09-23 11:12   ` [dpdk-dev] [PATCH v9 2/3] test/test_telemetry_data: add unit tests for data to JSON Ciara Power
2020-09-23 11:12   ` [dpdk-dev] [PATCH v9 3/3] ethdev: add common stats for telemetry Ciara Power
2020-10-06 20:56   ` [dpdk-dev] [PATCH v9 0/3] add basic ethdev stats with data object recursion Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200715122935.1822-4-ciara.power@intel.com \
    --to=ciara.power@intel.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=keith.wiles@intel.com \
    --cc=kevin.laatz@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.