netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3 v3] phy: allow flagging PHY devices as internal
@ 2013-05-23 11:11 Florian Fainelli
  2013-05-23 11:11 ` [PATCH 1/3 net-next v3] net: ethtool: disambiguate XCVR_* meaning Florian Fainelli
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Florian Fainelli @ 2013-05-23 11:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, afleming, jogo, bhutchings, Florian Fainelli

David, Andy,

This small patch set updates libphy to allow PHY drivers to flag a
specific PHY device as internal, which is then used to accurately
report the transceiver type (internal vs external) in ethtool.

As far as I can tell we only have one in-tree driver for the moment
which is known to be for internal PHYs.

Florian Fainelli (3):
  net: ethtool: disambiguate XCVR_* meaning
  phy: allow drivers to flag a PHY device as internal
  phy: bcm63xx: report Broadcom BCM63xx PHYs as internal

 drivers/net/phy/bcm63xx.c    |  4 ++--
 drivers/net/phy/phy.c        |  3 ++-
 drivers/net/phy/phy_device.c |  3 +++
 include/linux/phy.h          | 12 ++++++++++++
 include/uapi/linux/ethtool.h |  4 ++--
 5 files changed, 21 insertions(+), 5 deletions(-)

-- 
1.8.1.2

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

* [PATCH 1/3 net-next v3] net: ethtool: disambiguate XCVR_* meaning
  2013-05-23 11:11 [PATCH 0/3 v3] phy: allow flagging PHY devices as internal Florian Fainelli
@ 2013-05-23 11:11 ` Florian Fainelli
  2013-05-27 16:49   ` Ben Hutchings
  2013-05-23 11:11 ` [PATCH 2/3 net-next v3] phy: allow drivers to flag a PHY device as internal Florian Fainelli
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2013-05-23 11:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, afleming, jogo, bhutchings, Florian Fainelli

