X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Ftestpmd.c;h=8ed1b97dec31283d5c02b02f8b6cdb8043456fc6;hb=0f6beb151f5bbcd764d2b16b59c55a35f652b019;hp=2b60f6c5d3b125fd0bb72d6c65a5c4bd9e30f887;hpb=0f93edbf7c874480e21e365f527fecdb305984b9;p=dpdk.git diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 2b60f6c5d3..8ed1b97dec 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -240,14 +240,12 @@ uint32_t tx_pkt_times_intra; /**< Timings for send scheduling in TXONLY mode, time between packets. */ uint16_t nb_pkt_per_burst = DEF_PKT_BURST; /**< Number of packets per burst. */ +uint16_t nb_pkt_flowgen_clones; /**< Number of Tx packet clones to send in flowgen mode. */ uint16_t mb_mempool_cache = DEF_MBUF_CACHE; /**< Size of mbuf mempool cache. */ /* current configuration is in DCB or not,0 means it is not in DCB mode */ uint8_t dcb_config = 0; -/* Whether the dcb is in testing status */ -uint8_t dcb_test = 0; - /* * Configurable number of RX/TX queues. */ @@ -443,8 +441,11 @@ lcoreid_t latencystats_lcore_id = -1; * Ethernet device configuration. */ struct rte_eth_rxmode rx_mode = { - .max_rx_pkt_len = RTE_ETHER_MAX_LEN, - /**< Default maximum frame length. */ + /* Default maximum frame length. + * Zero is converted to "RTE_ETHER_MTU + PMD Ethernet overhead" + * in init_config(). + */ + .max_rx_pkt_len = 0, }; struct rte_eth_txmode tx_mode = { @@ -509,6 +510,11 @@ uint8_t gro_flush_cycles = GRO_DEFAULT_FLUSH_CYCLES; */ enum rte_eth_rx_mq_mode rx_mq_mode = ETH_MQ_RX_VMDQ_DCB_RSS; +/* + * Used to set forced link speed + */ +uint32_t eth_link_speed; + /* Forward function declarations */ static void setup_attached_port(portid_t pi); static void check_all_ports_link_status(uint32_t port_mask); @@ -1446,6 +1452,11 @@ init_config(void) rte_exit(EXIT_FAILURE, "rte_eth_dev_info_get() failed\n"); + ret = update_jumbo_frame_offload(pid); + if (ret != 0) + printf("Updating jumbo frame offload failed for port %u\n", + pid); + if (!(port->dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)) port->dev_conf.txmode.offloads &= @@ -1475,6 +1486,9 @@ init_config(void) port->tx_conf[k].offloads = port->dev_conf.txmode.offloads; + if (eth_link_speed) + port->dev_conf.link_speeds = eth_link_speed; + /* set flag to initialize port/queue */ port->need_reconfig = 1; port->need_reconfig_queues = 1; @@ -1562,10 +1576,6 @@ init_config(void) fwd_lcores[lc_id]->gso_ctx.flag = 0; } - /* Configuration of packet forwarding streams. */ - if (init_fwd_streams() < 0) - rte_exit(EXIT_FAILURE, "FAIL from init_fwd_streams()\n"); - fwd_config_setup(); /* create a gro context for each lcore */ @@ -1787,6 +1797,8 @@ fwd_stream_stats_display(streamid_t stream_id) " Rx- bad outer L4 checksum: %-14"PRIu64"\n", fs->rx_bad_ip_csum, fs->rx_bad_l4_csum, fs->rx_bad_outer_l4_csum); + printf(" RX- bad outer IP checksum: %-14"PRIu64"\n", + fs->rx_bad_outer_ip_csum); } else { printf("\n"); } @@ -1809,6 +1821,7 @@ fwd_stats_display(void) uint64_t rx_bad_ip_csum; uint64_t rx_bad_l4_csum; uint64_t rx_bad_outer_l4_csum; + uint64_t rx_bad_outer_ip_csum; } ports_stats[RTE_MAX_ETHPORTS]; uint64_t total_rx_dropped = 0; uint64_t total_tx_dropped = 0; @@ -1841,6 +1854,8 @@ fwd_stats_display(void) ports_stats[fs->rx_port].rx_bad_l4_csum += fs->rx_bad_l4_csum; ports_stats[fs->rx_port].rx_bad_outer_l4_csum += fs->rx_bad_outer_l4_csum; + ports_stats[fs->rx_port].rx_bad_outer_ip_csum += + fs->rx_bad_outer_ip_csum; if (record_core_cycles) fwd_cycles += fs->core_cycles; @@ -1872,13 +1887,16 @@ fwd_stats_display(void) "RX-total: %-"PRIu64"\n", stats.ipackets, stats.imissed, stats.ipackets + stats.imissed); - if (cur_fwd_eng == &csum_fwd_engine) + if (cur_fwd_eng == &csum_fwd_engine) { printf(" Bad-ipcsum: %-14"PRIu64 " Bad-l4csum: %-14"PRIu64 "Bad-outer-l4csum: %-14"PRIu64"\n", ports_stats[pt_id].rx_bad_ip_csum, ports_stats[pt_id].rx_bad_l4_csum, ports_stats[pt_id].rx_bad_outer_l4_csum); + printf(" Bad-outer-ipcsum: %-14"PRIu64"\n", + ports_stats[pt_id].rx_bad_outer_ip_csum); + } if (stats.ierrors + stats.rx_nombuf > 0) { printf(" RX-error: %-"PRIu64"\n", stats.ierrors); printf(" RX-nombufs: %-14"PRIu64"\n", stats.rx_nombuf); @@ -1956,6 +1974,7 @@ fwd_stats_reset(void) fs->rx_bad_ip_csum = 0; fs->rx_bad_l4_csum = 0; fs->rx_bad_outer_l4_csum = 0; + fs->rx_bad_outer_ip_csum = 0; memset(&fs->rx_burst_stats, 0, sizeof(fs->rx_burst_stats)); memset(&fs->tx_burst_stats, 0, sizeof(fs->tx_burst_stats)); @@ -2115,9 +2134,7 @@ start_packet_forwarding(int with_tx_first) { port_fwd_begin_t port_fwd_begin; port_fwd_end_t port_fwd_end; - struct rte_port *port; unsigned int i; - portid_t pt_id; if (strcmp(cur_fwd_eng->fwd_mode_name, "rxonly") == 0 && !nb_rxq) rte_exit(EXIT_FAILURE, "rxq are 0, cannot use rxonly fwd mode\n"); @@ -2140,24 +2157,6 @@ start_packet_forwarding(int with_tx_first) printf("Packet forwarding already started\n"); return; } - - - if(dcb_test) { - for (i = 0; i < nb_fwd_ports; i++) { - pt_id = fwd_ports_ids[i]; - port = &ports[pt_id]; - if (!port->dcb_flag) { - printf("In DCB mode, all forwarding ports must " - "be configured in this mode.\n"); - return; - } - } - if (nb_fwd_lcores == 1) { - printf("In DCB mode,the nb forwarding cores " - "should be larger than 1.\n"); - return; - } - } test_done = 0; fwd_config_setup(); @@ -2450,8 +2449,6 @@ start_port(portid_t pid) if (port_id_is_invalid(pid, ENABLED_WARN)) return 0; - if(dcb_config) - dcb_test = 1; RTE_ETH_FOREACH_DEV(pi) { if (pid != pi && pid != (portid_t)RTE_PORT_ALL) continue; @@ -2600,8 +2597,10 @@ start_port(portid_t pid) cnt_pi++; /* start port */ - if (rte_eth_dev_start(pi) < 0) { - printf("Fail to start port %d\n", pi); + diag = rte_eth_dev_start(pi); + if (diag < 0) { + printf("Fail to start port %d: %s\n", pi, + rte_strerror(-diag)); /* Fail to setup rx queue, return */ if (rte_atomic16_cmpset(&(port->port_status), @@ -2689,11 +2688,6 @@ stop_port(portid_t pid) portid_t peer_pl[RTE_MAX_ETHPORTS]; int peer_pi; - if (dcb_test) { - dcb_test = 0; - dcb_config = 0; - } - if (port_id_is_invalid(pid, ENABLED_WARN)) return; @@ -2987,8 +2981,6 @@ detach_devargs(char *identifier) memset(&da, 0, sizeof(da)); if (rte_devargs_parsef(&da, "%s", identifier)) { printf("cannot parse identifier\n"); - if (da.args) - free(da.args); return; } @@ -2997,6 +2989,7 @@ detach_devargs(char *identifier) if (ports[port_id].port_status != RTE_PORT_STOPPED) { printf("Port %u not stopped\n", port_id); rte_eth_iterator_cleanup(&iterator); + rte_devargs_reset(&da); return; } port_flow_flush(port_id); @@ -3006,6 +2999,7 @@ detach_devargs(char *identifier) if (rte_eal_hotplug_remove(da.bus->name, da.name) != 0) { TESTPMD_LOG(ERR, "Failed to detach device %s(%s)\n", da.name, da.bus->name); + rte_devargs_reset(&da); return; } @@ -3014,6 +3008,7 @@ detach_devargs(char *identifier) printf("Device %s is detached\n", identifier); printf("Now total ports is %d\n", nb_ports); printf("Done\n"); + rte_devargs_reset(&da); } void @@ -3340,6 +3335,80 @@ rxtx_port_config(struct rte_port *port) } } +/* + * Helper function to arrange max_rx_pktlen value and JUMBO_FRAME offload, + * MTU is also aligned if JUMBO_FRAME offload is not set. + * + * port->dev_info should be set before calling this function. + * + * return 0 on success, negative on error + */ +int +update_jumbo_frame_offload(portid_t portid) +{ + struct rte_port *port = &ports[portid]; + uint32_t eth_overhead; + uint64_t rx_offloads; + int ret; + bool on; + + /* Update the max_rx_pkt_len to have MTU as RTE_ETHER_MTU */ + if (port->dev_info.max_mtu != UINT16_MAX && + port->dev_info.max_rx_pktlen > port->dev_info.max_mtu) + eth_overhead = port->dev_info.max_rx_pktlen - + port->dev_info.max_mtu; + else + eth_overhead = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; + + rx_offloads = port->dev_conf.rxmode.offloads; + + /* Default config value is 0 to use PMD specific overhead */ + if (port->dev_conf.rxmode.max_rx_pkt_len == 0) + port->dev_conf.rxmode.max_rx_pkt_len = RTE_ETHER_MTU + eth_overhead; + + if (port->dev_conf.rxmode.max_rx_pkt_len <= RTE_ETHER_MTU + eth_overhead) { + rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; + on = false; + } else { + if ((port->dev_info.rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) { + printf("Frame size (%u) is not supported by port %u\n", + port->dev_conf.rxmode.max_rx_pkt_len, + portid); + return -1; + } + rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; + on = true; + } + + if (rx_offloads != port->dev_conf.rxmode.offloads) { + uint16_t qid; + + port->dev_conf.rxmode.offloads = rx_offloads; + + /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */ + for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) { + if (on) + port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; + else + port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; + } + } + + /* If JUMBO_FRAME is set MTU conversion done by ethdev layer, + * if unset do it here + */ + if ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) { + ret = rte_eth_dev_set_mtu(portid, + port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead); + if (ret) + printf("Failed to set MTU to %u for port %u\n", + port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead, + portid); + } + + return 0; +} + void init_port_config(void) { @@ -3522,8 +3591,6 @@ init_port_dcb_config(portid_t pid, rte_port = &ports[pid]; memset(&port_conf, 0, sizeof(struct rte_eth_conf)); - /* Enter DCB configuration status */ - dcb_config = 1; port_conf.rxmode = rte_port->dev_conf.rxmode; port_conf.txmode = rte_port->dev_conf.txmode; @@ -3591,6 +3658,9 @@ init_port_dcb_config(portid_t pid, rte_port->dcb_flag = 1; + /* Enter DCB configuration status */ + dcb_config = 1; + return 0; }