dpdk.git
10 years agoeal: do not try to load library from current directory
Pascal Mazon [Tue, 15 Apr 2014 13:50:22 +0000 (15:50 +0200)]
eal: do not try to load library from current directory

When loading a library "libfoo.so" (depending on "libbar.so", located in an
entirely different folder), with a LD_LIBRARY_PATH=/path/to/libfoo.so", it
returns an error:

 EAL: ./libfoo.so: cannot open shared object file: No such file or directory

If the first dlopen() fails (here, because it can't find all dependencies),
the code requires for a second dlopen() that looks for "./libfoo.so". It
turns on pathname matching, which does not use LD_LIBRARY_PATH. As a result,
it fails because it cannot find "./libfoo.so".

The error message matches the error of the second dlopen(), not the first's.

Do not try to look for a different library ("./"-prefixed) than the one
provided in argument. Let the dynamic library management handle it, just
provide an appropriate LD_LIBRARY_PATH.

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agoeal: check coremask against detected lcores
David Marchand [Tue, 15 Apr 2014 13:50:42 +0000 (15:50 +0200)]
eal: check coremask against detected lcores

lcores that are set in coremask should be checked against lcores detected on
system. This way, we won't need to check them later.

Besides, if specifying an unavailable lcore, we currently panic in
eal_thread_loop() because pthread_setaffinity_np fails.
So this check will return an error with a more explicit message in
eal_parse_coremask().

"EAL: pthread_setaffinity_np failed
 PANIC in eal_thread_loop():
 cannot set affinity"

becomes :

"EAL: lcore 4 unavailable
 EAL: invalid coremask"

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agoeal: fix check of all requested CPU features
Neil Horman [Wed, 16 Apr 2014 10:50:40 +0000 (06:50 -0400)]
eal: fix check of all requested CPU features

Only the last feature was checked since commit 99f2cdf9ca10
(eal: fix %rbx corruption and simplify the code)

The return code for rte_cpu_get_flag_enabled is only checked on the termination
of the for loop that it is called inside, but should be checked for every
iteration it makes through the for loop.  This is caused by some silly missing
brackets.  Simply add them in

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reported-by: Pablo De Lara Guarch <pablo.de.lara.guarch@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agokni: more compatibility with RHEL 6.4/6.5
Jean-Mickael Guerin [Tue, 15 Apr 2014 13:51:23 +0000 (15:51 +0200)]
kni: more compatibility with RHEL 6.4/6.5

For RH 6.5:
- always include mdio.h to get the definitions of MDIO_EEE, ETHTOOL_GEEE
- is_link_local_ether_addr(), pcie_capability_clear_and_set_word(),  and
  ether_addr_equal() have been backported

For RH 6.4:
- same issue with ether_addr_equal()
- here ETH_GEE is defined without having the functions.

igb_ethtool.c:2441: error: implicit declaration of function ‘mmd_eee_adv_to_ethtool_adv_t’

Signed-off-by: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agokni: disable FDB operations on RHEL 6.5
Jean-Mickael Guerin [Tue, 15 Apr 2014 13:51:22 +0000 (15:51 +0200)]
kni: disable FDB operations on RHEL 6.5

On RH 6.5:
igb_main.c:2298: error: unknown field ‘ndo_fdb_add’ specified in
initializer

FDB ops are present in RH 6.5 via the extension of netdev, so add the
ifdef inside the netdev ops definition of igb.

However, FDB functions are not set for RHEL 6.5: the implementation
relies on dev_mc_add_excl API which has not been backported.

Signed-off-by: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agokni: fix build with kernel 3.15
Aaro Koskinen [Mon, 14 Apr 2014 13:50:00 +0000 (16:50 +0300)]
kni: fix build with kernel 3.15

rxhash has been renamed to hash. In 3.14 and newer, we can use
skb_set_hash().

Signed-off-by: Aaro Koskinen <aaro.koskinen@nsn.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoivshmem: fix errors identified by hardening
Stephen Hemminger [Fri, 7 Mar 2014 18:13:41 +0000 (10:13 -0800)]
ivshmem: fix errors identified by hardening

Need to pass mode argument to open with O_CREAT.
Must check return value from ftruncate().

Signed-off-by: Stephen Hemminger <shemming@brocade.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: pass CROSS_COMPILE when compiling kernel modules
Aaro Koskinen [Fri, 7 Feb 2014 16:44:18 +0000 (18:44 +0200)]
mk: pass CROSS_COMPILE when compiling kernel modules

Pass CROSS_COMPILE to the kernel build system when compiling kernel
modules. Although we export CC etc. the top level kernel Makefile will
override the environment. As a result it will end up using wrong tools
if cross-compilation is desired but CROSS_COMPILE is not set.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nsn.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agovdev: allow external registration of virtual device drivers
Olivier Matz [Fri, 11 Apr 2014 07:36:53 +0000 (09:36 +0200)]
vdev: allow external registration of virtual device drivers

The registration of an external vdev driver (a .so library) is done in a
function that has the ((constructor)) attribute. This function is called
when dlopen(driver.so) is invoked.

As a result, we need to do the dlopen() before calling
rte_eal_vdev_init() that calls the initialization functions of all
registered drivers.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agovdev: new registration API
Olivier Matz [Fri, 11 Apr 2014 07:36:52 +0000 (09:36 +0200)]
vdev: new registration API

Instead of having a list of virtual device drivers in EAL code, add an
API to register drivers. Thanks to this new registration method, we can
remove the references to pmd_ring, pmd_pcap and pmd_xenvirt in EAL code.
This also enables the ability to register a virtual device driver as
a shared library.

The registration is done in an init function flaged with
__attribute__((constructor)). The new convention is to name this
function rte_pmd_xyz_init(). The per-device init function is renamed
rte_pmd_xyz_devinit().

By the way the internal PMDs are now also .so/standalone ready. Let's do
it later on. It will be required to ease maintenance.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agovdev: rename nonpci_devs as vdev
Olivier Matz [Fri, 11 Apr 2014 11:45:03 +0000 (13:45 +0200)]
vdev: rename nonpci_devs as vdev

The name "nonpci_devs" for virtual devices is ambiguous as a physical
device can also be non-PCI (ex: usb, sata, ...). A better name for this
file is "vdev" as it only deals with virtual devices.

This patch doesn't introduce any change except renaming.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agodevargs: add in doc
Thomas Monjalon [Thu, 10 Apr 2014 14:15:28 +0000 (16:15 +0200)]
devargs: add in doc

Reference the new library in doxygen.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agotestpmd: add dump commands for debug
Olivier Matz [Sat, 1 Mar 2014 12:15:01 +0000 (13:15 +0100)]
testpmd: add dump commands for debug

Copy all the dump commands provided in app/test into app/testpmd. These
commands are useful to debug a problem when using testpmd.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agodevargs: add dump command in test application
Olivier Matz [Fri, 28 Feb 2014 17:25:43 +0000 (18:25 +0100)]
devargs: add dump command in test application

This is useful for debug purposes. Example:

echo 100 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
echo 100 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
./app/test -c 0x15 -n 3 -m 64 \
  --use-dev="eth_ring0" --use-device="eth_ring1" --use-device="02:00.0"
RTE>>dump_devargs
User device white list:
  VIRTUAL eth_ring0
  VIRTUAL eth_ring1
  PCI whitelist 0000:02:00.0

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agodevargs: allow to provide arguments per pci device
Olivier Matz [Sat, 1 Mar 2014 12:14:54 +0000 (13:14 +0100)]
devargs: allow to provide arguments per pci device

Some PCI drivers may require some specific initialization arguments at
start-up.

Even if unused today, adding this feature seems coherent with virtual
devices in order to provide a full-featured rte_devargs framework. In
the future, it could be added in pmd_ixgbe or pmd_igb for instance to
enable debug of drivers or setting a specific operating mode at
start-up.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agodevargs: replace --use-device option by --pci-whitelist and --vdev
Olivier Matz [Sat, 1 Mar 2014 12:14:45 +0000 (13:14 +0100)]
devargs: replace --use-device option by --pci-whitelist and --vdev

This commit splits the "--use-device" option in two new options:

- "--pci-whitelist or -w": add a PCI device in the white list
- "--vdev": instanciate a new virtual device

Before the patch, the same option "--use-device" was used for these 2
use-cases.

By the way, we also add "--pci-blacklist" in addition to the existing
"-b" for coherency with the whitelist parameter.

Test result:

echo 100 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
echo 100 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
./app/test -c 0x15 -n 3 -m 64
RTE>>eal_flags_autotest
[...]
Test OK

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agodevargs: use a comma instead of semicolon to separate key/values
Olivier Matz [Fri, 28 Feb 2014 17:25:47 +0000 (18:25 +0100)]
devargs: use a comma instead of semicolon to separate key/values

This commit changes the API of --use-device command line argument.
It changes the separators from ';' to ','. Indeed, ';' is not the best
choice as this character is also used to separate shell commands,
forcing the user to surround arguments with quotes.

This commit impacts both devargs and kvargs as each of them define
a separator in --use-device argument:

- devargs defines the separator between the device name or pci_id and
   its arguments
- kvargs defines the separator between each key/value pairs in
   arguments for drivers using the kvargs API to parse their arguments

The modification of devargs and kvargs is done in one commit to keep
the coherency of --use-device.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agodevargs: use devargs for vdev and PCI whitelist/blacklist
Olivier Matz [Sat, 1 Mar 2014 12:14:34 +0000 (13:14 +0100)]
devargs: use devargs for vdev and PCI whitelist/blacklist

Remove old whitelist code:
- remove references to rte_pmd_ring, rte_pmd_pcap and pmd_xenvirt in
  is_valid_wl_entry() as we want to be able to register external virtual
  drivers as a shared library. Moreover this code was duplicated with
  dev_types[] from eal_common_pci.c
- eal_common_whitelist.c was badly named: it was able to process PCI
  devices white list and the registration of virtual devices
- the parsing code was complex: all arguments were prepended in
  one string dev_list_str[4096], then split again

Use the newly introduced rte_devargs to get:
- the PCI white list
- the PCI black list
- the list of virtual devices

Rework the tests:
- a part of the whitelist test can be removed as it is now tested
  in app/test/test_devargs.c
- the other parts are just reworked to adapt them to the new API

This commit induce a small API modification: it is not possible to specify
several devices per "--use-device" option. This notation was anyway a bit
cryptic. Ex:
  --use-device="eth_ring0,eth_pcap0;iface=ixgbe0"
  now becomes:
  --use-device="eth_ring0" --use-device="eth_pcap0;iface=ixgbe0"

On the other hand, it is now possible to work in PCI blacklist mode and
instanciate virtual drivers, which was not possible before this patch.

Test result:

./app/test -c 0x15 -n 3 -m 64
RTE>>devargs_autotest
EAL: invalid PCI identifier <08:1>
EAL: invalid PCI identifier <00.1>
EAL: invalid PCI identifier <foo>
EAL: invalid PCI identifier <>
EAL: invalid PCI identifier <000f:0:0>
Test OK

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agodevargs: introduce API and test
Olivier Matz [Sat, 1 Mar 2014 12:14:15 +0000 (13:14 +0100)]
devargs: introduce API and test

This commit introduces a new API for storing device arguments given by
the user. It only adds the framework and the test. The modification of
EAL to use this new module is done in next commit.

The final goals:

- unify pci-blacklist, pci-whitelist, and virtual devices arguments
  in one file
- allow to register a virtual device driver from a dpdk extension
  provided as a shared library. For that we will require to remove
  references to rte_pmd_ring and rte_pmd_pcap in argument parsing code
- clarify the API of eal_common_whitelist.c, and rework its code that is
  often complex for no reason.
- support arguments for PCI devices and possibly future non-PCI devices
  (other than virtual devices) without effort.

Test result:

echo 100 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
echo 100 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
./app/test -c 0x15 -n 3 -m 64
RTE>>eal_flags_autotest
[...]
Test OK

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopci: rename device and driver lists
Olivier Matz [Fri, 28 Feb 2014 17:25:44 +0000 (18:25 +0100)]
pci: rename device and driver lists

To avoid confusion with virtual devices, rename device_list as
pci_device_list and driver_list as pci_driver_list.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: use whole-archive option to keep unused symbols
Olivier Matz [Fri, 28 Feb 2014 17:25:40 +0000 (18:25 +0100)]
mk: use whole-archive option to keep unused symbols

To fully support dpdk extensions (loading of .so), all symbols provided
by dpdk libraries must be available in the binaries: before this patch,
unused functions/variables from dpdk static libraries could be stripped
by the linker because they are not used. These symbols can be used by a
dpdk extension that is loaded at runtime with the -d option.

Adding --whole-archive when generating a binary solves this issue.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbe: release software locked semaphores on initialization
Didier Pallard [Tue, 8 Apr 2014 13:29:57 +0000 (15:29 +0200)]
ixgbe: release software locked semaphores on initialization

It may happen that DPDK application gets killed while having
acquired locks on the ethernet hardware, causing these locks to
be never released. On next restart of the application, DPDK
skip those ports because it can not acquire the lock,
this may cause some ports (or even complete board if SMBI is locked)
to be inaccessible from DPDK application until reboot of the
hardware.

This patch release locks that are supposed to be locked due to
an improper exit of the application.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
10 years agoigb: release software locked semaphores on initialization
Didier Pallard [Tue, 8 Apr 2014 13:29:58 +0000 (15:29 +0200)]
igb: release software locked semaphores on initialization

It may happen that DPDK application gets killed while having
acquired locks on the ethernet hardware, causing these locks to
be never released. On next restart of the application, DPDK
skip those ports because it can not acquire the lock,
this may cause some ports (or even complete board if SMBI is locked)
to be inaccessible from DPDK application until reboot of the
hardware.

This patch release locks that are supposed to be locked due to
an improper exit of the application.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
10 years agotimer: fix TSC frequency by not reading /proc/cpuinfo
Bruce Richardson [Mon, 7 Apr 2014 12:57:28 +0000 (13:57 +0100)]
timer: fix TSC frequency by not reading /proc/cpuinfo

This reverts commit da6fd0759cbeb5fc14991a79e40105b9f6b99059.
"timer: get TSC frequency from /proc/cpuinfo"

The use of cpuinfo to determine the frequency of the TSC is not
advisable and leads to incorrect results when power management is
in use. This is because, while the TSC frequency does not change
in modern cpus with constant_tsc support, the frequency of the core,
and hence the frequency of the core reported by cpuinfo *does* change.

Depending on the current frequency of core 0 when an application is
started, the EAL can get a wildly incorrect value for the TSC freq.
Since frequency is scaled down for power saving, any incorrect value
is likely to be lower than the default, which means that any delay
loops inside the code which rely on the TSC will be shorter than
planned. This can cause issues (reported on the mailing list by a number
of people) where ports are not initialized correctly due to delays being
too short.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: fix %rbx corruption and simplify the code
Neil Horman [Tue, 25 Mar 2014 19:52:59 +0000 (15:52 -0400)]
eal: fix %rbx corruption and simplify the code

Neil Horman reported that on x86-64 the upper half of %rbx would get
clobbered when the code was compiled PIC or PIE, because the
i386-specific code to preserve %ebx was incorrectly compiled.

However, the code is really way more complex than it needs to be.  For
one thing, the CPUID instruction only needs %eax (leaf) and %ecx
(subleaf) as parameters, and since we are testing for bits, we might
as well list the bits explicitly.  Furthermore, we can use an array
rather than doing a switch statement inside a structure.

Reported-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: H. Peter Anvin <hpa@linux.intel.com>
10 years agomk: fix dependencies when modifying config
Thomas Monjalon [Wed, 19 Mar 2014 11:13:45 +0000 (12:13 +0100)]
mk: fix dependencies when modifying config

If .config file is changed and .depdirs was built before,
it must be updated.
It is now done silently (-s) in checkconfig rule.
Now .depdirs is not redone if .config is older.

It has been tested by enabling PMD_PCAP after a default build.
KVARGS dependency should appear in .depdirs.

There is also a typo fix for PHONY rule.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agoixgbe: support flow director for X540
Mauro Annarumma [Mon, 24 Mar 2014 21:17:06 +0000 (22:17 +0100)]
ixgbe: support flow director for X540

Flow director in X540 uses the same registers as in 82599.
So it just has to be enabled in the 82599 implementation.

Signed-off-by: Mauro Annarumma <mauroannarumma@hotmail.it>
Acked-by: Maxime Leroy <maxime.leroy@6wind.com>
10 years agomempool: use GCC push/pop_options
Stephen Hemminger [Fri, 7 Mar 2014 18:13:39 +0000 (10:13 -0800)]
mempool: use GCC push/pop_options

The include file should not change the GCC compile options for
the whole file being compiled, but only for the one inline function
that needs it. Using the push_options/pop_options fixes this.

Signed-off-by: Stephen Hemminger <shemming@brocade.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agohash: make arg for jhash2 const
Stephen Hemminger [Fri, 7 Mar 2014 18:13:38 +0000 (10:13 -0800)]
hash: make arg for jhash2 const

The argument to rte_jhash2() is not changed.

Signed-off-by: Stephen Hemminger <shemming@brocade.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agombuf: copy offload flags when doing attach/clone
Stephen Hemminger [Fri, 7 Mar 2014 18:13:36 +0000 (10:13 -0800)]
mbuf: copy offload flags when doing attach/clone

rte_pktmbuf_attach copies the packet meta data but does not
copy the offload flags. This means that cloned packets lose
their offload settings such as vlan tag.

Signed-off-by: Stephen Hemminger <shemming@brocade.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agovmxnet3: rename library
Thomas Monjalon [Fri, 21 Mar 2014 12:52:17 +0000 (13:52 +0100)]
vmxnet3: rename library

In order to distinguish clearly this implementation from the extension
vmxnet3-usermap, it is renamed to reflect its usage of uio framework.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Thomas Graf <tgraf@redhat.com>
10 years agopci: fix igb_uio mapping for virtio_uio and vmxnet3_uio
Daniel Kan [Wed, 12 Mar 2014 20:19:59 +0000 (13:19 -0700)]
pci: fix igb_uio mapping for virtio_uio and vmxnet3_uio

Since commit 10ed994 (pci: use igb_uio mapping only when needed),
the flag RTE_PCI_DRV_NEED_IGB_UIO must be set even if RTE_EAL_UNBIND_PORTS
is disabled.
It was not the case for virtio_uio and vmxnet3_uio so the uio resources were
not mapped when RTE_EAL_UNBIND_PORTS was not defined.
Specifically, pci_uio_map_resource() was not called so
pci_dev->mem_resource was not mapped.

Signed-off-by: Daniel Kan <dan@nyansa.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoigb_uio: don't bind vmxnet3 and virtio devices if disabled
David Marchand [Wed, 5 Mar 2014 15:16:28 +0000 (16:16 +0100)]
igb_uio: don't bind vmxnet3 and virtio devices if disabled

When not using vmxnet3-uio and virtio-uio PMDs, prevent igb_uio from binding
these devices. This way, vmxnet3 and virtio PMDs won't fail to initialize
because of a device silently bound to igb_uio.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agovirtio: rename library
Thomas Monjalon [Mon, 3 Feb 2014 17:45:14 +0000 (18:45 +0100)]
virtio: rename library

In order to distinguish clearly this implementation from the extension
virtio-net-pmd, it is renamed to reflect its usage of uio framework.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Chris Wright <chrisw@redhat.com>
10 years agotools: rename pci_unbind script
Thomas Monjalon [Mon, 3 Feb 2014 17:40:56 +0000 (18:40 +0100)]
tools: rename pci_unbind script

In order to make this tool available among other system commands,
the name must be more specific.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Chris Wright <chrisw@redhat.com>
10 years agoget rid of DOS format end of lines
Stephen Hemminger [Thu, 27 Feb 2014 18:29:00 +0000 (19:29 +0100)]
get rid of DOS format end of lines

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomem: get physical address of any pointer
Thomas Monjalon [Thu, 20 Mar 2014 14:05:16 +0000 (15:05 +0100)]
mem: get physical address of any pointer

Insert get_physaddr() into public API as rte_mem_virt2phy().

rte_mem_virt2phy() permits to obtain the physical address of any
virtual address mapped to the current process.
get_physaddr() was working only for addresses pointing exactly to
the first byte of a page.
Note that this function is very slow and shouldn't be called
after initialization to avoid a performance bottleneck.

The memory must be locked with mlock(). The function rte_mem_lock_page()
is a mlock() helper that lock the whole page.

A better name would be rte_mem_virt2phys but rte_mem_virt2phy is more
consistent with rte_mempool_virt2phy.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agomem: revert "get physical address of any pointer"
Thomas Monjalon [Thu, 20 Mar 2014 11:15:23 +0000 (12:15 +0100)]
mem: revert "get physical address of any pointer"

This reverts commit 57c24af85d9eaa81549a212169605b4e2468a29f
which was wrongly rebased in 1.6.0 branch:
- commit log must be changed for 1.6.0
- it breaks building for 32-bit
A new version of this commit has to be done.

10 years agomem: fix build of virtual address hinting for 32-bit
David Marchand [Fri, 28 Feb 2014 08:21:35 +0000 (09:21 +0100)]
mem: fix build of virtual address hinting for 32-bit

The initial commit doesn't build for 32-bit:
8ea9ff83 (mem: allow virtual memory address hinting)

lib/librte_eal/linuxapp/eal/eal.c: In function ‘eal_parse_base_virtaddr’:
build/include/rte_common.h:133:22:
error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
  RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)
                      ^

