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