Skip to contentSkip to conversation

cxl: Add list verbose option to the cxl command

PATCH Superseded [email protected] 3 participants 4 messages Jul 21, 2022 – Jul 22, 2022 Documentation

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cxl: Add list verbose option to the cxl command

From: Matthew Ho <[email protected]>

This adds the new subcommands cxl list -v, cxl list -vv, and cxl list -vvv, and builds on this pending patch series that adds region listing support:

https://lore.kernel.org/linux-cxl/[email protected]/

cxl list -v is now equivalent to cxl list -RMBDPT, cxl list -vv is equivalent to cxl list -RMBDPTi, and cxl list -vvv is equivalent to cxl list -RMBDPTiHI. These additions make it easier to list all of the CXL devices without having to remember which subcommand must be appended for each type of device.

---

Changes since v1 (previously titled "Add list all option to the cxl command"):
- cxl list -v, cxl list -vv, cxl list -vvv replace cxl list --all, providing greater control over detail of the output. --human has been excluded as it can be appended by the user.

 Documentation/cxl/cxl-list.txt | 20 ++++++++++++++++++++
 cxl/filter.h                   |  1 +
 cxl/list.c                     | 17 +++++++++++++++++
 3 files changed, 38 insertions(+)
Documentation/cxl/cxl-list.txt +20 -0
index 2906c2f6ef4b..f069aee8c674 100644
@@ -336,6 +336,26 @@ OPTIONS
 --region::
 	Specify the region name to filter the emitted regions.
 
+-v::
+--verbose::
+	Increase verbosity of the output. This can be specified
+	multiple times to be even more verbose on the
+	informational and miscellaneous output, and can be used
+	to override omitted flags for showing specific
+	information. Note that cxl list --verbose --verbose is
+	equivalent to cxl list -vv, and likewise
+	cxl list --verbose --verbose --verbose is equivalent to
+	cxl list -vvv.
+	- *-v*
+	  Automatically enable --memdevs, --regions, --buses,
+	  --ports, --decoders, --targets.
+	- *-vv*
+	  Everything *-v* provides, plus automatically include
+	  disabled devices with --idle.
+	- *-vvv*
+	  Everything *-vv* provides, plus automatically enable
+	  --health and --partition.
+
 --debug::
 	If the cxl tool was built with debug enabled, turn on debug
 	messages.
cxl/filter.h +1 -0
index d22d8b1f798b..256df49c3d0c 100644
@@ -26,6 +26,7 @@ struct cxl_filter_params {
 	bool human;
 	bool health;
 	bool partition;
+	int verbose;
 	struct log_ctx ctx;
 };
 
cxl/list.c +17 -0
index 5f604ecddf3c..4763c7c36024 100644
@@ -52,6 +52,8 @@ static const struct option options[] = {
 		    "include memory device health information"),
 	OPT_BOOLEAN('I', "partition", &param.partition,
 		    "include memory device partition information"),
+	OPT_INCR('v', "verbose", &param.verbose,
+		 "increase output detail"),
 #ifdef ENABLE_DEBUG
 	OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
 #endif
@@ -106,6 +108,21 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
 		param.memdevs = true;
 	}
 