RTE_PTR_ALIGN_CEIL return type is the same as what we give it as input.
So instead of casting the returned value, cast 'addr' which should be the same
as base_virtaddr.

Reported-by: Mats Liljegren <mats.liljegren@enea.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: revert build patches
David Marchand [Thu, 6 Mar 2014 10:11:56 +0000 (11:11 +0100)]
pcap: revert build patches

This reverts commits
a0cdfcf9 (use pcap-config to guess compilation flags),
ef5b2363 (fix build with empty LIBPCAP_CFLAGS) and
60191b89 (fix build when pcap_sendpacket is unavailable).

These patches are creating more problems than solving the initial one
(which was a build error with too old pcap libraries).
Since old pcap libraries are not that common, just revert them.

Reported-by: Meir Tseitlin <mirots@gmail.com>
Reported-by: Mats Liljegren <mats.liljegren@enea.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: fix build error introduced by kvargs
Olivier Matz [Sun, 2 Mar 2014 21:51:28 +0000 (22:51 +0100)]
pcap: fix build error introduced by kvargs

Due to a merge conflict between commits 4c745617a1 and 9d5752d80,
rte_eth_pcap.c was not compiling with the following error:

rte_eth_pcap.c: In function 'rte_pmd_init_internals':
rte_eth_pcap.c:559:30: error: dereferencing pointer to incomplete type
rte_eth_pcap.c:560:15: error: dereferencing pointer to incomplete type
rte_eth_pcap.c:561:18: error: dereferencing pointer to incomplete type
rte_eth_pcap.c:603:47: error: dereferencing pointer to incomplete type
rte_eth_pcap.c: In function 'rte_pmd_pcap_init':
rte_eth_pcap.c:732:73: error: 'dict' undeclared (first use in this
  function)
