From patchwork Wed Apr 21 08:09:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 91932 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DB73AA0548; Wed, 21 Apr 2021 10:09:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BC2104195D; Wed, 21 Apr 2021 10:09:31 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id C758540140 for ; Wed, 21 Apr 2021 10:09:29 +0200 (CEST) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FQCmy2fl9zpZQf; Wed, 21 Apr 2021 16:06:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Wed, 21 Apr 2021 16:09:23 +0800 From: Lijun Ou To: , CC: , Date: Wed, 21 Apr 2021 16:09:37 +0800 Message-ID: <1618992577-26999-1-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618835784-57993-1-git-send-email-oulijun@huawei.com> References: <1618835784-57993-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH V5] app/test-pmd: support cleanup txq mbufs command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Chengwen Feng This patch supports cleanup txq mbufs command: port cleanup (port_id) txq (queue_id) (free_cnt) Signed-off-by: Chengwen Feng Signed-off-by: Lijun Ou --- V4->V5: - rewrite patch title - define the new cmd. - Fix the comments given by Ferruh.yigit V3->V4: - revert the V3 scheme. V2->V3: - The command implementation is changed so that the queuestate does not depend on the command execution. V1->V2: - use Tx instead of TX - add note in doc --- app/test-pmd/cmdline.c | 85 +++++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++ 3 files changed, 96 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index ccaeefa..40389f3 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2455,6 +2455,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; @@ -17490,6 +17574,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 diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index 668fca8..70f10ba 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -230,6 +230,8 @@ New Features * Added commands to construct conntrack context and relevant indirect action handle creation, update for conntrack action as well as conntrack item matching. + * Added command to cleanup a Tx queue's mbuf on a port. + ``port cleanup (port_id) txq (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 5dd98c2..dc7d9ae 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2443,6 +2443,15 @@ hash of input [IP] packets received on port:: ipv6-udp-ex ) +port cleanup txq mbufs +~~~~~~~~~~~~~~~~~~~~~~ + +To cleanup txq mbufs currently cached by driver:: + + testpmd> port cleanup (port_id) txq (queue_id) (free_cnt) + +If the value of ``free_cnt`` is 0, driver should free all cached mbufs. + Device Functions ----------------