]> git.droids-corp.org - dpdk.git/commitdiff
net/enic: count truncated packets
authorJohn Daley <johndale@cisco.com>
Fri, 3 Jun 2016 00:22:47 +0000 (17:22 -0700)
committerBruce Richardson <bruce.richardson@intel.com>
Wed, 15 Jun 2016 15:13:56 +0000 (17:13 +0200)
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
drivers/net/enic/enic_main.c

index 584d49b3e4d917b3b8b0c5d7eabecc50211c28b4..9b6f349e2c8037e0dc4dc1aebb865d0c72629c71 100644 (file)
@@ -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 */
index c002ef360d32e81081fbbe7c8dc64f55208e1990..e4ccc7d44aca165b8094e33ff5ddd4c4a597796f 100644 (file)
@@ -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);
 }