hv: vpci: reshuffle pci_bar structure

The current code declare pci_bar structure following the PCI bar spec. However,
we could not tell whether the value in virtual BAR configuration space is valid
base address base on current pci_bar structure. We need to add more fields which
are duplicated instances of the vBAR information. Basides these fields which will
added, bar_base_mapped is another duplicated instance of the vBAR information.
This patch try to reshuffle the pci_bar structure to declare pci_bar structure
following the software implement benefit not the PCI bar spec.

Tracked-On: #3475
Signed-off-by: Li Fei1 <fei1.li@intel.com>
This commit is contained in:
Li Fei1
2019-11-06 21:39:18 +08:00
committed by wenlingz
parent f53baadd5a
commit c049c5c965
6 changed files with 121 additions and 236 deletions

View File

@@ -34,6 +34,15 @@
#include <pci.h>
struct pci_bar {
enum pci_bar_type type;
uint64_t size; /* BAR size */
uint64_t base; /* BAR guest physical address */
uint64_t base_hpa; /* BAR host physical address */
uint32_t fixed; /* BAR fix memory type encoding */
uint32_t mask; /* BAR size mask */
};
struct msix_table_entry {
uint64_t addr;
uint32_t data;
@@ -61,8 +70,8 @@ struct pci_msix {
union pci_cfgdata {
uint8_t data_8[PCI_REGMAX + 1U];
uint16_t data_16[(PCI_REGMAX + 1U) >> 2U];
uint32_t data_32[(PCI_REGMAX + 1U) >> 4U];
uint16_t data_16[(PCI_REGMAX + 1U) >> 1U];
uint32_t data_32[(PCI_REGMAX + 1U) >> 2U];
};
struct pci_vdev;
@@ -86,9 +95,6 @@ struct pci_vdev {
uint32_t nr_bars; /* 6 for normal device, 2 for bridge, 1 for cardbus */
struct pci_bar bar[PCI_BAR_COUNT];
/* Remember the previously mapped/registered vbar base for undo purpose */
uint64_t bar_base_mapped[PCI_BAR_COUNT];
struct pci_msi msi;
struct pci_msix msix;