X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Fcmdline.c;h=8468018cf35d08770202b20636a668fc289d9e52;hb=b3025311cd493ccaea50f103ae0d4734d7bc4132;hp=11f9c015c975291439a42fc3ba5fef2ac9320e3f;hpb=f29fa2c59b858dc725c3d8486eddb59797bbb6dc;p=dpdk.git diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 11f9c015c9..8468018cf3 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -8,12 +8,8 @@ #include #include #include -#include #include #include -#include -#include - #include #include @@ -258,6 +254,9 @@ static void cmd_help_long_parsed(void *parsed_result, "show port (port_id) fec_mode" " Show fec mode of a port.\n\n" + + "show port (port_id) flow_ctrl" + " Show flow control info of a port.\n\n" ); } @@ -908,6 +907,9 @@ static void cmd_help_long_parsed(void *parsed_result, " Register a dynf and Set/clear this flag on Tx. " "Testpmd will set this value to any Tx packet " "sent from this port\n\n" + + "port cleanup (port_id) txq (queue_id) (free_cnt)\n" + " Cleanup txq mbufs for a specific Tx queue\n\n" ); } @@ -1617,13 +1619,13 @@ cmd_config_speed_specific_parsed(void *parsed_result, struct cmd_config_speed_specific *res = parsed_result; uint32_t link_speed; - if (!all_ports_stopped()) { - printf("Please stop all ports first\n"); + if (port_id_is_invalid(res->id, ENABLED_WARN)) return; - } - if (port_id_is_invalid(res->id, ENABLED_WARN)) + if (!port_is_stopped(res->id)) { + printf("Please stop port %d first\n", res->id); return; + } if (parse_and_check_speed_duplex(res->value1, res->value2, &link_speed) < 0) @@ -2458,6 +2460,90 @@ cmdline_parse_inst_t cmd_config_rss_hash_key = { }, }; +/* *** cleanup txq mbufs *** */ +struct cmd_cleanup_txq_mbufs_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t keyword; + cmdline_fixed_string_t name; + uint16_t port_id; + uint16_t queue_id; + uint32_t free_cnt; +}; + +static void +cmd_cleanup_txq_mbufs_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_cleanup_txq_mbufs_result *res = parsed_result; + uint16_t port_id = res->port_id; + uint16_t queue_id = res->queue_id; + uint32_t free_cnt = res->free_cnt; + struct rte_eth_txq_info qinfo; + int ret; + + if (test_done == 0) { + printf("Please stop forwarding first\n"); + return; + } + + if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) { + printf("Failed to get port %u Tx queue %u info\n", + port_id, queue_id); + return; + } + + if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) { + printf("Tx queue %u not started\n", queue_id); + return; + } + + ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt); + if (ret < 0) { + printf("Failed to cleanup mbuf for port %u Tx queue %u " + "error desc: %s(%d)\n", + port_id, queue_id, strerror(-ret), ret); + return; + } + + printf("Cleanup port %u Tx queue %u mbuf nums: %u\n", + port_id, queue_id, ret); +} + +cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port = + TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port, + "port"); +cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup = + TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword, + "cleanup"); +cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id, + RTE_UINT16); +cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq = + TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name, + "txq"); +cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id = + TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id, + RTE_UINT16); +cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt = + TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt, + RTE_UINT32); + +cmdline_parse_inst_t cmd_cleanup_txq_mbufs = { + .f = cmd_cleanup_txq_mbufs_parsed, + .data = NULL, + .help_str = "port cleanup txq ", + .tokens = { + (void *)&cmd_cleanup_txq_mbufs_port, + (void *)&cmd_cleanup_txq_mbufs_cleanup, + (void *)&cmd_cleanup_txq_mbufs_port_id, + (void *)&cmd_cleanup_txq_mbufs_txq, + (void *)&cmd_cleanup_txq_mbufs_queue_id, + (void *)&cmd_cleanup_txq_mbufs_free_cnt, + NULL, + }, +}; + /* *** configure port rxq/txq ring size *** */ struct cmd_config_rxtx_ring_size { cmdline_fixed_string_t port; @@ -2820,6 +2906,10 @@ cmd_setup_rxtx_queue_parsed( if (!numa_support || socket_id == NUMA_NO_CONFIG) socket_id = port->socket_id; + if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) { + printf("Failed to setup TX queue: not enough descriptors\n"); + return; + } ret = rte_eth_tx_queue_setup(res->portid, res->qid, port->nb_tx_desc[res->qid], @@ -3176,6 +3266,7 @@ cmd_config_dcb_parsed(void *parsed_result, __rte_unused void *data) { struct cmd_config_dcb *res = parsed_result; + struct rte_eth_dcb_info dcb_info; portid_t port_id = res->port_id; struct rte_port *port; uint8_t pfc_en; @@ -3198,6 +3289,14 @@ cmd_config_dcb_parsed(void *parsed_result, printf("nb_cores shouldn't be less than number of TCs.\n"); return; } + + /* Check whether the port supports the report of DCB info. */ + ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info); + if (ret == -ENOTSUP) { + printf("rte_eth_dev_get_dcb_info not supported.\n"); + return; + } + if (!strncmp(res->pfc_en, "on", 2)) pfc_en = 1; else @@ -3212,13 +3311,13 @@ cmd_config_dcb_parsed(void *parsed_result, ret = init_port_dcb_config(port_id, DCB_ENABLED, (enum rte_eth_nb_tcs)res->num_tcs, pfc_en); - - if (ret != 0) { printf("Cannot initialize network ports.\n"); return; } + fwd_config_setup(); + cmd_reconfig_device_queue(port_id, 1, 1); } @@ -3511,7 +3610,7 @@ cmdline_parse_inst_t cmd_stop = { /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ unsigned int -parse_item_list(char* str, const char* item_name, unsigned int max_items, +parse_item_list(const char *str, const char *item_name, unsigned int max_items, unsigned int *parsed_items, int check_unique_values) { unsigned int nb_item; @@ -4576,7 +4675,7 @@ cmd_config_queue_tx_offloads(struct rte_port *port) int k; /* Apply queue tx offloads configuration */ - for (k = 0; k < port->dev_info.max_rx_queues; k++) + for (k = 0; k < port->dev_info.max_tx_queues; k++) port->tx_conf[k].offloads = port->dev_conf.txmode.offloads; } @@ -6869,6 +6968,80 @@ cmdline_parse_inst_t cmd_set_allmulti_mode_one = { }, }; +/* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */ +struct cmd_link_flow_ctrl_show { + cmdline_fixed_string_t show; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t flow_ctrl; +}; + +cmdline_parse_token_string_t cmd_lfc_show_show = + TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, + show, "show"); +cmdline_parse_token_string_t cmd_lfc_show_port = + TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, + port, "port"); +cmdline_parse_token_num_t cmd_lfc_show_portid = + TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl = + TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, + flow_ctrl, "flow_ctrl"); + +static void +cmd_link_flow_ctrl_show_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_link_flow_ctrl_show *res = parsed_result; + static const char *info_border = "*********************"; + struct rte_eth_fc_conf fc_conf; + bool rx_fc_en = false; + bool tx_fc_en = false; + int ret; + + ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); + if (ret != 0) { + printf("Failed to get current flow ctrl information: err = %d\n", + ret); + return; + } + + if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL) + rx_fc_en = true; + if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL) + tx_fc_en = true; + + printf("\n%s Flow control infos for port %-2d %s\n", + info_border, res->port_id, info_border); + printf("FC mode:\n"); + printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off"); + printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off"); + printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off"); + printf("Pause time: 0x%x\n", fc_conf.pause_time); + printf("High waterline: 0x%x\n", fc_conf.high_water); + printf("Low waterline: 0x%x\n", fc_conf.low_water); + printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off"); + printf("Forward MAC control frames: %s\n", + fc_conf.mac_ctrl_frame_fwd ? "on" : "off"); + printf("\n%s************** End ***********%s\n", + info_border, info_border); +} + +cmdline_parse_inst_t cmd_link_flow_control_show = { + .f = cmd_link_flow_ctrl_show_parsed, + .data = NULL, + .help_str = "show port flow_ctrl", + .tokens = { + (void *)&cmd_lfc_show_show, + (void *)&cmd_lfc_show_port, + (void *)&cmd_lfc_show_portid, + (void *)&cmd_lfc_show_flow_ctrl, + NULL, + }, +}; + /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ struct cmd_link_flow_ctrl_set_result { cmdline_fixed_string_t set; @@ -9563,7 +9736,7 @@ dump_socket_mem(FILE *f) fprintf(f, "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), - (double)alloc * 100 / (double)total, + total ? ((double)alloc * 100 / (double)total) : 0, (double)free / (1024 * 1024), n_alloc, n_free); if (last_allocs) @@ -16820,17 +16993,17 @@ cmd_set_port_fec_mode_parsed( { struct cmd_set_port_fec_mode *res = parsed_result; uint16_t port_id = res->port_id; - uint32_t mode; + uint32_t fec_capa; int ret; - ret = parse_fec_mode(res->fec_value, &mode); + ret = parse_fec_mode(res->fec_value, &fec_capa); if (ret < 0) { printf("Unknown fec mode: %s for Port %d\n", res->fec_value, port_id); return; } - ret = rte_eth_fec_set(port_id, mode); + ret = rte_eth_fec_set(port_id, fec_capa); if (ret == -ENOTSUP) { printf("Function not implemented\n"); return; @@ -17360,6 +17533,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, + (cmdline_parse_inst_t *)&cmd_link_flow_control_show, (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, (cmdline_parse_inst_t *)&cmd_config_dcb, (cmdline_parse_inst_t *)&cmd_read_reg, @@ -17413,6 +17587,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_showport_rss_hash, (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, + (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, #ifdef RTE_NET_I40E