From owner-freebsd-net@FreeBSD.ORG Fri Oct 17 17:27:57 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 3094219A for ; Fri, 17 Oct 2014 17:27:57 +0000 (UTC) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B2D885EE for ; Fri, 17 Oct 2014 17:27:56 +0000 (UTC) Received: by mail-wi0-f179.google.com with SMTP id d1so1849150wiv.12 for ; Fri, 17 Oct 2014 10:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=k9c5oyr6EaAqobHLBAVhYVeL3Q7w6cUjXWjI7rSDPW8=; b=teabLT2Dm0fgqChjvemOQNKUW+nDeWgtvHwTGg5gWxgnA0CgLfPYTF1Cvng1uw1qtN 9le2iIFsnLFQ8e6B7iBijUHKRQe+b2fcbMLu7uhgWb4+ILzfHxdwUmt4e7xR9cwyU6mB A7Hf93SyUKGsmRbzsQ20qWoQ0xNA9DLC3HXA9BAlfXdx/wtKh3EifJTxkM9KIVB9x9WG Fpil84cBqMeoan5PvRzS5M3s68uj+sFVc+Rb4E5RD3UoMa+VOCOGDmSsPP2QLOfE8USm httIywdnWWok196Hl0e/RE7W+YGcRnjE9IMocNVlHcs16/tQRKg3BKTPPsKKgsPK+J/K 8rvw== MIME-Version: 1.0 X-Received: by 10.180.38.34 with SMTP id d2mr312756wik.55.1413566874791; Fri, 17 Oct 2014 10:27:54 -0700 (PDT) Sender: rizzo.unipi@gmail.com Received: by 10.194.19.9 with HTTP; Fri, 17 Oct 2014 10:27:54 -0700 (PDT) In-Reply-To: <9C6995C3-2B7A-4769-A658-DCF1C1B23B60@cl.cam.ac.uk> References: <9C6995C3-2B7A-4769-A658-DCF1C1B23B60@cl.cam.ac.uk> Date: Fri, 17 Oct 2014 10:27:54 -0700 X-Google-Sender-Auth: nXCZAUmXjXOK4MQCWOR7NgYt5u0 Message-ID: Subject: Re: Netmap: head vs cur vs tail? From: Luigi Rizzo To: "Matthew 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: Fri, 17 Oct 2014 17:27:57 -0000 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) -----------------------------------------+-------------------------------