From patchwork Fri Mar 5 00:55:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 88492 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 DC217A0561; Fri, 5 Mar 2021 01:55:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B81222A2FA; Fri, 5 Mar 2021 01:55:21 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id BAEB622A2DA for ; Fri, 5 Mar 2021 01:55:16 +0100 (CET) Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Ds8Nb3vYqzMjCY; Fri, 5 Mar 2021 08:53:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Fri, 5 Mar 2021 08:55:12 +0800 From: Lijun Ou To: CC: , Date: Fri, 5 Mar 2021 08:55:55 +0800 Message-ID: <1614905757-33791-2-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614905757-33791-1-git-send-email-oulijun@huawei.com> References: <1614905757-33791-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 1/3] app/testpmd: support Tx mbuf free on demand cmd 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 support tx_done_cleanup command: tx_done_cleanup port (port_id) (queue_id) (free_cnt) User must make sure there are no concurrent access to the same Tx queue (like rte_eth_tx_burst, rte_eth_dev_tx_queue_stop and so on) when this command executed. Signed-off-by: Chengwen Feng Signed-off-by: Lijun Ou --- app/test-pmd/cmdline.c | 91 +++++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ 3 files changed, 100 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 14110eb..832ae70 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -675,6 +676,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set port (port_id) ptype_mask (ptype_mask)\n" " set packet types classification for a specific port\n\n" + "tx_done_cleanup (port_id) (queue_id) (free_cnt)\n" + " Cleanup a tx queue's mbuf on a port\n\n" + "set port (port_id) queue-region region_id (value) " "queue_start_index (value) queue_num (value)\n" " Set a queue region on a port\n\n" @@ -16910,6 +16914,92 @@ cmdline_parse_inst_t cmd_showport_macs = { }, }; +/* *** tx_done_cleanup *** */ +struct cmd_tx_done_cleanup_result { + cmdline_fixed_string_t clean; + cmdline_fixed_string_t port; + uint16_t port_id; + uint16_t queue_id; + uint32_t free_cnt; +}; + +static void +cmd_tx_done_cleanup_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_tx_done_cleanup_result *res = parsed_result; + struct rte_eth_dev *dev; + uint16_t port_id = res->port_id; + uint16_t queue_id = res->queue_id; + uint32_t free_cnt = res->free_cnt; + int ret; + + if (!rte_eth_dev_is_valid_port(port_id)) { + printf("Invalid port_id %u\n", port_id); + return; + } + + dev = &rte_eth_devices[port_id]; + if (queue_id >= dev->data->nb_tx_queues) { + printf("Invalid TX queue_id %u\n", queue_id); + return; + } + + if (dev->data->tx_queue_state[queue_id] != + RTE_ETH_QUEUE_STATE_STARTED) { + printf("TX queue_id %u not started!\n", queue_id); + return; + } + + /* + * rte_eth_tx_done_cleanup is a dataplane API, user must make sure + * there are no concurrent access to the same Tx queue (like + * rte_eth_tx_burst, rte_eth_dev_tx_queue_stop and so on) when this API + * called. + */ + 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 ", + .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 */ @@ -17035,6 +17125,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 23f7f0b..8077573 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -69,6 +69,8 @@ New Features * Added command to display Rx queue used descriptor count. ``show port (port_id) rxq (queue_id) desc used count`` + * Added command to cleanup a Tx queue's mbuf on a port. + ``tx_done_cleanup port `` Removed Items diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f59eb8a..39281f5 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -272,6 +272,13 @@ 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) + show config ~~~~~~~~~~~ From patchwork Fri Mar 5 00:55:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 88491 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 E7F5CA0561; Fri, 5 Mar 2021 01:55:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FE5D22A2EE; Fri, 5 Mar 2021 01:55:20 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id B5AA122A2D6 for ; Fri, 5 Mar 2021 01:55:16 +0100 (CET) Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Ds8Nb4K9qzMjH6; Fri, 5 Mar 2021 08:53:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Fri, 5 Mar 2021 08:55:12 +0800 From: Lijun Ou To: CC: , Date: Fri, 5 Mar 2021 08:55:56 +0800 Message-ID: <1614905757-33791-3-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614905757-33791-1-git-send-email-oulijun@huawei.com> References: <1614905757-33791-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 2/3] app/testpmd: remove forwarding config from parsing Rx and Tx 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: Huisong Li The "fwd_config_setup()" function does release and apply for memory of forwarding flows, and re-establish these flows when rxq/txq or rxd/txd is changed. The function is also called by "start_packet_forwarding()" when user executes "start" cmd. All changes for rxq/txq or rxd/txd can be updated uniformly when this command is executed. Therefore, it is a little redundant in the "cmd_config_rx_tx_parsed" function. In addition, the forwarding flows under one TC is configured based on number of queues allocated to TC. And number of queues allocated to TC is updated after calling "rte_eth_dev_configure" again. If the number of queues is reduced after configuring the DCB, and then, release and apply for flow memory, and reinitialize the forwarding flows under the DCB mode based on the old TC information. As a result, null pointer may be accessed. Like: set nbcore 4 port stop all port config 0 dcb vt off 4 pfc on port start all port stop all port config all rxq 8 port config all txq 8 At the moment, a segmentation fault occurs. Fixes: ce8d561418d4 ("app/testpmd: add port configuration settings") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Lijun Ou --- app/test-pmd/cmdline.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 832ae70..8b0f7d5 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -1837,8 +1837,6 @@ cmd_config_rx_tx_parsed(void *parsed_result, return; } - fwd_config_setup(); - init_port_config(); cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); From patchwork Fri Mar 5 00:55:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 88490 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 39DE6A0561; Fri, 5 Mar 2021 01:55:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 07E6422A2F0; Fri, 5 Mar 2021 01:55:19 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 976B34069F for ; Fri, 5 Mar 2021 01:55:16 +0100 (CET) Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Ds8Nb47SlzMjH3; Fri, 5 Mar 2021 08:53:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Fri, 5 Mar 2021 08:55:12 +0800 From: Lijun Ou To: CC: , Date: Fri, 5 Mar 2021 08:55:57 +0800 Message-ID: <1614905757-33791-4-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614905757-33791-1-git-send-email-oulijun@huawei.com> References: <1614905757-33791-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 3/3] app/testpmd: fix mixed use of RX/Rx/TX/Tx in testpmd 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: Hongbo Zheng In testpmd, when we input "show config rxtx", we can see like this: 1: testpmd> show config rxtx 2: io packet forwarding packets/burst=32 3: nb forwarding cores=1 - nb forwarding ports=1 4: port 0: RX queue number: 1 Tx queue number: 1 5: Rx offloads=0x0 Tx offloads=0x10000 6: RX queue: 0 7: RX desc=1024 - RX free threshold=32 8: RX threshold registers: pthresh=0 hthresh=0 wthresh=0 9: RX Offloads=0x0 10: TX queue: 0 11: TX desc=1024 - TX free threshold=928 12: TX threshold registers: pthresh=0 hthresh=0 wthresh=0 13: TX offloads=0x10000 - TX RS bit threshold=32 In line 4, RX/Tx is mixed used. Also in other lines, RX/Rx/TX/Tx is mixed used. This patch fix the mixed use of RX/Rx/TX/Tx in testpmd command "show config rxtx" output by change to unified use Rx/Tx. Signed-off-by: Hongbo Zheng Signed-off-by: Lijun Ou --- app/test-pmd/config.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 576d5ac..2435c26 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2505,7 +2505,7 @@ rxtx_config_display(void) int32_t rc; /* per port config */ - printf(" port %d: RX queue number: %d Tx queue number: %d\n", + printf(" port %d: Rx queue number: %d Tx queue number: %d\n", (unsigned int)pid, nb_rxq, nb_txq); printf(" Rx offloads=0x%"PRIx64" Tx offloads=0x%"PRIx64"\n", @@ -2533,13 +2533,13 @@ rxtx_config_display(void) offloads_tmp = rx_qinfo.conf.offloads; } - printf(" RX queue: %d\n", qid); - printf(" RX desc=%d - RX free threshold=%d\n", + printf(" Rx queue: %d\n", qid); + printf(" Rx desc=%d - Rx free threshold=%d\n", nb_rx_desc_tmp, rx_free_thresh_tmp); - printf(" RX threshold registers: pthresh=%d hthresh=%d " + printf(" Rx threshold registers: pthresh=%d hthresh=%d " " wthresh=%d\n", pthresh_tmp, hthresh_tmp, wthresh_tmp); - printf(" RX Offloads=0x%"PRIx64"\n", offloads_tmp); + printf(" Rx Offloads=0x%"PRIx64"\n", offloads_tmp); } /* per tx queue config only for first queue to be less verbose */ @@ -2565,13 +2565,13 @@ rxtx_config_display(void) tx_rs_thresh_tmp = tx_qinfo.conf.tx_rs_thresh; } - printf(" TX queue: %d\n", qid); - printf(" TX desc=%d - TX free threshold=%d\n", + printf(" Tx queue: %d\n", qid); + printf(" Tx desc=%d - Tx free threshold=%d\n", nb_tx_desc_tmp, tx_free_thresh_tmp); - printf(" TX threshold registers: pthresh=%d hthresh=%d " + printf(" Tx threshold registers: pthresh=%d hthresh=%d " " wthresh=%d\n", pthresh_tmp, hthresh_tmp, wthresh_tmp); - printf(" TX offloads=0x%"PRIx64" - TX RS bit threshold=%d\n", + printf(" Tx offloads=0x%"PRIx64" - Tx RS bit threshold=%d\n", offloads_tmp, tx_rs_thresh_tmp); } }