Use extended interface FIFO depth to workaround CRC errors emitted by
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 13 Sep 2008 04:04:39 +0000 (04:04 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 13 Sep 2008 04:04:39 +0000 (04:04 +0000)
JMC250 chips before rev.B

Information provided by Ethan <ethanhsiao@jmicron.com>

sys/dev/netif/jme/if_jme.c
sys/dev/netif/jme/if_jmevar.h
sys/dev/netif/mii_layer/jmphyreg.h

index 22f64f9..d913d91 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/jme/if_jme.c,v 1.2 2008/07/18 04:20:48 yongari Exp $
- * $DragonFly: src/sys/dev/netif/jme/if_jme.c,v 1.6 2008/09/13 03:12:23 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/jme/if_jme.c,v 1.7 2008/09/13 04:04:39 sephe Exp $
  */
 
 #include "opt_ethernet.h"
@@ -54,6 +54,7 @@
 #include <net/vlan/if_vlan_ether.h>
 
 #include <dev/netif/mii_layer/miivar.h>
+#include <dev/netif/mii_layer/jmphyreg.h>
 
 #include <bus/pci/pcireg.h>
 #include <bus/pci/pcivar.h>
@@ -427,6 +428,10 @@ jme_probe(device_t dev)
                        struct jme_softc *sc = device_get_softc(dev);
 
                        sc->jme_caps = sp->jme_caps;
+                       if (did == PCI_PRODUCT_JMICRON_JMC250 &&
+                           pci_get_revid(dev) == JME_REV_JMC250_A2)
+                               sc->jme_caps |= JME_CAP_EXTFIFO;
+
                        device_set_desc(dev, sp->jme_name);
                        return (0);
                }
@@ -748,8 +753,10 @@ jme_attach(device_t dev)
                                device_printf(sc->jme_dev,
                                    "FPGA PHY is at %d\n", sc->jme_phyaddr);
                                /* vendor magic. */
-                               jme_miibus_writereg(dev, sc->jme_phyaddr, 27,
-                                   0x0004);
+                               jme_miibus_writereg(dev, sc->jme_phyaddr,
+                                   JMPHY_CONF, JMPHY_CONF_DEFFIFO);
+
+                               /* XXX should we clear JME_CAP_EXTFIFO */
                        }
                }
        }
@@ -1827,6 +1834,7 @@ jme_mac_config(struct jme_softc *sc)
 {
        struct mii_data *mii;
        uint32_t ghc, rxmac, txmac, txpause;
+       int phyconf = JMPHY_CONF_DEFFIFO;
 
        mii = device_get_softc(sc->jme_miibus);
 
@@ -1868,16 +1876,26 @@ jme_mac_config(struct jme_softc *sc)
        case IFM_10_T:
                ghc |= GHC_SPEED_10;
                break;
+
        case IFM_100_TX:
                ghc |= GHC_SPEED_100;
+
+               /*
+                * Use extended FIFO depth to workaround CRC errors
+                * emitted by chips before JMC250B
+                */
+               phyconf = JMPHY_CONF_EXTFIFO;
                break;
+
        case IFM_1000_T:
                if (sc->jme_caps & JME_CAP_FASTETH)
                        break;
+
                ghc |= GHC_SPEED_1000;
                if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) == 0)
                        txmac |= TXMAC_CARRIER_EXT | TXMAC_FRAME_BURST;
                break;
+
        default:
                break;
        }
@@ -1885,6 +1903,11 @@ jme_mac_config(struct jme_softc *sc)
        CSR_WRITE_4(sc, JME_RXMAC, rxmac);
        CSR_WRITE_4(sc, JME_TXMAC, txmac);
        CSR_WRITE_4(sc, JME_TXPFC, txpause);
+
+       if (sc->jme_caps & JME_CAP_EXTFIFO) {
+               jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr,
+                                   JMPHY_CONF, phyconf);
+       }
 }
 
 static void
index 7387876..a5fd992 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/jme/if_jmevar.h,v 1.1 2008/05/27 01:42:01 yongari Exp $
- * $DragonFly: src/sys/dev/netif/jme/if_jmevar.h,v 1.3 2008/09/13 03:12:23 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/jme/if_jmevar.h,v 1.4 2008/09/13 04:04:39 sephe Exp $
  */
 
 #ifndef        _IF_JMEVAR_H
@@ -188,6 +188,7 @@ struct jme_softc {
 #define        JME_CAP_PMCAP           0x0004
 #define        JME_CAP_FASTETH         0x0008
 #define        JME_CAP_JUMBO           0x0010
+#define JME_CAP_EXTFIFO                0x0020
 
        uint32_t                jme_flags;
 #define        JME_FLAG_MSI            0x0001
index e1f69de..333d9b4 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/mii/jmphyreg.h,v 1.1 2008/05/27 01:16:40 yongari Exp $
- * $DragonFly: src/sys/dev/netif/mii_layer/jmphyreg.h,v 1.1 2008/07/22 11:28:49 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/mii_layer/jmphyreg.h,v 1.2 2008/09/13 04:04:39 sephe Exp $
  */
 
 #ifndef        _DEV_MII_JMPHYREG_H_
 #define        JMPHY_TMCTL                     0x1A
 #define        JMPHY_TMCTL_SLEEP_ENB           0x1000
 
+/* PHY specific configuration */
+#define JMPHY_CONF                     0x1B
+#define JMPHY_CONF_EXTFIFO             0x0000 /* use extended fifo */
+#define JMPHY_CONF_DEFFIFO             0x0004 /* use default fifo */
+
 #endif /* _DEV_MII_JMPHYREG_H_ */