|
|
e0018b |
From bbc0da95d12b3c890cc323a34b48cf489d4b467a Mon Sep 17 00:00:00 2001
|
|
|
e0018b |
From: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Date: Thu, 14 Jul 2022 10:02:09 -0700
|
|
|
e0018b |
Subject: [PATCH 178/217] cxl/list: Add DPA span to endpoint decoder listings
|
|
|
e0018b |
|
|
|
e0018b |
Optionally include in decoder listings the device local address space for
|
|
|
e0018b |
endpoint decoders with active / allocated capacity.
|
|
|
e0018b |
|
|
|
e0018b |
Link: https://lore.kernel.org/r/165781812967.1555691.4685129673233918478.stgit@dwillia2-xfh.jf.intel.com
|
|
|
e0018b |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
---
|
|
|
e0018b |
Documentation/cxl/lib/libcxl.txt | 2 ++
|
|
|
e0018b |
cxl/json.c | 18 +++++++++++++
|
|
|
e0018b |
cxl/lib/libcxl.c | 43 +++++++++++++++++++++++++++++++-
|
|
|
e0018b |
cxl/lib/libcxl.sym | 6 +++++
|
|
|
e0018b |
cxl/lib/private.h | 2 ++
|
|
|
e0018b |
cxl/libcxl.h | 2 ++
|
|
|
e0018b |
6 files changed, 72 insertions(+), 1 deletion(-)
|
|
|
e0018b |
|
|
|
e0018b |
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
|
|
|
e0018b |
index f8f0e66..2aef489 100644
|
|
|
e0018b |
--- a/Documentation/cxl/lib/libcxl.txt
|
|
|
e0018b |
+++ b/Documentation/cxl/lib/libcxl.txt
|
|
|
e0018b |
@@ -392,6 +392,8 @@ more CXL decoder objects.
|
|
|
e0018b |
----
|
|
|
e0018b |
unsigned long long cxl_decoder_get_resource(struct cxl_decoder *decoder);
|
|
|
e0018b |
unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder);
|
|
|
e0018b |
+unsigned long long cxl_decoder_get_dpa_resource(struct cxl_decoder *decoder);
|
|
|
e0018b |
+unsigned long long cxl_decoder_get_dpa_size(struct cxl_decoder *decoder);
|
|
|
e0018b |
const char *cxl_decoder_get_devname(struct cxl_decoder *decoder);
|
|
|
e0018b |
int cxl_decoder_get_id(struct cxl_decoder *decoder);
|
|
|
e0018b |
int cxl_decoder_get_nr_targets(struct cxl_decoder *decoder);
|
|
|
e0018b |
diff --git a/cxl/json.c b/cxl/json.c
|
|
|
e0018b |
index a213fda..3f52d3b 100644
|
|
|
e0018b |
--- a/cxl/json.c
|
|
|
e0018b |
+++ b/cxl/json.c
|
|
|
e0018b |
@@ -472,6 +472,24 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
|
|
|
e0018b |
json_object_object_add(jdecoder, "state", jobj);
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
+ if (cxl_port_is_endpoint(port)) {
|
|
|
e0018b |
+ size = cxl_decoder_get_dpa_size(decoder);
|
|
|
e0018b |
+ val = cxl_decoder_get_dpa_resource(decoder);
|
|
|
e0018b |
+ if (size && val < ULLONG_MAX) {
|
|
|
e0018b |
+ jobj = util_json_object_hex(val, flags);
|
|
|
e0018b |
+ if (jobj)
|
|
|
e0018b |
+ json_object_object_add(jdecoder, "dpa_resource",
|
|
|
e0018b |
+ jobj);
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (size && size < ULLONG_MAX) {
|
|
|
e0018b |
+ jobj = util_json_object_size(size, flags);
|
|
|
e0018b |
+ if (jobj)
|
|
|
e0018b |
+ json_object_object_add(jdecoder, "dpa_size",
|
|
|
e0018b |
+ jobj);
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
if (cxl_port_is_root(port) && cxl_decoder_is_mem_capable(decoder)) {
|
|
|
e0018b |
if (cxl_decoder_is_pmem_capable(decoder)) {
|
|
|
e0018b |
jobj = json_object_new_boolean(true);
|
|
|
e0018b |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
|
e0018b |
index bf3568d..6f4d64d 100644
|
|
|
e0018b |
--- a/cxl/lib/libcxl.c
|
|
|
e0018b |
+++ b/cxl/lib/libcxl.c
|
|
|
e0018b |
@@ -956,8 +956,19 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
|
|
|
e0018b |
decoder->size = strtoull(buf, NULL, 0);
|
|
|
e0018b |
|
|
|
e0018b |
switch (port->type) {
|
|
|
e0018b |
- case CXL_PORT_SWITCH:
|
|
|
e0018b |
case CXL_PORT_ENDPOINT:
|
|
|
e0018b |
+ sprintf(path, "%s/dpa_resource", cxldecoder_base);
|
|
|
e0018b |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
|
e0018b |
+ decoder->dpa_resource = ULLONG_MAX;
|
|
|
e0018b |
+ else
|
|
|
e0018b |
+ decoder->dpa_resource = strtoull(buf, NULL, 0);
|
|
|
e0018b |
+ sprintf(path, "%s/dpa_size", cxldecoder_base);
|
|
|
e0018b |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
|
e0018b |
+ decoder->dpa_size = ULLONG_MAX;
|
|
|
e0018b |
+ else
|
|
|
e0018b |
+ decoder->dpa_size = strtoull(buf, NULL, 0);
|
|
|
e0018b |
+
|
|
|
e0018b |
+ case CXL_PORT_SWITCH:
|
|
|
e0018b |
decoder->pmem_capable = true;
|
|
|
e0018b |
decoder->volatile_capable = true;
|
|
|
e0018b |
decoder->mem_capable = true;
|
|
|
e0018b |
@@ -1114,6 +1125,36 @@ CXL_EXPORT unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder)
|
|
|
e0018b |
return decoder->size;
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
+CXL_EXPORT unsigned long long
|
|
|
e0018b |
+cxl_decoder_get_dpa_resource(struct cxl_decoder *decoder)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
e0018b |
+ struct cxl_ctx *ctx = cxl_decoder_get_ctx(decoder);
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (!cxl_port_is_endpoint(port)) {
|
|
|
e0018b |
+ err(ctx, "%s: not an endpoint decoder\n",
|
|
|
e0018b |
+ cxl_decoder_get_devname(decoder));
|
|
|
e0018b |
+ return ULLONG_MAX;
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
+ return decoder->dpa_resource;
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
+CXL_EXPORT unsigned long long
|
|
|
e0018b |
+cxl_decoder_get_dpa_size(struct cxl_decoder *decoder)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
|
e0018b |
+ struct cxl_ctx *ctx = cxl_decoder_get_ctx(decoder);
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (!cxl_port_is_endpoint(port)) {
|
|
|
e0018b |
+ err(ctx, "%s: not an endpoint decoder\n",
|
|
|
e0018b |
+ cxl_decoder_get_devname(decoder));
|
|
|
e0018b |
+ return ULLONG_MAX;
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
+ return decoder->dpa_size;
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
CXL_EXPORT enum cxl_decoder_target_type
|
|
|
e0018b |
cxl_decoder_get_target_type(struct cxl_decoder *decoder)
|
|
|
e0018b |
{
|
|
|
e0018b |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
|
e0018b |
index dffcb60..8e2fc75 100644
|
|
|
e0018b |
--- a/cxl/lib/libcxl.sym
|
|
|
e0018b |
+++ b/cxl/lib/libcxl.sym
|
|
|
e0018b |
@@ -167,3 +167,9 @@ global:
|
|
|
e0018b |
cxl_cmd_new_set_partition;
|
|
|
e0018b |
cxl_cmd_partition_set_mode;
|
|
|
e0018b |
} LIBCXL_1;
|
|
|
e0018b |
+
|
|
|
e0018b |
+LIBCXL_3 {
|
|
|
e0018b |
+global:
|
|
|
e0018b |
+ cxl_decoder_get_dpa_resource;
|
|
|
e0018b |
+ cxl_decoder_get_dpa_size;
|
|
|
e0018b |
+} LIBCXL_2;
|
|
|
e0018b |
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
|
|
|
e0018b |
index c6d88f7..24a2ae6 100644
|
|
|
e0018b |
--- a/cxl/lib/private.h
|
|
|
e0018b |
+++ b/cxl/lib/private.h
|
|
|
e0018b |
@@ -101,6 +101,8 @@ struct cxl_decoder {
|
|
|
e0018b |
struct cxl_ctx *ctx;
|
|
|
e0018b |
u64 start;
|
|
|
e0018b |
u64 size;
|
|
|
e0018b |
+ u64 dpa_resource;
|
|
|
e0018b |
+ u64 dpa_size;
|
|
|
e0018b |
void *dev_buf;
|
|
|
e0018b |
size_t buf_len;
|
|
|
e0018b |
char *dev_path;
|
|
|
e0018b |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
|
e0018b |
index 0007f4d..76aebe3 100644
|
|
|
e0018b |
--- a/cxl/libcxl.h
|
|
|
e0018b |
+++ b/cxl/libcxl.h
|
|
|
e0018b |
@@ -129,6 +129,8 @@ struct cxl_decoder *cxl_decoder_get_first(struct cxl_port *port);
|
|
|
e0018b |
struct cxl_decoder *cxl_decoder_get_next(struct cxl_decoder *decoder);
|
|
|
e0018b |
unsigned long long cxl_decoder_get_resource(struct cxl_decoder *decoder);
|
|
|
e0018b |
unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder);
|
|
|
e0018b |
+unsigned long long cxl_decoder_get_dpa_resource(struct cxl_decoder *decoder);
|
|
|
e0018b |
+unsigned long long cxl_decoder_get_dpa_size(struct cxl_decoder *decoder);
|
|
|
e0018b |
const char *cxl_decoder_get_devname(struct cxl_decoder *decoder);
|
|
|
e0018b |
struct cxl_target *cxl_decoder_get_target_by_memdev(struct cxl_decoder *decoder,
|
|
|
e0018b |
struct cxl_memdev *memdev);
|
|
|
e0018b |
--
|
|
|
e0018b |
2.27.0
|
|
|
e0018b |
|