From owner-freebsd-net@FreeBSD.ORG Thu Feb 23 11:40:06 2012 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 EEA87106564A for ; Thu, 23 Feb 2012 11:40:06 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-pz0-f54.google.com (mail-pz0-f54.google.com [209.85.210.54]) by mx1.freebsd.org (Postfix) with ESMTP id ABF838FC14 for ; Thu, 23 Feb 2012 11:40:06 +0000 (UTC) Received: by daec6 with SMTP id c6so1292116dae.13 for ; Thu, 23 Feb 2012 03:40:06 -0800 (PST) Received-SPF: pass (google.com: domain of pyunyh@gmail.com designates 10.68.194.230 as permitted sender) client-ip=10.68.194.230; Authentication-Results: mr.google.com; spf=pass (google.com: domain of pyunyh@gmail.com designates 10.68.194.230 as permitted sender) smtp.mail=pyunyh@gmail.com; dkim=pass header.i=pyunyh@gmail.com Received: from mr.google.com ([10.68.194.230]) by 10.68.194.230 with SMTP id hz6mr3182201pbc.24.1329997206425 (num_hops = 1); Thu, 23 Feb 2012 03:40:06 -0800 (PST) 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:in-reply-to:user-agent; bh=rAxTE/JSFUGlxkk0CDjdzXkjm0IW7lltM9keGIfZWFQ=; b=NXEt8boTP0TSuS1ZtRmLJOdrsOOfJZGTpUW0Bk2riB+Wqwpktwk37d6t1V0XR2ch5H QyPMUnoW3iB5J//nIOYZ7Pf4TfOLwt1QKAUjHNfWSaynJQ6238loUcqDGHBCLNOILBH4 0BOryUM0D6MF8w8aJ5effMnDxe9gzerOXtyac= Received: by 10.68.194.230 with SMTP id hz6mr2679168pbc.24.1329997206366; Thu, 23 Feb 2012 03:40:06 -0800 (PST) Received: from pyunyh@gmail.com ([114.111.62.249]) by mx.google.com with ESMTPS id w8sm1285666pbo.23.2012.02.23.03.40.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 23 Feb 2012 03:40:05 -0800 (PST) Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Thu, 23 Feb 2012 20:40:00 -0800 From: YongHyeon PYUN Date: Thu, 23 Feb 2012 20:40:00 -0800 To: Nugroho Atmotaruno Message-ID: <20120224044000.GF13815@michelle.cdnetworks.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="bCsyhTFzCvuiizWE" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: freebsd-net@freebsd.org Subject: Re: re(4) intermittent up/down 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: Thu, 23 Feb 2012 11:40:07 -0000 --bCsyhTFzCvuiizWE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 23, 2012 at 04:57:27AM +0700, Nugroho Atmotaruno wrote: > Hi all, > > I'm using FBSD 9.0-RELEASE with TPLink TG-3268 (rl8169) flapping > (UP/DOWN every several seconds). > > [nugroho@xtreme ~]$ uname -a > FreeBSD xtreme.arc.itb.ac.id 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 > > [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 > > [root@xtreme ~]# ifconfig re0 > re0: flags=8843 metric 0 mtu 1500 > options=389b > ether f8:d1:11:04:15:d6 > inet 167.205.3.4 netmask 0xffffff80 broadcast 167.205.3.127 > inet6 fe80::fad1:11ff:fe04:15d6%re0 prefixlen 64 scopeid 0x7 > inet6 2403:8000:1:1880::4 prefixlen 64 > nd6 options=21 > media: Ethernet autoselect (1000baseT ) > status: active > Would you try attached patch? --bCsyhTFzCvuiizWE Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="rgephy.re.diff" Index: sys/dev/mii/rgephy.c =================================================================== --- sys/dev/mii/rgephy.c (revision 232042) +++ 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) { --bCsyhTFzCvuiizWE--