DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: jasvinder.singh@intel.com, yogesh.jangra@intel.com
Subject: [PATCH 19/21] net/softnic: add pipeline statistics CLI command
Date: Thu,  4 Aug 2022 16:58:37 +0000	[thread overview]
Message-ID: <20220804165839.1074817-20-cristian.dumitrescu@intel.com> (raw)
In-Reply-To: <20220804165839.1074817-1-cristian.dumitrescu@intel.com>

Add CLI command for pipeline statistics counters query.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_cli.c | 204 ++++++++++++++++++++++
 1 file changed, 204 insertions(+)

diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index 449e750e41..a391ce1139 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -1911,6 +1911,206 @@ cmd_softnic_pipeline_meter_stats(struct pmd_internals *softnic,
 	}
 }
 
+/**
+ * pipeline <pipeline_name> stats
+ */
+static void
+cmd_softnic_pipeline_stats(struct pmd_internals *softnic,
+	char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_swx_ctl_pipeline_info info;
+	struct pipeline *p;
+	uint32_t i;
+	int status;
+
+	if (n_tokens != 3) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	p = softnic_pipeline_find(softnic, tokens[1]);
+	if (!p) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name");
+		return;
+	}
+
+	if (strcmp(tokens[2], "stats")) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
+		return;
+	}
+
+	status = rte_swx_ctl_pipeline_info_get(p->p, &info);
+	if (status) {
+		snprintf(out, out_size, "Pipeline info get error.");
+		return;
+	}
+
+	snprintf(out, out_size, "Input ports:\n");
+	out_size -= strlen(out);
+	out += strlen(out);
+
+	for (i = 0; i < info.n_ports_in; i++) {
+		struct rte_swx_port_in_stats stats;
+
+		rte_swx_ctl_pipeline_port_in_stats_read(p->p, i, &stats);
+
+		snprintf(out, out_size, "\tPort %u:"
+			" packets %" PRIu64
+			" bytes %" PRIu64
+			" empty %" PRIu64 "\n",
+			i, stats.n_pkts, stats.n_bytes, stats.n_empty);
+		out_size -= strlen(out);
+		out += strlen(out);
+	}
+
+	snprintf(out, out_size, "\nOutput ports:\n");
+	out_size -= strlen(out);
+	out += strlen(out);
+
+	for (i = 0; i < info.n_ports_out; i++) {
+		struct rte_swx_port_out_stats stats;
+
+		rte_swx_ctl_pipeline_port_out_stats_read(p->p, i, &stats);
+
+		if (i != info.n_ports_out - 1)
+			snprintf(out, out_size, "\tPort %u:", i);
+		else
+			snprintf(out, out_size, "\tDROP:");
+
+		out_size -= strlen(out);
+		out += strlen(out);
+
+		snprintf(out,
+			out_size,
+			" packets %" PRIu64
+			" bytes %" PRIu64
+			" clone %" PRIu64
+			" clonerr %" PRIu64 "\n",
+			stats.n_pkts,
+			stats.n_bytes,
+			stats.n_pkts_clone,
+			stats.n_pkts_clone_err);
+
+		out_size -= strlen(out);
+		out += strlen(out);
+	}
+
+	snprintf(out, out_size, "\nTables:\n");
+	out_size -= strlen(out);
+	out += strlen(out);
+
+	for (i = 0; i < info.n_tables; i++) {
+		struct rte_swx_ctl_table_info table_info;
+		uint64_t n_pkts_action[info.n_actions];
+		struct rte_swx_table_stats stats = {
+			.n_pkts_hit = 0,
+			.n_pkts_miss = 0,
+			.n_pkts_action = n_pkts_action,
+		};
+		uint32_t j;
+
+		status = rte_swx_ctl_table_info_get(p->p, i, &table_info);
+		if (status) {
+			snprintf(out, out_size, "Table info get error.");
+			return;
+		}
+
+		status = rte_swx_ctl_pipeline_table_stats_read(p->p, table_info.name, &stats);
+		if (status) {
+			snprintf(out, out_size, "Table stats read error.");
+			return;
+		}
+
+		snprintf(out, out_size, "\tTable %s:\n"
+			"\t\tHit (packets): %" PRIu64 "\n"
+			"\t\tMiss (packets): %" PRIu64 "\n",
+			table_info.name,
+			stats.n_pkts_hit,
+			stats.n_pkts_miss);
+		out_size -= strlen(out);
+		out += strlen(out);
+
+		for (j = 0; j < info.n_actions; j++) {
+			struct rte_swx_ctl_action_info action_info;
+
+			status = rte_swx_ctl_action_info_get(p->p, j, &action_info);
+			if (status) {
+				snprintf(out, out_size, "Action info get error.");
+				return;
+			}
+
+			snprintf(out, out_size, "\t\tAction %s (packets): %" PRIu64 "\n",
+				action_info.name,
+				stats.n_pkts_action[j]);
+			out_size -= strlen(out);
+			out += strlen(out);
+		}
+	}
+
+	snprintf(out, out_size, "\nLearner tables:\n");
+	out_size -= strlen(out);
+	out += strlen(out);
+
+	for (i = 0; i < info.n_learners; i++) {
+		struct rte_swx_ctl_learner_info learner_info;
+		uint64_t n_pkts_action[info.n_actions];
+		struct rte_swx_learner_stats stats = {
+			.n_pkts_hit = 0,
+			.n_pkts_miss = 0,
+			.n_pkts_action = n_pkts_action,
+		};
+		uint32_t j;
+
+		status = rte_swx_ctl_learner_info_get(p->p, i, &learner_info);
+		if (status) {
+			snprintf(out, out_size, "Learner table info get error.");
+			return;
+		}
+
+		status = rte_swx_ctl_pipeline_learner_stats_read(p->p, learner_info.name, &stats);
+		if (status) {
+			snprintf(out, out_size, "Learner table stats read error.");
+			return;
+		}
+
+		snprintf(out, out_size, "\tLearner table %s:\n"
+			"\t\tHit (packets): %" PRIu64 "\n"
+			"\t\tMiss (packets): %" PRIu64 "\n"
+			"\t\tLearn OK (packets): %" PRIu64 "\n"
+			"\t\tLearn error (packets): %" PRIu64 "\n"
+			"\t\tRearm (packets): %" PRIu64 "\n"
+			"\t\tForget (packets): %" PRIu64 "\n",
+			learner_info.name,
+			stats.n_pkts_hit,
+			stats.n_pkts_miss,
+			stats.n_pkts_learn_ok,
+			stats.n_pkts_learn_err,
+			stats.n_pkts_rearm,
+			stats.n_pkts_forget);
+		out_size -= strlen(out);
+		out += strlen(out);
+
+		for (j = 0; j < info.n_actions; j++) {
+			struct rte_swx_ctl_action_info action_info;
+
+			status = rte_swx_ctl_action_info_get(p->p, j, &action_info);
+			if (status) {
+				snprintf(out, out_size, "Action info get error.");
+				return;
+			}
+
+			snprintf(out, out_size, "\t\tAction %s (packets): %" PRIu64 "\n",
+				action_info.name,
+				stats.n_pkts_action[j]);
+			out_size -= strlen(out);
+			out += strlen(out);
+		}
+	}
+}
+
 /**
  * thread <thread_id> pipeline <pipeline_name> enable [ period <timer_period_ms> ]
  */
