From owner-freebsd-net@FreeBSD.ORG Sat Oct 18 06:59:03 2014 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 09BC8BE2 for ; Sat, 18 Oct 2014 06:59:03 +0000 (UTC) Received: from ppsw-52.csi.cam.ac.uk (ppsw-52.csi.cam.ac.uk [131.111.8.152]) (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 BC970A7F for ; Sat, 18 Oct 2014 06:59:02 +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]:56088 helo=[192.168.0.5]) by ppsw-52.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (PLAIN:mpg39) (TLSv1:DHE-RSA-AES256-SHA:256) id 1XfNye-0006CJ-Ee (Exim 4.82_3-c0e5623) (return-path ); Sat, 18 Oct 2014 07:59:00 +0100 Mime-Version: 1.0 (1.0) Subject: Re: Netmap: head vs cur vs tail? From: "Matthew P. Grosvenor" X-Mailer: iPhone Mail (12A405) In-Reply-To: Date: Sat, 18 Oct 2014 07:58:57 +0100 Message-Id: <986ECDB1-3D76-4930-9C08-A2661F573431@cl.cam.ac.uk> References: <9C6995C3-2B7A-4769-A658-DCF1C1B23B60@cl.cam.ac.uk> To: Luigi Rizzo Sender: "M.P. Grosvenor" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 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, 18 Oct 2014 06:59:03 -0000 Thanks! This has tons more info. I'll have a read.=20 ----------- Sent from my phone, sorry about the typos.=20 > On 17 Oct 2014, at 18:27, Luigi Rizzo wrote: >=20 >=20 >=20 >> On Fri, Oct 17, 2014 at 9:55 AM, Matthew P. Grosvenor wrote: >> Hi all, >> I=E2=80=99m trying to understand how to use the netmap framework, specifi= cally how the head, tail and current =E2=80=9Cpointers=E2=80=9D interact wit= h each other. >>=20 >> Looking in man NETMAP(4) (http://www.freebsd.org/cgi/man.cgi?query=3Dnetm= ap&sektion=3D4) under data structures, struct netmap_ring it says: " cont= ains the index of he current read or write slot (cur), =E2=80=9C. In the exa= mple code, the following pattern is used: >=20 > =E2=80=8Bthe default netmap manpage at the above URL is the old one, > please use the one for 10-stable or 11-current=20 >=20 > http://www.freebsd.org/cgi/man.cgi=E2=80=8B?=E2=80=8Bquery=3Dnetmap&manpat= h=3DFreeBSD+10.0-stable >=20 > =E2=80=8Bwhich=E2=80=8B explains in more detail the role > of the three pointers (with some ascii graphics too). >=20 > Feel free to ask for more details if the page is not clear >=20 > cheers > luigi >=20 >>=20 >> i =3D ring->cur; >> ... >> ring->cur =3D NETMAP_RING_NEXT(ring, i); >>=20 >> However, in the example that ships with the netmap source (https://code.g= oogle.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 u= sed: >>=20 >> j =3D rxring->cur; >> while(=E2=80=A6){ >> j =3D nm_ring_next(rxring, j); >> =E2=80=A6 >> } >> rxring->head =3D rxring->cur =3D j; >>=20 >> So the obvious question is, what is the relationship between head and cur= rent? Do I believe the man page (and man page example) that head is not nece= ssary, 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=E2=80=99m looking for a better understanding of what h= ead, tail and current mean and how they affect the processing of rings. >=20 > =20 >> Cheers, >> Matt >>=20 >> _______________________________________________ >> freebsd-net@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-net >> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >=20 >=20 >=20 > --=20 > -----------------------------------------+------------------------------- > Prof. Luigi RIZZO, rizzo@iet.unipi.it . Dip. di Ing. dell'Informazione > http://www.iet.unipi.it/~luigi/ . Universita` di Pisa > TEL +39-050-2211611 . via Diotisalvi 2 > Mobile +39-338-6809875 . 56122 PISA (Italy) > -----------------------------------------+-------------------------------