From nobody Wed Nov 27 02:38:35 2024 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 BDE611B85D0 for ; Mon, 14 Oct 2024 15:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919487; cv=none; b=dyB+MHzXqoZ+SUIRcO0cJZYEqgc97MzDJOzeAcR6/XAsqult+CoOG08tchT/xgMwb9+uBe9Ui6vuP4okXV6fj5W68jLRQwtL8ZCQbm15bwo++UKbjGyIZ6Cg+av8TV7spAy1rXKZcJ45bB9kXpiovuInsuIr7AvNQtiGDGAoFC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919487; c=relaxed/simple; bh=0ONmNV9vzQUGV6frLDhiV8OgSXVkIdlWsYOsJ1KXX2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oiO9x/lynT0KbrL+bYs7SaCKaDrPmaoIlLmxF8fUcB1CsNIv7dHwzaKB0Il9YsxB+Y8eU8sBMt+mXHEPpnGSGQkHX25vHkfr7A4Woyf8n5blJYquSnT32lScauc21HPLJrN7darhozT7+HASPvjVmDzRnxbQLMF5QSianF5TurI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=jb4S/I5q; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="jb4S/I5q" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-37d6ff1cbe1so1051656f8f.3 for ; Mon, 14 Oct 2024 08:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1728919484; x=1729524284; 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=gvkSVt8VpmX4gMY6ZJ043PHdZhz1ZoH+BaE3ci1zs5w=; b=jb4S/I5qA15TE/GGPwwMJJXd50/byw1rJtxglFwKu9RHDaybS95MZ09NjSNhnPz2v3 CPPkaff1xzcm38hPUdrbdWgn781pvIv7OK35wCvihD0REI3mJDNIfzSIBJNInQQp4kSv MRQcMVNqhKWYlYfw7e6HOHEhMi7ghjZ9BI0h0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919484; x=1729524284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gvkSVt8VpmX4gMY6ZJ043PHdZhz1ZoH+BaE3ci1zs5w=; b=UwN1dH8QaPvSKDuZXmbdGhwixTK53+++FMEjJvF1Xdzcupd8WZyK+uVp4L77zkJMIE BVzRvaZq3Xi62LwC7t+6Hrj1s3EgS7kiBFAaLE5nC8yWpiSGmXi9zaCqP5njy1FdGFtr oZH+qA4he+1Io3+p0gmS4zQz7P7wcoLz4YrsrAJlN2fAMYgwoGgszCOE0EMbIeFDVJW/ aEg8As3dda7snAUiJb0r7YJe72+OMl12LsY3Gos6LWOOsT50gWkbf7YEETFxfdIUwcQ0 crf0DjnvVckpMFtpuHIlNs4ydZ5ujYnPnMbje7SIr2hztYyBN/IYgmWywuvEFvis1dVp Kriw== X-Gm-Message-State: AOJu0YyAzk8Qx2vquwNGM1PhqII7hHRwnW/x0ZUc7mnaXDxoCKNcVk42 ij0Xd8GoGxnTvByKHyHWyQdnFYzGzyWq1YB10NANpa4GXbG4ox//CZoT3/GNhajya6zvE5Rb6Ar ImHI= X-Google-Smtp-Source: AGHT+IGU6W/9rfcwX33740fJ/ldX1KMdmDVw4ohUw0JiVPbpOmH7KL8veexmd93cyiyKKuklxb5y8Q== X-Received: by 2002:adf:e88b:0:b0:37d:4cd6:6f2b with SMTP id ffacd0b85a97d-37d551d2566mr7314184f8f.14.1728919483907; Mon, 14 Oct 2024 08:24:43 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:43 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Alexandra Winter , "David S. Miller" , Eric Dumazet , Gal Pressman , Jakub Kicinski , Kory Maincent , Marc Kleine-Budde , Paolo Abeni , Sabrina Dubroca , Shannon Nelson , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 1/6] can: dev: add generic function can_update_bus_error_stats() Date: Mon, 14 Oct 2024 17:24:16 +0200 Message-ID: <20241014152431.2045377-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.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" The function aims to generalize the statistics update by centralizing the related code, thus avoiding code duplication. Signed-off-by: Dario Binacchi --- drivers/net/can/dev/dev.c | 30 ++++++++++++++++++++++++++++++ include/linux/can/dev.h | 1 + 2 files changed, 31 insertions(+) diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c index 6792c14fd7eb..0a3b1aad405b 100644 --- a/drivers/net/can/dev/dev.c +++ b/drivers/net/can/dev/dev.c @@ -16,6 +16,36 @@ #include #include =20 +void can_update_bus_error_stats(struct net_device *dev, struct can_frame *= cf) +{ + struct can_priv *priv =3D netdev_priv(dev); + bool rx_errors =3D false, tx_errors =3D false; + + if (!cf || !(cf->can_id & (CAN_ERR_PROT | CAN_ERR_BUSERROR))) + return; + + priv =3D netdev_priv(dev); + priv->can_stats.bus_error++; + + if ((cf->can_id & CAN_ERR_ACK) && cf->data[3] =3D=3D CAN_ERR_PROT_LOC_ACK) + tx_errors =3D true; + else if (cf->data[2] & (CAN_ERR_PROT_BIT1 | CAN_ERR_PROT_BIT0)) + tx_errors =3D true; + + if (cf->data[2] & (CAN_ERR_PROT_FORM | CAN_ERR_PROT_STUFF)) + rx_errors =3D true; + else if ((cf->data[2] & CAN_ERR_PROT_BIT) && + (cf->data[3] =3D=3D CAN_ERR_PROT_LOC_CRC_SEQ)) + rx_errors =3D true; + + if (rx_errors) + dev->stats.rx_errors++; + + if (tx_errors) + dev->stats.tx_errors++; +} +EXPORT_SYMBOL_GPL(can_update_bus_error_stats); + static void can_update_state_error_stats(struct net_device *dev, enum can_state new_state) { diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 23492213ea35..0977656b366d 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -201,6 +201,7 @@ void can_state_get_by_berr_counter(const struct net_dev= ice *dev, enum can_state *rx_state); void can_change_state(struct net_device *dev, struct can_frame *cf, enum can_state tx_state, enum can_state rx_state); +void can_update_bus_error_stats(struct net_device *dev, struct can_frame *= cf); =20 #ifdef CONFIG_OF void of_can_transceiver(struct net_device *dev); --=20 2.43.0 From nobody Wed Nov 27 02:38:35 2024 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 2093F1BBBC6 for ; Mon, 14 Oct 2024 15:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919488; cv=none; b=aiksv5pqg30wRedpqsX6K72b+JqGrJ4+XGyDvMPMlglqOjRjJmIQJGzQ/4x6c3fP5S1sgPSFtDEqQCWwCuISbfclM7yT3yp/25AXD5IdgSepzToURNlAymA/N+tqPHe6r9PO8FXywWxPXtJtf+najWDAY/TpLNjf2yFxcE/9LsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919488; c=relaxed/simple; bh=QuncdE9kUGyMlrCyIU0A4Zo2V78v+caSklfTJlnlBoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=osHyt3Jf4xOd3C358eTAZNHBi4u04t3xTp9XWxOMXw3/UVFNx/woV4OCq6AOXqcJ8Dv9qlrkQNpLzah0UzDe4BwuD4PvukkLDiocAFrH7jR9oQ8ufB2gUruC+bLF0EaEEo7F/mV6ehnfXkuywBKtXJIYl0TYMJuWS5NqCWs//Po= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=d3ZYJbnt; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="d3ZYJbnt" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-43123368ea9so20527415e9.0 for ; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1728919485; x=1729524285; 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=Z1ubGjttmwYd5EYJYtdXhE3bw7ehS4yxQFLk9r6TH7o=; b=d3ZYJbntwdn4IEaNQYmelmba8O6qT5VlM9+CeoiUHpYfCK1U2kCC501UVI6/PUaycf kGsSUlezrjY1RmvkME6SuYjhJzu0zRs1hUp6FnyNSfCDMF4VO8JEQEajhbrKdGNJF3sN REtbOnMyTL4VBfSpxUsrW/Idg+m+cAJZxsrQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919485; x=1729524285; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z1ubGjttmwYd5EYJYtdXhE3bw7ehS4yxQFLk9r6TH7o=; b=ri89Ba6mGL6SUjThV9Xse1wxfi1xbVvRDstg2/TBLiQD1D2pPxOLYz7pNC+TZ1zwLZ zoKlbLGsFANC4Pf0qvKUoQblHyjqWDFK3eytzSo5jYNJDfG121nLqrDpj0I3DxV0/ruL fch5gL9HwRTxdPtUTZ0ho/Zduu2xQcodCozWtqDPFS+msEI71Pvlm5dbgAl/lOOWT3Oa wRTlzShman4LNQmyGcHl9y2rl6fbkyg/EkVPezxiJnQVTVMVD4g00aXXki1j8Wg1o+ee J95FGXS8RyloFM7tMAgmL2qakYFzKDUHoxYTFGBd3rB+uU+2mjmh7/dsNLLmivAjxCwB ITGQ== X-Gm-Message-State: AOJu0Yy+oQXMm/uZQAxP3AZIrvFSBHgkaeK13niP8f9wD9XlA3X8PyLj xfH3roVTjIv9Mos6/iGhMZ3Q1JuhGMvwok7CIoVEPkAKPo/s0PUyve0HxBn76Zl53pNDY9oMyZF T4ic= X-Google-Smtp-Source: AGHT+IF4JWlOlvMPdCidrlARcCCytbWgSFORgP9Hmt+oL+CcsnuX/II03HaBHyokWumwj6uoTzDUZg== X-Received: by 2002:a05:600c:3b8e:b0:426:6e86:f82 with SMTP id 5b1f17b1804b1-43125609939mr71666065e9.22.1728919485308; Mon, 14 Oct 2024 08:24:45 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:45 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Frank Li , Haibo Chen , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Rob Herring , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 2/6] can: flexcan: use can_update_bus_error_stats() Date: Mon, 14 Oct 2024 17:24:17 +0200 Message-ID: <20241014152431.2045377-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.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" The patch delegates the statistics update in case of bus error to the can_update_bus_error_stats(). Signed-off-by: Dario Binacchi --- drivers/net/can/flexcan/flexcan-core.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexc= an/flexcan-core.c index ac1a860986df..790b8e162d73 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -819,7 +819,6 @@ static void flexcan_irq_bus_err(struct net_device *dev,= u32 reg_esr) struct flexcan_regs __iomem *regs =3D priv->regs; struct sk_buff *skb; struct can_frame *cf; - bool rx_errors =3D false, tx_errors =3D false; u32 timestamp; int err; =20 @@ -834,41 +833,31 @@ static void flexcan_irq_bus_err(struct net_device *de= v, u32 reg_esr) if (reg_esr & FLEXCAN_ESR_BIT1_ERR) { netdev_dbg(dev, "BIT1_ERR irq\n"); cf->data[2] |=3D CAN_ERR_PROT_BIT1; - tx_errors =3D true; } if (reg_esr & FLEXCAN_ESR_BIT0_ERR) { netdev_dbg(dev, "BIT0_ERR irq\n"); cf->data[2] |=3D CAN_ERR_PROT_BIT0; - tx_errors =3D true; } if (reg_esr & FLEXCAN_ESR_ACK_ERR) { netdev_dbg(dev, "ACK_ERR irq\n"); cf->can_id |=3D CAN_ERR_ACK; cf->data[3] =3D CAN_ERR_PROT_LOC_ACK; - tx_errors =3D true; } if (reg_esr & FLEXCAN_ESR_CRC_ERR) { netdev_dbg(dev, "CRC_ERR irq\n"); cf->data[2] |=3D CAN_ERR_PROT_BIT; cf->data[3] =3D CAN_ERR_PROT_LOC_CRC_SEQ; - rx_errors =3D true; } if (reg_esr & FLEXCAN_ESR_FRM_ERR) { netdev_dbg(dev, "FRM_ERR irq\n"); cf->data[2] |=3D CAN_ERR_PROT_FORM; - rx_errors =3D true; } if (reg_esr & FLEXCAN_ESR_STF_ERR) { netdev_dbg(dev, "STF_ERR irq\n"); cf->data[2] |=3D CAN_ERR_PROT_STUFF; - rx_errors =3D true; } =20 - priv->can.can_stats.bus_error++; - if (rx_errors) - dev->stats.rx_errors++; - if (tx_errors) - dev->stats.tx_errors++; + can_update_bus_error_stats(dev, cf); =20 err =3D can_rx_offload_queue_timestamp(&priv->offload, skb, timestamp); if (err) --=20 2.43.0 From nobody Wed Nov 27 02:38:35 2024 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 7EF501C2439 for ; Mon, 14 Oct 2024 15:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919490; cv=none; b=o/riON2tD4NZWsrzxz0ABUmfAmtg72DVst7dnKmTbycH1QdmLT2RNc78Wn+2SfKQZ9g9nSM3Daw0X4/6SWdQVoN3Xc2cmcDu7zzKTbpZep/Dg4xCJotKUivR8hAWiq2Sh0byXSfQn2zm0JMR2jXAbYGue6KV2d2lTYtZyp8iDoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919490; c=relaxed/simple; bh=lh4Nux2BM9KA0YnyuwNNz2cQ4XebGG7dievfjnPe1gk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j6Csy14bzHXLf3xIzf3oJ+9XltpKNNDSkFnxhKwM40hDVKtgohcqGi5/+yZLfpX74K7+YvMWU3suEgIUPs3Wb+nTMYZtirvYdauTYpaJfcuLt86PDp0Fz5LVINlmIM3qisprwl8OwPMT/gNFAr4hptmbgagw8vM6x+3oYuVEnwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=kgqMEN2N; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="kgqMEN2N" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-37d4a5ecc44so3138158f8f.2 for ; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1728919486; x=1729524286; 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=rl0FvaCWPNne/T/X4eNpX+jzq6AP7zoJV76Sz9wGAY8=; b=kgqMEN2NGsm6oSSnGHkwr3FvdGlXbmgdvPwthFXpJXxa33BOzWIBBlD8tKeJztLda4 Lq0oUqTexGkUDSEVfRcZuy868suTbFfldNnsf0Pcg9Fo7l5ESp/CR8UkpVu66dNtMAKz hsluwVNNq7V3WEOt/jUUKw8h3q/bdKrWxa64A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919486; x=1729524286; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rl0FvaCWPNne/T/X4eNpX+jzq6AP7zoJV76Sz9wGAY8=; b=hSt2mcQvN4kXVieSFXct8XEiMydXPSNZABad2tjUBoknOS9MTnBxPTuFSMoMveOez+ V3OgMO7H1e22TU+kkUuqXfext4vJVp4XkclR2HEUb4SfqR7l7LGbFlbqaVi1L8izPxmO iboBGSFhMyTe/F/rn0r/dnocRDQE0/NYyhQIQaGkd7PC2yZknB3pjHfMZaw4HLNjDOOz Ey4hvWjIBgSiWDWGWuROjH/FwXg1DVH6Iac///b35FiRWaXe4yPaFe2zk0Bm2lfO84Yx wZ//wALo+wV/rf3n9d9wLkmbbs/oSqVw43/rm9yGZ0CuRjhyZlTlf4WzJ8QQEJFWvAvJ l9mg== X-Gm-Message-State: AOJu0YxOFmeJxMYUQyvnemZTqD6hhpfb+yKUXdud7U0YRYgIcT6IZtX2 r+qXFlCPtWKymGdE04PHZxNu3yx7/aaTGRcxQACbTbjFleNZzARzm6tTm/p1Dy/O8hIN20Fb1md AfME= X-Google-Smtp-Source: AGHT+IHXtA2bKleaKXoB33rt2FVydaPUB5ihn14r2Ga+SIzk48TF91MSDXc9jkxNU0eOVF1n5dQXhw== X-Received: by 2002:a5d:684b:0:b0:37d:52d0:a59d with SMTP id ffacd0b85a97d-37d551ab465mr9434826f8f.10.1728919486433; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:46 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [RFC PATCH 3/6] can: dev: add helper macros to setup an error frame Date: Mon, 14 Oct 2024 17:24:18 +0200 Message-ID: <20241014152431.2045377-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.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" These helpers can prevent errors and code duplication when setting up a CAN error frame. Signed-off-by: Dario Binacchi --- include/linux/can/dev.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 0977656b366d..0202526be6b0 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -23,6 +23,33 @@ #include #include =20 +#define CAN_FRAME_ERROR_INIT(cf) \ + ((cf)->can_id |=3D CAN_ERR_PROT | CAN_ERR_BUSERROR) + +#define CAN_FRAME_SET_ERR_BIT0(cf) \ + ((cf)->data[2] |=3D CAN_ERR_PROT_BIT0) + +#define CAN_FRAME_SET_ERR_BIT1(cf) \ + ((cf)->data[2] |=3D CAN_ERR_PROT_BIT1) + +#define CAN_FRAME_SET_ERR_ACK(cf) \ + do { \ + ((cf)->can_id |=3D CAN_ERR_ACK); \ + ((cf)->data[3] =3D CAN_ERR_PROT_LOC_ACK); \ + } while (0) + +#define CAN_FRAME_SET_ERR_CRC(cf) \ + do { \ + ((cf)->data[2] |=3D CAN_ERR_PROT_BIT); \ + ((cf)->data[3] =3D CAN_ERR_PROT_LOC_CRC_SEQ); \ + } while (0) + +#define CAN_FRAME_SET_ERR_FORM(cf) \ + ((cf)->data[2] |=3D CAN_ERR_PROT_FORM) + +#define CAN_FRAME_SET_ERR_STUFF(cf) \ + ((cf)->data[2] |=3D CAN_ERR_PROT_STUFF) + /* * CAN mode */ --=20 2.43.0 From nobody Wed Nov 27 02:38:35 2024 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 DE11D1C7274 for ; Mon, 14 Oct 2024 15:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919491; cv=none; b=HQbmhHZ80nRoiVUA9Cygf6VBj1LfrWQCHxOJXBps24QTLAzXrSxqQK74MXqTM8o5Ve8xgfjUoZXSCUIqXzJ32jNJ2vEQI8GgxuOYsmyISAnt4tnBgpncq6TXPHyWyuSrRK1ciJ0SHQT8xVIk5jyC/+/QsREUDOOeQ54926aaNk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919491; c=relaxed/simple; bh=P/Am7rBXsNK0N5iJJRQ1pvU7nWegi2LeVq0ySNH9P/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EmMciGDCLgHMQY/jXF6QY/LtlW5RFNnA71LbC6bU4ZG7YbvI1dmmVk6s3TfsTXGLRXr5EHFmxw5u5ZekDOavFYwS8QIskpjnhkRtbQjm9AYKRx6wfnZtD4geu3tYWx4BNJXakQjcP59Ga2Dht6aCZ71wNVcc1j/LFxdpbyj9T40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=P8cydSdK; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="P8cydSdK" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-431291b27f1so18899525e9.0 for ; Mon, 14 Oct 2024 08:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1728919488; x=1729524288; 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=aYG5/yu0pXXht36spug+Xg/mIMYx6ohdGwedIw0qEKE=; b=P8cydSdKH7YH+49CQmSeXUuixs1Bq8hLrSa6uZzF9L3AkD+D/kb2zazrWvDlJr8VcD Xh1o//zO9/2dP1xD2Sr3rqHwhqFoXzGD8pp3tcPUg9H45BUn0TvtTc748rEkQkOG4vB8 35U7KOMPLG6HrSUS76SoJwf6eVSfOZawP4EDU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919488; x=1729524288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aYG5/yu0pXXht36spug+Xg/mIMYx6ohdGwedIw0qEKE=; b=YxuXSgTY0LVd9Mar8+VPqgve77BkzqQf+gKtniudFBP4MUtpWC4ghXOCdOA6GXZUry 3V3cHeavX2gyVwIAbQ5GbWrfgCCzbpsm1b94nMNDig5lib3alD/8xQvDatLs3OaWhhMQ 6zq+JaDb6aN3oxTBg5IHlVdzih7JrmlH9bpGbogi47BC1N0EF32/is+1khGhQYEcP7gh W7cNmcHkj5LI/lWk+02FUaJJtIj82NSLsaRloWqwCac1JQttl8JAE64ukersMU64f2mO uoP2wZ2o78FgqA9hxRCS5p71c5fEMD+cNA2Kn+hFQVnjC6AfpQ/hygb1qYo2/yw3qUA/ M8Tw== X-Gm-Message-State: AOJu0YyQlCxY4VlSW10NQqB7HZ6CBLYrdsiZnWajgw1iHvyNSFyBOND3 Cemw7jtI+NVinpuPRX64ojD+RECL2J55ckxal2u4DWO7alYSvIEtfH8fh/LMT2iudTl+m9o+b4F MB2s= X-Google-Smtp-Source: AGHT+IGZ3IYG7ZvyIsW6OHsWJAHiVpG6rdtl5YUGeUbVWbREtsc/3WlQVldg1bZQLb44Iu2gdNXasA== X-Received: by 2002:a5d:54c2:0:b0:37d:542c:559 with SMTP id ffacd0b85a97d-37d551b6a0fmr8141214f8f.18.1728919487917; Mon, 14 Oct 2024 08:24:47 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:47 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Frank Li , Haibo Chen , Han Xu , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Rob Herring , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 4/6] can: flexcan: use helper macros to setup the error frame Date: Mon, 14 Oct 2024 17:24:19 +0200 Message-ID: <20241014152431.2045377-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.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" The patch replaces the code that directly accesses cf->data[] for setting up the CAN error frame with the appropriate helper macros. Se hai bisogno di ulteriori traduzioni o modifiche, non esitare a chiedere! Signed-off-by: Dario Binacchi --- drivers/net/can/flexcan/flexcan-core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexc= an/flexcan-core.c index 790b8e162d73..ca620c8f028c 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -828,33 +828,31 @@ static void flexcan_irq_bus_err(struct net_device *de= v, u32 reg_esr) if (unlikely(!skb)) return; =20 - cf->can_id |=3D CAN_ERR_PROT | CAN_ERR_BUSERROR; + CAN_FRAME_ERROR_INIT(cf); =20 if (reg_esr & FLEXCAN_ESR_BIT1_ERR) { netdev_dbg(dev, "BIT1_ERR irq\n"); - cf->data[2] |=3D CAN_ERR_PROT_BIT1; + CAN_FRAME_SET_ERR_BIT1(cf); } if (reg_esr & FLEXCAN_ESR_BIT0_ERR) { netdev_dbg(dev, "BIT0_ERR irq\n"); - cf->data[2] |=3D CAN_ERR_PROT_BIT0; + CAN_FRAME_SET_ERR_BIT0(cf); } if (reg_esr & FLEXCAN_ESR_ACK_ERR) { netdev_dbg(dev, "ACK_ERR irq\n"); - cf->can_id |=3D CAN_ERR_ACK; - cf->data[3] =3D CAN_ERR_PROT_LOC_ACK; + CAN_FRAME_SET_ERR_ACK(cf); } if (reg_esr & FLEXCAN_ESR_CRC_ERR) { netdev_dbg(dev, "CRC_ERR irq\n"); - cf->data[2] |=3D CAN_ERR_PROT_BIT; - cf->data[3] =3D CAN_ERR_PROT_LOC_CRC_SEQ; + CAN_FRAME_SET_ERR_CRC(cf); } if (reg_esr & FLEXCAN_ESR_FRM_ERR) { netdev_dbg(dev, "FRM_ERR irq\n"); - cf->data[2] |=3D CAN_ERR_PROT_FORM; + CAN_FRAME_SET_ERR_FORM(cf); } if (reg_esr & FLEXCAN_ESR_STF_ERR) { netdev_dbg(dev, "STF_ERR irq\n"); - cf->data[2] |=3D CAN_ERR_PROT_STUFF; + CAN_FRAME_SET_ERR_STUFF(cf); } =20 can_update_bus_error_stats(dev, cf); --=20 2.43.0 From nobody Wed Nov 27 02:38:35 2024 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 BE0591C7617 for ; Mon, 14 Oct 2024 15:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919492; cv=none; b=nKpOJvf7ctUkjkGz+kR88gJI6dX7iFB+TKiWq3izH3XFqx/nbwiOTSUfOXJgSZxL6WtlpC093uTpnwnDpXmREGQMevqrHVj2ueDSDy1Ls3UcnvwVSC5Wfp9QBcVmoakxQbx62L/53wLUsYrFISe3hl6SgE4CvAI24Fg9Tj40U4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919492; c=relaxed/simple; bh=1scCBJ/VM0pca31nuWrlLm4/5Gj3CR8thHP51DHu8A8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oIYn8veZLfSfpSlDVflLE/nLQBI2xCvDT3fwq7GBW5CSTO8Lz4UjwwjKs68yAkrzPdzDrLsKH6+H/kRj2dUrKuNIQeXWbQGPSnDW8CtUxvGCkQ89OJqIIQ0sZcr3PflneBltzQc8hAQa3KJmHrKd4wzrUrXFZLVAlKKUmbKkbbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=pD3Q5pjF; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="pD3Q5pjF" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43058268d91so41552745e9.0 for ; Mon, 14 Oct 2024 08:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1728919489; x=1729524289; 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=pO1UlU+Kdbb/WHWYgWNeRFcofykWy+kMnflMuEIHEjY=; b=pD3Q5pjFO9bnrRkYpnuCRfhBqiI6wcwJz1497/3Hs09/Y/K+gxFv7XcQ8O0kk1wxiD eSDT8BRGeKhUzAFRWM3L1x2FR/UEjqF1jJ1HjeV8QOaE90PVWP0Nb6YAoIDll/b5nNdd ChRFXKwrGURxxkCLHjR8cQLCcR9IhMIWA5Sd4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919489; x=1729524289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pO1UlU+Kdbb/WHWYgWNeRFcofykWy+kMnflMuEIHEjY=; b=MF7DQyAIubCikn5RFOn37fMU3gSAvtaRIu70lvwMh+ba4ztt+oYcZifxd2PN1DKuoT CL3yjCH9Bc3I4N2yv9L8Mir8gEM0s573dBj1/VofRwpU6sVmtVKe04yAl4FMX6pkqT3y UClIF+saBmyySriHgQO27Con6REjq9e68iYaqMet4PHONkY9aJPDW1HYouWymhhlYgzk /3AsxfTr05rv64kEQokNv8HszZjMPZnnEVUXrywXZfOf0CXxWqN5eRHX9A8IuyuQitp3 +0NbUSIVry694ncBb6NRP3IbYRx598gReCpvIetmmxxtiJThGCyhdvf4ngrtXnRMAm5M IWWA== X-Gm-Message-State: AOJu0YxEcOP4LlsjY8KB4gLy1sI9gO3cmyla9lZJMHlvYL7+jhU7nnYS vjOrqDMfC50TdusEoHuWcFDfEUmvC0+/UQnlKrdrFDIu/0WDBlYROr7fMhb5Fdu5bhkWWy9DxYE ChLQ= X-Google-Smtp-Source: AGHT+IGS6aL9XD5X1p3cF17cXzZlqYIV9SimkvM6/DY29FPG7JvJGWB6ILxKTV26dH71FIhNPXlijA== X-Received: by 2002:a05:600c:3b0d:b0:428:10d7:a4b1 with SMTP id 5b1f17b1804b1-4311df56e7bmr106900825e9.25.1728919488976; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:48 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [RFC PATCH 5/6] can: netlink: extend stats to the error types (ack, CRC, form, ...) Date: Mon, 14 Oct 2024 17:24:20 +0200 Message-ID: <20241014152431.2045377-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.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" The CAN bus protocol specifies 5 CAN error types: - Bit Error [Transmitter] - Bit Stuffing Error [Receiver] - Form Error [Receiver] - ACK Error (Acknowledgment) [Transmitter] - CRC Error (Cyclic Redundancy Check) [Receiver] The patch also adds the corresponding counters to the statistics. Since each device/driver can determine which of these errors has occurred, why not export this information along with the more general counters? Signed-off-by: Dario Binacchi --- include/uapi/linux/can/netlink.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netl= ink.h index 02ec32d69474..8b33549e7e19 100644 --- a/include/uapi/linux/can/netlink.h +++ b/include/uapi/linux/can/netlink.h @@ -114,6 +114,12 @@ struct can_device_stats { __u32 bus_off; /* Changes to bus off state */ __u32 arbitration_lost; /* Arbitration lost errors */ __u32 restarts; /* CAN controller re-starts */ + __u32 bit_error; /* Bit error */ + __u32 stuff_error; /* Bit stuffing error */ + __u32 form_error; /* form error */ + __u32 ack_error; /* ack error */ + __u32 crc_error; /* CRC error */ + __u32 pad; }; =20 /* --=20 2.43.0 From nobody Wed Nov 27 02:38:35 2024 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 597881C7B99 for ; Mon, 14 Oct 2024 15:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919494; cv=none; b=qlIKg32Q/LKT0M6J1m+HqiY0rHbbPZy81z+04mVN+TV+wJ+qaTbxG/DrO08UjTofBk6CokXr2FzdOqcER+iZ2Y2I0zrIHqps0bRFIIbaxJi/Ko5fuoNvQf5Iiasw4wPKiZCFru8JeFJAw3McrWHvDD6+AAjYkeebPPvh+W4YG/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919494; c=relaxed/simple; bh=xpAc5RRbhHfs28chKhvyL6+voVGmTaE2zNIZn+iatNA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rvvb+j5NORGD6kg4Ivqm/MV1+ZNdSp0si814yo5MDBmltfoyNw4kEz5ueQhuqskOrDaeB/ZXDVrMhCcw8eao0O9H/kJNFLXoVg5HQDEXo97GkgbceUBlJ/H0q1OmmbdIp/aidBYHfRD7Ndo+XEbl5ClmHR39CiJSqL00ZbcNcYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=XBk9Vi6U; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="XBk9Vi6U" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-37d6756659eso1149384f8f.0 for ; Mon, 14 Oct 2024 08:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1728919490; x=1729524290; 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=QiHw9EzZ4u2R61UsONsymQwt0FhsGds7xVoU4Q9fXYA=; b=XBk9Vi6UrCXHgGV7QvBZvby0+oJfoKOFoPOLHiwZ3u0oSDxCcg8uTYVeyudSIVhiNT lvqoEtSTtPUzWrA1jzSv8O83/NBYdkCu2Cgv2UzWbQ0xfnHheaZczXncau2WxVIsf0u2 /YgLr4TX+w1VJQ4HHQHWbBaKjW5ZmVToJ6VrU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919490; x=1729524290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QiHw9EzZ4u2R61UsONsymQwt0FhsGds7xVoU4Q9fXYA=; b=QPZjucKHh5lyQ0b3vOp2llIpRgqWuybYM7QcxQ04R32cCBmefjFQJBAJWnan5Zn42j 48HE79/+BVt5dQM+1BxJHssiRSYaroieAn+h8dTQ+lOnKZP141B3jHnZ4e8Hwswax3UP nNTzbEPVAldg+SqfDScV5B8YsxENVzhldhZDAFDbM60w8zWZlWp1WJhUtFSA7kopTaFC sImcriflb7uiPhwW+ZGjUahWNhE9szq0lZ9QtR3TAA/bEfzSifQkd2/EWiz4llfO7ZKD zly7tKjB5TytCJhAtY0HfzyEdH5Tx7vpwt3VnS/kayDFsxK5urfDZOz3+ULVxoOBeVKF PlhQ== X-Gm-Message-State: AOJu0YxlWgU3KzLOi+sC1L/th/aLDpoWe8RAUqQ/gKbXxqx3Zdp9TeLl m370pE6j7R8WkZmgoF8Zl6eCLO51xNpCbQWumg+XyBXZHFjAbGntuXXd/r4j4cLdMj+KhU8/KmG DBFU= X-Google-Smtp-Source: AGHT+IFGv9Z7cCWKPOZTMaenQuoxsKq/VuIJIPMHB9aEeYKLQjYeCtT40BlGCnbEbTTHOhkV/N3T+A== X-Received: by 2002:adf:a407:0:b0:37d:509e:8742 with SMTP id ffacd0b85a97d-37d5fe954c8mr5128907f8f.1.1728919490496; Mon, 14 Oct 2024 08:24:50 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:50 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Carolina Jubran , "David S. Miller" , Eric Dumazet , Gal Pressman , Jakub Kicinski , Kory Maincent , Marc Kleine-Budde , Paolo Abeni , Sabrina Dubroca , Shannon Nelson , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 6/6] can: dev: update the error types stats (ack, CRC, form, ...) Date: Mon, 14 Oct 2024 17:24:21 +0200 Message-ID: <20241014152431.2045377-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.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" The patch modifies can_update_bus_error_stats() by also updating the counters related to the types of CAN errors. Signed-off-by: Dario Binacchi --- drivers/net/can/dev/dev.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c index 0a3b1aad405b..f035e68044b3 100644 --- a/drivers/net/can/dev/dev.c +++ b/drivers/net/can/dev/dev.c @@ -27,16 +27,31 @@ void can_update_bus_error_stats(struct net_device *dev,= struct can_frame *cf) priv =3D netdev_priv(dev); priv->can_stats.bus_error++; =20 - if ((cf->can_id & CAN_ERR_ACK) && cf->data[3] =3D=3D CAN_ERR_PROT_LOC_ACK) + if ((cf->can_id & CAN_ERR_ACK) && cf->data[3] =3D=3D CAN_ERR_PROT_LOC_ACK= ) { + priv->can_stats.ack_error++; tx_errors =3D true; - else if (cf->data[2] & (CAN_ERR_PROT_BIT1 | CAN_ERR_PROT_BIT0)) + } + + if (cf->data[2] & (CAN_ERR_PROT_BIT1 | CAN_ERR_PROT_BIT0)) { + priv->can_stats.bit_error++; tx_errors =3D true; + } =20 - if (cf->data[2] & (CAN_ERR_PROT_FORM | CAN_ERR_PROT_STUFF)) + if (cf->data[2] & CAN_ERR_PROT_FORM) { + priv->can_stats.form_error++; rx_errors =3D true; - else if ((cf->data[2] & CAN_ERR_PROT_BIT) && - (cf->data[3] =3D=3D CAN_ERR_PROT_LOC_CRC_SEQ)) + } + + if (cf->data[2] & CAN_ERR_PROT_STUFF) { + priv->can_stats.stuff_error++; rx_errors =3D true; + } + + if ((cf->data[2] & CAN_ERR_PROT_BIT) && + cf->data[3] =3D=3D CAN_ERR_PROT_LOC_CRC_SEQ) { + priv->can_stats.crc_error++; + rx_errors =3D true; + } =20 if (rx_errors) dev->stats.rx_errors++; --=20 2.43.0