Date: Fri, 17 Oct 2014 10:27:54 -0700 From: Luigi Rizzo <rizzo@iet.unipi.it> To: "Matthew P. Grosvenor" <matthew.grosvenor@cl.cam.ac.uk> Cc: "freebsd-net@freebsd.org" <freebsd-net@freebsd.org> Subject: Re: Netmap: head vs cur vs tail? Message-ID: <CA%2BhQ2%2Bg4awd8EHVe68O6%2B5B7QcFcco0scD5bPGWKhkUxT_LpgA@mail.gmail.com> In-Reply-To: <9C6995C3-2B7A-4769-A658-DCF1C1B23B60@cl.cam.ac.uk> References: <9C6995C3-2B7A-4769-A658-DCF1C1B23B60@cl.cam.ac.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Oct 17, 2014 at 9:55 AM, Matthew P. Grosvenor < matthew.grosvenor@cl.cam.ac.uk> 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 with each = other. > > 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), =E2=80=9C. In the example code, the fol= lowing > pattern is used: > =E2=80=8Bthe default netmap manpage at the above URL is the old one, please use the one for 10-stable or 11-current http://www.freebsd.org/cgi/man.cgi =E2=80=8B?=E2=80=8B query=3Dnetmap&manpath=3DFreeBSD+10.0-stable =E2=80=8Bwhich=E2=80=8B explains in more detail the role of the three pointers (with some ascii graphics too). Feel free to ask for more details if the page is not clear cheers luigi > 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: > > 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; > > 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 no= t > 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? > > 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. > > > Cheers, > Matt > > _______________________________________________ > 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 -----------------------------------------+------------------------------- 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) -----------------------------------------+-------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BhQ2%2Bg4awd8EHVe68O6%2B5B7QcFcco0scD5bPGWKhkUxT_LpgA>