Add a comment which explains the real meaning of XCVR_INTERNAL (PHY and
Ethernet MAC in the same package/die) and XCVR_EXTERNAL (PHY and
Ethernet MAC in a different package/die). Most if not all of the drivers
setting their transceiver type already do it the way the comment
describes it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/uapi/linux/ethtool.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 0c9b448..38dbafa 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -993,8 +993,8 @@ enum ethtool_sfeatures_retval_bits {
 #define PORT_OTHER		0xff
 
 /* Which transceiver to use. */
-#define XCVR_INTERNAL		0x00
-#define XCVR_EXTERNAL		0x01
+#define XCVR_INTERNAL		0x00 /* PHY and MAC are in the same package */
+#define XCVR_EXTERNAL		0x01 /* PHY and MAC are in different packages */
 #define XCVR_DUMMY1		0x02
 #define XCVR_DUMMY2		0x03
 #define XCVR_DUMMY3		0x04
-- 
1.8.1.2

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

* [PATCH 2/3 net-next v3] phy: allow drivers to flag a PHY device as internal
  2013-05-23 11:11 [PATCH 0/3 v3] phy: allow flagging PHY devices as internal Florian Fainelli
  2013-05-23 11:11 ` [PATCH 1/3 net-next v3] net: ethtool: disambiguate XCVR_* meaning Florian Fainelli
@ 2013-05-23 11:11 ` Florian Fainelli
  2013-05-23 11:11 ` [PATCH 3/3 net-next v3] phy: bcm63xx: report Broadcom BCM63xx PHYs " Florian Fainelli
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2013-05-23 11:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, afleming, jogo, bhutchings, Florian Fainelli

libphy currently always reports a PHY as an external transceiver from
the ethtool output. This is inaccurate, because some drivers should be
able to tell that a PHY device is an internal transceiver of an Ethernet
MAC. Add a new flag (PHY_IS_INTERNAL) which can be set by PHY drivers
just like other flags, and a corresponding helper: phy_is_internal()
which can be used by networking drivers to query if a given
PHY device is internal.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes since v1:
- fixed typo in commit message (accurate vs inaccurate)
- added phy_is_internal() helper anduse it

 drivers/net/phy/phy.c        |  3 ++-
 drivers/net/phy/phy_device.c |  3 +++
 include/linux/phy.h          | 12 ++++++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2d28a0e..b2a94e4 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -294,7 +294,8 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
 	cmd->duplex = phydev->duplex;
 	cmd->port = PORT_MII;
 	cmd->phy_address = phydev->addr;
-	cmd->transceiver = XCVR_EXTERNAL;
+	cmd->transceiver = phy_is_internal(phydev) ?
+		XCVR_INTERNAL : XCVR_EXTERNAL;
 	cmd->autoneg = phydev->autoneg;
 
 	return 0;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b55aa33..74630e9 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1017,6 +1017,9 @@ static int phy_probe(struct device *dev)
 			phy_interrupt_is_valid(phydev))
 		phydev->irq = PHY_POLL;
 
+	if (phydrv->flags & PHY_IS_INTERNAL)
+		phydev->is_internal = true;
+
 	mutex_lock(&phydev->lock);
 
 	/* Start out supporting everything. Eventually,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index fdfa115..ee411b0 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -49,6 +49,7 @@
 
 #define PHY_HAS_INTERRUPT	0x00000001
 #define PHY_HAS_MAGICANEG	0x00000002
+#define PHY_IS_INTERNAL		0x00000004
 
 /* Interface Mode definitions */
 typedef enum {
@@ -261,6 +262,7 @@ struct phy_c45_device_ids {
  * phy_id: UID for this device found during discovery
  * c45_ids: 802.3-c45 Device Identifers if is_c45.
  * is_c45:  Set to true if this phy uses clause 45 addressing.
+ * is_internal: Set to true if this phy is internal to a MAC.
  * state: state of the PHY for management purposes
  * dev_flags: Device-specific flags used by the PHY driver.
  * addr: Bus address of PHY
@@ -298,6 +300,7 @@ struct phy_device {
 
 	struct phy_c45_device_ids c45_ids;
 	bool is_c45;
+	bool is_internal;
 
 	enum phy_state state;
 
@@ -520,6 +523,15 @@ static inline bool phy_interrupt_is_valid(struct phy_device *phydev)
 	return phydev->irq != PHY_POLL && phydev->irq != PHY_IGNORE_INTERRUPT;
 }
 
+/**
+ * phy_is_internal - Convenience function for testing if a PHY is internal
+ * @phydev: the phy_device struct
+ */
+static inline bool phy_is_internal(struct phy_device *phydev)
+{
+	return phydev->is_internal;
+}
+
 struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
 		bool is_c45, struct phy_c45_device_ids *c45_ids);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45);
-- 
1.8.1.2

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

* [PATCH 3/3 net-next v3] phy: bcm63xx: report Broadcom BCM63xx PHYs as internal
  2013-05-23 11:11 [PATCH 0/3 v3] phy: allow flagging PHY devices as internal Florian Fainelli
  2013-05-23 11:11 ` [PATCH 1/3 net-next v3] net: ethtool: disambiguate XCVR_* meaning Florian Fainelli
  2013-05-23 11:11 ` [PATCH 2/3 net-next v3] phy: allow drivers to flag a PHY device as internal Florian Fainelli
@ 2013-05-23 11:11 ` Florian Fainelli
  2013-05-24 21:31 ` [PATCH 0/3 v3] phy: allow flagging PHY devices " Florian Fainelli
  2013-05-28  5:46 ` David Miller
  4 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2013-05-23 11:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, afleming, jogo, bhutchings, Florian Fainelli

The Broadcom BCM63xx PHY driver is for the SoC internal PHYs, flag these
as internal PHY devices.

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

diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c
index 84c7a39..ac55b08 100644
--- a/drivers/net/phy/bcm63xx.c
+++ b/drivers/net/phy/bcm63xx.c
@@ -78,7 +78,7 @@ static struct phy_driver bcm63xx_driver[] = {
 	.name		= "Broadcom BCM63XX (1)",
 	/* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
 	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause),
-	.flags		= PHY_HAS_INTERRUPT,
+	.flags		= PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
 	.config_init	= bcm63xx_config_init,
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= genphy_read_status,
@@ -91,7 +91,7 @@ static struct phy_driver bcm63xx_driver[] = {
 	.phy_id_mask	= 0xfffffc00,
 	.name		= "Broadcom BCM63XX (2)",
 	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause),
-	.flags		= PHY_HAS_INTERRUPT,
+	.flags		= PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
 	.config_init	= bcm63xx_config_init,
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= genphy_read_status,
-- 
1.8.1.2

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

* Re: [PATCH 0/3 v3] phy: allow flagging PHY devices as internal
  2013-05-23 11:11 [PATCH 0/3 v3] phy: allow flagging PHY devices as internal Florian Fainelli
                   ` (2 preceding siblings ...)
  2013-05-23 11:11 ` [PATCH 3/3 net-next v3] phy: bcm63xx: report Broadcom BCM63xx PHYs " Florian Fainelli
@ 2013-05-24 21:31 ` Florian Fainelli
  2013-05-26  6:36   ` David Miller
  2013-05-28  5:46 ` David Miller
  4 siblings, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2013-05-24 21:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, afleming, jogo, bhutchings

Ben,

Le jeudi 23 mai 2013 12:11:10, Florian Fainelli a écrit :
> David, Andy,
> 
> This small patch set updates libphy to allow PHY drivers to flag a
> specific PHY device as internal, which is then used to accurately
> report the transceiver type (internal vs external) in ethtool.

Does the first patch works for you or you do want me to be more descriptive?

Thanks

> 
> As far as I can tell we only have one in-tree driver for the moment
> which is known to be for internal PHYs.
> 
> Florian Fainelli (3):
>   net: ethtool: disambiguate XCVR_* meaning
>   phy: allow drivers to flag a PHY device as internal
>   phy: bcm63xx: report Broadcom BCM63xx PHYs as internal
> 
>  drivers/net/phy/bcm63xx.c    |  4 ++--
>  drivers/net/phy/phy.c        |  3 ++-
>  drivers/net/phy/phy_device.c |  3 +++
>  include/linux/phy.h          | 12 ++++++++++++
>  include/uapi/linux/ethtool.h |  4 ++--
>  5 files changed, 21 insertions(+), 5 deletions(-)

-- 
Florian

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

* Re: [PATCH 0/3 v3] phy: allow flagging PHY devices as internal
  2013-05-24 21:31 ` [PATCH 0/3 v3] phy: allow flagging PHY devices " Florian Fainelli
@ 2013-05-26  6:36   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2013-05-26  6:36 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, afleming, jogo, bhutchings

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Fri, 24 May 2013 22:31:11 +0100

> Ben,
> 
> Le jeudi 23 mai 2013 12:11:10, Florian Fainelli a écrit :
>> David, Andy,
>> 
>> This small patch set updates libphy to allow PHY drivers to flag a
>> specific PHY device as internal, which is then used to accurately
>> report the transceiver type (internal vs external) in ethtool.
> 
> Does the first patch works for you or you do want me to be more descriptive?

I'll apply this series once Ben gets a change to look it over.

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

* Re: [PATCH 1/3 net-next v3] net: ethtool: disambiguate XCVR_* meaning
  2013-05-23 11:11 ` [PATCH 1/3 net-next v3] net: ethtool: disambiguate XCVR_* meaning Florian Fainelli
@ 2013-05-27 16:49   ` Ben Hutchings
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Hutchings @ 2013-05-27 16:49 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: davem, netdev, afleming, jogo

On Thu, 2013-05-23 at 12:11 +0100, Florian Fainelli wrote:
> Add a comment which explains the real meaning of XCVR_INTERNAL (PHY and
> Ethernet MAC in the same package/die) and XCVR_EXTERNAL (PHY and
> Ethernet MAC in a different package/die). Most if not all of the drivers
> setting their transceiver type already do it the way the comment
> describes it.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

I had another look over the drivers that use both values, and I think
there aren't any remaining exceptions to the definition you're giving.
Sorry for holding this up.

Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>

Ben.

> ---
>  include/uapi/linux/ethtool.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
> index 0c9b448..38dbafa 100644
> --- a/include/uapi/linux/ethtool.h
> +++ b/include/uapi/linux/ethtool.h
> @@ -993,8 +993,8 @@ enum ethtool_sfeatures_retval_bits {
>  #define PORT_OTHER		0xff
>  
>  /* Which transceiver to use. */
> -#define XCVR_INTERNAL		0x00
> -#define XCVR_EXTERNAL		0x01
> +#define XCVR_INTERNAL		0x00 /* PHY and MAC are in the same package */
> +#define XCVR_EXTERNAL		0x01 /* PHY and MAC are in different packages */
>  #define XCVR_DUMMY1		0x02
>  #define XCVR_DUMMY2		0x03
>  #define XCVR_DUMMY3		0x04

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

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

* Re: [PATCH 0/3 v3] phy: allow flagging PHY devices as internal
  2013-05-23 11:11 [PATCH 0/3 v3] phy: allow flagging PHY devices as internal Florian Fainelli
                   ` (3 preceding siblings ...)
  2013-05-24 21:31 ` [PATCH 0/3 v3] phy: allow flagging PHY devices " Florian Fainelli
@ 2013-05-28  5:46 ` David Miller
  4 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2013-05-28  5:46 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, afleming, jogo, bhutchings

From: "Florian Fainelli" <f.fainelli@gmail.com>
Date: Thu, 23 May 2013 12:11:10 +0100

> This small patch set updates libphy to allow PHY drivers to flag a
> specific PHY device as internal, which is then used to accurately
> report the transceiver type (internal vs external) in ethtool.
> 
> As far as I can tell we only have one in-tree driver for the moment
> which is known to be for internal PHYs.

Series applied, thanks Florian.

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

end of thread, other threads:[~2013-05-28  5:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-23 11:11 [PATCH 0/3 v3] phy: allow flagging PHY devices as internal Florian Fainelli
2013-05-23 11:11 ` [PATCH 1/3 net-next v3] net: ethtool: disambiguate XCVR_* meaning Florian Fainelli
2013-05-27 16:49   ` Ben Hutchings
2013-05-23 11:11 ` [PATCH 2/3 net-next v3] phy: allow drivers to flag a PHY device as internal Florian Fainelli
2013-05-23 11:11 ` [PATCH 3/3 net-next v3] phy: bcm63xx: report Broadcom BCM63xx PHYs " Florian Fainelli
2013-05-24 21:31 ` [PATCH 0/3 v3] phy: allow flagging PHY devices " Florian Fainelli
2013-05-26  6:36   ` David Miller
2013-05-28  5:46 ` David Miller

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).