* [PATCH net-next 0/5] PHYLINK preparatory patches for DSA
@ 2017-11-30 19:57 Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 1/5] net: phy: phylink: Allow specifying PHY device flags Florian Fainelli
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Florian Fainelli @ 2017-11-30 19:57 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, rmk+kernel, vivien.didelot, Florian Fainelli
Hi all,
In preparation for having DSA migrate to PHYLINK, I had to come up with a
number of preparatory patches:
- we need to be able to pass phy_flags from an external component calling
phylink_of_phy_connect()
- DSA tries to connect through OF first, then fallsback using its own internal
MDIO bus, in that case we would both show an error, but also not know what
the correct phy_interface_t would be, instead use the PHY device/driver provided
one
- Finally bcm_sf2 makes use of all possible PHYs out there: internal, external,
fixed, and MoCA, the latter requires a bit of help to signal link notifications
through a MMIO interrupt, as well a report a correct PORT type
Florian Fainelli (5):
net: phy: phylink: Allow specifying PHY device flags
net: phy: phylink: Use PHY device interface if N/A
net: phy: phylink: Demote error message to debug
net: phy: phylink: Allow setting a custom link state callback
net: phy: phylink: Report MoCA as PORT_BNC
drivers/net/phy/phylink.c | 45 +++++++++++++++++++++++++++++++++++++++------
include/linux/phylink.h | 5 ++++-
2 files changed, 43 insertions(+), 7 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 1/5] net: phy: phylink: Allow specifying PHY device flags
2017-11-30 19:57 [PATCH net-next 0/5] PHYLINK preparatory patches for DSA Florian Fainelli
@ 2017-11-30 19:57 ` Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 2/5] net: phy: phylink: Use PHY device interface if N/A Florian Fainelli
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2017-11-30 19:57 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, rmk+kernel, vivien.didelot, Florian Fainelli
In order to let subsystems like DSA fully utilize PHYLINK, we need to be able
to communicate phy_device::flags from of_phy_{connect,attach} even when using
PHYLINK APIs.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phylink.c | 6 ++++--
include/linux/phylink.h | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e3bbc70372d3..0a81c7ff51b5 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -669,7 +669,8 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
}
EXPORT_SYMBOL_GPL(phylink_connect_phy);
-int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
+int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
+ u32 flags)
{
struct device_node *phy_node;
struct phy_device *phy_dev;
@@ -693,7 +694,8 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
return 0;
}
- phy_dev = of_phy_attach(pl->netdev, phy_node, 0, pl->link_interface);
+ phy_dev = of_phy_attach(pl->netdev, phy_node, flags,
+ pl->link_interface);
/* We're done with the phy_node handle */
of_node_put(phy_node);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index af67edd4ae38..875717a4e873 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -105,7 +105,7 @@ struct phylink *phylink_create(struct net_device *, struct device_node *,
void phylink_destroy(struct phylink *);
int phylink_connect_phy(struct phylink *, struct phy_device *);
-int phylink_of_phy_connect(struct phylink *, struct device_node *);
+int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
void phylink_disconnect_phy(struct phylink *);
void phylink_mac_change(struct phylink *, bool up);
--
2.14.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/5] net: phy: phylink: Use PHY device interface if N/A
2017-11-30 19:57 [PATCH net-next 0/5] PHYLINK preparatory patches for DSA Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 1/5] net: phy: phylink: Allow specifying PHY device flags Florian Fainelli
@ 2017-11-30 19:57 ` Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 3/5] net: phy: phylink: Demote error message to debug Florian Fainelli
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2017-11-30 19:57 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, rmk+kernel, vivien.didelot, Florian Fainelli
We may not always be able to resolve a correct phy_interface_t value before
actually connecting to the PHY device, when that happens, just have
phylink_connect_phy() utilize what the PHY device/driver provided.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phylink.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 0a81c7ff51b5..8a30ea8873af 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -657,6 +657,12 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
{
int ret;
+ /* Use PHY device/driver interface */
+ if (pl->link_interface == PHY_INTERFACE_MODE_NA) {
+ pl->link_interface = phy->interface;
+ pl->link_config.interface = pl->link_interface;
+ }
+
ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface);
if (ret)
return ret;
--
2.14.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/5] net: phy: phylink: Demote error message to debug
2017-11-30 19:57 [PATCH net-next 0/5] PHYLINK preparatory patches for DSA Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 1/5] net: phy: phylink: Allow specifying PHY device flags Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 2/5] net: phy: phylink: Use PHY device interface if N/A Florian Fainelli
@ 2017-11-30 19:57 ` Florian Fainelli
2017-11-30 23:26 ` Russell King - ARM Linux
2017-11-30 19:57 ` [PATCH net-next 4/5] net: phy: phylink: Allow setting a custom link state callback Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 5/5] net: phy: phylink: Report MoCA as PORT_BNC Florian Fainelli
4 siblings, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2017-11-30 19:57 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, rmk+kernel, vivien.didelot, Florian Fainelli
Some subsystems like DSA may be trying to connect to a PHY through OF first,
and then attempt a connect using a local MDIO bus, demote the error message:
"unable to find PHY node" into a debug print.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phylink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 8a30ea8873af..a41f0a224512 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -694,7 +694,7 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
if (!phy_node) {
if (pl->link_an_mode == MLO_AN_PHY) {
- netdev_err(pl->netdev, "unable to find PHY node\n");
+ netdev_dbg(pl->netdev, "unable to find PHY node\n");
return -ENODEV;
}
return 0;
--
2.14.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 4/5] net: phy: phylink: Allow setting a custom link state callback
2017-11-30 19:57 [PATCH net-next 0/5] PHYLINK preparatory patches for DSA Florian Fainelli
` (2 preceding siblings ...)
2017-11-30 19:57 ` [PATCH net-next 3/5] net: phy: phylink: Demote error message to debug Florian Fainelli
@ 2017-11-30 19:57 ` Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 5/5] net: phy: phylink: Report MoCA as PORT_BNC Florian Fainelli
4 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2017-11-30 19:57 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, rmk+kernel, vivien.didelot, Florian Fainelli
phylink_get_fixed_state() currently consults an optional "link_gpio"
GPIO descriptor, expand this mechanism to allow specifying a custom
callback. This is necessary to support out of band link notifcation
(e.g: from an interrupt within a MMIO register).
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phylink.c | 26 ++++++++++++++++++++++++--
include/linux/phylink.h | 3 +++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index a41f0a224512..0a8fd9aa1a19 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -50,6 +50,8 @@ struct phylink {
/* The link configuration settings */
struct phylink_link_state link_config;
struct gpio_desc *link_gpio;
+ void (*get_fixed_state)(struct net_device *dev,
+ struct phylink_link_state *s);
struct mutex state_mutex;
struct phylink_link_state phy_state;
@@ -339,12 +341,14 @@ static int phylink_get_mac_state(struct phylink *pl, struct phylink_link_state *
}
/* The fixed state is... fixed except for the link state,
- * which may be determined by a GPIO.
+ * which may be determined by a GPIO or a callback.
*/
static void phylink_get_fixed_state(struct phylink *pl, struct phylink_link_state *state)
{
*state = pl->link_config;
- if (pl->link_gpio)
+ if (pl->get_fixed_state)
+ pl->get_fixed_state(pl->netdev, state);
+ else if (pl->link_gpio)
state->link = !!gpiod_get_value(pl->link_gpio);
}
@@ -737,6 +741,24 @@ void phylink_disconnect_phy(struct phylink *pl)
}
EXPORT_SYMBOL_GPL(phylink_disconnect_phy);
+int phylink_fixed_state_cb(struct phylink *pl,
+ void (*cb)(struct net_device *dev,
+ struct phylink_link_state *state))
+{
+ /* It does not make sense to let the link be overriden unless we use
+ * MLO_AN_FIXED
+ */
+ if (pl->link_an_mode != MLO_AN_FIXED)
+ return -EINVAL;
+
+ mutex_lock(&pl->state_mutex);
+ pl->get_fixed_state = cb;
+ mutex_unlock(&pl->state_mutex);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(phylink_fixed_state_cb);
+
void phylink_mac_change(struct phylink *pl, bool up)
{
if (!up)
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 875717a4e873..d505ea321eb5 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -107,6 +107,9 @@ void phylink_destroy(struct phylink *);
int phylink_connect_phy(struct phylink *, struct phy_device *);
int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
void phylink_disconnect_phy(struct phylink *);
+int phylink_fixed_state_cb(struct phylink *,
+ void (*cb)(struct net_device *dev,
+ struct phylink_link_state *));
void phylink_mac_change(struct phylink *, bool up);
--
2.14.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 5/5] net: phy: phylink: Report MoCA as PORT_BNC
2017-11-30 19:57 [PATCH net-next 0/5] PHYLINK preparatory patches for DSA Florian Fainelli
` (3 preceding siblings ...)
2017-11-30 19:57 ` [PATCH net-next 4/5] net: phy: phylink: Allow setting a custom link state callback Florian Fainelli
@ 2017-11-30 19:57 ` Florian Fainelli
4 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2017-11-30 19:57 UTC (permalink / raw)
To: netdev; +Cc: davem, andrew, rmk+kernel, vivien.didelot, Florian Fainelli
Similarly to what PHYLIB already does, make sure that
PHY_INTERFACE_MODE_MOCA is reported as PORT_BNC.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phylink.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 0a8fd9aa1a19..20c48fbebdfb 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -525,7 +525,10 @@ struct phylink *phylink_create(struct net_device *ndev, struct device_node *np,
pl->netdev = ndev;
pl->phy_state.interface = iface;
pl->link_interface = iface;
- pl->link_port = PORT_MII;
+ if (iface == PHY_INTERFACE_MODE_MOCA)
+ pl->link_port = PORT_BNC;
+ else
+ pl->link_port = PORT_MII;
pl->link_config.interface = iface;
pl->link_config.pause = MLO_PAUSE_AN;
pl->link_config.speed = SPEED_UNKNOWN;
--
2.14.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/5] net: phy: phylink: Demote error message to debug
2017-11-30 19:57 ` [PATCH net-next 3/5] net: phy: phylink: Demote error message to debug Florian Fainelli
@ 2017-11-30 23:26 ` Russell King - ARM Linux
2017-11-30 23:36 ` Florian Fainelli
0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2017-11-30 23:26 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev, davem, andrew, vivien.didelot
On Thu, Nov 30, 2017 at 11:57:42AM -0800, Florian Fainelli wrote:
> Some subsystems like DSA may be trying to connect to a PHY through OF first,
> and then attempt a connect using a local MDIO bus, demote the error message:
> "unable to find PHY node" into a debug print.
Maybe it would be better to push this out to the drivers to print
if they wish?
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/5] net: phy: phylink: Demote error message to debug
2017-11-30 23:26 ` Russell King - ARM Linux
@ 2017-11-30 23:36 ` Florian Fainelli
0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2017-11-30 23:36 UTC (permalink / raw)
To: Russell King - ARM Linux; +Cc: netdev, davem, andrew, vivien.didelot
On 11/30/2017 03:26 PM, Russell King - ARM Linux wrote:
> On Thu, Nov 30, 2017 at 11:57:42AM -0800, Florian Fainelli wrote:
>> Some subsystems like DSA may be trying to connect to a PHY through OF first,
>> and then attempt a connect using a local MDIO bus, demote the error message:
>> "unable to find PHY node" into a debug print.
>
> Maybe it would be better to push this out to the drivers to print
> if they wish?
>
Sure, I will just drop that message then.
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-11-30 23:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-30 19:57 [PATCH net-next 0/5] PHYLINK preparatory patches for DSA Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 1/5] net: phy: phylink: Allow specifying PHY device flags Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 2/5] net: phy: phylink: Use PHY device interface if N/A Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 3/5] net: phy: phylink: Demote error message to debug Florian Fainelli
2017-11-30 23:26 ` Russell King - ARM Linux
2017-11-30 23:36 ` Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 4/5] net: phy: phylink: Allow setting a custom link state callback Florian Fainelli
2017-11-30 19:57 ` [PATCH net-next 5/5] net: phy: phylink: Report MoCA as PORT_BNC Florian Fainelli
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).