Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| stefanbethke:etherswitch [2011/12/13 08:24] – StefanBethke | stefanbethke:etherswitch [2015/08/31 07:10] (current) – add a space to make hyper link parsing work LiWenHsu | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| This page contains my ideas on how to design and implement a framework for configuring (embedded) ethernet switch controllers from %%FreeBSD%%. | This page contains my ideas on how to design and implement a framework for configuring (embedded) ethernet switch controllers from %%FreeBSD%%. | ||
| - | Many wireless router devices contain multiple Ethernet ports that are implemented by an Ethernet switch chip. These chips can often be configured in varioous | + | As of May 16th, this is only a slightly dated brain dump of various ideas and questions that I had during the past couple of months. I'm planning on updating this page shortly with information on the implementation that Adrian committed to -head. |
| + | |||
| + | In the meantime, please refer to my talk at BSDCan 2012 http:// | ||
| + | |||
| + | ---- | ||
| + | |||
| + | Many wireless router devices contain multiple Ethernet ports that are implemented by an Ethernet switch chip. These chips can often be configured in various | ||
| ====== Design Goals ====== | ====== Design Goals ====== | ||
| Line 50: | Line 56: | ||
| This Realtek Ethernet switch is used in the TP-LINK TL-WR1043ND. | This Realtek Ethernet switch is used in the TP-LINK TL-WR1043ND. | ||
| + | |||
| + | Accessing PHY registers through the switch controller over the bit-banging I2C is slow. The media status update routing uses the switch port status registers, resulting in a total of 3 register accesses instead of 5 * 3 * 3 register accesses compared to standard PHY polling. | ||
| + | |||
| + | ===== AR8x16 ===== | ||
| + | |||
| + | This family of Atheros switches is used in a number of devices, including the TP-LINK TL-MR3420 and TL-MR3220 (built-in to the %%SoC%%). | ||
| + | |||
| + | VLAN configuration on this switch differs significantly from the RL836x family. | ||
| + | |||
| + | ====== Current Implementation ====== | ||
| + | |||
| + | I've developed some code to control an RTL8366RB. | ||
| + | |||
| + | It consists of the sys/ | ||
| + | |||
| + | sys/ | ||
| + | |||
| + | ===== Ioctl Interface ===== | ||
| + | The cdev allows a userland program to issue a number of ioctl to query and configure the switch. | ||
| + | |||
| + | ===== Modeling the Switch ===== | ||
| + | One challenge in modeling the switch was to find a way to reuse the existing MII and PHY code (sys/ | ||
| + | |||
| + | ===== Implementation Issues ===== | ||
| + | |||
| + | Register access over the software-implemented I2C bus is slow, accessing PHY registers even more so. In one iteration of the kernel driver, a callout ran every second to run the miitick and miipoll functions for each of the five PHYs. This took about 100 milliseconds per PHY per function, or about a second in total. | ||
| + | |||
| + | ===== MII, MDIO, and miibus ===== | ||
| + | |||
| + | In a typical Ethernet controller, there is one MAC, one MDIO master, and one or more PHYs (with MII slave and MDIO slave interfaces). | ||
| + | |||
| + | {{stefanbethke/ | ||
| + | |||
| + | For embedded systems with an Ethernet switch, the picture becomes more complicated. | ||
| + | |||
| + | {{stefanbethke/ | ||
| + | |||
| + | arge0 has it's MAC connected to PHY4; it's MDIO master is not connected. | ||
| + | |||
| + | arge1 has it's MAC connected to a MAC of the switch core (back-to-back, | ||
| + | |||
| + | The switch controller has an internal MDIO master, which is used to communicate with the PHYs. PHY0 to PHY3 are connected to their respective switch MAC via an MII each. | ||
| + | |||
| + | ==== miibus Challenge ==== | ||
| + | |||
| + | Since arge1 has a fixed connection to the switch core, a hard-coded (via hints) setup is sufficient. | ||
| + | |||
| + | With the current miibus code, this poses a number of challenges: | ||
| + | * ethernet switches that are attached via MDIO may not look like PHYs, in particular, they might not have a BMSR or ID1 and ID2. This is the case with the Atheros AR8x16 series. | ||
| + | |||
| + | * attach hierarchy and sequence, e.g. for the PHY in the switch chip, where the switch chip is attached to arge1, but the PHY needs to be at arge0. | ||
| + | |||
| + | * creating miibus' | ||