dpdk.git
10 years agoapp/testpmd: configure RSS without restart
Ivan Boule [Fri, 16 May 2014 08:58:41 +0000 (10:58 +0200)]
app/testpmd: configure RSS without restart

The function cmd_config_rss_parsed() associated with the command
"port config rss all" required to first stop all ports, in order to
then entirely re-configure all ports with the new RSS hash computation
parameters.
Use now the new function rte_eth_dev_rss_hash_conf_update() that dynamically
only changes the RSS hash computation parameters of a port, without needing
to previously stop the port.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoethdev: allow to set RSS hash computation flags and/or key
Ivan Boule [Fri, 16 May 2014 08:58:40 +0000 (10:58 +0200)]
ethdev: allow to set RSS hash computation flags and/or key

1) Add a new function "rss_hash_update" in the PMD API to dynamically
   update the RSS flags and/or the RSS key used by a NIC to compute the RSS
   hash of input packets.
   The new function uses the existing data structure "rte_eth_rss_conf" for
   the argument that contains the new hash flags and/or the new hash key to
   use.

2) Add the ixgbe-specific function "ixgbe_dev_rss_hash_update" and the
   igb-specific function "eth_igb_rss_hash_update" to update the RSS
   hash configuration of ixgbe and igb controllers respectively.
   Before changing anything, these 2 functions check that the update RSS
   operation does not attempt to disable RSS, if RSS was enabled at port
   initialization time, or does not attempt to enable RSS, if RSS was
   disabled at port initialization time.

Note:
   Configuring the RSS hash flags and the RSS key used by a NIC consists in
   updating appropriate PCI registers of the NIC.
   These operations have been manually tested with the interactive commands
   "write reg" and "write regbit" of the testpmd application.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoethdev: check RETA queue indices against number of queues
Ivan Boule [Fri, 16 May 2014 08:58:39 +0000 (10:58 +0200)]
ethdev: check RETA queue indices against number of queues

Each entry of the RSS redirection table (RETA) of igb and ixgbe ports
contains a 4-bit RX queue index, thus imposing RSS RX queue indices to
be strictly lower than 16.
In addition, if a RETA entry is configured with a RX queue index that is
strictly lower than 16, but is greater or equal to the number of RX queues
of the port, then all input packets whose RSS hash value indexes that RETA
entry are silently dropped by the NIC.

Make the function rte_eth_dev_rss_reta_update() check that RX queue indices
that are supplied in the reta_conf argument are strictly lower than
ETH_RSS_RETA_MAX_QUEUE (16) and are strictly lower than the number of
RX queues of the port.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoigbvf: fix mac type for 82576
Konstantin Ananyev [Tue, 6 May 2014 14:33:01 +0000 (15:33 +0100)]
igbvf: fix mac type for 82576

e1000_vfadapt type corresponds to 82576 VF devices,
check e1000_set_mac_type() for more details.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agoixgbevf: assign a default mac address
Ivan Boule [Mon, 12 May 2014 14:12:30 +0000 (16:12 +0200)]
ixgbevf: assign a default mac address

When initializing a VF with no initial MAC address assigned by
the underlying Host PF driver, assign a default MAC address.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbevf: reset unused mailbox data registers
Ivan Boule [Mon, 12 May 2014 14:11:54 +0000 (16:11 +0200)]
ixgbevf: reset unused mailbox data registers

The VF_RESET message of the 82599 PF/VF communication protocol issued by a
a Guest VF driver may include an optional permanent MAC address assigned to
the VF by the Guest OS, in order to make it recorded into the 82599 RAR
registers by the Host PF driver.

To indicate the absence of this optional MAC address, the VF_RESET command
assumes that a NULL MAC address is sent, instead of using a dedicated bit
for this purpose. However, when sending a VF_RESET command with no permanent
MAC address, the function ixgbe_reset_hw_vf() of the 82599 VF driver
directly invokes the function ixgbe_write_mbx_vf() with a message that does
not include a NULL MAC address, wrongly assuming that this function fills in
with zero all unused mailbox data registers.

More globally, it is safer to explicitely reset to zero all remaining mailbox
data registers that are not used to store the content of a message, in order
to reset the data sent in a previous VF/PF exchange (in either side),
including the last exchange performed by another Guest OS to which that VF
was previously assigned.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbevf: skip null and permanent mac addresses
Ivan Boule [Mon, 12 May 2014 14:11:36 +0000 (16:11 +0200)]
ixgbevf: skip null and permanent mac addresses

On a 82599 VF, the deletion of a dynamically added MAC address consists in
first flushing all added MAC addresses, then in adding again all remaining MAC
addresses.
For this purpose, the function ixgbevf_remove_mac_addr() parses the pool
of MAC addresses associated with a VF, and must skip the VF permanent MAC
address that is stored into it, as well as all NULL MAC addresses.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbevf: avoid adding twice the permanent mac address
Ivan Boule [Mon, 12 May 2014 14:11:06 +0000 (16:11 +0200)]
ixgbevf: avoid adding twice the permanent mac address

During the initialization of a VF device, the rte_eth_dev_start() function
indirectly invokes the PMD "mac_addr_add" function with the permanent MAC
address assigned to the device.
In the case of 82599 VFs, this operation leads to exhausting the very
limited set of PF resources used to store VF MAC addresses.

To address this issue, do nothing in the function ixgbevf_add_mac_addr()
if the added MAC address is equal to the permanent MAC address of the VF.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbevf: add/remove mac address
Ivan Boule [Mon, 12 May 2014 14:10:46 +0000 (16:10 +0200)]
ixgbevf: add/remove mac address

Add missing PMD functions in the ixgbevf driver to add (respectively remove)
a MAC address to/from a 82599 VF.
For this purpose, these 2 functions use the VF/PF mailbox-based protocol.

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbevf: fix jumbo frame
Konstantin Ananyev [Tue, 6 May 2014 14:31:12 +0000 (15:31 +0100)]
ixgbevf: fix jumbo frame

