|
|
2eb93d |
From 101966ed3e4a73a6e0e1c269306e976040e068a9 Mon Sep 17 00:00:00 2001
|
|
|
2eb93d |
From: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
2eb93d |
Date: Thu, 7 Oct 2021 02:21:32 -0600
|
|
|
2eb93d |
Subject: [PATCH 039/217] libcxl: add label_size to cxl_memdev, and an API to
|
|
|
2eb93d |
retrieve it
|
|
|
2eb93d |
|
|
|
2eb93d |
Size of the Label Storage Area (LSA) is available as a sysfs attribute
|
|
|
2eb93d |
called 'label_storage_size'. Add that to libcxl's memdev so that it is available
|
|
|
2eb93d |
for label related commands.
|
|
|
2eb93d |
|
|
|
2eb93d |
Cc: Dan Williams <dan.j.williams@intel.com>
|
|
|
2eb93d |
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
2eb93d |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
2eb93d |
---
|
|
|
2eb93d |
cxl/lib/libcxl.c | 12 ++++++++++++
|
|
|
2eb93d |
cxl/lib/libcxl.sym | 1 +
|
|
|
2eb93d |
cxl/lib/private.h | 1 +
|
|
|
2eb93d |
cxl/libcxl.h | 1 +
|
|
|
2eb93d |
4 files changed, 15 insertions(+)
|
|
|
2eb93d |
|
|
|
2eb93d |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
|
2eb93d |
index 76913a2..def3a97 100644
|
|
|
2eb93d |
--- a/cxl/lib/libcxl.c
|
|
|
2eb93d |
+++ b/cxl/lib/libcxl.c
|
|
|
2eb93d |
@@ -247,6 +247,13 @@ static void *add_cxl_memdev(void *parent, int id, const char *cxlmem_base)
|
|
|
2eb93d |
if (memdev->payload_max < 0)
|
|
|
2eb93d |
goto err_read;
|
|
|
2eb93d |
|
|
|
2eb93d |
+ sprintf(path, "%s/label_storage_size", cxlmem_base);
|
|
|
2eb93d |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
|
2eb93d |
+ goto err_read;
|
|
|
2eb93d |
+ memdev->lsa_size = strtoull(buf, NULL, 0);
|
|
|
2eb93d |
+ if (memdev->lsa_size == ULLONG_MAX)
|
|
|
2eb93d |
+ goto err_read;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
memdev->dev_path = strdup(cxlmem_base);
|
|
|
2eb93d |
if (!memdev->dev_path)
|
|
|
2eb93d |
goto err_read;
|
|
|
2eb93d |
@@ -350,6 +357,11 @@ CXL_EXPORT const char *cxl_memdev_get_firmware_verison(struct cxl_memdev *memdev
|
|
|
2eb93d |
return memdev->firmware_version;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+CXL_EXPORT size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ return memdev->lsa_size;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
CXL_EXPORT void cxl_cmd_unref(struct cxl_cmd *cmd)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
if (!cmd)
|
|
|
2eb93d |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
|
2eb93d |
index 629322c..858e953 100644
|
|
|
2eb93d |
--- a/cxl/lib/libcxl.sym
|
|
|
2eb93d |
+++ b/cxl/lib/libcxl.sym
|
|
|
2eb93d |
@@ -64,6 +64,7 @@ global:
|
|
|
2eb93d |
cxl_cmd_health_info_get_pmem_errors;
|
|
|
2eb93d |
cxl_cmd_new_read_label;
|
|
|
2eb93d |
cxl_cmd_read_label_get_payload;
|
|
|
2eb93d |
+ cxl_memdev_get_label_size;
|
|
|
2eb93d |
local:
|
|
|
2eb93d |
*;
|
|
|
2eb93d |
};
|
|
|
2eb93d |
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
|
|
|
2eb93d |
index bf3a897..c4ed741 100644
|
|
|
2eb93d |
--- a/cxl/lib/private.h
|
|
|
2eb93d |
+++ b/cxl/lib/private.h
|
|
|
2eb93d |
@@ -21,6 +21,7 @@ struct cxl_memdev {
|
|
|
2eb93d |
unsigned long long pmem_size;
|
|
|
2eb93d |
unsigned long long ram_size;
|
|
|
2eb93d |
int payload_max;
|
|
|
2eb93d |
+ size_t lsa_size;
|
|
|
2eb93d |
struct kmod_module *module;
|
|
|
2eb93d |
};
|
|
|
2eb93d |
|
|
|
2eb93d |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
|
2eb93d |
index 7408745..d3b97a1 100644
|
|
|
2eb93d |
--- a/cxl/libcxl.h
|
|
|
2eb93d |
+++ b/cxl/libcxl.h
|
|
|
2eb93d |
@@ -42,6 +42,7 @@ struct cxl_ctx *cxl_memdev_get_ctx(struct cxl_memdev *memdev);
|
|
|
2eb93d |
unsigned long long cxl_memdev_get_pmem_size(struct cxl_memdev *memdev);
|
|
|
2eb93d |
unsigned long long cxl_memdev_get_ram_size(struct cxl_memdev *memdev);
|
|
|
2eb93d |
const char *cxl_memdev_get_firmware_verison(struct cxl_memdev *memdev);
|
|
|
2eb93d |
+size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev);
|
|
|
2eb93d |
|
|
|
2eb93d |
#define cxl_memdev_foreach(ctx, memdev) \
|
|
|
2eb93d |
for (memdev = cxl_memdev_get_first(ctx); \
|
|
|
2eb93d |
--
|
|
|
2eb93d |
2.27.0
|
|
|
2eb93d |
|