From mboxrd@z Thu Jan 1 00:00:00 1970 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 3137BC624A5 for ; Mon, 31 Aug 2026 15:09:17 +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:References:In-Reply-To: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:List-Owner; bh=TmcDYc7H0S6bH9oEkvwHBJoAArjFlGnTjn1pOTdkzQg=; b=NbEqhgLip1ObXCcZQfQldTvkzh 598SQ3dMjXCgwmeI/ZHBvQWcHmjbRRkwpTBW6xYraws4eIA9IkNZEWl1JmBo0lY0viqUdHXaw2aeZ Cd6es8reb9duL7oAeWhrWkgHZlfHtmtrGJA6N790NgtbmQl09zh+tTSAI46pnkZkUvuhsldgOHmus 7+SP75ui22bQMn7M5+gHi0iUtbZXpLp22WMCXR5MFo1QB20tiIztI5u/g4stSfvowFR3+FMvcWhMN B6Y59hDA2UtnHEK7ez0AtidX3ioZvQK+6luVytCvQEBTRAWl0Z9qOqDRqLtsU3rEMoQ65O7mtv7XC g6oRurGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x13dG-00000009oHE-2RVd; Mon, 31 Aug 2026 15:09:10 +0000 Received: from mail-centralusazlp170110009.outbound.protection.outlook.com ([2a01:111:f403:c111::9] helo=DM5PR21CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x13dD-00000009oE3-0ivk for linux-arm-kernel@lists.infradead.org; Mon, 31 Aug 2026 15:09:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K33ptnL8bmLWrGGsEyPAKD2FnEsUFf+dcBBURfX17wHTAd33IsgtkwBpbU2b6WN1qykwY0jov2boHqPPIu8znJSNTg2Sn6f01JKqcR8cfRgvSxPKEYDWudNZzwImuB/gOvq4R1sSsNQD888wl7lx+lEAez4XhmRTk+pNLEveiIAgdc9yUzHIrXSMlx5DZYFgJCUiS1jX09ln1hy7k0Ty78+TM0jtbgs8q4dpj5djCQo9Nf8kcGvCl4omAhJKWgOs9F+So6PZ7hAVgEPS2ZPDKTQew67rX63h9wH5whcv/gf4IknNAsxjRzmlseTDXgyCSdNmdtGeC4tdQPdFhqYekQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TmcDYc7H0S6bH9oEkvwHBJoAArjFlGnTjn1pOTdkzQg=; b=GwfiDGNOdASdaugMg+C3mvoFOz36CciJEQxz14Vr1gzECO0CcJDqxYgRvzqNmD3miCV79f8KK4XzRZONodxu3ZtYFsl27dyfCaKA+HlOm2U6dSVncwuQ8c2lIZwv2UaEsD2hbIty3KgSu0q0ANzE9YdLZBHeGBYX7H8wDuC64gVugnj4iUUAzIhoF41FhstLl0huyKqKkAooO/5GDlbN7GMpjP9xuVqEuGGxMi3xbmKsRUXr9BXGYtWBKwsmFT4ZHwh+BXW5g/ftG8OgaoWYEVaXLDIpC7s/BeOXUDG12BUKRTfOwcJAYqVsASziCym+ViSFB6pQ4KQ9fJ5wmS//Ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TmcDYc7H0S6bH9oEkvwHBJoAArjFlGnTjn1pOTdkzQg=; b=fJPjMhSivhq1tWsdJBzU+0UIpqsPIxHLjsgZusBtnEabF3NgOdNnRI2BcSQ491SpCd9XGWeQWQY+gTdvWgPOEsmJgAWLO9k++aMaqGbwt0Am1a4rH6QPAZVj3KTaxQ83MT2kav6WgUimhryQYE4kz97n+Pb2XBudpbLFIqFFCnQ= Received: from BY3PR03CA0020.namprd03.prod.outlook.com (2603:10b6:a03:39a::25) by SA3PR12MB7877.namprd12.prod.outlook.com (2603:10b6:806:31b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.13; Mon, 31 Aug 2026 15:08:56 +0000 Received: from SJ5PEPF000001EC.namprd05.prod.outlook.com (2603:10b6:a03:39a:cafe::a7) by BY3PR03CA0020.outlook.office365.com (2603:10b6:a03:39a::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.13 via Frontend Transport; Mon, 31 Aug 2026 15:08:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by SJ5PEPF000001EC.mail.protection.outlook.com (10.167.242.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.382.8 via Frontend Transport; Mon, 31 Aug 2026 15:08:56 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Mon, 31 Aug 2026 10:08:43 -0500 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Mon, 31 Aug 2026 10:08:44 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.46 via Frontend Transport; Mon, 31 Aug 2026 10:08:39 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Russell King CC: , , , Subject: [PATCH net-next v3 5/6] net: xilinx: axienet: Dispatch statistics through axienet_config ops Date: Mon, 31 Aug 2026 20:38:15 +0530 Message-ID: <20260831150816.1020883-6-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260831150816.1020883-1-suraj.gupta2@amd.com> References: <20260831150816.1020883-1-suraj.gupta2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EC:EE_|SA3PR12MB7877:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ac8846d-420f-4b7e-8a85-08df0771c754 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|7416014|36860700016|376014|82310400026|10067099003|6133799003|18002099003|22082099003|11063799006|56012099006|921020; X-Microsoft-Antispam-Message-Info: LEdmGx9nNypp9/bzi2dy7/LoQfzNk/smEj3LrTxOLb/7JoJz9qBZMwTnDO/dZnYdDRZzKJBlpkpjrK+t6/Le8ULxjvVKp5vebytJ7+l6XxN33xkeiTv7tC62vXTApNDe+P2yf0EIRfgURmXgl1Q2/nNLfB5oXUYMn/VuNauhXTBVgBaNs06v3H6aqYsrocUCZQJCDNKDZmSOijzL/HLsgKh39MVX7kiSTPpIILpQgUVWZRVVDr0y+r0mS/SDVdZZ0yZVRnYUB7Fse5CKiGEH5K9Vojc6Q4B6gMclMY1HwlwcxB6Qsm4TmLrHB9jfcS7/2Dqv2d2qkkNjh83vKEpGi4FctVjK5G61I7h8M50webBorZQjHLWq7xepxwLW6Ex1qsRzgX/fTZ43H/qNq0v2ypkHz0LkDZwK/2exfr2MFg//UDBxQOYz42IF+CpCf9N5Lhnylm4l8EFd8xJilWTzOMagLlTcgBMKRn8YHDKqT6G4FkjjFlflUOhpi6eKbOybnzGf2XI3+RyRAmT2dAe4ai9gARApF/eSsSdjZ90HuU2Kh9QJSi/fqg4FUTb09DtxEQIKXvPh4ajieHgBWm4y4N8fnOxtG7jQ7e97Rmpx21E2PyF0NpJhUv13q3rkpehbiHlbyLBPXl0crHvksDLgxtLPq+Pf/6DjpcOLi0G8+MKDV3RSdI1CvE3wcrIUclSDU3BOUPOn1JhdqRmYjPRE1dP6W75v2vFFllR4YtgaZKAjFuzpF+8oCMReZLG0x1aw X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(7416014)(36860700016)(376014)(82310400026)(10067099003)(6133799003)(18002099003)(22082099003)(11063799006)(56012099006)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YetvgdU5XsZ4cIlTX9LdC2GYSpOdgFyvCGjstGloWPXNaTy9Gd0eXUbjnCwq3Mp/d+4f8q4y4EjknTs/XTh5w+IhjBHeb8xiPgURlgiDjhMysehzYuLQnP0T2LH70n/Ny0uDyNvFYxUAJPMm1WPHWOtwNL08Kz+pdTqn7TOn7tH3XZ8QqpImnAsARxdB1RD/IfJjglOS9I4a6ii5Q329kD5fnxzV5mrvzpmzkKyM/KFJElP+wA3BZ6dfGz7XXhioD655x86iSN1eeswJaj1uckUR6rKER03hGxL+geJ/4yoOWMIBIUNaZVGIcngq5K3xjTwm7gWWn1Uskxq04taZQDdU/FjnbQ8yIDjOCSSHcCFkF0yea0NhHh92LG55/F1zzkut2VGr6ACO0bCd5fPsxr4/6j0PHBgZCMvrpLx2d5UXves6gMZHTzLIYrf73nS9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2026 15:08:56.6157 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ac8846d-420f-4b7e-8a85-08df0771c754 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7877 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260831_080907_293970_14AB1C9A X-CRM114-Status: GOOD ( 19.95 ) 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 The ndo_get_stats64() and ethtool statistics callbacks read the 1G MAC hardware counters directly. Supporting a second MAC type this way would require an "if (mactype == ...)" dispatch branch in each of the eight statistics callbacks. Add statistics operation function pointers to struct axienet_config and route get_stats64, get_ethtool_stats, get_strings, get_sset_count, get_pause_stats, get_eth_mac_stats, get_eth_ctrl_stats and get_rmon_stats through them. Factor the existing 1G counter reads into axienet_1g_*() helpers and populate axienet_1g_config with them. A NULL op means the MAC does not expose that statistics group, so a MAC without control-frame counters simply leaves get_eth_ctrl_stats unset instead of open-coding the special case in the callback. No functional change intended. Signed-off-by: Suraj Gupta --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 23 +++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 171 +++++++++++++----- 2 files changed, 146 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index a1d15b4797ce..f286c428343f 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -658,6 +658,15 @@ struct axienet_local { * @phylink_set_caps: Callback to set phylink MAC capabilities * @pcs_ops: phylink PCS operations for this MAC, or NULL if unused * @stats_update: Callback to latch/accumulate the periodic MAC counters + * @get_stats64: Callback to read MAC counters into rtnl_link_stats64 + * @get_ethtool_stats: Callback to read MAC counters for ethtool -S + * @get_strings: Callback to fill the ethtool -S statistic name strings + * @get_sset_count: Callback returning the number of ethtool -S statistics + * @get_pause_stats: Callback to read MAC pause-frame counters + * @get_eth_mac_stats: Callback to read IEEE 802.3 MAC counters + * @get_eth_ctrl_stats: Callback to read MAC-control frame counters, or NULL + * if the MAC exposes no control-frame counters + * @get_rmon_stats: Callback to read RMON counters and histogram ranges */ struct axienet_config { bool mdio; @@ -683,6 +692,20 @@ struct axienet_config { struct phylink_config *config); const struct phylink_pcs_ops *pcs_ops; void (*stats_update)(struct axienet_local *lp); + void (*get_stats64)(struct axienet_local *lp, + struct rtnl_link_stats64 *stats); + void (*get_ethtool_stats)(struct axienet_local *lp, u64 *data); + void (*get_strings)(u8 *data); + int (*get_sset_count)(void); + void (*get_pause_stats)(struct axienet_local *lp, + struct ethtool_pause_stats *pause_stats); + void (*get_eth_mac_stats)(struct axienet_local *lp, + struct ethtool_eth_mac_stats *mac_stats); + void (*get_eth_ctrl_stats)(struct axienet_local *lp, + struct ethtool_eth_ctrl_stats *ctrl_stats); + void (*get_rmon_stats)(struct axienet_local *lp, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges); }; static inline struct axienet_local *pcs_to_axienet_local(struct phylink_pcs *pcs) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 19fe2fd81f3a..198de353372a 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1874,29 +1874,11 @@ static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) return phylink_mii_ioctl(lp->phylink, rq, cmd); } -static void -axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) +static void axienet_1g_get_stats64(struct axienet_local *lp, + struct rtnl_link_stats64 *stats) { - struct axienet_local *lp = netdev_priv(dev); unsigned int start; - netdev_stats_to_stats64(stats, &dev->stats); - - do { - start = u64_stats_fetch_begin(&lp->rx_stat_sync); - stats->rx_packets = u64_stats_read(&lp->rx_packets); - stats->rx_bytes = u64_stats_read(&lp->rx_bytes); - } while (u64_stats_fetch_retry(&lp->rx_stat_sync, start)); - - do { - start = u64_stats_fetch_begin(&lp->tx_stat_sync); - stats->tx_packets = u64_stats_read(&lp->tx_packets); - stats->tx_bytes = u64_stats_read(&lp->tx_bytes); - } while (u64_stats_fetch_retry(&lp->tx_stat_sync, start)); - - if (!(lp->features & XAE_FEATURE_STATS)) - return; - do { start = read_seqcount_begin(&lp->hw_stats_seqcount); stats->rx_length_errors = @@ -1924,6 +1906,33 @@ axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); } +static void +axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) +{ + struct axienet_local *lp = netdev_priv(dev); + unsigned int start; + + netdev_stats_to_stats64(stats, &dev->stats); + + do { + start = u64_stats_fetch_begin(&lp->rx_stat_sync); + stats->rx_packets = u64_stats_read(&lp->rx_packets); + stats->rx_bytes = u64_stats_read(&lp->rx_bytes); + } while (u64_stats_fetch_retry(&lp->rx_stat_sync, start)); + + do { + start = u64_stats_fetch_begin(&lp->tx_stat_sync); + stats->tx_packets = u64_stats_read(&lp->tx_packets); + stats->tx_bytes = u64_stats_read(&lp->tx_bytes); + } while (u64_stats_fetch_retry(&lp->tx_stat_sync, start)); + + if (!(lp->features & XAE_FEATURE_STATS)) + return; + + if (lp->axienet_config->get_stats64) + lp->axienet_config->get_stats64(lp, stats); +} + static const struct net_device_ops axienet_netdev_ops = { .ndo_open = axienet_open, .ndo_stop = axienet_stop, @@ -2356,11 +2365,8 @@ static int axienet_ethtools_nway_reset(struct net_device *dev) return phylink_ethtool_nway_reset(lp->phylink); } -static void axienet_ethtools_get_ethtool_stats(struct net_device *dev, - struct ethtool_stats *stats, - u64 *data) +static void axienet_1g_get_ethtool_stats(struct axienet_local *lp, u64 *data) { - struct axienet_local *lp = netdev_priv(dev); unsigned int start; do { @@ -2377,6 +2383,17 @@ static void axienet_ethtools_get_ethtool_stats(struct net_device *dev, } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); } +static void axienet_ethtools_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, + u64 *data) +{ + struct axienet_local *lp = netdev_priv(dev); + + if (lp->features & XAE_FEATURE_STATS && + lp->axienet_config->get_ethtool_stats) + lp->axienet_config->get_ethtool_stats(lp, data); +} + static const char axienet_ethtool_stats_strings[][ETH_GSTRING_LEN] = { "Received bytes", "Transmitted bytes", @@ -2389,12 +2406,26 @@ static const char axienet_ethtool_stats_strings[][ETH_GSTRING_LEN] = { "User Defined Counter 2", }; +static void axienet_1g_get_strings(u8 *data) +{ + memcpy(data, axienet_ethtool_stats_strings, + sizeof(axienet_ethtool_stats_strings)); +} + +static int axienet_1g_get_sset_count(void) +{ + return ARRAY_SIZE(axienet_ethtool_stats_strings); +} + static void axienet_ethtools_get_strings(struct net_device *dev, u32 stringset, u8 *data) { + struct axienet_local *lp = netdev_priv(dev); + switch (stringset) { case ETH_SS_STATS: - memcpy(data, axienet_ethtool_stats_strings, - sizeof(axienet_ethtool_stats_strings)); + if (lp->features & XAE_FEATURE_STATS && + lp->axienet_config->get_strings) + lp->axienet_config->get_strings(data); break; } } @@ -2405,24 +2436,20 @@ static int axienet_ethtools_get_sset_count(struct net_device *dev, int sset) switch (sset) { case ETH_SS_STATS: - if (lp->features & XAE_FEATURE_STATS) - return ARRAY_SIZE(axienet_ethtool_stats_strings); + if (lp->features & XAE_FEATURE_STATS && + lp->axienet_config->get_sset_count) + return lp->axienet_config->get_sset_count(); fallthrough; default: return -EOPNOTSUPP; } } -static void -axienet_ethtools_get_pause_stats(struct net_device *dev, - struct ethtool_pause_stats *pause_stats) +static void axienet_1g_get_pause_stats(struct axienet_local *lp, + struct ethtool_pause_stats *pause_stats) { - struct axienet_local *lp = netdev_priv(dev); unsigned int start; - if (!(lp->features & XAE_FEATURE_STATS)) - return; - do { start = read_seqcount_begin(&lp->hw_stats_seqcount); pause_stats->tx_pause_frames = @@ -2433,15 +2460,23 @@ axienet_ethtools_get_pause_stats(struct net_device *dev, } static void -axienet_ethtool_get_eth_mac_stats(struct net_device *dev, - struct ethtool_eth_mac_stats *mac_stats) +axienet_ethtools_get_pause_stats(struct net_device *dev, + struct ethtool_pause_stats *pause_stats) { struct axienet_local *lp = netdev_priv(dev); - unsigned int start; if (!(lp->features & XAE_FEATURE_STATS)) return; + if (lp->axienet_config->get_pause_stats) + lp->axienet_config->get_pause_stats(lp, pause_stats); +} + +static void axienet_1g_get_eth_mac_stats(struct axienet_local *lp, + struct ethtool_eth_mac_stats *mac_stats) +{ + unsigned int start; + do { start = read_seqcount_begin(&lp->hw_stats_seqcount); mac_stats->FramesTransmittedOK = @@ -2478,15 +2513,24 @@ axienet_ethtool_get_eth_mac_stats(struct net_device *dev, } static void -axienet_ethtool_get_eth_ctrl_stats(struct net_device *dev, - struct ethtool_eth_ctrl_stats *ctrl_stats) +axienet_ethtool_get_eth_mac_stats(struct net_device *dev, + struct ethtool_eth_mac_stats *mac_stats) { struct axienet_local *lp = netdev_priv(dev); - unsigned int start; if (!(lp->features & XAE_FEATURE_STATS)) return; + if (lp->axienet_config->get_eth_mac_stats) + lp->axienet_config->get_eth_mac_stats(lp, mac_stats); +} + +static void +axienet_1g_get_eth_ctrl_stats(struct axienet_local *lp, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + unsigned int start; + do { start = read_seqcount_begin(&lp->hw_stats_seqcount); ctrl_stats->MACControlFramesTransmitted = @@ -2498,6 +2542,19 @@ axienet_ethtool_get_eth_ctrl_stats(struct net_device *dev, } while (read_seqcount_retry(&lp->hw_stats_seqcount, start)); } +static void +axienet_ethtool_get_eth_ctrl_stats(struct net_device *dev, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct axienet_local *lp = netdev_priv(dev); + + if (!(lp->features & XAE_FEATURE_STATS)) + return; + + if (lp->axienet_config->get_eth_ctrl_stats) + lp->axienet_config->get_eth_ctrl_stats(lp, ctrl_stats); +} + const struct ethtool_rmon_hist_range axienet_rmon_ranges[] = { { 64, 64 }, { 65, 127 }, @@ -2510,16 +2567,12 @@ const struct ethtool_rmon_hist_range axienet_rmon_ranges[] = { }; static void -axienet_ethtool_get_rmon_stats(struct net_device *dev, - struct ethtool_rmon_stats *rmon_stats, - const struct ethtool_rmon_hist_range **ranges) +axienet_1g_get_rmon_stats(struct axienet_local *lp, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) { - struct axienet_local *lp = netdev_priv(dev); unsigned int start; - if (!(lp->features & XAE_FEATURE_STATS)) - return; - do { start = read_seqcount_begin(&lp->hw_stats_seqcount); rmon_stats->undersize_pkts = @@ -2563,6 +2616,20 @@ axienet_ethtool_get_rmon_stats(struct net_device *dev, *ranges = axienet_rmon_ranges; } +static void +axienet_ethtool_get_rmon_stats(struct net_device *dev, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct axienet_local *lp = netdev_priv(dev); + + if (!(lp->features & XAE_FEATURE_STATS)) + return; + + if (lp->axienet_config->get_rmon_stats) + lp->axienet_config->get_rmon_stats(lp, rmon_stats, ranges); +} + static const struct ethtool_ops axienet_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USECS | @@ -2914,6 +2981,14 @@ static const struct axienet_config axienet_1g_config = { .phylink_set_caps = axienet_1g_phylink_set_caps, .pcs_ops = &axienet_pcs_ops, .stats_update = axienet_1g_stats_update, + .get_stats64 = axienet_1g_get_stats64, + .get_ethtool_stats = axienet_1g_get_ethtool_stats, + .get_strings = axienet_1g_get_strings, + .get_sset_count = axienet_1g_get_sset_count, + .get_pause_stats = axienet_1g_get_pause_stats, + .get_eth_mac_stats = axienet_1g_get_eth_mac_stats, + .get_eth_ctrl_stats = axienet_1g_get_eth_ctrl_stats, + .get_rmon_stats = axienet_1g_get_rmon_stats, }; /* Match table for of_platform binding */ -- 2.25.1