Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Feb 2012 21:59:05 GMT
From:      Nugroho Atmotaruno <atmotaruno@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/165509: re(4) intermittently UP/DOWN on TPLink TG-3268
Message-ID:  <201202272159.q1RLx5lD071771@red.freebsd.org>
Resent-Message-ID: <201202272200.q1RM0WmE001961@freefall.freebsd.org>

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

>Number:         165509
>Category:       kern
>Synopsis:       re(4) intermittently UP/DOWN on TPLink TG-3268
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 27 22:00:32 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Nugroho Atmotaruno
>Release:        FreeBSD 9.0 -RELEASE
>Organization:
ARC ITB
>Environment:
FreeBSD 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64

>Description:
TPLink TG-3268 (rl8169) flapping (UP/DOWN every several seconds).

[root@xtreme ~]# tail /var/log/messages
Feb 23 04:47:05 xtreme kernel: re0: link state changed to UP
Feb 23 04:47:07 xtreme kernel: re0: link state changed to DOWN
Feb 23 04:47:10 xtreme kernel: re0: link state changed to UP
Feb 23 04:47:16 xtreme kernel: re0: link state changed to DOWN
Feb 23 04:47:19 xtreme kernel: re0: link state changed to UP
Feb 23 04:47:20 xtreme kernel: re0: link state changed to DOWN
Feb 23 04:47:23 xtreme kernel: re0: link state changed to UP
Feb 23 04:48:44 xtreme kernel: re0: link state changed to DOWN
Feb 23 04:48:47 xtreme kernel: re0: link state changed to UP


[root@xtreme ~]# pciconf -lcv
re0@pci0:2:5:0: class=0x020000 card=0x816910ec chip=0x816910ec rev=0x10 hdr=0x00
   vendor     = 'Realtek Semiconductor Co., Ltd.'
   device     = 'RTL-8169 Gigabit Ethernet'
   class      = network
   subclass   = ethernet
   cap 01[dc] = powerspec 2  supports D0 D1 D2 D3  current D0

[root@xtreme ~]# devinfo -rv | grep rg
rgephy0 pnpinfo oui=0xe04c model=0x11 rev=0x3 at phyno=1
>How-To-Repeat:

>Fix:
YongHyeon PYUN sent following patch.

Patch attached with submission follows:

Index: sys/dev/mii/rgephy.c
===================================================================
--- sys/dev/mii/rgephy.c	(revision 232144)
+++ sys/dev/mii/rgephy.c	(working copy)
@@ -110,11 +110,16 @@
 rgephy_attach(device_t dev)
 {
 	struct mii_softc *sc;
+	struct mii_attach_args *ma;
+	u_int flags;
 
 	sc = device_get_softc(dev);
+	ma = device_get_ivars(dev);
+	flags = 0;
+	if (strcmp(ma->mii_data->mii_ifp->if_dname, "re") == 0)
+		flags |= MIIF_PHYPRIV0;
+	mii_phy_dev_attach(dev, flags, &rgephy_funcs, 0);
 
-	mii_phy_dev_attach(dev, 0, &rgephy_funcs, 0);
-
 	/* RTL8169S do not report auto-sense; add manually. */
 	sc->mii_capabilities = (PHY_READ(sc, MII_BMSR) | BMSR_ANEG) &
 	    sc->mii_capmask;
@@ -243,7 +248,8 @@
 		 * Check to see if we have link.  If we do, we don't
 		 * need to restart the autonegotiation process.
 		 */
-		if (sc->mii_mpd_rev >= 2) {
+		if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 &&
+		    sc->mii_mpd_rev >= 2) {
 			/* RTL8211B(L) */
 			reg = PHY_READ(sc, RGEPHY_MII_SSR);
 			if (reg & RGEPHY_SSR_LINK) {
@@ -298,7 +304,7 @@
 	mii->mii_media_status = IFM_AVALID;
 	mii->mii_media_active = IFM_ETHER;
 
-	if (sc->mii_mpd_rev >= 2) {
+	if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 && sc->mii_mpd_rev >= 2) {
 		ssr = PHY_READ(sc, RGEPHY_MII_SSR);
 		if (ssr & RGEPHY_SSR_LINK)
 			mii->mii_media_status |= IFM_ACTIVE;
@@ -328,7 +334,7 @@
 		}
 	}
 
-	if (sc->mii_mpd_rev >= 2) {
+	if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 && sc->mii_mpd_rev >= 2) {
 		ssr = PHY_READ(sc, RGEPHY_MII_SSR);
 		switch (ssr & RGEPHY_SSR_SPD_MASK) {
 		case RGEPHY_SSR_S1000:
@@ -484,7 +490,7 @@
 {
 	uint16_t ssr;
 
-	if (sc->mii_mpd_rev == 3) {
+	if ((sc->mii_flags & MIIF_PHYPRIV0) == 0 && sc->mii_mpd_rev == 3) {
 		/* RTL8211C(L) */
 		ssr = PHY_READ(sc, RGEPHY_MII_SSR);
 		if ((ssr & RGEPHY_SSR_ALDPS) != 0) {
Index: sys/dev/re/if_re.c
===================================================================
--- sys/dev/re/if_re.c	(revision 232145)
+++ sys/dev/re/if_re.c	(working copy)
@@ -1577,19 +1577,6 @@
 		re_gmii_writereg(dev, 1, 0x0e, 0);
 	}
 
-#define	RE_PHYAD_INTERNAL	 0
-
-	/* Do MII setup. */
-	phy = RE_PHYAD_INTERNAL;
-	if (sc->rl_type == RL_8169)
-		phy = 1;
-	error = mii_attach(dev, &sc->rl_miibus, ifp, re_ifmedia_upd,
-	    re_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, MIIF_DOPAUSE);
-	if (error != 0) {
-		device_printf(dev, "attaching PHYs failed\n");
-		goto fail;
-	}
-
 	ifp->if_softc = sc;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -1614,6 +1601,19 @@
 
 	TASK_INIT(&sc->rl_inttask, 0, re_int_task, sc);
 
+#define	RE_PHYAD_INTERNAL	 0
+
+	/* Do MII setup. */
+	phy = RE_PHYAD_INTERNAL;
+	if (sc->rl_type == RL_8169)
+		phy = 1;
+	error = mii_attach(dev, &sc->rl_miibus, ifp, re_ifmedia_upd,
+	    re_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, MIIF_DOPAUSE);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
+		goto fail;
+	}
+
 	/*
 	 * Call MI attach routine.
 	 */


>Release-Note:
>Audit-Trail:
>Unformatted:



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