DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Andrew Lee <alee@solarflare.com>,
	Robert Stonehouse <rstonehouse@solarflare.com>
Cc: dev@dpdk.org, Stephen Hemminger <sthemmin@microsoft.com>,
	Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] net/sfc: fix generic byte statistics to exclude FCS bytes
Date: Wed, 20 Jan 2021 15:44:18 +0300	[thread overview]
Message-ID: <20210120124418.2745343-2-andrew.rybchenko@oktetlabs.ru> (raw)
In-Reply-To: <20210120124418.2745343-1-andrew.rybchenko@oktetlabs.ru>

From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>

Generic byte statistics should not include Ethernet FCS bytes.

Fixes: 1caab2f1e684 ("net/sfc: add basic statistics")
Cc: stable@dpdk.org

Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/sfc/sfc_ethdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 93fc7baa0d..f5007c84ad 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -640,10 +640,19 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 			mac_stats[EFX_MAC_VADAPTER_TX_BROADCAST_BYTES];
 		stats->imissed = mac_stats[EFX_MAC_VADAPTER_RX_BAD_PACKETS];
 		stats->oerrors = mac_stats[EFX_MAC_VADAPTER_TX_BAD_PACKETS];
+
+		/* CRC is included in these stats, but shouldn't be */
+		stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN;
+		stats->obytes -= stats->opackets * RTE_ETHER_CRC_LEN;
 	} else {
 		stats->opackets = mac_stats[EFX_MAC_TX_PKTS];
 		stats->ibytes = mac_stats[EFX_MAC_RX_OCTETS];
 		stats->obytes = mac_stats[EFX_MAC_TX_OCTETS];
+
+		/* CRC is included in these stats, but shouldn't be */
+		stats->ibytes -= mac_stats[EFX_MAC_RX_PKTS] * RTE_ETHER_CRC_LEN;
+		stats->obytes -= mac_stats[EFX_MAC_TX_PKTS] * RTE_ETHER_CRC_LEN;
+
 		/*
 		 * Take into account stats which are whenever supported
 		 * on EF10. If some stat is not supported by current
-- 
2.29.2


  reply	other threads:[~2021-01-20 12:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 12:44 [dpdk-dev] [PATCH 1/2] ethdev: clarify what is included in generic byte statistics Andrew Rybchenko
2021-01-20 12:44 ` Andrew Rybchenko [this message]
2021-01-27 11:21 ` Ferruh Yigit
2021-01-27 11:31 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210120124418.2745343-2-andrew.rybchenko@oktetlabs.ru \
    --to=andrew.rybchenko@oktetlabs.ru \
    --cc=alee@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=rstonehouse@solarflare.com \
    --cc=stable@dpdk.org \
    --cc=sthemmin@microsoft.com \
    --cc=viacheslav.galaktionov@oktetlabs.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).