aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorVishal Verma <vishal.l.verma@intel.com>2021-10-07 02:21:32 -0600
committerVishal Verma <vishal.l.verma@intel.com>2021-12-09 14:06:43 -0700
commit101966ed3e4a73a6e0e1c269306e976040e068a9 (patch)
tree828b21774da02fc3ccdedde6fed01e5fe376b850
parentc7ae078f1050ed54e254377404af2ae0879f2a39 (diff)
libcxl: add label_size to cxl_memdev, and an API to retrieve it
Size of the Label Storage Area (LSA) is available as a sysfs attribute called 'label_storage_size'. Add that to libcxl's memdev so that it is available for label related commands. Cc: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
-rw-r--r--cxl/lib/libcxl.c12
-rw-r--r--cxl/lib/libcxl.sym1
-rw-r--r--cxl/lib/private.h1
-rw-r--r--cxl/libcxl.h1
4 files changed, 15 insertions, 0 deletions
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index 76913a2c..def3a97d 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -247,6 +247,13 @@ static void *add_cxl_memdev(void *parent, int id, const char *cxlmem_base)
if (memdev->payload_max < 0)
goto err_read;
+ sprintf(path, "%s/label_storage_size", cxlmem_base);
+ if (sysfs_read_attr(ctx, path, buf) < 0)
+ goto err_read;
+ memdev->lsa_size = strtoull(buf, NULL, 0);
+ if (memdev->lsa_size == ULLONG_MAX)
+ goto err_read;
+
memdev->dev_path = strdup(cxlmem_base);
if (!memdev->dev_path)
goto err_read;
@@ -350,6 +357,11 @@ CXL_EXPORT const char *cxl_memdev_get_firmware_verison(struct cxl_memdev *memdev
return memdev->firmware_version;
}
+CXL_EXPORT size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev)
+{
+ return memdev->lsa_size;
+}
+
CXL_EXPORT void cxl_cmd_unref(struct cxl_cmd *cmd)
{
if (!cmd)
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
index 629322cf..858e953f 100644
--- a/cxl/lib/libcxl.sym
+++ b/cxl/lib/libcxl.sym
@@ -64,6 +64,7 @@ global:
cxl_cmd_health_info_get_pmem_errors;
cxl_cmd_new_read_label;
cxl_cmd_read_label_get_payload;
+ cxl_memdev_get_label_size;
local:
*;
};
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
index bf3a8978..c4ed7417 100644
--- a/cxl/lib/private.h
+++ b/cxl/lib/private.h
@@ -21,6 +21,7 @@ struct cxl_memdev {
unsigned long long pmem_size;
unsigned long long ram_size;
int payload_max;
+ size_t lsa_size;
struct kmod_module *module;
};
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
index 74087454..d3b97a1d 100644
--- a/cxl/libcxl.h
+++ b/cxl/libcxl.h
@@ -42,6 +42,7 @@ struct cxl_ctx *cxl_memdev_get_ctx(struct cxl_memdev *memdev);
unsigned long long cxl_memdev_get_pmem_size(struct cxl_memdev *memdev);
unsigned long long cxl_memdev_get_ram_size(struct cxl_memdev *memdev);
const char *cxl_memdev_get_firmware_verison(struct cxl_memdev *memdev);
+size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev);
#define cxl_memdev_foreach(ctx, memdev) \
for (memdev = cxl_memdev_get_first(ctx); \