core.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright(c) 2020 Intel Corporation. */
  3. #ifndef __CXL_CORE_H__
  4. #define __CXL_CORE_H__
  5. extern const struct device_type cxl_nvdimm_bridge_type;
  6. extern const struct device_type cxl_nvdimm_type;
  7. extern const struct device_type cxl_pmu_type;
  8. extern struct attribute_group cxl_base_attribute_group;
  9. #ifdef CONFIG_CXL_REGION
  10. extern struct device_attribute dev_attr_create_pmem_region;
  11. extern struct device_attribute dev_attr_create_ram_region;
  12. extern struct device_attribute dev_attr_delete_region;
  13. extern struct device_attribute dev_attr_region;
  14. extern const struct device_type cxl_pmem_region_type;
  15. extern const struct device_type cxl_dax_region_type;
  16. extern const struct device_type cxl_region_type;
  17. void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled);
  18. #define CXL_REGION_ATTR(x) (&dev_attr_##x.attr)
  19. #define CXL_REGION_TYPE(x) (&cxl_region_type)
  20. #define SET_CXL_REGION_ATTR(x) (&dev_attr_##x.attr),
  21. #define CXL_PMEM_REGION_TYPE(x) (&cxl_pmem_region_type)
  22. #define CXL_DAX_REGION_TYPE(x) (&cxl_dax_region_type)
  23. int cxl_region_init(void);
  24. void cxl_region_exit(void);
  25. int cxl_get_poison_by_endpoint(struct cxl_port *port);
  26. struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa);
  27. u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
  28. u64 dpa);
  29. #else
  30. static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
  31. const struct cxl_memdev *cxlmd, u64 dpa)
  32. {
  33. return ULLONG_MAX;
  34. }
  35. static inline
  36. struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa)
  37. {
  38. return NULL;
  39. }
  40. static inline int cxl_get_poison_by_endpoint(struct cxl_port *port)
  41. {
  42. return 0;
  43. }
  44. static inline void cxl_decoder_kill_region(struct cxl_endpoint_decoder *cxled)
  45. {
  46. }
  47. static inline int cxl_region_init(void)
  48. {
  49. return 0;
  50. }
  51. static inline void cxl_region_exit(void)
  52. {
  53. }
  54. #define CXL_REGION_ATTR(x) NULL
  55. #define CXL_REGION_TYPE(x) NULL
  56. #define SET_CXL_REGION_ATTR(x)
  57. #define CXL_PMEM_REGION_TYPE(x) NULL
  58. #define CXL_DAX_REGION_TYPE(x) NULL
  59. #endif
  60. struct cxl_send_command;
  61. struct cxl_mem_query_commands;
  62. int cxl_query_cmd(struct cxl_memdev *cxlmd,
  63. struct cxl_mem_query_commands __user *q);
  64. int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s);
  65. void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr,
  66. resource_size_t length);
  67. struct dentry *cxl_debugfs_create_dir(const char *dir);
  68. int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
  69. enum cxl_decoder_mode mode);
  70. int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size);
  71. int cxl_dpa_free(struct cxl_endpoint_decoder *cxled);
  72. resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled);
  73. resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled);
  74. enum cxl_rcrb {
  75. CXL_RCRB_DOWNSTREAM,
  76. CXL_RCRB_UPSTREAM,
  77. };
  78. struct cxl_rcrb_info;
  79. resource_size_t __rcrb_to_component(struct device *dev,
  80. struct cxl_rcrb_info *ri,
  81. enum cxl_rcrb which);
  82. u16 cxl_rcrb_to_aer(struct device *dev, resource_size_t rcrb);
  83. extern struct rw_semaphore cxl_dpa_rwsem;
  84. extern struct rw_semaphore cxl_region_rwsem;
  85. int cxl_memdev_init(void);
  86. void cxl_memdev_exit(void);
  87. void cxl_mbox_init(void);
  88. enum cxl_poison_trace_type {
  89. CXL_POISON_TRACE_LIST,
  90. CXL_POISON_TRACE_INJECT,
  91. CXL_POISON_TRACE_CLEAR,
  92. };
  93. long cxl_pci_get_latency(struct pci_dev *pdev);
  94. int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c);
  95. int cxl_update_hmat_access_coordinates(int nid, struct cxl_region *cxlr,
  96. enum access_coordinate_class access);
  97. bool cxl_need_node_perf_attrs_update(int nid);
  98. int cxl_port_get_switch_dport_bandwidth(struct cxl_port *port,
  99. struct access_coordinate *c);
  100. #endif /* __CXL_CORE_H__ */