Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1560025 > unrolled thread
| Started by | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| First post | 2017-01-16 21:10 +0100 |
| Last post | 2017-01-25 22:30 +0100 |
| Articles | 10 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Florian Fainelli <f.fainelli@gmail.com> - 2017-01-16 21:10 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Greg KH <gregkh@linuxfoundation.org> - 2017-01-18 08:20 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Greg KH <gregkh@linuxfoundation.org> - 2017-01-19 15:50 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Andrew Lunn <andrew@lunn.ch> - 2017-01-19 16:00 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Greg KH <gregkh@linuxfoundation.org> - 2017-01-19 17:40 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-01-19 17:50 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-01-19 18:00 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Florian Fainelli <f.fainelli@gmail.com> - 2017-01-19 19:30 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Florian Fainelli <f.fainelli@gmail.com> - 2017-01-24 20:00 +0100
Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Greg KH <gregkh@linuxfoundation.org> - 2017-01-25 22:30 +0100
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-01-16 21:10 +0100 |
| Subject | Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() |
| Message-ID | <t0lLk-5zl-3@gated-at.bofh.it> |
On 01/15/2017 11:16 AM, Andrew Lunn wrote:
>>> What exactly is the relationship between these devices (a ascii-art tree
>>> or sysfs tree output might be nice) so I can try to understand what is
>>> going on here.
>
> Hi Greg, Florian
>
> A few diagrams and trees which might help understand what is going on.
>
> The first diagram comes from the 2008 patch which added all this code:
>
> +-----------+ +-----------+
> | | RGMII | |
> | +-------+ +------ 1000baseT MDI ("WAN")
> | | | 6-port +------ 1000baseT MDI ("LAN1")
> | CPU | | ethernet +------ 1000baseT MDI ("LAN2")
> | |MIImgmt| switch +------ 1000baseT MDI ("LAN3")
> | +-------+ w/5 PHYs +------ 1000baseT MDI ("LAN4")
> | | | |
> +-----------+ +-----------+
>
> We have an ethernet switch and a host CPU. The switch is connected to
> the CPU in two different ways. RGMII allows us to get Ethernet frames
> from the CPU into the switch. MIImgmt, is the management bus normally
> used for Ethernet PHYs, but Marvell switches also use it for Managing
> switches.
>
> The diagram above is the simplest setup. You can have multiple
> Ethernet switches, connected together via switch ports. Each switch
> has its own MIImgmt connect to the CPU, but there is only one RGMII
> link.
>
> When this code was designed back in 2008, it was decided to represent
> this is a platform device, and it has a platform_data, which i have
> slightly edited to keep it simple:
>
> struct dsa_platform_data {
> /*
> * Reference to a Linux network interface that connects
> * to the root switch chip of the tree.
> */
> struct device *netdev;
>
> /*
> * Info structs describing each of the switch chips
> * connected via this network interface.
> */
> int nr_chips;
> struct dsa_chip_data *chip;
> };
>
> This netdev is the CPU side of the RGMII interface.
>
> Each switch has a dsa_chip_data, again edited:
>
> struct dsa_chip_data {
> /*
> * How to access the switch configuration registers.
> */
> struct device *host_dev;
> int sw_addr;
> ...
> }
>
> The host_dev is the CPU side of the MIImgmt, and we have the address
> the switch is using on the bus.
>
> During probe of this platform device, we need to get from the
> struct device *netdev to a struct net_device *dev.
>
> So the code looks in the device net class to find the device
>
> | | | |-- f1074000.ethernet
> | | | | |-- deferred_probe
> | | | | |-- driver -> ../../../../../bus/platform/drivers/mvneta
> | | | | |-- driver_override
> | | | | |-- modalias
> | | | | |-- net
> | | | | | `-- eth1
> | | | | | |-- addr_assign_type
> | | | | | |-- address
> | | | | | |-- addr_len
> | | | | | |-- broadcast
> | | | | | |-- carrier
> | | | | | |-- carrier_changes
> | | | | | |-- deferred_probe
> | | | | | |-- device -> ../../../f1074000.ethernet
>
> and then use container_of() to get the net_device.
>
> Similarly, the code needs to get from struct device *host_dev to a struct mii_bus *.
>
> | | | |-- f1072004.mdio
> | | | | |-- deferred_probe
> | | | | |-- driver -> ../../../../../bus/platform/drivers/orion-mdio
> | | | | |-- driver_override
> | | | | |-- mdio_bus
> | | | | | `-- f1072004.mdio-mi
> | | | | | |-- deferred_probe
> | | | | | |-- device -> ../../../f1072004.mdio
>
Thanks Andrew! Greg, does that make it clearer how these devices
references are used, do you still think the way this is done is wrong,
too cautious, or valid?
--
Florian
[toc] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-01-18 08:20 +0100 |
| Message-ID | <t0SHf-13d-7@gated-at.bofh.it> |
| In reply to | #1560025 |
On Mon, Jan 16, 2017 at 12:01:02PM -0800, Florian Fainelli wrote:
> On 01/15/2017 11:16 AM, Andrew Lunn wrote:
> >>> What exactly is the relationship between these devices (a ascii-art tree
> >>> or sysfs tree output might be nice) so I can try to understand what is
> >>> going on here.
> >
> > Hi Greg, Florian
> >
> > A few diagrams and trees which might help understand what is going on.
> >
> > The first diagram comes from the 2008 patch which added all this code:
> >
> > +-----------+ +-----------+
> > | | RGMII | |
> > | +-------+ +------ 1000baseT MDI ("WAN")
> > | | | 6-port +------ 1000baseT MDI ("LAN1")
> > | CPU | | ethernet +------ 1000baseT MDI ("LAN2")
> > | |MIImgmt| switch +------ 1000baseT MDI ("LAN3")
> > | +-------+ w/5 PHYs +------ 1000baseT MDI ("LAN4")
> > | | | |
> > +-----------+ +-----------+
> >
> > We have an ethernet switch and a host CPU. The switch is connected to
> > the CPU in two different ways. RGMII allows us to get Ethernet frames
> > from the CPU into the switch. MIImgmt, is the management bus normally
> > used for Ethernet PHYs, but Marvell switches also use it for Managing
> > switches.
> >
> > The diagram above is the simplest setup. You can have multiple
> > Ethernet switches, connected together via switch ports. Each switch
> > has its own MIImgmt connect to the CPU, but there is only one RGMII
> > link.
> >
> > When this code was designed back in 2008, it was decided to represent
> > this is a platform device, and it has a platform_data, which i have
> > slightly edited to keep it simple:
> >
> > struct dsa_platform_data {
> > /*
> > * Reference to a Linux network interface that connects
> > * to the root switch chip of the tree.
> > */
> > struct device *netdev;
> >
> > /*
> > * Info structs describing each of the switch chips
> > * connected via this network interface.
> > */
> > int nr_chips;
> > struct dsa_chip_data *chip;
> > };
> >
> > This netdev is the CPU side of the RGMII interface.
> >
> > Each switch has a dsa_chip_data, again edited:
> >
> > struct dsa_chip_data {
> > /*
> > * How to access the switch configuration registers.
> > */
> > struct device *host_dev;
> > int sw_addr;
> > ...
> > }
> >
> > The host_dev is the CPU side of the MIImgmt, and we have the address
> > the switch is using on the bus.
> >
> > During probe of this platform device, we need to get from the
> > struct device *netdev to a struct net_device *dev.
> >
> > So the code looks in the device net class to find the device
> >
> > | | | |-- f1074000.ethernet
> > | | | | |-- deferred_probe
> > | | | | |-- driver -> ../../../../../bus/platform/drivers/mvneta
> > | | | | |-- driver_override
> > | | | | |-- modalias
> > | | | | |-- net
> > | | | | | `-- eth1
> > | | | | | |-- addr_assign_type
> > | | | | | |-- address
> > | | | | | |-- addr_len
> > | | | | | |-- broadcast
> > | | | | | |-- carrier
> > | | | | | |-- carrier_changes
> > | | | | | |-- deferred_probe
> > | | | | | |-- device -> ../../../f1074000.ethernet
> >
> > and then use container_of() to get the net_device.
> >
> > Similarly, the code needs to get from struct device *host_dev to a struct mii_bus *.
> >
> > | | | |-- f1072004.mdio
> > | | | | |-- deferred_probe
> > | | | | |-- driver -> ../../../../../bus/platform/drivers/orion-mdio
> > | | | | |-- driver_override
> > | | | | |-- mdio_bus
> > | | | | | `-- f1072004.mdio-mi
> > | | | | | |-- deferred_probe
> > | | | | | |-- device -> ../../../f1072004.mdio
> >
>
> Thanks Andrew! Greg, does that make it clearer how these devices
> references are used, do you still think the way this is done is wrong,
> too cautious, or valid?
I'm still not sold on it, I think there is something odd here with your
use/assumptions of the driver model. Give me a few days to catch up
with other stuff to respond back please...
thanks,
greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-01-19 15:50 +0100 |
| Message-ID | <t1mci-2Mr-33@gated-at.bofh.it> |
| In reply to | #1560025 |
On Mon, Jan 16, 2017 at 12:01:02PM -0800, Florian Fainelli wrote:
> On 01/15/2017 11:16 AM, Andrew Lunn wrote:
> >>> What exactly is the relationship between these devices (a ascii-art tree
> >>> or sysfs tree output might be nice) so I can try to understand what is
> >>> going on here.
> >
> > Hi Greg, Florian
> >
> > A few diagrams and trees which might help understand what is going on.
> >
> > The first diagram comes from the 2008 patch which added all this code:
> >
> > +-----------+ +-----------+
> > | | RGMII | |
> > | +-------+ +------ 1000baseT MDI ("WAN")
> > | | | 6-port +------ 1000baseT MDI ("LAN1")
> > | CPU | | ethernet +------ 1000baseT MDI ("LAN2")
> > | |MIImgmt| switch +------ 1000baseT MDI ("LAN3")
> > | +-------+ w/5 PHYs +------ 1000baseT MDI ("LAN4")
> > | | | |
> > +-----------+ +-----------+
> >
> > We have an ethernet switch and a host CPU. The switch is connected to
> > the CPU in two different ways. RGMII allows us to get Ethernet frames
> > from the CPU into the switch. MIImgmt, is the management bus normally
> > used for Ethernet PHYs, but Marvell switches also use it for Managing
> > switches.
> >
> > The diagram above is the simplest setup. You can have multiple
> > Ethernet switches, connected together via switch ports. Each switch
> > has its own MIImgmt connect to the CPU, but there is only one RGMII
> > link.
> >
> > When this code was designed back in 2008, it was decided to represent
> > this is a platform device, and it has a platform_data, which i have
> > slightly edited to keep it simple:
> >
> > struct dsa_platform_data {
> > /*
> > * Reference to a Linux network interface that connects
> > * to the root switch chip of the tree.
> > */
> > struct device *netdev;
This I think is the oddest thing, why do you need to have the "root
switch" here? You seem to have dropped the next value in this
structure:
struct net_device *of_netdev;
Isn't that the "real" net_device you need/want to get to here?
Or, when you set netdev, can't you also point to the "real" net_device
you want to later get to?
> > /*
> > * Info structs describing each of the switch chips
> > * connected via this network interface.
> > */
> > int nr_chips;
> > struct dsa_chip_data *chip;
> > };
> >
> > This netdev is the CPU side of the RGMII interface.
> >
> > Each switch has a dsa_chip_data, again edited:
> >
> > struct dsa_chip_data {
> > /*
> > * How to access the switch configuration registers.
> > */
> > struct device *host_dev;
> > int sw_addr;
> > ...
> > }
If each switch only has one dsa_chip_data, can't you point directly from
that structure back to the dsa_platform_device? Or is that what this
"host_dev" pointer is pointing to?
> > The host_dev is the CPU side of the MIImgmt, and we have the address
> > the switch is using on the bus.
"cpu side" means what? What 'struct device' is this? The host
controller? The platform device? Something else?
> > During probe of this platform device, we need to get from the
> > struct device *netdev to a struct net_device *dev.
Wait, what exactly is this "struct device *"? Who created it?
And why are you using a platform device? Shouldn't this be a custom
bus? I know people like to abuse platform devices, is that the case
here, or is it really driven only by a device tree representation?
Shouldn't you have a bus for RGMII devices? Is that the real problem
here, you don't have a representation for your RGMII "bus" with a
controller to bundle everything under (like a USB host controller, it
bridges from one bus to another).
> > So the code looks in the device net class to find the device
> >
> > | | | |-- f1074000.ethernet
> > | | | | |-- deferred_probe
> > | | | | |-- driver -> ../../../../../bus/platform/drivers/mvneta
> > | | | | |-- driver_override
> > | | | | |-- modalias
> > | | | | |-- net
> > | | | | | `-- eth1
> > | | | | | |-- addr_assign_type
> > | | | | | |-- address
> > | | | | | |-- addr_len
> > | | | | | |-- broadcast
> > | | | | | |-- carrier
> > | | | | | |-- carrier_changes
> > | | | | | |-- deferred_probe
> > | | | | | |-- device -> ../../../f1074000.ethernet
> >
> > and then use container_of() to get the net_device.
What 'struct device *' are you passing to container_of() here? The one
representing eth1? What call is this? And where are you trying to go
from there, to a peer? Why?
> > Similarly, the code needs to get from struct device *host_dev to a struct mii_bus *.
> >
> > | | | |-- f1072004.mdio
> > | | | | |-- deferred_probe
> > | | | | |-- driver -> ../../../../../bus/platform/drivers/orion-mdio
> > | | | | |-- driver_override
> > | | | | |-- mdio_bus
> > | | | | | `-- f1072004.mdio-mi
> > | | | | | |-- deferred_probe
> > | | | | | |-- device -> ../../../f1072004.mdio
Ok, this looks like the "peer" you want to get to from eth1, you want
f1072004.mdio-mi, right?
If so, why is eth1 not below f1072004.mdio-mi in the heirachy already?
Why is it up attached to the parent device, making this a "flat"
heirachy?
That's what is confusing about your functions, you are just walking all
of the "child" devices of a specific struct device, trying to find the
first random one that happens to belong to a specific 'bus' because you
are related to it.
Which is wrong, eth1 should be a child of your bus device, that way you
"know" how to get to it (it's your parent!).
So, I'm still confused, and still think this is all wrong, but feel free
to prove me wrong about this :)
thanks,
greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Date | 2017-01-19 16:00 +0100 |
| Message-ID | <t1mlX-2PW-3@gated-at.bofh.it> |
| In reply to | #1562792 |
> > > struct dsa_platform_data {
> > > /*
> > > * Reference to a Linux network interface that connects
> > > * to the root switch chip of the tree.
> > > */
> > > struct device *netdev;
>
> This I think is the oddest thing, why do you need to have the "root
> switch" here? You seem to have dropped the next value in this
> structure:
> struct net_device *of_netdev;
We are implementing platform_data for devices which don't support
device tree. When using OF, we don't have any of these issues. We can
go straight to the device.
It is a bit convoluted, but look at
arch/arm/mach-orion5x/rd88f5181l-ge-setup.c. It defines the start of
the dsa_platform_data in that file. It then gets passed through
common.c: orion5x_eth_switch_init() to
arch/arm/plat-orion/common.c:orion_ge00_switch_init() :
void __init orion_ge00_switch_init(struct dsa_platform_data *d)
{
int i;
d->netdev = &orion_ge00.dev;
for (i = 0; i < d->nr_chips; i++)
d->chip[i].host_dev = &orion_ge_mvmdio.dev;
platform_device_register_data(NULL, "dsa", 0, d, sizeof(d));
}
Where we have
static struct platform_device orion_ge00 = {
.name = MV643XX_ETH_NAME,
.id = 0,
.num_resources = 1,
.resource = orion_ge00_resources,
.dev = {
.coherent_dma_mask = DMA_BIT_MASK(32),
},
};
So this is the platform device for the Ethernet device. We cannot go
to the net_device, because it does not exist until this Ethernet
platform device is instantiated.
> Shouldn't you have a bus for RGMII devices? Is that the real problem
> here, you don't have a representation for your RGMII "bus" with a
> controller to bundle everything under (like a USB host controller, it
> bridges from one bus to another).
RGMII is not a bus. It is a point to point link. Normally, it is
between the Ethernet MAC and the Ethernet PHY. But you can also have
it between an Ethernet MAC and another Ethernet MAC. I'm not sure
describing this is a bus would be practical. It would mean every
ethernet driver also becomes a bus driver! Every Ethernet PHY would
become a bus device. That is a huge change, for a few legacy boards
which are not getting converted to device tree.
> If so, why is eth1 not below f1072004.mdio-mi in the heirachy already?
See the initial diagram above. The switch has two parents. It hangs of
an MDIO bus, and you would like to make RGMII also a bus. Can the
device model handle that? I thought it was a tree, not a graph?
Andrew
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-01-19 17:40 +0100 |
| Message-ID | <t1nUK-3Tq-17@gated-at.bofh.it> |
| In reply to | #1562796 |
On Thu, Jan 19, 2017 at 03:53:15PM +0100, Andrew Lunn wrote:
> > > > struct dsa_platform_data {
> > > > /*
> > > > * Reference to a Linux network interface that connects
> > > > * to the root switch chip of the tree.
> > > > */
> > > > struct device *netdev;
> >
> > This I think is the oddest thing, why do you need to have the "root
> > switch" here? You seem to have dropped the next value in this
> > structure:
> > struct net_device *of_netdev;
>
> We are implementing platform_data for devices which don't support
> device tree. When using OF, we don't have any of these issues. We can
> go straight to the device.
>
> It is a bit convoluted, but look at
> arch/arm/mach-orion5x/rd88f5181l-ge-setup.c. It defines the start of
> the dsa_platform_data in that file. It then gets passed through
> common.c: orion5x_eth_switch_init() to
> arch/arm/plat-orion/common.c:orion_ge00_switch_init() :
>
> void __init orion_ge00_switch_init(struct dsa_platform_data *d)
> {
> int i;
>
> d->netdev = &orion_ge00.dev;
> for (i = 0; i < d->nr_chips; i++)
> d->chip[i].host_dev = &orion_ge_mvmdio.dev;
>
> platform_device_register_data(NULL, "dsa", 0, d, sizeof(d));
> }
>
> Where we have
>
> static struct platform_device orion_ge00 = {
> .name = MV643XX_ETH_NAME,
> .id = 0,
> .num_resources = 1,
> .resource = orion_ge00_resources,
> .dev = {
> .coherent_dma_mask = DMA_BIT_MASK(32),
> },
> };
>
> So this is the platform device for the Ethernet device. We cannot go
> to the net_device, because it does not exist until this Ethernet
> platform device is instantiated.
Ok, fine, but why isn't the ethernet device a child of this platform
device? Why is it floating around somewhere else? You don't see that
happening for other devices.
> > Shouldn't you have a bus for RGMII devices? Is that the real problem
> > here, you don't have a representation for your RGMII "bus" with a
> > controller to bundle everything under (like a USB host controller, it
> > bridges from one bus to another).
>
> RGMII is not a bus. It is a point to point link.
That's fine, but you have multiple devices talking across it, so in the
kernel driver model "naming", it's a bus. Anything can be a bus, it's
just a way to group together devices of the same type.
> Normally, it is
> between the Ethernet MAC and the Ethernet PHY. But you can also have
> it between an Ethernet MAC and another Ethernet MAC. I'm not sure
> describing this is a bus would be practical. It would mean every
> ethernet driver also becomes a bus driver!
Instead of a custom platform device driver, yes. Is that a big deal?
How many do you have?
> Every Ethernet PHY would become a bus device. That is a huge change,
> for a few legacy boards which are not getting converted to device
> tree.
How many different drivers are we talking about here?
> > If so, why is eth1 not below f1072004.mdio-mi in the heirachy already?
>
> See the initial diagram above. The switch has two parents. It hangs of
> an MDIO bus, and you would like to make RGMII also a bus. Can the
> device model handle that? I thought it was a tree, not a graph?
It is a tree, you are correct. But right now you are picking and
choosing where you want to put that network device. Why not put it over
on the mdio bus? Or, like I mentioned, make it a custom bus where you
can properly show this relationship, not just in a generic "let's jump
to the parent and poke around randomly."
Again, it's that last sentance that I object the most to here. You all
keep ignoring it for some reason...
thanks,
greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Russell King - ARM Linux <linux@armlinux.org.uk> |
|---|---|
| Date | 2017-01-19 17:50 +0100 |
| Message-ID | <t1o4q-3Xc-45@gated-at.bofh.it> |
| In reply to | #1562887 |
On Thu, Jan 19, 2017 at 05:30:13PM +0100, Greg KH wrote:
> On Thu, Jan 19, 2017 at 03:53:15PM +0100, Andrew Lunn wrote:
> > > > > struct dsa_platform_data {
> > > > > /*
> > > > > * Reference to a Linux network interface that connects
> > > > > * to the root switch chip of the tree.
> > > > > */
> > > > > struct device *netdev;
> > >
> > > This I think is the oddest thing, why do you need to have the "root
> > > switch" here? You seem to have dropped the next value in this
> > > structure:
> > > struct net_device *of_netdev;
> >
> > We are implementing platform_data for devices which don't support
> > device tree. When using OF, we don't have any of these issues. We can
> > go straight to the device.
> >
> > It is a bit convoluted, but look at
> > arch/arm/mach-orion5x/rd88f5181l-ge-setup.c. It defines the start of
> > the dsa_platform_data in that file. It then gets passed through
> > common.c: orion5x_eth_switch_init() to
> > arch/arm/plat-orion/common.c:orion_ge00_switch_init() :
> >
> > void __init orion_ge00_switch_init(struct dsa_platform_data *d)
> > {
> > int i;
> >
> > d->netdev = &orion_ge00.dev;
> > for (i = 0; i < d->nr_chips; i++)
> > d->chip[i].host_dev = &orion_ge_mvmdio.dev;
> >
> > platform_device_register_data(NULL, "dsa", 0, d, sizeof(d));
> > }
> >
> > Where we have
> >
> > static struct platform_device orion_ge00 = {
> > .name = MV643XX_ETH_NAME,
> > .id = 0,
> > .num_resources = 1,
> > .resource = orion_ge00_resources,
> > .dev = {
> > .coherent_dma_mask = DMA_BIT_MASK(32),
> > },
> > };
> >
> > So this is the platform device for the Ethernet device. We cannot go
> > to the net_device, because it does not exist until this Ethernet
> > platform device is instantiated.
>
> Ok, fine, but why isn't the ethernet device a child of this platform
> device? Why is it floating around somewhere else? You don't see that
> happening for other devices.
The ethernet device is not a child of the DSA device. I'm going to
send a mail I've had queued up for a few hours redoing Andrew's
ASCII art, because I think that's what's causing the confusion here,
provided I haven't discarded it.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
[toc] | [prev] | [next] | [standalone]
| From | Russell King - ARM Linux <linux@armlinux.org.uk> |
|---|---|
| Date | 2017-01-19 18:00 +0100 |
| Message-ID | <t1oe6-40V-41@gated-at.bofh.it> |
| In reply to | #1562796 |
(This is mainly for Greg's benefit to help him understand the issue.)
I think the diagram you gave initially made this confusing, as it
talks about a CPU(sic) producing the "RGMII" and "MII-MGMT".
Let's instead show a better representation that hopefully helps Greg
understand networking. :)
CPU
System <-B-> Ethernet controller <-P-> } PHY <---> network cable
} - - - - - - - or - - - - - - -
MDIO bus -------M---> } Switch <-P-> PHYs <--> network
`----M----^ cables
'B' can be an on-SoC bus or something like PCI.
'P' are the high-speed connectivity between the ethernet controller and
PHY which carries the packet data. It has no addressing, it's a point
to point link. RGMII is just one wiring example, there are many
different interfaces there (SGMII, AUI, XAUI, XGMII to name a few.)
'M' are the MDIO bus, which is the bus by which ethernet PHYs and
switches can be identified and controlled.
The MDIO bus has a bus_type, has host drivers which are sometimes
part of the ethernet controller, but can also be stand-alone devices
shared between multiple ethernet controllers.
PHYs are a kind of MDIO device which are members of the MDIO bus
type. Each PHY (and switch) has a numerical address, and identifying
numbers within its register set which identifies the manufacturer
and device type. We have device_driver objects for these.
Expanding the above diagram to make it (hopefully) even clearer,
we can have this classic setup:
CPU
System <-B-> Ethernet controller <-P-> PHY <---> network cable
MDIO bus -------M------^
Or, in the case of two DSA switches attached to an Ethernet controller:
|~~~~~~~~|
System <-B-> Ethernet controller <-P-> Switch <-P-> PHY1 <--> network cable
MDIO bus ----+--M---> 1 <-P-> PHY2 <--> network cable
| | ... |
| | <-P-> PHYn <--> network cable
| |....^...| |
| | `---M---'
| P
| |
| |~~~~v~~~|
`------> Switch <-P-> PHY1 <--> network cable
| 2 ... |
| <-P-> PHYn <--> network cable
|........| |
`---M---'
The problem that the DSA guys are trying to deal with is how to
represent the link between the DSA switches (which are devices
sitting off their controlling bus - the MDIO bus) and the ethernet
controller associated with that collection of devices, be it a
switch or PHY.
Merely changing the parent/child relationships to try and solve
one issue just creates exactly the same problem elsewhere.
So, I hope with these diagrams, you can see that trying to make
the ethernet controller a child device of the DSA switches
means that (eg) it's no longer a PCI device, which is rather
absurd, especially when considering that what happens to the
right of the ethernet controller in the diagrams above is
normally external chips to the SoC or ethernet device.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-01-19 19:30 +0100 |
| Message-ID | <t1pDb-51e-7@gated-at.bofh.it> |
| In reply to | #1562927 |
On 01/19/2017 08:51 AM, Russell King - ARM Linux wrote: > (This is mainly for Greg's benefit to help him understand the issue.) > > I think the diagram you gave initially made this confusing, as it > talks about a CPU(sic) producing the "RGMII" and "MII-MGMT". > > Let's instead show a better representation that hopefully helps Greg > understand networking. :) > > > CPU > System <-B-> Ethernet controller <-P-> } PHY <---> network cable > } - - - - - - - or - - - - - - - > MDIO bus -------M---> } Switch <-P-> PHYs <--> network > `----M----^ cables > > 'B' can be an on-SoC bus or something like PCI. > > 'P' are the high-speed connectivity between the ethernet controller and > PHY which carries the packet data. It has no addressing, it's a point > to point link. RGMII is just one wiring example, there are many > different interfaces there (SGMII, AUI, XAUI, XGMII to name a few.) > > 'M' are the MDIO bus, which is the bus by which ethernet PHYs and > switches can be identified and controlled. So MDIO is one possible bus type to connect an Ethernet switch (and PHYs) to a the System, but is not necessarily the only one. You have existing devices out there with on-chip integrated switches (platform), SPI/GPIO/I2C/PCI(e). > > The MDIO bus has a bus_type, has host drivers which are sometimes > part of the ethernet controller, but can also be stand-alone devices > shared between multiple ethernet controllers. > > PHYs are a kind of MDIO device which are members of the MDIO bus > type. Each PHY (and switch) has a numerical address, and identifying > numbers within its register set which identifies the manufacturer > and device type. We have device_driver objects for these. > > Expanding the above diagram to make it (hopefully) even clearer, > we can have this classic setup: > > CPU > System <-B-> Ethernet controller <-P-> PHY <---> network cable > MDIO bus -------M------^ > > Or, in the case of two DSA switches attached to an Ethernet controller: > > |~~~~~~~~| > System <-B-> Ethernet controller <-P-> Switch <-P-> PHY1 <--> network cable > MDIO bus ----+--M---> 1 <-P-> PHY2 <--> network cable > | | ... | > | | <-P-> PHYn <--> network cable > | |....^...| | > | | `---M---' > | P > | | > | |~~~~v~~~| > `------> Switch <-P-> PHY1 <--> network cable > | 2 ... | > | <-P-> PHYn <--> network cable > |........| | > `---M---' > > The problem that the DSA guys are trying to deal with is how to > represent the link between the DSA switches (which are devices > sitting off their controlling bus - the MDIO bus) and the ethernet > controller associated with that collection of devices, be it a > switch or PHY. > > Merely changing the parent/child relationships to try and solve > one issue just creates exactly the same problem elsewhere. Exactly! > > So, I hope with these diagrams, you can see that trying to make > the ethernet controller a child device of the DSA switches > means that (eg) it's no longer a PCI device, which is rather > absurd, especially when considering that what happens to the > right of the ethernet controller in the diagrams above is > normally external chips to the SoC or ethernet device. > Indeed. Back to the actual code that triggered this discussion, the whole purpose is just a safeguard. Given a device reference, we can assume that it is indeed the backing device for a net_device, and we could do a to_net_device() right away (and crash if someone did not write correct platform_data structures), or, by walking the device tree (the device driver model one) we can make sure it does belong in the proper class and this is indeed what we think it is. HTH -- Florian
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-01-24 20:00 +0100 |
| Message-ID | <t3etY-7Tw-15@gated-at.bofh.it> |
| In reply to | #1562993 |
On 01/19/2017 10:12 AM, Florian Fainelli wrote: > > Back to the actual code that triggered this discussion, the whole > purpose is just a safeguard. Given a device reference, we can assume > that it is indeed the backing device for a net_device, and we could do a > to_net_device() right away (and crash if someone did not write correct > platform_data structures), or, by walking the device tree (the device > driver model one) we can make sure it does belong in the proper class > and this is indeed what we think it is. Greg, did Russell's explanation clarify things, or do you still think this is completely bogus and we need to re design the whole thing? Just asking so I can try to resubmit just the preparatory parts or just the whole thing. Thank you -- Florian
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-01-25 22:30 +0100 |
| Message-ID | <t3DiG-76w-39@gated-at.bofh.it> |
| In reply to | #1566071 |
On Tue, Jan 24, 2017 at 10:59:15AM -0800, Florian Fainelli wrote: > On 01/19/2017 10:12 AM, Florian Fainelli wrote: > > > > Back to the actual code that triggered this discussion, the whole > > purpose is just a safeguard. Given a device reference, we can assume > > that it is indeed the backing device for a net_device, and we could do a > > to_net_device() right away (and crash if someone did not write correct > > platform_data structures), or, by walking the device tree (the device > > driver model one) we can make sure it does belong in the proper class > > and this is indeed what we think it is. > > Greg, did Russell's explanation clarify things, or do you still think > this is completely bogus and we need to re design the whole thing? > > Just asking so I can try to resubmit just the preparatory parts or just > the whole thing. Sorry, I haven't gotten back to this, it's lower on my list. Should try to get to it tomorrow...
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web