netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] net: phy: small cleanups and improvements
@ 2014-02-12  1:27 Florian Fainelli
  2014-02-12  1:27 ` [PATCH 01/10] net: phy: use network device in phy_print_status Florian Fainelli
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Hi David,

This patchset contains some small cleanups which have been sent on the
mailing-list before to improve phy_print_status() and make it useful.

The second part of the patch allows PHY drivers to implement their own
aneg_done() callback.

Finally, two new sysfs properties are exposed to help troubleshoot libphy
aware Linux systems.

Thanks!

Florian Fainelli (10):
  net: phy: use network device in phy_print_status
  net: phy: update phy_print_status to show pause settings
  net: phy: display human readable PHY speed settings
  net: phy: add genphy_aneg_done()
  net: phy: allow driver to implement their own aneg_done
  net: phy: fix phy_{clear,config}_interrupt comment typos
  net: phy: re-design phy_modes to be self-contained
  net: phy: expose PHY device interface mode
  net: phy: add "has_fixups" boolean property
  net: phy: expose phydev->has_fixups to sysfs

 Documentation/ABI/testing/sysfs-bus-mdio | 21 ++++++++++++++
 drivers/net/phy/mdio_bus.c               | 20 ++++++++++++++
 drivers/net/phy/phy.c                    | 46 +++++++++++++++++++++++--------
 drivers/net/phy/phy_device.c             | 18 ++++++++++++
 drivers/of/of_net.c                      | 26 ++----------------
 include/linux/phy.h                      | 47 ++++++++++++++++++++++++++++++++
 6 files changed, 142 insertions(+), 36 deletions(-)

-- 
1.8.3.2

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/10] net: phy: use network device in phy_print_status
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-13  0:13   ` David Miller
  2014-02-12  1:27 ` [PATCH 02/10] net: phy: update phy_print_status to show pause settings Florian Fainelli
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

phy_print_status() currently uses dev_name(&phydev->dev) which will
usually result in printing something along those lines for Device Tree
aware drivers:

libphy: f0b60000.etherne:0a - Link is Down
libphy: f0ba0000.etherne:00 - Link is Up - 1000/Full

This is not terribly useful for network administrators or users since we
expect a network interface name to be able to correlate link events with
interfaces. Update phy_print_status() to use netdev_info() with
phydev->attached_dev which is the backing network device for our PHY
device. The leading dash is removed since netdev_info() prefixes the
messages with "<interface>: " already.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 19c9eca..c35b2e7 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -45,12 +45,11 @@
 void phy_print_status(struct phy_device *phydev)
 {
 	if (phydev->link) {
-		pr_info("%s - Link is Up - %d/%s\n",
-			dev_name(&phydev->dev),
+		netdev_info(phydev->attached_dev, "Link is Up - %d/%s\n",
 			phydev->speed,
 			DUPLEX_FULL == phydev->duplex ? "Full" : "Half");
 	} else	{
-		pr_info("%s - Link is Down\n", dev_name(&phydev->dev));
+		netdev_info(phydev->attached_dev, "Link is Down\n");
 	}
 }
 EXPORT_SYMBOL(phy_print_status);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/10] net: phy: update phy_print_status to show pause settings
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
  2014-02-12  1:27 ` [PATCH 01/10] net: phy: use network device in phy_print_status Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12  1:27 ` [PATCH 03/10] net: phy: display human readable PHY speed settings Florian Fainelli
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Update phy_print_status() to also display the PHY device pause settings
(rx/tx or off).

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index c35b2e7..8ae2260 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -45,9 +45,11 @@
 void phy_print_status(struct phy_device *phydev)
 {
 	if (phydev->link) {
-		netdev_info(phydev->attached_dev, "Link is Up - %d/%s\n",
+		netdev_info(phydev->attached_dev,
+			"Link is Up - %d/%s - flow control %s\n",
 			phydev->speed,
-			DUPLEX_FULL == phydev->duplex ? "Full" : "Half");
+			DUPLEX_FULL == phydev->duplex ? "Full" : "Half",
+			phydev->pause ? "rx/tx" : "off");
 	} else	{
 		netdev_info(phydev->attached_dev, "Link is Down\n");
 	}
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/10] net: phy: display human readable PHY speed settings
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
  2014-02-12  1:27 ` [PATCH 01/10] net: phy: use network device in phy_print_status Florian Fainelli
  2014-02-12  1:27 ` [PATCH 02/10] net: phy: update phy_print_status to show pause settings Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12  1:27 ` [PATCH 04/10] net: phy: add genphy_aneg_done() Florian Fainelli
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Use a convenience function: phy_speed_to_str() which will display human
readable speeds.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 8ae2260..36fc6e1 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -38,6 +38,26 @@
 
 #include <asm/irq.h>
 
