From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 6 15:20:52 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1F043126; Wed, 6 Feb 2013 15:20:52 +0000 (UTC) (envelope-from jacques.fourie@gmail.com) Received: from mail-wg0-x22a.google.com (wg-in-x022a.1e100.net [IPv6:2a00:1450:400c:c00::22a]) by mx1.freebsd.org (Postfix) with ESMTP id 8EE1F1F9; Wed, 6 Feb 2013 15:20:51 +0000 (UTC) Received: by mail-wg0-f42.google.com with SMTP id 12so5105630wgh.1 for ; Wed, 06 Feb 2013 07:20:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=RpIspa7UDDad0DOKWti2hvt9abWVcEa0ywHx1xw06P4=; b=iA1z2fjmIvgd/VXnn/3yI9vfMCrnTSChgtnsX4mt/nkcai1KAe9Lk3l+bAJ7DLGn/9 kj7Nw9jUdDgCld2+j+Iq0un59FOcuQVF+Sa0sVlNcJnBdCgYOE0+DVloopjOvwiqg0KT g8eZrS/r48giYy62rwCS8DjOOspQA9a0nrcCi9TCHyTSsdGQWwOmUuat9tRcll6RJ0cw qD0eiJhcX8HuaqddjmEZ61WO54I5Fgub7f+GKbwIQa4Q6QApjIJJXF0lMewxN+P5LUUk NO5gyebc9lkM8T1L4WTZOeu463DBmPmEC4mXvQGPFhLMp3fL+ZmlPuOL0o9cKGNOxOdC yiEw== MIME-Version: 1.0 X-Received: by 10.194.158.100 with SMTP id wt4mr50509815wjb.37.1360164050803; Wed, 06 Feb 2013 07:20:50 -0800 (PST) Received: by 10.194.110.132 with HTTP; Wed, 6 Feb 2013 07:20:50 -0800 (PST) In-Reply-To: <201302060836.55404.jhb@freebsd.org> References: <175CCF5F49938B4D99B2E3EF7F558EBE1C73F401F3@SC-VEXCH4.marvell.com> <201302060836.55404.jhb@freebsd.org> Date: Wed, 6 Feb 2013 17:20:50 +0200 Message-ID: Subject: Re: Mbuf memory handling From: Jacques Fourie To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Hackers freeBSD , Axel Fischer , Lino Sanfilippo , Markus Althoff X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2013 15:20:52 -0000 On Wed, Feb 6, 2013 at 3:36 PM, John Baldwin wrote: > On Wednesday, February 06, 2013 4:50:39 am Lino Sanfilippo wrote: > > > > Hi all, > > > > I want to implement a device driver for a NIC which stores received data > into chunks within > > a page (>=4k) in host memory. One page shall be used for multiple > packets and freed > > after all mbufs linked to that page have been processed. So I would like > to know what is the recommended way > > to handle this in FreeBSD? Any hints are very appreciated. > > I think you can get what you want by allocating M_JUMBOP mbuf clusters for > your receive buffers. When you want to split out a packet, allocate a new > packet header mbuf and use m_split() to let it take over the rest of the 4k > buffer and pass the original mbuf up to if_input() as the new packet. The > new mbufs you attach to the cluster via m_split() will all hold a reference > on the backing cluster and it won't be freed until all the mbufs are freed. > > The resulting mbufs will not be writeable (M_WRITABLE() will evaluate to 0), right? I don't know if this will be an issue in this particular application. > -- > John Baldwin > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >