#ifndef __CXL_H__
#define __CXL_H__
#include <linux/libnvdimm.h>
#include <linux/bitfield.h>
#include <linux/notifier.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/node.h>
#include <linux/io.h>
extern const struct nvdimm_security_ops *cxl_security_ops;
#define CXL_COMPONENT_REG_BLOCK_SIZE …
#define CXL_CM_OFFSET …
#define CXL_CM_CAP_HDR_OFFSET …
#define CXL_CM_CAP_HDR_ID_MASK …
#define CM_CAP_HDR_CAP_ID …
#define CXL_CM_CAP_HDR_VERSION_MASK …
#define CM_CAP_HDR_CAP_VERSION …
#define CXL_CM_CAP_HDR_CACHE_MEM_VERSION_MASK …
#define CM_CAP_HDR_CACHE_MEM_VERSION …
#define CXL_CM_CAP_HDR_ARRAY_SIZE_MASK …
#define CXL_CM_CAP_PTR_MASK …
#define CXL_CM_CAP_CAP_ID_RAS …
#define CXL_CM_CAP_CAP_ID_HDM …
#define CXL_CM_CAP_CAP_HDM_VERSION …
#define CXL_HDM_DECODER_CAP_OFFSET …
#define CXL_HDM_DECODER_COUNT_MASK …
#define CXL_HDM_DECODER_TARGET_COUNT_MASK …
#define CXL_HDM_DECODER_INTERLEAVE_11_8 …
#define CXL_HDM_DECODER_INTERLEAVE_14_12 …
#define CXL_HDM_DECODER_INTERLEAVE_3_6_12_WAY …
#define CXL_HDM_DECODER_INTERLEAVE_16_WAY …
#define CXL_HDM_DECODER_CTRL_OFFSET …
#define CXL_HDM_DECODER_ENABLE …
#define CXL_HDM_DECODER0_BASE_LOW_OFFSET(i) …
#define CXL_HDM_DECODER0_BASE_HIGH_OFFSET(i) …
#define CXL_HDM_DECODER0_SIZE_LOW_OFFSET(i) …
#define CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(i) …
#define CXL_HDM_DECODER0_CTRL_OFFSET(i) …
#define CXL_HDM_DECODER0_CTRL_IG_MASK …
#define CXL_HDM_DECODER0_CTRL_IW_MASK …
#define CXL_HDM_DECODER0_CTRL_LOCK …
#define CXL_HDM_DECODER0_CTRL_COMMIT …
#define CXL_HDM_DECODER0_CTRL_COMMITTED …
#define CXL_HDM_DECODER0_CTRL_COMMIT_ERROR …
#define CXL_HDM_DECODER0_CTRL_HOSTONLY …
#define CXL_HDM_DECODER0_TL_LOW(i) …
#define CXL_HDM_DECODER0_TL_HIGH(i) …
#define CXL_HDM_DECODER0_SKIP_LOW(i) …
#define CXL_HDM_DECODER0_SKIP_HIGH(i) …
#define CXL_DECODER_MIN_GRANULARITY …
#define CXL_DECODER_MAX_ENCODED_IG …
static inline int cxl_hdm_decoder_count(u32 cap_hdr)
{ … }
static inline int eig_to_granularity(u16 eig, unsigned int *granularity)
{ … }
static inline int eiw_to_ways(u8 eiw, unsigned int *ways)
{ … }
static inline int granularity_to_eig(int granularity, u16 *eig)
{ … }
static inline int ways_to_eiw(unsigned int ways, u8 *eiw)
{ … }
#define CXL_RAS_UNCORRECTABLE_STATUS_OFFSET …
#define CXL_RAS_UNCORRECTABLE_STATUS_MASK …
#define CXL_RAS_UNCORRECTABLE_MASK_OFFSET …
#define CXL_RAS_UNCORRECTABLE_MASK_MASK …
#define CXL_RAS_UNCORRECTABLE_MASK_F256B_MASK …
#define CXL_RAS_UNCORRECTABLE_SEVERITY_OFFSET …
#define CXL_RAS_UNCORRECTABLE_SEVERITY_MASK …
#define CXL_RAS_CORRECTABLE_STATUS_OFFSET …
#define CXL_RAS_CORRECTABLE_STATUS_MASK …
#define CXL_RAS_CORRECTABLE_MASK_OFFSET …
#define CXL_RAS_CORRECTABLE_MASK_MASK …
#define CXL_RAS_CAP_CONTROL_OFFSET …
#define CXL_RAS_CAP_CONTROL_FE_MASK …
#define CXL_RAS_HEADER_LOG_OFFSET …
#define CXL_RAS_CAPABILITY_LENGTH …
#define CXL_HEADERLOG_SIZE …
#define CXL_HEADERLOG_SIZE_U32 …
#define CXLDEV_CAP_ARRAY_OFFSET …
#define CXLDEV_CAP_ARRAY_CAP_ID …
#define CXLDEV_CAP_ARRAY_ID_MASK …
#define CXLDEV_CAP_ARRAY_COUNT_MASK …
#define CXLDEV_CAP_HDR_CAP_ID_MASK …
#define CXLDEV_CAP_CAP_ID_DEVICE_STATUS …
#define CXLDEV_CAP_CAP_ID_PRIMARY_MAILBOX …
#define CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX …
#define CXLDEV_CAP_CAP_ID_MEMDEV …
#define CXLDEV_DEV_EVENT_STATUS_OFFSET …
#define CXLDEV_EVENT_STATUS_INFO …
#define CXLDEV_EVENT_STATUS_WARN …
#define CXLDEV_EVENT_STATUS_FAIL …
#define CXLDEV_EVENT_STATUS_FATAL …
#define CXLDEV_EVENT_STATUS_ALL …
#define CXLDEV_EVENT_INT_MODE_MASK …
#define CXLDEV_EVENT_INT_MSGNUM_MASK …
#define CXLDEV_MBOX_CAPS_OFFSET …
#define CXLDEV_MBOX_CAP_PAYLOAD_SIZE_MASK …
#define CXLDEV_MBOX_CAP_BG_CMD_IRQ …
#define CXLDEV_MBOX_CAP_IRQ_MSGNUM_MASK …
#define CXLDEV_MBOX_CTRL_OFFSET …
#define CXLDEV_MBOX_CTRL_DOORBELL …
#define CXLDEV_MBOX_CTRL_BG_CMD_IRQ …
#define CXLDEV_MBOX_CMD_OFFSET …
#define CXLDEV_MBOX_CMD_COMMAND_OPCODE_MASK …
#define CXLDEV_MBOX_CMD_PAYLOAD_LENGTH_MASK …
#define CXLDEV_MBOX_STATUS_OFFSET …
#define CXLDEV_MBOX_STATUS_BG_CMD …
#define CXLDEV_MBOX_STATUS_RET_CODE_MASK …
#define CXLDEV_MBOX_BG_CMD_STATUS_OFFSET …
#define CXLDEV_MBOX_BG_CMD_COMMAND_OPCODE_MASK …
#define CXLDEV_MBOX_BG_CMD_COMMAND_PCT_MASK …
#define CXLDEV_MBOX_BG_CMD_COMMAND_RC_MASK …
#define CXLDEV_MBOX_BG_CMD_COMMAND_VENDOR_MASK …
#define CXLDEV_MBOX_PAYLOAD_OFFSET …
struct cxl_regs { … };
struct cxl_reg_map { … };
struct cxl_component_reg_map { … };
struct cxl_device_reg_map { … };
struct cxl_pmu_reg_map { … };
struct cxl_register_map { … };
void cxl_probe_component_regs(struct device *dev, void __iomem *base,
struct cxl_component_reg_map *map);
void cxl_probe_device_regs(struct device *dev, void __iomem *base,
struct cxl_device_reg_map *map);
int cxl_map_component_regs(const struct cxl_register_map *map,
struct cxl_component_regs *regs,
unsigned long map_mask);
int cxl_map_device_regs(const struct cxl_register_map *map,
struct cxl_device_regs *regs);
int cxl_map_pmu_regs(struct cxl_register_map *map, struct cxl_pmu_regs *regs);
enum cxl_regloc_type;
int cxl_count_regblock(struct pci_dev *pdev, enum cxl_regloc_type type);
int cxl_find_regblock_instance(struct pci_dev *pdev, enum cxl_regloc_type type,
struct cxl_register_map *map, int index);
int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type,
struct cxl_register_map *map);
int cxl_setup_regs(struct cxl_register_map *map);
struct cxl_dport;
resource_size_t cxl_rcd_component_reg_phys(struct device *dev,
struct cxl_dport *dport);
#define CXL_RESOURCE_NONE …
#define CXL_TARGET_STRLEN …
#define CXL_DECODER_F_RAM …
#define CXL_DECODER_F_PMEM …
#define CXL_DECODER_F_TYPE2 …
#define CXL_DECODER_F_TYPE3 …
#define CXL_DECODER_F_LOCK …
#define CXL_DECODER_F_ENABLE …
#define CXL_DECODER_F_MASK …
enum cxl_decoder_type { … };
#define CXL_DECODER_MAX_INTERLEAVE …
#define CXL_QOS_CLASS_INVALID …
struct cxl_decoder { … };
enum cxl_decoder_mode { … };
static inline const char *cxl_decoder_mode_name(enum cxl_decoder_mode mode)
{ … }
enum cxl_decoder_state { … };
struct cxl_endpoint_decoder { … };
struct cxl_switch_decoder { … };
struct cxl_root_decoder;
cxl_hpa_to_spa_fn;
struct cxl_root_decoder { … };
enum cxl_config_state { … };
struct cxl_region_params { … };
#define CXL_REGION_F_AUTO …
#define CXL_REGION_F_NEEDS_RESET …
struct cxl_region { … };
struct cxl_nvdimm_bridge { … };
#define CXL_DEV_ID_LEN …
struct cxl_nvdimm { … };
struct cxl_pmem_region_mapping { … };
struct cxl_pmem_region { … };
struct cxl_dax_region { … };
struct cxl_port { … };
struct cxl_root { … };
static inline struct cxl_root *
to_cxl_root(const struct cxl_port *port)
{ … }
struct cxl_root_ops { … };
static inline struct cxl_dport *
cxl_find_dport_by_dev(struct cxl_port *port, const struct device *dport_dev)
{ … }
struct cxl_rcrb_info { … };
struct cxl_dport { … };
struct cxl_ep { … };
struct cxl_region_ref { … };
static inline bool is_cxl_root(struct cxl_port *port)
{ … }
int cxl_num_decoders_committed(struct cxl_port *port);
bool is_cxl_port(const struct device *dev);
struct cxl_port *to_cxl_port(const struct device *dev);
struct pci_bus;
int devm_cxl_register_pci_bus(struct device *host, struct device *uport_dev,
struct pci_bus *bus);
struct pci_bus *cxl_port_to_pci_bus(struct cxl_port *port);
struct cxl_port *devm_cxl_add_port(struct device *host,
struct device *uport_dev,
resource_size_t component_reg_phys,
struct cxl_dport *parent_dport);
struct cxl_root *devm_cxl_add_root(struct device *host,
const struct cxl_root_ops *ops);
struct cxl_root *find_cxl_root(struct cxl_port *port);
void put_cxl_root(struct cxl_root *cxl_root);
DEFINE_FREE(…)
int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd);
void cxl_bus_rescan(void);
void cxl_bus_drain(void);
struct cxl_port *cxl_pci_find_port(struct pci_dev *pdev,
struct cxl_dport **dport);
struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd,
struct cxl_dport **dport);
bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd);
struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port,
struct device *dport, int port_id,
resource_size_t component_reg_phys);
struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port,
struct device *dport_dev, int port_id,
resource_size_t rcrb);
#ifdef CONFIG_PCIEAER_CXL
void cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport);
#else
static inline void cxl_setup_parent_dport(struct device *host,
struct cxl_dport *dport) { }
#endif
struct cxl_decoder *to_cxl_decoder(struct device *dev);
struct cxl_root_decoder *to_cxl_root_decoder(struct device *dev);
struct cxl_switch_decoder *to_cxl_switch_decoder(struct device *dev);
struct cxl_endpoint_decoder *to_cxl_endpoint_decoder(struct device *dev);
bool is_root_decoder(struct device *dev);
bool is_switch_decoder(struct device *dev);
bool is_endpoint_decoder(struct device *dev);
struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port,
unsigned int nr_targets);
struct cxl_switch_decoder *cxl_switch_decoder_alloc(struct cxl_port *port,
unsigned int nr_targets);
int cxl_decoder_add(struct cxl_decoder *cxld, int *target_map);
struct cxl_endpoint_decoder *cxl_endpoint_decoder_alloc(struct cxl_port *port);
int cxl_decoder_add_locked(struct cxl_decoder *cxld, int *target_map);
int cxl_decoder_autoremove(struct device *host, struct cxl_decoder *cxld);
static inline int cxl_root_decoder_autoremove(struct device *host,
struct cxl_root_decoder *cxlrd)
{ … }
int cxl_endpoint_autoremove(struct cxl_memdev *cxlmd, struct cxl_port *endpoint);
struct cxl_endpoint_dvsec_info { … };
struct cxl_hdm;
struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port,
struct cxl_endpoint_dvsec_info *info);
int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,
struct cxl_endpoint_dvsec_info *info);
int devm_cxl_add_passthrough_decoder(struct cxl_port *port);
int cxl_dvsec_rr_decode(struct device *dev, int dvsec,
struct cxl_endpoint_dvsec_info *info);
bool is_cxl_region(struct device *dev);
extern struct bus_type cxl_bus_type;
struct cxl_driver { … };
#define to_cxl_drv(__drv) …
int __cxl_driver_register(struct cxl_driver *cxl_drv, struct module *owner,
const char *modname);
#define cxl_driver_register(x) …
void cxl_driver_unregister(struct cxl_driver *cxl_drv);
#define module_cxl_driver(__cxl_driver) …
#define CXL_DEVICE_NVDIMM_BRIDGE …
#define CXL_DEVICE_NVDIMM …
#define CXL_DEVICE_PORT …
#define CXL_DEVICE_ROOT …
#define CXL_DEVICE_MEMORY_EXPANDER …
#define CXL_DEVICE_REGION …
#define CXL_DEVICE_PMEM_REGION …
#define CXL_DEVICE_DAX_REGION …
#define CXL_DEVICE_PMU …
#define MODULE_ALIAS_CXL(type) …
#define CXL_MODALIAS_FMT …
struct cxl_nvdimm_bridge *to_cxl_nvdimm_bridge(struct device *dev);
struct cxl_nvdimm_bridge *devm_cxl_add_nvdimm_bridge(struct device *host,
struct cxl_port *port);
struct cxl_nvdimm *to_cxl_nvdimm(struct device *dev);
bool is_cxl_nvdimm(struct device *dev);
bool is_cxl_nvdimm_bridge(struct device *dev);
int devm_cxl_add_nvdimm(struct cxl_port *parent_port, struct cxl_memdev *cxlmd);
struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_port *port);
#ifdef CONFIG_CXL_REGION
bool is_cxl_pmem_region(struct device *dev);
struct cxl_pmem_region *to_cxl_pmem_region(struct device *dev);
int cxl_add_to_region(struct cxl_port *root,
struct cxl_endpoint_decoder *cxled);
struct cxl_dax_region *to_cxl_dax_region(struct device *dev);
#else
static inline bool is_cxl_pmem_region(struct device *dev)
{
return false;
}
static inline struct cxl_pmem_region *to_cxl_pmem_region(struct device *dev)
{
return NULL;
}
static inline int cxl_add_to_region(struct cxl_port *root,
struct cxl_endpoint_decoder *cxled)
{
return 0;
}
static inline struct cxl_dax_region *to_cxl_dax_region(struct device *dev)
{
return NULL;
}
#endif
void cxl_endpoint_parse_cdat(struct cxl_port *port);
void cxl_switch_parse_cdat(struct cxl_port *port);
int cxl_endpoint_get_perf_coordinates(struct cxl_port *port,
struct access_coordinate *coord);
void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
struct cxl_endpoint_decoder *cxled);
void cxl_memdev_update_perf(struct cxl_memdev *cxlmd);
void cxl_coordinates_combine(struct access_coordinate *out,
struct access_coordinate *c1,
struct access_coordinate *c2);
bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port);
#ifndef __mock
#define __mock …
#endif
#endif