rte_eth_pcap.c:732:73: note: each undeclared identifier is reported
  only once for each function it appears in

This commit replaces "struct args_dict" by "struct rte_kvargs" to fix
the compilation issue.

By the way, it also removes the declaration of these functions from
the header file as no other file in DPDK references one of them. It
avoids to include <rte_kvargs.h> in rte_eth_pcap.h.

Reported-by: Meir Tseitlin <mirots@gmail.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoversion: 1.6.0r1
David Marchand [Wed, 19 Feb 2014 10:17:23 +0000 (11:17 +0100)]
version: 1.6.0r1

Signed-off-by: David Marchand <david.marchand@6wind.com>
10 years agoversion: add 4th digit and helper macros
Thomas Monjalon [Tue, 16 Apr 2013 09:44:12 +0000 (11:44 +0200)]
version: add 4th digit and helper macros

Applications can test versions, for compatibility, this way:
#if RTE_VERSION >= RTE_VERSION_NUM(1,2,3,4)

RTE_VERSION was already defined for use with rte_config.
It is moved in rte_version.h and updated to current version number.

Note that the first tag having this helper is 1.2.3r2.
Releases r0 have not this patch.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agoapp/testpmd: fix configuration of pause frames
Zijie Pan [Wed, 10 Jul 2013 07:27:47 +0000 (09:27 +0200)]
app/testpmd: fix configuration of pause frames

