From owner-svn-src-head@FreeBSD.ORG Mon Dec 5 20:14:52 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39D731065672; Mon, 5 Dec 2011 20:14:52 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id A91E88FC18; Mon, 5 Dec 2011 20:14:51 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id pB5KEomL098182; Mon, 5 Dec 2011 21:14:50 +0100 (CET) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id pB5KEomJ098181; Mon, 5 Dec 2011 21:14:50 +0100 (CET) (envelope-from marius) Date: Mon, 5 Dec 2011 21:14:50 +0100 From: Marius Strobl To: Luigi Rizzo Message-ID: <20111205201450.GR60194@alchemy.franken.de> References: <201112051533.pB5FXEuh043063@svn.freebsd.org> <20111205183854.GC54475@alchemy.franken.de> <20111205193150.GB49118@onelab2.iet.unipi.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111205193150.GB49118@onelab2.iet.unipi.it> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, Luigi Rizzo , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r228281 - in head/sys/dev: e1000 re X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Dec 2011 20:14:52 -0000 On Mon, Dec 05, 2011 at 08:31:50PM +0100, Luigi Rizzo wrote: > On Mon, Dec 05, 2011 at 07:38:54PM +0100, Marius Strobl wrote: > > On Mon, Dec 05, 2011 at 03:33:14PM +0000, Luigi Rizzo wrote: > ... > > > +#ifdef DEV_NETMAP > > > + if (slot) { > > > + int si = i + na->tx_rings[txr->me].nkr_hwofs; > > > + void *addr; > > > + > > > + if (si >= na->num_tx_desc) > > > + si -= na->num_tx_desc; > > > + addr = NMB(slot + si); > > > + txr->tx_base[i].buffer_addr = > > > + htole64(vtophys(addr)); > > > + /* reload the map for netmap mode */ > > > + netmap_load_map(txr->txtag, > > > + txbuf->map, addr, na->buff_size); > > > + } > > > +#endif /* DEV_NETMAP */ > > > > Can these vtophys(9) usages be fixed to use bus_dma(9) instead so netmap > > works with bounce buffers, IOMMUs etc? > > maybe. Can you suggest how to change it ? > > Consider that (not here but in other places) vtophys() is called > in a time-critical loop so performance matters a lot. As long as i > can compute the physical address in advance and cache it in my own > array, i suppose that should be fine (in which case the calls to > vtophys(addr) would become NMPB(slot + si) where the NMPB() macro > would hide translations and checks. > Basically, you'd call bus_dmamap_load(9) on the netmap buffers using the tags and maps the driver also uses in the !netmap case to load mbufs. If you're generally pre-allocating the netmap buffers (sorry, I don't have time to check the netmap code) it should also be fine to cache the resulting physical addresses obtained via the bus_dma callback. You'd still need to call bus_dmamap_sync(9) whenever you actually assign a buffer to the hardware and when taking off of it so the bounce buffers are copied over, streaming buffers are synced etc. Marius