When latest Linux ixgbe PF is used, and DPDK VF is used in DPDK application,
jumbo frames are not received.
Also - if Linux ixgbe PF has MTU set to 1500 (default),
then normal sized packets can be received by DPDK VF.
However, if Linux PF has MTU > 1500, then DPDK VF receives no packets
(normal or jumbo).
With ixgbe_mbox_api_10 ixgbe simply didn't allow set VF MTU > 1514 for 82599.
With ixgbe_mbox_ajpi_11 it does, though now, if PF uses jumbo frames,
it simply disables RX for all VFs.
So to work with PF ithat using jumbo frames, at startup each VF has to:
1. negotiate with PF mbox_api_11.
2. Send to PF SET_LPE message with desired MTU.
Note, that if PF already uses MTU bigger then asked by the VF,
then PF wouldn't take any action.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agotimer: fix pending counter
Vadim Suraev [Wed, 21 May 2014 20:35:55 +0000 (23:35 +0300)]
timer: fix pending counter

Bug: When a timer is running
 - if rte_timer_stop is called, the pending decrement is
 skipped (decremented only if the timer is pending) and due
 to the update flag the future processing is skipped so the
 timer is counted as pending while it is stopped. - the same
 applies when rte_timer_reset is called but then the pending
 statistics is additionally incremented so the timer is
 counted pending twice.
Solution: decrement the pending
 statistics after returning from the callback. If
 rte_timer_stop was called, it skipped decrementing the
 pending statistics. If rte_time_reset was called, the
 pending statistics was incremented. If neither was called
 and the timer is periodic, the pending statistics is
 incremented when it is reloaded

Signed-off-by: Vadim Suraev <vadim.suraev@gmail.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agotimer: fix reloading after changes
Vadim Suraev [Wed, 21 May 2014 19:53:45 +0000 (22:53 +0300)]
timer: fix reloading after changes

Bug: when a periodic timer's callback is running, if another
 timer is manipulated, the periodic timer is not reloaded.
Solution: set the update flag only if the modified timer is
 in RUNNING state

Signed-off-by: Vadim Suraev <vadim.suraev@gmail.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agocmdline: fix infinite loop after EOF
Cristian Dumitrescu [Fri, 23 May 2014 15:21:24 +0000 (16:21 +0100)]
cmdline: fix infinite loop after EOF

Stop on EOF when reading commands from a file or a pipe.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agomk: fix linking drivers in static apps
Bruce Richardson [Fri, 23 May 2014 14:39:24 +0000 (15:39 +0100)]
mk: fix linking drivers in static apps

The variable CONFIG_RTE_BUILD_SHARED_LIB was in rte.app.mk as
"RTE_BUILD_SHARED_LIB", which meant that none of the example apps linked
in the PMDs and just didn't work with any eth ports in any static builds.

This bug has been introduced in commit 3660cdf990:
  pcap: convert to use of PMD_REGISTER_DRIVER and fix linking

Link for l2fwd before patch:
  "... -Wl,--whole-archive -Wl,-lrte_kni -Wl,-lrte_timer -Wl,-lrte_hash
-Wl,-lrte_lpm -Wl,-lrte_power -Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lm
-Wl,-lrt -Wl,--start-group -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lethdev
-Wl,-lrte_malloc -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal
-Wl,-lrte_cmdline -Wl,-lrt -Wl,-lm -Wl,-ldl -Wl,--end-group
-Wl,--no-whole-archive"

Link for l2fwd after patch:
  "...  -Wl,--whole-archive -Wl,-lrte_kni -Wl,-lrte_timer -Wl,-lrte_hash
-Wl,-lrte_lpm -Wl,-lrte_power -Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lm
-Wl,-lrt -Wl,--start-group -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lethdev
-Wl,-lrte_malloc -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal
-Wl,-lrte_cmdline -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_pmd_virtio_uio
-Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ring -Wl,-lrt
-Wl,-lm -Wl,-ldl -Wl,--end-group -Wl,--no-whole-archive"

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agokni: fix build on Fedora 18 with kernel 3.6.10
Helin Zhang [Thu, 22 May 2014 03:35:17 +0000 (11:35 +0800)]
kni: fix build on Fedora 18 with kernel 3.6.10

Error of "implicit-function-declaration" can be seen when building KNI
kernel module on Linux kernel 3.6.10 platform, as follows.
  lib/librte_eal/linuxapp/kni/igb_ethtool.c:
    In function igb_get_eee:
  lib/librte_eal/linuxapp/kni/igb_ethtool.c:
    2441:4: error: implicit declaration of function
    mmd_eee_adv_to_ethtool_adv_t
  lib/librte_eal/linuxapp/kni/igb_ethtool.c:
    In function igb_set_eee:
  lib/librte_eal/linuxapp/kni/igb_ethtool.c:
    2551:2: error: implicit declaration of function
    ethtool_adv_to_mmd_eee_adv_t

The root cause is as follows.
On Fedora 18 with kernel 3.6.10, ETHTOOL_GEEE is defined in Linux
header file of "linux/ethtool.h", while is not defined in most of other
linux kernel versions.
mmd_eee_cap_to_ethtool_sup_t(), mmd_eee_adv_to_ethtool_adv_t() and
ethtool_adv_to_mmd_eee_adv_t() in kcompat.h are disabled by "#if
!defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE <=
RHEL_RELEASE_VERSION(6,4))", while are called in igb_get_eee() in
igb_ethtool.c which is enabled by "#ifdef ETHTOOL_GEEE".

Reported-by: Prashant Upadhyaya <prashant.upadhyaya@aricent.com>
Signed-off-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agosched: fix grinder bug
Stephen Hemminger [Wed, 14 May 2014 16:25:27 +0000 (09:25 -0700)]
sched: fix grinder bug

The rte_scheduler will get stuck and not deliver any more packets
if there are two active subports and then one of them stops enqueing
more packets. This is because of a bug in how the grinder state machines
are managed.

If a non-zero grinder is assigned (but not yet active), then the dequeue
would miss it and always return zero packets. The cure is to always
do a first pass over all grinders.

Signed-off-by: Stephen Hemminger <shemming@brocade.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agosched: fix build if debug enabled
Stephen Hemminger [Wed, 14 May 2014 16:25:26 +0000 (09:25 -0700)]
sched: fix build if debug enabled

Fix build error if RTE_SCHED_DEBUG is enabled.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agosched: use malloc instead of memzone for allocation
Stephen Hemminger [Wed, 14 May 2014 16:25:25 +0000 (09:25 -0700)]
sched: use malloc instead of memzone for allocation

The existing rte scheduler can only be safely configured once per port
because a memory zone has a fixed size once it is created and can never
be freed or change in size.

This patch changes the scheduler to use rte_malloc instead. This allows
for a port to be reconfigured by doing rte_sched_port_free followed
rte_sched_port_config.

