net: mvneta: discriminate error cause for missed packet
authorGregory CLEMENT <gregory.clement@bootlin.com>
Wed, 18 Jul 2018 16:10:54 +0000 (18:10 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 29 Jul 2018 05:12:55 +0000 (22:12 -0700)
In order to improve the diagnostic in case of error, make the distinction
between refill error and skb allocation error. Also make the information
available through the ethtool state.

Based on the work of Yelena Krivosheev <yelena@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mvneta.c

index e519439bac97d7e0a4848cf848eabd90c45b3635..da2d568262956dad3d14cc55f81cf65c81b343bd 100644 (file)
 
 enum {
        ETHTOOL_STAT_EEE_WAKEUP,
+       ETHTOOL_STAT_SKB_ALLOC_ERR,
+       ETHTOOL_STAT_REFILL_ERR,
        ETHTOOL_MAX_STATS,
 };
 
@@ -375,6 +377,8 @@ static const struct mvneta_statistic mvneta_statistics[] = {
        { 0x3054, T_REG_32, "fc_sent", },
        { 0x300c, T_REG_32, "internal_mac_transmit_err", },
        { ETHTOOL_STAT_EEE_WAKEUP, T_SW, "eee_wakeup_errors", },
+       { ETHTOOL_STAT_SKB_ALLOC_ERR, T_SW, "skb_alloc_errors", },
+       { ETHTOOL_STAT_REFILL_ERR, T_SW, "refill_errors", },
 };
 
 struct mvneta_pcpu_stats {
@@ -589,9 +593,6 @@ struct mvneta_rx_queue {
        /* num of rx descriptors in the rx descriptor ring */
        int size;
 
-       /* counter of times when mvneta_refill() failed */
-       int missed;
-
        u32 pkts_coal;
        u32 time_coal;
 
@@ -609,6 +610,10 @@ struct mvneta_rx_queue {
 
        /* Index of the next RX DMA descriptor to process */
        int next_desc_to_proc;
+
+       /* error counters */
+       u32 skb_alloc_err;
+       u32 refill_err;
 };
 
 static enum cpuhp_state online_hpstate;
@@ -1946,8 +1951,13 @@ err_drop_frame:
                if (rx_bytes <= rx_copybreak) {
                /* better copy a small frame and not unmap the DMA region */
                        skb = netdev_alloc_skb_ip_align(dev, rx_bytes);
-                       if (unlikely(!skb))
+                       if (unlikely(!skb)) {
+                               netdev_err(dev,
+                                          "Can't allocate skb on queue %d\n",
+                                          rxq->id);
+                               rxq->skb_alloc_err++;
                                goto err_drop_frame;
+                       }
 
                        dma_sync_single_range_for_cpu(dev->dev.parent,
                                                      phys_addr,
@@ -1972,7 +1982,7 @@ err_drop_frame:
                err = mvneta_rx_refill(pp, rx_desc, rxq);
                if (err) {
                        netdev_err(dev, "Linux processing - Can't refill\n");
-                       rxq->missed++;
+                       rxq->refill_err++;
                        goto err_drop_frame;
                }
 
@@ -2102,7 +2112,7 @@ err_drop_frame:
                err = hwbm_pool_refill(&bm_pool->hwbm_pool, GFP_ATOMIC);
                if (err) {
                        netdev_err(dev, "Linux processing - Can't refill\n");
-                       rxq->missed++;
+                       rxq->refill_err++;
                        goto err_drop_frame_ret_pool;
                }
 
@@ -3963,6 +3973,12 @@ static void mvneta_ethtool_update_stats(struct mvneta_port *pp)
                        case ETHTOOL_STAT_EEE_WAKEUP:
                                val = phylink_get_eee_err(pp->phylink);
                                break;
+                       case ETHTOOL_STAT_SKB_ALLOC_ERR:
+                               val = pp->rxqs[0].skb_alloc_err;
+                               break;
+                       case ETHTOOL_STAT_REFILL_ERR:
+                               val = pp->rxqs[0].refill_err;
+                               break;
                        }
                        break;
                }