Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Feb 2013 16:05:00 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Lino Sanfilippo <lsanfil@marvell.com>
Cc:        Hackers freeBSD <freebsd-hackers@freebsd.org>, Axel Fischer <afischer@marvell.com>, Jacques Fourie <jacques.fourie@gmail.com>, Ralf Assmann <rassmann@marvell.com>, Markus Althoff <malthoff@marvell.com>
Subject:   Re: Mbuf memory handling
Message-ID:  <201302061605.00583.jhb@freebsd.org>
In-Reply-To: <175CCF5F49938B4D99B2E3EF7F558EBE1C73F4038E@SC-VEXCH4.marvell.com>
References:  <175CCF5F49938B4D99B2E3EF7F558EBE1C73F401F3@SC-VEXCH4.marvell.com> <CALX0vxCKqMm2PdK_5t1SdOO91LjpZ1bHz-oDskx6pEj5FPhvtg@mail.gmail.com> <175CCF5F49938B4D99B2E3EF7F558EBE1C73F4038E@SC-VEXCH4.marvell.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, February 06, 2013 2:41:32 pm Lino Sanfilippo wrote:
> John, Jacques,
> 
> thank you very much for your help. An mbuf cluster seems to be the right 
direction.
> So I would have to do something like
> 
> mbuf = m_getjcl(how, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
> left_for_next_rcv = m_split(mbuf, chunksize);
> if_input(ifp, mbuf);
> 
> right?
> 
> >I agree that read-only buffers may be ok in this case but would like to 
point out that the M_WRITABLE() macro will evaluate to 0 if the refcount on 
the cluster is >1
> 
> The fact that the resulting mbufs returned by m_split() are not writeable 
any more is indeed a problem:
> What I would like to do is keep the 'left_for_next_rcv' mbuf until the next 
packet arrives and
> then fill it with the next packets data only up to 'chunksize', split it 
again to pass the new mbuf to
> the protocol stack and so on until 'left_for_next_rcv' becomes too small to 
be splitted further.
> Only then I would want to allocate a new "fresh" jumbo sized mbuf. Is it 
possible to
> realize this with cluster mbufs?

They are only read-only in the sense that you can't call routines like
m_pullup() or m_prepend(), etc.  Your device should still be able to DMA
into the buffer, but once the buffer is passed up to the stack the stack
can't mess with it.  This is probably what you want anyway as you wouldn't
want the stack appending to a buffer and spilling over into the cluster
where your device is going to DMA the next packet.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302061605.00583.jhb>