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

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