1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +00:00

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
Reviewed by:		rmacklem
MFC after:		2 weeks
This commit is contained in:
Hans Petter Selasky 2015-09-14 08:36:22 +00:00
parent ceff31dc0c
commit d76d40126e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287775
2 changed files with 17 additions and 6 deletions

View File

@ -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 */

View File

@ -811,7 +811,8 @@ tcp_output(struct tcpcb *tp)
*/
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 @@ tcp_output(struct tcpcb *tp)
*/
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);