Subject: RFC: dsa: add support for multiple CPU ports

From: Mathieu Olivari <[email-masked]>
Date: Tue, 10 Mar 2015 12:01:29 -0700

Hi all,

I’m writing a DSA driver for some QCA network switches already supported in
OpenWrt using swconfig. They connect to the CPU using MDIO for configuration,
and xMII ports for data. The main difference with what is supported comes from
the fact that most of these switches actually have multiple xMII connections to
the same CPU. Something like this:
(extending the picture from http://lwn.net/Articles/302333/)

	+-----------+       +-----------+
	|           | RGMII |           |
	|       eth0+-------+           +------ 1000baseT MDI ("WAN")
	|        wan|       |  7-port   +------ 1000baseT MDI ("LAN1")
	|   CPU     |       |  ethernet +------ 1000baseT MDI ("LAN2")
	|           | RGMII |  switch   +------ 1000baseT MDI ("LAN3")
	|       eth1+-------+  w/5 PHYs +------ 1000baseT MDI ("LAN4")
	|        lan|       |           |
	+-----------+       +-----------+
	          |   MDIO     |
	          \------------/

In a typical configuration, we configure the switch to isolate WAN & LAN from
each other.

The current DSA implementation is based on the assumption that there can be only
one xMII connection between the switch and the CPU (this switch port is known as
the CPU port), which obviously doesn't work anymore in that case. So I'm trying
to figure out the best way to extend DSA to support these hardware.

Here is my proposal. I was hoping to get feedback before i get too much down the
implementation path:
*add an optional phandle (cpu_dev) to the existing port device node, which would
 reference the ethernet device node this port is connected to
*save the corresponding net_device in the "ports" field of "struct dsa_switch"
*instrument the network layer to be able to look-up which switch port is
 connected to a particular net_device.

The third point would allow to perform operations currently limited to switch
ports. Typically, "ethtool -S eth0" could return the corresponding port's MIB
statistics in addition to the eth0 statistics.

Thoughts?

Thanks,
Mathieu