|
Jeff Moyer |
2c91dc |
From cafe4b2d4970b0d7f2193abb9cb32f58c03cbe3b Mon Sep 17 00:00:00 2001
|
|
Jeff Moyer |
2c91dc |
From: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
Date: Mon, 15 Aug 2022 13:22:09 -0600
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 194/217] libcxl: add low level APIs for region creation
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Add libcxl APIs to create a region under a given root decoder, and to
|
|
Jeff Moyer |
2c91dc |
set different attributes for the new region. These allow setting the
|
|
Jeff Moyer |
2c91dc |
size, interleave_ways, interleave_granularity, uuid, and the target
|
|
Jeff Moyer |
2c91dc |
devices for the newly minted cxl_region object.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Link: https://lore.kernel.org/r/20220815192214.545800-7-vishal.l.verma@intel.com
|
|
Jeff Moyer |
2c91dc |
Cc: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
---
|
|
Jeff Moyer |
2c91dc |
Documentation/cxl/lib/libcxl.txt | 69 ++++++
|
|
Jeff Moyer |
2c91dc |
cxl/lib/libcxl.c | 381 ++++++++++++++++++++++++++++++-
|
|
Jeff Moyer |
2c91dc |
cxl/lib/libcxl.sym | 16 ++
|
|
Jeff Moyer |
2c91dc |
cxl/lib/private.h | 2 +
|
|
Jeff Moyer |
2c91dc |
cxl/libcxl.h | 23 +-
|
|
Jeff Moyer |
2c91dc |
5 files changed, 488 insertions(+), 3 deletions(-)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
index 7a38ce4..50b0c9c 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
@@ -508,6 +508,75 @@ device to represent the root of a PCI device hierarchy. The
|
|
Jeff Moyer |
2c91dc |
cxl_target_get_physical_node() helper returns the device name of that
|
|
Jeff Moyer |
2c91dc |
companion object in the PCI hierarchy.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+==== REGIONS
|
|
Jeff Moyer |
2c91dc |
+A CXL region is composed of one or more slices of CXL memdevs, with configurable
|
|
Jeff Moyer |
2c91dc |
+interleave settings - both the number of interleave ways, and the interleave
|
|
Jeff Moyer |
2c91dc |
+granularity. In terms of hierarchy, it is the child of a CXL root decoder. A root
|
|
Jeff Moyer |
2c91dc |
+decoder (recall that this corresponds to an ACPI CEDT.CFMWS 'window'), may have
|
|
Jeff Moyer |
2c91dc |
+multiple child regions, but a region is strictly tied to one root decoder.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+The slices that compose a region are called mappings. A mapping is a
|
|
Jeff Moyer |
2c91dc |
+tuple of 'memdev', 'endpoint decoder', and the 'position'.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+===== REGION: Enumeration
|
|
Jeff Moyer |
2c91dc |
+----
|
|
Jeff Moyer |
2c91dc |
+struct cxl_region *cxl_region_get_first(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
+struct cxl_region *cxl_region_get_next(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#define cxl_region_foreach(decoder, region) \
|
|
Jeff Moyer |
2c91dc |
+ for (region = cxl_region_get_first(decoder); region != NULL; \
|
|
Jeff Moyer |
2c91dc |
+ region = cxl_region_get_next(region))
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#define cxl_region_foreach_safe(decoder, region, _region) \
|
|
Jeff Moyer |
2c91dc |
+ for (region = cxl_region_get_first(decoder), \
|
|
Jeff Moyer |
2c91dc |
+ _region = region ? cxl_region_get_next(region) : NULL; \
|
|
Jeff Moyer |
2c91dc |
+ region != NULL; \
|
|
Jeff Moyer |
2c91dc |
+ region = _region, \
|
|
Jeff Moyer |
2c91dc |
+ _region = _region ? cxl_region_get_next(_region) : NULL)
|
|
Jeff Moyer |
2c91dc |
+----
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+===== REGION: Attributes
|
|
Jeff Moyer |
2c91dc |
+----
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_get_id(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+const char *cxl_region_get_devname(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+void cxl_region_get_uuid(struct cxl_region *region, uuid_t uu);
|
|
Jeff Moyer |
2c91dc |
+unsigned long long cxl_region_get_size(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+unsigned long long cxl_region_get_resource(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+unsigned int cxl_region_get_interleave_ways(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+unsigned int cxl_region_get_interleave_granularity(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+struct cxl_decoder *cxl_region_get_target_decoder(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ int position);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_size(struct cxl_region *region, unsigned long long size);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_uuid(struct cxl_region *region, uuid_t uu);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_interleave_ways(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ unsigned int ways);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_interleave_granularity(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ unsigned int granularity);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_target(struct cxl_region *region, int position,
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_clear_target(struct cxl_region *region, int position);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_clear_all_targets(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_decode_commit(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_decode_reset(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+----
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+A region's resource attribute is the Host Physical Address at which the region's
|
|
Jeff Moyer |
2c91dc |
+address space starts. The region's address space is a subset of the parent root
|
|
Jeff Moyer |
2c91dc |
+decoder's address space.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+The interleave ways is the number of component memdevs participating in the
|
|
Jeff Moyer |
2c91dc |
+region.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+The interleave granularity depends on the root decoder's granularity, and must
|
|
Jeff Moyer |
2c91dc |
+follow the interleave math rules defined in the CXL spec.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+Regions have a list of targets 0..N, which are programmed with the name of an
|
|
Jeff Moyer |
2c91dc |
+endpoint decoder under each participating memdev.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+The 'decode_commit' and 'decode_reset' attributes reserve and free DPA space
|
|
Jeff Moyer |
2c91dc |
+on a given memdev by allocating an endpoint decoder, and programming it based
|
|
Jeff Moyer |
2c91dc |
+on the region's interleave geometry.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
include::../../copyright.txt[]
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
SEE ALSO
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
index ad98188..fd2ea4f 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
@@ -17,6 +17,7 @@
|
|
Jeff Moyer |
2c91dc |
#include <ccan/minmax/minmax.h>
|
|
Jeff Moyer |
2c91dc |
#include <ccan/array_size/array_size.h>
|
|
Jeff Moyer |
2c91dc |
#include <ccan/short_types/short_types.h>
|
|
Jeff Moyer |
2c91dc |
+#include <ccan/container_of/container_of.h>
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
#include <util/log.h>
|
|
Jeff Moyer |
2c91dc |
#include <util/list.h>
|
|
Jeff Moyer |
2c91dc |
@@ -420,6 +421,40 @@ CXL_EXPORT int cxl_region_enable(struct cxl_region *region)
|
|
Jeff Moyer |
2c91dc |
return 0;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+static int cxl_region_delete_name(struct cxl_decoder *decoder,
|
|
Jeff Moyer |
2c91dc |
+ const char *devname)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_decoder_get_ctx(decoder);
|
|
Jeff Moyer |
2c91dc |
+ char *path = decoder->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ int rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ sprintf(path, "%s/delete_region", decoder->dev_path);
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, devname);
|
|
Jeff Moyer |
2c91dc |
+ if (rc != 0) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "error deleting region: %s\n", strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_delete(struct cxl_region *region)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_decoder *decoder = cxl_region_get_decoder(region);
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ int rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (cxl_region_is_enabled(region))
|
|
Jeff Moyer |
2c91dc |
+ return -EBUSY;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ rc = cxl_region_delete_name(decoder, devname);
|
|
Jeff Moyer |
2c91dc |
+ if (rc != 0)
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ decoder->regions_init = 0;
|
|
Jeff Moyer |
2c91dc |
+ free_region(region, &decoder->regions);
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
static void *add_cxl_region(void *parent, int id, const char *cxlregion_base)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
const char *devname = devpath_to_devname(cxlregion_base);
|
|
Jeff Moyer |
2c91dc |
@@ -599,6 +634,258 @@ cxl_region_get_interleave_granularity(struct cxl_region *region)
|
|
Jeff Moyer |
2c91dc |
return region->interleave_granularity;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT struct cxl_decoder *
|
|
Jeff Moyer |
2c91dc |
+cxl_region_get_target_decoder(struct cxl_region *region, int position)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int len = region->buf_len, rc;
|
|
Jeff Moyer |
2c91dc |
+ char *path = region->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_decoder *decoder;
|
|
Jeff Moyer |
2c91dc |
+ char buf[SYSFS_ATTR_SIZE];
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (snprintf(path, len, "%s/target%d", region->dev_path, position) >=
|
|
Jeff Moyer |
2c91dc |
+ len) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: buffer too small!\n", devname);
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_read_attr(ctx, path, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: error reading target%d: %s\n", devname,
|
|
Jeff Moyer |
2c91dc |
+ position, strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ decoder = cxl_decoder_get_by_name(ctx, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (!decoder) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: error locating decoder for target%d\n", devname,
|
|
Jeff Moyer |
2c91dc |
+ position);
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+ return decoder;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_set_size(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ unsigned long long size)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int len = region->buf_len, rc;
|
|
Jeff Moyer |
2c91dc |
+ char *path = region->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ char buf[SYSFS_ATTR_SIZE];
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (size == 0) {
|
|
Jeff Moyer |
2c91dc |
+ dbg(ctx, "%s: cannot use %s to delete a region\n", __func__,
|
|
Jeff Moyer |
2c91dc |
+ devname);
|
|
Jeff Moyer |
2c91dc |
+ return -EINVAL;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (snprintf(path, len, "%s/size", region->dev_path) >= len) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: buffer too small!\n", devname);
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ sprintf(buf, "%#llx\n", size);
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0)
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ region->size = size;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_set_uuid(struct cxl_region *region, uuid_t uu)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int len = region->buf_len, rc;
|
|
Jeff Moyer |
2c91dc |
+ char *path = region->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ char uuid[SYSFS_ATTR_SIZE];
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (snprintf(path, len, "%s/uuid", region->dev_path) >= len) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: buffer too small!\n", devname);
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ uuid_unparse(uu, uuid);
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, uuid);
|
|
Jeff Moyer |
2c91dc |
+ if (rc != 0)
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+ memcpy(region->uuid, uu, sizeof(uuid_t));
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_set_interleave_ways(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ unsigned int ways)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int len = region->buf_len, rc;
|
|
Jeff Moyer |
2c91dc |
+ char *path = region->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ char buf[SYSFS_ATTR_SIZE];
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (snprintf(path, len, "%s/interleave_ways",
|
|
Jeff Moyer |
2c91dc |
+ region->dev_path) >= len) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: buffer too small!\n", devname);
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ sprintf(buf, "%u\n", ways);
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0)
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ region->interleave_ways = ways;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_set_interleave_granularity(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ unsigned int granularity)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int len = region->buf_len, rc;
|
|
Jeff Moyer |
2c91dc |
+ char *path = region->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ char buf[SYSFS_ATTR_SIZE];
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (snprintf(path, len, "%s/interleave_granularity",
|
|
Jeff Moyer |
2c91dc |
+ region->dev_path) >= len) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: buffer too small!\n", devname);
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ sprintf(buf, "%u\n", granularity);
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0)
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ region->interleave_granularity = granularity;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+static int region_write_target(struct cxl_region *region, int position,
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int len = region->buf_len, rc;
|
|
Jeff Moyer |
2c91dc |
+ char *path = region->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ const char *dec_name = "";
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (decoder)
|
|
Jeff Moyer |
2c91dc |
+ dec_name = cxl_decoder_get_devname(decoder);
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (snprintf(path, len, "%s/target%d", region->dev_path, position) >=
|
|
Jeff Moyer |
2c91dc |
+ len) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: buffer too small!\n", devname);
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, dec_name);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0)
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_set_target(struct cxl_region *region, int position,
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ if (!decoder)
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return region_write_target(region, position, decoder);
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_clear_target(struct cxl_region *region, int position)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (cxl_region_is_enabled(region)) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: can't clear targets on an active region\n",
|
|
Jeff Moyer |
2c91dc |
+ devname);
|
|
Jeff Moyer |
2c91dc |
+ return -EBUSY;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ rc = region_write_target(region, position, NULL);
|
|
Jeff Moyer |
2c91dc |
+ if (rc) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: error clearing target%d: %s\n",
|
|
Jeff Moyer |
2c91dc |
+ devname, position, strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_clear_all_targets(struct cxl_region *region)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ unsigned int ways, i;
|
|
Jeff Moyer |
2c91dc |
+ int rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (cxl_region_is_enabled(region)) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: can't clear targets on an active region\n",
|
|
Jeff Moyer |
2c91dc |
+ devname);
|
|
Jeff Moyer |
2c91dc |
+ return -EBUSY;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ ways = cxl_region_get_interleave_ways(region);
|
|
Jeff Moyer |
2c91dc |
+ if (ways == 0 || ways == UINT_MAX)
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ for (i = 0; i < ways; i++) {
|
|
Jeff Moyer |
2c91dc |
+ rc = region_write_target(region, i, NULL);
|
|
Jeff Moyer |
2c91dc |
+ if (rc) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: error clearing target%d: %s\n",
|
|
Jeff Moyer |
2c91dc |
+ devname, i, strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+static int set_region_decode(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ enum cxl_decode_state decode_state)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
+ int len = region->buf_len, rc;
|
|
Jeff Moyer |
2c91dc |
+ char *path = region->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ char buf[SYSFS_ATTR_SIZE];
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (snprintf(path, len, "%s/commit", region->dev_path) >= len) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "%s: buffer too small!\n", devname);
|
|
Jeff Moyer |
2c91dc |
+ return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ sprintf(buf, "%d\n", decode_state);
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0)
|
|
Jeff Moyer |
2c91dc |
+ return rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ region->decode_state = decode_state;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_decode_commit(struct cxl_region *region)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ return set_region_decode(region, CXL_DECODE_COMMIT);
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_region_decode_reset(struct cxl_region *region)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ return set_region_decode(region, CXL_DECODE_RESET);
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
static struct cxl_decoder *__cxl_port_match_decoder(struct cxl_port *port,
|
|
Jeff Moyer |
2c91dc |
const char *ident)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
@@ -633,8 +920,8 @@ static struct cxl_decoder *cxl_port_find_decoder(struct cxl_port *port,
|
|
Jeff Moyer |
2c91dc |
return NULL;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-static struct cxl_decoder *cxl_decoder_get_by_name(struct cxl_ctx *ctx,
|
|
Jeff Moyer |
2c91dc |
- const char *ident)
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT struct cxl_decoder *cxl_decoder_get_by_name(struct cxl_ctx *ctx,
|
|
Jeff Moyer |
2c91dc |
+ const char *ident)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
struct cxl_bus *bus;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
@@ -1399,6 +1686,18 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
|
|
Jeff Moyer |
2c91dc |
} else
|
|
Jeff Moyer |
2c91dc |
decoder->mode = CXL_DECODER_MODE_NONE;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+ sprintf(path, "%s/interleave_granularity", cxldecoder_base);
|
|
Jeff Moyer |
2c91dc |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
Jeff Moyer |
2c91dc |
+ decoder->interleave_granularity = UINT_MAX;
|
|
Jeff Moyer |
2c91dc |
+ else
|
|
Jeff Moyer |
2c91dc |
+ decoder->interleave_granularity = strtoul(buf, NULL, 0);
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ sprintf(path, "%s/interleave_ways", cxldecoder_base);
|
|
Jeff Moyer |
2c91dc |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
Jeff Moyer |
2c91dc |
+ decoder->interleave_ways = UINT_MAX;
|
|
Jeff Moyer |
2c91dc |
+ else
|
|
Jeff Moyer |
2c91dc |
+ decoder->interleave_ways = strtoul(buf, NULL, 0);
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
switch (port->type) {
|
|
Jeff Moyer |
2c91dc |
case CXL_PORT_ENDPOINT:
|
|
Jeff Moyer |
2c91dc |
sprintf(path, "%s/dpa_resource", cxldecoder_base);
|
|
Jeff Moyer |
2c91dc |
@@ -1731,6 +2030,66 @@ CXL_EXPORT bool cxl_decoder_is_locked(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
return decoder->locked;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT unsigned int
|
|
Jeff Moyer |
2c91dc |
+cxl_decoder_get_interleave_granularity(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ return decoder->interleave_granularity;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT unsigned int
|
|
Jeff Moyer |
2c91dc |
+cxl_decoder_get_interleave_ways(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ return decoder->interleave_ways;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT struct cxl_region *
|
|
Jeff Moyer |
2c91dc |
+cxl_decoder_create_pmem_region(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_ctx *ctx = cxl_decoder_get_ctx(decoder);
|
|
Jeff Moyer |
2c91dc |
+ char *path = decoder->dev_buf;
|
|
Jeff Moyer |
2c91dc |
+ char buf[SYSFS_ATTR_SIZE];
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_region *region;
|
|
Jeff Moyer |
2c91dc |
+ int rc;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ sprintf(path, "%s/create_pmem_region", decoder->dev_path);
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_read_attr(ctx, path, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "failed to read new region name: %s\n",
|
|
Jeff Moyer |
2c91dc |
+ strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ rc = sysfs_write_attr(ctx, path, buf);
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "failed to write new region name: %s\n",
|
|
Jeff Moyer |
2c91dc |
+ strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ /* Force a re-init of regions so that the new one can be discovered */
|
|
Jeff Moyer |
2c91dc |
+ decoder->regions_init = 0;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ /* create_region was successful, walk to the new region */
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_foreach(decoder, region) {
|
|
Jeff Moyer |
2c91dc |
+ const char *devname = cxl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (strcmp(devname, buf) == 0)
|
|
Jeff Moyer |
2c91dc |
+ goto found;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ /*
|
|
Jeff Moyer |
2c91dc |
+ * If walking to the region we just created failed, something has gone
|
|
Jeff Moyer |
2c91dc |
+ * very wrong. Attempt to delete it to avoid leaving a dangling region
|
|
Jeff Moyer |
2c91dc |
+ * id behind.
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+ err(ctx, "failed to add new region to libcxl\n");
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_delete_name(decoder, buf);
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ found:
|
|
Jeff Moyer |
2c91dc |
+ return region;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
CXL_EXPORT int cxl_decoder_get_nr_targets(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
return decoder->nr_targets;
|
|
Jeff Moyer |
2c91dc |
@@ -1741,6 +2100,24 @@ CXL_EXPORT const char *cxl_decoder_get_devname(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
return devpath_to_devname(decoder->dev_path);
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT struct cxl_memdev *
|
|
Jeff Moyer |
2c91dc |
+cxl_decoder_get_memdev(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_port *port = cxl_decoder_get_port(decoder);
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_endpoint *ep;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ if (!port)
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+ if (!cxl_port_is_endpoint(port))
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ ep = container_of(port, struct cxl_endpoint, port);
|
|
Jeff Moyer |
2c91dc |
+ if (!ep)
|
|
Jeff Moyer |
2c91dc |
+ return NULL;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return cxl_endpoint_get_memdev(ep);
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
CXL_EXPORT struct cxl_target *cxl_target_get_first(struct cxl_decoder *decoder)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
return list_top(&decoder->targets, struct cxl_target, list);
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
index e410298..cb23a0b 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
@@ -140,6 +140,7 @@ global:
|
|
Jeff Moyer |
2c91dc |
cxl_decoder_is_mem_capable;
|
|
Jeff Moyer |
2c91dc |
cxl_decoder_is_accelmem_capable;
|
|
Jeff Moyer |
2c91dc |
cxl_decoder_is_locked;
|
|
Jeff Moyer |
2c91dc |
+ cxl_decoder_create_pmem_region;
|
|
Jeff Moyer |
2c91dc |
cxl_target_get_first;
|
|
Jeff Moyer |
2c91dc |
cxl_target_get_next;
|
|
Jeff Moyer |
2c91dc |
cxl_target_get_decoder;
|
|
Jeff Moyer |
2c91dc |
@@ -183,6 +184,7 @@ global:
|
|
Jeff Moyer |
2c91dc |
cxl_region_is_enabled;
|
|
Jeff Moyer |
2c91dc |
cxl_region_disable;
|
|
Jeff Moyer |
2c91dc |
cxl_region_enable;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_delete;
|
|
Jeff Moyer |
2c91dc |
cxl_region_get_ctx;
|
|
Jeff Moyer |
2c91dc |
cxl_region_get_decoder;
|
|
Jeff Moyer |
2c91dc |
cxl_region_get_id;
|
|
Jeff Moyer |
2c91dc |
@@ -192,9 +194,23 @@ global:
|
|
Jeff Moyer |
2c91dc |
cxl_region_get_resource;
|
|
Jeff Moyer |
2c91dc |
cxl_region_get_interleave_ways;
|
|
Jeff Moyer |
2c91dc |
cxl_region_get_interleave_granularity;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_get_target_decoder;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_set_size;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_set_uuid;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_set_interleave_ways;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_set_interleave_granularity;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_set_target;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_clear_target;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_clear_all_targets;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_decode_commit;
|
|
Jeff Moyer |
2c91dc |
+ cxl_region_decode_reset;
|
|
Jeff Moyer |
2c91dc |
cxl_mapping_get_first;
|
|
Jeff Moyer |
2c91dc |
cxl_mapping_get_next;
|
|
Jeff Moyer |
2c91dc |
cxl_mapping_get_decoder;
|
|
Jeff Moyer |
2c91dc |
cxl_mapping_get_region;
|
|
Jeff Moyer |
2c91dc |
cxl_mapping_get_position;
|
|
Jeff Moyer |
2c91dc |
+ cxl_decoder_get_by_name;
|
|
Jeff Moyer |
2c91dc |
+ cxl_decoder_get_memdev;
|
|
Jeff Moyer |
2c91dc |
+ cxl_decoder_get_interleave_granularity;
|
|
Jeff Moyer |
2c91dc |
+ cxl_decoder_get_interleave_ways;
|
|
Jeff Moyer |
2c91dc |
} LIBCXL_2;
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
|
|
Jeff Moyer |
2c91dc |
index 5e2fdd5..8bc9620 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/private.h
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/private.h
|
|
Jeff Moyer |
2c91dc |
@@ -110,6 +110,8 @@ struct cxl_decoder {
|
|
Jeff Moyer |
2c91dc |
int nr_targets;
|
|
Jeff Moyer |
2c91dc |
int id;
|
|
Jeff Moyer |
2c91dc |
enum cxl_decoder_mode mode;
|
|
Jeff Moyer |
2c91dc |
+ unsigned int interleave_ways;
|
|
Jeff Moyer |
2c91dc |
+ unsigned int interleave_granularity;
|
|
Jeff Moyer |
2c91dc |
bool pmem_capable;
|
|
Jeff Moyer |
2c91dc |
bool volatile_capable;
|
|
Jeff Moyer |
2c91dc |
bool mem_capable;
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
index 19d94e4..69d9c09 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
@@ -195,7 +195,13 @@ bool cxl_decoder_is_volatile_capable(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
bool cxl_decoder_is_mem_capable(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
bool cxl_decoder_is_accelmem_capable(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
bool cxl_decoder_is_locked(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
+unsigned int
|
|
Jeff Moyer |
2c91dc |
+cxl_decoder_get_interleave_granularity(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
+unsigned int cxl_decoder_get_interleave_ways(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
+struct cxl_region *cxl_decoder_create_pmem_region(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
+struct cxl_decoder *cxl_decoder_get_by_name(struct cxl_ctx *ctx,
|
|
Jeff Moyer |
2c91dc |
+ const char *ident);
|
|
Jeff Moyer |
2c91dc |
+struct cxl_memdev *cxl_decoder_get_memdev(struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
#define cxl_decoder_foreach(port, decoder) \
|
|
Jeff Moyer |
2c91dc |
for (decoder = cxl_decoder_get_first(port); decoder != NULL; \
|
|
Jeff Moyer |
2c91dc |
decoder = cxl_decoder_get_next(decoder))
|
|
Jeff Moyer |
2c91dc |
@@ -244,6 +250,7 @@ int cxl_region_decode_is_committed(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
int cxl_region_is_enabled(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
int cxl_region_disable(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
int cxl_region_enable(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_delete(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
struct cxl_ctx *cxl_region_get_ctx(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
struct cxl_decoder *cxl_region_get_decoder(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
int cxl_region_get_id(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
@@ -253,6 +260,20 @@ unsigned long long cxl_region_get_size(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
unsigned long long cxl_region_get_resource(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
unsigned int cxl_region_get_interleave_ways(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
unsigned int cxl_region_get_interleave_granularity(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+struct cxl_decoder *cxl_region_get_target_decoder(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ int position);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_size(struct cxl_region *region, unsigned long long size);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_uuid(struct cxl_region *region, uuid_t uu);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_interleave_ways(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ unsigned int ways);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_interleave_granularity(struct cxl_region *region,
|
|
Jeff Moyer |
2c91dc |
+ unsigned int granularity);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_set_target(struct cxl_region *region, int position,
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_decoder *decoder);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_clear_target(struct cxl_region *region, int position);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_clear_all_targets(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_decode_commit(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
+int cxl_region_decode_reset(struct cxl_region *region);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
#define cxl_region_foreach(decoder, region) \
|
|
Jeff Moyer |
2c91dc |
for (region = cxl_region_get_first(decoder); region != NULL; \
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|