From: John Jacques <[email protected]>

Some errors were getting counted multiple times.

Signed-off-by: John Jacques <[email protected]>
---
 drivers/net/ethernet/lsi/lsi_acp_net.c | 75 ++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/lsi/lsi_acp_net.c 
b/drivers/net/ethernet/lsi/lsi_acp_net.c
index 179bc23..4aae097 100644
--- a/drivers/net/ethernet/lsi/lsi_acp_net.c
+++ b/drivers/net/ethernet/lsi/lsi_acp_net.c
@@ -462,6 +462,9 @@ static void clear_statistics(struct appnic_device *pdata)
 static void get_hw_statistics(struct appnic_device *pdata)
 {
        unsigned long flags;
+       u32 rx_under;
+       u32 rx_over;
+       u32 tx_under;
 
        /* stats.tx_packets */
        pdata->stats.tx_packets += read_mac(APPNIC_TX_STAT_PACKET_OK);
@@ -474,14 +477,17 @@ static void get_hw_statistics(struct appnic_device *pdata)
        pdata->stats.collisions +=
                read_mac(APPNIC_TX_STATUS_EXCESSIVE_COLLISION);
        pdata->stats.collisions +=
-       read_mac(APPNIC_TX_STAT_COLLISION_ABOVE_WATERMARK);
+               read_mac(APPNIC_TX_STAT_COLLISION_ABOVE_WATERMARK);
 
        /* stats.rx_length_errors */
-       pdata->stats.rx_length_errors += read_mac(APPNIC_RX_STAT_UNDERSIZE);
-       pdata->stats.rx_length_errors += read_mac(APPNIC_RX_STAT_OVERSIZE);
+       rx_under = read_mac(APPNIC_RX_STAT_UNDERSIZE);
+       pdata->stats.rx_length_errors += rx_under;
+       rx_over = read_mac(APPNIC_RX_STAT_OVERSIZE);
+       pdata->stats.rx_length_errors += rx_over;
 
        /* stats.tx_fifo_errors */
-       pdata->stats.tx_fifo_errors += read_mac(APPNIC_TX_STAT_UNDERRUN);
+       tx_under = read_mac(APPNIC_TX_STAT_UNDERRUN);
+       pdata->stats.tx_fifo_errors += tx_under;
 
        /* Lock this section out so the statistics maintained by the driver
         * don't get clobbered.
@@ -489,21 +495,17 @@ static void get_hw_statistics(struct appnic_device *pdata)
 
        spin_lock_irqsave(&pdata->dev_lock, flags);
 
-       pdata->stats.rx_errors +=
-               (pdata->stats.rx_length_errors +
-                pdata->stats.rx_crc_errors +
-                pdata->stats.rx_frame_errors +
-                pdata->stats.rx_fifo_errors +
-                pdata->stats.rx_dropped +
-                pdata->stats.rx_over_errors);
-
        pdata->stats.rx_dropped = 0;
        pdata->stats.rx_over_errors = 0;
 
-       pdata->stats.tx_errors += (pdata->stats.tx_fifo_errors +
-                                  pdata->stats.tx_aborted_errors);
+       /* Update the cumulative rx_errors. */
+       pdata->stats.rx_errors += (rx_under + rx_over);
+
        pdata->stats.tx_aborted_errors = 0;
 
+       /* Update the cumulative tx_errors. */
+       pdata->stats.tx_errors += tx_under;
+
        spin_unlock_irqrestore(&pdata->dev_lock, flags);
 }
 
@@ -728,31 +730,32 @@ static void lsinet_rx_packet(struct net_device *dev)
                BUG();
                dev_kfree_skb(sk_buff);
 
-       } else {
-               if (0 == error_num) {
-                       struct ethhdr *ethhdr = (struct ethhdr *) sk_buff->data;
-
-                       if (mac_addr_valid(dev, &ethhdr->h_dest[0])) {
-                               pdata->stats.rx_bytes += bytes_copied;
-                               pdata->stats.rx_packets++;
-                               sk_buff->dev = dev;
-                               sk_buff->protocol = eth_type_trans(sk_buff,
-                                                                  dev);
-                               if (netif_receive_skb(sk_buff) == NET_RX_DROP)
-                                       pdata->dropped_by_stack++;
-                       } else {
-                               dev_kfree_skb(sk_buff);
-                       }
+       } else if (0 == error_num) {
+               struct ethhdr *ethhdr = (struct ethhdr *)sk_buff->data;
+
+               if (mac_addr_valid(dev, &ethhdr->h_dest[0])) {
+                       pdata->stats.rx_bytes += bytes_copied;
+                       ++pdata->stats.rx_packets;
+                       sk_buff->dev = dev;
+                       sk_buff->protocol = eth_type_trans(sk_buff, dev);
+
+                       if (netif_receive_skb(sk_buff) == NET_RX_DROP)
+                               ++pdata->dropped_by_stack;
                } else {
                        dev_kfree_skb(sk_buff);
-
-                       if (0 != overflow_stat)
-                               pdata->stats.rx_fifo_errors++;
-                       else if (0 != crc_stat)
-                               pdata->stats.rx_crc_errors++;
-                       else if (0 != align_stat)
-                               pdata->stats.rx_frame_errors++;
                }
+       } else {
+               dev_kfree_skb(sk_buff);
+
+               pdata->stats.rx_errors +=
+                       (overflow_stat + crc_stat + align_stat);
+
+               if (0 != overflow_stat)
+                       pdata->stats.rx_fifo_errors += overflow_stat;
+               else if (0 != crc_stat)
+                       pdata->stats.rx_crc_errors += crc_stat;
+               else if (0 != align_stat)
+                       pdata->stats.rx_frame_errors += align_stat;
        }
 
        return;
-- 
1.9.1

-- 
_______________________________________________
linux-yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to