From patchwork Sat Nov 16 18:02:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13877676 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 CE0F518E35D for ; Sat, 16 Nov 2024 18:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780191; cv=none; b=gKAv4scZaDOpjAP2MTgfHbaY883EZ+4KffHp5KfaxBWx2miFuHi8h4wrZth7Cl6Q9rUbvqEJZhStzHpghJ7vb/buiHCnethkWOGUUOMWBGiuN32CG2EHWR1XgdF/1J0NbfZ/aZolEKQOSvxEFjcko5AaiBEUm1k5e/i3KHaHCO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780191; c=relaxed/simple; bh=6yVXQABDgHQ3YoFzFBc688YaHlYOrV8PMSvT0DmVF0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nGhTFXBq1226qa8l75oglZHgwauh39NSYxtbYysF+F7vFIDWGEB5Q0oEkWwxvxbujcS/6Lj1JSxOSEIVl1dhh2jO96T27gkCDGxhU+p2MtzKnuhS5m40IJDPR/UvDR5S5cWgCoOa3OLwW5pLfus7DnRahy7oz3k4JFMRaR/CJ/8= 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=HsKRaCyI; arc=none smtp.client-ip=209.85.208.51 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="HsKRaCyI" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5cf9ef18ae9so2026182a12.1 for ; Sat, 16 Nov 2024 10:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780188; x=1732384988; 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=CGnFcahEd0eVvjCCPAmskcKVoLg3YmWfRrAxcNnhTVM=; b=HsKRaCyI871iY1l5Qeyc6UDUSwcuGhGMCDevYQ2NGytn58BAQNcVs2Wqyv6d8Il4ZN imRPyozRk+2ElitXM/VyaorxyO4j3/yIH/qXBD6JyvbRKYMHCzd2mOPzq4ttVt3Uzt7t Mhqui6sOmmnYRMuweXVRqMKh/Qo3jn1h+qKek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780188; x=1732384988; 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=CGnFcahEd0eVvjCCPAmskcKVoLg3YmWfRrAxcNnhTVM=; b=NuXQjA4LBkT1xHpMSFhsy3vzKrZDOgNN4vnJmgP8AT7hKcqhDwTjfBL/A63HlWktXC yfz34P+to6kpna6kuum3BLPcS+6YXzcnZnh9p39x2qFNCdMjbVIMxbPIqL7dwk3OQFs+ F+4NdijDgXQMvVsRQHyfFfUsAzVtL/YMHXMlAFaCsXcPTIhsulYDrqaYhZ86QUDS3XlI EQFfYLju0AUqBnKbOpnVKXw75EhruajwaeW6Qy3/sq0w+6fAoBUZJ3M97/9Ml7RgIwwN 8W+4/i/qD3W/7E41H424MTtORsyNC8rJ1NQ1i05b7v2t6FUT/P0yln6nxZL8wB7rz0UV uurg== X-Forwarded-Encrypted: i=1; AJvYcCXfv6ave3Iyq7Gu0TElDp6IMs0PFgjzTlK+QegN+lNvZMfaBXCLvfLuV7w/Q5iTRr/z9ZBjEDI=@vger.kernel.org X-Gm-Message-State: AOJu0YxCZ/ZkTTmzTIhXkdberCltuYUnoMPi1KqDM2A99qOwY7W6VVrI 2p8gjxf8ZXIEnWB8SCBe5FtZNkrUjtqx7Qz313IOC8GvpHeM/b8N1UQx8af5I5Y= X-Google-Smtp-Source: AGHT+IEY6i5r17rHD7AA4pDo0eewtwkaRGniz3NbwzmDUylo6DVU+CLQMsuSqXx2AB1hMg+lZtDO9Q== X-Received: by 2002:a17:907:1c9d:b0:a9e:670f:9485 with SMTP id a640c23a62f3a-aa481a5cecfmr569044566b.30.1731780188249; Sat, 16 Nov 2024 10:03:08 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:07 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , Chandrasekar Ramakrishnan , "David S. Miller" , Dong Aisheng , Eric Dumazet , Fengguang Wu , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Varka Bhadram , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 1/7] can: m_can: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:30 +0100 Message-ID: <20241116180301.3935879-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The m_can_handle_lec_err() function was incorrectly incrementing only the receive error counter, even in cases of bit or acknowledgment errors that occur during transmission. The patch fixes the issue by incrementing the appropriate counter based on the type of error. Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support") Signed-off-by: Dario Binacchi --- drivers/net/can/m_can/m_can.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 16e9e7d7527d..337ccfae34fd 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -695,7 +695,6 @@ static int m_can_handle_lec_err(struct net_device *dev, u32 timestamp = 0; cdev->can.can_stats.bus_error++; - stats->rx_errors++; /* propagate the error condition to the CAN stack */ skb = alloc_can_err_skb(dev, &cf); @@ -711,26 +710,32 @@ static int m_can_handle_lec_err(struct net_device *dev, case LEC_STUFF_ERROR: netdev_dbg(dev, "stuff error\n"); cf->data[2] |= CAN_ERR_PROT_STUFF; + stats->rx_errors++; break; case LEC_FORM_ERROR: netdev_dbg(dev, "form error\n"); cf->data[2] |= CAN_ERR_PROT_FORM; + stats->rx_errors++; break; case LEC_ACK_ERROR: netdev_dbg(dev, "ack error\n"); cf->data[3] = CAN_ERR_PROT_LOC_ACK; + stats->tx_errors++; break; case LEC_BIT1_ERROR: netdev_dbg(dev, "bit1 error\n"); cf->data[2] |= CAN_ERR_PROT_BIT1; + stats->tx_errors++; break; case LEC_BIT0_ERROR: netdev_dbg(dev, "bit0 error\n"); cf->data[2] |= CAN_ERR_PROT_BIT0; + stats->tx_errors++; break; case LEC_CRC_ERROR: netdev_dbg(dev, "CRC error\n"); cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + stats->rx_errors++; break; default: break; From patchwork Sat Nov 16 18:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13877678 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 D1AFB1946AA for ; Sat, 16 Nov 2024 18:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780193; cv=none; b=dtMB3q5TAsFf/qRw5H0c3/HlxTPZ5rwACXDq0JsPMz0VSdapfgDVonLvOm8IpAbJk8XwOce1XN5uKl3TbATO6WoqM2aiPKtosDDE5CYryIJPz+X6KqqS2ZP9Cb6Pl+DjgIh0CTghnOWKqRKzLChtWn5ySWUwPHNHMitI+4wg3P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780193; c=relaxed/simple; bh=A34sGZ1LJl0UqZM4Ywby3Ot5AJSBqH2ddrj3nuGd0os=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H2ocRcEQcV1TCtFgCGdG9me1E7PO5U6NCZjKyUjnVGinoGSMf3R0Jibl2X6wMWMTkVrGNKAxCHyUxj5cclAFfFs4oRDVU5KqZ7ZnDKoUeeL9ku7CMmx65MOq3f5JQqcL83oSTH9FVlZApbV2xtBIUVHB+fXlA2ZPJM5bDBYNIz8= 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=IOzwUli6; arc=none smtp.client-ip=209.85.218.47 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="IOzwUli6" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a9f1c590ecdso313797066b.1 for ; Sat, 16 Nov 2024 10:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780190; x=1732384990; 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=MKS1He5MRcB9KzHlUh7sCjUXRUA/E/nSRL0TriRLZjg=; b=IOzwUli6lxoPfAGdmsommEzymo7E/Gf2QmVx3z6spbZionuPtyq/b4yhuTeQ0HNc9M CHm9ugJCn0br6/wHKUyWoIdLDThfLAE/S2xu5eXHAlrd1Ne+zb4Xrpqb5dQ1edjq+aiG bZCorLoEnlEIReD3DCEMYzXo7Re0hGvtmFMr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780190; x=1732384990; 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=MKS1He5MRcB9KzHlUh7sCjUXRUA/E/nSRL0TriRLZjg=; b=tT2rxWuA77AgS6MSFp0Eg11RKRcMXLxc+PFlbaGWM5PmuuLJIbXSZbF+9wMIwrRPEZ IbOcE6V/nBTzpRuXVtPKh4smdZ/QWn6lXV5KvyN/xdS3/EEsICXTzVy6bHy2YelcuLCR S/YCFhTbcZ8iUyWyx4rQyZc5nh2o7ZofyMwVRJgjpOGNa7qeoBELiEbfPgDIAXXTXHrd 9j+yMKTtqUcMrF/kW1crEtWIJWbeRTs4fr3ojcDJ+xCmqt4tOgfW/eUD7HDycACSoIxA NDFdfmy7LrmwbHbAtxZjgfuGS0qbwEHZNRCaWDIISbtZwNpgweYygyepL/EJjm0KSq3a p/mA== X-Forwarded-Encrypted: i=1; AJvYcCXIxExPfbegIHhLV0MbmZ7HwWM8H/t6z8lLRk7Fp9SXkhP7wC/Xiy0kUFprAe86oE4Pd1dYHVo=@vger.kernel.org X-Gm-Message-State: AOJu0YxSUHzpsRU/6QHEiJMSfE947INBLws/FNE4DKIGrLm2/B51vBuH VXaRsrpiidu2+sJDC1VNF8zdaluLjxZ82NFu+V/QblEzDxO/pIdw848/Cp99VIw= X-Google-Smtp-Source: AGHT+IFQitaQvnvCpjPNTAPjRJikCJXH/36A9a4AKWk86qEm3fbIuRU18rHtQaOlozEwQjJKTxS63g== X-Received: by 2002:a17:906:d542:b0:a99:f887:ec1d with SMTP id a640c23a62f3a-aa48354c913mr613773866b.49.1731780189884; Sat, 16 Nov 2024 10:03:09 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:09 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Marek Vasut , Paolo Abeni , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 2/7] can: ifi_canfd: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:31 +0100 Message-ID: <20241116180301.3935879-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The ifi_canfd_handle_lec_err() function was incorrectly incrementing only the receive error counter, even in cases of bit or acknowledgment errors that occur during transmission. The patch fixes the issue by incrementing the appropriate counter based on the type of error. Fixes: 5bbd655a8bd0 ("can: ifi: Add more detailed error reporting") Signed-off-by: Dario Binacchi --- drivers/net/can/ifi_canfd/ifi_canfd.c | 29 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c index d32b10900d2f..3944821303fc 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -390,7 +390,6 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev) return 0; priv->can.can_stats.bus_error++; - stats->rx_errors++; /* Propagate the error condition to the CAN stack. */ skb = alloc_can_err_skb(ndev, &cf); @@ -400,26 +399,40 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev) /* Read the error counter register and check for new errors. */ cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) { cf->data[2] |= CAN_ERR_PROT_OVERLOAD; + stats->rx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) { cf->data[3] = CAN_ERR_PROT_LOC_ACK; + stats->tx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_BIT0; + stats->tx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_BIT1; + stats->tx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_STUFF; + stats->rx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) { cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + stats->rx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_FORM; + stats->rx_errors++; + } /* Reset the error counter, ack the IRQ and re-enable the counter. */ writel(IFI_CANFD_ERROR_CTR_ER_RESET, priv->base + IFI_CANFD_ERROR_CTR); From patchwork Sat Nov 16 18:02:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13877679 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 2024219CC2D for ; Sat, 16 Nov 2024 18:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780195; cv=none; b=Ai2KMmhs5yMxM46Uo6zf1p5yVcUAcJ9/AgXTa0Kwf8PWIUe51iKMmZmopijUTPjyVIQVCZXB+lmHQaDd2MlpxZljLoaiwc4SsowoT73/MRc35gnf+dVgG+9RKMwfg7EnBWxM826b2bclDKXTHxYAJwiGI7YXZLOX5m+EbYlDvKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780195; c=relaxed/simple; bh=iVOkbe1eRnWeGsTAkh+kyxSnjEZFWE6KQVh2hr3CkMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sCtU8RmJzQ8VxBmVDLciNIcKbsgJQd3GmE6Jnev+QY/OfpIjBQz+vwn0Q6tu3H439XPPAxzXgn6fsPkEfUfxW+60C1izKZkxrkyToyLXWnBSuoTCPwFb8ILsdo4XEdAD0IgshUtPNLlHEPI4lySjhQYXbISUgpI+vbL5KBE2mkQ= 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=KC447fUs; arc=none smtp.client-ip=209.85.218.44 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="KC447fUs" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-aa4833e9c44so242675166b.2 for ; Sat, 16 Nov 2024 10:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780192; x=1732384992; 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=u1KN5qU2y25n0Oin8u2W01ajVRL3l5JZUYgBLtna1CA=; b=KC447fUsL8LwnpmfucdTwo0WlrEG83Da74tIB5BsC7E8xWn47ZcNLNSUbsGSztvXdU zsX07uTScA+wf3aZ7U2hOhW1k+StezN0wcUHaHR9JCpEIWtrHhTkrybJszUDRj9Qf8x+ y2YULSNNzJphGose2I52z8dYmXnv6EHq5pUJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780192; x=1732384992; 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=u1KN5qU2y25n0Oin8u2W01ajVRL3l5JZUYgBLtna1CA=; b=i1ZxXixHELOKylc+UjfEznPn1ces5jGyK2JR1mZ5fIF+J9BgCCsQgA0nv9aZ0ZD80v fMfc+Bo9dK0RiQlukGST9/tzNPnwdaMfq0z+EbAsfmZIVR1OuTREH5SrdXOSfFa+EpRB QBG+S0RozCw23UAMdxEhe0iV1Ftg39OS7VhTEHUsE/nRaO+Tnt3uL0kxp9yaUzReRjCy /B1PFUVn1I9U0OPMFXXDAAzzIvCW85FYJ/b/07ReL7ugGaD11yfxyGVa8RFCz7lBi82i gwDJMCvVvXcTnV8ZVgJl/jv9qgpdkqz32arhdin4Vw+1J9RB9FhfGjrpljD1k0XZnSYt Zj4w== X-Forwarded-Encrypted: i=1; AJvYcCXtAnntWCF0EJJcPaSqUVZqftg36nm28qiUC8ThulwlkBezVHzV9IvJbRwNOqqAgrhaPoZkcnA=@vger.kernel.org X-Gm-Message-State: AOJu0YzSfKysXaRllJFkzHtIaTliEivFmDwx5cPPya1AOj/pOCyGKYnP Mw6XeorZ4G26O/F6f8hjN2PmHFSGxMh3D/imawQz4LxMoXgUdUIHENNoByLVDp4= X-Google-Smtp-Source: AGHT+IES+ynBAJVqc7eTqNBNioplQ+TxFxR95t5P1e/kKOcra0XnT3EiiSNrB4CCUflAKPlc0RxwSg== X-Received: by 2002:a17:907:3689:b0:a9e:8612:eeca with SMTP id a640c23a62f3a-aa48352b54bmr627153166b.48.1731780192655; Sat, 16 Nov 2024 10:03:12 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:11 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Akshay Bhat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Krzysztof Kozlowski , Marc Kleine-Budde , Paolo Abeni , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 3/7] can: hi311x: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:32 +0100 Message-ID: <20241116180301.3935879-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The hi3110_can_ist() function was incorrectly incrementing only the receive error counter, even in cases of bit or acknowledgment errors that occur during transmission. The patch fixes the issue by incrementing the appropriate counter based on the type of error. Fixes: 57e83fb9b746 ("can: hi311x: Add Holt HI-311x CAN driver") Signed-off-by: Dario Binacchi --- drivers/net/can/spi/hi311x.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c index 148d974ebb21..7a4d98037cd3 100644 --- a/drivers/net/can/spi/hi311x.c +++ b/drivers/net/can/spi/hi311x.c @@ -701,17 +701,22 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; priv->can.can_stats.bus_error++; - priv->net->stats.rx_errors++; - if (eflag & HI3110_ERR_BITERR) + if (eflag & HI3110_ERR_BITERR) { cf->data[2] |= CAN_ERR_PROT_BIT; - else if (eflag & HI3110_ERR_FRMERR) + priv->net->stats.tx_errors++; + } else if (eflag & HI3110_ERR_FRMERR) { cf->data[2] |= CAN_ERR_PROT_FORM; - else if (eflag & HI3110_ERR_STUFERR) + priv->net->stats.rx_errors++; + } else if (eflag & HI3110_ERR_STUFERR) { cf->data[2] |= CAN_ERR_PROT_STUFF; - else if (eflag & HI3110_ERR_CRCERR) + priv->net->stats.rx_errors++; + } else if (eflag & HI3110_ERR_CRCERR) { cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; - else if (eflag & HI3110_ERR_ACKERR) + priv->net->stats.rx_errors++; + } else if (eflag & HI3110_ERR_ACKERR) { cf->data[3] |= CAN_ERR_PROT_LOC_ACK; + priv->net->stats.tx_errors++; + } cf->data[6] = hi3110_read(spi, HI3110_READ_TEC); cf->data[7] = hi3110_read(spi, HI3110_READ_REC); From patchwork Sat Nov 16 18:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13877680 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 B9FD71917F1 for ; Sat, 16 Nov 2024 18:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780199; cv=none; b=IK6XyhHyAwOkyM8F2OnVXkpWDZN0u7ebc5eJZhfN86kwAfBg46pUChT0xJk/NxoItfHL5ACRamW1qeYO1BWkQlvnhFdd4c2pdo2YIgjUEibAh3BPQ70oECXmDUnFADDRsp5idRKL6KOT87f7DWs2marec3/gPsasJPpOsDdqXPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780199; c=relaxed/simple; bh=b+NraIsUClYsl+LKVbalvzNKBzSiT/wtutwKCT3G2ao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PJt5Yd0CEDyk1lsx0+KlGBI6Yst5zuTOkxGBx/YpUkr9LZ6RFihOKotWnHuG5AiT2r5uS1AWuNIjr5Qt4oUnukTo92Saosfar/IJYJi889rgf0/2Pvhn08ov4l/I96XCctPSutwsQgkb6jnE55NkmmlTgux8H+wWEIeLFWp6gas= 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=asoGproX; arc=none smtp.client-ip=209.85.218.51 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="asoGproX" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a9acafdb745so558234066b.0 for ; Sat, 16 Nov 2024 10:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780195; x=1732384995; 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=IPi0av2xe0jC0J5HdvNkCxIcsg4iO3imVdR2/hegefY=; b=asoGproXuz1ZNgmEjSgCPF6L9Vv8f07KkLdTa0sETtE3Xsy1+7ZCsAMGhxDV6/VdJj WZg/Vq6znz40fyTgL24alMigYmclmtdnurp9jvan3a3yxsO+B6GMGD9dpCF8kjqeLITW yR7Le4s+AX/pKt5G0XvK0X3VmmrXGCxP01pHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780195; x=1732384995; 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=IPi0av2xe0jC0J5HdvNkCxIcsg4iO3imVdR2/hegefY=; b=L394b6YKTLlGlxygnDQYWEVF1MsIB0qE+wwjhIWT2w334Ph+/oHWg52ysw3707x4eY VsmCDLm2FHsDcs+34q9eDzrmZNGEq1dBI1oHCDAaM37oGM0az8WkyFkhokZtRwyUfwF0 IdvwsbmGItY39u/oYkVaoQiJwJoTSkZsvEaSWOtD2sVvTXdcAVxWH8N6DVDKAIEylBRB tFErXte1uNWVJ4u8bMshMHY6E97v72yxHiz/Loz84T2eBBdgmAi6jn97ke53RDOqkBhj ejYiDdWuFxOk91kshFmNjNhiVmDSl00Jiu46LTPHPhkWjthCZslFZV8VQ2hVJ6kE9NcR 6lGw== X-Forwarded-Encrypted: i=1; AJvYcCWg6UFRI5+JkiOSw9k8qIETh4BjfQDEemItm50/4v4PT74W5oTTEBmCPpMNJxFjcP3JnlAcIEQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxyzRYX0Fo2l5Nc9v+l+6TiVLnXEMJwm84kOepR0RN5vp6BDXAU qDxEC8c6B7OFkjatokEKKn6LmCfgVOv46+nKwYJozcagah05q7LhLh/dtisYdkc= X-Google-Smtp-Source: AGHT+IGiCGpsd+G1WFq5UxLc4I4k8txDJ+JeMk91+wJgoZFiUor+BpmbVpSQLk7uJcDP3qphPmkBiw== X-Received: by 2002:a17:907:9813:b0:a9e:c266:4e82 with SMTP id a640c23a62f3a-aa48185c694mr772769266b.6.1731780195092; Sat, 16 Nov 2024 10:03:15 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:14 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Paolo Abeni , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 4/7] can: sja1000: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:33 +0100 Message-ID: <20241116180301.3935879-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The sja1000_err() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 429da1cc841b ("can: Driver for the SJA1000 CAN controller") Signed-off-by: Dario Binacchi --- drivers/net/can/sja1000/sja1000.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index ddb3247948ad..706ee8f6b7db 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c @@ -460,7 +460,6 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) if (isrc & IRQ_BEI) { /* bus error interrupt */ priv->can.can_stats.bus_error++; - stats->rx_errors++; ecc = priv->read_reg(priv, SJA1000_ECC); @@ -485,8 +484,12 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) cf->data[3] = ecc & ECC_SEG; /* Error occurred during transmission? */ - if ((ecc & ECC_DIR) == 0) + if ((ecc & ECC_DIR) == 0) { cf->data[2] |= CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } } if (isrc & IRQ_EPI) { /* error passive interrupt */ From patchwork Sat Nov 16 18:02:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13877681 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.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 61F8F1B2181 for ; Sat, 16 Nov 2024 18:03:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780200; cv=none; b=BSMPS9pKb0txGu1eZia8DKdAB8Ov4dGM3Ket5/xQKzSRkGS+d2fsMgRlNwus1HInuRYqBJ7FWJxLvUNvJmgDghndNRFxRO32gEVg3BQ91OeEjjaetCY1+hszpFRZhTo1H2oKQWip1ARoWEexjUU6jB8imCaGlHux7j1os9waMd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780200; c=relaxed/simple; bh=0jjERzUdBGaOyD8hozmGujUsFYfwS4ojvocwRF0u2o4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oGtXIj+ob325VYnM8/YIxdvEZc89czMNn2pOA90lnCtNmxhAWHSAPjF3UWYxM90JjfW444SDauuJPlCOu/33e4sDykpzujgN3QY+CifzMSe1ZMHD2+nlemCr2gDmGdkM3NeXbU5kvIxfxBqoMDQmsC3zCOxrKyyDG9kgY407m9A= 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=ZP6OPMMs; arc=none smtp.client-ip=209.85.218.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="ZP6OPMMs" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a99eb8b607aso370355566b.2 for ; Sat, 16 Nov 2024 10:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780197; x=1732384997; 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=ZZp2LLELhHXaHE6P8yqyIkdBBd7fnVylmpcd4GsYhTg=; b=ZP6OPMMsPSoEV5qC2gEQ7Vdexb32aL/+XTdBRD+FQe+DqscjXa8xQNi7wKBD+mmPXN +BQHugUbzoNseK5FjndAgnnwzOLTNsLDOPwgW3Zy/vZx0Lp0Cs9lg6Ampx5a/6DQ7UED fDNDmlNRNpGTU7m8OSzldHPIagdwe+gfDwr98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780197; x=1732384997; 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=ZZp2LLELhHXaHE6P8yqyIkdBBd7fnVylmpcd4GsYhTg=; b=hD1JOPSUXmNpjY7NYn5A3uQEZIYWbJ9XaJP7BnV9mT1UpVdzz1kuPpnOVl22gdrsvo JiphV1CQYTcWV8t+FoR9naSAyBcSvGuWJXhqqPuSCLzdw7vmtzIt6/l0+xxO2k2+kaGR b3TZ3gt8hI8wrYK1qldJTFx3W7cyuEOCYmytnhuvvcWk4xnNA+l0bqMRaocShdegZERA 1+H+gCiiMSZhLbNrLSpu6ffCGHdGXmFITMJ89VfIZWdO8Fd4ME2IgpAXpjQmZ0juOUwn Ak4f6imeJw321sH3BTx1VsjnVfC4LHzys1BbqswHlkoF8NLhc2FXnLYx3AN9ymBfNPOM FHEA== X-Forwarded-Encrypted: i=1; AJvYcCVd1YvhVBMQoUAcYE+7DhDG9WDdTN6JZhGrIlF+1hIU8FbwpDkE68OrNJScgyFSPo+TqD+Ux+4=@vger.kernel.org X-Gm-Message-State: AOJu0YyNMq9AywJIpg6KRQqpt68zJgZbh6DTyXiFRnphlS4pVTW/lZiT shMEuH5xrrWPKZRfACuERnXyWSaih+fRS/mce95YrvzUMwO0GUnzyY/DNPJDSPs= X-Google-Smtp-Source: AGHT+IHco/HhB19U8GRhXEYmlvtasr6hZ6h72SXfmIX9BAE4Ibve8haYdY+6mq7whoM3rHFNs0pSVA== X-Received: by 2002:a17:907:d24:b0:a9a:bbcd:e63 with SMTP id a640c23a62f3a-aa483421c58mr612801466b.14.1731780196892; Sat, 16 Nov 2024 10:03:16 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:16 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , Chen-Yu Tsai , "David S. Miller" , Eric Dumazet , Gerhard Bertelsmann , Jakub Kicinski , Jernej Skrabec , Marc Kleine-Budde , Maxime Ripard , Paolo Abeni , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev, netdev@vger.kernel.org Subject: [PATCH 5/7] can: sun4i_can: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:34 +0100 Message-ID: <20241116180301.3935879-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The sun4i_can_err() function only incremented the receive error counter and never the transmit error counter, even if the STA_ERR_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the STA_ERR_DIR flag. Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module") Signed-off-by: Dario Binacchi --- drivers/net/can/sun4i_can.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 360158c295d3..40939141749d 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -579,7 +579,6 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) /* bus error interrupt */ netdev_dbg(dev, "bus error interrupt\n"); priv->can.can_stats.bus_error++; - stats->rx_errors++; if (likely(skb)) { ecc = readl(priv->base + SUN4I_REG_STA_ADDR); @@ -602,8 +601,12 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) break; } /* error occurred during transmission? */ - if ((ecc & SUN4I_STA_ERR_DIR) == 0) + if ((ecc & SUN4I_STA_ERR_DIR) == 0) { cf->data[2] |= CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } } } if (isrc & SUN4I_INT_ERR_PASSIVE) { From patchwork Sat Nov 16 18:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13877682 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 DB5421B85E3 for ; Sat, 16 Nov 2024 18:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780202; cv=none; b=mAF0hjlLLVpLRIjEGpdoXb0Rer2pKhtS3wGfzBKpuz4WG6JOUJW7dL5NW50E7ZKdgsg/LlJAS257T3IZC62mvXnjLmrRh9MKASKM4a3ngF+H+l6Uugc3qC4LMlIlJQgKeH2MuyOlFcYt4HfG5zrR922QpB/BA3NstgSyQFb3nAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780202; c=relaxed/simple; bh=nrpSX80iZEgD1tyuub9lydq0DIRCuLzTN3EI9VOm5RQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BVFQKCCVtNcKzuuu/cWCIUSunz5TZQsdQY+GGj0h+j8TGWSoSPvs6KyZsZur7ttpyszWr3DhhqWBkfCvKBJ2ffGv7R0EBa1EEkkBM4j1gmApL3CvVh9HXWeYPVgLwrD+PJ17XntySYWA0Eamhby47ptN75J5NaeC3DQZH2KgJsc= 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=M/o9Or9q; arc=none smtp.client-ip=209.85.221.51 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="M/o9Or9q" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-37d495d217bso703957f8f.0 for ; Sat, 16 Nov 2024 10:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780199; x=1732384999; 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=qzqc0qf43o4g73YzOl/3Mk2ZcRlSoSU0wYKvIRYgWeY=; b=M/o9Or9qDKQO6Miry9Q2iBYlM2DRWw4iWxL35GLPW+3oyJe99RrGwrcCcPLoO1XQtd 8SumikWdm0I/2B1NJc+EQODXwn9UC3hbItUiDFsnjNMrMKFPlKHbT+dVgNcsQg7ytnPF dgudLLpLriV8soznxDZ9UYOUlg43oMldjBi2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780199; x=1732384999; 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=qzqc0qf43o4g73YzOl/3Mk2ZcRlSoSU0wYKvIRYgWeY=; b=s4dXNNSbyEMxRuzSWezM3IWGQMzwFQzJOg0kr9iFhXM8Q2LIrAkEmiIaR2pI+dYyMO Gahegp9koQTJcEeSXOdkIU3QqouNrNJ95JLntZfKI1+pmRiDJzY75Mv/XxptE/5/9LZa ygflNNT62OkSl018z7c7/QovN34XTNdQzovcQ2U+MMnFmV2kyoLrlQvJ3PghL80UW/SO NgDrA7xuXSTipU3hTk+F0s3PJ9UcjsYS5Y6jJDu6MvV1KNq4EFvNao3iSbsYQl+FZdnw MF4Fj3SbVbEkmN+nJ5PHNcnu8hy1EC5gY7qu5JPkfO7ED1JXjt53Oj0d3cQCqv15BZQN UDXw== X-Forwarded-Encrypted: i=1; AJvYcCWfd3CGaFQtkvscgJybZuwhHM1pa/fM7VaxzfQtbq5bUqEZe6LdOMjMsqeVMhpW+4+vM/1i7to=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/hozG6RBGFUgzW+WwkwB36aDl2qbuMm3jEiRjhSzsZtgHU3Io lnKmjAOJVctLhPSlXAGXSp+5Wf5hNJO90ookiJfEjBIQJFjqjPDx2ZGtVzMTT/A= X-Google-Smtp-Source: AGHT+IGkyP3qGN+tINbIZ4XNnyhPqXqEDpgjVb/byBCp6YrVMvdl+zOjNIxpY2yrRpZDbbYKagylow== X-Received: by 2002:a05:6000:4213:b0:37d:5042:c8de with SMTP id ffacd0b85a97d-38225a45297mr6503959f8f.22.1731780199189; Sat, 16 Nov 2024 10:03:19 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:18 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Sebastian Haas , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 6/7] can: ems_usb: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:35 +0100 Message-ID: <20241116180301.3935879-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The ems_usb_rx_err() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB interface") Signed-off-by: Dario Binacchi --- drivers/net/can/usb/ems_usb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 050c0b49938a..98a70a2fe189 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -361,7 +361,6 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg) /* bus error interrupt */ dev->can.can_stats.bus_error++; - stats->rx_errors++; cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; @@ -381,8 +380,12 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg) } /* Error occurred during transmission? */ - if ((ecc & SJA1000_ECC_DIR) == 0) + if ((ecc & SJA1000_ECC_DIR) == 0) { cf->data[2] |= CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } if (dev->can.state == CAN_STATE_ERROR_WARNING || dev->can.state == CAN_STATE_ERROR_PASSIVE) { From patchwork Sat Nov 16 18:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13877683 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 4E4EB1917FD for ; Sat, 16 Nov 2024 18:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780203; cv=none; b=N3SneKnyq5J70jnx698bOLrq8Wo6qXsEkER7LOC1TJhPICthqDckQdiA31TvfkCs2j/SI6sX5l13UR5EyV9c/+boLnyvmg1UcchMNG/wIdDalqpAwDeMFnT1cm/iEZwG77Ur5GrQ27SDNRX4eoAwhufPvsEUVZPiOCLuU4VyZdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780203; c=relaxed/simple; bh=x191pU5csUjNf+5eLZ0Nmib7//JKYxHIAn9GWqpsWYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iWTS+w71itOD/bGXKX41SaiqECgQRPxKzCUiK6oKnQmxUQXbmINRmsLUb5inM2DiwU5+OUgN/+4uWxdgrrDXz0H4tqyfKKTV5r119SrjRf4unFnJvkS8+XKJ8azk+3HqaAz3TH8M1+A9Xst+Z0ltJU8K8Bidiwhy+Etn8W1LfuU= 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=N+rTDxhl; arc=none smtp.client-ip=209.85.218.41 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="N+rTDxhl" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a9f1c590ecdso313811966b.1 for ; Sat, 16 Nov 2024 10:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780201; x=1732385001; 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=2C7d9rxCEuHbUF9PXUs12JGZsS1zAdEa4j4i3gKpHM4=; b=N+rTDxhlx1q4v15tAgZKM0KDGpBxYrwrgaFir8eweP96Afo3FpVUhddFdnqylXfM1w OLg7xk4w911T5x3IBX/9uUxizVUmvpjS7z9+0BjaIapAYh8EDgQ8ni2Fv8evL+qn6C61 SFvoCbarlWTAvvqzw1lgHmhnNgLWn2TY7jakQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780201; x=1732385001; 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=2C7d9rxCEuHbUF9PXUs12JGZsS1zAdEa4j4i3gKpHM4=; b=mi+WwUIIePkAINDwF85fX5ZS2tbfre1G57yV9CQtmCR3yJSV91ELp8hiuOyKOesFgL YK48dRxVIEyCfuL+UVC6EOCzjsSBXLfQItD9Va7sh9r6pUQAzN5unqyP2CIeH0yeYwwC A+CT7aSaWKXFQmFMe6OvXhHWSZuqcpwCRZT7ZwqZBUDXVhOicEUZGgOjXV6xaLl7ie0Z pWcyCcCbW9r2iwnPNlj61bLpD44LccYKbnSKIFpmcY6iS0C3NSRtkGht2BgrWZP3vEVo QA3BN1WHMNMvzQOyrR++aOfNwRibVU9HpRpoYFmzRfVxzVk1J2bMzzICeu22wUN9ewjC trzg== X-Forwarded-Encrypted: i=1; AJvYcCUmGFJkFTSILmyrsyt2X1pJNhxIk+GZOyJx9c41IB6dg4o1Dk1q7vFlwDvWoDCpSecroy2qmOY=@vger.kernel.org X-Gm-Message-State: AOJu0YxDs/KS3sHT9i4moAv5qUUwYWpU2j48aLEj1jZAHsEMRZtDyjnL edyqDRkEUfbjBctBSp6rUHSO/u88dQrFfm84GxdDcqGftjUgp3saNi4MJ+9eNKg= X-Google-Smtp-Source: AGHT+IHL/EwOUuvDKou6kklzDzL1Ir/aKMiYpZiijN1w+hmbgwaSQwKLBVtSh5AFMY3NeE8czlFetQ== X-Received: by 2002:a17:906:5ad2:b0:a9f:508:592a with SMTP id a640c23a62f3a-aa4a28a3bd6mr104955266b.46.1731780200732; Sat, 16 Nov 2024 10:03:20 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:20 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Ji-Ze Hong (Peter Hong)" , Marc Kleine-Budde , Paolo Abeni , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 7/7] can: f81604: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:36 +0100 Message-ID: <20241116180301.3935879-8-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The f81604_handle_can_bus_errors() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 88da17436973 ("can: usb: f81604: add Fintek F81604 support") Signed-off-by: Dario Binacchi --- drivers/net/can/usb/f81604.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/f81604.c b/drivers/net/can/usb/f81604.c index bc0c8903fe77..8463e00517c9 100644 --- a/drivers/net/can/usb/f81604.c +++ b/drivers/net/can/usb/f81604.c @@ -526,7 +526,6 @@ static void f81604_handle_can_bus_errors(struct f81604_port_priv *priv, netdev_dbg(netdev, "bus error interrupt\n"); priv->can.can_stats.bus_error++; - stats->rx_errors++; if (skb) { cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; @@ -550,8 +549,12 @@ static void f81604_handle_can_bus_errors(struct f81604_port_priv *priv, cf->data[3] = data->ecc & F81604_SJA1000_ECC_SEG; /* Error occurred during transmission? */ - if ((data->ecc & F81604_SJA1000_ECC_DIR) == 0) + if ((data->ecc & F81604_SJA1000_ECC_DIR) == 0) { cf->data[2] |= CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } } set_bit(F81604_CLEAR_ECC, &priv->clear_flags);