|
|
2eb93d |
From 46564977afb733a92526c688fe106e19b139ddfc Mon Sep 17 00:00:00 2001
|
|
|
2eb93d |
From: Dan Williams <dan.j.williams@intel.com>
|
|
|
2eb93d |
Date: Sun, 23 Jan 2022 16:54:27 -0800
|
|
|
2eb93d |
Subject: [PATCH 116/217] cxl/list: Add decoder support
|
|
|
2eb93d |
|
|
|
2eb93d |
Decoder objects exist at each level of a CXL port topology and map a
|
|
|
2eb93d |
physical address range a set of interleaved ports at each level of the
|
|
|
2eb93d |
hierarchy. Typically end users mostly care about the root-level decoders
|
|
|
2eb93d |
which enumerate the potential CXL address space in the system, and the
|
|
|
2eb93d |
endpoint decoders that indicate which address ranges a given device
|
|
|
2eb93d |
contributes resources. Intermediate switch-level decoders are typically
|
|
|
2eb93d |
only useful for debugging decode problems.
|
|
|
2eb93d |
|
|
|
2eb93d |
$ cxl list -D -d 3.1 -u
|
|
|
2eb93d |
{
|
|
|
2eb93d |
"decoder":"decoder3.1",
|
|
|
2eb93d |
"resource":"0x8030000000",
|
|
|
2eb93d |
"size":"512.00 MiB (536.87 MB)",
|
|
|
2eb93d |
"volatile_capable":true
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
Link: https://lore.kernel.org/r/164298566760.3021641.3999006903066004615.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
|
2eb93d |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
2eb93d |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
2eb93d |
---
|
|
|
2eb93d |
.clang-format | 1 +
|
|
|
2eb93d |
Documentation/cxl/cxl-list.txt | 18 ++-
|
|
|
2eb93d |
Documentation/cxl/lib/libcxl.txt | 70 ++++++++-
|
|
|
2eb93d |
cxl/filter.c | 194 +++++++++++++++++++++++--
|
|
|
2eb93d |
cxl/filter.h | 2 +
|
|
|
2eb93d |
cxl/json.c | 62 ++++++++
|
|
|
2eb93d |
cxl/json.h | 2 +
|
|
|
2eb93d |
cxl/lib/libcxl.c | 239 ++++++++++++++++++++++++++++---
|
|
|
2eb93d |
cxl/lib/libcxl.sym | 14 ++
|
|
|
2eb93d |
cxl/lib/private.h | 31 +++-
|
|
|
2eb93d |
cxl/libcxl.h | 28 ++++
|
|
|
2eb93d |
cxl/list.c | 9 +-
|
|
|
2eb93d |
util/json.h | 1 +
|
|
|
2eb93d |
13 files changed, 643 insertions(+), 28 deletions(-)
|
|
|
2eb93d |
|
|
|
2eb93d |
diff --git a/.clang-format b/.clang-format
|
|
|
2eb93d |
index 106bc5e..16e28ac 100644
|
|
|
2eb93d |
--- a/.clang-format
|
|
|
2eb93d |
+++ b/.clang-format
|
|
|
2eb93d |
@@ -80,6 +80,7 @@ ForEachMacros:
|
|
|
2eb93d |
- 'cxl_memdev_foreach'
|
|
|
2eb93d |
- 'cxl_bus_foreach'
|
|
|
2eb93d |
- 'cxl_port_foreach'
|
|
|
2eb93d |
+ - 'cxl_decoder_foreach'
|
|
|
2eb93d |
- 'cxl_endpoint_foreach'
|
|
|
2eb93d |
- 'daxctl_dev_foreach'
|
|
|
2eb93d |
- 'daxctl_mapping_foreach'
|
|
|
2eb93d |
diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt
|
|
|
2eb93d |
index bac27c7..84872b9 100644
|
|
|
2eb93d |
--- a/Documentation/cxl/cxl-list.txt
|
|
|
2eb93d |
+++ b/Documentation/cxl/cxl-list.txt
|
|
|
2eb93d |
@@ -5,7 +5,7 @@ cxl-list(1)
|
|
|
2eb93d |
|
|
|
2eb93d |
NAME
|
|
|
2eb93d |
----
|
|
|
2eb93d |
-cxl-list - List CXL capable memory devices, and their attributes in json.
|
|
|
2eb93d |
+cxl-list - List platform CXL objects, and their attributes, in json.
|
|
|
2eb93d |
|
|
|
2eb93d |
SYNOPSIS
|
|
|
2eb93d |
--------
|
|
|
2eb93d |
@@ -29,6 +29,10 @@ The potential top-level array names and their nesting properties are:
|
|
|
2eb93d |
"endpoints":: nest under ports or buses (if ports are not emitted)
|
|
|
2eb93d |
"memdevs":: nest under endpoints or ports (if endpoints are not
|
|
|
2eb93d |
emitted) or buses (if endpoints and ports are not emitted)
|
|
|
2eb93d |
+"root decoders":: nest under buses
|
|
|
2eb93d |
+"port decoders":: nest under ports, or buses (if ports are not emitted)
|
|
|
2eb93d |
+"endpoint decoders":: nest under endpoints, or ports (if endpoints are
|
|
|
2eb93d |
+ not emitted) or buses (if endpoints and ports are not emitted)
|
|
|
2eb93d |
|
|
|
2eb93d |
Filters can by specifed as either a single identidier, a space separated
|
|
|
2eb93d |
quoted string, or a comma separated list. When multiple filter
|
|
|
2eb93d |
@@ -254,6 +258,18 @@ OPTIONS
|
|
|
2eb93d |
Specify CXL endpoint device name(s), or device id(s) to filter
|
|
|
2eb93d |
the emitted endpoint(s).
|
|
|
2eb93d |
|
|
|
2eb93d |
+-D::
|
|
|
2eb93d |
+--decoders::
|
|
|
2eb93d |
+ Include decoder objects (CXL Memory decode capability instances
|
|
|
2eb93d |
+ in buses, ports, and endpoints) in the listing.
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+-d::
|
|
|
2eb93d |
+--decoder::
|
|
|
2eb93d |
+ Specify CXL decoder device name(s), device id(s), or decoder type names
|
|
|
2eb93d |
+ to filter the emitted decoder(s). The format for a decoder name is
|
|
|
2eb93d |
+ "decoder<port_id>.<instance_id>". The possible decoder type names are
|
|
|
2eb93d |
+ "root", "switch", or "endpoint", similar to the port filter syntax.
|
|
|
2eb93d |
+
|
|
|
2eb93d |
--debug::
|
|
|
2eb93d |
If the cxl tool was built with debug enabled, turn on debug
|
|
|
2eb93d |
messages.
|
|
|
2eb93d |
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
|
|
|
2eb93d |
index 49edb71..73af3d0 100644
|
|
|
2eb93d |
--- a/Documentation/cxl/lib/libcxl.txt
|
|
|
2eb93d |
+++ b/Documentation/cxl/lib/libcxl.txt
|
|
|
2eb93d |
@@ -179,6 +179,7 @@ struct cxl_bus *cxl_bus_get_first(struct cxl_ctx *ctx);
|
|
|
2eb93d |
struct cxl_bus *cxl_bus_get_next(struct cxl_bus *bus);
|
|
|
2eb93d |
struct cxl_ctx *cxl_bus_get_ctx(struct cxl_bus *bus);
|
|
|
2eb93d |
struct cxl_bus *cxl_memdev_get_bus(struct cxl_memdev *memdev);
|
|
|
2eb93d |
+struct cxl_bus *cxl_port_get_bus(struct cxl_port *port);
|
|
|
2eb93d |
struct cxl_bus *cxl_endpoint_get_bus(struct cxl_endpoint *endpoint);
|
|
|
2eb93d |
|
|
|
2eb93d |
#define cxl_bus_foreach(ctx, bus) \
|
|
|
2eb93d |
@@ -215,9 +216,9 @@ struct cxl_port *cxl_bus_get_port(struct cxl_bus *bus);
|
|
|
2eb93d |
struct cxl_port *cxl_port_get_first(struct cxl_port *parent);
|
|
|
2eb93d |
struct cxl_port *cxl_port_get_next(struct cxl_port *port);
|
|
|
2eb93d |
struct cxl_port *cxl_port_get_parent(struct cxl_port *port);
|
|
|
2eb93d |
-struct cxl_bus *cxl_port_get_bus(struct cxl_port *port);
|
|
|
2eb93d |
struct cxl_ctx *cxl_port_get_ctx(struct cxl_port *port);
|
|
|
2eb93d |
const char *cxl_port_get_host(struct cxl_port *port);
|
|
|
2eb93d |
+struct cxl_port *cxl_decoder_get_port(struct cxl_decoder *decoder);
|
|
|
2eb93d |
|
|
|
2eb93d |
#define cxl_port_foreach(parent, port) \
|
|
|
2eb93d |
for (port = cxl_port_get_first(parent); port != NULL; \
|
|
|
2eb93d |
@@ -284,6 +285,73 @@ int cxl_endpoint_get_id(struct cxl_endpoint *endpoint);
|
|
|
2eb93d |
int cxl_endpoint_is_enabled(struct cxl_endpoint *endpoint);
|
|
|
2eb93d |
----
|
|
|
2eb93d |
|
|
|
2eb93d |
+DECODERS
|
|
|
2eb93d |
+--------
|
|
|
2eb93d |
+Decoder objects are associated with the "HDM Decoder Capability"
|
|
|
2eb93d |
+published in Port devices and CXL capable PCIe endpoints. The kernel
|
|
|
2eb93d |
+additionally models platform firmware described CXL memory ranges (like
|
|
|
2eb93d |
+the ACPI CEDT.CFMWS) as static decoder objects. They route System
|
|
|
2eb93d |
+Physical Addresses through a port topology to an endpoint decoder that
|
|
|
2eb93d |
+does the final translation from SPA to DPA (system-physical-address to
|
|
|
2eb93d |
+device-local-physical-address).
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+=== DECODER: Enumeration
|
|
|
2eb93d |
+----
|
|
|
2eb93d |
+struct cxl_decoder *cxl_decoder_get_first(struct cxl_port *port);
|
|
|
2eb93d |
+struct cxl_decoder *cxl_decoder_get_next(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+struct cxl_ctx *cxl_decoder_get_ctx(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+#define cxl_decoder_foreach(port, decoder) \
|
|
|
2eb93d |
+ for (decoder = cxl_decoder_get_first(port); decoder != NULL; \
|
|
|
2eb93d |
+ decoder = cxl_decoder_get_next(decoder))
|
|
|
2eb93d |
+----
|
|
|
2eb93d |
+The definition of a CXL port in libcxl is an object that hosts one or
|
|
|
2eb93d |
+more CXL decoder objects.
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+=== DECODER: Attributes
|
|
|
2eb93d |
+----
|
|
|
2eb93d |
+unsigned long long cxl_decoder_get_resource(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+const char *cxl_decoder_get_devname(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+int cxl_decoder_get_id(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+enum cxl_decoder_target_type {
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_UNKNOWN,
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_EXPANDER,
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_ACCELERATOR,
|
|
|
2eb93d |
+};
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+cxl_decoder_get_target_type(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_pmem_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_volatile_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_mem_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_accelmem_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_locked(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+----
|
|
|
2eb93d |
+The kernel protects the enumeration of the physical address layout of
|
|
|
2eb93d |
+the system. Without CAP_SYS_ADMIN cxl_decoder_get_resource() returns
|
|
|
2eb93d |
+ULLONG_MAX to indicate that the address information was not retrievable.
|
|
|
2eb93d |
+Otherwise, cxl_decoder_get_resource() returns the currently programmed
|
|
|
2eb93d |
+value of the base of the decoder's decode range. A zero-sized decoder
|
|
|
2eb93d |
+indicates a disabled decoder.
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+Root level decoders only support limited set of memory types in their
|
|
|
2eb93d |
+address range. The cxl_decoder_is_<memtype>_capable() helpers identify
|
|
|
2eb93d |
+what is supported. Switch level decoders, in contrast are capable of
|
|
|
2eb93d |
+routing any memory type, i.e. they just forward along the memory type
|
|
|
2eb93d |
+support from their parent port. Endpoint decoders follow the
|
|
|
2eb93d |
+capabilities of their host memory device.
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+The capabilities of a decoder are not to be confused with their type /
|
|
|
2eb93d |
+mode. The type ultimately depends on the endpoint. For example an
|
|
|
2eb93d |
+accelerator requires all decoders in its ancestry to be set to
|
|
|
2eb93d |
+CXL_DECODER_TTYPE_ACCELERATOR, and conversely plain memory expander
|
|
|
2eb93d |
+devices require CXL_DECODER_TTYPE_EXPANDER.
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+Platform firmware may setup the CXL decode hierarchy before the OS
|
|
|
2eb93d |
+boots, and may additionally require that the OS not change the decode
|
|
|
2eb93d |
+settings. This property is indicated by the cxl_decoder_is_locked() API.
|
|
|
2eb93d |
+
|
|
|
2eb93d |
include::../../copyright.txt[]
|
|
|
2eb93d |
|
|
|
2eb93d |
SEE ALSO
|
|
|
2eb93d |
diff --git a/cxl/filter.c b/cxl/filter.c
|
|
|
2eb93d |
index 6dc61a1..dc052f6 100644
|
|
|
2eb93d |
--- a/cxl/filter.c
|
|
|
2eb93d |
+++ b/cxl/filter.c
|
|
|
2eb93d |
@@ -171,6 +171,17 @@ util_cxl_endpoint_filter_by_port(struct cxl_endpoint *endpoint,
|
|
|
2eb93d |
return NULL;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+static struct cxl_decoder *
|
|
|
2eb93d |
+util_cxl_decoder_filter_by_port(struct cxl_decoder *decoder, const char *ident,
|
|
|
2eb93d |
+ enum cxl_port_filter_mode mode)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (util_cxl_port_filter(port, ident, mode))
|
|
|
2eb93d |
+ return decoder;
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static struct cxl_bus *util_cxl_bus_filter(struct cxl_bus *bus,
|
|
|
2eb93d |
const char *__ident)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
@@ -233,6 +244,16 @@ static struct cxl_port *util_cxl_port_filter_by_bus(struct cxl_port *port,
|
|
|
2eb93d |
return NULL;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+static struct cxl_decoder *
|
|
|
2eb93d |
+util_cxl_decoder_filter_by_bus(struct cxl_decoder *decoder, const char *__ident)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (!util_cxl_port_filter_by_bus(port, __ident))
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+ return decoder;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static struct cxl_memdev *
|
|
|
2eb93d |
util_cxl_memdev_serial_filter(struct cxl_memdev *memdev, const char *__serials)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
@@ -357,6 +378,49 @@ static struct cxl_port *util_cxl_port_filter_by_memdev(struct cxl_port *port,
|
|
|
2eb93d |
return NULL;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+static struct cxl_decoder *util_cxl_decoder_filter(struct cxl_decoder *decoder,
|
|
|
2eb93d |
+ const char *__ident)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
2eb93d |
+ int pid, did;
|
|
|
2eb93d |
+ char *ident, *save;
|
|
|
2eb93d |
+ const char *name;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (!__ident)
|
|
|
2eb93d |
+ return decoder;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ ident = strdup(__ident);
|
|
|
2eb93d |
+ if (!ident)
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ for (name = strtok_r(ident, which_sep(__ident), &save); name;
|
|
|
2eb93d |
+ name = strtok_r(NULL, which_sep(__ident), &save)) {
|
|
|
2eb93d |
+ if (strcmp(name, "all") == 0)
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (strcmp(name, "root") == 0 && cxl_port_is_root(port))
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+ if (strcmp(name, "switch") == 0 && cxl_port_is_switch(port))
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+ if (strcmp(name, "endpoint") == 0 && cxl_port_is_endpoint(port))
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if ((sscanf(name, "%d.%d", &pid, &did) == 2 ||
|
|
|
2eb93d |
+ sscanf(name, "decoder%d.%d", &pid, &did) == 2) &&
|
|
|
2eb93d |
+ cxl_port_get_id(port) == pid &&
|
|
|
2eb93d |
+ cxl_decoder_get_id(decoder) == did)
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (strcmp(name, cxl_decoder_get_devname(decoder)) == 0)
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ free(ident);
|
|
|
2eb93d |
+ if (name)
|
|
|
2eb93d |
+ return decoder;
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static unsigned long params_to_flags(struct cxl_filter_params *param)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
unsigned long flags = 0;
|
|
|
2eb93d |
@@ -440,15 +504,44 @@ static struct json_object *pick_array(struct json_object *child,
|
|
|
2eb93d |
return NULL;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+static void walk_decoders(struct cxl_port *port, struct cxl_filter_params *p,
|
|
|
2eb93d |
+ struct json_object *jdecoders, unsigned long flags)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_decoder *decoder;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ cxl_decoder_foreach(port, decoder) {
|
|
|
2eb93d |
+ struct json_object *jdecoder;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (!p->decoders)
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ if (!util_cxl_decoder_filter(decoder, p->decoder_filter))
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ if (!util_cxl_decoder_filter_by_bus(decoder, p->bus_filter))
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ if (!util_cxl_decoder_filter_by_port(decoder, p->port_filter,
|
|
|
2eb93d |
+ pf_mode(p)))
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ if (!p->idle && cxl_decoder_get_size(decoder) == 0)
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ jdecoder = util_cxl_decoder_to_json(decoder, flags);
|
|
|
2eb93d |
+ if (!decoder) {
|
|
|
2eb93d |
+ dbg(p, "decoder object allocation failure\n");
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ json_object_array_add(jdecoders, jdecoder);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static void walk_endpoints(struct cxl_port *port, struct cxl_filter_params *p,
|
|
|
2eb93d |
struct json_object *jeps, struct json_object *jdevs,
|
|
|
2eb93d |
- unsigned long flags)
|
|
|
2eb93d |
+ struct json_object *jdecoders, unsigned long flags)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
struct cxl_endpoint *endpoint;
|
|
|
2eb93d |
|
|
|
2eb93d |
cxl_endpoint_foreach(port, endpoint) {
|
|
|
2eb93d |
struct cxl_port *ep_port = cxl_endpoint_get_port(endpoint);
|
|
|
2eb93d |
const char *devname = cxl_endpoint_get_devname(endpoint);
|
|
|
2eb93d |
+ struct json_object *jchilddecoders = NULL;
|
|
|
2eb93d |
struct json_object *jendpoint = NULL;
|
|
|
2eb93d |
struct cxl_memdev *memdev;
|
|
|
2eb93d |
|
|
|
2eb93d |
@@ -495,14 +588,31 @@ static void walk_endpoints(struct cxl_port *port, struct cxl_filter_params *p,
|
|
|
2eb93d |
else
|
|
|
2eb93d |
json_object_array_add(jdevs, jobj);
|
|
|
2eb93d |
}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (p->decoders && p->endpoints) {
|
|
|
2eb93d |
+ jchilddecoders = json_object_new_array();
|
|
|
2eb93d |
+ if (!jchilddecoders) {
|
|
|
2eb93d |
+ err(p,
|
|
|
2eb93d |
+ "%s: failed to enumerate child decoders\n",
|
|
|
2eb93d |
+ devname);
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (!p->decoders)
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ walk_decoders(cxl_endpoint_get_port(endpoint), p,
|
|
|
2eb93d |
+ pick_array(jchilddecoders, jdecoders), flags);
|
|
|
2eb93d |
+ cond_add_put_array_suffix(jendpoint, "decoders", devname,
|
|
|
2eb93d |
+ jchilddecoders);
|
|
|
2eb93d |
}
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
-static void walk_child_ports(struct cxl_port *parent_port,
|
|
|
2eb93d |
- struct cxl_filter_params *p,
|
|
|
2eb93d |
- struct json_object *jports,
|
|
|
2eb93d |
- struct json_object *jeps,
|
|
|
2eb93d |
- struct json_object *jdevs, unsigned long flags)
|
|
|
2eb93d |
+static void
|
|
|
2eb93d |
+walk_child_ports(struct cxl_port *parent_port, struct cxl_filter_params *p,
|
|
|
2eb93d |
+ struct json_object *jports, struct json_object *jportdecoders,
|
|
|
2eb93d |
+ struct json_object *jeps, struct json_object *jepdecoders,
|
|
|
2eb93d |
+ struct json_object *jdevs, unsigned long flags)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
struct cxl_port *port;
|
|
|
2eb93d |
|
|
|
2eb93d |
@@ -512,6 +622,7 @@ static void walk_child_ports(struct cxl_port *parent_port,
|
|
|
2eb93d |
struct json_object *jchilddevs = NULL;
|
|
|
2eb93d |
struct json_object *jchildports = NULL;
|
|
|
2eb93d |
struct json_object *jchildeps = NULL;
|
|
|
2eb93d |
+ struct json_object *jchilddecoders = NULL;
|
|
|
2eb93d |
|
|
|
2eb93d |
if (!util_cxl_port_filter_by_memdev(port, p->memdev_filter,
|
|
|
2eb93d |
p->serial_filter))
|
|
|
2eb93d |
@@ -555,19 +666,37 @@ static void walk_child_ports(struct cxl_port *parent_port,
|
|
|
2eb93d |
continue;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (p->decoders) {
|
|
|
2eb93d |
+ jchilddecoders = json_object_new_array();
|
|
|
2eb93d |
+ if (!jchilddecoders) {
|
|
|
2eb93d |
+ err(p,
|
|
|
2eb93d |
+ "%s: failed to enumerate child decoders\n",
|
|
|
2eb93d |
+ devname);
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
walk_children:
|
|
|
2eb93d |
- if (p->endpoints || p->memdevs)
|
|
|
2eb93d |
+ if (p->endpoints || p->memdevs || p->decoders)
|
|
|
2eb93d |
walk_endpoints(port, p, pick_array(jchildeps, jeps),
|
|
|
2eb93d |
- pick_array(jchilddevs, jdevs), flags);
|
|
|
2eb93d |
+ pick_array(jchilddevs, jdevs),
|
|
|
2eb93d |
+ pick_array(jchilddecoders, jepdecoders),
|
|
|
2eb93d |
+ flags);
|
|
|
2eb93d |
|
|
|
2eb93d |
+ walk_decoders(port, p,
|
|
|
2eb93d |
+ pick_array(jchilddecoders, jportdecoders), flags);
|
|
|
2eb93d |
walk_child_ports(port, p, pick_array(jchildports, jports),
|
|
|
2eb93d |
+ pick_array(jchilddecoders, jportdecoders),
|
|
|
2eb93d |
pick_array(jchildeps, jeps),
|
|
|
2eb93d |
+ pick_array(jchilddecoders, jepdecoders),
|
|
|
2eb93d |
pick_array(jchilddevs, jdevs), flags);
|
|
|
2eb93d |
cond_add_put_array_suffix(jport, "ports", devname, jchildports);
|
|
|
2eb93d |
cond_add_put_array_suffix(jport, "endpoints", devname,
|
|
|
2eb93d |
jchildeps);
|
|
|
2eb93d |
+ cond_add_put_array_suffix(jport, "decoders", devname,
|
|
|
2eb93d |
+ jchilddecoders);
|
|
|
2eb93d |
cond_add_put_array_suffix(jport, "memdevs", devname,
|
|
|
2eb93d |
jchilddevs);
|
|
|
2eb93d |
}
|
|
|
2eb93d |
@@ -578,6 +707,9 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
|
|
|
2eb93d |
struct json_object *jdevs = NULL, *jbuses = NULL, *jports = NULL;
|
|
|
2eb93d |
struct json_object *jplatform = json_object_new_array();
|
|
|
2eb93d |
unsigned long flags = params_to_flags(p);
|
|
|
2eb93d |
+ struct json_object *jportdecoders = NULL;
|
|
|
2eb93d |
+ struct json_object *jbusdecoders = NULL;
|
|
|
2eb93d |
+ struct json_object *jepdecoders = NULL;
|
|
|
2eb93d |
struct json_object *janondevs = NULL;
|
|
|
2eb93d |
struct json_object *jeps = NULL;
|
|
|
2eb93d |
struct cxl_memdev *memdev;
|
|
|
2eb93d |
@@ -609,6 +741,18 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
|
|
|
2eb93d |
if (!jdevs)
|
|
|
2eb93d |
goto err;
|
|
|
2eb93d |
|
|
|
2eb93d |
+ jbusdecoders = json_object_new_array();
|
|
|
2eb93d |
+ if (!jbusdecoders)
|
|
|
2eb93d |
+ goto err;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ jportdecoders = json_object_new_array();
|
|
|
2eb93d |
+ if (!jportdecoders)
|
|
|
2eb93d |
+ goto err;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ jepdecoders = json_object_new_array();
|
|
|
2eb93d |
+ if (!jepdecoders)
|
|
|
2eb93d |
+ goto err;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
dbg(p, "walk memdevs\n");
|
|
|
2eb93d |
cxl_memdev_foreach(ctx, memdev) {
|
|
|
2eb93d |
struct json_object *janondev;
|
|
|
2eb93d |
@@ -633,6 +777,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
|
|
|
2eb93d |
dbg(p, "walk buses\n");
|
|
|
2eb93d |
cxl_bus_foreach(ctx, bus) {
|
|
|
2eb93d |
struct json_object *jbus = NULL;
|
|
|
2eb93d |
+ struct json_object *jchilddecoders = NULL;
|
|
|
2eb93d |
struct json_object *jchildports = NULL;
|
|
|
2eb93d |
struct json_object *jchilddevs = NULL;
|
|
|
2eb93d |
struct json_object *jchildeps = NULL;
|
|
|
2eb93d |
@@ -681,15 +826,33 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
|
|
|
2eb93d |
continue;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
}
|
|
|
2eb93d |
+ if (p->decoders) {
|
|
|
2eb93d |
+ jchilddecoders = json_object_new_array();
|
|
|
2eb93d |
+ if (!jchilddecoders) {
|
|
|
2eb93d |
+ err(p,
|
|
|
2eb93d |
+ "%s: failed to enumerate child decoders\n",
|
|
|
2eb93d |
+ devname);
|
|
|
2eb93d |
+ continue;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
}
|
|
|
2eb93d |
walk_children:
|
|
|
2eb93d |
+ dbg(p, "walk decoders\n");
|
|
|
2eb93d |
+ walk_decoders(port, p, pick_array(jchilddecoders, jbusdecoders),
|
|
|
2eb93d |
+ flags);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
dbg(p, "walk ports\n");
|
|
|
2eb93d |
walk_child_ports(port, p, pick_array(jchildports, jports),
|
|
|
2eb93d |
+ pick_array(jchilddecoders, jportdecoders),
|
|
|
2eb93d |
pick_array(jchildeps, jeps),
|
|
|
2eb93d |
+ pick_array(jchilddecoders, jepdecoders),
|
|
|
2eb93d |
pick_array(jchilddevs, jdevs), flags);
|
|
|
2eb93d |
cond_add_put_array_suffix(jbus, "ports", devname, jchildports);
|
|
|
2eb93d |
cond_add_put_array_suffix(jbus, "endpoints", devname,
|
|
|
2eb93d |
jchildeps);
|
|
|
2eb93d |
+ cond_add_put_array_suffix(jbus, "decoders", devname,
|
|
|
2eb93d |
+ jchilddecoders);
|
|
|
2eb93d |
cond_add_put_array_suffix(jbus, "memdevs", devname, jchilddevs);
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
@@ -703,12 +866,24 @@ walk_children:
|
|
|
2eb93d |
top_level_objs++;
|
|
|
2eb93d |
if (json_object_array_length(jdevs))
|
|
|
2eb93d |
top_level_objs++;
|
|
|
2eb93d |
+ if (json_object_array_length(jbusdecoders))
|
|
|
2eb93d |
+ top_level_objs++;
|
|
|
2eb93d |
+ if (json_object_array_length(jportdecoders))
|
|
|
2eb93d |
+ top_level_objs++;
|
|
|
2eb93d |
+ if (json_object_array_length(jepdecoders))
|
|
|
2eb93d |
+ top_level_objs++;
|
|
|
2eb93d |
|
|
|
2eb93d |
splice_array(p, janondevs, jplatform, "anon memdevs", top_level_objs > 1);
|
|
|
2eb93d |
splice_array(p, jbuses, jplatform, "buses", top_level_objs > 1);
|
|
|
2eb93d |
splice_array(p, jports, jplatform, "ports", top_level_objs > 1);
|
|
|
2eb93d |
splice_array(p, jeps, jplatform, "endpoints", top_level_objs > 1);
|
|
|
2eb93d |
splice_array(p, jdevs, jplatform, "memdevs", top_level_objs > 1);
|
|
|
2eb93d |
+ splice_array(p, jbusdecoders, jplatform, "root decoders",
|
|
|
2eb93d |
+ top_level_objs > 1);
|
|
|
2eb93d |
+ splice_array(p, jportdecoders, jplatform, "port decoders",
|
|
|
2eb93d |
+ top_level_objs > 1);
|
|
|
2eb93d |
+ splice_array(p, jepdecoders, jplatform, "endpoint decoders",
|
|
|
2eb93d |
+ top_level_objs > 1);
|
|
|
2eb93d |
|
|
|
2eb93d |
util_display_json_array(stdout, jplatform, flags);
|
|
|
2eb93d |
|
|
|
2eb93d |
@@ -719,6 +894,9 @@ err:
|
|
|
2eb93d |
json_object_put(jports);
|
|
|
2eb93d |
json_object_put(jeps);
|
|
|
2eb93d |
json_object_put(jdevs);
|
|
|
2eb93d |
+ json_object_put(jbusdecoders);
|
|
|
2eb93d |
+ json_object_put(jportdecoders);
|
|
|
2eb93d |
+ json_object_put(jepdecoders);
|
|
|
2eb93d |
json_object_put(jplatform);
|
|
|
2eb93d |
return -ENOMEM;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
diff --git a/cxl/filter.h b/cxl/filter.h
|
|
|
2eb93d |
index bbd341c..5d7bf45 100644
|
|
|
2eb93d |
--- a/cxl/filter.h
|
|
|
2eb93d |
+++ b/cxl/filter.h
|
|
|
2eb93d |
@@ -12,8 +12,10 @@ struct cxl_filter_params {
|
|
|
2eb93d |
const char *bus_filter;
|
|
|
2eb93d |
const char *port_filter;
|
|
|
2eb93d |
const char *endpoint_filter;
|
|
|
2eb93d |
+ const char *decoder_filter;
|
|
|
2eb93d |
bool single;
|
|
|
2eb93d |
bool endpoints;
|
|
|
2eb93d |
+ bool decoders;
|
|
|
2eb93d |
bool memdevs;
|
|
|
2eb93d |
bool ports;
|
|
|
2eb93d |
bool buses;
|
|
|
2eb93d |
diff --git a/cxl/json.c b/cxl/json.c
|
|
|
2eb93d |
index 51918d6..548bc52 100644
|
|
|
2eb93d |
--- a/cxl/json.c
|
|
|
2eb93d |
+++ b/cxl/json.c
|
|
|
2eb93d |
@@ -262,6 +262,68 @@ struct json_object *util_cxl_bus_to_json(struct cxl_bus *bus,
|
|
|
2eb93d |
return jbus;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
|
|
|
2eb93d |
+ unsigned long flags)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ const char *devname = cxl_decoder_get_devname(decoder);
|
|
|
2eb93d |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
2eb93d |
+ struct json_object *jdecoder, *jobj;
|
|
|
2eb93d |
+ u64 val;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ jdecoder = json_object_new_object();
|
|
|
2eb93d |
+ if (!jdecoder)
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ jobj = json_object_new_string(devname);
|
|
|
2eb93d |
+ if (jobj)
|
|
|
2eb93d |
+ json_object_object_add(jdecoder, "decoder", jobj);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ val = cxl_decoder_get_resource(decoder);
|
|
|
2eb93d |
+ if (val < ULLONG_MAX) {
|
|
|
2eb93d |
+ jobj = util_json_object_hex(val, flags);
|
|
|
2eb93d |
+ if (jobj)
|
|
|
2eb93d |
+ json_object_object_add(jdecoder, "resource", jobj);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ val = cxl_decoder_get_size(decoder);
|
|
|
2eb93d |
+ if (val < ULLONG_MAX) {
|
|
|
2eb93d |
+ jobj = util_json_object_size(val, flags);
|
|
|
2eb93d |
+ if (jobj)
|
|
|
2eb93d |
+ json_object_object_add(jdecoder, "size", jobj);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (val == 0) {
|
|
|
2eb93d |
+ jobj = json_object_new_string("disabled");
|
|
|
2eb93d |
+ if (jobj)
|
|
|
2eb93d |
+ json_object_object_add(jdecoder, "state", jobj);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (cxl_port_is_root(port) && cxl_decoder_is_mem_capable(decoder)) {
|
|
|
2eb93d |
+ if (cxl_decoder_is_pmem_capable(decoder)) {
|
|
|
2eb93d |
+ jobj = json_object_new_boolean(true);
|
|
|
2eb93d |
+ if (jobj)
|
|
|
2eb93d |
+ json_object_object_add(jdecoder, "pmem_capable",
|
|
|
2eb93d |
+ jobj);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ if (cxl_decoder_is_volatile_capable(decoder)) {
|
|
|
2eb93d |
+ jobj = json_object_new_boolean(true);
|
|
|
2eb93d |
+ if (jobj)
|
|
|
2eb93d |
+ json_object_object_add(
|
|
|
2eb93d |
+ jdecoder, "volatile_capable", jobj);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (cxl_port_is_root(port) &&
|
|
|
2eb93d |
+ cxl_decoder_is_accelmem_capable(decoder)) {
|
|
|
2eb93d |
+ jobj = json_object_new_boolean(true);
|
|
|
2eb93d |
+ if (jobj)
|
|
|
2eb93d |
+ json_object_object_add(jdecoder, "accelmem_capable",
|
|
|
2eb93d |
+ jobj);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ return jdecoder;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static struct json_object *__util_cxl_port_to_json(struct cxl_port *port,
|
|
|
2eb93d |
const char *name_key,
|
|
|
2eb93d |
unsigned long flags)
|
|
|
2eb93d |
diff --git a/cxl/json.h b/cxl/json.h
|
|
|
2eb93d |
index 8f45190..fcca2e6 100644
|
|
|
2eb93d |
--- a/cxl/json.h
|
|
|
2eb93d |
+++ b/cxl/json.h
|
|
|
2eb93d |
@@ -13,4 +13,6 @@ struct json_object *util_cxl_port_to_json(struct cxl_port *port,
|
|
|
2eb93d |
unsigned long flags);
|
|
|
2eb93d |
struct json_object *util_cxl_endpoint_to_json(struct cxl_endpoint *endpoint,
|
|
|
2eb93d |
unsigned long flags);
|
|
|
2eb93d |
+struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
|
|
|
2eb93d |
+ unsigned long flags);
|
|
|
2eb93d |
#endif /* __CXL_UTIL_JSON_H__ */
|
|
|
2eb93d |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
|
2eb93d |
index 2fdaf71..5e30923 100644
|
|
|
2eb93d |
--- a/cxl/lib/libcxl.c
|
|
|
2eb93d |
+++ b/cxl/lib/libcxl.c
|
|
|
2eb93d |
@@ -63,16 +63,26 @@ static void free_memdev(struct cxl_memdev *memdev, struct list_head *head)
|
|
|
2eb93d |
free(memdev->firmware_version);
|
|
|
2eb93d |
free(memdev->dev_buf);
|
|
|
2eb93d |
free(memdev->dev_path);
|
|
|
2eb93d |
- free(memdev->host);
|
|
|
2eb93d |
+ free(memdev->host_path);
|
|
|
2eb93d |
free(memdev);
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+static void free_decoder(struct cxl_decoder *decoder, struct list_head *head)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ if (head)
|
|
|
2eb93d |
+ list_del_from(head, &decoder->list);
|
|
|
2eb93d |
+ free(decoder->dev_buf);
|
|
|
2eb93d |
+ free(decoder->dev_path);
|
|
|
2eb93d |
+ free(decoder);
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static void free_port(struct cxl_port *port, struct list_head *head);
|
|
|
2eb93d |
static void free_endpoint(struct cxl_endpoint *endpoint, struct list_head *head);
|
|
|
2eb93d |
static void __free_port(struct cxl_port *port, struct list_head *head)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
struct cxl_port *child, *_c;
|
|
|
2eb93d |
struct cxl_endpoint *endpoint, *_e;
|
|
|
2eb93d |
+ struct cxl_decoder *decoder, *_d;
|
|
|
2eb93d |
|
|
|
2eb93d |
if (head)
|
|
|
2eb93d |
list_del_from(head, &port->list);
|
|
|
2eb93d |
@@ -80,6 +90,8 @@ static void __free_port(struct cxl_port *port, struct list_head *head)
|
|
|
2eb93d |
free_port(child, &port->child_ports);
|
|
|
2eb93d |
list_for_each_safe(&port->endpoints, endpoint, _e, port.list)
|
|
|
2eb93d |
free_endpoint(endpoint, &port->endpoints);
|
|
|
2eb93d |
+ list_for_each_safe(&port->decoders, decoder, _d, list)
|
|
|
2eb93d |
+ free_decoder(decoder, &port->decoders);
|
|
|
2eb93d |
kmod_module_unref(port->module);
|
|
|
2eb93d |
free(port->dev_buf);
|
|
|
2eb93d |
free(port->dev_path);
|
|
|
2eb93d |
@@ -298,9 +310,9 @@ static void *add_cxl_memdev(void *parent, int id, const char *cxlmem_base)
|
|
|
2eb93d |
char *path = calloc(1, strlen(cxlmem_base) + 100);
|
|
|
2eb93d |
struct cxl_ctx *ctx = parent;
|
|
|
2eb93d |
struct cxl_memdev *memdev, *memdev_dup;
|
|
|
2eb93d |
- char *host, *rpath = NULL;
|
|
|
2eb93d |
char buf[SYSFS_ATTR_SIZE];
|
|
|
2eb93d |
struct stat st;
|
|
|
2eb93d |
+ char *host;
|
|
|
2eb93d |
|
|
|
2eb93d |
if (!path)
|
|
|
2eb93d |
return NULL;
|
|
|
2eb93d |
@@ -358,21 +370,13 @@ static void *add_cxl_memdev(void *parent, int id, const char *cxlmem_base)
|
|
|
2eb93d |
if (!memdev->dev_path)
|
|
|
2eb93d |
goto err_read;
|
|
|
2eb93d |
|
|
|
2eb93d |
- rpath = realpath(cxlmem_base, NULL);
|
|
|
2eb93d |
- if (!rpath)
|
|
|
2eb93d |
+ memdev->host_path = realpath(cxlmem_base, NULL);
|
|
|
2eb93d |
+ if (!memdev->host_path)
|
|
|
2eb93d |
goto err_read;
|
|
|
2eb93d |
- host = strrchr(rpath, '/');
|
|
|
2eb93d |
- if (host) {
|
|
|
2eb93d |
- host[0] = '\0';
|
|
|
2eb93d |
- host = strrchr(rpath, '/');
|
|
|
2eb93d |
- }
|
|
|
2eb93d |
+ host = strrchr(memdev->host_path, '/');
|
|
|
2eb93d |
if (!host)
|
|
|
2eb93d |
goto err_read;
|
|
|
2eb93d |
- memdev->host = strdup(host + 1);
|
|
|
2eb93d |
- if (!memdev->host)
|
|
|
2eb93d |
- goto err_read;
|
|
|
2eb93d |
- free(rpath);
|
|
|
2eb93d |
- rpath = NULL;
|
|
|
2eb93d |
+ host[0] = '\0';
|
|
|
2eb93d |
|
|
|
2eb93d |
sprintf(path, "%s/firmware_version", cxlmem_base);
|
|
|
2eb93d |
if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
|
2eb93d |
@@ -404,8 +408,8 @@ static void *add_cxl_memdev(void *parent, int id, const char *cxlmem_base)
|
|
|
2eb93d |
free(memdev->firmware_version);
|
|
|
2eb93d |
free(memdev->dev_buf);
|
|
|
2eb93d |
free(memdev->dev_path);
|
|
|
2eb93d |
+ free(memdev->host_path);
|
|
|
2eb93d |
free(memdev);
|
|
|
2eb93d |
- free(rpath);
|
|
|
2eb93d |
err_dev:
|
|
|
2eb93d |
free(path);
|
|
|
2eb93d |
return NULL;
|
|
|
2eb93d |
@@ -463,7 +467,7 @@ CXL_EXPORT const char *cxl_memdev_get_devname(struct cxl_memdev *memdev)
|
|
|
2eb93d |
|
|
|
2eb93d |
CXL_EXPORT const char *cxl_memdev_get_host(struct cxl_memdev *memdev)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
- return memdev->host;
|
|
|
2eb93d |
+ return devpath_to_devname(memdev->host_path);
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
CXL_EXPORT struct cxl_bus *cxl_memdev_get_bus(struct cxl_memdev *memdev)
|
|
|
2eb93d |
@@ -679,9 +683,11 @@ static int cxl_port_init(struct cxl_port *port, struct cxl_port *parent_port,
|
|
|
2eb93d |
port->ctx = ctx;
|
|
|
2eb93d |
port->type = type;
|
|
|
2eb93d |
port->parent = parent_port;
|
|
|
2eb93d |
+ port->type = type;
|
|
|
2eb93d |
|
|
|
2eb93d |
list_head_init(&port->child_ports);
|
|
|
2eb93d |
list_head_init(&port->endpoints);
|
|
|
2eb93d |
+ list_head_init(&port->decoders);
|
|
|
2eb93d |
|
|
|
2eb93d |
port->dev_path = strdup(cxlport_base);
|
|
|
2eb93d |
if (!port->dev_path)
|
|
|
2eb93d |
@@ -842,6 +848,207 @@ cxl_endpoint_get_memdev(struct cxl_endpoint *endpoint)
|
|
|
2eb93d |
return NULL;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ const char *devname = devpath_to_devname(cxldecoder_base);
|
|
|
2eb93d |
+ char *path = calloc(1, strlen(cxldecoder_base) + 100);
|
|
|
2eb93d |
+ struct cxl_decoder *decoder, *decoder_dup;
|
|
|
2eb93d |
+ struct cxl_port *port = parent;
|
|
|
2eb93d |
+ struct cxl_ctx *ctx = cxl_port_get_ctx(port);
|
|
|
2eb93d |
+ char buf[SYSFS_ATTR_SIZE];
|
|
|
2eb93d |
+ size_t i;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ dbg(ctx, "%s: base: \'%s\'\n", devname, cxldecoder_base);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (!path)
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ decoder = calloc(1, sizeof(*decoder));
|
|
|
2eb93d |
+ if (!decoder)
|
|
|
2eb93d |
+ goto err;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ decoder->id = id;
|
|
|
2eb93d |
+ decoder->ctx = ctx;
|
|
|
2eb93d |
+ decoder->port = port;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ decoder->dev_path = strdup(cxldecoder_base);
|
|
|
2eb93d |
+ if (!decoder->dev_path)
|
|
|
2eb93d |
+ goto err;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ decoder->dev_buf = calloc(1, strlen(cxldecoder_base) + 50);
|
|
|
2eb93d |
+ if (!decoder->dev_buf)
|
|
|
2eb93d |
+ goto err;
|
|
|
2eb93d |
+ decoder->buf_len = strlen(cxldecoder_base) + 50;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ sprintf(path, "%s/start", cxldecoder_base);
|
|
|
2eb93d |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
|
2eb93d |
+ decoder->start = ULLONG_MAX;
|
|
|
2eb93d |
+ else
|
|
|
2eb93d |
+ decoder->start = strtoull(buf, NULL, 0);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ sprintf(path, "%s/size", cxldecoder_base);
|
|
|
2eb93d |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
|
2eb93d |
+ decoder->size = ULLONG_MAX;
|
|
|
2eb93d |
+ else
|
|
|
2eb93d |
+ decoder->size = strtoull(buf, NULL, 0);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ switch (port->type) {
|
|
|
2eb93d |
+ case CXL_PORT_SWITCH:
|
|
|
2eb93d |
+ case CXL_PORT_ENDPOINT:
|
|
|
2eb93d |
+ decoder->pmem_capable = true;
|
|
|
2eb93d |
+ decoder->volatile_capable = true;
|
|
|
2eb93d |
+ decoder->mem_capable = true;
|
|
|
2eb93d |
+ decoder->accelmem_capable = true;
|
|
|
2eb93d |
+ sprintf(path, "%s/locked", cxldecoder_base);
|
|
|
2eb93d |
+ if (sysfs_read_attr(ctx, path, buf) == 0)
|
|
|
2eb93d |
+ decoder->locked = !!strtoul(buf, NULL, 0);
|
|
|
2eb93d |
+ sprintf(path, "%s/target_type", cxldecoder_base);
|
|
|
2eb93d |
+ if (sysfs_read_attr(ctx, path, buf) == 0) {
|
|
|
2eb93d |
+ if (strcmp(buf, "accelerator") == 0)
|
|
|
2eb93d |
+ decoder->target_type =
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_ACCELERATOR;
|
|
|
2eb93d |
+ if (strcmp(buf, "expander") == 0)
|
|
|
2eb93d |
+ decoder->target_type =
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_EXPANDER;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+ case CXL_PORT_ROOT: {
|
|
|
2eb93d |
+ struct cxl_decoder_flag {
|
|
|
2eb93d |
+ char *name;
|
|
|
2eb93d |
+ bool *flag;
|
|
|
2eb93d |
+ } flags[] = {
|
|
|
2eb93d |
+ { "cap_type2", &decoder->accelmem_capable },
|
|
|
2eb93d |
+ { "cap_type3", &decoder->mem_capable },
|
|
|
2eb93d |
+ { "cap_ram", &decoder->volatile_capable },
|
|
|
2eb93d |
+ { "cap_pmem", &decoder->pmem_capable },
|
|
|
2eb93d |
+ { "locked", &decoder->locked },
|
|
|
2eb93d |
+ };
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ for (i = 0; i < ARRAY_SIZE(flags); i++) {
|
|
|
2eb93d |
+ struct cxl_decoder_flag *flag = &flags[i];
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ sprintf(path, "%s/%s", cxldecoder_base, flag->name);
|
|
|
2eb93d |
+ if (sysfs_read_attr(ctx, path, buf) == 0)
|
|
|
2eb93d |
+ *(flag->flag) = !!strtoul(buf, NULL, 0);
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ break;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ cxl_decoder_foreach(port, decoder_dup)
|
|
|
2eb93d |
+ if (decoder_dup->id == decoder->id) {
|
|
|
2eb93d |
+ free_decoder(decoder, NULL);
|
|
|
2eb93d |
+ return decoder_dup;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ list_add(&port->decoders, &decoder->list);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ return decoder;
|
|
|
2eb93d |
+err:
|
|
|
2eb93d |
+ free(decoder->dev_path);
|
|
|
2eb93d |
+ free(decoder->dev_buf);
|
|
|
2eb93d |
+ free(decoder);
|
|
|
2eb93d |
+ free(path);
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+static void cxl_decoders_init(struct cxl_port *port)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_ctx *ctx = cxl_port_get_ctx(port);
|
|
|
2eb93d |
+ char *decoder_fmt;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (port->decoders_init)
|
|
|
2eb93d |
+ return;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ if (asprintf(&decoder_fmt, "decoder%d.", cxl_port_get_id(port)) < 0) {
|
|
|
2eb93d |
+ err(ctx, "%s: failed to add decoder(s)\n",
|
|
|
2eb93d |
+ cxl_port_get_devname(port));
|
|
|
2eb93d |
+ return;
|
|
|
2eb93d |
+ }
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ port->decoders_init = 1;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ sysfs_device_parse(ctx, port->dev_path, decoder_fmt, port,
|
|
|
2eb93d |
+ add_cxl_decoder);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ free(decoder_fmt);
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT struct cxl_decoder *cxl_decoder_get_first(struct cxl_port *port)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ cxl_decoders_init(port);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ return list_top(&port->decoders, struct cxl_decoder, list);
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT struct cxl_decoder *cxl_decoder_get_next(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_port *port = decoder->port;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ return list_next(&port->decoders, decoder, list);
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT struct cxl_ctx *cxl_decoder_get_ctx(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->ctx;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT int cxl_decoder_get_id(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->id;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT struct cxl_port *cxl_decoder_get_port(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->port;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT unsigned long long cxl_decoder_get_resource(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->start;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->size;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT enum cxl_decoder_target_type
|
|
|
2eb93d |
+cxl_decoder_get_target_type(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->target_type;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT bool cxl_decoder_is_pmem_capable(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->pmem_capable;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT bool cxl_decoder_is_volatile_capable(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->volatile_capable;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT bool cxl_decoder_is_mem_capable(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->mem_capable;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT bool cxl_decoder_is_accelmem_capable(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->accelmem_capable;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT bool cxl_decoder_is_locked(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return decoder->locked;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT const char *cxl_decoder_get_devname(struct cxl_decoder *decoder)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return devpath_to_devname(decoder->dev_path);
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
static void *add_cxl_port(void *parent, int id, const char *cxlport_base)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
const char *devname = devpath_to_devname(cxlport_base);
|
|
|
2eb93d |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
|
2eb93d |
index f235e99..22babb7 100644
|
|
|
2eb93d |
--- a/cxl/lib/libcxl.sym
|
|
|
2eb93d |
+++ b/cxl/lib/libcxl.sym
|
|
|
2eb93d |
@@ -117,4 +117,18 @@ global:
|
|
|
2eb93d |
cxl_memdev_get_bus;
|
|
|
2eb93d |
cxl_memdev_disable_invalidate;
|
|
|
2eb93d |
cxl_memdev_enable;
|
|
|
2eb93d |
+ cxl_decoder_get_first;
|
|
|
2eb93d |
+ cxl_decoder_get_next;
|
|
|
2eb93d |
+ cxl_decoder_get_ctx;
|
|
|
2eb93d |
+ cxl_decoder_get_id;
|
|
|
2eb93d |
+ cxl_decoder_get_port;
|
|
|
2eb93d |
+ cxl_decoder_get_resource;
|
|
|
2eb93d |
+ cxl_decoder_get_size;
|
|
|
2eb93d |
+ cxl_decoder_get_devname;
|
|
|
2eb93d |
+ cxl_decoder_get_target_type;
|
|
|
2eb93d |
+ cxl_decoder_is_pmem_capable;
|
|
|
2eb93d |
+ cxl_decoder_is_volatile_capable;
|
|
|
2eb93d |
+ cxl_decoder_is_mem_capable;
|
|
|
2eb93d |
+ cxl_decoder_is_accelmem_capable;
|
|
|
2eb93d |
+ cxl_decoder_is_locked;
|
|
|
2eb93d |
} LIBCXL_1;
|
|
|
2eb93d |
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
|
|
|
2eb93d |
index c00bb36..1743a24 100644
|
|
|
2eb93d |
--- a/cxl/lib/private.h
|
|
|
2eb93d |
+++ b/cxl/lib/private.h
|
|
|
2eb93d |
@@ -23,7 +23,7 @@ struct cxl_memdev {
|
|
|
2eb93d |
int numa_node;
|
|
|
2eb93d |
void *dev_buf;
|
|
|
2eb93d |
size_t buf_len;
|
|
|
2eb93d |
- char *host;
|
|
|
2eb93d |
+ char *host_path;
|
|
|
2eb93d |
char *dev_path;
|
|
|
2eb93d |
char *firmware_version;
|
|
|
2eb93d |
struct cxl_ctx *ctx;
|
|
|
2eb93d |
@@ -52,6 +52,7 @@ struct cxl_port {
|
|
|
2eb93d |
char *uport;
|
|
|
2eb93d |
int ports_init;
|
|
|
2eb93d |
int endpoints_init;
|
|
|
2eb93d |
+ int decoders_init;
|
|
|
2eb93d |
struct cxl_ctx *ctx;
|
|
|
2eb93d |
struct cxl_bus *bus;
|
|
|
2eb93d |
enum cxl_port_type type;
|
|
|
2eb93d |
@@ -60,6 +61,7 @@ struct cxl_port {
|
|
|
2eb93d |
struct list_node list;
|
|
|
2eb93d |
struct list_head child_ports;
|
|
|
2eb93d |
struct list_head endpoints;
|
|
|
2eb93d |
+ struct list_head decoders;
|
|
|
2eb93d |
};
|
|
|
2eb93d |
|
|
|
2eb93d |
struct cxl_bus {
|
|
|
2eb93d |
@@ -71,6 +73,33 @@ struct cxl_endpoint {
|
|
|
2eb93d |
struct cxl_memdev *memdev;
|
|
|
2eb93d |
};
|
|
|
2eb93d |
|
|
|
2eb93d |
+struct cxl_target {
|
|
|
2eb93d |
+ struct list_node list;
|
|
|
2eb93d |
+ struct cxl_decoder *decoder;
|
|
|
2eb93d |
+ char *dev_path;
|
|
|
2eb93d |
+ int id, position;
|
|
|
2eb93d |
+};
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+struct cxl_decoder {
|
|
|
2eb93d |
+ struct cxl_port *port;
|
|
|
2eb93d |
+ struct list_node list;
|
|
|
2eb93d |
+ struct cxl_ctx *ctx;
|
|
|
2eb93d |
+ u64 start;
|
|
|
2eb93d |
+ u64 size;
|
|
|
2eb93d |
+ void *dev_buf;
|
|
|
2eb93d |
+ size_t buf_len;
|
|
|
2eb93d |
+ char *dev_path;
|
|
|
2eb93d |
+ int nr_targets;
|
|
|
2eb93d |
+ int id;
|
|
|
2eb93d |
+ bool pmem_capable;
|
|
|
2eb93d |
+ bool volatile_capable;
|
|
|
2eb93d |
+ bool mem_capable;
|
|
|
2eb93d |
+ bool accelmem_capable;
|
|
|
2eb93d |
+ bool locked;
|
|
|
2eb93d |
+ enum cxl_decoder_target_type target_type;
|
|
|
2eb93d |
+ struct list_head targets;
|
|
|
2eb93d |
+};
|
|
|
2eb93d |
+
|
|
|
2eb93d |
enum cxl_cmd_query_status {
|
|
|
2eb93d |
CXL_CMD_QUERY_NOT_RUN = 0,
|
|
|
2eb93d |
CXL_CMD_QUERY_OK,
|
|
|
2eb93d |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
|
2eb93d |
index 53f68dd..439ed93 100644
|
|
|
2eb93d |
--- a/cxl/libcxl.h
|
|
|
2eb93d |
+++ b/cxl/libcxl.h
|
|
|
2eb93d |
@@ -98,6 +98,34 @@ bool cxl_port_hosts_memdev(struct cxl_port *port, struct cxl_memdev *memdev);
|
|
|
2eb93d |
for (port = cxl_port_get_first(parent); port != NULL; \
|
|
|
2eb93d |
port = cxl_port_get_next(port))
|
|
|
2eb93d |
|
|
|
2eb93d |
+struct cxl_decoder;
|
|
|
2eb93d |
+struct cxl_decoder *cxl_decoder_get_first(struct cxl_port *port);
|
|
|
2eb93d |
+struct cxl_decoder *cxl_decoder_get_next(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+unsigned long long cxl_decoder_get_resource(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+const char *cxl_decoder_get_devname(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+struct cxl_ctx *cxl_decoder_get_ctx(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+int cxl_decoder_get_id(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+struct cxl_port *cxl_decoder_get_port(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+enum cxl_decoder_target_type {
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_UNKNOWN,
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_EXPANDER,
|
|
|
2eb93d |
+ CXL_DECODER_TTYPE_ACCELERATOR,
|
|
|
2eb93d |
+};
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+enum cxl_decoder_target_type
|
|
|
2eb93d |
+cxl_decoder_get_target_type(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_pmem_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_volatile_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_mem_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_accelmem_capable(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+bool cxl_decoder_is_locked(struct cxl_decoder *decoder);
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+#define cxl_decoder_foreach(port, decoder) \
|
|
|
2eb93d |
+ for (decoder = cxl_decoder_get_first(port); decoder != NULL; \
|
|
|
2eb93d |
+ decoder = cxl_decoder_get_next(decoder))
|
|
|
2eb93d |
+
|
|
|
2eb93d |
struct cxl_endpoint;
|
|
|
2eb93d |
struct cxl_endpoint *cxl_endpoint_get_first(struct cxl_port *parent);
|
|
|
2eb93d |
struct cxl_endpoint *cxl_endpoint_get_next(struct cxl_endpoint *endpoint);
|
|
|
2eb93d |
diff --git a/cxl/list.c b/cxl/list.c
|
|
|
2eb93d |
index b15e01c..d70192a 100644
|
|
|
2eb93d |
--- a/cxl/list.c
|
|
|
2eb93d |
+++ b/cxl/list.c
|
|
|
2eb93d |
@@ -36,6 +36,11 @@ static const struct option options[] = {
|
|
|
2eb93d |
"filter by CXL endpoint device name(s)"),
|
|
|
2eb93d |
OPT_BOOLEAN('E', "endpoints", ¶m.endpoints,
|
|
|
2eb93d |
"include CXL endpoint info"),
|
|
|
2eb93d |
+ OPT_STRING('d', "decoder", ¶m.decoder_filter,
|
|
|
2eb93d |
+ "decoder device name",
|
|
|
2eb93d |
+ "filter by CXL decoder device name(s) / class"),
|
|
|
2eb93d |
+ OPT_BOOLEAN('D', "decoders", ¶m.decoders,
|
|
|
2eb93d |
+ "include CXL decoder info"),
|
|
|
2eb93d |
OPT_BOOLEAN('i', "idle", ¶m.idle, "include disabled devices"),
|
|
|
2eb93d |
OPT_BOOLEAN('u', "human", ¶m.human,
|
|
|
2eb93d |
"use human friendly number formats "),
|
|
|
2eb93d |
@@ -50,7 +55,7 @@ static const struct option options[] = {
|
|
|
2eb93d |
static int num_list_flags(void)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
return !!param.memdevs + !!param.buses + !!param.ports +
|
|
|
2eb93d |
- !!param.endpoints;
|
|
|
2eb93d |
+ !!param.endpoints + !!param.decoders;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
|
|
|
2eb93d |
@@ -82,6 +87,8 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
|
|
|
2eb93d |
param.ports = true;
|
|
|
2eb93d |
if (param.endpoint_filter)
|
|
|
2eb93d |
param.endpoints = true;
|
|
|
2eb93d |
+ if (param.decoder_filter)
|
|
|
2eb93d |
+ param.decoders = true;
|
|
|
2eb93d |
if (num_list_flags() == 0) {
|
|
|
2eb93d |
/*
|
|
|
2eb93d |
* TODO: We likely want to list regions by default if
|
|
|
2eb93d |
diff --git a/util/json.h b/util/json.h
|
|
|
2eb93d |
index 061f0d4..e026df1 100644
|
|
|
2eb93d |
--- a/util/json.h
|
|
|
2eb93d |
+++ b/util/json.h
|
|
|
2eb93d |
@@ -18,6 +18,7 @@ enum util_json_flags {
|
|
|
2eb93d |
UTIL_JSON_FIRMWARE = (1 << 8),
|
|
|
2eb93d |
UTIL_JSON_DAX_MAPPINGS = (1 << 9),
|
|
|
2eb93d |
UTIL_JSON_HEALTH = (1 << 10),
|
|
|
2eb93d |
+ UTIL_JSON_TARGETS = (1 << 11),
|
|
|
2eb93d |
};
|
|
|
2eb93d |
|
|
|
2eb93d |
void util_display_json_array(FILE *f_out, struct json_object *jarray,
|
|
|
2eb93d |
--
|
|
|
2eb93d |
2.27.0
|
|
|
2eb93d |
|