DPDK patches and discussions
 help / color / mirror / Atom feed
From: John Daley <johndale@cisco.com>
To: dev@dpdk.org
Cc: John Daley <johndale@cisco.com>, Nelson Escobar <neescoba@cisco.com>
Subject: [dpdk-dev] [PATCH 03/11] enic: count truncated packets
Date: Fri, 20 May 2016 12:04:06 -0700	[thread overview]
Message-ID: <1463771054-16861-3-git-send-email-johndale@cisco.com> (raw)
In-Reply-To: <1463771054-16861-1-git-send-email-johndale@cisco.com>

Truncated packets occur on enic if an mbuf is not big enough to
receive it or there aren't enough mbufs if rx scatter is in use.
They show up as error packets but unlike other error packets (like
packets bad FCS) there are no nic drop counts incremented for them.
Truncated packets are calculated by subtracting hardware errors from
software errors. Note: this causes transient inaccuracies in the
ipackets count. Also, the length of truncated packets are counted
in ibytes even though truncated packets are dropped which can make
ibytes be slightly higher than it should be.

Signed-off-by: Nelson Escobar <neescoba@cisco.com>
Signed-off-by: John Daley <johndale@cisco.com>
---
 drivers/net/enic/enic.h      |  1 +
 drivers/net/enic/enic_main.c | 21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 584d49b..9b6f349 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -93,6 +93,7 @@ struct enic_fdir {
 
 struct enic_soft_stats {
 	rte_atomic64_t rx_nombuf;
+	rte_atomic64_t rx_packet_errors;
 };
 
 /* Per-instance private data structure */
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index c002ef3..e4ccc7d 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -215,12 +215,14 @@ static void enic_clear_soft_stats(struct enic *enic)
 {
 	struct enic_soft_stats *soft_stats = &enic->soft_stats;
 	rte_atomic64_clear(&soft_stats->rx_nombuf);
+	rte_atomic64_clear(&soft_stats->rx_packet_errors);
 }
 
 static void enic_init_soft_stats(struct enic *enic)
 {
 	struct enic_soft_stats *soft_stats = &enic->soft_stats;
 	rte_atomic64_init(&soft_stats->rx_nombuf);
+	rte_atomic64_init(&soft_stats->rx_packet_errors);
 	enic_clear_soft_stats(enic);
 }
 
@@ -234,14 +236,26 @@ void enic_dev_stats_clear(struct enic *enic)
 void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats)
 {
 	struct vnic_stats *stats;
-	struct enic_soft_stats *soft_stats;
+	struct enic_soft_stats *soft_stats = &enic->soft_stats;
+	int64_t rx_truncated;
+	uint64_t rx_packet_errors;
 
 	if (vnic_dev_stats_dump(enic->vdev, &stats)) {
 		dev_err(enic, "Error in getting stats\n");
 		return;
 	}
 
-	r_stats->ipackets = stats->rx.rx_frames_ok;
+	/* The number of truncated packets can only be calculated by
+	 * subtracting a hardware counter from error packets received by
+	 * the driver. Note: this causes transient inaccuracies in the
+	 * ipackets count. Also, the length of truncated packets are
+	 * counted in ibytes even though truncated packets are dropped
+	 * which can make ibytes be slightly higher than it should be.
+	 */
+	rx_packet_errors = rte_atomic64_read(&soft_stats->rx_packet_errors);
+	rx_truncated = rx_packet_errors - stats->rx.rx_errors;
+
+	r_stats->ipackets = stats->rx.rx_frames_ok - rx_truncated;
 	r_stats->opackets = stats->tx.tx_frames_ok;
 
 	r_stats->ibytes = stats->rx.rx_bytes_ok;
@@ -250,9 +264,8 @@ void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats)
 	r_stats->ierrors = stats->rx.rx_errors + stats->rx.rx_drop;
 	r_stats->oerrors = stats->tx.tx_errors;
 
-	r_stats->imissed = stats->rx.rx_no_bufs;
+	r_stats->imissed = stats->rx.rx_no_bufs + rx_truncated;
 
-	soft_stats = &enic->soft_stats;
 	r_stats->rx_nombuf = rte_atomic64_read(&soft_stats->rx_nombuf);
 }
 
-- 
2.7.0

  parent reply	other threads:[~2016-05-20 19:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 19:04 [dpdk-dev] [PATCH 01/11] enic: fix Rx drop counters John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 02/11] enic: drop bad packets, remove unused rx error flag John Daley
2016-05-20 19:04 ` John Daley [this message]
2016-05-20 19:04 ` [dpdk-dev] [PATCH 04/11] enic: Tx cleanup - put Tx and Rx functions into same file John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 05/11] enic: Tx cleanup - remove some unused functions John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 06/11] enic: Tx perf - improve processing of mbufs held by driver John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 07/11] enic: Tx perf - use completion message instead of completion queue John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 08/11] enic: Tx perf - bulk recycle mbufs, refactor John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 09/11] enic: Tx perf - optimize the transmit function John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 10/11] enic: Tx cleanup - remove unused files, functions, variables John Daley
2016-05-20 19:04 ` [dpdk-dev] [PATCH 11/11] enic: add ENIC_ASSERT macro John Daley

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=1463771054-16861-3-git-send-email-johndale@cisco.com \
    --to=johndale@cisco.com \
    --cc=dev@dpdk.org \
    --cc=neescoba@cisco.com \
    /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).