HV: unify the sharing mode and partition mode coding style for similar functions

Both sharing mode and partition mode should follow the same coding logic/style
for similar functions:

vdev cfgread/cfgwrite: should all return -ENODEV if the pci reg access is not handled by
it, but previously the partition mode code is not following this logic

vpci cfgread/cfgwrite: if the vdev cfgread/cfgwrite does not handle this reg,
pass on to next vdev cfgread/cfgwrite, if no vdev handles that req, passthru to
physical pci device

Tracked-On: #2534
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2019-03-06 16:54:01 -08:00
committed by Eddie Dong
parent 026250fd8a
commit 71ce4c255e
5 changed files with 19 additions and 25 deletions

View File

@@ -105,14 +105,15 @@ void vdev_pt_deinit(const struct pci_vdev *vdev)
int32_t vdev_pt_cfgread(const struct pci_vdev *vdev, uint32_t offset,
uint32_t bytes, uint32_t *val)
{
int32_t ret = -ENODEV;
/* PCI BARs is emulated */
if (pci_bar_access(offset)) {
*val = pci_vdev_read_cfg(vdev, offset, bytes);
} else {
*val = pci_pdev_read_cfg(vdev->pdev->bdf, offset, bytes);
ret = 0;
}
return 0;
return ret;
}
static void vdev_pt_remap_bar(struct pci_vdev *vdev, uint32_t idx,
@@ -178,14 +179,14 @@ static void vdev_pt_cfgwrite_bar(struct pci_vdev *vdev, uint32_t offset,
int32_t vdev_pt_cfgwrite(struct pci_vdev *vdev, uint32_t offset,
uint32_t bytes, uint32_t val)
{
int32_t ret = -ENODEV;
/* PCI BARs are emulated */
if (pci_bar_access(offset)) {
vdev_pt_cfgwrite_bar(vdev, offset, bytes, val);
} else {
/* Write directly to physical device's config space */
pci_pdev_write_cfg(vdev->pdev->bdf, offset, bytes, val);
ret = 0;
}
return 0;
return ret;
}