Commit Graph

99 Commits

Author SHA1 Message Date
Olivier Matz
f82f705b63 lpm: fix allocation of an existing object
Change rte_lpm*_create() functions to return NULL and set rte_errno to
EEXIST when the object name already exists. This is the behavior
described in the API documentation in the header file.

These functions were returning a pointer to the existing object in that
case, but it is a problem as the caller did not know if the object had
to be freed or not.

Doing this change also makes the lpm API more consistent with the other
APIs (mempool, rings, ...).

Fixes: 916e4f4f4e ("memory: fix for multi process support")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2016-04-06 17:30:06 +02:00
Michael Qiu
e13676bfe7 lpm: fix build of anonymous union initialization
In SUSE11-SP3 i686 platform, with gcc 4.5.1, there is a
compile issue:
	rte_lpm.c: In function ‘add_depth_small_v20’:
	rte_lpm.c:778:7: error: unknown field ‘next_hop’
		specified in initializer

The root cause is gcc only allow anonymous union initialized
according to the field it is defined. But next_hop is defined
in different field when in different platform(Endian).

One solution is add if define in the code to avoid this issue,
but there is a simple way, initialize it separately later.

Fixes: afc5c914a0 ("lpm: fix big endian support")

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
2016-03-31 21:31:55 +02:00
Christian Ehrhardt
768f0e4587 lpm6: fix use after free
In certain autotests lpm->max_rules turned out to be non initialized.
That was caused by a failing allocation for lpm->rules_tbl in rte_lpm6_create.
It then left the function via goto exit with lpm freed, but still a pointer
value being set.

In case of an allocation failure it resets lpm to NULL now, to avoid the
upper layers operate on that already freed memory.
Along that is also makes the RTE_LOG message of the failed allocation unique.

Fixes: 5c510e13a9 ("lpm: add IPv6 support")

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-22 17:55:16 +01:00
Christian Ehrhardt
732a5b5c53 lpm6: fix missing free
lpm6 autotests failed with the default alloc of 512M Memory.
While >=2500M was a workaround it became clear while debugging that it
had a leak.
One could see a lot of output like:
  LPM Test tests6[i]: FAIL
  LPM: LPM memory allocation failed

It turned out that in rte_lpm6_free
- lpm might not be freed if it didn't find a te (early return)
- lpm->rules_tbl was not freed ever

Fixes: 899d8bc9b3 ("lpm: make tailq fully local")

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-22 17:55:16 +01:00
Christian Ehrhardt
34c4b5846e lpm: fix use after free
There were further chances for a use after free by returning an already
freed pointer in rte_lpm_create for v20 and v1604.
Along that is also makes the RTE_LOG messages of the failed allocations
unique.

Fixes: f1f7261838 ("lpm: add a new config structure for IPv4")

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-22 17:55:16 +01:00
Christian Ehrhardt
d4c18f0a1d lpm: fix missing free
In rte_lpm_free lpm might not be freed if it didn't find a te (early return)

The two lpm interfaces rte_lpm_free_v20 and rte_lpm_free_v1604 had a leak.
rte_lpm_free_v20 might have missed to free rules_tbl
rte_lpm_free_v1604 due to an early exit might have missed to free
rules_tbl and lpm itself.

Fixes: 899d8bc9b3 ("lpm: make tailq fully local")

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-22 17:55:16 +01:00
Jerin Jacob
cbc2f1dccf lpm/arm: support NEON
Enabled CONFIG_RTE_LIBRTE_LPM, CONFIG_RTE_LIBRTE_TABLE,
CONFIG_RTE_LIBRTE_PIPELINE libraries for arm and arm64

TABLE, PIPELINE libraries were disabled due to LPM library dependency.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Jianbo Liu <jianbo.liu@linaro.org>
2016-03-11 15:56:07 +01:00
Jerin Jacob
15d8dfc05b lpm/x86: move SSE implementation to be architecture agnostic
-Used architecture agnostic xmm_t to represent 128 bit SIMD variable

-Introduced vect_* API abstraction in app/test to test rte_lpm_lookupx4
API in  architecture agnostic way

