[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241116180301.3935879-2-dario.binacchi@amarulasolutions.com>
Date: Sat, 16 Nov 2024 19:02:30 +0100
From: Dario Binacchi <dario.binacchi@...rulasolutions.com>
To: linux-kernel@...r.kernel.org
Cc: linux-amarula@...rulasolutions.com,
Dario Binacchi <dario.binacchi@...rulasolutions.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
Chandrasekar Ramakrishnan <rcsekar@...sung.com>,
"David S. Miller" <davem@...emloft.net>,
Dong Aisheng <b29396@...escale.com>,
Eric Dumazet <edumazet@...gle.com>,
Fengguang Wu <fengguang.wu@...el.com>,
Jakub Kicinski <kuba@...nel.org>,
Marc Kleine-Budde <mkl@...gutronix.de>,
Paolo Abeni <pabeni@...hat.com>,
Varka Bhadram <varkabhadram@...il.com>,
Vincent Mailhol <mailhol.vincent@...adoo.fr>,
linux-can@...r.kernel.org,
netdev@...r.kernel.org
Subject: [PATCH 1/7] can: m_can: fix {rx,tx}_errors statistics
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 <dario.binacchi@...rulasolutions.com>
---
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;
--
2.43.0
Powered by blists - more mailing lists