From patchwork Wed May 31 23:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13262852 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67C0318C3B for ; Wed, 31 May 2023 23:17:45 +0000 (UTC) Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E73512B for ; Wed, 31 May 2023 16:17:43 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-5ed99ebe076so3445906d6.2 for ; Wed, 31 May 2023 16:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1685575061; x=1688167061; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=aUonyLPu3YJU3XbzrJgT5gjhvSnZcuCAmhSI8TzMarA=; b=eVn7kDDtUHsJW3ZKsBNLUmR5kPLb4ec+3TUpSLKABq8UjiedJjBmUrIeAR24I423Kk 1GxfY7B0p4YdEr93Ren4SzaogwdKPS9aIK5vMBRmsaNnNWFiTjIQANaLBXIAfKOo694m /ufKCcCfh7YALESpXwLgqQ/pP6aNP5clK0W1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685575061; x=1688167061; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aUonyLPu3YJU3XbzrJgT5gjhvSnZcuCAmhSI8TzMarA=; b=e9/F2eLrLk87FOzATfjAGD3Kweig99E0NzsoQIuk3fQrdHZxAYU3RuZPifrMhsQD8+ R1zOg4GPZhvuiWexthy/8F7SUNrYCw2jEu9BViy+FehbF+uaqkkWKU1mLwyYxo1RcKFH w3sXhmDLTcbJG98LqleoOOvTxEHeGMCPDYaSaK4ISvFjPYL7QHLdoBd47fbPeTgaKCq+ oSpoi8wK9UkoJCGgpwVq2QJB5z1IifvTlV7zVeAYJh7y8PVVcf/0VqwcCJuC1Uias6wK BW41Ytbv/t3760fwr/VDo/5OxY92dNHzlxKczh2WUuLq2x43tV7tnFAhRpOvq5FTiv/e Q3jg== X-Gm-Message-State: AC+VfDygnuAqSJDRpzUxajwstqmofNZjTFd1sa73WIFAZNENjNfpYBV1 7/yjGXFyiNdqHnZ8YTM4zthxTpTvyP4jcGXIQiUFoTbK+0mkn/YSWmxwcYqqy/+EZdZyPRvYRqT yBKVntOzkLXLj2r/jo1laz+lc3VdsT2BkbioD5rNWfil7j3zJ5F8JihlM1gJ756f9VPXjMlZs9k E6n1KX/+KJ8Q== X-Google-Smtp-Source: ACHHUZ4v8BvRZ9BbOZOpc8ntSkjNkfjpV+9oejGtrcgtaFfB/jq18PhjwddnwDfvccIrWjOLMHzXiA== X-Received: by 2002:a05:6214:d87:b0:621:7d4:e059 with SMTP id e7-20020a0562140d8700b0062107d4e059mr7460996qve.10.1685575061540; Wed, 31 May 2023 16:17:41 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id c8-20020a0cfb08000000b00627a6fd04ddsm1551795qvp.122.2023.05.31.16.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 16:17:39 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org 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 , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next] net: phy: broadcom: Add LPI counter Date: Wed, 31 May 2023 16:17:29 -0700 Message-Id: <20230531231729.1873932-1-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MIME_NO_TEXT, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Andrew Lunn --- 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