From patchwork Fri Sep 6 09:36:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 13793804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDB68CE7AFC for ; Fri, 6 Sep 2024 09:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=+Jr/R2zvoa9OrlkdtJ3CRfJHk6CE8wO8NyUem2MPKOQ=; b=hHXlnId/Se4dfKDUe9uKwppS1a ioDScAQYopVaiMjOMCvOHRsK707pZsc6Qd3K2RTczy8CXctvAzjqjiIdUioPGPITjOidRpT16zvDW 3hAadKSzUeAmQHUnCjKJBuMTSvIPWgreI1gQoUtO116Nz8ed+7MB57T/UZPWj4S9O5Ok2K0WPCN0L Ftv+FSYiNKg8U0DsQwCxlxw0DgHnZWD5kFfd+LmN4RIpX18AndDYUxm3datR0tRl9wv8IvKyyOlnn rsli4IXK4TN/59iHE4agmrEFP2DBIJ7TCcDl/ry8vvVa9JQHHU5hVxLFEy9wdgIIH51l+6VprObro eU4KVUng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smVWN-0000000BaBg-00cj; Fri, 06 Sep 2024 09:44:51 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smVOs-0000000BXUC-0ZIt for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 09:37:08 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 4869arjo048909; Fri, 6 Sep 2024 04:36:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1725615413; bh=+Jr/R2zvoa9OrlkdtJ3CRfJHk6CE8wO8NyUem2MPKOQ=; h=From:To:CC:Subject:Date; b=yr+yyoePBktxkhIe9qbJVTrBh5rZTVJY1ZvDpx3YB0nn4kNkro0fOXLv7zTDF+Mts Y3AY5lmk174u4FKS7Di9aHmMgxeccSOXgdbPpYMX1GzfTiT+UBwbuKIWRofg4T6qCo OkjiEjgUwTd0rF7MmTNgKTG/1r27e2Sp+GRONx+U= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4869arXS024347 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Sep 2024 04:36:53 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 6 Sep 2024 04:36:53 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 6 Sep 2024 04:36:52 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4869arQn004462; Fri, 6 Sep 2024 04:36:53 -0500 Received: from localhost (danish-tpc.dhcp.ti.com [10.24.69.25]) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 4869aqcb018145; Fri, 6 Sep 2024 04:36:52 -0500 From: MD Danish Anwar To: , , , , , , , , , , , CC: , , , , Vignesh Raghavendra , Roger Quadros , Subject: [PATCH net-next v2] net: ti: icssg-prueth: Make pa_stats optional Date: Fri, 6 Sep 2024 15:06:49 +0530 Message-ID: <20240906093649.870883-1-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_023706_495515_304B00A4 X-CRM114-Status: GOOD ( 18.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org pa_stats is optional in dt bindings, make it optional in driver as well. Currently if pa_stats syscon regmap is not found driver returns -ENODEV. Fix this by not returning an error in case pa_stats is not found and continue generating ethtool stats without pa_stats. Fixes: 550ee90ac61c ("net: ti: icssg-prueth: Add support for PA Stats") Signed-off-by: MD Danish Anwar Reviewed-by: Andrew Lunn --- Cc: Jan Kiszka NOTE: This fix is targetted to net-next because the concerned commit is not yet synced to net. So the issue isn't present in net. v1 -> v2 *) Replacing the error code returned for optional resource to NULL in probe and simplified the if checks as suggested by Andrew Lunn v1 https://lore.kernel.org/all/20240905101739.44563-1-danishanwar@ti.com/ drivers/net/ethernet/ti/icssg/icssg_ethtool.c | 17 ++++++++++----- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 2 +- drivers/net/ethernet/ti/icssg/icssg_stats.c | 21 ++++++++++++------- 3 files changed, 26 insertions(+), 14 deletions(-) base-commit: 43b7724487109368363bb5cda034b3f600278d14 diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c index 5073ec195854..6b5cc1e6d64b 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c +++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c @@ -68,9 +68,13 @@ static int emac_nway_reset(struct net_device *ndev) static int emac_get_sset_count(struct net_device *ndev, int stringset) { + struct prueth_emac *emac = netdev_priv(ndev); switch (stringset) { case ETH_SS_STATS: - return ICSSG_NUM_ETHTOOL_STATS; + if (emac->prueth->pa_stats) + return ICSSG_NUM_ETHTOOL_STATS; + else + return ICSSG_NUM_ETHTOOL_STATS - ICSSG_NUM_PA_STATS; default: return -EOPNOTSUPP; } @@ -78,6 +82,7 @@ static int emac_get_sset_count(struct net_device *ndev, int stringset) static void emac_get_strings(struct net_device *ndev, u32 stringset, u8 *data) { + struct prueth_emac *emac = netdev_priv(ndev); u8 *p = data; int i; @@ -86,8 +91,9 @@ static void emac_get_strings(struct net_device *ndev, u32 stringset, u8 *data) for (i = 0; i < ARRAY_SIZE(icssg_all_miig_stats); i++) if (!icssg_all_miig_stats[i].standard_stats) ethtool_puts(&p, icssg_all_miig_stats[i].name); - for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) - ethtool_puts(&p, icssg_all_pa_stats[i].name); + if (emac->prueth->pa_stats) + for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) + ethtool_puts(&p, icssg_all_pa_stats[i].name); break; default: break; @@ -106,8 +112,9 @@ static void emac_get_ethtool_stats(struct net_device *ndev, if (!icssg_all_miig_stats[i].standard_stats) *(data++) = emac->stats[i]; - for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) - *(data++) = emac->pa_stats[i]; + if (emac->prueth->pa_stats) + for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) + *(data++) = emac->pa_stats[i]; } static int emac_get_ts_info(struct net_device *ndev, diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index becdda143c19..6644203d6bb7 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -1185,7 +1185,7 @@ static int prueth_probe(struct platform_device *pdev) prueth->pa_stats = syscon_regmap_lookup_by_phandle(np, "ti,pa-stats"); if (IS_ERR(prueth->pa_stats)) { dev_err(dev, "couldn't get ti,pa-stats syscon regmap\n"); - return -ENODEV; + prueth->pa_stats = NULL; } if (eth0_node) { diff --git a/drivers/net/ethernet/ti/icssg/icssg_stats.c b/drivers/net/ethernet/ti/icssg/icssg_stats.c index 06a15c0b2acc..8800bd3a8d07 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_stats.c +++ b/drivers/net/ethernet/ti/icssg/icssg_stats.c @@ -42,11 +42,14 @@ void emac_update_hardware_stats(struct prueth_emac *emac) emac->stats[i] -= tx_pkt_cnt * 8; } - for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { - reg = ICSSG_FW_STATS_BASE + icssg_all_pa_stats[i].offset * - PRUETH_NUM_MACS + slice * sizeof(u32); - regmap_read(prueth->pa_stats, reg, &val); - emac->pa_stats[i] += val; + if (prueth->pa_stats) { + for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { + reg = ICSSG_FW_STATS_BASE + + icssg_all_pa_stats[i].offset * + PRUETH_NUM_MACS + slice * sizeof(u32); + regmap_read(prueth->pa_stats, reg, &val); + emac->pa_stats[i] += val; + } } } @@ -70,9 +73,11 @@ int emac_get_stat_by_name(struct prueth_emac *emac, char *stat_name) return emac->stats[icssg_all_miig_stats[i].offset / sizeof(u32)]; } - for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { - if (!strcmp(icssg_all_pa_stats[i].name, stat_name)) - return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)]; + if (emac->prueth->pa_stats) { + for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { + if (!strcmp(icssg_all_pa_stats[i].name, stat_name)) + return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)]; + } } netdev_err(emac->ndev, "Invalid stats %s\n", stat_name);