aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2014-09-13 20:52:01 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2014-09-13 20:52:01 +0000
commit72f3100047515719aea60c495029eb2ab262240e (patch)
treef2a711c563349212d5fa8c8a4d2f0a78d82ace1e /sys/net/if.c
parent7ddf24b350be2842df1510a519f8eea3b80f2bf1 (diff)
downloadsrc-72f3100047515719aea60c495029eb2ab262240e.tar.gz
src-72f3100047515719aea60c495029eb2ab262240e.zip
Notes
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c60
1 files changed, 10 insertions, 50 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 5e9b77685449..017af336d2b6 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -423,52 +423,6 @@ if_grow(void)
}
/*
- * Compute the least common value of two "if_hw_tsomax" values:
- */
-u_int
-if_hw_tsomax_common(u_int a, u_int b)
-{
- u_int a_bytes = IF_HW_TSOMAX_GET_BYTES(a);
- u_int a_frag_count = IF_HW_TSOMAX_GET_FRAG_COUNT(a);
- u_int a_frag_size = IF_HW_TSOMAX_GET_FRAG_SIZE(a);
- u_int b_bytes = IF_HW_TSOMAX_GET_BYTES(b);
- u_int b_frag_count = IF_HW_TSOMAX_GET_FRAG_COUNT(b);
- u_int b_frag_size = IF_HW_TSOMAX_GET_FRAG_SIZE(b);
-
- return (IF_HW_TSOMAX_BUILD_VALUE(min(a_bytes, b_bytes),
- min(a_frag_count, b_frag_count),
- min(a_frag_size, b_frag_size)));
-}
-
-/*
- * Range check the "if_hw_tsomax" value:
- */
-u_int
-if_hw_tsomax_range_check(u_int a)
-{
- u_int a_bytes = IF_HW_TSOMAX_GET_BYTES(a);
- u_int a_frag_count = IF_HW_TSOMAX_GET_FRAG_COUNT(a);
- u_int a_frag_size = IF_HW_TSOMAX_GET_FRAG_SIZE(a);
-
- /* round down to nearest 4 bytes */
- a_bytes &= 0xFFFC;
-
- /* use default, if zero */
- if (a_bytes == 0)
- a_bytes = IF_HW_TSOMAX_DEFAULT_BYTES;
-
- /* use default, if zero */
- if (a_frag_count == 0)
- a_frag_count = IF_HW_TSOMAX_DEFAULT_FRAG_COUNT;
-
- /* use default, if zero */
- if (a_frag_size == 0)
- a_frag_size = IF_HW_TSOMAX_DEFAULT_FRAG_SIZE;
-
- return (IF_HW_TSOMAX_BUILD_VALUE(a_bytes, a_frag_count, a_frag_size));
-}
-
-/*
* Allocate a struct ifnet and an index for an interface. A layer 2
* common structure will also be allocated if an allocation routine is
* registered for the passed type.
@@ -491,7 +445,6 @@ if_alloc(u_char type)
ifp->if_index = idx;
ifp->if_type = type;
ifp->if_alloctype = type;
- ifp->if_hw_tsomax = IF_HW_TSOMAX_DEFAULT_VALUE();
if (if_com_alloc[type] != NULL) {
ifp->if_l2com = if_com_alloc[type](type, ifp);
if (ifp->if_l2com == NULL) {
@@ -704,9 +657,16 @@ if_attach_internal(struct ifnet *ifp, int vmove)
TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link);
/* Reliably crash if used uninitialized. */
ifp->if_broadcastaddr = NULL;
- /* range check TSO value */
- ifp->if_hw_tsomax =
- if_hw_tsomax_range_check(ifp->if_hw_tsomax);
+
+#if defined(INET) || defined(INET6)
+ /* Initialize to max value. */
+ if (ifp->if_hw_tsomax == 0)
+ ifp->if_hw_tsomax = min(IP_MAXPACKET, 32 * MCLBYTES -
+ (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN));
+ KASSERT(ifp->if_hw_tsomax <= IP_MAXPACKET &&
+ ifp->if_hw_tsomax >= IP_MAXPACKET / 8,
+ ("%s: tsomax outside of range", __func__));
+#endif
}
#ifdef VIMAGE
else {