From: Chen Jing D(Mark) Date: Thu, 14 Aug 2014 07:35:00 +0000 (+0800) Subject: testpmd: queue start and stop X-Git-Tag: spdx-start~10465 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5f4ec54f1d16;p=dpdk.git testpmd: queue start and stop The API provides functions to start/stop specific RX/TX queues (see 0748be2). This change adds command in testpmd to start/stop specific RX/TX queues. Signed-off-by: Chen Jing D(Mark) Reviewed-by: Konstantin Ananyev Reviewed-by: Changchun Ouyang Reviewed-by: Huawei Xie --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0abc23315d..b04a4e8a14 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -566,6 +566,10 @@ static void cmd_help_long_parsed(void *parsed_result, " tx rs bit threshold.\n\n" "port config mtu X value\n" " Set the MTU of port X to a given value\n\n" + + "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" + " Start/stop a rx/tx queue of port X. Only take effect" + " when port X is started\n" ); } @@ -1430,6 +1434,96 @@ cmdline_parse_inst_t cmd_config_rss_hash_key = { }, }; +/* *** configure port rxq/txq start/stop *** */ +struct cmd_config_rxtx_queue { + cmdline_fixed_string_t port; + uint8_t portid; + cmdline_fixed_string_t rxtxq; + uint16_t qid; + cmdline_fixed_string_t opname; +}; + +static void +cmd_config_rxtx_queue_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_rxtx_queue *res = parsed_result; + uint8_t isrx; + uint8_t isstart; + + if (test_done == 0) { + printf("Please stop forwarding first\n"); + return; + } + + if (port_id_is_invalid(res->portid)) + return; + + if (port_is_started(res->portid) != 1) { + printf("Please start port %u first\n", res->portid); + return; + } + + if (!strcmp(res->rxtxq, "rxq")) + isrx = 1; + else if (!strcmp(res->rxtxq, "txq")) + isrx = 0; + else { + printf("Unknown parameter\n"); + return; + } + + if (isrx && rx_queue_id_is_invalid(res->qid)) + return; + else if (!isrx && tx_queue_id_is_invalid(res->qid)) + return; + + if (!strcmp(res->opname, "start")) + isstart = 1; + else if (!strcmp(res->opname, "stop")) + isstart = 0; + else { + printf("Unknown parameter\n"); + return; + } + + if (isstart && isrx) + rte_eth_dev_rx_queue_start(res->portid, res->qid); + else if (!isstart && isrx) + rte_eth_dev_rx_queue_stop(res->portid, res->qid); + else if (isstart && !isrx) + rte_eth_dev_tx_queue_start(res->portid, res->qid); + else + rte_eth_dev_tx_queue_stop(res->portid, res->qid); +} + +cmdline_parse_token_string_t cmd_config_rxtx_queue_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); +cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = + TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8); +cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = + TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); +cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = + TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); +cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = + TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, + "start#stop"); + +cmdline_parse_inst_t cmd_config_rxtx_queue = { + .f = cmd_config_rxtx_queue_parsed, + .data = NULL, + .help_str = "port X rxq|txq ID start|stop", + .tokens = { + (void *)&cmd_config_speed_all_port, + (void *)&cmd_config_rxtx_queue_portid, + (void *)&cmd_config_rxtx_queue_rxtxq, + (void *)&cmd_config_rxtx_queue_qid, + (void *)&cmd_config_rxtx_queue_opname, + NULL, + }, +}; + /* *** Configure RSS RETA *** */ struct cmd_config_rss_reta { cmdline_fixed_string_t port; @@ -7398,6 +7492,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, (cmdline_parse_inst_t *)&cmd_config_rss, + (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, (cmdline_parse_inst_t *)&cmd_config_rss_reta, (cmdline_parse_inst_t *)&cmd_showport_reta, (cmdline_parse_inst_t *)&cmd_config_burst, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c72f6ee67d..606e34a85b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -311,7 +311,7 @@ port_infos_display(portid_t port_id) } } -static int +int port_id_is_invalid(portid_t port_id) { if (port_id < nb_ports) @@ -521,7 +521,7 @@ port_mtu_set(portid_t port_id, uint16_t mtu) /* * RX/TX ring descriptors display functions. */ -static int +int rx_queue_id_is_invalid(queueid_t rxq_id) { if (rxq_id < nb_rxq) @@ -530,7 +530,7 @@ rx_queue_id_is_invalid(queueid_t rxq_id) return 1; } -static int +int tx_queue_id_is_invalid(queueid_t txq_id) { if (txq_id < nb_txq) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index e8a4b45d7d..a112559d8d 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1513,6 +1513,18 @@ all_ports_stopped(void) return 1; } +int +port_is_started(portid_t port_id) +{ + if (port_id_is_invalid(port_id)) + return -1; + + if (ports[port_id].port_status != RTE_PORT_STARTED) + return 0; + + return 1; +} + void pmd_test_exit(void) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ac86bfefd4..b8322a2181 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -511,6 +511,7 @@ int start_port(portid_t pid); void stop_port(portid_t pid); void close_port(portid_t pid); int all_ports_stopped(void); +int port_is_started(portid_t port_id); void pmd_test_exit(void); void fdir_add_signature_filter(portid_t port_id, uint8_t queue_id, @@ -547,6 +548,9 @@ void get_ethertype_filter(uint8_t port_id, uint16_t index); void get_2tuple_filter(uint8_t port_id, uint16_t index); void get_5tuple_filter(uint8_t port_id, uint16_t index); void get_flex_filter(uint8_t port_id, uint16_t index); +int port_id_is_invalid(portid_t port_id); +int rx_queue_id_is_invalid(queueid_t rxq_id); +int tx_queue_id_is_invalid(queueid_t txq_id); /* * Work-around of a compilation error with ICC on invocations of the