From nobody Fri Apr 17 01:43:54 2026 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07B7737C10B for ; Tue, 24 Feb 2026 11:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771932313; cv=none; b=cZitnzSJXvq68L6nUL8NqPjKdAF4Ecij44dbHy3RFvPgc9/M8hBFtpupbjaQT+BriCwpDy3Bw6qXg+YHGg27In+WnZpIdUdIpfIhxuXQgJeU8fQjmayeR5T8kD1x24UIjyJ6qgPRsv369puSzpnlAyWxZnhkzbMlfvFTtpLp74Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771932313; c=relaxed/simple; bh=AkHZPDs6rJZL/T5tRNU/xswESXxvBJny1xv8Fd9B9Ig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cgtnxo5xI3eJ7W7mUXW8sDsXuyXmn6ePBmfFgaA/P1ER3iaggh4TjXeU6PeWjRz1hVjag7kFUfkCyJ859nMvsvq0gAfPewRpwEwJLy75EKFJ67JT+CkUAkpFUOzKaLrwfiMZCpBxmGTD2J46Iq4vtk4Vt/4e+bQi4WRNXdKSUMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=e3KIvU2o; arc=none smtp.client-ip=209.85.210.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e3KIvU2o" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-824a3509a12so2877537b3a.2 for ; Tue, 24 Feb 2026 03:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771932311; x=1772537111; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4wGVfhGIFbdZYOY8RusNA+8qDyP+5sQzDVbWcUdCdH8=; b=e3KIvU2ospnLLMp2v9DSG7aJVj1p2HfRNA3P/yza2fTKod0qaiF+UJNHw1Blp7Qwy9 yoLtUpwu/BfmfGkf3Oz13AzEsEsYskaB4md6i/vtVog1UVG+cHNHA032PKOcBUXj/0hD FFNt7t2R0GQbwkLssS4Q8JTRVz0v6oX7aUjMSzJvwTGtxAPrsUFSXds8FYZs+pwaP1ox O5z2ZHW2+yGIBg6A81LpqoRz1Pq49Rg6ezbr9+8bz78v4YPZfbbySGszevyn6atAU8Le 7MhWHOXJt39ap2VrjjCI7gaHAzv+YmRPJV4VzQ7kkwCIxDD7/UY3C8FjrCGbl0gJ72cG eyRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771932311; x=1772537111; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4wGVfhGIFbdZYOY8RusNA+8qDyP+5sQzDVbWcUdCdH8=; b=WXD45AbIW+MlxENn7R6r2VC8emvXN4fwnGVmzNtMrLmSwp/z2WmKA1WtwllGgAj8bL tppiR6DbvR5yIz4VhXTl2j8AfSo711NjcBIUT5fAk87yb6c/A+9cNfYX/ha22UUG5IMI kdIWb+bBfj/UlU9YdzQrzK0gFlTOVR7xRVOQGi8qVF7C1lcUUSdkO2Fb4SCSfdokat98 PbMDFYH9ybVpKPheoQCoHCvM04y15AWFbG19molU7wLDcYpi5F6093RErThCrKKVlwN4 HttXPGPQxsP69WvDKChXnU+huZTFKcCc3Jje+a4wRd2/uKzAp05mSissgTVhaL/LLfd5 90ow== X-Forwarded-Encrypted: i=1; AJvYcCUZuSf8uxeQ2iGj0mXaAcBK86fI+rL5GxMs3VO5tZLeQjlbtHcqUm7bdK7C67X3BXD5Rho2z2kidBhPMpI=@vger.kernel.org X-Gm-Message-State: AOJu0Ywtwvn6KOKa0Kf5HDDCf1QpRoGgJ5u9GhjwiLiRoa3MmQamXerZ mZvzrdms7dOQkoS7gouQESCVyFkD2skpk4OAlu5dpeSOlCeFwYkLtGuV X-Gm-Gg: AZuq6aJabNRlh55mf/2suaVp6WOjqbg/aige6lGp7iMYty/LD9//5SAoUM7AF+EKG7w 1++umyk38qs/abZtODT6HT/FA/DBVzxqWZEZORn5KoqL77uvmsEgQmgc5t3FCyRzrJ2YZ8+eEyV 71VZ3mR89NK8JU8tTZ74G9WuaA4VnsEj/DI1bv4mErGc5STaaespHkDtjPekXt6sxDE7+ksrz2m xunz07pxPWQL9X3Z8afvGrYFdYSr5niE3MEfC3+aiUunMnNx2cym83B8+i8qE0QBb5C8cI/6kpf 7OvKDgaVlqO28RyjdINUbvNlu22gaRRyCZJIPIMkgpKtBmFYHxjQTEU8CBdyOMXE6UN+mz+HIiQ E0odv8oYQM+g/mlfg/90i5L3ohHFPjwhkWybMarOj8kIC9d987Xi/rSSMN7cemu8ijs2xe5/XQE j8LwCuIXdU8F7De3BdW+eVv04wsl5t2fVY/JEO+79InbrA X-Received: by 2002:a05:6a00:8d2:b0:7b8:8bfa:5e1e with SMTP id d2e1a72fcca58-826da8d7b40mr10388552b3a.4.1771932311255; Tue, 24 Feb 2026 03:25:11 -0800 (PST) Received: from d.home.yangfl.dn42 ([2603:c020:800b:d7ff::38]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-826dd694eecsm10262316b3a.25.2026.02.24.03.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 03:25:10 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/3] net: dsa: yt921x: Refactor port error message Date: Tue, 24 Feb 2026 19:24:05 +0800 Message-ID: <20260224112411.1561917-2-mmyangfl@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260224112411.1561917-1-mmyangfl@gmail.com> References: <20260224112411.1561917-1-mmyangfl@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Sometimes we might get error from the underlying bus, but the return type of the function is void, so an error message is desired here. There are many instances of the same pattern, refactor it. Signed-off-by: David Yang --- drivers/net/dsa/yt921x.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c index 98e8915dd6c2..77864dcbb6c5 100644 --- a/drivers/net/dsa/yt921x.c +++ b/drivers/net/dsa/yt921x.c @@ -185,6 +185,12 @@ struct yt921x_reg_mdio { #define to_yt921x_priv(_ds) container_of_const(_ds, struct yt921x_priv, ds) #define to_device(priv) ((priv)->ds.dev) =20 +static void +print_port_err(const struct device *dev, int port, int res, const char *ac= tion) +{ + dev_err(dev, "Failed to %s port %d: %i\n", action, port, res); +} + static int yt921x_reg_read(struct yt921x_priv *priv, u32 reg, u32 *valp) { WARN_ON(!mutex_is_locked(&priv->reg_lock)); @@ -721,8 +727,7 @@ static int yt921x_read_mib(struct yt921x_priv *priv, in= t port) mib->tx_jumbo; =20 if (res) - dev_err(dev, "Failed to %s port %d: %i\n", "read stats for", - port, res); + print_port_err(dev, port, res, "read stats for"); return res; } =20 @@ -1102,8 +1107,7 @@ yt921x_dsa_port_mirror_del(struct dsa_switch *ds, int= port, mutex_unlock(&priv->reg_lock); =20 if (res) - dev_err(dev, "Failed to %s port %d: %i\n", "unmirror", - port, res); + print_port_err(dev, port, res, "unmirror"); } =20 static int @@ -1690,8 +1694,7 @@ static void yt921x_dsa_port_fast_age(struct dsa_switc= h *ds, int port) mutex_unlock(&priv->reg_lock); =20 if (res) - dev_err(dev, "Failed to %s port %d: %i\n", "clear FDB for", - port, res); + print_port_err(dev, port, res, "clear FDB for"); } =20 static int @@ -2266,8 +2269,7 @@ yt921x_dsa_port_bridge_leave(struct dsa_switch *ds, i= nt port, mutex_unlock(&priv->reg_lock); =20 if (res) - dev_err(dev, "Failed to %s port %d: %i\n", "unbridge", - port, res); + print_port_err(dev, port, res, "unbridge"); } =20 static int @@ -2399,8 +2401,7 @@ yt921x_dsa_port_stp_state_set(struct dsa_switch *ds, = int port, u8 state) mutex_unlock(&priv->reg_lock); =20 if (res) - dev_err(dev, "Failed to %s port %d: %i\n", "set STP state for", - port, res); + print_port_err(dev, port, res, "set STP state for"); } =20 static int __maybe_unused @@ -2738,8 +2739,7 @@ yt921x_phylink_mac_link_down(struct phylink_config *c= onfig, unsigned int mode, mutex_unlock(&priv->reg_lock); =20 if (res) - dev_err(dp->ds->dev, "Failed to %s port %d: %i\n", "bring down", - port, res); + print_port_err(dp->ds->dev, port, res, "bring down"); } =20 static void @@ -2759,8 +2759,7 @@ yt921x_phylink_mac_link_up(struct phylink_config *con= fig, mutex_unlock(&priv->reg_lock); =20 if (res) - dev_err(dp->ds->dev, "Failed to %s port %d: %i\n", "bring up", - port, res); + print_port_err(dp->ds->dev, port, res, "bring up"); =20 schedule_delayed_work(&priv->ports[port].mib_read, 0); } @@ -2779,8 +2778,7 @@ yt921x_phylink_mac_config(struct phylink_config *conf= ig, unsigned int mode, mutex_unlock(&priv->reg_lock); =20 if (res) - dev_err(dp->ds->dev, "Failed to %s port %d: %i\n", "config", - port, res); + print_port_err(dp->ds->dev, port, res, "config"); } =20 static void --=20 2.51.0 From nobody Fri Apr 17 01:43:54 2026 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B289937C0ED for ; Tue, 24 Feb 2026 11:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771932318; cv=none; b=lIqArVFHTgZf12J7l9jr1/bjvQbEseOmurohMGyL4qJnB03rr++8bBths63mD84YeUEuDujC6kLEn5Z0AIv0wMiuJWSJkMEe1C412lTcpY07h1K/dg1x6ZOKM4dcEQxjxSRL2qO5rpSEfl7xjOFoVQbYRKHbdYdKKFNUTA+Zrj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771932318; c=relaxed/simple; bh=NnA+ladcl5fN/a1cqakfqNn4Wc8T0mbMb1O+39wzdfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sBWeMv7twFTBZ3o+XABEPYQPXvHFW53/4Lpz2J0ItikzQPCziyJd38x1308v5/SVQajy7d+6WLp4M0+hojbcAwwv/CX8cduip+f7S7r34Jt7cveoUsJJT0epLDQjHKRurXfcDqHMZgOH96xBhBcDKMc7m0sJlQS+XbM4DV0DoRo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NT2brxlL; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NT2brxlL" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82318702afbso4950807b3a.1 for ; Tue, 24 Feb 2026 03:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771932317; x=1772537117; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jc5Mczx03HkfwLHmcGZSdli4mQTFqoQ2+whK6vNjKXs=; b=NT2brxlLMhdecWT3fr+KAyKfQ1QbNBkiEubvFRMlZq4TgSK5XW7gnq9B4Ojd7iJsO+ vT3cw+/6XIxz1YcgOgg8wubigMJdL1YfypxTo3jmYyb84uJkRCfPV/Nbs4YWDN1o2JLa b3M6LeX7lsWM/KS6gKjBS1cFaohk8rz90i7uBeY3d02ItnSpYFb/zcheIOKcnn6LdRwv X0oyVS1XA86kVZVKwj7P0YTtOSj6QLoYd05wD49HNiwHDqM+8Bn3N/SEC1rei+3B8Sc8 S2lXd0c/qn+BvMicVOAKpPGBmB2gUxkFTknoddqdx3NEMFOSOzm7dkYiueEfPO1/3wMv cEMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771932317; x=1772537117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jc5Mczx03HkfwLHmcGZSdli4mQTFqoQ2+whK6vNjKXs=; b=Wq5hdbD1XsYPNysmqSMLXCvAF4wwIlSelTqe+Xd188qPW3DZIXuj4Frs/OLNR3dQKr FussO1wfYaSwwGkAwtbL4KiL8VaYtf+pUt4uXOJ7h/cQbenVqJkWBxlOR7OiKvjoxnOt LbQxo1KYE5yTdF7xhnDIDvP1ZBqvoCOCevi/SuKA08Ez3X8ejt8OZixZ4xcABe9z++9y OFBFOZ7/sP+P/iMkmY07firTdQTiXGY5iZBioBqn4LBDc7pW3wCLenKGL6O0JdsvH36Q CWEcbICr3lBOoAfXKU3rlhIyi5shA71KaqlVj4v5VtZJAolLW8k0wxvPuCRKQIwJCmyD V5Jw== X-Forwarded-Encrypted: i=1; AJvYcCUSkyRoqRndBQYc485a3yoIAHnjhM913Ti1umOJy8TKDfugcWLF2hbGmmTLF24mUR4aDv6CEA359wjnmcc=@vger.kernel.org X-Gm-Message-State: AOJu0YyhSiuhWMeVbSR8UZYbX8iCaxxusLMEnAbisPY5SlUnBeM40XNr NviBW5G3Cv4KPXDOILYXoLUk5IGg6cWwatxuGJXZYGcC78DDLnzB1P2YJsFrr2zM X-Gm-Gg: ATEYQzyB7ZZjebW89E9GCvAXWdrL2UOBE1Kabwk9Aj+Yn6xXOxCO6bhjDxykWLS+/Lb 5Iac8aYwKosCJg/gA/SqnOQyo2BJefM/5n5/gZrH7XadZqGzBzI6qP8TmwJ9arWO675REvT0ucP syhe4QkmbOq3zTH0BfB8NiIJh2ImbEifKu69/4bzwCtnp/OIrkHGzerDazcRUbsYrtzS7bERFKr kV1dxqgYavQDaSEG/s+o3KrS/m4+92mrwOJDzlpKwqB9hGGRHLmy36QB8OP+FX+/rrwec0NTvx+ NNjI5OtVvbq4r2ssDqE3qIzBvp148sgdllzg4ncBURgJfC+3TKIAhe6k91N6SP7WzhOZ2yfWtPu kDiEqbLyzbASQxtnWHep9V6KBQ+ULGi42VshWUyUFMiNWVxJi2E6DAaPkERZJwazxDff+KoD56b 0lCb6S6U4UyVSOQyBRwn7JA8b48/qKEGNuPcCTG9pviLiER8fyvspzvlk= X-Received: by 2002:a05:6a00:cc4:b0:81f:4963:4967 with SMTP id d2e1a72fcca58-826daaab72emr12538770b3a.57.1771932317035; Tue, 24 Feb 2026 03:25:17 -0800 (PST) Received: from d.home.yangfl.dn42 ([2603:c020:800b:d7ff::38]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-826dd694eecsm10262316b3a.25.2026.02.24.03.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 03:25:16 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/3] net: dsa: yt921x: Return early for failed MIB read Date: Tue, 24 Feb 2026 19:24:06 +0800 Message-ID: <20260224112411.1561917-3-mmyangfl@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260224112411.1561917-1-mmyangfl@gmail.com> References: <20260224112411.1561917-1-mmyangfl@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch is a prerequisite for another patch. It does not change the behavior on the success path. Signed-off-by: David Yang --- drivers/net/dsa/yt921x.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c index 77864dcbb6c5..c72a74ed29cf 100644 --- a/drivers/net/dsa/yt921x.c +++ b/drivers/net/dsa/yt921x.c @@ -717,6 +717,11 @@ static int yt921x_read_mib(struct yt921x_priv *priv, i= nt port) WRITE_ONCE(*valp, val); } =20 + if (res) { + print_port_err(dev, port, res, "read stats for"); + return res; + } + pp->rx_frames =3D mib->rx_64byte + mib->rx_65_127byte + mib->rx_128_255byte + mib->rx_256_511byte + mib->rx_512_1023byte + mib->rx_1024_1518byte + @@ -726,9 +731,7 @@ static int yt921x_read_mib(struct yt921x_priv *priv, in= t port) mib->tx_512_1023byte + mib->tx_1024_1518byte + mib->tx_jumbo; =20 - if (res) - print_port_err(dev, port, res, "read stats for"); - return res; + return 0; } =20 static void yt921x_poll_mib(struct work_struct *work) --=20 2.51.0 From nobody Fri Apr 17 01:43:54 2026 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B47937C119 for ; Tue, 24 Feb 2026 11:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771932325; cv=none; b=YEivDnLQfI/AUrGA/sDEFR2m/DetAGAcwsT/l9AshI5HDN80r9BApxbNmXB3KDzaIwn6/Bb0CrXL5FNIOBVO4/tzNgTxpHVtDSd24LRdpScXvsMOEKCjrABRaOdmvfVVGEbtoMUXWtkfzBeI7evuW3yRazXKole9eIIxl1lmGDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771932325; c=relaxed/simple; bh=LZcP7kd1y33jHopcvJiXPxTCd82rkIHay4Vd6pLXi+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qcK2NsIZxwi1GkCG2q3l8MTxUss9MJnFsSMeA3rIdyPLxO3ngp7CtdZR7W6BBsGENhCv7WNIgb+ef9CH9oALsWcQXsx+YvEK1vnAq06T3Ol7WkRkHiid6o7i7CXuY0kjCMbh6CVFLDXpm029GD4++XuL+hTK8ou8MaBcDmvR3xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I4pmyDEr; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I4pmyDEr" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-82318702afbso4950891b3a.1 for ; Tue, 24 Feb 2026 03:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771932323; x=1772537123; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dOcX2gM7mINAIp6m4uVo0uhE59qoq9cORB6x4blHQWo=; b=I4pmyDErZHn49U7a1jbmzIH/+44Jy3ssALuiyeA6fZfMXFQQSk5N9+9qPHjUhdSfU6 lciB67yt5sxKcfRN1BtA3FLDFcZxw98jW0WtTp6HJvcdN72UdkkZcyujnkfkRB808VxO 4Ob8T+eJK9tO6rCizYGbD22F74MAR/yZV0FzhOkyg8IIaEFYi49/SGSTLujbvRpQVQQy Zyx7hbpFo6ZXyuvfc7E7jTekvfELXGXW8M+R11zawu0cZbvDY0lN83ET0RGboUfLgmgY F61Ypkoou3jZir3jnVWQ0cgFu36B1Cg8K9zCx39OKcmB3A1RsV+bQKcAnSi30Oz9hNI4 BLXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771932323; x=1772537123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dOcX2gM7mINAIp6m4uVo0uhE59qoq9cORB6x4blHQWo=; b=ZuObsUml1YJGbqNKez09Mp7fv4ZmUpKNuLi4WrsU4m1PNgIXnA+Dw1rYOGpCTiwAZi 87K/pc3RibIQ93L4YOpGRFt7xSISv/QwiFaYc3muz+xfOpR+EFIwcPjf3N87BIQGchCn AXMvDYt3hJA47m1gFmCeH9LYKq4jQ6dZhc5plFL1xsi/3Q/XQIVb6LY9heSNFdGhgwVg VqJ9MQjuKGNub6z6UTswv72lD+Eoh04XS6gXdkCeH4zgB72fccomYbti1fg3VZmDglxl /MjKVWEqZK7Moe012Ms9pwfyTtxF22oitkS/nPULGNjD4IVLY4jWqy3TVIVVwLD4L27k BFIA== X-Forwarded-Encrypted: i=1; AJvYcCX4k8Dw6ZKXdYkhR3twejj/JfD+1OfiPrTnZoeOhMGhpD8rFP5BqYi9zM0E1aD+eZM+f6u8mZcUJIDUuao=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8oLcZDKbXtn6vvI6ZtV/ePGmTjGa1si1pN0zHhOmfeMPq9Ud0 hhAhK8bZNMnVYeFR0iHw8DXVEQPhtVv9FWTAUR+sxw8q0HQr9NOZDDjf X-Gm-Gg: ATEYQzw2GZcdSweCltiqjayop1RQfLxqdLW+znuEcOyjDtw+GW8eJ7Q5PeN+Zr57sll 81S0SukvNhR40iYmQFAZh7wg3B3g79L1zwEgJ43QPX39Q2UhERyUVRimO9JkVtZfwgbfF9zeaWU DrXCanDzyKDwxTazHLVvj7YlNlg3B0frIGoxv4JcDcNDnoemPH9pkwLuGdah8kPHWfwAotZXIit w1d6YxL3Zy2kF7nSWYKwT8xKo+RkhRCF8O6FEL/u9ZGRutdRxZp1ARq/mNyJofCehwxEM7b4WAE Hvl0KYtb7TkVdJJnqy1B8rUOIsEUo/mlE7LGFrFzrIws9ATuOXqrlziEMoQngixOiwkPaJl4OO0 fh3yp4M0hMiQ3x33c/UpDZksIieezRwolbz/hNLvprXLsCTk9bPjEhbXGKxOaYWqy6AatXTKERM ID4styaJbg/FJ3mhMayvzd4RUro5uHhJ8s7ajS1oE04tdvkqD/CzizlAY= X-Received: by 2002:aa7:9a87:0:b0:823:1cc6:d60a with SMTP id d2e1a72fcca58-826da8d7bf8mr11167350b3a.2.1771932322746; Tue, 24 Feb 2026 03:25:22 -0800 (PST) Received: from d.home.yangfl.dn42 ([2603:c020:800b:d7ff::38]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-826dd694eecsm10262316b3a.25.2026.02.24.03.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 03:25:22 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 3/3] net: dsa: yt921x: Use u64_stats_t for MIB stats Date: Tue, 24 Feb 2026 19:24:07 +0800 Message-ID: <20260224112411.1561917-4-mmyangfl@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260224112411.1561917-1-mmyangfl@gmail.com> References: <20260224112411.1561917-1-mmyangfl@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 64-bit variables might not be atomic on 32-bit architectures, and could lead to load/store tearing. Use u64_stats_t to ensure consistency. Signed-off-by: David Yang --- drivers/net/dsa/yt921x.c | 198 +++++++++++++++++++++++---------------- drivers/net/dsa/yt921x.h | 114 ++++++++++++---------- 2 files changed, 179 insertions(+), 133 deletions(-) diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c index c72a74ed29cf..e22bd5b6eab9 100644 --- a/drivers/net/dsa/yt921x.c +++ b/drivers/net/dsa/yt921x.c @@ -20,6 +20,7 @@ #include #include #include +#include =20 #include #include @@ -676,22 +677,20 @@ yt921x_mbus_ext_init(struct yt921x_priv *priv, struct= device_node *mnp) static int yt921x_read_mib(struct yt921x_priv *priv, int port) { struct yt921x_port *pp =3D &priv->ports[port]; + struct yt921x_mib *mib_new =3D &pp->mib_new; struct device *dev =3D to_device(priv); struct yt921x_mib *mib =3D &pp->mib; + u64 rx_frames; + u64 tx_frames; int res =3D 0; =20 - /* Reading of yt921x_port::mib is not protected by a lock and it's vain - * to keep its consistency, since we have to read registers one by one - * and there is no way to make a snapshot of MIB stats. - * - * Writing (by this function only) is and should be protected by - * reg_lock. + /* u64_stats_read/set is redundant for mib_new, but I don't want to + * declare a plain u64 yt921x_mib variant. */ =20 for (size_t i =3D 0; i < ARRAY_SIZE(yt921x_mib_descs); i++) { const struct yt921x_mib_desc *desc =3D &yt921x_mib_descs[i]; u32 reg =3D YT921X_MIBn_DATA0(port) + desc->offset; - u64 *valp =3D &((u64 *)mib)[i]; u32 val0; u64 val; =20 @@ -700,7 +699,7 @@ static int yt921x_read_mib(struct yt921x_priv *priv, in= t port) break; =20 if (desc->size <=3D 1) { - u64 old_val =3D *valp; + u64 old_val =3D u64_stats_read(&mib->stats[i]); =20 val =3D (old_val & ~(u64)U32_MAX) | val0; if (val < old_val) @@ -714,7 +713,7 @@ static int yt921x_read_mib(struct yt921x_priv *priv, in= t port) val =3D ((u64)val1 << 32) | val0; } =20 - WRITE_ONCE(*valp, val); + u64_stats_set(&mib_new->stats[i], val); } =20 if (res) { @@ -722,14 +721,29 @@ static int yt921x_read_mib(struct yt921x_priv *priv, = int port) return res; } =20 - pp->rx_frames =3D mib->rx_64byte + mib->rx_65_127byte + - mib->rx_128_255byte + mib->rx_256_511byte + - mib->rx_512_1023byte + mib->rx_1024_1518byte + - mib->rx_jumbo; - pp->tx_frames =3D mib->tx_64byte + mib->tx_65_127byte + - mib->tx_128_255byte + mib->tx_256_511byte + - mib->tx_512_1023byte + mib->tx_1024_1518byte + - mib->tx_jumbo; + rx_frames =3D u64_stats_read(&mib_new->rx_64byte) + + u64_stats_read(&mib_new->rx_65_127byte) + + u64_stats_read(&mib_new->rx_128_255byte) + + u64_stats_read(&mib_new->rx_256_511byte) + + u64_stats_read(&mib_new->rx_512_1023byte) + + u64_stats_read(&mib_new->rx_1024_1518byte) + + u64_stats_read(&mib_new->rx_jumbo); + tx_frames =3D u64_stats_read(&mib_new->tx_64byte) + + u64_stats_read(&mib_new->tx_65_127byte) + + u64_stats_read(&mib_new->tx_128_255byte) + + u64_stats_read(&mib_new->tx_256_511byte) + + u64_stats_read(&mib_new->tx_512_1023byte) + + u64_stats_read(&mib_new->tx_1024_1518byte) + + u64_stats_read(&mib_new->tx_jumbo); + + u64_stats_update_begin(&pp->syncp); + for (size_t i =3D 0; i < ARRAY_SIZE(yt921x_mib_descs); i++) { + u64_stats_set(&mib->stats[i], + u64_stats_read(&mib_new->stats[i])); + } + u64_stats_set(&pp->rx_frames, rx_frames); + u64_stats_set(&pp->tx_frames, tx_frames); + u64_stats_update_end(&pp->syncp); =20 return 0; } @@ -774,11 +788,12 @@ yt921x_dsa_get_ethtool_stats(struct dsa_switch *ds, i= nt port, uint64_t *data) struct yt921x_priv *priv =3D to_yt921x_priv(ds); struct yt921x_port *pp =3D &priv->ports[port]; struct yt921x_mib *mib =3D &pp->mib; + unsigned int start; size_t j; =20 mutex_lock(&priv->reg_lock); + yt921x_read_mib(priv, port); - mutex_unlock(&priv->reg_lock); =20 j =3D 0; for (size_t i =3D 0; i < ARRAY_SIZE(yt921x_mib_descs); i++) { @@ -787,9 +802,11 @@ yt921x_dsa_get_ethtool_stats(struct dsa_switch *ds, in= t port, uint64_t *data) if (!desc->name) continue; =20 - data[j] =3D ((u64 *)mib)[i]; + data[j] =3D u64_stats_read(&((u64_stats_t *)mib)[i]); j++; } + + mutex_unlock(&priv->reg_lock); } =20 static int yt921x_dsa_get_sset_count(struct dsa_switch *ds, int port, int = sset) @@ -818,31 +835,33 @@ yt921x_dsa_get_eth_mac_stats(struct dsa_switch *ds, i= nt port, struct yt921x_mib *mib =3D &pp->mib; =20 mutex_lock(&priv->reg_lock); + yt921x_read_mib(priv, port); - mutex_unlock(&priv->reg_lock); =20 - mac_stats->FramesTransmittedOK =3D pp->tx_frames; - mac_stats->SingleCollisionFrames =3D mib->tx_single_collisions; - mac_stats->MultipleCollisionFrames =3D mib->tx_multiple_collisions; - mac_stats->FramesReceivedOK =3D pp->rx_frames; - mac_stats->FrameCheckSequenceErrors =3D mib->rx_crc_errors; - mac_stats->AlignmentErrors =3D mib->rx_alignment_errors; - mac_stats->OctetsTransmittedOK =3D mib->tx_good_bytes; - mac_stats->FramesWithDeferredXmissions =3D mib->tx_deferred; - mac_stats->LateCollisions =3D mib->tx_late_collisions; - mac_stats->FramesAbortedDueToXSColls =3D mib->tx_aborted_errors; + mac_stats->FramesTransmittedOK =3D u64_stats_read(&pp->tx_frames); + mac_stats->SingleCollisionFrames =3D u64_stats_read(&mib->tx_single_colli= sions); + mac_stats->MultipleCollisionFrames =3D u64_stats_read(&mib->tx_multiple_c= ollisions); + mac_stats->FramesReceivedOK =3D u64_stats_read(&pp->rx_frames); + mac_stats->FrameCheckSequenceErrors =3D u64_stats_read(&mib->rx_crc_error= s); + mac_stats->AlignmentErrors =3D u64_stats_read(&mib->rx_alignment_errors); + mac_stats->OctetsTransmittedOK =3D u64_stats_read(&mib->tx_good_bytes); + mac_stats->FramesWithDeferredXmissions =3D u64_stats_read(&mib->tx_deferr= ed); + mac_stats->LateCollisions =3D u64_stats_read(&mib->tx_late_collisions); + mac_stats->FramesAbortedDueToXSColls =3D u64_stats_read(&mib->tx_aborted_= errors); /* mac_stats->FramesLostDueToIntMACXmitError */ /* mac_stats->CarrierSenseErrors */ - mac_stats->OctetsReceivedOK =3D mib->rx_good_bytes; + mac_stats->OctetsReceivedOK =3D u64_stats_read(&mib->rx_good_bytes); /* mac_stats->FramesLostDueToIntMACRcvError */ - mac_stats->MulticastFramesXmittedOK =3D mib->tx_multicast; - mac_stats->BroadcastFramesXmittedOK =3D mib->tx_broadcast; + mac_stats->MulticastFramesXmittedOK =3D u64_stats_read(&mib->tx_multicast= ); + mac_stats->BroadcastFramesXmittedOK =3D u64_stats_read(&mib->tx_broadcast= ); /* mac_stats->FramesWithExcessiveDeferral */ - mac_stats->MulticastFramesReceivedOK =3D mib->rx_multicast; - mac_stats->BroadcastFramesReceivedOK =3D mib->rx_broadcast; + mac_stats->MulticastFramesReceivedOK =3D u64_stats_read(&mib->rx_multicas= t); + mac_stats->BroadcastFramesReceivedOK =3D u64_stats_read(&mib->rx_broadcas= t); /* mac_stats->InRangeLengthErrors */ /* mac_stats->OutOfRangeLengthField */ - mac_stats->FrameTooLongErrors =3D mib->rx_oversize_errors; + mac_stats->FrameTooLongErrors =3D u64_stats_read(&mib->rx_oversize_errors= ); + + mutex_unlock(&priv->reg_lock); } =20 static void @@ -854,12 +873,14 @@ yt921x_dsa_get_eth_ctrl_stats(struct dsa_switch *ds, = int port, struct yt921x_mib *mib =3D &pp->mib; =20 mutex_lock(&priv->reg_lock); + yt921x_read_mib(priv, port); - mutex_unlock(&priv->reg_lock); =20 - ctrl_stats->MACControlFramesTransmitted =3D mib->tx_pause; - ctrl_stats->MACControlFramesReceived =3D mib->rx_pause; + ctrl_stats->MACControlFramesTransmitted =3D u64_stats_read(&mib->tx_pause= ); + ctrl_stats->MACControlFramesReceived =3D u64_stats_read(&mib->rx_pause); /* ctrl_stats->UnsupportedOpcodesReceived */ + + mutex_unlock(&priv->reg_lock); } =20 static const struct ethtool_rmon_hist_range yt921x_rmon_ranges[] =3D { @@ -883,31 +904,33 @@ yt921x_dsa_get_rmon_stats(struct dsa_switch *ds, int = port, struct yt921x_mib *mib =3D &pp->mib; =20 mutex_lock(&priv->reg_lock); + yt921x_read_mib(priv, port); - mutex_unlock(&priv->reg_lock); =20 *ranges =3D yt921x_rmon_ranges; =20 - rmon_stats->undersize_pkts =3D mib->rx_undersize_errors; - rmon_stats->oversize_pkts =3D mib->rx_oversize_errors; - rmon_stats->fragments =3D mib->rx_alignment_errors; + rmon_stats->undersize_pkts =3D u64_stats_read(&mib->rx_undersize_errors); + rmon_stats->oversize_pkts =3D u64_stats_read(&mib->rx_oversize_errors); + rmon_stats->fragments =3D u64_stats_read(&mib->rx_alignment_errors); /* rmon_stats->jabbers */ =20 - rmon_stats->hist[0] =3D mib->rx_64byte; - rmon_stats->hist[1] =3D mib->rx_65_127byte; - rmon_stats->hist[2] =3D mib->rx_128_255byte; - rmon_stats->hist[3] =3D mib->rx_256_511byte; - rmon_stats->hist[4] =3D mib->rx_512_1023byte; - rmon_stats->hist[5] =3D mib->rx_1024_1518byte; - rmon_stats->hist[6] =3D mib->rx_jumbo; + rmon_stats->hist[0] =3D u64_stats_read(&mib->rx_64byte); + rmon_stats->hist[1] =3D u64_stats_read(&mib->rx_65_127byte); + rmon_stats->hist[2] =3D u64_stats_read(&mib->rx_128_255byte); + rmon_stats->hist[3] =3D u64_stats_read(&mib->rx_256_511byte); + rmon_stats->hist[4] =3D u64_stats_read(&mib->rx_512_1023byte); + rmon_stats->hist[5] =3D u64_stats_read(&mib->rx_1024_1518byte); + rmon_stats->hist[6] =3D u64_stats_read(&mib->rx_jumbo); + + rmon_stats->hist_tx[0] =3D u64_stats_read(&mib->tx_64byte); + rmon_stats->hist_tx[1] =3D u64_stats_read(&mib->tx_65_127byte); + rmon_stats->hist_tx[2] =3D u64_stats_read(&mib->tx_128_255byte); + rmon_stats->hist_tx[3] =3D u64_stats_read(&mib->tx_256_511byte); + rmon_stats->hist_tx[4] =3D u64_stats_read(&mib->tx_512_1023byte); + rmon_stats->hist_tx[5] =3D u64_stats_read(&mib->tx_1024_1518byte); + rmon_stats->hist_tx[6] =3D u64_stats_read(&mib->tx_jumbo); =20 - rmon_stats->hist_tx[0] =3D mib->tx_64byte; - rmon_stats->hist_tx[1] =3D mib->tx_65_127byte; - rmon_stats->hist_tx[2] =3D mib->tx_128_255byte; - rmon_stats->hist_tx[3] =3D mib->tx_256_511byte; - rmon_stats->hist_tx[4] =3D mib->tx_512_1023byte; - rmon_stats->hist_tx[5] =3D mib->tx_1024_1518byte; - rmon_stats->hist_tx[6] =3D mib->tx_jumbo; + mutex_unlock(&priv->reg_lock); } =20 static void @@ -917,33 +940,41 @@ yt921x_dsa_get_stats64(struct dsa_switch *ds, int por= t, struct yt921x_priv *priv =3D to_yt921x_priv(ds); struct yt921x_port *pp =3D &priv->ports[port]; struct yt921x_mib *mib =3D &pp->mib; + unsigned int start; + + do { + start =3D u64_stats_fetch_begin(&pp->syncp); + + stats->rx_length_errors =3D u64_stats_read(&mib->rx_undersize_errors) + + u64_stats_read(&mib->rx_fragment_errors); + stats->rx_over_errors =3D u64_stats_read(&mib->rx_oversize_errors); + stats->rx_crc_errors =3D u64_stats_read(&mib->rx_crc_errors); + stats->rx_frame_errors =3D u64_stats_read(&mib->rx_alignment_errors); + /* stats->rx_fifo_errors */ + /* stats->rx_missed_errors */ + + stats->tx_aborted_errors =3D u64_stats_read(&mib->tx_aborted_errors); + /* stats->tx_carrier_errors */ + stats->tx_fifo_errors =3D u64_stats_read(&mib->tx_undersize_errors); + /* stats->tx_heartbeat_errors */ + stats->tx_window_errors =3D u64_stats_read(&mib->tx_late_collisions); + + stats->rx_packets =3D u64_stats_read(&pp->rx_frames); + stats->tx_packets =3D u64_stats_read(&pp->tx_frames); + stats->rx_bytes =3D u64_stats_read(&mib->rx_good_bytes) - + ETH_FCS_LEN * stats->rx_packets; + stats->tx_bytes =3D u64_stats_read(&mib->tx_good_bytes) - + ETH_FCS_LEN * stats->tx_packets; + stats->rx_dropped =3D u64_stats_read(&mib->rx_dropped); + /* stats->tx_dropped */ + stats->multicast =3D u64_stats_read(&mib->rx_multicast); + stats->collisions =3D u64_stats_read(&mib->tx_collisions); + } while (u64_stats_fetch_retry(&pp->syncp, start)); =20 - stats->rx_length_errors =3D mib->rx_undersize_errors + - mib->rx_fragment_errors; - stats->rx_over_errors =3D mib->rx_oversize_errors; - stats->rx_crc_errors =3D mib->rx_crc_errors; - stats->rx_frame_errors =3D mib->rx_alignment_errors; - /* stats->rx_fifo_errors */ - /* stats->rx_missed_errors */ - - stats->tx_aborted_errors =3D mib->tx_aborted_errors; - /* stats->tx_carrier_errors */ - stats->tx_fifo_errors =3D mib->tx_undersize_errors; - /* stats->tx_heartbeat_errors */ - stats->tx_window_errors =3D mib->tx_late_collisions; - - stats->rx_packets =3D pp->rx_frames; - stats->tx_packets =3D pp->tx_frames; - stats->rx_bytes =3D mib->rx_good_bytes - ETH_FCS_LEN * stats->rx_packets; - stats->tx_bytes =3D mib->tx_good_bytes - ETH_FCS_LEN * stats->tx_packets; stats->rx_errors =3D stats->rx_length_errors + stats->rx_over_errors + stats->rx_crc_errors + stats->rx_frame_errors; stats->tx_errors =3D stats->tx_aborted_errors + stats->tx_fifo_errors + stats->tx_window_errors; - stats->rx_dropped =3D mib->rx_dropped; - /* stats->tx_dropped */ - stats->multicast =3D mib->rx_multicast; - stats->collisions =3D mib->tx_collisions; } =20 static void @@ -955,11 +986,13 @@ yt921x_dsa_get_pause_stats(struct dsa_switch *ds, int= port, struct yt921x_mib *mib =3D &pp->mib; =20 mutex_lock(&priv->reg_lock); + yt921x_read_mib(priv, port); - mutex_unlock(&priv->reg_lock); =20 - pause_stats->tx_pause_frames =3D mib->tx_pause; - pause_stats->rx_pause_frames =3D mib->rx_pause; + pause_stats->tx_pause_frames =3D u64_stats_read(&mib->tx_pause); + pause_stats->rx_pause_frames =3D u64_stats_read(&mib->rx_pause); + + mutex_unlock(&priv->reg_lock); } =20 static int @@ -3421,6 +3454,7 @@ static int yt921x_mdio_probe(struct mdio_device *mdio= dev) =20 pp->index =3D i; INIT_DELAYED_WORK(&pp->mib_read, yt921x_poll_mib); + u64_stats_init(&pp->syncp); } =20 ds =3D &priv->ds; diff --git a/drivers/net/dsa/yt921x.h b/drivers/net/dsa/yt921x.h index 3f129b8d403f..0f4231accf3e 100644 --- a/drivers/net/dsa/yt921x.h +++ b/drivers/net/dsa/yt921x.h @@ -6,6 +6,8 @@ #ifndef __YT921X_H #define __YT921X_H =20 +#include + #include =20 #define YT921X_SMI_SWITCHID_M GENMASK(3, 2) @@ -530,55 +532,61 @@ enum yt921x_fdb_entry_status { #define yt921x_port_is_external(port) (8 <=3D (port) && (port) < 9) =20 struct yt921x_mib { - u64 rx_broadcast; - u64 rx_pause; - u64 rx_multicast; - u64 rx_crc_errors; - - u64 rx_alignment_errors; - u64 rx_undersize_errors; - u64 rx_fragment_errors; - u64 rx_64byte; - - u64 rx_65_127byte; - u64 rx_128_255byte; - u64 rx_256_511byte; - u64 rx_512_1023byte; - - u64 rx_1024_1518byte; - u64 rx_jumbo; - u64 rx_good_bytes; - - u64 rx_bad_bytes; - u64 rx_oversize_errors; - - u64 rx_dropped; - u64 tx_broadcast; - u64 tx_pause; - u64 tx_multicast; - - u64 tx_undersize_errors; - u64 tx_64byte; - u64 tx_65_127byte; - u64 tx_128_255byte; - - u64 tx_256_511byte; - u64 tx_512_1023byte; - u64 tx_1024_1518byte; - u64 tx_jumbo; - - u64 tx_good_bytes; - u64 tx_collisions; - - u64 tx_aborted_errors; - u64 tx_multiple_collisions; - u64 tx_single_collisions; - u64 tx_good; - - u64 tx_deferred; - u64 tx_late_collisions; - u64 rx_oam; - u64 tx_oam; + union { + struct { + u64_stats_t rx_broadcast; + u64_stats_t rx_pause; + u64_stats_t rx_multicast; + u64_stats_t rx_crc_errors; + + u64_stats_t rx_alignment_errors; + u64_stats_t rx_undersize_errors; + u64_stats_t rx_fragment_errors; + u64_stats_t rx_64byte; + + u64_stats_t rx_65_127byte; + u64_stats_t rx_128_255byte; + u64_stats_t rx_256_511byte; + u64_stats_t rx_512_1023byte; + + u64_stats_t rx_1024_1518byte; + u64_stats_t rx_jumbo; + u64_stats_t rx_good_bytes; + + u64_stats_t rx_bad_bytes; + u64_stats_t rx_oversize_errors; + + u64_stats_t rx_dropped; + u64_stats_t tx_broadcast; + u64_stats_t tx_pause; + u64_stats_t tx_multicast; + + u64_stats_t tx_undersize_errors; + u64_stats_t tx_64byte; + u64_stats_t tx_65_127byte; + u64_stats_t tx_128_255byte; + + u64_stats_t tx_256_511byte; + u64_stats_t tx_512_1023byte; + u64_stats_t tx_1024_1518byte; + u64_stats_t tx_jumbo; + + u64_stats_t tx_good_bytes; + u64_stats_t tx_collisions; + + u64_stats_t tx_aborted_errors; + u64_stats_t tx_multiple_collisions; + u64_stats_t tx_single_collisions; + u64_stats_t tx_good; + + u64_stats_t tx_deferred; + u64_stats_t tx_late_collisions; + u64_stats_t rx_oam; + u64_stats_t tx_oam; + }; + + u64_stats_t stats[39]; + }; }; =20 struct yt921x_port { @@ -588,9 +596,13 @@ struct yt921x_port { bool isolated; =20 struct delayed_work mib_read; + struct u64_stats_sync syncp; struct yt921x_mib mib; - u64 rx_frames; - u64 tx_frames; + u64_stats_t rx_frames; + u64_stats_t tx_frames; + + /* only used by read routine to avoid huge allocations on the stack */ + struct yt921x_mib mib_new; }; =20 struct yt921x_reg_ops { --=20 2.51.0