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 12F3941E17 for ; Wed, 8 Mar 2023 09:48:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C850A4113C; Wed, 8 Mar 2023 09:48:02 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id A00A340ED6; Wed, 8 Mar 2023 09:48:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678265280; x=1709801280; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qU7+nlbqPNwiQdklsqdpn3odi5YvXPxBujkZGrFApa0=; b=W+AGB5NYq6kbXuDGMW2NPMDgdIeWOMf82BP+cquwBsDB4z+FvITRR6A4 +M/VKBbDfQQqhWO+v0rGV9X05wGfbMHtqlaiLGi/uKJFmUBYcyL+P2FZA sTaoaziieHR9ZPUwlGO/8Ld44TEXzvFBQymQelRk3HEVdlTcFhgDLKM+B 1UTaX/kEsbaPUXLBcKW7PQ0oOMLcm8yRHAXyTtwrsqp3DYYfwOpZbqWL9 3OpLqpXTSnhpPiN4/rHe5AjnBF6td9ymIaL9JUQNgHtjvuHdSI+pKODKi rEaPMqJroxrdUaz3ffZjffRVr2W9YIF7PD+udCPNLejwSLn+f3PISAVp7 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="398680720" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="398680720" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2023 00:47:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="654273520" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="654273520" Received: from unknown (HELO root..) ([10.239.252.115]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2023 00:47:56 -0800 From: Shiyang He To: dev@dpdk.org Cc: yidingx.zhou@intel.com, Shiyang He , stable@dpdk.org, Aman Singh , Yuying Zhang , Anatoly Burakov , Matan Azrad , Dmitry Kozlyuk Subject: [PATCH v4] app/testpmd: fix secondary process not forwarding Date: Wed, 8 Mar 2023 16:19:47 +0000 Message-Id: <20230308161947.700659-1-shiyangx.he@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230223144106.707999-1-shiyangx.he@intel.com> References: <20230223144106.707999-1-shiyangx.he@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Under multi-process scenario, the secondary process gets queue state from the wrong location (the global variable 'ports'). Therefore, the secondary process can not forward since "stream_init" is not called. This commit fixes the issue by calling 'rte_eth_rx/tx_queue_info_get' to get queue state from shared memory. Fixes: 3c4426db54fc ("app/testpmd: do not poll stopped queues") Cc: stable@dpdk.org Signed-off-by: Shiyang He v2: Add function return value processing v3: Add return value description v4: Update queue state in 'start_port()' --- app/test-pmd/testpmd.c | 72 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 0c14325b8d..aa2a7b68ca 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2379,6 +2379,70 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) } } +static void +update_rx_queue_state(uint16_t port_id, uint16_t queue_id) +{ + struct rte_eth_rxq_info rx_qinfo; + int32_t rc; + + rc = rte_eth_rx_queue_info_get(port_id, + queue_id, &rx_qinfo); + if (rc == 0) { + ports[port_id].rxq[queue_id].state = + rx_qinfo.queue_state; + } else if (rc == -ENOTSUP) { + /* + * Set the rxq state to RTE_ETH_QUEUE_STATE_STARTED + * to ensure that the PMDs do not implement + * rte_eth_rx_queue_info_get can forward. + */ + ports[port_id].rxq[queue_id].state = + RTE_ETH_QUEUE_STATE_STARTED; + } else { + TESTPMD_LOG(WARNING, + "Failed to get rx queue info\n"); + } +} + +static void +update_tx_queue_state(uint16_t port_id, uint16_t queue_id) +{ + struct rte_eth_txq_info tx_qinfo; + int32_t rc; + + rc = rte_eth_tx_queue_info_get(port_id, + queue_id, &tx_qinfo); + if (rc == 0) { + ports[port_id].txq[queue_id].state = + tx_qinfo.queue_state; + } else if (rc == -ENOTSUP) { + /* + * Set the txq state to RTE_ETH_QUEUE_STATE_STARTED + * to ensure that the PMDs do not implement + * rte_eth_tx_queue_info_get can forward. + */ + ports[port_id].txq[queue_id].state = + RTE_ETH_QUEUE_STATE_STARTED; + } else { + TESTPMD_LOG(WARNING, + "Failed to get tx queue info\n"); + } +} + +static void +update_queue_state(void) +{ + portid_t pi; + queueid_t qi; + + RTE_ETH_FOREACH_DEV(pi) { + for (qi = 0; qi < nb_rxq; qi++) + update_rx_queue_state(pi, qi); + for (qi = 0; qi < nb_txq; qi++) + update_tx_queue_state(pi, qi); + } +} + /* * Launch packet forwarding configuration. */ @@ -2418,9 +2482,12 @@ start_packet_forwarding(int with_tx_first) if (!pkt_fwd_shared_rxq_check()) return; - if (stream_init != NULL) + if (stream_init != NULL) { + if (rte_eal_process_type() == RTE_PROC_SECONDARY) + update_queue_state(); for (i = 0; i < cur_fwd_config.nb_fwd_streams; i++) stream_init(fwd_streams[i]); + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; if (port_fwd_begin != NULL) { @@ -3180,6 +3247,9 @@ start_port(portid_t pid) pl[cfg_pi++] = pi; } + if (rte_eal_process_type() == RTE_PROC_SECONDARY) + update_queue_state(); + if (at_least_one_port_successfully_started && !no_link_check) check_all_ports_link_status(RTE_PORT_ALL); else if (at_least_one_port_exist & all_ports_already_started) -- 2.37.2