[v11,11/12] app/graph: support CLI option to enable graph stats

Message ID 20231019173011.1186656-12-skori@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series add CLI based graph application |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sunil Kumar Kori Oct. 19, 2023, 5:30 p.m. UTC
  From: Sunil Kumar Kori <skori@marvell.com>

Adds application's command line parameter "--enable-graph-stats"
to enable dumping graph stats on console.

By default, no graph stats will be printed on console but same can
be dumped via telnet session using "graph stats show" command.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 app/graph/main.c           | 17 ++++++++++++++++-
 app/graph/module_api.h     |  2 ++
 doc/guides/tools/graph.rst |  4 ++++
 3 files changed, 22 insertions(+), 1 deletion(-)
  

Comments

Nithin Dabilpuram Oct. 23, 2023, 7:06 a.m. UTC | #1
Acked-By: Nithin Dabilpuram <ndabilpuram@marvell.com>

On Fri, Oct 20, 2023 at 2:07 AM <skori@marvell.com> wrote:
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> Adds application's command line parameter "--enable-graph-stats"
> to enable dumping graph stats on console.
>
> By default, no graph stats will be printed on console but same can
> be dumped via telnet session using "graph stats show" command.
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Acked-by: Jerin Jacob <jerinj@marvell.com>
> ---
>  app/graph/main.c           | 17 ++++++++++++++++-
>  app/graph/module_api.h     |  2 ++
>  doc/guides/tools/graph.rst |  4 ++++
>  3 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/app/graph/main.c b/app/graph/main.c
> index c1cb435588..465376425c 100644
> --- a/app/graph/main.c
> +++ b/app/graph/main.c
> @@ -21,12 +21,13 @@
>  volatile bool force_quit;
>  struct conn *conn;
>
> -static const char usage[] = "%s EAL_ARGS -- -s SCRIPT [-h HOST] [-p PORT] "
> +static const char usage[] = "%s EAL_ARGS -- -s SCRIPT [-h HOST] [-p PORT] [--enable-graph-stats] "
>                             "[--help]\n";
>
>  static struct app_params {
>         struct conn_params conn;
>         char *script_name;
> +       bool enable_graph_stats;
>  } app = {
>         .conn = {
>                 .welcome = "\nWelcome!\n\n",
> @@ -40,6 +41,7 @@ static struct app_params {
>                 .msg_handle_arg = NULL, /* set later. */
>         },
>         .script_name = NULL,
> +       .enable_graph_stats = false,
>  };
>
>  static void
> @@ -56,6 +58,7 @@ app_args_parse(int argc, char **argv)
>  {
>         struct option lgopts[] = {
>                 {"help", 0, 0, 'H'},
> +               {"enable-graph-stats", 0, 0, 'g'},
>         };
>         int h_present, p_present, s_present, n_args, i;
>         char *app_name = argv[0];
> @@ -133,6 +136,12 @@ app_args_parse(int argc, char **argv)
>                         }
>                         break;
>
> +               case 'g':
> +                       app.enable_graph_stats = true;
> +                       printf("WARNING! Telnet session can not be accessed with"
> +                              "--enable-graph-stats");
> +                       break;
> +
>                 case 'H':
>                 default:
>                         printf(usage, app_name);
> @@ -144,6 +153,12 @@ app_args_parse(int argc, char **argv)
>         return 0;
>  }
>
> +bool
> +app_graph_stats_enabled(void)
> +{
> +       return app.enable_graph_stats;
> +}
> +
>  bool
>  app_graph_exit(void)
>  {
> diff --git a/app/graph/module_api.h b/app/graph/module_api.h
> index 392dcfb222..a7d287f5c8 100644
> --- a/app/graph/module_api.h
> +++ b/app/graph/module_api.h
> @@ -24,5 +24,7 @@
>  extern volatile bool force_quit;
>  extern struct conn *conn;
>
> +bool app_graph_stats_enabled(void);
>  bool app_graph_exit(void);
> +
>  #endif
> diff --git a/doc/guides/tools/graph.rst b/doc/guides/tools/graph.rst
> index 08ec57b7f8..bd8611a3d0 100644
> --- a/doc/guides/tools/graph.rst
> +++ b/doc/guides/tools/graph.rst
> @@ -55,6 +55,10 @@ Following are the application command-line options:
>          a mandatory parameter which will be used to create desired graph
>          for a given use case.
>
> +* ``--enable-graph-stats``
> +
> +       Enable graph statistics printing on console. By default graph statistics are disabled.
> +
>  * ``--help``
>
>         Dumps application usage
> --
> 2.25.1
>
  

Patch

diff --git a/app/graph/main.c b/app/graph/main.c
index c1cb435588..465376425c 100644
--- a/app/graph/main.c
+++ b/app/graph/main.c
@@ -21,12 +21,13 @@ 
 volatile bool force_quit;
 struct conn *conn;
 
-static const char usage[] = "%s EAL_ARGS -- -s SCRIPT [-h HOST] [-p PORT] "
+static const char usage[] = "%s EAL_ARGS -- -s SCRIPT [-h HOST] [-p PORT] [--enable-graph-stats] "
 			    "[--help]\n";
 
 static struct app_params {
 	struct conn_params conn;
 	char *script_name;
+	bool enable_graph_stats;
 } app = {
 	.conn = {
 		.welcome = "\nWelcome!\n\n",
@@ -40,6 +41,7 @@  static struct app_params {
 		.msg_handle_arg = NULL, /* set later. */
 	},
 	.script_name = NULL,
+	.enable_graph_stats = false,
 };
 
 static void
@@ -56,6 +58,7 @@  app_args_parse(int argc, char **argv)
 {
 	struct option lgopts[] = {
 		{"help", 0, 0, 'H'},
+		{"enable-graph-stats", 0, 0, 'g'},
 	};
 	int h_present, p_present, s_present, n_args, i;
 	char *app_name = argv[0];
@@ -133,6 +136,12 @@  app_args_parse(int argc, char **argv)
 			}
 			break;
 
+		case 'g':
+			app.enable_graph_stats = true;
+			printf("WARNING! Telnet session can not be accessed with"
+			       "--enable-graph-stats");
+			break;
+
 		case 'H':
 		default:
 			printf(usage, app_name);
@@ -144,6 +153,12 @@  app_args_parse(int argc, char **argv)
 	return 0;
 }
 
+bool
+app_graph_stats_enabled(void)
+{
+	return app.enable_graph_stats;
+}
+
 bool
 app_graph_exit(void)
 {
diff --git a/app/graph/module_api.h b/app/graph/module_api.h
index 392dcfb222..a7d287f5c8 100644
--- a/app/graph/module_api.h
+++ b/app/graph/module_api.h
@@ -24,5 +24,7 @@ 
 extern volatile bool force_quit;
 extern struct conn *conn;
 
+bool app_graph_stats_enabled(void);
 bool app_graph_exit(void);
+
 #endif
diff --git a/doc/guides/tools/graph.rst b/doc/guides/tools/graph.rst
index 08ec57b7f8..bd8611a3d0 100644
--- a/doc/guides/tools/graph.rst
+++ b/doc/guides/tools/graph.rst
@@ -55,6 +55,10 @@  Following are the application command-line options:
         a mandatory parameter which will be used to create desired graph
         for a given use case.
 
+* ``--enable-graph-stats``
+
+       Enable graph statistics printing on console. By default graph statistics are disabled.
+
 * ``--help``
 
        Dumps application usage