From patchwork Mon Aug 4 09:37:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 34822 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9284921F5F for ; Mon, 4 Aug 2014 09:38:02 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lf10sf49078511pab.1 for ; Mon, 04 Aug 2014 02:38:01 -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=ElQ0vfF3R4CLlwNcQE2kIc3hYOsnqiBmncbKZSWOF1A=; b=Dnfmgvd9iliiUTwswDYlAodL4PqP35eRR5vdPx8+56Pq0zQrvbGA1FDfwG7Cyh5KQb cEfWRzWpj3PiV2HHgqZw6y904nunuQc8s+XUx79sFeARswb22Xchm+f0VkjqT+vXSIKz y2nlcZIAUDgG8xxrFmazYmKu98cDT6t9Uxi4zs6m8hV2iLeMdqxr9jXUFyWQ7uR8OzHN 1N75gskudRw4oeYRYoKN0zaQEVKZlUoBa8ivyNIfFp2aTOeSqFHpQcsqIu1PRrDan/Xs 5e0J7X2sJl9fWAs+3FhXB4CoIJ2lCgmbY9ijyq9p9L2DFJZEY7w8Ek1gGVC2hriU7nbS gkWw== X-Gm-Message-State: ALoCoQmXlqjvJBQTgghl+PDC7jD5HbVtrqIUsf2rthc/G86ICIcxu8h0wSwiqBJvsBgg5PVP/tht X-Received: by 10.66.163.41 with SMTP id yf9mr8624721pab.36.1407145081906; Mon, 04 Aug 2014 02:38:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.50 with SMTP id i47ls2094616qgd.38.gmail; Mon, 04 Aug 2014 02:38:01 -0700 (PDT) X-Received: by 10.52.179.161 with SMTP id dh1mr408847vdc.78.1407145081805; Mon, 04 Aug 2014 02:38:01 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id ak16si11560804vdc.93.2014.08.04.02.38.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 02:38:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so10627058vcb.37 for ; Mon, 04 Aug 2014 02:38:01 -0700 (PDT) X-Received: by 10.220.252.198 with SMTP id mx6mr21847397vcb.15.1407145081715; Mon, 04 Aug 2014 02:38:01 -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 tc5csp290894vcb; Mon, 4 Aug 2014 02:38:01 -0700 (PDT) X-Received: by 10.224.120.195 with SMTP id e3mr34252441qar.5.1407145081122; Mon, 04 Aug 2014 02:38:01 -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 v7si27628873qap.118.2014.08.04.02.38.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 04 Aug 2014 02:38:01 -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 1XEEiN-0004vF-VU; Mon, 04 Aug 2014 09:37:59 +0000 Received: from mail-lb0-f176.google.com ([209.85.217.176]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEEiI-0004vA-5D for lng-odp@lists.linaro.org; Mon, 04 Aug 2014 09:37:54 +0000 Received: by mail-lb0-f176.google.com with SMTP id u10so5049070lbd.7 for ; Mon, 04 Aug 2014 02:37:48 -0700 (PDT) X-Received: by 10.112.99.70 with SMTP id eo6mr21395195lbb.43.1407145068100; Mon, 04 Aug 2014 02:37:48 -0700 (PDT) Received: from localhost.localdomain ([83.149.9.118]) by mx.google.com with ESMTPSA id o9sm4487357laj.39.2014.08.04.02.37.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 02:37:47 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 4 Aug 2014 13:37:20 +0400 Message-Id: <1407145040-8393-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH] implement odp_init_global flags 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: maxim.uvarov@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.178 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 For some cases all layers of odp initialization is not needed and can be skipped. For example odp_timer_init() launch timer which acts each second is not needed for all applications. Signed-off-by: Maxim Uvarov --- 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/packet_netmap/odp_pktio_netmap.c | 2 +- example/timer/odp_timer_test.c | 2 +- include/odp_init.h | 9 +++++- platform/linux-dpdk/odp_init.c | 50 ++++++++++++++++++++------------ platform/linux-generic/odp_init.c | 50 ++++++++++++++++++++------------ platform/linux-keystone2/odp_init.c | 50 ++++++++++++++++++++------------ test/api_test/odp_common.c | 2 +- 11 files changed, 108 insertions(+), 65 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index e4a72fa..af1ff89 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -530,7 +530,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL)) { 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 e331ff2..6b6c75a 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -288,7 +288,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(ODP_INIT_F_ALL)) { 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..f6197f8 100644 --- a/example/odp_example/odp_example.c +++ b/example/odp_example/odp_example.c @@ -934,7 +934,7 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL)) { printf("ODP global init failed.\n"); return -1; } diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index edf8cfd..3e56453 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -285,7 +285,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_NOTIMER)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/packet_netmap/odp_pktio_netmap.c b/example/packet_netmap/odp_pktio_netmap.c index 7d33b19..9e38607 100644 --- a/example/packet_netmap/odp_pktio_netmap.c +++ b/example/packet_netmap/odp_pktio_netmap.c @@ -201,7 +201,7 @@ int main(int argc, char *argv[]) int i; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_NOTIMER)) { 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..4e566bc 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(ODP_INIT_F_ALL)) { printf("ODP global init failed.\n"); return -1; } diff --git a/include/odp_init.h b/include/odp_init.h index 490324a..cbb16e9 100644 --- a/include/odp_init.h +++ b/include/odp_init.h @@ -22,6 +22,13 @@ extern "C" { #include +#define ODP_INIT_F_ALL 0 +#define ODP_INIT_F_NOSHMINIT (1 << 0) +#define ODP_INIT_F_NOGPOOL (1 << 1) +#define ODP_INIT_F_NOGQUEUE (1 << 2) +#define ODP_INIT_F_NOSCHEDULE (1 << 3) +#define ODP_INIT_F_NOPKTIO (1 << 4) +#define ODP_INIT_F_NOTIMER (1 >> 5) @@ -33,7 +40,7 @@ extern "C" { * * @return 0 if successful */ -int odp_init_global(void); +int odp_init_global(uint8_t flags); /** diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index ecc2066..bb18237 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(uint8_t flags) { odp_thread_init_global(); @@ -61,34 +61,46 @@ int odp_init_global(void) return -1; } - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; + if (!(flags & ODP_INIT_F_NOSHMINIT)) { + 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 (!(flags & ODP_INIT_F_NOGPOOL)) { + 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 (!(flags & ODP_INIT_F_NOGQUEUE)) { + 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 (!(flags & ODP_INIT_F_NOSCHEDULE)) { + 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 (!(flags & ODP_INIT_F_NOPKTIO)) { + 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; + if (!(flags & ODP_INIT_F_NOTIMER)) { + if (odp_timer_init_global()) { + ODP_ERR("ODP timer init failed.\n"); + return -1; + } } return 0; diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index d4c2eb8..16ba79a 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -9,40 +9,52 @@ #include -int odp_init_global(void) +int odp_init_global(uint8_t flags) { odp_thread_init_global(); odp_system_info_init(); - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; + if (!(flags & ODP_INIT_F_NOSHMINIT)) { + 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 (!(flags & ODP_INIT_F_NOGPOOL)) { + 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 (!(flags & ODP_INIT_F_NOGQUEUE)) { + 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 (!(flags & ODP_INIT_F_NOSCHEDULE)) { + 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 (!(flags & ODP_INIT_F_NOPKTIO)) { + 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; + if (!(flags & ODP_INIT_F_NOTIMER)) { + if (odp_timer_init_global()) { + ODP_ERR("ODP timer init failed.\n"); + return -1; + } } return 0; diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c index f832551..a11fb27 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(uint8_t flags) { odp_thread_init_global(); @@ -99,34 +99,46 @@ int odp_init_global(void) 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 (!(flags & ODP_INIT_F_NOSHMINIT)) { + 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 (!(flags & ODP_INIT_F_NOGPOOL)) { + 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 (!(flags & ODP_INIT_F_NOGQUEUE)) { + 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 (!(flags & ODP_INIT_F_NOSCHEDULE)) { + 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 (!(flags & ODP_INIT_F_NOPKTIO)) { + 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; + if (!(flags & ODP_INIT_F_NOTIMER)) { + if (odp_timer_init_global()) { + ODP_ERR("ODP timer 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..dcb13ed 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(ODP_INIT_F_ALL)) { ODP_ERR("ODP global init failed.\n"); return -1; }