NIU: Implement discard counters, optimize
[pandora-kernel.git] / drivers / net / niu.c
index 7b6cdd0..f219f16 100644 (file)
@@ -3558,6 +3558,9 @@ static inline void niu_sync_rx_discard_stats(struct niu *np,
                if (unlikely(misc & RXMISC_OFLOW))
                        dev_err(np->device, "rx-%d: Counter overflow "
                                "RXMISC discard\n", rx_channel);
+
+               niudbg(RX_ERR, "%s-rx-%d: MISC drop=%u over=%u\n",
+                      np->dev->name, rx_channel, misc, misc-limit);
        }
 
        /* WRED (Weighted Random Early Discard) by hardware */
@@ -3569,6 +3572,9 @@ static inline void niu_sync_rx_discard_stats(struct niu *np,
                if (unlikely(wred & RED_DIS_CNT_OFLOW))
                        dev_err(np->device, "rx-%d: Counter overflow "
                                "WRED discard\n", rx_channel);
+
+               niudbg(RX_ERR, "%s-rx-%d: WRED drop=%u over=%u\n",
+                      np->dev->name, rx_channel, wred, wred-limit);
        }
 }
 
@@ -3612,7 +3618,9 @@ static int niu_rx_work(struct niu *np, struct rx_ring_info *rp, int budget)
 
        nw64(RX_DMA_CTL_STAT(rp->rx_channel), stat);
 
-       niu_sync_rx_discard_stats(np, rp, 0x7FFF);
+       /* Only sync discards stats when qlen indicate potential for drops */
+       if (qlen > 10)
+               niu_sync_rx_discard_stats(np, rp, 0x7FFF);
 
        return work_done;
 }