forked from Minki/linux
cxl for 5.12
Introduce an initial driver for CXL 2.0 Type-3 Memory Devices. CXL is Compute Express Link which released the 2.0 specification in November. The Linux relevant changes in CXL 2.0 are support for an OS to dynamically assign address space to memory devices, support for switches, persistent memory, and hotplug. A Type-3 Memory Device is a PCI enumerated device presenting the CXL Memory Device Class Code and implementing the CXL.mem protocol. CXL.mem allows device to advertise CPU and I/O coherent memory to the system, i.e. typical "System RAM" and "Persistent Memory" in Linux /proc/iomem terms. In addition to the CXL.mem fast path there is an administrative command hardware mailbox interface for maintenance and provisioning. It is this command interface that is the focus of the initial driver. With this driver a CXL device that is mapped by the BIOS can be administered by Linux. Linux support for CXL PMEM and dynamic CXL address space management are to be implemented post v5.12.4cdadfd5e0
cxl/mem: Introduce a driver for CXL-2.0-Type-3 endpoints Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>8adaf747c9
cxl/mem: Find device capabilities Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>b39cb1052a
cxl/mem: Register CXL memX devices Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>13237183c7
cxl/mem: Add a "RAW" send command Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>472b1ce6e9
cxl/mem: Enable commands via CEL Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>57ee605b97
cxl/mem: Add set of informational commands Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEf41QbsdZzFdA8EfZHtKRamZ9iAIFAmA1xV0ACgkQHtKRamZ9 iALEMQ/8Ce45LCh0oWh8FsSZ50i1KRwKGwpYNCiutTYLBArpBZXJdE1ZRFFCKgi9 ahMs29KSsj/60vG/DYuOwZBKClUiqOQHmtCRUQbb5wGxb7q8f2AKQSPOJ+Nn0nJE kgstMnkqe/neAlNDeMRdZcoBku2++hWjVVnz8QqE5Py3v3T+uEU5Au3fIhnCyvk5 usXcH8Y6R7Lb3BxT4z3DKumaRfoxIsQlH5XFbnUbgwlkE7KHoyAagZluJqh3cZpo sZrCpwG5Onw8rKqfLl//CZ8FfBjE2XfSqJkEPCCMfZUhI78sGGdmHL3ElM9/MNIB neGs3dQ5lkTaiw0nCqFtZMvDZEUsIgXPLiBByG22TM3/aIMmLqbJzeYG6UHENwC+ hLZDV/WJNLRfeUVppt+6PgcOgjTUjNV45SdVryf10Kh3NPZh7m6OPeqG/QTKHMv9 EgbFGihZF3NcSwvf5mdQNIMlnEL0WxOl/I+bSszYPXP6l38btegHR75gUXu7UGwl 9LQhkVEQL8UmfRKX2HaG6h8hyTUOf1kQiXgvchLxYLKHXSc0J/wAwCa0w3jw1m5r bdcVQx3JcBv2S1tUHp+wMqHDbLSGpeE5nF3emWabttsjSUmlb1LuAQxgrdyBtQi9 o5v6dDLOTmAH4sAt96HWKDzpUIMix3YmO3YSghYtNrwWUylQLuA= =3SAQ -----END PGP SIGNATURE----- Merge tag 'cxl-for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm Pull initial support for CXL (Compute Express Link) from Dan Williams: "Introduce an initial driver for CXL 2.0 Type-3 Memory Devices. CXL is Compute Express Link which released the 2.0 specification in November. The Linux relevant changes in CXL 2.0 are support for an OS to dynamically assign address space to memory devices, support for switches, persistent memory, and hotplug. A Type-3 Memory Device is a PCI enumerated device presenting the CXL Memory Device Class Code and implementing the CXL.mem protocol. CXL.mem allows device to advertise CPU and I/O coherent memory to the system, i.e. typical "System RAM" and "Persistent Memory" in Linux /proc/iomem terms. In addition to the CXL.mem fast path there is an administrative command hardware mailbox interface for maintenance and provisioning. It is this command interface that is the focus of the initial driver. With this driver a CXL device that is mapped by the BIOS can be administered by Linux. Linux support for CXL PMEM and dynamic CXL address space management are to be implemented post v5.12" Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>4cdadfd5e0
("cxl/mem: Introduce a driver for CXL-2.0-Type-3 endpoints")13237183c7
("cxl/mem: Add a "RAW" send command")472b1ce6e9
("cxl/mem: Enable commands via CEL")57ee605b97
("cxl/mem: Add set of informational commands") Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>8adaf747c9
("cxl/mem: Find device capabilities")b39cb1052a
("cxl/mem: Register CXL memX devices") * tag 'cxl-for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: cxl/mem: Fix potential memory leak cxl/mem: Return -EFAULT if copy_to_user() fails MAINTAINERS: Add maintainers of the CXL driver cxl/mem: Add set of informational commands cxl/mem: Enable commands via CEL cxl/mem: Add a "RAW" send command cxl/mem: Add basic IOCTL interface cxl/mem: Register CXL memX devices cxl/mem: Find device capabilities cxl/mem: Introduce a driver for CXL-2.0-Type-3 endpoints
This commit is contained in:
commit
825d150875
@ -109,6 +109,7 @@ ForEachMacros:
|
||||
- 'css_for_each_child'
|
||||
- 'css_for_each_descendant_post'
|
||||
- 'css_for_each_descendant_pre'
|
||||
- 'cxl_for_each_cmd'
|
||||
- 'device_for_each_child_node'
|
||||
- 'dma_fence_chain_for_each'
|
||||
- 'do_for_each_ftrace_op'
|
||||
|
26
Documentation/ABI/testing/sysfs-bus-cxl
Normal file
26
Documentation/ABI/testing/sysfs-bus-cxl
Normal file
@ -0,0 +1,26 @@
|
||||
What: /sys/bus/cxl/devices/memX/firmware_version
|
||||
Date: December, 2020
|
||||
KernelVersion: v5.12
|
||||
Contact: linux-cxl@vger.kernel.org
|
||||
Description:
|
||||
(RO) "FW Revision" string as reported by the Identify
|
||||
Memory Device Output Payload in the CXL-2.0
|
||||
specification.
|
||||
|
||||
What: /sys/bus/cxl/devices/memX/ram/size
|
||||
Date: December, 2020
|
||||
KernelVersion: v5.12
|
||||
Contact: linux-cxl@vger.kernel.org
|
||||
Description:
|
||||
(RO) "Volatile Only Capacity" as bytes. Represents the
|
||||
identically named field in the Identify Memory Device Output
|
||||
Payload in the CXL-2.0 specification.
|
||||
|
||||
What: /sys/bus/cxl/devices/memX/pmem/size
|
||||
Date: December, 2020
|
||||
KernelVersion: v5.12
|
||||
Contact: linux-cxl@vger.kernel.org
|
||||
Description:
|
||||
(RO) "Persistent Only Capacity" as bytes. Represents the
|
||||
identically named field in the Identify Memory Device Output
|
||||
Payload in the CXL-2.0 specification.
|
12
Documentation/driver-api/cxl/index.rst
Normal file
12
Documentation/driver-api/cxl/index.rst
Normal file
@ -0,0 +1,12 @@
|
||||
.. SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
====================
|
||||
Compute Express Link
|
||||
====================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
memory-devices
|
||||
|
||||
.. only:: subproject and html
|
46
Documentation/driver-api/cxl/memory-devices.rst
Normal file
46
Documentation/driver-api/cxl/memory-devices.rst
Normal file
@ -0,0 +1,46 @@
|
||||
.. SPDX-License-Identifier: GPL-2.0
|
||||
.. include:: <isonum.txt>
|
||||
|
||||
===================================
|
||||
Compute Express Link Memory Devices
|
||||
===================================
|
||||
|
||||
A Compute Express Link Memory Device is a CXL component that implements the
|
||||
CXL.mem protocol. It contains some amount of volatile memory, persistent memory,
|
||||
or both. It is enumerated as a PCI device for configuration and passing
|
||||
messages over an MMIO mailbox. Its contribution to the System Physical
|
||||
Address space is handled via HDM (Host Managed Device Memory) decoders
|
||||
that optionally define a device's contribution to an interleaved address
|
||||
range across multiple devices underneath a host-bridge or interleaved
|
||||
across host-bridges.
|
||||
|
||||
Driver Infrastructure
|
||||
=====================
|
||||
|
||||
This section covers the driver infrastructure for a CXL memory device.
|
||||
|
||||
CXL Memory Device
|
||||
-----------------
|
||||
|
||||
.. kernel-doc:: drivers/cxl/mem.c
|
||||
:doc: cxl mem
|
||||
|
||||
.. kernel-doc:: drivers/cxl/mem.c
|
||||
:internal:
|
||||
|
||||
CXL Bus
|
||||
-------
|
||||
.. kernel-doc:: drivers/cxl/bus.c
|
||||
:doc: cxl bus
|
||||
|
||||
External Interfaces
|
||||
===================
|
||||
|
||||
CXL IOCTL Interface
|
||||
-------------------
|
||||
|
||||
.. kernel-doc:: include/uapi/linux/cxl_mem.h
|
||||
:doc: UAPI
|
||||
|
||||
.. kernel-doc:: include/uapi/linux/cxl_mem.h
|
||||
:internal:
|
@ -35,6 +35,7 @@ available subsections can be seen below.
|
||||
usb/index
|
||||
firewire
|
||||
pci/index
|
||||
cxl/index
|
||||
spi
|
||||
i2c
|
||||
ipmb
|
||||
|
@ -353,6 +353,7 @@ Code Seq# Include File Comments
|
||||
<mailto:michael.klein@puffin.lb.shuttle.de>
|
||||
0xCC 00-0F drivers/misc/ibmvmc.h pseries VMC driver
|
||||
0xCD 01 linux/reiserfs_fs.h
|
||||
0xCE 01-02 uapi/linux/cxl_mem.h Compute Express Link Memory Devices
|
||||
0xCF 02 fs/cifs/ioctl.c
|
||||
0xDB 00-0F drivers/char/mwave/mwavepub.h
|
||||
0xDD 00-3F ZFCP device driver see drivers/s390/scsi/
|
||||
|
11
MAINTAINERS
11
MAINTAINERS
@ -4434,6 +4434,17 @@ M: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
|
||||
S: Maintained
|
||||
F: include/linux/compiler_attributes.h
|
||||
|
||||
COMPUTE EXPRESS LINK (CXL)
|
||||
M: Alison Schofield <alison.schofield@intel.com>
|
||||
M: Vishal Verma <vishal.l.verma@intel.com>
|
||||
M: Ira Weiny <ira.weiny@intel.com>
|
||||
M: Ben Widawsky <ben.widawsky@intel.com>
|
||||
M: Dan Williams <dan.j.williams@intel.com>
|
||||
L: linux-cxl@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/cxl/
|
||||
F: include/uapi/linux/cxl_mem.h
|
||||
|
||||
CONEXANT ACCESSRUNNER USB DRIVER
|
||||
L: accessrunner-general@lists.sourceforge.net
|
||||
S: Orphan
|
||||
|
@ -6,6 +6,7 @@ menu "Device Drivers"
|
||||
source "drivers/amba/Kconfig"
|
||||
source "drivers/eisa/Kconfig"
|
||||
source "drivers/pci/Kconfig"
|
||||
source "drivers/cxl/Kconfig"
|
||||
source "drivers/pcmcia/Kconfig"
|
||||
source "drivers/rapidio/Kconfig"
|
||||
|
||||
|
@ -73,6 +73,7 @@ obj-$(CONFIG_NVM) += lightnvm/
|
||||
obj-y += base/ block/ misc/ mfd/ nfc/
|
||||
obj-$(CONFIG_LIBNVDIMM) += nvdimm/
|
||||
obj-$(CONFIG_DAX) += dax/
|
||||
obj-$(CONFIG_CXL_BUS) += cxl/
|
||||
obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/
|
||||
obj-$(CONFIG_NUBUS) += nubus/
|
||||
obj-y += macintosh/
|
||||
|
53
drivers/cxl/Kconfig
Normal file
53
drivers/cxl/Kconfig
Normal file
@ -0,0 +1,53 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
menuconfig CXL_BUS
|
||||
tristate "CXL (Compute Express Link) Devices Support"
|
||||
depends on PCI
|
||||
help
|
||||
CXL is a bus that is electrically compatible with PCI Express, but
|
||||
layers three protocols on that signalling (CXL.io, CXL.cache, and
|
||||
CXL.mem). The CXL.cache protocol allows devices to hold cachelines
|
||||
locally, the CXL.mem protocol allows devices to be fully coherent
|
||||
memory targets, the CXL.io protocol is equivalent to PCI Express.
|
||||
Say 'y' to enable support for the configuration and management of
|
||||
devices supporting these protocols.
|
||||
|
||||
if CXL_BUS
|
||||
|
||||
config CXL_MEM
|
||||
tristate "CXL.mem: Memory Devices"
|
||||
help
|
||||
The CXL.mem protocol allows a device to act as a provider of
|
||||
"System RAM" and/or "Persistent Memory" that is fully coherent
|
||||
as if the memory was attached to the typical CPU memory
|
||||
controller.
|
||||
|
||||
Say 'y/m' to enable a driver (named "cxl_mem.ko" when built as
|
||||
a module) that will attach to CXL.mem devices for
|
||||
configuration, provisioning, and health monitoring. This
|
||||
driver is required for dynamic provisioning of CXL.mem
|
||||
attached memory which is a prerequisite for persistent memory
|
||||
support. Typically volatile memory is mapped by platform
|
||||
firmware and included in the platform memory map, but in some
|
||||
cases the OS is responsible for mapping that memory. See
|
||||
Chapter 2.3 Type 3 CXL Device in the CXL 2.0 specification.
|
||||
|
||||
If unsure say 'm'.
|
||||
|
||||
config CXL_MEM_RAW_COMMANDS
|
||||
bool "RAW Command Interface for Memory Devices"
|
||||
depends on CXL_MEM
|
||||
help
|
||||
Enable CXL RAW command interface.
|
||||
|
||||
The CXL driver ioctl interface may assign a kernel ioctl command
|
||||
number for each specification defined opcode. At any given point in
|
||||
time the number of opcodes that the specification defines and a device
|
||||
may implement may exceed the kernel's set of associated ioctl function
|
||||
numbers. The mismatch is either by omission, specification is too new,
|
||||
or by design. When prototyping new hardware, or developing / debugging
|
||||
the driver it is useful to be able to submit any possible command to
|
||||
the hardware, even commands that may crash the kernel due to their
|
||||
potential impact to memory currently in use by the kernel.
|
||||
|
||||
If developing CXL hardware or the driver say Y, otherwise say N.
|
||||
endif
|
7
drivers/cxl/Makefile
Normal file
7
drivers/cxl/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
obj-$(CONFIG_CXL_BUS) += cxl_bus.o
|
||||
obj-$(CONFIG_CXL_MEM) += cxl_mem.o
|
||||
|
||||
ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=CXL
|
||||
cxl_bus-y := bus.o
|
||||
cxl_mem-y := mem.o
|
29
drivers/cxl/bus.c
Normal file
29
drivers/cxl/bus.c
Normal file
@ -0,0 +1,29 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/* Copyright(c) 2020 Intel Corporation. All rights reserved. */
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
/**
|
||||
* DOC: cxl bus
|
||||
*
|
||||
* The CXL bus provides namespace for control devices and a rendezvous
|
||||
* point for cross-device interleave coordination.
|
||||
*/
|
||||
struct bus_type cxl_bus_type = {
|
||||
.name = "cxl",
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(cxl_bus_type);
|
||||
|
||||
static __init int cxl_bus_init(void)
|
||||
{
|
||||
return bus_register(&cxl_bus_type);
|
||||
}
|
||||
|
||||
static void cxl_bus_exit(void)
|
||||
{
|
||||
bus_unregister(&cxl_bus_type);
|
||||
}
|
||||
|
||||
module_init(cxl_bus_init);
|
||||
module_exit(cxl_bus_exit);
|
||||
MODULE_LICENSE("GPL v2");
|
95
drivers/cxl/cxl.h
Normal file
95
drivers/cxl/cxl.h
Normal file
@ -0,0 +1,95 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/* Copyright(c) 2020 Intel Corporation. */
|
||||
|
||||
#ifndef __CXL_H__
|
||||
#define __CXL_H__
|
||||
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
/* CXL 2.0 8.2.8.1 Device Capabilities Array Register */
|
||||
#define CXLDEV_CAP_ARRAY_OFFSET 0x0
|
||||
#define CXLDEV_CAP_ARRAY_CAP_ID 0
|
||||
#define CXLDEV_CAP_ARRAY_ID_MASK GENMASK_ULL(15, 0)
|
||||
#define CXLDEV_CAP_ARRAY_COUNT_MASK GENMASK_ULL(47, 32)
|
||||
/* CXL 2.0 8.2.8.2 CXL Device Capability Header Register */
|
||||
#define CXLDEV_CAP_HDR_CAP_ID_MASK GENMASK(15, 0)
|
||||
/* CXL 2.0 8.2.8.2.1 CXL Device Capabilities */
|
||||
#define CXLDEV_CAP_CAP_ID_DEVICE_STATUS 0x1
|
||||
#define CXLDEV_CAP_CAP_ID_PRIMARY_MAILBOX 0x2
|
||||
#define CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX 0x3
|
||||
#define CXLDEV_CAP_CAP_ID_MEMDEV 0x4000
|
||||
|
||||
/* CXL 2.0 8.2.8.4 Mailbox Registers */
|
||||
#define CXLDEV_MBOX_CAPS_OFFSET 0x00
|
||||
#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK GENMASK(4, 0)
|
||||
#define CXLDEV_MBOX_CTRL_OFFSET 0x04
|
||||
#define CXLDEV_MBOX_CTRL_DOORBELL BIT(0)
|
||||
#define CXLDEV_MBOX_CMD_OFFSET 0x08
|
||||
#define CXLDEV_MBOX_CMD_COMMAND_OPCODE_MASK GENMASK_ULL(15, 0)
|
||||
#define CXLDEV_MBOX_CMD_PAYLOAD_LENGTH_MASK GENMASK_ULL(36, 16)
|
||||
#define CXLDEV_MBOX_STATUS_OFFSET 0x10
|
||||
#define CXLDEV_MBOX_STATUS_RET_CODE_MASK GENMASK_ULL(47, 32)
|
||||
#define CXLDEV_MBOX_BG_CMD_STATUS_OFFSET 0x18
|
||||
#define CXLDEV_MBOX_PAYLOAD_OFFSET 0x20
|
||||
|
||||
/* CXL 2.0 8.2.8.5.1.1 Memory Device Status Register */
|
||||
#define CXLMDEV_STATUS_OFFSET 0x0
|
||||
#define CXLMDEV_DEV_FATAL BIT(0)
|
||||
#define CXLMDEV_FW_HALT BIT(1)
|
||||
#define CXLMDEV_STATUS_MEDIA_STATUS_MASK GENMASK(3, 2)
|
||||
#define CXLMDEV_MS_NOT_READY 0
|
||||
#define CXLMDEV_MS_READY 1
|
||||
#define CXLMDEV_MS_ERROR 2
|
||||
#define CXLMDEV_MS_DISABLED 3
|
||||
#define CXLMDEV_READY(status) \
|
||||
(FIELD_GET(CXLMDEV_STATUS_MEDIA_STATUS_MASK, status) == \
|
||||
CXLMDEV_MS_READY)
|
||||
#define CXLMDEV_MBOX_IF_READY BIT(4)
|
||||
#define CXLMDEV_RESET_NEEDED_MASK GENMASK(7, 5)
|
||||
#define CXLMDEV_RESET_NEEDED_NOT 0
|
||||
#define CXLMDEV_RESET_NEEDED_COLD 1
|
||||
#define CXLMDEV_RESET_NEEDED_WARM 2
|
||||
#define CXLMDEV_RESET_NEEDED_HOT 3
|
||||
#define CXLMDEV_RESET_NEEDED_CXL 4
|
||||
#define CXLMDEV_RESET_NEEDED(status) \
|
||||
(FIELD_GET(CXLMDEV_RESET_NEEDED_MASK, status) != \
|
||||
CXLMDEV_RESET_NEEDED_NOT)
|
||||
|
||||
struct cxl_memdev;
|
||||
/**
|
||||
* struct cxl_mem - A CXL memory device
|
||||
* @pdev: The PCI device associated with this CXL device.
|
||||
* @regs: IO mappings to the device's MMIO
|
||||
* @status_regs: CXL 2.0 8.2.8.3 Device Status Registers
|
||||
* @mbox_regs: CXL 2.0 8.2.8.4 Mailbox Registers
|
||||
* @memdev_regs: CXL 2.0 8.2.8.5 Memory Device Registers
|
||||
* @payload_size: Size of space for payload
|
||||
* (CXL 2.0 8.2.8.4.3 Mailbox Capabilities Register)
|
||||
* @mbox_mutex: Mutex to synchronize mailbox access.
|
||||
* @firmware_version: Firmware version for the memory device.
|
||||
* @enabled_commands: Hardware commands found enabled in CEL.
|
||||
* @pmem_range: Persistent memory capacity information.
|
||||
* @ram_range: Volatile memory capacity information.
|
||||
*/
|
||||
struct cxl_mem {
|
||||
struct pci_dev *pdev;
|
||||
void __iomem *regs;
|
||||
struct cxl_memdev *cxlmd;
|
||||
|
||||
void __iomem *status_regs;
|
||||
void __iomem *mbox_regs;
|
||||
void __iomem *memdev_regs;
|
||||
|
||||
size_t payload_size;
|
||||
struct mutex mbox_mutex; /* Protects device mailbox and firmware */
|
||||
char firmware_version[0x10];
|
||||
unsigned long *enabled_cmds;
|
||||
|
||||
struct range pmem_range;
|
||||
struct range ram_range;
|
||||
};
|
||||
|
||||
extern struct bus_type cxl_bus_type;
|
||||
#endif /* __CXL_H__ */
|
1552
drivers/cxl/mem.c
Normal file
1552
drivers/cxl/mem.c
Normal file
File diff suppressed because it is too large
Load Diff
31
drivers/cxl/pci.h
Normal file
31
drivers/cxl/pci.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/* Copyright(c) 2020 Intel Corporation. All rights reserved. */
|
||||
#ifndef __CXL_PCI_H__
|
||||
#define __CXL_PCI_H__
|
||||
|
||||
#define CXL_MEMORY_PROGIF 0x10
|
||||
|
||||
/*
|
||||
* See section 8.1 Configuration Space Registers in the CXL 2.0
|
||||
* Specification
|
||||
*/
|
||||
#define PCI_DVSEC_HEADER1_LENGTH_MASK GENMASK(31, 20)
|
||||
#define PCI_DVSEC_VENDOR_ID_CXL 0x1E98
|
||||
#define PCI_DVSEC_ID_CXL 0x0
|
||||
|
||||
#define PCI_DVSEC_ID_CXL_REGLOC_OFFSET 0x8
|
||||
#define PCI_DVSEC_ID_CXL_REGLOC_BLOCK1_OFFSET 0xC
|
||||
|
||||
/* BAR Indicator Register (BIR) */
|
||||
#define CXL_REGLOC_BIR_MASK GENMASK(2, 0)
|
||||
|
||||
/* Register Block Identifier (RBI) */
|
||||
#define CXL_REGLOC_RBI_MASK GENMASK(15, 8)
|
||||
#define CXL_REGLOC_RBI_EMPTY 0
|
||||
#define CXL_REGLOC_RBI_COMPONENT 1
|
||||
#define CXL_REGLOC_RBI_VIRT 2
|
||||
#define CXL_REGLOC_RBI_MEMDEV 3
|
||||
|
||||
#define CXL_REGLOC_ADDR_MASK GENMASK(31, 16)
|
||||
|
||||
#endif /* __CXL_PCI_H__ */
|
@ -51,6 +51,7 @@
|
||||
#define PCI_BASE_CLASS_MEMORY 0x05
|
||||
#define PCI_CLASS_MEMORY_RAM 0x0500
|
||||
#define PCI_CLASS_MEMORY_FLASH 0x0501
|
||||
#define PCI_CLASS_MEMORY_CXL 0x0502
|
||||
#define PCI_CLASS_MEMORY_OTHER 0x0580
|
||||
|
||||
#define PCI_BASE_CLASS_BRIDGE 0x06
|
||||
|
172
include/uapi/linux/cxl_mem.h
Normal file
172
include/uapi/linux/cxl_mem.h
Normal file
@ -0,0 +1,172 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/*
|
||||
* CXL IOCTLs for Memory Devices
|
||||
*/
|
||||
|
||||
#ifndef _UAPI_CXL_MEM_H_
|
||||
#define _UAPI_CXL_MEM_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* DOC: UAPI
|
||||
*
|
||||
* Not all of all commands that the driver supports are always available for use
|
||||
* by userspace. Userspace must check the results from the QUERY command in
|
||||
* order to determine the live set of commands.
|
||||
*/
|
||||
|
||||
#define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands)
|
||||
#define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command)
|
||||
|
||||
#define CXL_CMDS \
|
||||
___C(INVALID, "Invalid Command"), \
|
||||
___C(IDENTIFY, "Identify Command"), \
|
||||
___C(RAW, "Raw device command"), \
|
||||
___C(GET_SUPPORTED_LOGS, "Get Supported Logs"), \
|
||||
___C(GET_FW_INFO, "Get FW Info"), \
|
||||
___C(GET_PARTITION_INFO, "Get Partition Information"), \
|
||||
___C(GET_LSA, "Get Label Storage Area"), \
|
||||
___C(GET_HEALTH_INFO, "Get Health Info"), \
|
||||
___C(GET_LOG, "Get Log"), \
|
||||
___C(MAX, "invalid / last command")
|
||||
|
||||
#define ___C(a, b) CXL_MEM_COMMAND_ID_##a
|
||||
enum { CXL_CMDS };
|
||||
|
||||
#undef ___C
|
||||
#define ___C(a, b) { b }
|
||||
static const struct {
|
||||
const char *name;
|
||||
} cxl_command_names[] = { CXL_CMDS };
|
||||
|
||||
/*
|
||||
* Here's how this actually breaks out:
|
||||
* cxl_command_names[] = {
|
||||
* [CXL_MEM_COMMAND_ID_INVALID] = { "Invalid Command" },
|
||||
* [CXL_MEM_COMMAND_ID_IDENTIFY] = { "Identify Command" },
|
||||
* ...
|
||||
* [CXL_MEM_COMMAND_ID_MAX] = { "invalid / last command" },
|
||||
* };
|
||||
*/
|
||||
|
||||
#undef ___C
|
||||
|
||||
/**
|
||||
* struct cxl_command_info - Command information returned from a query.
|
||||
* @id: ID number for the command.
|
||||
* @flags: Flags that specify command behavior.
|
||||
* @size_in: Expected input size, or -1 if variable length.
|
||||
* @size_out: Expected output size, or -1 if variable length.
|
||||
*
|
||||
* Represents a single command that is supported by both the driver and the
|
||||
* hardware. This is returned as part of an array from the query ioctl. The
|
||||
* following would be a command that takes a variable length input and returns 0
|
||||
* bytes of output.
|
||||
*
|
||||
* - @id = 10
|
||||
* - @flags = 0
|
||||
* - @size_in = -1
|
||||
* - @size_out = 0
|
||||
*
|
||||
* See struct cxl_mem_query_commands.
|
||||
*/
|
||||
struct cxl_command_info {
|
||||
__u32 id;
|
||||
|
||||
__u32 flags;
|
||||
#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0)
|
||||
|
||||
__s32 size_in;
|
||||
__s32 size_out;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct cxl_mem_query_commands - Query supported commands.
|
||||
* @n_commands: In/out parameter. When @n_commands is > 0, the driver will
|
||||
* return min(num_support_commands, n_commands). When @n_commands
|
||||
* is 0, driver will return the number of total supported commands.
|
||||
* @rsvd: Reserved for future use.
|
||||
* @commands: Output array of supported commands. This array must be allocated
|
||||
* by userspace to be at least min(num_support_commands, @n_commands)
|
||||
*
|
||||
* Allow userspace to query the available commands supported by both the driver,
|
||||
* and the hardware. Commands that aren't supported by either the driver, or the
|
||||
* hardware are not returned in the query.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* - { .n_commands = 0 } // Get number of supported commands
|
||||
* - { .n_commands = 15, .commands = buf } // Return first 15 (or less)
|
||||
* supported commands
|
||||
*
|
||||
* See struct cxl_command_info.
|
||||
*/
|
||||
struct cxl_mem_query_commands {
|
||||
/*
|
||||
* Input: Number of commands to return (space allocated by user)
|
||||
* Output: Number of commands supported by the driver/hardware
|
||||
*
|
||||
* If n_commands is 0, kernel will only return number of commands and
|
||||
* not try to populate commands[], thus allowing userspace to know how
|
||||
* much space to allocate
|
||||
*/
|
||||
__u32 n_commands;
|
||||
__u32 rsvd;
|
||||
|
||||
struct cxl_command_info __user commands[]; /* out: supported commands */
|
||||
};
|
||||
|
||||
/**
|
||||
* struct cxl_send_command - Send a command to a memory device.
|
||||
* @id: The command to send to the memory device. This must be one of the
|
||||
* commands returned by the query command.
|
||||
* @flags: Flags for the command (input).
|
||||
* @raw: Special fields for raw commands
|
||||
* @raw.opcode: Opcode passed to hardware when using the RAW command.
|
||||
* @raw.rsvd: Must be zero.
|
||||
* @rsvd: Must be zero.
|
||||
* @retval: Return value from the memory device (output).
|
||||
* @in: Parameters associated with input payload.
|
||||
* @in.size: Size of the payload to provide to the device (input).
|
||||
* @in.rsvd: Must be zero.
|
||||
* @in.payload: Pointer to memory for payload input, payload is little endian.
|
||||
* @out: Parameters associated with output payload.
|
||||
* @out.size: Size of the payload received from the device (input/output). This
|
||||
* field is filled in by userspace to let the driver know how much
|
||||
* space was allocated for output. It is populated by the driver to
|
||||
* let userspace know how large the output payload actually was.
|
||||
* @out.rsvd: Must be zero.
|
||||
* @out.payload: Pointer to memory for payload output, payload is little endian.
|
||||
*
|
||||
* Mechanism for userspace to send a command to the hardware for processing. The
|
||||
* driver will do basic validation on the command sizes. In some cases even the
|
||||
* payload may be introspected. Userspace is required to allocate large enough
|
||||
* buffers for size_out which can be variable length in certain situations.
|
||||
*/
|
||||
struct cxl_send_command {
|
||||
__u32 id;
|
||||
__u32 flags;
|
||||
union {
|
||||
struct {
|
||||
__u16 opcode;
|
||||
__u16 rsvd;
|
||||
} raw;
|
||||
__u32 rsvd;
|
||||
};
|
||||
__u32 retval;
|
||||
|
||||
struct {
|
||||
__s32 size;
|
||||
__u32 rsvd;
|
||||
__u64 payload;
|
||||
} in;
|
||||
|
||||
struct {
|
||||
__s32 size;
|
||||
__u32 rsvd;
|
||||
__u64 payload;
|
||||
} out;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user