-Moved rte_lpm_lookupx4 SSE implementation to architecture specific
rte_lpm_sse.h file to accommodate new rte_lpm_lookupx4 implementation
for a different architecture.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
2016-03-11 15:50:11 +01:00
Michal Kobylinski
f1f7261838 lpm: add a new config structure for IPv4
A new rte_lpm_config structure is used so LPM library will allocate
exactly the amount of memory which is necessary to hold application’s
rules.

Signed-off-by: Michal Kobylinski <michalx.kobylinski@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
2016-03-09 23:05:05 +01:00
Michal Kobylinski
dc81ebbaca lpm: extend IPv4 next hop field
This patch extend next_hop field from 8-bits to 24-bits in LPM library
for IPv4.

Added versioning symbols to functions and updated
library and applications that have a dependency on LPM library.

Signed-off-by: Michal Kobylinski <michalx.kobylinski@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
2016-03-09 22:57:43 +01:00
Bruce Richardson
5ecdeba601 lpm: merge tbl24 and tbl8 structures
The tbl8 and tbl24 structures were essentially identical except for
slightly different names for one or two fields. Merge these two
structures into a single structure definition.

Two fields have been renamed as part of this change: the
"ext_entry" field in the tbl24 has been renamed to "valid_group" to match
the tbl8 value to make the merge easier, and the "tbl8_gindex" field has
been renamed to "group_idx". The "valid_group" field now serves two
purposes: in a tbl8 it indicates if the group, i.e. the tbl8, is valid,
and in a tbl24, it indicates if the "group_idx" is valid, i.e. whether
the value is a next_hop or a tbl8 index. [The name "group_idx" was used
to make this latter link between the fields clearer]

Suggested-by: Vladimir Medvedkin <medvedkinv@gmail.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-04 16:01:15 +01:00
Huawei Xie
693f715da4 remove extra parentheses in return statement
fix the error reported by checkpatch:
  "ERROR: return is not a function, parentheses are not required"

remove parentheses in return like:
  "return (logical expressions)"

remove parentheses in return a function like:
  "return (rte_mempool_lookup(...))"

Fixes: 6307b909b8 ("lib: remove extra parenthesis after return")

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
2016-02-10 15:47:50 +01:00
Na Na
3591a83607 lpm: fix incorrect reuse of already allocated tbl8
Fixes an initialization issue of 'valid_group' in the delete_depth_small().

When adding an entry to a tbl8, the .valid_group field should always be set,
so that future adds do not accidently find and use this table, thinking it is
currently invalid, i.e. unused, and thereby overwrite existing entries.

Signed-off-by: Na Na <nana.nn@alibaba-inc.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-11-04 01:18:22 +01:00
Na Na
5b720dc643 lpm: fix condition check in delete
Fixes an issue of check logic in delete_depth_small function.

For a tbl24 entry, the 'ext_entry' field indicates whether we need
to use tbl8_gindex to read the next_hop from a tbl8 entry, or whether
it can be read directly from this entry.

If a route is deleted, the prefix of previous route is used to override
the deleted route.

When checking the depth of the previous route the conditional checks
both the ext_entry and the depth, but the "else" leg fails to take
account that the condition could fail for one of two possible reasons,
leading to an incorrect flow when 'ext_entry == 0' is true,
but 'lpm->tbl24[i].depth > depth' is false.
The fix here is to add a condition check to the else leg so that it
only executes when ext_entry is set.

Signed-off-by: Na Na <nana.nn@alibaba-inc.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-11-04 01:13:11 +01:00
Thomas Monjalon
4d0a3f2a93 lpm: remove deprecated field
The library version is incremented.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
2015-09-03 19:22:48 +02:00
Zhe Tao
830118e7f3 lpm: fix depth small entry add
When adding a "depth small" entry, if its extended flag is not set and
its depth is smaller than the one in the tbl24, nothing should be done
otherwise will operate on the wrong memory area.

Signed-off-by: Zhe Tao <zhe.tao@intel.com>
Acked-by: Cunming Liang <cunming.liang@intel.com>
2015-08-03 13:50:00 +02:00
Sergio Gonzalez Monroy
2f9d47013e mem: move librte_malloc to eal/common
Move malloc inside eal and create a new section in MAINTAINERS file for
Memory Allocation in EAL.

