From: Florian Fainelli <f.fainelli@gmail.com>
To: John Crispin <blogic@openwrt.org>,
"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, "Michael Lee" <igvtee@gmail.com>,
"Felix Fietkau" <nbd@openwrt.org>,
"\"Steven Liu (劉人豪)\"" <steven.liu@mediatek.com>,
"\"Fred Chang (張嘉宏)\"" <Fred.Chang@mediatek.com>,
"Andrew Lunn" <andrew@lunn.ch>,
jogo@openwrt.org
Subject: Re: [RFC 2/8] net-next: phy: dont auto handle carrier state when multiple phys are attached
Date: Tue, 24 Nov 2015 10:42:24 -0800 [thread overview]
Message-ID: <5654AF90.9060500@gmail.com> (raw)
In-Reply-To: <1448181658-38111-2-git-send-email-blogic@openwrt.org>
On 22/11/15 00:40, John Crispin wrote:
> A network core might have more than one phy attached to its cpu port via a
> switch. The current code will set the carrier state to on/off when ever a
> cable is plugged into any of these ports.
Not really, no. The current PHY library implementation does not allow
more than one net_device instance to be bound to multiple PHY devices.
Since this is an integrated switch, you should really expose per-port
network devices, that is the paradigm we settled down on using for
Ethernet switches now (irrespective of using DSA or switchdev, or both).
>
> The patch adds a new bool that allows the driver to tell the phy_device to not
> set the carrier state. Instead the driver can manually handle the carrier
> state.
I am missing the bigger picture of how this is used, also, if link down
is a problem, would not link up be for the same reasons?
>
> Signed-off-by: John Crispin <blogic@openwrt.org>
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> Signed-off-by: Michael Lee <igvtee@gmail.com>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> ---
> drivers/net/phy/phy.c | 9 ++++++---
> include/linux/phy.h | 1 +
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 48ce6ef..bd2df40 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -843,7 +843,8 @@ void phy_state_machine(struct work_struct *work)
> /* If the link is down, give up on negotiation for now */
> if (!phydev->link) {
> phydev->state = PHY_NOLINK;
> - netif_carrier_off(phydev->attached_dev);
> + if (!phydev->no_auto_carrier_off)
> + netif_carrier_off(phydev->attached_dev);
> phydev->adjust_link(phydev->attached_dev);
> break;
> }
> @@ -926,7 +927,8 @@ void phy_state_machine(struct work_struct *work)
> netif_carrier_on(phydev->attached_dev);
> } else {
> phydev->state = PHY_NOLINK;
> - netif_carrier_off(phydev->attached_dev);
> + if (!phydev->no_auto_carrier_off)
> + netif_carrier_off(phydev->attached_dev);
> }
>
> phydev->adjust_link(phydev->attached_dev);
> @@ -938,7 +940,8 @@ void phy_state_machine(struct work_struct *work)
> case PHY_HALTED:
> if (phydev->link) {
> phydev->link = 0;
> - netif_carrier_off(phydev->attached_dev);
> + if (!phydev->no_auto_carrier_off)
> + netif_carrier_off(phydev->attached_dev);
> phydev->adjust_link(phydev->attached_dev);
> do_suspend = true;
> }
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 05fde31..276ab8a 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -377,6 +377,7 @@ struct phy_device {
> bool is_pseudo_fixed_link;
> bool has_fixups;
> bool suspended;
> + bool no_auto_carrier_off;
>
> enum phy_state state;
>
>
--
Florian
next prev parent reply other threads:[~2015-11-24 18:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-22 8:40 [RFC 1/8] Documentation: DT: net: add docs for ralink/mediatek SoC ethernet binding John Crispin
2015-11-22 8:40 ` [RFC 2/8] net-next: phy: dont auto handle carrier state when multiple phys are attached John Crispin
2015-11-24 18:42 ` Florian Fainelli [this message]
2015-11-22 8:40 ` [RFC 3/8] net-next: ralink: add the drivers core files John Crispin
2015-11-22 8:40 ` [RFC 4/8] net-next: ralink: add support for rt2880 John Crispin
2015-11-22 8:40 ` [RFC 5/8] net-next: ralink: add support for rt3050 family John Crispin
2015-11-22 16:36 ` Andrew Lunn
2015-11-22 19:06 ` John Crispin
2015-11-22 23:16 ` Andrew Lunn
2015-11-23 6:47 ` John Crispin
2015-11-22 8:40 ` [RFC 6/8] net-next: ralink: add support for rt3883 John Crispin
2015-11-22 8:40 ` [RFC 7/8] net-next: ralink: add support for mt7620 family John Crispin
2015-11-22 8:40 ` [RFC 8/8] net-next: ralink: add Kconfig and Makefile John Crispin
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=5654AF90.9060500@gmail.com \
--to=f.fainelli@gmail.com \
--cc=Fred.Chang@mediatek.com \
--cc=andrew@lunn.ch \
--cc=blogic@openwrt.org \
--cc=davem@davemloft.net \
--cc=igvtee@gmail.com \
--cc=jogo@openwrt.org \
--cc=nbd@openwrt.org \
--cc=netdev@vger.kernel.org \
--cc=steven.liu@mediatek.com \
/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 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).