Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Nov 2011 19:05:32 -0700
From:      YongHyeon PYUN <pyunyh@gmail.com>
To:        Andrey Smagin <samspeed@mail.ru>
Cc:        freebsd-net@freebsd.org
Subject:   Re: PCI-E VT6130 NIC (if_vge) hang system with gigabit link
Message-ID:  <20111102020532.GF6914@michelle.cdnetworks.com>
In-Reply-To: <20111101180135.GD6914@michelle.cdnetworks.com>
References:  <E1RIaki-0002pq-00.samspeed-mail-ru@f197.mail.ru> <E1RK1v8-0006v8-00.samspeed-mail-ru@f193.mail.ru> <20111031005519.GC1679@michelle.cdnetworks.com> <E1RKnhN-0003rb-00.samspeed-mail-ru@f283.mail.ru> <20111101180135.GD6914@michelle.cdnetworks.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <pyunyh@gmail.com>:
> > > 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111102020532.GF6914>