+static const char *phy_speed_to_str(int speed)
+{
+	switch (speed) {
+	case SPEED_10:
+		return "10Mbps";
+	case SPEED_100:
+		return "100Mbps";
+	case SPEED_1000:
+		return "1Gbps";
+	case SPEED_2500:
+		return "2.5Gbps";
+	case SPEED_10000:
+		return "10Gbps";
+	case SPEED_UNKNOWN:
+		return "Unknown";
+	default:
+		return "Unsupported (update phy.c)";
+	}
+}
+
 /**
  * phy_print_status - Convenience function to print out the current phy status
  * @phydev: the phy_device struct
@@ -46,8 +66,8 @@ void phy_print_status(struct phy_device *phydev)
 {
 	if (phydev->link) {
 		netdev_info(phydev->attached_dev,
-			"Link is Up - %d/%s - flow control %s\n",
-			phydev->speed,
+			"Link is Up - %s/%s - flow control %s\n",
+			phy_speed_to_str(phydev->speed),
 			DUPLEX_FULL == phydev->duplex ? "Full" : "Half",
 			phydev->pause ? "rx/tx" : "off");
 	} else	{
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/10] net: phy: add genphy_aneg_done()
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
                   ` (2 preceding siblings ...)
  2014-02-12  1:27 ` [PATCH 03/10] net: phy: display human readable PHY speed settings Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12 14:43   ` Sergei Shtylyov
  2014-02-12  1:27 ` [PATCH 05/10] net: phy: allow driver to implement their own aneg_done Florian Fainelli
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

In preparation for allowing PHY drivers to potentially override their
auto-negotiation done callback, move the contents of phy_aneg_done() to
genphy_aneg_done() since that function really is the generic
implementation based on the BMSR_ANEGCOMPLETE status.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c        |  4 +---
 drivers/net/phy/phy_device.c | 16 ++++++++++++++++
 include/linux/phy.h          |  1 +
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 36fc6e1..db9c543 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -120,9 +120,7 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
  */
 static inline int phy_aneg_done(struct phy_device *phydev)
 {
-	int retval = phy_read(phydev, MII_BMSR);
-
-	return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);
+	return genphy_aneg_done(phydev);
 }
 
 /* A structure for mapping a particular speed and duplex
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 82514e7..4e7db72 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -865,6 +865,22 @@ int genphy_config_aneg(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(genphy_config_aneg);
 
+/**
+ * genphy_aneg_done - return auto-negotiation status
+ * @phydev: target phy_device struct
+ *
+ * Description: Reads the status register and returns 0 either if
+ *   auto-negotiation is incomplete, or if there was an error.
+ *   Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
+ */
+int genphy_aneg_done(struct phy_device *phydev)
+{
+	int retval = phy_read(phydev, MII_BMSR);
+
+	return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);
+}
+EXPORT_SYMBOL(genphy_aneg_done);
+
 static int gen10g_config_aneg(struct phy_device *phydev)
 {
 	return 0;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 565188c..c572842 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -612,6 +612,7 @@ static inline int phy_read_status(struct phy_device *phydev)
 int genphy_setup_forced(struct phy_device *phydev);
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_config_aneg(struct phy_device *phydev);
+int genphy_aneg_done(struct phy_device *phydev);
 int genphy_update_link(struct phy_device *phydev);
 int genphy_read_status(struct phy_device *phydev);
 int genphy_suspend(struct phy_device *phydev);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/10] net: phy: allow driver to implement their own aneg_done
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
                   ` (3 preceding siblings ...)
  2014-02-12  1:27 ` [PATCH 04/10] net: phy: add genphy_aneg_done() Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12  1:27 ` [PATCH 06/10] net: phy: fix phy_{clear,config}_interrupt comment typos Florian Fainelli
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Some PHYs out there can be very quirky with respect to how they would
report the auto-negotiation is completed. Allow drivers to override the
generic aneg_done() implementation by providing their own.

Since not all drivers have been updated yet to use genphy_aneg_done() as
aneg_done() callback, we explicitely check that this callback is valid
before calling into it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c        | 9 ++++++---
 drivers/net/phy/phy_device.c | 1 +
 include/linux/phy.h          | 3 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index db9c543..2fa4611 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -114,12 +114,15 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
  * phy_aneg_done - return auto-negotiation status
  * @phydev: target phy_device struct
  *
- * Description: Reads the status register and returns 0 either if
- *   auto-negotiation is incomplete, or if there was an error.
- *   Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
+ * Description: Return the auto-negotiation status from this @phydev
+ * Returns > 0 on success or < 0 on error. 0 means that auto-negotiation
+ * is still pending.
  */
 static inline int phy_aneg_done(struct phy_device *phydev)
 {
+	if (phydev->drv->aneg_done)
+		return phydev->drv->aneg_done(phydev);
+
 	return genphy_aneg_done(phydev);
 }
 
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 4e7db72..7c18420 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1267,6 +1267,7 @@ static struct phy_driver genphy_driver[] = {
 	.config_init	= genphy_config_init,
 	.features	= 0,
 	.config_aneg	= genphy_config_aneg,
+	.aneg_done	= genphy_aneg_done,
 	.read_status	= genphy_read_status,
 	.suspend	= genphy_suspend,
 	.resume		= genphy_resume,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index c572842..eede657 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -417,6 +417,9 @@ struct phy_driver {
 	 */
 	int (*config_aneg)(struct phy_device *phydev);
 
+	/* Determines the auto negotiation result */
+	int (*aneg_done)(struct phy_device *phydev);
+
 	/* Determines the negotiated speed and duplex */
 	int (*read_status)(struct phy_device *phydev);
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/10] net: phy: fix phy_{clear,config}_interrupt comment typos
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
                   ` (4 preceding siblings ...)
  2014-02-12  1:27 ` [PATCH 05/10] net: phy: allow driver to implement their own aneg_done Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12  1:27 ` [PATCH 07/10] net: phy: re-design phy_modes to be self-contained Florian Fainelli
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

