pci: introduce library and driver
The PCI lib defines the types and methods allowing to use PCI elements. The PCI bus implements a bus driver for PCI devices by constructing rte_bus elements using the PCI lib. Move the relevant code out of the EAL to its expected place. Libraries, drivers, unit tests and applications are updated to use the new rte_bus_pci.h header when necessary. Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
This commit is contained in:
parent
3df742a917
commit
c752998b5e
12
MAINTAINERS
12
MAINTAINERS
@ -193,11 +193,12 @@ F: doc/guides/linux_gsg/
|
||||
Linux UIO
|
||||
M: Ferruh Yigit <ferruh.yigit@intel.com>
|
||||
F: lib/librte_eal/linuxapp/igb_uio/
|
||||
F: lib/librte_eal/linuxapp/eal/*uio*
|
||||
F: drivers/bus/pci/linux/*uio*
|
||||
|
||||
Linux VFIO
|
||||
M: Anatoly Burakov <anatoly.burakov@intel.com>
|
||||
F: lib/librte_eal/linuxapp/eal/*vfio*
|
||||
F: drivers/bus/pci/linux/*vfio*
|
||||
|
||||
FreeBSD EAL (with overlaps)
|
||||
M: Bruce Richardson <bruce.richardson@intel.com>
|
||||
@ -286,6 +287,12 @@ T: git://dpdk.org/next/dpdk-next-eventdev
|
||||
F: lib/librte_eventdev/*eth_rx_adapter*
|
||||
F: test/test/test_event_eth_rx_adapter.c
|
||||
|
||||
Bus Drivers
|
||||
-----------
|
||||
|
||||
PCI bus driver
|
||||
F: drivers/bus/pci/
|
||||
|
||||
|
||||
Networking Drivers
|
||||
------------------
|
||||
@ -840,6 +847,9 @@ M: Olivier Matz <olivier.matz@6wind.com>
|
||||
F: lib/librte_kvargs/
|
||||
F: test/test/test_kvargs.c
|
||||
|
||||
PCI
|
||||
F: lib/librte_pci/
|
||||
|
||||
Power management
|
||||
M: David Hunt <david.hunt@intel.com>
|
||||
F: lib/librte_power/
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define _TESTPMD_H_
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_gro.h>
|
||||
#include <rte_gso.h>
|
||||
|
||||
|
@ -122,6 +122,11 @@ CONFIG_RTE_EAL_PMD_PATH=""
|
||||
#
|
||||
CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
|
||||
|
||||
#
|
||||
# Compile the PCI library
|
||||
#
|
||||
CONFIG_RTE_LIBRTE_PCI=y
|
||||
|
||||
#
|
||||
# Compile the argument parser library
|
||||
#
|
||||
@ -147,6 +152,11 @@ CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n
|
||||
#
|
||||
CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n
|
||||
|
||||
#
|
||||
# Compile PCI bus driver
|
||||
#
|
||||
CONFIG_RTE_LIBRTE_PCI_BUS=y
|
||||
|
||||
#
|
||||
# Compile burst-oriented Amazon ENA PMD driver
|
||||
#
|
||||
|
@ -64,6 +64,7 @@ INPUT = doc/api/doxy-api-index.md \
|
||||
lib/librte_meter \
|
||||
lib/librte_metrics \
|
||||
lib/librte_net \
|
||||
lib/librte_pci \
|
||||
lib/librte_pdump \
|
||||
lib/librte_pipeline \
|
||||
lib/librte_port \
|
||||
|
@ -316,6 +316,35 @@ API Changes
|
||||
* ``rte_mem_phy2mch`` was used in Xen dom0 to obtain the physical address;
|
||||
remove this API as Xen dom0 support was removed.
|
||||
|
||||
* **PCI bus API moved outside of the EAL**
|
||||
|
||||
The PCI bus previously implemented within the EAL has been moved.
|
||||
A first part has been added as an RTE library providing PCI helpers to
|
||||
parse device locations or other such utilities.
|
||||
A second part consisting in the actual bus driver has been moved to its
|
||||
proper subdirectory, without changing its functionalities.
|
||||
|
||||
As such, several PCI-related functions are not proposed by the EAL anymore:
|
||||
|
||||
* rte_pci_detach
|
||||
* rte_pci_dump
|
||||
* rte_pci_ioport_map
|
||||
* rte_pci_ioport_read
|
||||
* rte_pci_ioport_unmap
|
||||
* rte_pci_ioport_write
|
||||
* rte_pci_map_device
|
||||
* rte_pci_probe
|
||||
* rte_pci_probe_one
|
||||
* rte_pci_read_config
|
||||
* rte_pci_register
|
||||
* rte_pci_scan
|
||||
* rte_pci_unmap_device
|
||||
* rte_pci_unregister
|
||||
* rte_pci_write_config
|
||||
|
||||
These functions are made available either as part of ``librte_pci`` or
|
||||
``librte_bus_pci``.
|
||||
|
||||
* **Add return value to stats_get dev op API**
|
||||
|
||||
The ``stats_get`` dev op API return value has been changed to be int.
|
||||
@ -447,6 +476,7 @@ The libraries prepended with a plus sign were incremented in this version.
|
||||
librte_meter.so.1
|
||||
librte_metrics.so.1
|
||||
librte_net.so.1
|
||||
+ librte_pci.so.1
|
||||
+ librte_pdump.so.2
|
||||
librte_pipeline.so.3
|
||||
+ librte_pmd_bnxt.so.2
|
||||
|
@ -36,4 +36,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
|
||||
|
||||
DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
|
||||
|
||||
DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
|
||||
|
||||
include $(RTE_SDK)/mk/rte.subdir.mk
|
||||
|
62
drivers/bus/pci/Makefile
Normal file
62
drivers/bus/pci/Makefile
Normal file
@ -0,0 +1,62 @@
|
||||
# BSD LICENSE
|
||||
#
|
||||
# Copyright(c) 2017 6WIND S.A.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of 6WIND nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(RTE_SDK)/mk/rte.vars.mk
|
||||
|
||||
LIB = librte_bus_pci.a
|
||||
LIBABIVER := 1
|
||||
EXPORT_MAP := rte_bus_pci_version.map
|
||||
|
||||
CFLAGS := -I$(SRCDIR) $(CFLAGS)
|
||||
CFLAGS += -O3 $(WERROR_FLAGS)
|
||||
|
||||
ifneq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),)
|
||||
SYSTEM := linux
|
||||
endif
|
||||
ifneq ($(CONFIG_RTE_EXEC_ENV_BSDAPP),)
|
||||
SYSTEM := bsd
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_pci
|
||||
|
||||
include $(RTE_SDK)/drivers/bus/pci/$(SYSTEM)/Makefile
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) := $(addprefix $(SYSTEM)/,$(SRCS))
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci_common.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci_common_uio.c
|
||||
|
||||
SYMLINK-$(CONFIG_RTE_LIBRTE_PCI_BUS)-include += rte_bus_pci.h
|
||||
|
||||
include $(RTE_SDK)/mk/rte.lib.mk
|
32
drivers/bus/pci/bsd/Makefile
Normal file
32
drivers/bus/pci/bsd/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
# BSD LICENSE
|
||||
#
|
||||
# Copyright(c) 2017 6WIND S.A.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of 6WIND nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SRCS += pci.c
|
@ -57,6 +57,7 @@
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_launch.h>
|
||||
#include <rte_memory.h>
|
||||
@ -71,7 +72,7 @@
|
||||
#include <rte_devargs.h>
|
||||
|
||||
#include "eal_filesystem.h"
|
||||
#include "eal_private.h"
|
||||
#include "private.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
@ -323,7 +324,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
|
||||
int ret;
|
||||
|
||||
TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) {
|
||||
ret = rte_pci_addr_cmp(&dev->addr, &dev2->addr);
|
||||
ret = pci_addr_cmp(&dev->addr, &dev2->addr);
|
||||
if (ret > 0)
|
||||
continue;
|
||||
else if (ret < 0) {
|
36
drivers/bus/pci/linux/Makefile
Normal file
36
drivers/bus/pci/linux/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
# BSD LICENSE
|
||||
#
|
||||
# Copyright(c) 2017 6WIND S.A.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of 6WIND nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SRCS += pci.c
|
||||
SRCS += pci_uio.c
|
||||
SRCS += pci_vfio.c
|
||||
|
||||
CFLAGS += -D_GNU_SOURCE
|
@ -37,15 +37,18 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_bus.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_eal_memconfig.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_memcpy.h>
|
||||
#include <rte_vfio.h>
|
||||
|
||||
#include "eal_filesystem.h"
|
||||
#include "eal_private.h"
|
||||
#include "eal_pci_init.h"
|
||||
#include "eal_filesystem.h"
|
||||
|
||||
#include "private.h"
|
||||
#include "pci_init.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
@ -363,7 +366,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
|
||||
int ret;
|
||||
|
||||
TAILQ_FOREACH(dev2, &rte_pci_bus.device_list, next) {
|
||||
ret = rte_pci_addr_cmp(&dev->addr, &dev2->addr);
|
||||
ret = pci_addr_cmp(&dev->addr, &dev2->addr);
|
||||
if (ret > 0)
|
||||
continue;
|
||||
|
@ -47,12 +47,13 @@
|
||||
|
||||
#include <rte_log.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_eal_memconfig.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_malloc.h>
|
||||
|
||||
#include "eal_filesystem.h"
|
||||
#include "eal_pci_init.h"
|
||||
#include "pci_init.h"
|
||||
|
||||
void *pci_map_addr = NULL;
|
||||
|
@ -42,13 +42,15 @@
|
||||
|
||||
#include <rte_log.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_eal_memconfig.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_vfio.h>
|
||||
|
||||
#include "eal_filesystem.h"
|
||||
#include "eal_pci_init.h"
|
||||
#include "eal_private.h"
|
||||
|
||||
#include "pci_init.h"
|
||||
#include "private.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
@ -580,7 +582,7 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
|
||||
|
||||
/* if we're in a secondary process, just find our tailq entry */
|
||||
TAILQ_FOREACH(vfio_res, vfio_res_list, next) {
|
||||
if (rte_pci_addr_cmp(&vfio_res->pci_addr,
|
||||
if (pci_addr_cmp(&vfio_res->pci_addr,
|
||||
&dev->addr))
|
||||
continue;
|
||||
break;
|
@ -45,6 +45,7 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_bus.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_per_lcore.h>
|
||||
#include <rte_memory.h>
|
||||
#include <rte_memzone.h>
|
||||
@ -53,7 +54,7 @@
|
||||
#include <rte_common.h>
|
||||
#include <rte_devargs.h>
|
||||
|
||||
#include "eal_private.h"
|
||||
#include "private.h"
|
||||
|
||||
extern struct rte_pci_bus rte_pci_bus;
|
||||
|
||||
@ -81,133 +82,12 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
|
||||
if (devargs->bus != pbus)
|
||||
continue;
|
||||
devargs->bus->parse(devargs->name, &addr);
|
||||
if (!rte_pci_addr_cmp(&dev->addr, &addr))
|
||||
if (!pci_addr_cmp(&dev->addr, &addr))
|
||||
return devargs;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
get_u8_pciaddr_field(const char *in, void *_u8, char dlm)
|
||||
{
|
||||
unsigned long val;
|
||||
uint8_t *u8 = _u8;
|
||||
char *end;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul(in, &end, 16);
|
||||
if (errno != 0 || end[0] != dlm || val > UINT8_MAX) {
|
||||
errno = errno ? errno : EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
*u8 = (uint8_t)val;
|
||||
return end + 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
rte_pci_bdf_parse(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
const char *in = input;
|
||||
|
||||
dev_addr->domain = 0;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->bus, ':');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->devid, '.');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->function, '\0');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
eal_parse_pci_BDF(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
return rte_pci_bdf_parse(input, dev_addr);
|
||||
}
|
||||
|
||||
static int
|
||||
rte_pci_dbdf_parse(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
const char *in = input;
|
||||
unsigned long val;
|
||||
char *end;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul(in, &end, 16);
|
||||
if (errno != 0 || end[0] != ':' || val > UINT16_MAX)
|
||||
return -EINVAL;
|
||||
dev_addr->domain = (uint16_t)val;
|
||||
in = end + 1;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->bus, ':');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->devid, '.');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->function, '\0');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
return rte_pci_dbdf_parse(input, dev_addr);
|
||||
}
|
||||
|
||||
void
|
||||
rte_pci_device_name(const struct rte_pci_addr *addr,
|
||||
char *output, size_t size)
|
||||
{
|
||||
RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
|
||||
RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
|
||||
addr->domain, addr->bus,
|
||||
addr->devid, addr->function) >= 0);
|
||||
}
|
||||
|
||||
int
|
||||
rte_pci_addr_cmp(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2)
|
||||
{
|
||||
uint64_t dev_addr, dev_addr2;
|
||||
|
||||
if ((addr == NULL) || (addr2 == NULL))
|
||||
return -1;
|
||||
|
||||
dev_addr = ((uint64_t)addr->domain << 24) |
|
||||
(addr->bus << 16) | (addr->devid << 8) | addr->function;
|
||||
dev_addr2 = ((uint64_t)addr2->domain << 24) |
|
||||
(addr2->bus << 16) | (addr2->devid << 8) | addr2->function;
|
||||
|
||||
if (dev_addr > dev_addr2)
|
||||
return 1;
|
||||
else if (dev_addr < dev_addr2)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2)
|
||||
{
|
||||
return rte_pci_addr_cmp(addr, addr2);
|
||||
}
|
||||
|
||||
int
|
||||
rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr)
|
||||
{
|
||||
if (rte_pci_bdf_parse(str, addr) == 0 ||
|
||||
rte_pci_dbdf_parse(str, addr) == 0)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
pci_name_set(struct rte_pci_device *dev)
|
||||
{
|
||||
@ -231,44 +111,6 @@ pci_name_set(struct rte_pci_device *dev)
|
||||
dev->device.name = dev->name;
|
||||
}
|
||||
|
||||
/* map a particular resource from a file */
|
||||
void *
|
||||
pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
|
||||
int additional_flags)
|
||||
{
|
||||
void *mapaddr;
|
||||
|
||||
/* Map the PCI memory resource of device */
|
||||
mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | additional_flags, fd, offset);
|
||||
if (mapaddr == MAP_FAILED) {
|
||||
RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n",
|
||||
__func__, fd, requested_addr,
|
||||
(unsigned long)size, (unsigned long)offset,
|
||||
strerror(errno), mapaddr);
|
||||
} else
|
||||
RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr);
|
||||
|
||||
return mapaddr;
|
||||
}
|
||||
|
||||
/* unmap a particular resource */
|
||||
void
|
||||
pci_unmap_resource(void *requested_addr, size_t size)
|
||||
{
|
||||
if (requested_addr == NULL)
|
||||
return;
|
||||
|
||||
/* Unmap the PCI memory resource of device */
|
||||
if (munmap(requested_addr, size)) {
|
||||
RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n",
|
||||
__func__, requested_addr, (unsigned long)size,
|
||||
strerror(errno));
|
||||
} else
|
||||
RTE_LOG(DEBUG, EAL, " PCI memory unmapped at %p\n",
|
||||
requested_addr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Match the PCI Driver and Device using the ID Table
|
||||
*/
|
||||
@ -467,7 +309,7 @@ rte_pci_probe_one(const struct rte_pci_addr *addr)
|
||||
goto err_return;
|
||||
|
||||
FOREACH_DEVICE_ON_PCIBUS(dev) {
|
||||
if (rte_pci_addr_cmp(&dev->addr, addr))
|
||||
if (pci_addr_cmp(&dev->addr, addr))
|
||||
continue;
|
||||
|
||||
ret = pci_probe_all_drivers(dev);
|
||||
@ -497,7 +339,7 @@ rte_pci_detach(const struct rte_pci_addr *addr)
|
||||
return -1;
|
||||
|
||||
FOREACH_DEVICE_ON_PCIBUS(dev) {
|
||||
if (rte_pci_addr_cmp(&dev->addr, addr))
|
||||
if (pci_addr_cmp(&dev->addr, addr))
|
||||
continue;
|
||||
|
||||
ret = rte_pci_detach_dev(dev);
|
||||
@ -599,7 +441,7 @@ pci_parse(const char *name, void *addr)
|
||||
struct rte_pci_addr pci_addr;
|
||||
bool parse;
|
||||
|
||||
parse = (rte_pci_addr_parse(name, &pci_addr) == 0);
|
||||
parse = (pci_addr_parse(name, &pci_addr) == 0);
|
||||
if (parse && addr != NULL)
|
||||
*out = pci_addr;
|
||||
return parse == false;
|
@ -39,11 +39,13 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <rte_eal.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_tailq.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_malloc.h>
|
||||
|
||||
#include "eal_private.h"
|
||||
#include "private.h"
|
||||
|
||||
static struct rte_tailq_elem rte_uio_tailq = {
|
||||
.name = "UIO_RESOURCE_LIST",
|
||||
@ -61,7 +63,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
|
||||
TAILQ_FOREACH(uio_res, uio_res_list, next) {
|
||||
|
||||
/* skip this element if it doesn't match our PCI address */
|
||||
if (rte_pci_addr_cmp(&uio_res->pci_addr, &dev->addr))
|
||||
if (pci_addr_cmp(&uio_res->pci_addr, &dev->addr))
|
||||
continue;
|
||||
|
||||
for (i = 0; i != uio_res->nb_maps; i++) {
|
||||
@ -187,7 +189,7 @@ pci_uio_find_resource(struct rte_pci_device *dev)
|
||||
TAILQ_FOREACH(uio_res, uio_res_list, next) {
|
||||
|
||||
/* skip this element if it doesn't match our PCI address */
|
||||
if (!rte_pci_addr_cmp(&uio_res->pci_addr, &dev->addr))
|
||||
if (!pci_addr_cmp(&uio_res->pci_addr, &dev->addr))
|
||||
return uio_res;
|
||||
}
|
||||
return NULL;
|
248
drivers/bus/pci/private.h
Normal file
248
drivers/bus/pci/private.h
Normal file
@ -0,0 +1,248 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright(c) 2017 6WIND. All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of 6WIND nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _PCI_PRIVATE_H_
|
||||
#define _PCI_PRIVATE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
struct rte_pci_driver;
|
||||
struct rte_pci_device;
|
||||
|
||||
/**
|
||||
* Probe the PCI bus
|
||||
*
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - !0 on error.
|
||||
*/
|
||||
int
|
||||
rte_pci_probe(void);
|
||||
|
||||
/**
|
||||
* Scan the content of the PCI bus, and the devices in the devices
|
||||
* list
|
||||
*
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int rte_pci_scan(void);
|
||||
|
||||
/**
|
||||
* Probe the single PCI device.
|
||||
*
|
||||
* Scan the content of the PCI bus, and find the pci device specified by pci
|
||||
* address, then call the probe() function for registered driver that has a
|
||||
* matching entry in its id_table for discovered device.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to probe.
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - Negative on error.
|
||||
*/
|
||||
int rte_pci_probe_one(const struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Close the single PCI device.
|
||||
*
|
||||
* Scan the content of the PCI bus, and find the pci device specified by pci
|
||||
* address, then call the remove() function for registered driver that has a
|
||||
* matching entry in its id_table for discovered device.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to close.
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - Negative on error.
|
||||
*/
|
||||
int rte_pci_detach(const struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Find the name of a PCI device.
|
||||
*/
|
||||
void
|
||||
pci_name_set(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Add a PCI device to the PCI Bus (append to PCI Device list). This function
|
||||
* also updates the bus references of the PCI Device (and the generic device
|
||||
* object embedded within.
|
||||
*
|
||||
* @param pci_dev
|
||||
* PCI device to add
|
||||
* @return void
|
||||
*/
|
||||
void rte_pci_add_device(struct rte_pci_device *pci_dev);
|
||||
|
||||
/**
|
||||
* Insert a PCI device in the PCI Bus at a particular location in the device
|
||||
* list. It also updates the PCI Bus reference of the new devices to be
|
||||
* inserted.
|
||||
*
|
||||
* @param exist_pci_dev
|
||||
* Existing PCI device in PCI Bus
|
||||
* @param new_pci_dev
|
||||
* PCI device to be added before exist_pci_dev
|
||||
* @return void
|
||||
*/
|
||||
void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
|
||||
struct rte_pci_device *new_pci_dev);
|
||||
|
||||
/**
|
||||
* Remove a PCI device from the PCI Bus. This sets to NULL the bus references
|
||||
* in the PCI device object as well as the generic device object.
|
||||
*
|
||||
* @param pci_device
|
||||
* PCI device to be removed from PCI Bus
|
||||
* @return void
|
||||
*/
|
||||
void rte_pci_remove_device(struct rte_pci_device *pci_device);
|
||||
|
||||
/**
|
||||
* Update a pci device object by asking the kernel for the latest information.
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to look for
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - negative on error.
|
||||
*/
|
||||
int pci_update_device(const struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Unbind kernel driver for this device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_unbind_kernel_driver(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Map the PCI resource of a PCI device in virtual memory
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_uio_map_resource(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Unmap the PCI resource of a PCI device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*/
|
||||
void pci_uio_unmap_resource(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Allocate uio resource for PCI device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param dev
|
||||
* PCI device to allocate uio resource
|
||||
* @param uio_res
|
||||
* Pointer to uio resource.
|
||||
* If the function returns 0, the pointer will be filled.
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_uio_alloc_resource(struct rte_pci_device *dev,
|
||||
struct mapped_pci_resource **uio_res);
|
||||
|
||||
/**
|
||||
* Free uio resource for PCI device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param dev
|
||||
* PCI device to free uio resource
|
||||
* @param uio_res
|
||||
* Pointer to uio resource.
|
||||
*/
|
||||
void pci_uio_free_resource(struct rte_pci_device *dev,
|
||||
struct mapped_pci_resource *uio_res);
|
||||
|
||||
/**
|
||||
* Map device memory to uio resource
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param dev
|
||||
* PCI device that has memory information.
|
||||
* @param res_idx
|
||||
* Memory resource index of the PCI device.
|
||||
* @param uio_res
|
||||
* uio resource that will keep mapping information.
|
||||
* @param map_idx
|
||||
* Mapping information index of the uio resource.
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
|
||||
struct mapped_pci_resource *uio_res, int map_idx);
|
||||
|
||||
/*
|
||||
* Match the PCI Driver and Device using the ID Table
|
||||
*
|
||||
* @param pci_drv
|
||||
* PCI driver from which ID table would be extracted
|
||||
* @param pci_dev
|
||||
* PCI device to match against the driver
|
||||
* @return
|
||||
* 1 for successful match
|
||||
* 0 for unsuccessful match
|
||||
*/
|
||||
int
|
||||
rte_pci_match(const struct rte_pci_driver *pci_drv,
|
||||
const struct rte_pci_device *pci_dev);
|
||||
|
||||
/**
|
||||
* Get iommu class of PCI devices on the bus.
|
||||
* And return their preferred iova mapping mode.
|
||||
*
|
||||
* @return
|
||||
* - enum rte_iova_mode.
|
||||
*/
|
||||
enum rte_iova_mode
|
||||
rte_pci_get_iommu_class(void);
|
||||
|
||||
#endif /* _PCI_PRIVATE_H_ */
|
@ -32,13 +32,13 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _RTE_PCI_H_
|
||||
#define _RTE_PCI_H_
|
||||
#ifndef _RTE_BUS_PCI_H_
|
||||
#define _RTE_BUS_PCI_H_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* RTE PCI Interface
|
||||
* RTE PCI Bus Interface
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -57,26 +57,11 @@ extern "C" {
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_bus.h>
|
||||
#include <rte_pci.h>
|
||||
|
||||
/** Pathname of PCI devices directory. */
|
||||
const char *pci_get_sysfs_path(void);
|
||||
|
||||
/** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
|
||||
#define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
|
||||
#define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
|
||||
|
||||
/** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
|
||||
#define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
|
||||
|
||||
/** Nb. of values in PCI device identifier format string. */
|
||||
#define PCI_FMT_NVAL 4
|
||||
|
||||
/** Nb. of values in PCI resource format. */
|
||||
#define PCI_RESOURCE_FMT_NVAL 3
|
||||
|
||||
/** Maximum number of PCI resources. */
|
||||
#define PCI_MAX_RESOURCE 6
|
||||
|
||||
/* Forward declarations */
|
||||
struct rte_pci_device;
|
||||
struct rte_pci_driver;
|
||||
@ -93,28 +78,6 @@ TAILQ_HEAD(rte_pci_driver_list, rte_pci_driver);
|
||||
#define FOREACH_DRIVER_ON_PCIBUS(p) \
|
||||
TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next)
|
||||
|
||||
/**
|
||||
* A structure describing an ID for a PCI driver. Each driver provides a
|
||||
* table of these IDs for each device that it supports.
|
||||
*/
|
||||
struct rte_pci_id {
|
||||
uint32_t class_id; /**< Class ID (class, subclass, pi) or RTE_CLASS_ANY_ID. */
|
||||
uint16_t vendor_id; /**< Vendor ID or PCI_ANY_ID. */
|
||||
uint16_t device_id; /**< Device ID or PCI_ANY_ID. */
|
||||
uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or PCI_ANY_ID. */
|
||||
uint16_t subsystem_device_id; /**< Subsystem device ID or PCI_ANY_ID. */
|
||||
};
|
||||
|
||||
/**
|
||||
* A structure describing the location of a PCI device.
|
||||
*/
|
||||
struct rte_pci_addr {
|
||||
uint32_t domain; /**< Device domain */
|
||||
uint8_t bus; /**< Device bus */
|
||||
uint8_t devid; /**< Device ID */
|
||||
uint8_t function; /**< Device function. */
|
||||
};
|
||||
|
||||
struct rte_devargs;
|
||||
|
||||
/**
|
||||
@ -140,6 +103,8 @@ struct rte_pci_device {
|
||||
*/
|
||||
#define RTE_DEV_TO_PCI(ptr) container_of(ptr, struct rte_pci_device, device)
|
||||
|
||||
#define RTE_ETH_DEV_TO_PCI(eth_dev) RTE_DEV_TO_PCI((eth_dev)->device)
|
||||
|
||||
/** Any PCI device identifier (vendor, device, ...) */
|
||||
#define PCI_ANY_ID (0xffff)
|
||||
#define RTE_CLASS_ANY_ID (0xffffff)
|
||||
@ -205,132 +170,6 @@ struct rte_pci_bus {
|
||||
/** Device driver supports IOVA as VA */
|
||||
#define RTE_PCI_DRV_IOVA_AS_VA 0X0040
|
||||
|
||||
/**
|
||||
* A structure describing a PCI mapping.
|
||||
*/
|
||||
struct pci_map {
|
||||
void *addr;
|
||||
char *path;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
uint64_t phaddr;
|
||||
};
|
||||
|
||||
struct pci_msix_table {
|
||||
int bar_index;
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* A structure describing a mapped PCI resource.
|
||||
* For multi-process we need to reproduce all PCI mappings in secondary
|
||||
* processes, so save them in a tailq.
|
||||
*/
|
||||
struct mapped_pci_resource {
|
||||
TAILQ_ENTRY(mapped_pci_resource) next;
|
||||
|
||||
struct rte_pci_addr pci_addr;
|
||||
char path[PATH_MAX];
|
||||
int nb_maps;
|
||||
struct pci_map maps[PCI_MAX_RESOURCE];
|
||||
struct pci_msix_table msix_table;
|
||||
};
|
||||
|
||||
/** mapped pci device list */
|
||||
TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Utility function to produce a PCI Bus-Device-Function value
|
||||
* given a string representation. Assumes that the BDF is provided without
|
||||
* a domain prefix (i.e. domain returned is always 0)
|
||||
*
|
||||
* @param input
|
||||
* The input string to be parsed. Should have the format XX:XX.X
|
||||
* @param dev_addr
|
||||
* The PCI Bus-Device-Function address to be returned. Domain will always be
|
||||
* returned as 0
|
||||
* @return
|
||||
* 0 on success, negative on error.
|
||||
*/
|
||||
int eal_parse_pci_BDF(const char *input, struct rte_pci_addr *dev_addr);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Utility function to produce a PCI Bus-Device-Function value
|
||||
* given a string representation. Assumes that the BDF is provided including
|
||||
* a domain prefix.
|
||||
*
|
||||
* @param input
|
||||
* The input string to be parsed. Should have the format XXXX:XX:XX.X
|
||||
* @param dev_addr
|
||||
* The PCI Bus-Device-Function address to be returned
|
||||
* @return
|
||||
* 0 on success, negative on error.
|
||||
*/
|
||||
int eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr);
|
||||
|
||||
/**
|
||||
* Utility function to write a pci device name, this device name can later be
|
||||
* used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
|
||||
* BDF helpers.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address
|
||||
* @param output
|
||||
* The output buffer string
|
||||
* @param size
|
||||
* The output buffer size
|
||||
*/
|
||||
void rte_pci_device_name(const struct rte_pci_addr *addr, char *output,
|
||||
size_t size);
|
||||
|
||||
/**
|
||||
* Utility function to compare two PCI device addresses.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @param addr2
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @return
|
||||
* 0 on equal PCI address.
|
||||
* Positive on addr is greater than addr2.
|
||||
* Negative on addr is less than addr2, or error.
|
||||
*/
|
||||
int rte_pci_addr_cmp(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Utility function to compare two PCI device addresses.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @param addr2
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @return
|
||||
* 0 on equal PCI address.
|
||||
* Positive on addr is greater than addr2.
|
||||
* Negative on addr is less than addr2, or error.
|
||||
*/
|
||||
int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2);
|
||||
|
||||
/**
|
||||
* Utility function to parse a string into a PCI location.
|
||||
*
|
||||
* @param str
|
||||
* The string to parse
|
||||
* @param addr
|
||||
* The reference to the structure where the location
|
||||
* is stored.
|
||||
* @return
|
||||
* 0 on success
|
||||
* <0 otherwise
|
||||
*/
|
||||
int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Map the PCI device resources in user space virtual memory address
|
||||
*
|
||||
@ -357,38 +196,6 @@ int rte_pci_map_device(struct rte_pci_device *dev);
|
||||
*/
|
||||
void rte_pci_unmap_device(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Map a particular resource from a file.
|
||||
*
|
||||
* @param requested_addr
|
||||
* The starting address for the new mapping range.
|
||||
* @param fd
|
||||
* The file descriptor.
|
||||
* @param offset
|
||||
* The offset for the mapping range.
|
||||
* @param size
|
||||
* The size for the mapping range.
|
||||
* @param additional_flags
|
||||
* The additional flags for the mapping range.
|
||||
* @return
|
||||
* - On success, the function returns a pointer to the mapped area.
|
||||
* - On error, the value MAP_FAILED is returned.
|
||||
*/
|
||||
void *pci_map_resource(void *requested_addr, int fd, off_t offset,
|
||||
size_t size, int additional_flags);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Unmap a particular resource.
|
||||
*
|
||||
* @param requested_addr
|
||||
* The address for the unmapping range.
|
||||
* @param size
|
||||
* The size for the unmapping range.
|
||||
*/
|
||||
void pci_unmap_resource(void *requested_addr, size_t size);
|
||||
|
||||
/**
|
||||
* Dump the content of the PCI bus.
|
||||
*
|
||||
@ -530,4 +337,4 @@ void rte_pci_ioport_write(struct rte_pci_ioport *p,
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RTE_PCI_H_ */
|
||||
#endif /* _RTE_BUS_PCI_H_ */
|
17
drivers/bus/pci/rte_bus_pci_version.map
Normal file
17
drivers/bus/pci/rte_bus_pci_version.map
Normal file
@ -0,0 +1,17 @@
|
||||
DPDK_17.11 {
|
||||
global:
|
||||
|
||||
rte_pci_dump;
|
||||
rte_pci_ioport_map;
|
||||
rte_pci_ioport_read;
|
||||
rte_pci_ioport_unmap;
|
||||
rte_pci_ioport_write;
|
||||
rte_pci_map_device;
|
||||
rte_pci_read_config;
|
||||
rte_pci_register;
|
||||
rte_pci_unmap_device;
|
||||
rte_pci_unregister;
|
||||
rte_pci_write_config;
|
||||
|
||||
local: *;
|
||||
};
|
@ -45,6 +45,7 @@ CFLAGS += -I$(SRCDIR)/qat_adf
|
||||
LDLIBS += -lcrypto
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_cryptodev
|
||||
LDLIBS += -lrte_pci -lrte_bus_pci
|
||||
|
||||
# library source files
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += qat_crypto.c
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include <rte_crypto_sym.h>
|
||||
#include <rte_byteorder.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <rte_memzone.h>
|
||||
#include <rte_cryptodev_pmd.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_prefetch.h>
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_malloc.h>
|
||||
|
@ -42,6 +42,7 @@ CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx/
|
||||
CFLAGS += -I$(RTE_SDK)/drivers/net/octeontx/
|
||||
|
||||
LDLIBS += -lrte_eal -lrte_eventdev -lrte_mempool_octeontx
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_octeontx_ssovf_version.map
|
||||
|
||||
|
@ -39,6 +39,7 @@ LIB = librte_pmd_skeleton_event.a
|
||||
|
||||
CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lrte_eal -lrte_eventdev
|
||||
LDLIBS += -lrte_pci -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_skeleton_event_version.map
|
||||
|
||||
|
@ -63,5 +63,6 @@ CFLAGS_rte_mempool_octeontx.o += -Ofast
|
||||
endif
|
||||
|
||||
LDLIBS += -lrte_eal -lrte_mempool -lrte_ring -lrte_mbuf
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
include $(RTE_SDK)/mk/rte.lib.mk
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_errno.h>
|
||||
#include <rte_memory.h>
|
||||
#include <rte_malloc.h>
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <rte_eal.h>
|
||||
#include <rte_io.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
#include "octeontx_mbox.h"
|
||||
#include "octeontx_pool_logs.h"
|
||||
|
@ -64,5 +64,6 @@ LDLIBS += -ldl
|
||||
endif
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
include $(RTE_SDK)/mk/rte.lib.mk
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ethdev_pci.h>
|
||||
#include <rte_kvargs.h>
|
||||
|
||||
|
@ -41,6 +41,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_avp_version.map
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_cycles.h>
|
||||
|
@ -11,6 +11,7 @@ CFLAGS += -DZLIB_CONST
|
||||
LDLIBS += -lz
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_bnx2x_version.map
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <rte_byteorder.h>
|
||||
#include <rte_spinlock.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_io.h>
|
||||
|
||||
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
|
||||
|
@ -46,6 +46,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_bnxt_version.map
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_memory.h>
|
||||
#include <rte_lcore.h>
|
||||
|
@ -40,6 +40,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_cmdline
|
||||
LDLIBS += -lrte_pci -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_bond_version.map
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_kvargs.h>
|
||||
|
||||
#include <cmdline_parse.h>
|
||||
|
@ -64,6 +64,7 @@ CFLAGS_BASE_DRIVER =
|
||||
endif
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
#
|
||||
# Add extra flags for base driver files (also known as shared code)
|
||||
|
@ -36,6 +36,7 @@
|
||||
#ifndef __T4_ADAPTER_H__
|
||||
#define __T4_ADAPTER_H__
|
||||
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_mbuf.h>
|
||||
#include <rte_io.h>
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_memory.h>
|
||||
|
@ -40,6 +40,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_e1000_version.map
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ethdev_pci.h>
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ethdev_pci.h>
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
|
@ -54,5 +54,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_ENA_PMD) += ena_eth_com.c
|
||||
CFLAGS += $(INCLUDES)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
include $(RTE_SDK)/mk/rte.lib.mk
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define _ENA_ETHDEV_H_
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
#include "ena_com.h"
|
||||
|
||||
|
@ -47,6 +47,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS) -Wno-strict-aliasing
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
VPATH += $(SRCDIR)/src
|
||||
|
||||
|
@ -35,8 +35,10 @@
|
||||
#ifndef _VNIC_DEV_H_
|
||||
#define _VNIC_DEV_H_
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
#include "enic_compat.h"
|
||||
#include "rte_pci.h"
|
||||
#include "vnic_resource.h"
|
||||
#include "vnic_devcmd.h"
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <rte_dev.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ethdev_pci.h>
|
||||
#include <rte_string_fns.h>
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <libgen.h>
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_memzone.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_mbuf.h>
|
||||
|
@ -78,6 +78,7 @@ endif
|
||||
endif
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
#
|
||||
# Add extra flags for base driver source files to disable warnings in them
|
||||
|
@ -41,6 +41,7 @@ CFLAGS += $(WERROR_FLAGS) -DPF_DRIVER -DVF_DRIVER -DINTEGRATED_VF
|
||||
CFLAGS += -DX722_A0_SUPPORT
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_i40e_version.map
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <rte_eal.h>
|
||||
#include <rte_string_fns.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ethdev_pci.h>
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_memory.h>
|
||||
|
@ -84,6 +84,7 @@ endif
|
||||
endif
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
#
|
||||
# Add extra flags for base driver files (also known as shared code)
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_memory.h>
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <rte_time.h>
|
||||
#include <rte_hash.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_tm_driver.h>
|
||||
|
||||
/* need update link, bit flag */
|
||||
|
@ -42,6 +42,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)/base -I$(SRCDIR)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_lio_version.map
|
||||
|
||||
|
@ -57,6 +57,7 @@ CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -libverbs -lmlx4
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
# A few warnings cannot be avoided in external headers.
|
||||
CFLAGS += -Wno-error=cast-qual
|
||||
|
@ -61,6 +61,7 @@
|
||||
#pragma GCC diagnostic error "-Wpedantic"
|
||||
#endif
|
||||
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_errno.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ether.h>
|
||||
|
@ -67,6 +67,7 @@ CFLAGS += -Wno-strict-prototypes
|
||||
LDLIBS += -libverbs -lmlx5
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
# A few warnings cannot be avoided in external headers.
|
||||
CFLAGS += -Wno-error=cast-qual
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ethdev_pci.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_kvargs.h>
|
||||
|
||||
|
@ -56,6 +56,7 @@
|
||||
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_mbuf.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_interrupts.h>
|
||||
|
@ -42,6 +42,7 @@ CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lm
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_nfp_version.map
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_malloc.h>
|
||||
|
||||
#include "nfp_nfpu.h"
|
||||
|
@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include "nfp_nspu.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -73,5 +73,6 @@ LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_mempool_octeontx
|
||||
LDLIBS += -lrte_eventdev
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
include $(RTE_SDK)/mk/rte.lib.mk
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <rte_eal.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
#include "octeontx_pkivf.h"
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <rte_cycles.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_memory.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_spinlock.h>
|
||||
|
||||
#include "../octeontx_logs.h"
|
||||
|
@ -15,6 +15,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_qede_version.map
|
||||
|
||||
|
@ -71,6 +71,7 @@ CFLAGS_sfc_ef10_tx.o += -wd3656
|
||||
endif
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
#
|
||||
# List of base driver object files for which
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_kvargs.h>
|
||||
#include <rte_spinlock.h>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ethdev_pci.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_errno.h>
|
||||
|
||||
#include "efx.h"
|
||||
|
@ -41,6 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lsze2
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_szedata2_version.map
|
||||
|
||||
|
@ -42,6 +42,7 @@ CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lm
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_thunderx_nicvf_version.map
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_random.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_tailq.h>
|
||||
|
||||
#include "base/nicvf_plat.h"
|
||||
|
@ -40,6 +40,7 @@ CFLAGS += -O3
|
||||
CFLAGS += $(WERROR_FLAGS)
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
EXPORT_MAP := rte_pmd_virtio_version.map
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_errno.h>
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ethdev.h>
|
||||
|
||||
struct virtqueue;
|
||||
|
@ -65,6 +65,7 @@ CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
|
||||
endif
|
||||
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
|
||||
LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
|
||||
LDLIBS += -lrte_bus_pci
|
||||
|
||||
VPATH += $(SRCDIR)/base
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_atomic.h>
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_memory.h>
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#ifdef RTE_LIBRTE_IXGBE_PMD
|
||||
#include <rte_pmd_ixgbe.h>
|
||||
#endif
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <rte_ip.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "pipeline.h"
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_ethdev.h>
|
||||
|
@ -33,6 +33,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
|
||||
|
||||
DIRS-y += librte_compat
|
||||
DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal
|
||||
DIRS-$(CONFIG_RTE_LIBRTE_PCI) += librte_pci
|
||||
DEPDIRS-librte_pci := librte_eal
|
||||
DIRS-$(CONFIG_RTE_LIBRTE_RING) += librte_ring
|
||||
DEPDIRS-librte_ring := librte_eal
|
||||
DIRS-$(CONFIG_RTE_LIBRTE_MEMPOOL) += librte_mempool
|
||||
|
@ -55,7 +55,6 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_pci.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_debug.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_lcore.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_timer.c
|
||||
@ -69,8 +68,6 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memzone.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_log.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_launch.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_vdev.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci_uio.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_tailqs.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_errno.c
|
||||
|
@ -66,7 +66,6 @@
|
||||
#include <rte_cpuflags.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_bus.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_version.h>
|
||||
|
@ -34,7 +34,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
|
||||
INC := rte_branch_prediction.h rte_common.h
|
||||
INC += rte_debug.h rte_eal.h rte_eal_interrupts.h
|
||||
INC += rte_errno.h rte_launch.h rte_lcore.h
|
||||
INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h
|
||||
INC += rte_log.h rte_memory.h rte_memzone.h
|
||||
INC += rte_per_lcore.h rte_random.h
|
||||
INC += rte_tailq.h rte_interrupts.h rte_alarm.h
|
||||
INC += rte_string_fns.h rte_version.h
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <rte_pci.h>
|
||||
|
||||
/**
|
||||
* Initialize the memzone subsystem (private to eal).
|
||||
@ -110,211 +109,6 @@ int rte_eal_timer_init(void);
|
||||
*/
|
||||
int rte_eal_log_init(const char *id, int facility);
|
||||
|
||||
struct rte_pci_driver;
|
||||
struct rte_pci_device;
|
||||
|
||||
/**
|
||||
* Probe the PCI bus
|
||||
*
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - !0 on error.
|
||||
*/
|
||||
int
|
||||
rte_pci_probe(void);
|
||||
|
||||
/**
|
||||
* Scan the content of the PCI bus, and the devices in the devices
|
||||
* list
|
||||
*
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int rte_pci_scan(void);
|
||||
|
||||
/**
|
||||
* Probe the single PCI device.
|
||||
*
|
||||
* Scan the content of the PCI bus, and find the pci device specified by pci
|
||||
* address, then call the probe() function for registered driver that has a
|
||||
* matching entry in its id_table for discovered device.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to probe.
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - Negative on error.
|
||||
*/
|
||||
int rte_pci_probe_one(const struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Close the single PCI device.
|
||||
*
|
||||
* Scan the content of the PCI bus, and find the pci device specified by pci
|
||||
* address, then call the remove() function for registered driver that has a
|
||||
* matching entry in its id_table for discovered device.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to close.
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - Negative on error.
|
||||
*/
|
||||
int rte_pci_detach(const struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Find the name of a PCI device.
|
||||
*/
|
||||
void pci_name_set(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Add a PCI device to the PCI Bus (append to PCI Device list). This function
|
||||
* also updates the bus references of the PCI Device (and the generic device
|
||||
* object embedded within.
|
||||
*
|
||||
* @param pci_dev
|
||||
* PCI device to add
|
||||
* @return void
|
||||
*/
|
||||
void rte_pci_add_device(struct rte_pci_device *pci_dev);
|
||||
|
||||
/**
|
||||
* Insert a PCI device in the PCI Bus at a particular location in the device
|
||||
* list. It also updates the PCI Bus reference of the new devices to be
|
||||
* inserted.
|
||||
*
|
||||
* @param exist_pci_dev
|
||||
* Existing PCI device in PCI Bus
|
||||
* @param new_pci_dev
|
||||
* PCI device to be added before exist_pci_dev
|
||||
* @return void
|
||||
*/
|
||||
void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
|
||||
struct rte_pci_device *new_pci_dev);
|
||||
|
||||
/**
|
||||
* Remove a PCI device from the PCI Bus. This sets to NULL the bus references
|
||||
* in the PCI device object as well as the generic device object.
|
||||
*
|
||||
* @param pci_device
|
||||
* PCI device to be removed from PCI Bus
|
||||
* @return void
|
||||
*/
|
||||
void rte_pci_remove_device(struct rte_pci_device *pci_device);
|
||||
|
||||
/**
|
||||
* Update a pci device object by asking the kernel for the latest information.
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to look for
|
||||
* @return
|
||||
* - 0 on success.
|
||||
* - negative on error.
|
||||
*/
|
||||
int pci_update_device(const struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Unbind kernel driver for this device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_unbind_kernel_driver(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Map the PCI resource of a PCI device in virtual memory
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_uio_map_resource(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Unmap the PCI resource of a PCI device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*/
|
||||
void pci_uio_unmap_resource(struct rte_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Allocate uio resource for PCI device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param dev
|
||||
* PCI device to allocate uio resource
|
||||
* @param uio_res
|
||||
* Pointer to uio resource.
|
||||
* If the function returns 0, the pointer will be filled.
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_uio_alloc_resource(struct rte_pci_device *dev,
|
||||
struct mapped_pci_resource **uio_res);
|
||||
|
||||
/**
|
||||
* Free uio resource for PCI device
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param dev
|
||||
* PCI device to free uio resource
|
||||
* @param uio_res
|
||||
* Pointer to uio resource.
|
||||
*/
|
||||
void pci_uio_free_resource(struct rte_pci_device *dev,
|
||||
struct mapped_pci_resource *uio_res);
|
||||
|
||||
/**
|
||||
* Map device memory to uio resource
|
||||
*
|
||||
* This function is private to EAL.
|
||||
*
|
||||
* @param dev
|
||||
* PCI device that has memory information.
|
||||
* @param res_idx
|
||||
* Memory resource index of the PCI device.
|
||||
* @param uio_res
|
||||
* uio resource that will keep mapping information.
|
||||
* @param map_idx
|
||||
* Mapping information index of the uio resource.
|
||||
* @return
|
||||
* 0 on success, negative on error
|
||||
*/
|
||||
int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
|
||||
struct mapped_pci_resource *uio_res, int map_idx);
|
||||
|
||||
/*
|
||||
* Match the PCI Driver and Device using the ID Table
|
||||
*
|
||||
* @param pci_drv
|
||||
* PCI driver from which ID table would be extracted
|
||||
* @param pci_dev
|
||||
* PCI device to match against the driver
|
||||
* @return
|
||||
* 1 for successful match
|
||||
* 0 for unsuccessful match
|
||||
*/
|
||||
int
|
||||
rte_pci_match(const struct rte_pci_driver *pci_drv,
|
||||
const struct rte_pci_device *pci_dev);
|
||||
|
||||
/**
|
||||
* Get iommu class of PCI devices on the bus.
|
||||
* And return their preferred iova mapping mode.
|
||||
*
|
||||
* @return
|
||||
* - enum rte_iova_mode.
|
||||
*/
|
||||
enum rte_iova_mode
|
||||
rte_pci_get_iommu_class(void);
|
||||
|
||||
/**
|
||||
* Init tail queues for non-EAL library structures. This is to allow
|
||||
* the rings, mempools, etc. lists to be shared among multiple processes
|
||||
|
@ -62,9 +62,6 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_thread.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_log.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_uio.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_vfio.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_debug.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_lcore.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_timer.c
|
||||
@ -78,8 +75,6 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_tailqs.c
|
||||
SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_errno.c
|
||||
@ -132,9 +127,6 @@ CFLAGS_eal_thread.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_log.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_common_log.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_hugepage_info.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_pci.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_pci_uio.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_pci_vfio.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_common_options.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
|
||||
|
@ -71,7 +71,6 @@
|
||||
#include <rte_cpuflags.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_bus.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_version.h>
|
||||
|
@ -60,7 +60,6 @@
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_errno.h>
|
||||
#include <rte_spinlock.h>
|
||||
|
@ -166,17 +166,6 @@ DPDK_17.05 {
|
||||
rte_log_set_global_level;
|
||||
rte_log_set_level;
|
||||
rte_log_set_level_regexp;
|
||||
rte_pci_dump;
|
||||
rte_pci_ioport_map;
|
||||
rte_pci_ioport_read;
|
||||
rte_pci_ioport_unmap;
|
||||
rte_pci_ioport_write;
|
||||
rte_pci_map_device;
|
||||
rte_pci_read_config;
|
||||
rte_pci_register;
|
||||
rte_pci_unmap_device;
|
||||
rte_pci_unregister;
|
||||
rte_pci_write_config;
|
||||
rte_vdev_init;
|
||||
rte_vdev_register;
|
||||
rte_vdev_uninit;
|
||||
@ -237,11 +226,8 @@ EXPERIMENTAL {
|
||||
DPDK_17.11 {
|
||||
global:
|
||||
|
||||
eal_parse_pci_BDF;
|
||||
eal_parse_pci_DomBDF;
|
||||
rte_eal_create_uio_dev;
|
||||
rte_bus_get_iommu_class;
|
||||
rte_eal_compare_pci_addr;
|
||||
rte_eal_has_pci;
|
||||
rte_eal_iova_mode;
|
||||
rte_eal_mbuf_default_mempool_ops;
|
||||
@ -249,9 +235,6 @@ DPDK_17.11 {
|
||||
rte_eal_vfio_intr_mode;
|
||||
rte_lcore_has_role;
|
||||
rte_memcpy_ptr;
|
||||
rte_pci_addr_cmp;
|
||||
rte_pci_addr_parse;
|
||||
rte_pci_device_name;
|
||||
vfio_enable;
|
||||
vfio_is_enabled;
|
||||
vfio_noiommu_is_enabled;
|
||||
|
@ -1156,8 +1156,6 @@ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RTE_ETH_DEV_TO_PCI(eth_dev) RTE_DEV_TO_PCI((eth_dev)->device)
|
||||
|
||||
/**
|
||||
* l2 tunnel configuration.
|
||||
*/
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_ethdev.h>
|
||||
|
||||
/**
|
||||
|
@ -50,6 +50,7 @@ extern "C" {
|
||||
#include <rte_eal.h>
|
||||
#include <rte_lcore.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
|
||||
#include "rte_eventdev_pmd.h"
|
||||
|
||||
|
49
lib/librte_pci/Makefile
Normal file
49
lib/librte_pci/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
# BSD LICENSE
|
||||
#
|
||||
# Copyright(c) 2017 6WIND S.A.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of 6WIND nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(RTE_SDK)/mk/rte.vars.mk
|
||||
|
||||
# library name
|
||||
LIB = librte_pci.a
|
||||
|
||||
CFLAGS := -I$(SRCDIR) $(CFLAGS)
|
||||
CFLAGS += $(WERROR_FLAGS) -O3
|
||||
LDLIBS += -lrte_eal
|
||||
|
||||
EXPORT_MAP := rte_pci_version.map
|
||||
|
||||
LIBABIVER := 1
|
||||
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_PCI) += rte_pci.c
|
||||
|
||||
SYMLINK-$(CONFIG_RTE_LIBRTE_PCI)-include += rte_pci.h
|
||||
|
||||
include $(RTE_SDK)/mk/rte.lib.mk
|
220
lib/librte_pci/rte_pci.c
Normal file
220
lib/librte_pci/rte_pci.c
Normal file
@ -0,0 +1,220 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
|
||||
* Copyright 2013-2014 6WIND S.A.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <rte_errno.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_bus.h>
|
||||
#include <rte_per_lcore.h>
|
||||
#include <rte_memory.h>
|
||||
#include <rte_memzone.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_string_fns.h>
|
||||
#include <rte_common.h>
|
||||
|
||||
#include "rte_pci.h"
|
||||
|
||||
static inline const char *
|
||||
get_u8_pciaddr_field(const char *in, void *_u8, char dlm)
|
||||
{
|
||||
unsigned long val;
|
||||
uint8_t *u8 = _u8;
|
||||
char *end;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul(in, &end, 16);
|
||||
if (errno != 0 || end[0] != dlm || val > UINT8_MAX) {
|
||||
errno = errno ? errno : EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
*u8 = (uint8_t)val;
|
||||
return end + 1;
|
||||
}
|
||||
|
||||
static int
|
||||
pci_bdf_parse(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
const char *in = input;
|
||||
|
||||
dev_addr->domain = 0;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->bus, ':');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->devid, '.');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->function, '\0');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
pci_dbdf_parse(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
const char *in = input;
|
||||
unsigned long val;
|
||||
char *end;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul(in, &end, 16);
|
||||
if (errno != 0 || end[0] != ':' || val > UINT16_MAX)
|
||||
return -EINVAL;
|
||||
dev_addr->domain = (uint16_t)val;
|
||||
in = end + 1;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->bus, ':');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->devid, '.');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
in = get_u8_pciaddr_field(in, &dev_addr->function, '\0');
|
||||
if (in == NULL)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
eal_parse_pci_BDF(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
return pci_bdf_parse(input, dev_addr);
|
||||
}
|
||||
|
||||
int
|
||||
eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
|
||||
{
|
||||
return pci_dbdf_parse(input, dev_addr);
|
||||
}
|
||||
|
||||
void
|
||||
rte_pci_device_name(const struct rte_pci_addr *addr,
|
||||
char *output, size_t size)
|
||||
{
|
||||
pci_device_name(addr, output, size);
|
||||
}
|
||||
|
||||
void
|
||||
pci_device_name(const struct rte_pci_addr *addr,
|
||||
char *output, size_t size)
|
||||
{
|
||||
RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
|
||||
RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
|
||||
addr->domain, addr->bus,
|
||||
addr->devid, addr->function) >= 0);
|
||||
}
|
||||
|
||||
int
|
||||
rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2)
|
||||
{
|
||||
return pci_addr_cmp(addr, addr2);
|
||||
}
|
||||
|
||||
int
|
||||
pci_addr_cmp(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2)
|
||||
{
|
||||
uint64_t dev_addr, dev_addr2;
|
||||
|
||||
if ((addr == NULL) || (addr2 == NULL))
|
||||
return -1;
|
||||
|
||||
dev_addr = ((uint64_t)addr->domain << 24) |
|
||||
(addr->bus << 16) | (addr->devid << 8) | addr->function;
|
||||
dev_addr2 = ((uint64_t)addr2->domain << 24) |
|
||||
(addr2->bus << 16) | (addr2->devid << 8) | addr2->function;
|
||||
|
||||
if (dev_addr > dev_addr2)
|
||||
return 1;
|
||||
else if (dev_addr < dev_addr2)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pci_addr_parse(const char *str, struct rte_pci_addr *addr)
|
||||
{
|
||||
if (pci_bdf_parse(str, addr) == 0 ||
|
||||
pci_dbdf_parse(str, addr) == 0)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* map a particular resource from a file */
|
||||
void *
|
||||
pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
|
||||
int additional_flags)
|
||||
{
|
||||
void *mapaddr;
|
||||
|
||||
/* Map the PCI memory resource of device */
|
||||
mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | additional_flags, fd, offset);
|
||||
if (mapaddr == MAP_FAILED) {
|
||||
RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n",
|
||||
__func__, fd, requested_addr,
|
||||
(unsigned long)size, (unsigned long)offset,
|
||||
strerror(errno), mapaddr);
|
||||
} else
|
||||
RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr);
|
||||
|
||||
return mapaddr;
|
||||
}
|
||||
|
||||
/* unmap a particular resource */
|
||||
void
|
||||
pci_unmap_resource(void *requested_addr, size_t size)
|
||||
{
|
||||
if (requested_addr == NULL)
|
||||
return;
|
||||
|
||||
/* Unmap the PCI memory resource of device */
|
||||
if (munmap(requested_addr, size)) {
|
||||
RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n",
|
||||
__func__, requested_addr, (unsigned long)size,
|
||||
strerror(errno));
|
||||
} else
|
||||
RTE_LOG(DEBUG, EAL, " PCI memory unmapped at %p\n",
|
||||
requested_addr);
|
||||
}
|
279
lib/librte_pci/rte_pci.h
Normal file
279
lib/librte_pci/rte_pci.h
Normal file
@ -0,0 +1,279 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
|
||||
* Copyright 2013-2014 6WIND S.A.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _RTE_PCI_H_
|
||||
#define _RTE_PCI_H_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* RTE PCI Library
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <sys/queue.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <rte_debug.h>
|
||||
#include <rte_interrupts.h>
|
||||
|
||||
/** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
|
||||
#define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
|
||||
#define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
|
||||
|
||||
/** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
|
||||
#define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
|
||||
|
||||
/** Nb. of values in PCI device identifier format string. */
|
||||
#define PCI_FMT_NVAL 4
|
||||
|
||||
/** Nb. of values in PCI resource format. */
|
||||
#define PCI_RESOURCE_FMT_NVAL 3
|
||||
|
||||
/** Maximum number of PCI resources. */
|
||||
#define PCI_MAX_RESOURCE 6
|
||||
|
||||
/**
|
||||
* A structure describing an ID for a PCI driver. Each driver provides a
|
||||
* table of these IDs for each device that it supports.
|
||||
*/
|
||||
struct rte_pci_id {
|
||||
uint32_t class_id; /**< Class ID or RTE_CLASS_ANY_ID. */
|
||||
uint16_t vendor_id; /**< Vendor ID or PCI_ANY_ID. */
|
||||
uint16_t device_id; /**< Device ID or PCI_ANY_ID. */
|
||||
uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or PCI_ANY_ID. */
|
||||
uint16_t subsystem_device_id; /**< Subsystem device ID or PCI_ANY_ID. */
|
||||
};
|
||||
|
||||
/**
|
||||
* A structure describing the location of a PCI device.
|
||||
*/
|
||||
struct rte_pci_addr {
|
||||
uint32_t domain; /**< Device domain */
|
||||
uint8_t bus; /**< Device bus */
|
||||
uint8_t devid; /**< Device ID */
|
||||
uint8_t function; /**< Device function. */
|
||||
};
|
||||
|
||||
/** Any PCI device identifier (vendor, device, ...) */
|
||||
#define PCI_ANY_ID (0xffff)
|
||||
#define RTE_CLASS_ANY_ID (0xffffff)
|
||||
|
||||
/**
|
||||
* A structure describing a PCI mapping.
|
||||
*/
|
||||
struct pci_map {
|
||||
void *addr;
|
||||
char *path;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
uint64_t phaddr;
|
||||
};
|
||||
|
||||
struct pci_msix_table {
|
||||
int bar_index;
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* A structure describing a mapped PCI resource.
|
||||
* For multi-process we need to reproduce all PCI mappings in secondary
|
||||
* processes, so save them in a tailq.
|
||||
*/
|
||||
struct mapped_pci_resource {
|
||||
TAILQ_ENTRY(mapped_pci_resource) next;
|
||||
|
||||
struct rte_pci_addr pci_addr;
|
||||
char path[PATH_MAX];
|
||||
int nb_maps;
|
||||
struct pci_map maps[PCI_MAX_RESOURCE];
|
||||
struct pci_msix_table msix_table;
|
||||
};
|
||||
|
||||
|
||||
/** mapped pci device list */
|
||||
TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Utility function to produce a PCI Bus-Device-Function value
|
||||
* given a string representation. Assumes that the BDF is provided without
|
||||
* a domain prefix (i.e. domain returned is always 0)
|
||||
*
|
||||
* @param input
|
||||
* The input string to be parsed. Should have the format XX:XX.X
|
||||
* @param dev_addr
|
||||
* The PCI Bus-Device-Function address to be returned.
|
||||
* Domain will always be returned as 0
|
||||
* @return
|
||||
* 0 on success, negative on error.
|
||||
*/
|
||||
int eal_parse_pci_BDF(const char *input, struct rte_pci_addr *dev_addr);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Utility function to produce a PCI Bus-Device-Function value
|
||||
* given a string representation. Assumes that the BDF is provided including
|
||||
* a domain prefix.
|
||||
*
|
||||
* @param input
|
||||
* The input string to be parsed. Should have the format XXXX:XX:XX.X
|
||||
* @param dev_addr
|
||||
* The PCI Bus-Device-Function address to be returned
|
||||
* @return
|
||||
* 0 on success, negative on error.
|
||||
*/
|
||||
int eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Utility function to write a pci device name, this device name can later be
|
||||
* used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
|
||||
* BDF helpers.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address
|
||||
* @param output
|
||||
* The output buffer string
|
||||
* @param size
|
||||
* The output buffer size
|
||||
*/
|
||||
void rte_pci_device_name(const struct rte_pci_addr *addr,
|
||||
char *output, size_t size);
|
||||
|
||||
/**
|
||||
* Utility function to write a pci device name, this device name can later be
|
||||
* used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
|
||||
* BDF helpers.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address
|
||||
* @param output
|
||||
* The output buffer string
|
||||
* @param size
|
||||
* The output buffer size
|
||||
*/
|
||||
void pci_device_name(const struct rte_pci_addr *addr,
|
||||
char *output, size_t size);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Utility function to compare two PCI device addresses.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @param addr2
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @return
|
||||
* 0 on equal PCI address.
|
||||
* Positive on addr is greater than addr2.
|
||||
* Negative on addr is less than addr2, or error.
|
||||
*/
|
||||
int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2);
|
||||
|
||||
/**
|
||||
* Utility function to compare two PCI device addresses.
|
||||
*
|
||||
* @param addr
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @param addr2
|
||||
* The PCI Bus-Device-Function address to compare
|
||||
* @return
|
||||
* 0 on equal PCI address.
|
||||
* Positive on addr is greater than addr2.
|
||||
* Negative on addr is less than addr2, or error.
|
||||
*/
|
||||
int pci_addr_cmp(const struct rte_pci_addr *addr,
|
||||
const struct rte_pci_addr *addr2);
|
||||
|
||||
|
||||
/**
|
||||
* Utility function to parse a string into a PCI location.
|
||||
*
|
||||
* @param str
|
||||
* The string to parse
|
||||
* @param addr
|
||||
* The reference to the structure where the location
|
||||
* is stored.
|
||||
* @return
|
||||
* 0 on success
|
||||
* <0 otherwise
|
||||
*/
|
||||
int pci_addr_parse(const char *str, struct rte_pci_addr *addr);
|
||||
|
||||
/**
|
||||
* Map a particular resource from a file.
|
||||
*
|
||||
* @param requested_addr
|
||||
* The starting address for the new mapping range.
|
||||
* @param fd
|
||||
* The file descriptor.
|
||||
* @param offset
|
||||
* The offset for the mapping range.
|
||||
* @param size
|
||||
* The size for the mapping range.
|
||||
* @param additional_flags
|
||||
* The additional flags for the mapping range.
|
||||
* @return
|
||||
* - On success, the function returns a pointer to the mapped area.
|
||||
* - On error, the value MAP_FAILED is returned.
|
||||
*/
|
||||
void *pci_map_resource(void *requested_addr, int fd, off_t offset,
|
||||
size_t size, int additional_flags);
|
||||
|
||||
/**
|
||||
* Unmap a particular resource.
|
||||
*
|
||||
* @param requested_addr
|
||||
* The address for the unmapping range.
|
||||
* @param size
|
||||
* The size for the unmapping range.
|
||||
*/
|
||||
void pci_unmap_resource(void *requested_addr, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RTE_PCI_H_ */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user