+	switch (param.verbose){
+	default:
+		break;
+	case 3:
+		param.health = true;
+		param.partition = true;
+	case 2:
+		param.idle = true;
+	case 1:
+		param.buses = true;
+		param.ports = true;
+		param.decoders = true;
+		param.targets = true;
+	}
+
 	log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
 	if (debug) {
 		cxl_set_log_priority(ctx, LOG_DEBUG);

--
2.34.1

Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · On Thu, 21 Jul 2022, [email protected] wrote:

From: Matthew Ho <[email protected]>

This adds the new subcommands cxl list -v, cxl list -vv, and cxl list -vvv, and builds on this pending patch series that adds region listing support:

https://lore.kernel.org/linux-cxl/[email protected]/

Quoted 8 lines

cxl list -v is now equivalent to cxl list -RMBDPT, cxl list -vv is equivalent to cxl list -RMBDPTi, and cxl list -vvv is equivalent to cxl list -RMBDPTiHI. These additions make it easier to list all of the CXL devices without having to remember which subcommand must be appended for each type of device.

With the exception of the switch() handling (see below).

Quoted 77 lines

---

Changes since v1 (previously titled "Add list all option to the cxl command"):
- cxl list -v, cxl list -vv, cxl list -vvv replace cxl list --all, providing greater control over detail of the output. --human has been excluded as it can be appended by the user.

Documentation/cxl/cxl-list.txt | 20 ++++++++++++++++++++
cxl/filter.h                   |  1 +
cxl/list.c                     | 17 +++++++++++++++++
3 files changed, 38 insertions(+)
Documentation/cxl/cxl-list.txt +20 -2
index 2906c2f6ef4b..f069aee8c674 100644
@@ -336,6 +336,26 @@ OPTIONS
--region::
 	Specify the region name to filter the emitted regions.
 
+-v::
+--verbose::
+	Increase verbosity of the output. This can be specified
+	multiple times to be even more verbose on the
+	informational and miscellaneous output, and can be used
+	to override omitted flags for showing specific
+	information. Note that cxl list --verbose --verbose is
+	equivalent to cxl list -vv, and likewise
+	cxl list --verbose --verbose --verbose is equivalent to
+	cxl list -vvv.
+	- *-v*
+	  Automatically enable --memdevs, --regions, --buses,
+	  --ports, --decoders, --targets.
+	- *-vv*
+	  Everything *-v* provides, plus automatically include
+	  disabled devices with --idle.
+	- *-vvv*
+	  Everything *-vv* provides, plus automatically enable
+	  --health and --partition.
+
--debug::
 	If the cxl tool was built with debug enabled, turn on debug
 	messages.
cxl/filter.h +1 -0
index d22d8b1f798b..256df49c3d0c 100644
@@ -26,6 +26,7 @@ struct cxl_filter_params {
 	bool human;
 	bool health;
 	bool partition;
+	int verbose;
 	struct log_ctx ctx;
 };
 
cxl/list.c +7 -0
index 5f604ecddf3c..4763c7c36024 100644
@@ -52,6 +52,8 @@ static const struct option options[] = {
 		    "include memory device health information"),
 	OPT_BOOLEAN('I', "partition", &param.partition,
 		    "include memory device partition information"),
+	OPT_INCR('v', "verbose", &param.verbose,
+		 "increase output detail"),
 #ifdef ENABLE_DEBUG
 	OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
 #endif
@@ -106,6 +108,21 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
 		param.memdevs = true;
 	}
 
+	switch (param.verbose){
+	default:
+		break;
+	case 3:
+		param.health = true;

cxl/list.c int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) · line 125

Quoted 10 lines
cxl/list.c +10 -0
+		param.partition = true;
+	case 2:
+		param.idle = true;
+	case 1:
+		param.buses = true;
+		param.ports = true;
+		param.decoders = true;
+		param.targets = true;
+	}
+

I think you want this:

    switch(param.verbose) {
    default:
    case 3:
	 ...
    case 2:
	 ...
    case 1:
	 ....
    case 0:
	 break;
    }
