|
|
2eb93d |
From c7ae078f1050ed54e254377404af2ae0879f2a39 Mon Sep 17 00:00:00 2001
|
|
|
2eb93d |
From: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
2eb93d |
Date: Thu, 7 Oct 2021 02:21:30 -0600
|
|
|
2eb93d |
Subject: [PATCH 038/217] libcxl: add support for the 'GET_LSA' command
|
|
|
2eb93d |
|
|
|
2eb93d |
Add a command allocator and accessor APIs for the 'GET_LSA' mailbox
|
|
|
2eb93d |
command.
|
|
|
2eb93d |
|
|
|
2eb93d |
Cc: Ben Widawsky <ben.widawsky@intel.com>
|
|
|
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 | 36 ++++++++++++++++++++++++++++++++++++
|
|
|
2eb93d |
cxl/lib/libcxl.sym | 2 ++
|
|
|
2eb93d |
cxl/lib/private.h | 5 +++++
|
|
|
2eb93d |
cxl/libcxl.h | 4 ++++
|
|
|
2eb93d |
4 files changed, 47 insertions(+)
|
|
|
2eb93d |
|
|
|
2eb93d |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
|
2eb93d |
index 065824d..76913a2 100644
|
|
|
2eb93d |
--- a/cxl/lib/libcxl.c
|
|
|
2eb93d |
+++ b/cxl/lib/libcxl.c
|
|
|
2eb93d |
@@ -1036,6 +1036,42 @@ CXL_EXPORT struct cxl_cmd *cxl_cmd_new_raw(struct cxl_memdev *memdev,
|
|
|
2eb93d |
return cmd;
|
|
|
2eb93d |
}
|
|
|
2eb93d |
|
|
|
2eb93d |
+CXL_EXPORT struct cxl_cmd *cxl_cmd_new_read_label(struct cxl_memdev *memdev,
|
|
|
2eb93d |
+ unsigned int offset, unsigned int length)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_cmd_get_lsa_in *get_lsa;
|
|
|
2eb93d |
+ struct cxl_cmd *cmd;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ cmd = cxl_cmd_new_generic(memdev, CXL_MEM_COMMAND_ID_GET_LSA);
|
|
|
2eb93d |
+ if (!cmd)
|
|
|
2eb93d |
+ return NULL;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ get_lsa = (struct cxl_cmd_get_lsa_in *)cmd->send_cmd->in.payload;
|
|
|
2eb93d |
+ get_lsa->offset = cpu_to_le32(offset);
|
|
|
2eb93d |
+ get_lsa->length = cpu_to_le32(length);
|
|
|
2eb93d |
+ return cmd;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+CXL_EXPORT ssize_t cxl_cmd_read_label_get_payload(struct cxl_cmd *cmd,
|
|
|
2eb93d |
+ void *buf, unsigned int length)
|
|
|
2eb93d |
+{
|
|
|
2eb93d |
+ struct cxl_cmd_get_lsa_in *get_lsa;
|
|
|
2eb93d |
+ void *payload;
|
|
|
2eb93d |
+ int rc;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ rc = cxl_cmd_validate_status(cmd, CXL_MEM_COMMAND_ID_GET_LSA);
|
|
|
2eb93d |
+ if (rc)
|
|
|
2eb93d |
+ return rc;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ get_lsa = (struct cxl_cmd_get_lsa_in *)cmd->send_cmd->in.payload;
|
|
|
2eb93d |
+ if (length > le32_to_cpu(get_lsa->length))
|
|
|
2eb93d |
+ return -EINVAL;
|
|
|
2eb93d |
+
|
|
|
2eb93d |
+ payload = (void *)cmd->send_cmd->out.payload;
|
|
|
2eb93d |
+ memcpy(buf, payload, length);
|
|
|
2eb93d |
+ return length;
|
|
|
2eb93d |
+}
|
|
|
2eb93d |
+
|
|
|
2eb93d |
CXL_EXPORT int cxl_cmd_submit(struct cxl_cmd *cmd)
|
|
|
2eb93d |
{
|
|
|
2eb93d |
struct cxl_memdev *memdev = cmd->memdev;
|
|
|
2eb93d |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
|
2eb93d |
index c83bc28..629322c 100644
|
|
|
2eb93d |
--- a/cxl/lib/libcxl.sym
|
|
|
2eb93d |
+++ b/cxl/lib/libcxl.sym
|
|
|
2eb93d |
@@ -62,6 +62,8 @@ global:
|
|
|
2eb93d |
cxl_cmd_health_info_get_dirty_shutdowns;
|
|
|
2eb93d |
cxl_cmd_health_info_get_volatile_errors;
|
|
|
2eb93d |
cxl_cmd_health_info_get_pmem_errors;
|
|
|
2eb93d |
+ cxl_cmd_new_read_label;
|
|
|
2eb93d |
+ cxl_cmd_read_label_get_payload;
|
|
|
2eb93d |
local:
|
|
|
2eb93d |
*;
|
|
|
2eb93d |
};
|
|
|
2eb93d |
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
|
|
|
2eb93d |
index 885553a..bf3a897 100644
|
|
|
2eb93d |
--- a/cxl/lib/private.h
|
|
|
2eb93d |
+++ b/cxl/lib/private.h
|
|
|
2eb93d |
@@ -73,6 +73,11 @@ struct cxl_cmd_identify {
|
|
|
2eb93d |
u8 qos_telemetry_caps;
|
|
|
2eb93d |
} __attribute__((packed));
|
|
|
2eb93d |
|
|
|
2eb93d |
+struct cxl_cmd_get_lsa_in {
|
|
|
2eb93d |
+ le32 offset;
|
|
|
2eb93d |
+ le32 length;
|
|
|
2eb93d |
+} __attribute__((packed));
|
|
|
2eb93d |
+
|
|
|
2eb93d |
struct cxl_cmd_get_health_info {
|
|
|
2eb93d |
u8 health_status;
|
|
|
2eb93d |
u8 media_status;
|
|
|
2eb93d |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
|
2eb93d |
index eae2db8..7408745 100644
|
|
|
2eb93d |
--- a/cxl/libcxl.h
|
|
|
2eb93d |
+++ b/cxl/libcxl.h
|
|
|
2eb93d |
@@ -95,6 +95,10 @@ int cxl_cmd_health_info_get_temperature(struct cxl_cmd *cmd);
|
|
|
2eb93d |
int cxl_cmd_health_info_get_dirty_shutdowns(struct cxl_cmd *cmd);
|
|
|
2eb93d |
int cxl_cmd_health_info_get_volatile_errors(struct cxl_cmd *cmd);
|
|
|
2eb93d |
int cxl_cmd_health_info_get_pmem_errors(struct cxl_cmd *cmd);
|
|
|
2eb93d |
+struct cxl_cmd *cxl_cmd_new_read_label(struct cxl_memdev *memdev,
|
|
|
2eb93d |
+ unsigned int offset, unsigned int length);
|
|
|
2eb93d |
+ssize_t cxl_cmd_read_label_get_payload(struct cxl_cmd *cmd, void *buf,
|
|
|
2eb93d |
+ unsigned int length);
|
|
|
2eb93d |
|
|
|
2eb93d |
#ifdef __cplusplus
|
|
|
2eb93d |
} /* extern "C" */
|
|
|
2eb93d |
--
|
|
|
2eb93d |
2.27.0
|
|
|
2eb93d |
|