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.56.49 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796107757; b=XSQgzaNUoENPQ/nPNmjHsr0uVPN/x+y0sq3o7qg7cuSQisaaIKt2mBlXBrad4qFWlLdA MjaFXR1qUjsE8fR0iZaFLs+k/yH/tZd+hBq469beqCfmHxa0dzp7zNuY1QC/fG4MMZYF4 1aldAflVP5xBAyYfrSgBlCS9LsK9Cwh26/A8m0ImdkXOJnz88uz8cOcKeTJwjiI9Xh1Hp iq+jNQpXWNogwCAwjr+yZ3A4jEJSayGd60k144w3IO+ixBuBlw4qpWbr/bnQDHVdqCibG PfOD9dUTh1ijlJTViNCL2hSD0l7STO/CQ9+1pr2f7+S2WoKBCFDn8QK1EBLcGysYVmg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796107757; 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=HHQQ2Re8XK/b16Ws3icsL/U9RgPyrvs5s4oTQB01lyA=; b=XoHJ5yfjoLlUAK9NucW+eLVDT+kWP7QWSFiaWR3xTzBawv1w+qhO9zWdRBCIylc6vCHa fLyY/xYz5YRXA/cok6VnyUZoVpKck7CuPdscZnS0Ut2zlLLXejxjdyuyrVAd/QYpkM4vK U7C75e2PE9FjUcuIIZUJeo2fAaBjkLLK+enpgwS7V0duf5HpUgjOykstQF8mKzvwxtBFd eOIX/zhcbItC8lWreyecS3UvX4zStxlP/7WEBXMw3Z1U9ISowpM6gtvnxHeVkP/gfdmyA axOJJZfXlD5pkxhl1NLCHxponhs6vbhjbv1/d9pJPsFPrKDycE6cWLyMFvAYIMDvDrQ== 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=LN2CPRtS; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.56.49 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010049.outbound.protection.outlook.com [52.101.56.49]) (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 78A61606A338 for ; Tue, 1 Dec 2026 06:49:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 78A61606A338 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=LN2CPRtS ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HafTmlgC2PsCEUpk5XZOzo6pzLcxWEO2OVHkDFHtFo/SLQ9GXjMPZ+sLNXmHkYzZqEhOyHSp6nKUop17nTZVJDSjOpHDdJVC3RAu0N3kOtiWDU1+g0v4tLGe4VD9cO6h8HMhEj7p691g6q0SAFOONTuV3JQIGz8BjTXTwMPbISc7UElGPZGh/AlmDYnKec8TsJXVbtSfVD658A9Ja828DNlZ3RUV/gfEDmqASVPR9MSqg5OmoAM6IwY36/OyaBwlj+m9InV1ll4oOzFSGU8atCqH+E15MpptUfSLqj2f/qTEEEjcOnoBst6wE4++YVf4mTVrI0h9bqY61RvdYVnuYQ== 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=HHQQ2Re8XK/b16Ws3icsL/U9RgPyrvs5s4oTQB01lyA=; b=Nt1Ki+hTed727ePG+rTF6UCXs+lp8F8+3Q71dXLs19ShAhK8JMwZM9JVKWNYcu8sd6ltLdUHaCVJJ+XhslMiE1zC3uhpi9vzmEksRBV3BNJvJoEkq3gsKVj3HMzPDK8UNzs+5tRuScaXpQmPGd+vSvWOIzEHIfEMYGF4O92h0e5QAR6H1Nv6csFJdx9rNwj5zWE3yGiN0vwjlZKUSB+Xcli9uo29RUTgVC4NvS03/6OC7V8S/upxeG1c3G0/Ewg0+E+NSs+c3ZGoDJRDVSVgvTK0GwDVbY+IetkyznG72c2QSeAjgJ0eMrvjS1nWZKo+L6kV1fRXsk/oPz/xIUtE1Q== 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=HHQQ2Re8XK/b16Ws3icsL/U9RgPyrvs5s4oTQB01lyA=; b=LN2CPRtS+NotzpVkAVFs4WFv1Lsgwe9TsTtMukzfcThTiy+USAG0ScE02pC7OcjQSxgNUqng+b4Nti65rG2EfG2B6N48HMOm6kZAD0RvnROwjX7qyi+ZaDqa3N7X3aawmBxyZNyArM7ODuKSot4R7nEFpsrZElnCjJcc+3vNkhk= Received: from CH0P220CA0026.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::22) by DM4PR12MB5963.namprd12.prod.outlook.com (2603:10b6:8:6a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Tue, 1 Dec 2026 06:49:12 +0000 Received: from CH2PEPF00016D4C.namprd02.prod.outlook.com (2603:10b6:610:ef:cafe::62) by CH0P220CA0026.outlook.office365.com (2603:10b6:610:ef::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.615.8 via Frontend Transport; Tue, 1 Dec 2026 06:49:12 +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 CH2PEPF00016D4C.mail.protection.outlook.com (10.167.244.121) 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:12 +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:09 -0600 From: Eric Joyner Date: Mon, 30 Nov 2026 22:48:53 -0800 Subject: [PATCH net-next v7 1/6] ionic: access the extra_stats counters one at a time 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-1-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: CH2PEPF00016D4C:EE_|DM4PR12MB5963:EE_ X-MS-Office365-Filtering-Correlation-Id: 18827917-853e-4f34-08fa-08df4f773520 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|23010399003|82310400026|376014|10067099003|56012099006|261022075727099003|261026140227099003|261026121527099003|261028144727099003|261022105027099003|261102123227099003|261021135927099003|261021123027099003|261021121427099003|261009223027099003|6133799003|22082099003|18002099003|11063799006; X-Microsoft-Antispam-Message-Info: JsgCXOt3GxfZ0dgLw9b5OHc2kp0Auf/FVLL7tOKitfei+P3AoXDVJ8lVeqVSNXcMQqTdKrpJzV94kdNjPpjX3tCKiHgCdMSyR3otN+RXjQNAEV7RhnhwQzETBVDnf58ZRy0o57zC8q7nKKgFVkap2Ef3fCcP6bJ1KMcJjcnKaJwZyUEyyTEPCSDGeDD28DqDJqHVqgIBRQIFD9qQTjro/g7Fgd/94/yHlTyFq/AaSWVzS5lwaW4IrALC0PKcLT5eqWsGXU6EadwJSAp/Siu3PFWrXce/MOm0fTDPPUNOk5mHXPwGOWfmvyLZU5t6HroR483C3Gl+MQ4UrgHyO/3Jud25klzgmXuNEvKqkpARW2JLo+HWUSgRDYr1/siiVKu643CQ06ztoquuCH4saKdbXeiKVzpE+tUZnxDHioxZTvjC85NYC/7oQsCdn8ttOsidLEIlnfatHOnOiKgAz/LHKN/Ka/4CxJZOlhPRpxOFpOYpnvsHsdnIZYzth83xQHrX/rk+BCz1Vl8rwsJuE6QcXe48/3BTr8tv9DXcKbTCbD0WXh7euJE9cBGxUMmUFcV6NYaA0jAR9kU73TNMaXiizoYxMFCyjboTXNlPYVIPlWVRcmR2/b24aLMWXWBhY3s73K8EAnN/gXkHlfKbwFivn00wVuyC+2fMUtY3T9r/dDYFs83frE09E7EpQ5dMAwkZpXQCJ6YsPa8Th1hts9xqzw== 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)(36860700016)(1800799024)(23010399003)(82310400026)(376014)(10067099003)(56012099006)(261022075727099003)(261026140227099003)(261026121527099003)(261028144727099003)(261022105027099003)(261102123227099003)(261021135927099003)(261021123027099003)(261021121427099003)(261009223027099003)(6133799003)(22082099003)(18002099003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ot98VlaXosTeLK0ygRxNchbLOE+z0N2a3bRlEPBypytfRXRMv/Hj9bBsXBz3Z0zMSlTRWtYQ4LG7NYbohg9W2pM3zYYC84AWM8O21Ob0yLeuuTJAQlZutMkok7EPsVo+UgA4lo8Bq3XZOK88/LWYbbZJbIB+0gxQetbuVu5vXZ7jua6R7eENdacSLn7Xc8LHoFN/kXGooTNrZ8/JECQ2LbtSos92tZjVjN8ibw883Qr3IAehKBZeLfwn6Toml8CjkFM+fCnHQzMRVzhQNysAZ2s8QT4Rh7aK+gWjxqKVTQG9VPZfgjOlriG+538ey1DMBirIdnTeFyMeNhw0vZN1ySoo3VjGhyZ04qJXL3ezwyUbjrEAhbBqhkQZq4CSTqD0/CKMAn35CeWrT2DymjKapGQ01V/BPHYH14weW3uwXVOKX7nHftXpe+1g+vUR4KGD X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 06:49:12.0575 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18827917-853e-4f34-08fa-08df4f773520 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: CH2PEPF00016D4C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5963 From: "Nikhil P. Rao" ionic_port_init() marks every counter in the device-written extra_stats block invalid before asking firmware to refresh it, so that a statistic this driver knows about but the firmware does not is reported as absent rather than as zero. It does that with a memset() of the whole block, and ethtool -S takes its snapshot of the block with a struct copy. Both run without a common lock: ionic_port_init() is called from the firmware recovery work, and an ethtool -S that got past the device present check before the netdev was detached can still be running. Neither memset() nor a struct copy guarantees the width of its accesses, so the snapshot can hold a counter that is neither its old value nor the marker, and ethtool -S then reports it. The .get_fec_stats handler added later in this series has the same need. The block is entirely __le64, each member naturally aligned, so walk it as an array and write the markers, and take the snapshot, one counter at a time with WRITE_ONCE() and READ_ONCE(). A counter read on its own is then either a complete value or the marker. Fixes: cb683ff6ee07 ("ionic: Report "rx_bits_phy" stat to ethtool") Signed-off-by: Nikhil P. Rao Signed-off-by: Eric Joyner Signed-off-by: Brett Creeley Reviewed-by: Vadim Fedorenko --- drivers/net/ethernet/pensando/ionic/ionic_main.c | 10 ++++++++-- drivers/net/ethernet/pensando/ionic/ionic_stats.c | 8 +++++++- drivers/net/ethernet/pensando/ionic/ionic_stats.h | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 1ad5f529e600..31b6cbb8f291 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -12,6 +12,7 @@ #include "ionic.h" #include "ionic_bus.h" #include "ionic_lif.h" +#include "ionic_stats.h" #include "ionic_debugfs.h" MODULE_DESCRIPTION(IONIC_DRV_DESCRIPTION); @@ -728,7 +729,10 @@ int ionic_port_init(struct ionic *ionic) struct ionic_identity *ident = &ionic->ident; struct ionic_dev *idev = &ionic->idev; bool allocated = false; + size_t nstats; + __le64 *stat; size_t sz; + size_t i; int err; if (!idev->port_info) { @@ -746,8 +750,10 @@ int ionic_port_init(struct ionic *ionic) /* If the driver knows about more "extra stats" than the firmware, * make sure these stats are marked as invalid. */ - memset(&idev->port_info->extra_stats, 0xff, - sizeof(idev->port_info->extra_stats)); + stat = (__le64 *)&idev->port_info->extra_stats; + nstats = sizeof(idev->port_info->extra_stats) / sizeof(*stat); + for (i = 0; i < nstats; i++) + WRITE_ONCE(stat[i], IONIC_STAT_INVALID); WRITE_ONCE(idev->link_down_count_init, false); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c index 428d5cca930f..89926e5a2f3c 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c @@ -237,7 +237,10 @@ static u32 ionic_extra_port_stats_get_count(struct ionic_lif *lif) { struct ionic_dev *idev = &lif->ionic->idev; struct ionic_port_extra_stats *pes_cache; + const __le64 *src; u32 count = 0; + __le64 *dst; + size_t i; if (!(lif->ionic->ident.dev.capabilities & cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS))) @@ -252,7 +255,10 @@ static u32 ionic_extra_port_stats_get_count(struct ionic_lif *lif) return count; } - *pes_cache = idev->port_info->extra_stats; + src = (const __le64 *)&idev->port_info->extra_stats; + dst = (__le64 *)pes_cache; + for (i = 0; i < sizeof(*pes_cache) / sizeof(*dst); i++) + dst[i] = READ_ONCE(src[i]); if (pes_cache->rx_bits_phy != IONIC_STAT_INVALID) count++; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.h b/drivers/net/ethernet/pensando/ionic/ionic_stats.h index 7ed935868e84..8a0edcc86fb8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.h @@ -4,6 +4,8 @@ #ifndef _IONIC_STATS_H_ #define _IONIC_STATS_H_ +#include + #define IONIC_STAT_INVALID (cpu_to_le64(~0ULL)) #define IONIC_STAT_TO_OFFSET(type, stat_name) (offsetof(type, stat_name)) -- 2.53.0