* [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY
@ 2011-09-08 6:54 Lambrecht Jürgen
2011-09-08 8:39 ` Florian Fainelli
2011-09-08 10:13 ` Francois Romieu
0 siblings, 2 replies; 6+ messages in thread
From: Lambrecht Jürgen @ 2011-09-08 6:54 UTC (permalink / raw)
To: netdev@vger.kernel.org; +Cc: linux-embedded@vger.kernel.org
Hello,
In our embedded designs, this is a useful patch. Maybe it can be useful
for somebody else too.
Or maybe there are already better solutions?
I know I could also write a driver for our switch, but that is too much
effort just to select the active port.
Kind regards,
Jürgen
In embedded design, instead of a PHY, sometimes a switch is used that
behaves as a PHY through its MII port. For example to use a daisy
chain network configuration instead of an expensive star config.
In that case, many phy ports are available, but only 1 should
be used
to check link status, and not the first one available as is
the case
without this configuration (that is, set to its default value 0).
So this options specifies the switch port number to be used
to check
link status, because if the link is down, no data is sent by the
TCP/IP stack.
Signed-off-by: Jürgen Lambrecht <J.Lambrecht@televic.com>
---
drivers/net/phy/Kconfig | 14 ++++++++++++++
drivers/net/phy/mdio_bus.c | 9 +++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index a702443..554561f 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -13,6 +13,20 @@ menuconfig PHYLIB
if PHYLIB
+config SWITCH_PHY
+ int "External switch port to be used if switch is used as PHY"
+ default "0"
+ help
+ In embedded design, instead of a PHY, sometimes a switch is
used that
+ behaves as a PHY through its MII port. For example to use a daisy
+ chain network configuration instead of an expensive star config.
+ In that case, many phy ports are available, but only 1 should
be used
+ to check link status, and not the first one available as is
the case
+ without this configuration (that is, set to its default value 0).
+ So this options specifies the switch port number to be used to
check
+ link status, because if the link is down, no data is sent by the
+ TCP/IP stack.
+
comment "MII PHY device drivers"
config MARVELL_PHY
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6c58da2..016437a 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -112,7 +112,14 @@ int mdiobus_register(struct mii_bus *bus)
if (bus->reset)
bus->reset(bus);
+ /* The config below is always availble with CONFIG_PHYLIB. If 0, the
+ behavior is as before without this patch (or P0 of the switch is
+ taken because it is the first one found). */
+#if CONFIG_SWITCH_PHY
+ i = CONFIG_SWITCH_PHY;
+#else
for (i = 0; i < PHY_MAX_ADDR; i++) {
+#endif
if ((bus->phy_mask & (1 << i)) == 0) {
struct phy_device *phydev;
@@ -122,7 +129,9 @@ int mdiobus_register(struct mii_bus *bus)
goto error;
}
}
+#if !CONFIG_SWITCH_PHY
}
+#endif
bus->state = MDIOBUS_REGISTERED;
pr_info("%s: probed\n", bus->name);
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY
2011-09-08 6:54 [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY Lambrecht Jürgen
@ 2011-09-08 8:39 ` Florian Fainelli
2011-09-08 10:00 ` Lambrecht Jürgen
2011-09-08 10:13 ` Francois Romieu
1 sibling, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2011-09-08 8:39 UTC (permalink / raw)
To: Lambrecht Jürgen
Cc: netdev@vger.kernel.org, linux-embedded@vger.kernel.org
Hello Jurgen,
On Thursday 08 September 2011 08:54:07 Lambrecht Jürgen wrote:
> Hello,
>
> In our embedded designs, this is a useful patch. Maybe it can be useful
> for somebody else too.
> Or maybe there are already better solutions?
> I know I could also write a driver for our switch, but that is too much
> effort just to select the active port.
This is not going to work well with all switches out there. You could use the
fixed-PHY driver to make your ethernet driver see the link as always up between
the MAC and switch CPU port.
A better solution would be to have proper switch drivers and user-space, which
reminds me that we (OpenWrt) should at some point propose our switch drivers
[1] for review.
[1]:
https://dev.openwrt.org/browser/trunk/target/linux/generic/files/drivers/net/phy/
>
> Kind regards,
> Jürgen
>
> In embedded design, instead of a PHY, sometimes a switch is used that
> behaves as a PHY through its MII port. For example to use a
> daisy chain network configuration instead of an expensive star config. In
> that case, many phy ports are available, but only 1 should be used
> to check link status, and not the first one available as is
> the case
> without this configuration (that is, set to its default value
> 0). So this options specifies the switch port number to be used to check
> link status, because if the link is down, no data is sent by the
> TCP/IP stack.
>
> Signed-off-by: Jürgen Lambrecht <J.Lambrecht@televic.com>
> ---
> drivers/net/phy/Kconfig | 14 ++++++++++++++
> drivers/net/phy/mdio_bus.c | 9 +++++++++
> 2 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index a702443..554561f 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -13,6 +13,20 @@ menuconfig PHYLIB
>
> if PHYLIB
>
> +config SWITCH_PHY
> + int "External switch port to be used if switch is used as PHY"
> + default "0"
> + help
> + In embedded design, instead of a PHY, sometimes a switch is
> used that
> + behaves as a PHY through its MII port. For example to use a daisy
> + chain network configuration instead of an expensive star config.
> + In that case, many phy ports are available, but only 1 should
> be used
> + to check link status, and not the first one available as is
> the case
> + without this configuration (that is, set to its default value 0).
> + So this options specifies the switch port number to be used to
> check
> + link status, because if the link is down, no data is sent by the
> + TCP/IP stack.
> +
> comment "MII PHY device drivers"
>
> config MARVELL_PHY
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 6c58da2..016437a 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -112,7 +112,14 @@ int mdiobus_register(struct mii_bus *bus)
> if (bus->reset)
> bus->reset(bus);
>
> + /* The config below is always availble with CONFIG_PHYLIB. If 0,
> the + behavior is as before without this patch (or P0 of the
> switch is + taken because it is the first one found). */
> +#if CONFIG_SWITCH_PHY
> + i = CONFIG_SWITCH_PHY;
> +#else
> for (i = 0; i < PHY_MAX_ADDR; i++) {
> +#endif
> if ((bus->phy_mask & (1 << i)) == 0) {
> struct phy_device *phydev;
>
> @@ -122,7 +129,9 @@ int mdiobus_register(struct mii_bus *bus)
> goto error;
> }
> }
> +#if !CONFIG_SWITCH_PHY
> }
> +#endif
>
> bus->state = MDIOBUS_REGISTERED;
> pr_info("%s: probed\n", bus->name);
> --
> 1.7.1
> N�����r��y����b�X��ǧv�^�)޺{.n�+���z�^�)����w*\x1fjg���\x1e�����ݢj/���z�ޖ��2�ޙ����
> &�)ߡ�a��\x7f��\x1e�G���h�\x0f�j:+v���w��٥
--
Florian
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY
2011-09-08 6:54 [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY Lambrecht Jürgen
2011-09-08 8:39 ` Florian Fainelli
@ 2011-09-08 10:13 ` Francois Romieu
2011-09-08 11:59 ` Lambrecht Jürgen
1 sibling, 1 reply; 6+ messages in thread
From: Francois Romieu @ 2011-09-08 10:13 UTC (permalink / raw)
To: Lambrecht Jürgen
Cc: netdev@vger.kernel.org, linux-embedded@vger.kernel.org
Lambrecht Jürgen <J.Lambrecht@TELEVIC.com> :
[...]
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 6c58da2..016437a 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -112,7 +112,14 @@ int mdiobus_register(struct mii_bus *bus)
> if (bus->reset)
> bus->reset(bus);
>
> + /* The config below is always availble with CONFIG_PHYLIB. If 0, the
> + behavior is as before without this patch (or P0 of the switch is
> + taken because it is the first one found). */
> +#if CONFIG_SWITCH_PHY
> + i = CONFIG_SWITCH_PHY;
> +#else
> for (i = 0; i < PHY_MAX_ADDR; i++) {
> +#endif
> if ((bus->phy_mask & (1 << i)) == 0) {
> struct phy_device *phydev;
This config option may help your platform but it is nowhere reusable on a
slightly different one (each mii_bus behavior is changed).
Which driver(s) do you use that you can not set phy_mask directly ?
--
Ueimor
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY
2011-09-08 10:13 ` Francois Romieu
@ 2011-09-08 11:59 ` Lambrecht Jürgen
2011-09-08 21:24 ` Francois Romieu
0 siblings, 1 reply; 6+ messages in thread
From: Lambrecht Jürgen @ 2011-09-08 11:59 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev@vger.kernel.org, linux-embedded@vger.kernel.org
On 09/08/2011 12:13 PM, Francois Romieu wrote:
>
> Lambrecht Jürgen <J.Lambrecht@TELEVIC.com> :
> [...]
> > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > index 6c58da2..016437a 100644
> > --- a/drivers/net/phy/mdio_bus.c
> > +++ b/drivers/net/phy/mdio_bus.c
> > @@ -112,7 +112,14 @@ int mdiobus_register(struct mii_bus *bus)
> > if (bus->reset)
> > bus->reset(bus);
> >
> > + /* The config below is always availble with CONFIG_PHYLIB.
> If 0, the
> > + behavior is as before without this patch (or P0 of the
> switch is
> > + taken because it is the first one found). */
> > +#if CONFIG_SWITCH_PHY
> > + i = CONFIG_SWITCH_PHY;
> > +#else
> > for (i = 0; i < PHY_MAX_ADDR; i++) {
> > +#endif
> > if ((bus->phy_mask & (1 << i)) == 0) {
> > struct phy_device *phydev;
>
> This config option may help your platform but it is nowhere reusable on a
> slightly different one (each mii_bus behavior is changed).
>
> Which driver(s) do you use that you can not set phy_mask directly ?
>
The HW driver is 'FEC' for iMX Ethernet. For the PHY, just MII and PHYLIB.
I am rather new to linux, didn't knew phy_mask. Checked it now, and is
not set in fec.c.
You mean then to patch drivers/net/fec.c in the same way (as my current
patch) to set the phy_mask instead (via menuconfig, or in the platform
init)?
Thanks for your reply,
Jürgen
>
>
> --
> Ueimor
>
--
Jürgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY
2011-09-08 11:59 ` Lambrecht Jürgen
@ 2011-09-08 21:24 ` Francois Romieu
0 siblings, 0 replies; 6+ messages in thread
From: Francois Romieu @ 2011-09-08 21:24 UTC (permalink / raw)
To: Lambrecht Jürgen
Cc: netdev@vger.kernel.org, linux-embedded@vger.kernel.org
Lambrecht Jürgen <J.Lambrecht@TELEVIC.com> :
> On 09/08/2011 12:13 PM, Francois Romieu wrote:
[...]
> > Which driver(s) do you use that you can not set phy_mask directly ?
> >
> The HW driver is 'FEC' for iMX Ethernet. For the PHY, just MII and PHYLIB.
> I am rather new to linux, didn't knew phy_mask. Checked it now, and is
> not set in fec.c.
> You mean then to patch drivers/net/fec.c in the same way (as my current
> patch) to set the phy_mask instead (via menuconfig, or in the platform
> init)?
It is not my area but I would have drivers/net/fec.c::fec_devtype.driver_data
point to a real struct where the relevant phy_mask and the current quirks
are stored, then add a new entry in fec_devtype and a reference to it
(Kconfig + platform init) somewhere below arch/arm/plat-mxc.
Freescale's application note suggests that the MX25 fec allows some freedom
for the implementation of the media interface. So it may not be overkill.
--
Ueimor
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-08 21:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-08 6:54 [PATCH] net: phy: Add config option to specify external switch port to be used if switch is used as PHY Lambrecht Jürgen
2011-09-08 8:39 ` Florian Fainelli
2011-09-08 10:00 ` Lambrecht Jürgen
2011-09-08 10:13 ` Francois Romieu
2011-09-08 11:59 ` Lambrecht Jürgen
2011-09-08 21:24 ` Francois Romieu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).