[v2] app/testpmd: fix secondary process not forwarding

Message ID 20230221154418.153972-1-shiyangx.he@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] app/testpmd: fix secondary process not forwarding |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Shiyang He Feb. 21, 2023, 3:44 p.m. UTC
  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 <shiyangx.he@intel.com>
Acked-by: Yuying Zhang <yuying.zhang@intel.com>

v2: Add function return value processing
---
 app/test-pmd/testpmd.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
  

Comments

lihuisong (C) Feb. 22, 2023, 6:20 a.m. UTC | #1
在 2023/2/21 23:44, Shiyang He 写道:
> 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 <shiyangx.he@intel.com>
> Acked-by: Yuying Zhang <yuying.zhang@intel.com>
>
> v2: Add function return value processing
> ---
>   app/test-pmd/testpmd.c | 35 +++++++++++++++++++++++++++++++++--
>   1 file changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 0c14325b8d..b450f3f6c4 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2418,9 +2418,40 @@ start_packet_forwarding(int with_tx_first)
>   	if (!pkt_fwd_shared_rxq_check())
>   		return;
>   
> -	if (stream_init != NULL)
> -		for (i = 0; i < cur_fwd_config.nb_fwd_streams; i++)
> +	if (stream_init != NULL) {
> +		for (i = 0; i < cur_fwd_config.nb_fwd_streams; i++) {
> +			if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> +				struct fwd_stream *fs = fwd_streams[i];
> +				struct rte_eth_rxq_info rx_qinfo;
> +				struct rte_eth_txq_info tx_qinfo;
> +				int32_t rc;
> +				rc = rte_eth_rx_queue_info_get(fs->rx_port,
> +						fs->rx_queue, &rx_qinfo);
> +				if (!rc)
> +					ports[fs->rx_port].rxq[fs->rx_queue].state =
> +						rx_qinfo.queue_state;
> +				else if (-ENOTSUP == rc)
"rc != 0" and "rc == -ENOTSUP" style are always welcome in dpdk.
Additionally, it is better to add some comments about '-ENOTSUP' here, 
because this patch does not describe it anywhere.
> +					ports[fs->rx_port].rxq[fs->rx_queue].state =
> +						RTE_ETH_QUEUE_STATE_STARTED;
> +				else
> +					TESTPMD_LOG(WARNING,
> +						"Failed to get rx queue info\n");
> +
> +				rc = rte_eth_tx_queue_info_get(fs->tx_port,
> +						fs->tx_queue, &tx_qinfo);
> +				if (!rc)
> +					ports[fs->tx_port].txq[fs->tx_queue].state =
> +						tx_qinfo.queue_state;
> +				else if (-ENOTSUP == rc)
> +					ports[fs->tx_port].txq[fs->tx_queue].state =
> +						RTE_ETH_QUEUE_STATE_STARTED;
> +				else
> +					TESTPMD_LOG(WARNING,
> +						"Failed to get tx queue info\n");
> +			}
>   			stream_init(fwd_streams[i]);
> +		}
> +	}
>   
>   	port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;
>   	if (port_fwd_begin != NULL) {
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0c14325b8d..b450f3f6c4 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2418,9 +2418,40 @@  start_packet_forwarding(int with_tx_first)
 	if (!pkt_fwd_shared_rxq_check())
 		return;
 
-	if (stream_init != NULL)
-		for (i = 0; i < cur_fwd_config.nb_fwd_streams; i++)
+	if (stream_init != NULL) {
+		for (i = 0; i < cur_fwd_config.nb_fwd_streams; i++) {
+			if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+				struct fwd_stream *fs = fwd_streams[i];
+				struct rte_eth_rxq_info rx_qinfo;
+				struct rte_eth_txq_info tx_qinfo;
+				int32_t rc;
+				rc = rte_eth_rx_queue_info_get(fs->rx_port,
+						fs->rx_queue, &rx_qinfo);
+				if (!rc)
+					ports[fs->rx_port].rxq[fs->rx_queue].state =
+						rx_qinfo.queue_state;
+				else if (-ENOTSUP == rc)
+					ports[fs->rx_port].rxq[fs->rx_queue].state =
+						RTE_ETH_QUEUE_STATE_STARTED;
+				else
+					TESTPMD_LOG(WARNING,
+						"Failed to get rx queue info\n");
+
+				rc = rte_eth_tx_queue_info_get(fs->tx_port,
+						fs->tx_queue, &tx_qinfo);
+				if (!rc)
+					ports[fs->tx_port].txq[fs->tx_queue].state =
+						tx_qinfo.queue_state;
+				else if (-ENOTSUP == rc)
+					ports[fs->tx_port].txq[fs->tx_queue].state =
+						RTE_ETH_QUEUE_STATE_STARTED;
+				else
+					TESTPMD_LOG(WARNING,
+						"Failed to get tx queue info\n");
+			}
 			stream_init(fwd_streams[i]);
+		}
+	}
 
 	port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;
 	if (port_fwd_begin != NULL) {