From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.43.65 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796107765; b=5m8wHkgSZg405k69tCujXZi3oOGp4CWZCkpsd1xH+5Plp1OBL1p9/eiRZS7kJbXC3VZx pbtdnkOnU2pUr4l4C0do+VfV4im1u4zDfUvB5czTv4MGbkfc6HF4jzHk8E4IsPOQEo4OL VUuyZJLZmFPbrL3msEBlbxqCJGH0YnoGoDMEjxwN3xkH1smF/o5s1iLw2vGRo69RbgpDa pQQAkLT4eQKPG1emVxwIXZ1T+QD3be2Tiq2x4AhvQVu4dLlVUeTgb8ToffcWPt5/S0Lgh i9VEMuW7nznEGktWGT1t46s/Xx9/wtLH6P2LUiwB1cWgVy4dhGkTezJMySfMFRhmP5w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796107765; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-ID:References:In-Reply-To:To:CC:X-Mailer:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=Ae+FSrLiFTmVOLjisgV5Hsu2Gfl3WkiX10F2FE22B3Q=; b=u61QCm4JxqMQ7ZIQodSKJCdvr40D03mxojWZjOrvGehEFarEu1M4yBsy13RrcqUz6YWi A3Qhv10qiAu/z+MOzD007/tobTARgXkypuG+3KryBDegdltPcCtGulD/CwewLKEk4xYx5 GKs9PK3tfhJkg8m4jEKVzOR6MOQR4paIiNuGVe84GvgEXUUtdevJujahbaPMBcAoOwPr0 zFHRcewUvqov0TfxzLG2N15EP5zfSZLCZbWCs3M7+7FLDrMb1uqcG+xj/Zkw26kFRj9io cvcWWvs9RDYO0W3K5vYBhwS0LqxJPgtNiUS1ZEkXjF+WVSR8XQqs71Nma+ALtAuTowg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=2FvwmmXI; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.43.65 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012065.outbound.protection.outlook.com [52.101.43.65]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12E2B606A6A8 for ; Tue, 1 Dec 2026 06:49:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12E2B606A6A8 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, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=2FvwmmXI ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jPNp/ds5g1AESanVZMdnCdiAdbbpQIEy1XJcxNcPO224WrRqbXiOoYSIBwfmEv745tqbglQNUvX9E7YSiCam1B/8CK1FFyZRhrm69zJvioqHvVua8HJpozsUTQOidJw5yA/+7gEi1hJzPp7S0SKRHDTM10ZWKAJZmg/rz7F0fo7bmLb3ZQnuxomokPqIpgPgveSoUpLocO+k52suGaziUQK9+LGLBk7OQyC2rAW3JUlnLDjSfMrFw3T1ZYFTuNMzIloM1Ps0TQJnYLMuex7rIcKXt5lBAiSasxj2uBpxpYT/w8PAUIR2W0KYDwmf48tuEjhdh3ua3N9V5o59YzO+Kw== 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=Ae+FSrLiFTmVOLjisgV5Hsu2Gfl3WkiX10F2FE22B3Q=; b=A3m2+YCF597aImbSq0qGlNys5qKX3+G/bOldmE2Uj0JahjmnvNDoEJR2KTxE9YWpu5uo/qkXWl7wjQuxiZciJh+iZ1gDpMXsdg36MDhvndHgrZS0/p8PSyvixPHz2r+HtAN41st6gHKSzhGe0GKqxylts8jGlwoa0+c90XOBxq5TM+2K77Dp2uRMeVyCtHwKemr4qj8g0HySidAxJXb7PCbeXoh5r2P5F2aj1qv8Pof752pGLIp7DqLEnaV++qCl1DCtaY1rjK023AsEVPCERCmT6C7IgwLpp6h8yzrK910V7Gam8fsIeBX5BR1JhqdOLWm/RFZXCMSigU2YGLBFTQ== 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=Ae+FSrLiFTmVOLjisgV5Hsu2Gfl3WkiX10F2FE22B3Q=; b=2FvwmmXId3NZ3npywv5r5ChzZt4YuYeAvuF4ThWf2MXcofbforL5OQAKqHkVZAN/BuUyOc25cxCueWxV2MijM418uCQIq+DSqW/mcXLV0yntePCykasbSg3d/RMl/sc9WsOeEl7tDAAk1qWsC5rc63EFgihLtq7RVtJJ5KwjT+Y= Received: from CH2PR02CA0016.namprd02.prod.outlook.com (2603:10b6:610:4e::26) by IA0PPF12042BF6F.namprd12.prod.outlook.com (2603:10b6:20f:fc04::bc8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 06:49:18 +0000 Received: from CH2PEPF00016D4B.namprd02.prod.outlook.com (2603:10b6:610:4e:cafe::b) by CH2PR02CA0016.outlook.office365.com (2603:10b6:610:4e::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.12 via Frontend Transport; Tue, 1 Dec 2026 06:49:17 +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 CH2PEPF00016D4B.mail.protection.outlook.com (10.167.244.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 06:49:17 +0000 Received: from SCSEJOYNER01.amd.com (10.180.168.240) 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.57; Tue, 1 Dec 2026 00:49:16 -0600 From: Eric Joyner Date: Mon, 30 Nov 2026 22:48:58 -0800 Subject: [PATCH net-next v7 6/6] ionic: Add .get_fec_stats ethtool handler X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261130-ionic-get-fec-stats-v7-6-730c1672f561@amd.com> References: <20261130-ionic-get-fec-stats-v7-0-730c1672f561@amd.com> In-Reply-To: <20261130-ionic-get-fec-stats-v7-0-730c1672f561@amd.com> To: CC: Brett Creeley , Andrew Lunn , "David S. Miller" , "Jakub Kicinski" , Paolo Abeni , Simon Horman , Vadim Fedorenko , "Nikhil P. Rao" , Eric Joyner , Eric Dumazet X-Mailer: b4 0.14.3 X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00016D4B:EE_|IA0PPF12042BF6F:EE_ X-MS-Office365-Filtering-Correlation-Id: 8845ea1e-ed2d-4f29-66e7-08df4f773888 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|1800799024|376014|11063799006|5023799004|6133799003|261009223027099003|22082099003|18002099003|3023799007|56012099006|10067099003|261102123227099003|261022075727099003|261026121527099003|261021121427099003|261021135927099003; X-Microsoft-Antispam-Message-Info: g4+G2sMLXroszP4gGxZpTBHzxQeZzNrboZR81yEdafN/S2cZFL4V6nEUOUaWmQ/XzO6X3M8ncB2J24F2+FMO8n3MG9rZEoQqQZ2LeULuAwWzraCB8WKLQwgEGXEn0AYXvskYfCJLhHxvXLUZAL/Ck84yhmgsaIK2H+TsTl/UfKOrcQSwpv0MC5tGtSqXwcOjbBAGC7pP8WdK9Vea/2FTzgMDVV7D8kRFTm9cyBgVEpTdVHZBVbv5P3xHNAS7bUvghN9f66Dx0FNwRy1hAKLaxOogqjRiGvduOhmbOYdMUwOBYXKaPdwZBtsNAPCDz0FmHVeX6dka6lB1qxX/bE0Q5pxRgtaNgGjsZ/OoMEj/XdCtkcp8Ny5a9bZT8sy8LpqkV/YutXOwGIYyGfIdlXDcopiGIukEYBcXAD43lwzBc7p1NRm+pFG54KuwCEv+0hdO3wYO8ZetiS8RRZO55UM03ETdXmpXAAJ2e4zsvEUy5EMJvNed8NjN6s3ixPar05BMkX/nXvFqtHhYDyznRriC2vo/CME2QMhqZVUAbEQ2M2O1KngtAjvL6IYEJTRy11z5xKYPx3veEJ3LF/UrXBYMKJydkowUiE8RZf4jxRgNcu1AZMBRvn/OjWUJQlbwrWYI5NUnD4VhhIWzWIT10sPRkUrTYC5JnTJRgyjJtoSH1RRwan0ezAq+6dA0FD6MuzLmKvcWdIBA5VtCdUy29l8BGw== 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)(82310400026)(23010399003)(36860700016)(1800799024)(376014)(11063799006)(5023799004)(6133799003)(261009223027099003)(22082099003)(18002099003)(3023799007)(56012099006)(10067099003)(261102123227099003)(261022075727099003)(261026121527099003)(261021121427099003)(261021135927099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NMSodGPqhf9J+aGa3D9Bg9+fdq9N+hY6zodCGH7EzclUR+bWhzGDZ9mCzW2R9U2pvbZHSmIVhAOCdxActHVLUPHjYbIzWcRjJqJYn5mgLdGnqff0Sxx5ApllHW8gjC29TKBKeNOo2eL4R+vn5xp4MP2fd3mXjgMZReJ8/r7rKO+cWLPdHZM/oGrEVNs6KNr14bTHzD1LtzmrHaSZypSgzNAYqG3swM4lOCxDy4dEnyNlibYWn2Lq57PyapjPov3qZpBNT9g8gf1RzzTCsSTddVk1skyZDOPSwx6FrERuOdSiBekJN1dUlbzHDJsZ57KZKRC7+4VfAldSFdKXfv/vGCHLsC8nTHPOW0EZGqDRp7J4HyNPXrNWL9DVwqMUlM14ITSiSSibxBWSS4YgRCnuns4J6zmsI7aJkJ14d8ufq4/UJ9+K3sMVAaf49Usynjw+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 06:49:17.7500 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8845ea1e-ed2d-4f29-66e7-08df4f773888 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: CH2PEPF00016D4B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PPF12042BF6F Reports FEC statistics totals and an 802.3ck FEC histogram. Per-lane counts currently aren't supported. Every counter reported here comes from the RS decoder, including fec_corrected_bits_total despite its name, and the only histogram format firmware produces is the 16-bin one from RS(544,514), so nothing is reported unless RS is the active FEC mode. The only devices whose firmware reports the histogram do not support RS(528,514), so RS on those devices is always RS(544,514). These are physical port counters, so virtual functions are skipped the same way ionic_get_link_ext_stats() skips them, rather than reporting the port's counters as if they belonged to the VF. The reporting of these statistics is gated by DEV_CAP_EXTRA_STATS and checks for IONIC_STAT_INVALID, since only the newest devices support reporting all of these stats. Older devices can only report some of the statistics or not at all, and so the output will properly exclude those unsupported statistics. The firmware writes these counters by DMA while they are being read. Use READ_ONCE() to ensure that the IONIC_STAT_INVALID test and the store see the same value. Counters are still read one at a time, so the set reported can span more than one firmware update. Co-developed-by: Nikhil P. Rao Signed-off-by: Nikhil P. Rao Signed-off-by: Eric Joyner Signed-off-by: Brett Creeley --- .../net/ethernet/pensando/ionic/ionic_ethtool.c | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c index c25483134b93..8f316d1ed9f2 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c @@ -465,6 +465,91 @@ static int ionic_get_fecparam(struct net_device *netdev, return 0; } +#define IONIC_FEC_STAT(dst, src) \ + do { \ + __le64 __val = READ_ONCE(src); \ + \ + if (__val != IONIC_STAT_INVALID) \ + (dst) = le64_to_cpu(__val); \ + } while (0) + +static const struct ethtool_fec_hist_range ionic_fec_hist_ranges[] = { + { 0, 0}, + { 1, 1}, + { 2, 2}, + { 3, 3}, + { 4, 4}, + { 5, 5}, + { 6, 6}, + { 7, 7}, + { 8, 8}, + { 9, 9}, + { 10, 10}, + { 11, 11}, + { 12, 12}, + { 13, 13}, + { 14, 14}, + { 15, 15}, + { 0, 0}, +}; + +static void +ionic_fill_fec_hist(const struct ionic_port_extra_stats *extra_stats, + struct ethtool_fec_hist *hist) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(extra_stats->fec_codeword_error_bin); i++) { + __le64 val = READ_ONCE(extra_stats->fec_codeword_error_bin[i]); + + if (val == IONIC_STAT_INVALID) + return; + + hist->values[i].sum = le64_to_cpu(val); + } + + hist->ranges = ionic_fec_hist_ranges; +} + +static void ionic_get_fec_stats(struct net_device *netdev, + struct ethtool_fec_stats *fec_stats, + struct ethtool_fec_hist *hist) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic_port_info *port_info; + u32 active_fec; + u32 fec; + + if (lif->ionic->pdev->is_virtfn) + return; + + if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) + return; + + if (!(lif->ionic->ident.dev.capabilities & + cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS))) + return; + + port_info = lif->ionic->idev.port_info; + if (!port_info) { + netdev_err_once(netdev, "port_info not initialized\n"); + return; + } + + ionic_get_fec_modes(port_info, &fec, &active_fec); + if (active_fec != ETHTOOL_FEC_RS) + return; + + IONIC_FEC_STAT(fec_stats->corrected_blocks.total, + port_info->extra_stats.rsfec_correctable_blocks); + IONIC_FEC_STAT(fec_stats->uncorrectable_blocks.total, + port_info->extra_stats.rsfec_uncorrectable_blocks); + IONIC_FEC_STAT(fec_stats->corrected_bits.total, + port_info->extra_stats.fec_corrected_bits_total); + + ionic_fill_fec_hist(&port_info->extra_stats, hist); +} + static int ionic_set_fecparam(struct net_device *netdev, struct ethtool_fecparam *fec) { @@ -1206,6 +1291,7 @@ static const struct ethtool_ops ionic_ethtool_ops = { .get_module_eeprom_by_page = ionic_get_module_eeprom_by_page, .get_pauseparam = ionic_get_pauseparam, .set_pauseparam = ionic_set_pauseparam, + .get_fec_stats = ionic_get_fec_stats, .get_fecparam = ionic_get_fecparam, .set_fecparam = ionic_set_fecparam, .get_ts_info = ionic_get_ts_info, -- 2.53.0