From patchwork Tue Aug 26 16:03:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 36041 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B49562054F for ; Tue, 26 Aug 2014 16:04:10 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id w10sf116666268pde.3 for ; Tue, 26 Aug 2014 09:04:10 -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=yZ/Z0NCoNbvt/SJScSxwdqLflLQKuCtwcCCo1dhDoR8=; b=h3iyaKjNXj7pg3jRCSo1TQHVeJKOoRBLuowllbnH28VJcIEyXEOCUmZSEWRnr+uoFN tFicvdgK4U5uPMJeP0EKUhW/rXgEtddTgjrfQ6sXkXwWMRW5mJrq2fxCh94kY8Ttf2OH el8DH9sLBHubHsklpySYINpgk07QXjT1tGr/c54BJvXmm2dPbZ2DoAZ0kyxzMCHqZIxp wVRGjJjO+15PnxiDP/uAytf58MFOWdk5+MZuMrE0S/6DNfu3LUpCJjffCVIXR1cC9qBe yO8xhjpUMkYyoQmsacqQpTAYhc7D+cd/mMXHdHMifcuJ3zTu0wix1o8M2LTbqqx50iXH O+Ig== X-Gm-Message-State: ALoCoQn2yg9wYuNaxBL7+rYJ08TagMrWxWV+JmLmW3dnIjijh1EQZ/K1sAfqMS1JzY1sA2lgA26+ X-Received: by 10.66.66.196 with SMTP id h4mr13527376pat.18.1409069049977; Tue, 26 Aug 2014 09:04:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.21 with SMTP id h21ls2665508qge.52.gmail; Tue, 26 Aug 2014 09:04:09 -0700 (PDT) X-Received: by 10.236.203.2 with SMTP id e2mr11096330yho.105.1409069049869; Tue, 26 Aug 2014 09:04:09 -0700 (PDT) Received: from mail-yk0-f175.google.com (mail-yk0-f175.google.com [209.85.160.175]) by mx.google.com with ESMTPS id g62si2925837yha.25.2014.08.26.09.04.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Aug 2014 09:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.160.175 as permitted sender) client-ip=209.85.160.175; Received: by mail-yk0-f175.google.com with SMTP id q200so11472971ykb.34 for ; Tue, 26 Aug 2014 09:04:09 -0700 (PDT) X-Received: by 10.220.44.80 with SMTP id z16mr24677002vce.7.1409069049763; Tue, 26 Aug 2014 09:04:09 -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.45.67 with SMTP id uj3csp211214vcb; Tue, 26 Aug 2014 09:04:09 -0700 (PDT) X-Received: by 10.224.66.7 with SMTP id l7mr48080130qai.46.1409069048695; Tue, 26 Aug 2014 09:04:08 -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 m7si4353964qag.55.2014.08.26.09.04.07 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 26 Aug 2014 09:04:08 -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 1XMJE6-0006ka-QS; Tue, 26 Aug 2014 16:04:06 +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 1XMJE0-0006kG-Hu for lng-odp@lists.linaro.org; Tue, 26 Aug 2014 16:04:00 +0000 Received: by mail-qc0-f180.google.com with SMTP id l6so15512317qcy.39 for ; Tue, 26 Aug 2014 09:03:55 -0700 (PDT) X-Received: by 10.140.84.21 with SMTP id k21mr43904082qgd.70.1409069035301; Tue, 26 Aug 2014 09:03:55 -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 a64sm5561054qge.22.2014.08.26.09.03.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Aug 2014 09:03:54 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Tue, 26 Aug 2014 12:03:45 -0400 Message-Id: <1409069025-60872-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH v3] 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.160.175 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 --- v2: Factor out odp_platform_init so that odp_global_init is only defined for linux_generic and resued. v3: Use -M to simplify the diff Fix missing doxygen comments example/generator/odp_generator.c | 2 +- example/l2fwd/odp_l2fwd.c | 2 +- example/odp_example/odp_example.c | 2 +- example/packet/odp_pktio.c | 2 +- example/timer/odp_timer_test.c | 2 +- platform/linux-dpdk/Makefile.am | 3 +- platform/linux-dpdk/{odp_init.c => odp_platform.c} | 63 +------------------ platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/api/odp_init.h | 26 ++++++-- platform/linux-generic/include/odp_internal.h | 3 + platform/linux-generic/odp_init.c | 9 ++- platform/linux-generic/odp_platform.c | 14 +++++ platform/linux-keystone2/Makefile.am | 3 +- .../linux-keystone2/{odp_init.c => odp_platform.c} | 72 +++------------------- test/api_test/odp_common.c | 2 +- 15 files changed, 68 insertions(+), 138 deletions(-) rename platform/linux-dpdk/{odp_init.c => odp_platform.c} (50%) create mode 100644 platform/linux-generic/odp_platform.c rename platform/linux-keystone2/{odp_init.c => odp_platform.c} (72%) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 9fa9b37..ba7aa68 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -525,7 +525,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(NULL, NULL)) { 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 d74449a..f8d6729 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -323,7 +323,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(NULL, NULL)) { 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 f0bdf29..3d38ac7 100644 --- a/example/odp_example/odp_example.c +++ b/example/odp_example/odp_example.c @@ -951,7 +951,7 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(NULL, NULL)) { printf("ODP global init failed.\n"); return -1; } diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index f247bd0..f3543a0 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -311,7 +311,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(NULL, NULL)) { 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..1af8c2b 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -210,7 +210,7 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(NULL, NULL)) { printf("ODP global init failed.\n"); return -1; } diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index ff49b7d..70fa549 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -67,13 +67,14 @@ __LIB__libodp_la_SOURCES = \ odp_buffer.c \ odp_buffer_pool.c \ ../linux-generic/odp_coremask.c \ - odp_init.c \ + ../linux-generic/odp_init.c \ odp_linux.c \ odp_packet.c \ odp_packet_dpdk.c \ ../linux-generic/odp_packet_flags.c \ odp_packet_io.c \ ../linux-generic/odp_packet_socket.c \ + odp_platform.c \ odp_queue.c \ ../linux-generic/odp_ring.c \ ../linux-generic/odp_rwlock.c \ diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_platform.c similarity index 50% rename from platform/linux-dpdk/odp_init.c rename to platform/linux-dpdk/odp_platform.c index ecc2066..5a054fd 100644 --- a/platform/linux-dpdk/odp_init.c +++ b/platform/linux-dpdk/odp_platform.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, Linaro Limited +/* Copyright (c) 2014, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -9,7 +9,7 @@ #include #include -int odp_init_dpdk(void) +int odp_init_platform(odp_global_platform_init_t *platform_params ODP_UNUSED) { int test_argc = 5; char *test_argv[6]; @@ -50,64 +50,7 @@ int odp_init_dpdk(void) return 0; } -int odp_init_global(void) +int odp_crypto_init_global(void) { - odp_thread_init_global(); - - odp_system_info_init(); - - if (odp_init_dpdk()) { - ODP_ERR("ODP dpdk init failed.\n"); - return -1; - } - - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; - } - - if (odp_buffer_pool_init_global()) { - ODP_ERR("ODP buffer pool init failed.\n"); - return -1; - } - - if (odp_queue_init_global()) { - ODP_ERR("ODP queue init failed.\n"); - return -1; - } - - if (odp_schedule_init_global()) { - ODP_ERR("ODP schedule init failed.\n"); - return -1; - } - - if (odp_pktio_init_global()) { - ODP_ERR("ODP packet io init failed.\n"); - return -1; - } - - if (odp_timer_init_global()) { - ODP_ERR("ODP timer init failed.\n"); - return -1; - } - - return 0; -} - - -int odp_init_local(int thr_id) -{ - odp_thread_init_local(thr_id); - - if (odp_pktio_init_local()) { - ODP_ERR("ODP packet io local init failed.\n"); - return -1; - } - - if (odp_schedule_init_local()) { - ODP_ERR("ODP schedule local init failed.\n"); - return -1; - } - return 0; } diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index f4dfdc1..c4aae9d 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -62,6 +62,7 @@ __LIB__libodp_la_SOURCES = \ odp_packet_flags.c \ odp_packet_io.c \ odp_packet_socket.c \ + odp_platform.c \ odp_queue.c \ odp_ring.c \ odp_rwlock.c \ diff --git a/platform/linux-generic/include/api/odp_init.h b/platform/linux-generic/include/api/odp_init.h index 490324a..4acaea4 100644 --- a/platform/linux-generic/include/api/odp_init.h +++ b/platform/linux-generic/include/api/odp_init.h @@ -23,23 +23,41 @@ extern "C" { #include +/** + * ODP initialisation + * Data that is required to initialize the ODP + * application, such as specifying a logging callback, the log level etc. + */ +typedef struct odp_global_init { +} odp_global_init_t; +/** + * ODP platform initialization + * Platform specific data. ODP does nothing with + * this data. + */ +typedef struct odp_global_platform_init { +} odp_global_platform_init_t; /** - * Perform global ODP initalisation. + * Perform global ODP initialisation. * * This function must be called once before calling * any other ODP API functions. - * + * @param[in] params Those parameters that are interpreted by ODP + * @param[in] platform_params Those parameters that are passed + * without interpretation to the implementation. * @return 0 if successful */ -int odp_init_global(void); +int odp_init_global(odp_global_init_t *params, + odp_global_platform_init_t *platform_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-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index aa79493..6c71fc9 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include /** * @file @@ -42,6 +43,8 @@ int odp_schedule_init_local(void); int odp_timer_init_global(void); int odp_timer_disarm_all(void); +int odp_init_platform(odp_global_platform_init_t *platform_params); + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 5b7e192..f595def 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -8,13 +8,18 @@ #include #include - -int odp_init_global(void) +int odp_init_global(odp_global_init_t *params ODP_UNUSED, + odp_global_platform_init_t *platform_params ODP_UNUSED) { odp_thread_init_global(); odp_system_info_init(); + if (odp_init_platform(platform_params)) { + ODP_ERR("ODP platform init failed.\n"); + return -1; + } + if (odp_shm_init_global()) { ODP_ERR("ODP shm init failed.\n"); return -1; diff --git a/platform/linux-generic/odp_platform.c b/platform/linux-generic/odp_platform.c new file mode 100644 index 0000000..a9efa7f --- /dev/null +++ b/platform/linux-generic/odp_platform.c @@ -0,0 +1,14 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +int odp_init_platform(odp_global_platform_init_t *platform_params ODP_UNUSED) +{ + return 0; +} diff --git a/platform/linux-keystone2/Makefile.am b/platform/linux-keystone2/Makefile.am index 8e5fbb3..6e3cc00 100644 --- a/platform/linux-keystone2/Makefile.am +++ b/platform/linux-keystone2/Makefile.am @@ -70,12 +70,13 @@ __LIB__libodp_la_SOURCES = \ odp_buffer.c \ odp_buffer_pool.c \ ../linux-generic/odp_coremask.c \ - odp_init.c \ + ../linux-generic/odp_init.c \ ../linux-generic/odp_linux.c \ odp_packet.c \ ../linux-generic/odp_packet_flags.c \ odp_packet_io.c \ ../linux-generic/odp_packet_socket.c \ + odp_platform.c \ odp_queue.c \ ../linux-generic/odp_ring.c \ ../linux-generic/odp_rwlock.c \ diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_platform.c similarity index 72% rename from platform/linux-keystone2/odp_init.c rename to platform/linux-keystone2/odp_platform.c index f832551..4659b8a 100644 --- a/platform/linux-keystone2/odp_init.c +++ b/platform/linux-keystone2/odp_platform.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, Linaro Limited +/* Copyright (c) 2014, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -15,17 +15,19 @@ #include /* - * Make region_configs[] global, because hw_config is saved in - * ti_em_rh_init_global() and it references region_configs[]. - */ + * * Make region_configs[] global, because hw_config is saved in + * * ti_em_rh_init_global() and it references region_configs[]. + * */ static ti_em_osal_hw_region_config_t region_configs[TI_ODP_REGION_NUM]; -static int ti_init_hw_config(void) +int odp_init_platform(odp_global_platform_init_t *platform_params ODP_UNUSED) { ti_em_rh_hw_config_t hw_config; ti_em_osal_hw_region_config_t *reg_config; memset(&hw_config, 0, sizeof(ti_em_rh_hw_config_t)); + ti_em_osal_core_init_global(); + /* Set ODP initialization parameters */ hw_config.private_free_queue_idx = MY_EM_PRIVATE_FREE_QUEUE_IDX; hw_config.hw_queue_base_idx = MY_EM_SCHED_QUEUE_IDX; @@ -89,65 +91,7 @@ static int ti_init_hw_config(void) return 0; } - -int odp_init_global(void) +int odp_crypto_init_global(void) { - odp_thread_init_global(); - - odp_system_info_init(); - - ti_em_osal_core_init_global(); - ti_init_hw_config(); - - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; - } - - if (odp_buffer_pool_init_global()) { - ODP_ERR("ODP buffer pool init failed.\n"); - return -1; - } - - if (odp_queue_init_global()) { - ODP_ERR("ODP queue init failed.\n"); - return -1; - } - - if (odp_schedule_init_global()) { - ODP_ERR("ODP schedule init failed.\n"); - return -1; - } - - if (odp_pktio_init_global()) { - ODP_ERR("ODP packet io init failed.\n"); - return -1; - } - - if (odp_timer_init_global()) { - ODP_ERR("ODP timer init failed.\n"); - return -1; - } - - return 0; -} - - -int odp_init_local(int thr_id) -{ - odp_thread_init_local(thr_id); - - ti_em_rh_init_local(); - - if (odp_pktio_init_local()) { - ODP_ERR("ODP packet io local init failed.\n"); - return -1; - } - - if (odp_schedule_init_local()) { - ODP_ERR("ODP schedule local init failed.\n"); - return -1; - } - return 0; } diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c index 89ebd2d..fc583c0 100644 --- a/test/api_test/odp_common.c +++ b/test/api_test/odp_common.c @@ -56,7 +56,7 @@ int odp_test_global_init(void) { memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(NULL, NULL)) { ODP_ERR("ODP global init failed.\n"); return -1; }