From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 118B71B1B6 for ; Sun, 4 Feb 2018 15:56:47 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Feb 2018 06:56:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,458,1511856000"; d="scan'208";a="28692305" Received: from dpdk-xiao-1.sh.intel.com ([10.67.110.153]) by orsmga001.jf.intel.com with ESMTP; 04 Feb 2018 06:56:44 -0800 From: Xiao Wang 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 Date: Sun, 4 Feb 2018 22:55:40 +0800 Message-Id: <20180204145542.38345-2-xiao.w.wang@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180204145542.38345-1-xiao.w.wang@intel.com> References: <20180204145542.38345-1-xiao.w.wang@intel.com> Subject: [dpdk-dev] [PATCH 1/3] bus/pci: expose API for vDPA X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 14:56:48 -0000 Some existing PCI APIs are helpful for vDPA device setup, expose them for the later driver patch. Signed-off-by: Xiao Wang --- 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 +#include /** 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