diff mbox series

[net-next,v2,4/4] net: dsa: microchip: count pause packets together will all other packets

Message ID 20220628085155.2591201-5-o.rempel@pengutronix.de (mailing list archive)
State Accepted
Commit 961d6c70d886ecc057f6e501db5879feb55db3b3
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: add pause stats support | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Oleksij Rempel June 28, 2022, 8:51 a.m. UTC
This switch is calculating tx/rx_bytes for all packets including pause.
So, include rx/tx_pause counter to rx/tx_packets to make tx/rx_bytes fit
to rx/tx_packets.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz_common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Vladimir Oltean June 28, 2022, 10:20 a.m. UTC | #1
On Tue, Jun 28, 2022 at 10:51:55AM +0200, Oleksij Rempel wrote:
> This switch is calculating tx/rx_bytes for all packets including pause.
> So, include rx/tx_pause counter to rx/tx_packets to make tx/rx_bytes fit
> to rx/tx_packets.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---

I think this is a reasonable thing to do.

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Florian Fainelli June 28, 2022, 2:47 p.m. UTC | #2
On 6/28/2022 1:51 AM, Oleksij Rempel wrote:
> This switch is calculating tx/rx_bytes for all packets including pause.
> So, include rx/tx_pause counter to rx/tx_packets to make tx/rx_bytes fit
> to rx/tx_packets.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

Might have been worth a comment above to explain why the pause frame 
counting is appropriate, or we can always go back to git log. Thanks!
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 7c221ec331ee..f5ad9cd8eff5 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -598,8 +598,10 @@  void ksz_r_mib_stats64(struct ksz_device *dev, int port)
 
 	spin_lock(&mib->stats64_lock);
 
-	stats->rx_packets = raw->rx_bcast + raw->rx_mcast + raw->rx_ucast;
-	stats->tx_packets = raw->tx_bcast + raw->tx_mcast + raw->tx_ucast;
+	stats->rx_packets = raw->rx_bcast + raw->rx_mcast + raw->rx_ucast +
+		raw->rx_pause;
+	stats->tx_packets = raw->tx_bcast + raw->tx_mcast + raw->tx_ucast +
+		raw->tx_pause;
 
 	/* HW counters are counting bytes + FCS which is not acceptable
 	 * for rtnl_link_stats64 interface