The comments above phy_{clear,config}_interrupt used the word "on"
instead of "or", when talking about the return values of the functions,
fix these two typos.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2fa4611..fc918b6 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -83,7 +83,7 @@ EXPORT_SYMBOL(phy_print_status);
  * If the @phydev driver has an ack_interrupt function, call it to
  * ack and clear the phy device's interrupt.
  *
- * Returns 0 on success on < 0 on error.
+ * Returns 0 on success or < 0 on error.
  */
 static int phy_clear_interrupt(struct phy_device *phydev)
 {
@@ -98,7 +98,7 @@ static int phy_clear_interrupt(struct phy_device *phydev)
  * @phydev: the phy_device struct
  * @interrupts: interrupt flags to configure for this @phydev
  *
- * Returns 0 on success on < 0 on error.
+ * Returns 0 on success or < 0 on error.
  */
 static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
 {
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/10] net: phy: re-design phy_modes to be self-contained
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
                   ` (5 preceding siblings ...)
  2014-02-12  1:27 ` [PATCH 06/10] net: phy: fix phy_{clear,config}_interrupt comment typos Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12  1:27 ` [PATCH 08/10] net: phy: expose PHY device interface mode Florian Fainelli
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

of_get_phy_mode() uses a local array to map phy_interface_t values from
include/linux/net/phy.h to a string which is read from the 'phy-mode' or
'phy-connection-type' property. In preparation for exposing the PHY
interface mode through sysfs, perform the following:

- mode phy_modes from drivers/of/of_net.c to include/linux/phy.h such
  that it is right below the phy_interface_t enum
- make it a static inline function returning the string such that we can
  use it by just including include/linux/net/phy.h
- add a PHY_INTERFACE_MODE_MAX enum value to guard the iteration in
  of_get_phy_mode()

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/of/of_net.c | 26 ++------------------------
 include/linux/phy.h | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index a208a45..84215c1 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -12,28 +12,6 @@
 #include <linux/export.h>
 
 /**
- * It maps 'enum phy_interface_t' found in include/linux/phy.h
- * into the device tree binding of 'phy-mode', so that Ethernet
- * device driver can get phy interface from device tree.
- */
-static const char *phy_modes[] = {
-	[PHY_INTERFACE_MODE_NA]		= "",
-	[PHY_INTERFACE_MODE_MII]	= "mii",
-	[PHY_INTERFACE_MODE_GMII]	= "gmii",
-	[PHY_INTERFACE_MODE_SGMII]	= "sgmii",
-	[PHY_INTERFACE_MODE_TBI]	= "tbi",
-	[PHY_INTERFACE_MODE_REVMII]	= "rev-mii",
-	[PHY_INTERFACE_MODE_RMII]	= "rmii",
-	[PHY_INTERFACE_MODE_RGMII]	= "rgmii",
-	[PHY_INTERFACE_MODE_RGMII_ID]	= "rgmii-id",
-	[PHY_INTERFACE_MODE_RGMII_RXID]	= "rgmii-rxid",
-	[PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
-	[PHY_INTERFACE_MODE_RTBI]	= "rtbi",
-	[PHY_INTERFACE_MODE_SMII]	= "smii",
-	[PHY_INTERFACE_MODE_XGMII]	= "xgmii",
-};
-
-/**
  * of_get_phy_mode - Get phy mode for given device_node
  * @np:	Pointer to the given device_node
  *
@@ -49,8 +27,8 @@ int of_get_phy_mode(struct device_node *np)
 	if (err < 0)
 		return err;
 
-	for (i = 0; i < ARRAY_SIZE(phy_modes); i++)
-		if (!strcasecmp(pm, phy_modes[i]))
+	for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++)
+		if (!strcasecmp(pm, phy_modes(i)))
 			return i;
 
 	return -ENODEV;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index eede657..ef7fa11 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -74,8 +74,50 @@ typedef enum {
 	PHY_INTERFACE_MODE_RTBI,
 	PHY_INTERFACE_MODE_SMII,
 	PHY_INTERFACE_MODE_XGMII,
+	PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
+/**
+ * It maps 'enum phy_interface_t' found in include/linux/phy.h
+ * into the device tree binding of 'phy-mode', so that Ethernet
+ * device driver can get phy interface from device tree.
+ */
+static inline const char *phy_modes(phy_interface_t interface)
+{
+	switch (interface) {
+	case PHY_INTERFACE_MODE_NA:
+		return "";
+	case PHY_INTERFACE_MODE_MII:
+		return "mii";
+	case PHY_INTERFACE_MODE_GMII:
+		return "gmii";
+	case PHY_INTERFACE_MODE_SGMII:
+		return "sgmii";
+	case PHY_INTERFACE_MODE_TBI:
+		return "tbi";
+	case PHY_INTERFACE_MODE_REVMII:
+		return "rev-mii";
+	case PHY_INTERFACE_MODE_RMII:
+		return "rmii";
+	case PHY_INTERFACE_MODE_RGMII:
+		return "rgmii";
+	case PHY_INTERFACE_MODE_RGMII_ID:
+		return "rgmii-id";
+	case PHY_INTERFACE_MODE_RGMII_RXID:
+		return "rgmii-rxid";
+	case PHY_INTERFACE_MODE_RGMII_TXID:
+		return "rgmii-txid";
+	case PHY_INTERFACE_MODE_RTBI:
+		return "rtbi";
+	case PHY_INTERFACE_MODE_SMII:
+		return "smii";
+	case PHY_INTERFACE_MODE_XGMII:
+		return "xgmii";
+	default:
+		return "unknown";
+	}
+}
+
 
 #define PHY_INIT_TIMEOUT	100000
 #define PHY_STATE_TIME		1
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/10] net: phy: expose PHY device interface mode
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
                   ` (6 preceding siblings ...)
  2014-02-12  1:27 ` [PATCH 07/10] net: phy: re-design phy_modes to be self-contained Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12  1:27 ` [PATCH 09/10] net: phy: add "has_fixups" boolean property Florian Fainelli
  2014-02-12  1:27 ` [PATCH 10/10] net: phy: expose phydev->has_fixups to sysfs Florian Fainelli
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Expose the PHY device interface mode through sysfs since this is an
useful piece of information for knowing how the attached networking
device will have configured its transmit/receive path.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 Documentation/ABI/testing/sysfs-bus-mdio | 10 ++++++++++
 drivers/net/phy/mdio_bus.c               | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-mdio b/Documentation/ABI/testing/sysfs-bus-mdio
index 6349749..2133afd 100644
--- a/Documentation/ABI/testing/sysfs-bus-mdio
+++ b/Documentation/ABI/testing/sysfs-bus-mdio
@@ -7,3 +7,13 @@ Description:
 		by the device during bus enumeration, encoded in hexadecimal.
 		This ID is used to match the device with the appropriate
 		driver.
+
+What:		/sys/bus/mdio_bus/devices/.../phy_interface
+Date:		February 2014
+KernelVersion:	3.15
+Contact:	netdev@vger.kernel.org
+Description:
+		This attribute contains the PHY interface as configured by the
+		Ethernet driver during bus enumeration, encoded in string.
+		This interface mode is used to configure the Ethernet MAC with the
+		appropriate mode for its data lines to the PHY hardware.
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 71e4900..7c66ea0 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -432,8 +432,18 @@ phy_id_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR_RO(phy_id);
 
+static ssize_t
+phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct phy_device *phydev = to_phy_device(dev);
+
+	return sprintf(buf, "%s\n", phy_modes(phydev->interface));
+}
+static DEVICE_ATTR_RO(phy_interface);
+
 static struct attribute *mdio_dev_attrs[] = {
 	&dev_attr_phy_id.attr,
+	&dev_attr_phy_interface.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(mdio_dev);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/10] net: phy: add "has_fixups" boolean property
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
                   ` (7 preceding siblings ...)
  2014-02-12  1:27 ` [PATCH 08/10] net: phy: expose PHY device interface mode Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  2014-02-12  1:27 ` [PATCH 10/10] net: phy: expose phydev->has_fixups to sysfs Florian Fainelli
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Add a boolean property which indicates if the PHY has had any fixup
routine ran on it. We are later going to use that boolean to expose it
as a sysfs property to help troubleshooting.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy_device.c | 1 +
 include/linux/phy.h          | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7c18420..c2d778d 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -139,6 +139,7 @@ static int phy_scan_fixups(struct phy_device *phydev)
 				mutex_unlock(&phy_fixup_lock);
 				return err;
 			}
