Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Oct 2015 08:30:41 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r289020 - in stable/10/sys: net netinet
Message-ID:  <201510080830.t988UfUb069581@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu Oct  8 08:30:40 2015
New Revision: 289020
URL: https://svnweb.freebsd.org/changeset/base/289020

Log:
  MFC r287775:
  Update TSO limits to include all headers.
  
  To make driver programming easier the TSO limits are changed to
  reflect the values used in the BUSDMA tag a network adapter driver is
  using. The TCP/IP network stack will subtract space for all linklevel
  and protocol level headers and ensure that the full mbuf chain passed
  to the network adapter fits within the given limits. See r287775
  for a more detailed description.
  
  Differential Revision:	https://reviews.freebsd.org/D3477
  Reviewed by:		rmacklem

Modified:
  stable/10/sys/net/if_var.h
  stable/10/sys/netinet/tcp_output.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/if_var.h
==============================================================================
--- stable/10/sys/net/if_var.h	Thu Oct  8 08:06:23 2015	(r289019)
+++ stable/10/sys/net/if_var.h	Thu Oct  8 08:30:40 2015	(r289020)
@@ -236,11 +236,12 @@ struct ifnet {
 	 * count limit does not apply. If all three fields are zero,
 	 * there is no TSO limit.
 	 *
-	 * NOTE: The TSO limits only apply to the data payload part of
-	 * a TCP/IP packet. That means there is no need to subtract
-	 * space for ethernet-, vlan-, IP- or TCP- headers from the
-	 * TSO limits unless the hardware driver in question requires
-	 * so.
+	 * NOTE: The TSO limits should reflect the values used in the
+	 * BUSDMA tag a network adapter is using to load a mbuf chain
+	 * for transmission. The TCP/IP network stack will subtract
+	 * space for all linklevel and protocol level headers and
+	 * ensure that the full mbuf chain passed to the network
+	 * adapter fits within the given limits.
 	 */
 	u_int	if_hw_tsomax;
 

Modified: stable/10/sys/netinet/tcp_output.c
==============================================================================
--- stable/10/sys/netinet/tcp_output.c	Thu Oct  8 08:06:23 2015	(r289019)
+++ stable/10/sys/netinet/tcp_output.c	Thu Oct  8 08:30:40 2015	(r289020)
@@ -807,7 +807,8 @@ send:
 			 */
 			if (if_hw_tsomax != 0) {
 				/* compute maximum TSO length */
-				max_len = (if_hw_tsomax - hdrlen);
+				max_len = (if_hw_tsomax - hdrlen -
+				    max_linkhdr);
 				if (max_len <= 0) {
 					len = 0;
 				} else if (len > max_len) {
@@ -822,6 +823,15 @@ send:
 			 */
 			if (if_hw_tsomaxsegcount != 0 &&
 			    if_hw_tsomaxsegsize != 0) {
+				/*
+				 * Subtract one segment for the LINK
+				 * and TCP/IP headers mbuf that will
+				 * be prepended to this mbuf chain
+				 * after the code in this section
+				 * limits the number of mbufs in the
+				 * chain to if_hw_tsomaxsegcount.
+				 */
+				if_hw_tsomaxsegcount -= 1;
 				max_len = 0;
 				mb = sbsndmbuf(&so->so_snd, off, &moff);
 



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