@@ -2191,6 +2391,10 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg)
 			return;
 		}
 
+		if ((n_tokens >= 3) && !strcmp(tokens[2], "stats")) {
+			cmd_softnic_pipeline_stats(softnic, tokens, n_tokens, out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
-- 
2.34.1


  parent reply	other threads:[~2022-08-04 17:01 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 16:58 [PATCH 00/21] net/softnic: replace the legacy pipeline with SWX pipeline Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 01/21] net/softnic: remove the traffic manager support Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 02/21] net/softnic: remove flow support Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 03/21] net/softnic: remove the meter support Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 04/21] net/softnic: remove cryptodev support Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 05/21] net/softnic: remove tap support Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 06/21] net/softnic: remove the legacy pipeline CLI commands Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 07/21] net/softnic: replace the legacy pipeline with the SWX pipeline Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 08/21] net/softnic: remove the list of Ethernet devices Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 09/21] net/softnic: remove unused text parsing functions Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 10/21] net/softnic: add pipeline code generation CLI command Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 11/21] net/softnic: add pipeline library build " Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 12/21] net/softnic: add pipeline " Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 13/21] net/softnic: add pipeline table CLI commands Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 14/21] net/softnic: add pipeline selector " Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 15/21] net/softnic: add pipeline learner " Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 16/21] net/softnic: add pipeline commit and abort " Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 17/21] net/softnic: add the pipeline register read/write " Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 18/21] net/softnic: add the pipeline meter " Cristian Dumitrescu
