From owner-freebsd-net@FreeBSD.ORG Wed Nov 2 02:07:09 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3ACFE106564A for ; Wed, 2 Nov 2011 02:07:09 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id AF6FD8FC15 for ; Wed, 2 Nov 2011 02:07:08 +0000 (UTC) Received: by wyg36 with SMTP id 36so1263830wyg.13 for ; Tue, 01 Nov 2011 19:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=XChjSS9d0Su4u5eNAIEjgR7ELH2WiOtbqLAp++pd/Mc=; b=wF1Fs1OK6Qzj4W8xiTxZh2wCg043W7Sben+OurUoZvmjyqGKKHbA0gDcUKf4mckmqx eEMbJuy1JyipThYjQMCadC5WJAqipMR0+QUQbSijHet/kueeBaJspfJJ/5cbC+KlOm1Z r/0zGNDzZEGTt5VdcvSFrcnbI8JgcWm7U5VmQ= Received: by 10.216.131.215 with SMTP id m65mr688884wei.5.1320199627535; Tue, 01 Nov 2011 19:07:07 -0700 (PDT) Received: from pyunyh@gmail.com ([174.35.1.224]) by mx.google.com with ESMTPS id es5sm1458656wbb.11.2011.11.01.19.07.03 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 01 Nov 2011 19:07:05 -0700 (PDT) Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Tue, 01 Nov 2011 19:05:32 -0700 From: YongHyeon PYUN Date: Tue, 1 Nov 2011 19:05:32 -0700 To: Andrey Smagin Message-ID: <20111102020532.GF6914@michelle.cdnetworks.com> References: <20111031005519.GC1679@michelle.cdnetworks.com> <20111101180135.GD6914@michelle.cdnetworks.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="GvXjxJ+pjyke8COw" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20111101180135.GD6914@michelle.cdnetworks.com> User-Agent: Mutt/1.4.2.3i Cc: freebsd-net@freebsd.org Subject: Re: PCI-E VT6130 NIC (if_vge) hang system with gigabit link X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2011 02:07:09 -0000 --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Nov 01, 2011 at 11:01:35AM -0700, YongHyeon PYUN wrote: > On Mon, Oct 31, 2011 at 12:58:29PM +0400, Andrey Smagin wrote: > > > > > > > > 31 октября 2011, 04:56 от YongHyeon PYUN : > > > On Sat, Oct 29, 2011 at 09:57:30AM +0400, Andrey Smagin wrote: > > > > > > > > Ok. With autonegotiation ifconfig show speed 100MBit. > > > > > > And vge(4) work without problems with the resolved speed/duplex > > > of auto-negotiation? > > > > > > > with manual 1000baseT full-duplex settings in dmesg: > > > > vge0: failed to start MII autopoll > > > > vge0: MII read timed out > > > > vge0: failed to start MII autopoll > > > > vge0: link state changed to UP > > > > vge0: MII read timed out > > > > > > [...] > > > > > > Did vge(4) ever work with 1000baseT on your box? > > Hm... I never seen 1000baseT with vge on this box because > > it have only FreeBSD. > > > And why you have to manually configure 1000baseT link? > > With autonegatiation link stand on 100Mbit full-duplex > > > Does link partner(switch) also use auto-negotiation? > > In box also present Intel if_em gigabit and if_nfe gigabit card wich work with > > same cable and partner(switch) at gigabit speed. I only switch connector to if_vge socket. > > > > > > > I should have been more clearer. I wanted to know which previous > FreeBSD release was able to establish a 1000baseT link. > Downshifting feature of IC Plus IP1001 PHY is automatically enabled > which will downshift to 100TX link when 1000baseT link > establishment fails in auto-negotiation process. So can you confirm > there is no cabling issues there? If there is no cabling issue there, please try attached patch and let me know whether the patch makes any difference on you. Thanks. --GvXjxJ+pjyke8COw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="vge.link.diff" Index: sys/dev/vge/if_vge.c =================================================================== --- sys/dev/vge/if_vge.c (revision 227010) +++ sys/dev/vge/if_vge.c (working copy) @@ -173,6 +173,7 @@ static void vge_freebufs(struct vge_softc *); static void vge_ifmedia_sts(struct ifnet *, struct ifmediareq *); static int vge_ifmedia_upd(struct ifnet *); +static int vge_ifmedia_upd_locked(struct vge_softc *); static void vge_init(void *); static void vge_init_locked(struct vge_softc *); static void vge_intr(void *); @@ -180,7 +181,6 @@ static int vge_ioctl(struct ifnet *, u_long, caddr_t); static void vge_link_statchg(void *); static int vge_miibus_readreg(device_t, int, int); -static void vge_miibus_statchg(device_t); static int vge_miibus_writereg(device_t, int, int, int); static void vge_miipoll_start(struct vge_softc *); static void vge_miipoll_stop(struct vge_softc *); @@ -190,6 +190,7 @@ static int vge_rx_list_init(struct vge_softc *); static int vge_rxeof(struct vge_softc *, int); static void vge_rxfilter(struct vge_softc *); +static void vge_setmedia(struct vge_softc *); static void vge_setvlan(struct vge_softc *); static void vge_setwol(struct vge_softc *); static void vge_start(struct ifnet *); @@ -218,7 +219,6 @@ /* MII interface */ DEVMETHOD(miibus_readreg, vge_miibus_readreg), DEVMETHOD(miibus_writereg, vge_miibus_writereg), - DEVMETHOD(miibus_statchg, vge_miibus_statchg), { 0, 0 } }; @@ -1102,7 +1102,7 @@ /* Do MII setup */ error = mii_attach(dev, &sc->vge_miibus, ifp, vge_ifmedia_upd, vge_ifmedia_sts, BMSR_DEFCAPMASK, sc->vge_phyaddr, MII_OFFSET_ANY, - 0); + MIIF_DOPAUSE); if (error != 0) { device_printf(dev, "attaching PHYs failed\n"); goto fail; @@ -1660,30 +1660,41 @@ { struct vge_softc *sc; struct ifnet *ifp; - struct mii_data *mii; + uint8_t physts; sc = xsc; ifp = sc->vge_ifp; VGE_LOCK_ASSERT(sc); - mii = device_get_softc(sc->vge_miibus); - mii_pollstat(mii); - if ((sc->vge_flags & VGE_FLAG_LINK) != 0) { - if (!(mii->mii_media_status & IFM_ACTIVE)) { + physts = CSR_READ_1(sc, VGE_PHYSTS0); + if ((physts & VGE_PHYSTS_RESETSTS) == 0) { + if ((physts & VGE_PHYSTS_LINK) == 0) { sc->vge_flags &= ~VGE_FLAG_LINK; if_link_state_change(sc->vge_ifp, LINK_STATE_DOWN); - } - } else { - if (mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { + } else { sc->vge_flags |= VGE_FLAG_LINK; if_link_state_change(sc->vge_ifp, LINK_STATE_UP); + CSR_WRITE_1(sc, VGE_CRC2, VGE_CR2_FDX_TXFLOWCTL_ENABLE | + VGE_CR2_FDX_RXFLOWCTL_ENABLE); + if ((physts & VGE_PHYSTS_FDX) != 0) { + if ((physts & VGE_PHYSTS_TXFLOWCAP) != 0) + CSR_WRITE_1(sc, VGE_CRS2, + VGE_CR2_FDX_TXFLOWCTL_ENABLE); + if ((physts & VGE_PHYSTS_RXFLOWCAP) != 0) + CSR_WRITE_1(sc, VGE_CRS2, + VGE_CR2_FDX_RXFLOWCTL_ENABLE); + } if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) vge_start_locked(ifp); } } + /* + * Restart MII auto-polling because link state change interrupt + * will disable it. + */ + vge_miipoll_start(sc); } #ifdef DEVICE_POLLING @@ -2099,10 +2110,17 @@ vge_rxfilter(sc); vge_setvlan(sc); - /* Enable flow control */ + /* Initialize pause timer. */ + CSR_WRITE_2(sc, VGE_TX_PAUSE_TIMER, 0xFFFF); + /* + * Initialize flow control parameters. + * TX XON high threshold : 48 + * TX pause low threshold : 24 + * Disable hald-duplex flow control + */ + CSR_WRITE_1(sc, VGE_CRC2, 0xFF); + CSR_WRITE_1(sc, VGE_CRS2, VGE_CR2_XON_ENABLE | 0x0B); - CSR_WRITE_1(sc, VGE_CRS2, 0x8B); - /* Enable jumbo frame reception (if desired) */ /* Start the MAC. */ @@ -2129,7 +2147,7 @@ CSR_WRITE_1(sc, VGE_CRS3, VGE_CR3_INT_GMSK); sc->vge_flags &= ~VGE_FLAG_LINK; - mii_mediachg(mii); + vge_ifmedia_upd_locked(sc); ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -2143,14 +2161,28 @@ vge_ifmedia_upd(struct ifnet *ifp) { struct vge_softc *sc; - struct mii_data *mii; int error; sc = ifp->if_softc; VGE_LOCK(sc); + error = vge_ifmedia_upd_locked(sc); + VGE_UNLOCK(sc); + + return (error); +} + +static int +vge_ifmedia_upd_locked(struct vge_softc *sc) +{ + struct mii_data *mii; + struct mii_softc *miisc; + int error; + mii = device_get_softc(sc->vge_miibus); + LIST_FOREACH(miisc, &mii->mii_phys, mii_list) + PHY_RESET(miisc); + vge_setmedia(sc); error = mii_mediachg(mii); - VGE_UNLOCK(sc); return (error); } @@ -2179,13 +2211,11 @@ } static void -vge_miibus_statchg(device_t dev) +vge_setmedia(struct vge_softc *sc) { - struct vge_softc *sc; struct mii_data *mii; struct ifmedia_entry *ife; - sc = device_get_softc(dev); mii = device_get_softc(sc->vge_miibus); ife = mii->mii_media.ifm_cur; @@ -2219,7 +2249,7 @@ } break; default: - device_printf(dev, "unknown media type: %x\n", + device_printf(sc->vge_dev, "unknown media type: %x\n", IFM_SUBTYPE(ife->ifm_media)); break; } @@ -2772,6 +2802,9 @@ break; } } + /* Clear forced MAC speed/duplex configuration. */ + CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE); + CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE); vge_miibus_writereg(sc->vge_dev, sc->vge_phyaddr, MII_100T2CR, 0); vge_miibus_writereg(sc->vge_dev, sc->vge_phyaddr, MII_ANAR, ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10 | ANAR_CSMA); --GvXjxJ+pjyke8COw--