pciif.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * PCI Backend/Frontend Common Data Structures & Macros
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to
  6. * deal in the Software without restriction, including without limitation the
  7. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. * sell copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. *
  22. * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
  23. */
  24. #ifndef __XEN_PCI_COMMON_H__
  25. #define __XEN_PCI_COMMON_H__
  26. /* Be sure to bump this number if you change this file */
  27. #define XEN_PCI_MAGIC "7"
  28. /* xen_pci_sharedinfo flags */
  29. #define _XEN_PCIF_active (0)
  30. #define XEN_PCIF_active (1<<_XEN_PCIF_active)
  31. #define _XEN_PCIB_AERHANDLER (1)
  32. #define XEN_PCIB_AERHANDLER (1<<_XEN_PCIB_AERHANDLER)
  33. #define _XEN_PCIB_active (2)
  34. #define XEN_PCIB_active (1<<_XEN_PCIB_active)
  35. /* xen_pci_op commands */
  36. #define XEN_PCI_OP_conf_read (0)
  37. #define XEN_PCI_OP_conf_write (1)
  38. #define XEN_PCI_OP_enable_msi (2)
  39. #define XEN_PCI_OP_disable_msi (3)
  40. #define XEN_PCI_OP_enable_msix (4)
  41. #define XEN_PCI_OP_disable_msix (5)
  42. #define XEN_PCI_OP_aer_detected (6)
  43. #define XEN_PCI_OP_aer_resume (7)
  44. #define XEN_PCI_OP_aer_mmio (8)
  45. #define XEN_PCI_OP_aer_slotreset (9)
  46. /* xen_pci_op error numbers */
  47. #define XEN_PCI_ERR_success (0)
  48. #define XEN_PCI_ERR_dev_not_found (-1)
  49. #define XEN_PCI_ERR_invalid_offset (-2)
  50. #define XEN_PCI_ERR_access_denied (-3)
  51. #define XEN_PCI_ERR_not_implemented (-4)
  52. /* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
  53. #define XEN_PCI_ERR_op_failed (-5)
  54. /*
  55. * it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry))
  56. * Should not exceed 128
  57. */
  58. #define SH_INFO_MAX_VEC 128
  59. struct xen_msix_entry {
  60. uint16_t vector;
  61. uint16_t entry;
  62. };
  63. struct xen_pci_op {
  64. /* IN: what action to perform: XEN_PCI_OP_* */
  65. uint32_t cmd;
  66. /* OUT: will contain an error number (if any) from errno.h */
  67. int32_t err;
  68. /* IN: which device to touch */
  69. uint32_t domain; /* PCI Domain/Segment */
  70. uint32_t bus;
  71. uint32_t devfn;
  72. /* IN: which configuration registers to touch */
  73. int32_t offset;
  74. int32_t size;
  75. /* IN/OUT: Contains the result after a READ or the value to WRITE */
  76. uint32_t value;
  77. /* IN: Contains extra infor for this operation */
  78. uint32_t info;
  79. /*IN: param for msi-x */
  80. struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
  81. };
  82. /*used for pcie aer handling*/
  83. struct xen_pcie_aer_op {
  84. /* IN: what action to perform: XEN_PCI_OP_* */
  85. uint32_t cmd;
  86. /*IN/OUT: return aer_op result or carry error_detected state as input*/
  87. int32_t err;
  88. /* IN: which device to touch */
  89. uint32_t domain; /* PCI Domain/Segment*/
  90. uint32_t bus;
  91. uint32_t devfn;
  92. };
  93. struct xen_pci_sharedinfo {
  94. /* flags - XEN_PCIF_* */
  95. uint32_t flags;
  96. struct xen_pci_op op;
  97. struct xen_pcie_aer_op aer_op;
  98. };
  99. #endif /* __XEN_PCI_COMMON_H__ */