From patchwork Thu Aug 7 15:56:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 35055 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B00D921137 for ; Thu, 7 Aug 2014 16:03:46 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf27142673pab.8 for ; Thu, 07 Aug 2014 09:03:46 -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=8YxrbtcAtGFbT0ZIfb45eQSLMjg63ETNZjvAvhFYAEI=; b=JVS3W0dtHBBwwb78JljDu8T6vQKEdF0ngI9i4oaoaQcb0o+mFdH1cl+a5CL2FEC+4+ UloqwkSYyo2gQXAROlpmAhW/yQIAPA8kwzwupaARpr3wP+CDwO/X38Obg/FE0t0v7/QU +4+5poyiY5aUhJfTkpOhzR1PoV1ELhqhtwMSkZbdPkdsLBweNf+92ZxD1AaKqBy0V+7u r41p8bvdFwF1GXTGJ4fE6JsMr2Y4z0UcNEJczuSmXkRuHiZ5e9gc0CPFGH1pEikqf0Hp unrlPJe9cNdSeiwXHQwKM4HtRejDFfenzIGVN4kzEzVxMG/g6lXK7gQr1B5MBNO8lioq 5GPw== X-Gm-Message-State: ALoCoQl1mnQDRmpAYQIePxxomm0qRz2Gy/4uTwoZjQFMbCkRIG54aoFMJx6N5BUiy5SvHvq5gTtV X-Received: by 10.66.245.197 with SMTP id xq5mr653567pac.42.1407427426023; Thu, 07 Aug 2014 09:03:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.134 with SMTP id m6ls182102qge.8.gmail; Thu, 07 Aug 2014 09:03:45 -0700 (PDT) X-Received: by 10.52.149.209 with SMTP id uc17mr1199926vdb.65.1407427425910; Thu, 07 Aug 2014 09:03:45 -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 i6si1926850vdt.83.2014.08.07.09.03.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Aug 2014 09:03:45 -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 la4so6531779vcb.23 for ; Thu, 07 Aug 2014 09:03:45 -0700 (PDT) X-Received: by 10.53.3.169 with SMTP id bx9mr948869vdd.80.1407427425815; Thu, 07 Aug 2014 09:03:45 -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 tc5csp41716vcb; Thu, 7 Aug 2014 09:03:44 -0700 (PDT) X-Received: by 10.224.51.15 with SMTP id b15mr29559117qag.19.1407427047111; Thu, 07 Aug 2014 08:57:27 -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 z4si997023qaj.72.2014.08.07.08.56.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 Aug 2014 08:57:27 -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 1XFQ3k-0008SE-Iu; Thu, 07 Aug 2014 15:56:56 +0000 Received: from mail-la0-f53.google.com ([209.85.215.53]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XFQ3e-0008RW-3d for lng-odp@lists.linaro.org; Thu, 07 Aug 2014 15:56:50 +0000 Received: by mail-la0-f53.google.com with SMTP id gl10so3743011lab.12 for ; Thu, 07 Aug 2014 08:56:43 -0700 (PDT) X-Received: by 10.112.166.139 with SMTP id zg11mr16579498lbb.62.1407427003833; Thu, 07 Aug 2014 08:56:43 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-29-79.pppoe.mtu-net.ru. [91.76.29.79]) by mx.google.com with ESMTPSA id q2sm124878lah.8.2014.08.07.08.56.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Aug 2014 08:56:42 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 7 Aug 2014 19:56:36 +0400 Message-Id: <1407426996-12784-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] [PATCHv3] implement odp_init_global init mask 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 Add ability to specify which odp layers should be initialized. Signed-off-by: Maxim Uvarov --- v3: use uint32_t rename GQUEUE -> QUEUE GPOOL -> POOL v2: change logic according to v1. If flag set layer will be initialized. 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 | 10 ++++++- 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, 109 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..8079fd0 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_ALL & ~ODP_INIT_F_TIMER)) { 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..9c5ee6b 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_ALL & ~ODP_INIT_F_TIMER)) { 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..bada995 100644 --- a/include/odp_init.h +++ b/include/odp_init.h @@ -22,6 +22,13 @@ extern "C" { #include +#define ODP_INIT_F_ALL 0xffffffff +#define ODP_INIT_F_SHMINIT (1 << 0) +#define ODP_INIT_F_POOL (1 << 1) +#define ODP_INIT_F_QUEUE (1 << 2) +#define ODP_INIT_F_SCHEDULE (1 << 3) +#define ODP_INIT_F_PKTIO (1 << 4) +#define ODP_INIT_F_TIMER (1 << 5) @@ -31,9 +38,10 @@ extern "C" { * This function must be called once before calling * any other ODP API functions. * + * @param mask Mask odp layers to be initialized * @return 0 if successful */ -int odp_init_global(void); +int odp_init_global(uint32_t mask); /** diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index ecc2066..b6865e9 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(uint32_t mask) { 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 (mask & ODP_INIT_F_SHMINIT) { + 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 (mask & ODP_INIT_F_POOL) { + 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 (mask & ODP_INIT_F_QUEUE) { + 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 (mask & ODP_INIT_F_SCHEDULE) { + 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 (mask & ODP_INIT_F_PKTIO) { + 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 (mask & ODP_INIT_F_TIMER) { + 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..26cc019 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(uint32_t mask) { odp_thread_init_global(); odp_system_info_init(); - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; + if (mask & ODP_INIT_F_SHMINIT) { + 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 (mask & ODP_INIT_F_POOL) { + 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 (mask & ODP_INIT_F_QUEUE) { + 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 (mask & ODP_INIT_F_SCHEDULE) { + 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 (mask & ODP_INIT_F_PKTIO) { + 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 (mask & ODP_INIT_F_TIMER) { + 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..ffeb996 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(uint32_t mask) { 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 (mask & ODP_INIT_F_SHMINIT) { + 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 (mask & ODP_INIT_F_POOL) { + 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 (mask & ODP_INIT_F_QUEUE) { + 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 (mask & ODP_INIT_F_SCHEDULE) { + 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 (mask & ODP_INIT_F_PKTIO) { + 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 (mask & ODP_INIT_F_TIMER) { + 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; }