app/testpmd: fix secondary process not forwarding
PATCH 1/1 app/testpmd: fix secondary process not forwarding
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.
--- app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +27 -2
@@ -2378,9 +2378,34 @@ 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_PRIMARY ) { +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 +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 +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 ) {
Signature · 1 line
2.34.1
Quoted 11 lines · On Fri, 30 Dec 2022 07:55:53 +0000 Shiyang He <[email protected]> wrote:
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 a78040c990cb ("app/testpmd: update forward engine beginning")Signed-off-by Shiyang He <[email protected]>
Would it be possible to fix this the initialization of ports variable, rather than doing a per-state fixup here?
Quoted 7 lines
Quoted 7 lines
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.
Quoted 7 lines
Quoted 4 lines
Fixes a78040c990cb ("app/testpmd: update forward engine beginning")Signed-off-by Shiyang He <[email protected]>Would it be possible to fix this the initialization of ports variable, rather than doing a per-state fixup here?
In multi-process scenario, the secondary process does not initialize the queue state in the 'ports' variable, and the ethdev's queue state may be changed by any other process, which causes 'ports' queue state of per-process and ethdev's queue state are inconsistent. Therefore, getting the queue state from ethdev is a feasible way which I can think of.
@Zhang, Yuying Hi, please take a look at this patch! Are there any comments?
Quoted 31 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: Wednesday, January 4, 2023 10:02 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 7 lines
Quoted 7 lines
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.
Quoted 7 lines
Quoted 4 lines
Fixes a78040c990cb ("app/testpmd: update forward engine beginning")Signed-off-by Shiyang He <[email protected]>Would it be possible to fix this the initialization of ports variable, rather than doing a per-state fixup here?
In multi-process scenario, the secondary process does not initialize the queue state in the 'ports' variable, and the ethdev's queue state may be changed by any other process, which causes 'ports' queue state of per-process and ethdev's queue state are inconsistent. Therefore, getting the queue state from ethdev is a feasible way which I can think of.
Hi Shiyang,
Quoted 11 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: 2023年1月13日 17:08
To: He, ShiyangX <[email protected]>; Zhang, Yuying <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwarding
Quoted 33 lines
@Zhang, Yuying Hi, please take a look at this patch! Are there any comments?
Quoted 31 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: Wednesday, January 4, 2023 10:02 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 7 lines
Quoted 7 lines
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.
Quoted 7 lines
Quoted 4 lines
Fixes a78040c990cb ("app/testpmd: update forward engine beginning")Signed-off-by Shiyang He <[email protected]>Would it be possible to fix this the initialization of ports variable, rather than doing a per-state fixup here?
In multi-process scenario, the secondary process does not initialize the queue state in the 'ports' variable, and the ethdev's queue state may be changed by any other process, which causes 'ports' queue state of per-process and ethdev's queue state are inconsistent. Therefore, getting the queue state from ethdev is a feasible way which I can think of.
You should fix the queue state in the 'ports' variable of secondary process in the initialization of ports variable instead of fixup here.
Quoted 57 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: Wednesday, February 8, 2023 11:22 AM
To: He, ShiyangX <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingHi Shiyang,
Quoted 11 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: 2023年1月13日 17:08
To: He, ShiyangX <[email protected]>; Zhang, Yuying <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 8 lines
@Zhang, Yuying Hi, please take a look at this patch! Are there any comments?
Quoted 6 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: Wednesday, January 4, 2023 10:02 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>;Zhang,
Quoted 9 lines
Quoted 9 lines
Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 3 lines
Quoted 3 lines
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" isnot called.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 9 lines
This commit fixes the issue by calling 'rte_eth_rx/tx_queue_info_get' to get queue state from shared memory.
Fixes a78040c990cb ("app/testpmd: update forward enginebeginning")
Cc: [email protected]Signed-off-by Shiyang He <[email protected]>Would it be possible to fix this the initialization of ports variable, rather than doing a per-state fixup here?
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
In multi-process scenario, the secondary process does not initialize the queue state in the 'ports' variable, and the ethdev's queue state may be changed by any other process, which causes 'ports' queue state of per-process and ethdev's queue state are inconsistent. Therefore, getting the queue state from ethdev is a feasible way which I can think of.
You should fix the queue state in the 'ports' variable of secondary process in the initialization of ports variable instead of fixup here.
If the ethdev's queue state is changed by other processes, the queue state in the 'ports' variable is inconsistent with ethdev's queue state. Therefore, should obtain it from ethdev when accessing the queue state in the 'ports' variable.
Zhang, Yuying
Acked-byQuoted 39 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: 2023年2月8日 14:39
To: Zhang, Yuying <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 6 lines
-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: Wednesday, February 8, 2023 11:22 AM
To: He, ShiyangX <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>;Burakov,
Quoted 18 lines
Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingHi Shiyang,
Quoted 12 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: 2023年1月13日 17:08
To: He, ShiyangX <[email protected]>; Zhang, Yuying <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwarding
Quoted 30 lines
Quoted 1 line
Quoted 1 line
@Zhang, Yuying Hi, please take a look at this patch! Are there any
comments?
Quoted 28 lines
Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: He, ShiyangX <[email protected]>
Sent: Wednesday, January 4, 2023 10:02 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>;Zhang,
Quoted 10 lines
Quoted 10 lines
Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: RE: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 4 lines
Quoted 4 lines
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" isnot called.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
This commit fixes the issue by calling 'rte_eth_rx/tx_queue_info_get' to get queue state from shared memory.
Fixes a78040c990cb ("app/testpmd: update forward enginebeginning")
Cc: [email protected]Signed-off-by Shiyang He <[email protected]>
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Would it be possible to fix this the initialization of ports variable, rather than doing a per-state fixup here?
In multi-process scenario, the secondary process does not initialize the queue state in the 'ports' variable, and the ethdev's queue state may be changed by any other process, which causes 'ports' queue state of per-process and ethdev's queue state are inconsistent. Therefore, getting the queue state from ethdev is a feasible
way which I can think of.
Quoted 3 lines
You should fix the queue state in the 'ports' variable of secondary process in the initialization of ports variable instead of fixup here.
If the ethdev's queue state is changed by other processes, the queue state in the 'ports' variable is inconsistent with ethdev's queue state. Therefore, should obtain it from ethdev when accessing the queue state in the 'ports' variable.
Quoted 8 lines · 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 a78040c990cb ("app/testpmd: update forward engine beginning")
should use this commit:
Quoted 12 lines
Signed-off-by Shiyang He <[email protected]>--- app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +0
-0
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2383
Quoted 8 lines
app/test-pmd/testpmd.c +3
-2@@ -2378,9 +2378,34 @@ 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_PRIMARY ) {
directly use "rte_eal_process_type() == RTE_PROC_SECONDARY"?
Quoted 11 lines
app/test-pmd/testpmd.c +11
-0+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 + TESTPMD_LOG(WARNING,
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2404
Quoted 10 lines
app/test-pmd/testpmd.c +10
-0+ "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 +TESTPMD_LOG (WARNING , +"Failed to get tx queue info\n" );
not all PMDs implement rte_eth_rx/tx_queue_info_get() to query the state, right? Can you set this state to 'START' if the return value is '-ENOTSUP'?
Quoted 7 lines
app/test-pmd/testpmd.c +3
-0+ }stream_init (fwd_streams[i]); + } + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;if (port_fwd_begin !=NULL ) {
Quoted 18 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Monday, February 20, 2023 8:46 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: Re: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 4 lines · 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.
Quoted 6 lines
Quoted 4 lines
This commit fixes the issue by calling 'rte_eth_rx/tx_queue_info_get' to get queue state from shared memory.
Fixes a78040c990cb ("app/testpmd: update forward engine beginning")should use this commit:
Fixes 3c4426db54fc ("app/testpmd: do not poll stopped queues")
Thanks for your comments, I will ask maintainer to help fix this problem.
Quoted 15 lines
Quoted 15 lines
Signed-off-by Shiyang He <[email protected]>--- app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
134d79a555..2c73daf9eb100644app/test-pmd/testpmd.c +0
-0@@ -2378,9 +2378,34 @@ start_packet_forwarding(int with_tx_first)if (!pkt_fwd_shared_rxq_check ())return ;
Quoted 7 lines
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2383
Quoted 5 lines
app/test-pmd/testpmd.c +3
-2-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_PRIMARY ) {directly use "
rte_eal_process_type()==RTE_PROC_SECONDARY"?
The following action should be executed for all non-primary processes.
Quoted 15 lines
Quoted 10 lines
app/test-pmd/testpmd.c +8
-0+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 =
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 4 lines
app/test-pmd/testpmd.c +4
-0+ rx_qinfo.queue_state; + else + TESTPMD_LOG(WARNING, + "Failed to get rx queueinfo\n");
Quoted 14 lines
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 10 lines
app/test-pmd/testpmd.c +5
-0+ + 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 =
app/test-pmd/testpmd.c +4
-0+ tx_qinfo.queue_state; + else + TESTPMD_LOG(WARNING, + "Failed to get tx queueinfo\n");
not all PMDs implement rte_eth_rx/tx_queue_info_get() to query the state, right?
Can you set this state to 'START' if the return value is '-ENOTSUP'?
If pmd doesn't implement "rte_eth_rx/tx_queue_info_get()" to query queue state, should use the default value instead of modifying the state, because it may be modified elsewhere.
Quoted 7 lines
Quoted 7 lines
app/test-pmd/testpmd.c +3
-0+ }stream_init (fwd_streams[i]); + } + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;if (port_fwd_begin !=NULL ) {
Quoted 40 lines · ShiyangX
Quoted 17 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Monday, February 20, 2023 8:46 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: Re: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 4 lines · 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.Quoted 6 lines
Quoted 4 lines
This commit fixes the issue by calling 'rte_eth_rx/tx_queue_info_get' to get queue state from shared memory.
Fixes a78040c990cb ("app/testpmd: update forward engine beginning")should use this commit:
Fixes 3c4426db54fc ("app/testpmd: do not poll stopped queues")Thanks for your comments, I will ask maintainer to help fix this problem.
Quoted 15 lines
Quoted 15 lines
Signed-off-by Shiyang He <[email protected]>--- app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
134d79a555..2c73daf9eb100644app/test-pmd/testpmd.c +0
-0@@ -2378,9 +2378,34 @@ start_packet_forwarding(int with_tx_first)if (!pkt_fwd_shared_rxq_check ())return ;
Quoted 7 lines
Quoted 6 lines
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2383
Quoted 5 lines
app/test-pmd/testpmd.c +3
-2-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_PRIMARY ) {directly use "
rte_eal_process_type()==RTE_PROC_SECONDARY"?The following action should be executed for all non-primary processes.
"all non-primary processes" is which processes? it's only 'secondary' here, not 'auto', right?
Quoted 29 lines
Quoted 15 lines
Quoted 10 lines
app/test-pmd/testpmd.c +8
-0+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 =
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 4 lines
app/test-pmd/testpmd.c +4
-0+ rx_qinfo.queue_state; + else + TESTPMD_LOG(WARNING, + "Failed to get rx queueinfo\n");
Quoted 14 lines
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 10 lines
app/test-pmd/testpmd.c +5
-0+ + 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 =
app/test-pmd/testpmd.c +4
-0+ tx_qinfo.queue_state; + else + TESTPMD_LOG(WARNING, + "Failed to get tx queueinfo\n");
not all PMDs implement rte_eth_rx/tx_queue_info_get() to query the state, right?
Can you set this state to 'START' if the return value is '-ENOTSUP'?
Quoted 1 line
If pmd doesn't implement "rte_eth_rx/tx_queue_info_get()" to query queue state, should use the default value instead of modifying the state, because it may be modified elsewhere.
The rx/tx_queue_start/stop() can change Rx/Tx queue state if PMD supports this API.
In primary, if PMD doesn't support this API, this queue state do not be changed and still be the original value(RTE_ETH_QUEUE_STATE_STARTED) start_port() sets. However, in secondary, Rx/Tx queue state have not been initialized, your patch also do not it.
Namely, their default values are wrong.
Our plan needs to ensure that the PMDs that do not support rx/tx_queue_start/stop() or rx/tx_queue_info_get() can forward in secondary.
I think we either add the initialization of queue state in start_port() or somewhere else, or make sure it's ok here.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
app/test-pmd/testpmd.c +3
-0+ }stream_init (fwd_streams[i]); + } + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;if (port_fwd_begin !=NULL ) {
Quoted 106 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Tuesday, February 21, 2023 2:38 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: Re: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 42 lines · ShiyangX
Quoted 19 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Monday, February 20, 2023 8:46 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Burakov, Anatoly <[email protected]>; Li, Xiaoyun <[email protected]>; Alvin Zhang <[email protected]>
Subject: Re: [PATCH] app/testpmd: fix secondary process not forwardingQuoted 4 lines · 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.Quoted 6 lines
Quoted 4 lines
This commit fixes the issue by calling 'rte_eth_rx/tx_queue_info_get' to get queue state from shared memory.
Fixes a78040c990cb ("app/testpmd: update forward engine beginning")should use this commit:
Fixes 3c4426db54fc ("app/testpmd: do not poll stopped queues")Thanks for your comments, I will ask maintainer to help fix this problem.
Quoted 15 lines
Quoted 15 lines
Signed-off-by Shiyang He <[email protected]>--- app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
134d79a555..2c73daf9eb100644app/test-pmd/testpmd.c +0
-0@@ -2378,9 +2378,34 @@ start_packet_forwarding(int with_tx_first)if (!pkt_fwd_shared_rxq_check ())return ;Quoted 7 lines
Quoted 6 lines
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2383
Quoted 5 lines
app/test-pmd/testpmd.c +3
-2-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_PRIMARY ) {directly use "
rte_eal_process_type()==RTE_PROC_SECONDARY"?The following action should be executed for all non-primary processes.
"all non-primary processes" is which processes? it's only 'secondary' here, not 'auto', right?
Quoted 29 lines
Quoted 15 lines
Quoted 10 lines
app/test-pmd/testpmd.c +8
-0+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 =
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 4 lines
app/test-pmd/testpmd.c +4
-0+ rx_qinfo.queue_state; + else + TESTPMD_LOG(WARNING, + "Failed to get rx queueinfo\n");
Quoted 14 lines
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 10 lines
app/test-pmd/testpmd.c +5
-0+ + 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 =
app/test-pmd/testpmd.c +4
-0+ tx_qinfo.queue_state; + else + TESTPMD_LOG(WARNING, + "Failed to get tx queueinfo\n");
not all PMDs implement rte_eth_rx/tx_queue_info_get() to query the state, right?
Can you set this state to 'START' if the return value is '-ENOTSUP'?Quoted 1 line
If pmd doesn't implement "rte_eth_rx/tx_queue_info_get()" to query
queue state, should use the default value instead of modifying the state, because it may be modified elsewhere.
The rx/tx_queue_start/stop() can change Rx/Tx queue state if PMD supports this API.
In primary, if PMD doesn't support this API, this queue state do not be changed and still be the originalvalue(RTE_ETH_QUEUE_STATE_STARTED)start_port()sets.
However, in secondary, Rx/Tx queue state have not been initialized, your patch also do not it.
Namely, their default values are wrong.
Quoted 6 lines
Our plan needs to ensure that the PMDs that do not support rx/tx_queue_start/stop() or rx/tx_queue_info_get() can forward in secondary.
I think we either add the initialization of queue state in
start_port()or somewhere else, or make sure it's ok here.
Thanks for your comment, the v2 patch will be sent soon!
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
app/test-pmd/testpmd.c +3
-0+ }stream_init (fwd_streams[i]); + } + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;if (port_fwd_begin !=NULL ) {
PATCH v2 1/1 app/testpmd: fix secondary process not forwarding
In reply to Shiyang HeUnder 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.
v2: Add function return value processing
--- app/test-pmd/testpmd.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +33 -2
@@ -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 ) {
Signature · 1 line
2.37.2
Quoted 31 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v2: Add function return value processing
--- app/test-pmd/testpmd.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +3
-2@@ -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 ) {
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2433
Quoted 10 lines
app/test-pmd/testpmd.c +10
-0+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.
Quoted 24 lines
app/test-pmd/testpmd.c +20
-0+ 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 v3 1/1 app/testpmd: fix secondary process not forwarding
In reply to Shiyang HeUnder 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.
v3: Add return value description
--- app/test-pmd/testpmd.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +43 -2
@@ -2418,9 +2418,50 @@ 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 ==0 ) { + ports[fs->rx_port].rxq[fs->rx_queue].state = + rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the rxq state to RTE_ETH_QUEUE_STATE_STARTED +* to ensure that the PMDs do not implement +* rte_eth_rx_queue_info_get can forward. +*/ + 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 ==0 ) { + ports[fs->tx_port].txq[fs->tx_queue].state = + tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the txq state to RTE_ETH_QUEUE_STATE_STARTED +* to ensure that the PMDs do not implement +* rte_eth_tx_queue_info_get can forward. +*/ + 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 ) {
Signature · 1 line
2.37.2
Quoted 59 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
--- app/test-pmd/testpmd.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +31
-2@@ -2418,9 +2418,50 @@ 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 ==0 ) { + ports[fs->rx_port].rxq[fs->rx_queue].state = + rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the rxq state to RTE_ETH_QUEUE_STATE_STARTED +* to ensure that the PMDs do not implement +* rte_eth_rx_queue_info_get can forward. +*/ + 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 ==0 ) { + ports[fs->tx_port].txq[fs->tx_queue].state = + tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the txq state to RTE_ETH_QUEUE_STATE_STARTED
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2461
Quoted 10 lines
app/test-pmd/testpmd.c +10
-0+* to ensure that the PMDs do not implement +* rte_eth_tx_queue_info_get can forward. +*/ + 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" ); + } + }
This code is a little long after adding some comments.😂
It is a full code block. Let's extract a function to do it. what do you think, Shiyang?
Quoted 6 lines
app/test-pmd/testpmd.c +2
-0stream_init (fwd_streams[i]); + } + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;if (port_fwd_begin !=NULL ) {
Quoted 65 lines · lihuisong (C)
Quoted 63 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
---
app/test-pmd/testpmd.c| 45 ++++++++++++++++++++++++++++++++++++++++--1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +36
-1@@ -2418,9 +2418,50 @@ 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 == 0) { + ports[fs->rx_port].rxq[fs->rx_queue].state = + rx_qinfo.queue_state; + } else if (rc == -ENOTSUP) { + /* Set the rxq state to RTE_ETH_QUEUE_STATE_STARTED + * to ensure that the PMDs do not implement + * rte_eth_rx_queue_info_get can forward. + */ + 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 == 0) { + ports[fs->tx_port].txq[fs->tx_queue].state = + tx_qinfo.queue_state; + } else if (rc == -ENOTSUP) { + /* Set the txq state to RTE_ETH_QUEUE_STATE_STARTED + * to ensure that the PMDs do not implement + * rte_eth_tx_queue_info_get can forward. + */ + ports[fs->tx_port].txq[fs->tx_queue].state = + RTE_ETH_QUEUE_STATE_STARTED;
Quoted 8 lines
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2461
Quoted 5 lines
app/test-pmd/testpmd.c +5
-0+ } else { + TESTPMD_LOG(WARNING, + "Failed to get tx queue info\n"); + } + }This code is a little long after adding some comments.😂
It is a full code block. Let's extract a function to do it. what do you think, Shiyang?
+1 to extract code into a function.
Quoted 5 lines
Quoted 5 lines
app/test-pmd/testpmd.c +2
-0stream_init(fwd_streams[i]); + } + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin; if (port_fwd_begin != NULL) {
Quoted 63 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
--- app/test-pmd/testpmd.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +35
-2@@ -2418,9 +2418,50 @@ 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 ==0 ) { + ports[fs->rx_port].rxq[fs->rx_queue].state = + rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the rxq state to RTE_ETH_QUEUE_STATE_STARTED +* to ensure that the PMDs do not implement +* rte_eth_rx_queue_info_get can forward. +*/ + 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 ==0 ) { + ports[fs->tx_port].txq[fs->tx_queue].state = + tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the txq state to RTE_ETH_QUEUE_STATE_STARTED +* to ensure that the PMDs do not implement +* rte_eth_tx_queue_info_get can forward. +*/ + ports[fs->tx_port].txq[fs->tx_queue].state =
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2465
Quoted 10 lines
app/test-pmd/testpmd.c +8
-0+RTE_ETH_QUEUE_STATE_STARTED ; + }else { +TESTPMD_LOG (WARNING , +"Failed to get tx queue info\n" ); + } + }stream_init (fwd_streams[i]); + } + }
Testpmd duplicates some dpdk/ethdev state/config in application level, and this can bite in multiple cases, as it is happening here.
I am not sure if this was a design decision, but I think instead of testpmd storing ethdev related state/config in application level, it should store only application level state/config, and when ethdev related state/config is required app should get it directly from ethdev.
It may be too late already for testpmd, there is a mixed usage, but I am for preferring this approach when there is an opportunity.
For above issue, why queue state needs to be stored in application level 'port' variable?
Where is this queue state used?
Can it work to get queue state directly from ethdev where this state is used, instead of storing it in the 'port' variable in advance?
And perhaps testpmd 'port' variable can be updated there, both for primary and secondary, for backward compatibility (other existing users of this queue state).
What do you think?
Quoted 122 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 6, 2023 11:06 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 24 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
--- app/test-pmd/testpmd.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
0c14325b8d..a050472aea100644app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2423
Quoted 8 lines
app/test-pmd/testpmd.c +3
-2@@ -2418,9 +2418,50 @@ 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 ){
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 12 lines
app/test-pmd/testpmd.c +8
-0+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 ==0 ) { + ports[fs->rx_port].rxq[fs-rx_queue].state =
app/test-pmd/testpmd.c +3
-0+ rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the rxq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_rx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->rx_port].rxq[fs-rx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get rx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 10 lines
app/test-pmd/testpmd.c +6
-0+ } + + rc =rte_eth_tx_queue_info_get (fs->tx_port, + fs->tx_queue, &tx_qinfo); +if (rc ==0 ) { + ports[fs->tx_port].txq[fs-tx_queue].state =
app/test-pmd/testpmd.c +3
-0+ tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the txq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_tx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->tx_port].txq[fs-tx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get tx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2464
Quoted 6 lines
app/test-pmd/testpmd.c +4
-0+ } + }stream_init (fwd_streams[i]); + } + }Testpmd duplicates some dpdk/ethdev state/config in application level, and this can bite in multiple cases, as it is happening here.
I am not sure if this was a design decision, but I think instead of testpmd storing ethdev related state/config in application level, it should store only application level state/config, and when ethdev related state/config is required app should get it directly from ethdev.
It may be too late already for testpmd, there is a mixed usage, but I am for preferring this approach when there is an opportunity.
For above issue, why queue state needs to be stored in application level 'port' variable?
Where is this queue state used?
Quoted 8 lines
Can it work to get queue state directly from ethdev where this state is used, instead of storing it in the 'port' variable in advance?
And perhaps testpmd 'port' variable can be updated there, both for primary and secondary, for backward compatibility (other existing users of this queue state).
What do you think?
Thanks for your comments!
It is an effective method to get queue state directly from ethdev where this state is used. I also don't know the design meaning of the 'ports' variable. If modification is needed, a higher level of design and more work are required.
As a bug fix, apart from extracting the code block into a function, is the solution feasible?
Quoted 131 lines · ShiyangX
Quoted 122 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 6, 2023 11:06 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 24 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
--- app/test-pmd/testpmd.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
0c14325b8d..a050472aea100644app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2423
Quoted 8 lines
app/test-pmd/testpmd.c +3
-2@@ -2418,9 +2418,50 @@ 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 ){
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 12 lines
app/test-pmd/testpmd.c +8
-0+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 ==0 ) { + ports[fs->rx_port].rxq[fs-rx_queue].state =
app/test-pmd/testpmd.c +3
-0+ rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the rxq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_rx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->rx_port].rxq[fs-rx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get rx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 10 lines
app/test-pmd/testpmd.c +6
-0+ } + + rc =rte_eth_tx_queue_info_get (fs->tx_port, + fs->tx_queue, &tx_qinfo); +if (rc ==0 ) { + ports[fs->tx_port].txq[fs-tx_queue].state =
app/test-pmd/testpmd.c +3
-0+ tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the txq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_tx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->tx_port].txq[fs-tx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get tx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2464
Quoted 6 lines
app/test-pmd/testpmd.c +4
-0+ } + }stream_init (fwd_streams[i]); + } + }Testpmd duplicates some dpdk/ethdev state/config in application level, and this can bite in multiple cases, as it is happening here.
I am not sure if this was a design decision, but I think instead of testpmd storing ethdev related state/config in application level, it should store only application level state/config, and when ethdev related state/config is required app should get it directly from ethdev.
It may be too late already for testpmd, there is a mixed usage, but I am for preferring this approach when there is an opportunity.
For above issue, why queue state needs to be stored in application level 'port' variable?
Where is this queue state used?Quoted 8 lines
Can it work to get queue state directly from ethdev where this state is used, instead of storing it in the 'port' variable in advance?
And perhaps testpmd 'port' variable can be updated there, both for primary and secondary, for backward compatibility (other existing users of this queue state).
What do you think?
Quoted 7 lines
Thanks for your comments!
It is an effective method to get queue state directly from ethdev where this state is used. I also don't know the design meaning of the 'ports' variable. If modification is needed, a higher level of design and more work are required.
As a bug fix, apart from extracting the code block into a function, is the solution feasible?
Hi Shiyang,
As a bug fix, this issue (testpmd stored state not being up to date for secondary process) looks like have potential to occur many different flavors, that is why what about having a central update?
I think 'start_port()' can be a good place for this kind of update:
start_port() {
... if (secondary) update_state() }
update_state() {
update_queue_state()
}
update_queue_state() {
<your code goes here>
}
Having secondary checks and updates in multiple places can make code harder to understand.
What do you think to update as above?
Quoted 181 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, March 7, 2023 7:41 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 114 lines · ShiyangX
Quoted 114 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 6, 2023 11:06 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 24 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
--- app/test-pmd/testpmd.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
0c14325b8d..a050472aea100644app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2423
Quoted 8 lines
app/test-pmd/testpmd.c +3
-2@@ -2418,9 +2418,50 @@ 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 ){
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 12 lines
app/test-pmd/testpmd.c +8
-0+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 ==0 ) { + ports[fs->rx_port].rxq[fs-rx_queue].state =
app/test-pmd/testpmd.c +3
-0+ rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the rxq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_rx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->rx_port].rxq[fs-rx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get rx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 10 lines
app/test-pmd/testpmd.c +6
-0+ } + + rc =rte_eth_tx_queue_info_get (fs->tx_port, + fs->tx_queue, &tx_qinfo); +if (rc ==0 ) { + ports[fs->tx_port].txq[fs-tx_queue].state =
app/test-pmd/testpmd.c +3
-0+ tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the txq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_tx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->tx_port].txq[fs-tx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get tx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2464
Quoted 6 lines
app/test-pmd/testpmd.c +4
-0+ } + }stream_init (fwd_streams[i]); + } + }Testpmd duplicates some dpdk/ethdev state/config in application level, and this can bite in multiple cases, as it is happening here.
I am not sure if this was a design decision, but I think instead of testpmd storing ethdev related state/config in application level, it should store only application level state/config, and when ethdev related state/config is required app should get it directly from ethdev.
Quoted 6 lines
Quoted 6 lines
It may be too late already for testpmd, there is a mixed usage, but I am for preferring this approach when there is an opportunity.
For above issue, why queue state needs to be stored in application level
'port'
Quoted 10 lines
Quoted 10 lines
variable?
Where is this queue state used?Can it work to get queue state directly from ethdev where this state is used, instead of storing it in the 'port' variable in advance?
And perhaps testpmd 'port' variable can be updated there, both for primary and secondary, for backward compatibility (other existing users of this queue state).
Quoted 5 lines
Quoted 1 line
What do you think?
Thanks for your comments!
It is an effective method to get queue state directly from ethdev where this
state is used.
Quoted 4 lines
I also don't know the design meaning of the 'ports' variable. If modification is needed, a higher level of design and more work are required.
As a bug fix, apart from extracting the code block into a function, is the
solution feasible?
Hi Shiyang,
As a bug fix, this issue (testpmd stored state not being up to date for secondary process) looks like have potential to occur many different flavors, that is why what about having a central update?
I think '
start_port()' can be a good place for this kind of update:
start_port(){... if (secondary) update_state() }
update_state(){
update_queue_state()
}
update_queue_state(){
<your code goes here>
}
Quoted 7 lines
Having secondary checks and updates in multiple places can make code harder to understand.
What do you think to update as above?
Thanks for your reply!
It is more reasonable to update the queue state in 'start_port()'. I'll send a new patch asap.
Quoted 180 lines · ShiyangX
Quoted 180 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, March 7, 2023 7:41 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 112 lines · ShiyangX
Quoted 112 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 6, 2023 11:06 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 24 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
--- app/test-pmd/testpmd.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
0c14325b8d..a050472aea100644app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2423
Quoted 8 lines
app/test-pmd/testpmd.c +3
-2@@ -2418,9 +2418,50 @@ 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 ){
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 12 lines
app/test-pmd/testpmd.c +8
-0+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 ==0 ) { + ports[fs->rx_port].rxq[fs-rx_queue].state =
app/test-pmd/testpmd.c +3
-0+ rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the rxq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_rx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->rx_port].rxq[fs-rx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get rx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 10 lines
app/test-pmd/testpmd.c +6
-0+ } + + rc =rte_eth_tx_queue_info_get (fs->tx_port, + fs->tx_queue, &tx_qinfo); +if (rc ==0 ) { + ports[fs->tx_port].txq[fs-tx_queue].state =
app/test-pmd/testpmd.c +3
-0+ tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* Set the txq state to
RTE_ETH_QUEUE_STATE_STARTEDapp/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* to ensure that the PMDs do not implement
app/test-pmd/testpmd.c
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+* rte_eth_tx_queue_info_get can forward.
Quoted 4 lines
app/test-pmd/testpmd.c +2
-0+*/ + ports[fs->tx_port].txq[fs-tx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first)
Quoted 3 lines
app/test-pmd/testpmd.c +3
-0+ }else { + TESTPMD_LOG(WARNING, + "Failed to get tx queueinfo\n");
app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2464
Quoted 6 lines
app/test-pmd/testpmd.c +4
-0+ } + }stream_init (fwd_streams[i]); + } + }Testpmd duplicates some dpdk/ethdev state/config in application level, and this can bite in multiple cases, as it is happening here.
I am not sure if this was a design decision, but I think instead of testpmd storing ethdev related state/config in application level, it should store only application level state/config, and when ethdev related state/config is required app should get it directly from ethdev.
Quoted 6 lines
Quoted 6 lines
It may be too late already for testpmd, there is a mixed usage, but I am for preferring this approach when there is an opportunity.
For above issue, why queue state needs to be stored in application level
'port'
Quoted 6 lines
Quoted 6 lines
variable?
Where is this queue state used?Can it work to get queue state directly from ethdev where this state is used, instead of storing it in the 'port' variable in advance?
Quoted 8 lines
Quoted 5 lines
And perhaps testpmd 'port' variable can be updated there, both for primary and secondary, for backward compatibility (other existing users of this queue state).
What do you think?
Thanks for your comments!
It is an effective method to get queue state directly from ethdev where this
state is used.
Quoted 4 lines
I also don't know the design meaning of the 'ports' variable. If modification is needed, a higher level of design and more work are required.
As a bug fix, apart from extracting the code block into a function, is the
solution feasible?
Hi Shiyang,
As a bug fix, this issue (testpmd stored state not being up to date for secondary process) looks like have potential to occur many different flavors, that is why what about having a central update?
I think '
start_port()' can be a good place for this kind of update:
start_port(){... if (secondary) update_state() }
update_state(){
update_queue_state()
}
update_queue_state(){
<your code goes here>
}Having secondary checks and updates in multiple places can make code harder to understand.
Quoted 6 lines
Quoted 4 lines
What do you think to update as above?
Thanks for your reply!
It is more reasonable to update the queue state in 'start_port()'. I'll send a new patch asap.
It's also necessary to update the queue state when start forwarding.
Because the state may be changed after start port.
The state cannot be updated in real time(because of no notification), but it's helpful for secondary.
Quoted 196 lines · lihuisong (C)
Quoted 194 lines · ShiyangX
Quoted 194 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, March 7, 2023 7:41 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying
<[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 114 lines · ShiyangX
Quoted 114 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 6, 2023 11:06 PM
To: He, ShiyangX <[email protected]>; [email protected]
Cc: Zhou, YidingX <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Singh, Aman Deep <[email protected]>; Burakov, Anatoly <[email protected]>; Matan Azrad <[email protected]>; Dmitry Kozlyuk <[email protected]>
Subject: Re: [PATCH v3] app/testpmd: fix secondary process not forwardingQuoted 25 lines · 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")Signed-off-by Shiyang He <[email protected]>Acked-by Yuying Zhang <[email protected]>v3: Add return value description
---
app/test-pmd/testpmd.c| 45
++++++++++++++++++++++++++++++++++++++++--1 file changed, 43 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
0c14325b8d..a050472aea100644app/test-pmd/testpmd.c start_packet_forwarding(int with_tx_first) · line 2423
Quoted 8 lines
app/test-pmd/testpmd.c +3
-2@@ -2418,9 +2418,50 @@ 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){
Quoted 8 lines
app/test-pmd/testpmd.c +8
-0+ 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 == 0) { + ports[fs->rx_port].rxq[fs-Quoted 4 lines
rx_queue].state =
+ rx_qinfo.queue_state;
+ } else if (rc ==-ENOTSUP) {
+ /* Set the rxq state to
RTE_ETH_QUEUE_STATE_STARTEDQuoted 1 line
+ * to ensure that the PMDs do not
implement
Quoted 1 line
+ *
rte_eth_rx_queue_info_getcanforward.
Quoted 4 lines
+ */
+ ports[fs->rx_port].rxq[fs-
rx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;
Quoted 3 lines
+ } else {
+ TESTPMD_LOG(WARNING,
+ "Failed to get rx queueinfo\n");
Quoted 10 lines
+ }
+
+ rc =rte_eth_tx_queue_info_get(fs->tx_port, + fs->tx_queue, &tx_qinfo); + if (rc == 0) {
+ ports[fs->tx_port].txq[fs- tx_queue].state =
+ tx_qinfo.queue_state;
+ } else if (rc ==-ENOTSUP) {
+ /* Set the txq state to
RTE_ETH_QUEUE_STATE_STARTEDQuoted 1 line
+ * to ensure that the PMDs do not
implement
Quoted 1 line
+ *
rte_eth_tx_queue_info_getcanforward.
Quoted 4 lines
+ */
+ ports[fs->tx_port].txq[fs-
tx_queue].state =
+RTE_ETH_QUEUE_STATE_STARTED;
Quoted 3 lines
+ } else {
+ TESTPMD_LOG(WARNING,
+ "Failed to get tx queueinfo\n");
Quoted 6 lines
+ }
+ }
stream_init(fwd_streams[i]);
+ }
+ }Testpmd duplicates some dpdk/ethdev state/config in application level, and this can bite in multiple cases, as it is happening here.
I am not sure if this was a design decision, but I think instead of testpmd storing ethdev related state/config in application level, it should store only application level state/config, and when ethdev related state/config is required app should get it directly from ethdev.
Quoted 7 lines
Quoted 7 lines
It may be too late already for testpmd, there is a mixed usage, but I am for preferring this approach when there is an opportunity.
For above issue, why queue state needs to be stored in application level
'port'
Quoted 10 lines
Quoted 10 lines
variable?
Where is this queue state used?Can it work to get queue state directly from ethdev where this state is used, instead of storing it in the 'port' variable in advance?
And perhaps testpmd 'port' variable can be updated there, both for primary and secondary, for backward compatibility (other existing users of this queue state).
Quoted 5 lines
Quoted 1 line
What do you think?
Thanks for your comments!
It is an effective method to get queue state directly from ethdev where this
state is used.
Quoted 6 lines
I also don't know the design meaning of the 'ports' variable. If modification is needed, a higher level of design and more work are required.
As a bug fix, apart from extracting the code block into a function, is the
solution feasible?
Hi Shiyang,
As a bug fix, this issue (testpmd stored state not being up to date for secondary process) looks like have potential to occur many different flavors,
that is why what about having a central update?I think '
start_port()' can be a good place for this kind of update:
start_port(){...
if (secondary)
update_state()
}
update_state(){
update_queue_state()
}
update_queue_state(){
<your code goes here>
}Having secondary checks and updates in multiple places can make code harder
to understand.What do you think to update as above?
Quoted 5 lines
Quoted 3 lines
Thanks for your reply!
It is more reasonable to update the queue state in 'start_port()'. I'll send a new patch asap.It's also necessary to update the queue state when start forwarding. Because the state may be changed after start port.
I was hoping updating on a single point can be sufficient, is this needed because of testpmd commands?
Quoted 2 lines
The state cannot be updated in real time(because of no notification), but it's helpful for secondary.
PATCH v4 1/1 app/testpmd: fix secondary process not forwarding
In reply to Shiyang HeUnder 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.
v2: Add function return value processing
v3: Add return value description
v4: Update queue state in 'start_port()'
--- app/test-pmd/testpmd.c | 72 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-)
app/test-pmd/testpmd.c +71 -1
@@ -2379,6 +2379,70 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) } } +static void +update_rx_queue_state (uint16_t port_id,uint16_t queue_id) +{ +struct rte_eth_rxq_info rx_qinfo; +int32_t rc; + + rc =rte_eth_rx_queue_info_get (port_id, + queue_id, &rx_qinfo); +if (rc ==0 ) { + ports[port_id].rxq[queue_id].state = + rx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* +* Set the rxq state to RTE_ETH_QUEUE_STATE_STARTED +* to ensure that the PMDs do not implement +* rte_eth_rx_queue_info_get can forward. +*/ + ports[port_id].rxq[queue_id].state = +RTE_ETH_QUEUE_STATE_STARTED ; + }else { +TESTPMD_LOG (WARNING , +"Failed to get rx queue info\n" ); + } +} + +static void +update_tx_queue_state (uint16_t port_id,uint16_t queue_id) +{ +struct rte_eth_txq_info tx_qinfo; +int32_t rc; + + rc =rte_eth_tx_queue_info_get (port_id, + queue_id, &tx_qinfo); +if (rc ==0 ) { + ports[port_id].txq[queue_id].state = + tx_qinfo.queue_state; + }else if (rc == -ENOTSUP ) { +/* +* Set the txq state to RTE_ETH_QUEUE_STATE_STARTED +* to ensure that the PMDs do not implement +* rte_eth_tx_queue_info_get can forward. +*/ + ports[port_id].txq[queue_id].state = +RTE_ETH_QUEUE_STATE_STARTED ; + }else { +TESTPMD_LOG (WARNING , +"Failed to get tx queue info\n" ); + } +} + +static void +update_queue_state (void ) +{ +portid_t pi; +queueid_t qi; + +RTE_ETH_FOREACH_DEV (pi) { +for (qi =0 ; qi < nb_rxq; qi++) +update_rx_queue_state (pi, qi); +for (qi =0 ; qi < nb_txq; qi++) +update_tx_queue_state (pi, qi); + } +} +/* * Launch packet forwarding configuration. */
@@ -2418,9 +2482,12 @@ start_packet_forwarding(int with_tx_first)if (!pkt_fwd_shared_rxq_check ())return ; -if (stream_init !=NULL ) +if (stream_init !=NULL ) { +if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) +update_queue_state ();for (i =0 ; i < cur_fwd_config.nb_fwd_streams; i++)stream_init (fwd_streams[i]); + } port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;if (port_fwd_begin !=NULL ) {
@@ -3180,6 +3247,9 @@ start_port(portid_t pid) pl[cfg_pi++] = pi; } +if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) +update_queue_state (); +if (at_least_one_port_successfully_started && !no_link_check)check_all_ports_link_status (RTE_PORT_ALL );else if (at_least_one_port_exist & all_ports_already_started)
Signature · 1 line
2.37.2
Quoted 11 lines · 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")Signed-off-by Shiyang He <[email protected]>
Applied to dpdk-next-net/main, thanks.