pciif.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * PCI Backend/Frontend Common Data Structures & Macros
  4. *
  5. * Author: Ryan Wilson <[email protected]>
  6. */
  7. #ifndef __XEN_PCI_COMMON_H__
  8. #define __XEN_PCI_COMMON_H__
  9. /* Be sure to bump this number if you change this file */
  10. #define XEN_PCI_MAGIC "7"
  11. /* xen_pci_sharedinfo flags */
  12. #define _XEN_PCIF_active (0)
  13. #define XEN_PCIF_active (1<<_XEN_PCIF_active)
  14. #define _XEN_PCIB_AERHANDLER (1)
  15. #define XEN_PCIB_AERHANDLER (1<<_XEN_PCIB_AERHANDLER)
  16. #define _XEN_PCIB_active (2)
  17. #define XEN_PCIB_active (1<<_XEN_PCIB_active)
  18. /* xen_pci_op commands */
  19. #define XEN_PCI_OP_conf_read (0)
  20. #define XEN_PCI_OP_conf_write (1)
  21. #define XEN_PCI_OP_enable_msi (2)
  22. #define XEN_PCI_OP_disable_msi (3)
  23. #define XEN_PCI_OP_enable_msix (4)
  24. #define XEN_PCI_OP_disable_msix (5)
  25. #define XEN_PCI_OP_aer_detected (6)
  26. #define XEN_PCI_OP_aer_resume (7)
  27. #define XEN_PCI_OP_aer_mmio (8)
  28. #define XEN_PCI_OP_aer_slotreset (9)
  29. /* xen_pci_op error numbers */
  30. #define XEN_PCI_ERR_success (0)
  31. #define XEN_PCI_ERR_dev_not_found (-1)
  32. #define XEN_PCI_ERR_invalid_offset (-2)
  33. #define XEN_PCI_ERR_access_denied (-3)
  34. #define XEN_PCI_ERR_not_implemented (-4)
  35. /* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
  36. #define XEN_PCI_ERR_op_failed (-5)
  37. /*
  38. * it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry))
  39. * Should not exceed 128
  40. */
  41. #define SH_INFO_MAX_VEC 128
  42. struct xen_msix_entry {
  43. uint16_t vector;
  44. uint16_t entry;
  45. };
  46. struct xen_pci_op {
  47. /* IN: what action to perform: XEN_PCI_OP_* */
  48. uint32_t cmd;
  49. /* OUT: will contain an error number (if any) from errno.h */
  50. int32_t err;
  51. /* IN: which device to touch */
  52. uint32_t domain; /* PCI Domain/Segment */
  53. uint32_t bus;
  54. uint32_t devfn;
  55. /* IN: which configuration registers to touch */
  56. int32_t offset;
  57. int32_t size;
  58. /* IN/OUT: Contains the result after a READ or the value to WRITE */
  59. uint32_t value;
  60. /* IN: Contains extra infor for this operation */
  61. uint32_t info;
  62. /*IN: param for msi-x */
  63. struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
  64. };
  65. /*used for pcie aer handling*/
  66. struct xen_pcie_aer_op {
  67. /* IN: what action to perform: XEN_PCI_OP_* */
  68. uint32_t cmd;
  69. /*IN/OUT: return aer_op result or carry error_detected state as input*/
  70. int32_t err;
  71. /* IN: which device to touch */
  72. uint32_t domain; /* PCI Domain/Segment*/
  73. uint32_t bus;
  74. uint32_t devfn;
  75. };
  76. struct xen_pci_sharedinfo {
  77. /* flags - XEN_PCIF_* */
  78. uint32_t flags;
  79. struct xen_pci_op op;
  80. struct xen_pcie_aer_op aer_op;
  81. };
  82. #endif /* __XEN_PCI_COMMON_H__ */