From patchwork Mon Aug 4 15:23:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 34857 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EAA6921F5F for ; Mon, 4 Aug 2014 15:23:27 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf14788609igi.8 for ; Mon, 04 Aug 2014 08:23:27 -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=hI+mtivG1u7HrqpxOs2iVankY/zhs9VD5KaZOq+3b4M=; b=VYyFG6+K4P09FW9RZQpEuD4x4PVNnrPI9VUABl8tboIQaYpL0vu+F6iRL5cm+0i9u3 V1T5PxCAjNYASGVXJ0P5qGK4BHpXobGqicl8marJnurZUzWhC6OdzbZGv5Aa7VN6t1TR eAi9XSMQ3UHNoVgAx2w0hE3y74lkQ/Bbfe/TTCzZXGAh22+ma4AAEETK3mCTkVK5GEIW LBujpe0+ZmP4pT9QQNudFpSIndeaTW8pjJFjVqUCZhopsCa+Q9nbWRkEdTTxpW20/a8z BBH2fF5Xj8m++CoQEnveVSN+zH/S98/q1i0srPF/CfJAlh3WfImHmZww9O7l6dzvGTuX 25BA== X-Gm-Message-State: ALoCoQm9UPGUpGTkjI/6kKs9dUY+3fpYpCT/v746H3OSuKPw1vbMa9OspQ0H1MpFH2UB4YvERtjD X-Received: by 10.182.142.135 with SMTP id rw7mr8477410obb.46.1407165807427; Mon, 04 Aug 2014 08:23:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.113 with SMTP id l104ls2229182qga.61.gmail; Mon, 04 Aug 2014 08:23:27 -0700 (PDT) X-Received: by 10.52.83.227 with SMTP id t3mr20688103vdy.20.1407165807300; Mon, 04 Aug 2014 08:23:27 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id n6si12192854vec.0.2014.08.04.08.23.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 08:23:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so11491719vcb.27 for ; Mon, 04 Aug 2014 08:23:27 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr1709033vdb.86.1407165807149; Mon, 04 Aug 2014 08:23:27 -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 tc5csp312854vcb; Mon, 4 Aug 2014 08:23:26 -0700 (PDT) X-Received: by 10.140.40.210 with SMTP id x76mr16920345qgx.61.1407165806582; Mon, 04 Aug 2014 08:23:26 -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 8si29082102qgz.7.2014.08.04.08.23.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 04 Aug 2014 08:23:26 -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 1XEK6f-0005xu-EF; Mon, 04 Aug 2014 15:23:25 +0000 Received: from mail-la0-f50.google.com ([209.85.215.50]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEK6Z-0005wX-7l for lng-odp@lists.linaro.org; Mon, 04 Aug 2014 15:23:19 +0000 Received: by mail-la0-f50.google.com with SMTP id gf5so5486771lab.37 for ; Mon, 04 Aug 2014 08:23:13 -0700 (PDT) X-Received: by 10.152.87.229 with SMTP id bb5mr3656304lab.75.1407165792904; Mon, 04 Aug 2014 08:23:12 -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 l2sm28078316lba.28.2014.08.04.08.23.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 08:23:12 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 4 Aug 2014 19:23:06 +0400 Message-Id: <1407165786-32589-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] [PATCHv2] 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.182 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 --- 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..f119e99 100644 --- a/include/odp_init.h +++ b/include/odp_init.h @@ -22,6 +22,13 @@ extern "C" { #include +#define ODP_INIT_F_ALL 0xff +#define ODP_INIT_F_SHMINIT (1 << 0) +#define ODP_INIT_F_GPOOL (1 << 1) +#define ODP_INIT_F_GQUEUE (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(uint8_t mask); /** diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index ecc2066..76ac94d 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 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_GPOOL) { + 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_GQUEUE) { + 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..7649f9c 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 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_GPOOL) { + 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_GQUEUE) { + 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..de28fda 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 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_GPOOL) { + 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_GQUEUE) { + 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; }