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