On Fri, Sep 12, 2025 at 8:27 AM Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> wrote: > Hi Stephen, > > On Fri, Sep 12, 2025, 04:51 Stephen Hemminger > wrote: > >> >> Ok, the Windows #ifdef was confusing me then looked more closely. >> This patch is adding a set of rings so that primary and secondary >> can communicate, the adding one command. >> >> The idea is good, but there is a better way to handle this. >> There already exists a way for primary and secondary to communicate >> through the mp service. This is used for hotplug and pdump and probably >> other things as well. >> > Yeah, agree. Testpmd have also hutplug callbacks, I have tried that too, > but it is in lower layer to call any stopping fwd_engines. > >> >> The communication can be either way, for example I proposed patches >> to pdump so that primary can tell secondary to participate. >> >> >> https://patchwork.dpdk.org/project/dpdk/patch/20250814165307.12786-7-stephen@networkplumber.org/ >> >> This of testpmd can be done in similar way. >> The handler in secondary should be able to act same as >> when SIGINT is received. Set the flag f_exit which will cause the main >> loop to exit. >> >> This can then happen immediately, and the proc monitor alarm function >> is only then needed to handle when primary process crashes. >> > Yeah, we can try that, my only concern is that if it can handle and stop > any numbers of secondary processes fwd_engines as the current solution can > stop. > > Please check the __handle_primary_request in https://elixir.bootlin.com/dpdk/v25.07/source/lib/eal/common/hotplug_mp.c#L225 , testpmd is calling this api during hutplug callbacks. I had tried a similar one as proposed in pdump but could not call stop_packet_forwarding from this lower layer as given below. There is only eal_bus_cleanup(), and local_dev_remove support. We only left with the ring solution to used if for IPC as in https://elixir.bootlin.com/dpdk/v25.07/source/examples/multi_process/simple_mp/main.c#L75 git diff diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 0f58a31eb5..9155453efa 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -72,6 +72,7 @@ #endif #ifdef RTE_NET_MLX5 #include "mlx5_testpmd.h" +#include "hotplug_mp.h" #endif #include "testpmd.h" @@ -3634,6 +3635,11 @@ pmd_test_exit(void) printf("\nStopping port %d...\n", pt_id); fflush(stdout); stop_port(pt_id); + printf("Stopping secondary process...\n"); + struct eal_dev_mp_req req; + memset(&req, 0, sizeof(req)); + req.t = ETH_REQ_STOP; //EAL_DEV_REQ_TYPE_DETACH; + eal_dev_hotplug_request_to_secondary(&req); } RTE_ETH_FOREACH_DEV(pt_id) { printf("\nShutting down port %d...\n", pt_id); diff --git a/lib/eal/common/hotplug_mp.c b/lib/eal/common/hotplug_mp.c index 17089ca3db..d324db428f 100644 --- a/lib/eal/common/hotplug_mp.c +++ b/lib/eal/common/hotplug_mp.c @@ -239,6 +239,11 @@ static void __handle_primary_request(void *param) memset(&mp_resp, 0, sizeof(mp_resp)); switch (req->t) { + case ETH_REQ_STOP: + printf("__handle_secondary_request called " + "for secondary processes fwd_engine stopping...\n"); + //eal_bus_cleanup(); + break; case EAL_DEV_REQ_TYPE_ATTACH: case EAL_DEV_REQ_TYPE_DETACH_ROLLBACK: ret = local_dev_probe(req->devargs, &dev); diff --git a/lib/eal/common/hotplug_mp.h b/lib/eal/common/hotplug_mp.h index 7221284286..7a46285994 100644 --- a/lib/eal/common/hotplug_mp.h +++ b/lib/eal/common/hotplug_mp.h @@ -19,6 +19,7 @@ enum eal_dev_req_type { EAL_DEV_REQ_TYPE_DETACH, EAL_DEV_REQ_TYPE_ATTACH_ROLLBACK, EAL_DEV_REQ_TYPE_DETACH_ROLLBACK, + ETH_REQ_STOP, };