From: Xiao Wang <xiao.w.wang@intel.com>
To: dev@dpdk.org
Cc: jianfeng.tan@intel.com, tiwei.bie@intel.com,
maxime.coquelin@redhat.com, yliu@fridaylinux.org,
cunming.liang@intel.com, dan.daly@intel.com,
zhihong.wang@intel.com, Xiao Wang <xiao.w.wang@intel.com>
Subject: [dpdk-dev] [PATCH 1/3] bus/pci: expose API for vDPA
Date: Sun, 4 Feb 2018 22:55:40 +0800 [thread overview]
Message-ID: <20180204145542.38345-2-xiao.w.wang@intel.com> (raw)
In-Reply-To: <20180204145542.38345-1-xiao.w.wang@intel.com>
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(-)
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;
--
2.15.1
next prev parent reply other threads:[~2018-02-04 14:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-04 14:55 [dpdk-dev] [PATCH 0/3] add vDPA sample driver Xiao Wang
2018-02-04 14:55 ` Xiao Wang [this message]
2018-02-04 14:55 ` [dpdk-dev] [PATCH 2/3] net/vdpa_virtio_pci: introduce vdpa " Xiao Wang
2018-02-06 14:24 ` Maxime Coquelin
2018-02-08 2:23 ` Wang, Xiao W
2018-02-08 9:08 ` Maxime Coquelin
2018-02-12 15:36 ` Wang, Xiao W
2018-02-04 14:55 ` [dpdk-dev] [PATCH 3/3] examples/vdpa: add a new sample for vdpa Xiao Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180204145542.38345-2-xiao.w.wang@intel.com \
--to=xiao.w.wang@intel.com \
--cc=cunming.liang@intel.com \
--cc=dan.daly@intel.com \
--cc=dev@dpdk.org \
--cc=jianfeng.tan@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=tiwei.bie@intel.com \
--cc=yliu@fridaylinux.org \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).