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