The patch also removes the now unused name parameter from the
port parameters structure.

Signed-off-by: Stephen Hemminger <shemming@brocade.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoconfig: rename "default" configurations as "native"
David Marchand [Wed, 14 May 2014 14:58:08 +0000 (16:58 +0200)]
config: rename "default" configurations as "native"

The "default" part in configuration filenames is misleading.
Rename this as "native", as this is the RTE_MACHINE that is set in these files.
This should make it clearer for people who build DPDK on a system then run it on
another one.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agoconfig: factorize configurations
David Marchand [Wed, 14 May 2014 14:58:07 +0000 (16:58 +0200)]
config: factorize configurations

linux and bsd default configurations now have their own default common
configuration files.
Specific options are then set in the specific files.
This makes it easier to globally enable/disable some features in DPDK for
multiple targets.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agoigb: fix indentation of previous patchset
Thomas Monjalon [Wed, 21 May 2014 11:23:50 +0000 (13:23 +0200)]
igb: fix indentation of previous patchset

There was an indentation error in commit d93c252e88f2b29a5
"convert to use of PMD_REGISTER_DRIVER and fix linking"

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: fix indentation of previous patchset
Thomas Monjalon [Wed, 21 May 2014 11:21:16 +0000 (13:21 +0200)]
eal: fix indentation of previous patchset

There was an indentation error in commit e57f20e051770861377ff
"make vdev init path generic for both virtual and pci devices"

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoethdev: remove rte_pmd_init_all function
Neil Horman [Mon, 21 Apr 2014 14:59:39 +0000 (10:59 -0400)]
ethdev: remove rte_pmd_init_all function

Now that we've converted all the pmds in dpdk to use the driver registration
macro, rte_pmd_init_all has become empty.  As theres no reason to keep it around
anymore, just remove it and fix up all the eample callers.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agovmxnet3: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:38 +0000 (10:59 -0400)]
vmxnet3: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the vmxnet3 pmd driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the vmxnet3 library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agovirtio: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:37 +0000 (10:59 -0400)]
virtio: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the virtio pmd driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the virtio library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbevf: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:36 +0000 (10:59 -0400)]
ixgbevf: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the ixgbevf pmd driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the ixgbevf library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoixgbe: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:35 +0000 (10:59 -0400)]
ixgbe: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the ixgbe pmd driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the ixgbe library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoigbvf: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:33 +0000 (10:59 -0400)]
igbvf: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the igbvf pmd driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the igbvf library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoigb: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:32 +0000 (10:59 -0400)]
igb: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the igb pmd driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the igb library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoe1000: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:34 +0000 (10:59 -0400)]
e1000: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the e1000 pmd driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the e1000 library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: make vdev init path generic for both virtual and pci devices
Neil Horman [Mon, 21 Apr 2014 14:59:31 +0000 (10:59 -0400)]
eal: make vdev init path generic for both virtual and pci devices

Currently, physical device pmds use a separate initalization path
(rte_pmd_init_all) while virtual devices use a constructor registration and
rte_eal_dev_init.  Theres no reason to have them be separate.  This patch
removes the vdev specific nomenclature from the vdev init path and makes it more
generic for use with all pmds.  This is the first step in converting the
physical device pmds to using the same constructor based registration path that
the virtual devices use.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoxenvirt: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:30 +0000 (10:59 -0400)]
xenvirt: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the xenvirt driver to use the PMD_REGISTER_DRIVER macro.
This means that the test applications now have no reference to the xenvirt library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

A few notes:

xenvirt was unbuildable as of commit 4c39baf297d10c217e7d3e7370f26a1fede58308..
That commit neglected to include the rte_vdev.h header, so several structs were
left undefined.  This patch includes a fix for that as well.

Also, The linkage for xenvirt is broken in much the same way pmd_ring was, in
that the xenvirt pmd has a function that is called directly from applications
(the example being the testpmd application).  The function is
rte_mempool_gntalloc_create, and should clearly be moved into the rte_mempool
library, with the supporting code in the function implementation moved to a new
xenvirt library separate from the pmd.  This is a large undertaking that
detracts from the purpose of this series however, and so for now, I'm leaving
the linkage to the application in place, and will address this issue in a later
series

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoring: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:29 +0000 (10:59 -0400)]
ring: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the ring driver to use the PMD_REGISTER_DRIVER macro and fix up the
Makefile so that its linkage is only done if we are building static libraries.
This means that the test applications now have no reference to the ring library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Note that the ring driver was also written in such a way that it violated some
general layering principles, several functions were contained in the pmd which
were being called by example from the test application in the app/test
directory.  Specifically it was calling eth_ring_pair_attach,
eth_ring_pair_create and rte_eth_ring_devinit, which should only be called
internally to the dpdk core library.  To correct this I've removed those
functions, and instead allowed them to be called indirectly at initalization
time using the vdev command line argument key nodeaction=<name>:<node>:<action>
where action is one of ATTACH or CREATE.  I've tested out the functionality of
the command line with the testpmd utility, with success, and have removed the
called functions from the test utility.  This will affect how the test utility
is invoked (the -d and --vdev option will need to be specified on the command
line now), but honestly, given the way it was coded, I think the testing of the
ring pmd was not the best example of how to code with dpdk to begin with.  I
have also left the two layer violating functions in place, so as not to break
existing applications, but added deprecation warnings to them so that apps can
migrate off them.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopcap: convert to use of PMD_REGISTER_DRIVER and fix linking
Neil Horman [Mon, 21 Apr 2014 14:59:28 +0000 (10:59 -0400)]
pcap: convert to use of PMD_REGISTER_DRIVER and fix linking

Convert the pcap driver to use the PMD_REGISTER_DRIVER macro and fix up the
Makefile so that its linkage is only done if we are building static libraries.
This means that the test applications now have no reference to the pcap library
when building DSO's and must specify its use on the command line with the -d
option.  Static linking will still initalize the driver automatically.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: add PMD_REGISTER_DRIVER macro
Neil Horman [Mon, 21 Apr 2014 14:59:27 +0000 (10:59 -0400)]
eal: add PMD_REGISTER_DRIVER macro

Rather than have each driver have to remember to add a constructor to it to make
sure its gets registered properly, wrap that process up in a macro to make
registration a one line affair.  This also sets the stage for us to make
registration of vdev pmds and physical pmds a uniform process

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoivshmem: fix build
Olivier Matz [Mon, 19 May 2014 12:36:37 +0000 (14:36 +0200)]
ivshmem: fix build

