From owner-svn-src-all@FreeBSD.ORG Thu Dec 8 17:49:20 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 569B21065675; Thu, 8 Dec 2011 17:49:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 02CD38FC08; Thu, 8 Dec 2011 17:49:20 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id AAB1946B0D; Thu, 8 Dec 2011 12:49:19 -0500 (EST) Received: from John-Baldwins-MacBook-Air.local (c-68-36-150-83.hsd1.nj.comcast.net [68.36.150.83]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 18139B93A; Thu, 8 Dec 2011 12:49:19 -0500 (EST) Message-ID: <4EE0F89E.1070107@FreeBSD.org> Date: Thu, 08 Dec 2011 12:49:18 -0500 From: John Baldwin User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Luigi Rizzo References: <201112051533.pB5FXEuh043063@svn.freebsd.org> <20111205183854.GC54475@alchemy.franken.de> <20111205193150.GB49118@onelab2.iet.unipi.it> In-Reply-To: <20111205193150.GB49118@onelab2.iet.unipi.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 08 Dec 2011 12:49:19 -0500 (EST) Cc: svn-src-head@freebsd.org, Luigi Rizzo , src-committers@freebsd.org, svn-src-all@freebsd.org, Marius Strobl Subject: Re: svn commit: r228281 - in head/sys/dev: e1000 re X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2011 17:49:20 -0000 On 12/5/11 2:31 PM, 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. For your use case, you probably don't want to be coping with bounce buffers at all. That is, if you are preallocating long-lived buffers that keep getting reused while netmap is active that are allocated at startup and free'd at teardown, you probably want to allocate buffers that won't require bounce buffers. That means you have to let the drivers allocate the buffers (or give you a suitable bus_dma tag since different devices have different addressing requirements, etc.). You could then use bus_dmamem_alloc() to allocate your buffers. -- John Baldwin