|
|
e0018b |
From 244862cbbfecda9b6b638eccaca526f4daba2795 Mon Sep 17 00:00:00 2001
|
|
|
e0018b |
From: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
Date: Thu, 7 Oct 2021 02:21:28 -0600
|
|
|
e0018b |
Subject: [PATCH 036/217] libcxl: add support for the 'Identify Device' command
|
|
|
e0018b |
|
|
|
e0018b |
Add APIs to allocate and send an 'Identify Device' command, and
|
|
|
e0018b |
accessors to retrieve some of the fields from the resulting data.
|
|
|
e0018b |
|
|
|
e0018b |
Only add a handful accessor functions; more can be added as the need
|
|
|
e0018b |
arises. The fields added are fw_revision, partition_align, and
|
|
|
e0018b |
lsa_size.
|
|
|
e0018b |
|
|
|
e0018b |
Cc: Ben Widawsky <ben.widawsky@intel.com>
|
|
|
e0018b |
Cc: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
---
|
|
|
e0018b |
cxl/lib/libcxl.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
e0018b |
cxl/lib/libcxl.sym | 4 ++++
|
|
|
e0018b |
cxl/lib/private.h | 19 +++++++++++++++++
|
|
|
e0018b |
cxl/libcxl.h | 4 ++++
|
|
|
e0018b |
4 files changed, 79 insertions(+)
|
|
|
e0018b |
|
|
|
e0018b |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
|
e0018b |
index 727d599..ed21670 100644
|
|
|
e0018b |
--- a/cxl/lib/libcxl.c
|
|
|
e0018b |
+++ b/cxl/lib/libcxl.c
|
|
|
e0018b |
@@ -13,7 +13,10 @@
|
|
|
e0018b |
#include <sys/sysmacros.h>
|
|
|
e0018b |
#include <uuid/uuid.h>
|
|
|
e0018b |
#include <ccan/list/list.h>
|
|
|
e0018b |
+#include <ccan/endian/endian.h>
|
|
|
e0018b |
+#include <ccan/minmax/minmax.h>
|
|
|
e0018b |
#include <ccan/array_size/array_size.h>
|
|
|
e0018b |
+#include <ccan/short_types/short_types.h>
|
|
|
e0018b |
|
|
|
e0018b |
#include <util/log.h>
|
|
|
e0018b |
#include <util/size.h>
|
|
|
e0018b |
@@ -674,6 +677,55 @@ CXL_EXPORT const char *cxl_cmd_get_devname(struct cxl_cmd *cmd)
|
|
|
e0018b |
return cxl_memdev_get_devname(cmd->memdev);
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
+CXL_EXPORT struct cxl_cmd *cxl_cmd_new_identify(struct cxl_memdev *memdev)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ return cxl_cmd_new_generic(memdev, CXL_MEM_COMMAND_ID_IDENTIFY);
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
+CXL_EXPORT int cxl_cmd_identify_get_fw_rev(struct cxl_cmd *cmd, char *fw_rev,
|
|
|
e0018b |
+ int fw_len)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ struct cxl_cmd_identify *id =
|
|
|
e0018b |
+ (struct cxl_cmd_identify *)cmd->send_cmd->out.payload;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (cmd->send_cmd->id != CXL_MEM_COMMAND_ID_IDENTIFY)
|
|
|
e0018b |
+ return -EINVAL;
|
|
|
e0018b |
+ if (cmd->status < 0)
|
|
|
e0018b |
+ return cmd->status;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (fw_len > 0)
|
|
|
e0018b |
+ memcpy(fw_rev, id->fw_revision,
|
|
|
e0018b |
+ min(fw_len, CXL_CMD_IDENTIFY_FW_REV_LENGTH));
|
|
|
e0018b |
+ return 0;
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
+CXL_EXPORT unsigned long long cxl_cmd_identify_get_partition_align(
|
|
|
e0018b |
+ struct cxl_cmd *cmd)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ struct cxl_cmd_identify *id =
|
|
|
e0018b |
+ (struct cxl_cmd_identify *)cmd->send_cmd->out.payload;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (cmd->send_cmd->id != CXL_MEM_COMMAND_ID_IDENTIFY)
|
|
|
e0018b |
+ return -EINVAL;
|
|
|
e0018b |
+ if (cmd->status < 0)
|
|
|
e0018b |
+ return cmd->status;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ return le64_to_cpu(id->partition_align);
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
+CXL_EXPORT unsigned int cxl_cmd_identify_get_label_size(struct cxl_cmd *cmd)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ struct cxl_cmd_identify *id =
|
|
|
e0018b |
+ (struct cxl_cmd_identify *)cmd->send_cmd->out.payload;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (cmd->send_cmd->id != CXL_MEM_COMMAND_ID_IDENTIFY)
|
|
|
e0018b |
+ return -EINVAL;
|
|
|
e0018b |
+ if (cmd->status < 0)
|
|
|
e0018b |
+ return cmd->status;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ return le32_to_cpu(id->lsa_size);
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
CXL_EXPORT struct cxl_cmd *cxl_cmd_new_raw(struct cxl_memdev *memdev,
|
|
|
e0018b |
int opcode)
|
|
|
e0018b |
{
|
|
|
e0018b |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
|
e0018b |
index 3900f90..1dc45f4 100644
|
|
|
e0018b |
--- a/cxl/lib/libcxl.sym
|
|
|
e0018b |
+++ b/cxl/lib/libcxl.sym
|
|
|
e0018b |
@@ -29,6 +29,10 @@ global:
|
|
|
e0018b |
cxl_cmd_submit;
|
|
|
e0018b |
cxl_cmd_get_mbox_status;
|
|
|
e0018b |
cxl_cmd_get_out_size;
|
|
|
e0018b |
+ cxl_cmd_new_identify;
|
|
|
e0018b |
+ cxl_cmd_identify_get_fw_rev;
|
|
|
e0018b |
+ cxl_cmd_identify_get_partition_align;
|
|
|
e0018b |
+ cxl_cmd_identify_get_label_size;
|
|
|
e0018b |
local:
|
|
|
e0018b |
*;
|
|
|
e0018b |
};
|
|
|
e0018b |
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
|
|
|
e0018b |
index 87ca17e..3273f21 100644
|
|
|
e0018b |
--- a/cxl/lib/private.h
|
|
|
e0018b |
+++ b/cxl/lib/private.h
|
|
|
e0018b |
@@ -54,6 +54,25 @@ struct cxl_cmd {
|
|
|
e0018b |
int status;
|
|
|
e0018b |
};
|
|
|
e0018b |
|
|
|
e0018b |
+#define CXL_CMD_IDENTIFY_FW_REV_LENGTH 0x10
|
|
|
e0018b |
+
|
|
|
e0018b |
+struct cxl_cmd_identify {
|
|
|
e0018b |
+ char fw_revision[CXL_CMD_IDENTIFY_FW_REV_LENGTH];
|
|
|
e0018b |
+ le64 total_capacity;
|
|
|
e0018b |
+ le64 volatile_capacity;
|
|
|
e0018b |
+ le64 persistent_capacity;
|
|
|
e0018b |
+ le64 partition_align;
|
|
|
e0018b |
+ le16 info_event_log_size;
|
|
|
e0018b |
+ le16 warning_event_log_size;
|
|
|
e0018b |
+ le16 failure_event_log_size;
|
|
|
e0018b |
+ le16 fatal_event_log_size;
|
|
|
e0018b |
+ le32 lsa_size;
|
|
|
e0018b |
+ u8 poison_list_max_mer[3];
|
|
|
e0018b |
+ le16 inject_poison_limit;
|
|
|
e0018b |
+ u8 poison_caps;
|
|
|
e0018b |
+ u8 qos_telemetry_caps;
|
|
|
e0018b |
+} __attribute__((packed));
|
|
|
e0018b |
+
|
|
|
e0018b |
static inline int check_kmod(struct kmod_ctx *kmod_ctx)
|
|
|
e0018b |
{
|
|
|
e0018b |
return kmod_ctx ? 0 : -ENXIO;
|
|
|
e0018b |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
|
e0018b |
index 6e87b80..0f2d5e9 100644
|
|
|
e0018b |
--- a/cxl/libcxl.h
|
|
|
e0018b |
+++ b/cxl/libcxl.h
|
|
|
e0018b |
@@ -58,6 +58,10 @@ void cxl_cmd_unref(struct cxl_cmd *cmd);
|
|
|
e0018b |
int cxl_cmd_submit(struct cxl_cmd *cmd);
|
|
|
e0018b |
int cxl_cmd_get_mbox_status(struct cxl_cmd *cmd);
|
|
|
e0018b |
int cxl_cmd_get_out_size(struct cxl_cmd *cmd);
|
|
|
e0018b |
+struct cxl_cmd *cxl_cmd_new_identify(struct cxl_memdev *memdev);
|
|
|
e0018b |
+int cxl_cmd_identify_get_fw_rev(struct cxl_cmd *cmd, char *fw_rev, int fw_len);
|
|
|
e0018b |
+unsigned long long cxl_cmd_identify_get_partition_align(struct cxl_cmd *cmd);
|
|
|
e0018b |
+unsigned int cxl_cmd_identify_get_label_size(struct cxl_cmd *cmd);
|
|
|
e0018b |
|
|
|
e0018b |
#ifdef __cplusplus
|
|
|
e0018b |
} /* extern "C" */
|
|
|
e0018b |
--
|
|
|
e0018b |
2.27.0
|
|
|
e0018b |
|