Fix compilation error introduced by:
e5ac7c2ff367edd eal: don't inline string functions

The stdio.h include is missing due to its removing from rte_string_fns.h.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomempool: add iterator function
Stephen Hemminger [Fri, 2 May 2014 23:42:54 +0000 (16:42 -0700)]
mempool: add iterator function

Add function to iterate over mempool.
Useful for diagnostic code that wants to look at mempool usage patterns.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agomemzone: add iterator function
Stephen Hemminger [Fri, 2 May 2014 23:42:55 +0000 (16:42 -0700)]
memzone: add iterator function

When doing diagnostic function, it is useful to have a ability
to iterate over all memzones.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agoeal: don't inline string functions
Stephen Hemminger [Fri, 2 May 2014 23:42:53 +0000 (16:42 -0700)]
eal: don't inline string functions

It makes no sense to inline string functions, in fact snprintf
can't be inlined because the function supports variable number of
arguments.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
[Thomas: update includes]
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agoadd FILE argument to debug functions
Stephen Hemminger [Fri, 2 May 2014 23:42:56 +0000 (16:42 -0700)]
add FILE argument to debug functions

The DPDK dump functions are useful for remote debugging of an
applications. But when application runs as a daemon, stdout
is typically routed to /dev/null.

Instead change all these functions to take a stdio FILE * handle
instead. An application can then use open_memstream() to capture
the output.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
[Thomas: fix quota_watermark example]
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agospelling fixes
Stephen Hemminger [Fri, 2 May 2014 23:42:52 +0000 (16:42 -0700)]
spelling fixes

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agomk: add "make examples" target in root makefile
Olivier Matz [Fri, 16 May 2014 08:19:01 +0000 (10:19 +0200)]
mk: add "make examples" target in root makefile

It is now possible to build all projects from the examples/ directory
using one command from root directory.

Some illustration of what is possible:

- build examples in the DPDK tree for one target

  # install the x86_64-default-linuxapp-gcc in
  # ${RTE_SDK}/x86_64-default-linuxapp-gcc directory
  user@droids:~/dpdk.org$ make install T=x86_64-default-linuxapp-gcc
  # build examples for this new installation in
  # ${RTE_SDK}/examples directory
  user@droids:~/dpdk.org$ make examples T=x86_64-default-linuxapp-gcc

- build examples outside DPDK tree for several targets

  # install all targets matching x86_64-*-linuxapp-gcc in
  # ${RTE_SDK}/x86_64-*-linuxapp-gcc directories
  user@droids:~/dpdk.org$ make install T=x86_64-*-linuxapp-gcc
  # build examples for these installations in /tmp/foobar
  user@droids:~/dpdk.org$ make examples T=x86_64-*-linuxapp-gcc O=/tmp/foobar

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoexamples/netmap_compat: fix makefile
Olivier Matz [Fri, 16 May 2014 08:19:00 +0000 (10:19 +0200)]
examples/netmap_compat: fix makefile

It is not allowed to reference a an absolute file name in SRCS-y.
A VPATH has to be used, else the dependencies won't be checked
properly.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoexamples/qos_sched: fix makefile
Olivier Matz [Fri, 16 May 2014 08:18:59 +0000 (10:18 +0200)]
examples/qos_sched: fix makefile

The example does not compile as the linker complains about duplicated
symbols.

Remove -lsched from LDLIBS, it is already present in rte.app.mk and
added by the DPDK framework automatically.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoexamples: add a makefile to build all examples
Olivier Matz [Fri, 16 May 2014 08:18:58 +0000 (10:18 +0200)]
examples: add a makefile to build all examples

It is now possible to build all examples by doing the following:

  user@droids:~/dpdk.org$ cd examples
  user@droids:~/dpdk.org/examples$ make RTE_SDK=${PWD}/.. \
      RTE_TARGET=x86_64-default-linuxapp-gcc

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoexamples: use rte.extsubdir.mk to build examples with subdirectories
Olivier Matz [Fri, 16 May 2014 08:18:57 +0000 (10:18 +0200)]
examples: use rte.extsubdir.mk to build examples with subdirectories

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: introduce rte.extsubdir.mk for projects with subdirectories
Olivier Matz [Fri, 16 May 2014 08:18:56 +0000 (10:18 +0200)]
mk: introduce rte.extsubdir.mk for projects with subdirectories

This makefile can be included by a project that needs to build several
applications or libraries that are located in different directories.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: add missing scripts directory in install directory
David Marchand [Fri, 9 May 2014 13:31:01 +0000 (15:31 +0200)]
mk: add missing scripts directory in install directory

Trying to install headers for an external library using DPDK exported makefile
rte.extshared.mk results in following error :

$ cd dpdk
$ make install DESTDIR=/home/marchand/myapp/staging/plop T=x86_64-default-linuxapp-gcc
$ cd ~/myapp
$ make RTE_SDK=/home/marchand/myapp/staging/plop RTE_TARGET=x86_64-default-linuxapp-gcc
  CC plop.o
  LD plop.so
  SYMLINK-FILE include/plop.h
/bin/sh:
/home/marchand/myapp/staging/plop/scripts/relpath.sh: No such file or directory
ln: `/home/marchand/myapp/build/include' and `./include' are the same file
make[1]: *** [/home/marchand/myapp/build/include/plop.h] Error 1
make: *** [all] Error 2

This comes from the fact that DPDK only installs its mk/ directory while some
makefiles require the scripts/ directory content as well.

So install missing files from scripts/.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: add --disable-link-check option
David Marchand [Wed, 30 Apr 2014 13:30:02 +0000 (15:30 +0200)]
app/testpmd: add --disable-link-check option

When starting/stopping ports, a link status check on all available ports is
done. This can be annoying when cables are not plugged at the time.
Default behavior is untouched.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: show mac address at initialization
Zijie Pan [Wed, 30 Apr 2014 13:29:48 +0000 (15:29 +0200)]
app/testpmd: show mac address at initialization

Display port number and MAC address at start up.
It is useful when configuring a packet generator.

Signed-off-by: Zijie Pan <zijie.pan@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: add engine that replies to ARP and ICMP echo requests
Ivan Boule [Wed, 30 Apr 2014 13:30:11 +0000 (15:30 +0200)]
app/testpmd: add engine that replies to ARP and ICMP echo requests

