From owner-freebsd-net@FreeBSD.ORG Sat Jan 3 18:08:21 2015 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7FF208A9 for ; Sat, 3 Jan 2015 18:08:21 +0000 (UTC) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 07E4321F1 for ; Sat, 3 Jan 2015 18:08:21 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 386497300A; Sat, 3 Jan 2015 19:13:04 +0100 (CET) Date: Sat, 3 Jan 2015 19:13:04 +0100 From: Luigi Rizzo To: Slawa Olhovchenkov Subject: Re: netmap pipes Message-ID: <20150103181304.GE95134@onelab2.iet.unipi.it> References: <20150103164035.GC49169@zxy.spb.ru> <20150103172139.GB95134@onelab2.iet.unipi.it> <20150103173255.GD49169@zxy.spb.ru> <20150103174207.GC95134@onelab2.iet.unipi.it> <20150103175721.GE49169@zxy.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150103175721.GE49169@zxy.spb.ru> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jan 2015 18:08:21 -0000 On Sat, Jan 03, 2015 at 09:57:21PM +0400, Slawa Olhovchenkov wrote: > On Sat, Jan 03, 2015 at 06:42:07PM +0100, Luigi Rizzo wrote: > > > On Sat, Jan 03, 2015 at 09:32:55PM +0400, Slawa Olhovchenkov wrote: > > > On Sat, Jan 03, 2015 at 06:21:39PM +0100, Luigi Rizzo wrote: > > > > > > > On Sat, Jan 03, 2015 at 08:40:35PM +0400, Slawa Olhovchenkov wrote: > > > > > Can anybody explain netmap pipes (more then netmap(4))? > > > > > How use it? > > > > > How it works? > > > > > pipes works over existing network adapter in netmap mode? > > > > > Or indepened (can I create netmap pipe named 'some_strange_name')? > > > > > What purpose of master and slave? > > > > > > > > think of pipes as regular netmap ports connected back to back, > > > > (or as two ports on a VALE switch, if you like). > > > > They are unrelated to network devices (though the name indicates > > > > how they share memory, but forget that for the time being); > > > > are created using the "strange names" like valeX:Y{0 and valeX:Y}0 > > > > (which I realize are not yet in the manpage, sorry); > > > > > > can I use names other then valeX:Y? for example 'inside0'? > > > > no, the basename has to be netmap:fooX (where foo is some existing > > ethernet device) or valeX:Y > > Can I transfer through netmap pipes packet with non-ethernet structure? yes. A pipe will not look at the packet's headers or content. > > > > and you have master and slave because need to name both endpoints. > > > > > > I create pipe with many slaves (NIOCREGIF with nr_arg1=16, for > > > example), how I can use this? Writing to master replicated to all > > > slaves? Writing to any slaves reading from master? Or unidirected? > > > > a pipe has only two endpoints. > > What differens between master and slave? there is no difference between master and slave, you just need two names and a way to relate them. > Can I write to slave and read from master? pipes are bidirectional and blocking. So you can write on one and read from the other, in any order. > Can I first create slave second master? You can create the endpoints in any order (internally, they are both created at the same time). > > If you want a full n-port switch use a VALE switch. > > Hmm. > NIOCREGIF > binds the port named in nr_name to the file descriptor. For a phys- > ical device this also switches it into netmap mode, disconnecting > it from the host stack. Multiple file descriptors can be bound to > the same port, with proper synchronization left to the user. > > NIOCREGIF can also bind a file descriptor to one endpoint of a > netmap pipe, consisting of two netmap ports with a crossover con- > nection. A netmap pipe share the same memory space of the parent > port, and is meant to enable configuration where a master process > acts as a dispatcher towards slave processes. > > To enable this function, the nr_arg1 field of the structure can be > used as a hint to the kernel to indicate how many pipes we expect > to use, and reserve extra space in the memory region. > > What this talk about? This is a 'power user' feature which maybe is not what you need (and at the moment I don't have time to explain in more detail or update the manpage). Pipes share memory with the netmap port (VALE port or NIC) with the same basename, and since memory allocation occurs at once, on the first open you need to tell the OS how many pipes need to share memory with the same port -- that is the role of nr_arg1. cheers luigi