- Don't claim 7422 MTU size is support by various 8111/8169 chips (PCI devices);
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 18 Oct 2008 11:26:52 +0000 (11:26 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 18 Oct 2008 11:26:52 +0000 (11:26 +0000)
  6144 MTU size works reliably.
    Set MTU above 6144 (6 * 1024) on these chips and do following test:
    netperf -H host -l 30 -t UDP_STREAM -- -m (mtu-28)
    All kinds of wiredness will pop up on the test box.
- Set max supported MTU to 9216 for 8168D.
  Obtained-from: Realtek r8168-8.008.00
- Set max supported MTU to 6144 for non-8168D GigE chips.
- Cleanup jumbo frame/MTU size related macros.

# As usual, 8169(with 88E1000 PHY) does not seem to work well with any jumbo
# frame size

sys/dev/netif/re/if_re.c
sys/dev/netif/re/if_revar.h

index 0ecea3e..54bf0de 100644 (file)
@@ -33,7 +33,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/re/if_re.c,v 1.25 2004/06/09 14:34:01 naddy Exp $
- * $DragonFly: src/sys/dev/netif/re/if_re.c,v 1.88 2008/10/18 04:44:41 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/re/if_re.c,v 1.89 2008/10/18 11:26:52 sephe Exp $
  */
 
 /*
@@ -196,61 +196,61 @@ static const struct re_type {
 };
 
 static const struct re_hwrev re_hwrevs[] = {
-       { RE_HWREV_8139CPLUS,   RE_MACVER_UNKN,
+       { RE_HWREV_8139CPLUS,   RE_MACVER_UNKN,         ETHERMTU,
          RE_C_HWCSUM | RE_C_8139CP },
 
-       { RE_HWREV_8169,        RE_MACVER_UNKN,
-         RE_C_HWCSUM | RE_C_JUMBO | RE_C_8169 },
+       { RE_HWREV_8169,        RE_MACVER_UNKN,         RE_MTU_6K,
+         RE_C_HWCSUM | RE_C_8169 },
 
-       { RE_HWREV_8110S,       RE_MACVER_03,
-         RE_C_HWCSUM | RE_C_JUMBO | RE_C_8169 },
+       { RE_HWREV_8110S,       RE_MACVER_03,           RE_MTU_6K,
+         RE_C_HWCSUM | RE_C_8169 },
 
-       { RE_HWREV_8169S,       RE_MACVER_03,
-         RE_C_HWCSUM | RE_C_JUMBO | RE_C_8169 },
+       { RE_HWREV_8169S,       RE_MACVER_03,           RE_MTU_6K,
+         RE_C_HWCSUM | RE_C_8169 },
 
-       { RE_HWREV_8169SB,      RE_MACVER_04,
-         RE_C_HWCSUM | RE_C_JUMBO | RE_C_PHYPMGT | RE_C_8169 },
+       { RE_HWREV_8169SB,      RE_MACVER_04,           RE_MTU_6K,
+         RE_C_HWCSUM | RE_C_PHYPMGT | RE_C_8169 },
 
-       { RE_HWREV_8169SC1,     RE_MACVER_05,
-         RE_C_HWCSUM | RE_C_JUMBO | RE_C_PHYPMGT | RE_C_8169 },
+       { RE_HWREV_8169SC1,     RE_MACVER_05,           RE_MTU_6K,
+         RE_C_HWCSUM | RE_C_PHYPMGT | RE_C_8169 },
 
-       { RE_HWREV_8169SC2,     RE_MACVER_06,
-         RE_C_HWCSUM | RE_C_JUMBO | RE_C_PHYPMGT | RE_C_8169 },
+       { RE_HWREV_8169SC2,     RE_MACVER_06,           RE_MTU_6K,
+         RE_C_HWCSUM | RE_C_PHYPMGT | RE_C_8169 },
 
-       { RE_HWREV_8168B1,      RE_MACVER_21,
-         RE_C_HWIM | RE_C_HWCSUM | RE_C_JUMBO | RE_C_PHYPMGT },
+       { RE_HWREV_8168B1,      RE_MACVER_21,           RE_MTU_6K,
+         RE_C_HWIM | RE_C_HWCSUM | RE_C_PHYPMGT },
 
-       { RE_HWREV_8168B2,      RE_MACVER_23,
-         RE_C_HWIM | RE_C_HWCSUM | RE_C_JUMBO | RE_C_PHYPMGT | RE_C_AUTOPAD },
+       { RE_HWREV_8168B2,      RE_MACVER_23,           RE_MTU_6K,
+         RE_C_HWIM | RE_C_HWCSUM | RE_C_PHYPMGT | RE_C_AUTOPAD },
 
-       { RE_HWREV_8168B3,      RE_MACVER_23,
-         RE_C_HWIM | RE_C_HWCSUM | RE_C_JUMBO | RE_C_PHYPMGT | RE_C_AUTOPAD },
+       { RE_HWREV_8168B3,      RE_MACVER_23,           RE_MTU_6K,
+         RE_C_HWIM | RE_C_HWCSUM | RE_C_PHYPMGT | RE_C_AUTOPAD },
 
-       { RE_HWREV_8168C,       RE_MACVER_29,
-         RE_C_HWIM | RE_C_HWCSUM | RE_C_JUMBO | RE_C_MAC2 | RE_C_PHYPMGT |
+       { RE_HWREV_8168C,       RE_MACVER_29,           RE_MTU_6K,
+         RE_C_HWIM | RE_C_HWCSUM | RE_C_MAC2 | RE_C_PHYPMGT |
          RE_C_AUTOPAD | RE_C_CONTIGRX },
 
-       { RE_HWREV_8168CP,      RE_MACVER_2B,
-         RE_C_HWIM | RE_C_HWCSUM | RE_C_JUMBO | RE_C_MAC2 | RE_C_PHYPMGT |
+       { RE_HWREV_8168CP,      RE_MACVER_2B,           RE_MTU_6K,
+         RE_C_HWIM | RE_C_HWCSUM | RE_C_MAC2 | RE_C_PHYPMGT |
          RE_C_AUTOPAD | RE_C_CONTIGRX },
 
-       { RE_HWREV_8168D,       RE_MACVER_2A,
-         RE_C_HWIM | RE_C_HWCSUM | RE_C_JUMBO | RE_C_MAC2 | RE_C_PHYPMGT |
+       { RE_HWREV_8168D,       RE_MACVER_2A,           RE_MTU_9K,
+         RE_C_HWIM | RE_C_HWCSUM | RE_C_MAC2 | RE_C_PHYPMGT |
          RE_C_AUTOPAD | RE_C_CONTIGRX },
 
-       { RE_HWREV_8100E,       RE_MACVER_UNKN,
+       { RE_HWREV_8100E,       RE_MACVER_UNKN,         ETHERMTU,
          RE_C_HWCSUM },
 
-       { RE_HWREV_8101E1,      RE_MACVER_16,
+       { RE_HWREV_8101E1,      RE_MACVER_16,           ETHERMTU,
          RE_C_HWCSUM },
 
-       { RE_HWREV_8101E2,      RE_MACVER_16,
+       { RE_HWREV_8101E2,      RE_MACVER_16,           ETHERMTU,
          RE_C_HWCSUM },
 
-       { RE_HWREV_8102E,       RE_MACVER_15,
+       { RE_HWREV_8102E,       RE_MACVER_15,           ETHERMTU,
          RE_C_HWCSUM | RE_C_MAC2 | RE_C_AUTOPAD },
 
-       { RE_HWREV_8102EL,      RE_MACVER_15,
+       { RE_HWREV_8102EL,      RE_MACVER_15,           ETHERMTU,
          RE_C_HWCSUM | RE_C_MAC2 | RE_C_AUTOPAD },
 
        { RE_HWREV_NULL, 0, 0 }
@@ -955,15 +955,8 @@ re_probe(device_t dev)
                        sc->re_hwrev = hw_rev->re_hwrev;
                        sc->re_macver = hw_rev->re_macver;
                        sc->re_caps = hw_rev->re_caps;
-
-                       if (sc->re_caps & RE_C_JUMBO) {
-                               sc->re_swcsum_lim = RE_JUMBO_MTU;
-                               sc->re_maxmtu = RE_JUMBO_MTU;
-                       } else {
-                               sc->re_swcsum_lim = ETHERMTU;
-                               sc->re_maxmtu = ETHERMTU;
-                       }
-                       sc->re_swcsum_lim += ETHER_HDR_LEN;
+                       sc->re_maxmtu = hw_rev->re_maxmtu;
+                       sc->re_swcsum_lim = RE_SWCSUM_UNLIMITED;
 
                        /*
                         * Apply chip property fixup
@@ -1185,7 +1178,7 @@ re_allocmem(device_t dev)
                        ETHER_ALIGN, 0,
                        BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
                        NULL, NULL,
-                       RE_JUMBO_FRAMELEN, RE_MAXSEGS, MCLBYTES,
+                       RE_FRAMELEN_MAX, RE_MAXSEGS, MCLBYTES,
                        BUS_DMA_ALLOCNOW,
                        &sc->re_ldata.re_mtag);
        if (error) {
@@ -1230,6 +1223,7 @@ re_allocmem(device_t dev)
                error = re_jpool_alloc(sc);
                if (error) {
                        re_jpool_free(sc);
+                       /* Disable jumbo frame support */
                        sc->re_maxmtu = ETHERMTU;
                }
        }
