Blame SOURCES/0200-cxl-Add-list-verbose-option-to-the-cxl-command.patch

2eb93d
From 8b61e8e75443d79d22bf6e74e6b0e36acdd605c3 Mon Sep 17 00:00:00 2001
2eb93d
From: Matthew Ho <sunfishho12@gmail.com>
2eb93d
Date: Fri, 12 Aug 2022 15:15:53 -0700
2eb93d
Subject: [PATCH 200/217] cxl: Add list verbose option to the cxl command
2eb93d
2eb93d
This adds the new subcommands cxl list -v, cxl list -vv, and cxl list -vvv.
2eb93d
2eb93d
cxl list -v is now equivalent to cxl list -RMBDPT, cxl list -vv is
2eb93d
equivalent to cxl list -RMBDPTi, and cxl list -vvv is equivalent to
2eb93d
cxl list -RMBDPTiHI. These additions make it easier to list all of the CXL
2eb93d
devices without having to remember which subcommand must be appended for each
2eb93d
type of device.
2eb93d
2eb93d
Link: https://lore.kernel.org/r/20220812221553.92278-1-sunfishho12@gmail.com
2eb93d
Reviewed-by: Adam Manzanares <a.manzanares@samsung.com>
2eb93d
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
2eb93d
Acked-by: Davidlohr Bueso <dave@stgolabs.net>
2eb93d
Signed-off-by: Matthew Ho <sunfishho12@gmail.com>
2eb93d
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
---
2eb93d
 Documentation/cxl/cxl-list.txt | 18 ++++++++++++++++++
2eb93d
 cxl/filter.h                   |  1 +
2eb93d
 cxl/list.c                     | 21 +++++++++++++++++++++
2eb93d
 3 files changed, 40 insertions(+)
2eb93d
2eb93d
diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt
2eb93d
index b88940a..14a2b4b 100644
2eb93d
--- a/Documentation/cxl/cxl-list.txt
2eb93d
+++ b/Documentation/cxl/cxl-list.txt
2eb93d
@@ -344,6 +344,24 @@ OPTIONS
2eb93d
 --region::
2eb93d
 	Specify CXL region device name(s), or device id(s), to filter the listing.
2eb93d
 
2eb93d
+-v::
2eb93d
+--verbose::
2eb93d
+	Increase verbosity of the output. This can be specified
2eb93d
+	multiple times to be even more verbose on the
2eb93d
+	informational and miscellaneous output, and can be used
2eb93d
+	to override omitted flags for showing specific
2eb93d
+	information. Note that cxl list --verbose --verbose is
2eb93d
+	equivalent to cxl list -vv.
2eb93d
+	- *-v*
2eb93d
+	  Enable --memdevs, --regions, --buses,
2eb93d
+	  --ports, --decoders, and --targets.
2eb93d
+	- *-vv*
2eb93d
+	  Everything *-v* provides, plus include disabled
2eb93d
+	  devices with --idle.
2eb93d
+	- *-vvv*
2eb93d
+	  Everything *-vv* provides, plus enable
2eb93d
+	  --health and --partition.
2eb93d
+
2eb93d
 --debug::
2eb93d
 	If the cxl tool was built with debug enabled, turn on debug
2eb93d
 	messages.
2eb93d
diff --git a/cxl/filter.h b/cxl/filter.h
2eb93d
index d22d8b1..256df49 100644
2eb93d
--- a/cxl/filter.h
2eb93d
+++ b/cxl/filter.h
2eb93d
@@ -26,6 +26,7 @@ struct cxl_filter_params {
2eb93d
 	bool human;
2eb93d
 	bool health;
2eb93d
 	bool partition;
2eb93d
+	int verbose;
2eb93d
 	struct log_ctx ctx;
2eb93d
 };
2eb93d
 
2eb93d
diff --git a/cxl/list.c b/cxl/list.c
2eb93d
index 5f604ec..8c48fbb 100644
2eb93d
--- a/cxl/list.c
2eb93d
+++ b/cxl/list.c
2eb93d
@@ -52,6 +52,8 @@ static const struct option options[] = {
2eb93d
 		    "include memory device health information"),
2eb93d
 	OPT_BOOLEAN('I', "partition", &param.partition,
2eb93d
 		    "include memory device partition information"),
2eb93d
+	OPT_INCR('v', "verbose", &param.verbose,
2eb93d
+		 "increase output detail"),
2eb93d
 #ifdef ENABLE_DEBUG
2eb93d
 	OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
2eb93d
 #endif
2eb93d
@@ -106,6 +108,25 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
2eb93d
 		param.memdevs = true;
2eb93d
 	}
2eb93d
 
2eb93d
+	switch(param.verbose){
2eb93d
+	default:
2eb93d
+	case 3:
2eb93d
+		param.health = true;
2eb93d
+		param.partition = true;
2eb93d
+		/* fallthrough */
2eb93d
+	case 2:
2eb93d
+		param.idle = true;
2eb93d
+		/* fallthrough */
2eb93d
+	case 1:
2eb93d
+		param.buses = true;
2eb93d
+		param.ports = true;
2eb93d
+		param.decoders = true;
2eb93d
+		param.targets = true;
2eb93d
+		/*fallthrough*/
2eb93d
+	case 0:
2eb93d
+		break;
2eb93d
+	}
2eb93d
+
2eb93d
 	log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
2eb93d
 	if (debug) {
2eb93d
 		cxl_set_log_priority(ctx, LOG_DEBUG);
2eb93d
-- 
2eb93d
2.27.0
2eb93d