Quoted 6 lines
cxl/list.c +0 -1
 	log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
 	if (debug) {
 		cxl_set_log_priority(ctx, LOG_DEBUG);
--

2.34.1

Reviewed-by on v2 1/1
#2 lore raw
In reply to [email protected]
Quoted 5 lines · sunfishho12@ wrote:

From: Matthew Ho <[email protected]>

This adds the new subcommands cxl list -v, cxl list -vv, and cxl list -vvv, and builds on this pending patch series that adds region listing support:

Quoted 7 lines

https://lore.kernel.org/linux-cxl/[email protected]/

cxl list -v is now equivalent to cxl list -RMBDPT, cxl list -vv is equivalent to cxl list -RMBDPTi, and cxl list -vvv is equivalent to cxl list -RMBDPTiHI. These additions make it easier to list all of the CXL devices without having to remember which subcommand must be appended for each type of device.

Looks good, minor comments below that after addressing you can add:

Quoted 32 lines

---

Changes since v1 (previously titled "Add list all option to the cxl command"):
- cxl list -v, cxl list -vv, cxl list -vvv replace cxl list --all, providing greater control over detail of the output. --human has been excluded as it can be appended by the user.

 Documentation/cxl/cxl-list.txt | 20 ++++++++++++++++++++
 cxl/filter.h                   |  1 +
 cxl/list.c                     | 17 +++++++++++++++++
 3 files changed, 38 insertions(+)
Documentation/cxl/cxl-list.txt +9 -0
index 2906c2f6ef4b..f069aee8c674 100644
@@ -336,6 +336,26 @@ OPTIONS
 --region::
 	Specify the region name to filter the emitted regions.
 
+-v::
+--verbose::
+	Increase verbosity of the output. This can be specified
+	multiple times to be even more verbose on the
+	informational and miscellaneous output, and can be used
+	to override omitted flags for showing specific
+	information. Note that cxl list --verbose --verbose is
+	equivalent to cxl list -vv, and likewise
+	cxl list --verbose --verbose --verbose is equivalent to

Documentation/cxl/cxl-list.txt OPTIONS · line 357

Quoted 10 lines
Documentation/cxl/cxl-list.txt +10 -0
+	cxl list -vvv.
+	- *-v*
+	  Automatically enable --memdevs, --regions, --buses,
+	  --ports, --decoders, --targets.
+	- *-vv*
+	  Everything *-v* provides, plus automatically include
+	  disabled devices with --idle.
+	- *-vvv*
+	  Everything *-vv* provides, plus automatically enable
+	  --health and --partition.

These descriptions can drop the word "automatically" without any loss of clarity.

Quoted 30 lines
Documentation/cxl/cxl-list.txt +1 -0
+
 --debug::
 	If the cxl tool was built with debug enabled, turn on debug
 	messages.
cxl/filter.h +1 -0
index d22d8b1f798b..256df49c3d0c 100644
@@ -26,6 +26,7 @@ struct cxl_filter_params {
 	bool human;
 	bool health;
 	bool partition;
+	int verbose;
 	struct log_ctx ctx;
 };
 
cxl/list.c +2 -0
index 5f604ecddf3c..4763c7c36024 100644
@@ -52,6 +52,8 @@ static const struct option options[] = {
 		    "include memory device health information"),
 	OPT_BOOLEAN('I', "partition", &param.partition,
 		    "include memory device partition information"),
+	OPT_INCR('v', "verbose", &param.verbose,
+		 "increase output detail"),
 #ifdef ENABLE_DEBUG
 	OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
 #endif

cxl/list.c int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) · line 116

Quoted 9 lines
cxl/list.c +6 -0
@@ -106,6 +108,21 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
 		param.memdevs = true;
 	}
 
+	switch (param.verbose){
+	default:
+		break;
+	case 3:
+		param.health = true;
+		param.partition = true;

add a "/* fallthrough */;" statement here...

cxl/list.c int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) · line 118

Quoted 2 lines
cxl/list.c +2 -0
+	case 2:
+		param.idle = true;

...and here.

cxl/list.c int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) · line 123

Quoted 5 lines
cxl/list.c +5 -0
+	case 1:
+		param.buses = true;
+		param.ports = true;
+		param.decoders = true;
+		param.targets = true;

...and a "break;" here just because the ndctl project tries to follow kernel C-style.