The entries for the configuration of the reception and of the transmission
of pause frames are inverted in the mode conversion array.

Signed-off-by: Zijie Pan <zijie.pan@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agoapp/testpmd: fix build without librte_cmdline
Thomas Monjalon [Thu, 14 Nov 2013 22:19:47 +0000 (23:19 +0100)]
app/testpmd: fix build without librte_cmdline

Some features are not available if LIBRTE_CMDLINE is disabled:
- interactive mode
- ethernet address parsing

Note: ethernet address parsing could be rewritten without cmdline dependency.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agoapp/test: fix build without librte_cmdline
Thomas Monjalon [Thu, 14 Nov 2013 21:26:30 +0000 (22:26 +0100)]
app/test: fix build without librte_cmdline

Some features are not available if LIBRTE_CMDLINE is disabled:
- interactive commands
- cmdline tests
Remove also cmdline_parse includes which are not needed.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agokni: fix build with kernel 3.14
Aaro Koskinen [Tue, 4 Feb 2014 12:59:09 +0000 (13:59 +0100)]
kni: fix build with kernel 3.14

ether_addr_equal() was added in Linux 3.5. compare_ether_addr() was
deleted in 3.14. Start using ether_addr_equal() and provide an own
implementation for older kernels.

This fixes the compilation with Linux 3.14-rc1.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nsn.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agokni: fix build with kernel < 3.3 with netdev_features_t backport
Adrien Mazarguil [Thu, 21 Mar 2013 10:09:23 +0000 (11:09 +0100)]
kni: fix build with kernel < 3.3 with netdev_features_t backport

