From patchwork Mon Aug 25 15:55:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 35926 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 860BF20565 for ; Mon, 25 Aug 2014 15:56:08 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lf10sf117923694pab.1 for ; Mon, 25 Aug 2014 08:56:06 -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=bTbBV3V4zBzJCWByHEWTwDSkGKb9XY8kDrUpiRxTlfA=; b=dX/jCykeseJvIDEKkMbKI2z7COeEZEN5y9i5ZNpPsEDfExWP7rnLs02qY0k8ltNRC1 St2j7wgiwf++8bJZzjY/Zs8tA0i426EV5Bs7gbZgkT+e/9kcGjL7kKN0mymuh1Tr2SKt e0elvJMerEfSBh/GMlvA4XD4wER0de7M91Kn5jJtjt9/sWsaUQiLymU88kCxKRPRb5O9 XLVKjU9l3otrEmEAlOEeInhFENaV5vFiNrdJeDoB2TiIEZKuXSjZUF94ZcmZ08SUppL4 2ugq8TL8kc92pSDtYcRc8ryR1AeEFz3MyTlXDH+tnGIbL8jYAOOFzipYSRstiQ1aP5Ku /7VQ== X-Gm-Message-State: ALoCoQn++CIzGBw76kuDPYeihcj+8N3KsYCo1nZjhVnWU97uQjPi9ms8Y9cRjKHwnIrPIFqKS1p4 X-Received: by 10.70.34.195 with SMTP id b3mr7678614pdj.7.1408982164871; Mon, 25 Aug 2014 08:56:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.133 with SMTP id c5ls2230969qga.38.gmail; Mon, 25 Aug 2014 08:56:04 -0700 (PDT) X-Received: by 10.52.88.74 with SMTP id be10mr3518145vdb.54.1408982164704; Mon, 25 Aug 2014 08:56:04 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id g8si111271vdu.82.2014.08.25.08.56.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 08:56:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so15535685vcb.12 for ; Mon, 25 Aug 2014 08:56:04 -0700 (PDT) X-Received: by 10.52.3.40 with SMTP id 8mr16183264vdz.24.1408982164568; Mon, 25 Aug 2014 08:56:04 -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 uj3csp128285vcb; Mon, 25 Aug 2014 08:56:03 -0700 (PDT) X-Received: by 10.140.106.5 with SMTP id d5mr1214708qgf.23.1408982162957; Mon, 25 Aug 2014 08:56:02 -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 g71si186006qge.112.2014.08.25.08.56.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Aug 2014 08:56:02 -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 1XLwcj-000083-I2; Mon, 25 Aug 2014 15:56:01 +0000 Received: from mail-qc0-f170.google.com ([209.85.216.170]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XLwcd-00007y-0u for lng-odp@lists.linaro.org; Mon, 25 Aug 2014 15:55:55 +0000 Received: by mail-qc0-f170.google.com with SMTP id x3so14080384qcv.1 for ; Mon, 25 Aug 2014 08:55:49 -0700 (PDT) X-Received: by 10.224.163.83 with SMTP id z19mr37437219qax.68.1408982149700; Mon, 25 Aug 2014 08:55:49 -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 v111sm403849qge.7.2014.08.25.08.55.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Aug 2014 08:55:48 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 25 Aug 2014 11:55:41 -0400 Message-Id: <1408982141-16820-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH v2] 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.181 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. 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 | 113 ------------------- platform/linux-dpdk/odp_platform.c | 56 ++++++++++ platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/api/odp_init.h | 22 +++- 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 +- platform/linux-keystone2/odp_init.c | 153 -------------------------- platform/linux-keystone2/odp_platform.c | 97 ++++++++++++++++ test/api_test/odp_common.c | 2 +- 17 files changed, 207 insertions(+), 279 deletions(-) delete mode 100644 platform/linux-dpdk/odp_init.c create mode 100644 platform/linux-dpdk/odp_platform.c create mode 100644 platform/linux-generic/odp_platform.c delete mode 100644 platform/linux-keystone2/odp_init.c create mode 100644 platform/linux-keystone2/odp_platform.c 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_init.c deleted file mode 100644 index ecc2066..0000000 --- a/platform/linux-dpdk/odp_init.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include - -int odp_init_dpdk(void) -{ - int test_argc = 5; - char *test_argv[6]; - int core_count, i, num_cores = 0; - char core_mask[8]; - - core_count = odp_sys_core_count(); - for (i = 0; i < core_count; i++) - num_cores += (0x1 << i); - sprintf(core_mask, "%x", num_cores); - - test_argv[0] = malloc(sizeof("odp_dpdk")); - strcpy(test_argv[0], "odp_dpdk"); - test_argv[1] = malloc(sizeof("-c")); - strcpy(test_argv[1], "-c"); - test_argv[2] = malloc(sizeof(core_mask)); - strcpy(test_argv[2], core_mask); - test_argv[3] = malloc(sizeof("-n")); - strcpy(test_argv[3], "-n"); - test_argv[4] = malloc(sizeof("3")); - strcpy(test_argv[4], "3"); - - if (rte_eal_init(test_argc, (char **)test_argv) < 0) { - ODP_ERR("Cannot init the Intel DPDK EAL!"); - return -1; - } - - if (rte_pmd_init_all() < 0) { - ODP_ERR("Cannot init pmd\n"); - return -1; - } - - if (rte_eal_pci_probe() < 0) { - ODP_ERR("Cannot probe PCI\n"); - return -1; - } - - return 0; -} - -int odp_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-dpdk/odp_platform.c b/platform/linux-dpdk/odp_platform.c new file mode 100644 index 0000000..5a054fd --- /dev/null +++ b/platform/linux-dpdk/odp_platform.c @@ -0,0 +1,56 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +int odp_init_platform(odp_global_platform_init_t *platform_params ODP_UNUSED) +{ + int test_argc = 5; + char *test_argv[6]; + int core_count, i, num_cores = 0; + char core_mask[8]; + + core_count = odp_sys_core_count(); + for (i = 0; i < core_count; i++) + num_cores += (0x1 << i); + sprintf(core_mask, "%x", num_cores); + + test_argv[0] = malloc(sizeof("odp_dpdk")); + strcpy(test_argv[0], "odp_dpdk"); + test_argv[1] = malloc(sizeof("-c")); + strcpy(test_argv[1], "-c"); + test_argv[2] = malloc(sizeof(core_mask)); + strcpy(test_argv[2], core_mask); + test_argv[3] = malloc(sizeof("-n")); + strcpy(test_argv[3], "-n"); + test_argv[4] = malloc(sizeof("3")); + strcpy(test_argv[4], "3"); + + if (rte_eal_init(test_argc, (char **)test_argv) < 0) { + ODP_ERR("Cannot init the Intel DPDK EAL!"); + return -1; + } + + if (rte_pmd_init_all() < 0) { + ODP_ERR("Cannot init pmd\n"); + return -1; + } + + if (rte_eal_pci_probe() < 0) { + ODP_ERR("Cannot probe PCI\n"); + return -1; + } + + return 0; +} + +int odp_crypto_init_global(void) +{ + 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..45db5f5 100644 --- a/platform/linux-generic/include/api/odp_init.h +++ b/platform/linux-generic/include/api/odp_init.h @@ -23,23 +23,39 @@ 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. * * @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_init.c deleted file mode 100644 index f832551..0000000 --- a/platform/linux-keystone2/odp_init.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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) -{ - 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)); - - /* 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; - hw_config.dma_idx = -1; /* not used */ - hw_config.dma_queue_base_idx = 0; /* not used */ - hw_config.device_id = MY_EM_DEVICE_ID; - hw_config.process_id = MY_EM_PROCESS_ID; - hw_config.chain_config_ptr = NULL; - hw_config.dispatch_mode = MY_EM_DISPATCH_MODE; - - /* The location of the PDSP communication memory (physical address) */ - hw_config.pdsp_comm_mem_config.paddr = MY_EM_PDSP_COMM_MEM_BASE; - hw_config.pdsp_comm_mem_config.vaddr = MY_EM_PDSP_COMM_MEM_VBASE; - hw_config.pdsp_comm_mem_config.size = MY_EM_PDSP_COMM_MEM_SIZE; - hw_config.pdsp_comm_mem_config.offset = MY_EM_PDSP_COMM_MEM_OFFSET; - - TI_EM_OSAL_TRACE(2, "physical address of the PDSP communication memory is 0x%x\n", - hw_config.pdsp_comm_mem_config.paddr); - - /* Define descriptor regions */ - reg_config = ®ion_configs[TI_EM_RH_PUBLIC]; - reg_config->region_idx = TI_ODP_PUBLIC_REGION_IDX; - reg_config->desc_size = - ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_packet_hdr_t)); - reg_config->desc_num = TI_ODP_PUBLIC_DESC_NUM; - reg_config->desc_base = TI_ODP_PUBLIC_DESC_BASE; - reg_config->desc_vbase = TI_ODP_PUBLIC_DESC_VBASE; - reg_config->desc_offset = TI_ODP_PUBLIC_DESC_OFFSET; - reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR; - reg_config->start_idx = TI_ODP_PUBLIC_START_DESC_IDX; - - reg_config = ®ion_configs[TI_EM_RH_PRIVATE]; - reg_config->region_idx = TI_ODP_PRIVATE_REGION_IDX; - reg_config->desc_size = TI_EM_PRIVATE_EVENT_DSC_SIZE; - reg_config->desc_num = TI_EM_RH_PRIVATE_EVENT_NUM; - reg_config->desc_base = TI_ODP_PRIVATE_DESC_BASE; - reg_config->desc_vbase = TI_ODP_PRIVATE_DESC_VBASE; - reg_config->desc_offset = TI_ODP_PRIVATE_DESC_OFFSET; - reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR; - reg_config->start_idx = TI_ODP_PRIVATE_START_DESC_IDX; - - hw_config.region_num = TI_ODP_REGION_NUM; - hw_config.region_configs = ®ion_configs[0]; - - /* Define PDSP configuration */ - hw_config.pdsp_num = 0; - /* do not use router (no chaining) */ - hw_config.pdsp_router.pdsp_id = -1; - - TI_EM_OSAL_TRACE(1, "calling EM global initialization\n"); - - /* call OpenEM global initialization */ - if (ti_em_rh_init_global(0, - NULL, - MY_EM_CORE_NUM, - &hw_config) != EM_OK) { - TI_EM_OSAL_ERROR("EM global initialization failed!\n"); - return -1; - } - - return 0; -} - - -int odp_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/platform/linux-keystone2/odp_platform.c b/platform/linux-keystone2/odp_platform.c new file mode 100644 index 0000000..4659b8a --- /dev/null +++ b/platform/linux-keystone2/odp_platform.c @@ -0,0 +1,97 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * * 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]; + +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; + hw_config.dma_idx = -1; /* not used */ + hw_config.dma_queue_base_idx = 0; /* not used */ + hw_config.device_id = MY_EM_DEVICE_ID; + hw_config.process_id = MY_EM_PROCESS_ID; + hw_config.chain_config_ptr = NULL; + hw_config.dispatch_mode = MY_EM_DISPATCH_MODE; + + /* The location of the PDSP communication memory (physical address) */ + hw_config.pdsp_comm_mem_config.paddr = MY_EM_PDSP_COMM_MEM_BASE; + hw_config.pdsp_comm_mem_config.vaddr = MY_EM_PDSP_COMM_MEM_VBASE; + hw_config.pdsp_comm_mem_config.size = MY_EM_PDSP_COMM_MEM_SIZE; + hw_config.pdsp_comm_mem_config.offset = MY_EM_PDSP_COMM_MEM_OFFSET; + + TI_EM_OSAL_TRACE(2, "physical address of the PDSP communication memory is 0x%x\n", + hw_config.pdsp_comm_mem_config.paddr); + + /* Define descriptor regions */ + reg_config = ®ion_configs[TI_EM_RH_PUBLIC]; + reg_config->region_idx = TI_ODP_PUBLIC_REGION_IDX; + reg_config->desc_size = + ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_packet_hdr_t)); + reg_config->desc_num = TI_ODP_PUBLIC_DESC_NUM; + reg_config->desc_base = TI_ODP_PUBLIC_DESC_BASE; + reg_config->desc_vbase = TI_ODP_PUBLIC_DESC_VBASE; + reg_config->desc_offset = TI_ODP_PUBLIC_DESC_OFFSET; + reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR; + reg_config->start_idx = TI_ODP_PUBLIC_START_DESC_IDX; + + reg_config = ®ion_configs[TI_EM_RH_PRIVATE]; + reg_config->region_idx = TI_ODP_PRIVATE_REGION_IDX; + reg_config->desc_size = TI_EM_PRIVATE_EVENT_DSC_SIZE; + reg_config->desc_num = TI_EM_RH_PRIVATE_EVENT_NUM; + reg_config->desc_base = TI_ODP_PRIVATE_DESC_BASE; + reg_config->desc_vbase = TI_ODP_PRIVATE_DESC_VBASE; + reg_config->desc_offset = TI_ODP_PRIVATE_DESC_OFFSET; + reg_config->desc_flag = TI_EM_RH_UNMANAGED_DESCRIPTOR; + reg_config->start_idx = TI_ODP_PRIVATE_START_DESC_IDX; + + hw_config.region_num = TI_ODP_REGION_NUM; + hw_config.region_configs = ®ion_configs[0]; + + /* Define PDSP configuration */ + hw_config.pdsp_num = 0; + /* do not use router (no chaining) */ + hw_config.pdsp_router.pdsp_id = -1; + + TI_EM_OSAL_TRACE(1, "calling EM global initialization\n"); + + /* call OpenEM global initialization */ + if (ti_em_rh_init_global(0, + NULL, + MY_EM_CORE_NUM, + &hw_config) != EM_OK) { + TI_EM_OSAL_ERROR("EM global initialization failed!\n"); + return -1; + } + + return 0; +} + +int odp_crypto_init_global(void) +{ + 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; }