Subject: Re: m_defrag() addition
To: Jaromir Dolecek <jdolecek@NetBSD.org>
From: Sam Leffler <sam@errno.com>
List: tech-kern
Date: 02/20/2005 11:30:34
Jaromir Dolecek wrote:
> Hi,
> 
> I'd like to add a routine for coalescing mbuf chain into fewer
> segments. Primary consuments would be network drivers, which would
> use the routine if the original mbuf chain is too fragmented to be
> loadable into their DMA rings. Bunch of drivers already use custom
> code for this, and it would be good to centralize the code.
> Basically _any_ network driver using DMA to push trasmit packets
> should be using this.
> 
> The implementation I've prepared only deals with < MCLBYTES packets.
> Extending the function to also handle ethernet JUMBO packets
> would be possible later, and would benefit all drivers using the
> function.
> 
> The function would return new mbuf chain on success or NULL
> on failure, the old mbuf chain would be freed in either case.
> 
> The name and semantics is borrowed from FreeBSD, so having this
> function would also be convenient for API compatibility.
> 
> Would anyone object if I'd add this function to uipc_mbuf.c et.al.?
> 

Note that the code in FreeBSD has several issues that required me to 
bypass it in favor of private code.  For example it optimally compacts 
the mbufs instead of doing a "good enough job" to satisfy the 
fragmentation requirements of the caller.  I plan to change the FreeBSD 
routine to take another arg that specifies the max fragmentation level 
so m_it can stop early and/or return an indication of whether it was 
able to satisfy the callers' requirement (otherwise the caller must do a 
bus_dma call in order to find out if it's defrag'd enough to handle).

	Sam