Skip to content

Commit 4d6d265

Browse files
passgatmarckleinebudde
authored andcommitted
can: c_can: fix {rx,tx}_errors statistics
The c_can_handle_bus_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: 881ff67 ("can: c_can: Added support for Bosch C_CAN controller") Signed-off-by: Dario Binacchi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent e4de81f commit 4d6d265

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/net/can/c_can/c_can_main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,6 @@ static int c_can_handle_bus_err(struct net_device *dev,
10111011

10121012
/* common for all type of bus errors */
10131013
priv->can.can_stats.bus_error++;
1014-
stats->rx_errors++;
10151014

10161015
/* propagate the error condition to the CAN stack */
10171016
skb = alloc_can_err_skb(dev, &cf);
@@ -1027,26 +1026,32 @@ static int c_can_handle_bus_err(struct net_device *dev,
10271026
case LEC_STUFF_ERROR:
10281027
netdev_dbg(dev, "stuff error\n");
10291028
cf->data[2] |= CAN_ERR_PROT_STUFF;
1029+
stats->rx_errors++;
10301030
break;
10311031
case LEC_FORM_ERROR:
10321032
netdev_dbg(dev, "form error\n");
10331033
cf->data[2] |= CAN_ERR_PROT_FORM;
1034+
stats->rx_errors++;
10341035
break;
10351036
case LEC_ACK_ERROR:
10361037
netdev_dbg(dev, "ack error\n");
10371038
cf->data[3] = CAN_ERR_PROT_LOC_ACK;
1039+
stats->tx_errors++;
10381040
break;
10391041
case LEC_BIT1_ERROR:
10401042
netdev_dbg(dev, "bit1 error\n");
10411043
cf->data[2] |= CAN_ERR_PROT_BIT1;
1044+
stats->tx_errors++;
10421045
break;
10431046
case LEC_BIT0_ERROR:
10441047
netdev_dbg(dev, "bit0 error\n");
10451048
cf->data[2] |= CAN_ERR_PROT_BIT0;
1049+
stats->tx_errors++;
10461050
break;
10471051
case LEC_CRC_ERROR:
10481052
netdev_dbg(dev, "CRC error\n");
10491053
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
1054+
stats->rx_errors++;
10501055
break;
10511056
default:
10521057
break;

0 commit comments

Comments
 (0)