Function update_queue_state updates queue state of all queues
of all ports, using the queue num nb_rxq|nb_txq stored locally
by testpmd. An error on the invalid queue ID occurs if we run
testpmd with two ports and detach-attach one of them and start
the other port first. This is because the attached port has not
been configured and has no queues, which differs from nb_rxq|nb_txq.
The similar error happens in multi-process senoris if secondary
process attaches a port and starts it.

This patch updates queue state of the specified port, which has
been configured by primary process. As the secondary process
cannot configure the ports, make sure that the secondary process
starts the port only after the primary process has done so.

Fixes: 141a520b35f7 ("app/testpmd: fix primary process not polling all queues")
Fixes: 5028f207a4fa ("app/testpmd: fix secondary process packet forwarding")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai <haij...@huawei.com>
---
 app/test-pmd/testpmd.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--
v1->v2:
1. Fix spelling mistakes.
2. Update queue state of a specified port insead of all port in start_port()

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1fc70650e0a4..904184d0836b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2477,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++)
@@ -2530,7 +2533,7 @@ start_packet_forwarding(int with_tx_first)
                return;
 
        if (stream_init != NULL) {
-               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]);
        }
@@ -3293,7 +3296,7 @@ start_port(portid_t pid)
                pl[cfg_pi++] = pi;
        }
 
-       update_queue_state();
+       update_queue_state(pid);
 
        if (at_least_one_port_successfully_started && !no_link_check)
                check_all_ports_link_status(RTE_PORT_ALL);
-- 
2.33.0

Reply via email to