netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs
@ 2017-12-15  1:48 Florian Fainelli
  2017-12-15  2:00 ` Chris Healy
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Florian Fainelli @ 2017-12-15  1:48 UTC (permalink / raw)
  To: netdev; +Cc: andrew, cphealy, Florian Fainelli

Add an entry for the builtin PHYs present in the Broadcom BCM5395 switch. This
allows us to retrieve the PHY statistics among other things.

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

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index a8f69c5777bc..3bb6b66dc7bf 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -540,6 +540,37 @@ static int brcm_fet_config_intr(struct phy_device *phydev)
 	return err;
 }
 
+struct bcm53xx_phy_priv {
+	u64	*stats;
+};
+
+static int bcm53xx_phy_probe(struct phy_device *phydev)
+{
+	struct bcm53xx_phy_priv *priv;
+
+	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	phydev->priv = priv;
+
+	priv->stats = devm_kcalloc(&phydev->mdio.dev,
+				   bcm_phy_get_sset_count(phydev), sizeof(u64),
+				   GFP_KERNEL);
+	if (!priv->stats)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void bcm53xx_phy_get_stats(struct phy_device *phydev,
+				  struct ethtool_stats *stats, u64 *data)
+{
+	struct bcm53xx_phy_priv *priv = phydev->priv;
+
+	bcm_phy_get_stats(phydev, priv->stats, stats, data);
+}
+
 static struct phy_driver broadcom_drivers[] = {
 {
 	.phy_id		= PHY_ID_BCM5411,
@@ -679,6 +710,16 @@ static struct phy_driver broadcom_drivers[] = {
 	.config_init	= brcm_fet_config_init,
 	.ack_interrupt	= brcm_fet_ack_interrupt,
 	.config_intr	= brcm_fet_config_intr,
+}, {
+	.phy_id		= PHY_ID_BCM5395,
+	.phy_id_mask	= 0xfffffff0,
+	.name		= "Broadcom BCM5395",
+	.flags		= PHY_IS_INTERNAL,
+	.features	= PHY_GBIT_FEATURES,
+	.get_sset_count	= bcm_phy_get_sset_count,
+	.get_strings	= bcm_phy_get_strings,
+	.get_stats	= bcm53xx_phy_get_stats,
+	.probe		= bcm53xx_phy_probe,
 } };
 
 module_phy_driver(broadcom_drivers);
@@ -699,6 +740,7 @@ static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
 	{ PHY_ID_BCM57780, 0xfffffff0 },
 	{ PHY_ID_BCMAC131, 0xfffffff0 },
 	{ PHY_ID_BCM5241, 0xfffffff0 },
+	{ PHY_ID_BCM5395, 0xfffffff0 },
 	{ }
 };
 
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 8ff86b4c1b8a..d3339dd48b1a 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -14,6 +14,7 @@
 #define PHY_ID_BCM5241			0x0143bc30
 #define PHY_ID_BCMAC131			0x0143bc70
 #define PHY_ID_BCM5481			0x0143bca0
+#define PHY_ID_BCM5395			0x0143bcf0
 #define PHY_ID_BCM54810			0x03625d00
 #define PHY_ID_BCM5482			0x0143bcb0
 #define PHY_ID_BCM5411			0x00206070
-- 
2.7.4

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

* Re: [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs
  2017-12-15  1:48 [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs Florian Fainelli
@ 2017-12-15  2:00 ` Chris Healy
  2017-12-15  9:10 ` Andrew Lunn
  2017-12-15 20:41 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Chris Healy @ 2017-12-15  2:00 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, Andrew Lunn

Tested-by: Chris Healy <cphealy@gmail.com>

Successfully tested on a machine with a Broadcom BCM5395 switch.

On Thu, Dec 14, 2017 at 5:48 PM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> Add an entry for the builtin PHYs present in the Broadcom BCM5395 switch. This
> allows us to retrieve the PHY statistics among other things.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/net/phy/broadcom.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  include/linux/brcmphy.h    |  1 +
>  2 files changed, 43 insertions(+)
>
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index a8f69c5777bc..3bb6b66dc7bf 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c
> @@ -540,6 +540,37 @@ static int brcm_fet_config_intr(struct phy_device *phydev)
>         return err;
>  }
>
> +struct bcm53xx_phy_priv {
> +       u64     *stats;
> +};
> +
> +static int bcm53xx_phy_probe(struct phy_device *phydev)
> +{
> +       struct bcm53xx_phy_priv *priv;
> +
> +       priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
> +       if (!priv)
> +               return -ENOMEM;
> +
> +       phydev->priv = priv;
> +
> +       priv->stats = devm_kcalloc(&phydev->mdio.dev,
> +                                  bcm_phy_get_sset_count(phydev), sizeof(u64),
> +                                  GFP_KERNEL);
> +       if (!priv->stats)
> +               return -ENOMEM;
> +
> +       return 0;
> +}
> +
> +static void bcm53xx_phy_get_stats(struct phy_device *phydev,
> +                                 struct ethtool_stats *stats, u64 *data)
> +{
> +       struct bcm53xx_phy_priv *priv = phydev->priv;
> +
> +       bcm_phy_get_stats(phydev, priv->stats, stats, data);
> +}
> +
>  static struct phy_driver broadcom_drivers[] = {
>  {
>         .phy_id         = PHY_ID_BCM5411,
> @@ -679,6 +710,16 @@ static struct phy_driver broadcom_drivers[] = {
>         .config_init    = brcm_fet_config_init,
>         .ack_interrupt  = brcm_fet_ack_interrupt,
>         .config_intr    = brcm_fet_config_intr,
> +}, {
> +       .phy_id         = PHY_ID_BCM5395,
> +       .phy_id_mask    = 0xfffffff0,
> +       .name           = "Broadcom BCM5395",
> +       .flags          = PHY_IS_INTERNAL,
> +       .features       = PHY_GBIT_FEATURES,
> +       .get_sset_count = bcm_phy_get_sset_count,
> +       .get_strings    = bcm_phy_get_strings,
> +       .get_stats      = bcm53xx_phy_get_stats,
> +       .probe          = bcm53xx_phy_probe,
>  } };
>
>  module_phy_driver(broadcom_drivers);
> @@ -699,6 +740,7 @@ static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
>         { PHY_ID_BCM57780, 0xfffffff0 },
>         { PHY_ID_BCMAC131, 0xfffffff0 },
>         { PHY_ID_BCM5241, 0xfffffff0 },
> +       { PHY_ID_BCM5395, 0xfffffff0 },
>         { }
>  };
>
> diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
> index 8ff86b4c1b8a..d3339dd48b1a 100644
> --- a/include/linux/brcmphy.h
> +++ b/include/linux/brcmphy.h
> @@ -14,6 +14,7 @@
>  #define PHY_ID_BCM5241                 0x0143bc30
>  #define PHY_ID_BCMAC131                        0x0143bc70
>  #define PHY_ID_BCM5481                 0x0143bca0
> +#define PHY_ID_BCM5395                 0x0143bcf0
>  #define PHY_ID_BCM54810                        0x03625d00
>  #define PHY_ID_BCM5482                 0x0143bcb0
>  #define PHY_ID_BCM5411                 0x00206070
> --
> 2.7.4
>

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

* Re: [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs
  2017-12-15  1:48 [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs Florian Fainelli
  2017-12-15  2:00 ` Chris Healy