The netdev_features_t typedef appeared in Linux 3.3, but checking the kernel
version isn't enough with some distributions (such as Debian Wheezy) that
backported it into 3.2, causing a compilation failure due to redefinition.

Since the presence of a typedef can't be tested at compile time, this commit
adds type kni_netdev_features_t, which, depending on the kernel version,
translates either to u32 or netdev_features_t.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agokni: fix build with 802.1p kernel support
Thomas Monjalon [Thu, 7 Feb 2013 13:07:47 +0000 (14:07 +0100)]
kni: fix build with 802.1p kernel support

C90 compilers forbid mixed declaration and code.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
10 years agoixgbe: remove residual fix about resetting big Tx queues
Thomas Monjalon [Wed, 15 Jan 2014 15:41:21 +0000 (16:41 +0100)]
ixgbe: remove residual fix about resetting big Tx queues

No need to keep residues of a fix which is replaced by another one.
This reverts commit 5a6d9897f91f6bb4b2
(residual fix about resetting big Tx queues).

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: save if_index of the bound device
Mats Liljegren [Fri, 24 Jan 2014 13:24:15 +0000 (14:24 +0100)]
pcap: save if_index of the bound device

Use command line parameters to get the name of the interface.
This name is converted into if_index, which is provided as
device info.

Signed-off-by: Mats Liljegren <mats.liljegren@enea.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: fix build when pcap_sendpacket is unavailable
David Marchand [Fri, 22 Nov 2013 10:24:57 +0000 (11:24 +0100)]
pcap: fix build when pcap_sendpacket is unavailable

Before libpcap 1.0.0, pcap_sendpacket was not available on linux targets (unless
backported).
When using such a library, we won't be able to send packet on the wire, yet we
can still dump packets into a pcap file.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: fix build with old libpcap
David Marchand [Fri, 22 Nov 2013 10:24:56 +0000 (11:24 +0100)]
pcap: fix build with old libpcap

For backwards compatibility, pcap.h includes pcap/pcap.h.
Hence, to be compatible with older pcap libraries, we must include pcap.h.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: fix build with empty LIBPCAP_CFLAGS
Robert Sanford [Fri, 6 Dec 2013 16:48:34 +0000 (11:48 -0500)]
pcap: fix build with empty LIBPCAP_CFLAGS

In rte.sdkbuild.mk with CONFIG_RTE_LIBRTE_PMD_PCAP=y,
we error-exit if LIBPCAP_CFLAGS is empty.
On some distros (e.g., Centos 6.4), it is normal for "pcap-config --cflags"
to output only a newline, because pcap header files reside in /usr/include/.
Solution is to remove the line that checks whether LIBPCAP_CFLAGS is empty.

Signed-off-by: Robert Sanford <rsanford@prolexic.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: use pcap-config to guess compilation flags
David Marchand [Fri, 22 Nov 2013 10:24:55 +0000 (11:24 +0100)]
pcap: use pcap-config to guess compilation flags

Use pcap-config to populate CFLAGS and LDFLAGS.
LIBPCAP_CFLAGS and LIBPCAP_LDFLAGS can be used to override this (useful when
cross-compiling).

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: remove unused constant
Thomas Monjalon [Thu, 2 Jan 2014 17:31:08 +0000 (18:31 +0100)]
pcap: remove unused constant

RTE_ETH_PCAP_MBUFS is not used anymore since commit 6eb0ae218a9803bc0
(pcap: fix mbuf allocation).

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoethdev: introduce if_index in device info
Mats Liljegren [Fri, 24 Jan 2014 13:24:14 +0000 (14:24 +0100)]
ethdev: introduce if_index in device info

This field is intended for pcap to describe the name of the interface
as known to Linux. It is an interface index, but can be translated into
an interface name using if_indextoname() function.

When using pcap, interrupt affinity becomes important, and this field
gives the application a chance to ensure that interrupt affinity is set
to the lcore handling the device.

Signed-off-by: Mats Liljegren <mats.liljegren@enea.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoethdev: fix non-reconfigurable pmd init
Thomas Monjalon [Fri, 13 Sep 2013 12:14:02 +0000 (14:14 +0200)]
ethdev: fix non-reconfigurable pmd init

Some Poll-Mode Drivers (PMD) are not reconfigurable and,
thus, do not implement (rx|tx)_queue_release functions.
For these drivers, the functions rte_eth_dev_(rx|tx)_queue_config
must return an ENOTSUP error only when reconfiguring,
but not at initial configuration.

Move the FUNC_PTR_OR_ERR_RET check into the case of reconfiguration.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agoethdev: add pause frame counters for em/igb/ixgbe
Ivan Boule [Thu, 27 Jun 2013 12:54:08 +0000 (14:54 +0200)]
ethdev: add pause frame counters for em/igb/ixgbe

Add into the `rte_eth_stats` data structure 4 (64-bit) counters
of XOFF/XON pause frames received and sent on a given port.

Update em, igb, and ixgbe drivers to return the value of the 4 XOFF/XON
counters through the `rte_eth_stats_get` function exported by the DPDK
API.

Display the value of the 4 XOFF/XON counters in the `testpmd` application.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoethdev: add support for device offload capabilities
Ivan Boule [Tue, 16 Apr 2013 12:42:33 +0000 (14:42 +0200)]
ethdev: add support for device offload capabilities

1) Make device RX and TX offload capabilities to be returned in the
   rte_eth_dev_info data structure by the function rte_eth_dev_info_get

   The following initial set of RX offload capabilities are defined:
   - VLAN header stripping
   - IPv4 header checksum check
   - UDP checksum check
   - TCP checksum check
   - TCP large receive offload (LRO)

   The following initial set of TX offload capabilities are defined:
   - VLAN header insertion
   - IPv4 header checksum computation
   - UDP checksum computation
   - TCP checksum computation
   - SCTP checksum computation
   - TCP segmentation offload (Transmit Segmentation Offload)
   - UDP segmentation offload

   2) Update the eth_dev_infos_get() function of the igb and ixgbe PMDs
      to return the offload capabilities which are supported by the
      device and that are effectively managed by the driver.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopci: add option --create-uio-dev to run without hotplug
Olivier Matz [Tue, 28 Jan 2014 14:26:00 +0000 (15:26 +0100)]
pci: add option --create-uio-dev to run without hotplug

When the user specifies --create-uio-dev in dpdk eal start options, the
DPDK will create the /dev/uioX instead of waiting that a program does it
(which is usually hotplug).