Add a new specific packet processing engine in the "testpmd" application that
only replies to ARP requests and to ICMP echo requests.
For this purpose, a new "icmpecho" forwarding mode is provided that can be
dynamically selected with the following testpmd command:

    set fwd icmpecho

before starting the receipt of packets on the selected ports.

Then, the "icmpecho" engine performs the following actions on all received
packets:

- replies to a received ARP request by sending back on the RX port a ARP
  reply with a "sender hardware address" field containing the MAC address
  of the RX port,

- replies to a ICMP echo request by sending back on the RX port a ICMP echo
  reply, swapping the IP source and the IP destination address in the IP
  header,

- otherwise, simply drops the received packet.

When replying to a received packet that was encapsulated into a VLAN tunnel,
the reply is sent back with the same VLAN identifier.
By default, the testpmd configures VLAN header stripping RX option on each
port.
This option is not managed by the icmpecho engine which won't detect
packets that were encapsulated into a VLAN.
To address this issue, the VLAN header stripping option must be previously
switched off with the following testpmd command:

    vlan set strip off

When the "verbose" mode has been set with the testpmd command
"set verbose 1", the "icmpecho" engine displays informations about each
received packet.

The "icmpecho" forwarding engine can also be used to simply check port
connectivity at the hardware level (check that cables are well-plugged)
and at the software level (receipt of VLAN packets, for instance).

Signed-off-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: allow txpkts to be setup via command line
Cyril Chemparathy [Thu, 3 Apr 2014 17:30:14 +0000 (10:30 -0700)]
app/testpmd: allow txpkts to be setup via command line

We allow a new --txpkts command-line parameter to configure segment sizes when
in txonly or flowgen forwarding modes.

Signed-off-by: Cyril Chemparathy <cchemparathy@tilera.com>
[Thomas: add usage help]
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: add flowgen forwarding engine
Cyril Chemparathy [Thu, 3 Apr 2014 17:30:16 +0000 (10:30 -0700)]
app/testpmd: add flowgen forwarding engine

This commit adds a multi-flow traffic generator forwarding engine.  In effect,
this forwarding mode functions very similar to the txonly mode, with the
difference that it generates multiple L4 flows.

Signed-off-by: Cyril Chemparathy <cchemparathy@tilera.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: add macswap forwarding engine
Cyril Chemparathy [Thu, 3 Apr 2014 17:30:15 +0000 (10:30 -0700)]
app/testpmd: add macswap forwarding engine

This commit adds a new forwarding mode, in which the source and destination
MAC addresses of packets are swapped before forwarding according to the
port-topology in effect.  This has been designed for operation primarily with
--port-topology=loopback.

Signed-off-by: Cyril Chemparathy <cchemparathy@tilera.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: list forwarding engines
Thomas Monjalon [Wed, 14 May 2014 15:24:41 +0000 (17:24 +0200)]
app/testpmd: list forwarding engines

Having a function to list forwarding engines helps to show them
in cli help and in parameters usage witout duplicating code.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
10 years agoapp/testpmd: allow command line selection of forwarding engine
Cyril Chemparathy [Thu, 3 Apr 2014 17:30:13 +0000 (10:30 -0700)]
app/testpmd: allow command line selection of forwarding engine

This commit allows testpmd forwarding mode selection through command line
parameters instead of having to set this up in interactive mode.

Signed-off-by: Cyril Chemparathy <cchemparathy@tilera.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: add auto-start option in interactive mode
Cyril Chemparathy [Thu, 3 Apr 2014 17:30:12 +0000 (10:30 -0700)]
app/testpmd: add auto-start option in interactive mode

This patch adds support for a command-line argument --auto-start (-a).  When
running in interactive mode, this allows us to start traffic without user
intervention before dropping to the prompt.

Signed-off-by: Cyril Chemparathy <cchemparathy@tilera.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: add loopback topology
Cyril Chemparathy [Thu, 3 Apr 2014 17:30:11 +0000 (10:30 -0700)]
app/testpmd: add loopback topology

This commits adds a new "loop" option to the --port-topology argument.  With
the loop option specified, ingress traffic is simply transmitted back on the
same interface.

Signed-off-by: Cyril Chemparathy <cchemparathy@tilera.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: fix incompatible sign for printf arguments
Julien Cretin [Mon, 12 May 2014 15:35:11 +0000 (17:35 +0200)]
app/testpmd: fix incompatible sign for printf arguments

The socket_id member of struct rte_port is an unsigned int while the d
conversion specifier of printf expects an int.

The addr_bytes member of struct ether_addr is an array of uint8_t
while the X conversion specifier of printf expects an unsigned int.
Values of type uint8_t are promoted to type int when used in the
ellipsis notation of a function.

These minor bugs were found using TrustInSoft Analyzer.

Signed-off-by: Julien Cretin <julien.cretin@trust-in-soft.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: fix minor signed overflow in a constant
Julien Cretin [Mon, 12 May 2014 15:35:09 +0000 (17:35 +0200)]
app/testpmd: fix minor signed overflow in a constant

The expression (192 << 24) has an undefined behavior since:
- the integer constant 192 has type int, and
- 192 x 2^24 is not representable as an int.

Suffixing 192 with U defines a behavior since:
- the integer constant 192U has type unsigned int, and
- the value of (192U << 24) is defined as
  (192 x 2^24) % (UINT_MAX + 1)

This minor bug was found using TrustInSoft Analyzer.

Signed-off-by: Julien Cretin <julien.cretin@trust-in-soft.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomem: remove redundant check in optimize_object_size
Julien Cretin [Mon, 12 May 2014 15:35:10 +0000 (17:35 +0200)]
mem: remove redundant check in optimize_object_size

The second condition of this logical OR:
    (get_gcd(new_obj_size, nrank * nchan) != 1 ||
    get_gcd(nchan, new_obj_size) != 1)
is redundant with the first condition.

We can show that the first condition is equivalent to its disjunction
with the second condition using these two results:

- R1: For all conditions A and B, if B implies A, then (A || B) is
  equivalent to A.

- R2: (get_gcd(nchan, new_obj_size) != 1) implies
  (get_gcd(new_obj_size, nrank * nchan) != 1)

