Skip to content

Commit

Permalink
bus/pci: avoid depending on private kernel value
Browse files Browse the repository at this point in the history
The value 40 used in VFIO_GET_REGION_ADDR() is a private value
(VFIO_PCI_OFFSET_SHIFT) defined in Linux kernel source [1]. It
is not part of VFIO API, and we should not depend on it.

[1] https://github.com/torvalds/linux/blob/v6.2/include/linux/vfio_pci_core.h

Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Acked-by: Sunil Kumar Kori <skori@marvell.com>
Acked-by: Yahui Cao <yahui.cao@intel.com>
  • Loading branch information
chenbo-xia authored and tmonjalo committed Jun 7, 2023
1 parent 87a0202 commit 4b74154
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 56 deletions.
4 changes: 2 additions & 2 deletions drivers/bus/pci/linux/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ int rte_pci_read_config(const struct rte_pci_device *device,
return pci_uio_read_config(intr_handle, buf, len, offset);
#ifdef VFIO_PRESENT
case RTE_PCI_KDRV_VFIO:
return pci_vfio_read_config(intr_handle, buf, len, offset);
return pci_vfio_read_config(device, buf, len, offset);
#endif
default:
rte_pci_device_name(&device->addr, devname,
Expand All @@ -669,7 +669,7 @@ int rte_pci_write_config(const struct rte_pci_device *device,
return pci_uio_write_config(intr_handle, buf, len, offset);
#ifdef VFIO_PRESENT
case RTE_PCI_KDRV_VFIO:
return pci_vfio_write_config(intr_handle, buf, len, offset);
return pci_vfio_write_config(device, buf, len, offset);
#endif
default:
rte_pci_device_name(&device->addr, devname,
Expand Down
4 changes: 2 additions & 2 deletions drivers/bus/pci/linux/pci_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ int pci_uio_ioport_unmap(struct rte_pci_ioport *p);
#endif

/* access config space */
int pci_vfio_read_config(const struct rte_intr_handle *intr_handle,
int pci_vfio_read_config(const struct rte_pci_device *dev,
void *buf, size_t len, off_t offs);
int pci_vfio_write_config(const struct rte_intr_handle *intr_handle,
int pci_vfio_write_config(const struct rte_pci_device *dev,
const void *buf, size_t len, off_t offs);

int pci_vfio_ioport_map(struct rte_pci_device *dev, int bar,
Expand Down
Loading

0 comments on commit 4b74154

Please sign in to comment.