ethdev: remove redundant id field in xstats name lookup
[dpdk.git] / app / test-pmd / config.c
index 6f1ead0..c5865f9 100644 (file)
@@ -138,6 +138,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
@@ -255,29 +260,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);
 }
 
@@ -1199,10 +1231,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;
 
@@ -1211,7 +1241,7 @@ 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 (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_streams; lc_id++) {
                struct fwd_stream *fs;
 
                fs = fwd_streams[lc_id];
@@ -2094,6 +2124,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++) {