cxl: Add support for extended linear cache
Subsystems (2)
Dave Jiang
maintainerPATCH v2 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.
---
v2:
- Add documentation. (Alison)
--- Documentation/cxl/cxl-list.txt | 15 +++++++++++++++ Documentation/cxl/lib/libcxl.txt | 1 + cxl/json.c | 10 ++++++++++ cxl/lib/libcxl.c | 10 ++++++++++ cxl/lib/libcxl.sym | 5 +++++ cxl/lib/private.h | 1 + cxl/libcxl.h | 2 ++ 7 files changed, 44 insertions(+)
Documentation/cxl/cxl-list.txt +15 -0
@@ -409,6 +409,21 @@ OPTIONS ] } } + +# cxl list -R +[ + { + "region":"region0", + "resource":277025390592, + "size":549755813888, + "extended_linear_cache_size":274877906944, + "type":"ram", + "interleave_ways":2, + "interleave_granularity":256, + "decode_state":"commit", + "qos_class_mismatch":true + } +] ---- -r::
Documentation/cxl/lib/libcxl.txt +1 -0
@@ -588,6 +588,7 @@ 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); enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region); unsigned long long cxl_region_get_resource(struct cxl_region *region); unsigned int cxl_region_get_interleave_ways(struct cxl_region *region);
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.
Thanks for adding the man page example. I hadn't realized we had no example for 'cxl list -R' previously. Now we do.
Reviewed and applied w this note:
[ as: move cxl-list example under "cxl -R" ]
https://github.com/pmem/ndctl/commit/01c90830d65b6b331986f5996dcf6ad73c1579f4
Quoted 145 lines
Signed-off-by Dave Jiang <[email protected]>---
v2:
- Add documentation. (Alison)--- Documentation/cxl/cxl-list.txt | 15 +++++++++++++++ Documentation/cxl/lib/libcxl.txt | 1 + cxl/json.c | 10 ++++++++++ cxl/lib/libcxl.c | 10 ++++++++++ cxl/lib/libcxl.sym | 5 +++++ cxl/lib/private.h | 1 + cxl/libcxl.h | 2 ++ 7 files changed, 44 insertions(+)Documentation/cxl/cxl-list.txt +15
-0@@ -409,6 +409,21 @@ OPTIONS ] } } + +# cxl list -R +[ + { + "region":"region0", + "resource":277025390592, + "size":549755813888, + "extended_linear_cache_size":274877906944, + "type":"ram", + "interleave_ways":2, + "interleave_granularity":256, + "decode_state":"commit", + "qos_class_mismatch":true + } +] ---- -r::Documentation/cxl/lib/libcxl.txt +1
-0@@ -588,6 +588,7 @@ 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); enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region); unsigned long long cxl_region_get_resource(struct cxl_region *region); unsigned int cxl_region_get_interleave_ways(struct cxl_region *region);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:
38f04b06ac0b0d116b24cefc603cdeb479ab205bSignature · 1 line
2.51.0