From owner-freebsd-net@FreeBSD.ORG Sat Feb 25 05:21:33 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 76B02106566B for ; Sat, 25 Feb 2012 05:21:33 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3D4668FC0C for ; Sat, 25 Feb 2012 05:21:32 +0000 (UTC) Received: by pbcxa7 with SMTP id xa7so3662482pbc.13 for ; Fri, 24 Feb 2012 21:21:32 -0800 (PST) Received-SPF: pass (google.com: domain of pyunyh@gmail.com designates 10.68.240.100 as permitted sender) client-ip=10.68.240.100; Authentication-Results: mr.google.com; spf=pass (google.com: domain of pyunyh@gmail.com designates 10.68.240.100 as permitted sender) smtp.mail=pyunyh@gmail.com; dkim=pass header.i=pyunyh@gmail.com Received: from mr.google.com ([10.68.240.100]) by 10.68.240.100 with SMTP id vz4mr15529920pbc.78.1330147292840 (num_hops = 1); Fri, 24 Feb 2012 21:21:32 -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=hrqmzbYqGiPmzk5wpboP9RU0mJ3w2xkEQn6s5sP3ZXQ=; b=lhll3vmCimeUtkBVJpNwJ8QkwMYP82hlwbyzdmUi6PRofiA3ztWpOESeFvEAdaTclP H9PeISn0PC94F8LyOpvO7xCflxLsZdthvmg/AvBbFUCmKBn8XI2wAibf5CtaDGZICDXd TG4RlmsnICxRBdWMSJ7fZWG4zsG/4vA2V5NwM= Received: by 10.68.240.100 with SMTP id vz4mr12827115pbc.78.1330147292764; Fri, 24 Feb 2012 21:21:32 -0800 (PST) Received: from pyunyh@gmail.com ([114.111.62.249]) by mx.google.com with ESMTPS id y9sm6282729pbi.3.2012.02.24.21.21.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Feb 2012 21:21:32 -0800 (PST) Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Sat, 25 Feb 2012 14:21:26 -0800 From: YongHyeon PYUN Date: Sat, 25 Feb 2012 14:21:26 -0800 To: Nugroho Atmotaruno Message-ID: <20120225222126.GB3718@michelle.cdnetworks.com> References: <20120224044000.GF13815@michelle.cdnetworks.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dTy3Mrz/UPE2dbVg" 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: Sat, 25 Feb 2012 05:21:33 -0000 --dTy3Mrz/UPE2dbVg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 24, 2012 at 08:04:24PM +0700, Nugroho Atmotaruno wrote: > On Fri, Feb 24, 2012 at 10:56 AM, Nugroho Atmotaruno > wrote: > > > > Hi Pyun, > > > > I patched my machine last night, but the problem is still there. > > > > [nugroho@xtreme ~]$ uname -a > > FreeBSD xtreme.arc.itb.ac.id 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Thu > > Feb 23 21:44:02 WIT 2012 > > nugroho@xtreme.arc.itb.ac.id:/sys/amd64/compile/GENERIC ??amd64 > > > > [nugroho@xtreme ~]$ tail /var/log/messages > > Feb 24 10:42:49 xtreme kernel: re0: link state changed to DOWN > > Feb 24 10:42:52 xtreme kernel: re0: link state changed to UP > > Feb 24 10:42:53 xtreme kernel: re0: link state changed to DOWN > > Feb 24 10:42:55 xtreme kernel: re0: link state changed to UP > > Feb 24 10:42:56 xtreme kernel: re0: link state changed to DOWN > > Feb 24 10:43:02 xtreme kernel: re0: link state changed to UP > > Feb 24 10:43:03 xtreme kernel: re0: link state changed to DOWN > > Feb 24 10:43:06 xtreme kernel: re0: link state changed to UP > > Feb 24 10:49:16 xtreme kernel: re0: link state changed to DOWN > > Feb 24 10:49:19 xtreme kernel: re0: link state changed to UP > > > > After repatching, and recompiling my kernel, i got kernel panic. I > don't know why but I didn't get kernel crash dump. I took a screenshot > here[1]. > > [1] http://i.imgur.com/8NIwS.jpg Oops, back out previous patch and try this one. --dTy3Mrz/UPE2dbVg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rgephy.re.diff2" 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. */ --dTy3Mrz/UPE2dbVg--