svn commit: r279892 - head/sys/dev/cxgbe/tom

John Baldwin jhb at FreeBSD.org
Wed Mar 11 17:35:08 UTC 2015


Author: jhb
Date: Wed Mar 11 17:35:07 2015
New Revision: 279892
URL: https://svnweb.freebsd.org/changeset/base/279892

Log:
  Resize receive socket buffers that support autosizing when receiving
  TCP data via direct data placement.
  
  Sponsored by:	Chelsio
  MFC after:	1 week

Modified:
  head/sys/dev/cxgbe/tom/t4_ddp.c

Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_ddp.c	Wed Mar 11 16:02:24 2015	(r279891)
+++ head/sys/dev/cxgbe/tom/t4_ddp.c	Wed Mar 11 17:35:07 2015	(r279892)
@@ -65,6 +65,13 @@ __FBSDID("$FreeBSD$");
 #include "common/t4_tcb.h"
 #include "tom/t4_tom.h"
 
+VNET_DECLARE(int, tcp_do_autorcvbuf);
+#define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf)
+VNET_DECLARE(int, tcp_autorcvbuf_inc);
+#define V_tcp_autorcvbuf_inc VNET(tcp_autorcvbuf_inc)
+VNET_DECLARE(int, tcp_autorcvbuf_max);
+#define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max)
+
 #define PPOD_SZ(n)	((n) * sizeof(struct pagepod))
 #define PPOD_SIZE	(PPOD_SZ(1))
 
@@ -411,6 +418,21 @@ handle_ddp_data(struct toepcb *toep, __b
 	else
 		discourage_ddp(toep);
 
+	/* receive buffer autosize */
+	if (sb->sb_flags & SB_AUTOSIZE &&
+	    V_tcp_do_autorcvbuf &&
+	    sb->sb_hiwat < V_tcp_autorcvbuf_max &&
+	    len > (sbspace(sb) / 8 * 7)) {
+		unsigned int hiwat = sb->sb_hiwat;
+		unsigned int newsize = min(hiwat + V_tcp_autorcvbuf_inc,
+		    V_tcp_autorcvbuf_max);
+
+		if (!sbreserve_locked(sb, newsize, so, NULL))
+			sb->sb_flags &= ~SB_AUTOSIZE;
+		else
+			toep->rx_credits += newsize - hiwat;
+	}
+
 	KASSERT(toep->sb_cc >= sbused(sb),
 	    ("%s: sb %p has more data (%d) than last time (%d).",
 	    __func__, sb, sbused(sb), toep->sb_cc));


More information about the svn-src-head mailing list