NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8)



The following reply was made to PR kern/37809; it has been noted by GNATS.

From: Julian Coleman <jdc%coris.org.uk@localhost>
To: Aymeric Vincent <vincent%labri.fr@localhost>
Cc: macallan%netbsd.org@localhost, gnats-bugs%netbsd.org@localhost
Subject: Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple 
Powerbook5,8)
Date: Sat, 19 Jan 2008 22:59:25 +0000

 --6WlEvdN9Dv0WHSBl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi,
 
 > I enclose my full dmesg (with your patch) in case you spot something
 > interesting: most notably (even without your patch), I fall into the
 > category of those adapters for which the second phy is now ruled out
 > due to the stricter test.
 > But this only seems to have an incidence on this MIF register in the
 > old code.
 
 > gem0 at pci2 dev 15 function 0: Apple Computer Intrepid 2 GMAC (rev. 0x00)
 > gem0: interrupting at irq 41
 > ukphy0 at gem0 phy 0: Generic IEEE 802.3u media interface
 > ukphy0: OUI 0x001018, model 0x000d, rev. 3
 > ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 
 > 1000baseT-FDX, auto
 > ukphy1 at gem0 phy 1: Generic IEEE 802.3u media interface
 > ukphy1: OUI 0x604112, model 0x0031, rev. 10
 > ukphy1: 
 > gem0: cannot accommodate MII device ukphy1 at PHY 1, instance 1
 > gem0: using PHY at MDIO_0
 > gem0: Ethernet address 00:14:51:19:93:74, 10KB RX fifo, 4KB TX fifo
 
 That's useful.  It does look like the problem is that we're now selecting the
 wrong PHY.  Can you try the attached patch (instead of the previous), please?
 It should put back the PHY handling behaviour of 1.67.  It's not quite final,
 because it breaks my fibre interface, but it might get the Apple ones working.
 
 There are also some other bugs I'd like to fix when this one is fixed:
  - some odd interaction with ipfilter (see PR 34799)
  - TCP checksums are probably wrong for received traffic on the
    underlying interface when VLAN's are configured
  - the card error counters aren't collected anywhere
 
 Hopefully, I'll not break anything else when I get to those ;-)
 
 Thanks,
 
 J
 
 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/
 
 --6WlEvdN9Dv0WHSBl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="gem.c.diffs"
 
 --- sys/dev/ic/gem.c.dist      2008-01-05 20:27:44.000000000 +0000
 +++ sys/dev/ic/gem.c   2008-01-19 22:52:39.000000000 +0000
 @@ -283,6 +283,8 @@
         * GEM_MIF_CONFIG_MDI0 nor GEM_MIF_CONFIG_MDI1 are set
         * being set, as both are set on Sun X1141A (with SERDES).  So,
         * we rely on our bus attachment setting GEM_SERDES or GEM_SERIAL.
 +       * Also, for Apple variants with 2 PHY's, we prefer the external
 +       * PHY over the internal PHY.
         */
        gem_mifinit(sc);
  
 @@ -320,17 +322,29 @@
                                sc->sc_phys[child->mii_inst] = child->mii_phy;
                        }
  
 -                      if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI0) {
 +                      /*
 +                       * Now select and activate the PHY we will use.
 +                       *
 +                       * The order of preference is External (MDI1),
 +                       * then Internal (MDI0),
 +                       */
 +                      if (sc->sc_phys[1]) {
 +printf("%s: using external PHY\n", sc->sc_dev.dv_xname);
  #ifdef GEM_DEBUG
 -                              aprint_debug("%s: using PHY at MDIO_0\n",
 +                              aprint_debug("%s: using external PHY\n",
                                    sc->sc_dev.dv_xname);
  #endif
 +                              sc->sc_mif_config |= GEM_MIF_CONFIG_PHY_SEL;
                        } else {
 +printf("%s: using internal PHY\n", sc->sc_dev.dv_xname);
  #ifdef GEM_DEBUG
 -                              aprint_debug("%s: using PHY at MDIO_1\n",
 +                              aprint_debug("%s: using internal PHY\n",
                                    sc->sc_dev.dv_xname);
 +                              sc->sc_mif_config &= ~GEM_MIF_CONFIG_PHY_SEL;
  #endif
                        }
 +                      bus_space_write_4(t, h, GEM_MIF_CONFIG,
 +                          sc->sc_mif_config);
                        if (sc->sc_variant != GEM_SUN_ERI)
                                bus_space_write_4(t, h, GEM_MII_DATAPATH_MODE,
                                    GEM_MII_DATAPATH_MII);
 @@ -1233,10 +1247,16 @@
        /*
         * Enable MII outputs.  Enable GMII if there is a gigabit PHY.
         */
 +      sc->sc_mif_config = bus_space_read_4(t, h, GEM_MIF_CONFIG);
        v = GEM_MAC_XIF_TX_MII_ENA;
 -      if (sc->sc_flags & GEM_GIGABIT)
 -              v |= GEM_MAC_XIF_GMII_MODE;
 -      bus_space_write_4(t, h, GEM_MAC_XIF_CONFIG, v);
 +      if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0) {
 +              if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) {
 +                      v |= GEM_MAC_XIF_FDPLX_LED;
 +                      if (sc->sc_flags & GEM_GIGABIT)
 +                              v |= GEM_MAC_XIF_GMII_MODE;
 +              }
 +              bus_space_write_4(t, h, GEM_MAC_XIF_CONFIG, v);
 +      }
  }
  
  #ifdef GEM_DEBUG
 @@ -2303,16 +2323,10 @@
        else
                sc->sc_flags &= ~GEM_LINK;
  
 -      switch (IFM_SUBTYPE(sc->sc_mii.mii_media_active)) {
 -      case IFM_1000_SX:
 -      case IFM_1000_LX:
 -      case IFM_1000_CX:
 -      case IFM_1000_T:
 +      if (sc->sc_ethercom.ec_if.if_baudrate == IF_Mbps(1000))
                gigabit = 1;
 -              break;
 -      default:
 +      else
                gigabit = 0;
 -      }
  
        /*
         * The configuration done here corresponds to the steps F) and
 @@ -2363,17 +2377,29 @@
        else
                v = 0;
        v |= GEM_MAC_XIF_TX_MII_ENA;
 -      if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) & IFM_FDX) == 0) {
 -              /* MII/GMII needs echo disable if half duplex. */
 -              if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0)
 -                      v |= GEM_MAC_XIF_ECHO_DISABL;
 -              v &= ~GEM_MAC_XIF_FDPLX_LED;
 -      } else {
 -              v |= GEM_MAC_XIF_MII_BUF_ENA;
 -              v |= GEM_MAC_XIF_FDPLX_LED;
 +
 +      /* If an external transceiver is connected, enable its MII drivers */
 +      sc->sc_mif_config = bus_space_read_4(t, mac, GEM_MIF_CONFIG);
 +      if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0) {
 +              if ((sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) != 0) {
 +                      /* External MII needs echo disable if half duplex. */
 +                      if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) &
 +                          IFM_FDX) != 0)
 +                              /* turn on full duplex LED */
 +                              v |= GEM_MAC_XIF_FDPLX_LED;
 +                      else
 +                              /* half duplex -- disable echo */
 +                              v |= GEM_MAC_XIF_ECHO_DISABL;
 +                      if (gigabit)
 +                              v |= GEM_MAC_XIF_GMII_MODE;
 +                      else
 +                              v &= ~GEM_MAC_XIF_GMII_MODE;
 +              } else
 +                      /* Internal MII needs buf enable */
 +                      v |= GEM_MAC_XIF_MII_BUF_ENA;
 +              bus_space_write_4(t, mac, GEM_MAC_XIF_CONFIG, v);
        }
 -      if (gigabit != 0)
 -              v |= GEM_MAC_XIF_GMII_MODE;
 +
        if ((ifp->if_flags & IFF_RUNNING) != 0 &&
            (sc->sc_flags & GEM_LINK) != 0) {
                bus_space_write_4(t, mac, GEM_MAC_TX_CONFIG,
 
 --6WlEvdN9Dv0WHSBl--
 



Home | Main Index | Thread Index | Old Index