This option is useful in embedded environments where there is no hotplug
to do the work.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopci: split the function providing uio device and mappings
Olivier Matz [Fri, 24 Jan 2014 15:31:26 +0000 (16:31 +0100)]
pci: split the function providing uio device and mappings

Add a new function pci_get_uio_dev() that parses /sys/bus/pci/devices
to get the uio device associated with a PCI device. This patch just
moves some code that was in pci_uio_map_resource() in the new function
without any functional change.

Thanks to this change, the next commit will be easier to understand.
Moreover it improves readability: having smaller functions help to
understand what pci_uio_map_resource() does.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopci: support 82546EB
Thomas Monjalon [Fri, 20 Dec 2013 12:16:22 +0000 (13:16 +0100)]
pci: support 82546EB

Intel 82546EB Gigabit ethernet controller is reported to be working
with copper.

Tested-by: Ognjen Joldzic <ognjen.joldzic@gmail.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopci: add flag to force unbind device
Damien Millescamps [Wed, 10 Jul 2013 13:14:52 +0000 (15:14 +0200)]
pci: add flag to force unbind device

Some devices need to be unbound in order to be used via the PMD
without kernel module.

Signed-off-by: Damien Millescamps <damien.millescamps@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopci: use igb_uio mapping only when needed
Thomas Monjalon [Tue, 17 Sep 2013 10:00:57 +0000 (12:00 +0200)]
pci: use igb_uio mapping only when needed

Since DPDK 1.4, if RTE_EAL_UNBIND_PORTS is disabled, igb_uio mapping is
done for all devices (commit eee16c964cd), breaking some non-Intel drivers.
But pci_uio_map_resource() should only be called for Intel devices
(using igb_uio kernel module).
The flag RTE_PCI_DRV_NEED_IGB_UIO is set for all those devices, even when
RTE_EAL_UNBIND_PORTS is disabled (fixes commit a22f5ce8fcc).

Signed-off-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Damien Millescamps <damien.millescamps@6wind.com>
10 years agopci: do not check BAR0 mapping
David Marchand [Thu, 18 Jul 2013 08:02:36 +0000 (10:02 +0200)]
pci: do not check BAR0 mapping

Since DPDK 1.4, bars mapping is checked and prevent from initializing
drivers which do not use igb_uio mapping (see commit eee16c964cd).

There is no need to check for bars mapping, especially BAR0 is not required.
If bars mapping failed, then pci_uio_map_resource will fail and we won't reach
this check. So get rid of BAR0 check.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: Damien Millescamps <damien.millescamps@6wind.com>
10 years agomem: fix mempool for --no-huge
Damien Millescamps [Fri, 1 Mar 2013 15:10:57 +0000 (16:10 +0100)]
mem: fix mempool for --no-huge

In --no-huge mode, mempool provides objects with their associated
header/trailer fitting in a standard page (usually 4KB).
This means all non-UIO driver should work correctly in this mode,
since UIO drivers allocate ring sizes that cannot fit in a page.

Extend rte_mempool_virt2phy to obtain the correct physical address when
elements of the pool are not on the same physically contiguous memory region.

Reason for this patch is to be able to run on a kernel < 2.6.37 without
the need to patch it, since all kernel below are either bugged or don't
have huge page support at all (< 2.6.28).

Signed-off-by: Damien Millescamps <damien.millescamps@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
10 years agomem: get hugepages config
Damien Millescamps [Fri, 29 Mar 2013 10:34:00 +0000 (11:34 +0100)]
mem: get hugepages config

Allow external libraries and applications to know if hugepages
are enabled.

Signed-off-by: Damien Millescamps <damien.millescamps@6wind.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
10 years agomem: get memzone from any CPU socket when hugepages are disabled
Adrien Mazarguil [Thu, 21 Feb 2013 16:39:23 +0000 (17:39 +0100)]
mem: get memzone from any CPU socket when hugepages are disabled

When huge pages are disabled, memory is allocated for a single, undefined
CPU socket using malloc(), causing rte_memzone_reserve_aligned() to fail
most of the time.

This patch causes that memory to use SOCKET_ID_ANY instead of 0, and allow
it to be used in place of any socket ID specified by user.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Damien Millescamps <damien.millescamps@6wind.com>
10 years agomem: fix rte_malloc(SOCKET_ID_ANY), try to allocate on other nodes
Olivier Matz [Tue, 11 Jun 2013 14:18:07 +0000 (16:18 +0200)]
mem: fix rte_malloc(SOCKET_ID_ANY), try to allocate on other nodes

Before this patch, rte_malloc(SOCKET_ID_ANY) was equivalent to
rte_malloc(this_socket). If the user specifies SOCKET_ID_ANY, it means that
memory can be allocated on any socket. So fix the behavior of rte_malloc() in
order to do that. The current CPU socket is still the default, but if it fails,
other sockets are tested.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomem: remove unneeded log
Olivier Matz [Mon, 15 Jul 2013 07:37:12 +0000 (09:37 +0200)]
mem: remove unneeded log

Remove an error log in memzone_reserve_aligned_thread_unsafe().
It is up to the caller to log the error, and this is already done
in DPDK code (especially in network drivers).

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomem: get physical address of any rte_malloc buffer
Didier Pallard [Tue, 19 Mar 2013 16:00:02 +0000 (17:00 +0100)]
mem: get physical address of any rte_malloc buffer

Get physical address of any rte_malloc allocated buffer using
function rte_malloc_virt2phy(addr).
The rte_memzone pointer is now stored in each allocated memory block
header to allow simple computation of physical address of a block
using the memzone it comes from.
The function rte_malloc_virt2phy has a dependency on rte_memory.h:
phys_addr_t must be defined.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomem: more const qualifiers in malloc API
Thomas Monjalon [Fri, 12 Jul 2013 10:12:15 +0000 (12:12 +0200)]
mem: more const qualifiers in malloc API

Some functions don't modify their parameter which should be marked as const.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
10 years agomem: get physical address of any pointer
Damien Millescamps [Wed, 12 Jun 2013 05:50:20 +0000 (07:50 +0200)]
mem: get physical address of any pointer

Extract rte_mem_virt2phy() from get_physaddr().

rte_mem_virt2phy() permits to obtain the physical address of any
virtual address mapped to the current process calling this function.
Note that this function is very slow and shouldn't be called
after initialization to avoid a performance bottleneck.

The memory must be locked with mlock(). The function rte_mem_lock_page()
is a mlock() helper that lock the whole page.

A better name would be rte_mem_virt2phys but rte_mem_virt2phy is more
consistent with rte_mempool_virt2phy.

