Commit Graph

83 Commits

Author SHA1 Message Date
Congwen Zhang
1459d335d0 lpm: remove recursively included header file
includes itself: rte_lpm.h -> rte_lpm_sse.h -> rte_lpm.h
includes itself: rte_lpm.h -> rte_lpm_neon.h -> rte_lpm.h

Signed-off-by: Congwen Zhang <zhang.congwen@zte.com.cn>
2019-01-28 01:47:23 +01:00
Alex Kiselev
e480688dce lpm6: add incremental update on delete
Rework the delete function and add additional
internal data structures to support incremental
LPM tree update rather than full tree rebuild.

Signed-off-by: Alex Kiselev <alex@therouter.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2018-09-19 17:11:37 +02:00
Alex Kiselev
86b3b21952 lpm6: store rules in hash table
Rework the lpm6 rule subsystem and replace
current rules algorithm complexity O(n)
with hashtables which allow dealing with
large (50k) rule sets.

Signed-off-by: Alex Kiselev <alex@therouter.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2018-09-19 17:11:17 +02:00
Pavan Nikhilesh
fc29c712dd lpm: fix allocation of an existing object
Fix rte_lpm_create_*() functions to return NULL and set rte_errno to
EEXIST when lpm object name already exists.
This is the behavior described in the API documentation in the header
file.

Fixes: 134975073a ("lib: remove unnecessary pointer cast")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Acked-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2018-02-01 00:35:06 +01:00
Bruce Richardson
579182f2b0 build: set compat lib as universal dependency
By making "compat" lib (which consists of a header only) a dependency of
the EAL, we make the header file available to all other libs, drivers and
apps, and thereby make it less work to do ABI versioning.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:59:00 +01:00
Bruce Richardson
6c9457c279 build: replace license text with SPDX tag
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:58:59 +01:00
Bruce Richardson
a4b3d0092c lpm: install vector header files with meson
The main rte_lpm.h header file also includes architecture specific headers,
depending on the architecture on which it is used. These also need to be
installed into the include directory as part of the "ninja install"
process. Thankfully, since the vector headers all have different names we
can just install all 3 of them in all cases, which avoids conflicts or
issues with multi-architecture installs, or the need to use
architecture-specific subdirectories.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:58:59 +01:00
Bruce Richardson
5b9656b157 lib: build with meson
Add non-EAL libraries to DPDK build. The compat lib is a special case,
along with the previously-added EAL, but all other libs can be build using
the same set of commands, where the individual meson.build files only need
to specify their dependencies, source files, header files and ABI versions.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Keith Wiles <keith.wiles@intel.com>
Acked-by: Luca Boccassi <luca.boccassi@gmail.com>
2018-01-30 17:49:16 +01:00
Adrien Mazarguil
0d440d081c lib: fix missing includes in exported headers
Many exported headers rely on definitions found in rte_config.h without
including it, as shown by the following command:

 grep -L '^#include <rte_config.h>' -- \
  $(grep -Rl \
    $(sed -n '/^#define \([^ ]\+\).*$/{s//\1/;H;};${x;s/\n//;s/\n/\\|/g;p;}' \
      build/include/rte_config.h) \
    -- build/include/)

We cannot assume external applications will include rte_config.h on their
own, neither directly nor through a -include parameter like DPDK does
internally.

This not only causes obvious compilation failures that can be reproduced
with check-includes.sh such as:

 [...]/rte_memory.h:88:43: error: ‘RTE_CACHE_LINE_SIZE’ was not declared in
     this scope
  #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE)
                                            ^

It also results in less visible issues, for instance rte_hash_crc.h relying
on RTE_ARCH_X86_64's presence to provide dedicated inline functions.

This patch partially reverts the commit below and adds missing include
lines to the remaining files.

Fixes: f1a7a5c5f4 ("remove include of generated config header")
Cc: stable@dpdk.org

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
2018-01-17 00:31:05 +01:00
Zhiyong Yang
134975073a lib: remove unnecessary pointer cast
void * pointer can be assigned to any data type pointer.
Unnecessary cast can be removed in order to keep code clearer.

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2018-01-16 01:53:35 +01:00
Hemant Agrawal
b2e1c99ec8 lpm: fix ARM big endian build
Compiling on ARM BE using Linaro toolchain caused following
error/warnings.

rte_lpm.c: In function ‘add_depth_big_v20’:
rte_lpm.c:911:4: error: braces around scalar initializer [-Werror]
    { .group_idx = (uint8_t)tbl8_group_index, },
    ^
rte_lpm.c:911:4: note: (near initialization for
	‘new_tbl24_entry.depth’)
rte_lpm.c:911:6:error: field name not in record or union initializer
    { .group_idx = (uint8_t)tbl8_group_index, },
      ^
rte_lpm.c:911:6: note: (near initialization for
	‘new_tbl24_entry.depth’)
rte_lpm.c:914:13: error: initialized field overwritten
	[-Werror=override-init]
    .depth = 0,

