* [PATCH net-next] net: phy: broadcom: Add LPI counter
@ 2023-05-31 23:17 Florian Fainelli
2023-06-01 14:19 ` Andrew Lunn
2023-06-02 5:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2023-05-31 23:17 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, Florian Fainelli,
Broadcom internal kernel review list, Andrew Lunn,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
[-- Attachment #1: Type: text/plain, Size: 2341 bytes --]
Add the ability to read the PHY maintained LPI counter which is in the
Clause 45 vendor space, device address 7, offset 0x803F. The counter is
cleared on read.
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/phy/bcm-phy-lib.c | 19 ++++++++++++-------
include/linux/brcmphy.h | 2 ++
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
index 5603d0a9ce96..c6e2e5f636d4 100644
--- a/drivers/net/phy/bcm-phy-lib.c
+++ b/drivers/net/phy/bcm-phy-lib.c
@@ -496,18 +496,20 @@ EXPORT_SYMBOL_GPL(bcm_phy_downshift_set);
struct bcm_phy_hw_stat {
const char *string;
- u8 reg;
+ int devad;
+ u16 reg;
u8 shift;
u8 bits;
};
/* Counters freeze at either 0xffff or 0xff, better than nothing */
static const struct bcm_phy_hw_stat bcm_phy_hw_stats[] = {
- { "phy_receive_errors", MII_BRCM_CORE_BASE12, 0, 16 },
- { "phy_serdes_ber_errors", MII_BRCM_CORE_BASE13, 8, 8 },
- { "phy_false_carrier_sense_errors", MII_BRCM_CORE_BASE13, 0, 8 },
- { "phy_local_rcvr_nok", MII_BRCM_CORE_BASE14, 8, 8 },
- { "phy_remote_rcv_nok", MII_BRCM_CORE_BASE14, 0, 8 },
+ { "phy_receive_errors", -1, MII_BRCM_CORE_BASE12, 0, 16 },
+ { "phy_serdes_ber_errors", -1, MII_BRCM_CORE_BASE13, 8, 8 },
+ { "phy_false_carrier_sense_errors", -1, MII_BRCM_CORE_BASE13, 0, 8 },
+ { "phy_local_rcvr_nok", -1, MII_BRCM_CORE_BASE14, 8, 8 },
+ { "phy_remote_rcv_nok", -1, MII_BRCM_CORE_BASE14, 0, 8 },
+ { "phy_lpi_count", MDIO_MMD_AN, BRCM_CL45VEN_EEE_LPI_CNT, 0, 16 },
};
int bcm_phy_get_sset_count(struct phy_device *phydev)
@@ -536,7 +538,10 @@ static u64 bcm_phy_get_stat(struct phy_device *phydev, u64 *shadow,
int val;
u64 ret;
- val = phy_read(phydev, stat.reg);
+ if (stat.devad < 0)
+ val = phy_read(phydev, stat.reg);
+ else
+ val = phy_read_mmd(phydev, stat.devad, stat.reg);
if (val < 0) {
ret = U64_MAX;
} else {
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index e9afbfb6d7a5..251833ab271f 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -359,6 +359,8 @@
#define LPI_FEATURE_EN 0x8000
#define LPI_FEATURE_EN_DIG1000X 0x4000
+#define BRCM_CL45VEN_EEE_LPI_CNT 0x803f
+
/* Core register definitions*/
#define MII_BRCM_CORE_BASE12 0x12
#define MII_BRCM_CORE_BASE13 0x13
--
2.34.1
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: phy: broadcom: Add LPI counter
2023-05-31 23:17 [PATCH net-next] net: phy: broadcom: Add LPI counter Florian Fainelli
@ 2023-06-01 14:19 ` Andrew Lunn
2023-06-02 5:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2023-06-01 14:19 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, Florian Fainelli, Broadcom internal kernel review list,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
On Wed, May 31, 2023 at 04:17:29PM -0700, Florian Fainelli wrote:
> Add the ability to read the PHY maintained LPI counter which is in the
> Clause 45 vendor space, device address 7, offset 0x803F. The counter is
> cleared on read.
>
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: phy: broadcom: Add LPI counter
2023-05-31 23:17 [PATCH net-next] net: phy: broadcom: Add LPI counter Florian Fainelli
2023-06-01 14:19 ` Andrew Lunn
@ 2023-06-02 5:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-02 5:00 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, f.fainelli, bcm-kernel-feedback-list, andrew, hkallweit1,
linux, davem, edumazet, kuba, pabeni, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 31 May 2023 16:17:29 -0700 you wrote:
> Add the ability to read the PHY maintained LPI counter which is in the
> Clause 45 vendor space, device address 7, offset 0x803F. The counter is
> cleared on read.
>
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
> drivers/net/phy/bcm-phy-lib.c | 19 ++++++++++++-------
> include/linux/brcmphy.h | 2 ++
> 2 files changed, 14 insertions(+), 7 deletions(-)
Here is the summary with links:
- [net-next] net: phy: broadcom: Add LPI counter
https://git.kernel.org/netdev/net-next/c/e8b6f79b4184
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-02 5:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31 23:17 [PATCH net-next] net: phy: broadcom: Add LPI counter Florian Fainelli
2023-06-01 14:19 ` Andrew Lunn
2023-06-02 5:00 ` patchwork-bot+netdevbpf
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).