From 3cb0272c8ee00baeea38c8342784b3ad9ac6433e Mon Sep 17 00:00:00 2001 From: hselasky Date: Wed, 19 Nov 2014 09:07:49 +0000 Subject: [PATCH] MFC r274376: Fix some minor TSO issues: - Improve description of TSO limits. - Remove a not needed KASSERT() - Remove some not needed variable casts. Sponsored by: Mellanox Technologies git-svn-id: svn://svn.freebsd.org/base/stable/9@274705 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/net/if.c | 7 ------- sys/net/if_var.h | 23 ++++++++++++++++++----- sys/netinet/tcp_output.c | 16 ++++++++-------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 8711a8d9b..84346c698 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -747,13 +747,6 @@ if_attach_internal(struct ifnet *ifp, int vmove) ifp->if_hw_tsomaxsegsize); } } - /* - * If the "if_hw_tsomax" limit is set, check if it is - * too small: - */ - KASSERT(ifp->if_hw_tsomax == 0 || - ifp->if_hw_tsomax >= (IP_MAXPACKET / 8), - ("%s: if_hw_tsomax is outside of range", __func__)); #endif } #ifdef VIMAGE diff --git a/sys/net/if_var.h b/sys/net/if_var.h index e40dae0a3..4119a007e 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -211,11 +211,24 @@ struct ifnet { * be used with care where binary compatibility is required. */ char if_cspare[3]; - u_int if_hw_tsomax; /* TSO total burst length - * limit in bytes. A value of - * zero means no limit. Have - * to find a better place for - * it eventually. */ + + /* + * Network adapter TSO limits: + * =========================== + * + * If the "if_hw_tsomax" field is zero the maximum segment + * length limit does not apply. If the "if_hw_tsomaxsegcount" + * or the "if_hw_tsomaxsegsize" field is zero the TSO segment + * 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. + */ + u_int if_hw_tsomax; int if_ispare[1]; /* * TSO fields for segment limits. If a field is zero below, diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 98ea9c943..01253d3ab 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -794,9 +794,9 @@ send: max_len = (if_hw_tsomax - hdrlen); if (max_len <= 0) { len = 0; - } else if (len > (u_int)max_len) { + } else if (len > max_len) { sendalot = 1; - len = (u_int)max_len; + len = max_len; } } @@ -809,7 +809,7 @@ send: max_len = 0; mb = sbsndmbuf(&so->so_snd, off, &moff); - while (mb != NULL && (u_int)max_len < len) { + while (mb != NULL && max_len < len) { u_int mlen; u_int frags; @@ -843,9 +843,9 @@ send: } if (max_len <= 0) { len = 0; - } else if (len > (u_int)max_len) { + } else if (len > max_len) { sendalot = 1; - len = (u_int)max_len; + len = max_len; } } @@ -856,7 +856,7 @@ send: */ max_len = (tp->t_maxopd - optlen); if ((off + len) < so->so_snd.sb_cc) { - moff = len % (u_int)max_len; + moff = len % max_len; if (moff != 0) { len -= moff; sendalot = 1; @@ -867,8 +867,8 @@ send: * In case there are too many small fragments * don't use TSO: */ - if (len <= (u_int)max_len) { - len = (u_int)max_len; + if (len <= max_len) { + len = max_len; sendalot = 1; tso = 0; } -- 2.45.0