aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorMike Holmes <mike.holmes@linaro.org>2014-11-07 07:37:13 -0500
committerMaxim Uvarov <maxim.uvarov@linaro.org>2014-11-19 20:00:41 +0300
commitb5854d0a604b7c4672edc423ca313e07fda2bf29 (patch)
tree3bb375102592029b78552593a48dfdeb7d9eba87 /example
parentdc4bf89e36476b8cd31f3fdc1a2bb075af20f8ff (diff)
example: Remove use of ODP API logging
Removing the calls to the ODP API error functions from applications allows the functions to be moved into the ODP APIs internal interface. Applications should consume ODP implementation error messages and not use the library for its own logging needs. Signed-off-by: Mike Holmes <mike.holmes@linaro.org> Reviewed-by: Ciprian Barbu <ciprian.barbu@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r--example/example_debug.h88
-rw-r--r--example/generator/Makefile.am1
-rw-r--r--example/generator/odp_generator.c44
-rw-r--r--example/ipsec/Makefile.am1
-rw-r--r--example/ipsec/odp_ipsec.c47
-rw-r--r--example/ipsec/odp_ipsec_cache.c4
-rw-r--r--example/ipsec/odp_ipsec_fwd_db.c4
-rw-r--r--example/ipsec/odp_ipsec_loop_db.c4
-rw-r--r--example/ipsec/odp_ipsec_sa_db.c4
-rw-r--r--example/ipsec/odp_ipsec_sp_db.c4
-rw-r--r--example/ipsec/odp_ipsec_stream.c9
-rw-r--r--example/l2fwd/Makefile.am1
-rw-r--r--example/l2fwd/odp_l2fwd.c47
-rw-r--r--example/odp_example/Makefile.am1
-rw-r--r--example/odp_example/odp_example.c75
-rw-r--r--example/packet/Makefile.am1
-rw-r--r--example/packet/odp_pktio.c34
-rw-r--r--example/timer/Makefile.am1
-rw-r--r--example/timer/odp_timer_test.c22
19 files changed, 262 insertions, 130 deletions
diff --git a/example/example_debug.h b/example/example_debug.h
new file mode 100644
index 000000000..b83667c53
--- /dev/null
+++ b/example/example_debug.h
@@ -0,0 +1,88 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/**
+ * @file
+ *
+ * example debug
+ */
+
+#ifndef EXAMPLE_DEBUG_H_
+#define EXAMPLE_DEBUG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef EXAMPLE_DEBUG_PRINT
+#define EXAMPLE_DEBUG_PRINT 1
+#endif
+
+/**
+ * log level.
+ */
+typedef enum example_log_level {
+ EXAMPLE_LOG_DBG,
+ EXAMPLE_LOG_ERR,
+ EXAMPLE_LOG_ABORT
+} example_log_level_e;
+
+/**
+ * default LOG macro.
+ */
+#define EXAMPLE_LOG(level, fmt, ...) \
+do { \
+ switch (level) { \
+ case EXAMPLE_LOG_ERR: \
+ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ break; \
+ case EXAMPLE_LOG_DBG: \
+ if (EXAMPLE_DEBUG_PRINT == 1) \
+ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ break; \
+ case EXAMPLE_LOG_ABORT: \
+ fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ abort(); \
+ break; \
+ default: \
+ fprintf(stderr, "Unknown LOG level"); \
+ break;\
+ } \
+} while (0)
+
+/**
+ * Debug printing macro, which prints output when DEBUG flag is set.
+ */
+#define EXAMPLE_DBG(fmt, ...) \
+ EXAMPLE_LOG(EXAMPLE_LOG_DBG, fmt, ##__VA_ARGS__)
+
+/**
+ * Print output to stderr (file, line and function).
+ */
+#define EXAMPLE_ERR(fmt, ...) \
+ EXAMPLE_LOG(EXAMPLE_LOG_ERR, fmt, ##__VA_ARGS__)
+
+/**
+ * Print output to stderr (file, line and function),
+ * then abort.
+ */
+#define EXAMPLE_ABORT(fmt, ...) \
+ EXAMPLE_LOG(EXAMPLE_LOG_ABORT, fmt, ##__VA_ARGS__)
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/example/generator/Makefile.am b/example/generator/Makefile.am
index 5b3d55ac5..394985f31 100644
--- a/example/generator/Makefile.am
+++ b/example/generator/Makefile.am
@@ -2,5 +2,6 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_generator
odp_generator_LDFLAGS = $(AM_LDFLAGS) -static
+odp_generator_CFLAGS = $(AM_CFLAGS) -I../
dist_odp_generator_SOURCES = odp_generator.c
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index ffa5e6233..e2e0ba415 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -16,6 +16,8 @@
#include <unistd.h>
#include <sys/time.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odph_linux.h>
@@ -55,7 +57,8 @@ typedef struct {
int number; /**< packets number to be sent */
int payload; /**< data len */
int timeout; /**< wait time */
- int interval; /**< wait interval ms between sending each packet */
+ int interval; /**< wait interval ms between sending
+ each packet */
} appl_args_t;
/**
@@ -303,13 +306,13 @@ static void *gen_send_thread(void *arg)
/* Open a packet IO instance for this thread */
pktio = odp_pktio_open(thr_args->pktio_dev, thr_args->pool);
if (pktio == ODP_PKTIO_INVALID) {
- ODP_ERR(" [%02i] Error: pktio create failed\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pktio create failed\n", thr);
return NULL;
}
outq_def = odp_pktio_outq_getdef(pktio);
if (outq_def == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%02i] Error: def output-Q query\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: def output-Q query\n", thr);
return NULL;
}
@@ -318,7 +321,7 @@ static void *gen_send_thread(void *arg)
int err;
buf = odp_buffer_alloc(thr_args->pool);
if (!odp_buffer_is_valid(buf)) {
- ODP_ERR(" [%2i] alloc_single failed\n", thr);
+ EXAMPLE_ERR(" [%2i] alloc_single failed\n", thr);
return NULL;
}
@@ -329,7 +332,7 @@ static void *gen_send_thread(void *arg)
err = odp_queue_enq(outq_def, buf);
if (err != 0) {
- ODP_ERR(" [%02i] send pkt err!\n", thr);
+ EXAMPLE_ERR(" [%02i] send pkt err!\n", thr);
return NULL;
}
@@ -463,7 +466,7 @@ static void *gen_recv_thread(void *arg)
/* Open a packet IO instance for this thread */
pktio = odp_pktio_open(thr_args->pktio_dev, thr_args->pool);
if (pktio == ODP_PKTIO_INVALID) {
- ODP_ERR(" [%02i] Error: pktio create failed\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pktio create failed\n", thr);
return NULL;
}
@@ -475,13 +478,14 @@ static void *gen_recv_thread(void *arg)
inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0';
inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam);
if (inq_def == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%02i] Error: pktio queue creation failed\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pktio queue creation failed\n",
+ thr);
return NULL;
}
ret = odp_pktio_inq_setdef(pktio, inq_def);
if (ret != 0) {
- ODP_ERR(" [%02i] Error: default input-Q setup\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: default input-Q setup\n", thr);
return NULL;
}
@@ -520,12 +524,12 @@ int main(int argc, char *argv[])
/* Init ODP before calling anything else */
if (odp_init_global(NULL, NULL)) {
- ODP_ERR("Error: ODP global init failed.\n");
+ EXAMPLE_ERR("Error: ODP global init failed.\n");
exit(EXIT_FAILURE);
}
if (odp_init_local()) {
- ODP_ERR("Error: ODP local init failed.\n");
+ EXAMPLE_ERR("Error: ODP local init failed.\n");
exit(EXIT_FAILURE);
}
@@ -541,7 +545,7 @@ int main(int argc, char *argv[])
args = odp_shm_addr(shm);
if (args == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(args, 0, sizeof(*args));
@@ -584,7 +588,7 @@ int main(int argc, char *argv[])
pool_base = odp_shm_addr(shm);
if (pool_base == NULL) {
- ODP_ERR("Error: packet pool mem alloc failed.\n");
+ EXAMPLE_ERR("Error: packet pool mem alloc failed.\n");
exit(EXIT_FAILURE);
}
@@ -594,7 +598,7 @@ int main(int argc, char *argv[])
ODP_CACHE_LINE_SIZE,
ODP_BUFFER_TYPE_PACKET);
if (pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR("Error: packet pool create failed.\n");
+ EXAMPLE_ERR("Error: packet pool create failed.\n");
exit(EXIT_FAILURE);
}
odp_buffer_pool_print(pool);
@@ -636,7 +640,7 @@ int main(int argc, char *argv[])
} else if (args->appl.mode == APPL_MODE_RCV) {
thr_run_func = gen_recv_thread;
} else {
- ODP_ERR("ERR MODE\n");
+ EXAMPLE_ERR("ERR MODE\n");
exit(EXIT_FAILURE);
}
/*
@@ -754,35 +758,35 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
} else if (optarg[0] == 'r') {
appl_args->mode = APPL_MODE_RCV;
} else {
- ODP_ERR("wrong mode!\n");
+ EXAMPLE_ERR("wrong mode!\n");
exit(EXIT_FAILURE);
}
break;
case 'a':
if (scan_mac(optarg, &appl_args->srcmac) != 1) {
- ODP_ERR("wrong src mac:%s\n", optarg);
+ EXAMPLE_ERR("wrong src mac:%s\n", optarg);
exit(EXIT_FAILURE);
}
break;
case 'b':
if (scan_mac(optarg, &appl_args->dstmac) != 1) {
- ODP_ERR("wrong dst mac:%s\n", optarg);
+ EXAMPLE_ERR("wrong dst mac:%s\n", optarg);
exit(EXIT_FAILURE);
}
break;
case 'c':
if (scan_ip(optarg, &appl_args->srcip) != 1) {
- ODP_ERR("wrong src ip:%s\n", optarg);
+ EXAMPLE_ERR("wrong src ip:%s\n", optarg);
exit(EXIT_FAILURE);
}
break;
case 'd':
if (scan_ip(optarg, &appl_args->dstip) != 1) {
- ODP_ERR("wrong dst ip:%s\n", optarg);
+ EXAMPLE_ERR("wrong dst ip:%s\n", optarg);
exit(EXIT_FAILURE);
}
break;
@@ -802,7 +806,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
case 'i':
appl_args->interval = atoi(optarg);
if (appl_args->interval <= 200 && geteuid() != 0) {
- ODP_ERR("should be root user\n");
+ EXAMPLE_ERR("should be root user\n");
exit(EXIT_FAILURE);
}
break;
diff --git a/example/ipsec/Makefile.am b/example/ipsec/Makefile.am
index ac0949e63..b4ef0cb80 100644
--- a/example/ipsec/Makefile.am
+++ b/example/ipsec/Makefile.am
@@ -2,6 +2,7 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_ipsec
odp_ipsec_LDFLAGS = $(AM_LDFLAGS) -static
+odp_ipsec_CFLAGS = $(AM_CFLAGS) -I../
dist_odp_ipsec_SOURCES = odp_ipsec.c \
odp_ipsec_sa_db.c \
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 37ad34db6..807ca7ef7 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -15,6 +15,8 @@
#include <getopt.h>
#include <unistd.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odph_linux.h>
@@ -234,7 +236,7 @@ int query_mac_address(char *intf, uint8_t *src_mac)
/* Get a socket descriptor */
sd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (sd < 0) {
- ODP_ERR("Error: socket() failed for %s\n", intf);
+ EXAMPLE_ERR("Error: socket() failed for %s\n", intf);
return -1;
}
@@ -243,7 +245,7 @@ int query_mac_address(char *intf, uint8_t *src_mac)
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", intf);
if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0) {
close(sd);
- ODP_ERR("Error: ioctl() failed for %s\n", intf);
+ EXAMPLE_ERR("Error: ioctl() failed for %s\n", intf);
return -1;
}
memcpy(src_mac, ifr.ifr_hwaddr.sa_data, ODPH_ETHADDR_LEN);
@@ -382,7 +384,7 @@ void ipsec_init_pre(void)
ODP_QUEUE_TYPE_SCHED,
&qparam);
if (ODP_QUEUE_INVALID == completionq) {
- ODP_ERR("Error: completion queue creation failed\n");
+ EXAMPLE_ERR("Error: completion queue creation failed\n");
exit(EXIT_FAILURE);
}
@@ -394,7 +396,7 @@ void ipsec_init_pre(void)
ODP_QUEUE_TYPE_SCHED,
&qparam);
if (ODP_QUEUE_INVALID == seqnumq) {
- ODP_ERR("Error: sequence number queue creation failed\n");
+ EXAMPLE_ERR("Error: sequence number queue creation failed\n");
exit(EXIT_FAILURE);
}
@@ -411,7 +413,7 @@ void ipsec_init_pre(void)
ODP_BUFFER_TYPE_PACKET);
if (ODP_BUFFER_POOL_INVALID == out_pool) {
- ODP_ERR("Error: message pool create failed.\n");
+ EXAMPLE_ERR("Error: message pool create failed.\n");
exit(EXIT_FAILURE);
}
@@ -454,7 +456,8 @@ void ipsec_init_post(crypto_api_mode_e api_mode)
entry->input,
completionq,
out_pool)) {
- ODP_ERR("Error: IPSec cache entry failed.\n");
+ EXAMPLE_ERR("Error: IPSec cache entry failed.\n"
+ );
exit(EXIT_FAILURE);
}
} else {
@@ -487,7 +490,7 @@ void initialize_loop(char *intf)
/* Derive loopback interface index */
idx = loop_if_index(intf);
if (idx < 0) {
- ODP_ERR("Error: loopback \"%s\" invalid\n", intf);
+ EXAMPLE_ERR("Error: loopback \"%s\" invalid\n", intf);
exit(EXIT_FAILURE);
}
@@ -500,7 +503,8 @@ void initialize_loop(char *intf)
inq_def = QUEUE_CREATE(queue_name, ODP_QUEUE_TYPE_SCHED, &qparam);
if (ODP_QUEUE_INVALID == inq_def) {
- ODP_ERR("Error: input queue creation failed for %s\n", intf);
+ EXAMPLE_ERR("Error: input queue creation failed for %s\n",
+ intf);
exit(EXIT_FAILURE);
}
/* Create output queue */
@@ -512,7 +516,8 @@ void initialize_loop(char *intf)
outq_def = QUEUE_CREATE(queue_name, ODP_QUEUE_TYPE_POLL, &qparam);
if (ODP_QUEUE_INVALID == outq_def) {
- ODP_ERR("Error: output queue creation failed for %s\n", intf);
+ EXAMPLE_ERR("Error: output queue creation failed for %s\n",
+ intf);
exit(EXIT_FAILURE);
}
@@ -556,7 +561,7 @@ void initialize_intf(char *intf)
*/
pktio = odp_pktio_open(intf, pkt_pool);
if (ODP_PKTIO_INVALID == pktio) {
- ODP_ERR("Error: pktio create failed for %s\n", intf);
+ EXAMPLE_ERR("Error: pktio create failed for %s\n", intf);
exit(EXIT_FAILURE);
}
outq_def = odp_pktio_outq_getdef(pktio);
@@ -573,13 +578,14 @@ void initialize_intf(char *intf)
inq_def = QUEUE_CREATE(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam);
if (ODP_QUEUE_INVALID == inq_def) {
- ODP_ERR("Error: pktio queue creation failed for %s\n", intf);
+ EXAMPLE_ERR("Error: pktio queue creation failed for %s\n",
+ intf);
exit(EXIT_FAILURE);
}
ret = odp_pktio_inq_setdef(pktio, inq_def);
if (ret) {
- ODP_ERR("Error: default input-Q setup for %s\n", intf);
+ EXAMPLE_ERR("Error: default input-Q setup for %s\n", intf);
exit(EXIT_FAILURE);
}
@@ -590,7 +596,8 @@ void initialize_intf(char *intf)
ret = odp_pktio_get_mac_addr(pktio, src_mac);
#endif
if (ret) {
- ODP_ERR("Error: failed during MAC address get for %s\n", intf);
+ EXAMPLE_ERR("Error: failed during MAC address get for %s\n",
+ intf);
exit(EXIT_FAILURE);
}
@@ -1177,13 +1184,13 @@ main(int argc, char *argv[])
/* Init ODP before calling anything else */
if (odp_init_global(NULL, NULL)) {
- ODP_ERR("Error: ODP global init failed.\n");
+ EXAMPLE_ERR("Error: ODP global init failed.\n");
exit(EXIT_FAILURE);
}
/* Init this thread */
if (odp_init_local()) {
- ODP_ERR("Error: ODP local init failed.\n");
+ EXAMPLE_ERR("Error: ODP local init failed.\n");
exit(EXIT_FAILURE);
}
@@ -1194,7 +1201,7 @@ main(int argc, char *argv[])
args = odp_shm_addr(shm);
if (NULL == args) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(args, 0, sizeof(*args));
@@ -1239,7 +1246,7 @@ main(int argc, char *argv[])
pool_base = odp_shm_addr(shm);
if (NULL == pool_base) {
- ODP_ERR("Error: packet pool mem alloc failed.\n");
+ EXAMPLE_ERR("Error: packet pool mem alloc failed.\n");
exit(EXIT_FAILURE);
}
@@ -1249,7 +1256,7 @@ main(int argc, char *argv[])
ODP_CACHE_LINE_SIZE,
ODP_BUFFER_TYPE_PACKET);
if (ODP_BUFFER_POOL_INVALID == pkt_pool) {
- ODP_ERR("Error: packet pool create failed.\n");
+ EXAMPLE_ERR("Error: packet pool create failed.\n");
exit(EXIT_FAILURE);
}
@@ -1260,7 +1267,7 @@ main(int argc, char *argv[])
pool_base = odp_shm_addr(shm);
if (NULL == pool_base) {
- ODP_ERR("Error: context pool mem alloc failed.\n");
+ EXAMPLE_ERR("Error: context pool mem alloc failed.\n");
exit(EXIT_FAILURE);
}
@@ -1270,7 +1277,7 @@ main(int argc, char *argv[])
ODP_CACHE_LINE_SIZE,
ODP_BUFFER_TYPE_RAW);
if (ODP_BUFFER_POOL_INVALID == ctx_pool) {
- ODP_ERR("Error: context pool create failed.\n");
+ EXAMPLE_ERR("Error: context pool create failed.\n");
exit(EXIT_FAILURE);
}
diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index 1397d77bf..fb53bb631 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <string.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odph_ipsec.h>
@@ -28,7 +30,7 @@ void init_ipsec_cache(void)
ipsec_cache = odp_shm_addr(shm);
if (ipsec_cache == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(ipsec_cache, 0, sizeof(*ipsec_cache));
diff --git a/example/ipsec/odp_ipsec_fwd_db.c b/example/ipsec/odp_ipsec_fwd_db.c
index e067db956..4168420ed 100644
--- a/example/ipsec/odp_ipsec_fwd_db.c
+++ b/example/ipsec/odp_ipsec_fwd_db.c
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <string.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odp_ipsec_fwd_db.h>
@@ -26,7 +28,7 @@ void init_fwd_db(void)
fwd_db = odp_shm_addr(shm);
if (fwd_db == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(fwd_db, 0, sizeof(*fwd_db));
diff --git a/example/ipsec/odp_ipsec_loop_db.c b/example/ipsec/odp_ipsec_loop_db.c
index af4590ac3..d213bb354 100644
--- a/example/ipsec/odp_ipsec_loop_db.c
+++ b/example/ipsec/odp_ipsec_loop_db.c
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <string.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odp_ipsec_loop_db.h>
@@ -26,7 +28,7 @@ void init_loopback_db(void)
loopback_db = odp_shm_addr(shm);
if (loopback_db == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(loopback_db, 0, sizeof(*loopback_db));
diff --git a/example/ipsec/odp_ipsec_sa_db.c b/example/ipsec/odp_ipsec_sa_db.c
index e8679db2f..384c0cef3 100644
--- a/example/ipsec/odp_ipsec_sa_db.c
+++ b/example/ipsec/odp_ipsec_sa_db.c
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <string.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odp_ipsec_sa_db.h>
@@ -26,7 +28,7 @@ void init_sa_db(void)
sa_db = odp_shm_addr(shm);
if (sa_db == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(sa_db, 0, sizeof(*sa_db));
diff --git a/example/ipsec/odp_ipsec_sp_db.c b/example/ipsec/odp_ipsec_sp_db.c
index f288dfed2..b0f44803d 100644
--- a/example/ipsec/odp_ipsec_sp_db.c
+++ b/example/ipsec/odp_ipsec_sp_db.c
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <string.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odp_align.h>
#include <odp_crypto.h>
@@ -28,7 +30,7 @@ void init_sp_db(void)
sp_db = odp_shm_addr(shm);
if (sp_db == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(sp_db, 0, sizeof(*sp_db));
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index fa9aba805..139d00e54 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -12,6 +12,8 @@
#include <openssl/hmac.h>
#include <openssl/evp.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odph_packet.h>
@@ -56,7 +58,7 @@ void init_stream_db(void)
stream_db = odp_shm_addr(shm);
if (stream_db == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(stream_db, 0, sizeof(*stream_db));
@@ -100,7 +102,8 @@ int create_stream_db_entry(char *input)
case 2:
entry->input.loop = loop_if_index(token);
if (entry->input.loop < 0) {
- ODP_ERR("Error: stream must have input loop\n");
+ EXAMPLE_ERR("Error: stream must have input"
+ " loop\n");
exit(EXIT_FAILURE);
}
break;
@@ -479,7 +482,7 @@ int create_stream_db_inputs(void)
/* Lookup the packet pool */
pkt_pool = odp_buffer_pool_lookup("packet_pool");
if (pkt_pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR("Error: pkt_pool not found\n");
+ EXAMPLE_ERR("Error: pkt_pool not found\n");
exit(EXIT_FAILURE);
}
diff --git a/example/l2fwd/Makefile.am b/example/l2fwd/Makefile.am
index a83e75732..d57a15958 100644
--- a/example/l2fwd/Makefile.am
+++ b/example/l2fwd/Makefile.am
@@ -2,5 +2,6 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_l2fwd
odp_l2fwd_LDFLAGS = $(AM_LDFLAGS) -static
+odp_l2fwd_CFLAGS = $(AM_CFLAGS) -I../
dist_odp_l2fwd_SOURCES = odp_l2fwd.c
diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c
index 57037cd45..ebac8c53d 100644
--- a/example/l2fwd/odp_l2fwd.c
+++ b/example/l2fwd/odp_l2fwd.c
@@ -15,6 +15,8 @@
#include <getopt.h>
#include <unistd.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odph_linux.h>
#include <odph_packet.h>
@@ -128,7 +130,7 @@ static odp_pktio_t burst_mode_init_params(void *arg, odp_buffer_pool_t pool)
/* Open a packet IO instance for this thread */
pktio = odp_pktio_open(args->srcif, pool);
if (pktio == ODP_PKTIO_INVALID)
- ODP_ERR(" Error: pktio create failed");
+ EXAMPLE_ERR(" Error: pktio create failed");
return pktio;
}
@@ -167,13 +169,13 @@ static odp_pktio_t queue_mode_init_params(void *arg, odp_buffer_pool_t pool)
inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam);
if (inq_def == ODP_QUEUE_INVALID) {
- ODP_ERR(" Error: pktio queue creation failed");
+ EXAMPLE_ERR(" Error: pktio queue creation failed");
return ODP_PKTIO_INVALID;
}
ret = odp_pktio_inq_setdef(pktio, inq_def);
if (ret != 0) {
- ODP_ERR(" Error: default input-Q setup");
+ EXAMPLE_ERR(" Error: default input-Q setup");
return ODP_PKTIO_INVALID;
}
@@ -200,8 +202,8 @@ static void *pktio_queue_thread(void *arg)
thr_args = arg;
if (thr_args->srcpktio == 0 || thr_args->dstpktio == 0) {
- ODP_ERR("Invalid srcpktio:%d dstpktio:%d\n",
- thr_args->srcpktio, thr_args->dstpktio);
+ EXAMPLE_ERR("Invalid srcpktio:%d dstpktio:%d\n",
+ thr_args->srcpktio, thr_args->dstpktio);
return NULL;
}
printf("[%02i] srcif:%s dstif:%s spktio:%02i dpktio:%02i QUEUE mode\n",
@@ -224,14 +226,15 @@ static void *pktio_queue_thread(void *arg)
pkt = odp_packet_from_buffer(buf);
/* Drop packets with errors */
if (odp_unlikely(drop_err_pkts(&pkt, 1) == 0)) {
- ODP_ERR("Drop frame - err_cnt:%lu\n", ++err_cnt);
+ EXAMPLE_ERR("Drop frame - err_cnt:%lu\n", ++err_cnt);
continue;
}
pktio_tmp = odp_pktio_get_input(pkt);
outq_def = odp_pktio_outq_getdef(dstpktio[pktio_tmp]);
if (outq_def == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%02i] Error: def output-Q query\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: def output-Q query\n",
+ thr);
return NULL;
}
@@ -267,8 +270,8 @@ static void *pktio_ifburst_thread(void *arg)
thr_args = arg;
if (thr_args->srcpktio == 0 || thr_args->dstpktio == 0) {
- ODP_ERR("Invalid srcpktio:%d dstpktio:%d\n",
- thr_args->srcpktio, thr_args->dstpktio);
+ EXAMPLE_ERR("Invalid srcpktio:%d dstpktio:%d\n",
+ thr_args->srcpktio, thr_args->dstpktio);
return NULL;
}
printf("[%02i] srcif:%s dstif:%s spktio:%02i dpktio:%02i BURST mode\n",
@@ -286,8 +289,8 @@ static void *pktio_ifburst_thread(void *arg)
odp_pktio_send(thr_args->dstpktio, pkt_tbl,
pkts_ok);
if (odp_unlikely(pkts_ok != pkts))
- ODP_ERR("Dropped frames:%u - err_cnt:%lu\n",
- pkts-pkts_ok, ++err_cnt);
+ EXAMPLE_ERR("Dropped frames:%u - err_cnt:%lu\n",
+ pkts-pkts_ok, ++err_cnt);
/* Print packet counts every once in a while */
tmp += pkts_ok;
@@ -320,13 +323,13 @@ int main(int argc, char *argv[])
/* Init ODP before calling anything else */
if (odp_init_global(NULL, NULL)) {
- ODP_ERR("Error: ODP global init failed.\n");
+ EXAMPLE_ERR("Error: ODP global init failed.\n");
exit(EXIT_FAILURE);
}
/* Init this thread */
if (odp_init_local()) {
- ODP_ERR("Error: ODP local init failed.\n");
+ EXAMPLE_ERR("Error: ODP local init failed.\n");
exit(EXIT_FAILURE);
}
@@ -336,7 +339,7 @@ int main(int argc, char *argv[])
gbl_args = odp_shm_addr(shm);
if (gbl_args == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(gbl_args, 0, sizeof(*gbl_args));
@@ -359,13 +362,13 @@ int main(int argc, char *argv[])
printf("Num worker threads: %i\n", num_workers);
if (num_workers < gbl_args->appl.if_count) {
- ODP_ERR("Error: core count %d is less than interface count\n",
- num_workers);
+ EXAMPLE_ERR("Error: core count %d is less than interface "
+ "count\n", num_workers);
exit(EXIT_FAILURE);
}
if (gbl_args->appl.if_count % 2 != 0) {
- ODP_ERR("Error: interface count %d is odd in fwd appl.\n",
- gbl_args->appl.if_count);
+ EXAMPLE_ERR("Error: interface count %d is odd in fwd appl.\n",
+ gbl_args->appl.if_count);
exit(EXIT_FAILURE);
}
/*
@@ -385,7 +388,7 @@ int main(int argc, char *argv[])
pool_base = odp_shm_addr(shm);
if (pool_base == NULL) {
- ODP_ERR("Error: packet pool mem alloc failed.\n");
+ EXAMPLE_ERR("Error: packet pool mem alloc failed.\n");
exit(EXIT_FAILURE);
}
@@ -395,7 +398,7 @@ int main(int argc, char *argv[])
ODP_CACHE_LINE_SIZE,
ODP_BUFFER_TYPE_PACKET);
if (pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR("Error: packet pool create failed.\n");
+ EXAMPLE_ERR("Error: packet pool create failed.\n");
exit(EXIT_FAILURE);
}
odp_buffer_pool_print(pool);
@@ -418,13 +421,13 @@ int main(int argc, char *argv[])
if (gbl_args->appl.mode == APPL_MODE_PKT_BURST) {
pktio = burst_mode_init_params(&gbl_args->thread[i], pool);
if (pktio == ODP_PKTIO_INVALID) {
- ODP_ERR(" for thread:%02i\n", i);
+ EXAMPLE_ERR(" for thread:%02i\n", i);
exit(EXIT_FAILURE);
}
} else { /* APPL_MODE_PKT_QUEUE */
pktio = queue_mode_init_params(&gbl_args->thread[i], pool);
if (pktio == ODP_PKTIO_INVALID) {
- ODP_ERR(" for thread:%02i\n", i);
+ EXAMPLE_ERR(" for thread:%02i\n", i);
exit(EXIT_FAILURE);
}
}
diff --git a/example/odp_example/Makefile.am b/example/odp_example/Makefile.am
index e6f23d0e2..95136e791 100644
--- a/example/odp_example/Makefile.am
+++ b/example/odp_example/Makefile.am
@@ -2,5 +2,6 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_example
odp_example_LDFLAGS = $(AM_LDFLAGS) -static
+odp_example_CFLAGS = $(AM_CFLAGS) -I../
dist_odp_example_SOURCES = odp_example.c
diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c
index d0ec9779a..5fe2a993c 100644
--- a/example/odp_example/odp_example.c
+++ b/example/odp_example/odp_example.c
@@ -13,6 +13,8 @@
#include <string.h>
#include <stdlib.h>
+#include <example_debug.h>
+
/* ODP main header */
#include <odp.h>
@@ -93,7 +95,7 @@ static int create_queue(int thr, odp_buffer_pool_t msg_pool, int prio)
buf = odp_buffer_alloc(msg_pool);
if (!odp_buffer_is_valid(buf)) {
- ODP_ERR(" [%i] msg_pool alloc failed\n", thr);
+ EXAMPLE_ERR(" [%i] msg_pool alloc failed\n", thr);
return -1;
}
@@ -103,12 +105,12 @@ static int create_queue(int thr, odp_buffer_pool_t msg_pool, int prio)
queue = odp_queue_lookup(name);
if (queue == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%i] Queue %s lookup failed.\n", thr, name);
+ EXAMPLE_ERR(" [%i] Queue %s lookup failed.\n", thr, name);
return -1;
}
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -142,19 +144,20 @@ static int create_queues(int thr, odp_buffer_pool_t msg_pool, int prio)
queue = odp_queue_lookup(name);
if (queue == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%i] Queue %s lookup failed.\n", thr, name);
+ EXAMPLE_ERR(" [%i] Queue %s lookup failed.\n", thr,
+ name);
return -1;
}
buf = odp_buffer_alloc(msg_pool);
if (!odp_buffer_is_valid(buf)) {
- ODP_ERR(" [%i] msg_pool alloc failed\n", thr);
+ EXAMPLE_ERR(" [%i] msg_pool alloc failed\n", thr);
return -1;
}
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -183,7 +186,7 @@ static int test_alloc_single(int thr, odp_buffer_pool_t pool)
temp_buf = odp_buffer_alloc(pool);
if (!odp_buffer_is_valid(temp_buf)) {
- ODP_ERR(" [%i] alloc_single failed\n", thr);
+ EXAMPLE_ERR(" [%i] alloc_single failed\n", thr);
return -1;
}
@@ -221,7 +224,7 @@ static int test_alloc_multi(int thr, odp_buffer_pool_t pool)
temp_buf[j] = odp_buffer_alloc(pool);
if (!odp_buffer_is_valid(temp_buf[j])) {
- ODP_ERR(" [%i] alloc_multi failed\n", thr);
+ EXAMPLE_ERR(" [%i] alloc_multi failed\n", thr);
return -1;
}
}
@@ -263,7 +266,7 @@ static int test_poll_queue(int thr, odp_buffer_pool_t msg_pool)
buf = odp_buffer_alloc(msg_pool);
if (!odp_buffer_is_valid(buf)) {
- ODP_ERR(" [%i] msg_pool alloc failed\n", thr);
+ EXAMPLE_ERR(" [%i] msg_pool alloc failed\n", thr);
return -1;
}
@@ -284,14 +287,14 @@ static int test_poll_queue(int thr, odp_buffer_pool_t msg_pool)
for (i = 0; i < QUEUE_ROUNDS; i++) {
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
buf = odp_queue_deq(queue);
if (!odp_buffer_is_valid(buf)) {
- ODP_ERR(" [%i] Queue empty.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue empty.\n", thr);
return -1;
}
}
@@ -340,7 +343,7 @@ static int test_schedule_one_single(const char *str, int thr,
buf = odp_schedule_one(&queue, ODP_SCHED_WAIT);
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -401,7 +404,7 @@ static int test_schedule_one_many(const char *str, int thr,
buf = odp_schedule_one(&queue, ODP_SCHED_WAIT);
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -459,7 +462,7 @@ static int test_schedule_single(const char *str, int thr,
buf = odp_schedule(&queue, ODP_SCHED_WAIT);
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -478,7 +481,7 @@ static int test_schedule_single(const char *str, int thr,
tot++;
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -538,7 +541,7 @@ static int test_schedule_many(const char *str, int thr,
buf = odp_schedule(&queue, ODP_SCHED_WAIT);
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -557,7 +560,7 @@ static int test_schedule_many(const char *str, int thr,
tot++;
if (odp_queue_enq(queue, buf)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -616,7 +619,8 @@ static int test_schedule_multi(const char *str, int thr,
queue = odp_queue_lookup(name);
if (queue == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%i] Queue %s lookup failed.\n", thr, name);
+ EXAMPLE_ERR(" [%i] Queue %s lookup failed.\n", thr,
+ name);
return -1;
}
@@ -624,13 +628,14 @@ static int test_schedule_multi(const char *str, int thr,
buf[j] = odp_buffer_alloc(msg_pool);
if (!odp_buffer_is_valid(buf[j])) {
- ODP_ERR(" [%i] msg_pool alloc failed\n", thr);
+ EXAMPLE_ERR(" [%i] msg_pool alloc failed\n",
+ thr);
return -1;
}
}
if (odp_queue_enq_multi(queue, buf, MULTI_BUFS_MAX)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -645,7 +650,7 @@ static int test_schedule_multi(const char *str, int thr,
tot += num;
if (odp_queue_enq_multi(queue, buf, num)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -663,7 +668,7 @@ static int test_schedule_multi(const char *str, int thr,
tot += num;
if (odp_queue_enq_multi(queue, buf, num)) {
- ODP_ERR(" [%i] Queue enqueue failed.\n", thr);
+ EXAMPLE_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
}
@@ -715,7 +720,7 @@ static void *run_thread(void *arg)
globals = odp_shm_addr(shm);
if (globals == NULL) {
- ODP_ERR("Shared mem lookup failed\n");
+ EXAMPLE_ERR("Shared mem lookup failed\n");
return NULL;
}
@@ -735,7 +740,7 @@ static void *run_thread(void *arg)
msg_pool = odp_buffer_pool_lookup("msg_pool");
if (msg_pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR(" [%i] msg_pool not found\n", thr);
+ EXAMPLE_ERR(" [%i] msg_pool not found\n", thr);
return NULL;
}
@@ -835,7 +840,7 @@ static void test_time(void)
double err;
if (clock_gettime(CLOCK_MONOTONIC, &tp2)) {
- ODP_ERR("clock_gettime failed.\n");
+ EXAMPLE_ERR("clock_gettime failed.\n");
return;
}
@@ -843,7 +848,7 @@ static void test_time(void)
do {
if (clock_gettime(CLOCK_MONOTONIC, &tp1)) {
- ODP_ERR("clock_gettime failed.\n");
+ EXAMPLE_ERR("clock_gettime failed.\n");
return;
}
@@ -853,7 +858,7 @@ static void test_time(void)
do {
if (clock_gettime(CLOCK_MONOTONIC, &tp2)) {
- ODP_ERR("clock_gettime failed.\n");
+ EXAMPLE_ERR("clock_gettime failed.\n");
return;
}
@@ -971,7 +976,7 @@ int main(int argc, char *argv[])
/* ODP global init */
if (odp_init_global(NULL, NULL)) {
- ODP_ERR("ODP global init failed.\n");
+ EXAMPLE_ERR("ODP global init failed.\n");
return -1;
}
@@ -980,7 +985,7 @@ int main(int argc, char *argv[])
* setting up resources for worker threads.
*/
if (odp_init_local()) {
- ODP_ERR("ODP global init failed.\n");
+ EXAMPLE_ERR("ODP global init failed.\n");
return -1;
}
@@ -1028,7 +1033,7 @@ int main(int argc, char *argv[])
globals = odp_shm_addr(shm);
if (globals == NULL) {
- ODP_ERR("Shared memory reserve failed.\n");
+ EXAMPLE_ERR("Shared memory reserve failed.\n");
return -1;
}
@@ -1043,7 +1048,7 @@ int main(int argc, char *argv[])
pool_base = odp_shm_addr(shm);
if (pool_base == NULL) {
- ODP_ERR("Shared memory reserve failed.\n");
+ EXAMPLE_ERR("Shared memory reserve failed.\n");
return -1;
}
@@ -1052,7 +1057,7 @@ int main(int argc, char *argv[])
ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW);
if (pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR("Pool create failed.\n");
+ EXAMPLE_ERR("Pool create failed.\n");
return -1;
}
@@ -1064,7 +1069,7 @@ int main(int argc, char *argv[])
queue = odp_queue_create("poll_queue", ODP_QUEUE_TYPE_POLL, NULL);
if (queue == ODP_QUEUE_INVALID) {
- ODP_ERR("Poll queue create failed.\n");
+ EXAMPLE_ERR("Poll queue create failed.\n");
return -1;
}
@@ -1096,7 +1101,7 @@ int main(int argc, char *argv[])
&param);
if (queue == ODP_QUEUE_INVALID) {
- ODP_ERR("Schedule queue create failed.\n");
+ EXAMPLE_ERR("Schedule queue create failed.\n");
return -1;
}
}
@@ -1116,7 +1121,7 @@ int main(int argc, char *argv[])
first_core);
if (ret < 0) {
- ODP_ERR("Fork workers failed %i\n", ret);
+ EXAMPLE_ERR("Fork workers failed %i\n", ret);
return -1;
}
diff --git a/example/packet/Makefile.am b/example/packet/Makefile.am
index 603a1abbf..da5fc4558 100644
--- a/example/packet/Makefile.am
+++ b/example/packet/Makefile.am
@@ -2,5 +2,6 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_pktio
odp_pktio_LDFLAGS = $(AM_LDFLAGS) -static
+odp_pktio_CFLAGS = $(AM_CFLAGS) -I../
dist_odp_pktio_SOURCES = odp_pktio.c
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 2cf3f0d3f..3e08b3492 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -15,6 +15,8 @@
#include <getopt.h>
#include <unistd.h>
+#include <example_debug.h>
+
#include <odp.h>
#include <odph_linux.h>
#include <odph_packet.h>
@@ -130,14 +132,14 @@ static void *pktio_queue_thread(void *arg)
/* Lookup the packet pool */
pkt_pool = odp_buffer_pool_lookup("packet_pool");
if (pkt_pool == ODP_BUFFER_POOL_INVALID || pkt_pool != thr_args->pool) {
- ODP_ERR(" [%02i] Error: pkt_pool not found\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pkt_pool not found\n", thr);
return NULL;
}
/* Open a packet IO instance for this thread */
pktio = odp_pktio_open(thr_args->pktio_dev, pkt_pool);
if (pktio == ODP_PKTIO_INVALID) {
- ODP_ERR(" [%02i] Error: pktio create failed\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pktio create failed\n", thr);
return NULL;
}
@@ -153,13 +155,14 @@ static void *pktio_queue_thread(void *arg)
inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam);
if (inq_def == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%02i] Error: pktio queue creation failed\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pktio queue creation failed\n",
+ thr);
return NULL;
}
ret = odp_pktio_inq_setdef(pktio, inq_def);
if (ret != 0) {
- ODP_ERR(" [%02i] Error: default input-Q setup\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: default input-Q setup\n", thr);
return NULL;
}
@@ -185,7 +188,7 @@ static void *pktio_queue_thread(void *arg)
/* Drop packets with errors */
if (odp_unlikely(drop_err_pkts(&pkt, 1) == 0)) {
- ODP_ERR("Drop frame - err_cnt:%lu\n", ++err_cnt);
+ EXAMPLE_ERR("Drop frame - err_cnt:%lu\n", ++err_cnt);
continue;
}
@@ -193,7 +196,8 @@ static void *pktio_queue_thread(void *arg)
outq_def = odp_pktio_outq_getdef(pktio_tmp);
if (outq_def == ODP_QUEUE_INVALID) {
- ODP_ERR(" [%02i] Error: def output-Q query\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: def output-Q query\n",
+ thr);
return NULL;
}
@@ -239,14 +243,14 @@ static void *pktio_ifburst_thread(void *arg)
/* Lookup the packet pool */
pkt_pool = odp_buffer_pool_lookup("packet_pool");
if (pkt_pool == ODP_BUFFER_POOL_INVALID || pkt_pool != thr_args->pool) {
- ODP_ERR(" [%02i] Error: pkt_pool not found\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pkt_pool not found\n", thr);
return NULL;
}
/* Open a packet IO instance for this thread */
pktio = odp_pktio_open(thr_args->pktio_dev, pkt_pool);
if (pktio == ODP_PKTIO_INVALID) {
- ODP_ERR(" [%02i] Error: pktio create failed.\n", thr);
+ EXAMPLE_ERR(" [%02i] Error: pktio create failed.\n", thr);
return NULL;
}
@@ -266,8 +270,8 @@ static void *pktio_ifburst_thread(void *arg)
}
if (odp_unlikely(pkts_ok != pkts))
- ODP_ERR("Dropped frames:%u - err_cnt:%lu\n",
- pkts-pkts_ok, ++err_cnt);
+ EXAMPLE_ERR("Dropped frames:%u - err_cnt:%lu\n",
+ pkts-pkts_ok, ++err_cnt);
/* Print packet counts every once in a while */
tmp += pkts_ok;
@@ -300,13 +304,13 @@ int main(int argc, char *argv[])
/* Init ODP before calling anything else */
if (odp_init_global(NULL, NULL)) {
- ODP_ERR("Error: ODP global init failed.\n");
+ EXAMPLE_ERR("Error: ODP global init failed.\n");
exit(EXIT_FAILURE);
}
/* Init this thread */
if (odp_init_local()) {
- ODP_ERR("Error: ODP local init failed.\n");
+ EXAMPLE_ERR("Error: ODP local init failed.\n");
exit(EXIT_FAILURE);
}
@@ -316,7 +320,7 @@ int main(int argc, char *argv[])
args = odp_shm_addr(shm);
if (args == NULL) {
- ODP_ERR("Error: shared mem alloc failed.\n");
+ EXAMPLE_ERR("Error: shared mem alloc failed.\n");
exit(EXIT_FAILURE);
}
memset(args, 0, sizeof(*args));
@@ -355,7 +359,7 @@ int main(int argc, char *argv[])
pool_base = odp_shm_addr(shm);
if (pool_base == NULL) {
- ODP_ERR("Error: packet pool mem alloc failed.\n");
+ EXAMPLE_ERR("Error: packet pool mem alloc failed.\n");
exit(EXIT_FAILURE);
}
@@ -365,7 +369,7 @@ int main(int argc, char *argv[])
ODP_CACHE_LINE_SIZE,
ODP_BUFFER_TYPE_PACKET);
if (pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR("Error: packet pool create failed.\n");
+ EXAMPLE_ERR("Error: packet pool create failed.\n");
exit(EXIT_FAILURE);
}
odp_buffer_pool_print(pool);
diff --git a/example/timer/Makefile.am b/example/timer/Makefile.am
index 6229f1311..dffd4eb1c 100644
--- a/example/timer/Makefile.am
+++ b/example/timer/Makefile.am
@@ -2,5 +2,6 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_timer_test
odp_timer_test_LDFLAGS = $(AM_LDFLAGS) -static
+odp_timer_test_CFLAGS = $(AM_CFLAGS) -I../
dist_odp_timer_test_SOURCES = odp_timer_test.c
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 78b2ae210..04b4d89ed 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -13,6 +13,8 @@
#include <string.h>
#include <stdlib.h>
+#include <example_debug.h>
+
/* ODP main header */
#include <odp.h>
@@ -55,25 +57,25 @@ static void test_abs_timeouts(int thr, test_args_t *args)
odp_buffer_t buf;
int num;
- ODP_DBG(" [%i] test_timeouts\n", thr);
+ EXAMPLE_DBG(" [%i] test_timeouts\n", thr);
queue = odp_queue_lookup("timer_queue");
period_ns = args->period_us*ODP_TIME_USEC;
period = odp_timer_ns_to_tick(test_timer, period_ns);
- ODP_DBG(" [%i] period %"PRIu64" ticks, %"PRIu64" ns\n", thr,
- period, period_ns);
+ EXAMPLE_DBG(" [%i] period %"PRIu64" ticks, %"PRIu64" ns\n", thr,
+ period, period_ns);
tick = odp_timer_current_tick(test_timer);
- ODP_DBG(" [%i] current tick %"PRIu64"\n", thr, tick);
+ EXAMPLE_DBG(" [%i] current tick %"PRIu64"\n", thr, tick);
tick += period;
if (odp_timer_absolute_tmo(test_timer, tick, queue, ODP_BUFFER_INVALID)
== ODP_TIMER_TMO_INVALID){
- ODP_DBG("Timeout request failed\n");
+ EXAMPLE_DBG("Timeout request failed\n");
return;
}
@@ -87,7 +89,7 @@ static void test_abs_timeouts(int thr, test_args_t *args)
tmo = odp_timeout_from_buffer(buf);
tick = odp_timeout_tick(tmo);
- ODP_DBG(" [%i] timeout, tick %"PRIu64"\n", thr, tick);
+ EXAMPLE_DBG(" [%i] timeout, tick %"PRIu64"\n", thr, tick);
odp_buffer_free(buf);
@@ -131,7 +133,7 @@ static void *run_thread(void *ptr)
msg_pool = odp_buffer_pool_lookup("msg_pool");
if (msg_pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR(" [%i] msg_pool not found\n", thr);
+ EXAMPLE_ERR(" [%i] msg_pool not found\n", thr);
return NULL;
}
@@ -319,7 +321,7 @@ int main(int argc, char *argv[])
ODP_BUFFER_TYPE_TIMEOUT);
if (pool == ODP_BUFFER_POOL_INVALID) {
- ODP_ERR("Pool create failed.\n");
+ EXAMPLE_ERR("Pool create failed.\n");
return -1;
}
@@ -334,7 +336,7 @@ int main(int argc, char *argv[])
queue = odp_queue_create("timer_queue", ODP_QUEUE_TYPE_SCHED, &param);
if (queue == ODP_QUEUE_INVALID) {
- ODP_ERR("Timer queue create failed.\n");
+ EXAMPLE_ERR("Timer queue create failed.\n");
return -1;
}
@@ -344,7 +346,7 @@ int main(int argc, char *argv[])
args.max_us*ODP_TIME_USEC);
if (test_timer == ODP_TIMER_INVALID) {
- ODP_ERR("Timer create failed.\n");
+ EXAMPLE_ERR("Timer create failed.\n");
return -1;
}