anitazha / rpms / ndctl

Forked from rpms/ndctl a year ago
Clone

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

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