[v9,4/6] app/procinfo: add support for debug ring

Message ID 20190110213645.29901-5-vipin.varghese@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series app/proc-info: enhance debug of proc-info tool |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Varghese, Vipin Jan. 10, 2019, 9:36 p.m. UTC
  Function show_ring is used for displaying information of RING instance
of the primary process.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
Acked-by: Reshma  Pattan <reshma.pattan@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
---
 app/proc-info/main.c           | 52 +++++++++++++++++++++++++++++++++-
 doc/guides/tools/proc_info.rst |  8 +++++-
 2 files changed, 58 insertions(+), 2 deletions(-)
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 4f625a371..ed136d828 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -82,6 +82,9 @@  static uint32_t enable_shw_port;
 static uint32_t enable_shw_tm;
 /**< Enable show crypto. */
 static uint32_t enable_shw_crypto;
+/**< Enable show ring. */
+static uint32_t enable_shw_ring;
+static char *ring_name;
 
 /**< display usage */
 static void
@@ -104,7 +107,8 @@  proc_info_usage(const char *prgname)
 		"  --host-id STRING: host id used to identify the system process is running on\n"
 		"  --show-port: to display ports information\n"
 		"  --show-tm: to display traffic manager information for ports\n"
-		"  --show-crypto: to display crypto information\n",
+		"  --show-crypto: to display crypto information\n"
+		"  --show-ring[=name]: to display ring information\n",
 		prgname);
 }
 
@@ -214,6 +218,7 @@  proc_info_parse_args(int argc, char **argv)
 		{"show-port", 0, NULL, 0},
 		{"show-tm", 0, NULL, 0},
 		{"show-crypto", 0, NULL, 0},
+		{"show-ring", optional_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -266,6 +271,11 @@  proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-crypto", MAX_LONG_OPT_SZ))
 				enable_shw_crypto = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"show-ring", MAX_LONG_OPT_SZ)) {
+				enable_shw_ring = 1;
+				ring_name = optarg;
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1070,6 +1080,44 @@  show_crypto(void)
 	STATS_BDR_STR(50, "");
 }
 
+static void
+show_ring(char *name)
+{
+	snprintf(bdr_str, MAX_STRING_LEN, " show - RING %"PRIu64,
+			rte_get_tsc_hz());
+	STATS_BDR_STR(10, bdr_str);
+
+	if (name != NULL) {
+		struct rte_ring *ptr = rte_ring_lookup(name);
+		if (ptr != NULL) {
+			printf("  - Name (%s) on socket (%d)\n"
+				"  - flags:\n"
+				"\t  -- Single Producer Enqueue (%u)\n"
+				"\t  -- Single Consmer Dequeue (%u)\n",
+				ptr->name,
+				ptr->memzone->socket_id,
+				ptr->flags & RING_F_SP_ENQ,
+				ptr->flags & RING_F_SC_DEQ);
+			printf("  - size (%u) mask (0x%x) capacity (%u)\n",
+				ptr->size,
+				ptr->mask,
+				ptr->capacity);
+			printf("  - count (%u) free count (%u)\n",
+				rte_ring_count(ptr),
+				rte_ring_free_count(ptr));
+			printf("  - full (%d) empty (%d)\n",
+				rte_ring_full(ptr),
+				rte_ring_empty(ptr));
+
+			STATS_BDR_STR(50, "");
+			return;
+		}
+	}
+
+	rte_ring_list_dump(stdout);
+	STATS_BDR_STR(50, "");
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1157,6 +1205,8 @@  main(int argc, char **argv)
 		show_tm();
 	if (enable_shw_crypto)
 		show_crypto();
+	if (enable_shw_ring)
+		show_ring(ring_name);
 
 	ret = rte_eal_cleanup();
 	if (ret)
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index 883864d18..ba5c3dbd1 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -18,7 +18,8 @@  The application has a number of command line options:
 .. code-block:: console
 
    ./$(RTE_TARGET)/app/dpdk-procinfo -- -m | [-p PORTMASK] [--stats | --xstats |
-   --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto ]
+   --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto |
+   --show-ring[=name] ]
 
 Parameters
 ~~~~~~~~~~
@@ -54,6 +55,11 @@  configurations and statistics.
 The show-crypto parameter displays available cryptodev configurations,
 settings and stats per node.
 
+**--show-ring[=name]**
+The show-ring pararmeter display current allocation of all ring with
+debug information. Specifying the name allows to display details for specific
+ring. For invalid or no ring name, whole list is dump.
+
 Limitations
 -----------