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