Quoted 8 lines
cxl/list.c +2 -1
+	}
+
 	log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
 	if (debug) {
 		cxl_set_log_priority(ctx, LOG_DEBUG);
--

2.34.1

author
#3 lore raw
Quoted 54 lines · Dan Williams
Quoted 5 lines · sunfishho12@ wrote:

From: Matthew Ho <[email protected]>

This adds the new subcommands cxl list -v, cxl list -vv, and cxl list -vvv, and builds on this pending patch series that adds region listing support:

Quoted 7 lines

https://lore.kernel.org/linux-cxl/[email protected]/

cxl list -v is now equivalent to cxl list -RMBDPT, cxl list -vv is equivalent to cxl list -RMBDPTi, and cxl list -vvv is equivalent to cxl list -RMBDPTiHI. These additions make it easier to list all of the CXL devices without having to remember which subcommand must be appended for each type of device.

Looks good, minor comments below that after addressing you can add:

Quoted 36 lines

---

Changes since v1 (previously titled "Add list all option to the cxl command"):
- cxl list -v, cxl list -vv, cxl list -vvv replace cxl list --all, providing greater control over detail of the output. --human has been excluded as it can be appended by the user.

 Documentation/cxl/cxl-list.txt | 20 ++++++++++++++++++++
 cxl/filter.h                   |  1 +
 cxl/list.c                     | 17 +++++++++++++++++
 3 files changed, 38 insertions(+)
Documentation/cxl/cxl-list.txt +13 -0
index 2906c2f6ef4b..f069aee8c674 100644
@@ -336,6 +336,26 @@ OPTIONS
 --region::
 	Specify the region name to filter the emitted regions.
 
+-v::
+--verbose::
+	Increase verbosity of the output. This can be specified
+	multiple times to be even more verbose on the
+	informational and miscellaneous output, and can be used
+	to override omitted flags for showing specific
+	information. Note that cxl list --verbose --verbose is
+	equivalent to cxl list -vv, and likewise
+	cxl list --verbose --verbose --verbose is equivalent to
+	cxl list -vvv.
+	- *-v*
+	  Automatically enable --memdevs, --regions, --buses,
+	  --ports, --decoders, --targets.
Quoted 9 lines

Documentation/cxl/cxl-list.txt OPTIONS · line 357

Quoted 6 lines
Documentation/cxl/cxl-list.txt +6 -0
+	- *-vv*
+	  Everything *-v* provides, plus automatically include
+	  disabled devices with --idle.
+	- *-vvv*
+	  Everything *-vv* provides, plus automatically enable
+	  --health and --partition.

These descriptions can drop the word "automatically" without any loss of clarity.

Sounds good, will drop that in a follow up patch.

Quoted 47 lines
Quoted 30 lines
Documentation/cxl/cxl-list.txt +1 -0
+
 --debug::
 	If the cxl tool was built with debug enabled, turn on debug
 	messages.
cxl/filter.h +1 -0
index d22d8b1f798b..256df49c3d0c 100644
@@ -26,6 +26,7 @@ struct cxl_filter_params {
 	bool human;
 	bool health;
 	bool partition;
+	int verbose;
 	struct log_ctx ctx;
 };
 
cxl/list.c +2 -0
index 5f604ecddf3c..4763c7c36024 100644
@@ -52,6 +52,8 @@ static const struct option options[] = {
 		    "include memory device health information"),
 	OPT_BOOLEAN('I', "partition", &param.partition,
 		    "include memory device partition information"),
+	OPT_INCR('v', "verbose", &param.verbose,
+		 "increase output detail"),
 #ifdef ENABLE_DEBUG
 	OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
 #endif

cxl/list.c int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) · line 116

Quoted 9 lines
cxl/list.c +6 -0
@@ -106,6 +108,21 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
 		param.memdevs = true;
 	}
 
+	switch (param.verbose){
+	default:
+		break;
+	case 3:
+		param.health = true;
+		param.partition = true;

add a "/* fallthrough */;" statement here...

cxl/list.c int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) · line 118

Quoted 2 lines
cxl/list.c +2 -0
+	case 2:
+		param.idle = true;

...and here.

Quoted 9 lines

cxl/list.c int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) · line 123

Quoted 5 lines
cxl/list.c +5 -0
+	case 1:
+		param.buses = true;
+		param.ports = true;
+		param.decoders = true;
+		param.targets = true;

...and a "break;" here just because the ndctl project tries to follow kernel C-style.

Will combine this with David's suggestion to add a "case 0:", thanks for the feedback.

Best,
Matthew

Quoted 10 lines
Quoted 8 lines
cxl/list.c +2 -1
+	}
+
 	log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
 	if (debug) {
 		cxl_set_log_priority(ctx, LOG_DEBUG);
--

2.34.1