From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012047.outbound.protection.outlook.com [40.93.195.47]) (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 33B2C3BB661; Tue, 6 Oct 2026 11:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.195.47 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791284796; cv=fail; b=AoBaoqr/BCUdlUehLlH9/ZFtKsoBqNyZsLibSyvwReKRW6p7gXiTo4VeS+WgKIyabIBqyEwUM+k+LiTbz37zcnj2dBbSle7Ci6J7rxjg71h69KGjT5x4bPgHZMdMDTcVWlLx33Ta6YCASDl3Yx97Ky0yv0g4lqo5T1AuyzfIX/g= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791284796; c=relaxed/simple; bh=00CoiD+lhfygo8hCB7JhhpXAhlb7L/9USYZ7MOBWmQg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pve9QuzSdd9vOgP/nWYm/l/GkBqIsL1jwSb0M9+b+Qv3waqL6ykdo4RQrYOgu2pIorTfO0souyoKzNFDCeclw6MQ7l9AYquDUgjuGZh8r+MMJi/HDkjRxtqLAXPS5e9npvRLhO9QC2pINi63qH1ftZTuzs6FUl0sAkRWYy0X3jA= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=3Tv+5GvQ; arc=fail smtp.client-ip=40.93.195.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="3Tv+5GvQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GaT5PaCtbjU67ApEXZK8ehVSexCOh33bmdd0DB1CzOeHq5/GcTEdPbof8fh+bQ5f0jQT4+M7Jbpaa/Wx6IFtUR/hILshgXLETAKJyt6E54XV2pkfhlYezamDzEN7RWSFDZh4fdXqTXi31QkZUFSEl1CgFOClbqbJeHM7b5dSlHiFT3RPDlPoSf8YmrimBVBE+V9La56P7as947GOQoXWe5lp4Tc7B2hdERax0ARFxNQAE1YIrZQrs+IxutVQSxTjDhhHfukesGuOiBmJk5obpFxLgYYdVejyIK11bBBNPlxnRuyV22rB0K+0KEvUhGrf7ZLoBF5i5nzFhcG1lx4+pQ== 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=xSK9oDfwuBAZngf59bFjWtUD6R4342eyW5PKy4GfgyQ=; b=t7S7Cxd5zdhXzpJy3Jh6YKnlsQYFkMIi8rG3lVvM6Ytjw3eaPdEDqtU4uFm9kHMVpl3Jh/9yIJ6oBiA9MWilYTupp1BwcYCkyMA6ACi+gIzuO5mZIkXKp1ZStmu1utvJSmFlDeeo9VJN6XCFC/ghWCsP48OFAO1WBzLgXxln4sDzi735GfUIZzwnt/ceSUSDxnMqL+B2uh/OOEq6PArIhiZpWsgQz2OENcqhck0GjJgvPxM1/KdFH60PWnCYsdGYLuHXarZ4ewEEWn7DxqslO+kr3f6v23M28y23bLB9Kg0MH3/7nDj391Fd9bcp6tM/NDAQvmPrQiEagwYhHLCILA== 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=xSK9oDfwuBAZngf59bFjWtUD6R4342eyW5PKy4GfgyQ=; b=3Tv+5GvQhUps22uTS6JvOxnf5gX3ApGP8LkzVqSutNOyUnmn9baRB9DFhWn0DZKuR0qPaIOA+oEDDcQvnpRLrO4X2b4fjmaDplrHJJBPk4cpqIUtvsMlVR9/doCh/PCOKwpFRqLpQR+7CiVx0kmZUqEXdOHboO7YmVGPWE3N+7w= Received: from BN8PR04CA0054.namprd04.prod.outlook.com (2603:10b6:408:d4::28) by PH7PR12MB9253.namprd12.prod.outlook.com (2603:10b6:510:30d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.18; Tue, 6 Oct 2026 11:06:23 +0000 Received: from IA0PEPF00000043.namprd04.prod.outlook.com (2603:10b6:408:d4:cafe::56) by BN8PR04CA0054.outlook.office365.com (2603:10b6:408:d4::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.472.20 via Frontend Transport; Tue, 6 Oct 2026 11:06:22 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by IA0PEPF00000043.mail.protection.outlook.com (10.167.249.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.496.14 via Frontend Transport; Tue, 6 Oct 2026 11:06:22 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 6 Oct 2026 06:06:17 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 6 Oct 2026 06:06:16 -0500 Received: from xhdsuragupt40.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.49 via Frontend Transport; Tue, 6 Oct 2026 06:06:12 -0500 From: Suraj Gupta To: Radhey Shyam Pandey , Andrew Lunn , "David S . Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: Michal Simek , Russell King , , , , Subject: [PATCH net-next v4 5/6] net: xilinx: axienet: Dispatch statistics through axienet_config ops Date: Tue, 6 Oct 2026 16:35:49 +0530 Message-ID: <20261006110550.1990213-6-suraj.gupta2@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261006110550.1990213-1-suraj.gupta2@amd.com> References: <20261006110550.1990213-1-suraj.gupta2@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA0PEPF00000043:EE_|PH7PR12MB9253:EE_ X-MS-Office365-Filtering-Correlation-Id: cbab6f4e-ad07-4b1c-7e87-08df2399db68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|82310400026|23010399003|376014|36860700016|10067099003|56012099006|6133799003|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: O+/4BC9hg+EfAW07vl1MtQiWITd+hB5UZLjK+3CJNaB3HqhS6FM3U++XFCsWpVKjYyWrQVl+JZN1npqE9CBZWJkjFgJp7zlgcwsjlihjpgkGhzRfwvRzv+498Ce9Rl0Y58BpgV62xsyrP5qseL2bpZsHX8Ts+CmFb2nqwrh0trXnI7BEN3T9w0AeWpjXLmHkpXIoGJLDXkMipJMbwuggSM+MMUPXkkgXr8oSZjvkqC3WwHrnFCTuCRUBOHLoF0seQUE9C2ZdYngltmXDt8gCFvJyiTMQER8hiF8EG3vPYdOjVQYxc/kRxayAAY90wX5TwZFuKg07/V96bjYVrsy9vrqiQvItM0fH+IlyCL74FHR1iRQrgVWUHLXd4NMR/t9vdt9PVp/J+PdpjO4AJ9QUH5AJMp0lkZOYNwPlrd2dJ39/AblReS8ak9OX50Q/nP0GwIIxYSHQJmLZHIVo4emsBfgW+MnwYGKgIPxS/btdZUF1GzXB5Me8gnfsOzTuYw0UtyKGVGuOjeo7i5opSUwKBV6IZ+qMlYWJ0oceJcWKJmtmLkGe57h2CABiVGLulKu/YFowraKz4h8F1c3MgWaowbV7YmaXp+pUrh+mnDpNv2NRmWpJ7tYo58O6pPXljiM8OXBackAbqVuCDI+bxm0/jp8mUIaNieu1uoQTna9+5z+lP3DRroxqCNfNJDgBZvihFSvpyC28uqQ7/n4GwhWg9A== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(82310400026)(23010399003)(376014)(36860700016)(10067099003)(56012099006)(6133799003)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 097RDdMe171J4IRDyBhkfusVtr/TgQqqETakyHH2q1NPX1QknNhunya1Ndw8T/lLgcKr+OXkdAjRy/4mi8wr++8tZaFYDhm1mgW3Zv0jGX6ftgSAOq8RdB9aLqdc8WsDmAlL+rZB2b/3vmdveo1cHZYVUUhRLm6hOBwpgl/YUte/jpjZWlTS48FnJolUyfG/iK6WdId3zIaomRB9HyT0cRRtlwlp1D7eH3mu9TJlBO5KACKxvM0l2j0AKshJ4bTaK80xmGNe+9oGQUvAsHJ30sg+YbXDHtRwYzBu8Tm2QAFuH6ElN3vnGAa94CRx0FL4t7ygjCtfH0vhII0Ya1NZL/8A/yzmLfct00uEW2vnKKhbT+aizEiwchFss6jctdKiNr//YUqZUSaNnn6+CC3+u8/owN7vxVuUbbl5rWg3okpR8MKT/GjRSaIfeq7IYJI4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2026 11:06:22.7487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbab6f4e-ad07-4b1c-7e87-08df2399db68 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: IA0PEPF00000043.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9253 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 07545eae3c12..7ba2fe29e97b 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 68e94231ff04..d0aa768452ea 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1875,29 +1875,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 = @@ -1925,6 +1907,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, @@ -2357,11 +2366,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 { @@ -2378,6 +2384,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", @@ -2390,12 +2407,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; } } @@ -2406,24 +2437,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 = @@ -2434,15 +2461,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 = @@ -2479,15 +2514,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 = @@ -2499,6 +2543,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 }, @@ -2511,16 +2568,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 = @@ -2564,6 +2617,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 | @@ -2915,6 +2982,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