Signed-off-by: Damien Millescamps <damien.millescamps@6wind.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agotimer: add precise TSC function
Didier Pallard [Wed, 19 Feb 2014 16:46:08 +0000 (17:46 +0100)]
timer: add precise TSC function

According to Intel Developer's Manual:

"The RDTSC instruction is not a serializing instruction. It does not necessarily wait
 until all previous instructions have been executed before reading the counter. Simi-
 larly, subsequent instructions may begin execution before the read operation is
 performed. If software requires RDTSC to be executed only after all previous instruc-
 tions have completed locally, it can either use RDTSCP (if the processor supports that
 instruction) or execute the sequence LFENCE;RDTSC."

So add a rte_rdtsc_precise function that do a memory barrier before rdtsc to
synchronize operations and ensure that the TSC read is done at the expected place.
Use r/w memory barrier instead of lfence to serialize both loads and stores.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Reviewed-by: François-Frédéric Ozog <ff@ozog.com>
Reviewed-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agotimer: get TSC frequency from /proc/cpuinfo
Thomas Monjalon [Thu, 31 May 2012 17:00:31 +0000 (19:00 +0200)]
timer: get TSC frequency from /proc/cpuinfo

TSC frequency was guessed by reading CLOCK_MONOTONIC_RAW or sleeping 1 sec.
Now, read frequency from cpuinfo first.
Keep other methods as fallbacks.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agotimer: check TSC reliability
Ivan Boule [Thu, 31 May 2012 14:41:57 +0000 (16:41 +0200)]
timer: check TSC reliability

Read flags from /proc/cpuinfo and warn if constant_tsc or nonstop_tsc is
not found.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agospinlock: fix build with clang
Olivier Matz [Fri, 24 Jan 2014 15:29:06 +0000 (16:29 +0100)]
spinlock: fix build with clang

LLVM clang requires an explicitly sized "cmp" assembly instruction.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agohash: reverse the operand order to crc32
H. Peter Anvin [Tue, 25 Feb 2014 10:07:40 +0000 (02:07 -0800)]
hash: reverse the operand order to crc32

Checkin

a132a9cf2bcd440a974b9d3f5c44ba30b2c895a1 hash: use intrinsic

changed the rte_hash_crc.h from using the crc32 instruction via inline
assembly to using an intrinsic.  The intrinsic should allow for better
compiler performance, but the change did not account for the fact that
the inline assembly being in AT&T syntax used the opposite operand
order of the intrinsic.

This turns out to not matter for correctness, because the CRC32
operation is commutative.  However, it could potentially matter for
performance, because the loop is more efficient with the moving
pointer in the source operand and the accumulation in the destination
operand.

This was discovered by Jan Beulich when looking at the equivalent code
in the Linux kernel.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Reported-by: Jan Beulich <jbeulich@suse.com>
Reported-by: Pashupati Kumar <kumarp@brocade.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agolog: remove app path from syslog id
Thomas Monjalon [Mon, 16 Sep 2013 10:36:20 +0000 (12:36 +0200)]
log: remove app path from syslog id

This reverts commit "log: get full path as syslog id" (494a02537f1)
and restore the original patch from Stephen Hemminger (04210699eee).

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
10 years agokvargs: add in doc
Thomas Monjalon [Tue, 4 Feb 2014 15:11:12 +0000 (16:11 +0100)]
kvargs: add in doc

Reference the new library in doxygen.
Move also some items from misc to a new basic section.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agokvargs: add test case in app/test
Olivier Matz [Tue, 28 Jan 2014 15:06:44 +0000 (16:06 +0100)]
kvargs: add test case in app/test

Add a file app/test/test_kvargs.c that checks the rte_kvargs API.
The test passes:

  RTE>>kvargs
  == test valid case ==
  == test invalid case ==
  PMD: Error parsing device, invalid key <wrong-key>
  Test OK

I also tested that rte_eth_pcap runs with the following arguments:

  ./app/testpmd -c 0x15 -n 3 --proc-type=primary --huge-dir=/mnt/huge \
    --use-device="eth_pcap0;iface=ixgbe0" \
    -- -i --port-topology=chained

  ./app/testpmd -c 0x15 -n 3 --proc-type=primary --huge-dir=/mnt/huge \
    --use-device="eth_pcap0;rx_iface=ixgbe0;rx_iface=ixgbe1;tx_iface=ixgbe0" \
    -- -i --port-topology=chained

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: make the NULL key to match all entries
Olivier Matz [Tue, 28 Jan 2014 16:06:43 +0000 (17:06 +0100)]
kvargs: make the NULL key to match all entries

In rte_kvargs_process() and rte_kvargs_count(), if the key_match
argument is NULL, process all entries.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: add the key in handler pameters
Olivier Matz [Tue, 28 Jan 2014 16:06:42 +0000 (17:06 +0100)]
kvargs: add the key in handler pameters

This argument can be useful when rte_kvargs_process() is called with
key=NULL, in this case the handler is invoked for all entries of the
kvlist.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: add const attribute in handler parameters
Olivier Matz [Tue, 28 Jan 2014 16:06:41 +0000 (17:06 +0100)]
kvargs: add const attribute in handler parameters

The "value" argument is read-only and should be const.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: be strict when matching a key
Olivier Matz [Tue, 28 Jan 2014 16:06:40 +0000 (17:06 +0100)]
kvargs: be strict when matching a key

When we match a key in is_valid_key() and rte_kvargs_process(), do a
strict comparison (strcmp()) instead of using strstr(s1, s2) which tries
a find s1 in s2. This old behavior could lead to unexpected match, for
instance "cola" match "chocolate".

Surprisingly, no patch was needed on rte_kvargs_count() as it already
used strcmp().

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: simpler parsing and allow duplicated keys
Olivier Matz [Tue, 28 Jan 2014 16:06:39 +0000 (17:06 +0100)]
kvargs: simpler parsing and allow duplicated keys

Remove the rte_kvargs_add_pair() function whose only role was to check
if a key is duplicated. Having duplicated keys is now allowed by kvargs
API.

Also replace rte_strsplit() by more a standard function strtok_r() that
is easier to understand for people already knowing the libc. It also
avoids useless calls to strnlen(). The delimiters macros become strings
instead of chars due to the strtok_r() API.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: rework API to fix memory leak
Olivier Matz [Tue, 28 Jan 2014 16:06:38 +0000 (17:06 +0100)]
kvargs: rework API to fix memory leak

Before the patch, a call to rte_kvargs_tokenize() resulted in a call to
strdup() to allocate a modifiable copy of the argument string. This
string was never freed, excepted in the error cases of
rte_kvargs_tokenize() where rte_free() was wrongly called instead of
free(). In other cases, freeing this string was impossible as the
pointer not saved.

