]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Fix some minor TSO issues:
authorhselasky <hselasky@FreeBSD.org>
Tue, 11 Nov 2014 12:05:59 +0000 (12:05 +0000)
committerhselasky <hselasky@FreeBSD.org>
Tue, 11 Nov 2014 12:05:59 +0000 (12:05 +0000)
- Improve description of TSO limits.
- Remove a not needed KASSERT()
- Remove some not needed variable casts.

Sponsored by: Mellanox Technologies
Discussed with: lstewart @
MFC after: 1 week

sys/net/if.c
sys/net/if_var.h
sys/netinet/tcp_output.c

index 0103c3fdd5c4565d4dcc3c3623d7b89bd316e278..d97e0e11cdf0f8166613eb66f2f516c5a7f3d4d5 100644 (file)
@@ -717,13 +717,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
index 643a1a489a57926195d9d2b5a5b401962d2c7c4d..98e9828dab5b24bbec71cf21e1281dd9df97df4f 100644 (file)
@@ -232,16 +232,24 @@ struct ifnet {
        counter_u64_t   if_counters[IFCOUNTERS];
 
        /* Stuff that's only temporary and doesn't belong here. */
-       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. */
 
        /*
-        * TSO fields for segment limits. If a field below is zero,
-        * there is no TSO segment limit.
+        * 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;           /* TSO maximum size in bytes */
        u_int   if_hw_tsomaxsegcount;   /* TSO maximum segment count */
        u_int   if_hw_tsomaxsegsize;    /* TSO maximum segment size in bytes */
 
index d9d13a32f47857c50a5d5852cbdc9fce8313d277..7919e2b72e01ab1cbf321bafd7be84e4a04b7a01 100644 (file)
@@ -802,9 +802,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;
                                }
                        }
 
@@ -817,7 +817,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;
 
@@ -851,9 +851,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;
                                }
                        }
 
@@ -864,7 +864,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;
@@ -875,8 +875,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;
                        }