From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) by dpdk.org (Postfix) with ESMTP id 4785A56A1 for ; Tue, 24 May 2016 08:33:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3481; q=dns/txt; s=iport; t=1464071583; x=1465281183; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1GfyO+zyCggjh0D8t4LY+iuflrp9f+tD7rT9HSvKHfs=; b=Hr/3coq/0VARi2cKz+XgkZQx6zYRtt/4mv6wKzbjBNiksaAY674Z3ZJj n/WpHwo4kRuR48+NiAtEdGfBXJE/leQqAFKVC2/slLTTarcd/4tIGQsQw ZvVFsO5rVfLyqmlvIPPP3ulKrKpTi+A1qWrLpi4JYSrcgyqveJmDUVFAb 8=; X-IronPort-AV: E=Sophos;i="5.26,359,1459814400"; d="scan'208";a="107662082" Received: from rcdn-core-7.cisco.com ([173.37.93.143]) by rcdn-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2016 06:33:02 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-7.cisco.com (8.14.5/8.14.5) with ESMTP id u4O6X2Bq016000; Tue, 24 May 2016 06:33:02 GMT Received: by cisco.com (Postfix, from userid 392789) id 612C63FAAE0E; Mon, 23 May 2016 23:33:02 -0700 (PDT) From: John Daley To: dev@dpdk.org Cc: John Daley , Nelson Escobar Date: Mon, 23 May 2016 23:32:51 -0700 Message-Id: <1464071579-30072-4-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464071579-30072-1-git-send-email-johndale@cisco.com> References: <1464071579-30072-1-git-send-email-johndale@cisco.com> Subject: [dpdk-dev] [PATCH v2 03/11] enic: count truncated packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2016 06:33:03 -0000 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 Signed-off-by: John Daley --- 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