app/testpmd: add bits per second to statistics
[dpdk.git] / app / test-pmd / config.c
index 33a4e98..8035961 100644 (file)
@@ -119,9 +119,12 @@ nic_stats_display(portid_t port_id)
 {
        static uint64_t prev_pkts_rx[RTE_MAX_ETHPORTS];
        static uint64_t prev_pkts_tx[RTE_MAX_ETHPORTS];
+       static uint64_t prev_bytes_rx[RTE_MAX_ETHPORTS];
+       static uint64_t prev_bytes_tx[RTE_MAX_ETHPORTS];
        static uint64_t prev_cycles[RTE_MAX_ETHPORTS];
-       uint64_t diff_pkts_rx, diff_pkts_tx, diff_cycles;
-       uint64_t mpps_rx, mpps_tx;
+       uint64_t diff_pkts_rx, diff_pkts_tx, diff_bytes_rx, diff_bytes_tx,
+                                                               diff_cycles;
+       uint64_t mpps_rx, mpps_tx, mbps_rx, mbps_tx;
        struct rte_eth_stats stats;
        struct rte_port *port = &ports[port_id];
        uint8_t i;
@@ -192,9 +195,22 @@ nic_stats_display(portid_t port_id)
                diff_pkts_rx * rte_get_tsc_hz() / diff_cycles : 0;
        mpps_tx = diff_cycles > 0 ?
                diff_pkts_tx * rte_get_tsc_hz() / diff_cycles : 0;
+
+       diff_bytes_rx = (stats.ibytes > prev_bytes_rx[port_id]) ?
+               (stats.ibytes - prev_bytes_rx[port_id]) : 0;
+       diff_bytes_tx = (stats.obytes > prev_bytes_tx[port_id]) ?
+               (stats.obytes - prev_bytes_tx[port_id]) : 0;
+       prev_bytes_rx[port_id] = stats.ibytes;
+       prev_bytes_tx[port_id] = stats.obytes;
+       mbps_rx = diff_cycles > 0 ?
+               diff_bytes_rx * rte_get_tsc_hz() / diff_cycles : 0;
+       mbps_tx = diff_cycles > 0 ?
+               diff_bytes_tx * rte_get_tsc_hz() / diff_cycles : 0;
+
        printf("\n  Throughput (since last show)\n");
-       printf("  Rx-pps: %12"PRIu64"\n  Tx-pps: %12"PRIu64"\n",
-                       mpps_rx, mpps_tx);
+       printf("  Rx-pps: %12"PRIu64"          Rx-bps: %12"PRIu64"\n  Tx-pps: %12"
+              PRIu64"          Tx-bps: %12"PRIu64"\n", mpps_rx, mbps_rx * 8,
+              mpps_tx, mbps_tx * 8);
 
        printf("  %s############################%s\n",
               nic_stats_border, nic_stats_border);
@@ -454,9 +470,11 @@ skip_parse:
 
                        /* List ports with matching device name */
                        RTE_ETH_FOREACH_DEV_OF(port_id, dev) {
-                               rte_eth_macaddr_get(port_id, &mac_addr);
                                printf("\n\tPort id: %-2d", port_id);
-                               print_ethaddr("\n\tMAC address: ", &mac_addr);
+                               if (eth_macaddr_get_print_err(port_id,
+                                                             &mac_addr) == 0)
+                                       print_ethaddr("\n\tMAC address: ",
+                                                     &mac_addr);
                                rte_eth_dev_get_name_by_port(port_id, name);
                                printf("\n\tDevice name: %s", name);
                                printf("\n");
@@ -494,8 +512,8 @@ port_infos_display(portid_t port_id)
 
        printf("\n%s Infos for port %-2d %s\n",
               info_border, port_id, info_border);
-       rte_eth_macaddr_get(port_id, &mac_addr);
-       print_ethaddr("MAC address: ", &mac_addr);
+       if (eth_macaddr_get_print_err(port_id, &mac_addr) == 0)
+               print_ethaddr("MAC address: ", &mac_addr);
        rte_eth_dev_get_name_by_port(port_id, name);
        printf("\nDevice name: %s", name);
        printf("\nDriver name: %s", dev_info.driver_name);
@@ -646,7 +664,9 @@ port_summary_display(portid_t port_id)
                return;
 
        rte_eth_dev_get_name_by_port(port_id, name);
-       rte_eth_macaddr_get(port_id, &mac_addr);
+       ret = eth_macaddr_get_print_err(port_id, &mac_addr);
+       if (ret != 0)
+               return;
 
        printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n",
                port_id, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1],
@@ -1645,10 +1665,10 @@ ring_rx_descriptor_display(const struct rte_memzone *ring_mz,
 #endif
                           uint16_t desc_id)
 {
-       int ret;
        struct igb_ring_desc_16_bytes *ring =
                (struct igb_ring_desc_16_bytes *)ring_mz->addr;
 #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+       int ret;
        struct rte_eth_dev_info dev_info;
 
        ret = eth_dev_info_get_print_err(port_id, &dev_info);