Fixes: dc81ebbaca ("lpm: extend IPv4 next hop field")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2018-01-12 17:27:03 +01:00
Bruce Richardson
369991d997 lib: use SPDX tag for Intel copyright files
Replace the BSD license header with the SPDX tag for files
with only an Intel copyright on them.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2018-01-04 22:41:39 +01:00
Thomas Monjalon
4c00cfdc0e remove useless memzone includes
The memzone header is often included without good reason.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-11-06 22:12:08 +01:00
Olivier Matz
1f148d8eaf lpm6: fix compilation with -Og
The compilation with gcc-6.3.0 and EXTRA_CFLAGS=-Og gives the following
error:

  CC rte_lpm6.o
  rte_lpm6.c: In function ‘rte_lpm6_add_v1705’:
  rte_lpm6.c:442:11: error: ‘tbl_next’ may be used uninitialized in
                             this function [-Werror=maybe-uninitialized]
     if (!tbl[tbl_index].valid) {
             ^
  rte_lpm6.c:521:29: note: ‘tbl_next’ was declared here
    struct rte_lpm6_tbl_entry *tbl_next;
                               ^~~~~~~~

This is a false positive from gcc. Fix it by initializing tbl_next
to NULL.

Fixes: 5c510e13a9 ("lpm: add IPv6 support")
Cc: stable@dpdk.org

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-10-27 01:05:55 +02:00
Igor Ryzhov
490424e6c9 lpm6: set errno on creation error
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-10-24 21:35:53 +02:00
Igor Ryzhov
fa8ecf6634 lpm: set errno on creation error
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-10-24 21:35:53 +02:00
Olivier Matz
cbc12b0a96 mk: do not generate LDLIBS from directory dependencies
The list of libraries in LDLIBS was generated from the DEPDIRS-xyz
variable. This is valid when the subdirectory name match the library
name, but it's not always the case, especially for PMDs.

The patches removes this feature and explicitly adds the proper
libraries in LDLIBS.

Some DEPDIRS-xyz variables become useless, remove them.

Reported-by: Gage Eads <gage.eads@intel.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Gage Eads <gage.eads@intel.com>
2017-10-24 02:14:57 +02:00
Stephen Hemminger
d24b29d167 lib: remove duplicate includes
Include files only need to be refrenced once per file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-07-16 17:30:06 +02:00
Jerin Jacob
3abcd29f2d update Cavium Inc copyright headers
Replace the incorrect reference to "Cavium Networks", "Cavium Ltd"
company name with correct the "Cavium, Inc" company name in
copyright headers.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
2017-07-08 17:43:49 +02:00
Wei Dai
9d042b3ee0 lpm: fix index of tbl8
From v20 to v1604, number of tbl8 can be up to 1<<24,
(uint8_t) or (uint16_t) may truncate the number of
index of tlb8 in v1604 and cause wrong number.

Fixes: dc81ebbaca ("lpm: extend IPv4 next hop field")
Cc: stable@dpdk.org

Signed-off-by: Wei Dai <wei.dai@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-06-19 23:30:01 +02:00
Sangjin Han
bbdb713665 lpm: fix build with gcc -O0 option
When rte_lpm.h is used on x86, -O0 option (no optimization at all)
given to gcc causes a compile error like this:

error: the last argument must be an 8-bit immediate
   i24 = _mm_srli_si128(i24, sizeof(uint64_t));

-O0 option is useful for debugging and code coverage measurement, but
this error prevents DPDK programs from building. This patch replaces
"sizeof(uint64_t)" with a constant literal "8" to work around the issue.
The issue occurs on gcc/g++ versions from 4.8 to 5.

Signed-off-by: Sangjin Han <sangjin@eecs.berkeley.edu>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-06-05 15:10:31 +02:00
Olivier Matz
feb9f680cd mk: optimize directory dependencies
Before this patch, the management of dependencies between directories
had several issues:

- the generation of .depdirs, done at configuration is slow: it can take
  more than one minute on some slow targets (usually ~10s on a standard
  PC without -j).

- for instance, it is possible to express a dependency like:
  - app/foo depends on lib/librte_foo
  - and lib/librte_foo depends on app/bar
  But this won't work because the directories are traversed with a
  depth-first algorithm, so we have to choose between doing 'app' before
  or after 'lib'.

- the script depdirs-rule.sh is too complex.

- we cannot use "make -d" for debug, because the output of make is used for
  the generation of .depdirs.

This patch moves the DEPDIRS-* variables in the upper Makefile, making
the dependencies much easier to calculate. A DEPDIRS variable is still
used to process library dependencies in LDLIBS.

After this commit, "make config" is almost immediate.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Tested-by: Robin Jarry <robin.jarry@6wind.com>
Tested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
2017-03-27 23:28:43 +02:00
Vladyslav Buslov
d89a5bce1d lpm6: extend next hop field
This patch extend next_hop field from 8-bits to 21-bits in LPM library
for IPv6.

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

Signed-off-by: Vladyslav Buslov <vladyslav.buslov@harmonicinc.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-03-15 18:49:41 +01:00
Wei Dai
c7e9d6a6ed lpm: fix freeing memory
The memory pointed by lpm->rules_tbl should also be freed
when memory malloc for tbl8 fails in rte_lpm_create_v1604( ).
And the memory pointed by lpm->tbl8 should also be freed
when the lpm object is freed in rte_lpm_free_v1604( ).

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

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Wei Dai <wei.dai@intel.com>
2016-11-06 23:46:03 +01:00
Wei Dai
f05b0fbe7d lpm: remove redundant check when adding rule
When a rule with depth > 24 is added into an existing
rule with depth <=24, a new tbl8 is allocated, the existing
rule first fulfill whole new tbl8, so the filed valid of
each entry in this tbl8 is always true and depth of each
entry is always <= 24 before adding the new rule with depth > 24.

Signed-off-by: Wei Dai <wei.dai@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2016-10-13 22:17:00 +02:00
Wei Dai
69ed52dddc lpm: fix freeing unused sub-table on rule delete
When all rules with depth > 24 are deleted in a same sub-table
(tlb8 group) and only a rule with depth <=24 is left in it,
this sub-table (tlb8 group) should be recycled.

Fixes: dc81ebbaca ("lpm: extend IPv4 next hop field")
Fixes: af75078fec ("first public release")

Signed-off-by: Wei Dai <wei.dai@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2016-10-13 22:13:19 +02:00
Adrien Mazarguil
f04519d809 lib: add missing include dependencies
Exported header files for use by applications should be self sufficient and
allow out of order inclusion. Moreover, they must include all the system
headers they need for types and macros.

This commit prevents the following errors:

 error: `RTE_MAX_LCORE' undeclared here (not in a function)
 error: `RTE_LPM_VALID_EXT_ENTRY_BITMASK' undeclared
  (first use in this function)
 error: #error "Unsupported cache line size"
 error: `asm' undeclared (first use in this function)
 error: implicit declaration of function `[...]'
 error: unknown type name `[...]'
 error: field `mac_addr' has incomplete type
 error: `CHAR_BIT' undeclared here (not in a function)
 error: `struct [...]' declared inside parameter list
 error: unknown type name `uint8_t'

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
2016-09-13 15:35:28 +02:00
Adrien Mazarguil
79d6f5fc58 lib: work around unnamed structs/unions
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked to avoid warnings and compilation failures.

Unnamed structs/unions are allowed since C11, however many compiler
versions do not use this mode by default.

This commit prevents the following errors:

 error: ISO C99 doesn't support unnamed structs/unions
 error: struct has no named members

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
2016-09-13 15:35:28 +02:00
Adrien Mazarguil
8d4b8c87f2 lib: work around nonstandard bit-fields
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.

This commit prevents the following errors:

 error: type of bit-field `[...]' is a GCC extension

Note: the standard does not require implementations to issue a diagnostic
message with these, and such errors do not occur with recent GCC or clang
versions. However, GCC 4.7 is still common and using the extension keyword
is easier than checking compiler version.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
2016-09-13 15:35:28 +02:00
Adrien Mazarguil
347a1e037f lib: use C99 syntax for zero-size arrays
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.

The extension keyword is used whenever the C99 syntax cannot do it.

This commit prevents the following errors:

 error: ISO C forbids zero-size array `[...]'

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
2016-09-13 15:35:28 +02:00
Gowrishankar Muthukrishnan
d2cc795934 lpm: add AltiVec for ppc64
This patch adds ppc64le port for LPM library in DPDK.

Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
Acked-by: Chao Zhu <chaozhu@linux.vnet.ibm.com>
2016-09-09 17:56:08 +02:00
Daniel Mrzyglod
9199cd6d51 lpm6: fix possible garbage in lookup
Fix issue reported by clang scan-build

Value of pointer tbl_next was uninitialized. When function lookup_step()
take else branch it may provide garbage into tbl = tbl_next;

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

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
2016-05-02 15:15:45 +02:00
Igor Ryzhov
6226aa5672 lpm6: fix missing header dependency
Include stdint.h for the definition of uint*_t types.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2016-05-02 12:37:49 +02:00
Christian Ehrhardt
7cc3f2c2a4 lpm: fix freeing in compatibility mode
Back then when we fixed the missing free lpm I was to quickly to say yes
if it applies not only to the lpm6 but also to all of the lpm code.

It turned out to not apply to all of them. In rte_lpm_create_v20 there
is an unexpected fused allocation:
mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
[...]
lpm = (struct rte_lpm_v20 *)rte_zmalloc_socket(mem_name,mem_size,
               RTE_CACHE_LINE_SIZE, socket_id);

That causes lpm->rules_tbl not to have an own struct malloc_elem that
can be derived via RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN) in
malloc_elem_from_data.
Due to that the rte_lpm_free_v20 accidentially misderives the elem and
assumes it is ELEM_FREE triggering in malloc_elem_free
if (!malloc_elem_cookies_ok(elem) || elem->state !=
        return -1;

While it seems counter-intuitive the way to properly remove rules_tbl in
the old fused allocation style of rte_lpm_free_v20 is to not remove it.

The newer rte_lpm_free_v1604 is safe because in rte_lpm_create_v1604
rules_tbl is a separate allocation.

Fixes: d4c18f0a1d ("lpm: fix missing free")

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-05-02 12:37:48 +02:00
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