remove unused ring includes
[dpdk.git] / app / test-pmd / config.c
index eb5514d..83bebfe 100644 (file)
@@ -84,7 +84,6 @@
 #include <rte_lcore.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
-#include <rte_ring.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
@@ -92,6 +91,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
+#include <rte_cycles.h>
 
 #include "testpmd.h"
 
@@ -137,6 +137,11 @@ static const struct rss_type_info rss_type_table[] = {
        { "ipv6-ex", ETH_RSS_IPV6_EX },
        { "ipv6-tcp-ex", ETH_RSS_IPV6_TCP_EX },
        { "ipv6-udp-ex", ETH_RSS_IPV6_UDP_EX },
+       { "port", ETH_RSS_PORT },
+       { "vxlan", ETH_RSS_VXLAN },
+       { "geneve", ETH_RSS_GENEVE },
+       { "nvgre", ETH_RSS_NVGRE },
+
 };
 
 static void
@@ -150,6 +155,11 @@ print_ethaddr(const char *name, struct ether_addr *eth_addr)
 void
 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_cycles[RTE_MAX_ETHPORTS];
+       uint64_t diff_pkts_rx, diff_pkts_tx, diff_cycles;
+       uint64_t mpps_rx, mpps_tx;
        struct rte_eth_stats stats;
        struct rte_port *port = &ports[port_id];
        uint8_t i;
@@ -209,6 +219,23 @@ nic_stats_display(portid_t port_id)
                }
        }
 
+       diff_cycles = prev_cycles[port_id];
+       prev_cycles[port_id] = rte_rdtsc();
+       if (diff_cycles > 0)
+               diff_cycles = prev_cycles[port_id] - diff_cycles;
+
+       diff_pkts_rx = stats.ipackets - prev_pkts_rx[port_id];
+       diff_pkts_tx = stats.opackets - prev_pkts_tx[port_id];
+       prev_pkts_rx[port_id] = stats.ipackets;
+       prev_pkts_tx[port_id] = stats.opackets;
+       mpps_rx = diff_cycles > 0 ?
+               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;
+       printf("\n  Throughput (since last show)\n");
+       printf("  Rx-pps: %12"PRIu64"\n  Tx-pps: %12"PRIu64"\n",
+                       mpps_rx, mpps_tx);
+
        printf("  %s############################%s\n",
               nic_stats_border, nic_stats_border);
 }
@@ -232,29 +259,56 @@ nic_stats_clear(portid_t port_id)
 void
 nic_xstats_display(portid_t port_id)
 {
-       struct rte_eth_xstats *xstats;
-       int len, ret, i;
+       struct rte_eth_xstat *xstats;
+       int cnt_xstats, idx_xstat;
+       struct rte_eth_xstat_name *xstats_names;
 
        printf("###### NIC extended statistics for port %-2d\n", port_id);
+       if (!rte_eth_dev_is_valid_port(port_id)) {
+               printf("Error: Invalid port number %i\n", port_id);
+               return;
+       }
 
-       len = rte_eth_xstats_get(port_id, NULL, 0);
-       if (len < 0) {
-               printf("Cannot get xstats count\n");
+       /* Get count */
+       cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0);
+       if (cnt_xstats  < 0) {
+               printf("Error: Cannot get count of xstats\n");
+               return;
+       }
+
+       /* Get id-name lookup table */
+       xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * cnt_xstats);
+       if (xstats_names == NULL) {
+               printf("Cannot allocate memory for xstats lookup\n");
+               return;
+       }
+       if (cnt_xstats != rte_eth_xstats_get_names(
+                       port_id, xstats_names, cnt_xstats)) {
+               printf("Error: Cannot get xstats lookup\n");
+               free(xstats_names);
                return;
        }
