[dpdk-dev] [PATCH 1/4] testpmd: add command to start/stop specfic queue

Chen Jing D(Mark) jing.d.chen at intel.com
Thu Aug 14 09:35:00 CEST 2014


From: "Chen Jing D(Mark)" <jing.d.chen at intel.com>

rte_ether library provide function pointer to start/stop specific
RX/TX queue, NIC driver also implemented functions. This change
adds command in testpmd to start/stop specific RX/TX queue.

Signed-off-by: Chen Jing D(Mark) <jing.d.chen at intel.com>
Reviewed-by: Konstantin Ananyev <konstantin.ananyev at intel.com>
Reviewed-by: Changchun Ouyang <changchun.ouyang at intel.com>
Reviewed-by: Huawei Xie <huawei.xie at intel.com>
---
 app/test-pmd/cmdline.c |   95 ++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |    6 ++--
 app/test-pmd/testpmd.c |   12 ++++++
 app/test-pmd/testpmd.h |    4 ++
 4 files changed, 114 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 345be11..ddf5def 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -565,6 +565,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"
 		);
 	}
 
@@ -1425,6 +1429,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;
@@ -7393,6 +7487,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 c72f6ee..606e34a 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 e8a4b45..a112559 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 ac86bfe..b8322a2 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
-- 
1.7.7.6



More information about the dev mailing list