1181624Skmacy/*
2181624Skmacy * PCI Backend/Frontend Common Data Structures & Macros
3181624Skmacy *
4181624Skmacy * Permission is hereby granted, free of charge, to any person obtaining a copy
5181624Skmacy * of this software and associated documentation files (the "Software"), to
6181624Skmacy * deal in the Software without restriction, including without limitation the
7181624Skmacy * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8181624Skmacy * sell copies of the Software, and to permit persons to whom the Software is
9181624Skmacy * furnished to do so, subject to the following conditions:
10181624Skmacy *
11181624Skmacy * The above copyright notice and this permission notice shall be included in
12181624Skmacy * all copies or substantial portions of the Software.
13181624Skmacy *
14181624Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15181624Skmacy * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16181624Skmacy * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17181624Skmacy * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18181624Skmacy * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19181624Skmacy * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20181624Skmacy * DEALINGS IN THE SOFTWARE.
21181624Skmacy *
22181624Skmacy *   Author: Ryan Wilson <hap9@epoch.ncsc.mil>
23181624Skmacy */
24181624Skmacy#ifndef __XEN_PCI_COMMON_H__
25181624Skmacy#define __XEN_PCI_COMMON_H__
26181624Skmacy
27181624Skmacy/* Be sure to bump this number if you change this file */
28181624Skmacy#define XEN_PCI_MAGIC "7"
29181624Skmacy
30181624Skmacy/* xen_pci_sharedinfo flags */
31181624Skmacy#define _XEN_PCIF_active     (0)
32251767Sgibbs#define XEN_PCIF_active      (1<<_XEN_PCIF_active)
33251767Sgibbs#define _XEN_PCIB_AERHANDLER (1)
34251767Sgibbs#define XEN_PCIB_AERHANDLER  (1<<_XEN_PCIB_AERHANDLER)
35251767Sgibbs#define _XEN_PCIB_active     (2)
36251767Sgibbs#define XEN_PCIB_active      (1<<_XEN_PCIB_active)
37181624Skmacy
38181624Skmacy/* xen_pci_op commands */
39251767Sgibbs#define XEN_PCI_OP_conf_read    	(0)
40251767Sgibbs#define XEN_PCI_OP_conf_write   	(1)
41251767Sgibbs#define XEN_PCI_OP_enable_msi   	(2)
42251767Sgibbs#define XEN_PCI_OP_disable_msi  	(3)
43251767Sgibbs#define XEN_PCI_OP_enable_msix  	(4)
44251767Sgibbs#define XEN_PCI_OP_disable_msix 	(5)
45251767Sgibbs#define XEN_PCI_OP_aer_detected 	(6)
46251767Sgibbs#define XEN_PCI_OP_aer_resume		(7)
47251767Sgibbs#define XEN_PCI_OP_aer_mmio		(8)
48251767Sgibbs#define XEN_PCI_OP_aer_slotreset	(9)
49288917Sroyger#define XEN_PCI_OP_enable_multi_msi	(10)
50181624Skmacy
51181624Skmacy/* xen_pci_op error numbers */
52181624Skmacy#define XEN_PCI_ERR_success          (0)
53181624Skmacy#define XEN_PCI_ERR_dev_not_found   (-1)
54181624Skmacy#define XEN_PCI_ERR_invalid_offset  (-2)
55181624Skmacy#define XEN_PCI_ERR_access_denied   (-3)
56181624Skmacy#define XEN_PCI_ERR_not_implemented (-4)
57181624Skmacy/* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
58181624Skmacy#define XEN_PCI_ERR_op_failed       (-5)
59181624Skmacy
60183375Skmacy/*
61183375Skmacy * it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry))
62183375Skmacy * Should not exceed 128
63183375Skmacy */
64183375Skmacy#define SH_INFO_MAX_VEC     128
65183375Skmacy
66183375Skmacystruct xen_msix_entry {
67183375Skmacy    uint16_t vector;
68183375Skmacy    uint16_t entry;
69183375Skmacy};
70181624Skmacystruct xen_pci_op {
71181624Skmacy    /* IN: what action to perform: XEN_PCI_OP_* */
72181624Skmacy    uint32_t cmd;
73181624Skmacy
74181624Skmacy    /* OUT: will contain an error number (if any) from errno.h */
75181624Skmacy    int32_t err;
76181624Skmacy
77181624Skmacy    /* IN: which device to touch */
78181624Skmacy    uint32_t domain; /* PCI Domain/Segment */
79181624Skmacy    uint32_t bus;
80181624Skmacy    uint32_t devfn;
81181624Skmacy
82181624Skmacy    /* IN: which configuration registers to touch */
83181624Skmacy    int32_t offset;
84181624Skmacy    int32_t size;
85181624Skmacy
86181624Skmacy    /* IN/OUT: Contains the result after a READ or the value to WRITE */
87181624Skmacy    uint32_t value;
88183375Skmacy    /* IN: Contains extra infor for this operation */
89183375Skmacy    uint32_t info;
90183375Skmacy    /*IN:  param for msi-x */
91183375Skmacy    struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
92181624Skmacy};
93181624Skmacy
94251767Sgibbs/*used for pcie aer handling*/
95251767Sgibbsstruct xen_pcie_aer_op
96251767Sgibbs{
97251767Sgibbs
98251767Sgibbs    /* IN: what action to perform: XEN_PCI_OP_* */
99251767Sgibbs    uint32_t cmd;
100251767Sgibbs    /*IN/OUT: return aer_op result or carry error_detected state as input*/
101251767Sgibbs    int32_t err;
102251767Sgibbs
103251767Sgibbs    /* IN: which device to touch */
104251767Sgibbs    uint32_t domain; /* PCI Domain/Segment*/
105251767Sgibbs    uint32_t bus;
106251767Sgibbs    uint32_t devfn;
107251767Sgibbs};
108181624Skmacystruct xen_pci_sharedinfo {
109181624Skmacy    /* flags - XEN_PCIF_* */
110181624Skmacy    uint32_t flags;
111181624Skmacy    struct xen_pci_op op;
112251767Sgibbs    struct xen_pcie_aer_op aer_op;
113181624Skmacy};
114181624Skmacy
115181624Skmacy#endif /* __XEN_PCI_COMMON_H__ */
116181624Skmacy
117181624Skmacy/*
118181624Skmacy * Local variables:
119181624Skmacy * mode: C
120288917Sroyger * c-file-style: "BSD"
121181624Skmacy * c-basic-offset: 4
122181624Skmacy * tab-width: 4
123181624Skmacy * indent-tabs-mode: nil
124181624Skmacy * End:
125181624Skmacy */
126