summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/broadcom/genet/bcmgenet.c
diff options
context:
space:
mode:
authorPetri Gynther <pgynther@google.com>2015-03-11 01:55:00 +0300
committerDavid S. Miller <davem@davemloft.net>2015-03-12 00:54:55 +0300
commitd26ea6cc48da5a97d8188220c334cf3669fa8dc7 (patch)
treed6408c7ced8b23593c980a9dac69c34a78b5c2ae /drivers/net/ethernet/broadcom/genet/bcmgenet.c
parent61f0d861fc6924fa673ecf1128a911d49cb10dc8 (diff)
downloadlinux-d26ea6cc48da5a97d8188220c334cf3669fa8dc7.tar.xz
net: bcmgenet: collect Rx discarded packet count
Bits 31:16 of RDMA_PROD_INDEX contain Rx discarded packet count, which are the Rx packets that had to be dropped by MAC hardware since there was no room on the Rx queue. Add code to collect this information into the netdev stats. Signed-off-by: Petri Gynther <pgynther@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/genet/bcmgenet.c')
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 275be56fd324..d3be1aeb7f47 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1384,9 +1384,27 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_priv *priv,
int len, err;
unsigned int rxpktprocessed = 0, rxpkttoprocess;
unsigned int p_index;
+ unsigned int discards;
unsigned int chksum_ok = 0;
p_index = bcmgenet_rdma_ring_readl(priv, index, RDMA_PROD_INDEX);
+
+ discards = (p_index >> DMA_P_INDEX_DISCARD_CNT_SHIFT) &
+ DMA_P_INDEX_DISCARD_CNT_MASK;
+ if (discards > ring->old_discards) {
+ discards = discards - ring->old_discards;
+ dev->stats.rx_missed_errors += discards;
+ dev->stats.rx_errors += discards;
+ ring->old_discards += discards;
+
+ /* Clear HW register when we reach 75% of maximum 0xFFFF */
+ if (ring->old_discards >= 0xC000) {
+ ring->old_discards = 0;
+ bcmgenet_rdma_ring_writel(priv, index, 0,
+ RDMA_PROD_INDEX);
+ }
+ }
+
p_index &= DMA_P_INDEX_MASK;
if (likely(p_index >= ring->c_index))