From owner-freebsd-net@FreeBSD.ORG Fri Oct 17 16:55:33 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B55B19B3 for ; Fri, 17 Oct 2014 16:55:33 +0000 (UTC) Received: from ppsw-50.csi.cam.ac.uk (ppsw-50.csi.cam.ac.uk [131.111.8.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 77DE1B9 for ; Fri, 17 Oct 2014 16:55:33 +0000 (UTC) X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from bpb8.clarehall.cam.ac.uk ([131.111.224.154]:58604 helo=[192.168.0.2]) by ppsw-50.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (PLAIN:mpg39) (TLSv1:AES128-SHA:128) id 1XfAoN-00039w-rx (Exim 4.82_3-c0e5623) for freebsd-net@freebsd.org (return-path ); Fri, 17 Oct 2014 17:55:31 +0100 From: "Matthew P. Grosvenor" Subject: Netmap: head vs cur vs tail? Message-Id: <9C6995C3-2B7A-4769-A658-DCF1C1B23B60@cl.cam.ac.uk> Date: Fri, 17 Oct 2014 17:55:26 +0100 To: freebsd-net@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) Sender: "M.P. Grosvenor" Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 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: Fri, 17 Oct 2014 16:55:33 -0000 Hi all, I=92m trying to understand how to use the netmap framework, specifically = how the head, tail and current =93pointers=94 interact with each other.=20= Looking in man NETMAP(4) = (http://www.freebsd.org/cgi/man.cgi?query=3Dnetmap&sektion=3D4) under = data structures, struct netmap_ring it says: " contains the index = of he current read or write slot (cur), =93. In the example code, the = following pattern is used:=20 i =3D ring->cur; ... ring->cur =3D NETMAP_RING_NEXT(ring, i); However, in the example that ships with the netmap source = (https://code.google.com/p/netmap/source/browse/examples/bridge.c#72 & = https://code.google.com/p/netmap/source/browse/examples/pkt-gen.c#660) = the following pattern is used:=20 j =3D rxring->cur;=20 while(=85){ j =3D nm_ring_next(rxring, j); =85 } rxring->head =3D rxring->cur =3D j; So the obvious question is, what is the relationship between head and = current? Do I believe the man page (and man page example) that head is = not necessary, or do I believe the example code that head is necessary = and should be set to the same value as current? And if so, what is the = point of head? And why is it updated outside of the loop in both of the = examples?=20 At a high level, I=92m looking for a better understanding of what head, = tail and current mean and how they affect the processing of rings.=20 Cheers, Matt