2022-08-04 16:58 ` Cristian Dumitrescu [this message]
2022-08-04 16:58 ` [PATCH 20/21] net/softnic: add pipeline mirroring CLI command Cristian Dumitrescu
2022-08-04 16:58 ` [PATCH 21/21] net/softnic: update the default device program Cristian Dumitrescu
2022-08-26 13:17 ` [PATCH V2 00/21] net/softnic: replace the legacy pipeline with SWX pipeline Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 01/21] net/softnic: remove the traffic manager support Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 02/21] net/softnic: remove flow support Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 03/21] net/softnic: remove the meter support Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 04/21] net/softnic: remove cryptodev support Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 05/21] net/softnic: remove tap support Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 06/21] net/softnic: remove the legacy pipeline CLI commands Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 07/21] net/softnic: replace the legacy pipeline with the SWX pipeline Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 08/21] net/softnic: remove the list of Ethernet devices Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 09/21] net/softnic: remove unused text parsing functions Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 10/21] net/softnic: add pipeline code generation CLI command Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 11/21] net/softnic: add pipeline library build " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 12/21] net/softnic: add pipeline " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 13/21] net/softnic: add pipeline table CLI commands Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 14/21] net/softnic: add pipeline selector " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 15/21] net/softnic: add pipeline learner " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 16/21] net/softnic: add pipeline commit and abort " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 17/21] net/softnic: add the pipeline register read/write " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 18/21] net/softnic: add the pipeline meter " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 19/21] net/softnic: add pipeline statistics CLI command Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 20/21] net/softnic: add pipeline mirroring " Cristian Dumitrescu
2022-08-26 13:17   ` [PATCH V2 21/21] net/softnic: update the default device program Cristian Dumitrescu
2022-09-01 14:20 ` [PATCH V3 00/21] net/softnic: replace the legacy pipeline with SWX pipeline Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 01/21] net/softnic: remove the traffic manager support Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 02/21] net/softnic: remove flow support Cristian Dumitrescu
2022-11-30 11:18     ` Ferruh Yigit
2022-12-01 11:27       ` Dumitrescu, Cristian
2022-09-01 14:20   ` [PATCH V3 03/21] net/softnic: remove the meter support Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 04/21] net/softnic: remove cryptodev support Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 05/21] net/softnic: remove tap support Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 06/21] net/softnic: remove the legacy pipeline CLI commands Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 07/21] net/softnic: replace the legacy pipeline with the SWX pipeline Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 08/21] net/softnic: remove the list of Ethernet devices Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 09/21] net/softnic: remove unused text parsing functions Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 10/21] net/softnic: add pipeline code generation CLI command Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 11/21] net/softnic: add pipeline library build " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 12/21] net/softnic: add pipeline " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 13/21] net/softnic: add pipeline table CLI commands Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 14/21] net/softnic: add pipeline selector " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 15/21] net/softnic: add pipeline learner " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 16/21] net/softnic: add pipeline commit and abort " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 17/21] net/softnic: add the pipeline register read/write " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 18/21] net/softnic: add the pipeline meter " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 19/21] net/softnic: add pipeline statistics CLI command Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 20/21] net/softnic: add pipeline mirroring " Cristian Dumitrescu
2022-09-01 14:20   ` [PATCH V3 21/21] net/softnic: update the default device program Cristian Dumitrescu
2022-09-21 11:48   ` [PATCH V3 00/21] net/softnic: replace the legacy pipeline with SWX pipeline 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=20220804165839.1074817-20-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasvinder.singh@intel.com \
    --cc=yogesh.jangra@intel.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).