-       xstats = malloc(sizeof(xstats[0]) * len);
+
+       /* Get stats themselves */
+       xstats = malloc(sizeof(struct rte_eth_xstat) * cnt_xstats);
        if (xstats == NULL) {
                printf("Cannot allocate memory for xstats\n");
+               free(xstats_names);
                return;
        }
-       ret = rte_eth_xstats_get(port_id, xstats, len);
-       if (ret < 0 || ret > len) {
-               printf("Cannot get xstats\n");
+       if (cnt_xstats != rte_eth_xstats_get(port_id, xstats, cnt_xstats)) {
+               printf("Error: Unable to get xstats\n");
+               free(xstats_names);
                free(xstats);
                return;
        }
-       for (i = 0; i < len; i++)
-               printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value);
+
+       /* Display xstats */
+       for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++)
+               printf("%s: %"PRIu64"\n",
+                       xstats_names[idx_xstat].name,
+                       xstats[idx_xstat].value);
+       free(xstats_names);
        free(xstats);
 }
 
@@ -1146,14 +1200,9 @@ simple_fwd_config_setup(void)
 }
 
 /**
- * For the RSS forwarding test, each core is assigned on every port a transmit
- * queue whose index is the index of the core itself. This approach limits the
- * maximumm number of processing cores of the RSS test to the maximum number of
- * TX queues supported by the devices.
- *
- * Each core is assigned a single stream, each stream being composed of
- * a RX queue to poll on a RX port for input messages, associated with
- * a TX queue of a TX port where to send forwarded packets.
+ * For the RSS forwarding test all streams distributed over lcores. Each stream
+ * being composed of a RX queue to poll on a RX port for input messages,
+ * associated with a TX queue of a TX port where to send forwarded packets.
  * All packets received on the RX queue of index "RxQj" of the RX port "RxPi"
  * are sent on the TX queue "TxQl" of the TX port "TxPk" according to the two
  * following rules:
@@ -1167,7 +1216,7 @@ rss_fwd_config_setup(void)
        portid_t   txp;
        queueid_t  rxq;
        queueid_t  nb_q;
-       lcoreid_t  lc_id;
+       streamid_t  sm_id;
 
        nb_q = nb_rxq;
        if (nb_q > nb_txq)
@@ -1176,10 +1225,8 @@ rss_fwd_config_setup(void)
        cur_fwd_config.nb_fwd_ports = nb_fwd_ports;
        cur_fwd_config.nb_fwd_streams =
                (streamid_t) (nb_q * cur_fwd_config.nb_fwd_ports);
-       if (cur_fwd_config.nb_fwd_streams > cur_fwd_config.nb_fwd_lcores)
-               cur_fwd_config.nb_fwd_streams =
-                       (streamid_t)cur_fwd_config.nb_fwd_lcores;
-       else
+
+       if (cur_fwd_config.nb_fwd_streams < cur_fwd_config.nb_fwd_lcores)
                cur_fwd_config.nb_fwd_lcores =
                        (lcoreid_t)cur_fwd_config.nb_fwd_streams;
 
@@ -1188,10 +1235,10 @@ rss_fwd_config_setup(void)
 
        setup_fwd_config_of_each_lcore(&cur_fwd_config);
        rxp = 0; rxq = 0;
-       for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) {
+       for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
                struct fwd_stream *fs;
 
-               fs = fwd_streams[lc_id];
+               fs = fwd_streams[sm_id];
 
                if ((rxp & 0x1) == 0)
                        txp = (portid_t) (rxp + 1);
@@ -2071,6 +2118,10 @@ flowtype_to_str(uint16_t flow_type)
                {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
                {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
                {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
+               {"port", RTE_ETH_FLOW_PORT},
+               {"vxlan", RTE_ETH_FLOW_VXLAN},
+               {"geneve", RTE_ETH_FLOW_GENEVE},
+               {"nvgre", RTE_ETH_FLOW_NVGRE},
        };
 
        for (i = 0; i < RTE_DIM(flowtype_str_table); i++) {