Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 May 2011 15:16:43 +0200
From:      Marius Strobl <marius@alchemy.franken.de>
To:        Damjan Marion <damjan.marion@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Embedded switch instead of stadard PHY
Message-ID:  <20110508131643.GA23650@alchemy.franken.de>
In-Reply-To: <34CF3ED0-52BC-4D0E-922A-FE26F624E77F@gmail.com>
References:  <34CF3ED0-52BC-4D0E-922A-FE26F624E77F@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, May 07, 2011 at 07:22:23PM +0200, Damjan Marion wrote:
> 
> Hi,
> 
> 
> I would like to implement support for embedded switch on WRT350Nv2 router which is based on 88F5181L SoC (ARM). FreeBSD already have support for embedded gigabit card (if_mge) but in case if this router MAC is connected directly to 8-port ethernet chip (88E6131). If I use MII_PHY_ANY scan founds following PHYs on miibus:
> 
> mge0: <Marvell Gigabit Ethernet controller> mem 0xf1072000-0xf1073fff irq 18,19,20,21,22 on simplebus0
> miibus0: <MII bus> on mge0
> e1000phy0: <Marvell 88E1000 Gigabit PHY> PHY 12 on miibus0
> e1000phy0: id1=0x0141, id2=0x0c00 
> e1000phy1: <Marvell 88E1000 Gigabit PHY> PHY 13 on miibus0
> e1000phy1: id1=0x0141, id2=0x0c00 
> e1000phy2: <Marvell 88E1000 Gigabit PHY> PHY 14 on miibus0
> e1000phy2: id1=0x0141, id2=0x0c00 
> e1000phy3: <Marvell 88E1000 Gigabit PHY> PHY 15 on miibus0
> e1000phy3: id1=0x0141, id2=0x0c00 
> ukphy0: <Generic IEEE 802.3u media interface> PHY 20 on miibus0
> ukphy0:  
> ukphy1: <Generic IEEE 802.3u media interface> PHY 21 on miibus0
> ukphy1:  
> ukphy2: <Generic IEEE 802.3u media interface> PHY 22 on miibus0
> ukphy2:  
> ukphy3: <Generic IEEE 802.3u media interface> PHY 23 on miibus0
> 
> if_mge MAC is connected to port 3 of E6131 and port 3 acts in reverse-GMII mode to simulate PHY side.
> 
> Reason for output above is that E6131 uses non-standard registers on multiple device addresses and on some of them mii_attach fails, and on another it false detects PHY (20-23 above).

Well, if the switch responds on these addresses then from a MII point
of view there's nothing wrong about this when using MII_PHY_ANY. If
you want only one of these to attach than use that address instead of
MII_PHY_ANY. By calling mii_attach() multiple times with different
addresses you can also attach a subset.

> 
> 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.

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.

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.

Marius




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