DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: remove invalid ports when other process detach
@ 2022-03-02  2:33 Chengwen Feng
  2022-03-02  8:26 ` Thomas Monjalon
  0 siblings, 1 reply; 8+ messages in thread
From: Chengwen Feng @ 2022-03-02  2:33 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, xiaoyun.li, aman.deep.singh, yuying.zhang

Start main and secondary process:
./dpdk-testpmd -a BDF0 -a BDF1 --proc-type=auto -- -i --rxq=8 --txq=8
	--num-procs=2 --proc-id=0
./dpdk-testpmd -a BDF0 -a BDF1 --proc-type=auto -- -i --rxq=8 --txq=8
	--num-procs=2 --proc-id=1
Execute following command in main process:
	port stop 0
	port detach 0
Execute following command in secondary process:
	set fwd mac
	start
The secondary process will display:
	Invalid port_id=0
	telcore 19 called rx_pkt_burst for not ready port 0
	stpmd> 8: [/lib64/libc.so.6(+0xdf600) [0xffff9e1dc600]]
	7: [/lib64/libpthread.so.0(+0x7c48) [0xffff9e28ac48]]
	6: [/usr/app/testpmd(eal_thread_loop+0x2c4) [0xb23574]]
	5: [/usr/app/testpmd() [0x9c21d8]]
	4: [/usr/app/testpmd() [0x9c2108]]
	3: [/usr/app/testpmd() [0x9b6cf0]]
	2: [/usr/app/testpmd() [0xad8620]]
	1: [/usr/app/testpmd(rte_dump_stack+0x20) [0xb1a130]]

The root cause it that the secondary process has not removed invalid
ports when it processes RTE_ETH_EVENT_DESTROY event.

This patch adds a delay remove invalid ports invoke when process the
RTE_ETH_EVENT_DESTROY event.

Note: There will be two invoke of removing invalid ports in main
process, one is trigger by user command, another is trigger by
RTE_ETH_EVENT_DESTROY event. This patch keeps it unchanged to ensure
that the correct number of ports is displayed after detaching
successfully.

Fixes: 85c6571c9103 ("app/testpmd: reset port status on close notification")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/testpmd.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..a6a2533806 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3534,6 +3534,13 @@ rmv_port_callback(void *arg)
 		start_packet_forwarding(0);
 }
 
+static void
+remove_invalid_ports_callback(void *arg)
+{
+	RTE_SET_USED(arg);
+	remove_invalid_ports();
+}
+
 /* This function is used by the interrupt thread */
 static int
 eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
@@ -3569,6 +3576,10 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
 	case RTE_ETH_EVENT_DESTROY:
 		ports[port_id].port_status = RTE_PORT_CLOSED;
 		printf("Port %u is closed\n", port_id);
+		if (rte_eal_alarm_set(100000, remove_invalid_ports_callback,
+				(void *)(intptr_t)port_id))
+			fprintf(stderr,
+				"Could not set up deferred device released\n");
 		break;
 	default:
 		break;
-- 
2.33.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-23  8:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02  2:33 [PATCH] app/testpmd: remove invalid ports when other process detach Chengwen Feng
2022-03-02  8:26 ` Thomas Monjalon
2022-03-02  8:36   ` fengchengwen
2022-04-11  2:05     ` fengchengwen
2022-05-20 15:05     ` Ferruh Yigit
2022-05-20 15:14       ` Ferruh Yigit
2022-05-21 10:00       ` fengchengwen
2022-05-23  8:43         ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).