cxlpci.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright(c) 2020 Intel Corporation. All rights reserved. */
  3. #ifndef __CXL_PCI_H__
  4. #define __CXL_PCI_H__
  5. #include <linux/pci.h>
  6. #include "cxl.h"
  7. #define CXL_MEMORY_PROGIF 0x10
  8. /*
  9. * NOTE: Currently all the functions which are enabled for CXL require their
  10. * vectors to be in the first 16. Use this as the default max.
  11. */
  12. #define CXL_PCI_DEFAULT_MAX_VECTORS 16
  13. /* Register Block Identifier (RBI) */
  14. enum cxl_regloc_type {
  15. CXL_REGLOC_RBI_EMPTY = 0,
  16. CXL_REGLOC_RBI_COMPONENT,
  17. CXL_REGLOC_RBI_VIRT,
  18. CXL_REGLOC_RBI_MEMDEV,
  19. CXL_REGLOC_RBI_PMU,
  20. CXL_REGLOC_RBI_TYPES
  21. };
  22. /*
  23. * Table Access DOE, CDAT Read Entry Response
  24. *
  25. * Spec refs:
  26. *
  27. * CXL 3.1 8.1.11, Table 8-14: Read Entry Response
  28. * CDAT Specification 1.03: 2 CDAT Data Structures
  29. */
  30. struct cdat_header {
  31. __le32 length;
  32. u8 revision;
  33. u8 checksum;
  34. u8 reserved[6];
  35. __le32 sequence;
  36. } __packed;
  37. struct cdat_entry_header {
  38. u8 type;
  39. u8 reserved;
  40. __le16 length;
  41. } __packed;
  42. /*
  43. * The DOE CDAT read response contains a CDAT read entry (either the
  44. * CDAT header or a structure).
  45. */
  46. union cdat_data {
  47. struct cdat_header header;
  48. struct cdat_entry_header entry;
  49. } __packed;
  50. /* There is an additional CDAT response header of 4 bytes. */
  51. struct cdat_doe_rsp {
  52. __le32 doe_header;
  53. u8 data[];
  54. } __packed;
  55. /*
  56. * CXL v3.0 6.2.3 Table 6-4
  57. * The table indicates that if PCIe Flit Mode is set, then CXL is in 256B flits
  58. * mode, otherwise it's 68B flits mode.
  59. */
  60. static inline bool cxl_pci_flit_256(struct pci_dev *pdev)
  61. {
  62. u16 lnksta2;
  63. pcie_capability_read_word(pdev, PCI_EXP_LNKSTA2, &lnksta2);
  64. return lnksta2 & PCI_EXP_LNKSTA2_FLIT;
  65. }
  66. struct cxl_dev_state;
  67. void read_cdat_data(struct cxl_port *port);
  68. #ifdef CONFIG_CXL_RAS
  69. void cxl_cor_error_detected(struct pci_dev *pdev);
  70. pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
  71. pci_channel_state_t state);
  72. void devm_cxl_dport_rch_ras_setup(struct cxl_dport *dport);
  73. void devm_cxl_port_ras_setup(struct cxl_port *port);
  74. #else
  75. static inline void cxl_cor_error_detected(struct pci_dev *pdev) { }
  76. static inline pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
  77. pci_channel_state_t state)
  78. {
  79. return PCI_ERS_RESULT_NONE;
  80. }
  81. static inline void devm_cxl_dport_rch_ras_setup(struct cxl_dport *dport)
  82. {
  83. }
  84. static inline void devm_cxl_port_ras_setup(struct cxl_port *port)
  85. {
  86. }
  87. #endif
  88. #endif /* __CXL_PCI_H__ */