I'm asking for some input on the attached m_dup() patch, so that existing functionality or dependencies are not broken. The background for the change is to allow m_dup() to defrag long mbuf chains that doesn't fit into a specific hardware's scatter gather entries, typically when doing TSO.

In my case the HW limit is 16 entries of length 4K for doing a 64KByte TSO packet. Currently m_dup() is at best producing 32 entries of each 2K for a 64Kbytes TSO packet.

By allowing m_dup() to get JUMBO clusters when allocating mbufs, we avoid creating a new function, specific to the hardware, to defrag some rare-occurring very long mbuf chains into a mbuf chain below 16 entries.

Any comments?


=== uipc_mbuf.c
--- uipc_mbuf.c	(revision 268358)
+++ uipc_mbuf.c	(local)
@@ -917,7 +917,15 @@
 		struct mbuf *n;
 		/* Get the next new mbuf */
-		if (remain >= MINCLSIZE) {
+		if (remain >= MJUM16BYTES) {
+			/*
+			 * By allocating a bigger mbuf, we get fewer
+			 * scatter gather entries for the hardware to
+			 * process:
+			 */
+			n = m_getjcl(how, m->m_type, 0, MJUM16BYTES);
+			nsize = MJUM16BYTES;
+		} else if (remain >= MINCLSIZE) {
 			n = m_getcl(how, m->m_type, 0);
 			nsize = MCLBYTES;
 		} else {
freebsd-current@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to