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) 32181624Skmacy#define XEN_PCIF_active (1<<_XEN_PCI_active) 33181624Skmacy 34181624Skmacy/* xen_pci_op commands */ 35181624Skmacy#define XEN_PCI_OP_conf_read (0) 36181624Skmacy#define XEN_PCI_OP_conf_write (1) 37183375Skmacy#define XEN_PCI_OP_enable_msi (2) 38183375Skmacy#define XEN_PCI_OP_disable_msi (3) 39183375Skmacy#define XEN_PCI_OP_enable_msix (4) 40183375Skmacy#define XEN_PCI_OP_disable_msix (5) 41181624Skmacy 42181624Skmacy/* xen_pci_op error numbers */ 43181624Skmacy#define XEN_PCI_ERR_success (0) 44181624Skmacy#define XEN_PCI_ERR_dev_not_found (-1) 45181624Skmacy#define XEN_PCI_ERR_invalid_offset (-2) 46181624Skmacy#define XEN_PCI_ERR_access_denied (-3) 47181624Skmacy#define XEN_PCI_ERR_not_implemented (-4) 48181624Skmacy/* XEN_PCI_ERR_op_failed - backend failed to complete the operation */ 49181624Skmacy#define XEN_PCI_ERR_op_failed (-5) 50181624Skmacy 51183375Skmacy/* 52183375Skmacy * it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry)) 53183375Skmacy * Should not exceed 128 54183375Skmacy */ 55183375Skmacy#define SH_INFO_MAX_VEC 128 56183375Skmacy 57183375Skmacystruct xen_msix_entry { 58183375Skmacy uint16_t vector; 59183375Skmacy uint16_t entry; 60183375Skmacy}; 61181624Skmacystruct xen_pci_op { 62181624Skmacy /* IN: what action to perform: XEN_PCI_OP_* */ 63181624Skmacy uint32_t cmd; 64181624Skmacy 65181624Skmacy /* OUT: will contain an error number (if any) from errno.h */ 66181624Skmacy int32_t err; 67181624Skmacy 68181624Skmacy /* IN: which device to touch */ 69181624Skmacy uint32_t domain; /* PCI Domain/Segment */ 70181624Skmacy uint32_t bus; 71181624Skmacy uint32_t devfn; 72181624Skmacy 73181624Skmacy /* IN: which configuration registers to touch */ 74181624Skmacy int32_t offset; 75181624Skmacy int32_t size; 76181624Skmacy 77181624Skmacy /* IN/OUT: Contains the result after a READ or the value to WRITE */ 78181624Skmacy uint32_t value; 79183375Skmacy /* IN: Contains extra infor for this operation */ 80183375Skmacy uint32_t info; 81183375Skmacy /*IN: param for msi-x */ 82183375Skmacy struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC]; 83181624Skmacy}; 84181624Skmacy 85181624Skmacystruct xen_pci_sharedinfo { 86181624Skmacy /* flags - XEN_PCIF_* */ 87181624Skmacy uint32_t flags; 88181624Skmacy struct xen_pci_op op; 89181624Skmacy}; 90181624Skmacy 91181624Skmacy#endif /* __XEN_PCI_COMMON_H__ */ 92181624Skmacy 93181624Skmacy/* 94181624Skmacy * Local variables: 95181624Skmacy * mode: C 96181624Skmacy * c-set-style: "BSD" 97181624Skmacy * c-basic-offset: 4 98181624Skmacy * tab-width: 4 99181624Skmacy * indent-tabs-mode: nil 100181624Skmacy * End: 101181624Skmacy */ 102