Create a dummy malloc library to avoid breaking applications that have
librte_malloc in their DT_NEEDED entries.

This is the first step towards using malloc to allocate memory directly
from memsegs. Thus, memzones would allocate memory through malloc,
allowing to free memzones.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
2015-07-16 13:44:48 +02:00
Xuelin Shi
afc5c914a0 lpm: fix big endian support
This module uses type conversion between struct and int.
Also truncation and comparison is used with this int.
It is not safe for different endian arch.

Add ifdef for big endian struct to fix this issue.

Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-07-10 23:23:15 +02:00
Ferruh Yigit
6307b909b8 lib: remove extra parenthesis after return
Remove extra parenthesis from return statements.

Signed-off-by: Ferruh Yigit <ferruhy@gmail.com>
2015-06-23 23:31:15 +02:00
Stephen Hemminger
a43a55472f lib: fix whitespace
More places with trailing whitespace, and empty blank lines

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2015-06-12 11:10:10 +02:00
Konstantin Ananyev
1e496d6fdf eal/x86: move header file for vector instructions
lib/librte_eal/common/include/rte_common_vect.h ->
lib/librte_eal/common/include/arch/x86/rte_vect.h

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
2015-03-20 19:24:38 +01:00
David Marchand
a2348166ea tailq: move to dynamic tailq
Use dynamic tailq rather than static entries.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
2015-03-10 12:06:08 +01:00
David Marchand
ff708facfc tailq: remove unneeded inclusions
Only keep inclusion where really needed.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
2015-03-10 11:47:46 +01:00
Igor Ryzhov
e128e53879 lpm: fix overflow issue
LPM table overflow may occur if table is full and added rule has
the biggest depth that already have some rules.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-02-24 02:08:19 +01:00
Neil Horman
133b75923b mk: add library version extension
To differentiate libraries that break ABI, we add a library version number
suffix to the library, which must be incremented when a given libraries ABI is
broken.  This patch enforces that addition, sets the initial abi soname
extension to 1 for each library and creates a symlink to the base SONAME so that
the test applications will link properly.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
2015-02-03 16:56:58 +01:00
Neil Horman
9d41beed24 lib: provide initial versioning
Add linker version script files to each DPDK library to put a stake in the
ground from which we can start cleaning up API's

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
2015-02-03 16:56:58 +01:00
Konstantin Ananyev
da826b7135 eal: introduce ymm type for AVX 256-bit
New data type to manipulate 256 bit AVX values.
Rename field in the rte_xmm to keep common naming across SSE/AVX fields.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
2015-01-28 17:11:25 +01:00
Sergio Gonzalez Monroy
fdf20fa7be add prefix to cache line macros
CACHE_LINE_SIZE is a macro defined in machine/param.h in FreeBSD and
conflicts with DPDK macro version.
Adding RTE_ prefix to avoid conflicts.
CACHE_LINE_MASK and CACHE_LINE_ROUNDUP are also prefixed.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
[Thomas: updated on HEAD, including PPC]
2014-11-27 16:21:11 +01:00
Anatoly Burakov
899d8bc9b3 lpm: make tailq fully local
Since the data structures such as rings are shared in their entirety,
those TAILQ pointers are shared as well. Meaning that, after a
successful rte_ring creation, the tailq_next pointer of the last
ring in the TAILQ will be updated with a pointer to a ring which may
not be present in the address space of another process (i.e. a ring
that may be host-local or guest-local, and not shared over IVSHMEM).
Any successive ring create/lookup on the other side of IVSHMEM will
result in trying to dereference an invalid pointer.

This patchset fixes this problem by creating a default tailq entry
that may be used by any data structure that chooses to use TAILQs.
This default TAILQ entry will consist of a tailq_next/tailq_prev
pointers, and an opaque pointer to arbitrary data. All TAILQ
pointers from data structures themselves will be removed and
replaced by those generic TAILQ entries, thus fixing the problem
of potentially exposing local address space to shared structures.

