From patchwork Tue Nov 11 17:35:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 40603 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7BB05206A5 for ; Tue, 11 Nov 2014 17:36:38 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf420879lbj.0 for ; Tue, 11 Nov 2014 09:36:37 -0800 (PST) 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=Ol3/NbYzvCj/JSxoWfVsLSyXG1J4IxoPo1dghhqc7WA=; b=XMozKIVXa+13oELk5U9tHydNUOxcEyLPaijaw4PHqvGz1aJgVQpZ7QJMjKgq4LFxvI NXXTTkxo7lduqjZFjJWp0YqYKhPg1x2r4wTnjOgZWzhxhTTfX1wIoM94KPGPL8zLcOiK WPTjez3HmHobzA3z92N9f6TIA8rssdY+sdJ+Bnluv0GVInuKSke4iYnilYEm3aTLvKgg /IGwizmKJ4HyRm3jciGSX0Ks8cE+dCZOSmsNsHej8auzkxDbDu+zs5L21Bsf4iNnT0kO Ryd/gTZSoCdPTRHoJjrgmhkYGZXZcBsLic3cQx3nKfzpWlDN5p79z7gyfiS3iil2pa4j l4MA== X-Gm-Message-State: ALoCoQnQy3vYspqmvwi1G7zHIwW1R5nCWd/OZrLFtnSP5wiLFUgRbqMoAdmx50fP4iCk78Cnf28n X-Received: by 10.180.89.7 with SMTP id bk7mr5418433wib.6.1415727397408; Tue, 11 Nov 2014 09:36:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.178.196 with SMTP id da4ls226798lac.1.gmail; Tue, 11 Nov 2014 09:36:37 -0800 (PST) X-Received: by 10.112.142.197 with SMTP id ry5mr9681738lbb.26.1415727397242; Tue, 11 Nov 2014 09:36:37 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id nb4si32282629lbb.35.2014.11.11.09.36.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 09:36:37 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id z11so1219656lbi.25 for ; Tue, 11 Nov 2014 09:36:37 -0800 (PST) X-Received: by 10.152.29.8 with SMTP id f8mr37481807lah.56.1415727397139; Tue, 11 Nov 2014 09:36:37 -0800 (PST) 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.184.201 with SMTP id ew9csp295864lbc; Tue, 11 Nov 2014 09:36:36 -0800 (PST) X-Received: by 10.194.58.8 with SMTP id m8mr56878087wjq.43.1415727396517; Tue, 11 Nov 2014 09:36:36 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id ay3si36284657wjb.145.2014.11.11.09.36.32 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 09:36:36 -0800 (PST) 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 1XoFMj-0004BW-IZ; Tue, 11 Nov 2014 17:36:29 +0000 Received: from mail-lb0-f177.google.com ([209.85.217.177]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XoFMU-0004Af-Nl for lng-odp@lists.linaro.org; Tue, 11 Nov 2014 17:36:14 +0000 Received: by mail-lb0-f177.google.com with SMTP id z12so1231336lbi.22 for ; Tue, 11 Nov 2014 09:36:09 -0800 (PST) X-Received: by 10.112.144.228 with SMTP id sp4mr36731145lbb.58.1415727369056; Tue, 11 Nov 2014 09:36:09 -0800 (PST) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id ql6sm6122819lbb.31.2014.11.11.09.36.08 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 09:36:08 -0800 (PST) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Tue, 11 Nov 2014 19:35:57 +0200 Message-Id: <1415727359-22406-3-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415727359-22406-1-git-send-email-ciprian.barbu@linaro.org> References: <1415727359-22406-1-git-send-email-ciprian.barbu@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH NETMAP 2/4] Use single mmap address for all pktios 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: ciprian.barbu@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.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ciprian Barbu --- platform/linux-netmap/Makefile.am | 2 +- platform/linux-netmap/include/odp_internal.h | 51 +++++++++++++++ platform/linux-netmap/odp_init.c | 96 ++++++++++++++++++++++++++++ platform/linux-netmap/odp_packet_netmap.c | 31 ++++++++- 4 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 platform/linux-netmap/include/odp_internal.h create mode 100644 platform/linux-netmap/odp_init.c diff --git a/platform/linux-netmap/Makefile.am b/platform/linux-netmap/Makefile.am index eae382a..46bb254 100644 --- a/platform/linux-netmap/Makefile.am +++ b/platform/linux-netmap/Makefile.am @@ -65,7 +65,7 @@ __LIB__libodp_la_SOURCES = \ ../linux-generic/odp_classification.c \ ../linux-generic/odp_coremask.c \ ../linux-generic/odp_crypto.c \ - ../linux-generic/odp_init.c \ + odp_init.c \ ../linux-generic/odp_linux.c \ ../linux-generic/odp_packet.c \ ../linux-generic/odp_packet_flags.c \ diff --git a/platform/linux-netmap/include/odp_internal.h b/platform/linux-netmap/include/odp_internal.h new file mode 100644 index 0000000..b2592c6 --- /dev/null +++ b/platform/linux-netmap/include/odp_internal.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2013, Linaro Limited + * 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 + + +int odp_system_info_init(void); + +int odp_thread_init_global(void); +int odp_thread_init_local(void); + +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_pktio_init_local(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 odp_netmap_init_global(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-netmap/odp_init.c b/platform/linux-netmap/odp_init.c new file mode 100644 index 0000000..22c52b4 --- /dev/null +++ b/platform/linux-netmap/odp_init.c @@ -0,0 +1,96 @@ +/* Copyright (c) 2013, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + + +int odp_init_global(odp_init_t *params ODP_UNUSED, + odp_platform_init_t *platform_params ODP_UNUSED) +{ + odp_system_info_init(); + + if (odp_shm_init_global()) { + ODP_ERR("ODP shm init failed.\n"); + return -1; + } + + if (odp_thread_init_global()) { + ODP_ERR("ODP thread init failed.\n"); + return -1; + } + + if (odp_buffer_pool_init_global()) { + ODP_ERR("ODP buffer pool init failed.\n"); + return -1; + } + + if (odp_queue_init_global()) { + ODP_ERR("ODP queue init failed.\n"); + return -1; + } + + if (odp_schedule_init_global()) { + ODP_ERR("ODP schedule init failed.\n"); + return -1; + } + + if (odp_pktio_init_global()) { + ODP_ERR("ODP packet io init failed.\n"); + return -1; + } + + if (odp_timer_init_global()) { + ODP_ERR("ODP timer init failed.\n"); + return -1; + } + + if (odp_crypto_init_global()) { + ODP_ERR("ODP crypto init failed.\n"); + return -1; + } + + if (odp_netmap_init_global()) { + ODP_ERR("ODP netmap global init failed.\n"); + return -1; + } + + return 0; +} + +int odp_term_global(void) +{ + ODP_UNIMPLEMENTED(); + return 0; +} + +int odp_init_local(void) +{ + if (odp_thread_init_local()) { + ODP_ERR("ODP thread local init failed.\n"); + return -1; + } + + if (odp_pktio_init_local()) { + ODP_ERR("ODP packet io local init failed.\n"); + return -1; + } + + if (odp_schedule_init_local()) { + ODP_ERR("ODP schedule local init failed.\n"); + return -1; + } + + return 0; +} + +int odp_term_local(void) +{ + ODP_UNIMPLEMENTED(); + return 0; +} diff --git a/platform/linux-netmap/odp_packet_netmap.c b/platform/linux-netmap/odp_packet_netmap.c index ec4e0ea..29e7862 100644 --- a/platform/linux-netmap/odp_packet_netmap.c +++ b/platform/linux-netmap/odp_packet_netmap.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -54,6 +55,17 @@ #define WAITLINK_TMO 2 #define POLL_TMO 50 +static struct nm_desc mmap_desc; /** Used to store the mmap address; + filled in first time, used for + subsequent calls to nm_open */ +static odp_spinlock_t mmap_desc_lock; + +int odp_netmap_init_global(void) +{ + odp_spinlock_init(&mmap_desc_lock); + return 0; +} + static int nm_do_ioctl(pkt_netmap_t * const pkt_nm, unsigned long cmd, int subcmd) { @@ -134,13 +146,30 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, snprintf(pkt_nm->ifname, sizeof(pkt_nm->ifname), "%s", netdev); snprintf(ifname, sizeof(ifname), "netmap:%s", netdev); - pkt_nm->desc = nm_open(ifname, NULL, 0, 0); + + odp_spinlock_lock(&mmap_desc_lock); + ODP_DBG("[%04d] Initial mmap addr: %p\n", + odp_thread_id(), + mmap_desc.mem); + + if (mmap_desc.mem == NULL) + pkt_nm->desc = nm_open(ifname, NULL, 0, NULL); + else + pkt_nm->desc = nm_open(ifname, NULL, NM_OPEN_NO_MMAP, + &mmap_desc); if (pkt_nm->desc == NULL) { ODP_ERR("Error opening nm interface: %s\n", strerror(errno)); + odp_spinlock_unlock(&mmap_desc_lock); return -1; } + if (mmap_desc.mem == NULL) { + mmap_desc.mem = pkt_nm->desc->mem; + mmap_desc.memsize = pkt_nm->desc->memsize; + } + odp_spinlock_unlock(&mmap_desc_lock); + ODP_DBG("thread %d mmap addr %p\n", odp_thread_id(), pkt_nm->desc->mem);