From patchwork Fri Nov 14 12:48:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 40828 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 82D8C240ED for ; Fri, 14 Nov 2014 12:49:06 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf10687743eek.1 for ; Fri, 14 Nov 2014 04:49:05 -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=ZwwgkAfM0DcAYllTKwCZcJmjNylAP2cvyJRXVKQ5I/k=; b=OnEsNsP9Q3UNOy9rCgXFmFujvN55YNDhhThA7iQjCptNsTGurbYb3NCnZp8gbwnmv4 xhi2kKrFipLLj5LQXvX9qWZLFDIQaYFjskSid3ocKYyCCs5rbJ+XzICl2jg0IPhfgbN9 2o+DhLsc3mFfcjpaBR9OhDCNql4JnMei2qxMZhTDeenw1Qlr195PXEq71TgRlmJkA1Xa mlw+gaxQXK+QDBtt95G/yQ3zhuZyAg78sCfex4vIDE5m4dErWGskfqAxcOhYjGJBpI/Y nqmLKWTlVOr1PNsJZUdu+1aM8axYAVDjx7YIh0Ynqa6VHWIwCJ6JMUSKFrodeKH7c3br 178w== X-Gm-Message-State: ALoCoQmVg+E/EjdlLK7YEAE0B2x7z6EgK96FQQsvoR5UFQmFN0mO0fFMGqfJxSvWm7bdlv3dhk0d X-Received: by 10.180.101.170 with SMTP id fh10mr1057608wib.4.1415969345805; Fri, 14 Nov 2014 04:49:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.72 with SMTP id j8ls710331lag.105.gmail; Fri, 14 Nov 2014 04:49:05 -0800 (PST) X-Received: by 10.152.216.167 with SMTP id or7mr1609898lac.93.1415969345539; Fri, 14 Nov 2014 04:49:05 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id h4si41602984lbd.53.2014.11.14.04.49.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 04:49:05 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so12637695lbv.26 for ; Fri, 14 Nov 2014 04:49:05 -0800 (PST) X-Received: by 10.152.116.102 with SMTP id jv6mr8157772lab.40.1415969345440; Fri, 14 Nov 2014 04:49:05 -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 ew9csp757616lbc; Fri, 14 Nov 2014 04:49:04 -0800 (PST) X-Received: by 10.140.106.195 with SMTP id e61mr4705426qgf.71.1415969344136; Fri, 14 Nov 2014 04:49:04 -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 t2si50910291qcj.8.2014.11.14.04.49.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 14 Nov 2014 04:49:04 -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 1XpGJC-0005R3-BC; Fri, 14 Nov 2014 12:49:02 +0000 Received: from mail-lb0-f180.google.com ([209.85.217.180]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XpGIy-0005PM-IR for lng-odp@lists.linaro.org; Fri, 14 Nov 2014 12:48:48 +0000 Received: by mail-lb0-f180.google.com with SMTP id z11so6016090lbi.11 for ; Fri, 14 Nov 2014 04:48:43 -0800 (PST) X-Received: by 10.152.88.69 with SMTP id be5mr8200726lab.36.1415969322937; Fri, 14 Nov 2014 04:48:42 -0800 (PST) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id r4sm8175438lar.3.2014.11.14.04.48.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 04:48:42 -0800 (PST) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Fri, 14 Nov 2014 14:48:23 +0200 Message-Id: <1415969305-13255-3-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415969305-13255-1-git-send-email-ciprian.barbu@linaro.org> References: <1415969305-13255-1-git-send-email-ciprian.barbu@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 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.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: 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 0b08cad..98e0962 100644 --- a/platform/linux-netmap/Makefile.am +++ b/platform/linux-netmap/Makefile.am @@ -67,7 +67,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 6243040..936c9b7 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, strncpy(pkt_nm->ifname, netdev, sizeof(pkt_nm->ifname)); snprintf(ifname, sizeof(ifname), "netmap:%s", netdev); - pkt_nm->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->nm_desc = nm_open(ifname, NULL, 0, NULL); + else + pkt_nm->nm_desc = nm_open(ifname, NULL, NM_OPEN_NO_MMAP, + &mmap_desc); if (pkt_nm->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->nm_desc->mem; + mmap_desc.memsize = pkt_nm->nm_desc->memsize; + } + odp_spinlock_unlock(&mmap_desc_lock); + ODP_DBG("thread %d mmap addr %p\n", odp_thread_id(), pkt_nm->nm_desc->mem);