From patchwork Wed Aug 13 10:13:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 35342 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 46BE620DCC for ; Wed, 13 Aug 2014 10:14:04 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id g18sf52303106oah.10 for ; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) 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=utLAbcljUiBxffs6TanBcGX/QBzEDz6vRiIpMyYa5IY=; b=KpEXaOphjk2GNgYr48dfZWfivGHnEG5igZOczzU31pTGAaqADgpRF6nhHgv9qIk9Tm b3k1XRv1esbTrioPctzQiSzrWJmuPTaYWGHmBR/vYGxQT778Oye5/8MiA99VvN9BvhGY FdA5dH8POoo0s4dFHsjTwDby7pmjuPQiU5J6TbjYWzwcYC+xO+1dpOfBibnyYq9BhE3u 1RrMIf5RXcYSo6mLs+Zp3sNrKn//8iqY4/5mdh/QVLAkXMdTYCwZHDEP5xKXSIOLYvCB T8njEnPdIrFHZ/lhNXsqpDP4Sj9X/DB2y4zVIY9YwVjufdIYb7M/fnbJLolYcpHSxm+8 kG+w== X-Gm-Message-State: ALoCoQnxxaxuAscXXJt/BoZk7YrE2U7JL+AxlfQDxUcGiuLFfyDdJ9BWM8zLaDdxlMdCQ3RtTJCe X-Received: by 10.50.43.168 with SMTP id x8mr17493226igl.4.1407924843890; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.21 with SMTP id h21ls536771qge.52.gmail; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) X-Received: by 10.221.61.5 with SMTP id wu5mr2705708vcb.13.1407924843809; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id a7si651049vdb.93.2014.08.13.03.14.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Aug 2014 03:14:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id id10so14700744vcb.35 for ; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) X-Received: by 10.52.228.67 with SMTP id sg3mr2330592vdc.6.1407924843709; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp318137vcb; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) X-Received: by 10.224.15.72 with SMTP id j8mr5457875qaa.8.1407924843129; Wed, 13 Aug 2014 03:14:03 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id y11si1887714qay.12.2014.08.13.03.14.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 13 Aug 2014 03:14:03 -0700 (PDT) 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-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XHVZC-0001UN-1c; Wed, 13 Aug 2014 10:14:02 +0000 Received: from mail-qc0-f180.google.com ([209.85.216.180]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XHVZ6-0001UC-4f for lng-odp@lists.linaro.org; Wed, 13 Aug 2014 10:13:56 +0000 Received: by mail-qc0-f180.google.com with SMTP id l6so3962829qcy.11 for ; Wed, 13 Aug 2014 03:13:51 -0700 (PDT) X-Received: by 10.229.212.138 with SMTP id gs10mr5175751qcb.7.1407924830932; Wed, 13 Aug 2014 03:13:50 -0700 (PDT) Received: from fedora1.holmesfamily.ws (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by mx.google.com with ESMTPSA id j47sm1635529qge.46.2014.08.13.03.13.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Aug 2014 03:13:50 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 13 Aug 2014 06:13:34 -0400 Message-Id: <1407924814-50675-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [RFC] Add global_init paramiters 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.220.176 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 Signed-off-by: Mike Holmes --- This adds the two agreed upon init structure members, I left flags out but the understanding is we add it along with its first agreed use case. I wondered though if we need an init struct initializer function that platforms can implement to set the defaults as they should be ? Next steps would be to incorporate the logging callback and any debug level control, presumably we will have another run time API that allows further manipulation of the debug level, this would just be the initial state of that. example/generator/odp_generator.c | 3 ++- example/l2fwd/odp_l2fwd.c | 3 ++- example/odp_example/odp_example.c | 3 ++- example/packet/odp_pktio.c | 3 ++- example/timer/odp_timer_test.c | 3 ++- include/odp_init.h | 22 +++++++++++++++++----- platform/linux-dpdk/odp_init.c | 2 +- platform/linux-generic/odp_init.c | 2 +- platform/linux-keystone2/odp_init.c | 2 +- test/api_test/odp_common.c | 3 ++- 10 files changed, 32 insertions(+), 14 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index b10372e..893233f 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -522,6 +522,7 @@ int main(int argc, char *argv[]) { odp_linux_pthread_t thread_tbl[MAX_WORKERS]; odp_buffer_pool_t pool; + odp_global_init_t init_data; int thr_id; int num_workers; void *pool_base; @@ -530,7 +531,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(init_data)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index f89ea7a..12a6f53 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -280,6 +280,7 @@ int main(int argc, char *argv[]) { odp_linux_pthread_t thread_tbl[MAX_WORKERS]; odp_buffer_pool_t pool; + odp_global_init_t init_data; int thr_id; void *pool_base; int i; @@ -288,7 +289,7 @@ int main(int argc, char *argv[]) odp_pktio_t pktio; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(init_data)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c index be96093..c82ef51 100644 --- a/example/odp_example/odp_example.c +++ b/example/odp_example/odp_example.c @@ -917,6 +917,7 @@ static void parse_args(int argc, char *argv[], test_args_t *args) int main(int argc, char *argv[]) { odp_linux_pthread_t thread_tbl[MAX_WORKERS]; + odp_global_init_t init_data; test_args_t args; int thr_id; int num_workers; @@ -934,7 +935,7 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(init_data)) { printf("ODP global init failed.\n"); return -1; } diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 247a28a..aa3e848 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -277,6 +277,7 @@ int main(int argc, char *argv[]) { odp_linux_pthread_t thread_tbl[MAX_WORKERS]; odp_buffer_pool_t pool; + odp_global_init_t init_data; int thr_id; int num_workers; void *pool_base; @@ -285,7 +286,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(init_data)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index dbe0e5b..1fce60f 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -193,6 +193,7 @@ static void parse_args(int argc, char *argv[], test_args_t *args) int main(int argc, char *argv[]) { odp_linux_pthread_t thread_tbl[MAX_WORKERS]; + odp_global_init_t init_data; test_args_t args; int thr_id; int num_workers; @@ -210,7 +211,7 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(init_data)) { printf("ODP global init failed.\n"); return -1; } diff --git a/include/odp_init.h b/include/odp_init.h index 490324a..520e6eb 100644 --- a/include/odp_init.h +++ b/include/odp_init.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - /** * @file * @@ -23,23 +22,36 @@ extern "C" { #include - +/** + * ODP initialisation struct + */ +typedef struct odp_global_init{ + /** Callback for logging replaces the default implementation if + * not NULL + */ + int (*logging)(char *format,...); + /** Platform specific data. ODP does nothing with + * this pointer + */ + void *platform_implimentaion_data; +} odp_global_init_t; /** - * Perform global ODP initalisation. + * Perform global ODP initialisation. * * This function must be called once before calling * any other ODP API functions. * * @return 0 if successful */ -int odp_init_global(void); +int odp_init_global(odp_global_init_t params); /** - * Perform thread local ODP initalisation. + * Perform thread local ODP initialisation. * * All threads must call this function before calling + * * any other ODP API functions. * @param thr_id Thread id * @return 0 if successful diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index ecc2066..97a4024 100644 --- a/platform/linux-dpdk/odp_init.c +++ b/platform/linux-dpdk/odp_init.c @@ -50,7 +50,7 @@ int odp_init_dpdk(void) return 0; } -int odp_init_global(void) +int odp_init_global(odp_global_init_t params ODP_UNUSED) { odp_thread_init_global(); diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index d4c2eb8..db04903 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -9,7 +9,7 @@ #include -int odp_init_global(void) +int odp_init_global(odp_global_init_t params ODP_UNUSED) { odp_thread_init_global(); diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c index f832551..066dace 100644 --- a/platform/linux-keystone2/odp_init.c +++ b/platform/linux-keystone2/odp_init.c @@ -90,7 +90,7 @@ static int ti_init_hw_config(void) } -int odp_init_global(void) +int odp_init_global(odp_global_init_t init_data ODP_UNUSED) { odp_thread_init_global(); diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c index 89ebd2d..cfbef19 100644 --- a/test/api_test/odp_common.c +++ b/test/api_test/odp_common.c @@ -54,9 +54,10 @@ void odp_print_system_info(void) /** test init globals and call odp_init_global() */ int odp_test_global_init(void) { + odp_global_init_t init_data; memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(init_data)) { ODP_ERR("ODP global init failed.\n"); return -1; }