xref: /linux/include/xen/interface/io/pciif.h (revision 9e2b3e834c450ce23073093992f450544100c99a)
1*9e2b3e83SJuergen Gross /* SPDX-License-Identifier: MIT */
2956a9202SRyan Wilson /*
3956a9202SRyan Wilson  * PCI Backend/Frontend Common Data Structures & Macros
4956a9202SRyan Wilson  *
5956a9202SRyan Wilson  *   Author: Ryan Wilson <hap9@epoch.ncsc.mil>
6956a9202SRyan Wilson  */
7956a9202SRyan Wilson #ifndef __XEN_PCI_COMMON_H__
8956a9202SRyan Wilson #define __XEN_PCI_COMMON_H__
9956a9202SRyan Wilson 
10956a9202SRyan Wilson /* Be sure to bump this number if you change this file */
11956a9202SRyan Wilson #define XEN_PCI_MAGIC "7"
12956a9202SRyan Wilson 
13956a9202SRyan Wilson /* xen_pci_sharedinfo flags */
14956a9202SRyan Wilson #define	_XEN_PCIF_active		(0)
15956a9202SRyan Wilson #define	XEN_PCIF_active			(1<<_XEN_PCIF_active)
16956a9202SRyan Wilson #define	_XEN_PCIB_AERHANDLER		(1)
17956a9202SRyan Wilson #define	XEN_PCIB_AERHANDLER		(1<<_XEN_PCIB_AERHANDLER)
18956a9202SRyan Wilson #define	_XEN_PCIB_active		(2)
19956a9202SRyan Wilson #define	XEN_PCIB_active			(1<<_XEN_PCIB_active)
20956a9202SRyan Wilson 
21956a9202SRyan Wilson /* xen_pci_op commands */
22956a9202SRyan Wilson #define	XEN_PCI_OP_conf_read		(0)
23956a9202SRyan Wilson #define	XEN_PCI_OP_conf_write		(1)
24956a9202SRyan Wilson #define	XEN_PCI_OP_enable_msi		(2)
25956a9202SRyan Wilson #define	XEN_PCI_OP_disable_msi		(3)
26956a9202SRyan Wilson #define	XEN_PCI_OP_enable_msix		(4)
27956a9202SRyan Wilson #define	XEN_PCI_OP_disable_msix		(5)
28956a9202SRyan Wilson #define	XEN_PCI_OP_aer_detected		(6)
29956a9202SRyan Wilson #define	XEN_PCI_OP_aer_resume		(7)
30956a9202SRyan Wilson #define	XEN_PCI_OP_aer_mmio		(8)
31956a9202SRyan Wilson #define	XEN_PCI_OP_aer_slotreset	(9)
32956a9202SRyan Wilson 
33956a9202SRyan Wilson /* xen_pci_op error numbers */
34956a9202SRyan Wilson #define	XEN_PCI_ERR_success		(0)
35956a9202SRyan Wilson #define	XEN_PCI_ERR_dev_not_found	(-1)
36956a9202SRyan Wilson #define	XEN_PCI_ERR_invalid_offset	(-2)
37956a9202SRyan Wilson #define	XEN_PCI_ERR_access_denied	(-3)
38956a9202SRyan Wilson #define	XEN_PCI_ERR_not_implemented	(-4)
39956a9202SRyan Wilson /* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
40956a9202SRyan Wilson #define XEN_PCI_ERR_op_failed		(-5)
41956a9202SRyan Wilson 
42956a9202SRyan Wilson /*
43956a9202SRyan Wilson  * it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry))
44956a9202SRyan Wilson  * Should not exceed 128
45956a9202SRyan Wilson  */
46956a9202SRyan Wilson #define SH_INFO_MAX_VEC			128
47956a9202SRyan Wilson 
48956a9202SRyan Wilson struct xen_msix_entry {
49956a9202SRyan Wilson 	uint16_t vector;
50956a9202SRyan Wilson 	uint16_t entry;
51956a9202SRyan Wilson };
52956a9202SRyan Wilson struct xen_pci_op {
53956a9202SRyan Wilson 	/* IN: what action to perform: XEN_PCI_OP_* */
54956a9202SRyan Wilson 	uint32_t cmd;
55956a9202SRyan Wilson 
56956a9202SRyan Wilson 	/* OUT: will contain an error number (if any) from errno.h */
57956a9202SRyan Wilson 	int32_t err;
58956a9202SRyan Wilson 
59956a9202SRyan Wilson 	/* IN: which device to touch */
60956a9202SRyan Wilson 	uint32_t domain; /* PCI Domain/Segment */
61956a9202SRyan Wilson 	uint32_t bus;
62956a9202SRyan Wilson 	uint32_t devfn;
63956a9202SRyan Wilson 
64956a9202SRyan Wilson 	/* IN: which configuration registers to touch */
65956a9202SRyan Wilson 	int32_t offset;
66956a9202SRyan Wilson 	int32_t size;
67956a9202SRyan Wilson 
68956a9202SRyan Wilson 	/* IN/OUT: Contains the result after a READ or the value to WRITE */
69956a9202SRyan Wilson 	uint32_t value;
70956a9202SRyan Wilson 	/* IN: Contains extra infor for this operation */
71956a9202SRyan Wilson 	uint32_t info;
72956a9202SRyan Wilson 	/*IN:  param for msi-x */
73956a9202SRyan Wilson 	struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
74956a9202SRyan Wilson };
75956a9202SRyan Wilson 
76956a9202SRyan Wilson /*used for pcie aer handling*/
77956a9202SRyan Wilson struct xen_pcie_aer_op {
78956a9202SRyan Wilson 	/* IN: what action to perform: XEN_PCI_OP_* */
79956a9202SRyan Wilson 	uint32_t cmd;
80956a9202SRyan Wilson 	/*IN/OUT: return aer_op result or carry error_detected state as input*/
81956a9202SRyan Wilson 	int32_t err;
82956a9202SRyan Wilson 
83956a9202SRyan Wilson 	/* IN: which device to touch */
84956a9202SRyan Wilson 	uint32_t domain; /* PCI Domain/Segment*/
85956a9202SRyan Wilson 	uint32_t bus;
86956a9202SRyan Wilson 	uint32_t devfn;
87956a9202SRyan Wilson };
88956a9202SRyan Wilson struct xen_pci_sharedinfo {
89956a9202SRyan Wilson 	/* flags - XEN_PCIF_* */
90956a9202SRyan Wilson 	uint32_t flags;
91956a9202SRyan Wilson 	struct xen_pci_op op;
92956a9202SRyan Wilson 	struct xen_pcie_aer_op aer_op;
93956a9202SRyan Wilson };
94956a9202SRyan Wilson 
95956a9202SRyan Wilson #endif /* __XEN_PCI_COMMON_H__ */
96