+			phydev->has_fixups = true;
 		}
 	}
 	mutex_unlock(&phy_fixup_lock);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index ef7fa11..42f1bc7 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -350,6 +350,7 @@ struct phy_device {
 	struct phy_c45_device_ids c45_ids;
 	bool is_c45;
 	bool is_internal;
+	bool has_fixups;
 
 	enum phy_state state;
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/10] net: phy: expose phydev->has_fixups to sysfs
  2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
                   ` (8 preceding siblings ...)
  2014-02-12  1:27 ` [PATCH 09/10] net: phy: add "has_fixups" boolean property Florian Fainelli
@ 2014-02-12  1:27 ` Florian Fainelli
  9 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2014-02-12  1:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Expose the PHY device has_fixups boolean as a sysfs property to help
troubleshooting PHY configurations.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 Documentation/ABI/testing/sysfs-bus-mdio | 11 +++++++++++
 drivers/net/phy/mdio_bus.c               | 10 ++++++++++
 2 files changed, 21 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-mdio b/Documentation/ABI/testing/sysfs-bus-mdio
index 2133afd..fcab995 100644
--- a/Documentation/ABI/testing/sysfs-bus-mdio
+++ b/Documentation/ABI/testing/sysfs-bus-mdio
@@ -17,3 +17,14 @@ Description:
 		Ethernet driver during bus enumeration, encoded in string.
 		This interface mode is used to configure the Ethernet MAC with the
 		appropriate mode for its data lines to the PHY hardware.
+
+What:		/sys/bus/mdio_bus/devices/.../phy_has_fixups
+Date:		February 2014
+KernelVersion:	3.15
+Contact:	netdev@vger.kernel.org
+Description:
+		This attribute contains the boolean value whether a given PHY
+		device has had any "fixup" workaround running on it, encoded as
+		a boolean. This information is provided to help troubleshooting
+		PHY configurations.
+
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 7c66ea0..76f54b3 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -441,9 +441,19 @@ phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR_RO(phy_interface);
 
+static ssize_t
+phy_has_fixups_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct phy_device *phydev = to_phy_device(dev);
+
+	return sprintf(buf, "%d\n", phydev->has_fixups);
+}
+static DEVICE_ATTR_RO(phy_has_fixups);
+
 static struct attribute *mdio_dev_attrs[] = {
 	&dev_attr_phy_id.attr,
 	&dev_attr_phy_interface.attr,
+	&dev_attr_phy_has_fixups.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(mdio_dev);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 04/10] net: phy: add genphy_aneg_done()
  2014-02-12  1:27 ` [PATCH 04/10] net: phy: add genphy_aneg_done() Florian Fainelli
