From patchwork Mon Mar 2 18:46:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 45307 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EACFA214B5 for ; Mon, 2 Mar 2015 18:48:03 +0000 (UTC) Received: by lbiw7 with SMTP id w7sf25576913lbi.0 for ; Mon, 02 Mar 2015 10:48:02 -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:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=sqnf0/+MWknP0iEmLuUCs7iE4SRibv/zoL7g0+kWnR8=; b=hbeR8D3ZOkb7dxznOj1OOCxZreR4Jkz77vew6LMJ+bB9y5ZbuhYtvd2r3f2tI8P/l4 JBzEdy2bYPwjRimOhdZCZUAhnDMioDDPxYXwcRz1RjCKkYiki9CL4uyGYAmCw2u2rMlc FaC/QCNAIW8CTiSdARZPq6qwliI63WgBcjNZchsZFm1QIpFAmY0IEiXfV9W+t3sOFIOt 19roo8qV1FoZq6JUxfdHLyPeRnldSxSnrHiUdgGX7czUcQ/fWa7U2+JmUZ/mw6WxW4y+ klhDwp/1HDd80Mw5dWesz/BIF7/PJ/7tTURdv5KjTUJCZIXKXcQQptbLDK/QiWIx5kWm JHpw== X-Gm-Message-State: ALoCoQk0OVKMyONiQ4v9ugYuvHezdW63lLb+0mHcjM94cXC7s5kUYteNAk2J6TcsK6cPb9v6fLGT X-Received: by 10.180.80.35 with SMTP id o3mr2477363wix.0.1425322082875; Mon, 02 Mar 2015 10:48:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.42 with SMTP id g10ls486321laa.51.gmail; Mon, 02 Mar 2015 10:48:02 -0800 (PST) X-Received: by 10.152.21.99 with SMTP id u3mr3322816lae.105.1425322082642; Mon, 02 Mar 2015 10:48:02 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id d9si9438617lad.116.2015.03.02.10.48.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Mar 2015 10:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by labgd6 with SMTP id gd6so32415133lab.7 for ; Mon, 02 Mar 2015 10:48:02 -0800 (PST) X-Received: by 10.112.211.200 with SMTP id ne8mr25341600lbc.73.1425322082545; Mon, 02 Mar 2015 10:48:02 -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.35.133 with SMTP id h5csp90179lbj; Mon, 2 Mar 2015 10:48:01 -0800 (PST) X-Received: by 10.140.231.151 with SMTP id b145mr52568242qhc.22.1425322079888; Mon, 02 Mar 2015 10:47:59 -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 l5si12432019qay.12.2015.03.02.10.47.58 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Mar 2015 10:47:59 -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 1YSVNl-0008Gl-1j; Mon, 02 Mar 2015 18:47:57 +0000 Received: from mail-lb0-f175.google.com ([209.85.217.175]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YSVNA-0008A9-Nw for lng-odp@lists.linaro.org; Mon, 02 Mar 2015 18:47:20 +0000 Received: by lbjf15 with SMTP id f15so4172119lbj.2 for ; Mon, 02 Mar 2015 10:47:15 -0800 (PST) X-Received: by 10.152.22.33 with SMTP id a1mr25773282laf.79.1425322035225; Mon, 02 Mar 2015 10:47:15 -0800 (PST) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id i13sm2696725lab.38.2015.03.02.10.47.14 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Mar 2015 10:47:14 -0800 (PST) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Mon, 2 Mar 2015 20:46:53 +0200 Message-Id: <1425322017-14636-9-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1425322017-14636-1-git-send-email-ciprian.barbu@linaro.org> References: <1425322017-14636-1-git-send-email-ciprian.barbu@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH NETMAP 08/12] linux-netmap: pktio: 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.215.50 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/odp_packet_netmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/platform/linux-netmap/odp_packet_netmap.c b/platform/linux-netmap/odp_packet_netmap.c index 361f639..632ae49 100644 --- a/platform/linux-netmap/odp_packet_netmap.c +++ b/platform/linux-netmap/odp_packet_netmap.c @@ -55,8 +55,14 @@ #define WAITLINK_TMO 2 #define POLL_TMO 0 +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 nm_global_lock; + int odp_netmap_init_global(void) { + odp_spinlock_init(&nm_global_lock); return 0; } @@ -142,13 +148,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->desc = nm_open(ifname, NULL, 0, 0); + + odp_spinlock_lock(&nm_global_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(&nm_global_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(&nm_global_lock); + ODP_DBG("[%04d] mmap addr %p\n", odp_thread_id(), pkt_nm->desc->mem);