svn commit: r287775 - in head/sys: net netinet
Alexander V. Chernikov
melifaro at freebsd.org
Mon Sep 14 08:49:09 UTC 2015
14.09.2015, 11:36, "Hans Petter Selasky" <hselasky at FreeBSD.org>:
> Author: hselasky
> Date: Mon Sep 14 08:36:22 2015
> New Revision: 287775
> URL: https://svnweb.freebsd.org/changeset/base/287775
>
> Log:
> 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.
>
> Implementation notes:
>
> If a network adapter driver needs to fixup the first mbuf in order to
> support VLAN tag insertion, the size of the VLAN tag should be
> subtracted from the TSO limit. Else not.
>
> Network adapters which typically inline the complete header mbuf could
> technically transmit one more segment. This patch does not implement a
> mechanism to recover the last segment for data transmission. It is
> believed when sufficiently large mbuf clusters are used, the segment
> limit will not be reached and recovering the last segment will not
> have any effect.
>
> The current TSO algorithm tries to send MTU-sized packets, where the
> MTU typically is 1500 bytes, which gives 1448 bytes of TCP data
> payload per packet for IPv4. That means if the TSO length limitiation
> is set to 65536 bytes, there will be a data payload remainder of
> (65536 - 1500) mod 1448 bytes which is equal to 324 bytes. Trying to
> recover total TSO length due to inlining mbuf header data will not
> have any effect, because adding or removing the ETH/IP/TCP headers
> to or from 324 bytes will not cause more or less TCP payload to be
> TSO'ed.
>
> Existing network adapter limits will be updated separately.
>
> Differential Revision: https://reviews.freebsd.org/D3458
Probably different revision id ?
> Reviewed by: rmacklem
> MFC after: 2 weeks
>
> Modified:
> head/sys/net/if_var.h
> head/sys/netinet/tcp_output.c
>
> Modified: head/sys/net/if_var.h
> ==============================================================================
> --- head/sys/net/if_var.h Mon Sep 14 08:01:05 2015 (r287774)
> +++ head/sys/net/if_var.h Mon Sep 14 08:36:22 2015 (r287775)
> @@ -243,11 +243,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; /* TSO maximum size in bytes */
> u_int if_hw_tsomaxsegcount; /* TSO maximum segment count */
>
> Modified: head/sys/netinet/tcp_output.c
> ==============================================================================
> --- head/sys/netinet/tcp_output.c Mon Sep 14 08:01:05 2015 (r287774)
> +++ head/sys/netinet/tcp_output.c Mon Sep 14 08:36:22 2015 (r287775)
> @@ -811,7 +811,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) {
> @@ -826,6 +827,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);
More information about the svn-src-all
mailing list