[4/5] app/testpmd: remove useless casts on statistics
diff mbox series

Message ID 1550158972-21895-5-git-send-email-david.marchand@redhat.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • display testpmd forwarding engine stats on the fly
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

David Marchand Feb. 14, 2019, 3:42 p.m. UTC
Caught by code review while investigating the stats display code.
Switching all port and fwd engine statistics to uint64_t makes it
possible to drop all casts.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 app/test-pmd/testpmd.c | 62 ++++++++++++++++++--------------------------------
 app/test-pmd/testpmd.h | 12 +++++-----
 2 files changed, 28 insertions(+), 46 deletions(-)

Patch
diff mbox series

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 3acd97b..ab110b0 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1376,7 +1376,7 @@  struct extmem_param {
 		printf("  RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: "
 		       "%-"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64"Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1390,13 +1390,13 @@  struct extmem_param {
 		printf("  TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: "
 		       "%-"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 	else {
 		printf("  RX-packets:             %14"PRIu64"    RX-dropped:%14"PRIu64"    RX-total:"
 		       "%14"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum:%14"PRIu64"    Bad-l4csum:%14"PRIu64"    Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1411,7 +1411,7 @@  struct extmem_param {
 		printf("  TX-packets:             %14"PRIu64"    TX-dropped:%14"PRIu64"    TX-total:"
 		       "%14"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
@@ -1459,13 +1459,15 @@  struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
+	printf("  RX-packets: %-14"PRIu64" TX-packets: %-14"PRIu64
+	       " TX-dropped: %-14"PRIu64"\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
 	if (cur_fwd_eng == &csum_fwd_engine) {
-	       printf("  RX- bad IP checksum: %-14u  Rx- bad L4 checksum: "
-			"%-14u Rx- bad outer L4 checksum: %-14u\n",
+		printf("  RX- bad IP checksum: %-14"PRIu64
+		       "  Rx- bad L4 checksum: %-14"PRIu64
+		       " Rx- bad outer L4 checksum: %-14"PRIu64"\n",
 			fs->rx_bad_ip_csum, fs->rx_bad_l4_csum,
 			fs->rx_bad_outer_l4_csum);
 	}
@@ -1743,9 +1745,6 @@  struct extmem_param {
 	uint64_t total_rx_dropped;
 	uint64_t total_tx_dropped;
 	uint64_t total_rx_nombuf;
-	uint64_t tx_dropped;
-	uint64_t rx_bad_ip_csum;
-	uint64_t rx_bad_l4_csum;
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t fwd_cycles;
 #endif
@@ -1772,42 +1771,25 @@  struct extmem_param {
 	fwd_cycles = 0;
 #endif
 	for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
+		struct fwd_stream *fs = fwd_streams[sm_id];
+
 		if (cur_fwd_config.nb_fwd_streams >
 		    cur_fwd_config.nb_fwd_ports) {
 			fwd_stream_stats_display(sm_id);
-			ports[fwd_streams[sm_id]->tx_port].tx_stream = NULL;
-			ports[fwd_streams[sm_id]->rx_port].rx_stream = NULL;
+			ports[fs->tx_port].tx_stream = NULL;
+			ports[fs->rx_port].rx_stream = NULL;
 		} else {
-			ports[fwd_streams[sm_id]->tx_port].tx_stream =
-				fwd_streams[sm_id];
-			ports[fwd_streams[sm_id]->rx_port].rx_stream =
-				fwd_streams[sm_id];
-		}
-		tx_dropped = ports[fwd_streams[sm_id]->tx_port].tx_dropped;
-		tx_dropped = (uint64_t) (tx_dropped +
-					 fwd_streams[sm_id]->fwd_dropped);
-		ports[fwd_streams[sm_id]->tx_port].tx_dropped = tx_dropped;
-
-		rx_bad_ip_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum;
-		rx_bad_ip_csum = (uint64_t) (rx_bad_ip_csum +
-					 fwd_streams[sm_id]->rx_bad_ip_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum =
-							rx_bad_ip_csum;
-
-		rx_bad_l4_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum;
-		rx_bad_l4_csum = (uint64_t) (rx_bad_l4_csum +
-					 fwd_streams[sm_id]->rx_bad_l4_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum =
-							rx_bad_l4_csum;
-
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_outer_l4_csum +=
-				fwd_streams[sm_id]->rx_bad_outer_l4_csum;
+			ports[fs->tx_port].tx_stream = fs;
+			ports[fs->rx_port].rx_stream = fs;
+		}
+		ports[fs->tx_port].tx_dropped += fs->fwd_dropped;
+		ports[fs->rx_port].rx_bad_ip_csum += fs->rx_bad_ip_csum;
+		ports[fs->rx_port].rx_bad_l4_csum += fs->rx_bad_l4_csum;
+		ports[fs->rx_port].rx_bad_outer_l4_csum +=
+				fs->rx_bad_outer_l4_csum;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
-		fwd_cycles = (uint64_t) (fwd_cycles +
-					 fwd_streams[sm_id]->core_cycles);
+		fwd_cycles += fs->core_cycles;
 #endif
 	}
 	total_recv = 0;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 85b791b..4f4a48f 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -119,12 +119,12 @@  struct fwd_stream {
 	unsigned int retry_enabled;
 
 	/* "read-write" results */
-	unsigned int rx_packets;  /**< received packets */
-	unsigned int tx_packets;  /**< received packets transmitted */
-	unsigned int fwd_dropped; /**< received packets not forwarded */
-	unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */
-	unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
-	unsigned int rx_bad_outer_l4_csum;
+	uint64_t rx_packets;  /**< received packets */
+	uint64_t tx_packets;  /**< received packets transmitted */
+	uint64_t fwd_dropped; /**< received packets not forwarded */
+	uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
+	uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
+	uint64_t rx_bad_outer_l4_csum;
 	/**< received packets has bad outer l4 checksum */
 	unsigned int gro_times;	/**< GRO operation times */
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES