net: bcmgenet: log RX buffer allocation and RX/TX dma failures
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 19 Nov 2014 18:29:56 +0000 (10:29 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Nov 2014 19:46:12 +0000 (14:46 -0500)
To help troubleshoot heavy memory pressure conditions, add a bunch of
statistics counter to log RX buffer allocation and RX/TX DMA mapping
failures. These are reported like any other counters through the ethtool
stats interface.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/genet/bcmgenet.h

index da1a2500c91ce43677e7cada4b66196c17af2513..fcbf1255ae5a919ad5fb052d9bcbb7045534cc9e 100644 (file)
@@ -613,6 +613,9 @@ static const struct bcmgenet_stats bcmgenet_gstrings_stats[] = {
                        UMAC_RBUF_OVFL_CNT),
        STAT_GENET_MISC("rbuf_err_cnt", mib.rbuf_err_cnt, UMAC_RBUF_ERR_CNT),
        STAT_GENET_MISC("mdf_err_cnt", mib.mdf_err_cnt, UMAC_MDF_ERR_CNT),
+       STAT_GENET_MIB_RX("alloc_rx_buff_failed", mib.alloc_rx_buff_failed),
+       STAT_GENET_MIB_RX("rx_dma_failed", mib.rx_dma_failed),
+       STAT_GENET_MIB_TX("tx_dma_failed", mib.tx_dma_failed),
 };
 
 #define BCMGENET_STATS_LEN     ARRAY_SIZE(bcmgenet_gstrings_stats)
@@ -989,6 +992,7 @@ static int bcmgenet_xmit_single(struct net_device *dev,
        mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
        ret = dma_mapping_error(kdev, mapping);
        if (ret) {
+               priv->mib.tx_dma_failed++;
                netif_err(priv, tx_err, dev, "Tx DMA map failed\n");
                dev_kfree_skb(skb);
                return ret;
@@ -1035,6 +1039,7 @@ static int bcmgenet_xmit_frag(struct net_device *dev,
                                   skb_frag_size(frag), DMA_TO_DEVICE);
        ret = dma_mapping_error(kdev, mapping);
        if (ret) {
+               priv->mib.tx_dma_failed++;
                netif_err(priv, tx_err, dev, "%s: Tx DMA map failed\n",
                          __func__);
                return ret;
@@ -1231,6 +1236,7 @@ static int bcmgenet_rx_refill(struct bcmgenet_priv *priv, struct enet_cb *cb)
                                 priv->rx_buf_len, DMA_FROM_DEVICE);
        ret = dma_mapping_error(kdev, mapping);
        if (ret) {
+               priv->mib.rx_dma_failed++;
                bcmgenet_free_cb(cb);
                netif_err(priv, rx_err, priv->dev,
                          "%s DMA map failed\n", __func__);
@@ -1397,8 +1403,10 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_priv *priv,
                /* refill RX path on the current control block */
 refill:
                err = bcmgenet_rx_refill(priv, cb);
-               if (err)
+               if (err) {
+                       priv->mib.alloc_rx_buff_failed++;
                        netif_err(priv, rx_err, dev, "Rx refill failed\n");
+               }
 
                rxpktprocessed++;
                priv->rx_read_ptr++;
index 31b2da5f9b821342315ddebd958a765e7560cd51..c4ca7282a6011c382d08dadc69524e5cf9912ef8 100644 (file)
@@ -143,6 +143,9 @@ struct bcmgenet_mib_counters {
        u32     rbuf_ovflow_cnt;
        u32     rbuf_err_cnt;
        u32     mdf_err_cnt;
+       u32     alloc_rx_buff_failed;
+       u32     rx_dma_failed;
+       u32     tx_dma_failed;
 };
 
 #define UMAC_HD_BKP_CTRL               0x004