diff options
author | Matias Elo <matias.elo@nokia.com> | 2019-08-22 15:36:13 +0300 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2019-08-22 15:36:13 +0300 |
commit | e50bbcfccb4d5f94f830f0df6de108db03acd339 (patch) | |
tree | 298cf43e9b2b026fb69a1e815a4c93eee5649491 /helper | |
parent | 8101a05ffcd8983f564ade693c92deba54bd5b2b (diff) | |
parent | c8d22107bd8b64efc91bc064fe20e7aeeac7efff (diff) |
Merge ODP linux-generic v1.22.0.0 into linux-dpdk
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'helper')
-rw-r--r-- | helper/Makefile.am | 2 | ||||
-rw-r--r-- | helper/chksum.c | 11 | ||||
-rw-r--r-- | helper/cuckootable.c | 4 | ||||
-rw-r--r-- | helper/hashtable.c | 4 | ||||
-rw-r--r-- | helper/include/odp/helper/odph_api.h | 1 | ||||
-rw-r--r-- | helper/include/odp/helper/odph_debug.h (renamed from helper/include/odph_debug.h) | 28 | ||||
-rw-r--r-- | helper/iplookuptable.c | 2 | ||||
-rw-r--r-- | helper/lineartable.c | 4 | ||||
-rw-r--r-- | helper/linux/thread.c | 2 | ||||
-rw-r--r-- | helper/test/.gitignore | 1 | ||||
-rw-r--r-- | helper/test/Makefile.am | 2 | ||||
-rw-r--r-- | helper/test/chksum.c | 1 | ||||
-rw-r--r-- | helper/test/cuckootable.c | 1 | ||||
-rw-r--r-- | helper/test/debug.c | 31 | ||||
-rw-r--r-- | helper/test/iplookuptable.c | 2 | ||||
-rw-r--r-- | helper/test/linux/process.c | 2 | ||||
-rw-r--r-- | helper/test/linux/pthread.c | 2 | ||||
-rw-r--r-- | helper/test/odpthreads.c | 1 | ||||
-rw-r--r-- | helper/test/parse.c | 2 | ||||
-rw-r--r-- | helper/test/table.c | 3 | ||||
-rw-r--r-- | helper/test/version.c | 2 | ||||
-rw-r--r-- | helper/threads.c | 2 |
22 files changed, 78 insertions, 32 deletions
diff --git a/helper/Makefile.am b/helper/Makefile.am index 242a2e944..762f80602 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -15,6 +15,7 @@ AM_LDFLAGS = -version-number '$(ODPHELPER_LIBSO_VERSION)' helperincludedir = $(includedir)/odp/helper/ helperinclude_HEADERS = \ include/odp/helper/chksum.h\ + include/odp/helper/odph_debug.h \ include/odp/helper/eth.h\ include/odp/helper/icmp.h\ include/odp/helper/ip.h\ @@ -43,7 +44,6 @@ helperlinuxinclude_HEADERS = \ endif noinst_HEADERS = \ - include/odph_debug.h \ include/odph_list_internal.h __LIB__libodphelper_la_SOURCES = \ diff --git a/helper/chksum.c b/helper/chksum.c index 7c7c20a2f..c3e712421 100644 --- a/helper/chksum.c +++ b/helper/chksum.c @@ -106,9 +106,10 @@ static inline int odph_process_l4_hdr(odp_packet_t odp_pkt, odph_udphdr_t *udp_hdr_ptr; odph_tcphdr_t *tcp_hdr_ptr; odp_bool_t split_l4_hdr, is_tcp; - uint32_t l4_offset, l4_len, hdr_len, pkt_chksum_offset; + uint32_t l4_offset, l4_len, pkt_chksum_offset; uint16_t *pkt_chksum_ptr; uint8_t *l4_ptr; + uint32_t hdr_len = 0; /* Parse the TCP/UDP header. */ l4_offset = odp_packet_l4_offset(odp_pkt); @@ -185,9 +186,10 @@ static inline int odph_process_l3_hdr(odp_packet_t odp_pkt, odph_ipv6hdr_t *ipv6_hdr_ptr, ipv6_hdr; odp_bool_t split_l3_hdr; swap_buf_t swap_buf; - uint32_t l3_offset, l4_offset, l3_hdrs_len, hdr_len, addrs_len; + uint32_t l3_offset, l4_offset, l3_hdrs_len, addrs_len; uint32_t protocol, l3_len, l4_len, idx, ipv6_payload_len, sum; uint16_t *addrs_ptr; + uint32_t hdr_len = 0; /* The following computation using the l3 and l4 offsets handles both * the case of IPv4 options and IPv6 extension headers uniformly. */ @@ -271,11 +273,12 @@ int odph_udp_tcp_chksum(odp_packet_t odp_pkt, odph_l4_hdr_t udp_tcp_hdr; odp_bool_t split_l4_hdr, is_tcp, is_last; odp_bool_t has_odd_byte_in; - uint32_t l4_len, sum, ones_compl_sum, remaining_seg_len; + uint32_t l4_len, sum, ones_compl_sum; uint32_t data_len, pkt_chksum_offset, offset; uint16_t *pkt_chksum_ptr, chksum; uint8_t *data_ptr, odd_byte_in_out; int rc, ret_code; + uint32_t remaining_seg_len = 0; /* First parse and process the l4 header */ rc = odph_process_l4_hdr(odp_pkt, op, &udp_tcp_hdr, chksum_ptr, &l4_len, @@ -364,7 +367,7 @@ static uint32_t odph_packet_crc32c(odp_packet_t pkt, return sum; while (length > 0) { - uint32_t seg_len; + uint32_t seg_len = 0; void *data = odp_packet_offset(pkt, offset, &seg_len, NULL); if (seg_len > length) diff --git a/helper/cuckootable.c b/helper/cuckootable.c index febfa28ed..5609e6906 100644 --- a/helper/cuckootable.c +++ b/helper/cuckootable.c @@ -44,8 +44,8 @@ #include <errno.h> #include <stdio.h> -#include "odp/helper/odph_cuckootable.h" -#include "odph_debug.h" +#include <odp/helper/odph_cuckootable.h> +#include <odp/helper/odph_debug.h> #include <odp_api.h> /* More efficient access to a map of single ullong */ diff --git a/helper/hashtable.c b/helper/hashtable.c index 16f6c14cc..496bca5e6 100644 --- a/helper/hashtable.c +++ b/helper/hashtable.c @@ -10,9 +10,9 @@ #include <string.h> #include <malloc.h> -#include "odp/helper/odph_hashtable.h" +#include <odp/helper/odph_hashtable.h> +#include <odp/helper/odph_debug.h> #include "odph_list_internal.h" -#include "odph_debug.h" #include <odp_api.h> #define ODPH_SUCCESS 0 diff --git a/helper/include/odp/helper/odph_api.h b/helper/include/odp/helper/odph_api.h index 4bd10bf46..921914aa2 100644 --- a/helper/include/odp/helper/odph_api.h +++ b/helper/include/odp/helper/odph_api.h @@ -18,6 +18,7 @@ extern "C" { #endif +#include <odp/helper/odph_debug.h> #include <odp/helper/chksum.h> #include <odp/helper/odph_cuckootable.h> #include <odp/helper/eth.h> diff --git a/helper/include/odph_debug.h b/helper/include/odp/helper/odph_debug.h index d08918be0..c99936f4b 100644 --- a/helper/include/odph_debug.h +++ b/helper/include/odp/helper/odph_debug.h @@ -1,16 +1,19 @@ /* Copyright (c) 2015-2018, Linaro Limited + * Copyright (c) 2019, Nokia + * * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ + /** * @file * - * HELPER debug + * Helper debug */ -#ifndef HELPER_DEBUG_H_ -#define HELPER_DEBUG_H_ +#ifndef ODPH_DEBUG_H_ +#define ODPH_DEBUG_H_ #include <stdio.h> #include <stdlib.h> @@ -20,13 +23,28 @@ extern "C" { #endif /** + * Assert macro for applications and helper code + * + * No code is generated when ODPH_DEBUG=0. Prints error message and aborts when + * ODPH_DEBUG=1 and 'cond' is false. + */ +#define ODPH_ASSERT(cond) \ + do { \ + if ((ODPH_DEBUG == 1) && (!(cond))) { \ + fprintf(stderr, "%s:%d:%s(): %s\n", __FILE__, __LINE__,\ + __func__, #cond); \ + abort(); \ + } \ + } while (0) + +/** * log level. */ -typedef enum HELPER_log_level { +typedef enum odph_log_level { ODPH_LOG_DBG, ODPH_LOG_ERR, ODPH_LOG_ABORT -} HELPER_log_level_e; +} odph_log_level_e; /** * default LOG macro. diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c index 84b4e2cbb..1b5538ab8 100644 --- a/helper/iplookuptable.c +++ b/helper/iplookuptable.c @@ -12,8 +12,8 @@ #include <stdio.h> #include <odp/helper/odph_iplookuptable.h> +#include <odp/helper/odph_debug.h> #include "odph_list_internal.h" -#include "odph_debug.h" #include <odp_api.h> /** @magic word, write to the first byte of the memory block diff --git a/helper/lineartable.c b/helper/lineartable.c index b27246cbd..8479d2f1a 100644 --- a/helper/lineartable.c +++ b/helper/lineartable.c @@ -10,8 +10,8 @@ #include <string.h> #include <malloc.h> -#include "odp/helper/odph_lineartable.h" -#include "odph_debug.h" +#include <odp/helper/odph_lineartable.h> +#include <odp/helper/odph_debug.h> #include <odp_api.h> #define ODPH_SUCCESS 0 diff --git a/helper/linux/thread.c b/helper/linux/thread.c index 6ed1bc8f6..eecd6fed1 100644 --- a/helper/linux/thread.c +++ b/helper/linux/thread.c @@ -24,7 +24,7 @@ #include <odp_api.h> #include <odp/helper/linux/pthread.h> #include <odp/helper/linux/process.h> -#include "odph_debug.h" +#include <odp/helper/odph_debug.h> static void *_odph_run_start_routine(void *arg) { diff --git a/helper/test/.gitignore b/helper/test/.gitignore index 5a6c60bcc..23fab7b30 100644 --- a/helper/test/.gitignore +++ b/helper/test/.gitignore @@ -10,3 +10,4 @@ table thread pthread version +debug diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am index de8e77e38..386c9c221 100644 --- a/helper/test/Makefile.am +++ b/helper/test/Makefile.am @@ -1,6 +1,7 @@ include $(top_srcdir)/test/Makefile.inc EXECUTABLES = version \ + debug \ chksum \ cuckootable \ parse\ @@ -38,3 +39,4 @@ parse_SOURCES = parse.c table_SOURCES = table.c iplookuptable_SOURCES = iplookuptable.c version_SOURCES = version.c +debug_SOURCES = debug.c diff --git a/helper/test/chksum.c b/helper/test/chksum.c index 5c7c650e0..9fa4ec18a 100644 --- a/helper/test/chksum.c +++ b/helper/test/chksum.c @@ -6,7 +6,6 @@ #include "config.h" -#include "odph_debug.h" #include <odp_api.h> #include <odp/helper/odph_api.h> diff --git a/helper/test/cuckootable.c b/helper/test/cuckootable.c index 3afa490a6..ee5f1d832 100644 --- a/helper/test/cuckootable.c +++ b/helper/test/cuckootable.c @@ -50,7 +50,6 @@ #include <time.h> #include <odp_api.h> -#include <odph_debug.h> #include <odp/helper/odph_api.h> /******************************************************************************* diff --git a/helper/test/debug.c b/helper/test/debug.c new file mode 100644 index 000000000..e20fd325a --- /dev/null +++ b/helper/test/debug.c @@ -0,0 +1,31 @@ +/* Copyright (c) 2019, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" + +#include <odp_api.h> +#include <odp/helper/odph_api.h> + +#include <stdio.h> +#include <string.h> + +int main(void) +{ + printf("\nHelper library version is: %s\n\n", odph_version_str()); + + printf("Helper debugging:\n"); + printf(" ODPH_DEBUG: %i\n", ODPH_DEBUG); + printf(" ODPH_DEBUG_PRINT: %i\n\n", ODPH_DEBUG_PRINT); + + /* ASSERT(true) should work always */ + ODPH_ASSERT(1); + + /* ASSERT(false) should not abort when not debugging */ + if (ODPH_DEBUG == 0) + ODPH_ASSERT(0); + + return 0; +} diff --git a/helper/test/iplookuptable.c b/helper/test/iplookuptable.c index 5e16e7110..6637242d8 100644 --- a/helper/test/iplookuptable.c +++ b/helper/test/iplookuptable.c @@ -13,9 +13,7 @@ #include <errno.h> #include <odp_api.h> -#include <odph_debug.h> #include <odp/helper/odph_api.h> -#include <odp/helper/ip.h> static void print_prefix_info( const char *msg, uint32_t ip, uint8_t cidr) diff --git a/helper/test/linux/process.c b/helper/test/linux/process.c index 92d779d9a..26c9649d6 100644 --- a/helper/test/linux/process.c +++ b/helper/test/linux/process.c @@ -6,8 +6,8 @@ #include "config.h" -#include <odph_debug.h> #include <odp_api.h> +#include <odp/helper/odph_api.h> #include <odp/helper/linux/pthread.h> #include <odp/helper/linux/process.h> diff --git a/helper/test/linux/pthread.c b/helper/test/linux/pthread.c index 8441805d3..b0a578151 100644 --- a/helper/test/linux/pthread.c +++ b/helper/test/linux/pthread.c @@ -6,8 +6,8 @@ #include "config.h" -#include <odph_debug.h> #include <odp_api.h> +#include <odp/helper/odph_api.h> #include <odp/helper/linux/pthread.h> #include <string.h> diff --git a/helper/test/odpthreads.c b/helper/test/odpthreads.c index 55db37e0d..dbff4294e 100644 --- a/helper/test/odpthreads.c +++ b/helper/test/odpthreads.c @@ -15,7 +15,6 @@ #include <unistd.h> #include <stdlib.h> -#include <odph_debug.h> #include <odp_api.h> #include <odp/helper/odph_api.h> diff --git a/helper/test/parse.c b/helper/test/parse.c index f2f12cc05..5f8c5846a 100644 --- a/helper/test/parse.c +++ b/helper/test/parse.c @@ -6,8 +6,6 @@ #include "config.h" -#include <odph_debug.h> - #include <odp_api.h> #include <odp/helper/odph_api.h> diff --git a/helper/test/table.c b/helper/test/table.c index 29d87cb24..2887bd599 100644 --- a/helper/test/table.c +++ b/helper/test/table.c @@ -6,9 +6,8 @@ #include "config.h" -#include <odph_debug.h> -#include <odp/helper/odph_api.h> #include <odp_api.h> +#include <odp/helper/odph_api.h> /** * Address Resolution Protocol (ARP) diff --git a/helper/test/version.c b/helper/test/version.c index bd817bb47..22ee2955d 100644 --- a/helper/test/version.c +++ b/helper/test/version.c @@ -6,8 +6,6 @@ #include "config.h" -#include <odph_debug.h> - #include <odp_api.h> #include <odp/helper/odph_api.h> diff --git a/helper/threads.c b/helper/threads.c index e30c9f29d..37a0c25db 100644 --- a/helper/threads.c +++ b/helper/threads.c @@ -20,7 +20,7 @@ #include <odp_api.h> #include <odp/helper/threads.h> -#include "odph_debug.h" +#include <odp/helper/odph_debug.h> #define FAILED_CPU -1 |