We can show R1 with the following truth table (0 is false, 1 is true):
        +-----+-----++----------+-----+-------------+
        |  A  |  B  || (A || B) |  A  | B implies A |
        +-----+-----++----------+-----+-------------+
        |  0  |  0  ||     0    |  0  |      1      |
        |  0  |  1  ||     1    |  0  |      0      |
        |  1  |  0  ||     1    |  1  |      1      |
        |  1  |  1  ||     1    |  1  |      1      |
        +-----+-----++----------+-----+-------------+
                Truth table of (A || B) and A

We can show R2 by looking at the code of optimize_object_size and
get_gcd.

We see that:
- S1: (nchan >= 1) and (nrank >= 1).
- S2: get_gcd returns 0 only when both arguments are 0.

Let:
- X be get_gcd(new_obj_size, nrank * nchan).
- Y be get_gcd(nchan, new_obj_size).

Suppose:
- H1: get_gcd returns the greatest common divisor of its arguments.
- H2: (nrank * nchan) does not exceed UINT_MAX.

We prove (Y != 1) implies (X != 1) with the following steps:
- Suppose L0: (Y != 1). We have to show (X != 1).
- By H1, Y is the greatest common divisor of nchan and new_obj_size.
  In particular, we have L1: Y divides nchan and new_obj_size.
- By H2, we have L2: nchan divides (nrank * nchan)
- By L1 and L2, we have L3: Y divides (nrank * nchan) and
  new_obj_size.
- By H1 and L3, we have L4: (Y <= X).
- By S1 and S2, we have L5: (Y != 0).
- By L0 and L5, we have L6: (Y > 1).
- By L4 and L6, we have (X > 1) and thus (X != 1), which concludes.

R2 was also tested for all values of new_obj_size, nrank, and nchan
between 0 and 2000.

This redundant condition was found using TrustInSoft Analyzer.

Signed-off-by: Julien Cretin <julien.cretin@trust-in-soft.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomem: change default per socket memory allocation
Didier Pallard [Fri, 9 May 2014 13:30:42 +0000 (15:30 +0200)]
mem: change default per socket memory allocation

Currently, if there is more memory in hugepages than the amount
requested by dpdk application, the memory is allocated by taking as much
memory as possible from each socket, starting from first one.
For example if a system is configured with 8 GB in 2 sockets (4 GB per
socket), and dpdk is requesting only 4GB of memory, all memory will be
taken in socket 0 (that have exactly 4GB of free hugepages) even if some
cores are configured on socket 1, and there are free hugepages on socket
1...

Change this behaviour to allocate memory on all sockets where some cores
are configured, spreading the memory amongst sockets using following
ratio per socket:
N° of cores configured on the socket / Total number of configured cores
* requested memory
If this new algorithm fails, it defaults to previous behaviour.

This algorithm is used when memory amount is specified globally using
-m option. Per socket memory allocation can always be done using
--socket-mem option.

It is implemented only for Linux as BSD part looks not to be ready for NUMA.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Venky Venkatesan <venky.venkatesan@intel.com>
10 years agoring: allow to initialize without memzone
Olivier Matz [Fri, 9 May 2014 10:14:53 +0000 (12:14 +0200)]
ring: allow to initialize without memzone

Allow to initialize a ring in an already allocated memory. The rte_ring_create()
function that allocates a ring in a rte_memzone is still available and now uses
the new rte_ring_init() function in order to factorize the code.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
10 years agoring: get size in memory
Olivier Matz [Fri, 9 May 2014 10:14:52 +0000 (12:14 +0200)]
ring: get size in memory

Add a function that returns the amount of memory occupied by a rte_ring
structure and its object table. This commit prepares the next one that
will allow to allocate a ring dynamically.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
10 years agopci: remove deprecated RTE_EAL_UNBIND_PORTS option
David Marchand [Fri, 9 May 2014 13:15:59 +0000 (15:15 +0200)]
pci: remove deprecated RTE_EAL_UNBIND_PORTS option

RTE_EAL_UNBIND_PORTS was deprecated in DPDK 1.4.0 and removed in 1.6.0, but the
code was not removed.

The bind/unbind operations should not be handled by the eal.
These operations should be either done outside of dpdk or inside the PMDs
themselves as these are their problems.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agopci: move RTE_PCI_DRV_FORCE_UNBIND handling out of #ifdef
David Marchand [Fri, 9 May 2014 13:15:58 +0000 (15:15 +0200)]
pci: move RTE_PCI_DRV_FORCE_UNBIND handling out of #ifdef

Move RTE_PCI_DRV_FORCE_UNBIND flag handling out of RTE_EAL_UNBIND_PORTS section.
This had nothing to do with RTE_EAL_UNBIND_PORTS anyway.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agopci: pci_switch_module cleanup
David Marchand [Fri, 9 May 2014 13:15:57 +0000 (15:15 +0200)]
pci: pci_switch_module cleanup

The pci_switch_module() function should only do what its name tells: unbind pci
devices and rebind them on the specified kernel driver.
Hence, it can not call pci_uio_map_resource().

Call to pci_uio_map_resource() should be moved to rte_eal_pci_probe_one_driver()
so that we can factorize code.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agopci: rework interrupt fd init and fix fd leak
David Marchand [Fri, 9 May 2014 13:15:56 +0000 (15:15 +0200)]
pci: rework interrupt fd init and fix fd leak

A fd leak happens in pci_map_resource when multiple bars are mapped.
Fix this by closing fd unconditionnally in this function and open the
intr_handle fd in pci_uio_map_resource instead.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agopci: remove virtio-uio workaround
David Marchand [Fri, 9 May 2014 13:15:55 +0000 (15:15 +0200)]
pci: remove virtio-uio workaround

virtio-uio does not need eal to map bars from uio device, so remove flag
RTE_PCI_DRV_NEED_IGB_UIO.
Then, move virtio-uio workaround out of generic eal_pci.c for linux
implementation.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agopci: align bsd implementation on linux
David Marchand [Fri, 9 May 2014 13:15:54 +0000 (15:15 +0200)]
pci: align bsd implementation on linux

bsd implementation lacks check on driver flags, fix this.
Besides, check on BAR0 is not needed and could cause trouble for devices that
have no BAR0.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agopci: fix potential mem leaks
David Marchand [Fri, 9 May 2014 13:15:53 +0000 (15:15 +0200)]
pci: fix potential mem leaks

Looking at bsd implementation, we can see that there are some potential mem
leaks in linux implementation. Fix them.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agomem: take reserved hugepages into account
Burakov, Anatoly [Wed, 16 Apr 2014 11:11:12 +0000 (11:11 +0000)]
mem: take reserved hugepages into account

