@@ -411,6 +411,35 @@ OPTIONS
}
----
+-N::
+--extents::
+ Append Dynamic Capacity extent information.
+----
+13:34:28 > ./build/cxl/cxl list -r 8 -Nu
+{
+ "region":"region8",
+ "resource":"0xf030000000",
+ "size":"512.00 MiB (536.87 MB)",
+ "type":"dc",
+ "interleave_ways":1,
+ "interleave_granularity":256,
+ "decode_state":"commit",
+ "extents":[
+ {
+ "offset":"0x10000000",
+ "length":"64.00 MiB (67.11 MB)",
+ "tag":"00000000-0000-0000-0000-000000000000"
+ },
+ {
+ "offset":"0x8000000",
+ "length":"64.00 MiB (67.11 MB)",
+ "tag":"00000000-0000-0000-0000-000000000000"
+ }
+ ]
+}
+----
+
+
-r::
--region::
Specify CXL region device name(s), or device id(s), to filter the listing.
@@ -31,6 +31,7 @@ struct cxl_filter_params {
bool alert_config;
bool dax;
bool media_errors;
+ bool extents;
int verbose;
struct log_ctx ctx;
};
@@ -91,6 +92,8 @@ static inline unsigned long cxl_filter_to_flags(struct cxl_filter_params *param)
flags |= UTIL_JSON_DAX | UTIL_JSON_DAX_DEVS;
if (param->media_errors)
flags |= UTIL_JSON_MEDIA_ERRORS;
+ if (param->extents)
+ flags |= UTIL_JSON_EXTENTS;
return flags;
}
@@ -1169,6 +1169,50 @@ void util_cxl_mappings_append_json(struct json_object *jregion,
json_object_object_add(jregion, "mappings", jmappings);
}
+void util_cxl_extents_append_json(struct json_object *jregion,
+ struct cxl_region *region,
+ unsigned long flags)
+{
+ struct json_object *jextents;
+ struct cxl_region_extent *extent;
+
+ jextents = json_object_new_array();
+ if (!jextents)
+ return;
+
+ cxl_extent_foreach(region, extent) {
+ struct json_object *jextent, *jobj;
+ unsigned long long val;
+ char tag_str[40];
+ uuid_t tag;
+
+ jextent = json_object_new_object();
+ if (!jextent)
+ continue;
+
+ val = cxl_extent_get_offset(extent);
+ jobj = util_json_object_hex(val, flags);
+ if (jobj)
+ json_object_object_add(jextent, "offset", jobj);
+
+ val = cxl_extent_get_length(extent);
+ jobj = util_json_object_size(val, flags);
+ if (jobj)
+ json_object_object_add(jextent, "length", jobj);
+
+ cxl_extent_get_tag(extent, tag);
+ uuid_unparse(tag, tag_str);
+ jobj = json_object_new_string(tag_str);
+ if (jobj)
+ json_object_object_add(jextent, "tag", jobj);
+
+ json_object_array_add(jextents, jextent);
+ json_object_set_userdata(jextent, extent, NULL);
+ }
+
+ json_object_object_add(jregion, "extents", jextents);
+}
+
struct json_object *util_cxl_region_to_json(struct cxl_region *region,
unsigned long flags)
{
@@ -1255,6 +1299,9 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region,
}
}
+ if (flags & UTIL_JSON_EXTENTS)
+ util_cxl_extents_append_json(jregion, region, flags);
+
if (cxl_region_qos_class_mismatch(region)) {
jobj = json_object_new_boolean(true);
if (jobj)
@@ -20,6 +20,9 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region,
void util_cxl_mappings_append_json(struct json_object *jregion,
struct cxl_region *region,
unsigned long flags);
+void util_cxl_extents_append_json(struct json_object *jregion,
+ struct cxl_region *region,
+ unsigned long flags);
void util_cxl_targets_append_json(struct json_object *jdecoder,
struct cxl_decoder *decoder,
const char *ident, const char *serial,
@@ -59,6 +59,8 @@ static const struct option options[] = {
"include alert configuration information"),
OPT_BOOLEAN('L', "media-errors", ¶m.media_errors,
"include media-error information "),
+ OPT_BOOLEAN('N', "extents", ¶m.extents,
+ "include extent information (Dynamic Capacity regions only)"),
OPT_INCR('v', "verbose", ¶m.verbose, "increase output detail"),
#ifdef ENABLE_DEBUG
OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
@@ -135,6 +137,7 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
param.decoders = true;
param.targets = true;
param.regions = true;
+ param.extents = true;
/*fallthrough*/
case 0:
break;
@@ -21,6 +21,7 @@ enum util_json_flags {
UTIL_JSON_TARGETS = (1 << 11),
UTIL_JSON_PARTITION = (1 << 12),
UTIL_JSON_ALERT_CONFIG = (1 << 13),
+ UTIL_JSON_EXTENTS = (1 << 14),
};
void util_display_json_array(FILE *f_out, struct json_object *jarray,
DCD regions have 0 or more extents. The ability to list those and their properties is useful to end users. Add an option for extent output to region queries. An example of this is: $ ./build/cxl/cxl list -r 8 -Nu { "region":"region8", ... "type":"dc", ... "extents":[ { "offset":"0x10000000", "length":"64.00 MiB (67.11 MB)", "tag":"00000000-0000-0000-0000-000000000000" }, { "offset":"0x8000000", "length":"64.00 MiB (67.11 MB)", "tag":"00000000-0000-0000-0000-000000000000" } ] } Signed-off-by: Ira Weiny <ira.weiny@intel.com> --- Changes: [djiang: report strerror() on opendir() error] [djiang: Fix up strtoull() error checking] [Alison: Enhance man page] [Alison: Enhance extent processing debug] [Alison: Fix up libcxl export symbols] --- Documentation/cxl/cxl-list.txt | 29 ++++++++++++++++++++++++++ cxl/filter.h | 3 +++ cxl/json.c | 47 ++++++++++++++++++++++++++++++++++++++++++ cxl/json.h | 3 +++ cxl/list.c | 3 +++ util/json.h | 1 + 6 files changed, 86 insertions(+)