From owner-freebsd-hackers@FreeBSD.ORG Wed May 11 00:42:19 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B65A8106564A for ; Wed, 11 May 2011 00:42:19 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 6A05D8FC08 for ; Wed, 11 May 2011 00:42:19 +0000 (UTC) Received: from [192.168.14.163] ([24.114.252.233]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p4B0bg7g034687 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Tue, 10 May 2011 18:37:45 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: Date: Tue, 10 May 2011 11:01:49 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <9B3FEB02-B71C-412B-BB7E-31A236021CDD@bsdimp.com> References: <34CF3ED0-52BC-4D0E-922A-FE26F624E77F@gmail.com> <20110508131643.GA23650@alchemy.franken.de> To: Damjan Marion X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Tue, 10 May 2011 18:37:46 -0600 (MDT) Cc: freebsd-hackers@freebsd.org, Marius Strobl Subject: Re: Embedded switch instead of stadard PHY X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2011 00:42:19 -0000 On May 8, 2011, at 7:52 AM, Damjan Marion wrote > On May 8, 2011, at 3:16 PM, Marius Strobl wrote: >> On Sat, May 07, 2011 at 07:22:23PM +0200, Damjan Marion wrote: > Yes, my initial idea is to attach manually only to one PHY, but = problem=20 > is that either i can attach to PHY12-15 which is reporting wrong ID2=20= > belonging to different PHY driver or to attach on PHY20-23 where ID1 = and ID2=20 > registers doesn't exist, but luckily some values are at that address = and=20 > they are recognized as unknown PHY. There's supposed to be 'wiring' information for the switches/PHYs in the = DTS. Maybe you can key off that to determine which ones to attach to. =20= > In both cases it sounds like a workaround more than a proper solution, = so=20 > I was wondering if there is some better way to detect PHY, not only by=20= > ID1 and ID2 values. In case of this device there is another register = which=20 > contains product identifier, and that is what linux driver probes. Usually detection by ID1/ID2 is the better way. However, some devices, = like this switch, respond on multiply PHY addresses (sometimes bogusly, = sometimes not). >>> I would like to hear form more experienced people how to implement = this properly, as it is obvious that it cannot be addressed with = existing routines. >>=20 >> Depends on what you understand by properly. One idea I particularly >> like is to handle switch ports as pseudo-interfaces hanging off of = the >> the MAC driver parent roughly similar to vlan(4). That way you'd have >> per port link status and could configure the media. >>=20 >> What you can do now without changing mii(4) is to just attach the >> the PHY side, i.e. port 3, and configure/handle the ports in a >> special PHY driver, either by hardcoding their configuration like >> rlswitch(4) does or by providing SYSCTLs as Adrian already said. >> If we had a way to access the PHY registers from userland similar >> to what pci(4)/pciconf(8) allows, which is another thing I'd like >> to see in order to provide miitool-like functionality, one could >> also easily handle the port configuration from userland instead >> of putting everything into the kernel. That probably also would >> have its merits as in reality there are probably a lot of quirks >> like unconnected ports etc. >=20 > Agree, I will try to code something and then I will ask wider audience = to comment on. That would be cool. Most switches are on the PHY bus, so you can program their registers. = Many are on the PHY bus multiple times. Once for the real(ish) PHY they = provide and once for the switch registers they expose (for some, "twice" = means up to 4 times). Some are just nuts. It would be nice if there was a way for a device's MII routine to = control enumeration of the PHY bus. This would allow us to convert the = rlswitch device in the tree to one of these. That way, it could = 'filter' out the PHYs addresses that are intended to be like traditional = PHYs from the addresses that are intended to be used for switch = management. We likely should also have a switch interface that one can tweak via = ifconfig. I'd like that to be an explicit goal of this work, even if = others do it. However, that's a big ticket item. I kinda like the 'let us put a few = of these in the tree with kludges then refactor' model, but worry we end = up without the refactoring... Warner=