Some applications reserve hugepages for later use,
but DPDK doesn't take reserved pages into account
when calculating number of available number of hugepages.

This patch adds reading from "resv_hugepages" file
in addition to "free_hugepages".

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoversion: 1.7.0-rc0
Thomas Monjalon [Fri, 9 May 2014 17:18:02 +0000 (19:18 +0200)]
version: 1.7.0-rc0

Start development cycle for version 1.7.0.

This new development workflow introduces a new versioning scheme.
Instead of having releases r0, r1, r2, etc, there will be release
candidates. Last number has special meanings:
< 16 numbers are reserved for release candidates (RTE_VER_SUFFIX is -rc)
16 is reserved for the release (RTE_VER_SUFFIX must be unset)
> 16 numbers can be used locally (RTE_VER_SUFFIX must be set)

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
10 years agoeal: print maximum and detected lcores
Wang Sheng-Hui [Mon, 14 Apr 2014 05:37:04 +0000 (13:37 +0800)]
eal: print maximum and detected lcores

Print the maximum lcore(s) as configured, and the number of lcore(s) detected
on eal cpu init as debug info besides the not separate detected/not-detected
lcore info.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
[Thomas: add BSD part]
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: remove useless output of undetected lcores
Didier Pallard [Wed, 30 Apr 2014 14:14:53 +0000 (16:14 +0200)]
eal: remove useless output of undetected lcores

Increasing maximum number of lcores gives a huge place to undetected
lcores in output traces. Moreover, this output does not give any
interesting information, since list of undetected lcores can be deduced
from list of detected ones.
So remove output related to undetected cores.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: remove unused config fields
David Marchand [Fri, 18 Apr 2014 12:58:08 +0000 (14:58 +0200)]
eal: remove unused config fields

There is no need for a 'magic' field in struct rte_config, as this part of the
structure is local to each process. All threads of a process are synchronised
because of the run_once atomic.
So remove this field, as it is only adding confusion when reading code that
references 'magic' field from struct rte_mem_config.

Besides, there is no reference about the 'version' field, so remove it as well.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agomk: sort config templates listing
Thomas Monjalon [Fri, 2 May 2014 13:28:02 +0000 (15:28 +0200)]
mk: sort config templates listing

The config templates can be seen with "make showconfigs", "make config" or
"make help". It's easier to read if it's sorted.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
10 years agoversion: 1.6.0r2
Thomas Monjalon [Wed, 30 Apr 2014 11:21:17 +0000 (13:21 +0200)]
version: 1.6.0r2

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agopkg: add recipe for RPM
Thomas Monjalon [Thu, 26 Sep 2013 16:22:16 +0000 (18:22 +0200)]
pkg: add recipe for RPM

Packages can be built with:
RPM_BUILD_NCPUS=8 rpmbuild -ta dpdk-1.6.0r1.tar.gz

There are packages for runtime and development.
Once devel package is installed, it can be used like this:
make -C /usr/share/dpdk/examples/helloworld RTE_SDK=/usr/share/dpdk

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agomk: fix build ignoring other installed versions
Thomas Monjalon [Tue, 29 Apr 2014 07:57:38 +0000 (09:57 +0200)]
mk: fix build ignoring other installed versions

If some DPDK libraries are installed on the system, the linker was trying
to use them before searching in -L path.
The obscure reason is that we were prefixing -L with -Wl, to pass it
directly to the linker.
But -L is also a gcc option. And allowing gcc to process this option fixes
the issue.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agoeal: fix usage description for bsd
Thomas Monjalon [Wed, 30 Apr 2014 15:05:45 +0000 (17:05 +0200)]
eal: fix usage description for bsd

A line was forgotten when removing blacklist option in commit
"use devargs for vdev and PCI lists with bsd" (cd25fb0863).

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoeal: fix vdev allocation on non-0 numa socket
Maxime Leroy [Wed, 30 Apr 2014 13:15:08 +0000 (15:15 +0200)]
eal: fix vdev allocation on non-0 numa socket

vdev ethdev can not be allocated on a numa socket that is not socket 0.
The reason comes from rte_eth_dev_allocate() which uses rte_socket_id() to
identify the socket on which vdev driver data should be allocated.
However, at this initialization step, rte_socket_id() always returns 0.

Looking at rte_socket_id(), it needs rte_lcore_id() which uses the per-core
global _lcore_id variable. This variable is initialised by
eal_thread_init_master.

So eal_thread_init_master should be called before rte_eal_vdev_init().

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: fix crash of tx_first mode with numa
Adrien Mazarguil [Wed, 30 Apr 2014 13:16:16 +0000 (15:16 +0200)]
app/testpmd: fix crash of tx_first mode with numa

When NUMA is enabled, the mbuf pool pointer of per-core fwd_lcores structure
is not set, causing a crash when accessing to mbp for txonly burst.

Initialize fwd_lcore after allocating NUMA memory pools.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agoapp/testpmd: check socket id validity
Liu Xiaofeng [Tue, 15 Apr 2014 13:51:39 +0000 (15:51 +0200)]
app/testpmd: check socket id validity

Now socket id is from device's numa_node, if it is invalid, just set it to 0
as default to avoid crash which will be caused by the reference to
port_per_socket[socket_id].

Also one warning is displayed to user that port-numa-config and
ring-numa-config parameters should be used along with --numa for NUMA mode.

A check for NUMA_NO_CONFIG was also missing from init_fwd_stream().

Signed-off-by: Liu Xiaofeng <xiaofeng.liu@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomalloc: simplify heap initialisation
David Marchand [Fri, 18 Apr 2014 12:56:18 +0000 (14:56 +0200)]
malloc: simplify heap initialisation

There should be no real need for this initialised field as the whole structure
is set to 0 in rte_config_init() by primary process, and secondary processes
wait for this to happen before anything else (looking at mem_config magic).

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agomalloc: fix race condition on numa_socket field
David Marchand [Fri, 18 Apr 2014 12:56:17 +0000 (14:56 +0200)]
malloc: fix race condition on numa_socket field

We don't really need this field as it is only used when creating the memzone
object associated to this heap.
Removing numa_socket field makes things simpler and remove race condition.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agokni: fix build with debian kernel 3.2.57-2
David Marchand [Tue, 29 Apr 2014 14:16:03 +0000 (16:16 +0200)]
kni: fix build with debian kernel 3.2.57-2

