From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D28754265D; Thu, 28 Sep 2023 09:46:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B55BA40DDB; Thu, 28 Sep 2023 09:46:29 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 549F2402F0 for ; Thu, 28 Sep 2023 09:46:17 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rx56T5yjHzNnp5; Thu, 28 Sep 2023 15:42:25 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 28 Sep 2023 15:46:15 +0800 From: Jie Hai To: , Aman Singh , Yuying Zhang , Anatoly Burakov , Dmitry Kozlyuk , Matan Azrad CC: , Subject: [PATCH v2 8/8] app/testpmd: fix primary process not polling all queues Date: Thu, 28 Sep 2023 15:43:05 +0800 Message-ID: <20230928074305.2991100-9-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230928074305.2991100-1-haijie1@huawei.com> References: <20230908112901.1169869-1-haijie1@huawei.com> <20230928074305.2991100-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected 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 Here's how the problem arises. step1: Start the app. dpdk-testpmd -a 0000:35:00.0 -l 0-3 -- -i --rxq=10 --txq=10 step2: Perform the following steps and send traffic. As expected, queue 7 does not send or receive packets, and other queues do. port 0 rxq 7 stop port 0 txq 7 stop set fwd mac start step3: Perform the following steps and send traffic. All queues are expected to send and receive packets normally, but that's not the case for queue 7. stop port stop all port start all start show port xstats all In fact, only the value of rx_q7_packets for queue 7 is not zero, which means queue 7 is enabled for the driver but is not involved in packet receiving and forwarding by software. If we check queue state by command 'show rxq info 0 7' and 'show txq info 0 7', we see queue 7 is started as other queues are. Rx queue state: started Tx queue state: started The queue 7 is started but cannot forward. That's the problem. We know that each stream has a read-only "disabled" field that control if this stream should be used to forward. This field depends on testpmd local queue state, please see commit 3c4426db54fc ("app/testpmd: do not poll stopped queues"). DPDK framework maintains ethdev queue state that drivers reported, which indicates the real state of queues. There are commands that update these two kind queue state such as 'port X rxq|txq start|stop'. But these operations take effect only in one stop-start round. In the following stop-start round, the preceding operations do not take effect anymore. However, only the ethdev queue state is updated, causing the testpmd and ethdev state information to diverge and causing unexpected side effects as above problem. There was a similar problem for the secondary process, please see commit 5028f207a4fa ("app/testpmd: fix secondary process packet forwarding"). This patch applies its workaround with some difference to the primary process. Not all PMDs implement rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get, however they may support deferred_start with primary process. To not break their behavior, retain the original testpmd local queue state for those PMDs. Fixes: 3c4426db54fc ("app/testpmd: do not poll stopped queues") Cc: stable@dpdk.org Signed-off-by: Jie Hai Acked-by: Ferruh Yigit --- app/test-pmd/testpmd.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 938ca035d4f8..079ef3392014 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2424,6 +2424,13 @@ update_rx_queue_state(uint16_t port_id, uint16_t queue_id) ports[port_id].rxq[queue_id].state = rx_qinfo.queue_state; } else if (rc == -ENOTSUP) { + /* + * Do not change the rxq state for primary process + * to ensure that the PMDs do not implement + * rte_eth_rx_queue_info_get can forward as before. + */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + return; /* * Set the rxq state to RTE_ETH_QUEUE_STATE_STARTED * to ensure that the PMDs do not implement @@ -2449,6 +2456,13 @@ update_tx_queue_state(uint16_t port_id, uint16_t queue_id) ports[port_id].txq[queue_id].state = tx_qinfo.queue_state; } else if (rc == -ENOTSUP) { + /* + * Do not change the txq state for primary process + * to ensure that the PMDs do not implement + * rte_eth_tx_queue_info_get can forward as before. + */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + return; /* * Set the txq state to RTE_ETH_QUEUE_STATE_STARTED * to ensure that the PMDs do not implement @@ -2463,12 +2477,15 @@ update_tx_queue_state(uint16_t port_id, uint16_t queue_id) } static void -update_queue_state(void) +update_queue_state(portid_t pid) { portid_t pi; queueid_t qi; RTE_ETH_FOREACH_DEV(pi) { + if (pid != pi && pid != (portid_t)RTE_PORT_ALL) + continue; + for (qi = 0; qi < nb_rxq; qi++) update_rx_queue_state(pi, qi); for (qi = 0; qi < nb_txq; qi++) @@ -2516,8 +2533,7 @@ start_packet_forwarding(int with_tx_first) return; if (stream_init != NULL) { - if (rte_eal_process_type() == RTE_PROC_SECONDARY) - update_queue_state(); + update_queue_state(RTE_PORT_ALL); for (i = 0; i < cur_fwd_config.nb_fwd_streams; i++) stream_init(fwd_streams[i]); } @@ -3280,8 +3296,7 @@ start_port(portid_t pid) pl[cfg_pi++] = pi; } - if (rte_eal_process_type() == RTE_PROC_SECONDARY) - update_queue_state(); + update_queue_state(pi); if (at_least_one_port_successfully_started && !no_link_check) check_all_ports_link_status(RTE_PORT_ALL); -- 2.30.0