Technically, only rte_ring structure require modification, because
IVSHMEM is only using memzones (which aren't in TAILQs) and rings,
but for consistency's sake other TAILQ-based data structures were
adapted as well.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
2014-07-22 19:42:23 +02:00
Stephen Hemminger
6f41fe75e2 eal: deprecate rte_snprintf
The function rte_snprintf serves no useful purpose. It is the
same as snprintf() for all valid inputs. Deprecate it and
replace all uses in current code.

Leave the tests for the deprecated function in place.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
2014-06-27 02:31:24 +02:00
Cristian Dumitrescu
212841e67c lpm: check rule existence
Added API function for LPM IPv4 and IPv6 to query for the existence
of a rule/route and return the next hop ID associated with the route
if route is present.
This is used by the Packet Framework LPM table for implementing a
routing table.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Acked-by: Pablo de Lara Guarch <pablo.de.lara.guarch@intel.com>
Acked by: Ivan Boule <ivan.boule@6wind.com>
2014-06-17 02:37:28 +02:00
Konstantin Ananyev
3440438c5d lpm: introduce rte_lpm_lookupx4
Allows to lookup four IP addresses in an LPM table.
Uses SSE instrincts.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Tested-by: Waterman Cao <waterman.cao@intel.com>
Acked-by: Pablo de Lara Guarch <pablo.de.lara.guarch@intel.com>
2014-06-12 12:11:39 +02:00
Bruce Richardson
3031749c2d remove trailing whitespaces
This commit removes trailing whitespace from lines in files. Almost all
files are affected, as the BSD license copyright header had trailing
whitespace on 4 lines in it [hence the number of files reporting 8 lines
changed in the diffstat].

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
[Thomas: remove spaces before tabs in libs]
[Thomas: remove more trailing spaces in non-C files]
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
2014-06-11 00:29:34 +02:00
Bruce Richardson
e9d48c0072 update Intel copyright years to 2014
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2014-02-25 21:29:14 +01:00
Intel
466e137457 lpm: fix sub-rule deletion
Restore group validation flag of the tbl8 entry
if sub-rule is replaced by an encompassing rule.

Signed-off-by: Intel
2014-01-15 16:37:43 +01:00
Intel
9cb80085a4 lpm: fix route adding
Signed-off-by: Intel
2013-11-21 10:12:01 +01:00
Intel
ef8ff191a4 lpm: rework rules storage
Signed-off-by: Intel
2013-10-09 16:04:09 +02:00
Intel
1c1d4d7a92 doc: whitespace changes in licenses
Signed-off-by: Intel
2013-10-09 14:51:55 +02:00
Intel
5c510e13a9 lpm: add IPv6 support
Signed-off-by: Intel
2013-09-17 14:09:21 +02:00
Intel
b6df9fc871 update copyright date to 2013
Signed-off-by: Intel
2013-07-25 16:07:52 +02:00
Zijie Pan
cddaf87a1e lib: fix unused values
Fix warnings of type "Value stored to 'xxx' is never read".

Signed-off-by: Zijie Pan <zijie.pan@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
2013-07-25 16:07:51 +02:00
Intel
916e4f4f4e memory: fix for multi process support
Signed-off-by: Intel
2013-07-25 15:23:27 +02:00
Intel
3569fcf1c4 lpm: rework lpm lookup + add bulk function
Signed-off-by: Intel
2013-07-25 15:23:27 +02:00
Intel
f9b4c4ed3f lpm: allocate memory on right numa socket
Signed-off-by: Intel
2013-07-25 15:23:27 +02:00
Intel
4cdf471a06 lpm: don't use memzone for allocations
Signed-off-by: Intel
2013-07-25 15:23:26 +02:00
Intel
a76109c628 lpm: minor changes
Signed-off-by: Intel
2013-07-25 15:23:26 +02:00
Intel
30a37273c1 lib: update tailq api
Signed-off-by: Intel
2013-07-25 15:01:57 +02:00
Intel
dada9ef6ed remove version in all files
Signed-off-by: Intel
2013-07-05 11:59:50 +02:00
Intel
af75078fec first public release
version 1.2.3

Signed-off-by: Intel
2013-03-11 17:19:20 +01:00