|
Jeff Moyer |
2c91dc |
From 894fb9b2b59364f7f5683ea68c8bd765223a4ca8 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:25 -0600
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 033/217] cxl: add a local copy of the cxl_mem UAPI header
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
While CXL functionality is under development, it is useful to have a
|
|
Jeff Moyer |
2c91dc |
local copy of the UAPI header for cxl_mem definitions. This allows
|
|
Jeff Moyer |
2c91dc |
building cxl and libcxl on systems where the appropriate kernel headers
|
|
Jeff Moyer |
2c91dc |
are not installed in the usual locations.
|
|
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 |
Makefile.am | 3 +-
|
|
Jeff Moyer |
2c91dc |
Makefile.am.in | 1 +
|
|
Jeff Moyer |
2c91dc |
cxl/cxl_mem.h | 189 ++++++++++++++++++++++++++++++++++++++++++++
|
|
Jeff Moyer |
2c91dc |
cxl/lib/Makefile.am | 2 +-
|
|
Jeff Moyer |
2c91dc |
4 files changed, 193 insertions(+), 2 deletions(-)
|
|
Jeff Moyer |
2c91dc |
create mode 100644 cxl/cxl_mem.h
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/Makefile.am b/Makefile.am
|
|
Jeff Moyer |
2c91dc |
index 428fd40..4904ee7 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Makefile.am
|
|
Jeff Moyer |
2c91dc |
+++ b/Makefile.am
|
|
Jeff Moyer |
2c91dc |
@@ -89,4 +89,5 @@ libutil_a_SOURCES = \
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
nobase_include_HEADERS = \
|
|
Jeff Moyer |
2c91dc |
daxctl/libdaxctl.h \
|
|
Jeff Moyer |
2c91dc |
- cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
+ cxl/libcxl.h \
|
|
Jeff Moyer |
2c91dc |
+ cxl/cxl_mem.h
|
|
Jeff Moyer |
2c91dc |
diff --git a/Makefile.am.in b/Makefile.am.in
|
|
Jeff Moyer |
2c91dc |
index aaeee53..a748128 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Makefile.am.in
|
|
Jeff Moyer |
2c91dc |
+++ b/Makefile.am.in
|
|
Jeff Moyer |
2c91dc |
@@ -11,6 +11,7 @@ AM_CPPFLAGS = \
|
|
Jeff Moyer |
2c91dc |
-DNDCTL_MAN_PATH=\""$(mandir)"\" \
|
|
Jeff Moyer |
2c91dc |
-I${top_srcdir}/ndctl/lib \
|
|
Jeff Moyer |
2c91dc |
-I${top_srcdir}/ndctl \
|
|
Jeff Moyer |
2c91dc |
+ -I${top_srcdir}/cxl \
|
|
Jeff Moyer |
2c91dc |
-I${top_srcdir}/ \
|
|
Jeff Moyer |
2c91dc |
$(KMOD_CFLAGS) \
|
|
Jeff Moyer |
2c91dc |
$(UDEV_CFLAGS) \
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/cxl_mem.h b/cxl/cxl_mem.h
|
|
Jeff Moyer |
2c91dc |
new file mode 100644
|
|
Jeff Moyer |
2c91dc |
index 0000000..d38cc9c
|
|
Jeff Moyer |
2c91dc |
--- /dev/null
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/cxl_mem.h
|
|
Jeff Moyer |
2c91dc |
@@ -0,0 +1,189 @@
|
|
Jeff Moyer |
2c91dc |
+/* SPDX-License-Identifier: LGPL-2.1 */
|
|
Jeff Moyer |
2c91dc |
+/* Copyright (C) 2020-2021, Intel Corporation. All rights reserved. */
|
|
Jeff Moyer |
2c91dc |
+/*
|
|
Jeff Moyer |
2c91dc |
+ * CXL IOCTLs for Memory Devices
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#ifndef _UAPI_CXL_MEM_H_
|
|
Jeff Moyer |
2c91dc |
+#define _UAPI_CXL_MEM_H_
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#include <linux/types.h>
|
|
Jeff Moyer |
2c91dc |
+#include <sys/user.h>
|
|
Jeff Moyer |
2c91dc |
+#include <unistd.h>
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#define __user
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+/**
|
|
Jeff Moyer |
2c91dc |
+ * DOC: UAPI
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * Not all of all commands that the driver supports are always available for use
|
|
Jeff Moyer |
2c91dc |
+ * by userspace. Userspace must check the results from the QUERY command in
|
|
Jeff Moyer |
2c91dc |
+ * order to determine the live set of commands.
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands)
|
|
Jeff Moyer |
2c91dc |
+#define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command)
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#define CXL_CMDS \
|
|
Jeff Moyer |
2c91dc |
+ ___C(INVALID, "Invalid Command"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(IDENTIFY, "Identify Command"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(RAW, "Raw device command"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_SUPPORTED_LOGS, "Get Supported Logs"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_FW_INFO, "Get FW Info"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_PARTITION_INFO, "Get Partition Information"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_LSA, "Get Label Storage Area"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_HEALTH_INFO, "Get Health Info"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_LOG, "Get Log"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(SET_PARTITION_INFO, "Set Partition Information"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(SET_LSA, "Set Label Storage Area"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_ALERT_CONFIG, "Get Alert Configuration"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(SET_ALERT_CONFIG, "Set Alert Configuration"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_SHUTDOWN_STATE, "Get Shutdown State"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(SET_SHUTDOWN_STATE, "Set Shutdown State"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_POISON, "Get Poison List"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(INJECT_POISON, "Inject Poison"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(CLEAR_POISON, "Clear Poison"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_SCAN_MEDIA_CAPS, "Get Scan Media Capabilities"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(SCAN_MEDIA, "Scan Media"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(GET_SCAN_MEDIA, "Get Scan Media Results"), \
|
|
Jeff Moyer |
2c91dc |
+ ___C(MAX, "invalid / last command")
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#define ___C(a, b) CXL_MEM_COMMAND_ID_##a
|
|
Jeff Moyer |
2c91dc |
+enum { CXL_CMDS };
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#undef ___C
|
|
Jeff Moyer |
2c91dc |
+#define ___C(a, b) { b }
|
|
Jeff Moyer |
2c91dc |
+static const struct {
|
|
Jeff Moyer |
2c91dc |
+ const char *name;
|
|
Jeff Moyer |
2c91dc |
+} cxl_command_names[] = { CXL_CMDS };
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+/*
|
|
Jeff Moyer |
2c91dc |
+ * Here's how this actually breaks out:
|
|
Jeff Moyer |
2c91dc |
+ * cxl_command_names[] = {
|
|
Jeff Moyer |
2c91dc |
+ * [CXL_MEM_COMMAND_ID_INVALID] = { "Invalid Command" },
|
|
Jeff Moyer |
2c91dc |
+ * [CXL_MEM_COMMAND_ID_IDENTIFY] = { "Identify Command" },
|
|
Jeff Moyer |
2c91dc |
+ * ...
|
|
Jeff Moyer |
2c91dc |
+ * [CXL_MEM_COMMAND_ID_MAX] = { "invalid / last command" },
|
|
Jeff Moyer |
2c91dc |
+ * };
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#undef ___C
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+/**
|
|
Jeff Moyer |
2c91dc |
+ * struct cxl_command_info - Command information returned from a query.
|
|
Jeff Moyer |
2c91dc |
+ * @id: ID number for the command.
|
|
Jeff Moyer |
2c91dc |
+ * @flags: Flags that specify command behavior.
|
|
Jeff Moyer |
2c91dc |
+ * @size_in: Expected input size, or -1 if variable length.
|
|
Jeff Moyer |
2c91dc |
+ * @size_out: Expected output size, or -1 if variable length.
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * Represents a single command that is supported by both the driver and the
|
|
Jeff Moyer |
2c91dc |
+ * hardware. This is returned as part of an array from the query ioctl. The
|
|
Jeff Moyer |
2c91dc |
+ * following would be a command that takes a variable length input and returns 0
|
|
Jeff Moyer |
2c91dc |
+ * bytes of output.
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * - @id = 10
|
|
Jeff Moyer |
2c91dc |
+ * - @flags = 0
|
|
Jeff Moyer |
2c91dc |
+ * - @size_in = -1
|
|
Jeff Moyer |
2c91dc |
+ * - @size_out = 0
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * See struct cxl_mem_query_commands.
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+struct cxl_command_info {
|
|
Jeff Moyer |
2c91dc |
+ __u32 id;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ __u32 flags;
|
|
Jeff Moyer |
2c91dc |
+#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0)
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ __s32 size_in;
|
|
Jeff Moyer |
2c91dc |
+ __s32 size_out;
|
|
Jeff Moyer |
2c91dc |
+};
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+/**
|
|
Jeff Moyer |
2c91dc |
+ * struct cxl_mem_query_commands - Query supported commands.
|
|
Jeff Moyer |
2c91dc |
+ * @n_commands: In/out parameter. When @n_commands is > 0, the driver will
|
|
Jeff Moyer |
2c91dc |
+ * return min(num_support_commands, n_commands). When @n_commands
|
|
Jeff Moyer |
2c91dc |
+ * is 0, driver will return the number of total supported commands.
|
|
Jeff Moyer |
2c91dc |
+ * @rsvd: Reserved for future use.
|
|
Jeff Moyer |
2c91dc |
+ * @commands: Output array of supported commands. This array must be allocated
|
|
Jeff Moyer |
2c91dc |
+ * by userspace to be at least min(num_support_commands, @n_commands)
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * Allow userspace to query the available commands supported by both the driver,
|
|
Jeff Moyer |
2c91dc |
+ * and the hardware. Commands that aren't supported by either the driver, or the
|
|
Jeff Moyer |
2c91dc |
+ * hardware are not returned in the query.
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * Examples:
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * - { .n_commands = 0 } // Get number of supported commands
|
|
Jeff Moyer |
2c91dc |
+ * - { .n_commands = 15, .commands = buf } // Return first 15 (or less)
|
|
Jeff Moyer |
2c91dc |
+ * supported commands
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * See struct cxl_command_info.
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+struct cxl_mem_query_commands {
|
|
Jeff Moyer |
2c91dc |
+ /*
|
|
Jeff Moyer |
2c91dc |
+ * Input: Number of commands to return (space allocated by user)
|
|
Jeff Moyer |
2c91dc |
+ * Output: Number of commands supported by the driver/hardware
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * If n_commands is 0, kernel will only return number of commands and
|
|
Jeff Moyer |
2c91dc |
+ * not try to populate commands[], thus allowing userspace to know how
|
|
Jeff Moyer |
2c91dc |
+ * much space to allocate
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+ __u32 n_commands;
|
|
Jeff Moyer |
2c91dc |
+ __u32 rsvd;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ struct cxl_command_info __user commands[]; /* out: supported commands */
|
|
Jeff Moyer |
2c91dc |
+};
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+/**
|
|
Jeff Moyer |
2c91dc |
+ * struct cxl_send_command - Send a command to a memory device.
|
|
Jeff Moyer |
2c91dc |
+ * @id: The command to send to the memory device. This must be one of the
|
|
Jeff Moyer |
2c91dc |
+ * commands returned by the query command.
|
|
Jeff Moyer |
2c91dc |
+ * @flags: Flags for the command (input).
|
|
Jeff Moyer |
2c91dc |
+ * @raw: Special fields for raw commands
|
|
Jeff Moyer |
2c91dc |
+ * @raw.opcode: Opcode passed to hardware when using the RAW command.
|
|
Jeff Moyer |
2c91dc |
+ * @raw.rsvd: Must be zero.
|
|
Jeff Moyer |
2c91dc |
+ * @rsvd: Must be zero.
|
|
Jeff Moyer |
2c91dc |
+ * @retval: Return value from the memory device (output).
|
|
Jeff Moyer |
2c91dc |
+ * @in: Parameters associated with input payload.
|
|
Jeff Moyer |
2c91dc |
+ * @in.size: Size of the payload to provide to the device (input).
|
|
Jeff Moyer |
2c91dc |
+ * @in.rsvd: Must be zero.
|
|
Jeff Moyer |
2c91dc |
+ * @in.payload: Pointer to memory for payload input, payload is little endian.
|
|
Jeff Moyer |
2c91dc |
+ * @out: Parameters associated with output payload.
|
|
Jeff Moyer |
2c91dc |
+ * @out.size: Size of the payload received from the device (input/output). This
|
|
Jeff Moyer |
2c91dc |
+ * field is filled in by userspace to let the driver know how much
|
|
Jeff Moyer |
2c91dc |
+ * space was allocated for output. It is populated by the driver to
|
|
Jeff Moyer |
2c91dc |
+ * let userspace know how large the output payload actually was.
|
|
Jeff Moyer |
2c91dc |
+ * @out.rsvd: Must be zero.
|
|
Jeff Moyer |
2c91dc |
+ * @out.payload: Pointer to memory for payload output, payload is little endian.
|
|
Jeff Moyer |
2c91dc |
+ *
|
|
Jeff Moyer |
2c91dc |
+ * Mechanism for userspace to send a command to the hardware for processing. The
|
|
Jeff Moyer |
2c91dc |
+ * driver will do basic validation on the command sizes. In some cases even the
|
|
Jeff Moyer |
2c91dc |
+ * payload may be introspected. Userspace is required to allocate large enough
|
|
Jeff Moyer |
2c91dc |
+ * buffers for size_out which can be variable length in certain situations.
|
|
Jeff Moyer |
2c91dc |
+ */
|
|
Jeff Moyer |
2c91dc |
+struct cxl_send_command {
|
|
Jeff Moyer |
2c91dc |
+ __u32 id;
|
|
Jeff Moyer |
2c91dc |
+ __u32 flags;
|
|
Jeff Moyer |
2c91dc |
+ union {
|
|
Jeff Moyer |
2c91dc |
+ struct {
|
|
Jeff Moyer |
2c91dc |
+ __u16 opcode;
|
|
Jeff Moyer |
2c91dc |
+ __u16 rsvd;
|
|
Jeff Moyer |
2c91dc |
+ } raw;
|
|
Jeff Moyer |
2c91dc |
+ __u32 rsvd;
|
|
Jeff Moyer |
2c91dc |
+ };
|
|
Jeff Moyer |
2c91dc |
+ __u32 retval;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ struct {
|
|
Jeff Moyer |
2c91dc |
+ __s32 size;
|
|
Jeff Moyer |
2c91dc |
+ __u32 rsvd;
|
|
Jeff Moyer |
2c91dc |
+ __u64 payload;
|
|
Jeff Moyer |
2c91dc |
+ } in;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ struct {
|
|
Jeff Moyer |
2c91dc |
+ __s32 size;
|
|
Jeff Moyer |
2c91dc |
+ __u32 rsvd;
|
|
Jeff Moyer |
2c91dc |
+ __u64 payload;
|
|
Jeff Moyer |
2c91dc |
+ } out;
|
|
Jeff Moyer |
2c91dc |
+};
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+#endif
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/Makefile.am b/cxl/lib/Makefile.am
|
|
Jeff Moyer |
2c91dc |
index 277f0cd..72c9ccd 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/Makefile.am
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/Makefile.am
|
|
Jeff Moyer |
2c91dc |
@@ -3,7 +3,7 @@ include $(top_srcdir)/Makefile.am.in
|
|
Jeff Moyer |
2c91dc |
%.pc: %.pc.in Makefile
|
|
Jeff Moyer |
2c91dc |
$(SED_PROCESS)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-pkginclude_HEADERS = ../libcxl.h
|
|
Jeff Moyer |
2c91dc |
+pkginclude_HEADERS = ../libcxl.h ../cxl_mem.h
|
|
Jeff Moyer |
2c91dc |
lib_LTLIBRARIES = libcxl.la
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
libcxl_la_SOURCES =\
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|