From patchwork Fri Sep 26 15:19:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 38004 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2356720F2E for ; Fri, 26 Sep 2014 15:20:44 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id c13sf6200685eek.11 for ; Fri, 26 Sep 2014 08:20:43 -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:in-reply-to :references: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=lMSQAci9Ynu5zPV5Bq6AGbFoDzVFHdfr5PNOlr8tmNA=; b=J1yeOpLg8wmpa3bIA8pmXnMwTQNg60R4ThCsHgd83wj+U2QsjoYdG9GcDuQhPNcmym qXfyaQvXxyfXY8X9nb0UAwrOP030FLE2QA67lkoSQTzss1eVh5PqcdNki5IDghnIzZFx bxGObCa675XVHICUf4C4MDpyITxI2y2jmXGUVE3xHV/NGC27XrOYDw0SEZG9Ry9n1yWj dWRSunpMlnDTxgfB9G45GnSd06hzIUgc9ol/oGPi61pYPynSJjB3oKtCwZLelCqVGguy aFy1THeCysxd6XosQYaEcCoRqelfBYRD4LwcHdBZ7419aSWPBdxEIgtlXGcUh33Yl8Ah qkcA== X-Gm-Message-State: ALoCoQmOikQp+vfdrHXGouqsnfiy+2HFxv9WCb49Ix2ziZhtKIu0GYyz8SgB+foIwAdZVkjrm8J6 X-Received: by 10.112.89.8 with SMTP id bk8mr3247794lbb.6.1411744843181; Fri, 26 Sep 2014 08:20:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.224.161 with SMTP id rd1ls397526lac.95.gmail; Fri, 26 Sep 2014 08:20:43 -0700 (PDT) X-Received: by 10.152.26.133 with SMTP id l5mr21579298lag.4.1411744842958; Fri, 26 Sep 2014 08:20:42 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com [209.85.215.51]) by mx.google.com with ESMTPS id h1si7584495lbf.84.2014.09.26.08.20.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Sep 2014 08:20:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id pv20so5191827lab.10 for ; Fri, 26 Sep 2014 08:20:42 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr20776025lac.44.1411744842371; Fri, 26 Sep 2014 08:20:42 -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.112.130.169 with SMTP id of9csp80414lbb; Fri, 26 Sep 2014 08:20:39 -0700 (PDT) X-Received: by 10.229.100.68 with SMTP id x4mr28682409qcn.29.1411744838978; Fri, 26 Sep 2014 08:20:38 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id q7si6205551qcf.37.2014.09.26.08.20.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 26 Sep 2014 08:20:38 -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-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XXXK0-000487-C9; Fri, 26 Sep 2014 15:20:36 +0000 Received: from mail-la0-f44.google.com ([209.85.215.44]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XXXJW-00046Z-Lr for lng-odp@lists.linaro.org; Fri, 26 Sep 2014 15:20:07 +0000 Received: by mail-la0-f44.google.com with SMTP id gi9so4438514lab.31 for ; Fri, 26 Sep 2014 08:20:00 -0700 (PDT) X-Received: by 10.112.145.100 with SMTP id st4mr10623900lbb.17.1411744800114; Fri, 26 Sep 2014 08:20:00 -0700 (PDT) Received: from localhost.localdomain ([81.200.0.212]) by mx.google.com with ESMTPSA id x5sm1979656lad.30.2014.09.26.08.19.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Sep 2014 08:19:58 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 26 Sep 2014 19:19:43 +0400 Message-Id: <1411744784-2309-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1411744784-2309-1-git-send-email-maxim.uvarov@linaro.org> References: <1411744784-2309-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 2/3] git split: delete keystone2 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.215.51 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 keystone2 will be developed and supported in different git repo: https://git.linaro.org/lng/odp-keystone2.git Signed-off-by: Maxim Uvarov --- configure.ac | 1 - platform/linux-keystone2/Makefile.am | 89 --- platform/linux-keystone2/Makefile.inc | 18 - platform/linux-keystone2/README | 72 --- platform/linux-keystone2/include/api/mcsdk_tune.h | 208 ------- platform/linux-keystone2/include/api/odp_buffer.h | 174 ------ .../linux-keystone2/include/api/odp_buffer_pool.h | 101 --- platform/linux-keystone2/include/api/odp_crypto.h | 372 ----------- platform/linux-keystone2/include/api/odp_packet.h | 257 -------- .../linux-keystone2/include/api/odp_packet_io.h | 137 ---- platform/linux-keystone2/include/api/odp_state.h | 56 -- .../linux-keystone2/include/api/odp_ti_mcsdk.h | 58 -- .../linux-keystone2/include/odp_buffer_internal.h | 60 -- .../include/odp_buffer_pool_internal.h | 31 - .../linux-keystone2/include/odp_crypto_internal.h | 84 --- .../linux-keystone2/include/odp_debug_internal.h | 70 --- platform/linux-keystone2/include/odp_internal.h | 53 -- .../linux-keystone2/include/odp_packet_internal.h | 167 ----- .../include/odp_packet_io_internal.h | 47 -- .../linux-keystone2/include/odp_packet_io_queue.h | 34 - .../linux-keystone2/include/odp_queue_internal.h | 134 ---- platform/linux-keystone2/include/sockrmmsg.h | 27 - platform/linux-keystone2/include/sockutils.h | 46 -- platform/linux-keystone2/mcsdk/mcsdk_init.c | 690 --------------------- platform/linux-keystone2/mcsdk/mcsdk_navig.c | 267 -------- platform/linux-keystone2/mcsdk/mcsdk_rmclient.c | 273 -------- platform/linux-keystone2/mcsdk/sockutils.c | 223 ------- platform/linux-keystone2/odp_buffer.c | 70 --- platform/linux-keystone2/odp_buffer_pool.c | 132 ---- platform/linux-keystone2/odp_crypto.c | 492 --------------- platform/linux-keystone2/odp_init.c | 88 --- platform/linux-keystone2/odp_packet.c | 345 ----------- platform/linux-keystone2/odp_packet_io.c | 484 --------------- platform/linux-keystone2/odp_queue.c | 425 ------------- 34 files changed, 5785 deletions(-) delete mode 100644 platform/linux-keystone2/Makefile.am delete mode 100644 platform/linux-keystone2/Makefile.inc delete mode 100644 platform/linux-keystone2/README delete mode 100644 platform/linux-keystone2/include/api/mcsdk_tune.h delete mode 100644 platform/linux-keystone2/include/api/odp_buffer.h delete mode 100644 platform/linux-keystone2/include/api/odp_buffer_pool.h delete mode 100644 platform/linux-keystone2/include/api/odp_crypto.h delete mode 100644 platform/linux-keystone2/include/api/odp_packet.h delete mode 100644 platform/linux-keystone2/include/api/odp_packet_io.h delete mode 100644 platform/linux-keystone2/include/api/odp_state.h delete mode 100644 platform/linux-keystone2/include/api/odp_ti_mcsdk.h delete mode 100644 platform/linux-keystone2/include/odp_buffer_internal.h delete mode 100644 platform/linux-keystone2/include/odp_buffer_pool_internal.h delete mode 100644 platform/linux-keystone2/include/odp_crypto_internal.h delete mode 100644 platform/linux-keystone2/include/odp_debug_internal.h delete mode 100644 platform/linux-keystone2/include/odp_internal.h delete mode 100644 platform/linux-keystone2/include/odp_packet_internal.h delete mode 100644 platform/linux-keystone2/include/odp_packet_io_internal.h delete mode 100644 platform/linux-keystone2/include/odp_packet_io_queue.h delete mode 100644 platform/linux-keystone2/include/odp_queue_internal.h delete mode 100644 platform/linux-keystone2/include/sockrmmsg.h delete mode 100644 platform/linux-keystone2/include/sockutils.h delete mode 100644 platform/linux-keystone2/mcsdk/mcsdk_init.c delete mode 100644 platform/linux-keystone2/mcsdk/mcsdk_navig.c delete mode 100644 platform/linux-keystone2/mcsdk/mcsdk_rmclient.c delete mode 100644 platform/linux-keystone2/mcsdk/sockutils.c delete mode 100644 platform/linux-keystone2/odp_buffer.c delete mode 100644 platform/linux-keystone2/odp_buffer_pool.c delete mode 100644 platform/linux-keystone2/odp_crypto.c delete mode 100644 platform/linux-keystone2/odp_init.c delete mode 100644 platform/linux-keystone2/odp_packet.c delete mode 100644 platform/linux-keystone2/odp_packet_io.c delete mode 100644 platform/linux-keystone2/odp_queue.c diff --git a/configure.ac b/configure.ac index 1d882f4..296c9c5 100644 --- a/configure.ac +++ b/configure.ac @@ -150,7 +150,6 @@ AC_CHECK_FUNCS([bzero clock_gettime gethostbyname getpagesize gettimeofday memse AC_CONFIG_FILES([Makefile platform/Makefile platform/linux-generic/Makefile - platform/linux-keystone2/Makefile example/Makefile example/generator/Makefile example/ipsec/Makefile diff --git a/platform/linux-keystone2/Makefile.am b/platform/linux-keystone2/Makefile.am deleted file mode 100644 index f72b350..0000000 --- a/platform/linux-keystone2/Makefile.am +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (c) 2014, Linaro Limited -# Copyright (c) 2014, Texas Instruments Incorporated -# All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause - -include $(top_srcdir)/Makefile.inc -include $(top_srcdir)/platform/Makefile.inc -include Makefile.inc - -AM_CFLAGS += -I$(srcdir)/include -AM_CFLAGS += -I$(srcdir)/include/api -AM_CFLAGS += -I$(top_srcdir)/platform/linux-generic/include -AM_CFLAGS += -I$(top_srcdir)/platform/linux-generic/include/api -AM_CFLAGS += -I$(top_srcdir)/helper/include -KS2_LIBS = -lnwalsa_$(KS2_DEVICE) -lpktlib -lpa -lsa -lcppi_$(KS2_DEVICE) -lqmss_$(KS2_DEVICE) -lrm -lhplib_$(KS2_DEVICE) -LIBS += $(KS2_LIBS) - -include_HEADERS = \ - $(srcdir)/include/api/odp_buffer.h \ - $(srcdir)/include/api/odp_buffer_pool.h \ - $(srcdir)/include/api/odp_crypto.h \ - $(srcdir)/include/api/odp_packet.h \ - $(srcdir)/include/api/odp_packet_io.h \ - $(srcdir)/include/api/odp_state.h \ - $(srcdir)/include/api/odp_ti_mcsdk.h \ - $(srcdir)/include/api/mcsdk_tune.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_align.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_atomic.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_barrier.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_byteorder.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_compiler.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_config.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_coremask.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_debug.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_hints.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_init.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_packet_flags.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_queue.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_rwlock.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_schedule.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_shared_memory.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_spinlock.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_std_types.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_sync.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_system_info.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_thread.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_ticketlock.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_time.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_timer.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_version.h - -subdirheadersdir = $(includedir)/helper -subdirheaders_HEADERS = \ - $(top_srcdir)/helper/include/odph_chksum.h \ - $(top_srcdir)/helper/include/odph_eth.h \ - $(top_srcdir)/helper/include/odph_ip.h \ - $(top_srcdir)/helper/include/odph_linux.h \ - $(top_srcdir)/helper/include/odph_packet.h \ - $(top_srcdir)/helper/include/odph_ring.h \ - $(top_srcdir)/helper/include/odph_udp.h - -__LIB__libodp_la_SOURCES = \ - odp_buffer.c \ - odp_buffer_pool.c \ - odp_crypto.c \ - odp_init.c \ - odp_packet.c \ - odp_packet_io.c \ - odp_queue.c \ - mcsdk/mcsdk_init.c \ - mcsdk/mcsdk_navig.c \ - mcsdk/mcsdk_rmclient.c \ - mcsdk/sockutils.c \ - ../linux-generic/odp_barrier.c \ - ../linux-generic/odp_coremask.c \ - ../linux-generic/odp_linux.c \ - ../linux-generic/odp_packet_flags.c \ - ../linux-generic/odp_ring.c \ - ../linux-generic/odp_rwlock.c \ - ../linux-generic/odp_schedule.c \ - ../linux-generic/odp_shared_memory.c \ - ../linux-generic/odp_spinlock.c \ - ../linux-generic/odp_system_info.c \ - ../linux-generic/odp_thread.c \ - ../linux-generic/odp_ticketlock.c \ - ../linux-generic/odp_time.c \ - ../linux-generic/odp_timer.c diff --git a/platform/linux-keystone2/Makefile.inc b/platform/linux-keystone2/Makefile.inc deleted file mode 100644 index 4757781..0000000 --- a/platform/linux-keystone2/Makefile.inc +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2014, Linaro Limited -# Copyright (c) 2014, Texas Instruments Incorporated -# All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause - -# MCSDK_CFLAGS should match flags used to build McSDK libraries - -KS2_DEVICE ?= k2k -CSL_DEVICE = DEVICE_K2K - -MCSDK_CFLAGS = -D$(CSL_DEVICE) -D_GNU_SOURCE -D_LITTLE_ENDIAN -MCSDK_CFLAGS += -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -DMAKEFILE_BUILD -MCSDK_CFLAGS += -DNWAL_ENABLE_SA - -AM_CFLAGS += $(MCSDK_CFLAGS) -AM_CFLAGS += -I$(SDK_INSTALL_PATH)/usr/include -AM_LDFLAGS += -L$(SDK_INSTALL_PATH)/usr/lib diff --git a/platform/linux-keystone2/README b/platform/linux-keystone2/README deleted file mode 100644 index 22ec676..0000000 --- a/platform/linux-keystone2/README +++ /dev/null @@ -1,72 +0,0 @@ -Copyright (c) 2014, Linaro Limited -Copyright (c) 2014, Texas Instruments Incorporated -All rights reserved. - -SPDX-License-Identifier: BSD-3-Clause - -1. Intro - -OpenDataPlane implementation for TI Keystone2 SoC's. Current version supports -HW buffer, queues, Packet IO and Crypto APIs. This drop does not target high -performance. It is rather proof of ODP API functionality. It still uses -linux-generic's SW scheduler. - -2. ODP build-time dependecies - - 2.1 McSDK libraries - -Keystone ODP is based on slightly modified TI Multicore SDK libraries. -Check a following README file for instructions: -https://git.linaro.org/people/taras.kondratiuk/ks2-odp-build.git/blob/refs/heads/master:/README - -3. ODP build - -./bootstrap -./configure --host=arm-linux-gnueabihf --with-platform=linux-keystone2 --with-sdk-install-path= --enable-static --disable-shared -# if openem is installed to the default path then you don't need to specify -# --with-sdk-install-path= when you run configure. -make - -4. ODP run-time dependencies - - 4.1 U-boot - -Sources: git://git.ti.com/keystone-linux/u-boot.git -Tag: K2_UBOOT_2013_01_14.07 -config: make _evm_config # is "k2hk", "k2l" or "k2e" -Build instructions: -http://processors.wiki.ti.com/index.php/MCSDK_UG_Chapter_Exploring#U-Boot_Build_instructions - - 4.2 Boot monitor - -Sources: git://git.ti.com/keystone-linux/boot-monitor.git -Tag: K2_BM_14.07 -Build instructions: -http://processors.wiki.ti.com/index.php/MCSDK_UG_Chapter_Exploring#Boot_Monitor_Build_instructions - - 4.3 Linux kernel - -Sources: git://git.ti.com/keystone-linux/linux.git -Tag: K2_LINUX_03.10.10_14.07 -config: keystone2_defconfig -DTB: k2hk-evm.dtb - -Current implementation relies on kernel to enable and configure network -interfaces. - - 4.3 McSDK parts - -Parts are built along with McSDK libraries (see item #2.1 of this instruction) - -- HPLIB kernel module (hplibmod.ko) -- Resource Manager server - -4. Limitations - -ODP does not provide API to free resources on application exit. So on the next -application start there maybe no resources available or HW resource can be in -unpredictable state which may lead to unpredictable behaviour. Hence, it is -recommended to reboot the system after ODP application exit. This limitation -will be partially addressed with 'free' API in future, but this doesn't handle -an application crash case. There maybe a need to add clean-up capabilities to -Resource Management server. diff --git a/platform/linux-keystone2/include/api/mcsdk_tune.h b/platform/linux-keystone2/include/api/mcsdk_tune.h deleted file mode 100644 index 204330e..0000000 --- a/platform/linux-keystone2/include/api/mcsdk_tune.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef MCSDK_TUNE_H_ -#define MCSDK_TUNE_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup tune_parameters - * @def NETAPI_ENABLE_SECURITY - * Define this to enable securtiy. - * @note Libraries using netapi need to be built with SA enabled -*/ -#ifdef NWAL_ENABLE_SA -#define NETAPI_ENABLE_SECURITY -#endif - -/** - * @ingroup tune_parameters - * @def NETAPI_USE_DDR - * Define this to enable use of cached DDR for buffers and descriptors. - * @note Do not define if USE_MSMC defined below -*/ -#define NETAPI_USE_DDR - -/** - * @ingroup tune_parameters - * @def NETAPI_USE_MSMC - * Define this to enable use of un-cached MSMC for buffers and descriptors - * @note Do not define if USE_DDR defined above -*/ - -#if defined(NETAPI_USE_MSMC) && defined(NETAPI_USE_DDR) -#error "only define NETAPI_USE_MSMC or NETAPI_USE_DDR" -#endif - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_NUM_CORES - * This defines the number of cores (theads) - */ -#define TUNE_NETAPI_NUM_CORES 5 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_PERM_MEM_SZ - * This defines how much contiguous memory to grab. This is used for - * descriptors and buffers in the case of uncached configuration only. - * descriptors and buffers. Can't be bigger than msmc if - * MSMC memory is being using uncached. - */ -#define TUNE_NETAPI_PERM_MEM_SZ (2*1024*1024) - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_DEFAULT_BUFFER_SIZE - * This defines the size of the netapi default pktlib heap buffers This - * can be set at @ref netapi_init - */ -#define TUNE_NETAPI_DEFAULT_BUFFER_SIZE 1600 - - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_DEFAULT_NUM_BUFFERS - * This defines the number of netapi default pktlib heap buffers - * (and assoc descriptors) this can be set at @ref netapi_init - */ -#define TUNE_NETAPI_DEFAULT_NUM_BUFFERS 200 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM - * Defines the number of of QM descriptors (total). - * @note Must be a power or 2. 16384 is abs max. - */ -#define TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM 0x4000 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_NUM_GLOBAL_DESC - * This defines the number of global descriptors. - * @note Must be a power or 2 -*/ -#define TUNE_NETAPI_NUM_GLOBAL_DESC TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_DESC_SIZE - * This defines the descriptor size - * @note This define should NOT be changes - */ -#define TUNE_NETAPI_DESC_SIZE 128 - -#ifdef NETAPI_USE_DDR -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_QM_START_INDEX - * This defines the queue manager start index - * @note This must reflect what the kernel is uding for their region, - * see device tree blob for details. - */ -#define TUNE_NETAPI_QM_START_INDEX 0 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_QM_GLOBAL_REGION - * This defines the queue manager global region - * @note This must reflect what the kernel is using for their region, - * see device tree blob for details. - */ -#define TUNE_NETAPI_QM_GLOBAL_REGION 18 - -#else /* use msmc */ -#define TUNE_NETAPI_QM_START_INDEX 0 -#define TUNE_NETAPI_QM_GLOBAL_REGION 0 -#endif - - -/* NWAL internal config. Should not have to change */ -#define TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC 32 -#define TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC 200 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_MAC - * This defines the number of logical mac addresses - */ -#define TUNE_NETAPI_MAX_NUM_MAC 64 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_IP - * This defines the number of ip addresses - */ -#define TUNE_NETAPI_MAX_NUM_IP 64 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE - * This defines the number of ports per core - */ -#define TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE 4 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_PORTS - * This defines the number maximum number of ports - */ -#define TUNE_NETAPI_MAX_NUM_PORTS (TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE * \ - TUNE_NETAPI_NUM_CORES) - -#ifdef NETAPI_ENABLE_SECURITY -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS - * This defines the number maximum number of ipsec channels - */ -#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS 128 -#else -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS - * This defines the number maximum number of ipsec channels - */ -#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS 0 -#endif - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_L2_L3_HDRS - * This defines the number maximum number of L2_L3 headers to reserve - * in the nwal layer. This should be kept small as transport lib does not - * expose this nwal feature by default - */ -#define TUNE_NETAPI_MAX_NUM_L2_L3_HDRS 3 - -/** - * @ingroup tune_parameters - * @def TUNE_NETAPI_MAX_NUM_TRANS - * This defines the number maximum number of transactions with NETCP that - * can be outstanding at any one time - */ -#define TUNE_NETAPI_MAX_NUM_TRANS (TUNE_NETAPI_MAX_NUM_MAC + \ - TUNE_NETAPI_MAX_NUM_IP + \ - TUNE_NETAPI_MAX_NUM_PORTS + \ - TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS) - -/* PA control buffer pool (internal) */ -#define TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE 520 -#define TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF 16 -#define TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF 16 - - -#ifdef __cplusplus -} -#endif - -#endif /* MCSDK_TUNE_H_ */ diff --git a/platform/linux-keystone2/include/api/odp_buffer.h b/platform/linux-keystone2/include/api/odp_buffer.h deleted file mode 100644 index 1889cfb..0000000 --- a/platform/linux-keystone2/include/api/odp_buffer.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP buffer descriptor - */ - -#ifndef ODP_BUFFER_H_ -#define ODP_BUFFER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * ODP buffer - */ -typedef Ti_Pkt * odp_buffer_t; - -#define ODP_BUFFER_INVALID ((odp_buffer_t)0) /**< Invalid buffer */ - -/** - * @internal Convert ODP buffer to PKTLIB packet handle - * - * @param buf Buffer handle - * - * @return PKTLIB packet handle - */ -static inline Ti_Pkt *_odp_buf_to_ti_pkt(odp_buffer_t buf) -{ - return (Ti_Pkt *)buf; -} - -/** - * @internal Convert PKTLIB packet handle to ODP buffer - * - * @param pkt PKTLIB packet handle - * - * @return ODP buffer handle - */ -static inline odp_buffer_t _ti_pkt_to_odp_buf(Ti_Pkt *pkt) -{ - return (odp_buffer_t)pkt; -} - -/** - * @internal Convert ODP buffer to CPPI descriptor - * - * @param buf Buffer handle - * - * @return CPPI descriptor - */ -static inline Cppi_HostDesc *_odp_buf_to_cppi_desc(odp_buffer_t buf) -{ - return Pktlib_getDescFromPacket(_odp_buf_to_ti_pkt(buf)); -} - -/** - * @internal Convert CPPI descriptor to ODP buffer - * - * @param desc CPPI descriptor pointer - * - * @return ODP buffer handle - */ -static inline odp_buffer_t _cppi_desc_to_odp_buf(Cppi_HostDesc *desc) -{ - return _ti_pkt_to_odp_buf(Pktlib_getPacketFromDesc(desc)); -} - -/** - * Buffer start address - * - * @param buf Buffer handle - * - * @return Buffer start address - */ -static inline void *odp_buffer_addr(odp_buffer_t buf) -{ - return (void *)_odp_buf_to_cppi_desc(buf)->buffPtr; -} - -/** - * Buffer maximum data size - * - * @param buf Buffer handle - * - * @return Buffer maximum data size - */ -static inline size_t odp_buffer_size(odp_buffer_t buf) -{ - return _odp_buf_to_cppi_desc(buf)->buffLen; -} - -#define ODP_BUFFER_TYPE_INVALID (-1) /**< Buffer type invalid */ -#define ODP_BUFFER_TYPE_ANY 0 /**< Buffer that can hold any other - buffer type */ -#define ODP_BUFFER_TYPE_RAW 1 /**< Raw buffer, no additional metadata */ -#define ODP_BUFFER_TYPE_PACKET 2 /**< Packet buffer */ -#define ODP_BUFFER_TYPE_TIMEOUT 3 /**< Timeout buffer */ -/** - * Buffer type - * - * @param buf Buffer handle - * - * @return Buffer type - */ -static inline int odp_buffer_type(odp_buffer_t buf) -{ - return Pktlib_getUsrFlags(_odp_buf_to_ti_pkt(buf)); -} - -/** - * Tests if buffer is valid - * - * @param buf Buffer handle - * - * @return 1 if valid, otherwise 0 - */ -static inline int odp_buffer_is_valid(odp_buffer_t buf) -{ - return (buf != ODP_BUFFER_INVALID); -} - -/** - * Print buffer metadata to STDOUT - * - * @param buf Buffer handle - */ -void odp_buffer_print(odp_buffer_t buf); - -/** - * @internal Set buffer user context - * - * @param buffer Buffer handle - * @param context User context - */ -static inline void odp_buffer_set_ctx(odp_buffer_t buffer, void *context) -{ - Cppi_setTimeStamp(Cppi_DescType_HOST, - (Cppi_Desc *)_odp_buf_to_cppi_desc(buffer), - (uint32_t) context); -} - -/** - * @internal Get buffer user context - * - * @param buffer Buffer handle - * - * @return User context - */ -static inline void *odp_buffer_get_ctx(odp_buffer_t buffer) -{ - uint32_t app_ctx_id = 0; - Cppi_getTimeStamp(Cppi_DescType_HOST, - (Cppi_Desc *)_odp_buf_to_cppi_desc(buffer), - &app_ctx_id); - return (void *)app_ctx_id; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/api/odp_buffer_pool.h b/platform/linux-keystone2/include/api/odp_buffer_pool.h deleted file mode 100644 index 970c33a..0000000 --- a/platform/linux-keystone2/include/api/odp_buffer_pool.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP buffer pool - */ - -#ifndef ODP_BUFFER_POOL_H_ -#define ODP_BUFFER_POOL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - - -#include -#include -#include - -/** Maximum queue name length in chars */ -/* #define ODP_BUFFER_POOL_NAME_LEN PKTLIB_MAX_HEAP_NAME */ - -/** Invalid buffer pool */ -#define ODP_BUFFER_POOL_INVALID (NULL) - -/** ODP buffer pool */ -typedef Pktlib_HeapHandle odp_buffer_pool_t; - - -/** - * Create a buffer pool - * - * @param name Name of the pool (max ODP_BUFFER_POOL_NAME_LEN - 1 chars) - * @param base_addr Pool base address - * @param size Pool size in bytes - * @param buf_size Buffer size in bytes - * @param buf_align Minimum buffer alignment - * @param buf_type Buffer type - * - * @return Buffer pool handle - */ -odp_buffer_pool_t odp_buffer_pool_create(const char *name, - void *base_addr, uint64_t size, - size_t buf_size, size_t buf_align, - int buf_type); - - -/** - * Find a buffer pool by name - * - * @param name Name of the pool - * - * @return Buffer pool handle, or ODP_BUFFER_POOL_INVALID if not found. - */ -odp_buffer_pool_t odp_buffer_pool_lookup(const char *name); - - -/** - * Print buffer pool info - * - * @param pool Pool handle - * - */ -void odp_buffer_pool_print(odp_buffer_pool_t pool); - - - -/** - * Buffer alloc - * - * @param pool Pool handle - * - * @return Buffer handle or ODP_BUFFER_INVALID - */ -odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool); - - -/** - * Buffer free - * - * @param buf Buffer handle - * - */ -void odp_buffer_free(odp_buffer_t buf); - - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/api/odp_crypto.h b/platform/linux-keystone2/include/api/odp_crypto.h deleted file mode 100644 index c61795e..0000000 --- a/platform/linux-keystone2/include/api/odp_crypto.h +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP crypto - */ - -#ifndef ODP_CRYPTO_H_ -#define ODP_CRYPTO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include - -/** Invalid session handle */ -#define ODP_CRYPTO_SESSION_INVALID NULL - -/** - * Crypto API opaque session handle - */ -typedef struct odp_crypto_session_s *odp_crypto_session_t; - -/** - * Crypto API operation mode - */ -enum odp_crypto_op_mode { - ODP_CRYPTO_SYNC, /**< Synchronous, return results immediately */ - ODP_CRYPTO_ASYNC, /**< Aynchronous, return results via posted event */ -}; - -/** - * Crypto API operation type - */ -enum odp_crypto_op { - ODP_CRYPTO_OP_ENCODE, /**< Encrypt and/or compute authentication ICV */ - ODP_CRYPTO_OP_DECODE /**< Decrypt and/or verify authentication ICV */ -}; - -/** - * Crypto API cipher algorithm - */ -enum odp_cipher_alg { - ODP_CIPHER_ALG_NULL = NWAL_SA_EALG_NULL, /**< No cipher */ - ODP_CIPHER_ALG_DES = NWAL_SA_EALG_DES_CBC, /**< DES cipher block chaining */ - ODP_CIPHER_ALG_3DES_CBC = NWAL_SA_EALG_3DES_CBC, /**< Triple DES cipher block chaining */ - ODP_CIPHER_ALG_AES_CBC = NWAL_SA_EALG_AES_CBC, /**< AES cipher block chaining */ - ODP_CIPHER_ALG_AES_CTR = NWAL_SA_EALG_AES_CTR, /**< AES counter */ - ODP_CIPHER_ALG_AES_CCM = NWAL_SA_EALG_AES_CCM, /**< AES counter with CBC-MAC */ - ODP_CIPHER_ALG_AES_GCM = NWAL_SA_EALG_AES_GCM, /**< AES galois counter */ -}; - -/** - * Crypto API authentication algorithm - */ -enum odp_auth_alg { - ODP_AUTH_ALG_NULL = NWAL_SA_AALG_NULL, /**< No authentication */ - ODP_AUTH_ALG_MD5_96 = NWAL_SA_AALG_HMAC_MD5, /**< HMAC-MD5 with 96 bit key */ - ODP_AUTH_ALG_SHA1 = NWAL_SA_AALG_HMAC_SHA1, /**< HMAC-SHA1 */ -}; - -/** - * Crypto API key structure - */ -typedef struct odp_crypto_key { - uint8_t *data; /**< Key data */ - uint32_t length; /**< Key length in bytes */ -} odp_crypto_key_t; - -/** - * Crypto API IV structure - */ -typedef struct odp_crypto_iv { - uint8_t *data; /**< IV data */ - uint32_t length; /**< IV length in bytes */ -} odp_crypto_iv_t; - -/** - * Crypto API data range specifier - */ -typedef struct odp_crypto_data_range { - uint32_t offset; /**< Offset from beginning of buffer (chain) */ - uint32_t length; /**< Length of data to operate on */ -} odp_crypto_data_range_t; - -/** - * Crypto API session creation paramters - * - * @todo Add "odp_session_proc_info_t" - */ -typedef struct odp_crypto_session_params { - enum odp_crypto_op op; /**< Encode versus decode */ - bool auth_cipher_text; /**< Authenticate/cipher ordering */ - enum odp_crypto_op_mode pref_mode; /**< Preferred sync vs async */ - enum odp_cipher_alg cipher_alg; /**< Cipher algorithm */ - odp_crypto_key_t cipher_key; /**< Cipher key */ - odp_crypto_iv_t iv; /**< Cipher Initialization Vector (IV) */ - enum odp_auth_alg auth_alg; /**< Authentication algorithm */ - odp_crypto_key_t auth_key; /**< Authentication key */ - odp_queue_t compl_queue; /**< Async mode completion event queue */ - odp_buffer_pool_t output_pool; /**< Output buffer pool */ -} odp_crypto_session_params_t; - -/** - * @var odp_crypto_session_params_t::auth_cipher_text - * - * Controls ordering of authentication and cipher operations, - * and is relative to the operation (encode vs decode). - * When encoding, @c TRUE indicates the authentication operation - * should be peformed @b after the cipher operation else before. - * When decoding, @c TRUE indicates the reverse order of operation. - * - * @var odp_crypto_session_params_t::compl_queue - * - * When the API operates asynchronously, the completion queue is - * used to return the completion status of the operation to the - * application. - * - * @var odp_crypto_session_params_t::output_pool - * - * When the output packet is not specified during the call to - * odp_crypto_operation, the output packet buffer will be allocated - * from this pool. - */ - -/** - * Crypto API per packet operation parameters - * - * @todo Clarify who zero's ICV and how this relates to "hash_result_offset" - */ -typedef struct odp_crypto_op_params { - odp_crypto_session_t session; /**< Session handle from creation */ - odp_packet_t pkt; /**< Input packet buffer */ - odp_packet_t out_pkt; /**< Output packet buffer */ - uint8_t *override_iv_ptr; /**< Override session IV pointer */ - uint32_t hash_result_offset; /**< Offset from start of packet buffer for hash result */ - odp_crypto_data_range_t cipher_range; /**< Data range to apply cipher */ - odp_crypto_data_range_t auth_range; /**< Data range to authenticate */ -} odp_crypto_op_params_t; - -/** - * @var odp_crypto_op_params_t::pkt - * Specifies the input packet buffer for the crypto operation. When the - * @c out_pkt variable is set to @c ODP_PACKET_INVALID (indicating a new - * buffer should be allocated for the resulting packet), the \#define TBD - * indicates whether the implementation will free the input packet buffer - * or if it becomes the responsibility of the caller. - * - * @var odp_crypto_op_params_t::out_pkt - * - * The API supports both "in place" (the original packet "pkt" is - * modified) and "copy" (the packet is replicated to a new buffer - * which contains the modified data). - * - * The "in place" mode of operation is indicated by setting @c out_pkt - * equal to @c pkt. For the copy mode of operation, setting @c out_pkt - * to a valid packet buffer value indicates the caller wishes to specify - * the destination buffer. Setting @c out_pkt to @c ODP_PACKET_INVALID - * indicates the caller wishes the destination packet buffer be allocated - * from the output pool specified during session creation. - * - * @sa odp_crypto_session_params_t::output_pool. - */ - -/** - * Crypto API session creation return code - */ -enum odp_crypto_ses_create_err { - ODP_CRYPTO_SES_CREATE_ERR_NONE, /**< Session created */ - ODP_CRYPTO_SES_CREATE_ERR_ENOMEM, /**< Creation failed, no resources */ - ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER, /**< Creation failed, bad cipher params */ - ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH, /**< Creation failed, bad auth params */ -}; - -/** - * Crypto API algorithm return code - */ -enum crypto_alg_err { - ODP_CRYPTO_ALG_ERR_NONE, /**< Algorithm successful */ - ODP_CRYPTO_ALG_ERR_DATA_SIZE, /**< Invalid data block size */ - ODP_CRYPTO_ALG_ERR_KEY_SIZE, /**< Key size invalid for algorithm */ - ODP_CRYPTO_ALG_ERR_ICV_CHECK, /**< Computed ICV value mismatch */ -}; - -/** - * Crypto API hardware centric return code - */ -enum crypto_hw_err { - ODP_CRYPTO_HW_ERR_NONE, /**< Operation completed successfully */ - ODP_CRYPTO_HW_ERR_DMA, /**< Error detected during DMA of data */ - ODP_CRYPTO_HW_ERR_BP_DEPLETED, /**< Operation failed due to buffer pool depletion */ -}; - -/** - * Cryto API per packet operation completion status - */ -typedef struct odp_crypto_compl_status { - enum crypto_alg_err alg_err; /**< Algorithm specific return code */ - enum crypto_hw_err hw_err; /**< Hardware specific return code */ -} odp_crypto_compl_status_t; - - -/** - * Crypto session creation (synchronous) - * - * @param params Session parameters - * @param session Created session else ODP_CRYPTO_SESSION_INVALID - * @param status Failure code if unsuccessful - * - * @return 0 if successful else -1 - */ -int -odp_crypto_session_create(odp_crypto_session_params_t *params, - odp_crypto_session_t *session, - enum odp_crypto_ses_create_err *status); - -/** - * Crypto session destroy (synchronous) - * - * @param session Session handle to destroy - * - * @return 0 if successful else -1 - */ -int odp_crypto_session_destroy(odp_crypto_session_t session); - -/** - * Crypto session creation (asynchronous) - * - * Initiate crypto session creation. Results are delivered using - * the completion event via the completion queue. - * - * @param params Session parameters - * @param completion_event Event by which the session creation results are - * delivered. - * @param completion_queue Queue by which the completion event will be - * delivered. - * - * @return 0 if successful else -1 - * - */ -int -odp_crypto_session_create_async(odp_crypto_session_params_t *params, - odp_buffer_t completion_event, - odp_queue_t completion_queue); - - -/** - * Crypto session creation completion status - * - * Accessor function for obtaining creation status from the completion event. - * - * @param completion_event Event containing operation results - * @param status Pointer to store creation return code - */ -void -odp_crypto_get_ses_create_compl_status(odp_buffer_t completion_event, - enum odp_crypto_ses_create_err *status); - -/** - * Crypto session creation completion return value - * - * Accessor function for obtaining handle for newly created session. - * - * @param completion_event Event containing operation results - * @param session Pointer to store session handle - */ -void -odp_crypto_get_ses_create_compl_session(odp_buffer_t completion_event, - odp_crypto_session_t *session); - -/** - * Crypto per packet operation - * - * Performs the cryptographic operations specified during session creation - * on the packet. If the operation is performed synchronously, "posted" - * will return FALSE and the result of the operation is immediately available - * in the completion event. If "posted" returns TRUE the result will be - * delivered via the completion queue specified when the session was created. - * - * @todo Resolve if completion_event is necessary, can/should the output - * packet buffer always be used instead. - * - * @param params Operation parameters - * @param posted Pointer to return posted, TRUE for async operation - * @param completion_event Event by which the operation results are delivered. - * - * @return 0 if successful else -1 - */ -int -odp_crypto_operation(odp_crypto_op_params_t *params, - bool *posted, - odp_buffer_t completion_event); - -/** - * Crypto per packet operation set user context in completion event - * - * @param completion_event Event containing operation results - * @param ctx User data - */ -void -odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event, - void *ctx); - -/** - * Crypto per packet operation completion status - * - * Accessor function for obtaining operation status from the completion event. - * - * @param completion_event Event containing operation results - * @param auth Pointer to store authentication results - * @param cipher Pointer to store cipher results - */ -void -odp_crypto_get_operation_compl_status(odp_buffer_t completion_event, - odp_crypto_compl_status_t *auth, - odp_crypto_compl_status_t *cipher); - -/** - * Crypto per packet operation query completed operation packet - * - * Accessor function for obtaining current packet buffer, can be - * different from input packet buffer on some systems - * - * @param completion_event Event containing operation results - * - * @return Packet structure where data now resides - */ -odp_packet_t -odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event); - -/** - * Crypto per packet operation query user context in completion event - * - * @param completion_event Event containing operation results - * - * @return User data - */ -void * -odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event); - -/** - * Generate random byte string - * - * @param buf Pointer to store result - * @param len Pointer to input length value as well as return value - * @param use_entropy Use entropy - * - * @todo Define the implication of the use_entropy parameter - * - * @return 0 if succesful - */ -int -odp_hw_random_get(uint8_t *buf, size_t *len, bool use_entropy); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/api/odp_packet.h b/platform/linux-keystone2/include/api/odp_packet.h deleted file mode 100644 index c28a387..0000000 --- a/platform/linux-keystone2/include/api/odp_packet.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet descriptor - */ - -#ifndef ODP_PACKET_H_ -#define ODP_PACKET_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * ODP packet descriptor - */ -typedef odp_buffer_t odp_packet_t; - -/** Invalid packet */ -#define ODP_PACKET_INVALID ODP_BUFFER_INVALID - -/** Invalid offset */ -#define ODP_PACKET_OFFSET_INVALID ((size_t)-1) - - -/** - * Initialize the packet - * - * Needs to be called if the user allocates a packet buffer, i.e. the packet - * has not been received from I/O through ODP. - * - * @param pkt Packet handle - */ -void odp_packet_init(odp_packet_t pkt); - -/** - * Convert from packet handle to buffer handle - * - * @param buf Buffer handle - * - * @return Packet handle - */ -static inline odp_packet_t odp_packet_from_buffer(odp_buffer_t buf) -{ - return buf; -} - -/** - * Convert from buffer handle to packet handle - * - * @param pkt Packet handle - * - * @return Buffer handle - */ -static inline odp_buffer_t odp_buffer_from_packet(odp_packet_t pkt) -{ - return pkt; -} - -/** - * Set the packet length - * - * @param pkt Packet handle - * @param len Length of packet in bytes - */ -void odp_packet_set_len(odp_packet_t pkt, size_t len); - -/** - * Get the packet length - * - * @param pkt Packet handle - * - * @return Packet length in bytes - */ -size_t odp_packet_get_len(odp_packet_t pkt); - -/** - * Get address to the start of the packet buffer - * - * The address of the packet buffer is not necessarily the same as the start - * address of the received frame, e.g. an eth frame may be offset by 2 or 6 - * bytes to ensure 32 or 64-bit alignment of the IP header. - * Use odp_packet_l2(pkt) to get the start address of a received valid frame - * or odp_packet_start(pkt) to get the start address even if no valid L2 header - * could be found. - * - * @param pkt Packet handle - * - * @return Pointer to the start of the packet buffer - * - * @see odp_packet_l2(), odp_packet_start() - */ -uint8_t *odp_packet_buf_addr(odp_packet_t pkt); - -/** - * Get pointer to the start of the received frame - * - * The address of the packet buffer is not necessarily the same as the start - * address of the received frame, e.g. an eth frame may be offset by 2 or 6 - * bytes to ensure 32 or 64-bit alignment of the IP header. - * Use odp_packet_l2(pkt) to get the start address of a received valid eth frame - * - * odp_packet_start() will always return a pointer to the start of the frame, - * even if the frame is unrecognized and no valid L2 header could be found. - * - * @param pkt Packet handle - * - * @return Pointer to the start of the received frame - * - * @see odp_packet_l2(), odp_packet_buf_addr() - */ -uint8_t *odp_packet_start(odp_packet_t pkt); - -/** - * Get pointer to the start of the L2 frame - * - * The L2 frame header address is not necessarily the same as the address of the - * packet buffer, see odp_packet_buf_addr() - * - * @param pkt Packet handle - * - * @return Pointer to L2 header or NULL if not found - * - * @see odp_packet_buf_addr(), odp_packet_start() - */ -uint8_t *odp_packet_l2(odp_packet_t pkt); - -/** - * Return the byte offset from the packet buffer to the L2 frame - * - * @param pkt Packet handle - * - * @return L2 byte offset or ODP_PACKET_OFFSET_INVALID if not found - */ -size_t odp_packet_l2_offset(odp_packet_t pkt); - -/** - * Set the byte offset to the L2 frame - * - * @param pkt Packet handle - * @param offset L2 byte offset - */ -void odp_packet_set_l2_offset(odp_packet_t pkt, size_t offset); - - -/** - * Get pointer to the start of the L3 packet - * - * @param pkt Packet handle - * - * @return Pointer to L3 packet or NULL if not found - * - */ -uint8_t *odp_packet_l3(odp_packet_t pkt); - -/** - * Return the byte offset from the packet buffer to the L3 packet - * - * @param pkt Packet handle - * - * @return L3 byte offset or ODP_PACKET_OFFSET_INVALID if not found - */ -size_t odp_packet_l3_offset(odp_packet_t pkt); - -/** - * Set the byte offset to the L3 packet - * - * @param pkt Packet handle - * @param offset L3 byte offset - */ -void odp_packet_set_l3_offset(odp_packet_t pkt, size_t offset); - - -/** - * Get pointer to the start of the L4 packet - * - * @param pkt Packet handle - * - * @return Pointer to L4 packet or NULL if not found - * - */ -uint8_t *odp_packet_l4(odp_packet_t pkt); - -/** - * Return the byte offset from the packet buffer to the L4 packet - * - * @param pkt Packet handle - * - * @return L4 byte offset or ODP_PACKET_OFFSET_INVALID if not found - */ -size_t odp_packet_l4_offset(odp_packet_t pkt); - -/** - * Set the byte offset to the L4 packet - * - * @param pkt Packet handle - * @param offset L4 byte offset - */ -void odp_packet_set_l4_offset(odp_packet_t pkt, size_t offset); - -/** - * Print (debug) information about the packet - * - * @param pkt Packet handle - */ -void odp_packet_print(odp_packet_t pkt); - -/** - * Copy contents and metadata from pkt_src to pkt_dst - * Useful when creating copies of packets - * - * @param pkt_dst Destination packet - * @param pkt_src Source packet - * - * @return 0 if successful - */ -int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src); - -/** - * Set packet user context - * - * @param pkt Packet handle - * @param ctx User context - * - */ -static inline void odp_packet_set_ctx(odp_packet_t pkt, void *ctx) -{ - odp_buffer_set_ctx(odp_buffer_from_packet(pkt), ctx); -} - -/** - * Get packet user context - * - * @param pkt Packet handle - * - * @return User context - */ -static inline void *odp_packet_get_ctx(odp_packet_t pkt) -{ - return odp_buffer_get_ctx(odp_buffer_from_packet(pkt)); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/api/odp_packet_io.h b/platform/linux-keystone2/include/api/odp_packet_io.h deleted file mode 100644 index 5301123..0000000 --- a/platform/linux-keystone2/include/api/odp_packet_io.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP Packet IO - */ - -#ifndef ODP_PACKET_IO_H_ -#define ODP_PACKET_IO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -#include - -/** ODP packet IO handle */ -typedef uint32_t odp_pktio_t; - -/** Invalid packet IO handle */ -#define ODP_PKTIO_INVALID ((odp_pktio_t)-1) - -/** - * Open an ODP packet IO instance - * - * @param dev Packet IO device - * @param pool Pool to use for packet IO - * @param params Set of parameters to pass to the arch dependent implementation - * - * @return ODP packet IO handle or ODP_PKTIO_INVALID on error - */ -odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, - odp_pktio_params_t *params); - -/** - * Close an ODP packet IO instance - * - * @param id ODP packet IO handle - * - * @return 0 on success or -1 on error - */ -int odp_pktio_close(odp_pktio_t id); - -/** - * Receive packets - * - * @param id ODP packet IO handle - * @param pkt_table[] Storage for received packets (filled by function) - * @param len Length of pkt_table[], i.e. max number of pkts to receive - * - * @return Number of packets received or -1 on error - */ -int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len); - -/** - * Send packets - * - * @param id ODP packet IO handle - * @param pkt_table[] Array of packets to send - * @param len length of pkt_table[] - * - * @return Number of packets sent or -1 on error - */ -int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len); - -/** - * Set the default input queue to be associated with a pktio handle - * - * @param id ODP packet IO handle - * @param queue default input queue set - * @return 0 on success or -1 on error - */ -int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue); - -/** - * Get default input queue associated with a pktio handle - * - * @param id ODP packet IO handle - * - * @return Default input queue set or ODP_QUEUE_INVALID on error - */ -odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id); - -/** - * Remove default input queue (if set) - * - * @param id ODP packet IO handle - * - * @return 0 on success or -1 on error - */ -int odp_pktio_inq_remdef(odp_pktio_t id); - -/** - * Query default output queue - * - * @param id ODP packet IO handle - * - * @return Default out queue or ODP_QUEUE_INVALID on error - */ -odp_queue_t odp_pktio_outq_getdef(odp_pktio_t id); - -/** - * Store packet input handle into packet - * - * @param pkt ODP packet buffer handle - * @param id ODP packet IO handle - * - * @return - */ -void odp_pktio_set_input(odp_packet_t pkt, odp_pktio_t id); - -/** - * Get stored packet input handle from packet - * - * @param pkt ODP packet buffer handle - * - * @return Packet IO handle - */ -odp_pktio_t odp_pktio_get_input(odp_packet_t pkt); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/api/odp_state.h b/platform/linux-keystone2/include/api/odp_state.h deleted file mode 100644 index 7975ca8..0000000 --- a/platform/linux-keystone2/include/api/odp_state.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_STATE_H_ -#define ODP_STATE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * @internal Global ODP state - */ -struct odp_global_s { - struct mcsdk_cfg_s cfg; /**< McSDK configuration */ - struct { - nwal_Inst handle; /**< NWAL handle */ - Pktlib_HeapHandle sa2pa_heap; /**< Internal SA->PA heap */ - Pktlib_HeapHandle pa2sa_heap; /**< Internal PA->SA head */ - } nwal; /**< Global NWAL state */ -}; - -/** @internal Per process ODP state */ -struct odp_proc_s { - struct { - Pktlib_HeapHandle netcp_heap; /**< internal default heap */ - Pktlib_HeapHandle netcp_control_rx_heap; /**< rx control messages */ - Pktlib_HeapHandle netcp_control_tx_heap; /**< tx control messages */ - } nwal; /**< Per process NWAL state */ - Rm_ServiceHandle *rm_service; /**< Resource Manager service handle */ -}; - -/** @internal Per thread ODP state */ -struct odp_local_s { - struct { - nwalLocCfg_t cfg; /**< Local NWAL configuration */ - } nwal; /**< thread NWAL state */ - int is_main_thread; /**< Marks a main thread which run global init */ -}; - -extern struct odp_global_s *odp_global; -extern struct odp_proc_s odp_proc; -extern __thread struct odp_local_s odp_local; - -#ifdef __cplusplus -} -#endif - -#endif /* ODP_STATE_H_ */ diff --git a/platform/linux-keystone2/include/api/odp_ti_mcsdk.h b/platform/linux-keystone2/include/api/odp_ti_mcsdk.h deleted file mode 100644 index 21b609d..0000000 --- a/platform/linux-keystone2/include/api/odp_ti_mcsdk.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_TI_MCSDK_H_ -#define ODP_TI_MCSDK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include - -/** @internal McSDK initialization configuration */ -struct mcsdk_cfg_s { - int def_mem_size; /**< Bytes of CMA memory we have allocated */ - int min_buf_headroom_size; /**< Minimal amount of headroom in a buffer */ - int def_max_descriptors; /**< Number of descriptors in system (must be power of 2), 2^14 max */ - int def_tot_descriptors_for_us; /**< Number of descriptors to create in our region (must be power of 2)*/ - int def_heap_n_descriptors; /**< Number of descriptor plus buffers in default heap*/ - int def_heap_n_zdescriptors; /**< Number of zero len descriptors in defaut heap*/ - int def_heap_buf_size; /**< Size of buffers in default heap, max amount of area for packet data */ - int def_heap_tailroom_size; /**< Size of tailroom in reserve */ - int def_heap_extra_size; /**< Size of extra space at end of buffer */ - int def_multi_process; /**< Flag to indicate if NETAPI init is for multi-process environment */ -}; - -Rm_ServiceHandle *rm_client_init(void); -int mcsdk_global_init(void); -int mcsdk_local_init(int thread_id); -int mcsdk_cppi_init(void); -int mcsdk_qmss_init(int max_descriptors); -int mcsdk_qmss_start(void); -int mcsdk_cppi_start(void); -int mcsdk_qmss_setup_memregion(uint32_t desc_num, uint32_t desc_size, - uint32_t *desc_mem_base, Qmss_MemRegion mem_region); -int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table); -int mcsdk_nwal_start(Pktlib_HeapHandle pkt_heap, - Pktlib_HeapHandle cmd_rx_heap, - Pktlib_HeapHandle cmd_tx_heap); - -extern Pktlib_HeapIfTable pktlib_if_table; -extern hplib_virtualAddrInfo_T odp_vm_info; - -#ifdef __cplusplus -} -#endif - -#endif /* ODP_TI_MCSDK_H_ */ diff --git a/platform/linux-keystone2/include/odp_buffer_internal.h b/platform/linux-keystone2/include/odp_buffer_internal.h deleted file mode 100644 index c3228ec..0000000 --- a/platform/linux-keystone2/include/odp_buffer_internal.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP buffer descriptor - implementation internal - */ - -#ifndef ODP_BUFFER_INTERNAL_H_ -#define ODP_BUFFER_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include - -typedef struct odp_bufhdr { - int type; -} odp_buffer_hdr_t; - -ODP_STATIC_ASSERT(sizeof(Cppi_HostDesc) <= ODP_CACHE_LINE_SIZE, - "ODP_BUFFER_HDR_T__SIZE_ERROR"); - -static inline struct odp_bufhdr *odp_buffer_hdr(odp_buffer_t buf) -{ - return (struct odp_bufhdr *)(_odp_buf_to_cppi_desc(buf)->origBuffPtr); -} - -/* Compatibility function for timer code reused from linux-generic */ -static inline odp_buffer_hdr_t *odp_buf_to_hdr(odp_buffer_t buf) -{ - return (odp_buffer_hdr_t *)odp_buffer_hdr(buf); -} - -extern odp_buffer_pool_t odp_buf_to_pool(odp_buffer_t buf); - - -int odp_buffer_snprint(char *str, size_t n, odp_buffer_t buf); - -void odp_buffer_copy_scatter(odp_buffer_t buf_dst, odp_buffer_t buf_src); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_buffer_pool_internal.h b/platform/linux-keystone2/include/odp_buffer_pool_internal.h deleted file mode 100644 index 95960c9..0000000 --- a/platform/linux-keystone2/include/odp_buffer_pool_internal.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP buffer pool - internal header - */ - -#ifndef ODP_BUFFER_POOL_INTERNAL_H_ -#define ODP_BUFFER_POOL_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -uint32_t _odp_pool_get_free_queue(odp_buffer_pool_t pool_id); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_crypto_internal.h b/platform/linux-keystone2/include/odp_crypto_internal.h deleted file mode 100644 index 17756fd..0000000 --- a/platform/linux-keystone2/include/odp_crypto_internal.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_CRYPTO_INTERNAL_H_ -#define ODP_CRYPTO_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#define OP_RESULT_MAGIC 0x91919191 - -/** Forward declaration of session structure */ -struct odp_crypto_session_s; - -/** - * Algorithm handler function prototype - */ -typedef -enum crypto_alg_err (*crypto_func_t)(struct odp_crypto_op_params *params, - struct odp_crypto_session_s *session); - -#define ODP_CRYPTO_MAX_IV_LENGTH 32 - -struct iv_full { - uint8_t data[ODP_CRYPTO_MAX_IV_LENGTH]; - size_t length; -}; - - -/** - * Per crypto session data structure - */ -struct odp_crypto_session_s { - nwal_Handle dm_handle; - nwalTxDmPSCmdInfo_t dm_ps_cmdinfo; - odp_buffer_pool_t out_pool; - uint32_t out_flow_id; - odp_queue_t compl_queue; - struct { - enum odp_cipher_alg alg; - struct iv_full iv; - } cipher; - - struct { - enum odp_auth_alg alg; - struct iv_full iv; - uint32_t tag_len; - } auth; - - uint32_t index; - enum odp_crypto_op op; -}; - -/** - * Per packet operation result - */ -struct odp_operation_result_s { - uint32_t magic; - struct odp_crypto_compl_status cipher; - struct odp_crypto_compl_status auth; -}; - -/** - * Per session creation operation result - */ -struct odp_session_result_s { - enum odp_crypto_ses_create_err rc; - odp_crypto_session_t session; -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_debug_internal.h b/platform/linux-keystone2/include/odp_debug_internal.h deleted file mode 100644 index 7684a6a..0000000 --- a/platform/linux-keystone2/include/odp_debug_internal.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_DEBUG_INTERNAL_H_ -#define ODP_DEBUG_INTERNAL_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define ODP_PRINT_LEVEL_DISABLED 0 -#define ODP_PRINT_LEVEL_CRIT 1 -#define ODP_PRINT_LEVEL_ERR 2 -#define ODP_PRINT_LEVEL_WARN 3 -#define ODP_PRINT_LEVEL_INFO 4 -#define ODP_PRINT_LEVEL_DBG 5 -#define ODP_PRINT_LEVEL_VDBG 6 -#define ODP_PRINT_LEVEL_MAX 7 - -#define ODP_PRINT_LEVEL ODP_PRINT_LEVEL_WARN - -/** - * Internal debug printing macro - */ -#ifndef ODP_NO_PRINT -#define odp_print(level, fmt, ...) \ - do { if (level <= ODP_PRINT_LEVEL) \ - fprintf(stderr, "%s():%d: " fmt, \ - __func__, __LINE__, ##__VA_ARGS__); \ - } while (0) -#else -#define odp_print(level, fmt, ...) -#endif - -#define odp_pr_err(fmt, ...) \ - odp_print(ODP_PRINT_LEVEL_ERR, fmt, ##__VA_ARGS__) -#define odp_pr_warn(fmt, ...) \ - odp_print(ODP_PRINT_LEVEL_WARN, fmt, ##__VA_ARGS__) -#define odp_pr_info(fmt, ...) \ - odp_print(ODP_PRINT_LEVEL_INFO, fmt, ##__VA_ARGS__) -#define odp_pr_dbg(fmt, ...) \ - odp_print(ODP_PRINT_LEVEL_DBG, fmt, ##__VA_ARGS__) -#define odp_pr_vdbg(fmt, ...) \ - odp_print(ODP_PRINT_LEVEL_VDBG, fmt, ##__VA_ARGS__) - -void odp_print_mem(void *addr, size_t size, const char *desc); - -static inline void odp_pr_mem(int level, void *addr, size_t size, - const char *desc) -{ - if (level <= ODP_PRINT_LEVEL) - odp_print_mem(addr, size, desc); -} - -#define odp_pr_err_mem(...) odp_pr_mem(ODP_PRINT_LEVEL_ERR, ##__VA_ARGS__) -#define odp_pr_dbg_mem(...) odp_pr_mem(ODP_PRINT_LEVEL_DBG, ##__VA_ARGS__) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_internal.h b/platform/linux-keystone2/include/odp_internal.h deleted file mode 100644 index c409289..0000000 --- a/platform/linux-keystone2/include/odp_internal.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP HW system information - */ - -#ifndef ODP_INTERNAL_H_ -#define ODP_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -int odp_system_info_init(void); - -void odp_thread_init_global(void); -void odp_thread_init_local(int thr_id); - -int odp_shm_init_global(void); -int odp_shm_init_local(void); - -int odp_buffer_pool_init_global(void); - -int odp_pktio_init_global(void); - -int odp_queue_init_global(void); - -int odp_crypto_init_global(void); - -int odp_schedule_init_global(void); -int odp_schedule_init_local(void); - -int odp_timer_init_global(void); -int odp_timer_disarm_all(void); - -int mcsdk_global_init(void); -int mcsdk_local_init(int thread_id); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_packet_internal.h b/platform/linux-keystone2/include/odp_packet_internal.h deleted file mode 100644 index 7d3258a..0000000 --- a/platform/linux-keystone2/include/odp_packet_internal.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet descriptor - implementation internal - */ - -#ifndef ODP_PACKET_INTERNAL_H_ -#define ODP_PACKET_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include - -/** - * Packet input & protocol flags - */ -typedef union { - /* All input flags */ - uint32_t all; - - struct { - /* Bitfield flags for each protocol */ - uint32_t l2:1; /**< known L2 protocol present */ - uint32_t l3:1; /**< known L3 protocol present */ - uint32_t l4:1; /**< known L4 protocol present */ - - uint32_t eth:1; /**< Ethernet */ - uint32_t jumbo:1; /**< Jumbo frame */ - uint32_t vlan:1; /**< VLAN hdr found */ - uint32_t vlan_qinq:1; /**< Stacked VLAN found, QinQ */ - - uint32_t arp:1; /**< ARP */ - - uint32_t ipv4:1; /**< IPv4 */ - uint32_t ipv6:1; /**< IPv6 */ - uint32_t ipfrag:1; /**< IP fragment */ - uint32_t ipopt:1; /**< IP optional headers */ - uint32_t ipsec:1; /**< IPSec decryption may be needed */ - - uint32_t udp:1; /**< UDP */ - uint32_t tcp:1; /**< TCP */ - uint32_t sctp:1; /**< SCTP */ - uint32_t icmp:1; /**< ICMP */ - }; -} input_flags_t; - -ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t), "INPUT_FLAGS_SIZE_ERROR"); - -/** - * Packet error flags - */ -typedef union { - /* All error flags */ - uint32_t all; - - struct { - /* Bitfield flags for each detected error */ - uint32_t frame_len:1; /**< Frame length error */ - uint32_t l2_chksum:1; /**< L2 checksum error, checks TBD */ - uint32_t ip_err:1; /**< IP error, checks TBD */ - uint32_t tcp_err:1; /**< TCP error, checks TBD */ - uint32_t udp_err:1; /**< UDP error, checks TBD */ - }; -} error_flags_t; - -ODP_STATIC_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t), "ERROR_FLAGS_SIZE_ERROR"); - -/** - * Packet output flags - */ -typedef union { - /* All output flags */ - uint32_t all; - - struct { - /* Bitfield flags for each output option */ - uint32_t l4_chksum:1; /**< Request L4 checksum calculation */ - }; -} output_flags_t; - -ODP_STATIC_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t), "OUTPUT_FLAGS_SIZE_ERROR"); - -/** - * Internal Packet header - */ -struct odp_pkthdr { - /* common buffer header */ - struct odp_bufhdr buf_hdr; - - input_flags_t input_flags; - error_flags_t error_flags; - output_flags_t output_flags; - - uint16_t frame_offset; /**< offset to start of frame, even on error */ - uint16_t l2_offset; /**< offset to L2 hdr, e.g. Eth */ - uint16_t l3_offset; /**< offset to L3 hdr, e.g. IPv4, IPv6 */ - uint16_t l4_offset; /**< offset to L4 hdr (TCP, UDP, SCTP, also ICMP) */ - - uint32_t frame_len; - - odp_pktio_t input; - - struct { - int16_t saved_buf_offset; - uint32_t hash_offset; - union { - struct { - } enc; - struct { - uint32_t hash_tag[5]; - } dec; - }; - - } crypto; - -}; - -ODP_STATIC_ASSERT(sizeof(struct odp_pkthdr) <= ODP_CACHE_LINE_SIZE, - "PACKET_HDR_T_SIZE_ERROR"); - -/** - * Return the packet header - */ -static inline struct odp_pkthdr *odp_packet_hdr(odp_packet_t pkt) -{ - odp_buffer_t buf = odp_buffer_from_packet(pkt); - return (struct odp_pkthdr *)odp_buffer_hdr(buf); -} - -/** - * Parse packet and set internal metadata - */ -void odp_packet_parse(odp_packet_t pkt, size_t len, size_t l2_offset); - -static inline void odp_pr_packet(int level, odp_packet_t pkt) -{ - if (level <= ODP_PRINT_LEVEL) - odp_packet_print(pkt); -} - -#define odp_pr_err_packet(...) \ - odp_pr_packet(ODP_PRINT_LEVEL_ERR, ##__VA_ARGS__) -#define odp_pr_dbg_packet(...) \ - odp_pr_packet(ODP_PRINT_LEVEL_DBG, ##__VA_ARGS__) -#define odp_pr_vdbg_packet(...) \ - odp_pr_packet(ODP_PRINT_LEVEL_VDBG, ##__VA_ARGS__) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_packet_io_internal.h b/platform/linux-keystone2/include/odp_packet_io_internal.h deleted file mode 100644 index baa925c..0000000 --- a/platform/linux-keystone2/include/odp_packet_io_internal.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet IO - implementation internal - */ - -#ifndef ODP_PACKET_IO_INTERNAL_H_ -#define ODP_PACKET_IO_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -struct pktio_entry { - odp_spinlock_t lock; /**< entry spinlock */ - int taken; /**< is entry taken(1) or free(0) */ - odp_queue_t inq_default; /**< default input queue, if set */ - odp_queue_t outq_default; /**< default out queue */ - odp_buffer_pool_t in_pool; /**< pool for incoming packets */ - odp_pktio_t id; /**< pktio handle */ - nwalTxPSCmdInfo_t tx_ps_cmdinfo; /**< saved Command Label */ - int port; /**< netcp port number */ -}; - -typedef union { - struct pktio_entry s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pktio_entry))]; -} pktio_entry_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_packet_io_queue.h b/platform/linux-keystone2/include/odp_packet_io_queue.h deleted file mode 100644 index 4d3a79d..0000000 --- a/platform/linux-keystone2/include/odp_packet_io_queue.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet IO - implementation internal - */ - -#ifndef ODP_PACKET_IO_QUEUE_H_ -#define ODP_PACKET_IO_QUEUE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -odp_buffer_t pktin_dequeue(queue_entry_t *queue); -int pktin_deq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num); -int pktout_enqueue(queue_entry_t *queue, odp_buffer_t buf); -int pktout_enq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/odp_queue_internal.h b/platform/linux-keystone2/include/odp_queue_internal.h deleted file mode 100644 index 8046d66..0000000 --- a/platform/linux-keystone2/include/odp_queue_internal.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP queue - implementation internal - */ - -#ifndef ODP_QUEUE_INTERNAL_H_ -#define ODP_QUEUE_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include - - -#define USE_TICKETLOCK - -#ifdef USE_TICKETLOCK -#include -#else -#include -#endif - -#define QUEUE_MULTI_MAX 8 - -#define QUEUE_STATUS_FREE 0 -#define QUEUE_STATUS_READY 1 -#define QUEUE_STATUS_NOTSCHED 2 -#define QUEUE_STATUS_SCHED 3 - -/* forward declaration */ -union queue_entry_u; - -typedef int (*enq_func_t)(union queue_entry_u *, odp_buffer_t); -typedef odp_buffer_t (*deq_func_t)(union queue_entry_u *); - -typedef int (*enq_multi_func_t)(union queue_entry_u *, odp_buffer_t *, int); -typedef int (*deq_multi_func_t)(union queue_entry_u *, odp_buffer_t *, int); - -struct queue_entry_s { -#ifdef USE_TICKETLOCK - odp_ticketlock_t lock ODP_ALIGNED_CACHE; -#else - odp_spinlock_t lock ODP_ALIGNED_CACHE; -#endif - - int status; - - enq_func_t enqueue ODP_ALIGNED_CACHE; - deq_func_t dequeue; - enq_multi_func_t enqueue_multi; - deq_multi_func_t dequeue_multi; - - odp_queue_t handle; - odp_buffer_t sched_buf; - odp_queue_type_t type; - odp_queue_param_t param; - odp_pktio_t pktin; - pktio_entry_t *pktout_entry; - Qmss_QueueHnd qmss_queue; - char name[ODP_QUEUE_NAME_LEN]; -}; - -typedef union queue_entry_u { - struct queue_entry_s s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct queue_entry_s))]; -} queue_entry_t; - - -queue_entry_t *get_qentry(uint32_t queue_id); - -int queue_enq(queue_entry_t *queue, odp_buffer_t buf); -odp_buffer_t queue_deq(queue_entry_t *queue); - -int queue_enq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num); -int queue_deq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num); - -void queue_lock(queue_entry_t *queue); -void queue_unlock(queue_entry_t *queue); - -odp_buffer_t queue_sched_buf(odp_queue_t queue); -int queue_sched_atomic(odp_queue_t handle); - -static inline uint32_t queue_to_id(odp_queue_t handle) -{ - return handle - 1; -} - -static inline odp_queue_t queue_from_id(uint32_t queue_id) -{ - return queue_id + 1; -} - -static inline queue_entry_t *queue_to_qentry(odp_queue_t handle) -{ - uint32_t queue_id; - - queue_id = queue_to_id(handle); - return get_qentry(queue_id); -} - -static inline const char *odp_queue_name(odp_queue_t handle) -{ - return queue_to_qentry(handle)->s.name; -} - - -static inline Qmss_QueueHnd _odp_queue_to_qmss_queue(odp_queue_t queue) -{ - queue_entry_t *entry = queue_to_qentry(queue); - return entry->s.qmss_queue; -} - -odp_queue_t _odp_queue_create(const char *name, odp_queue_type_t type, - odp_queue_param_t *param, int32_t hw_queue); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-keystone2/include/sockrmmsg.h b/platform/linux-keystone2/include/sockrmmsg.h deleted file mode 100644 index d0628f9..0000000 --- a/platform/linux-keystone2/include/sockrmmsg.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef __SOCKRMMSG_H__ -#define __SOCKRMMSG_H__ - -#include - -#define RM_SERVER_SOCKET_NAME "/tmp/var/run/rm/rm_server" - -#define msg_alloc(p) \ - do { \ - p = calloc(1, sizeof(*p)); \ - if (p) { \ - p->length = sizeof(*p); \ - } \ - } while (0) - -#define msg_length(x) ((x) ? (sizeof(*x) + x->length) : 0) -#define msg_data(x) ((x->length) ? ((char *)x + sizeof(*x)) : NULL) - -#endif /* __SOCKRMMSG_H__ */ diff --git a/platform/linux-keystone2/include/sockutils.h b/platform/linux-keystone2/include/sockutils.h deleted file mode 100644 index cabdcee..0000000 --- a/platform/linux-keystone2/include/sockutils.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef __SOCKUTILS_H__ -#define __SOCKUTILS_H__ - -#include -#include - -#ifndef UNIX_PATH_MAX -#define UNIX_PATH_MAX 108 -#endif - - -typedef enum { - sock_name_e, - sock_addr_e -} sock_name_type; - -typedef struct { - sock_name_type type; - union sock { - char *name; - struct sockaddr_un *addr; - } s; -} sock_name_t; - -#define sock_h void * - -sock_h sock_open(sock_name_t *sock_name); - -int sock_close(sock_h handle); - -int sock_send(sock_h handle, const char *data, int length, - sock_name_t *to); - -int sock_wait(sock_h handle, int *size, struct timeval *timeout, int extern_fd); - -int sock_recv(sock_h handle, char *data, int length, sock_name_t *from); - -#endif diff --git a/platform/linux-keystone2/mcsdk/mcsdk_init.c b/platform/linux-keystone2/mcsdk/mcsdk_init.c deleted file mode 100644 index 37eef12..0000000 --- a/platform/linux-keystone2/mcsdk/mcsdk_init.c +++ /dev/null @@ -1,690 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include - -/* Global variables to hold virtual address of various subsystems */ -hplib_virtualAddrInfo_T odp_vm_info; - -/* - * Global variables which needs to be populated with memory pool attributes - * which is passed to HPLIB for memory pool initialization - */ -void *global_descriptor_mem_base; -void *sa_context_mem_base; - -static uint8_t *cma_mem_alloc(uint32_t size); -static void cma_mem_free(uint8_t *ptr, uint32_t size); - -Pktlib_HeapIfTable pktlib_if_table = { - .data_malloc = cma_mem_alloc, - .data_free = cma_mem_free, -}; - -struct mcsdk_cfg_s default_mcsdk_cfg = { - .def_mem_size = TUNE_NETAPI_PERM_MEM_SZ, - .def_max_descriptors = TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, - .def_tot_descriptors_for_us = TUNE_NETAPI_NUM_GLOBAL_DESC, - .def_heap_n_descriptors = TUNE_NETAPI_DEFAULT_NUM_BUFFERS, - .def_heap_n_zdescriptors = 0, - .def_heap_buf_size = TUNE_NETAPI_DEFAULT_BUFFER_SIZE, - .def_heap_tailroom_size = 0, - .def_heap_extra_size = 0, - .min_buf_headroom_size = ODP_CACHE_LINE_SIZE, -}; - -/** - * NWAL Memory Buffer Configuration - * @todo: Buffers for NWAL can be allocated dynamically - */ -#define NWAL_CONFIG_SEC_CONTEXT_SZ 384 - -#define NWAL_CONFIG_BUFSIZE_NWAL_HANDLE 3400 - -#define NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC 256 -#define NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN 256 -#define NWAL_CONFIG_BUFSIZE_NWAL_PER_IP 128 -#define NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT 128 -#define NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR 128 -#define NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT 384 -#define NWAL_CHAN_HANDLE_SIZE \ - ((NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \ - (NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN * \ - TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) + \ - (NWAL_CONFIG_BUFSIZE_NWAL_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \ - (NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS) + \ - (NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \ - (NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR * \ - TUNE_NETAPI_MAX_NUM_L2_L3_HDRS)) - -uint8_t nwal_inst_mem[NWAL_CONFIG_BUFSIZE_NWAL_HANDLE] ODP_ALIGNED_CACHE; -uint8_t nwal_handle_mem[NWAL_CHAN_HANDLE_SIZE] ODP_ALIGNED_CACHE; - -/** - * @todo: Check if below size information can be made available - * from PA interface file - */ -#define NWAL_CONFIG_BUFSIZE_PA_BUF0 256 -#define NWAL_CONFIG_BUFSIZE_PA_BUF1 (128 * TUNE_NETAPI_MAX_NUM_MAC) -#define NWAL_CONFIG_BUFSIZE_PA_BUF2 13824 - -struct pa_global { - /* Memory used for the PA Instance.*/ - uint8_t pa_buf0[NWAL_CONFIG_BUFSIZE_PA_BUF0] ODP_ALIGNED_CACHE; - /* Memory used for PA handles */ - uint8_t pa_buf1[NWAL_CONFIG_BUFSIZE_PA_BUF1] ODP_ALIGNED_CACHE; - uint8_t pa_buf2[NWAL_CONFIG_BUFSIZE_PA_BUF2] ODP_ALIGNED_CACHE; -}; - - -#define NWAL_CONFIG_BUFSIZE_SA_HANDLE 512 -#define NWAL_CONFIG_BUFSIZE_SA_HANDLE_PER_CHAN 512 - -struct sa_global { - /* Memory used for SA LLD global Handle */ - uint8_t salld_handle[NWAL_CONFIG_BUFSIZE_SA_HANDLE] ODP_ALIGNED_CACHE; - /* Memory used by SA LLD per Channel */ - uint8_t salld_chan_handle[NWAL_CONFIG_BUFSIZE_SA_HANDLE_PER_CHAN * - TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2] - ODP_ALIGNED_CACHE; -}; - -static uint8_t *cma_mem_alloc(uint32_t size) -{ - return (uint8_t *)hplib_vmMemAlloc( - size + odp_global->cfg.def_heap_extra_size, 128, 0); -} - -static void cma_mem_free(uint8_t *ptr ODP_UNUSED, uint32_t size ODP_UNUSED) -{ - /* Do Nothing. */ - odp_pr_err("need to provide a free () for some reason!!\n"); - return; -} - -/******************************************************************** - * FUNCTION PURPOSE: Internal NETAPI function to initialize NWAL subsystem - ******************************************************************** - * DESCRIPTION: Internal NETAPI function to initialize NWAL subsytem - ********************************************************************/ -int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table) -{ - nwalSizeInfo_t nwal_size_info; - nwal_RetValue nwal_ret; - nwalGlobCfg_t nwal_global_cfg; - uint8_t count; - int sizes[nwal_N_BUFS]; - int aligns[nwal_N_BUFS]; - void *bases[nwal_N_BUFS]; - Pktlib_HeapCfg heap_cfg; - int32_t pktlib_err; - void *base = NULL; - struct pa_global *pa_entry = NULL; - struct sa_global *sa_entry = NULL; - - memset(&odp_global->nwal, 0, sizeof(odp_global->nwal)); - memset(&nwal_global_cfg, 0, sizeof(nwal_global_cfg)); - - nwal_global_cfg.rmHandle = odp_proc.rm_service; - - base = hplib_shmOpen(); - if (base) { - if (hplib_shmAddEntry(base, sizeof(struct pa_global), PA_ENTRY) - == hplib_OK) { - pa_entry = (struct pa_global *)hplib_shmGetEntry( - base, PA_ENTRY); - nwal_global_cfg.instPoolBaseAddr = (void *)pa_entry; - } else { - odp_pr_err("Unable to Add shared memory segment for PASS\n"); - return -1; - } - if (hplib_shmAddEntry(base, sizeof(struct sa_global), SA_ENTRY) - == hplib_OK) { - sa_entry = (struct sa_global *)hplib_shmGetEntry( - base, SA_ENTRY); - nwal_global_cfg.instPoolSaBaseAddr = (void *)sa_entry; - } else { - odp_pr_err("Unable to Add shared memory segment for SASS\n"); - return -1; - } - } - /* Initialize Buffer Pool for NetCP PA to SA packets */ - nwal_global_cfg.pa2SaBufPool.numBufPools = 1; - nwal_global_cfg.pa2SaBufPool.bufPool[0].descSize = - TUNE_NETAPI_DESC_SIZE; - nwal_global_cfg.pa2SaBufPool.bufPool[0].bufSize = - odp_global->cfg.def_heap_buf_size; - - /* Initialize the heap configuration. */ - memset((void *)&heap_cfg, 0, sizeof(Pktlib_HeapCfg)); - /* Populate the heap configuration */ - heap_cfg.name = "nwal PA2SA"; - heap_cfg.memRegion = region2use; - heap_cfg.sharedHeap = 0; - heap_cfg.useStarvationQueue = 0; - heap_cfg.dataBufferSize = odp_global->cfg.def_heap_buf_size; - heap_cfg.numPkts = TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC; - heap_cfg.numZeroBufferPackets = 0; - heap_cfg.heapInterfaceTable.data_malloc = p_table->data_malloc; - heap_cfg.heapInterfaceTable.data_free = p_table->data_free; - heap_cfg.dataBufferPktThreshold = 0; - heap_cfg.zeroBufferPktThreshold = 0; - - nwal_global_cfg.pa2SaBufPool.bufPool[0].heapHandle = - Pktlib_createHeap(&heap_cfg, &pktlib_err); - if (nwal_global_cfg.pa2SaBufPool.bufPool[0].heapHandle == NULL) { - odp_pr_err("Heap Creation Failed for PA to SA Buffer Pool, Error Code: %d\n", - pktlib_err); - return -1; - } - odp_global->nwal.pa2sa_heap = - nwal_global_cfg.pa2SaBufPool.bufPool[0].heapHandle; - /* Initialize Buffer Pool for NetCP SA to PA packets */ - nwal_global_cfg.sa2PaBufPool.numBufPools = 1; - nwal_global_cfg.sa2PaBufPool.bufPool[0].descSize = - TUNE_NETAPI_DESC_SIZE; - nwal_global_cfg.sa2PaBufPool.bufPool[0].bufSize = - odp_global->cfg.def_heap_buf_size; - - /* Populate the heap configuration */ - heap_cfg.name = "nwal SA2PA"; - heap_cfg.numPkts = TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC; - - nwal_global_cfg.sa2PaBufPool.bufPool[0].heapHandle = - Pktlib_createHeap(&heap_cfg, &pktlib_err); - if (nwal_global_cfg.sa2PaBufPool.bufPool[0].heapHandle == NULL) { - odp_pr_err("Heap Creation Failed for SA to PA Buffer Pool, Error Code: %d\n", - pktlib_err); - return -1; - } - odp_global->nwal.sa2pa_heap = - nwal_global_cfg.sa2PaBufPool.bufPool[0].heapHandle; - nwal_global_cfg.hopLimit = 5;/* Default TTL / Hop Limit */ - nwal_global_cfg.paPowerOn = nwal_TRUE; - nwal_global_cfg.saPowerOn = nwal_TRUE; - nwal_global_cfg.paFwActive = nwal_TRUE; - nwal_global_cfg.saFwActive = nwal_FALSE; - - /* Pick Default Physical Address */ - nwal_global_cfg.paVirtBaseAddr = (uint32_t)odp_vm_info.passCfgVaddr; - nwal_global_cfg.saVirtBaseAddr = (uint32_t)odp_vm_info.passCfgVaddr + - CSL_NETCP_CFG_SA_CFG_REGS - - CSL_NETCP_CFG_REGS; - - nwal_global_cfg.rxDefPktQ = QMSS_PARAM_NOT_SPECIFIED; - - /* Get the Buffer Requirement from NWAL */ - memset(&nwal_size_info, 0, sizeof(nwal_size_info)); - nwal_size_info.nMaxMacAddress = TUNE_NETAPI_MAX_NUM_MAC; - nwal_size_info.nMaxIpAddress = TUNE_NETAPI_MAX_NUM_IP; - nwal_size_info.nMaxL4Ports = TUNE_NETAPI_MAX_NUM_PORTS; - nwal_size_info.nMaxIpSecChannels = TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS; - nwal_size_info.nMaxDmSecChannels = TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS; - nwal_size_info.nMaxL2L3Hdr = TUNE_NETAPI_MAX_NUM_L2_L3_HDRS; - /** - * @todo: nProc increased by 1, because nwal_getLocContext() - * checks for >=. Better to fix nwal_getLocContext() - */ - nwal_size_info.nProc = TUNE_NETAPI_NUM_CORES + 1; - nwal_ret = nwal_getBufferReq(&nwal_size_info, sizes, aligns); - if (nwal_ret != nwal_OK) { - odp_pr_err("nwal_getBufferReq Failed %d\n", - nwal_ret); - return nwal_FALSE; - } - - /* Check for memory size requirement and update the base */ - count = 0; - bases[nwal_BUF_INDEX_INST] = (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)nwal_inst_mem); - if (NWAL_CONFIG_BUFSIZE_NWAL_HANDLE < sizes[nwal_BUF_INDEX_INST]) { - /* Resize Memory */ - while (1) - ; - } - count++; - - bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)nwal_handle_mem); - if (NWAL_CHAN_HANDLE_SIZE < sizes[nwal_BUF_INDEX_INT_HANDLES]) { - /* Resize Memory */ - while (1) - ; - } - count++; - bases[nwal_BUF_INDEX_PA_LLD_BUF0] = (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)pa_entry->pa_buf0); - if ((NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0]) { - /* Resize Memory */ - while (1) - ; - } - count++; - - bases[nwal_BUF_INDEX_PA_LLD_BUF1] = (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)pa_entry->pa_buf1); - if ((NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1]) { - /* Resize Memory */ - while (1) - ; - } - count++; - - bases[nwal_BUF_INDEX_PA_LLD_BUF2] = (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)pa_entry->pa_buf2); - if ((NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2]) { - /* Resize Memory */ - while (1) - ; - } - count++; -#ifdef NETAPI_ENABLE_SECURITY - bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = - (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)sa_entry->salld_handle); - if ((NWAL_CONFIG_BUFSIZE_SA_HANDLE) - < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE]) { - /* Resize Memory */ - while (1) - ; - } - count++; - - bases[nwal_BUF_INDEX_SA_CONTEXT] = (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)sa_context_mem_base); - /* also save this here for easy access to sa_start */ - nwal_global_cfg.scPoolBaseAddr = bases[nwal_BUF_INDEX_SA_CONTEXT]; - count++; - - bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = - (uint32_t *)Osal_nwalLocToGlobAddr( - (uint32_t)sa_entry->salld_chan_handle); - if ((NWAL_CONFIG_BUFSIZE_SA_HANDLE_PER_CHAN - * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS * 2) - < sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE]) { - /* Resize Memory */ - while (1) - ; - } - count++; -#else - bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = 0; - bases[nwal_BUF_INDEX_SA_CONTEXT] = 0; - bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = 0; - count = count+3; -#endif - if (count != nwal_N_BUFS) { - while (1) - ; - } - - /* Initialize NWAL module */ - nwal_ret = nwal_create(&nwal_global_cfg, &nwal_size_info, sizes, bases, - &odp_global->nwal.handle); - if (nwal_ret != nwal_OK) { - odp_pr_err("nwal_create Failed %d\n", - nwal_ret); - return -1; - } - - odp_pr_dbg("Global and Local Network initialization Successful\n"); - return 1; -} - -/******************************************************************** - * FUNCTION PURPOSE: Internal NETAPI function to start NWAL - ******************************************************************** - * DESCRIPTION: Internal NETAPI function to start NWAL, per thread/core - ********************************************************************/ -int mcsdk_nwal_start(Pktlib_HeapHandle pkt_heap, Pktlib_HeapHandle cmd_rx_heap, - Pktlib_HeapHandle cmd_tx_heap) -{ - nwalLocCfg_t nwal_local_cfg; - nwal_RetValue nwal_ret; - - memset(&nwal_local_cfg, 0, sizeof(nwal_local_cfg)); - - /* - * Update the Start of Packet Offset for the default flows created - * by NWAL - */ - nwal_local_cfg.rxSopPktOffset = odp_global->cfg.min_buf_headroom_size; - nwal_local_cfg.rxPktTailRoomSz = odp_global->cfg.def_heap_tailroom_size; - - /* Call back registration for the core */ - nwal_local_cfg.pRxPktCallBack = NULL; - nwal_local_cfg.pCmdCallBack = NULL; - nwal_local_cfg.pPaStatsCallBack = NULL; - nwal_local_cfg.pRxDmCallBack = NULL; - - /* Initialize Buffer Pool for Control packets from NetCP to Host */ - nwal_local_cfg.rxCtlPool.numBufPools = 1; - nwal_local_cfg.rxCtlPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE; - nwal_local_cfg.rxCtlPool.bufPool[0].bufSize = - TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE; - nwal_local_cfg.rxCtlPool.bufPool[0].heapHandle = cmd_rx_heap; - - /* Initialize Buffer Pool for Control packets from Host to NetCP */ - nwal_local_cfg.txCtlPool.numBufPools = 1; - nwal_local_cfg.txCtlPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE; - nwal_local_cfg.txCtlPool.bufPool[0].bufSize = - TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE; - nwal_local_cfg.txCtlPool.bufPool[0].heapHandle = cmd_tx_heap; - - /* Initialize Buffer Pool for Packets from NetCP to Host */ - nwal_local_cfg.rxPktPool.numBufPools = 1; - nwal_local_cfg.rxPktPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE; - nwal_local_cfg.rxPktPool.bufPool[0].bufSize = - odp_global->cfg.def_heap_buf_size; - nwal_local_cfg.rxPktPool.bufPool[0].heapHandle = pkt_heap; - - /* Initialize Buffer Pool for Packets from Host to NetCP */ - nwal_local_cfg.txPktPool.numBufPools = 1; - nwal_local_cfg.txPktPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE; - nwal_local_cfg.txPktPool.bufPool[0].bufSize = - odp_global->cfg.def_heap_buf_size; - nwal_local_cfg.txPktPool.bufPool[0].heapHandle = pkt_heap; - - memcpy(&odp_local.nwal.cfg, &nwal_local_cfg, sizeof(nwalLocCfg_t)); - while (1) { - nwal_ret = nwal_start(odp_global->nwal.handle, &nwal_local_cfg); - if (nwal_ret == nwal_ERR_INVALID_STATE) - continue; - break; - } - - if (nwal_ret != nwal_OK) { - odp_pr_err(">nwal_start:Failed ->err %d !!!\n", nwal_ret); - return -1; - } - return 1; -} - -int mcsdk_global_init(void) -{ - int32_t result; - Pktlib_HeapHandle shared_heap; - Pktlib_HeapHandle control_rx_heap, control_tx_heap; - Pktlib_HeapCfg heap_cfg; - int32_t pktlib_err; - void *base; - hplib_memPoolAttr_T mem_pool_attr[HPLIB_MAX_MEM_POOLS]; - int thread_id; - - thread_id = odp_thread_create(0); - odp_thread_init_local(thread_id); - hplib_utilSetupThread(thread_id, NULL, hplib_spinLock_Type_LOL); - - odp_local.is_main_thread = 1; /*Prevent local_init on this thread */ - - base = hplib_shmCreate(HPLIB_SHM_SIZE); - if (base == NULL) { - odp_pr_err("hplib_shmCreate failure\n"); - return -1; - } else { - odp_pr_dbg("hplib_shmCreate success\n"); - } - - if (hplib_shmAddEntry(base, sizeof(struct odp_global_s), NETAPI_ENTRY) - != hplib_OK) { - odp_pr_err("hplib_shmAddEntry failed for NETAPI_ENTRY\n"); - return -1; - } else { - odp_pr_dbg("hplib_shmAddEntry success for NETAPI_ENTRY\n"); - odp_global = hplib_shmGetEntry(base, NETAPI_ENTRY); - odp_global->cfg = default_mcsdk_cfg; - } - - hplib_utilModOpen(); - hplib_utilOsalCreate(); - - odp_proc.rm_service = rm_client_init(); - -#ifdef NETAPI_USE_DDR - /* Init attributes for DDR */ - mem_pool_attr[0].attr = HPLIB_ATTR_KM_CACHED0; - mem_pool_attr[0].phys_addr = 0; - mem_pool_attr[0].size = 0; - - /* Init attributes for un-cached MSMC */ - mem_pool_attr[1].attr = HPLIB_ATTR_UN_CACHED; - mem_pool_attr[1].phys_addr = CSL_MSMC_SRAM_REGS; - mem_pool_attr[1].size = TUNE_NETAPI_PERM_MEM_SZ; -#else - mem_pool_attr[1].attr = HPLIB_ATTR_KM_CACHED0; - mem_pool_attr[1].phys_addr = 0; - mem_pool_attr[1].size = 0; - - /* Init attributes for un-cached MSMC */ - mem_pool_attr[0].attr = HPLIB_ATTR_UN_CACHED; - mem_pool_attr[0].phys_addr = CSL_MSMC_SRAM_REGS; - mem_pool_attr[0].size = TUNE_NETAPI_PERM_MEM_SZ; -#endif - /* initialize all the memory we are going to use - - chunk for buffers, descriptors - - memory mapped peripherals we use, such as QMSS, PA, etc */ - result = hplib_vmInit(&odp_vm_info, 2, &mem_pool_attr[0]); - - hplib_initMallocArea(0); - hplib_initMallocArea(1); - -#ifdef NETAPI_ENABLE_SECURITY - /* - * allocate 2x number of tunnels since we need one for inflow and - * one for data mode - */ - sa_context_mem_base = hplib_vmMemAlloc( - (TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS * 2 * - NWAL_CONFIG_SEC_CONTEXT_SZ), - 128, 0); - if (!sa_context_mem_base) { - odp_pr_err("Failed to map SA context memory region\n"); - return -1; - } - odp_pr_dbg("SA Memory mapped/allocated at address %p.\n", - sa_context_mem_base); - -#else - sa_context_mem_base = NULL; -#endif - - /* Allocate QM region from contiguous chunk above */ - global_descriptor_mem_base = hplib_vmMemAlloc( - (odp_global->cfg.def_tot_descriptors_for_us - * TUNE_NETAPI_DESC_SIZE), - 128, 0); - - odp_pr_dbg("global desc region=%p\n", global_descriptor_mem_base); - - /* Initialize Queue Manager Sub System */ - result = mcsdk_qmss_init(odp_global->cfg.def_max_descriptors); - - if (result != 1) { - odp_pr_err("returned from netapip_initQm with failure\n"); - return -1; - } - - /* Start the QMSS. */ - if (mcsdk_qmss_start() != 1) { - odp_pr_err("returned from netapip_startQm with failure\n"); - return -1; - } - - /* Initialize the global descriptor memory region. */ - result = mcsdk_qmss_setup_memregion( - odp_global->cfg.def_tot_descriptors_for_us, - TUNE_NETAPI_DESC_SIZE, - global_descriptor_mem_base, - TUNE_NETAPI_QM_GLOBAL_REGION); - - if (result < 0) { - odp_pr_err("can't setup QM shared region\n"); - return -1; - } - - odp_pr_dbg("returned from netapip_qmSetupMemRegion\n"); - /* Initialize CPPI CPDMA */ - - result = mcsdk_cppi_init(); - odp_pr_dbg("returned from netapip_initCppi\n"); - if (result != 1) { - odp_pr_err("Error initializing CPPI SubSystem error code : %d\n", - result); - return -1; - } - mcsdk_cppi_start(); - - /* CPPI and Queue Manager are initialized. */ - odp_pr_dbg("Queue Manager and CPPI are initialized.\n"); - - /* create main pkt heap */ - /* Initialize the Shared Heaps. */ - Pktlib_sharedHeapInit(); - odp_pr_dbg("returned from Pktlib_sharedHeapInit\n"); - - /* Initialize the heap configuration. */ - memset((void *)&heap_cfg, 0, sizeof(Pktlib_HeapCfg)); - /* Populate the heap configuration */ - heap_cfg.name = "nwal_packet"; - heap_cfg.memRegion = TUNE_NETAPI_QM_GLOBAL_REGION; - heap_cfg.sharedHeap = 1; - heap_cfg.useStarvationQueue = 0; - heap_cfg.dataBufferSize = odp_global->cfg.def_heap_buf_size; - heap_cfg.numPkts = odp_global->cfg.def_heap_n_descriptors; - heap_cfg.numZeroBufferPackets = odp_global->cfg.def_heap_n_zdescriptors; - heap_cfg.heapInterfaceTable.data_malloc = - pktlib_if_table.data_malloc; - heap_cfg.heapInterfaceTable.data_free = pktlib_if_table.data_free; - heap_cfg.dataBufferPktThreshold = 0; - heap_cfg.zeroBufferPktThreshold = 0; - - /* Create Shared Heap with specified configuration. */ - shared_heap = Pktlib_createHeap(&heap_cfg, &pktlib_err); - odp_pr_dbg("returned from Pktlib_createHeap1\n"); - if (!shared_heap) { - /** @todo: cleanup on failure */ - odp_pr_err("heap create failed, Error Code: %d\n", - pktlib_err); - return -1; - } - odp_proc.nwal.netcp_heap = shared_heap; - - /* Update for Control */ - heap_cfg.name = "nwal_control_rx"; - heap_cfg.sharedHeap = 1; - heap_cfg.dataBufferSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE; - heap_cfg.numPkts = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF; - heap_cfg.numZeroBufferPackets = 0; - - control_rx_heap = Pktlib_createHeap(&heap_cfg, &pktlib_err); - odp_pr_dbg("returned from Pktlib_createHeap2\n"); - if (!control_rx_heap) { - /** @todo: cleanup on failure */ - odp_pr_err("control rx heap create failed, Error Code: %d\n", - pktlib_err); - return -1; - } - odp_proc.nwal.netcp_control_rx_heap = control_rx_heap; - - heap_cfg.name = "nwal_control_tx"; - heap_cfg.numPkts = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF; - - control_tx_heap = Pktlib_createHeap(&heap_cfg, &pktlib_err); - odp_pr_dbg("returned from Pktlib_createHeap3\n"); - if (!control_tx_heap) { - /** @todo: cleanup on failure */ - odp_pr_err("control tx heap create failed, Error Code: %d\n", - pktlib_err); - return -1; - } - odp_proc.nwal.netcp_control_tx_heap = control_tx_heap; - - /* Init NWAL */ - result = mcsdk_nwal_init(TUNE_NETAPI_QM_GLOBAL_REGION, - &pktlib_if_table); - if (result < 0) { - odp_pr_err("netapi init_nwal() failed\n"); - return -1; - } - odp_pr_dbg("returned from netapip_initNwal\n"); - - /* start NWAL */ - result = mcsdk_nwal_start(shared_heap, control_rx_heap, - control_tx_heap); - if (result < 0) { - odp_pr_err("netapi start_nwal() failed\n"); - return -1; - } - odp_pr_dbg("returned from netapip_startNwal\n"); - return 0; -} - -int mcsdk_local_init(int thread_id) -{ - int ret; - /* Main thread already finished initialization */ - if (odp_local.is_main_thread) { - odp_pr_dbg("Skip odp_local_init() for the main thread\n"); - return 1; - } - odp_pr_dbg("thread_id: %d\n", thread_id); - - hplib_utilSetupThread(thread_id, NULL, hplib_spinLock_Type_LOL); - /* Start the QMSS. */ - if (mcsdk_qmss_start() != 1) - return -1; - - mcsdk_cppi_start(); - - ret = mcsdk_nwal_start(odp_proc.nwal.netcp_heap, - odp_proc.nwal.netcp_control_rx_heap, - odp_proc.nwal.netcp_control_tx_heap); - - if (ret < 0) { - odp_pr_err("mcsdk_nwal_start() failed\n"); - return -1; - } - odp_pr_dbg("thread_id: %d\n", thread_id); - return 0; -} - -void odp_print_mem(void *addr, size_t size, const char *desc) -{ - uint8_t *start_ptr, *end_ptr, *ptr; - int i; - - if (!size) - return; - - if (desc) - printf("\n%s (%u bytes)\n", desc, size); - else - printf("Dumping %u bytes at address 0x%08x\n", - size, (unsigned int)addr); - - start_ptr = addr; - end_ptr = start_ptr + size; - ptr = (typeof(ptr))(((uintptr_t)start_ptr) & ~0xF); - - while (ptr < end_ptr) { - printf("0x%08x: ", (unsigned int)ptr); - for (i = 0; i < 16; i++) { - if (start_ptr <= ptr && ptr < end_ptr) - printf("%02x ", *ptr); - else - printf("__ "); - ptr++; - } - printf("\n"); - } -} diff --git a/platform/linux-keystone2/mcsdk/mcsdk_navig.c b/platform/linux-keystone2/mcsdk/mcsdk_navig.c deleted file mode 100644 index dd1caba..0000000 --- a/platform/linux-keystone2/mcsdk/mcsdk_navig.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -extern Qmss_GlobalConfigParams qmssGblCfgParams; -extern Cppi_GlobalConfigParams cppiGblCfgParams; - -/** - * Internal NETAPI macro to convert to IP Register Virtual Address - * from a mapped base Virtual Address. - * - * @param virt_base_addr Virtual base address mapped using mmap for IP - * @param phys_base_addr Physical base address for the IP - * @param phys_reg_addr Physical register address - * - * @return virtual address - */ -static inline void *reg_phys2virt(void *virt_base_addr, - uint32_t phys_base_addr, - uint32_t phys_reg_addr) -{ - return (void *)((uint8_t *)virt_base_addr + - (phys_reg_addr - phys_base_addr)); -} - -/***************************************************************************** - * FUNCTION PURPOSE: Global Initialization of CPPI. Once Per System - ***************************************************************************** - * DESCRIPTION: The function will initialize the CPPI - *****************************************************************************/ -int mcsdk_cppi_init(void) -{ - int32_t result; - Cppi_GlobalConfigParams config_params; - Cppi_GlobalCPDMAConfigParams *dma_cfgs; - - config_params = cppiGblCfgParams; - /* Convert Physical address to Virtual address for LLD access */ - /* PASS CPDMA regs */ - dma_cfgs = &config_params.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA]; - dma_cfgs->gblCfgRegs = reg_phys2virt(odp_vm_info.passCfgVaddr, - CSL_NETCP_CFG_REGS, (uint32_t)dma_cfgs->gblCfgRegs); - - dma_cfgs->txChRegs = reg_phys2virt(odp_vm_info.passCfgVaddr, - CSL_NETCP_CFG_REGS, (uint32_t)dma_cfgs->txChRegs); - - dma_cfgs->rxChRegs = reg_phys2virt(odp_vm_info.passCfgVaddr, - CSL_NETCP_CFG_REGS, (uint32_t)dma_cfgs->rxChRegs); - - dma_cfgs->txSchedRegs = reg_phys2virt(odp_vm_info.passCfgVaddr, - CSL_NETCP_CFG_REGS, (uint32_t)dma_cfgs->txSchedRegs); - - dma_cfgs->rxFlowRegs = reg_phys2virt(odp_vm_info.passCfgVaddr, - CSL_NETCP_CFG_REGS, (uint32_t)dma_cfgs->rxFlowRegs); - - /* QMSS CPDMA regs */ - dma_cfgs = &config_params.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA]; - dma_cfgs->gblCfgRegs = reg_phys2virt(odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, (uint32_t)dma_cfgs->gblCfgRegs); - - dma_cfgs->txChRegs = reg_phys2virt(odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, (uint32_t)dma_cfgs->txChRegs); - - dma_cfgs->rxChRegs = reg_phys2virt(odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, (uint32_t)dma_cfgs->rxChRegs); - - dma_cfgs->txSchedRegs = reg_phys2virt(odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, (uint32_t)dma_cfgs->txSchedRegs); - - dma_cfgs->rxFlowRegs = reg_phys2virt(odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, (uint32_t)dma_cfgs->rxFlowRegs); - - result = Cppi_init(&config_params); - if (result != CPPI_SOK) { - odp_pr_err("Cppi_init failed with error code %d\n", result); - return -1; - } - return 1; -} - -/***************************************************************************** - * FUNCTION PURPOSE: Global Initialization of Queue Manager. Once Per System - ***************************************************************************** - * DESCRIPTION: The function will initialize the Queue Manager - *****************************************************************************/ -int mcsdk_qmss_init(int max_descriptors) -{ - Qmss_InitCfg init_config; - int32_t result; - Qmss_GlobalConfigParams config_params; - Qmss_GlobalConfigRegs *regs; - uint32_t count; - - memset(&init_config, 0, sizeof(Qmss_InitCfg)); - - /* Use Internal Linking RAM for optimal performance */ - init_config.linkingRAM0Base = 0; - init_config.linkingRAM0Size = 0; - init_config.linkingRAM1Base = 0; - init_config.maxDescNum = max_descriptors; - init_config.qmssHwStatus = QMSS_HW_INIT_COMPLETE; - - config_params = qmssGblCfgParams; - config_params.qmRmServiceHandle = odp_proc.rm_service; - regs = &config_params.regs; - - /* Convert address to Virtual address */ - for (count = 0; count < config_params.maxQueMgrGroups; count++) { - Qmss_GlobalConfigGroupRegs *group_regs; - group_regs = &config_params.groupRegs[count]; - group_regs->qmConfigReg = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)group_regs->qmConfigReg); - - group_regs->qmDescReg = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)group_regs->qmDescReg); - - group_regs->qmQueMgmtReg = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)group_regs->qmQueMgmtReg); - - group_regs->qmQueMgmtProxyReg = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)group_regs->qmQueMgmtProxyReg); - - group_regs->qmQueStatReg = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)group_regs->qmQueStatReg); - - group_regs->qmStatusRAM = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)group_regs->qmStatusRAM); - - group_regs->qmQueMgmtDataReg = reg_phys2virt( - odp_vm_info.qmssDataVaddr, - CSL_QMSS_DATA_BASE, - (uint32_t)group_regs->qmQueMgmtDataReg); - - group_regs->qmQueMgmtProxyDataReg = - NULL; - } - - for (count = 0; count < QMSS_MAX_INTD; count++) { - regs->qmQueIntdReg[count] = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)regs->qmQueIntdReg[count]); - } - - for (count = 0; count < QMSS_MAX_PDSP; count++) { - regs->qmPdspCmdReg[count] = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)regs->qmPdspCmdReg[count]); - - regs->qmPdspCtrlReg[count] = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)regs->qmPdspCtrlReg[count]); - - regs->qmPdspIRamReg[count] = reg_phys2virt( - odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, - (uint32_t)regs->qmPdspIRamReg[count]); - } - - regs->qmLinkingRAMReg = reg_phys2virt(odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, (uint32_t)regs->qmLinkingRAMReg); - - regs->qmBaseAddr = reg_phys2virt(odp_vm_info.qmssCfgVaddr, - CSL_QMSS_CFG_BASE, (uint32_t)regs->qmBaseAddr); - - result = Qmss_init(&init_config, &config_params); - if (result != QMSS_SOK) { - odp_pr_err("%s: qmss_Init failed with error code %d\n", - __func__, result); - return nwal_FALSE; - } - return 1; -} - -/******************************************************************** - * FUNCTION PURPOSE: Internal NETAPI function to start QM - ******************************************************************** - * DESCRIPTION: Internal NETAPI function to start QM - * once per thread/core - ********************************************************************/ -int mcsdk_qmss_start(void) -{ - int32_t result; - Qmss_StartCfg start_cfg; - - start_cfg.rmServiceHandle = odp_proc.rm_service; - - result = Qmss_startCfg(&start_cfg); - if (result != QMSS_SOK) { - odp_pr_err("Qmss_start failed with error code %d\n", result); - return -1; - } - return 1; -} - -int mcsdk_cppi_start(void) -{ - Cppi_StartCfg start_cfg; - - start_cfg.rmServiceHandle = odp_proc.rm_service; - - Cppi_startCfg(&start_cfg); - - return 1; -} - -/******************************************************************** - * FUNCTION PURPOSE: Internal NETAPI function to setup the QM memory region - ******************************************************************** - * DESCRIPTION: Internal NETAPI function to setup the QM memory region, - * once per SOC - ********************************************************************/ -int mcsdk_qmss_setup_memregion(uint32_t desc_num, uint32_t desc_size, - uint32_t *desc_mem_base, Qmss_MemRegion mem_region) -{ - Qmss_MemRegInfo mem_info; - Int32 result; - - memset(&mem_info, 0, sizeof(Qmss_MemRegInfo)); - mem_info.descBase = desc_mem_base; - mem_info.descSize = desc_size; - mem_info.descNum = desc_num; - mem_info.manageDescFlag = Qmss_ManageDesc_MANAGE_DESCRIPTOR; - mem_info.memRegion = mem_region; - mem_info.startIndex = TUNE_NETAPI_QM_START_INDEX; - - memset(desc_mem_base, 0, (desc_size * desc_num)); - - result = Qmss_insertMemoryRegion(&mem_info); - if (result < QMSS_SOK) { - odp_pr_err("Qmss_insertMemoryRegion returned error code %d\n", - result); - return -1; - } - - return 1; -} diff --git a/platform/linux-keystone2/mcsdk/mcsdk_rmclient.c b/platform/linux-keystone2/mcsdk/mcsdk_rmclient.c deleted file mode 100644 index c42c691..0000000 --- a/platform/linux-keystone2/mcsdk/mcsdk_rmclient.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - * - * Based on TI McSDK NETAPI library - */ - -/* Standard includes */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* Socket Includes */ -#include "sockutils.h" -#include "sockrmmsg.h" - -/* RM Includes */ -#include -#include -#include - -/* Test FALSE */ -#define RM_TEST_FALSE 0 -/* Test TRUE */ -#define RM_TEST_TRUE 1 - -/* Socket timeout */ -#define CLIENT_SOCK_TIMEOUT_USEC 500 - -/* Application's registered RM transport indices */ -#define SERVER_TO_CLIENT 0 -/* Maximum number of registered RM transports */ -#define MAX_MAPPING_ENTRIES 1 - -/* RM registered transport mapping structure */ -struct trans_map_entry_s { - /* Registered RM transport handle */ - Rm_TransportHandle transportHandle; - /* Remote socket tied to the transport handle */ - sock_name_t *remote_sock; -}; - -/* Client instance name */ -char rm_client_name[RM_NAME_MAX_CHARS] = "RM_Client0"; - -/* Client socket name */ -char rm_client_sock_name[] = "/tmp/var/run/rm/rm_client"; - -/* Client socket handle */ -sock_h rm_client_socket; - -/* Client instance handles */ -Rm_Handle rm_client_handle; - -/* Transport map stores the RM transport handle to IPC MessageQ mapping */ -struct trans_map_entry_s rm_transport_map[MAX_MAPPING_ENTRIES]; - -hplib_spinLock_T net_rm_lock; - - -static Rm_Packet *transport_alloc(Rm_AppTransportHandle transport ODP_UNUSED, - uint32_t pkt_size, - Rm_PacketHandle *pkt_handle) -{ - Rm_Packet *rm_pkt = NULL; - - rm_pkt = calloc(1, sizeof(*rm_pkt)); - if (!rm_pkt) { - odp_pr_err("can't malloc for RM send message (err: %s)\n", - strerror(errno)); - return NULL; - } - rm_pkt->pktLenBytes = pkt_size; - *pkt_handle = rm_pkt; - - return rm_pkt; -} - -static void transport_free(Rm_Packet *rm_pkt) -{ - if (rm_pkt) - free(rm_pkt); -} - -static void transport_receive(void) -{ - int32_t rm_result; - int retval; - int length = 0; - sock_name_t server_sock_addr; - Rm_Packet *rm_pkt = NULL; - struct sockaddr_un server_addr; - - retval = sock_wait(rm_client_socket, &length, NULL, -1); - if (retval == -2) { - /* Timeout */ - return; - } else if (retval < 0) { - odp_pr_err("Error in reading from socket, error %d\n", retval); - return; - } - - if (length < (int)sizeof(*rm_pkt)) { - odp_pr_err("invalid RM message length %d\n", length); - return; - } - rm_pkt = calloc(1, length); - if (!rm_pkt) { - odp_pr_err("can't malloc for recv'd RM message (err: %s)\n", - strerror(errno)); - return; - } - - server_sock_addr.type = sock_addr_e; - server_sock_addr.s.addr = &server_addr; - retval = sock_recv(rm_client_socket, (char *)rm_pkt, length, - &server_sock_addr); - if (retval != length) { - odp_pr_err("recv RM pkt failed from socket, received = %d, expected = %d\n", - retval, length); - return; - } - - odp_pr_vdbg("received RM pkt of size %d bytes from %s\n", length, - server_sock_addr.s.addr->sun_path); - - /* Provide packet to RM Server for processing */ - rm_result = Rm_receivePacket( - rm_transport_map[SERVER_TO_CLIENT].transportHandle, - rm_pkt); - if (rm_result != RM_OK) - odp_pr_err("RM failed to process received packet: %d\n", - rm_result); - - transport_free(rm_pkt); -} - -static int32_t transport_send_rcv(Rm_AppTransportHandle app_transport, - Rm_PacketHandle pkt_handle) -{ - sock_name_t *server_sock_name = (sock_name_t *)app_transport; - Rm_Packet *rm_pkt = (Rm_Packet *)pkt_handle; - - hplib_mSpinLockLock(&net_rm_lock); - if (sock_send(rm_client_socket, (char *)rm_pkt, - (int)rm_pkt->pktLenBytes, server_sock_name)) { - odp_pr_err("send data failed\n"); - hplib_mSpinLockUnlock(&net_rm_lock); - return -1; - } - - /* Wait for response from Server */ - transport_receive(); - hplib_mSpinLockUnlock(&net_rm_lock); - - return 0; -} - -static int connection_setup(void) -{ - Rm_TransportCfg transport_cfg; - int i; - sock_name_t sock_name; - int32_t result = 0; - char server_sock_name[] = RM_SERVER_SOCKET_NAME; - - /* Initialize the transport map */ - for (i = 0; i < MAX_MAPPING_ENTRIES; i++) - rm_transport_map[i].transportHandle = NULL; - - sock_name.type = sock_name_e; - sock_name.s.name = rm_client_sock_name; - - rm_client_socket = sock_open(&sock_name); - if (!rm_client_socket) { - odp_pr_err("Client socket open failed\n"); - return -1; - } - - rm_transport_map[SERVER_TO_CLIENT].remote_sock = - calloc(1, sizeof(sock_name_t)); - rm_transport_map[SERVER_TO_CLIENT].remote_sock->type = - sock_name_e; - rm_transport_map[SERVER_TO_CLIENT].remote_sock->s.name = - calloc(1, strlen(server_sock_name) + 1); - strncpy(rm_transport_map[SERVER_TO_CLIENT].remote_sock->s.name, - server_sock_name, strlen(server_sock_name) + 1); - - /* Register the Server with the Client instance */ - transport_cfg.rmHandle = rm_client_handle; - transport_cfg.appTransportHandle = (Rm_AppTransportHandle) - rm_transport_map[SERVER_TO_CLIENT].remote_sock; - transport_cfg.remoteInstType = Rm_instType_SERVER; - transport_cfg.transportCallouts.rmAllocPkt = transport_alloc; - transport_cfg.transportCallouts.rmSendPkt = transport_send_rcv; - rm_transport_map[SERVER_TO_CLIENT].transportHandle = - Rm_transportRegister(&transport_cfg, &result); - - return 0; -} - -static int free_all_resources(Rm_ServiceHandle *rm_service) -{ - Rm_ServiceReqInfo request; - Rm_ServiceRespInfo response; - return 0; - memset((void *)&request, 0, sizeof(request)); - memset((void *)&response, 0, sizeof(response)); - - request.type = Rm_service_RESOURCE_FREE; - request.resourceName = "ALL"; - request.resourceBase = RM_RESOURCE_BASE_UNSPECIFIED; - request.resourceLength = 0; - request.resourceAlignment = 0; - /* RM will block until resource is returned since callback is NULL */ - request.callback.serviceCallback = NULL; - odp_pr_dbg("resourceName: %s\n", request.resourceName); - rm_service->Rm_serviceHandler(rm_service->rmHandle, &request, - &response); - odp_pr_dbg("serviceState: %d\n", response.serviceState); - - return (response.serviceState == RM_SERVICE_APPROVED) ? 0 : 1; -} - -Rm_ServiceHandle *rm_client_init(void) -{ - Rm_InitCfg init_cfg; - int32_t result; - Rm_ServiceHandle *service_handle = NULL; - - hplib_mSpinLockInit(&net_rm_lock); - - odp_pr_dbg("RM Version : 0x%08x\nVersion String: %s\n", Rm_getVersion(), - Rm_getVersionStr()); - - /* Initialize the RM Client */ - memset(&init_cfg, 0, sizeof(init_cfg)); - init_cfg.instName = rm_client_name; - init_cfg.instType = Rm_instType_CLIENT; - init_cfg.instCfg.clientCfg.staticPolicy = NULL; - - rm_client_handle = Rm_init(&init_cfg, &result); - if (result != RM_OK) { - odp_pr_err("%s: Initialization failed\n", rm_client_name); - return NULL; - } - - odp_pr_dbg("Initialized %s\n", rm_client_name); - - /* Open Client service handle */ - service_handle = Rm_serviceOpenHandle(rm_client_handle, &result); - if (result != RM_OK) { - odp_pr_err("%s: Service handle open failed\n", rm_client_name); - return NULL; - } - - if (connection_setup()) - return NULL; - - free_all_resources(service_handle); - - return service_handle; -} diff --git a/platform/linux-keystone2/mcsdk/sockutils.c b/platform/linux-keystone2/mcsdk/sockutils.c deleted file mode 100644 index b31e8cc..0000000 --- a/platform/linux-keystone2/mcsdk/sockutils.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - * - * Based on TI McSDK NETAPI library - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "sockutils.h" -#include "odp_debug_internal.h" - -typedef struct sock_data { - struct sockaddr_un addr; - fd_set readfds; - int fd; -} sock_data_t; - -static int check_and_create_path(char *path) -{ - char *d = path; - if (!d) - return -1; - - while ((d = strchr(d + 1, '/'))) { - *d = 0; - if (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { - if (errno != EEXIST) { - *d = '/'; - odp_pr_err("can't create path %s (error: %s)", - path, strerror(errno)); - return -1; - } - } - *d = '/'; - } - return 0; -} - -sock_h sock_open(sock_name_t *sock_name) -{ - sock_data_t *sd = 0; - int retval = 0; - - if (!sock_name) - return 0; - - sd = calloc(1, sizeof(sock_data_t)); - - if (sock_name->type == sock_addr_e) { - memcpy(&sd->addr, sock_name->s.addr, - sizeof(struct sockaddr_un)); - } else { - if (check_and_create_path(sock_name->s.name) < 0) - goto check_n_return; - sd->addr.sun_family = AF_UNIX; - strncpy(sd->addr.sun_path, sock_name->s.name, UNIX_PATH_MAX); - } - - sd->fd = socket(AF_UNIX, SOCK_DGRAM, 0); - if (sd->fd < 0) { - odp_pr_err("can't open socket %s (error: %s)", - sd->addr.sun_path, strerror(errno)); - goto check_n_return; - } - - unlink(sd->addr.sun_path); - if (bind(sd->fd, (struct sockaddr *)&sd->addr, - sizeof(struct sockaddr_un)) < 0) { - odp_pr_err("can't bind socket %s (error: %s)", - sd->addr.sun_path, strerror(errno)); - goto check_n_return; - } - - FD_ZERO(&sd->readfds); - FD_SET(sd->fd, &sd->readfds); - - retval = (int) sd; - -check_n_return: - if (!retval) - sock_close((sock_h)sd); - - return (sock_h)retval; -} - -int sock_close(sock_h handle) -{ - sock_data_t *sd = (sock_data_t *)handle; - - if (!sd) - return -1; - - if (sd->fd) - close(sd->fd); - free(sd); - - return 0; -} - -int sock_send(sock_h handle, const char *data, int length, - sock_name_t *to) -{ - int fd; - sock_data_t *sd = (sock_data_t *)handle; - struct sockaddr_un to_addr; - - if (!to) - return -1; - - if (to->type == sock_addr_e) { - memcpy(&to_addr, to->s.addr, sizeof(struct sockaddr_un)); - } else { - to_addr.sun_family = AF_UNIX; - strncpy(to_addr.sun_path, to->s.name, UNIX_PATH_MAX); - } - - if (sd) { - fd = sd->fd; - } else { - fd = socket(AF_UNIX, SOCK_DGRAM, 0); - if (fd < 0) { - odp_pr_err("can't open socket %s (error: %s)", - to_addr.sun_path, strerror(errno)); - return -1; - } - } - - if (sendto(fd, data, length, 0, (struct sockaddr *)&to_addr, - sizeof(struct sockaddr_un)) < 0) { - odp_pr_err("can't send data to %s (error: %s)", - to_addr.sun_path, strerror(errno)); - return -1; - } - - return 0; -} - -int sock_wait(sock_h handle, int *size, struct timeval *timeout, int extern_fd) -{ - sock_data_t *sd = (sock_data_t *)handle; - int retval; - fd_set fds; - - if (!sd) { - odp_pr_err("invalid hanlde"); - return -1; - } - - fds = sd->readfds; - - if (extern_fd != -1) - FD_SET(extern_fd, &fds); - - retval = select(FD_SETSIZE, &fds, NULL, NULL, timeout); - if (retval == -1) { - odp_pr_err("select failed for %s (error: %s)", - sd->addr.sun_path, strerror(errno)); - return -1; - } - - if ((extern_fd != -1) && (FD_ISSET(extern_fd, &fds))) - return 1; - - if (!FD_ISSET(sd->fd, &fds)) - return -2; /* Wait timedout */ - - if (!retval) - return 0; - - if (size != 0) { - retval = ioctl(sd->fd, FIONREAD, size); - if (retval == -1) { - odp_pr_err("can't read datagram size for %s (error: %s)", - sd->addr.sun_path, strerror(errno)); - return -1; - } - } - - return 0; -} - -int sock_recv(sock_h handle, char *data, int length, sock_name_t *from) -{ - int size; - sock_data_t *sd = (sock_data_t *)handle; - socklen_t from_length = 0; - struct sockaddr *sock_addr; - - if (!sd) { - odp_pr_err("invalid handle"); - return -1; - } - - if (from) { - from->type = sock_addr_e; - if (from->type && from->s.addr) { - from_length = sizeof(struct sockaddr_un); - } else { - odp_pr_err("invalid from parameter"); - return -1; - } - } - - sock_addr = (struct sockaddr *)((from_length) ? from->s.addr : NULL); - size = recvfrom(sd->fd, data, length, 0, sock_addr, &from_length); - if (size < 1) { - odp_pr_err("can't read datagram from socket for %s (error: %s), size %d", - sd->addr.sun_path, strerror(errno), size); - return -1; - } - - return size; -} diff --git a/platform/linux-keystone2/odp_buffer.c b/platform/linux-keystone2/odp_buffer.c deleted file mode 100644 index 676a8a4..0000000 --- a/platform/linux-keystone2/odp_buffer.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include - -int odp_buffer_snprint(char *str, size_t n, odp_buffer_t buf) -{ - Cppi_HostDesc *desc; - int len = 0; - - if (!odp_buffer_is_valid(buf)) { - printf("Buffer is not valid.\n"); - return len; - } - - desc = _odp_buf_to_cppi_desc(buf); - - len += snprintf(&str[len], n-len, - "Buffer\n"); - len += snprintf(&str[len], n-len, - " desc_vaddr %p\n", desc); - len += snprintf(&str[len], n-len, - " buf_paddr_o 0x%x\n", desc->origBuffPtr); - len += snprintf(&str[len], n-len, - " buf_paddr 0x%x\n", desc->buffPtr); - len += snprintf(&str[len], n-len, - " buf_len_o 0x%x\n", desc->origBufferLen); - len += snprintf(&str[len], n-len, - " buf_len 0x%x\n", desc->buffLen); - len += snprintf(&str[len], n-len, - " pool %p\n", odp_buf_to_pool(buf)); - - len += snprintf(&str[len], n-len, "\n"); - - return len; -} - -void odp_buffer_print(odp_buffer_t buf) -{ - int max_len = 512; - char str[max_len]; - int len; - Cppi_HostDesc *desc; - - len = odp_buffer_snprint(str, max_len-1, buf); - if (!len) - return; - str[len] = 0; - - printf("\n%s\n", str); - - desc = _odp_buf_to_cppi_desc(buf); - odp_print_mem(desc, sizeof(*desc), "Descriptor dump"); - odp_print_mem((void *)desc->origBuffPtr, - desc->buffPtr - desc->origBuffPtr + 128, - "Buffer start"); -} - -void odp_buffer_copy_scatter(odp_buffer_t buf_dst, odp_buffer_t buf_src) -{ - (void)buf_dst; - (void)buf_src; -} diff --git a/platform/linux-keystone2/odp_buffer_pool.c b/platform/linux-keystone2/odp_buffer_pool.c deleted file mode 100644 index 3ff0180..0000000 --- a/platform/linux-keystone2/odp_buffer_pool.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/** - * @todo: Currently a number of HW descriptors is limited, - * so temporary limit max number of buffers per pool - * to be albe to run ODP example apps. - * Descriptor management have to be made more intelligent - * To remove this limitation. - */ -#define MAX_BUFS_PER_POOL 1024 - -int odp_buffer_pool_init_global(void) -{ - /* Pktlib initialized in mcsdk_global_init() */ - return 0; -} - -odp_buffer_pool_t odp_buffer_pool_create(const char *name, - void *base_addr ODP_UNUSED, uint64_t size, - size_t buf_size, size_t buf_align, - int buf_type ODP_UNUSED) -{ - Pktlib_HeapCfg heap_cfg; - Pktlib_HeapHandle heap_handle; - int num_bufs; - int err_code; - - buf_size = ODP_ALIGN_ROUNDUP(buf_size, buf_align); - /* - * XXX: size is used only to get number of buffers. - * Memory is allocated for each buffer separately - */ - num_bufs = size / buf_size; - buf_size += odp_global->cfg.min_buf_headroom_size; - buf_size = ODP_CACHE_LINE_SIZE_ROUNDUP(buf_size); - - - if (num_bufs > MAX_BUFS_PER_POOL) { - odp_pr_dbg("Limiting number of buffer in %s from %d to %d\n", - name, num_bufs, MAX_BUFS_PER_POOL); - num_bufs = MAX_BUFS_PER_POOL; - } - - /* Initialize the heap configuration. */ - memset((void *)&heap_cfg, 0, sizeof(Pktlib_HeapCfg)); - /* Populate the heap configuration */ - heap_cfg.name = name; - heap_cfg.memRegion = TUNE_NETAPI_QM_GLOBAL_REGION; - heap_cfg.sharedHeap = 1; - heap_cfg.useStarvationQueue = 0; - heap_cfg.dataBufferSize = buf_size; - heap_cfg.numPkts = num_bufs; - heap_cfg.numZeroBufferPackets = 0; - heap_cfg.heapInterfaceTable.data_malloc = - pktlib_if_table.data_malloc; - heap_cfg.heapInterfaceTable.data_free = - pktlib_if_table.data_free; - heap_cfg.dataBufferPktThreshold = 0; - heap_cfg.zeroBufferPktThreshold = 0; - odp_pr_dbg("name: %s, buf_size: %u, num_bufs: %u\n", name, buf_size, - num_bufs); - /* Create Shared Heap with specified configuration. */ - heap_handle = Pktlib_createHeap(&heap_cfg, &err_code); - odp_pr_dbg("heap_handle: %p, err_code: %d\n", heap_handle, err_code); - return heap_handle; -} - -odp_buffer_pool_t odp_buffer_pool_lookup(const char *name) -{ - return Pktlib_findHeapByName(name); -} - -odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool_id) -{ - Ti_Pkt *pkt; - odp_buffer_t buf; - Cppi_HostDesc *desc; - - pkt = Pktlib_allocPacket(pool_id, -1); - if (!pkt) - return ODP_BUFFER_INVALID; - - buf = _ti_pkt_to_odp_buf(pkt); - desc = _odp_buf_to_cppi_desc(buf); - - /* Leave space for buffer metadata. There must be enough space. */ - desc->buffPtr = desc->origBuffPtr + - odp_global->cfg.min_buf_headroom_size; - - odp_pr_vdbg("pool_id: %p, pkt: %p, buf: %p\n", pool_id, pkt, buf); - return buf; -} - -void odp_buffer_free(odp_buffer_t buf) -{ - odp_pr_vdbg("buf: %p\n", buf); - Pktlib_freePacket(_odp_buf_to_ti_pkt(buf)); -} - -void odp_buffer_pool_print(odp_buffer_pool_t pool_id) -{ - (void)pool_id; -} - -odp_buffer_pool_t odp_buf_to_pool(odp_buffer_t buf) -{ - return Pktlib_getPktHeap(_odp_buf_to_ti_pkt(buf)); -} - -uint32_t _odp_pool_get_free_queue(odp_buffer_pool_t pool_id) -{ - return Pktlib_getInternalHeapQueue(pool_id); -} diff --git a/platform/linux-keystone2/odp_crypto.c b/platform/linux-keystone2/odp_crypto.c deleted file mode 100644 index 7525bab..0000000 --- a/platform/linux-keystone2/odp_crypto.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define MAX_SESSIONS 32 - -typedef struct { - odp_atomic_u32_t next; - uint32_t max; - struct odp_crypto_session_s sessions[0]; -} odp_crypto_global_t; - -static odp_crypto_global_t *global; - -static struct odp_crypto_session_s *alloc_session(void) -{ - uint32_t idx; - struct odp_crypto_session_s *session = NULL; - - idx = odp_atomic_fetch_inc_u32(&global->next); - if (idx < global->max) { - session = &global->sessions[idx]; - session->index = idx; - } - return session; -} - -static void _print_nwalCreateDmSAParams(nwalCreateDmSAParams_t *dmSaParam) -{ - odp_pr_dbg("dmSaParam.dmChnType = %u\n", - dmSaParam->dmSaParam.dmChnType); - odp_pr_dbg("dmSaParam.authMode = %u\n", dmSaParam->dmSaParam.authMode); - odp_pr_dbg("dmSaParam.cipherMode = %u\n", - dmSaParam->dmSaParam.cipherMode); - odp_pr_dbg("dmSaParam.enc1st = %u\n", dmSaParam->dmSaParam.enc1st); - odp_pr_dbg("dmSaParam.macSize = %u\n", dmSaParam->dmSaParam.macSize); - odp_pr_dbg("dmSaParam.aadSize = %u\n", dmSaParam->dmSaParam.aadSize); - odp_pr_dbg("dmSaParam.replayWindow = %u\n", - dmSaParam->dmSaParam.replayWindow); - - if (dmSaParam->dmSaParam.cipherMode != NWAL_SA_EALG_NULL) - odp_pr_dbg_mem(dmSaParam->keyParam.pEncKey, - dmSaParam->keyParam.encKeySize, - "keyParam.pEncKey"); - if (dmSaParam->dmSaParam.authMode != NWAL_SA_AALG_NULL) - odp_pr_dbg_mem(dmSaParam->keyParam.pAuthKey, - dmSaParam->keyParam.macKeySize, - "keyParam.pAuthKey"); -} - -int odp_crypto_session_create(odp_crypto_session_params_t *params, - odp_crypto_session_t *session_out, - enum odp_crypto_ses_create_err *status) -{ - nwal_RetValue nwal_ret; - nwalCreateDmSAParams_t sa_params; - nwalMbufPool_t rx_pool; - Cppi_FlowHnd out_flow; - struct odp_crypto_session_s *session; - - ODP_ASSERT((params->cipher_alg != ODP_CIPHER_ALG_NULL || - params->auth_alg != ODP_AUTH_ALG_NULL), - "Both algorithms are NULL"); - - if (params->cipher_alg == ODP_CIPHER_ALG_NULL) { - params->cipher_key.data = NULL; - params->cipher_key.length = 0; - } - - if (params->auth_alg == ODP_AUTH_ALG_NULL && - params->cipher_alg != ODP_CIPHER_ALG_AES_GCM && - params->cipher_alg != ODP_CIPHER_ALG_AES_CCM) { - params->auth_key.data = NULL; - params->auth_key.length = 0; - } - - /* Default to failure result */ - *status = ODP_CRYPTO_SES_CREATE_ERR_NONE; - *session_out = ODP_CRYPTO_SESSION_INVALID; - - - /* Allocate memory for this session */ - session = alloc_session(); - if (!session) { - *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM; - return -1; - } - - /* Copy stuff over */ - session->op = params->op; - session->cipher.alg = params->cipher_alg; - session->auth.alg = params->auth_alg; - if (sizeof(session->cipher.iv.data) < params->iv.length) { - *status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER; - return -1; - } - memcpy(session->cipher.iv.data, params->iv.data, params->iv.length); - /** @todo: need separate IV for Auth */ - memcpy(session->auth.iv.data, params->iv.data, params->iv.length); - - session->compl_queue = params->compl_queue; - session->out_pool = params->output_pool; - - rx_pool.numBufPools = 1; - rx_pool.bufPool[0].heapHandle = session->out_pool; - rx_pool.bufPool[0].bufSize = - Pktlib_getMaxBufferSize(session->out_pool); - rx_pool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE; - - nwal_ret = nwal_SetupFlow(odp_global->nwal.handle, - &rx_pool, - 0, /* buffer header travels via SA, so no offset */ - odp_local.nwal.cfg.rxPktTailRoomSz, - &out_flow, - nwal_FALSE); - - if (nwal_ret != nwal_OK) { - *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM; - return -1; - } - - session->out_flow_id = Cppi_getFlowId(out_flow); - - memset(&sa_params, 0, sizeof(nwalCreateDmSAParams_t)); - sa_params.dmSaParam.dmChnType = - (params->op == ODP_CRYPTO_OP_DECODE) ? - NWAL_DM_CHAN_DECRYPT : - NWAL_DM_CHAN_ENCRYPT; - sa_params.dmSaParam.replayWindow = 64; /** @todo: always 64? */ - sa_params.dmSaParam.authMode = params->auth_alg; - sa_params.dmSaParam.cipherMode = params->cipher_alg; - - sa_params.dmSaParam.enc1st = (params->op == ODP_CRYPTO_OP_ENCODE) ? - params->auth_cipher_text : !params->auth_cipher_text; - - if ((sa_params.dmSaParam.cipherMode == NWAL_SA_EALG_AES_GCM) || - (sa_params.dmSaParam.cipherMode == NWAL_SA_EALG_AES_CCM) || - (sa_params.dmSaParam.authMode == NWAL_SA_AALG_GMAC)) { - sa_params.dmSaParam.macSize = 16; - sa_params.dmSaParam.aadSize = 8; - /* Enc1st needs to always be true for combined algorithms */ - sa_params.dmSaParam.enc1st = nwal_TRUE; - } else if (sa_params.dmSaParam.authMode != NWAL_SA_AALG_NULL) { - sa_params.dmSaParam.macSize = 12; - sa_params.dmSaParam.aadSize = 0; - } else { - sa_params.dmSaParam.enc1st = nwal_TRUE; - sa_params.dmSaParam.macSize = 0; - } - - sa_params.keyParam.pEncKey = params->cipher_key.data; - sa_params.keyParam.encKeySize = params->cipher_key.length; - sa_params.keyParam.pAuthKey = params->auth_key.data; - sa_params.keyParam.macKeySize = params->auth_key.length; - - session->auth.tag_len = sa_params.dmSaParam.macSize; - - ODP_ASSERT(session->auth.tag_len <= - ODP_FIELD_SIZEOF(struct odp_pkthdr, crypto.dec.hash_tag), - "Auth tag length is bigger than hash_tag array"); - - _print_nwalCreateDmSAParams(&sa_params); - odp_pr_dbg("Session addr: %p\n", session); - nwal_ret = nwal_setDMSecAssoc(odp_global->nwal.handle, - (nwal_AppId) session, - &sa_params, - &session->dm_handle); - if (nwal_ret != nwal_OK) { - odp_pr_err("nwal_setDMSecAssoc() returned Error Code %d\n", - nwal_ret); - *status = ODP_CRYPTO_SES_CREATE_ERR_ENOMEM; - return -1; - } - - nwal_ret = nwal_initDMPSCmdInfo(odp_global->nwal.handle, - session->dm_handle, - &session->dm_ps_cmdinfo); - - *status = ODP_CRYPTO_SES_CREATE_ERR_NONE; - *session_out = session; - - return 0; -} - -int odp_crypto_session_destroy(odp_crypto_session_t ses) -{ - struct odp_crypto_session_s *session = ses; - nwal_RetValue nwal_ret; - nwal_ret = nwal_delDMSecAssoc(odp_global->nwal.handle, - session->dm_handle); - return (nwal_ret == nwal_OK) ? 0 : -1; -} - -#define ODP_CRYPTO_BUFFER_PROCESSED_OFFSET (-1) - -static inline void hash_copy_be32(uint8_t *dest, const uint32be_t *sa, size_t n) -{ - union hash_u { - uint32_t hash32; - uint8_t hash[4]; - } hash; - - n /= 4; - while (n--) { - unsigned int i; - hash.hash32 = odp_be_to_cpu_32(*sa++); - for (i = 0; i < sizeof(hash.hash); i++) - *dest++ = hash.hash[i]; - }; -} - -static inline int hash_compare_be32(const uint32_t *orig, const uint32be_t *sa, - size_t n) -{ - n /= 4; - while (n--) { - if (*orig++ != odp_be_to_cpu_32(*sa++)) - return 1; - }; - return 0; -} - -/** - * Set bufPtr to origBuffPtr to pass buffer header via SA - * - * @return offset value - */ -static inline int16_t odp_crypto_buffer_preprocess(odp_buffer_t buf) -{ - struct odp_pkthdr *hdr; - int16_t offset; - Cppi_HostDesc *desc; - uint32_t packet_length; - - desc = _odp_buf_to_cppi_desc(buf); - hdr = odp_packet_hdr(odp_packet_from_buffer(buf)); - offset = desc->buffPtr - desc->origBuffPtr; - hdr->crypto.saved_buf_offset = offset; - odp_pr_dbg("buffPtr: 0x%08x, buffLen: 0x%x, offset: %x\n", - desc->buffPtr, desc->buffLen, offset); - desc->buffPtr -= offset; - desc->buffLen += offset; - packet_length = odp_packet_get_len(odp_packet_from_buffer(buf)); - odp_packet_set_len(odp_packet_from_buffer(buf), - packet_length + offset); - odp_pr_vdbg_packet(odp_packet_from_buffer(buf)); - return offset; -} - -/** - * Restore bufPtr after SA operation - * - * @return offset value - */ -static inline void odp_crypto_buffer_postprocess(odp_buffer_t buf, - enum crypto_alg_err *alg_err) -{ - Cppi_HostDesc *desc; - int16_t offset; - uint8_t *auth_tag = NULL; - uint32_t auth_tag_len = 0; - struct odp_pkthdr *hdr; - struct odp_crypto_session_s *session; - Ti_Pkt *pkt; - uint32_t packet_length; - nwal_Bool_t result; - enum crypto_alg_err auth_err = ODP_CRYPTO_ALG_ERR_NONE; - - odp_pr_vdbg_packet(odp_packet_from_buffer(buf)); - hdr = odp_packet_hdr(odp_packet_from_buffer(buf)); - offset = hdr->crypto.saved_buf_offset; - if (offset == ODP_CRYPTO_BUFFER_PROCESSED_OFFSET) { - /* Buffer already post-processed */ - return; - } - ODP_ASSERT(offset >= 0, "Wrong saved buffer offset\n"); - - hdr->crypto.saved_buf_offset = ODP_CRYPTO_BUFFER_PROCESSED_OFFSET; - pkt = _odp_buf_to_ti_pkt(buf); - desc = _odp_buf_to_cppi_desc(buf); - - odp_pr_dbg("buffPtr: 0x%08x, buffLen: 0x%x, offset: %x\n", - desc->buffPtr, desc->buffLen, offset); - desc->buffPtr += offset; - desc->buffLen -= offset; - packet_length = odp_packet_get_len(odp_packet_from_buffer(buf)); - odp_packet_set_len(odp_packet_from_buffer(buf), - packet_length - offset); - - result = nwal_mGetAppidFmPkt(pkt, (nwal_AppId *)&session); - ODP_ASSERT(result == nwal_TRUE, "Can't get crypto session context\n"); - odp_pr_dbg("Session addr: %p\n", session); - - nwal_mmGetDmAuthTag(pkt, &auth_tag, &auth_tag_len); - - ODP_ASSERT(session->auth.tag_len <= auth_tag_len, - "Auth tag length from SA is bigger than ICV length"); - ODP_ASSERT(!((uintptr_t)auth_tag & 0x3), - "Auth tag is not 4 bytes aligned"); - - if (session->op == ODP_CRYPTO_OP_ENCODE) { - /* Copy hash to packet */ - uint8_t *data = odp_buffer_addr(buf); - data += hdr->crypto.hash_offset; - hash_copy_be32(data, (uint32be_t *)(void *)auth_tag, - session->auth.tag_len); - } else if (hash_compare_be32(hdr->crypto.dec.hash_tag, - (uint32be_t *)(void *)auth_tag, - session->auth.tag_len)) { - odp_pr_dbg("ICV is wrong\n"); - odp_pr_dbg_mem(hdr->crypto.dec.hash_tag, session->auth.tag_len, - "Saved auth tag"); - odp_pr_dbg_mem(auth_tag, session->auth.tag_len, - "Decoded auth tag"); - auth_err = ODP_CRYPTO_ALG_ERR_ICV_CHECK; - } - - if (alg_err) - *alg_err = auth_err; - return; -} - -int odp_crypto_operation(odp_crypto_op_params_t *params, - bool *posted, - odp_buffer_t completion_event ODP_UNUSED) -{ - nwalTxDmPSCmdInfo_t *dm_cmd_info; - Cppi_HostDesc *desc; - struct odp_crypto_session_s *session; - odp_buffer_t buf = odp_buffer_from_packet(params->pkt); - struct odp_pkthdr *hdr = odp_packet_hdr(params->pkt); - uint32_t offset; - uint8_t *data; - - session = (struct odp_crypto_session_s *)(intptr_t)params->session; - - /* Out packet is allocated from out poll and can't be specified */ - if (params->out_pkt != ODP_PACKET_INVALID) - return -1; - - dm_cmd_info = &session->dm_ps_cmdinfo; - dm_cmd_info->rxSbSaQ = _odp_queue_to_qmss_queue(session->compl_queue); - dm_cmd_info->rxPktFlowId = session->out_flow_id; - - /* Save hash tag for decode operation and fill hash result with 0's*/ - data = odp_packet_buf_addr(params->pkt); - data += params->hash_result_offset; - hdr->crypto.hash_offset = params->hash_result_offset; - if (session->op == ODP_CRYPTO_OP_DECODE) - memcpy(hdr->crypto.dec.hash_tag, data, session->auth.tag_len); - memset(data, 0, session->auth.tag_len); - - offset = odp_crypto_buffer_preprocess(buf); - - nwal_mCmdDMUpdate(_odp_buf_to_ti_pkt(buf), - dm_cmd_info, - nwal_HANDLE_INVALID, - params->cipher_range.offset + offset, - params->cipher_range.length, - (params->override_iv_ptr) ? - params->override_iv_ptr : - session->cipher.iv.data, - params->auth_range.offset + offset, - params->auth_range.length, - NULL, - 0, /** @todo: Should be aadSize from session? */ - NULL); - - desc = _odp_buf_to_cppi_desc(buf); - desc = Osal_qmssConvertDescVirtToPhy(0, desc); - - Qmss_queuePushDescSizeRaw(dm_cmd_info->txQueue, - desc, - NWAL_DESC_SIZE); - - *posted = 1; - return 0; -} - - -int odp_crypto_init_global(void) -{ - size_t mem_size; - odp_shm_t shm; - - /* Calculate the memory size we need */ - mem_size = sizeof(*global); - mem_size += (MAX_SESSIONS * sizeof(struct odp_crypto_session_s)); - - /* Allocate our globally shared memory */ - shm = odp_shm_reserve("crypto_pool", mem_size, ODP_CACHE_LINE_SIZE, 0); - global = odp_shm_addr(shm); - - /* Clear it out */ - memset(global, 0, mem_size); - - /* Initialize it */ - global->max = MAX_SESSIONS; - - return 0; -} - -int odp_hw_random_get(uint8_t *buf, uint32_t *len, bool use_entropy ODP_UNUSED) -{ - Sa_RngData_t random; - uint8_t *random_buf; - uint32_t length = *len; - uint32_t i; - nwal_RetValue ret; - - ret = nwal_getSARandomNum(odp_global->nwal.handle, &random); - if (ret != nwal_OK) { - *len = 0; - return -1; - } - random_buf = (uint8_t *)&random; - if (length > sizeof(Sa_RngData_t)) - length = sizeof(Sa_RngData_t); - - for (i = 0; i < length; i++) - *buf++ = *random_buf++; - *len = length; - - return 0; -} -void -odp_crypto_get_operation_compl_status(odp_buffer_t completion_event, - struct odp_crypto_compl_status *auth, - struct odp_crypto_compl_status *cipher) -{ - auth->hw_err = ODP_CRYPTO_HW_ERR_NONE; - auth->alg_err = ODP_CRYPTO_ALG_ERR_NONE; - cipher->hw_err = ODP_CRYPTO_HW_ERR_NONE; - cipher->alg_err = ODP_CRYPTO_ALG_ERR_NONE; - - odp_crypto_buffer_postprocess(completion_event, &auth->alg_err); - - return; -} - -odp_packet_t -odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event) -{ - odp_crypto_buffer_postprocess(completion_event, NULL); - return odp_packet_from_buffer(completion_event); -} - - -void *odp_crypto_get_operation_compl_ctx(odp_buffer_t completion ODP_UNUSED) -{ - /* Not supported */ - return NULL; -} - -void odp_crypto_get_ses_create_compl_status(odp_buffer_t completion_event, - enum odp_crypto_ses_create_err *status) -{ - struct odp_session_result_s *result; - - result = odp_buffer_addr(completion_event); - *status = result->rc; -} - -void odp_crypto_get_ses_create_compl_session(odp_buffer_t completion_event, - odp_crypto_session_t *session) -{ - struct odp_session_result_s *result; - - result = odp_buffer_addr(completion_event); - *session = result->session; -} diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c deleted file mode 100644 index 80c178f..0000000 --- a/platform/linux-keystone2/odp_init.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include - -struct odp_global_s *odp_global; -struct odp_proc_s odp_proc; -__thread struct odp_local_s odp_local; - -int odp_init_global(void) -{ - odp_thread_init_global(); - - odp_system_info_init(); - - if (mcsdk_global_init()) { - odp_pr_err("ODP McSDK init failed.\n"); - return -1; - } - - if (odp_shm_init_global()) { - odp_pr_err("ODP shm init failed.\n"); - return -1; - } - - if (odp_buffer_pool_init_global()) { - odp_pr_err("ODP buffer pool init failed.\n"); - return -1; - } - - if (odp_queue_init_global()) { - odp_pr_err("ODP queue init failed.\n"); - return -1; - } - - if (odp_schedule_init_global()) { - odp_pr_err("ODP schedule init failed.\n"); - return -1; - } - - if (odp_pktio_init_global()) { - odp_pr_err("ODP packet io init failed.\n"); - return -1; - } - - if (odp_crypto_init_global()) { - odp_pr_err("ODP crypto init failed.\n"); - return -1; - } - - if (odp_timer_init_global()) { - odp_pr_err("ODP timer init failed.\n"); - return -1; - } - - return 0; -} - - -int odp_init_local(int thr_id) -{ - int ret = 0; - odp_thread_init_local(thr_id); - - ret = mcsdk_local_init(thr_id); - if (ret < 0) { - odp_pr_err("Failed to local init McSDK\n"); - return -1; - } else if (ret > 0) { - odp_pr_dbg("Skipping local init McSDK\n"); - return 0; - } - - if (odp_schedule_init_local()) { - odp_pr_err("ODP schedule local init failed.\n"); - return -1; - } - return 0; -} diff --git a/platform/linux-keystone2/odp_packet.c b/platform/linux-keystone2/odp_packet.c deleted file mode 100644 index a0cd48e..0000000 --- a/platform/linux-keystone2/odp_packet.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#define ODP_PACKET_HDR_OFFSET_INVALID ((uint16_t)-1) - -static inline uint8_t parse_ipv4(struct odp_pkthdr *pkt_hdr, - odph_ipv4hdr_t *ipv4, - size_t *offset_out); -static inline uint8_t parse_ipv6(struct odp_pkthdr *pkt_hdr, - odph_ipv6hdr_t *ipv6, - size_t *offset_out); - -void odp_packet_init(odp_packet_t pkt) -{ - struct odp_pkthdr *const pkt_hdr = odp_packet_hdr(pkt); - - pkt_hdr->l2_offset = ODP_PACKET_HDR_OFFSET_INVALID; - pkt_hdr->l3_offset = ODP_PACKET_HDR_OFFSET_INVALID; - pkt_hdr->l4_offset = ODP_PACKET_HDR_OFFSET_INVALID; -} - -void odp_packet_set_len(odp_packet_t pkt, size_t len) -{ - odp_buffer_t buf = odp_buffer_from_packet(pkt); - Pktlib_setPacketLen(_odp_buf_to_ti_pkt(buf), len); - /** - * @todo: Buffer length should be modified by buffer API when it - * become available - */ - _odp_buf_to_cppi_desc(buf)->buffLen = len; -} - -size_t odp_packet_get_len(odp_packet_t pkt) -{ - odp_buffer_t buf = odp_buffer_from_packet(pkt); - return Pktlib_getPacketLen(_odp_buf_to_ti_pkt(buf)); -} - -uint8_t *odp_packet_buf_addr(odp_packet_t pkt) -{ - return odp_buffer_addr(odp_buffer_from_packet(pkt)); -} - -uint8_t *odp_packet_start(odp_packet_t pkt) -{ - return odp_packet_buf_addr(pkt) + odp_packet_hdr(pkt)->frame_offset; -} - - -uint8_t *odp_packet_l2(odp_packet_t pkt) -{ - const size_t offset = odp_packet_l2_offset(pkt); - - if (odp_unlikely(offset == ODP_PACKET_HDR_OFFSET_INVALID)) - return NULL; - - return odp_packet_buf_addr(pkt) + offset; -} - -size_t odp_packet_l2_offset(odp_packet_t pkt) -{ - return odp_packet_hdr(pkt)->l2_offset; -} - -void odp_packet_set_l2_offset(odp_packet_t pkt, size_t offset) -{ - odp_packet_hdr(pkt)->l2_offset = offset; -} - -uint8_t *odp_packet_l3(odp_packet_t pkt) -{ - const size_t offset = odp_packet_l3_offset(pkt); - - if (odp_unlikely(offset == ODP_PACKET_HDR_OFFSET_INVALID)) - return NULL; - - return odp_packet_buf_addr(pkt) + offset; -} - -size_t odp_packet_l3_offset(odp_packet_t pkt) -{ - return odp_packet_hdr(pkt)->l3_offset; -} - -void odp_packet_set_l3_offset(odp_packet_t pkt, size_t offset) -{ - odp_packet_hdr(pkt)->l3_offset = offset; -} - -uint8_t *odp_packet_l4(odp_packet_t pkt) -{ - const size_t offset = odp_packet_l4_offset(pkt); - - if (odp_unlikely(offset == ODP_PACKET_HDR_OFFSET_INVALID)) - return NULL; - - return odp_packet_buf_addr(pkt) + offset; -} - -size_t odp_packet_l4_offset(odp_packet_t pkt) -{ - return odp_packet_hdr(pkt)->l4_offset; -} - -void odp_packet_set_l4_offset(odp_packet_t pkt, size_t offset) -{ - odp_packet_hdr(pkt)->l4_offset = offset; -} - -/** - * Simple packet parser: eth, VLAN, IP, TCP/UDP/ICMP - * - * Internal function: caller is responsible for passing only - * valid packet handles, lengths and offsets - * (usually done&called in packet input). - * - * @param pkt Packet handle - * @param len Packet length in bytes - * @param frame_offset Byte offset to L2 header - */ -void odp_packet_parse(odp_packet_t pkt, size_t len, size_t frame_offset) -{ - struct odp_pkthdr *const pkt_hdr = odp_packet_hdr(pkt); - odph_ethhdr_t *eth; - odph_vlanhdr_t *vlan; - odph_ipv4hdr_t *ipv4; - odph_ipv6hdr_t *ipv6; - uint16_t ethtype; - size_t offset = 0; - uint8_t ip_proto = 0; - - pkt_hdr->input_flags.eth = 1; - pkt_hdr->frame_offset = frame_offset; - - if (odp_unlikely(len < ODPH_ETH_LEN_MIN)) { - pkt_hdr->error_flags.frame_len = 1; - return; - } else if (len > ODPH_ETH_LEN_MAX) { - pkt_hdr->input_flags.jumbo = 1; - } - - len -= 4; /* Crop L2 CRC */ - odp_packet_set_len(pkt, len); - - /* Assume valid L2 header, no CRC/FCS check in SW */ - pkt_hdr->input_flags.l2 = 1; - pkt_hdr->l2_offset = frame_offset; - - eth = (odph_ethhdr_t *)odp_packet_start(pkt); - ethtype = odp_be_to_cpu_16(eth->type); - vlan = (odph_vlanhdr_t *)ð->type; - - if (ethtype == ODPH_ETHTYPE_VLAN_OUTER) { - pkt_hdr->input_flags.vlan_qinq = 1; - ethtype = odp_be_to_cpu_16(vlan->tpid); - offset += sizeof(odph_vlanhdr_t); - vlan = &vlan[1]; - } - - if (ethtype == ODPH_ETHTYPE_VLAN) { - pkt_hdr->input_flags.vlan = 1; - ethtype = odp_be_to_cpu_16(vlan->tpid); - offset += sizeof(odph_vlanhdr_t); - } - - /* Set l3_offset+flag only for known ethtypes */ - switch (ethtype) { - case ODPH_ETHTYPE_IPV4: - pkt_hdr->input_flags.ipv4 = 1; - pkt_hdr->input_flags.l3 = 1; - pkt_hdr->l3_offset = frame_offset + ODPH_ETHHDR_LEN + offset; - ipv4 = (odph_ipv4hdr_t *)odp_packet_l3(pkt); - ip_proto = parse_ipv4(pkt_hdr, ipv4, &offset); - break; - case ODPH_ETHTYPE_IPV6: - pkt_hdr->input_flags.ipv6 = 1; - pkt_hdr->input_flags.l3 = 1; - pkt_hdr->l3_offset = frame_offset + ODPH_ETHHDR_LEN + offset; - ipv6 = (odph_ipv6hdr_t *)odp_packet_l3(pkt); - ip_proto = parse_ipv6(pkt_hdr, ipv6, &offset); - break; - case ODPH_ETHTYPE_ARP: - pkt_hdr->input_flags.arp = 1; - /* fall through */ - default: - ip_proto = 0; - break; - } - - switch (ip_proto) { - case ODPH_IPPROTO_UDP: - pkt_hdr->input_flags.udp = 1; - pkt_hdr->input_flags.l4 = 1; - pkt_hdr->l4_offset = pkt_hdr->l3_offset + offset; - break; - case ODPH_IPPROTO_TCP: - pkt_hdr->input_flags.tcp = 1; - pkt_hdr->input_flags.l4 = 1; - pkt_hdr->l4_offset = pkt_hdr->l3_offset + offset; - break; - case ODPH_IPPROTO_SCTP: - pkt_hdr->input_flags.sctp = 1; - pkt_hdr->input_flags.l4 = 1; - pkt_hdr->l4_offset = pkt_hdr->l3_offset + offset; - break; - case ODPH_IPPROTO_ICMP: - pkt_hdr->input_flags.icmp = 1; - pkt_hdr->input_flags.l4 = 1; - pkt_hdr->l4_offset = pkt_hdr->l3_offset + offset; - break; - default: - /* 0 or unhandled IP protocols, don't set L4 flag+offset */ - if (pkt_hdr->input_flags.ipv6) { - /* IPv6 next_hdr is not L4, mark as IP-option instead */ - pkt_hdr->input_flags.ipopt = 1; - } - break; - } -} - -static inline uint8_t parse_ipv4(struct odp_pkthdr *pkt_hdr, - odph_ipv4hdr_t *ipv4, - size_t *offset_out) -{ - uint8_t ihl; - uint16_t frag_offset; - - ihl = ODPH_IPV4HDR_IHL(ipv4->ver_ihl); - if (odp_unlikely(ihl < ODPH_IPV4HDR_IHL_MIN)) { - pkt_hdr->error_flags.ip_err = 1; - return 0; - } - - if (odp_unlikely(ihl > ODPH_IPV4HDR_IHL_MIN)) { - pkt_hdr->input_flags.ipopt = 1; - return 0; - } - - /* A packet is a fragment if: - * "more fragments" flag is set (all fragments except the last) - * OR - * "fragment offset" field is nonzero (all fragments except the first) - */ - frag_offset = odp_be_to_cpu_16(ipv4->frag_offset); - if (odp_unlikely(ODPH_IPV4HDR_IS_FRAGMENT(frag_offset))) { - pkt_hdr->input_flags.ipfrag = 1; - return 0; - } - - if (ipv4->proto == ODPH_IPPROTO_ESP || - ipv4->proto == ODPH_IPPROTO_AH) { - pkt_hdr->input_flags.ipsec = 1; - return 0; - } - - /* Set pkt_hdr->input_flags.ipopt when checking L4 hdrs after return */ - - *offset_out = sizeof(uint32_t) * ihl; - return ipv4->proto; -} - -static inline uint8_t parse_ipv6(struct odp_pkthdr *pkt_hdr, - odph_ipv6hdr_t *ipv6, - size_t *offset_out) -{ - if (ipv6->next_hdr == ODPH_IPPROTO_ESP || - ipv6->next_hdr == ODPH_IPPROTO_AH) { - pkt_hdr->input_flags.ipopt = 1; - pkt_hdr->input_flags.ipsec = 1; - return 0; - } - - if (odp_unlikely(ipv6->next_hdr == ODPH_IPPROTO_FRAG)) { - pkt_hdr->input_flags.ipopt = 1; - pkt_hdr->input_flags.ipfrag = 1; - return 0; - } - - /* Don't step through more extensions */ - *offset_out = ODPH_IPV6HDR_LEN; - return ipv6->next_hdr; -} - -void odp_packet_print(odp_packet_t pkt) -{ - int max_len = 512; - char str[max_len]; - int len = 0; - int n = max_len-1; - Cppi_HostDesc *desc; - struct odp_pkthdr *hdr = odp_packet_hdr(pkt); - odp_buffer_t buf = odp_buffer_from_packet(pkt); - - len += snprintf(&str[len], n-len, "Packet "); - len += odp_buffer_snprint(&str[len], n-len, (odp_buffer_t) pkt); - len += snprintf(&str[len], n-len, - " input_flags 0x%x\n", hdr->input_flags.all); - len += snprintf(&str[len], n-len, - " error_flags 0x%x\n", hdr->error_flags.all); - len += snprintf(&str[len], n-len, - " output_flags 0x%x\n", hdr->output_flags.all); - len += snprintf(&str[len], n-len, - " frame_offset %u\n", hdr->frame_offset); - len += snprintf(&str[len], n-len, - " l2_offset %u\n", hdr->l2_offset); - len += snprintf(&str[len], n-len, - " l3_offset %u\n", hdr->l3_offset); - len += snprintf(&str[len], n-len, - " l4_offset %u\n", hdr->l4_offset); - len += snprintf(&str[len], n-len, - " packet len %u\n", odp_packet_get_len(pkt)); - len += snprintf(&str[len], n-len, - " input %u\n", hdr->input); - str[len] = '\0'; - - printf("\n%s\n", str); - desc = _odp_buf_to_cppi_desc(buf); - odp_print_mem(desc, sizeof(*desc), "Descriptor dump"); - odp_print_mem((void *)desc->origBuffPtr, - desc->buffPtr - desc->origBuffPtr + 128, - "Buffer start"); -} - -int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src) -{ - (void) pkt_dst; - (void) pkt_src; - return -1; -} diff --git a/platform/linux-keystone2/odp_packet_io.c b/platform/linux-keystone2/odp_packet_io.c deleted file mode 100644 index 63a09ce..0000000 --- a/platform/linux-keystone2/odp_packet_io.c +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef ODP_HAVE_NETMAP -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include -#ifdef ODP_HAVE_NETMAP -#include -#endif - -#include - -#define DUMMY_PKTIO - -typedef struct { - pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; -} pktio_table_t; - -static pktio_table_t *pktio_tbl; - -#define MAX_PORT_INDEX 4 -static int port_index(const char *interface) -{ - int ret, port; - - ret = sscanf(interface, "eth%d", &port); - if (1 != ret) - return -1; - port++; - if (port > MAX_PORT_INDEX) - return -1; - return port; -} - -static pktio_entry_t *get_entry(odp_pktio_t id) -{ - if (odp_unlikely(id == ODP_PKTIO_INVALID || - id > ODP_CONFIG_PKTIO_ENTRIES)) - return NULL; - - return &pktio_tbl->entries[id]; -} - -int odp_pktio_init_global(void) -{ - pktio_entry_t *pktio_entry; - int id; - odp_shm_t shm; - - shm = odp_shm_reserve("odp_pktio_entries", - sizeof(pktio_table_t), - sizeof(pktio_entry_t), 0); - - pktio_tbl = odp_shm_addr(shm); - - if (pktio_tbl == NULL) - return -1; - - memset(pktio_tbl, 0, sizeof(pktio_table_t)); - - for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) { - pktio_entry = get_entry(id); - - odp_spinlock_init(&pktio_entry->s.lock); - } - return 0; -} - -static int is_free(pktio_entry_t *entry) -{ - return (entry->s.taken == 0); -} - -static void set_free(pktio_entry_t *entry) -{ - entry->s.taken = 0; -} - -static void set_taken(pktio_entry_t *entry) -{ - entry->s.taken = 1; -} - -static void lock_entry(pktio_entry_t *entry) -{ - odp_spinlock_lock(&entry->s.lock); -} - -static void unlock_entry(pktio_entry_t *entry) -{ - odp_spinlock_unlock(&entry->s.lock); -} - -static int free_pktio_entry(odp_pktio_t id) -{ - pktio_entry_t *entry = get_entry(id); - - if (entry == NULL) - return -1; - - set_free(entry); - - return 0; -} - -static nwalTxPktInfo_t tx_pkt_info = { - .pPkt = NULL, - .txFlag1 = NWAL_TX_FLAG1_META_DATA_VALID, - .lpbackPass = 0, - .enetPort = 0, - .mtuSize = 0, - .startOffset = 0, - .saOffBytes = 0, - .saPayloadLen = 0, - .saAhIcvOffBytes = 0, - .saAhMacSize = 0, - .etherLenOffBytes = 0, - .ipOffBytes = 0, - .l4OffBytes = 0, - .l4HdrLen = 0, - .pseudoHdrChecksum = 0, - .ploadLen = 0, -}; - -odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, - odp_pktio_params_t *params ODP_UNUSED) -{ - odp_pktio_t id; - pktio_entry_t *pktio_entry; - char name[ODP_QUEUE_NAME_LEN]; - queue_entry_t *queue_entry; - odp_queue_t qid = ODP_QUEUE_INVALID; - nwal_RetValue ret_nwal; - int port; - - odp_pr_dbg("Allocating HW pktio\n"); - - /* Create a default output queue for each pktio resource */ - port = port_index(dev); - if (port < 0) { - odp_pr_err("Wrong pktio name: %s\n", dev); - return ODP_PKTIO_INVALID; - } - - /** - * Until classification API is in place there is no criteria to - * differentiate pktio except a port number. So map port directly - * to pktio entry. - */ - id = port; - - pktio_entry = get_entry(id); - lock_entry(pktio_entry); - if (!is_free(pktio_entry)) { - /* Entry already initialized */ - odp_pr_dbg("PktIO %d is already initialized\n", id); - goto unlock; - } - - set_taken(pktio_entry); - pktio_entry->s.inq_default = ODP_QUEUE_INVALID; - pktio_entry->s.outq_default = ODP_QUEUE_INVALID; - pktio_entry->s.port = port; - - snprintf(name, sizeof(name), "%i-pktio_outq_default", (int)id); - name[ODP_QUEUE_NAME_LEN-1] = '\0'; - - qid = odp_queue_create(name, ODP_QUEUE_TYPE_PKTOUT, NULL); - odp_pr_dbg("Created queue %u\n", (uint32_t)qid); - if (qid == ODP_QUEUE_INVALID) { - free_pktio_entry(id); - id = ODP_PKTIO_INVALID; - odp_pr_err("Couldn't create queue: %s\n", name); - goto unlock; - } - - ret_nwal = nwal_initPSCmdInfo(odp_global->nwal.handle, - &tx_pkt_info, - &pktio_entry->s.tx_ps_cmdinfo); - - if (ret_nwal != nwal_OK) { - odp_pr_err("Couldn't create PSCmdInfo\n"); - goto unlock; - } - - pktio_entry->s.in_pool = pool; - pktio_entry->s.outq_default = qid; - pktio_entry->s.id = id; - - queue_entry = queue_to_qentry(qid); - queue_entry->s.pktout_entry = pktio_entry; -unlock: - unlock_entry(pktio_entry); - return id; -} - -int odp_pktio_close(odp_pktio_t id) -{ - pktio_entry_t *entry; - - entry = get_entry(id); - if (entry == NULL) - return -1; - - /* Only one entry per port exists, so no need to delete it */ - - return 0; -} - -void odp_pktio_set_input(odp_packet_t pkt, odp_pktio_t pktio) -{ - odp_packet_hdr(pkt)->input = pktio; -} - -odp_pktio_t odp_pktio_get_input(odp_packet_t pkt) -{ - return odp_packet_hdr(pkt)->input; -} - -static int pktio_inq_setdef_locked(odp_pktio_t id, odp_queue_t queue) -{ - nwal_RetValue nwal_ret; - nwal_Handle handle; - pktio_entry_t *pktio_entry = get_entry(id); - queue_entry_t *queue_entry = queue_to_qentry(queue); - nwalMacParam_t mac_info = { - .validParams = NWAL_SET_MAC_VALID_PARAM_IFNUM, - .ifNum = 0, - .vlanId = 0, - .macAddr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - .remMacAddr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - .matchAction = NWAL_MATCH_ACTION_HOST, - .failAction = NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, - .appRxPktFlowId = CPPI_PARAM_NOT_SPECIFIED, - .appRxPktQueue = QMSS_PARAM_NOT_SPECIFIED, - .routeType = 0, - }; - - ODP_ASSERT(pktio_entry && queue_entry, "Not valid entries"); - ODP_ASSERT(queue_entry->s.type == ODP_QUEUE_TYPE_PKTIN, - "Not PKTIN queue"); - - pktio_entry->s.inq_default = queue; - odp_sync_stores(); - mac_info.appRxPktQueue = _odp_queue_to_qmss_queue(queue); - /** @todo: Specify flow corresponding to the pool */ - mac_info.appRxPktFlowId = QMSS_PARAM_NOT_SPECIFIED; - mac_info.ifNum = pktio_entry->s.port; - - nwal_ret = nwal_setMacIface(odp_global->nwal.handle, - NWAL_TRANSID_SPIN_WAIT, - (nwal_AppId) (0x12345678), - &mac_info, - &handle); - if (nwal_ret != nwal_OK) { - odp_pr_err("nwal_setMacIface returned Error Code %d\n", - nwal_ret); - return -1; - } - - odp_pr_info("MAC i/f added\n"); - - queue_lock(queue_entry); - queue_entry->s.pktin = id; - queue_entry->s.status = QUEUE_STATUS_SCHED; - queue_unlock(queue_entry); - - odp_schedule_queue(queue, queue_entry->s.param.sched.prio); - - return 0; -} - -static int pktio_inq_create_setdef(odp_pktio_t id) -{ - char name[ODP_QUEUE_NAME_LEN]; - odp_queue_param_t qparam; - odp_queue_t inq_def; - pktio_entry_t *pktio_entry = get_entry(id); - int ret = 0; - - ODP_ASSERT(pktio_entry, "Not valid entry"); - lock_entry(pktio_entry); - if (pktio_entry->s.inq_default != ODP_QUEUE_INVALID) { - ret = 0; - odp_pr_dbg("default input queue is already set: %u\n", - pktio_entry->s.inq_default); - goto unlock; - } - - odp_pr_dbg("Creating default input queue\n"); - qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; - qparam.sched.sync = ODP_SCHED_SYNC_NONE; - qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - snprintf(name, sizeof(name), "%i-pktio_inq_default", (int)id); - name[ODP_QUEUE_NAME_LEN-1] = '\0'; - inq_def = odp_queue_create(name, ODP_QUEUE_TYPE_PKTIN, &qparam); - if (inq_def == ODP_QUEUE_INVALID) { - odp_pr_err("pktio input queue creation failed\n"); - ret = -1; - goto unlock; - } - - if (pktio_inq_setdef_locked(id, inq_def)) { - odp_pr_err("default input-Q setup\n"); - ret = -1; - goto unlock; - } -unlock: - unlock_entry(pktio_entry); - return ret; -} - -int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) -{ - pktio_entry_t *pktio_entry = get_entry(id); - unsigned pkts = 0; - odp_buffer_t buf; - - ODP_ASSERT(pktio_entry, "Not valid entry"); - - if (pktio_entry->s.inq_default == ODP_QUEUE_INVALID) { - /** - * Create a default input queue. - * @todo: It is a kind of WA for current ODP API usage. - * It should be revised. - */ - if (pktio_inq_create_setdef(id)) - return -1; - } - - for (pkts = 0; pkts < len; pkts++) { - buf = odp_queue_deq(pktio_entry->s.inq_default); - if (!odp_buffer_is_valid(buf)) - break; - - pkt_table[pkts] = odp_packet_from_buffer(buf); - } - return pkts; -} - -static inline void pktio_buffer_send(pktio_entry_t *pktio, odp_buffer_t buf) -{ - nwal_mCmdSetPort(_odp_buf_to_ti_pkt(buf), - &(pktio->s.tx_ps_cmdinfo), - pktio->s.port); - - Qmss_queuePushDescSize(pktio->s.tx_ps_cmdinfo.txQueue, - _odp_buf_to_cppi_desc(buf), - NWAL_DESC_SIZE); -} - -int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) -{ - pktio_entry_t *pktio_entry = get_entry(id); - unsigned pkts; - - if (pktio_entry == NULL) - return -1; - - for (pkts = 0; pkts < len; pkts++) { - pktio_buffer_send(pktio_entry, - odp_buffer_from_packet(pkt_table[pkts])); - } - return pkts; -} - -int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue) -{ - pktio_entry_t *pktio_entry = get_entry(id); - int ret = 0; - - ODP_ASSERT(pktio_entry, "Not valid entry"); - - lock_entry(pktio_entry); - if (pktio_entry->s.inq_default == ODP_QUEUE_INVALID) { - ret = pktio_inq_setdef_locked(id, queue); - } else { - /* Default queue can be assigned only once */ - odp_pr_err("pktio %u: default input queue %s is already set\n", - id, - odp_queue_name(pktio_entry->s.inq_default)); - ret = -1; - } - unlock_entry(pktio_entry); - return ret; -} - -int odp_pktio_inq_remdef(odp_pktio_t id) -{ - return odp_pktio_inq_setdef(id, ODP_QUEUE_INVALID); -} - -odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id) -{ - pktio_entry_t *pktio_entry = get_entry(id); - - if (pktio_entry == NULL) - return ODP_QUEUE_INVALID; - - return pktio_entry->s.inq_default; -} - -odp_queue_t odp_pktio_outq_getdef(odp_pktio_t id) -{ - pktio_entry_t *pktio_entry = get_entry(id); - - if (pktio_entry == NULL) - return ODP_QUEUE_INVALID; - - return pktio_entry->s.outq_default; -} - -int pktout_enqueue(queue_entry_t *queue, odp_buffer_t buf) -{ - pktio_entry_t *pktio = queue->s.pktout_entry; - odp_pr_vdbg("sending packet\n"); - odp_pr_vdbg_packet(odp_packet_from_buffer(buf)); - pktio_buffer_send(pktio, buf); - return 0; -} - -int pktout_enq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num) -{ - int i; - pktio_entry_t *pktio = queue->s.pktout_entry; - for (i = 0; i < num; i++) - pktio_buffer_send(pktio, buf[i]); - return 0; -} - -static inline void update_in_packet(odp_buffer_t buf, - odp_pktio_t pktin) -{ - if (!odp_buffer_is_valid(buf)) - return; - - odp_packet_t pkt = odp_packet_from_buffer(buf); - struct odp_pkthdr *pkt_hdr = odp_packet_hdr(pkt); - size_t len = odp_packet_get_len(pkt); - pkt_hdr->input = pktin; - odp_packet_parse(pkt, len, 0); -} - -odp_buffer_t pktin_dequeue(queue_entry_t *queue) -{ - odp_buffer_t buf; - buf = queue_deq(queue); - - update_in_packet(buf, queue->s.pktin); - return buf; -} - -int pktin_deq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num) -{ - int i; - num = queue_deq_multi(queue, buf, num); - - for (i = 0; i < num; i++) - update_in_packet(buf[i], queue->s.pktin); - return num; -} diff --git a/platform/linux-keystone2/odp_queue.c b/platform/linux-keystone2/odp_queue.c deleted file mode 100644 index 59e1e0b..0000000 --- a/platform/linux-keystone2/odp_queue.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright (c) 2014, Linaro Limited - * Copyright (c) 2014, Texas Instruments Incorporated - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef USE_TICKETLOCK -#include -#define LOCK(a) odp_ticketlock_lock(a) -#define UNLOCK(a) odp_ticketlock_unlock(a) -#define LOCK_INIT(a) odp_ticketlock_init(a) -#else -#include -#define LOCK(a) odp_spinlock_lock(a) -#define UNLOCK(a) odp_spinlock_unlock(a) -#define LOCK_INIT(a) odp_spinlock_init(a) -#endif - -#include - - -typedef struct queue_table_t { - queue_entry_t queue[ODP_CONFIG_QUEUES]; -} queue_table_t; - -static queue_table_t *queue_tbl; - - -queue_entry_t *get_qentry(uint32_t queue_id) -{ - return &queue_tbl->queue[queue_id]; -} - -static int queue_init(queue_entry_t *queue, const char *name, - odp_queue_type_t type, odp_queue_param_t *param) -{ - strncpy(queue->s.name, name, ODP_QUEUE_NAME_LEN - 1); - queue->s.type = type; - - if (type != ODP_QUEUE_TYPE_PKTOUT) { - uint8_t allocated = 0; - queue->s.qmss_queue = Qmss_queueOpen( - Qmss_QueueType_GENERAL_PURPOSE_QUEUE, - QMSS_PARAM_NOT_SPECIFIED, - &allocated); - if (allocated) - Qmss_queueEmpty(queue->s.qmss_queue); - odp_pr_vdbg(">>>>>> queue_s: %p, qmss_queue: %d\n", - queue, queue->s.qmss_queue); - if (queue->s.qmss_queue < 0) - return -1; - } - - if (param) { - memcpy(&queue->s.param, param, sizeof(odp_queue_param_t)); - } else { - /* Defaults */ - memset(&queue->s.param, 0, sizeof(odp_queue_param_t)); - queue->s.param.sched.prio = ODP_SCHED_PRIO_DEFAULT; - queue->s.param.sched.sync = ODP_SCHED_SYNC_DEFAULT; - queue->s.param.sched.group = ODP_SCHED_GROUP_DEFAULT; - } - - switch (type) { - case ODP_QUEUE_TYPE_PKTIN: - queue->s.enqueue = NULL; - queue->s.dequeue = pktin_dequeue; - queue->s.enqueue_multi = NULL; - queue->s.dequeue_multi = pktin_deq_multi; - break; - case ODP_QUEUE_TYPE_PKTOUT: - queue->s.enqueue = pktout_enqueue; - queue->s.dequeue = NULL; - queue->s.enqueue_multi = pktout_enq_multi; - queue->s.dequeue_multi = NULL; - break; - default: - queue->s.enqueue = queue_enq; - queue->s.dequeue = queue_deq; - queue->s.enqueue_multi = queue_enq_multi; - queue->s.dequeue_multi = queue_deq_multi; - break; - } - - queue->s.sched_buf = ODP_BUFFER_INVALID; - return 0; -} - - -int odp_queue_init_global(void) -{ - uint32_t i; - odp_shm_t shm; - - odp_pr_dbg("Queue init ... "); - - shm = odp_shm_reserve("odp_queues", - sizeof(queue_table_t), - sizeof(queue_entry_t), 0); - - queue_tbl = odp_shm_addr(shm); - - if (queue_tbl == NULL) - return -1; - - memset(queue_tbl, 0, sizeof(queue_table_t)); - - for (i = 0; i < ODP_CONFIG_QUEUES; i++) { - /* init locks */ - queue_entry_t *queue = get_qentry(i); - LOCK_INIT(&queue->s.lock); - queue->s.handle = queue_from_id(i); - queue->s.status = QUEUE_STATUS_FREE; - } - - odp_pr_dbg("done\n"); - odp_pr_dbg("Queue init global\n"); - odp_pr_dbg(" struct queue_entry_s size %zu\n", - sizeof(struct queue_entry_s)); - odp_pr_dbg(" queue_entry_t size %zu\n", - sizeof(queue_entry_t)); - odp_pr_dbg("\n"); - - return 0; -} - -odp_queue_type_t odp_queue_type(odp_queue_t handle) -{ - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - - return queue->s.type; -} - -odp_schedule_sync_t odp_queue_sched_type(odp_queue_t handle) -{ - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - - return queue->s.param.sched.sync; -} - -odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type, - odp_queue_param_t *param) -{ - uint32_t i; - queue_entry_t *queue; - odp_queue_t handle = ODP_QUEUE_INVALID; - - odp_pr_vdbg(">>>>>> name: %s, type: %d\n", name, type); - - for (i = 0; i < ODP_CONFIG_QUEUES; i++) { - queue = &queue_tbl->queue[i]; - - if (queue->s.status != QUEUE_STATUS_FREE) - continue; - - LOCK(&queue->s.lock); - if (queue->s.status != QUEUE_STATUS_FREE) { - UNLOCK(&queue->s.lock); - continue; - } - - if (queue_init(queue, name, type, param)) { - UNLOCK(&queue->s.lock); - break; - } - - if (type == ODP_QUEUE_TYPE_SCHED || - type == ODP_QUEUE_TYPE_PKTIN) - queue->s.status = QUEUE_STATUS_NOTSCHED; - else - queue->s.status = QUEUE_STATUS_READY; - - handle = queue->s.handle; - odp_pr_vdbg(">>>>>> handle: %u\n", handle); - UNLOCK(&queue->s.lock); - break; - } - - if (handle != ODP_QUEUE_INVALID && - (type == ODP_QUEUE_TYPE_SCHED || type == ODP_QUEUE_TYPE_PKTIN)) { - odp_buffer_t buf; - - buf = odp_schedule_buffer_alloc(handle); - if (buf == ODP_BUFFER_INVALID) { - odp_pr_err("queue_init: sched buf alloc failed\n"); - return ODP_QUEUE_INVALID; - } - - queue->s.sched_buf = buf; - odp_schedule_mask_set(handle, queue->s.param.sched.prio); - } - - return handle; -} - -odp_buffer_t queue_sched_buf(odp_queue_t handle) -{ - queue_entry_t *queue; - queue = queue_to_qentry(handle); - - return queue->s.sched_buf; -} - - -int queue_sched_atomic(odp_queue_t handle) -{ - queue_entry_t *queue; - queue = queue_to_qentry(handle); - - return queue->s.param.sched.sync == ODP_SCHED_SYNC_ATOMIC; -} - - -odp_queue_t odp_queue_lookup(const char *name) -{ - uint32_t i; - - for (i = 0; i < ODP_CONFIG_QUEUES; i++) { - queue_entry_t *queue = &queue_tbl->queue[i]; - - if (queue->s.status == QUEUE_STATUS_FREE) - continue; - - LOCK(&queue->s.lock); - if (strcmp(name, queue->s.name) == 0) { - /* found it */ - UNLOCK(&queue->s.lock); - return queue->s.handle; - } - UNLOCK(&queue->s.lock); - } - - return ODP_QUEUE_INVALID; -} - - -int queue_enq(queue_entry_t *queue, odp_buffer_t buf) -{ - odp_pr_vdbg("queue: %s, buf: %p, qmss_queue: %d\n", - queue->s.name, buf, queue->s.qmss_queue); - Qmss_queuePushDescSize(queue->s.qmss_queue, - _odp_buf_to_cppi_desc(buf), - NWAL_DESC_SIZE); -#if 1 - if (queue->s.type == ODP_QUEUE_TYPE_SCHED) { - int sched = 0; - LOCK(&queue->s.lock); - if (queue->s.status == QUEUE_STATUS_NOTSCHED) { - queue->s.status = QUEUE_STATUS_SCHED; - sched = 1; - } - odp_pr_vdbg("status: %d, sched: %d\n", queue->s.status, sched); - UNLOCK(&queue->s.lock); - /* Add queue to scheduling */ - if (sched) - odp_schedule_queue(queue->s.handle, - queue->s.param.sched.prio); - } -#endif - return 0; -} - - -int queue_enq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num) -{ - int i; - - /** - * @todo: Should this series of buffers be enqueued atomically? - * Can another buffer be pushed in this queue in the middle? - */ - for (i = 0; i < num; i++) { - /** @todo: Implement multi dequeue a lower level */ - odp_pr_vdbg("queue: %s, buf: %p, qmss_queue: %d\n", - queue->s.name, buf[i], queue->s.qmss_queue); - Qmss_queuePushDescSize(queue->s.qmss_queue, - _odp_buf_to_cppi_desc(buf[i]), - NWAL_DESC_SIZE); - } - - if (queue->s.type == ODP_QUEUE_TYPE_SCHED) { - int sched = 0; - LOCK(&queue->s.lock); - if (queue->s.status == QUEUE_STATUS_NOTSCHED) { - queue->s.status = QUEUE_STATUS_SCHED; - sched = 1; - } - odp_pr_vdbg("status: %d, sched: %d\n", queue->s.status, sched); - UNLOCK(&queue->s.lock); - /* Add queue to scheduling */ - if (sched) - odp_schedule_queue(queue->s.handle, - queue->s.param.sched.prio); - } - return 0; -} - - -int odp_queue_enq_multi(odp_queue_t handle, odp_buffer_t buf[], int num) -{ - queue_entry_t *queue; - - if (num > QUEUE_MULTI_MAX) - num = QUEUE_MULTI_MAX; - - queue = queue_to_qentry(handle); - - ODP_ASSERT(queue->s.enqueue_multi, "No multi enqueue function"); - return queue->s.enqueue_multi(queue, buf, num); -} - - -int odp_queue_enq(odp_queue_t handle, odp_buffer_t buf) -{ - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - - odp_pr_vdbg(">>>>>> handle: %u, buf: %p\n", handle, buf); - ODP_ASSERT(queue->s.enqueue, "No enqueue function"); - return queue->s.enqueue(queue, buf); -} - -odp_buffer_t queue_deq(queue_entry_t *queue) -{ - Cppi_HostDesc *desc; - - desc = (void *)QMSS_DESC_PTR(Qmss_queuePop(queue->s.qmss_queue)); - odp_pr_vdbg("queue: %s, buf: %p, qmss_queue: %d\n", - queue->s.name, desc, queue->s.qmss_queue); - - if (!desc && queue->s.type == ODP_QUEUE_TYPE_SCHED) { - LOCK(&queue->s.lock); - if (!desc && queue->s.status == QUEUE_STATUS_SCHED) - queue->s.status = QUEUE_STATUS_NOTSCHED; - odp_pr_vdbg("status: %d\n", queue->s.status); - UNLOCK(&queue->s.lock); - } - - return _cppi_desc_to_odp_buf(desc); -} - - -int queue_deq_multi(queue_entry_t *queue, odp_buffer_t buf[], int num) -{ - int i; - for (i = 0; i < num; i++) { - Cppi_HostDesc *desc; - /** @todo: Implement multi dequeue a lower level */ - desc = Qmss_queuePop(queue->s.qmss_queue); - desc = (void *)QMSS_DESC_PTR(desc); - buf[i] = _cppi_desc_to_odp_buf(desc); - if (!buf[i]) { - if (queue->s.type != ODP_QUEUE_TYPE_SCHED) - break; - LOCK(&queue->s.lock); - if (queue->s.status == QUEUE_STATUS_SCHED) - queue->s.status = QUEUE_STATUS_NOTSCHED; - odp_pr_vdbg("status: %d\n", queue->s.status); - UNLOCK(&queue->s.lock); - break; - } - } - - return i; -} - - -int odp_queue_deq_multi(odp_queue_t handle, odp_buffer_t buf[], int num) -{ - queue_entry_t *queue; - - if (num > QUEUE_MULTI_MAX) - num = QUEUE_MULTI_MAX; - - queue = queue_to_qentry(handle); - - ODP_ASSERT(queue->s.dequeue_multi, "No multi dequeue function"); - return queue->s.dequeue_multi(queue, buf, num); -} - - -odp_buffer_t odp_queue_deq(odp_queue_t handle) -{ - queue_entry_t *queue; - - queue = queue_to_qentry(handle); - ODP_ASSERT(queue->s.dequeue, "No dequeue function"); - return queue->s.dequeue(queue); -} - - -void queue_lock(queue_entry_t *queue) -{ - LOCK(&queue->s.lock); -} - - -void queue_unlock(queue_entry_t *queue) -{ - UNLOCK(&queue->s.lock); -}