drivers: net: xgene: Refactor statistics error parsing code
authorQuan Nguyen <qnguyen@apm.com>
Wed, 10 May 2017 20:45:03 +0000 (13:45 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 May 2017 15:41:09 +0000 (11:41 -0400)
This patch fixes the tx error counters and adds more rx error counters.

Signed-off-by: Quan Nguyen <qnguyen@apm.com>
Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
drivers/net/ethernet/apm/xgene/xgene_enet_main.h

index 47c5b754068dfe68527255b56cebb959b79723c5..02df5776e94283277a3ab8bedddc5693bf256f5a 100644 (file)
@@ -205,30 +205,24 @@ static u32 xgene_enet_ring_len(struct xgene_enet_desc_ring *ring)
 }
 
 void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
-                           struct xgene_enet_pdata *pdata,
                            enum xgene_enet_err_code status)
 {
        switch (status) {
        case INGRESS_CRC:
                ring->rx_crc_errors++;
-               ring->rx_dropped++;
                break;
        case INGRESS_CHECKSUM:
        case INGRESS_CHECKSUM_COMPUTE:
                ring->rx_errors++;
-               ring->rx_dropped++;
                break;
        case INGRESS_TRUNC_FRAME:
                ring->rx_frame_errors++;
-               ring->rx_dropped++;
                break;
        case INGRESS_PKT_LEN:
                ring->rx_length_errors++;
-               ring->rx_dropped++;
                break;
        case INGRESS_PKT_UNDER:
                ring->rx_frame_errors++;
-               ring->rx_dropped++;
                break;
        case INGRESS_FIFO_OVERRUN:
                ring->rx_fifo_errors++;
index 057f9515c2a814722e6010d3007d2a27d46dc753..3ce349f96c8d28518b8d05cd2adc6e2c95099676 100644 (file)
@@ -380,9 +380,7 @@ static inline u16 xgene_enet_get_numslots(u16 id, u32 size)
 }
 
 void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
-                           struct xgene_enet_pdata *pdata,
                            enum xgene_enet_err_code status);
-
 int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata);
 void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata);
 bool xgene_ring_mgr_init(struct xgene_enet_pdata *p);
index e4f2ef2d750beb04a2cbfe66bd062c313a264555..3f24b83a6c554ccba5d6eccaea466688939b5054 100644 (file)
@@ -246,9 +246,9 @@ static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring,
        skb_frag_t *frag;
        dma_addr_t *frag_dma_addr;
        u16 skb_index;
-       u8 status;
-       int i, ret = 0;
        u8 mss_index;
+       u8 status;
+       int i;
 
        skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
        skb = cp_ring->cp_skb[skb_index];
@@ -275,19 +275,17 @@ static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring,
        /* Checking for error */
        status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0));
        if (unlikely(status > 2)) {
-               xgene_enet_parse_error(cp_ring, netdev_priv(cp_ring->ndev),
-                                      status);
-               ret = -EIO;
+               cp_ring->tx_dropped++;
+               cp_ring->tx_errors++;
        }
 
        if (likely(skb)) {
                dev_kfree_skb_any(skb);
        } else {
                netdev_err(cp_ring->ndev, "completion skb is NULL\n");
-               ret = -EIO;
        }
 
-       return ret;
+       return 0;
 }
 
 static int xgene_enet_setup_mss(struct net_device *ndev, u32 mss)
@@ -711,7 +709,8 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
                if (!xgene_enet_errata_10GE_8(skb, datalen, status)) {
                        dev_kfree_skb_any(skb);
                        xgene_enet_free_pagepool(page_pool, raw_desc, exp_desc);
-                       xgene_enet_parse_error(rx_ring, pdata, status);
+                       xgene_enet_parse_error(rx_ring, status);
+                       rx_ring->rx_dropped++;
                        goto out;
                }
        }
@@ -1477,6 +1476,8 @@ static void xgene_enet_get_stats64(
                if (ring) {
                        stats->tx_packets += ring->tx_packets;
                        stats->tx_bytes += ring->tx_bytes;
+                       stats->tx_dropped += ring->tx_dropped;
+                       stats->tx_errors += ring->tx_errors;
                }
        }
 
@@ -1485,11 +1486,16 @@ static void xgene_enet_get_stats64(
                if (ring) {
                        stats->rx_packets += ring->rx_packets;
                        stats->rx_bytes += ring->rx_bytes;
-                       stats->rx_errors += ring->rx_length_errors +
+                       stats->rx_dropped += ring->rx_dropped;
+                       stats->rx_errors += ring->rx_errors +
+                               ring->rx_length_errors +
                                ring->rx_crc_errors +
                                ring->rx_frame_errors +
                                ring->rx_fifo_errors;
-                       stats->rx_dropped += ring->rx_dropped;
+                       stats->rx_length_errors += ring->rx_length_errors;
+                       stats->rx_crc_errors += ring->rx_crc_errors;
+                       stats->rx_frame_errors += ring->rx_frame_errors;
+                       stats->rx_fifo_errors += ring->rx_fifo_errors;
                }
        }
 }
index 5e6fd718b685798632aa27184e222735c442ee7a..3bf66385dbdf294a712f24edfd050c62f03ac947 100644 (file)
@@ -138,6 +138,8 @@ struct xgene_enet_desc_ring {
        __le64 *exp_bufs;
        u64 tx_packets;
        u64 tx_bytes;
+       u64 tx_dropped;
+       u64 tx_errors;
        u64 rx_packets;
        u64 rx_bytes;
        u64 rx_dropped;