HV: add uint32_t nr_bars to struct pci_vdev

Use nr_bars instead of PCI_BAR_COUNT to check bar access offset.
As while normal pci device has max 6 bars, pci bridge only has 2 bars,
so for pci normal pci device, pci cfg offsets 0x10-0x24 are for bar access,
but for pci bridge, only 0x10-0x14 are for bar access (0x18-0x24 are
for other accesses).

Rename function:
 pci_bar_access --> is_bar_offset

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2019-06-24 14:20:47 -07:00
committed by wenlingz
parent 28d454bfb9
commit f7c4d2b5c4
4 changed files with 14 additions and 9 deletions

View File

@@ -74,6 +74,7 @@ struct pci_vdev {
union pci_cfgdata cfgdata;
/* The bar info of the virtual PCI device. */
uint32_t nr_bars; /* 6 for normal device, 2 for bridge, 1 for cardbus */
struct pci_bar bar[PCI_BAR_COUNT];
struct pci_msi msi;

View File

@@ -227,12 +227,12 @@ static inline uint32_t pci_bar_offset(uint32_t idx)
return PCIR_BARS + (idx << 2U);
}
static inline bool pci_bar_access(uint32_t offset)
static inline bool is_bar_offset(uint32_t nr_bars, uint32_t offset)
{
bool ret;
if ((offset >= pci_bar_offset(0U))
&& (offset < pci_bar_offset(PCI_BAR_COUNT))) {
&& (offset < pci_bar_offset(nr_bars))) {
ret = true;
} else {
ret = false;