Following debian kernel headers upgrade to 3.2.57, pci capability accessors
have been backported (upstream commit 8c0d3a02c1309eb6112d2e7c8172e8ceb26ecfca,
("PCI: Add accessors for PCI Express Capability", v3.7-rc1)).

It results in the same compilation error as redhat 6.x.
However, there is no clear way to determine we are building on a debian kernel.
So, rather than determine if we are building on a distribution kernel, look at
PCI_EXP_LNKSTA2 that appeared in this upstream commit.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agonic_uio: fix build with freebsd 10
Olivier Matz [Fri, 25 Apr 2014 11:59:45 +0000 (13:59 +0200)]
nic_uio: fix build with freebsd 10

Compiling the DPDK under FreeBSD gives the following error due to a
missing include <sys/rwlock.h>.

In file included from nic_uio.c:52:
@/vm/vm_pager.h:126:2: error: implicit declaration of function 'rw_assert' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
        VM_OBJECT_ASSERT_WLOCKED(object);
        ^
@/vm/vm_object.h:226:2: note: expanded from macro 'VM_OBJECT_ASSERT_WLOCKED'
        rw_assert(&(object)->lock, RA_WLOCKED)
        ^
In file included from nic_uio.c:52:
@/vm/vm_pager.h:126:2: error: use of undeclared identifier 'RA_WLOCKED'
@/vm/vm_object.h:226:29: note: expanded from macro 'VM_OBJECT_ASSERT_WLOCKED'
        rw_assert(&(object)->lock, RA_WLOCKED)
                                   ^
In file included from nic_uio.c:52:
@/vm/vm_pager.h:143:2: error: use of undeclared identifier 'RA_WLOCKED'
        VM_OBJECT_ASSERT_WLOCKED(object);
        ^
@/vm/vm_object.h:226:29: note: expanded from macro 'VM_OBJECT_ASSERT_WLOCKED'
        rw_assert(&(object)->lock, RA_WLOCKED)
                                   ^
In file included from nic_uio.c:52:
@/vm/vm_pager.h:167:2: error: use of undeclared identifier 'RA_WLOCKED'
        VM_OBJECT_ASSERT_WLOCKED(object);
        ^
@/vm/vm_object.h:226:29: note: expanded from macro 'VM_OBJECT_ASSERT_WLOCKED'
        rw_assert(&(object)->lock, RA_WLOCKED)
                                   ^
In file included from nic_uio.c:52:
@/vm/vm_pager.h:190:2: error: use of undeclared identifier 'RA_WLOCKED'
        VM_OBJECT_ASSERT_WLOCKED(m->object);
        ^
@/vm/vm_object.h:226:29: note: expanded from macro 'VM_OBJECT_ASSERT_WLOCKED'
        rw_assert(&(object)->lock, RA_WLOCKED)
                                   ^

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agodevargs: allow to provide arguments per pci device for bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:44 +0000 (13:59 +0200)]
devargs: allow to provide arguments per pci device for bsd

The bsdapp part was missing in commit 8e245de6ca7e050e282cd49ffd5e68a5b6ff62f5.

Add the ability to pass some specific initialization arguments to PCI
devices at start-up.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agodevargs: replace --use-device option by --pci-whitelist and --vdev for bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:43 +0000 (13:59 +0200)]
devargs: replace --use-device option by --pci-whitelist and --vdev for bsd

The bsdapp part was missing in commit cac6d08c8bde2fdb57806c49038187cdb54219a8.

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

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agodevargs: use a comma to separate key/values for bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:42 +0000 (13:59 +0200)]
devargs: use a comma to separate key/values for bsd

The bsdapp part was missing in commit a8b97e3a1db0a9366d58811411b904e4fef8160f.

This commit changes the API of --use-device command line argument.
It changes the separators from ';' to ','.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agodevargs: use devargs for vdev and PCI lists with bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:41 +0000 (13:59 +0200)]
devargs: use devargs for vdev and PCI lists with bsd

The bsdapp part was missing in commit 12204589517e06230e24e0f23396222f2929bd77.

This patch removes old whitelist code and use the newly introduced
rte_devargs to get the PCI white list, the PCI black list and the list
of virtual devices.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agodevargs: build common functions for bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:40 +0000 (13:59 +0200)]
devargs: build common functions for bsd

The bsd part was missing in commit bf6dea0e04afc0d1f2c8056cd4d1aecab12502d1.

This commit introduces a new API for storing device arguments given by
the user. It only adds the framework and the test.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agopci: rename device and driver lists for bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:39 +0000 (13:59 +0200)]
pci: rename device and driver lists for bsd

The bsdapp part was missing in commit 5b1f4a67dd5bcfa8d5139c064ced6e37a9149419.

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: Neil Horman <nhorman@tuxdriver.com>
10 years agomem: get dummy physical address in case of --no-huge with bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:48 +0000 (13:59 +0200)]
mem: get dummy physical address in case of --no-huge with bsd

The bsdapp part was missing in commit 57c24af85d9eaa81549a212169605b4e2468a29f.

This commit adds a dummy rte_mem_virt2phy() to fix the compilation of
DPDK under BSD. This function is only used when the debug option
"--no-huge" is given, to get the physical address of mempools in memory.

As a result, it seems acceptable for now to implement a dummy function
to fix the compilation as the usual case (using contigmem module) works
properly.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agomem: get hugepages config for bsd
Olivier Matz [Fri, 25 Apr 2014 11:59:47 +0000 (13:59 +0200)]
mem: get hugepages config for bsd

The bsdapp part was missing in c5e9eeca5a67a8272f0fdedcd0afc9b2d22be376.

This commit allows external libraries and applications to know if
hugepages are enabled.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
10 years agomk: use the Q variable instead of @ for bsd module
Olivier Matz [Fri, 25 Apr 2014 11:59:46 +0000 (13:59 +0200)]
mk: use the Q variable instead of @ for bsd module

This allows to use V=1 to be more verbose to debug the build process
of a bsd kernel module.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
10 years agomk: fix -share option error
Neil Horman [Wed, 16 Apr 2014 13:51:44 +0000 (09:51 -0400)]
mk: fix -share option error

The shared libraries built with the current makefile set produce static
libraries rather than actual shared objects.  This is due to several missing
options that are required to correctly build shared objects using ld, as well as
a mis-specified -share option (which should be -shared). Switching to the use of
CC rather than LD and fixing the -shared option corrects these problems and
builds the DSOs correctly.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
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>