This patch introduces rte_kvargs_free() in order to free the structure
properly. The pointer to the duplicated string is now kept in the
rte_kvargs structure. A call to rte_kvargs_parse() directly allocates
the structure, making rte_kvargs_init() useless.

The only drawback of this API change is that a key/value associations
cannot be added to an existing kvlist. But it's not used today, and
there is not obvious use case for that.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: remove useless size field
Olivier Matz [Tue, 28 Jan 2014 16:06:37 +0000 (17:06 +0100)]
kvargs: remove useless size field

This value was not very useful as the size of the table is fixed (equals
RTE_KVARGS_MAX).

By the way, the memset in the initialization function was wrong (size
too short). Even if it was not really an issue since we rely on the
"count" field, it is now fixed by this patch.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: remove driver name in arguments
Olivier Matz [Tue, 28 Jan 2014 16:06:36 +0000 (17:06 +0100)]
kvargs: remove driver name in arguments

Now that rte_kvargs is a generic library, there is no need to have an argument
for the driver name in rte_kvargs_tokenize() and rte_kvargs_parse()
prototypes. This argument was only used to log the driver name in case of
error. Instead, we can add a log in init function of pmd_pcap and pmd_ring.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: use the new library in pmd_pcap
Olivier Matz [Tue, 28 Jan 2014 15:06:35 +0000 (16:06 +0100)]
kvargs: use the new library in pmd_pcap

The rte_kvargs library is a reworked copy of rte_eth_pcap_arg_parser,
so it provides the same service. Therefore we can use it and remove the
code of rte_eth_pcap_arg_parser.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agokvargs: add a new library to parse key/value arguments
Olivier Matz [Tue, 28 Jan 2014 16:06:34 +0000 (17:06 +0100)]
kvargs: add a new library to parse key/value arguments

Copy the code from rte_eth_pcap_arg_parser.[ch], without any functional
modifications, only:
- rename functions and structure
- restyle (indentation)
- add comments (doxygen style)
- add "const" or "static" attributes, remove unneeded "inline"

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agoeal: remove unused macro for blacklist
Thomas Monjalon [Wed, 30 Oct 2013 15:26:14 +0000 (16:26 +0100)]
eal: remove unused macro for blacklist

This macro was used for blacklist parsing but is not used anymore
since commit 5a55b9ac91face71e9d665eecc716201d28745b0.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agoeal: fix recording of detected/enabled logical cores
Ivan Boule [Fri, 8 Feb 2013 12:01:52 +0000 (13:01 +0100)]
eal: fix recording of detected/enabled logical cores

1) In the EAL initialization phase, invoke the function rte_eal_cpu_init
   to detect the set of running cores (and enable them by default) before
   processing the [enabled] core mask option that is performed during the
   parsing of EAL arguments.

2) In the function rte_eal_cpu_init():
   - to parse the set of all running logical cores on the machine, do not
     use the RTE_LCORE_FOREACH macro that considers the set of already
     detected cores...
     Instead, use a standard loop based on the RTE_MAX_LCORE constant.
   - explicitely set to ROLE_RTE the role of each detected logical core
     that is recorded in the EAL configuration, as all running cores are
     enabled by default.

3) In the function eal_parse_coremask(), update the "lcore_count" field
   of the EAL configuration with the effective number of logical cores
   that are set in the mask of enabled logical cores.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: fix type of pointer arithmetic result
Thomas Monjalon [Fri, 12 Jul 2013 10:54:35 +0000 (12:54 +0200)]
eal: fix type of pointer arithmetic result

Adding or subtracting a value to a pointer makes a new pointer
of unknown type.
So typeof() is replaced by (void*) in RTE_PTR_ADD() and RTE_PTR_SUB().

But RTE_PTR_ALIGN_* macros have in their explicit API to return a pointer
of the same type. Since RTE_PTR_ALIGN_CEIL is based on RTE_PTR_ADD, a
typeof() is added to keep the original behaviour.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
10 years agoeal: add support for shared object drivers
Damien Millescamps [Wed, 12 Jun 2013 05:51:27 +0000 (07:51 +0200)]
eal: add support for shared object drivers

Add an option to specify libraries to be loaded before probing the PCI.

For instance, testpmd -d librte_pmd_xxx.so can be used to enable xxx driver
support on testpmd without any recompilation of testpmd.

Plugins are loaded before creating threads because we want the threads to
inherit any property that could be set while loading a plugin, such as iopl().

Signed-off-by: Damien Millescamps <damien.millescamps@6wind.com>
Signed-off-by: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: fix command-line dependency check for quoted strings
Adrien Mazarguil [Fri, 15 Nov 2013 14:38:52 +0000 (15:38 +0100)]
mk: fix command-line dependency check for quoted strings

Before recompiling a file, rte.compile-pre.mk checks whether the command
line is different from the previous one.

This is done by storing for each object file the entire command line in a
kind of dependency file with a .cmd extension (see obj2cmd). If that file
exists, the line is retrieved first and compared against $(C_TO_O_STR).
The object file gets recompiled if the file doesn't exist or if the line
is different.

The problem is that sometimes, files are recompiled for no apparent reason.

The check doesn't work properly when a command line contains double-quoted
strings such as -DFOO='"bar"' because the shell interprets and strips them.
This is fixed by protecting C_TO_O_CMD with simple quotes, knowing that
such quotes are already escaped in C_TO_O_STR.

Moreover, because simple quotes are escaped in C_TO_O_STR, the retrieved
command should be compared against C_TO_O instead.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: fix EXTRA_LDFLAGS override
Julien Courtat [Fri, 15 Nov 2013 14:22:37 +0000 (15:22 +0100)]
mk: fix EXTRA_LDFLAGS override

The GCC prefix -Wl was ignored because the command line value has higher priority.
It ended in impossibilty for GCC to pass parameters to LD.
The prefixed value must override the command line one.

Signed-off-by: Julien Courtat <julien.courtat@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: allow to build shared libraries
Didier Pallard [Fri, 4 Jan 2013 17:00:11 +0000 (18:00 +0100)]
mk: allow to build shared libraries

Add mk/rte.shared.mk and mk/rte.extshared.mk in framework to
   allow shared libraries compilation through framework

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agomk: allow to specify DESTDIR in build rule
Olivier Matz [Wed, 30 Jan 2013 15:32:15 +0000 (16:32 +0100)]
mk: allow to specify DESTDIR in build rule

This will install the binary sdk (bin + modules + libs + headers + mk)
in the specified directory.
This directory can be used as RTE_SDK by external applications.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>