Netmap: head vs cur vs tail?
Luigi Rizzo
rizzo at iet.unipi.it
Fri Oct 17 17:27:57 UTC 2014
On Fri, Oct 17, 2014 at 9:55 AM, Matthew P. Grosvenor <
matthew.grosvenor at cl.cam.ac.uk> wrote:
> Hi all,
> I’m trying to understand how to use the netmap framework, specifically how
> the head, tail and current “pointers” interact with each other.
>
> Looking in man NETMAP(4) (
> http://www.freebsd.org/cgi/man.cgi?query=netmap&sektion=4) under data
> structures, struct netmap_ring it says: " contains the index of he
> current read or write slot (cur), “. In the example code, the following
> pattern is used:
>
the 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
?
query=netmap&manpath=FreeBSD+10.0-stable
which
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 = ring->cur;
> ...
> ring->cur = 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 = rxring->cur;
> while(…){
> j = nm_ring_next(rxring, j);
> …
> }
> rxring->head = rxring->cur = 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?
>
> At a high level, I’m looking for a better understanding of what head, tail
> and current mean and how they affect the processing of rings.
>
>
> Cheers,
> Matt
>
> _______________________________________________
> freebsd-net at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"
>
--
-----------------------------------------+-------------------------------
Prof. Luigi RIZZO, rizzo at 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)
-----------------------------------------+-------------------------------
More information about the freebsd-net
mailing list