0001
0002
0003
0004 #ifndef __CXL_CORE_H__
0005 #define __CXL_CORE_H__
0006
0007 extern const struct device_type cxl_nvdimm_bridge_type;
0008 extern const struct device_type cxl_nvdimm_type;
0009
0010 extern struct attribute_group cxl_base_attribute_group;
0011
0012 #ifdef CONFIG_CXL_REGION
0013 extern struct device_attribute dev_attr_create_pmem_region;
0014 extern struct device_attribute dev_attr_delete_region;
0015 extern struct device_attribute dev_attr_region;
0016 extern const struct device_type cxl_pmem_region_type;
0017 extern const struct device_type cxl_region_type;
0018 void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled);
0019 #define CXL_REGION_ATTR(x) (&dev_attr_##x.attr)
0020 #define CXL_REGION_TYPE(x) (&cxl_region_type)
0021 #define SET_CXL_REGION_ATTR(x) (&dev_attr_##x.attr),
0022 #define CXL_PMEM_REGION_TYPE(x) (&cxl_pmem_region_type)
0023 int cxl_region_init(void);
0024 void cxl_region_exit(void);
0025 #else
0026 static inline void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled)
0027 {
0028 }
0029 static inline int cxl_region_init(void)
0030 {
0031 return 0;
0032 }
0033 static inline void cxl_region_exit(void)
0034 {
0035 }
0036 #define CXL_REGION_ATTR(x) NULL
0037 #define CXL_REGION_TYPE(x) NULL
0038 #define SET_CXL_REGION_ATTR(x)
0039 #define CXL_PMEM_REGION_TYPE(x) NULL
0040 #endif
0041
0042 struct cxl_send_command;
0043 struct cxl_mem_query_commands;
0044 int cxl_query_cmd(struct cxl_memdev *cxlmd,
0045 struct cxl_mem_query_commands __user *q);
0046 int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s);
0047 void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr,
0048 resource_size_t length);
0049
0050 struct dentry *cxl_debugfs_create_dir(const char *dir);
0051 int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
0052 enum cxl_decoder_mode mode);
0053 int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size);
0054 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled);
0055 resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled);
0056 resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled);
0057 extern struct rw_semaphore cxl_dpa_rwsem;
0058
0059 bool is_switch_decoder(struct device *dev);
0060 struct cxl_switch_decoder *to_cxl_switch_decoder(struct device *dev);
0061 static inline struct cxl_ep *cxl_ep_load(struct cxl_port *port,
0062 struct cxl_memdev *cxlmd)
0063 {
0064 if (!port)
0065 return NULL;
0066
0067 return xa_load(&port->endpoints, (unsigned long)&cxlmd->dev);
0068 }
0069
0070 int cxl_memdev_init(void);
0071 void cxl_memdev_exit(void);
0072 void cxl_mbox_init(void);
0073
0074 #endif