From owner-freebsd-net@FreeBSD.ORG Wed Apr 1 10:36:32 2009 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E360B10656DB for ; Wed, 1 Apr 2009 10:36:32 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.226]) by mx1.freebsd.org (Postfix) with ESMTP id B21228FC1C for ; Wed, 1 Apr 2009 10:36:32 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by rv-out-0506.google.com with SMTP id l9so3803417rvb.43 for ; Wed, 01 Apr 2009 03:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:from:date:to:cc :subject:message-id:reply-to:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=b8rWJgwky+sggFvSRYa9r8LZAT0GWBSTWHCA1iQNNRI=; b=d/6fWXliieEQJaV4+v1nWbUX9YGbRgpWKIdP95TRbGlp0am4pGIgtA11Cd4tz+TDsr KT42RmssNLz7hMBmXK3gAlULn4tpyF2rFLpNMZL1cYXMRaLjdlaeffK+ArmkDwNc5eTS AI/8E3k/Pl7sPDt8/Dr5u+ZJkdzgENEFJURLk= DomainKey-Signature: a=rsa-sha1; c=nofws; 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; b=n9JcepkSpEoCLUlTgPqdnrcrIRuYdpecPhHjx5p15EqF23o3v981UqQ+bJhfZvau5U OOudtw4MrS2861SOdWiolfpy/ziTxsssvzQL6XS+eTcmK7Puy77Q/gN7MQeAbj8qvRO2 DjEDFVAb+0Rd+ntSd9ndy+KMyh5T14zBd2kfs= Received: by 10.141.33.19 with SMTP id l19mr3956888rvj.209.1238580613270; Wed, 01 Apr 2009 03:10:13 -0700 (PDT) Received: from michelle.cdnetworks.co.kr ([114.111.62.249]) by mx.google.com with ESMTPS id f21sm19656270rvb.5.2009.04.01.03.10.11 (version=SSLv3 cipher=RC4-MD5); Wed, 01 Apr 2009 03:10:12 -0700 (PDT) Received: by michelle.cdnetworks.co.kr (sSMTP sendmail emulation); Wed, 1 Apr 2009 19:09:39 +0900 From: Pyun YongHyeon Date: Wed, 1 Apr 2009 19:09:39 +0900 To: "M. Warner Losh" Message-ID: <20090401100939.GB12246@michelle.cdnetworks.co.kr> References: <20090401.013246.-1253043078.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090401.013246.-1253043078.imp@bsdimp.com> User-Agent: Mutt/1.4.2.3i Cc: net@freebsd.org Subject: Re: Small change to ukphy 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, 01 Apr 2009 10:36:33 -0000 On Wed, Apr 01, 2009 at 01:32:46AM -0600, M. Warner Losh wrote: > I've encountered a number of PHY chips that need auto negotiation > kicked off to come out of ISO state. This makes sense, because the > ukphy driver never seems to take the PHY out of isolation state > otherwise. > > Index: ukphy.c > =================================================================== > --- ukphy.c (revision 190463) > +++ ukphy.c (working copy) > @@ -146,6 +146,7 @@ > sc->mii_phy = ma->mii_phyno; > sc->mii_service = ukphy_service; > sc->mii_pdata = mii; > + sc->mii_flags |= MIIF_FORCEANEG; > > mii->mii_instance++; > > > This forces auto negotiation. The reason for this is that it takes it > out of ISO state (Isolate). Once out of that state, things work If the purpose is to take PHY out of isolated state couldn't this be handled in ifm_change_cb_t handler of parent interface? I guess the callback can reset the PHY and subsequent mii_mediachg() call may start auto-negotiation. > well. The question I have is will we properly go back into ISO state > for PHYs that should be isolated. > If the PHY requires special handing for ISO state in reset it may need separated PHY driver as ukphy(4) does not set MIIF_NOISOLATE. As you said it would be really great if we have a generic way to pass various MII flags or driver specific information to mii(4). > NetBSD has many of its NIC drivers setting this flag. Their APIs > allow them to set this directly at mii attach time. Ours don't, so > none of our drivers set this flag. > > The other fix for this might be: > Index: mii_physubr.c > =================================================================== > --- mii_physubr.c (revision 190463) > +++ mii_physubr.c (working copy) > @@ -113,7 +113,9 @@ > int bmcr, anar, gtcr; > > if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { > - if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0 || > + bmcr = PHY_READ(sc, MII_BMCR); > + if ((bmcr & BMCR_AUTOEN) == 0 || > + (bmcr & BMCR_ISO) || > (sc->mii_flags & MIIF_FORCEANEG)) > (void) mii_phy_auto(sc); > return; > > Which says that if auto negotiation is enabled, and ISO is set to go > ahead and kick off an auto negotiation. I'm less sure of this path, > but it is an alternative. Otherwise, we never write to the BMCR to > take the device out of isolation. If there's a better place to do > this, then I'm all ears. > > Either one of these hacks make several PC Cards that I have start to > work... In fact, I'm starting to approach 100% (up from 50%) of my > ed-based PC Cards working with this simple change (and others to the > ed driver). I know that these cards are a little behind the leading > edge, but I'd like to get them working since I've put a few hours into > investigating things here. > > Comments? > > Warner