@ 2014-02-12 14:43   ` Sergei Shtylyov
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Shtylyov @ 2014-02-12 14:43 UTC (permalink / raw)
  To: Florian Fainelli, netdev; +Cc: davem

Hello.

On 12-02-2014 5:27, Florian Fainelli wrote:

> In preparation for allowing PHY drivers to potentially override their
> auto-negotiation done callback, move the contents of phy_aneg_done() to
> genphy_aneg_done() since that function really is the generic
> implementation based on the BMSR_ANEGCOMPLETE status.

> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
[...]

> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 82514e7..4e7db72 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -865,6 +865,22 @@ int genphy_config_aneg(struct phy_device *phydev)
>   }
>   EXPORT_SYMBOL(genphy_config_aneg);
>
> +/**
> + * genphy_aneg_done - return auto-negotiation status
> + * @phydev: target phy_device struct
> + *
> + * Description: Reads the status register and returns 0 either if
> + *   auto-negotiation is incomplete, or if there was an error.
> + *   Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
> + */
> +int genphy_aneg_done(struct phy_device *phydev)
> +{
> +	int retval = phy_read(phydev, MII_BMSR);
> +
> +	return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);

    I doubt parens are needed here.

WBR, Sergei

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 01/10] net: phy: use network device in phy_print_status
  2014-02-12  1:27 ` [PATCH 01/10] net: phy: use network device in phy_print_status Florian Fainelli
