tcp/tso: Add per-device TSO aggregation size limit
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 16 Jan 2013 11:02:36 +0000 (19:02 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 22 Jan 2013 11:56:34 +0000 (19:56 +0800)
commite41e61d527704e7aa16af8e67ac60563ee8e4962
tree08417040aeab5c464064d5641090d08dc3b3e2f2
parenta90935f39cb8efe7865e08bcc28c6997ca3bf155
tcp/tso: Add per-device TSO aggregation size limit

- Prevent possible TSO large burst, when it is inappropriate (plenty of
  >24 segements bursts were observered, even when 32 parallel sending TCP
  streams are running on the same GigE NIC).
  TSO large burst has following drawbacks on a single TX queue, even on
  the devices that are multiple TX queues capable:
  o  Delay other senders' packet transmission quite a lot.
  o  Has negative effect on TCP receivers, which sends ACKs.
  o  Cause buffer bloat in software sending queues, whose upper limit is
     based on "packet count".
  o  Packet scheduler's decision could be less effective.
  On the other hand, TSO large burst could improve CPU usage.
- Improve fairness between multiple TX queues on the devices that are
  multiple TX queues capable but only fetch data on TSO large packet
  boundary instead of TCP segment boundary.

Drivers could supply their own TSO aggregation size limit.  If driver
does not set it, the default value is 6000 (4 segments if MTU is 1500).
The default value increases CPU usage a little bit: on i7-2600 w/ HT
enabled, single TCP sending stream, CPU usage increases from 14%~17%
to 17%~20%.

User could configure TSO aggregation size limit by using ifconfig(8):
ifconfig ifaceX tsolen _n_
sbin/ifconfig/ifconfig.8
sbin/ifconfig/ifconfig.c
sys/net/if.c
sys/net/if.h
sys/net/if_ethersubr.c
sys/net/if_var.h
sys/netinet/tcp_output.c
sys/sys/sockio.h