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

cxgb4: Fix misleading packet/frame count stats.

Do not count pause frames as part of general TX/RX frame
counters.

Based on the original work of Casey Leedom <leedom@chelsio.com>
Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ganesh Goudar and committed by
David S. Miller
f750e82e 4b89aa3c

+35
+18
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 5501 5501 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p) 5502 5502 { 5503 5503 u32 bgmap = t4_get_mps_bg_map(adap, idx); 5504 + u32 stat_ctl = t4_read_reg(adap, MPS_STAT_CTL_A); 5504 5505 5505 5506 #define GET_STAT(name) \ 5506 5507 t4_read_reg64(adap, \ ··· 5533 5532 p->tx_ppp6 = GET_STAT(TX_PORT_PPP6); 5534 5533 p->tx_ppp7 = GET_STAT(TX_PORT_PPP7); 5535 5534 5535 + if (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T5) { 5536 + if (stat_ctl & COUNTPAUSESTATTX_F) { 5537 + p->tx_frames -= p->tx_pause; 5538 + p->tx_octets -= p->tx_pause * 64; 5539 + } 5540 + if (stat_ctl & COUNTPAUSEMCTX_F) 5541 + p->tx_mcast_frames -= p->tx_pause; 5542 + } 5536 5543 p->rx_octets = GET_STAT(RX_PORT_BYTES); 5537 5544 p->rx_frames = GET_STAT(RX_PORT_FRAMES); 5538 5545 p->rx_bcast_frames = GET_STAT(RX_PORT_BCAST); ··· 5568 5559 p->rx_ppp5 = GET_STAT(RX_PORT_PPP5); 5569 5560 p->rx_ppp6 = GET_STAT(RX_PORT_PPP6); 5570 5561 p->rx_ppp7 = GET_STAT(RX_PORT_PPP7); 5562 + 5563 + if (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T5) { 5564 + if (stat_ctl & COUNTPAUSESTATRX_F) { 5565 + p->rx_frames -= p->rx_pause; 5566 + p->rx_octets -= p->rx_pause * 64; 5567 + } 5568 + if (stat_ctl & COUNTPAUSEMCRX_F) 5569 + p->rx_mcast_frames -= p->rx_pause; 5570 + } 5571 5571 5572 5572 p->rx_ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_DROP_FRAME) : 0; 5573 5573 p->rx_ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_DROP_FRAME) : 0;
+17
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
··· 1798 1798 1799 1799 #define MPS_CMN_CTL_A 0x9000 1800 1800 1801 + #define COUNTPAUSEMCRX_S 5 1802 + #define COUNTPAUSEMCRX_V(x) ((x) << COUNTPAUSEMCRX_S) 1803 + #define COUNTPAUSEMCRX_F COUNTPAUSEMCRX_V(1U) 1804 + 1805 + #define COUNTPAUSESTATRX_S 4 1806 + #define COUNTPAUSESTATRX_V(x) ((x) << COUNTPAUSESTATRX_S) 1807 + #define COUNTPAUSESTATRX_F COUNTPAUSESTATRX_V(1U) 1808 + 1809 + #define COUNTPAUSEMCTX_S 3 1810 + #define COUNTPAUSEMCTX_V(x) ((x) << COUNTPAUSEMCTX_S) 1811 + #define COUNTPAUSEMCTX_F COUNTPAUSEMCTX_V(1U) 1812 + 1813 + #define COUNTPAUSESTATTX_S 2 1814 + #define COUNTPAUSESTATTX_V(x) ((x) << COUNTPAUSESTATTX_S) 1815 + #define COUNTPAUSESTATTX_F COUNTPAUSESTATTX_V(1U) 1816 + 1801 1817 #define NUMPORTS_S 0 1802 1818 #define NUMPORTS_M 0x3U 1803 1819 #define NUMPORTS_G(x) (((x) >> NUMPORTS_S) & NUMPORTS_M) 1804 1820 1805 1821 #define MPS_INT_CAUSE_A 0x9008 1806 1822 #define MPS_TX_INT_CAUSE_A 0x9408 1823 + #define MPS_STAT_CTL_A 0x9600 1807 1824 1808 1825 #define FRMERR_S 15 1809 1826 #define FRMERR_V(x) ((x) << FRMERR_S)