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