cxl: Add support for extended linear cache
Dave Jiang
maintainerPATCH 1/1 cxl: Add support for extended linear cache
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(+)
cxl/json.c +10 -0
@@ -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)
cxl/lib/libcxl.c +10 -0
@@ -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;
cxl/lib/libcxl.sym +5 -0
@@ -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;
cxl/lib/private.h +1 -0
@@ -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;
cxl/libcxl.h +2 -0
@@ -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
Signature · 1 line
2.51.0
Alison Schofield
maintainerQuoted 4 lines · Dave Jiang
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.
Please update
- Documentation/cxl/lib/libcxl.txt
- Documentation/cxl/cxl-list.txt
Otherwise, looks good!