ndctl/0104-cxl-list-Add-debug-opt...

104 lines
3.1 KiB
Diff

From 2a43dce3913b392a13a5ee918c8ee831a25d720e Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.williams@intel.com>
Date: Sun, 23 Jan 2022 16:53:24 -0800
Subject: [PATCH 104/217] cxl/list: Add --debug option
Add an option to turn on libray and cxl_filter_walk() messages. Gate it
based on the global ENABLE_DEBUG configuration setting.
Link: https://lore.kernel.org/r/164298560409.3021641.11040422738199381922.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
Documentation/cxl/cxl-list.txt | 6 ++++--
cxl/filter.c | 3 +++
cxl/list.c | 9 +++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt
index 3076deb..42b6de6 100644
--- a/Documentation/cxl/cxl-list.txt
+++ b/Documentation/cxl/cxl-list.txt
@@ -200,9 +200,11 @@ OPTIONS
descendants of the individual ports that match the filter. By default
all descendant objects are listed.
-include::human-option.txt[]
+--debug::
+ If the cxl tool was built with debug enabled, turn on debug
+ messages.
-include::verbose-option.txt[]
+include::human-option.txt[]
include::../copyright.txt[]
diff --git a/cxl/filter.c b/cxl/filter.c
index 8b79db3..32171a4 100644
--- a/cxl/filter.c
+++ b/cxl/filter.c
@@ -387,6 +387,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
if (!jports)
goto err;
+ dbg(p, "walk memdevs\n");
cxl_memdev_foreach(ctx, memdev) {
struct json_object *jdev;
@@ -403,6 +404,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
}
}
+ dbg(p, "walk buses\n");
cxl_bus_foreach(ctx, bus) {
struct json_object *jbus = NULL;
struct json_object *jchildports = NULL;
@@ -431,6 +433,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
}
}
walk_children:
+ dbg(p, "walk ports\n");
walk_child_ports(port, p, pick_array(jchildports, jports),
flags);
cond_add_put_array_suffix(jbus, "ports", devname, jchildports);
diff --git a/cxl/list.c b/cxl/list.c
index 1ef91b4..01ab19b 100644
--- a/cxl/list.c
+++ b/cxl/list.c
@@ -13,6 +13,7 @@
#include "filter.h"
static struct cxl_filter_params param;
+static bool debug;
static const struct option options[] = {
OPT_STRING('m', "memdev", &param.memdev_filter, "memory device name(s)",
@@ -35,6 +36,9 @@ static const struct option options[] = {
"use human friendly number formats "),
OPT_BOOLEAN('H', "health", &param.health,
"include memory device health information "),
+#ifdef ENABLE_DEBUG
+ OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
+#endif
OPT_END(),
};
@@ -84,9 +88,14 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
}
log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
+ if (debug) {
+ cxl_set_log_priority(ctx, LOG_DEBUG);
+ param.ctx.log_priority = LOG_DEBUG;
+ }
if (cxl_filter_has(param.port_filter, "root") && param.ports)
param.buses = true;
+ dbg(&param, "walk topology\n");
return cxl_filter_walk(ctx, &param);
}
--
2.27.0