+ 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_tx_done_cleanup_clean =
+ TOKEN_STRING_INITIALIZER(struct cmd_tx_done_cleanup_result, clean,
+ "tx_done_cleanup");
+cmdline_parse_token_string_t cmd_tx_done_cleanup_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_tx_done_cleanup_result, port,
+ "port");
+cmdline_parse_token_num_t cmd_tx_done_cleanup_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_tx_done_cleanup_result, port_id,
+ UINT16);
+cmdline_parse_token_num_t cmd_tx_done_cleanup_queue_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_tx_done_cleanup_result, queue_id,
+ UINT16);
+cmdline_parse_token_num_t cmd_tx_done_cleanup_free_cnt =
+ TOKEN_NUM_INITIALIZER(struct cmd_tx_done_cleanup_result, free_cnt,
+ UINT32);
+
+cmdline_parse_inst_t cmd_tx_done_cleanup = {
+ .f = cmd_tx_done_cleanup_parsed,
+ .data = NULL,
+ .help_str = "tx_done_cleanup port <port_id> <queue_id> <free_cnt>",
+ .tokens = {
+ (void *)&cmd_tx_done_cleanup_clean,
+ (void *)&cmd_tx_done_cleanup_port,
+ (void *)&cmd_tx_done_cleanup_port_id,
+ (void *)&cmd_tx_done_cleanup_queue_id,
+ (void *)&cmd_tx_done_cleanup_free_cnt,
+ NULL,
+ },
+};
+
/*
********************************************************************************
*/
/* list of instructions */
@@ -17040,6 +17123,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_config_rss_reta,
(cmdline_parse_inst_t *)&cmd_showport_reta,
(cmdline_parse_inst_t *)&cmd_showport_macs,
+ (cmdline_parse_inst_t *)&cmd_tx_done_cleanup,
(cmdline_parse_inst_t *)&cmd_config_burst,
(cmdline_parse_inst_t *)&cmd_config_thresh,
(cmdline_parse_inst_t *)&cmd_config_threshold,
diff --git a/doc/guides/rel_notes/release_21_05.rst
b/doc/guides/rel_notes/release_21_05.rst
index 4538bb9..554499f 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -217,6 +217,8 @@ New Features
``show port (port_id) rxq (queue_id) desc used count``
* Added command to dump internal representation information of
single flow.
``flow dump (port_id) rule (rule_id)``
+ * Added command to cleanup a Tx queue's mbuf on a port.
+ ``tx_done_cleanup port <port_id> <queue_id> <free_cnt>``
* **Updated ipsec-secgw sample application.**
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a736e7d..6472647 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -270,6 +270,17 @@ and ready to be processed by the driver on a
given RX queue::
testpmd> show port (port_id) rxq (queue_id) desc used count
+cleanup txq mbufs
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Request the driver to free mbufs currently cached by the driver for a
given port's
+Tx queue::
+ testpmd> tx_done_cleanup port (port_id) (queue_id) (free_cnt)
+
+.. note::
+ This command is dangerous, users must make sure there are no
cucurrent access to
+ the same Tx queue (link rte_eth_tx_burst,
rte_eth_dev_tx_queue_stop and so on).
+
show config
~~~~~~~~~~~