Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Petri Gynther and committed by
David S. Miller
d26ea6cc 61f0d861

+19
+18
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 1384 1384 int len, err; 1385 1385 unsigned int rxpktprocessed = 0, rxpkttoprocess; 1386 1386 unsigned int p_index; 1387 + unsigned int discards; 1387 1388 unsigned int chksum_ok = 0; 1388 1389 1389 1390 p_index = bcmgenet_rdma_ring_readl(priv, index, RDMA_PROD_INDEX); 1391 + 1392 + discards = (p_index >> DMA_P_INDEX_DISCARD_CNT_SHIFT) & 1393 + DMA_P_INDEX_DISCARD_CNT_MASK; 1394 + if (discards > ring->old_discards) { 1395 + discards = discards - ring->old_discards; 1396 + dev->stats.rx_missed_errors += discards; 1397 + dev->stats.rx_errors += discards; 1398 + ring->old_discards += discards; 1399 + 1400 + /* Clear HW register when we reach 75% of maximum 0xFFFF */ 1401 + if (ring->old_discards >= 0xC000) { 1402 + ring->old_discards = 0; 1403 + bcmgenet_rdma_ring_writel(priv, index, 0, 1404 + RDMA_PROD_INDEX); 1405 + } 1406 + } 1407 + 1390 1408 p_index &= DMA_P_INDEX_MASK; 1391 1409 1392 1410 if (likely(p_index >= ring->c_index))
+1
drivers/net/ethernet/broadcom/genet/bcmgenet.h
··· 548 548 unsigned int read_ptr; /* Rx ring read pointer */ 549 549 unsigned int cb_ptr; /* Rx ring initial CB ptr */ 550 550 unsigned int end_ptr; /* Rx ring end CB ptr */ 551 + unsigned int old_discards; 551 552 }; 552 553 553 554 /* device context */