[dpdk-dev,1/3] bus/pci: expose API for vDPA

Message ID 20180204145542.38345-2-xiao.w.wang@intel.com
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Xiao Wang Feb. 4, 2018, 2:55 p.m.
Some existing PCI APIs are helpful for vDPA device setup, expose them
for the later driver patch.

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 drivers/bus/pci/Makefile                |  1 +
 drivers/bus/pci/linux/pci.c             | 10 +++-------
 drivers/bus/pci/linux/pci_init.h        | 22 +++++++++++++++++++++-
 drivers/bus/pci/linux/pci_vfio.c        |  5 ++---
 drivers/bus/pci/rte_bus_pci_version.map | 13 +++++++++++++
 5 files changed, 40 insertions(+), 11 deletions(-)

Patch

diff --git a/drivers/bus/pci/Makefile b/drivers/bus/pci/Makefile
index f3df1c4ce..e45bee024 100644
--- a/drivers/bus/pci/Makefile
+++ b/drivers/bus/pci/Makefile
@@ -45,6 +45,7 @@  ifneq ($(CONFIG_RTE_EXEC_ENV_BSDAPP),)
 SYSTEM := bsd
 endif
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -I$(RTE_SDK)/drivers/bus/pci/$(SYSTEM)
 CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
 CFLAGS += -I$(RTE_SDK)/lib/librte_eal/$(SYSTEM)app/eal
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index abde64119..06b811d5e 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -32,7 +32,7 @@ 
 
 extern struct rte_pci_bus rte_pci_bus;
 
-static int
+int
 pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
 {
 	int count;
@@ -168,8 +168,7 @@  pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,
 	return 0;
 }
 
-/* parse the "resource" sysfs file */
-static int
+int
 pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
 {
 	FILE *f;
@@ -372,10 +371,7 @@  pci_update_device(const struct rte_pci_addr *addr)
 	return pci_scan_one(filename, addr);
 }
 
-/*
- * split up a pci address into its constituent parts.
- */
-static int
+int
 parse_pci_addr_format(const char *buf, int bufsize, struct rte_pci_addr *addr)
 {
 	/* first split on ':' */
diff --git a/drivers/bus/pci/linux/pci_init.h b/drivers/bus/pci/linux/pci_init.h
index c2e603a37..9e06cb57d 100644
--- a/drivers/bus/pci/linux/pci_init.h
+++ b/drivers/bus/pci/linux/pci_init.h
@@ -6,6 +6,7 @@ 
 #define EAL_PCI_INIT_H_
 
 #include <rte_vfio.h>
+#include <stdbool.h>
 
 /** IO resource type: */
 #define IORESOURCE_IO         0x00000100
@@ -15,7 +16,7 @@ 
  * Helper function to map PCI resources right after hugepages in virtual memory
  */
 extern void *pci_map_addr;
-void *pci_find_max_end_va(void);
+void *__rte_experimental pci_find_max_end_va(void);
 
 /* parse one line of the "resource" sysfs file (note that the 'line'
  * string is modified)
@@ -83,6 +84,25 @@  int pci_vfio_unmap_resource(struct rte_pci_device *dev);
 
 int pci_vfio_is_enabled(void);
 
+/* parse sysfs file path */
+int __rte_experimental
+pci_get_kernel_driver_by_path(const char *filename, char *dri_name);
+
+/* parse the "resource" sysfs file */
+int __rte_experimental
+pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev);
+
+/* split up a pci address into its constituent parts */
+int __rte_experimental
+parse_pci_addr_format(const char *buf, int bufsize, struct rte_pci_addr *addr);
+
+/* get PCI BAR info for MSI-X interrupts */
+int __rte_experimental
+pci_vfio_get_msix_bar(int fd, struct pci_msix_table *msix_table);
+
+/* enable DMA and reset device */
+int __rte_experimental
+pci_rte_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd);
 #endif
 
 #endif /* EAL_PCI_INIT_H_ */
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index aeeaa9ed8..6d0486a7d 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -59,8 +59,7 @@  pci_vfio_write_config(const struct rte_intr_handle *intr_handle,
 	       VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX) + offs);
 }
 
-/* get PCI BAR number where MSI-X interrupts are */
-static int
+int
 pci_vfio_get_msix_bar(int fd, struct pci_msix_table *msix_table)
 {
 	int ret;
@@ -295,7 +294,7 @@  pci_vfio_is_ioport_bar(int vfio_dev_fd, int bar_index)
 	return (ioport_bar & PCI_BASE_ADDRESS_SPACE_IO) != 0;
 }
 
-static int
+int
 pci_rte_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
 {
 	if (pci_vfio_setup_interrupts(dev, vfio_dev_fd) != 0) {
diff --git a/drivers/bus/pci/rte_bus_pci_version.map b/drivers/bus/pci/rte_bus_pci_version.map
index 27e9c4f10..fd806ad33 100644
--- a/drivers/bus/pci/rte_bus_pci_version.map
+++ b/drivers/bus/pci/rte_bus_pci_version.map
@@ -16,3 +16,16 @@  DPDK_17.11 {
 
 	local: *;
 };
+
+EXPERIMENTAL {
+	global:
+
+	pci_map_addr;
+	pci_find_max_end_va;
+	pci_get_kernel_driver_by_path;
+	pci_parse_sysfs_resource;
+	pci_vfio_get_msix_bar;
+	pci_rte_vfio_setup_device;
+	parse_pci_addr_format;
+
+} DPDK_17.11;