+ mii_status = mdio_read(dev, vp->phys[0], MII_BMSR);
+ if (!(mii_status & BMSR_LSTATUS)) {
+ /* Re-read to get actual link status */
+ mii_status = mdio_read(dev, vp->phys[0], MII_BMSR);
+ }
+ ok = 1;
+ if (vortex_debug > 2)
+ printk(KERN_DEBUG "%s: MII transceiver has status %4.4x.\n",
+ dev->name, mii_status);
+ if (mii_status & BMSR_LSTATUS) {
+ int mii_reg5 = mdio_read(dev, vp->phys[0], MII_LPA);
+ if (! vp->force_fd && mii_reg5 != 0xffff) {
+ int duplex;
+
+ mii_reg5 &= vp->advertising;
+ duplex = (mii_reg5&0x0100) || (mii_reg5 & 0x01C0) == 0x0040;
+ if (vp->full_duplex != duplex) {
+ vp->full_duplex = duplex;
+ printk(KERN_INFO "%s: Setting %s-duplex based on MII "
+ "#%d link partner capability of %4.4x.\n",
+ dev->name, vp->full_duplex ? "full" : "half",
+ vp->phys[0], mii_reg5);
+ /* Set the full-duplex bit. */
+ EL3WINDOW(3);
+ iowrite16( (vp->full_duplex ? 0x20 : 0) |
+ (vp->large_frames ? 0x40 : 0) |
+ ((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0),
+ ioaddr + Wn3_MAC_Ctrl);
+ if (vortex_debug > 1)
+ printk(KERN_DEBUG "Setting duplex in Wn3_MAC_Ctrl\n");
+ /* AKPM: bug: should reset Tx and Rx after setting Duplex. Page 180 */
+ }
+ }
+ netif_carrier_on(dev);
+ } else {
+ netif_carrier_off(dev);
+ }