DPDK patches and discussions
 help / color / mirror / Atom feed
From: Naga Harish K S V <s.v.naga.harish.k@intel.com>
To: jerinj@marvell.com, jay.jayatheerthan@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/3] eventdev/eth_rx: support telemetry
Date: Wed, 27 Oct 2021 23:54:29 -0500	[thread overview]
Message-ID: <20211028045430.2989816-2-s.v.naga.harish.k@intel.com> (raw)
In-Reply-To: <20211028045430.2989816-1-s.v.naga.harish.k@intel.com>

Added telemetry support for rxa_queue_stats and
rxa_queue_stats_reset to get and reset rx queue
stats respectively

Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
---
 lib/eventdev/rte_event_eth_rx_adapter.c | 124 ++++++++++++++++++++++++
 1 file changed, 124 insertions(+)

diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index ec5b2ef7a6..fe71b0883e 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -3329,6 +3329,122 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
 	return 0;
 }
 
+static int
+handle_rxa_get_queue_stats(const char *cmd __rte_unused,
+			   const char *params,
+			   struct rte_tel_data *d)
+{
+	uint8_t rx_adapter_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id;
+	char *token, *l_params;
+	struct rte_event_eth_rx_adapter_queue_stats q_stats;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	/* Get Rx adapter ID from parameter string */
+	l_params = strdup(params);
+	token = strtok(l_params, ",");
+	rx_adapter_id = strtoul(token, NULL, 10);
+	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	if (token == NULL || strlen(token) == 0 || !isdigit(*token))
+		return -1;
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	if (token == NULL || strlen(token) == 0 || !isdigit(*token))
+		return -1;
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, igrnoring");
+
+	if (rte_event_eth_rx_adapter_queue_stats_get(rx_adapter_id, eth_dev_id,
+						    rx_queue_id, &q_stats)) {
+		RTE_EDEV_LOG_ERR("Failed to get Rx adapter queue stats");
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
+	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	RXA_ADD_DICT(q_stats, rx_event_buf_count);
+	RXA_ADD_DICT(q_stats, rx_event_buf_size);
+	RXA_ADD_DICT(q_stats, rx_poll_count);
+	RXA_ADD_DICT(q_stats, rx_packets);
+	RXA_ADD_DICT(q_stats, rx_dropped);
+
+	return 0;
+}
+
+static int
+handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
+			     const char *params,
+			     struct rte_tel_data *d __rte_unused)
+{
+	uint8_t rx_adapter_id;
+	uint16_t rx_queue_id;
+	int eth_dev_id;
+	char *token, *l_params;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	/* Get Rx adapter ID from parameter string */
+	l_params = strdup(params);
+	token = strtok(l_params, ",");
+	rx_adapter_id = strtoul(token, NULL, 10);
+	RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	if (token == NULL || strlen(token) == 0 || !isdigit(*token))
+		return -1;
+
+	/* Get device ID from parameter string */
+	eth_dev_id = strtoul(token, NULL, 10);
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(eth_dev_id, -EINVAL);
+
+	token = strtok(NULL, ",");
+	if (token == NULL || strlen(token) == 0 || !isdigit(*token))
+		return -1;
+
+	/* Get Rx queue ID from parameter string */
+	rx_queue_id = strtoul(token, NULL, 10);
+	if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+		RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+		return -EINVAL;
+	}
+
+	token = strtok(NULL, "\0");
+	if (token != NULL)
+		RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+				 " telemetry command, igrnoring");
+
+	if (rte_event_eth_rx_adapter_queue_stats_reset(rx_adapter_id,
+						       eth_dev_id,
+						       rx_queue_id)) {
+		RTE_EDEV_LOG_ERR("Failed to reset Rx adapter queue stats");
+		return -1;
+	}
+
+	return 0;
+}
+
 RTE_INIT(rxa_init_telemetry)
 {
 	rte_telemetry_register_cmd("/eventdev/rxa_stats",
@@ -3342,4 +3458,12 @@ RTE_INIT(rxa_init_telemetry)
 	rte_telemetry_register_cmd("/eventdev/rxa_queue_conf",
 		handle_rxa_get_queue_conf,
 		"Returns Rx queue config. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats",
+		handle_rxa_get_queue_stats,
+		"Returns Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
+
+	rte_telemetry_register_cmd("/eventdev/rxa_queue_stats_reset",
+		handle_rxa_queue_stats_reset,
+		"Reset Rx queue stats. Parameter: rxa_id, dev_id, queue_id");
 }
-- 
2.25.1


  reply	other threads:[~2021-10-28  4:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28  4:54 [dpdk-dev] [PATCH 1/3] eventdev/eth_rx: add queue stats get and reset APIs Naga Harish K S V
2021-10-28  4:54 ` Naga Harish K S V [this message]
2021-10-28  4:54 ` [dpdk-dev] [PATCH 3/3] test/event: add unit test for Rx adapter Naga Harish K S V
2021-10-28  6:55 ` [dpdk-dev] [PATCH v2 1/3] eventdev/eth_rx: add queue stats get and reset APIs Naga Harish K S V
2021-10-28  6:55   ` [dpdk-dev] [PATCH v2 2/3] eventdev/eth_rx: support telemetry Naga Harish K S V
2021-10-28  6:55   ` [dpdk-dev] [PATCH v2 3/3] test/event: add unit test for Rx adapter Naga Harish K S V
2021-10-28  7:06 ` [dpdk-dev] [PATCH v2 1/3] eventdev/eth_rx: add queue stats get and reset APIs Naga Harish K S V
2021-10-28  7:06   ` [dpdk-dev] [PATCH v2 2/3] eventdev/eth_rx: support telemetry Naga Harish K S V
2021-10-28  7:06   ` [dpdk-dev] [PATCH v2 3/3] test/event: add unit test for Rx adapter Naga Harish K S V
2021-10-28  8:10   ` [dpdk-dev] [PATCH v2 1/3] eventdev/eth_rx: add queue stats get and reset APIs Jayatheerthan, Jay
2021-10-28 10:27   ` [dpdk-dev] [PATCH v3 " Naga Harish K S V
2021-10-28 10:27     ` [dpdk-dev] [PATCH v3 2/3] eventdev/eth_rx: support telemetry Naga Harish K S V
2021-10-28 10:27     ` [dpdk-dev] [PATCH v3 3/3] test/event: add unit test for Rx adapter Naga Harish K S V
2021-11-02 11:00     ` [dpdk-dev] [PATCH v3 1/3] eventdev/eth_rx: add queue stats get and reset APIs Jerin Jacob
2021-10-28 10:37   ` Naga Harish K S V
2021-10-28 10:37     ` [dpdk-dev] [PATCH v3 2/3] eventdev/eth_rx: support telemetry Naga Harish K S V
2021-10-28 10:37     ` [dpdk-dev] [PATCH v3 3/3] test/event: add unit test for Rx adapter Naga Harish K S V

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=20211028045430.2989816-2-s.v.naga.harish.k@intel.com \
    --to=s.v.naga.harish.k@intel.com \
    --cc=dev@dpdk.org \
    --cc=jay.jayatheerthan@intel.com \
    --cc=jerinj@marvell.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).