Some drivers need ability to access PCI config (for example for power
management). This adds an abstraction to do this for both Linux
and BSD.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Harish Patil <harish.patil@qlogic.com>
Move common functions from BSD/Linux to eal_common_memory.c file.
BSD uses contigmem kernel module and Linux uses /proc/self/pagemap file.
Signed-off-by: Ravi Kerur <rkerur@gmail.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Move common functions from BSD/Linux to eal_common_timer.c.
BSD uses sysctl and Linux uses CLOCK_MONOTIC_RAW to calibrate TSC.
HPET is specific to Linux and not integrated in the common init.
Signed-off-by: Ravi Kerur <rkerur@gmail.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
[Thomas: move inclusion used by ixgbe bypass]
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
There are close and detach functions in ethdev.
To keep a consistent naming, PCI functions called by ethdev detach
must be named "detach" instead of "close".
Fix also comments which mix close and uninit names.
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Implement rte_memzone_free which, as its name implies, would free a
memzone.
Currently memzone are tracked in an array and cannot be free.
To be able to reuse the same array to track memzones, we have to
change how we keep track of reserved memzones.
With this patch, any memzone with addr NULL is not used, so we also need
to change how we look for the next memzone entry free.
Add new unit test for rte_memzone_free API.
Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Move malloc inside eal and create a new section in MAINTAINERS file for
Memory Allocation in EAL.
Create a dummy malloc library to avoid breaking applications that have
librte_malloc in their DT_NEEDED entries.
This is the first step towards using malloc to allocate memory directly
from memsegs. Thus, memzones would allocate memory through malloc,
allowing to free memzones.
Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
After code rework from bellow commit, logic expects hugepage_sz field to
always be set (ie. not zero value).
When using --no-huge, this field was left unset defaulting to zero.
Set hugepage_sz to RTE_PGSIZE_4K when using --no-huge.
Fixes: b3dfffd962 ("mem: allow multiple page sizes to be requested")
Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
The patch fixes vfio initialization issue introduced by below patch.
Root cause is that VFIO_PRESENT is inaccessible in eal common level.
To fix it, remove pci_map/unmap_device from common code, then implement
in linux and bsd code.
Fixes: 35b3313e32 ("pci: merge mapping functions for linux and bsd")
Reported-by: Michael Qiu <michael.qiu@intel.com>
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
This patch removes CONFIG_RTE_LIBRTE_EAL_HOTPLUG option, and enables it
as default in both Linux and BSD.
Also, to support port hotplug, rte_eal_pci_scan() and below missing
symbols should be exported to ethdev library.
- rte_eal_parse_devargs_str()
- rte_eal_pci_close_one()
- rte_eal_pci_probe_one()
- rte_eal_pci_scan()
- rte_eal_vdev_init()
- rte_eal_vdev_uninit()
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
This patch consolidates below functions, and implements these in common
eal code.
- rte_eal_pci_probe_one_driver()
- rte_eal_pci_close_one_driver()
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: David Marchand <david.marchand@6wind.com>
The patch consolidates below functions, and implemented in common
eal code.
- pci_map_device()
- pci_unmap_device()
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
The patch consolidates below functions, and implemented in common
eal code.
- pci_map_resource()
- pci_unmap_resource()
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
This patch consolidates below structures, and defines them in common code.
- struct pci_map
- struct mapped_pci_resources
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
This patch adds a new function called pci_uio_map_resource_by_index().
The function hides how to map uio resource in linuxapp and bsdapp.
With the function, pci_uio_map_resource() will be more abstracted.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: David Marchand <david.marchand@6wind.com>
This patch adds new functions called pci_uio_alloc_resource() and
pci_uio_free_resource().
The functions hides how to prepare or free uio resource in linuxapp
and bsdapp. With the function, pci_uio_map_resource() will be more
abstracted.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: David Marchand <david.marchand@6wind.com>
This patch fixes below.
- bsdapp
- Use map_id in pci_uio_map_resource().
- Fix interface of pci_map_resource().
- Move path variable of mapped_pci_resource structure to pci_map.
- linuxapp
- Remove redundant error message of linuxapp.
'pci_uio_map_resource()' is implemented in both linuxapp and bsdapp,
but interface is different. The patch fixes the function of bsdapp
to do same as linuxapp. After applying it, file descriptor should be
opened and closed out of pci_map_resource().
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
To merge pci code of linuxapp and bsdapp, this patch changes names
like below.
- uio_map to pci_map
- uio_resource to mapped_pci_resource
- uio_res_list to mapped_pci_res_list
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
This patch fixes following memory leaks.
- When open() is failed, uio_res and fds won't be freed in
pci_uio_map_resource().
- When pci_map_resource() is failed but path is allocated correctly,
path and fds won't be freed in pci_uio_map_recource().
Also, some mapped resources should be freed.
- When pci_uio_unmap() is called, path should be freed.
Also, fixes below.
- When pci_map_resource() is failed, mapaddr will be MAP_FAILED.
In this case, pci_map_addr should not be incremented in
pci_uio_map_resource().
- To shrink code, move close().
- Remove fail variable.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
This patch fixes coding style of below files in linuxapp and bsdapp.
- eal_pci.c
- eal_pci_uio.c
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
The RTE_LOG(DEBUG, ...) messages in rte_eal_cpu_init() are printed
even when the log level on the command line was set to INFO or lower.
The problem is the rte_eal_cpu_init() routine was called before
the command line args are scanned. Setting --log-level=7 now
correctly does not print the messages from the rte_eal_cpu_init() routine.
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
Move ring PMD to drivers directory
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Move pcap pmd to drivers/net directory
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Compilation on FreeBSD with clang was broken, giving the error message:
lib/librte_eal/bsdapp/eal/eal_pci.c:438:16: fatal error: assigning to
'struct rte_pci_id *' from 'const struct rte_pci_id *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {
^ ~~~~~~~~~~~~
This patch fixes the issue by adding "const" to the type of id_table.
Fixes: 6065355a03 ("pci: make device id tables const")
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Closing /dev/io fd causes SIGBUS in inb/outb instructions
as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
0 0x0000000000492f2c in outb (port=49170, data=0 '\000')
at /usr/include/machine/cpufunc.h:244
1 0x0000000000492f7a in outb_p (data=0 '\000', port=49170)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211
2 0x000000000049328d in vtpci_set_status (hw=0x80331f380, status=0 '\000')
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130
3 0x00000000004931fe in vtpci_reset (hw=0x80331f380)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108
4 0x00000000004a175e in eth_virtio_dev_init (eth_dev=0x831b80 <rte_eth_devices>)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150
5 0x0000000000462c09 in rte_eth_dev_init (pci_drv=0x79d1a0 <rte_virtio_pmd>,
pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326
6 0x000000000046f03f in rte_eal_pci_probe_one_driver (dr=0x79d1a0 <rte_virtio_pmd>,
dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487
7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560)
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116
8 0x0000000000475bb9 in rte_eal_pci_probe ()
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246
9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0)
at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:554
10 0x0000000000404544 in main ()
Fixes: 8a312224bc ("eal/bsd: fix fd leak")
Signed-off-by: Raz Amir <razamir22@gmail.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Kernel driver (kdrv) seems easier to understand than
passthrough driver (pt_driver). It's also more generic
as a PMD could run on top of any PCI kernel driver if
it would offer such support.
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Michael Qiu <michael.qiu@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
Commit a2348166ea ("tailq: move to dynamic tailq") introduced a bug in
uio/vfio resources list init.
These resources list were pointed at through a pointer initialised only once but
too early in the eal init (before tailqs init).
Fix this by "resolving" this pointer when used (which is well after tailqs
init).
Fixes: a2348166ea ("tailq: move to dynamic tailq")
Reported-by: Marvin Liu <yong.liu@intel.com>
Reported-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Signed-off-by: David Marchand <david.marchand@6wind.com>
Tested-by: John McNamara <john.mcnamara@intel.com>
Tested-by: Tetsuya Mukawa <mukawa@igel.co.jp>
The contigmem module was using an "int" type for specifying the
size of blocks of memory to be reserved. A 2GB block was therefore
overflowing the signed 32-bit value, making 1GB the largest block
size that could be reserved as a single unit.
The fix is to change the type used for the buffer/block size to
an "int64_t" value.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
No static entry remaining, the rte_tailq api is for "internal use" only, get rid
of the static slots.
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
This register system makes it possible to reserve a tailq for the dpdk
libraries.
The "dynamic" tailqs are right after the "static" tailqs in shared mem.
Primary process is responsible for writing the tailq names, so that secondary
processes can find them.
This is a temp commit, "static" tailqs are removed after conversion of all
users in next commits.
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
The "reserve" macros and functions do not check if the requested entry is free.
They do nothing more than the lookup function (which itself "creates" entries
...).
The rte_tailq api is marked as "internal use" in documentation and these macros
are only used in test application, so just get rid of them.
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
There is no reason why we should use the "reserve" tailq api, since the pci
entry is already statically reserved.
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Theres no need to export this variable. Its set and queried from an API call
that doesn't exist in the hot path. Instead just export the rte_socket_id
symbol and make the variable private to protect it from type changes. We should
do this with the other exported variables too, but I think its too late in the
release cycle to do that.
tested using distributor_autotest (which uses rte_socket_id), successfully.
Only tested on linux, as I don't currently have a bsd system spun up, but the
changes are symmetric, and should be fine
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
This patch replaces pci_addr_comparison() and memcmp() of pci addresses by
rte_eal_compare_pci_addr().
To compare PCI addresses, rte_eal_compare_pci_addr() doesn't use memcmp().
This is because sizeof(struct rte_pci_addr) returns 6, but actually
this structure is like below.
struct rte_pci_addr {
uint16_t domain; /**< Device domain */
uint8_t bus; /**< Device bus */
uint8_t devid; /**< Device ID */
uint8_t function; /**< Device function. */
};
If the structure is dynamically allocated in a function without bzero,
last 1 byte may have value. As a result, memcmp may not work.
To avoid such a case, rte_eal_compare_pci_addr() compare following values.
dev_addr = (addr->domain << 24) | (addr->bus << 16) |
(addr->devid << 8) | addr->function;
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
As per_lcore__socket_id and rte_sys_gettid are missing in version map,
it causes compiling error when CONFIG_RTE_BUILD_SHARED_LIB is enabled.
Fixes: ef76436c68 ("eal: get unique thread id")
Fixes: 9e29251b2a ("eal: thread affinity API")
Reported-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Tested-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: John McNamara <john.mcnamara@intel.com>
Set _lcore_id and _socket_id to (-1) by default.
For those non EAL thread, _lcore_id shall always be LCORE_ID_ANY.
The libraries using _lcore_id as index need to take care.
_socket_id always be SOCKET_ID_ANY until the thread changes the affinity
by rte_thread_set_affinity().
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
EAL threads use assigned cpuset to set core affinity during startup.
It keeps 1:1 mapping, if no '--lcores' option is used.
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
1. add two TLS *_socket_id* and *_cpuset*
2. add one internal API, eal_cpu_socket_id/eal_thread_dump_affinity
3. add two public API, rte_thread_set/get_affinity
4. update EAL version map for EAL public API
The API works for both EAL thread and non EAL thread.
When calling rte_thread_set_affinity, the *_socket_id* and
*_cpuset* of calling thread will be updated if the thread
successfully set the cpu affinity.
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
The rte_gettid() wraps the linux and freebsd syscall gettid().
It provides a persistent unique thread id for the calling thread.
It will save the unique id in TLS on the first time.
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
It defines eal_cpu_socket_id() which exposing the origin private cpu_socket_id().
The function is only used inside EAL. It returns socket_id of the specified cpu_id.
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
The patch adds 'cpuset' into per-lcore configure 'lcore_config[]',
as the lcore no longer always 1:1 pinning with physical cpu.
The lcore now stands for a EAL thread rather than a logical cpu.
It doesn't change the default behavior of 1:1 mapping, but allows to
affinity the EAL thread to multiple cpus.
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>