From patchwork Fri Nov 7 12:37:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 40397 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 117AC24237 for ; Fri, 7 Nov 2014 12:37:46 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf3314748eek.4 for ; Fri, 07 Nov 2014 04:37:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=DvXEuGEHM1KRSbSh7IB7TW8QGhVhUAf36uq3pbGsk5A=; b=hP3Y/UT1tszHTFP3yoibejRA920pBiuJJY5peeP/tUubLoVFOeazMVTuRUnTWOwdV6 H1lz7evuxyby8W6+Q4tJwhKlYimhormLQCUl/Sd2Qky5aYeiqoDFJhfqwF6IlX2mJcCl bt/MRxtx+5nHjqLLdabXtfhQs4nL/3t6/vPXqixI9Bd3wfu1z7uhR/zjkpHTgf7vIbaA YBxpzlAPtMSnNtp0Zo5uq3y1mg0GNdFFPm54HAb+O1yZAi6QJTI7b93du5/smndwcL2b cb9uwaHqxKqkobfXr4hgxT2bpLZGhigXmig7JZFmNVnG+nri98N0uTSS8uzfU76K08PQ POFg== X-Gm-Message-State: ALoCoQmZ8eXG+xkPiFn/T1j/tfRIDPxRe3G0nCRIbARba/uzknwM2Oe3/kI+tl+M2wz8n2wUTOC5 X-Received: by 10.180.100.100 with SMTP id ex4mr615984wib.2.1415363865300; Fri, 07 Nov 2014 04:37:45 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.7 with SMTP id i7ls205004lam.107.gmail; Fri, 07 Nov 2014 04:37:44 -0800 (PST) X-Received: by 10.152.30.9 with SMTP id o9mr11177478lah.8.1415363864863; Fri, 07 Nov 2014 04:37:44 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id xm7si14897984lbb.97.2014.11.07.04.37.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 04:37:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id pn19so4370907lab.18 for ; Fri, 07 Nov 2014 04:37:44 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr10834774laz.27.1415363864708; Fri, 07 Nov 2014 04:37:44 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp190096lbc; Fri, 7 Nov 2014 04:37:42 -0800 (PST) X-Received: by 10.224.10.195 with SMTP id q3mr17390856qaq.8.1415363861764; Fri, 07 Nov 2014 04:37:41 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id l7si16848431qad.1.2014.11.07.04.37.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 07 Nov 2014 04:37:41 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XminK-0006ar-3e; Fri, 07 Nov 2014 12:37:38 +0000 Received: from mail-qc0-f173.google.com ([209.85.216.173]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XminC-0006am-Ok for lng-odp@lists.linaro.org; Fri, 07 Nov 2014 12:37:30 +0000 Received: by mail-qc0-f173.google.com with SMTP id x3so2402205qcv.32 for ; Fri, 07 Nov 2014 04:37:25 -0800 (PST) X-Received: by 10.224.127.133 with SMTP id g5mr17148559qas.24.1415363845557; Fri, 07 Nov 2014 04:37:25 -0800 (PST) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id r6sm8291625qad.18.2014.11.07.04.37.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Nov 2014 04:37:24 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Fri, 7 Nov 2014 07:37:13 -0500 Message-Id: <1415363833-57742-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH v2] example: Remove use of ODP API logging X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 --- example/example_debug.h | 88 +++++++++++++++++++++++++++++++++++++++ example/generator/Makefile.am | 1 + example/generator/odp_generator.c | 44 +++++++++++--------- example/ipsec/Makefile.am | 1 + example/ipsec/odp_ipsec.c | 47 ++++++++++++--------- example/ipsec/odp_ipsec_cache.c | 4 +- example/ipsec/odp_ipsec_fwd_db.c | 4 +- example/ipsec/odp_ipsec_loop_db.c | 4 +- example/ipsec/odp_ipsec_sa_db.c | 4 +- example/ipsec/odp_ipsec_sp_db.c | 4 +- example/ipsec/odp_ipsec_stream.c | 9 ++-- example/l2fwd/Makefile.am | 1 + example/l2fwd/odp_l2fwd.c | 47 +++++++++++---------- example/odp_example/Makefile.am | 1 + example/odp_example/odp_example.c | 75 +++++++++++++++++---------------- example/packet/Makefile.am | 1 + example/packet/odp_pktio.c | 34 ++++++++------- example/timer/Makefile.am | 1 + example/timer/odp_timer_test.c | 22 +++++----- 19 files changed, 262 insertions(+), 130 deletions(-) create mode 100644 example/example_debug.h diff --git a/example/example_debug.h b/example/example_debug.h new file mode 100644 index 0000000..b83667c --- /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 +#include + +#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 5b3d55a..394985f 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 ffa5e62..e2e0ba4 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -16,6 +16,8 @@ #include #include +#include + #include #include @@ -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 ac0949e..b4ef0cb 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 da6c48e..709855c 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -15,6 +15,8 @@ #include #include +#include + #include #include @@ -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); } @@ -1176,13 +1183,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); } @@ -1193,7 +1200,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)); @@ -1238,7 +1245,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); } @@ -1248,7 +1255,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); } @@ -1259,7 +1266,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); } @@ -1269,7 +1276,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 1397d77..fb53bb6 100644 --- a/example/ipsec/odp_ipsec_cache.c +++ b/example/ipsec/odp_ipsec_cache.c @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -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 e067db9..4168420 100644 --- a/example/ipsec/odp_ipsec_fwd_db.c +++ b/example/ipsec/odp_ipsec_fwd_db.c @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -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 af4590a..d213bb3 100644 --- a/example/ipsec/odp_ipsec_loop_db.c +++ b/example/ipsec/odp_ipsec_loop_db.c @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -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 e8679db..384c0ce 100644 --- a/example/ipsec/odp_ipsec_sa_db.c +++ b/example/ipsec/odp_ipsec_sa_db.c @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -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 f288dfe..b0f4480 100644 --- a/example/ipsec/odp_ipsec_sp_db.c +++ b/example/ipsec/odp_ipsec_sp_db.c @@ -7,6 +7,8 @@ #include #include +#include + #include #include #include @@ -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 fa9aba8..139d00e 100644 --- a/example/ipsec/odp_ipsec_stream.c +++ b/example/ipsec/odp_ipsec_stream.c @@ -12,6 +12,8 @@ #include #include +#include + #include #include @@ -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 a83e757..d57a159 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 57037cd..ebac8c5 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -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 e6f23d0..95136e7 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 1ed4a0b..a674b77 100644 --- a/example/odp_example/odp_example.c +++ b/example/odp_example/odp_example.c @@ -13,6 +13,8 @@ #include #include +#include + /* ODP main header */ #include @@ -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; } } @@ -339,7 +342,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; } } @@ -399,7 +402,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; } } @@ -456,7 +459,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; } } @@ -475,7 +478,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; } } @@ -534,7 +537,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; } } @@ -553,7 +556,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; } } @@ -611,7 +614,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; } @@ -619,13 +623,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; } } @@ -640,7 +645,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; } } @@ -658,7 +663,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; } } @@ -710,7 +715,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; } @@ -730,7 +735,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; } @@ -830,7 +835,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; } @@ -838,7 +843,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; } @@ -848,7 +853,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; } @@ -966,7 +971,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; } @@ -975,7 +980,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; } @@ -1023,7 +1028,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; } @@ -1038,7 +1043,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; } @@ -1047,7 +1052,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; } @@ -1059,7 +1064,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; } @@ -1091,7 +1096,7 @@ int main(int argc, char *argv[]) ¶m); if (queue == ODP_QUEUE_INVALID) { - ODP_ERR("Schedule queue create failed.\n"); + EXAMPLE_ERR("Schedule queue create failed.\n"); return -1; } } @@ -1111,7 +1116,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 603a1ab..da5fc45 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 2cf3f0d..3e08b34 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -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 6229f13..dffd4eb 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 78b2ae2..04b4d89 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -13,6 +13,8 @@ #include #include +#include + /* ODP main header */ #include @@ -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, ¶m); 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; }