X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Fconfig.c;h=8cf537d594e5834e285240716345e69bd12d8121;hb=ac7cd715d462090df0032667d7a87400d9814688;hp=eb5514d18d4c0dfad271006ba415e11b4f903a2c;hpb=bf56fce1fb45b83747527e6312f61c0fcf3789b8;p=dpdk.git diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index eb5514d18d..8cf537d594 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -84,7 +84,6 @@ #include #include #include -#include #include #include #include @@ -92,6 +91,7 @@ #include #include #include +#include #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; } - xstats = malloc(sizeof(xstats[0]) * len); + + /* 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; + } + + /* 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); } @@ -400,10 +454,13 @@ port_infos_display(portid_t port_id) } port = &ports[port_id]; rte_eth_link_get_nowait(port_id, &link); + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(port_id, &dev_info); 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); + printf("\nDriver name: %s", dev_info.driver_name); printf("\nConnect to socket: %u", port->socket_id); if (port_numa[port_id] != NUMA_NO_CONFIG) { @@ -446,8 +503,6 @@ port_infos_display(portid_t port_id) printf(" qinq(extend) off \n"); } - memset(&dev_info, 0, sizeof(dev_info)); - rte_eth_dev_info_get(port_id, &dev_info); if (dev_info.hash_key_size > 0) printf("Hash key size in bytes: %u\n", dev_info.hash_key_size); if (dev_info.reta_size > 0) @@ -899,7 +954,7 @@ rxtx_config_display(void) rx_mode.hw_strip_crc ? "enabled" : "disabled", nb_pkt_per_burst); - if (cur_fwd_eng == &tx_only_engine) + if (cur_fwd_eng == &tx_only_engine || cur_fwd_eng == &flow_gen_engine) printf(" packet len=%u - nb packet segments=%d\n", (unsigned)tx_pkt_length, (int) tx_pkt_nb_segs); @@ -957,14 +1012,26 @@ void port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key) { struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[10 * 4] = ""; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; uint64_t rss_hf; uint8_t i; int diag; + struct rte_eth_dev_info dev_info; + uint8_t hash_key_size; if (port_id_is_invalid(port_id, ENABLED_WARN)) return; + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(port_id, &dev_info); + if (dev_info.hash_key_size > 0 && + dev_info.hash_key_size <= sizeof(rss_key)) + hash_key_size = dev_info.hash_key_size; + else { + printf("dev_info did not provide a valid hash key size\n"); + return; + } + rss_conf.rss_hf = 0; for (i = 0; i < RTE_DIM(rss_type_table); i++) { if (!strcmp(rss_info, rss_type_table[i].str)) @@ -973,7 +1040,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key) /* Get RSS hash key if asked to display it */ rss_conf.rss_key = (show_rss_key) ? rss_key : NULL; - rss_conf.rss_key_len = sizeof(rss_key); + rss_conf.rss_key_len = hash_key_size; diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf); if (diag != 0) { switch (diag) { @@ -1003,7 +1070,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key) if (!show_rss_key) return; printf("RSS key:\n"); - for (i = 0; i < sizeof(rss_key); i++) + for (i = 0; i < hash_key_size; i++) printf("%02X", rss_key[i]); printf("\n"); } @@ -1146,14 +1213,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 +1229,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 +1238,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 +1248,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); @@ -1998,26 +2058,33 @@ set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value) static inline void print_fdir_mask(struct rte_eth_fdir_masks *mask) { - printf("\n vlan_tci: 0x%04x, ", mask->vlan_tci_mask); + printf("\n vlan_tci: 0x%04x", rte_be_to_cpu_16(mask->vlan_tci_mask)); - if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) - printf("mac_addr: 0x%02x", mask->mac_addr_byte_mask); - else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) - printf("mac_addr: 0x%02x, tunnel_type: 0x%01x, tunnel_id: 0x%08x", + if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) + printf(", mac_addr: 0x%02x, tunnel_type: 0x%01x," + " tunnel_id: 0x%08x", mask->mac_addr_byte_mask, mask->tunnel_type_mask, - mask->tunnel_id_mask); - else { - printf("src_ipv4: 0x%08x, dst_ipv4: 0x%08x," - " src_port: 0x%04x, dst_port: 0x%04x", - mask->ipv4_mask.src_ip, mask->ipv4_mask.dst_ip, - mask->src_port_mask, mask->dst_port_mask); + rte_be_to_cpu_32(mask->tunnel_id_mask)); + else if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN) { + printf(", src_ipv4: 0x%08x, dst_ipv4: 0x%08x", + rte_be_to_cpu_32(mask->ipv4_mask.src_ip), + rte_be_to_cpu_32(mask->ipv4_mask.dst_ip)); + + printf("\n src_port: 0x%04x, dst_port: 0x%04x", + rte_be_to_cpu_16(mask->src_port_mask), + rte_be_to_cpu_16(mask->dst_port_mask)); + + printf("\n src_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x", + rte_be_to_cpu_32(mask->ipv6_mask.src_ip[0]), + rte_be_to_cpu_32(mask->ipv6_mask.src_ip[1]), + rte_be_to_cpu_32(mask->ipv6_mask.src_ip[2]), + rte_be_to_cpu_32(mask->ipv6_mask.src_ip[3])); - printf("\n src_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x," - " dst_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x", - mask->ipv6_mask.src_ip[0], mask->ipv6_mask.src_ip[1], - mask->ipv6_mask.src_ip[2], mask->ipv6_mask.src_ip[3], - mask->ipv6_mask.dst_ip[0], mask->ipv6_mask.dst_ip[1], - mask->ipv6_mask.dst_ip[2], mask->ipv6_mask.dst_ip[3]); + printf("\n dst_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x", + rte_be_to_cpu_32(mask->ipv6_mask.dst_ip[0]), + rte_be_to_cpu_32(mask->ipv6_mask.dst_ip[1]), + rte_be_to_cpu_32(mask->ipv6_mask.dst_ip[2]), + rte_be_to_cpu_32(mask->ipv6_mask.dst_ip[3])); } printf("\n"); @@ -2071,6 +2138,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++) {