Add the retrieval of extended linear cache if the sysfs attribute exists and the libcxl function that retrieves the size of the extended linear cache. Support for cxl list also is added and presents the json attribute if the extended linear cache size is greater than 0.
Signed-off-by: Dave Jiang <[email protected]> --- cxl/json.c | 10 ++++++++++ cxl/lib/libcxl.c | 10 ++++++++++ cxl/lib/libcxl.sym | 5 +++++ cxl/lib/private.h | 1 + cxl/libcxl.h | 2 ++ 5 files changed, 28 insertions(+) diff --git a/cxl/json.c b/cxl/json.c index bde4589065e7..e9cb88afa43f 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -994,6 +994,16 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region, json_object_object_add(jregion, "size", jobj); } + val = cxl_region_get_extended_linear_cache_size(region); + if (val > 0) { + jobj = util_json_object_size(val, flags); + if (jobj) { + json_object_object_add(jregion, + "extended_linear_cache_size", + jobj); + } + } + if (mode != CXL_DECODER_MODE_NONE) { jobj = json_object_new_string(cxl_decoder_mode_name(mode)); if (jobj) diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c index cafde1cee4e8..32728de9cab6 100644 --- a/cxl/lib/libcxl.c +++ b/cxl/lib/libcxl.c @@ -585,6 +585,10 @@ static void *add_cxl_region(void *parent, int id, const char *cxlregion_base) else region->size = strtoull(buf, NULL, 0); + sprintf(path, "%s/extended_linear_cache_size", cxlregion_base); + if (sysfs_read_attr(ctx, path, buf) == 0) + region->cache_size = strtoull(buf, NULL, 0); + sprintf(path, "%s/resource", cxlregion_base); if (sysfs_read_attr(ctx, path, buf) == 0) resource = strtoull(buf, NULL, 0); @@ -744,6 +748,12 @@ CXL_EXPORT unsigned long long cxl_region_get_size(struct cxl_region *region) return region->size; } +CXL_EXPORT unsigned long long +cxl_region_get_extended_linear_cache_size(struct cxl_region *region) +{ + return region->cache_size; +} + CXL_EXPORT unsigned long long cxl_region_get_resource(struct cxl_region *region) { return region->start; diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym index e01a676cdeb9..36a93c3c262a 100644 --- a/cxl/lib/libcxl.sym +++ b/cxl/lib/libcxl.sym @@ -300,3 +300,8 @@ LIBCXL_10 { global: cxl_memdev_is_port_ancestor; } LIBCXL_9; + +LIBCXL_11 { +global: + cxl_region_get_extended_linear_cache_size; +} LIBCXL_10; diff --git a/cxl/lib/private.h b/cxl/lib/private.h index 7d5a1bcc14ac..542cdb7eec7c 100644 --- a/cxl/lib/private.h +++ b/cxl/lib/private.h @@ -174,6 +174,7 @@ struct cxl_region { uuid_t uuid; u64 start; u64 size; + u64 cache_size; unsigned int interleave_ways; unsigned int interleave_granularity; enum cxl_decode_state decode_state; diff --git a/cxl/libcxl.h b/cxl/libcxl.h index 54bc025b121d..9371aac943fb 100644 --- a/cxl/libcxl.h +++ b/cxl/libcxl.h @@ -327,6 +327,8 @@ int cxl_region_get_id(struct cxl_region *region); const char *cxl_region_get_devname(struct cxl_region *region); void cxl_region_get_uuid(struct cxl_region *region, uuid_t uu); unsigned long long cxl_region_get_size(struct cxl_region *region); +unsigned long long +cxl_region_get_extended_linear_cache_size(struct cxl_region *region); unsigned long long cxl_region_get_resource(struct cxl_region *region); enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region); unsigned int cxl_region_get_interleave_ways(struct cxl_region *region); base-commit: 38f04b06ac0b0d116b24cefc603cdeb479ab205b -- 2.51.0
