2021-05-14 13:21:49 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
/* Copyright(c) 2020-2021 Intel Corporation. */
|
|
|
|
#ifndef __CXL_MEM_H__
|
|
|
|
#define __CXL_MEM_H__
|
2021-09-09 13:12:32 +08:00
|
|
|
#include <uapi/linux/cxl_mem.h>
|
2021-06-16 07:36:31 +08:00
|
|
|
#include <linux/cdev.h>
|
|
|
|
#include "cxl.h"
|
2021-05-14 13:21:49 +08:00
|
|
|
|
|
|
|
/* 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 - CXL bus object representing a Type-3 Memory Device
|
|
|
|
* @dev: driver core device object
|
|
|
|
* @cdev: char dev core object for ioctl operations
|
2021-11-03 04:29:01 +08:00
|
|
|
* @cxlds: The device state backing this device
|
2022-02-04 23:18:31 +08:00
|
|
|
* @detach_work: active memdev lost a port in its ancestry
|
2021-05-14 13:21:49 +08:00
|
|
|
* @id: id number of this memdev instance.
|
|
|
|
*/
|
|
|
|
struct cxl_memdev {
|
|
|
|
struct device dev;
|
|
|
|
struct cdev cdev;
|
2021-11-03 04:29:01 +08:00
|
|
|
struct cxl_dev_state *cxlds;
|
2022-02-04 23:18:31 +08:00
|
|
|
struct work_struct detach_work;
|
2021-05-14 13:21:49 +08:00
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
2021-08-03 01:30:05 +08:00
|
|
|
static inline struct cxl_memdev *to_cxl_memdev(struct device *dev)
|
|
|
|
{
|
|
|
|
return container_of(dev, struct cxl_memdev, dev);
|
|
|
|
}
|
|
|
|
|
2022-02-04 23:18:31 +08:00
|
|
|
bool is_cxl_memdev(struct device *dev);
|
|
|
|
static inline bool is_cxl_endpoint(struct cxl_port *port)
|
|
|
|
{
|
|
|
|
return is_cxl_memdev(port->uport);
|
|
|
|
}
|
|
|
|
|
2021-11-03 04:29:01 +08:00
|
|
|
struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds);
|
2021-08-03 01:30:05 +08:00
|
|
|
|
2021-09-09 13:12:21 +08:00
|
|
|
/**
|
|
|
|
* struct cxl_mbox_cmd - A command to be submitted to hardware.
|
|
|
|
* @opcode: (input) The command set and command submitted to hardware.
|
|
|
|
* @payload_in: (input) Pointer to the input payload.
|
|
|
|
* @payload_out: (output) Pointer to the output payload. Must be allocated by
|
|
|
|
* the caller.
|
|
|
|
* @size_in: (input) Number of bytes to load from @payload_in.
|
|
|
|
* @size_out: (input) Max number of bytes loaded into @payload_out.
|
|
|
|
* (output) Number of bytes generated by the device. For fixed size
|
|
|
|
* outputs commands this is always expected to be deterministic. For
|
|
|
|
* variable sized output commands, it tells the exact number of bytes
|
|
|
|
* written.
|
|
|
|
* @return_code: (output) Error code returned from hardware.
|
|
|
|
*
|
|
|
|
* This is the primary mechanism used to send commands to the hardware.
|
|
|
|
* All the fields except @payload_* correspond exactly to the fields described in
|
|
|
|
* Command Register section of the CXL 2.0 8.2.8.4.5. @payload_in and
|
|
|
|
* @payload_out are written to, and read from the Command Payload Registers
|
|
|
|
* defined in CXL 2.0 8.2.8.4.8.
|
|
|
|
*/
|
|
|
|
struct cxl_mbox_cmd {
|
|
|
|
u16 opcode;
|
|
|
|
void *payload_in;
|
|
|
|
void *payload_out;
|
|
|
|
size_t size_in;
|
|
|
|
size_t size_out;
|
|
|
|
u16 return_code;
|
|
|
|
};
|
|
|
|
|
2022-04-04 10:12:15 +08:00
|
|
|
/*
|
|
|
|
* Per CXL 2.0 Section 8.2.8.4.5.1
|
|
|
|
*/
|
|
|
|
#define CMD_CMD_RC_TABLE \
|
|
|
|
C(SUCCESS, 0, NULL), \
|
|
|
|
C(BACKGROUND, -ENXIO, "background cmd started successfully"), \
|
|
|
|
C(INPUT, -ENXIO, "cmd input was invalid"), \
|
|
|
|
C(UNSUPPORTED, -ENXIO, "cmd is not supported"), \
|
|
|
|
C(INTERNAL, -ENXIO, "internal device error"), \
|
|
|
|
C(RETRY, -ENXIO, "temporary error, retry once"), \
|
|
|
|
C(BUSY, -ENXIO, "ongoing background operation"), \
|
|
|
|
C(MEDIADISABLED, -ENXIO, "media access is disabled"), \
|
|
|
|
C(FWINPROGRESS, -ENXIO, "one FW package can be transferred at a time"), \
|
|
|
|
C(FWOOO, -ENXIO, "FW package content was transferred out of order"), \
|
|
|
|
C(FWAUTH, -ENXIO, "FW package authentication failed"), \
|
|
|
|
C(FWSLOT, -ENXIO, "FW slot is not supported for requested operation"), \
|
|
|
|
C(FWROLLBACK, -ENXIO, "rolled back to the previous active FW"), \
|
|
|
|
C(FWRESET, -ENXIO, "FW failed to activate, needs cold reset"), \
|
|
|
|
C(HANDLE, -ENXIO, "one or more Event Record Handles were invalid"), \
|
|
|
|
C(PADDR, -ENXIO, "physical address specified is invalid"), \
|
|
|
|
C(POISONLMT, -ENXIO, "poison injection limit has been reached"), \
|
|
|
|
C(MEDIAFAILURE, -ENXIO, "permanent issue with the media"), \
|
|
|
|
C(ABORT, -ENXIO, "background cmd was aborted by device"), \
|
|
|
|
C(SECURITY, -ENXIO, "not valid in the current security state"), \
|
|
|
|
C(PASSPHRASE, -ENXIO, "phrase doesn't match current set passphrase"), \
|
|
|
|
C(MBUNSUPPORTED, -ENXIO, "unsupported on the mailbox it was issued on"),\
|
|
|
|
C(PAYLOADLEN, -ENXIO, "invalid payload length")
|
|
|
|
|
|
|
|
#undef C
|
|
|
|
#define C(a, b, c) CXL_MBOX_CMD_RC_##a
|
|
|
|
enum { CMD_CMD_RC_TABLE };
|
|
|
|
#undef C
|
|
|
|
#define C(a, b, c) { b, c }
|
|
|
|
struct cxl_mbox_cmd_rc {
|
|
|
|
int err;
|
|
|
|
const char *desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const
|
|
|
|
struct cxl_mbox_cmd_rc cxl_mbox_cmd_rctable[] ={ CMD_CMD_RC_TABLE };
|
|
|
|
#undef C
|
|
|
|
|
|
|
|
static inline const char *cxl_mbox_cmd_rc2str(struct cxl_mbox_cmd *mbox_cmd)
|
|
|
|
{
|
|
|
|
return cxl_mbox_cmd_rctable[mbox_cmd->return_code].desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int cxl_mbox_cmd_rc2errno(struct cxl_mbox_cmd *mbox_cmd)
|
|
|
|
{
|
|
|
|
return cxl_mbox_cmd_rctable[mbox_cmd->return_code].err;
|
|
|
|
}
|
|
|
|
|
2021-09-09 13:12:21 +08:00
|
|
|
/*
|
|
|
|
* CXL 2.0 - Memory capacity multiplier
|
|
|
|
* See Section 8.2.9.5
|
|
|
|
*
|
|
|
|
* Volatile, Persistent, and Partition capacities are specified to be in
|
|
|
|
* multiples of 256MB - define a multiplier to convert to/from bytes.
|
|
|
|
*/
|
|
|
|
#define CXL_CAPACITY_MULTIPLIER SZ_256M
|
|
|
|
|
2022-02-02 07:48:56 +08:00
|
|
|
/**
|
|
|
|
* struct cxl_endpoint_dvsec_info - Cached DVSEC info
|
|
|
|
* @mem_enabled: cached value of mem_enabled in the DVSEC, PCIE_DEVICE
|
|
|
|
* @ranges: Number of active HDM ranges this device uses.
|
|
|
|
* @dvsec_range: cached attributes of the ranges in the DVSEC, PCIE_DEVICE
|
|
|
|
*/
|
|
|
|
struct cxl_endpoint_dvsec_info {
|
|
|
|
bool mem_enabled;
|
|
|
|
int ranges;
|
|
|
|
struct range dvsec_range[2];
|
|
|
|
};
|
|
|
|
|
2021-05-14 13:21:49 +08:00
|
|
|
/**
|
2021-11-03 04:29:01 +08:00
|
|
|
* struct cxl_dev_state - The driver device state
|
|
|
|
*
|
|
|
|
* cxl_dev_state represents the CXL driver/device state. It provides an
|
|
|
|
* interface to mailbox commands as well as some cached data about the device.
|
|
|
|
* Currently only memory devices are represented.
|
|
|
|
*
|
|
|
|
* @dev: The device associated with this CXL state
|
cxl/mem: Introduce 'struct cxl_regs' for "composable" CXL devices
CXL MMIO register blocks are organized by device type and capabilities.
There are Component registers, Device registers (yes, an ambiguous
name), and Memory Device registers (a specific extension of Device
registers).
It is possible for a given device instance (endpoint or port) to
implement register sets from multiple of the above categories.
The driver code that enumerates and maps the registers is type specific
so it is useful to have a dedicated type and helpers for each block
type.
At the same time, once the registers are mapped the origin type does not
matter. It is overly pedantic to reference the register block type in
code that is using the registers.
In preparation for the endpoint driver to incorporate Component registers
into its MMIO operations reorganize the registers to allow typed
enumeration + mapping, but anonymous usage. With the end state of
'struct cxl_regs' to be:
struct cxl_regs {
union {
struct {
CXL_DEVICE_REGS();
};
struct cxl_device_regs device_regs;
};
union {
struct {
CXL_COMPONENT_REGS();
};
struct cxl_component_regs component_regs;
};
};
With this arrangement the driver can share component init code with
ports, but when using the registers it can directly reference the
component register block type by name without the 'component_regs'
prefix.
So, map + enumerate can be shared across drivers of different CXL
classes e.g.:
void cxl_setup_device_regs(struct device *dev, void __iomem *base,
struct cxl_device_regs *regs);
void cxl_setup_component_regs(struct device *dev, void __iomem *base,
struct cxl_component_regs *regs);
...while inline usage in the driver need not indicate where the
registers came from:
readl(cxlm->regs.mbox + MBOX_OFFSET);
readl(cxlm->regs.hdm + HDM_OFFSET);
...instead of:
readl(cxlm->regs.device_regs.mbox + MBOX_OFFSET);
readl(cxlm->regs.component_regs.hdm + HDM_OFFSET);
This complexity of the definition in .h yields improvement in code
readability in .c while maintaining type-safety for organization of
setup code. It prepares the implementation to maintain organization in
the face of CXL devices that compose register interfaces consisting of
multiple types.
Given that this new container is named 'regs' rename the common register
base pointer @base, and fixup the kernel-doc for the missing @cxlmd
description.
Reviewed-by: Ben Widawsky <ben.widawsky@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/162096971451.1865304.13540251513463515153.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2021-05-14 13:21:54 +08:00
|
|
|
* @regs: Parsed register blocks
|
2022-02-02 06:06:32 +08:00
|
|
|
* @cxl_dvsec: Offset to the PCIe device DVSEC
|
2021-05-14 13:21:49 +08:00
|
|
|
* @payload_size: Size of space for payload
|
|
|
|
* (CXL 2.0 8.2.8.4.3 Mailbox Capabilities Register)
|
2021-05-21 03:47:45 +08:00
|
|
|
* @lsa_size: Size of Label Storage Area
|
|
|
|
* (CXL 2.0 8.2.9.5.1.1 Identify Memory Device)
|
2021-05-14 13:21:49 +08:00
|
|
|
* @mbox_mutex: Mutex to synchronize mailbox access.
|
|
|
|
* @firmware_version: Firmware version for the memory device.
|
|
|
|
* @enabled_cmds: Hardware commands found enabled in CEL.
|
2021-09-15 03:03:04 +08:00
|
|
|
* @exclusive_cmds: Commands that are kernel-internal only
|
2022-05-22 06:35:29 +08:00
|
|
|
* @dpa_res: Overall DPA resource tree for the device
|
|
|
|
* @pmem_res: Active Persistent memory capacity configuration
|
|
|
|
* @ram_res: Active Volatile memory capacity configuration
|
2021-09-14 06:24:32 +08:00
|
|
|
* @total_bytes: sum of all possible capacities
|
|
|
|
* @volatile_only_bytes: hard volatile capacity
|
|
|
|
* @persistent_only_bytes: hard persistent capacity
|
|
|
|
* @partition_align_bytes: alignment size for partition-able capacity
|
|
|
|
* @active_volatile_bytes: sum of hard + soft volatile
|
|
|
|
* @active_persistent_bytes: sum of hard + soft persistent
|
|
|
|
* @next_volatile_bytes: volatile capacity change pending device reset
|
|
|
|
* @next_persistent_bytes: persistent capacity change pending device reset
|
2022-02-02 05:28:53 +08:00
|
|
|
* @component_reg_phys: register base of component registers
|
2022-02-02 07:48:56 +08:00
|
|
|
* @info: Cached DVSEC information about the device.
|
2022-02-01 05:56:11 +08:00
|
|
|
* @serial: PCIe Device Serial Number
|
2022-07-20 04:52:47 +08:00
|
|
|
* @doe_mbs: PCI DOE mailbox array
|
2021-09-09 13:12:21 +08:00
|
|
|
* @mbox_send: @dev specific transport for transmitting mailbox commands
|
2021-09-14 06:24:32 +08:00
|
|
|
*
|
|
|
|
* See section 8.2.9.5.2 Capacity Configuration and Label Storage for
|
|
|
|
* details on capacity parameters.
|
2021-05-14 13:21:49 +08:00
|
|
|
*/
|
2021-11-03 04:29:01 +08:00
|
|
|
struct cxl_dev_state {
|
2021-09-09 13:12:09 +08:00
|
|
|
struct device *dev;
|
2021-05-14 13:21:49 +08:00
|
|
|
|
cxl/mem: Introduce 'struct cxl_regs' for "composable" CXL devices
CXL MMIO register blocks are organized by device type and capabilities.
There are Component registers, Device registers (yes, an ambiguous
name), and Memory Device registers (a specific extension of Device
registers).
It is possible for a given device instance (endpoint or port) to
implement register sets from multiple of the above categories.
The driver code that enumerates and maps the registers is type specific
so it is useful to have a dedicated type and helpers for each block
type.
At the same time, once the registers are mapped the origin type does not
matter. It is overly pedantic to reference the register block type in
code that is using the registers.
In preparation for the endpoint driver to incorporate Component registers
into its MMIO operations reorganize the registers to allow typed
enumeration + mapping, but anonymous usage. With the end state of
'struct cxl_regs' to be:
struct cxl_regs {
union {
struct {
CXL_DEVICE_REGS();
};
struct cxl_device_regs device_regs;
};
union {
struct {
CXL_COMPONENT_REGS();
};
struct cxl_component_regs component_regs;
};
};
With this arrangement the driver can share component init code with
ports, but when using the registers it can directly reference the
component register block type by name without the 'component_regs'
prefix.
So, map + enumerate can be shared across drivers of different CXL
classes e.g.:
void cxl_setup_device_regs(struct device *dev, void __iomem *base,
struct cxl_device_regs *regs);
void cxl_setup_component_regs(struct device *dev, void __iomem *base,
struct cxl_component_regs *regs);
...while inline usage in the driver need not indicate where the
registers came from:
readl(cxlm->regs.mbox + MBOX_OFFSET);
readl(cxlm->regs.hdm + HDM_OFFSET);
...instead of:
readl(cxlm->regs.device_regs.mbox + MBOX_OFFSET);
readl(cxlm->regs.component_regs.hdm + HDM_OFFSET);
This complexity of the definition in .h yields improvement in code
readability in .c while maintaining type-safety for organization of
setup code. It prepares the implementation to maintain organization in
the face of CXL devices that compose register interfaces consisting of
multiple types.
Given that this new container is named 'regs' rename the common register
base pointer @base, and fixup the kernel-doc for the missing @cxlmd
description.
Reviewed-by: Ben Widawsky <ben.widawsky@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/162096971451.1865304.13540251513463515153.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2021-05-14 13:21:54 +08:00
|
|
|
struct cxl_regs regs;
|
2022-02-02 06:06:32 +08:00
|
|
|
int cxl_dvsec;
|
2021-05-14 13:21:49 +08:00
|
|
|
|
|
|
|
size_t payload_size;
|
2021-05-21 03:47:45 +08:00
|
|
|
size_t lsa_size;
|
2021-05-14 13:21:49 +08:00
|
|
|
struct mutex mbox_mutex; /* Protects device mailbox and firmware */
|
|
|
|
char firmware_version[0x10];
|
2021-09-09 13:12:44 +08:00
|
|
|
DECLARE_BITMAP(enabled_cmds, CXL_MEM_COMMAND_ID_MAX);
|
2021-09-15 03:03:04 +08:00
|
|
|
DECLARE_BITMAP(exclusive_cmds, CXL_MEM_COMMAND_ID_MAX);
|
2021-05-14 13:21:49 +08:00
|
|
|
|
2022-05-22 06:35:29 +08:00
|
|
|
struct resource dpa_res;
|
|
|
|
struct resource pmem_res;
|
|
|
|
struct resource ram_res;
|
2021-06-18 06:16:18 +08:00
|
|
|
u64 total_bytes;
|
|
|
|
u64 volatile_only_bytes;
|
|
|
|
u64 persistent_only_bytes;
|
|
|
|
u64 partition_align_bytes;
|
2021-08-11 02:57:59 +08:00
|
|
|
|
|
|
|
u64 active_volatile_bytes;
|
|
|
|
u64 active_persistent_bytes;
|
|
|
|
u64 next_volatile_bytes;
|
|
|
|
u64 next_persistent_bytes;
|
2021-09-09 13:12:21 +08:00
|
|
|
|
2022-02-02 05:28:53 +08:00
|
|
|
resource_size_t component_reg_phys;
|
2022-02-01 05:56:11 +08:00
|
|
|
u64 serial;
|
2022-02-02 05:28:53 +08:00
|
|
|
|
2022-07-20 04:52:47 +08:00
|
|
|
struct xarray doe_mbs;
|
|
|
|
|
2021-11-03 04:29:01 +08:00
|
|
|
int (*mbox_send)(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd);
|
2021-05-14 13:21:49 +08:00
|
|
|
};
|
2021-09-09 13:12:32 +08:00
|
|
|
|
|
|
|
enum cxl_opcode {
|
|
|
|
CXL_MBOX_OP_INVALID = 0x0000,
|
|
|
|
CXL_MBOX_OP_RAW = CXL_MBOX_OP_INVALID,
|
|
|
|
CXL_MBOX_OP_GET_FW_INFO = 0x0200,
|
|
|
|
CXL_MBOX_OP_ACTIVATE_FW = 0x0202,
|
|
|
|
CXL_MBOX_OP_GET_SUPPORTED_LOGS = 0x0400,
|
|
|
|
CXL_MBOX_OP_GET_LOG = 0x0401,
|
|
|
|
CXL_MBOX_OP_IDENTIFY = 0x4000,
|
|
|
|
CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100,
|
|
|
|
CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,
|
|
|
|
CXL_MBOX_OP_GET_LSA = 0x4102,
|
|
|
|
CXL_MBOX_OP_SET_LSA = 0x4103,
|
|
|
|
CXL_MBOX_OP_GET_HEALTH_INFO = 0x4200,
|
|
|
|
CXL_MBOX_OP_GET_ALERT_CONFIG = 0x4201,
|
|
|
|
CXL_MBOX_OP_SET_ALERT_CONFIG = 0x4202,
|
|
|
|
CXL_MBOX_OP_GET_SHUTDOWN_STATE = 0x4203,
|
|
|
|
CXL_MBOX_OP_SET_SHUTDOWN_STATE = 0x4204,
|
|
|
|
CXL_MBOX_OP_GET_POISON = 0x4300,
|
|
|
|
CXL_MBOX_OP_INJECT_POISON = 0x4301,
|
|
|
|
CXL_MBOX_OP_CLEAR_POISON = 0x4302,
|
|
|
|
CXL_MBOX_OP_GET_SCAN_MEDIA_CAPS = 0x4303,
|
|
|
|
CXL_MBOX_OP_SCAN_MEDIA = 0x4304,
|
|
|
|
CXL_MBOX_OP_GET_SCAN_MEDIA = 0x4305,
|
|
|
|
CXL_MBOX_OP_MAX = 0x10000
|
|
|
|
};
|
|
|
|
|
2021-09-09 13:13:15 +08:00
|
|
|
#define DEFINE_CXL_CEL_UUID \
|
|
|
|
UUID_INIT(0xda9c0b5, 0xbf41, 0x4b78, 0x8f, 0x79, 0x96, 0xb1, 0x62, \
|
|
|
|
0x3b, 0x3f, 0x17)
|
|
|
|
|
|
|
|
#define DEFINE_CXL_VENDOR_DEBUG_UUID \
|
|
|
|
UUID_INIT(0xe1819d9, 0x11a9, 0x400c, 0x81, 0x1f, 0xd6, 0x07, 0x19, \
|
|
|
|
0x40, 0x3d, 0x86)
|
|
|
|
|
|
|
|
struct cxl_mbox_get_supported_logs {
|
|
|
|
__le16 entries;
|
|
|
|
u8 rsvd[6];
|
|
|
|
struct cxl_gsl_entry {
|
|
|
|
uuid_t uuid;
|
|
|
|
__le32 size;
|
|
|
|
} __packed entry[];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct cxl_cel_entry {
|
|
|
|
__le16 opcode;
|
|
|
|
__le16 effect;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct cxl_mbox_get_log {
|
|
|
|
uuid_t uuid;
|
|
|
|
__le32 offset;
|
|
|
|
__le32 length;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */
|
|
|
|
struct cxl_mbox_identify {
|
|
|
|
char fw_revision[0x10];
|
|
|
|
__le64 total_capacity;
|
|
|
|
__le64 volatile_capacity;
|
|
|
|
__le64 persistent_capacity;
|
|
|
|
__le64 partition_align;
|
|
|
|
__le16 info_event_log_size;
|
|
|
|
__le16 warning_event_log_size;
|
|
|
|
__le16 failure_event_log_size;
|
|
|
|
__le16 fatal_event_log_size;
|
|
|
|
__le32 lsa_size;
|
|
|
|
u8 poison_list_max_mer[3];
|
|
|
|
__le16 inject_poison_limit;
|
|
|
|
u8 poison_caps;
|
|
|
|
u8 qos_telemetry_caps;
|
|
|
|
} __packed;
|
|
|
|
|
2022-05-24 14:26:11 +08:00
|
|
|
struct cxl_mbox_get_partition_info {
|
|
|
|
__le64 active_volatile_cap;
|
|
|
|
__le64 active_persistent_cap;
|
|
|
|
__le64 next_volatile_cap;
|
|
|
|
__le64 next_persistent_cap;
|
|
|
|
} __packed;
|
|
|
|
|
2021-09-09 13:13:15 +08:00
|
|
|
struct cxl_mbox_get_lsa {
|
2022-02-26 06:14:56 +08:00
|
|
|
__le32 offset;
|
|
|
|
__le32 length;
|
2021-09-09 13:13:15 +08:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct cxl_mbox_set_lsa {
|
2022-02-26 06:14:56 +08:00
|
|
|
__le32 offset;
|
|
|
|
__le32 reserved;
|
2021-09-09 13:13:15 +08:00
|
|
|
u8 data[];
|
|
|
|
} __packed;
|
|
|
|
|
2022-03-31 09:27:18 +08:00
|
|
|
struct cxl_mbox_set_partition_info {
|
|
|
|
__le64 volatile_capacity;
|
|
|
|
u8 flags;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
#define CXL_SET_PARTITION_IMMEDIATE_FLAG BIT(0)
|
|
|
|
|
2021-09-09 13:12:32 +08:00
|
|
|
/**
|
|
|
|
* struct cxl_mem_command - Driver representation of a memory device command
|
|
|
|
* @info: Command information as it exists for the UAPI
|
|
|
|
* @opcode: The actual bits used for the mailbox protocol
|
|
|
|
* @flags: Set of flags effecting driver behavior.
|
|
|
|
*
|
|
|
|
* * %CXL_CMD_FLAG_FORCE_ENABLE: In cases of error, commands with this flag
|
|
|
|
* will be enabled by the driver regardless of what hardware may have
|
|
|
|
* advertised.
|
|
|
|
*
|
|
|
|
* The cxl_mem_command is the driver's internal representation of commands that
|
|
|
|
* are supported by the driver. Some of these commands may not be supported by
|
|
|
|
* the hardware. The driver will use @info to validate the fields passed in by
|
|
|
|
* the user then submit the @opcode to the hardware.
|
|
|
|
*
|
|
|
|
* See struct cxl_command_info.
|
|
|
|
*/
|
|
|
|
struct cxl_mem_command {
|
|
|
|
struct cxl_command_info info;
|
|
|
|
enum cxl_opcode opcode;
|
|
|
|
u32 flags;
|
|
|
|
#define CXL_CMD_FLAG_NONE 0
|
|
|
|
#define CXL_CMD_FLAG_FORCE_ENABLE BIT(0)
|
|
|
|
};
|
|
|
|
|
2021-11-03 04:29:01 +08:00
|
|
|
int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
|
|
|
|
size_t in_size, void *out, size_t out_size);
|
|
|
|
int cxl_dev_state_identify(struct cxl_dev_state *cxlds);
|
2022-05-19 07:34:43 +08:00
|
|
|
int cxl_await_media_ready(struct cxl_dev_state *cxlds);
|
2021-11-03 04:29:01 +08:00
|
|
|
int cxl_enumerate_cmds(struct cxl_dev_state *cxlds);
|
|
|
|
int cxl_mem_create_range_info(struct cxl_dev_state *cxlds);
|
|
|
|
struct cxl_dev_state *cxl_dev_state_create(struct device *dev);
|
|
|
|
void set_exclusive_cxl_commands(struct cxl_dev_state *cxlds, unsigned long *cmds);
|
|
|
|
void clear_exclusive_cxl_commands(struct cxl_dev_state *cxlds, unsigned long *cmds);
|
2022-04-23 06:58:11 +08:00
|
|
|
#ifdef CONFIG_CXL_SUSPEND
|
|
|
|
void cxl_mem_active_inc(void);
|
|
|
|
void cxl_mem_active_dec(void);
|
|
|
|
#else
|
|
|
|
static inline void cxl_mem_active_inc(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void cxl_mem_active_dec(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2022-02-02 04:24:30 +08:00
|
|
|
|
|
|
|
struct cxl_hdm {
|
|
|
|
struct cxl_component_regs regs;
|
|
|
|
unsigned int decoder_count;
|
|
|
|
unsigned int target_count;
|
|
|
|
unsigned int interleave_mask;
|
|
|
|
struct cxl_port *port;
|
|
|
|
};
|
2022-05-27 03:15:25 +08:00
|
|
|
|
|
|
|
struct seq_file;
|
|
|
|
struct dentry *cxl_debugfs_create_dir(const char *dir);
|
|
|
|
void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds);
|
2021-05-14 13:21:49 +08:00
|
|
|
#endif /* __CXL_MEM_H__ */
|