aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIra W. Snyder <iws@ovro.caltech.edu>2012-07-19 11:54:18 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2012-07-20 11:49:03 -0400
commit88b587039c1ad4e7a981bea3269eeb02a1a2a14b (patch)
tree54a97a0157e7f8330c8625f5527ffcb11bfcae64
parent9e4d6909a273ada78cf48379e478855bc13ae0cb (diff)
can: janz-ican3: fix error and byte counters
The error and byte counter statistics were being incremented incorrectly. For example, a TX error would be counted both in tx_errors and rx_errors. This corrects the problem so that tx_errors and rx_errors are only incremented for errors caused by packets sent to the bus. Error packets generated by the driver are not counted. The byte counters are only increased for packets which are actually transmitted or received from the bus. Error packets generated by the driver are not counted. Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--drivers/net/can/janz-ican3.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index b19aca591c7a..4a5a8fb53a2f 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -907,8 +907,8 @@ static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg)
907 if (skb) { 907 if (skb) {
908 cf->can_id |= CAN_ERR_CRTL; 908 cf->can_id |= CAN_ERR_CRTL;
909 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; 909 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
910 stats->rx_over_errors++;
910 stats->rx_errors++; 911 stats->rx_errors++;
911 stats->rx_bytes += cf->can_dlc;
912 netif_rx(skb); 912 netif_rx(skb);
913 } 913 }
914} 914}
@@ -982,7 +982,6 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
982 982
983 dev_dbg(mod->dev, "bus error interrupt\n"); 983 dev_dbg(mod->dev, "bus error interrupt\n");
984 mod->can.can_stats.bus_error++; 984 mod->can.can_stats.bus_error++;
985 stats->rx_errors++;
986 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; 985 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
987 986
988 switch (ecc & ECC_MASK) { 987 switch (ecc & ECC_MASK) {
@@ -1001,8 +1000,12 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
1001 break; 1000 break;
1002 } 1001 }
1003 1002
1004 if ((ecc & ECC_DIR) == 0) 1003 if (!(ecc & ECC_DIR)) {
1005 cf->data[2] |= CAN_ERR_PROT_TX; 1004 cf->data[2] |= CAN_ERR_PROT_TX;
1005 stats->tx_errors++;
1006 } else {
1007 stats->rx_errors++;
1008 }
1006 1009
1007 cf->data[6] = txerr; 1010 cf->data[6] = txerr;
1008 cf->data[7] = rxerr; 1011 cf->data[7] = rxerr;
@@ -1028,8 +1031,6 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
1028 } 1031 }
1029 1032
1030 mod->can.state = state; 1033 mod->can.state = state;
1031 stats->rx_errors++;
1032 stats->rx_bytes += cf->can_dlc;
1033 netif_rx(skb); 1034 netif_rx(skb);
1034 return 0; 1035 return 0;
1035} 1036}