@ 2017-12-15  9:10 ` Andrew Lunn
  2017-12-15 20:08   ` Florian Fainelli
  2017-12-15 20:41 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2017-12-15  9:10 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, cphealy

On Thu, Dec 14, 2017 at 05:48:16PM -0800, Florian Fainelli wrote:
> Add an entry for the builtin PHYs present in the Broadcom BCM5395 switch. This
> allows us to retrieve the PHY statistics among other things.

>  static struct phy_driver broadcom_drivers[] = {
>  {
>  	.phy_id		= PHY_ID_BCM5411,
> @@ -679,6 +710,16 @@ static struct phy_driver broadcom_drivers[] = {
>  	.config_init	= brcm_fet_config_init,
>  	.ack_interrupt	= brcm_fet_ack_interrupt,
>  	.config_intr	= brcm_fet_config_intr,
> +}, {
> +	.phy_id		= PHY_ID_BCM5395,
> +	.phy_id_mask	= 0xfffffff0,
> +	.name		= "Broadcom BCM5395",
> +	.flags		= PHY_IS_INTERNAL,
> +	.features	= PHY_GBIT_FEATURES,
> +	.get_sset_count	= bcm_phy_get_sset_count,
> +	.get_strings	= bcm_phy_get_strings,
> +	.get_stats	= bcm53xx_phy_get_stats,
> +	.probe		= bcm53xx_phy_probe,
>  } };

Hi Florian

Is this the only PHY supported by this driver which has statistics?

   Andrew

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

* Re: [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs
  2017-12-15  9:10 ` Andrew Lunn
@ 2017-12-15 20:08   ` Florian Fainelli
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2017-12-15 20:08 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, cphealy

On December 15, 2017 1:10:44 AM PST, Andrew Lunn <andrew@lunn.ch> wrote:
>On Thu, Dec 14, 2017 at 05:48:16PM -0800, Florian Fainelli wrote:
>> Add an entry for the builtin PHYs present in the Broadcom BCM5395
>switch. This
>> allows us to retrieve the PHY statistics among other things.
>
>>  static struct phy_driver broadcom_drivers[] = {
>>  {
>>  	.phy_id		= PHY_ID_BCM5411,
>> @@ -679,6 +710,16 @@ static struct phy_driver broadcom_drivers[] = {
>>  	.config_init	= brcm_fet_config_init,
>>  	.ack_interrupt	= brcm_fet_ack_interrupt,
>>  	.config_intr	= brcm_fet_config_intr,
>> +}, {
>> +	.phy_id		= PHY_ID_BCM5395,
>> +	.phy_id_mask	= 0xfffffff0,
>> +	.name		= "Broadcom BCM5395",
>> +	.flags		= PHY_IS_INTERNAL,
>> +	.features	= PHY_GBIT_FEATURES,
>> +	.get_sset_count	= bcm_phy_get_sset_count,
>> +	.get_strings	= bcm_phy_get_strings,
>> +	.get_stats	= bcm53xx_phy_get_stats,
>> +	.probe		= bcm53xx_phy_probe,
>>  } };
>
>Hi Florian
>
>Is this the only PHY supported by this driver which has statistics?

I need to cross check with the various data sheets to be sure, but it is quite likely that all Gigabit capable PHYs listed above would also support the same statistics. In any case, this would be a follow on patch to this one.

Thanks!
>
>   Andrew

Hi Andrew,
-- 
Florian

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

* Re: [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs
  2017-12-15  1:48 [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs Florian Fainelli
  2017-12-15  2:00 ` Chris Healy
  2017-12-15  9:10 ` Andrew Lunn
@ 2017-12-15 20:41 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-12-15 20:41 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, andrew, cphealy

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Thu, 14 Dec 2017 17:48:16 -0800

> Add an entry for the builtin PHYs present in the Broadcom BCM5395 switch. This
> allows us to retrieve the PHY statistics among other things.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied, thanks Florian.

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

end of thread, other threads:[~2017-12-15 20:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-15  1:48 [PATCH net-next] net: phy: broadcom: Add entry for 5395 switch PHYs Florian Fainelli
2017-12-15  2:00 ` Chris Healy
2017-12-15  9:10 ` Andrew Lunn
2017-12-15 20:08   ` Florian Fainelli
2017-12-15 20:41 ` 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).