@@ -2615,7 +2609,7 @@ re_init(void *xsc)
                if (ifp->if_mtu > ETHERMTU) {
                        KKASSERT(sc->re_ldata.re_jbuf != NULL);
                        sc->re_flags |= RE_F_USE_JPOOL;
-                       sc->re_rxbuf_size = RE_JUMBO_FRAME_9K;
+                       sc->re_rxbuf_size = RE_FRAMELEN_MAX;
                        sc->re_newbuf = re_newbuf_jumbo;
                } else {
                        sc->re_flags &= ~RE_F_USE_JPOOL;
@@ -2710,12 +2704,10 @@ re_init(void *xsc)
                CSR_WRITE_4(sc, RE_TXCFG, RE_TXCFG_CONFIG);
 
        framelen = RE_FRAMELEN(ifp->if_mtu);
-       if (framelen < RE_FRAMELEN_2K) {
-               CSR_WRITE_1(sc, RE_EARLY_TX_THRESH,
-                           howmany(RE_FRAMELEN_2K, 128));
-       } else {
+       if (framelen < MCLBYTES)
+               CSR_WRITE_1(sc, RE_EARLY_TX_THRESH, howmany(MCLBYTES, 128));
+       else
                CSR_WRITE_1(sc, RE_EARLY_TX_THRESH, howmany(framelen, 128));
-       }
 
        CSR_WRITE_4(sc, RE_RXCFG, RE_RXCFG_CONFIG);
 
index 12e3b17..692c919 100644 (file)
@@ -33,7 +33,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/pci/if_rlreg.h,v 1.42 2004/05/24 19:39:23 jhb Exp $
- * $DragonFly: src/sys/dev/netif/re/if_revar.h,v 1.27 2008/10/17 14:12:23 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/re/if_revar.h,v 1.28 2008/10/18 11:26:52 sephe Exp $
  */
 
 #define RE_RX_DESC_CNT_8139CP  64
 #define RE_ADDR_LO(y)          ((uint64_t) (y) & 0xFFFFFFFF)
 #define RE_ADDR_HI(y)          ((uint64_t) (y) >> 32)
 
-#define RE_JUMBO_FRAMELEN      7440
-#define RE_JUMBO_MTU           (RE_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
-#define RE_FRAMELEN_2K         2048
-#define RE_FRAMELEN(mtu)       (mtu + ETHER_HDR_LEN + ETHER_CRC_LEN)
+#define RE_MTU_6K              (6 * 1024)
+#define RE_MTU_9K              (9 * 1024)
+
+#define RE_ETHER_EXTRA         (ETHER_HDR_LEN + ETHER_CRC_LEN + EVL_ENCAPLEN)
+#define RE_FRAMELEN(mtu)       ((mtu) + RE_ETHER_EXTRA)
+
+#define RE_FRAMELEN_6K         RE_FRAMELEN(RE_MTU_6K)
+#define RE_FRAMELEN_9K         RE_FRAMELEN(RE_MTU_9K)
+#define RE_FRAMELEN_MAX                RE_FRAMELEN_9K
+
 #define RE_SWCSUM_LIM_8169     2038
+#define RE_SWCSUM_UNLIMITED    65536   /* XXX should be enough */
 
 #define RE_BUF_ALIGN           8
-#define RE_JUMBO_FRAME_9K      9022
-#define RE_JBUF_SIZE           roundup2(RE_JUMBO_FRAME_9K, RE_BUF_ALIGN)
+#define RE_JBUF_SIZE           roundup2(RE_FRAMELEN_MAX, RE_BUF_ALIGN)
 
 #define        RE_TIMEOUT              1000
 
 struct re_hwrev {
        uint32_t                re_hwrev;
        uint32_t                re_macver;      /* see RE_MACVER_ */
+       int                     re_maxmtu;
        uint32_t                re_caps;        /* see RE_C_ */
 };
 
@@ -210,7 +217,6 @@ struct re_softc {
 #define RE_C_PCI64             0x2     /* PCI-X */
 #define RE_C_HWIM              0x4     /* hardware interrupt moderation */
 #define RE_C_HWCSUM            0x8     /* hardware csum offload */
-#define RE_C_JUMBO             0x10    /* jumbo frame */
 #define RE_C_8139CP            0x20    /* is 8139C+ */
 #define RE_C_MAC2              0x40    /* MAC style 2 */
 #define RE_C_PHYPMGT           0x80    /* PHY supports power mgmt */