* [PATCH 0/3] testpmd support stop specify lcore
@ 2025-11-04 4:09 Chengwen Feng
2025-11-04 4:09 ` [PATCH 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Chengwen Feng @ 2025-11-04 4:09 UTC (permalink / raw)
To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong
This patch support stop specify lcore for testpmd, and also include
two bugfix which found when test DCB function.
Chengwen Feng (3):
app/testpmd: fix invalid txp when setup DCB forward
app/testpmd: fix wrong Rx queues when setup DCB forward
app/testpmd: support stop specify lcore
app/test-pmd/cmdline.c | 63 +++++++++++++++++++++
app/test-pmd/config.c | 9 +--
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++
3 files changed, 73 insertions(+), 6 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/3] app/testpmd: fix invalid txp when setup DCB forward 2025-11-04 4:09 [PATCH 0/3] testpmd support stop specify lcore Chengwen Feng @ 2025-11-04 4:09 ` Chengwen Feng 2025-11-04 4:09 ` [PATCH 2/3] app/testpmd: fix wrong Rx queues " Chengwen Feng ` (3 subsequent siblings) 4 siblings, 0 replies; 10+ messages in thread From: Chengwen Feng @ 2025-11-04 4:09 UTC (permalink / raw) To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong The txp maybe invalid (e.g. start with only one port but set with 1), this commit fix it by get txp from fwd_topology_tx_port_get() function. An added benefit is that the DCB test also supports '--port-topology' parameter. Fixes: 1a572499beb6 ("app/testpmd: setup DCB forwarding based on traffic class") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> --- app/test-pmd/config.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 3ce2a14a1b..0f687018c7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -5187,7 +5187,7 @@ dcb_fwd_config_setup(void) /* reinitialize forwarding streams */ init_fwd_streams(); sm_id = 0; - txp = 1; + txp = fwd_topology_tx_port_get(rxp); /* get the dcb info on the first RX and TX ports */ (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info); (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info); @@ -5235,11 +5235,8 @@ dcb_fwd_config_setup(void) rxp++; if (rxp >= nb_fwd_ports) return; + txp = fwd_topology_tx_port_get(rxp); /* get the dcb information on next RX and TX ports */ - if ((rxp & 0x1) == 0) - txp = (portid_t) (rxp + 1); - else - txp = (portid_t) (rxp - 1); rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info); rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info); } -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/3] app/testpmd: fix wrong Rx queues when setup DCB forward 2025-11-04 4:09 [PATCH 0/3] testpmd support stop specify lcore Chengwen Feng 2025-11-04 4:09 ` [PATCH 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng @ 2025-11-04 4:09 ` Chengwen Feng 2025-11-04 4:09 ` [PATCH 3/3] app/testpmd: support stop specify lcore Chengwen Feng ` (2 subsequent siblings) 4 siblings, 0 replies; 10+ messages in thread From: Chengwen Feng @ 2025-11-04 4:09 UTC (permalink / raw) To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong The nb_rx_queue should get from rxp_dcb_info not txp_dcb_info, this commit fix it. Fixes: 1a572499beb6 ("app/testpmd: setup DCB forwarding based on traffic class") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> --- app/test-pmd/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 0f687018c7..8557371488 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -5205,7 +5205,7 @@ dcb_fwd_config_setup(void) fwd_lcores[lc_id]->stream_idx; rxq = rxp_dcb_info.tc_queue.tc_rxq[i][tc].base; txq = txp_dcb_info.tc_queue.tc_txq[i][tc].base; - nb_rx_queue = txp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue; + nb_rx_queue = rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue; nb_tx_queue = txp_dcb_info.tc_queue.tc_txq[i][tc].nb_queue; for (j = 0; j < nb_rx_queue; j++) { struct fwd_stream *fs; -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/3] app/testpmd: support stop specify lcore 2025-11-04 4:09 [PATCH 0/3] testpmd support stop specify lcore Chengwen Feng 2025-11-04 4:09 ` [PATCH 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng 2025-11-04 4:09 ` [PATCH 2/3] app/testpmd: fix wrong Rx queues " Chengwen Feng @ 2025-11-04 4:09 ` Chengwen Feng 2025-11-05 0:21 ` [PATCH 0/3] testpmd " Stephen Hemminger 2025-11-05 9:47 ` [PATCH v2 0/3] testpmd support pause/resume specify lcore's fwd Chengwen Feng 4 siblings, 0 replies; 10+ messages in thread From: Chengwen Feng @ 2025-11-04 4:09 UTC (permalink / raw) To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong This commit supports stop specify lcore, the command: stop fwd_core (lcore_id) The background of this command: 1. Only some TCs are expected to generate traffic when the DCB function is tested based on txonly forwarding. 2. Because each lcore will process all the traffic of one TC, therefore, we could stop the lcores which process unexpected TCs by this command. Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> --- app/test-pmd/cmdline.c | 63 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ 2 files changed, 70 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 22afbdbad3..e03f6e6181 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -150,6 +150,9 @@ static void cmd_help_long_parsed(void *parsed_result, " Stop packet forwarding, and display accumulated" " statistics.\n\n" + "stop fwd_core (lcore_id)\n" + " Stop specify lcore's forwarding.\n\n" + "quit\n" " Quit to prompt.\n\n" ); @@ -3975,6 +3978,65 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +/* *** stop specify forward core *** */ +struct cmd_stop_fwd_core_result { + cmdline_fixed_string_t stop; + cmdline_fixed_string_t fwd_core; + uint32_t lcore_id; +}; + +static void +cmd_stop_fwd_core_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_stop_fwd_core_result *res = parsed_result; + struct fwd_lcore *fc = lcore_to_fwd_lcore(res->lcore_id); + + if (test_done) { + fprintf(stderr, "Packet forwarding not started\n"); + return; + } + + if (fc == NULL) { + fprintf(stderr, "core: %u not in the forward corelist.\n", res->lcore_id); + return; + } + + if (fc->stopped) { + fprintf(stderr, "core: %u already stopped!\n", res->lcore_id); + return; + } + + printf("Telling core: %u to stop...", res->lcore_id); + fc->stopped = 1; + printf("\nWaiting for core: %u to finish...\n", res->lcore_id); + rte_eal_wait_lcore(res->lcore_id); + printf("Done.\n"); +} + +static cmdline_parse_token_string_t cmd_stop_fwd_core_stop = + TOKEN_STRING_INITIALIZER(struct cmd_stop_fwd_core_result, + stop, "stop"); +static cmdline_parse_token_string_t cmd_stop_fwd_core_fwd_core = + TOKEN_STRING_INITIALIZER(struct cmd_stop_fwd_core_result, + fwd_core, "fwd_core"); +static cmdline_parse_token_num_t cmd_stop_fwd_core_lcore_id = + TOKEN_NUM_INITIALIZER(struct cmd_stop_fwd_core_result, + lcore_id, RTE_UINT32); + +static cmdline_parse_inst_t cmd_stop_fwd_core = { + .f = cmd_stop_fwd_core_parsed, + .data = NULL, + .help_str = "stop fwd_core <lcore_id>: stop specify lcore's forwarding.", + .tokens = { + (void *)&cmd_stop_fwd_core_stop, + (void *)&cmd_stop_fwd_core_fwd_core, + (void *)&cmd_stop_fwd_core_lcore_id, + NULL, + }, +}; + static unsigned int get_ptype(char *value) { @@ -14051,6 +14113,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_config_dcb, &cmd_read_rxd_txd, &cmd_stop, + &cmd_stop_fwd_core, &cmd_mac_addr, &cmd_set_fwd_eth_peer, &cmd_set_xstats_hide_zero, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index e423abd40e..0a362d06b8 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -143,6 +143,13 @@ Stop packet forwarding, and display accumulated statistics:: testpmd> stop +stop fwd_core +~~~~~~~~~~~~~ + +Stop specify lcore's forwarding:: + + testpmd> stop fwd_core (lcore_id) + quit ~~~~ -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] testpmd support stop specify lcore 2025-11-04 4:09 [PATCH 0/3] testpmd support stop specify lcore Chengwen Feng ` (2 preceding siblings ...) 2025-11-04 4:09 ` [PATCH 3/3] app/testpmd: support stop specify lcore Chengwen Feng @ 2025-11-05 0:21 ` Stephen Hemminger 2025-11-05 0:43 ` fengchengwen 2025-11-05 9:47 ` [PATCH v2 0/3] testpmd support pause/resume specify lcore's fwd Chengwen Feng 4 siblings, 1 reply; 10+ messages in thread From: Stephen Hemminger @ 2025-11-05 0:21 UTC (permalink / raw) To: Chengwen Feng Cc: thomas, dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong On Tue, 4 Nov 2025 12:09:13 +0800 Chengwen Feng <fengchengwen@huawei.com> wrote: > This patch support stop specify lcore for testpmd, and also include > two bugfix which found when test DCB function. > > Chengwen Feng (3): > app/testpmd: fix invalid txp when setup DCB forward > app/testpmd: fix wrong Rx queues when setup DCB forward > app/testpmd: support stop specify lcore > > app/test-pmd/cmdline.c | 63 +++++++++++++++++++++ > app/test-pmd/config.c | 9 +-- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ > 3 files changed, 73 insertions(+), 6 deletions(-) > If there is a stop lcore, why is there not a command to restart the lcore? Looks like this just an optimization for DCB. Could it be handled better by having testpmd not spawn lcores that have no queues? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] testpmd support stop specify lcore 2025-11-05 0:21 ` [PATCH 0/3] testpmd " Stephen Hemminger @ 2025-11-05 0:43 ` fengchengwen 0 siblings, 0 replies; 10+ messages in thread From: fengchengwen @ 2025-11-05 0:43 UTC (permalink / raw) To: Stephen Hemminger Cc: thomas, dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong On 11/5/2025 8:21 AM, Stephen Hemminger wrote: > On Tue, 4 Nov 2025 12:09:13 +0800 > Chengwen Feng <fengchengwen@huawei.com> wrote: > >> This patch support stop specify lcore for testpmd, and also include >> two bugfix which found when test DCB function. >> >> Chengwen Feng (3): >> app/testpmd: fix invalid txp when setup DCB forward >> app/testpmd: fix wrong Rx queues when setup DCB forward >> app/testpmd: support stop specify lcore >> >> app/test-pmd/cmdline.c | 63 +++++++++++++++++++++ >> app/test-pmd/config.c | 9 +-- >> doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ >> 3 files changed, 73 insertions(+), 6 deletions(-) >> > > If there is a stop lcore, why is there not a command to restart the lcore? The restart lcore is more complex which include data prepare (init). But I think could impl such pause / restart function by config fc->stopped a special value: Current: run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) { do { forwarding logic } while(!fc->stopped); } We could adjust the logic to support pause / restart function: run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) { _restart: do { forwarding logic } while(!fc->stopped); while (fc->stopped == 2) { nop } if (fc->stopped == 1) return; if (fc->stopped == 0) // means restart goto _restart; } So we could configure fc->stopped = 2 to pause forwarding, and config it to 0 to restart forwarding. > Looks like this just an optimization for DCB. Yes, mainly for test the Tx direction's DCB function. > Could it be handled better by having testpmd not spawn lcores that > have no queues? The lcore spawned by testpmd always has queues. In this patchset, we just stop some queue's forwarding. > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 0/3] testpmd support pause/resume specify lcore's fwd 2025-11-04 4:09 [PATCH 0/3] testpmd support stop specify lcore Chengwen Feng ` (3 preceding siblings ...) 2025-11-05 0:21 ` [PATCH 0/3] testpmd " Stephen Hemminger @ 2025-11-05 9:47 ` Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng ` (2 more replies) 4 siblings, 3 replies; 10+ messages in thread From: Chengwen Feng @ 2025-11-05 9:47 UTC (permalink / raw) To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong This patch support pause/resume specify lcore's forwarding for testpmd, and also include two bugfix which found when test DCB function. Chengwen Feng (3): app/testpmd: fix invalid txp when setup DCB forward app/testpmd: fix wrong Rx queues when setup DCB forward app/testpmd: support pause/resume specify lcore app/test-pmd/cmdline.c | 126 ++++++++++++++++++++ app/test-pmd/config.c | 9 +- app/test-pmd/testpmd.c | 5 + app/test-pmd/testpmd.h | 2 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 14 +++ 5 files changed, 149 insertions(+), 7 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/3] app/testpmd: fix invalid txp when setup DCB forward 2025-11-05 9:47 ` [PATCH v2 0/3] testpmd support pause/resume specify lcore's fwd Chengwen Feng @ 2025-11-05 9:47 ` Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 2/3] app/testpmd: fix wrong Rx queues " Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 3/3] app/testpmd: support pause/resume specify lcore Chengwen Feng 2 siblings, 0 replies; 10+ messages in thread From: Chengwen Feng @ 2025-11-05 9:47 UTC (permalink / raw) To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong The txp maybe invalid (e.g. start with only one port but set with 1), this commit fix it by get txp from fwd_topology_tx_port_get() function. An added benefit is that the DCB test also supports '--port-topology' parameter. Fixes: 1a572499beb6 ("app/testpmd: setup DCB forwarding based on traffic class") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> --- app/test-pmd/config.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 3ce2a14a1b..0f687018c7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -5187,7 +5187,7 @@ dcb_fwd_config_setup(void) /* reinitialize forwarding streams */ init_fwd_streams(); sm_id = 0; - txp = 1; + txp = fwd_topology_tx_port_get(rxp); /* get the dcb info on the first RX and TX ports */ (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info); (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info); @@ -5235,11 +5235,8 @@ dcb_fwd_config_setup(void) rxp++; if (rxp >= nb_fwd_ports) return; + txp = fwd_topology_tx_port_get(rxp); /* get the dcb information on next RX and TX ports */ - if ((rxp & 0x1) == 0) - txp = (portid_t) (rxp + 1); - else - txp = (portid_t) (rxp - 1); rte_eth_dev_get_dcb_info(fwd_ports_ids[rxp], &rxp_dcb_info); rte_eth_dev_get_dcb_info(fwd_ports_ids[txp], &txp_dcb_info); } -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] app/testpmd: fix wrong Rx queues when setup DCB forward 2025-11-05 9:47 ` [PATCH v2 0/3] testpmd support pause/resume specify lcore's fwd Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng @ 2025-11-05 9:47 ` Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 3/3] app/testpmd: support pause/resume specify lcore Chengwen Feng 2 siblings, 0 replies; 10+ messages in thread From: Chengwen Feng @ 2025-11-05 9:47 UTC (permalink / raw) To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong The nb_rx_queue should get from rxp_dcb_info not txp_dcb_info, this commit fix it. Fixes: 1a572499beb6 ("app/testpmd: setup DCB forwarding based on traffic class") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> --- app/test-pmd/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 0f687018c7..8557371488 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -5205,7 +5205,7 @@ dcb_fwd_config_setup(void) fwd_lcores[lc_id]->stream_idx; rxq = rxp_dcb_info.tc_queue.tc_rxq[i][tc].base; txq = txp_dcb_info.tc_queue.tc_txq[i][tc].base; - nb_rx_queue = txp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue; + nb_rx_queue = rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue; nb_tx_queue = txp_dcb_info.tc_queue.tc_txq[i][tc].nb_queue; for (j = 0; j < nb_rx_queue; j++) { struct fwd_stream *fs; -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] app/testpmd: support pause/resume specify lcore 2025-11-05 9:47 ` [PATCH v2 0/3] testpmd support pause/resume specify lcore's fwd Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 2/3] app/testpmd: fix wrong Rx queues " Chengwen Feng @ 2025-11-05 9:47 ` Chengwen Feng 2 siblings, 0 replies; 10+ messages in thread From: Chengwen Feng @ 2025-11-05 9:47 UTC (permalink / raw) To: thomas, stephen; +Cc: dev, aman.deep.singh, liuyonglong, yangxingui, lihuisong This commit supports pause/resume specify lcore, the command: pause fwd_core (lcore_id) resume fwd_core (lcore_id) The background of this command: 1. Only some TCs are expected to generate traffic when the DCB function is tested based on txonly forwarding. 2. Because each lcore will process all the traffic of one TC, therefore, we could pause the lcores which process unexpected TCs by this command. Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> --- app/test-pmd/cmdline.c | 126 ++++++++++++++++++++ app/test-pmd/testpmd.c | 5 + app/test-pmd/testpmd.h | 2 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 14 +++ 4 files changed, 146 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 22afbdbad3..dacc1921bd 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -150,6 +150,12 @@ static void cmd_help_long_parsed(void *parsed_result, " Stop packet forwarding, and display accumulated" " statistics.\n\n" + "pause fwd_core (lcore_id)\n" + " Pause specify lcore's forwarding.\n\n" + + "resume fwd_core (lcore_id)\n" + " Resume specify lcore's forwarding.\n\n" + "quit\n" " Quit to prompt.\n\n" ); @@ -3975,6 +3981,124 @@ static cmdline_parse_inst_t cmd_stop = { }, }; +/* *** pause specify forward core *** */ +struct cmd_pause_fwd_core_result { + cmdline_fixed_string_t pause; + cmdline_fixed_string_t fwd_core; + uint32_t lcore_id; +}; + +static void +cmd_pause_fwd_core_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_pause_fwd_core_result *res = parsed_result; + struct fwd_lcore *fc = lcore_to_fwd_lcore(res->lcore_id); + + if (test_done) { + fprintf(stderr, "Packet forwarding not started\n"); + return; + } + + if (fc == NULL) { + fprintf(stderr, "core: %u not in the forward corelist.\n", res->lcore_id); + return; + } + + if (fc->stopped == 2) { + fprintf(stderr, "core: %u already paused!\n", res->lcore_id); + return; + } + + printf("Telling core: %u to pause...", res->lcore_id); + fc->stopped = 2; + printf("\nWaiting for core: %u to finish...\n", res->lcore_id); + rte_delay_ms(10); + printf("Done.\n"); +} + +static cmdline_parse_token_string_t cmd_pause_fwd_core_pause = + TOKEN_STRING_INITIALIZER(struct cmd_pause_fwd_core_result, + pause, "pause"); +static cmdline_parse_token_string_t cmd_pause_fwd_core_fwd_core = + TOKEN_STRING_INITIALIZER(struct cmd_pause_fwd_core_result, + fwd_core, "fwd_core"); +static cmdline_parse_token_num_t cmd_pause_fwd_core_lcore_id = + TOKEN_NUM_INITIALIZER(struct cmd_pause_fwd_core_result, + lcore_id, RTE_UINT32); + +static cmdline_parse_inst_t cmd_pause_fwd_core = { + .f = cmd_pause_fwd_core_parsed, + .data = NULL, + .help_str = "pause fwd_core <lcore_id>: pause specify lcore's forwarding.", + .tokens = { + (void *)&cmd_pause_fwd_core_pause, + (void *)&cmd_pause_fwd_core_fwd_core, + (void *)&cmd_pause_fwd_core_lcore_id, + NULL, + }, +}; + +/* *** resume specify forward core *** */ +struct cmd_resume_fwd_core_result { + cmdline_fixed_string_t resume; + cmdline_fixed_string_t fwd_core; + uint32_t lcore_id; +}; + +static void +cmd_resume_fwd_core_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_resume_fwd_core_result *res = parsed_result; + struct fwd_lcore *fc = lcore_to_fwd_lcore(res->lcore_id); + + if (test_done) { + fprintf(stderr, "Packet forwarding not started\n"); + return; + } + + if (fc == NULL) { + fprintf(stderr, "core: %u not in the forward corelist.\n", res->lcore_id); + return; + } + + if (fc->stopped != 2) { + fprintf(stderr, "core: %u not in pause state!\n", res->lcore_id); + return; + } + + printf("Telling core: %u to resume...", res->lcore_id); + fc->stopped = 0; + printf("\nWaiting for core: %u to resume...\n", res->lcore_id); + rte_delay_ms(10); + printf("Done.\n"); +} + +static cmdline_parse_token_string_t cmd_resume_fwd_core_resume = + TOKEN_STRING_INITIALIZER(struct cmd_resume_fwd_core_result, + resume, "resume"); +static cmdline_parse_token_string_t cmd_resume_fwd_core_fwd_core = + TOKEN_STRING_INITIALIZER(struct cmd_resume_fwd_core_result, + fwd_core, "fwd_core"); +static cmdline_parse_token_num_t cmd_resume_fwd_core_lcore_id = + TOKEN_NUM_INITIALIZER(struct cmd_resume_fwd_core_result, + lcore_id, RTE_UINT32); + +static cmdline_parse_inst_t cmd_resume_fwd_core = { + .f = cmd_resume_fwd_core_parsed, + .data = NULL, + .help_str = "resume fwd_core <lcore_id>: resume specify lcore's forwarding.", + .tokens = { + (void *)&cmd_resume_fwd_core_resume, + (void *)&cmd_resume_fwd_core_fwd_core, + (void *)&cmd_resume_fwd_core_lcore_id, + NULL, + }, +}; + static unsigned int get_ptype(char *value) { @@ -14051,6 +14175,8 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_config_dcb, &cmd_read_rxd_txd, &cmd_stop, + &cmd_pause_fwd_core, + &cmd_resume_fwd_core, &cmd_mac_addr, &cmd_set_fwd_eth_peer, &cmd_set_xstats_hide_zero, diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 2360da3a48..05549be1c5 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2247,6 +2247,7 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) #endif fsm = &fwd_streams[fc->stream_idx]; nb_fs = fc->stream_nb; +_resume: prev_tsc = rte_rdtsc(); do { for (sm_id = 0; sm_id < nb_fs; sm_id++) { @@ -2287,6 +2288,10 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) prev_tsc = tsc; } } while (! fc->stopped); + while (fc->stopped == 2) + rte_pause(); + if (fc->stopped == 0) + goto _resume; } static int diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index fa46865c67..c3c4373af7 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -399,7 +399,7 @@ struct fwd_lcore { streamid_t stream_idx; /**< index of 1st stream in "fwd_streams" */ streamid_t stream_nb; /**< number of streams in "fwd_streams" */ lcoreid_t cpuid_idx; /**< index of logical core in CPU id table */ - volatile char stopped; /**< stop forwarding when set */ + volatile char stopped; /**< stop forwarding when set to 1, pause when set to 2 */ uint64_t total_cycles; /**< used with --record-core-cycles */ }; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index e423abd40e..be125ff35c 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -143,6 +143,20 @@ Stop packet forwarding, and display accumulated statistics:: testpmd> stop +pause fwd_core +~~~~~~~~~~~~~~ + +Pause specify lcore's forwarding:: + + testpmd> pause fwd_core (lcore_id) + +resume fwd_core +~~~~~~~~~~~~~~~ + +Resume specify lcore's forwarding:: + + testpmd> resume fwd_core (lcore_id) + quit ~~~~ -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-11-05 9:48 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-11-04 4:09 [PATCH 0/3] testpmd support stop specify lcore Chengwen Feng 2025-11-04 4:09 ` [PATCH 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng 2025-11-04 4:09 ` [PATCH 2/3] app/testpmd: fix wrong Rx queues " Chengwen Feng 2025-11-04 4:09 ` [PATCH 3/3] app/testpmd: support stop specify lcore Chengwen Feng 2025-11-05 0:21 ` [PATCH 0/3] testpmd " Stephen Hemminger 2025-11-05 0:43 ` fengchengwen 2025-11-05 9:47 ` [PATCH v2 0/3] testpmd support pause/resume specify lcore's fwd Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 1/3] app/testpmd: fix invalid txp when setup DCB forward Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 2/3] app/testpmd: fix wrong Rx queues " Chengwen Feng 2025-11-05 9:47 ` [PATCH v2 3/3] app/testpmd: support pause/resume specify lcore Chengwen Feng
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).