@ 2014-02-13  0:13   ` David Miller
  2014-02-13  0:20     ` Florian Fainelli
  0 siblings, 1 reply; 15+ messages in thread
From: David Miller @ 2014-02-13  0:13 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev


Series applied, but this patch series had several problems which I want you
absolutely to correct in future submissions.

First of all, when you submit more than one patch at a time, you must
provide a leading "PATCH 00/NN" posting which gives a top-level,
detailed, description of the overall nature of the changes you are
submitting.

It also gives me a single, specific, posting to reply to when I reply
the whole series.  Otherwise I have only two options, 1) pick an
arbitrary patch to reply to (which I am doing right now) or 2) reply
to every single patch (which is a serious waste of everyone's time).

Furthermore, some of your patches added empty lines to the end of files.
I corrected this by hand, but please avoid this in the future.

Thank you.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 01/10] net: phy: use network device in phy_print_status
  2014-02-13  0:13   ` David Miller
@ 2014-02-13  0:20     ` Florian Fainelli
  2014-02-13  0:22       ` David Miller
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Fainelli @ 2014-02-13  0:20 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

2014-02-12 16:13 GMT-08:00 David Miller <davem@davemloft.net>:
>
> Series applied, but this patch series had several problems which I want you
> absolutely to correct in future submissions.
>
> First of all, when you submit more than one patch at a time, you must
> provide a leading "PATCH 00/NN" posting which gives a top-level,
> detailed, description of the overall nature of the changes you are
> submitting.

Weird, did not you receive this cover-letter:
http://permalink.gmane.org/gmane.linux.network/303496
if not, that probably explains why the threading was all messed up in
your inbox.

>
> It also gives me a single, specific, posting to reply to when I reply
> the whole series.  Otherwise I have only two options, 1) pick an
> arbitrary patch to reply to (which I am doing right now) or 2) reply
> to every single patch (which is a serious waste of everyone's time).
>
> Furthermore, some of your patches added empty lines to the end of files.
> I corrected this by hand, but please avoid this in the future.

Thanks!

>
> Thank you.
>



-- 
Florian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 01/10] net: phy: use network device in phy_print_status
  2014-02-13  0:20     ` Florian Fainelli
