From owner-freebsd-net@FreeBSD.ORG Thu Sep 4 15:49:28 2014 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 73140E81 for ; Thu, 4 Sep 2014 15:49:28 +0000 (UTC) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 351D61BC9 for ; Thu, 4 Sep 2014 15:49:27 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 64C187300A; Thu, 4 Sep 2014 17:48:29 +0200 (CEST) Date: Thu, 4 Sep 2014 17:48:29 +0200 From: Luigi Rizzo To: "Eggert, Lars" Subject: Re: netmap extra rings and buffers Message-ID: <20140904154829.GA80780@onelab2.iet.unipi.it> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: "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: Thu, 04 Sep 2014 15:49:28 -0000 On Thu, Sep 04, 2014 at 11:58:28AM +0000, Eggert, Lars wrote: > Hi Luigi, > > I'm allocating extra rings and/or extra buffers via the nr_arg1/nr_arg3 parameters for NIOCREGIF. > > Once I've done that, how do I actually access those rings and buffers? > > For extra rings, the documentation and example code don't really say anything. > > For extra buffers, the documentation says "nifp->ni_bufs_head will be the index of the first buffer" but doesn't really explain how I can find the buffer given its index (since it's not in a ring, the NETMAP_BUF macro doesn't seem to apply?) The part about "buffers are linked to each other using the first uint32_t as the index" is also unclear to me. > > Do you have some more text or example code that shows how to use extra rings and buffers? the ifield to request extra rings is only important when you want to make sure that the memory region for a VALE port has also space to host some pipes. Otherwise, for physical ports (which at the moment all share the same address space) there is not a real need to specify it. For the extra buffers, remember that NETMAP_BUF() can translate buffer indexes for any netmap buffer, even those not in a ring. All it does is grab the base address of the buffer pool from the ring, and add the buffer index times the buffer size. So you can navigate the pool of extra buffers as follows uint32_t x = nifp->ni_bufs_head; // index of first buf void *p = NETMAP_BUF(any_ring, x); // address of the first buffer x = *((uint32_t *)p); // index of the next buffer cheers luigi