All of lore.kernel.org
 help / color / mirror / Atom feed
From: f.fainelli@gmail.com (Florian Fainelli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class()
Date: Thu, 19 Jan 2017 10:12:07 -0800	[thread overview]
Message-ID: <841dc133-e9af-e7ca-75bf-8371337d6281@gmail.com> (raw)
In-Reply-To: <20170119165155.GH27312@n2100.armlinux.org.uk>



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

WARNING: multiple messages have this Message-ID (diff)
From: Florian Fainelli <f.fainelli@gmail.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>,
	Andrew Lunn <andrew@lunn.ch>,
	Greg KH <gregkh@linuxfoundation.org>
Cc: netdev@vger.kernel.org, Jason Cooper <jason@lakedaemon.net>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	"David S. Miller" <davem@davemloft.net>,
	"moderated list:ARM SUB-ARCHITECTURES" 
	<linux-arm-kernel@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class()
Date: Thu, 19 Jan 2017 10:12:07 -0800	[thread overview]
Message-ID: <841dc133-e9af-e7ca-75bf-8371337d6281@gmail.com> (raw)
In-Reply-To: <20170119165155.GH27312@n2100.armlinux.org.uk>



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

WARNING: multiple messages have this Message-ID (diff)
From: Florian Fainelli <f.fainelli@gmail.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>,
	Andrew Lunn <andrew@lunn.ch>,
	Greg KH <gregkh@linuxfoundation.org>
Cc: Jason Cooper <jason@lakedaemon.net>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	netdev@vger.kernel.org, open list <linux-kernel@vger.kernel.org>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	"David S. Miller" <davem@davemloft.net>,
	"moderated list:ARM SUB-ARCHITECTURES"
	<linux-arm-kernel@lists.infradead.org>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Subject: Re: [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class()
Date: Thu, 19 Jan 2017 10:12:07 -0800	[thread overview]
Message-ID: <841dc133-e9af-e7ca-75bf-8371337d6281@gmail.com> (raw)
In-Reply-To: <20170119165155.GH27312@n2100.armlinux.org.uk>



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

  reply	other threads:[~2017-01-19 18:12 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-14 21:47 [PATCH net-next v3 00/10] net: dsa: Support for pdata in dsa2 Florian Fainelli
2017-01-14 21:47 ` Florian Fainelli
2017-01-14 21:47 ` Florian Fainelli
2017-01-14 21:47 ` [PATCH net-next v3 01/10] net: dsa: Pass device pointer to dsa_register_switch Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-14 21:47 ` [PATCH net-next v3 02/10] net: dsa: Make most functions take a dsa_port argument Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-14 21:47 ` [PATCH net-next v3 03/10] net: dsa: Suffix function manipulating device_node with _dn Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-14 21:47 ` [PATCH net-next v3 04/10] net: dsa: Move ports assignment closer to error checking Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-15 10:17   ` Sergei Shtylyov
2017-01-15 10:17     ` Sergei Shtylyov
2017-01-14 21:47 ` [PATCH net-next v3 05/10] drivers: base: Add device_find_class() Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-15 11:04   ` Greg KH
2017-01-15 11:04     ` Greg KH
2017-01-15 17:39     ` Florian Fainelli
2017-01-15 17:39       ` Florian Fainelli
2017-01-14 21:47 ` [PATCH net-next v3 06/10] net: dsa: Migrate to device_find_class() Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-15 11:06   ` Greg KH
2017-01-15 11:06     ` Greg KH
2017-01-15 17:27     ` Florian Fainelli
2017-01-15 17:27       ` Florian Fainelli
2017-01-15 17:27       ` Florian Fainelli
2017-01-15 17:39       ` Greg KH
2017-01-15 17:39         ` Greg KH
2017-01-15 17:52         ` Florian Fainelli
2017-01-15 17:52           ` Florian Fainelli
2017-01-15 17:52           ` Florian Fainelli
2017-01-15 19:16           ` Andrew Lunn
2017-01-15 19:16             ` Andrew Lunn
2017-01-15 19:16             ` Andrew Lunn
2017-01-16 20:01             ` Florian Fainelli
2017-01-16 20:01               ` Florian Fainelli
2017-01-18  7:06               ` Greg KH
2017-01-18  7:06                 ` Greg KH
2017-01-18  7:06                 ` Greg KH
2017-01-19 14:28               ` Greg KH
2017-01-19 14:28                 ` Greg KH
2017-01-19 14:28                 ` Greg KH
2017-01-19 14:53                 ` Andrew Lunn
2017-01-19 14:53                   ` Andrew Lunn
2017-01-19 14:53                   ` Andrew Lunn
2017-01-19 16:30                   ` Greg KH
2017-01-19 16:30                     ` Greg KH
2017-01-19 16:30                     ` Greg KH
2017-01-19 16:35                     ` Russell King - ARM Linux
2017-01-19 16:35                       ` Russell King - ARM Linux
2017-01-19 16:35                       ` Russell King - ARM Linux
2017-01-19 16:51                   ` Russell King - ARM Linux
2017-01-19 16:51                     ` Russell King - ARM Linux
2017-01-19 18:12                     ` Florian Fainelli [this message]
2017-01-19 18:12                       ` Florian Fainelli
2017-01-19 18:12                       ` Florian Fainelli
2017-01-24 18:59                       ` Florian Fainelli
2017-01-24 18:59                         ` Florian Fainelli
2017-01-25 21:25                         ` Greg KH
2017-01-25 21:25                           ` Greg KH
2017-01-30 22:46                           ` Florian Fainelli
2017-01-30 22:46                             ` Florian Fainelli
2017-01-30 22:46                             ` Florian Fainelli
2017-02-10 13:02                     ` Greg KH
2017-02-10 13:02                       ` Greg KH
2017-02-10 13:02                       ` Greg KH
2017-02-10 18:30                       ` Florian Fainelli
2017-02-10 18:30                         ` Florian Fainelli
2017-02-10 18:30                         ` Florian Fainelli
2017-02-12 12:56                         ` Greg KH
2017-02-12 12:56                           ` Greg KH
2017-01-14 21:47 ` [PATCH net-next v3 07/10] net: Relocate dev_to_net_device() into core Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-15 11:07   ` Greg KH
2017-01-15 11:07     ` Greg KH
2017-01-15 17:20     ` Florian Fainelli
2017-01-15 17:20       ` Florian Fainelli
2017-01-15 17:40       ` Greg KH
2017-01-15 17:40         ` Greg KH
2017-01-14 21:47 ` [PATCH net-next v3 08/10] net: dsa: Add support for platform data Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-14 21:47 ` [PATCH net-next v3 09/10] net: phy: Allow pre-declaration of MDIO devices Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-14 21:47 ` [PATCH net-next v3 10/10] ARM: orion: Register DSA switch as a MDIO device Florian Fainelli
2017-01-14 21:47   ` Florian Fainelli
2017-01-15 11:08 ` [PATCH net-next v3 00/10] net: dsa: Support for pdata in dsa2 Greg KH
2017-01-15 11:08   ` Greg KH
2017-01-15 17:40   ` Florian Fainelli
2017-01-15 17:40     ` Florian Fainelli
2017-01-15 17:49     ` Greg KH
2017-01-15 17:49       ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=841dc133-e9af-e7ca-75bf-8371337d6281@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.