162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * PCI Backend/Frontend Common Data Structures & Macros 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Author: Ryan Wilson <hap9@epoch.ncsc.mil> 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci#ifndef __XEN_PCI_COMMON_H__ 862306a36Sopenharmony_ci#define __XEN_PCI_COMMON_H__ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* Be sure to bump this number if you change this file */ 1162306a36Sopenharmony_ci#define XEN_PCI_MAGIC "7" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/* xen_pci_sharedinfo flags */ 1462306a36Sopenharmony_ci#define _XEN_PCIF_active (0) 1562306a36Sopenharmony_ci#define XEN_PCIF_active (1<<_XEN_PCIF_active) 1662306a36Sopenharmony_ci#define _XEN_PCIB_AERHANDLER (1) 1762306a36Sopenharmony_ci#define XEN_PCIB_AERHANDLER (1<<_XEN_PCIB_AERHANDLER) 1862306a36Sopenharmony_ci#define _XEN_PCIB_active (2) 1962306a36Sopenharmony_ci#define XEN_PCIB_active (1<<_XEN_PCIB_active) 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* xen_pci_op commands */ 2262306a36Sopenharmony_ci#define XEN_PCI_OP_conf_read (0) 2362306a36Sopenharmony_ci#define XEN_PCI_OP_conf_write (1) 2462306a36Sopenharmony_ci#define XEN_PCI_OP_enable_msi (2) 2562306a36Sopenharmony_ci#define XEN_PCI_OP_disable_msi (3) 2662306a36Sopenharmony_ci#define XEN_PCI_OP_enable_msix (4) 2762306a36Sopenharmony_ci#define XEN_PCI_OP_disable_msix (5) 2862306a36Sopenharmony_ci#define XEN_PCI_OP_aer_detected (6) 2962306a36Sopenharmony_ci#define XEN_PCI_OP_aer_resume (7) 3062306a36Sopenharmony_ci#define XEN_PCI_OP_aer_mmio (8) 3162306a36Sopenharmony_ci#define XEN_PCI_OP_aer_slotreset (9) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* xen_pci_op error numbers */ 3462306a36Sopenharmony_ci#define XEN_PCI_ERR_success (0) 3562306a36Sopenharmony_ci#define XEN_PCI_ERR_dev_not_found (-1) 3662306a36Sopenharmony_ci#define XEN_PCI_ERR_invalid_offset (-2) 3762306a36Sopenharmony_ci#define XEN_PCI_ERR_access_denied (-3) 3862306a36Sopenharmony_ci#define XEN_PCI_ERR_not_implemented (-4) 3962306a36Sopenharmony_ci/* XEN_PCI_ERR_op_failed - backend failed to complete the operation */ 4062306a36Sopenharmony_ci#define XEN_PCI_ERR_op_failed (-5) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry)) 4462306a36Sopenharmony_ci * Should not exceed 128 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci#define SH_INFO_MAX_VEC 128 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistruct xen_msix_entry { 4962306a36Sopenharmony_ci uint16_t vector; 5062306a36Sopenharmony_ci uint16_t entry; 5162306a36Sopenharmony_ci}; 5262306a36Sopenharmony_cistruct xen_pci_op { 5362306a36Sopenharmony_ci /* IN: what action to perform: XEN_PCI_OP_* */ 5462306a36Sopenharmony_ci uint32_t cmd; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci /* OUT: will contain an error number (if any) from errno.h */ 5762306a36Sopenharmony_ci int32_t err; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci /* IN: which device to touch */ 6062306a36Sopenharmony_ci uint32_t domain; /* PCI Domain/Segment */ 6162306a36Sopenharmony_ci uint32_t bus; 6262306a36Sopenharmony_ci uint32_t devfn; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci /* IN: which configuration registers to touch */ 6562306a36Sopenharmony_ci int32_t offset; 6662306a36Sopenharmony_ci int32_t size; 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci /* IN/OUT: Contains the result after a READ or the value to WRITE */ 6962306a36Sopenharmony_ci uint32_t value; 7062306a36Sopenharmony_ci /* IN: Contains extra infor for this operation */ 7162306a36Sopenharmony_ci uint32_t info; 7262306a36Sopenharmony_ci /*IN: param for msi-x */ 7362306a36Sopenharmony_ci struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC]; 7462306a36Sopenharmony_ci}; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/*used for pcie aer handling*/ 7762306a36Sopenharmony_cistruct xen_pcie_aer_op { 7862306a36Sopenharmony_ci /* IN: what action to perform: XEN_PCI_OP_* */ 7962306a36Sopenharmony_ci uint32_t cmd; 8062306a36Sopenharmony_ci /*IN/OUT: return aer_op result or carry error_detected state as input*/ 8162306a36Sopenharmony_ci int32_t err; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci /* IN: which device to touch */ 8462306a36Sopenharmony_ci uint32_t domain; /* PCI Domain/Segment*/ 8562306a36Sopenharmony_ci uint32_t bus; 8662306a36Sopenharmony_ci uint32_t devfn; 8762306a36Sopenharmony_ci}; 8862306a36Sopenharmony_cistruct xen_pci_sharedinfo { 8962306a36Sopenharmony_ci /* flags - XEN_PCIF_* */ 9062306a36Sopenharmony_ci uint32_t flags; 9162306a36Sopenharmony_ci struct xen_pci_op op; 9262306a36Sopenharmony_ci struct xen_pcie_aer_op aer_op; 9362306a36Sopenharmony_ci}; 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#endif /* __XEN_PCI_COMMON_H__ */ 96