@ 2014-02-13  0:22       ` David Miller
  0 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2014-02-13  0:22 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Wed, 12 Feb 2014 16:20:19 -0800

> 2014-02-12 16:13 GMT-08:00 David Miller <davem@davemloft.net>:
>>
>> Series applied, but this patch series had several problems which I want you
>> absolutely to correct in future submissions.
>>
>> First of all, when you submit more than one patch at a time, you must
>> provide a leading "PATCH 00/NN" posting which gives a top-level,
>> detailed, description of the overall nature of the changes you are
>> submitting.
> 
> Weird, did not you receive this cover-letter:
> http://permalink.gmane.org/gmane.linux.network/303496
> if not, that probably explains why the threading was all messed up in
> your inbox.

Weird indeed, I'll watch out for this in the future.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-02-13  0:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-12  1:27 [PATCH 00/10] net: phy: small cleanups and improvements Florian Fainelli
2014-02-12  1:27 ` [PATCH 01/10] net: phy: use network device in phy_print_status Florian Fainelli
2014-02-13  0:13   ` David Miller
2014-02-13  0:20     ` Florian Fainelli
2014-02-13  0:22       ` David Miller
2014-02-12  1:27 ` [PATCH 02/10] net: phy: update phy_print_status to show pause settings Florian Fainelli
2014-02-12  1:27 ` [PATCH 03/10] net: phy: display human readable PHY speed settings Florian Fainelli
2014-02-12  1:27 ` [PATCH 04/10] net: phy: add genphy_aneg_done() Florian Fainelli
2014-02-12 14:43   ` Sergei Shtylyov
2014-02-12  1:27 ` [PATCH 05/10] net: phy: allow driver to implement their own aneg_done Florian Fainelli
2014-02-12  1:27 ` [PATCH 06/10] net: phy: fix phy_{clear,config}_interrupt comment typos Florian Fainelli
2014-02-12  1:27 ` [PATCH 07/10] net: phy: re-design phy_modes to be self-contained Florian Fainelli
2014-02-12  1:27 ` [PATCH 08/10] net: phy: expose PHY device interface mode Florian Fainelli
2014-02-12  1:27 ` [PATCH 09/10] net: phy: add "has_fixups" boolean property Florian Fainelli
2014-02-12  1:27 ` [PATCH 10/10] net: phy: expose phydev->has_fixups to sysfs 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).