Skip to contentSkip to conversation

display testpmd forwarding engine stats on the fly

PATCH Superseded David Marchand 10 participants 72 messages Feb 14, 2019 – Mar 25, 2019

lore
Share & tools
lore
#0 lore raw

cover display testpmd forwarding engine stats on the fly

Here is a little series that makes it possible to display and clear testpmd fwd engines while they run without having to stop them. This is mostly handy when running stress tests and you look for packets drops without having to stop/start testpmd forwarding.

Example:

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 261977064 TX-packets: 261977064 TX-dropped: 0

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 261985142 TX-packets: 261985142 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 261977096      RX-dropped: 0             RX-total: 261977096
  TX-packets: 261985155      TX-dropped: 0             TX-total: 261985155

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 261985188      RX-dropped: 0             RX-total: 261985188
  TX-packets: 261977128      TX-dropped: 0             TX-total: 261977128

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 523962284      RX-dropped: 0             RX-total: 523962284
  TX-packets: 523962283      TX-dropped: 0             TX-total: 523962283

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 274293770 TX-packets: 274293642 TX-dropped: 128

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 274301850 TX-packets: 274301850 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
  TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
  TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
  TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

David Marchand (5):
app/testpmd: remove unused fwd_ctx field app/testpmd: add missing newline when showing statistics app/testpmd: add missing transmit errors stats app/testpmd: remove useless casts on statistics app/testpmd: display/clear forwarding stats on demand

 app/test-pmd/cmdline.c                      |  44 +++
 app/test-pmd/testpmd.c                      | 451 ++++++++++++++--------------
 app/test-pmd/testpmd.h                      |  22 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 316 insertions(+), 237 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/5 app/testpmd: remove unused fwd_ctx field

Remove some leftover from a previous rework.

Fixes c4bcc342c8ee ("app/testpmd: refactor ieee1588 forwarding")
---
 app/test-pmd/testpmd.h | 1 -
 1 file changed, 1 deletion(-)
app/test-pmd/testpmd.h +0 -1
index fa48878..85b791b 100644
@@ -173,7 +173,6 @@ struct rte_port {
 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
 	uint16_t                tx_vlan_id;/**< The tag ID */
 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-	void                    *fwd_ctx;   /**< Forwarding mode context */
 	uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
 	uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
 	uint64_t                rx_bad_outer_l4_csum;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] app/testpmd: remove unused fwd_ctx field

I believe this patch should be cc'ed/sent to [email protected]

Quoted 27 lines · David Marchand

Remove some leftover from a previous rework.

Fixes c4bcc342c8ee ("app/testpmd: refactor ieee1588 forwarding")
---
 app/test-pmd/testpmd.h | 1 -
 1 file changed, 1 deletion(-)
app/test-pmd/testpmd.h +0 -0
index fa48878..85b791b 100644
@@ -173,7 +173,6 @@ struct rte_port {
        uint16_t                tunnel_tso_segsz; /**< Segmentation

offload MSS for tunneled pkts. */

        uint16_t                tx_vlan_id;/**< The tag ID */
        uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-       void                    *fwd_ctx;   /**< Forwarding mode context */
        uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip
checksum  */
        uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4
checksum */
        uint64_t                rx_bad_outer_l4_csum;

--
1.8.3.1

Signature · 2 lines
regards,
Rami Rosen
#3 lore raw

PATCH 2/5 app/testpmd: add missing newline when showing statistics

In reply to David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:
RX-packets: 3542977 TX-packets: 3542971 TX-dropped: 6 RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:
RX-packets: 4629969 TX-packets: 4629969 TX-dropped: 0
RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others] TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]

---
 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +1 -1
index 98c1baa..984155a 100644
@@ -1459,7 +1459,7 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
Signature · 1 line
1.8.3.1
#4 lore raw

Re: [PATCH 2/5] app/testpmd: add missing newline when showing statistics

+1
Reviewed-by: Rami Rosen <ramirose at gmail.com>

Quoted 35 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:
RX-packets: 3542977 TX-packets: 3542971 TX-dropped: 6

         RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:
RX-packets: 4629969 TX-packets: 4629969 TX-dropped: 0
RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others] TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]

---
 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +1 -2
index 98c1baa..984155a 100644
@@ -1459,7 +1459,7 @@ struct extmem_param {
               "TX Port=%2d/Queue=%2d %s\n",
               fwd_top_stats_border, fs->rx_port, fs->rx_queue,
               fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-       printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+       printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
               fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
        /* if checksum mode */
--

1.8.3.1

Signature · 2 lines
regards,
Rami Rosen
#5 lore raw

PATCH 3/5 app/testpmd: add missing transmit errors stats

In reply to David Marchand

pmd can report transmit errors but those stats are not accounted here.

---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c +1 -0
index 984155a..3acd97b 100644
@@ -1838,6 +1838,7 @@ struct extmem_param {
 		total_recv += stats.ipackets;
 		total_xmit += stats.opackets;
 		total_rx_dropped += stats.imissed;
+		port->tx_dropped += stats.oerrors;
 		total_tx_dropped += port->tx_dropped;
 		total_rx_nombuf  += stats.rx_nombuf;
 
Signature · 1 line
1.8.3.1
#6 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 13 lines · David Marchand

pmd can report transmit errors but those stats are not accounted here.

---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c +0 -0
index 984155a..3acd97b 100644

app/test-pmd/testpmd.c struct extmem_param { · line 1844

Quoted 7 lines
app/test-pmd/testpmd.c +1 -0
@@ -1838,6 +1838,7 @@ struct extmem_param {
 		total_recv += stats.ipackets;
 		total_xmit += stats.opackets;
 		total_rx_dropped += stats.imissed;
+		port->tx_dropped += stats.oerrors;
 		total_tx_dropped += port->tx_dropped;
 		total_rx_nombuf  += stats.rx_nombuf;
 

Without knowing as to whether the line is needed or not, the line itself looks out of place. All other lines are assignments to local variables, apart from this. Should a local variable be defined for consistency?

/Bruce

#7 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 8 lines · Bruce Richardson
Quoted 7 lines · David Marchand

pmd can report transmit errors but those stats are not accounted here.

---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 17 lines

app/test-pmd/testpmd.c struct extmem_param { · line 1844

Quoted 13 lines
app/test-pmd/testpmd.c +1 -0
index 984155a..3acd97b 100644
@@ -1838,6 +1838,7 @@ struct extmem_param {
              total_recv += stats.ipackets;
              total_xmit += stats.opackets;
              total_rx_dropped += stats.imissed;
+             port->tx_dropped += stats.oerrors;
              total_tx_dropped += port->tx_dropped;
              total_rx_nombuf  += stats.rx_nombuf;
 

Without knowing as to whether the line is needed or not, the line itself looks out of place. All other lines are assignments to local variables, apart from this. Should a local variable be defined for consistency?

Indeed this looks wrong to add it to port->tx_dropped.
It actually "works" since this part is called when stopping forwarding and port->tx_dropped gets reset later when starting forwarding again.

I suppose I should move this to total_tx_dropped instead.

Thanks Bruce.

Signature · 1 line
David Marchand
#8 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 20 lines · David Marchand
Quoted 17 lines · Bruce Richardson
Quoted 16 lines · David Marchand

pmd can report transmit errors but those stats are not accounted here.

---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c +1 -0
index 984155a..3acd97b 100644
@@ -1838,6 +1838,7 @@ struct extmem_param {
              total_recv += stats.ipackets;
              total_xmit += stats.opackets;
              total_rx_dropped += stats.imissed;
+             port->tx_dropped += stats.oerrors;
Quoted 10 lines
Quoted 8 lines

app/test-pmd/testpmd.c struct extmem_param { · line 1844

Quoted 4 lines
app/test-pmd/testpmd.c +0 -0
              total_tx_dropped += port->tx_dropped;
              total_rx_nombuf  += stats.rx_nombuf;
 

Without knowing as to whether the line is needed or not, the line itself looks out of place. All other lines are assignments to local variables, apart from this. Should a local variable be defined for consistency?

Thinking again about this oerrors stats...

We had a discussion with Maxime, last week.
So I want to make sure that what we both agreed makes sense :-)

What is the purpose of oerrors ?

Since the drivers (via rte_eth_tx_burst return value) report the numbers of packets successfully transmitted, the application can try to retransmit the packets that did not make it and counts this.
If the driver counts such "missed" packets, then it does the job the application will do anyway (wasting some cycles).
But what is more a problem is that the application does not know if the packets in oerrors are its own retries or problems that the driver can not detect (hw problems) but the hw can.

So the best option is that oerrors does not report the packets the driver refuses (and I can see some drivers that do not comply to this) but only "external" errors from the driver pov.

Back to my patch here, if we agree on this definition of oerrors, I can not add it to total_tx_dropped, but I suppose I can add some "TX HW errors: " and "Total TX HW errors: " logs so that we are aware that something went bad "further" than the driver.

Let's sleep on it :-)

Signature · 1 line
David Marchand
#9 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

14/02/2019 19:51, David Marchand:

Quoted 11 lines

What is the purpose of oerrors ?

Since the drivers (via rte_eth_tx_burst return value) report the numbers of packets successfully transmitted, the application can try to retransmit the packets that did not make it and counts this.
If the driver counts such "missed" packets, then it does the job the application will do anyway (wasting some cycles).
But what is more a problem is that the application does not know if the packets in oerrors are its own retries or problems that the driver can not detect (hw problems) but the hw can.

Quoted 3 lines

So the best option is that oerrors does not report the packets the driver refuses (and I can see some drivers that do not comply to this) but only "external" errors from the driver pov.

I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.

What about splitting the Tx errors in 2 fields? oerrors / ofull ? Who said it's awful? sorry Bruce for anticipating ;)

#10 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 19 lines · Thomas Monjalon

14/02/2019 19:51, David Marchand:

Quoted 3 lines

What is the purpose of oerrors ?

Since the drivers (via rte_eth_tx_burst return value) report the numbers

of

Quoted 1 line

packets successfully transmitted, the application can try to retransmit

the

Quoted 5 lines

packets that did not make it and counts this.
If the driver counts such "missed" packets, then it does the job the application will do anyway (wasting some cycles).
But what is more a problem is that the application does not know if the packets in oerrors are its own retries or problems that the driver can

not

Quoted 5 lines

detect (hw problems) but the hw can.

So the best option is that oerrors does not report the packets the driver refuses (and I can see some drivers that do not comply to this) but only "external" errors from the driver pov.

Quoted 8 lines

I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.

What about splitting the Tx errors in 2 fields? oerrors / ofull ? Who said it's awful? sorry Bruce for anticipating ;)

Summary, correct me if we are not aligned :-)

- ofull (maybe ofifoerrors?) is actually a count of SW failed transmits
- it would be handled in rte_eth_tx_burst() itself in a generic way
- the drivers do not need to track such SW failed transmits
- oerrors only counts packets HW failed transmits, dropped out of the driver tx_pkt_burst() knowledge
- the application does not have to track SW failed transmits since the stats is in ethdev

It sounds good to me, this means an ethdev abi breakage.

I will drop my current patch anyway.
Touching oerrors would be a separate effort.

Signature · 1 line
David Marchand
#11 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 32 lines · David Marchand

On Fri, Feb 15, 2019 at 9:58 AM Thomas Monjalon <[1][email protected]> wrote:

14/02/2019 19:51, David Marchand:
> What is the purpose of oerrors ?
>
> Since the drivers (via rte_eth_tx_burst return value) report the numbers of
> packets successfully transmitted, the application can try to retransmit the
> packets that did not make it and counts this.
> If the driver counts such "missed" packets, then it does the job the
> application will do anyway (wasting some cycles).
> But what is more a problem is that the application does not know if the
> packets in oerrors are its own retries or problems that the driver can not
> detect (hw problems) but the hw can.
>
> So the best option is that oerrors does not report the packets the driver
> refuses (and I can see some drivers that do not comply to this) but only
> "external" errors from the driver pov.
I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.
What about splitting the Tx errors in 2 fields? oerrors / ofull ? Who said it's awful? sorry Bruce for anticipating ;)

Quoted 9 lines

Summary, correct me if we are not aligned :-)
- ofull (maybe ofifoerrors?) is actually a count of SW failed transmits
- it would be handled in rte_eth_tx_burst() itself in a generic way
- the drivers do not need to track such SW failed transmits
- oerrors only counts packets HW failed transmits, dropped out of the driver tx_pkt_burst() knowledge
- the application does not have to track SW failed transmits since the stats is in ethdev
It sounds good to me, this means an ethdev abi breakage.

Hang on, why do we need ethdev to track this at all, given that it's trivial for apps to track this themselves. Would we not be better just to add this tracking into testpmd and leave ethdev and drivers alone? Perhaps I'm missing something?

#12 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 47 lines · Bruce Richardson
Quoted 32 lines · David Marchand

On Fri, Feb 15, 2019 at 9:58 AM Thomas Monjalon
<[1][email protected]> wrote:

    14/02/2019 19:51, David Marchand:
Quoted 3 lines

What is the purpose of oerrors ?

Since the drivers (via rte_eth_tx_burst return value) report the

numbers of

Quoted 1 line

packets successfully transmitted, the application can try to

retransmit the

Quoted 2 lines

packets that did not make it and counts this.
If the driver counts such "missed" packets, then it does the job

the

Quoted 2 lines

application will do anyway (wasting some cycles).
But what is more a problem is that the application does not know

if the

Quoted 1 line

packets in oerrors are its own retries or problems that the driver

can not

Quoted 3 lines

detect (hw problems) but the hw can.

So the best option is that oerrors does not report the packets the

driver

Quoted 1 line

refuses (and I can see some drivers that do not comply to this)

but only

Quoted 1 line

"external" errors from the driver pov.

I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.
What about splitting the Tx errors in 2 fields? oerrors / ofull ? Who said it's awful? sorry Bruce for anticipating ;)

Quoted 9 lines

Summary, correct me if we are not aligned :-)
- ofull (maybe ofifoerrors?) is actually a count of SW failed transmits
- it would be handled in rte_eth_tx_burst() itself in a generic way
- the drivers do not need to track such SW failed transmits
- oerrors only counts packets HW failed transmits, dropped out of the driver tx_pkt_burst() knowledge
- the application does not have to track SW failed transmits since the stats is in ethdev
It sounds good to me, this means an ethdev abi breakage.

Quoted 4 lines

Hang on, why do we need ethdev to track this at all, given that it's trivial for apps to track this themselves. Would we not be better just to add this tracking into testpmd and leave ethdev and drivers alone? Perhaps I'm missing something?

Adding the counters to ethdev stats is a good idea to me, the number of tx full failures is a great counter as it can tell you a lot about performance of the application. if the ofull counter is high then we have a lot of re-xmit attempts which can point to the problem quicker IMO. Adding it to the PMDs is the right place for this type of information as it is a very common needed counter.

Quoted 1 line

Regards,
Keith

#13 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

In reply to Bruce Richardson
Quoted 44 lines · Bruce Richardson
Quoted 32 lines · David Marchand

On Fri, Feb 15, 2019 at 9:58 AM Thomas Monjalon <[1][email protected]> wrote:

14/02/2019 19:51, David Marchand:
> What is the purpose of oerrors ?
>
> Since the drivers (via rte_eth_tx_burst return value) report the numbers of
> packets successfully transmitted, the application can try to retransmit the
> packets that did not make it and counts this.
> If the driver counts such "missed" packets, then it does the job the
> application will do anyway (wasting some cycles).
> But what is more a problem is that the application does not know if the
> packets in oerrors are its own retries or problems that the driver can not
> detect (hw problems) but the hw can.
>
> So the best option is that oerrors does not report the packets the driver
> refuses (and I can see some drivers that do not comply to this) but only
> "external" errors from the driver pov.
I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.
What about splitting the Tx errors in 2 fields? oerrors / ofull ? Who said it's awful? sorry Bruce for anticipating ;)

Quoted 2 lines

Summary, correct me if we are not aligned :-)
- ofull (maybe ofifoerrors?) is actually a count of SW failed

transmits

Quoted 7 lines

- it would be handled in rte_eth_tx_burst() itself in a generic way
- the drivers do not need to track such SW failed transmits
- oerrors only counts packets HW failed transmits, dropped out of the driver tx_pkt_burst() knowledge
- the application does not have to track SW failed transmits since the stats is in ethdev
It sounds good to me, this means an ethdev abi breakage.

Quoted 5 lines

Hang on, why do we need ethdev to track this at all, given that it's trivial for apps to track this themselves. Would we not be better just to add this tracking into testpmd and leave ethdev and drivers alone? Perhaps I'm missing something?

This was my first intention but Thomas hopped in ;-)

testpmd does it already via the fs->fwd_dropped stats and ovs has its tx_dropped stat.

The problem is that all drivers have different approach about this. Some drivers only count real hw errors in oerrors.
But others count the packets it can't send in oerrors (+ there are some cases that seem buggy to me where the driver will always refuse the mbufs for reason X and the application can retry indefinitely to send...).

Signature · 1 line
David Marchand
#14 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

15/02/2019 16:04, David Marchand:

Quoted 47 lines
Quoted 44 lines · Bruce Richardson
Quoted 32 lines · David Marchand

On Fri, Feb 15, 2019 at 9:58 AM Thomas Monjalon <[1][email protected]> wrote:

14/02/2019 19:51, David Marchand:
> What is the purpose of oerrors ?
>
> Since the drivers (via rte_eth_tx_burst return value) report the numbers of
> packets successfully transmitted, the application can try to retransmit the
> packets that did not make it and counts this.
> If the driver counts such "missed" packets, then it does the job the
> application will do anyway (wasting some cycles).
> But what is more a problem is that the application does not know if the
> packets in oerrors are its own retries or problems that the driver can not
> detect (hw problems) but the hw can.
>
> So the best option is that oerrors does not report the packets the driver
> refuses (and I can see some drivers that do not comply to this) but only
> "external" errors from the driver pov.
I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.
What about splitting the Tx errors in 2 fields? oerrors / ofull ? Who said it's awful? sorry Bruce for anticipating ;)

Quoted 2 lines

Summary, correct me if we are not aligned :-)
- ofull (maybe ofifoerrors?) is actually a count of SW failed

transmits

Quoted 7 lines

- it would be handled in rte_eth_tx_burst() itself in a generic way
- the drivers do not need to track such SW failed transmits
- oerrors only counts packets HW failed transmits, dropped out of the driver tx_pkt_burst() knowledge
- the application does not have to track SW failed transmits since the stats is in ethdev
It sounds good to me, this means an ethdev abi breakage.

Quoted 7 lines
Quoted 5 lines

Hang on, why do we need ethdev to track this at all, given that it's trivial for apps to track this themselves. Would we not be better just to add this tracking into testpmd and leave ethdev and drivers alone? Perhaps I'm missing something?

This was my first intention but Thomas hopped in ;-)

I was just opening the discussion :)

Quoted 8 lines

testpmd does it already via the fs->fwd_dropped stats and ovs has its tx_dropped stat.

The problem is that all drivers have different approach about this. Some drivers only count real hw errors in oerrors.
But others count the packets it can't send in oerrors (+ there are some cases that seem buggy to me where the driver will always refuse the mbufs for reason X and the application can retry indefinitely to send...).

We have 3 options:
1/ status quo = oerrors is inconsistent across drivers 2/ API break = oerrors stop being incremented for temporary
unavailability (i.e. queue full, kind of ERETRY), report only packets which will be never sent, may be a small performance gain for some drivers
3/ API + ABI break = same as 2/ +
report ERETRY errors in ofull (same as tx_burst() delta)

Note that the option 2 is a light API break which does not require any deprecation notice because the original definition of oerrors is really vague: "failed transmitted packets"
By changing the definition of errors to "packets lost", we can count HW errors + packets not matching requirements.
As David suggests, the packets not matching requirements can be freed as it is done for packets successfully transmitted to the HW. We need also to update the definition of the return value of rte_eth_tx_burst(): "packets actually stored in transmit descriptors". We should also count the bad packets rejected by the driver. Then the number of bad packets would be the difference between the return value of rte_eth_tx_burst() and opackets counter. This solution is fixing some bugs and enforce a consistent behaviour.

The option 3 is breaking the ABI and may degrade the performances. The only benefit is convenience or semantic: ofull would be the equivalent of imissed.
The application can count the same by making the difference between the burst size and the return of rte_eth_tx_burst.

My vote is for the option 2.

#15 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 89 lines · Thomas Monjalon

15/02/2019 16:04, David Marchand:

Quoted 1 line

On Fri, Feb 15, 2019 at 3:05 PM Bruce Richardson <

[email protected]>

Quoted 10 lines
Quoted 8 lines · wrote:
Quoted 7 lines · David Marchand

On Fri, Feb 15, 2019 at 9:58 AM Thomas Monjalon <[1][email protected]> wrote:

14/02/2019 19:51, David Marchand:
> What is the purpose of oerrors ?
>
> Since the drivers (via rte_eth_tx_burst return value) report

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

numbers of
> packets successfully transmitted, the application can try to retransmit the
> packets that did not make it and counts this.
> If the driver counts such "missed" packets, then it does the

job

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the
> application will do anyway (wasting some cycles). > But what is more a problem is that the application does not

know

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

if the
> packets in oerrors are its own retries or problems that the

driver

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

can not
> detect (hw problems) but the hw can.
>
> So the best option is that oerrors does not report the

packets the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

driver
> refuses (and I can see some drivers that do not comply to

this)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

but only
> "external" errors from the driver pov.
I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.
What about splitting the Tx errors in 2 fields? oerrors / ofull

?

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Who said it's awful? sorry Bruce for anticipating ;)

Summary, correct me if we are not aligned :-)
- ofull (maybe ofifoerrors?) is actually a count of SW failed

transmits

Quoted 1 line

- it would be handled in rte_eth_tx_burst() itself in a generic

way

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

- the drivers do not need to track such SW failed transmits
- oerrors only counts packets HW failed transmits, dropped out of

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

driver tx_pkt_burst() knowledge
- the application does not have to track SW failed transmits

since the

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

stats is in ethdev
It sounds good to me, this means an ethdev abi breakage.

Hang on, why do we need ethdev to track this at all, given that it's trivial for apps to track this themselves. Would we not be better just

to

Quoted 1 line
Quoted 1 line

add this tracking into testpmd and leave ethdev and drivers alone?

Perhaps

Quoted 4 lines
Quoted 2 lines

I'm missing something?

This was my first intention but Thomas hopped in ;-)

I was just opening the discussion :)

Quoted 8 lines

testpmd does it already via the fs->fwd_dropped stats and ovs has its tx_dropped stat.

The problem is that all drivers have different approach about this. Some drivers only count real hw errors in oerrors.
But others count the packets it can't send in oerrors (+ there are some cases that seem buggy to me where the driver will always refuse the mbufs for reason X and the application can retry indefinitely to send...).

We have 3 options:
1/ status quo = oerrors is inconsistent across drivers 2/ API break = oerrors stop being incremented for temporary
unavailability (i.e. queue full, kind of ERETRY), report only packets which will be never sent, may be a small performance gain for some drivers
3/ API + ABI break = same as 2/ +
report ERETRY errors in ofull (same as tx_burst() delta)

Quoted 14 lines

Note that the option 2 is a light API break which does not require any deprecation notice because the original definition of oerrors is really vague: "failed transmitted packets"
By changing the definition of errors to "packets lost", we can count HW errors + packets not matching requirements.
As David suggests, the packets not matching requirements can be freed as it is done for packets successfully transmitted to the HW. We need also to update the definition of the return value of rte_eth_tx_burst(): "packets actually stored in transmit descriptors". We should also count the bad packets rejected by the driver. Then the number of bad packets would be the difference between the return value of rte_eth_tx_burst() and opackets counter. This solution is fixing some bugs and enforce a consistent behaviour.

I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Quoted 8 lines

The option 3 is breaking the ABI and may degrade the performances. The only benefit is convenience or semantic: ofull would be the equivalent of imissed.
The application can count the same by making the difference between the burst size and the return of rte_eth_tx_burst.

My vote is for the option 2.

Signature · 1 line
David Marchand
#16 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 117 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of David Marchand
Sent: Friday, February 15, 2019 5:32 PM
To: Thomas Monjalon <[email protected]>
Cc: Richardson, Bruce <[email protected]>; [email protected]; Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; Maxime Coquelin <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Wiles, Keith <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 89 lines · Thomas Monjalon

15/02/2019 16:04, David Marchand:

Quoted 1 line

On Fri, Feb 15, 2019 at 3:05 PM Bruce Richardson <

[email protected]>

Quoted 10 lines
Quoted 8 lines · wrote:
Quoted 7 lines · David Marchand

On Fri, Feb 15, 2019 at 9:58 AM Thomas Monjalon <[1][email protected]> wrote:

14/02/2019 19:51, David Marchand:
> What is the purpose of oerrors ?
>
> Since the drivers (via rte_eth_tx_burst return value) report

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

numbers of
> packets successfully transmitted, the application can try to retransmit the
> packets that did not make it and counts this.
> If the driver counts such "missed" packets, then it does the

job

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the
> application will do anyway (wasting some cycles). > But what is more a problem is that the application does not

know

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

if the
> packets in oerrors are its own retries or problems that the

driver

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

can not
> detect (hw problems) but the hw can.
>
> So the best option is that oerrors does not report the

packets the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

driver
> refuses (and I can see some drivers that do not comply to

this)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

but only
> "external" errors from the driver pov.
I can see the benefit of having driver errors in the stats, so it is generically stored for later analysis or print. It could be managed at ethdev level instead of the application doing the computation.
What about splitting the Tx errors in 2 fields? oerrors / ofull

?

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Who said it's awful? sorry Bruce for anticipating ;)

Summary, correct me if we are not aligned :-)
- ofull (maybe ofifoerrors?) is actually a count of SW failed

transmits

Quoted 1 line

- it would be handled in rte_eth_tx_burst() itself in a generic

way

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

- the drivers do not need to track such SW failed transmits
- oerrors only counts packets HW failed transmits, dropped out of

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

driver tx_pkt_burst() knowledge
- the application does not have to track SW failed transmits

since the

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

stats is in ethdev
It sounds good to me, this means an ethdev abi breakage.

Hang on, why do we need ethdev to track this at all, given that it's trivial for apps to track this themselves. Would we not be better just

to

Quoted 1 line
Quoted 1 line

add this tracking into testpmd and leave ethdev and drivers alone?

Perhaps

Quoted 4 lines
Quoted 2 lines

I'm missing something?

This was my first intention but Thomas hopped in ;-)

I was just opening the discussion :)

Quoted 8 lines

testpmd does it already via the fs->fwd_dropped stats and ovs has its tx_dropped stat.

The problem is that all drivers have different approach about this. Some drivers only count real hw errors in oerrors.
But others count the packets it can't send in oerrors (+ there are some cases that seem buggy to me where the driver will always refuse the mbufs for reason X and the application can retry indefinitely to send...).

We have 3 options:
1/ status quo = oerrors is inconsistent across drivers 2/ API break = oerrors stop being incremented for temporary
unavailability (i.e. queue full, kind of ERETRY), report only packets which will be never sent, may be a small performance gain for some drivers
3/ API + ABI break = same as 2/ +
report ERETRY errors in ofull (same as tx_burst() delta)

Quoted 14 lines

Note that the option 2 is a light API break which does not require any deprecation notice because the original definition of oerrors is really vague: "failed transmitted packets"
By changing the definition of errors to "packets lost", we can count HW errors + packets not matching requirements.
As David suggests, the packets not matching requirements can be freed as it is done for packets successfully transmitted to the HW. We need also to update the definition of the return value of rte_eth_tx_burst(): "packets actually stored in transmit descriptors". We should also count the bad packets rejected by the driver. Then the number of bad packets would be the difference between the return value of rte_eth_tx_burst() and opackets counter. This solution is fixing some bugs and enforce a consistent behaviour.

Quoted 4 lines

I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

Quoted 15 lines
Quoted 10 lines

The option 3 is breaking the ABI and may degrade the performances. The only benefit is convenience or semantic: ofull would be the equivalent of imissed.
The application can count the same by making the difference between the burst size and the return of rte_eth_tx_burst.

My vote is for the option 2.

--
David Marchand

#17 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 10 lines · Konstantin
Quoted 6 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of David Marchand I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

How does the upper layer know if this is a transient state or something that can't be resolved?

Signature · 1 line
David Marchand
#18 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

From: dev [mailto:[email protected]] On Behalf Of David Marchand I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

How does the upper layer know if this is a transient state or something that can't be resolved?

Via rte_errno, for example.

#19 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

15/02/2019 19:42, Ananyev, Konstantin:

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

From: dev [mailto:[email protected]] On Behalf Of David Marchand I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

How does the upper layer know if this is a transient state or something that can't be resolved?

Via rte_errno, for example.

rte_errno is not a result per packet.
I think it is better to "eat" the packet
as it is done for those transmitted to the HW.

#20 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 10 lines · On Fri, 15 Feb 2019 20:38:59 +0100 Thomas Monjalon <[email protected]> wrote:

15/02/2019 19:42, Ananyev, Konstantin:

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

From: dev [mailto:[email protected]] On Behalf Of David Marchand I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

How does the upper layer know if this is a transient state or something that can't be resolved?

Via rte_errno, for example.

rte_errno is not a result per packet.
I think it is better to "eat" the packet
as it is done for those transmitted to the HW.

First off rte_errno doesn't work for a burst API.

IMHO (which matches /2) all drivers should only increment oerrors for something for a packet which it could not transmit because of hardware condition (link down etc) or mbuf which has parameters which can not be handled. In either case, the packet must be dropped by driver and oerrors incremented. The driver should also maintain internal stats (available by xstats) for any conditions like this.

When no tx descriptors are available, the driver must not increment any counter and return partial success to the application. If application then wants to do back pressure or drop it should keep its own statistics.

This is close to the original model in the Intel drivers, and matches what BSD and Linux do on the OS level for drivers. Like many driver assumptions the corner cases were not explicitly documented and new drivers probably don't follow the same pattern.

#21 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Quoted 19 lines
Quoted 14 lines · On Fri, 15 Feb 2019 20:38:59 +0100 Thomas Monjalon <[email protected]> wrote:

15/02/2019 19:42, Ananyev, Konstantin:

Quoted 12 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

From: dev [mailto:[email protected]] On Behalf Of David Marchand I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

How does the upper layer know if this is a transient state or something that can't be resolved?

Via rte_errno, for example.

Quoted 7 lines
Quoted 5 lines

rte_errno is not a result per packet.
I think it is better to "eat" the packet
as it is done for those transmitted to the HW.

First off rte_errno doesn't work for a burst API.

It doesn't allow to return individual error value for each packet. Though if we stop after first error happens - it is sufficient.

Quoted 3 lines

IMHO (which matches /2) all drivers should only increment oerrors for something for a packet which it could not transmit because of hardware condition (link down etc)

It sounds too expensive to check that HW is in healthy state and link is up for every tx_burst operation.

Quoted 1 line

or mbuf which has parameters which can not be handled.

Right now it is responsibility of different function - tx_prepare().

Quoted 2 lines

In either case, the packet
must be dropped by driver and oerrors incremented.

Right now tx_burst() only cares - is there enough free TX descriptors to submit packet or not.

Quoted 1 line

From my perspective - it is better to keep it that way.

If the user would like to drop packets if the link is down,
or if the packet is malformed - there should be no problem to create a wrapper on top of tx_burst() that would do all these extra checking and packet freeing.

Quoted 11 lines

The driver should also maintain
internal stats (available by xstats) for any conditions like this.

When no tx descriptors are available, the driver must not increment any counter and return partial success to the application. If application then wants to do back pressure or drop it should keep its own statistics.

This is close to the original model in the Intel drivers, and matches what BSD and Linux do on the OS level for drivers. Like many driver assumptions the corner cases were not explicitly documented and new drivers probably don't follow the same pattern.

#22 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

In reply to Thomas Monjalon
Quoted 19 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, February 15, 2019 7:39 PM
To: Ananyev, Konstantin <[email protected]>
Cc: David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; Maxime Coquelin <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Wiles, Keith <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 3/5] app/testpmd: add missing transmit errors stats

15/02/2019 19:42, Ananyev, Konstantin:

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

From: dev [mailto:[email protected]] On Behalf Of David Marchand I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives it back to the application is a bad driver.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

How does the upper layer know if this is a transient state or something that can't be resolved?

Via rte_errno, for example.

rte_errno is not a result per packet.

Surely it is not.
But tx_burst() can return after first failure.

Quoted 2 lines

I think it is better to "eat" the packet
as it is done for those transmitted to the HW.

Probably extra clarification is needed here.
Right now tx_burst (at least for PMDs I am aware about) doesn't do any checking that:
- packet is correct and can be handled
(this is responsibility of tx_prepare)
- HW/PMD SW state is in valid and properly configured (link is up, queue is configured, HW initialized properly).

All that really tx_burst() care about -there is enough free TX descriptors to fill. When that happens - tx_burst() returns straightway.

So what particular error conditions are you talking about, and when you think we have to 'eat' the packets? Konstantin

#23 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Hello Konstantin,

Quoted 50 lines · Konstantin
Quoted 7 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, February 15, 2019 7:39 PM
To: Ananyev, Konstantin <[email protected]>
Cc: David Marchand <[email protected]>; Richardson, Bruce <

[email protected]>; [email protected]; Lu, Wenzhuo

Quoted 1 line

<[email protected]>; Wu, Jingjing <[email protected]>;

Iremonger, Bernard <[email protected]>; Maxime Coquelin

Quoted 1 line

<[email protected]>; Yigit, Ferruh <[email protected]>; Andrew

Rybchenko <[email protected]>; Wiles, Keith

Quoted 2 lines

<[email protected]>
Subject: Re: [dpdk-dev] [PATCH 3/5] app/testpmd: add missing transmit

errors stats

Quoted 3 lines

15/02/2019 19:42, Ananyev, Konstantin:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

From: dev [mailto:[email protected]] On Behalf Of David

Marchand

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I am also for option 2 especially because of this. A driver that refuses a packet for reason X (which is a

limitation, or an

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

incorrect config or whatever that is not a transient condition)

but gives

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

it back to the application is a bad driver.

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

How does the upper layer know if this is a transient state or

something that can't be resolved?

Quoted 4 lines
Quoted 2 lines

Via rte_errno, for example.

rte_errno is not a result per packet.

Surely it is not.
But tx_burst() can return after first failure.

Quoted 2 lines

I think it is better to "eat" the packet
as it is done for those transmitted to the HW.

Probably extra clarification is needed here.
Right now tx_burst (at least for PMDs I am aware about) doesn't do any checking that:
- packet is correct and can be handled
(this is responsibility of tx_prepare)
- HW/PMD SW state is in valid and properly configured (link is up, queue is configured, HW initialized properly).

Quoted 7 lines

All that really tx_burst() care about -there is enough free TX descriptors to fill. When that happens - tx_burst() returns straightway.

So what particular error conditions are you talking about, and when you think we have to 'eat' the packets?

- This is how Intel drivers are written yes.
But some drivers try to do more and have (useless ?) checks on mbufs or internal states.

Found the following ones last week.
There are more but it takes time to investigate.
https://git.dpdk.org/dpdk/tree/drivers/net/atlantic/atl_rxtx.c?id=b13baac8d5ffb6b0b7a6ca0def884d3f1a82babb#n1346
https://git.dpdk.org/dpdk/tree/drivers/net/fm10k/fm10k_rxtx.c?id=b13baac8d5ffb6b0b7a6ca0def884d3f1a82babb#n646
https://git.dpdk.org/dpdk/tree/drivers/net/cxgbe/sge.c?id=b13baac8d5ffb6b0b7a6ca0def884d3f1a82babb#n1123

I would say first, we can have a cleanup to get rid of the unneeded checks, and see what the different maintainers think about this.
Then look again at the situation.

- I will drop this patch on testpmd which was wrong.
But I intend to send an update on the doc to describe oerrors as solution 2:
2/ API break = oerrors stop being incremented for temporary
unavailability (i.e. queue full, kind of ERETRY),
report only packets which will be never sent,
may be a small performance gain for some drivers

There is some cleanup to do as well in quite a few drivers.

Signature · 1 line
David Marchand
#24 lore raw

Re: [PATCH 3/5] app/testpmd: add missing transmit errors stats

Hi David,

Hello Konstantin,

Quoted 17 lines · On Sat, Feb 16, 2019 at 1:50 PM Ananyev, Konstantin…

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]<mailto:[email protected]>]
Sent: Friday, February 15, 2019 7:39 PM
To: Ananyev, Konstantin <[email protected]<mailto:[email protected]>>
Cc: David Marchand <[email protected]<mailto:[email protected]>>; Richardson, Bruce <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>; Lu, Wenzhuo <[email protected]<mailto:[email protected]>>; Wu, Jingjing <[email protected]<mailto:[email protected]>>; Iremonger, Bernard <[email protected]<mailto:[email protected]>>; Maxime Coquelin <[email protected]<mailto:[email protected]>>; Yigit, Ferruh <[email protected]<mailto:[email protected]>>; Andrew Rybchenko <[email protected]<mailto:[email protected]>>; Wiles, Keith <[email protected]<mailto:[email protected]>>
Subject: Re: [dpdk-dev] [PATCH 3/5] app/testpmd: add missing transmit errors stats

15/02/2019 19:42, Ananyev, Konstantin:

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

From: dev [mailto:[email protected]<mailto:[email protected]>] On Behalf Of David Marchand I am also for option 2 especially because of this.
A driver that refuses a packet for reason X (which is a limitation, or an incorrect config or whatever that is not a transient condition) but gives
it back to the application is a bad driver.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Why? What.s wrong to leave it to the upper layer to decide what to do with the packets that can't be sent (by one reason or another)?

How does the upper layer know if this is a transient state or something that can't be resolved?

Via rte_errno, for example.

rte_errno is not a result per packet.

Surely it is not.
But tx_burst() can return after first failure.

Quoted 2 lines

I think it is better to "eat" the packet
as it is done for those transmitted to the HW.

Probably extra clarification is needed here.
Right now tx_burst (at least for PMDs I am aware about) doesn't do any checking that:
- packet is correct and can be handled
(this is responsibility of tx_prepare)
- HW/PMD SW state is in valid and properly configured (link is up, queue is configured, HW initialized properly).

All that really tx_burst() care about -there is enough free TX descriptors to fill. When that happens - tx_burst() returns straightway.

So what particular error conditions are you talking about, and when you think we have to 'eat' the packets?

- This is how Intel drivers are written yes.
But some drivers try to do more and have (useless ?) checks on mbufs or internal states.

Found the following ones last week.
There are more but it takes time to investigate.
https://git.dpdk.org/dpdk/tree/drivers/net/atlantic/atl_rxtx.c?id=b13baac8d5ffb6b0b7a6ca0def884d3f1a82babb#n1346
https://git.dpdk.org/dpdk/tree/drivers/net/fm10k/fm10k_rxtx.c?id=b13baac8d5ffb6b0b7a6ca0def884d3f1a82babb#n646
https://git.dpdk.org/dpdk/tree/drivers/net/cxgbe/sge.c?id=b13baac8d5ffb6b0b7a6ca0def884d3f1a82babb#n1123

I would say first, we can have a cleanup to get rid of the unneeded checks, and see what the different maintainers think about this. Then look again at the situation.

- I will drop this patch on testpmd which was wrong.
But I intend to send an update on the doc to describe oerrors as solution 2:
2/ API break = oerrors stop being incremented for temporary
unavailability (i.e. queue full, kind of ERETRY),
report only packets which will be never sent,
may be a small performance gain for some drivers

There is some cleanup to do as well in quite a few drivers.

I didn’t look at all your links above, but fm10k checks definitely seems redundant. Cleanup of such things sounds like a good thing.
Thanks
Konstantin

#25 lore raw

PATCH 4/5 app/testpmd: remove useless casts on statistics

In reply to David Marchand

Caught by code review while investigating the stats display code. Switching all port and fwd engine statistics to uint64_t makes it possible to drop all casts.

---
 app/test-pmd/testpmd.c | 62 ++++++++++++++++++--------------------------------
 app/test-pmd/testpmd.h | 12 +++++-----
 2 files changed, 28 insertions(+), 46 deletions(-)
app/test-pmd/testpmd.c +22 -40
index 3acd97b..ab110b0 100644
@@ -1376,7 +1376,7 @@ struct extmem_param {
 		printf("  RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: "
 		       "%-"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64"Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1390,13 +1390,13 @@ struct extmem_param {
 		printf("  TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: "
 		       "%-"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 	else {
 		printf("  RX-packets:             %14"PRIu64"    RX-dropped:%14"PRIu64"    RX-total:"
 		       "%14"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum:%14"PRIu64"    Bad-l4csum:%14"PRIu64"    Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1411,7 +1411,7 @@ struct extmem_param {
 		printf("  TX-packets:             %14"PRIu64"    TX-dropped:%14"PRIu64"    TX-total:"
 		       "%14"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
@@ -1459,13 +1459,15 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
+	printf("  RX-packets: %-14"PRIu64" TX-packets: %-14"PRIu64
+	       " TX-dropped: %-14"PRIu64"\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
 	if (cur_fwd_eng == &csum_fwd_engine) {
-	       printf("  RX- bad IP checksum: %-14u  Rx- bad L4 checksum: "
-			"%-14u Rx- bad outer L4 checksum: %-14u\n",
+		printf("  RX- bad IP checksum: %-14"PRIu64
+		       "  Rx- bad L4 checksum: %-14"PRIu64
+		       " Rx- bad outer L4 checksum: %-14"PRIu64"\n",
 			fs->rx_bad_ip_csum, fs->rx_bad_l4_csum,
 			fs->rx_bad_outer_l4_csum);
 	}
@@ -1743,9 +1745,6 @@ struct extmem_param {
 	uint64_t total_rx_dropped;
 	uint64_t total_tx_dropped;
 	uint64_t total_rx_nombuf;
-	uint64_t tx_dropped;
-	uint64_t rx_bad_ip_csum;
-	uint64_t rx_bad_l4_csum;
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t fwd_cycles;
 #endif
@@ -1772,42 +1771,25 @@ struct extmem_param {
 	fwd_cycles = 0;
 #endif
 	for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
+		struct fwd_stream *fs = fwd_streams[sm_id];
+
 		if (cur_fwd_config.nb_fwd_streams >
 		    cur_fwd_config.nb_fwd_ports) {
 			fwd_stream_stats_display(sm_id);
-			ports[fwd_streams[sm_id]->tx_port].tx_stream = NULL;
-			ports[fwd_streams[sm_id]->rx_port].rx_stream = NULL;
+			ports[fs->tx_port].tx_stream = NULL;
+			ports[fs->rx_port].rx_stream = NULL;
 		} else {
-			ports[fwd_streams[sm_id]->tx_port].tx_stream =
-				fwd_streams[sm_id];
-			ports[fwd_streams[sm_id]->rx_port].rx_stream =
-				fwd_streams[sm_id];
-		}
-		tx_dropped = ports[fwd_streams[sm_id]->tx_port].tx_dropped;
-		tx_dropped = (uint64_t) (tx_dropped +
-					 fwd_streams[sm_id]->fwd_dropped);
-		ports[fwd_streams[sm_id]->tx_port].tx_dropped = tx_dropped;
-
-		rx_bad_ip_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum;
-		rx_bad_ip_csum = (uint64_t) (rx_bad_ip_csum +
-					 fwd_streams[sm_id]->rx_bad_ip_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum =
-							rx_bad_ip_csum;
-
-		rx_bad_l4_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum;
-		rx_bad_l4_csum = (uint64_t) (rx_bad_l4_csum +
-					 fwd_streams[sm_id]->rx_bad_l4_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum =
-							rx_bad_l4_csum;
-
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_outer_l4_csum +=
-				fwd_streams[sm_id]->rx_bad_outer_l4_csum;
+			ports[fs->tx_port].tx_stream = fs;
+			ports[fs->rx_port].rx_stream = fs;
+		}
+		ports[fs->tx_port].tx_dropped += fs->fwd_dropped;
+		ports[fs->rx_port].rx_bad_ip_csum += fs->rx_bad_ip_csum;
+		ports[fs->rx_port].rx_bad_l4_csum += fs->rx_bad_l4_csum;
+		ports[fs->rx_port].rx_bad_outer_l4_csum +=
+				fs->rx_bad_outer_l4_csum;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
-		fwd_cycles = (uint64_t) (fwd_cycles +
-					 fwd_streams[sm_id]->core_cycles);
+		fwd_cycles += fs->core_cycles;
 #endif
 	}
 	total_recv = 0;
app/test-pmd/testpmd.h +6 -6
index 85b791b..4f4a48f 100644
@@ -119,12 +119,12 @@ struct fwd_stream {
 	unsigned int retry_enabled;
 
 	/* "read-write" results */
-	unsigned int rx_packets;  /**< received packets */
-	unsigned int tx_packets;  /**< received packets transmitted */
-	unsigned int fwd_dropped; /**< received packets not forwarded */
-	unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */
-	unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
-	unsigned int rx_bad_outer_l4_csum;
+	uint64_t rx_packets;  /**< received packets */
+	uint64_t tx_packets;  /**< received packets transmitted */
+	uint64_t fwd_dropped; /**< received packets not forwarded */
+	uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
+	uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
+	uint64_t rx_bad_outer_l4_csum;
 	/**< received packets has bad outer l4 checksum */
 	unsigned int gro_times;	/**< GRO operation times */
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH 5/5 app/testpmd: display/clear forwarding stats on demand

In reply to David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, rte_port can't be used to maintain any statistics. Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

---
 app/test-pmd/cmdline.c                      |  44 +++
 app/test-pmd/testpmd.c                      | 426 +++++++++++++++-------------
 app/test-pmd/testpmd.h                      |   9 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 306 insertions(+), 209 deletions(-)
app/test-pmd/cmdline.c +44 -0
index db53cc0..58b11b7 100644
@@ -7386,6 +7386,49 @@ struct cmd_showqueue_result {
 	},
 };
 
+/* show/clear fwd engine statistics */
+struct fwd_result {
+	cmdline_fixed_string_t action;
+	cmdline_fixed_string_t fwd;
+	cmdline_fixed_string_t stats;
+	cmdline_fixed_string_t all;
+};
+
+cmdline_parse_token_string_t cmd_fwd_action =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
+cmdline_parse_token_string_t cmd_fwd_fwd =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
+cmdline_parse_token_string_t cmd_fwd_stats =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
+cmdline_parse_token_string_t cmd_fwd_all =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
+
+static void
+cmd_fwd_parsed(void *parsed_result,
+	       __rte_unused struct cmdline *cl,
+	       __rte_unused void *data)
+{
+	struct fwd_result *res = parsed_result;
+
+	if (!strcmp(res->action, "show"))
+		fwd_stats_display();
+	else
+		fwd_stats_reset();
+}
+
+static cmdline_parse_inst_t cmd_fwdall = {
+	.f = cmd_fwd_parsed,
+	.data = NULL,
+	.help_str = "show|clear fwd stats all",
+	.tokens = {
+		(void *)&cmd_fwd_action,
+		(void *)&cmd_fwd_fwd,
+		(void *)&cmd_fwd_stats,
+		(void *)&cmd_fwd_all,
+		NULL,
+	},
+};
+
 /* *** READ PORT REGISTER *** */
 struct cmd_read_reg_result {
 	cmdline_fixed_string_t read;
@@ -18559,6 +18602,7 @@ struct cmd_show_tx_metadata_result {
 	(cmdline_parse_inst_t *)&cmd_showqueue,
 	(cmdline_parse_inst_t *)&cmd_showportall,
 	(cmdline_parse_inst_t *)&cmd_showcfg,
+	(cmdline_parse_inst_t *)&cmd_fwdall,
 	(cmdline_parse_inst_t *)&cmd_start,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
app/test-pmd/testpmd.c +224 -202

470 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -7
index 4f4a48f..f43b1a7 100644
@@ -164,19 +164,12 @@ struct rte_port {
 	struct rte_eth_conf     dev_conf;   /**< Port configuration. */
 	struct ether_addr       eth_addr;   /**< Port ethernet address */
 	struct rte_eth_stats    stats;      /**< Last port statistics */
-	uint64_t                tx_dropped; /**< If no descriptor in TX ring */
-	struct fwd_stream       *rx_stream; /**< Port RX stream, if unique */
-	struct fwd_stream       *tx_stream; /**< Port TX stream, if unique */
 	unsigned int            socket_id;  /**< For NUMA support */
 	uint16_t		parse_tunnel:1; /**< Parse internal headers */
 	uint16_t                tso_segsz;  /**< Segmentation offload MSS for non-tunneled packets. */
 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
 	uint16_t                tx_vlan_id;/**< The tag ID */
 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-	uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
-	uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
-	uint64_t                rx_bad_outer_l4_csum;
-	/**< rx pkts with bad outer l4 checksum */
 	uint8_t                 tx_queue_stats_mapping_enabled;
 	uint8_t                 rx_queue_stats_mapping_enabled;
 	volatile uint16_t        port_status;    /**< port started or not */
@@ -767,6 +760,8 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 char *list_pkt_forwarding_retry_modes(void);
 void set_pkt_forwarding_mode(const char *fwd_mode);
 void start_packet_forwarding(int with_tx_first);
+void fwd_stats_display(void);
+void fwd_stats_reset(void);
 void stop_packet_forwarding(void);
 void dev_set_link_up(portid_t pid);
 void dev_set_link_down(portid_t pid);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +36 -0
index 0291480..a20c2c9 100644
@@ -336,6 +336,42 @@ Example::
    Set rxonly packet forwarding mode
 
 
+show fwd
+~~~~~~~~
+
+When running, forwarding engines maintain statistics from the time they have been started.
+Example for the io forwarding engine, with some packet drops on the tx side::
+
+   testpmd> show fwd stats all
+
+     ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
+     RX-packets: 274293770      TX-packets: 274293642      TX-dropped: 128
+
+     ------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
+     RX-packets: 274301850      TX-packets: 274301850      TX-dropped: 0
+
+     ---------------------- Forward statistics for port 0  ----------------------
+     RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
+     TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862
+     ----------------------------------------------------------------------------
+
+     ---------------------- Forward statistics for port 1  ----------------------
+     RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
+     TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834
+     ----------------------------------------------------------------------------
+
+     +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
+     RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
+     TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696
+     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+clear fwd
+~~~~~~~~~
+
+Clear the forwarding engines statistics::
+
+   testpmd> clear fwd stats all
+
 read rxd
 ~~~~~~~~
 
Signature · 1 line
1.8.3.1
#27 lore raw

v2 cover display testpmd forwarding engine stats on the fly

In reply to David Marchand

Here is a little series that makes it possible to display and clear testpmd fwd engines while they run without having to stop them. This is mostly handy when running stress tests and you look for packets drops without having to stop/start testpmd forwarding.

Example:

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 261977064 TX-packets: 261977064 TX-dropped: 0

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 261985142 TX-packets: 261985142 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 261977096      RX-dropped: 0             RX-total: 261977096
  TX-packets: 261985155      TX-dropped: 0             TX-total: 261985155

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 261985188      RX-dropped: 0             RX-total: 261985188
  TX-packets: 261977128      TX-dropped: 0             TX-total: 261977128

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 523962284      RX-dropped: 0             RX-total: 523962284
  TX-packets: 523962283      TX-dropped: 0             TX-total: 523962283

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 274293770 TX-packets: 274293642 TX-dropped: 128

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 274301850 TX-packets: 274301850 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
  TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
  TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
  TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Signature · 22 lines
David Marchand

---
Changelog since v1:
- Cc: stable for patch 1
- removed buggy patch 3

---
David Marchand (4):
  app/testpmd: remove unused fwd_ctx field
  app/testpmd: add missing newline when showing statistics
  app/testpmd: remove useless casts on statistics
  app/testpmd: display/clear forwarding stats on demand

 app/test-pmd/cmdline.c                      |  44 +++
 app/test-pmd/testpmd.c                      | 450 ++++++++++++++--------------
 app/test-pmd/testpmd.h                      |  22 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 315 insertions(+), 237 deletions(-)

-- 
1.8.3.1
#28 lore raw

PATCH v2 1/4 app/testpmd: remove unused fwd_ctx field

Remove some leftover from a previous rework.

Fixes c4bcc342c8ee ("app/testpmd: refactor ieee1588 forwarding")

---
Changelog since v1:
- added Cc: stable

---
 app/test-pmd/testpmd.h | 1 -
 1 file changed, 1 deletion(-)
app/test-pmd/testpmd.h +0 -1
index fa48878..85b791b 100644
@@ -173,7 +173,6 @@ struct rte_port {
 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
 	uint16_t                tx_vlan_id;/**< The tag ID */
 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-	void                    *fwd_ctx;   /**< Forwarding mode context */
 	uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
 	uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
 	uint64_t                rx_bad_outer_l4_csum;
Signature · 1 line
1.8.3.1
Applied
#29 lore raw

Re: [dpdk-stable] [PATCH v2 1/4] app/testpmd: remove unused fwd_ctx field

Quoted 7 lines · David Marchand

Remove some leftover from a previous rework.

Fixes c4bcc342c8ee ("app/testpmd: refactor ieee1588 forwarding")

This patch looks independent from rest the patchset, and simple enough, so merging it individually.

Applied to dpdk-next-net/master, thanks.

#30 lore raw

PATCH v2 2/4 app/testpmd: add missing newline when showing statistics

In reply to David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:
RX-packets: 3542977 TX-packets: 3542971 TX-dropped: 6 RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:
RX-packets: 4629969 TX-packets: 4629969 TX-dropped: 0
RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others] TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]

---
 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +1 -1
index 98c1baa..984155a 100644
@@ -1459,7 +1459,7 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
Signature · 1 line
1.8.3.1
#31 lore raw

Re: [PATCH v2 2/4] app/testpmd: add missing newline when showing statistics

Quoted 23 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:

   RX-packets: 3542977        TX-packets: 3542971        TX-dropped: 6               RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
   TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:

   RX-packets: 4629969        TX-packets: 4629969        TX-dropped: 0
   RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
   TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
---
  app/test-pmd/testpmd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +0 -0
index 98c1baa..984155a 100644

app/test-pmd/testpmd.c struct extmem_param { · line 1465

Quoted 8 lines
app/test-pmd/testpmd.c +1 -1
@@ -1459,7 +1459,7 @@ struct extmem_param {
  	       "TX Port=%2d/Queue=%2d %s\n",
  	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
  	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
  	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
  	/* if checksum mode */

I'd suggest to add Fixes tag since it looks like a bug Rx burst stats should be printed on its own line regardless Rx checksum stats printed or skipped.

Fixes af75078fece3 ("first public release")

Andrew.

#32 lore raw

PATCH v2 3/4 app/testpmd: remove useless casts on statistics

In reply to David Marchand

Caught by code review while investigating the stats display code. Switching all port and fwd engine statistics to uint64_t makes it possible to drop all casts.

---
 app/test-pmd/testpmd.c | 62 ++++++++++++++++++--------------------------------
 app/test-pmd/testpmd.h | 12 +++++-----
 2 files changed, 28 insertions(+), 46 deletions(-)
app/test-pmd/testpmd.c +22 -40
index 984155a..3651a13 100644
@@ -1376,7 +1376,7 @@ struct extmem_param {
 		printf("  RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: "
 		       "%-"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64"Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1390,13 +1390,13 @@ struct extmem_param {
 		printf("  TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: "
 		       "%-"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 	else {
 		printf("  RX-packets:             %14"PRIu64"    RX-dropped:%14"PRIu64"    RX-total:"
 		       "%14"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum:%14"PRIu64"    Bad-l4csum:%14"PRIu64"    Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1411,7 +1411,7 @@ struct extmem_param {
 		printf("  TX-packets:             %14"PRIu64"    TX-dropped:%14"PRIu64"    TX-total:"
 		       "%14"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
@@ -1459,13 +1459,15 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
+	printf("  RX-packets: %-14"PRIu64" TX-packets: %-14"PRIu64
+	       " TX-dropped: %-14"PRIu64"\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
 	if (cur_fwd_eng == &csum_fwd_engine) {
-	       printf("  RX- bad IP checksum: %-14u  Rx- bad L4 checksum: "
-			"%-14u Rx- bad outer L4 checksum: %-14u\n",
+		printf("  RX- bad IP checksum: %-14"PRIu64
+		       "  Rx- bad L4 checksum: %-14"PRIu64
+		       " Rx- bad outer L4 checksum: %-14"PRIu64"\n",
 			fs->rx_bad_ip_csum, fs->rx_bad_l4_csum,
 			fs->rx_bad_outer_l4_csum);
 	}
@@ -1743,9 +1745,6 @@ struct extmem_param {
 	uint64_t total_rx_dropped;
 	uint64_t total_tx_dropped;
 	uint64_t total_rx_nombuf;
-	uint64_t tx_dropped;
-	uint64_t rx_bad_ip_csum;
-	uint64_t rx_bad_l4_csum;
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t fwd_cycles;
 #endif
@@ -1772,42 +1771,25 @@ struct extmem_param {
 	fwd_cycles = 0;
 #endif
 	for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
+		struct fwd_stream *fs = fwd_streams[sm_id];
+
 		if (cur_fwd_config.nb_fwd_streams >
 		    cur_fwd_config.nb_fwd_ports) {
 			fwd_stream_stats_display(sm_id);
-			ports[fwd_streams[sm_id]->tx_port].tx_stream = NULL;
-			ports[fwd_streams[sm_id]->rx_port].rx_stream = NULL;
+			ports[fs->tx_port].tx_stream = NULL;
+			ports[fs->rx_port].rx_stream = NULL;
 		} else {
-			ports[fwd_streams[sm_id]->tx_port].tx_stream =
-				fwd_streams[sm_id];
-			ports[fwd_streams[sm_id]->rx_port].rx_stream =
-				fwd_streams[sm_id];
-		}
-		tx_dropped = ports[fwd_streams[sm_id]->tx_port].tx_dropped;
-		tx_dropped = (uint64_t) (tx_dropped +
-					 fwd_streams[sm_id]->fwd_dropped);
-		ports[fwd_streams[sm_id]->tx_port].tx_dropped = tx_dropped;
-
-		rx_bad_ip_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum;
-		rx_bad_ip_csum = (uint64_t) (rx_bad_ip_csum +
-					 fwd_streams[sm_id]->rx_bad_ip_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum =
-							rx_bad_ip_csum;
-
-		rx_bad_l4_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum;
-		rx_bad_l4_csum = (uint64_t) (rx_bad_l4_csum +
-					 fwd_streams[sm_id]->rx_bad_l4_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum =
-							rx_bad_l4_csum;
-
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_outer_l4_csum +=
-				fwd_streams[sm_id]->rx_bad_outer_l4_csum;
+			ports[fs->tx_port].tx_stream = fs;
+			ports[fs->rx_port].rx_stream = fs;
+		}
+		ports[fs->tx_port].tx_dropped += fs->fwd_dropped;
+		ports[fs->rx_port].rx_bad_ip_csum += fs->rx_bad_ip_csum;
+		ports[fs->rx_port].rx_bad_l4_csum += fs->rx_bad_l4_csum;
+		ports[fs->rx_port].rx_bad_outer_l4_csum +=
+				fs->rx_bad_outer_l4_csum;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
-		fwd_cycles = (uint64_t) (fwd_cycles +
-					 fwd_streams[sm_id]->core_cycles);
+		fwd_cycles += fs->core_cycles;
 #endif
 	}
 	total_recv = 0;
app/test-pmd/testpmd.h +6 -6
index 85b791b..4f4a48f 100644
@@ -119,12 +119,12 @@ struct fwd_stream {
 	unsigned int retry_enabled;
 
 	/* "read-write" results */
-	unsigned int rx_packets;  /**< received packets */
-	unsigned int tx_packets;  /**< received packets transmitted */
-	unsigned int fwd_dropped; /**< received packets not forwarded */
-	unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */
-	unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
-	unsigned int rx_bad_outer_l4_csum;
+	uint64_t rx_packets;  /**< received packets */
+	uint64_t tx_packets;  /**< received packets transmitted */
+	uint64_t fwd_dropped; /**< received packets not forwarded */
+	uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
+	uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
+	uint64_t rx_bad_outer_l4_csum;
 	/**< received packets has bad outer l4 checksum */
 	unsigned int gro_times;	/**< GRO operation times */
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
Signature · 1 line
1.8.3.1
#33 lore raw

Re: [PATCH v2 3/4] app/testpmd: remove useless casts on statistics

Quoted 5 lines · David Marchand

Caught by code review while investigating the stats display code. Switching all port and fwd engine statistics to uint64_t makes it possible to drop all casts.

Patch summary is misleading here. The main change here is changing of counters bitwidth. 32-bit counters overflow pretty fast on 100G, so it is a good idea to fix it.

Andrew.

#34 lore raw

Re: [PATCH v2 3/4] app/testpmd: remove useless casts on statistics

Quoted 6 lines · Andrew Rybchenko

On 3/11/19 6:35 PM, David Marchand wrote:

Caught by code review while investigating the stats display code. Switching all port and fwd engine statistics to uint64_t makes it possible to drop all casts.

Quoted 8 lines

Patch summary is misleading here. The main change here is changing of counters bitwidth. 32-bit counters overflow pretty fast on 100G, so it is a good idea to fix it.

Oops, I was so focused on the casts and had in mind "unsigned int" was 64 bits wide...
Will reword and this will deserve a Fixes: tag.

Thanks for catching.

Signature · 1 line
David Marchand
#35 lore raw

PATCH v2 4/4 app/testpmd: display/clear forwarding stats on demand

In reply to David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, rte_port can't be used to maintain any statistics. Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

---
Changelog since v1:
- removed hunk from now deleted patch 3

---
 app/test-pmd/cmdline.c                      |  44 +++
 app/test-pmd/testpmd.c                      | 424 +++++++++++++++-------------
 app/test-pmd/testpmd.h                      |   9 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 305 insertions(+), 208 deletions(-)
app/test-pmd/cmdline.c +44 -0
index db53cc0..58b11b7 100644
@@ -7386,6 +7386,49 @@ struct cmd_showqueue_result {
 	},
 };
 
+/* show/clear fwd engine statistics */
+struct fwd_result {
+	cmdline_fixed_string_t action;
+	cmdline_fixed_string_t fwd;
+	cmdline_fixed_string_t stats;
+	cmdline_fixed_string_t all;
+};
+
+cmdline_parse_token_string_t cmd_fwd_action =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
+cmdline_parse_token_string_t cmd_fwd_fwd =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
+cmdline_parse_token_string_t cmd_fwd_stats =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
+cmdline_parse_token_string_t cmd_fwd_all =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
+
+static void
+cmd_fwd_parsed(void *parsed_result,
+	       __rte_unused struct cmdline *cl,
+	       __rte_unused void *data)
+{
+	struct fwd_result *res = parsed_result;
+
+	if (!strcmp(res->action, "show"))
+		fwd_stats_display();
+	else
+		fwd_stats_reset();
+}
+
+static cmdline_parse_inst_t cmd_fwdall = {
+	.f = cmd_fwd_parsed,
+	.data = NULL,
+	.help_str = "show|clear fwd stats all",
+	.tokens = {
+		(void *)&cmd_fwd_action,
+		(void *)&cmd_fwd_fwd,
+		(void *)&cmd_fwd_stats,
+		(void *)&cmd_fwd_all,
+		NULL,
+	},
+};
+
 /* *** READ PORT REGISTER *** */
 struct cmd_read_reg_result {
 	cmdline_fixed_string_t read;
@@ -18559,6 +18602,7 @@ struct cmd_show_tx_metadata_result {
 	(cmdline_parse_inst_t *)&cmd_showqueue,
 	(cmdline_parse_inst_t *)&cmd_showportall,
 	(cmdline_parse_inst_t *)&cmd_showcfg,
+	(cmdline_parse_inst_t *)&cmd_fwdall,
 	(cmdline_parse_inst_t *)&cmd_start,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
app/test-pmd/testpmd.c +223 -201

468 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -7
index 4f4a48f..f43b1a7 100644
@@ -164,19 +164,12 @@ struct rte_port {
 	struct rte_eth_conf     dev_conf;   /**< Port configuration. */
 	struct ether_addr       eth_addr;   /**< Port ethernet address */
 	struct rte_eth_stats    stats;      /**< Last port statistics */
-	uint64_t                tx_dropped; /**< If no descriptor in TX ring */
-	struct fwd_stream       *rx_stream; /**< Port RX stream, if unique */
-	struct fwd_stream       *tx_stream; /**< Port TX stream, if unique */
 	unsigned int            socket_id;  /**< For NUMA support */
 	uint16_t		parse_tunnel:1; /**< Parse internal headers */
 	uint16_t                tso_segsz;  /**< Segmentation offload MSS for non-tunneled packets. */
 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
 	uint16_t                tx_vlan_id;/**< The tag ID */
 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-	uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
-	uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
-	uint64_t                rx_bad_outer_l4_csum;
-	/**< rx pkts with bad outer l4 checksum */
 	uint8_t                 tx_queue_stats_mapping_enabled;
 	uint8_t                 rx_queue_stats_mapping_enabled;
 	volatile uint16_t        port_status;    /**< port started or not */
@@ -767,6 +760,8 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 char *list_pkt_forwarding_retry_modes(void);
 void set_pkt_forwarding_mode(const char *fwd_mode);
 void start_packet_forwarding(int with_tx_first);
+void fwd_stats_display(void);
+void fwd_stats_reset(void);
 void stop_packet_forwarding(void);
 void dev_set_link_up(portid_t pid);
 void dev_set_link_down(portid_t pid);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +36 -0
index 1a12da4..06c8b2a 100644
@@ -336,6 +336,42 @@ Example::
    Set rxonly packet forwarding mode
 
 
+show fwd
+~~~~~~~~
+
+When running, forwarding engines maintain statistics from the time they have been started.
+Example for the io forwarding engine, with some packet drops on the tx side::
+
+   testpmd> show fwd stats all
+
+     ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
+     RX-packets: 274293770      TX-packets: 274293642      TX-dropped: 128
+
+     ------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
+     RX-packets: 274301850      TX-packets: 274301850      TX-dropped: 0
+
+     ---------------------- Forward statistics for port 0  ----------------------
+     RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
+     TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862
+     ----------------------------------------------------------------------------
+
+     ---------------------- Forward statistics for port 1  ----------------------
+     RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
+     TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834
+     ----------------------------------------------------------------------------
+
+     +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
+     RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
+     TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696
+     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+clear fwd
+~~~~~~~~~
+
+Clear the forwarding engines statistics::
+
+   testpmd> clear fwd stats all
+
 read rxd
 ~~~~~~~~
 
Signature · 1 line
1.8.3.1
#36 lore raw

v3 cover display testpmd forwarding engine stats on the fly

In reply to David Marchand

Here is a little series that makes it possible to display and clear testpmd fwd engines while they run without having to stop them. This is mostly handy when running stress tests and you look for packets drops without having to stop/start testpmd forwarding.

Example:

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 261977064 TX-packets: 261977064 TX-dropped: 0

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 261985142 TX-packets: 261985142 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 261977096      RX-dropped: 0             RX-total: 261977096
  TX-packets: 261985155      TX-dropped: 0             TX-total: 261985155

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 261985188      RX-dropped: 0             RX-total: 261985188
  TX-packets: 261977128      TX-dropped: 0             TX-total: 261977128

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 523962284      RX-dropped: 0             RX-total: 523962284
  TX-packets: 523962283      TX-dropped: 0             TX-total: 523962283

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 274293770 TX-packets: 274293642 TX-dropped: 128

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 274301850 TX-packets: 274301850 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
  TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
  TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
  TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Signature · 27 lines
David Marchand

---
Changelog since v2:
- first patch has been merged in net-next, removed from the series
- split patch (numbered 3 in v2) in two following Andrew comment

Changelog since v1:
- Cc: stable for patch 1
- removed buggy patch 3

---

David Marchand (4):
  app/testpmd: add missing newline when showing statistics
  app/testpmd: extend fwd statistics to 64bits
  app/testpmd: remove useless casts on statistics
  app/testpmd: display/clear forwarding stats on demand

 app/test-pmd/cmdline.c                      |  44 +++
 app/test-pmd/testpmd.c                      | 450 ++++++++++++++--------------
 app/test-pmd/testpmd.h                      |  21 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 315 insertions(+), 236 deletions(-)

-- 
1.8.3.1
#37 lore raw

PATCH v3 1/4 app/testpmd: add missing newline when showing statistics

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:
RX-packets: 3542977 TX-packets: 3542971 TX-dropped: 6 RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:
RX-packets: 4629969 TX-packets: 4629969 TX-dropped: 0
RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others] TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- Cc'd stable

---
 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +1 -1
index d9d0c16..78206f6 100644
@@ -1459,7 +1459,7 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
Signature · 1 line
1.8.3.1
Reviewed-by on v3 1/4
#38 lore raw

Re: [PATCH v3 1/4] app/testpmd: add missing newline when showing statistics

Quoted 12 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:

   RX-packets: 3542977        TX-packets: 3542971        TX-dropped: 6               RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
   TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:

   RX-packets: 4629969        TX-packets: 4629969        TX-dropped: 0
   RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
   TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
Quoted 5 lines
Fixes af75078fece3 ("first public release")
#39 lore raw

PATCH v3 2/4 app/testpmd: extend fwd statistics to 64bits

In reply to David Marchand

fwd engine statistics are stored as unsigned int (32bits) and can wrap quite quickly.
Example: sending 7mpps for 614s gives us 4298000000 packets => 0x1002e4680 larger than 32bits.

testpmd reports forwarding stats as:
RX-packets: 3500381 TX-packets: 3500010 TX-dropped: 371

While the port and accumulated stats are reported as 64bits:
RX-packets: 4298467677 RX-dropped: 0 RX-total: 4298467677
TX-packets: 4298467306 TX-dropped: 371 TX-total: 4298467677

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- split out of the previous patch with a dedicated commitlog
- Cc'd stable

---
 app/test-pmd/testpmd.c | 51 +++++++++++++++++---------------------------------
 app/test-pmd/testpmd.h | 12 ++++++------
 2 files changed, 23 insertions(+), 40 deletions(-)
app/test-pmd/testpmd.c +17 -34
index 78206f6..af9a765 100644
@@ -1459,13 +1459,15 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
+	printf("  RX-packets: %-14"PRIu64" TX-packets: %-14"PRIu64
+	       " TX-dropped: %-14"PRIu64"\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
 	if (cur_fwd_eng == &csum_fwd_engine) {
-	       printf("  RX- bad IP checksum: %-14u  Rx- bad L4 checksum: "
-			"%-14u Rx- bad outer L4 checksum: %-14u\n",
+		printf("  RX- bad IP checksum: %-14"PRIu64
+		       "  Rx- bad L4 checksum: %-14"PRIu64
+		       " Rx- bad outer L4 checksum: %-14"PRIu64"\n",
 			fs->rx_bad_ip_csum, fs->rx_bad_l4_csum,
 			fs->rx_bad_outer_l4_csum);
 	}
@@ -1743,9 +1745,6 @@ struct extmem_param {
 	uint64_t total_rx_dropped;
 	uint64_t total_tx_dropped;
 	uint64_t total_rx_nombuf;
-	uint64_t tx_dropped;
-	uint64_t rx_bad_ip_csum;
-	uint64_t rx_bad_l4_csum;
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t fwd_cycles;
 #endif
@@ -1772,38 +1771,22 @@ struct extmem_param {
 	fwd_cycles = 0;
 #endif
 	for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
+		struct fwd_stream *fs = fwd_streams[sm_id];
+
 		if (cur_fwd_config.nb_fwd_streams >
 		    cur_fwd_config.nb_fwd_ports) {
 			fwd_stream_stats_display(sm_id);
-			ports[fwd_streams[sm_id]->tx_port].tx_stream = NULL;
-			ports[fwd_streams[sm_id]->rx_port].rx_stream = NULL;
+			ports[fs->tx_port].tx_stream = NULL;
+			ports[fs->rx_port].rx_stream = NULL;
 		} else {
-			ports[fwd_streams[sm_id]->tx_port].tx_stream =
-				fwd_streams[sm_id];
-			ports[fwd_streams[sm_id]->rx_port].rx_stream =
-				fwd_streams[sm_id];
-		}
-		tx_dropped = ports[fwd_streams[sm_id]->tx_port].tx_dropped;
-		tx_dropped = (uint64_t) (tx_dropped +
-					 fwd_streams[sm_id]->fwd_dropped);
-		ports[fwd_streams[sm_id]->tx_port].tx_dropped = tx_dropped;
-
-		rx_bad_ip_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum;
-		rx_bad_ip_csum = (uint64_t) (rx_bad_ip_csum +
-					 fwd_streams[sm_id]->rx_bad_ip_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum =
-							rx_bad_ip_csum;
-
-		rx_bad_l4_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum;
-		rx_bad_l4_csum = (uint64_t) (rx_bad_l4_csum +
-					 fwd_streams[sm_id]->rx_bad_l4_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum =
-							rx_bad_l4_csum;
-
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_outer_l4_csum +=
-				fwd_streams[sm_id]->rx_bad_outer_l4_csum;
+			ports[fs->tx_port].tx_stream = fs;
+			ports[fs->rx_port].rx_stream = fs;
+		}
+		ports[fs->tx_port].tx_dropped += fs->fwd_dropped;
+		ports[fs->rx_port].rx_bad_ip_csum += fs->rx_bad_ip_csum;
+		ports[fs->rx_port].rx_bad_l4_csum += fs->rx_bad_l4_csum;
+		ports[fs->rx_port].rx_bad_outer_l4_csum +=
+				fs->rx_bad_outer_l4_csum;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 		fwd_cycles = (uint64_t) (fwd_cycles +
app/test-pmd/testpmd.h +6 -6
index 85b791b..4f4a48f 100644
@@ -119,12 +119,12 @@ struct fwd_stream {
 	unsigned int retry_enabled;
 
 	/* "read-write" results */
-	unsigned int rx_packets;  /**< received packets */
-	unsigned int tx_packets;  /**< received packets transmitted */
-	unsigned int fwd_dropped; /**< received packets not forwarded */
-	unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */
-	unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
-	unsigned int rx_bad_outer_l4_csum;
+	uint64_t rx_packets;  /**< received packets */
+	uint64_t tx_packets;  /**< received packets transmitted */
+	uint64_t fwd_dropped; /**< received packets not forwarded */
+	uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
+	uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
+	uint64_t rx_bad_outer_l4_csum;
 	/**< received packets has bad outer l4 checksum */
 	unsigned int gro_times;	/**< GRO operation times */
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
Signature · 1 line
1.8.3.1
Reviewed-by on v3 2/4
#40 lore raw

Re: [PATCH v3 2/4] app/testpmd: extend fwd statistics to 64bits

Quoted 8 lines · David Marchand

fwd engine statistics are stored as unsigned int (32bits) and can wrap quite quickly.
Example: sending 7mpps for 614s gives us 4298000000 packets => 0x1002e4680 larger than 32bits.

testpmd reports forwarding stats as:
RX-packets: 3500381 TX-packets: 3500010 TX-dropped: 371

Quoted 8 lines

While the port and accumulated stats are reported as 64bits:
RX-packets: 4298467677 RX-dropped: 0 RX-total: 4298467677
TX-packets: 4298467306 TX-dropped: 371 TX-total: 4298467677

Fixes af75078fece3 ("first public release")

RX and Rx are used for error stats. Don't know why. But the patch simply preserves it, so not a problem of the patch.

#41 lore raw

PATCH v3 3/4 app/testpmd: remove useless casts on statistics

In reply to David Marchand

Caught by code review while investigating the fwd stats display code.

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- focused on useless casts only
- Cc'd stable

---
 app/test-pmd/testpmd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/testpmd.c +4 -4
index af9a765..103319f 100644
@@ -1376,7 +1376,7 @@ struct extmem_param {
 		printf("  RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: "
 		       "%-"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64"Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1390,13 +1390,13 @@ struct extmem_param {
 		printf("  TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: "
 		       "%-"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 	else {
 		printf("  RX-packets:             %14"PRIu64"    RX-dropped:%14"PRIu64"    RX-total:"
 		       "%14"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum:%14"PRIu64"    Bad-l4csum:%14"PRIu64"    Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1411,7 +1411,7 @@ struct extmem_param {
 		printf("  TX-packets:             %14"PRIu64"    TX-dropped:%14"PRIu64"    TX-total:"
 		       "%14"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
Signature · 1 line
1.8.3.1
#43 lore raw

PATCH v3 4/4 app/testpmd: display/clear forwarding stats on demand

In reply to David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, the (testpmd only) rte_port structure can't be used to maintain any statistics.
Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

---
Changelog since v1:
- removed hunk from now deleted patch 3

---
 app/test-pmd/cmdline.c                      |  44 +++
 app/test-pmd/testpmd.c                      | 425 +++++++++++++++-------------
 app/test-pmd/testpmd.h                      |   9 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 305 insertions(+), 209 deletions(-)
app/test-pmd/cmdline.c +44 -0
index db53cc0..58b11b7 100644
@@ -7386,6 +7386,49 @@ struct cmd_showqueue_result {
 	},
 };
 
+/* show/clear fwd engine statistics */
+struct fwd_result {
+	cmdline_fixed_string_t action;
+	cmdline_fixed_string_t fwd;
+	cmdline_fixed_string_t stats;
+	cmdline_fixed_string_t all;
+};
+
+cmdline_parse_token_string_t cmd_fwd_action =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
+cmdline_parse_token_string_t cmd_fwd_fwd =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
+cmdline_parse_token_string_t cmd_fwd_stats =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
+cmdline_parse_token_string_t cmd_fwd_all =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
+
+static void
+cmd_fwd_parsed(void *parsed_result,
+	       __rte_unused struct cmdline *cl,
+	       __rte_unused void *data)
+{
+	struct fwd_result *res = parsed_result;
+
+	if (!strcmp(res->action, "show"))
+		fwd_stats_display();
+	else
+		fwd_stats_reset();
+}
+
+static cmdline_parse_inst_t cmd_fwdall = {
+	.f = cmd_fwd_parsed,
+	.data = NULL,
+	.help_str = "show|clear fwd stats all",
+	.tokens = {
+		(void *)&cmd_fwd_action,
+		(void *)&cmd_fwd_fwd,
+		(void *)&cmd_fwd_stats,
+		(void *)&cmd_fwd_all,
+		NULL,
+	},
+};
+
 /* *** READ PORT REGISTER *** */
 struct cmd_read_reg_result {
 	cmdline_fixed_string_t read;
@@ -18559,6 +18602,7 @@ struct cmd_show_tx_metadata_result {
 	(cmdline_parse_inst_t *)&cmd_showqueue,
 	(cmdline_parse_inst_t *)&cmd_showportall,
 	(cmdline_parse_inst_t *)&cmd_showcfg,
+	(cmdline_parse_inst_t *)&cmd_fwdall,
 	(cmdline_parse_inst_t *)&cmd_start,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
app/test-pmd/testpmd.c +223 -202

469 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -7
index 4f4a48f..f43b1a7 100644
@@ -164,19 +164,12 @@ struct rte_port {
 	struct rte_eth_conf     dev_conf;   /**< Port configuration. */
 	struct ether_addr       eth_addr;   /**< Port ethernet address */
 	struct rte_eth_stats    stats;      /**< Last port statistics */
-	uint64_t                tx_dropped; /**< If no descriptor in TX ring */
-	struct fwd_stream       *rx_stream; /**< Port RX stream, if unique */
-	struct fwd_stream       *tx_stream; /**< Port TX stream, if unique */
 	unsigned int            socket_id;  /**< For NUMA support */
 	uint16_t		parse_tunnel:1; /**< Parse internal headers */
 	uint16_t                tso_segsz;  /**< Segmentation offload MSS for non-tunneled packets. */
 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
 	uint16_t                tx_vlan_id;/**< The tag ID */
 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-	uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
-	uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
-	uint64_t                rx_bad_outer_l4_csum;
-	/**< rx pkts with bad outer l4 checksum */
 	uint8_t                 tx_queue_stats_mapping_enabled;
 	uint8_t                 rx_queue_stats_mapping_enabled;
 	volatile uint16_t        port_status;    /**< port started or not */
@@ -767,6 +760,8 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 char *list_pkt_forwarding_retry_modes(void);
 void set_pkt_forwarding_mode(const char *fwd_mode);
 void start_packet_forwarding(int with_tx_first);
+void fwd_stats_display(void);
+void fwd_stats_reset(void);
 void stop_packet_forwarding(void);
 void dev_set_link_up(portid_t pid);
 void dev_set_link_down(portid_t pid);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +36 -0
index 1a12da4..06c8b2a 100644
@@ -336,6 +336,42 @@ Example::
    Set rxonly packet forwarding mode
 
 
+show fwd
+~~~~~~~~
+
+When running, forwarding engines maintain statistics from the time they have been started.
+Example for the io forwarding engine, with some packet drops on the tx side::
+
+   testpmd> show fwd stats all
+
+     ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
+     RX-packets: 274293770      TX-packets: 274293642      TX-dropped: 128
+
+     ------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
+     RX-packets: 274301850      TX-packets: 274301850      TX-dropped: 0
+
+     ---------------------- Forward statistics for port 0  ----------------------
+     RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
+     TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862
+     ----------------------------------------------------------------------------
+
+     ---------------------- Forward statistics for port 1  ----------------------
+     RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
+     TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834
+     ----------------------------------------------------------------------------
+
+     +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
+     RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
+     TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696
+     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+clear fwd
+~~~~~~~~~
+
+Clear the forwarding engines statistics::
+
+   testpmd> clear fwd stats all
+
 read rxd
 ~~~~~~~~
 
Signature · 1 line
1.8.3.1
#44 lore raw

Re: [PATCH v3 4/4] app/testpmd: display/clear forwarding stats on demand

Quoted 2 lines · David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

Won't this be duplicating existing commands:
"show port stats all|<port_id>"
"clear port stats all|<port_id>"

What benefit "show/clear fwd stats all" adds against existing ones?

testpmd> show port stats all

######################## NIC statistics for port 0 ########################
RX-packets: 133257152 RX-missed: 0 RX-bytes: 0
RX-errors: 0
RX-nombuf: 0
TX-packets: 131952064 TX-errors: 0 TX-bytes: 0

Throughput (since last show)
Rx-pps: 0
Tx-pps: 0
############################################################################

######################## NIC statistics for port 1 ########################
RX-packets: 133333440 RX-missed: 0 RX-bytes: 0
RX-errors: 0
RX-nombuf: 0
TX-packets: 131952064 TX-errors: 0 TX-bytes: 0

Throughput (since last show)
Rx-pps: 0
Tx-pps: 0
############################################################################

Quoted 12 lines

To be able to do so, the (testpmd only) rte_port structure can't be used to maintain any statistics.
Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

---
Changelog since v1:
- removed hunk from now deleted patch 3

<...>

#45 lore raw

Re: [PATCH v3 4/4] app/testpmd: display/clear forwarding stats on demand

Quoted 10 lines · Ferruh Yigit
Quoted 2 lines · David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

Won't this be duplicating existing commands:
"show port stats all|<port_id>"
"clear port stats all|<port_id>"

What benefit "show/clear fwd stats all" adds against existing ones?

Forwarding engines like "iofwd" maintain software statistics like "fwd_dropped" which gives you how much of the packets to be transmitted could not make it to the "wire".
"show port stats" won't give you those stats.

You could stop/start the forwarding to get them, but when debugging you most likely do not want to stop the forwarding.
I have been using this while tracking drops in a PVP setup.

Signature · 1 line
David Marchand
#46 lore raw

Re: [PATCH v3 4/4] app/testpmd: display/clear forwarding stats on demand

Quoted 14 lines · David Marchand

On Wed, Mar 20, 2019 at 1:25 PM Ferruh Yigit <[email protected] <mailto:[email protected]>> wrote:

On 3/20/2019 10:02 AM, David Marchand wrote:
> Add a new "show/clear fwd stats all" command to display fwd and port > statistics on the fly.

Won't this be duplicating existing commands:
"show port stats all|<port_id>"
"clear port stats all|<port_id>"

What benefit "show/clear fwd stats all" adds against existing ones?

Quoted 8 lines

Forwarding engines like "iofwd" maintain software statistics like "fwd_dropped" which gives you how much of the packets to be transmitted could not make it to the "wire".
"show port stats" won't give you those stats.

You could stop/start the forwarding to get them, but when debugging you most likely do not want to stop the forwarding.
I have been using this while tracking drops in a PVP setup.

I see, they are slightly different, no objection from me.

#47 lore raw

Re: [PATCH v3 4/4] app/testpmd: display/clear forwarding stats on demand

In reply to David Marchand
Quoted 10 lines · David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, the (testpmd only) rte_port structure can't be used to maintain any statistics.
Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

<...>

Quoted 6 lines
app/test-pmd/cmdline.c +6 -0
+/* show/clear fwd engine statistics */
+struct fwd_result {
+	cmdline_fixed_string_t action;
+	cmdline_fixed_string_t fwd;
+	cmdline_fixed_string_t stats;
+	cmdline_fixed_string_t all;

app/test-pmd/cmdline.c struct cmd_showqueue_result { · line 7404

Quoted 10 lines
app/test-pmd/cmdline.c +10 -0
+};
+
+cmdline_parse_token_string_t cmd_fwd_action =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
+cmdline_parse_token_string_t cmd_fwd_fwd =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
+cmdline_parse_token_string_t cmd_fwd_stats =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
+cmdline_parse_token_string_t cmd_fwd_all =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");

Do we need "all"?
Normally we have it when there is selection between specific <port_id> or all, here only option is all.

Quoted 16 lines
app/test-pmd/cmdline.c +16 -0
+
+static void
+cmd_fwd_parsed(void *parsed_result,
+	       __rte_unused struct cmdline *cl,
+	       __rte_unused void *data)
+{
+	struct fwd_result *res = parsed_result;
+
+	if (!strcmp(res->action, "show"))
+		fwd_stats_display();
+	else
+		fwd_stats_reset();
+}
+
+static cmdline_parse_inst_t cmd_fwdall = {
+	.f = cmd_fwd_parsed,

app/test-pmd/cmdline.c struct cmd_showqueue_result { · line 7430

Quoted 10 lines
app/test-pmd/cmdline.c +10 -0
+	.data = NULL,
+	.help_str = "show|clear fwd stats all",
+	.tokens = {
+		(void *)&cmd_fwd_action,
+		(void *)&cmd_fwd_fwd,
+		(void *)&cmd_fwd_stats,
+		(void *)&cmd_fwd_all,
+		NULL,
+	},
+};

in 'app/test-pmd/cmdline.c', there is 'cmd_help_long_parsed()' function to display the help output, can you please add new command information there too?

app/test-pmd/cmdline.c struct cmd_show_tx_metadata_result { · line 18605

Quoted 9 lines
app/test-pmd/cmdline.c +2 -0
+
 /* *** READ PORT REGISTER *** */
 struct cmd_read_reg_result {
 	cmdline_fixed_string_t read;
@@ -18559,6 +18602,7 @@ struct cmd_show_tx_metadata_result {
 	(cmdline_parse_inst_t *)&cmd_showqueue,
 	(cmdline_parse_inst_t *)&cmd_showportall,
 	(cmdline_parse_inst_t *)&cmd_showcfg,
+	(cmdline_parse_inst_t *)&cmd_fwdall,

command name looks misleading 'fwdall', it feels like it is something doing forwarding more than display, what about following same syntax with above 'cmd_showportall', so 'cmd_showfwdall' or 'cmd_showfwd' based on your answer to drop "all"?

<...>

app/test-pmd/testpmd.c struct extmem_param { · line 1445

Quoted 3 lines
app/test-pmd/testpmd.c +3 -0
+#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
+		fwd_cycles += fs->core_cycles;
+#endif

Ahh, it seems I missed this config option, looks useful :) I wonder if it is documented anywhere.

#48 lore raw

Re: [PATCH v3 4/4] app/testpmd: display/clear forwarding stats on demand

Quoted 27 lines · Ferruh Yigit
Quoted 10 lines · David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, the (testpmd only) rte_port structure can't be used to maintain any statistics.
Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

<...>

Quoted 13 lines
app/test-pmd/cmdline.c +13 -0
+/* show/clear fwd engine statistics */
+struct fwd_result {
+     cmdline_fixed_string_t action;
+     cmdline_fixed_string_t fwd;
+     cmdline_fixed_string_t stats;
+     cmdline_fixed_string_t all;
+};
+
+cmdline_parse_token_string_t cmd_fwd_action =
+     TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
+cmdline_parse_token_string_t cmd_fwd_fwd =
+     TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
+cmdline_parse_token_string_t cmd_fwd_stats =
Quoted 9 lines

app/test-pmd/cmdline.c struct cmd_showqueue_result { · line 7404

Quoted 3 lines
app/test-pmd/cmdline.c +3 -0
+     TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
+cmdline_parse_token_string_t cmd_fwd_all =
+     TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");

Do we need "all"?
Normally we have it when there is selection between specific <port_id> or all,
here only option is all.

Well, the thing is that if we add a specific <fwd_id> later, we would have to introduce this "all".
And since a lot of people are going to use this command, this would break their scripts ;-)

I find it consistent with "show port stats all" as well.

Quoted 22 lines
Quoted 22 lines
app/test-pmd/cmdline.c +22 -0
+
+static void
+cmd_fwd_parsed(void *parsed_result,
+            __rte_unused struct cmdline *cl,
+            __rte_unused void *data)
+{
+     struct fwd_result *res = parsed_result;
+
+     if (!strcmp(res->action, "show"))
+             fwd_stats_display();
+     else
+             fwd_stats_reset();
+}
+
+static cmdline_parse_inst_t cmd_fwdall = {
+     .f = cmd_fwd_parsed,
+     .data = NULL,
+     .help_str = "show|clear fwd stats all",
+     .tokens = {
+             (void *)&cmd_fwd_action,
+             (void *)&cmd_fwd_fwd,
+             (void *)&cmd_fwd_stats,
Quoted 9 lines

app/test-pmd/cmdline.c struct cmd_showqueue_result { · line 7430

Quoted 4 lines
app/test-pmd/cmdline.c +4 -0
+             (void *)&cmd_fwd_all,
+             NULL,
+     },
+};

in 'app/test-pmd/cmdline.c', there is 'cmd_help_long_parsed()' function to display the help output, can you please add new command information there too?

Indeed, will do.

Quoted 7 lines
Quoted 7 lines
app/test-pmd/cmdline.c +1 -0
+
 /* *** READ PORT REGISTER *** */
 struct cmd_read_reg_result {
      cmdline_fixed_string_t read;
@@ -18559,6 +18602,7 @@ struct cmd_show_tx_metadata_result {
      (cmdline_parse_inst_t *)&cmd_showqueue,
      (cmdline_parse_inst_t *)&cmd_showportall,
Quoted 9 lines

app/test-pmd/cmdline.c struct cmd_show_tx_metadata_result { · line 18605

Quoted 2 lines
app/test-pmd/cmdline.c +1 -0
      (cmdline_parse_inst_t *)&cmd_showcfg,
+     (cmdline_parse_inst_t *)&cmd_fwdall,

command name looks misleading 'fwdall', it feels like it is something doing forwarding more than display, what about following same syntax with above 'cmd_showportall', so 'cmd_showfwdall' or 'cmd_showfwd' based on your answer to
drop "all"?

I would go with cmd_showfwdall.

Quoted 9 lines

<...>

app/test-pmd/testpmd.c struct extmem_param { · line 1445

Quoted 3 lines
app/test-pmd/testpmd.c +3 -0
+#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
+             fwd_cycles += fs->core_cycles;
+#endif

Ahh, it seems I missed this config option, looks useful :) I wonder if it is documented anywhere.

Well, it does seem quite unknown.
I am not sure of the accuracy, just tried it to check if it was really broken or not, seems to work.

Signature · 1 line
David Marchand
#49 lore raw

v4 cover display testpmd forwarding engine stats on the fly

In reply to David Marchand

Here is a little series that makes it possible to display and clear testpmd fwd engines while they run without having to stop them. This is mostly handy when running stress tests and you look for packets drops without having to stop/start testpmd forwarding.

Example:

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 261977064 TX-packets: 261977064 TX-dropped: 0

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 261985142 TX-packets: 261985142 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 261977096      RX-dropped: 0             RX-total: 261977096
  TX-packets: 261985155      TX-dropped: 0             TX-total: 261985155

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 261985188      RX-dropped: 0             RX-total: 261985188
  TX-packets: 261977128      TX-dropped: 0             TX-total: 261977128

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 523962284      RX-dropped: 0             RX-total: 523962284
  TX-packets: 523962283      TX-dropped: 0             TX-total: 523962283

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 274293770 TX-packets: 274293642 TX-dropped: 128

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 274301850 TX-packets: 274301850 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
  TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
  TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
  TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Signature · 30 lines
David Marchand

---
Changelog since v3:
- updated patch 4 following Ferruh comments

Changelog since v2:
- first patch has been merged in net-next, removed from the series
- split patch (numbered 3 in v2) in two following Andrew comment

Changelog since v1:
- Cc: stable for patch 1
- removed buggy patch 3

---

David Marchand (4):
  app/testpmd: add missing newline when showing statistics
  app/testpmd: extend fwd statistics to 64bits
  app/testpmd: remove useless casts on statistics
  app/testpmd: display/clear forwarding stats on demand

 app/test-pmd/cmdline.c                      |  49 +++
 app/test-pmd/testpmd.c                      | 450 ++++++++++++++--------------
 app/test-pmd/testpmd.h                      |  21 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 320 insertions(+), 236 deletions(-)

-- 
1.8.3.1
#50 lore raw

PATCH v4 1/4 app/testpmd: add missing newline when showing statistics

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:
RX-packets: 3542977 TX-packets: 3542971 TX-dropped: 6 RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:
RX-packets: 4629969 TX-packets: 4629969 TX-dropped: 0
RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others] TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- Cc'd stable

---
 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +1 -1
index 216be47..40199c1 100644
@@ -1459,7 +1459,7 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
Signature · 1 line
1.8.3.1
Reviewed-by on v4 1/4
#51 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

Quoted 32 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:

   RX-packets: 3542977        TX-packets: 3542971        TX-dropped: 6               RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
   TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:

   RX-packets: 4629969        TX-packets: 4629969        TX-dropped: 0
   RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
   TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- Cc'd stable

---
  app/test-pmd/testpmd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +0 -0
index 216be47..40199c1 100644

app/test-pmd/testpmd.c struct extmem_param { · line 1465

Quoted 8 lines
app/test-pmd/testpmd.c +1 -1
@@ -1459,7 +1459,7 @@ struct extmem_param {
  	       "TX Port=%2d/Queue=%2d %s\n",
  	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
  	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
  	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
  	/* if checksum mode */
#52 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

In reply to David Marchand
Quoted 7 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:

   RX-packets: 3542977        TX-packets: 3542971        TX-dropped: 6               RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
   TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
Quoted 7 lines

After:

   RX-packets: 4629969        TX-packets: 4629969        TX-dropped: 0
   RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
   TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
Fixes af75078fece3 ("first public release")

While the patch is good, I wonder whether we should backport it. Indeed, it might break some scripts parsing testpmd output.

Any thoughts?

Quoted 8 lines

---
Changelog since v2:
- Cc'd stable

---

#53 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

Quoted 17 lines · Maxime Coquelin
Quoted 5 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:

   RX-packets: 3542977        TX-packets: 3542971        TX-dropped: 6
             RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of

others]

Quoted 7 lines
   TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:

   RX-packets: 4629969        TX-packets: 4629969        TX-dropped: 0
   RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
   TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
Quoted 8 lines
Quoted 2 lines
Fixes af75078fece3 ("first public release")

While the patch is good, I wonder whether we should backport it. Indeed, it might break some scripts parsing testpmd output.

Any thoughts?

It seems unlikely, this feature is disabled by default. But yes, I would avoid backporting it.

Signature · 1 line
David Marchand
#54 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

Quoted 34 lines · David Marchand

On Fri, Mar 22, 2019 at 6:17 PM Maxime Coquelin <[email protected] <mailto:[email protected]>> wrote:

    On 3/22/19 2:37 PM, David Marchand wrote:
    > Having the standard stats and the rx burst stats on the same
    line gives a
    > really long line and is not consistent with the rest.
    >
    > Before:
    >    RX-packets: 3542977        TX-packets: 3542971   TX-dropped:
    6               RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts
    + 61% of others]
    >    TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of
    others]
    >
    > After:
    >    RX-packets: 4629969        TX-packets: 4629969   TX-dropped: 0
    >    RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of
    others]
    >    TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of
    others]
    >
    > Fixes: af75078fece3 ("first public release")
    > Cc:[email protected] <mailto:Cc%[email protected]>

    While the patch is good, I wonder whether we should backport it.
    Indeed, it might break some scripts parsing testpmd output.

    Any thoughts?
Quoted 2 lines

It seems unlikely, this feature is disabled by default. But yes, I would avoid backporting it.

For me it looks like a bug. That's why I think it should be backported, but the fix is not 100% correct in fact. I'll reply directly to the patch.

#55 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

In reply to David Marchand
Quoted 31 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:

   RX-packets: 3542977        TX-packets: 3542971        TX-dropped: 6               RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]
   TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:

   RX-packets: 4629969        TX-packets: 4629969        TX-dropped: 0
   RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
   TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- Cc'd stable

---
  app/test-pmd/testpmd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +0 -0
index 216be47..40199c1 100644

app/test-pmd/testpmd.c struct extmem_param { · line 1465

Quoted 8 lines
app/test-pmd/testpmd.c +1 -1
@@ -1459,7 +1459,7 @@ struct extmem_param {
  	       "TX Port=%2d/Queue=%2d %s\n",
  	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
  	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
  	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
  	/* if checksum mode */

In fact bad Rx checksum counters follow and I think they should be in this line.

That's why there is no \n here from the very beginning.

My fix for the bug (local) just add \n in else branch below.

Andrew.

#56 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

Quoted 47 lines · Andrew Rybchenko
Quoted 5 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:

   RX-packets: 3542977        TX-packets: 3542971        TX-dropped: 6
             RX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of

others]

Quoted 26 lines
   TX-bursts : 499440 [24% of 2 pkts + 15% of 1 pkts + 61% of others]

After:

   RX-packets: 4629969        TX-packets: 4629969        TX-dropped: 0
   RX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
   TX-bursts : 663328 [19% of 2 pkts + 17% of 3 pkts + 64% of others]
Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- Cc'd stable

---
  app/test-pmd/testpmd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +0 -0
index 216be47..40199c1 100644

app/test-pmd/testpmd.c struct extmem_param { · line 1465

Quoted 8 lines
app/test-pmd/testpmd.c +1 -1
@@ -1459,7 +1459,7 @@ struct extmem_param {
             "TX Port=%2d/Queue=%2d %s\n",
             fwd_top_stats_border, fs->rx_port, fs->rx_queue,
             fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-     printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+     printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
             fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
      /* if checksum mode */

In fact bad Rx checksum counters follow and I think they should be in this line.

Quoted 4 lines

That's why there is no \n here from the very beginning.

My fix for the bug (local) just add \n in else branch below.

Mm, ok, I will look at this monday.
I might add the \n in pkt_burst_stats_display() and update other callers.

Signature · 1 line
David Marchand
#57 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

Quoted 4 lines · David Marchand
Quoted 1 line · Andrew Rybchenko
Quoted 8 lines
Quoted 7 lines

In fact bad Rx checksum counters follow and I think they should be in this line.

That's why there is no \n here from the very beginning.

My fix for the bug (local) just add \n in else branch below.

Just to be clear.

origin/master:
- iofwd engine:
------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0
-------
RX-packets: 121811360 TX-packets: 121811392 TX-dropped:
0 RX-bursts : 3806605 [100% of 32 pkts]
TX-bursts : 3806606 [100% of 32 pkts]

- csum engine:
------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0
-------
RX-packets: 5467488 TX-packets: 5467520 TX-dropped:
0 RX- bad IP checksum: 0 Rx- bad L4 checksum:
0 Rx- bad outer L4 checksum: 0
RX-bursts : 170859 [100% of 32 pkts]
TX-bursts : 170860 [100% of 32 pkts]

So, as suggested, I added a printf("\n") in the else for the csum engine block:

- iofwd engine:
------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0
-------
RX-packets: 259770560 TX-packets: 259770592 TX-dropped:
0
RX-bursts : 8117830 [100% of 32 pkts]
TX-bursts : 8117831 [100% of 32 pkts]

- csum engine:
------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0
-------
RX-packets: 7834016 TX-packets: 7834048 TX-dropped:
0 RX- bad IP checksum: 0 Rx- bad L4 checksum:
0 Rx- bad outer L4 checksum: 0
RX-bursts : 244813 [100% of 32 pkts]
TX-bursts : 244814 [100% of 32 pkts]

deal ?

Signature · 1 line
David Marchand
#58 lore raw

Re: [PATCH v4 1/4] app/testpmd: add missing newline when showing statistics

Quoted 54 lines · David Marchand
Quoted 10 lines · David Marchand
Quoted 7 lines · Andrew Rybchenko

In fact bad Rx checksum counters follow and I think they should be in this line.

That's why there is no \n here from the very beginning.

My fix for the bug (local) just add \n in else branch below.

Just to be clear.

origin/master:
- iofwd engine:

   ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0

-------
RX-packets: 121811360 TX-packets: 121811392 TX-dropped:
0 RX-bursts : 3806605 [100% of 32 pkts]
TX-bursts : 3806606 [100% of 32 pkts]

- csum engine:

   ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0

-------
RX-packets: 5467488 TX-packets: 5467520 TX-dropped:
0 RX- bad IP checksum: 0 Rx- bad L4 checksum:
0 Rx- bad outer L4 checksum: 0
RX-bursts : 170859 [100% of 32 pkts]
TX-bursts : 170860 [100% of 32 pkts]

So, as suggested, I added a printf("\n") in the else for the csum engine block:

- iofwd engine:

   ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0

-------
RX-packets: 259770560 TX-packets: 259770592 TX-dropped:
0
RX-bursts : 8117830 [100% of 32 pkts]
TX-bursts : 8117831 [100% of 32 pkts]

- csum engine:

   ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0

-------
RX-packets: 7834016 TX-packets: 7834048 TX-dropped:
0 RX- bad IP checksum: 0 Rx- bad L4 checksum:
0 Rx- bad outer L4 checksum: 0
RX-bursts : 244813 [100% of 32 pkts]
TX-bursts : 244814 [100% of 32 pkts]

Quoted 1 line

deal ?

Yes, thanks a lot.

Andrew.

#59 lore raw

PATCH v4 2/4 app/testpmd: extend fwd statistics to 64bits

In reply to David Marchand

fwd engine statistics are stored as unsigned int (32bits) and can wrap quite quickly.
Example: sending 7mpps for 614s gives us 4298000000 packets => 0x1002e4680 larger than 32bits.

testpmd reports forwarding stats as:
RX-packets: 3500381 TX-packets: 3500010 TX-dropped: 371

While the port and accumulated stats are reported as 64bits:
RX-packets: 4298467677 RX-dropped: 0 RX-total: 4298467677
TX-packets: 4298467306 TX-dropped: 371 TX-total: 4298467677

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- split out of the previous patch with a dedicated commitlog
- Cc'd stable

---
 app/test-pmd/testpmd.c | 51 +++++++++++++++++---------------------------------
 app/test-pmd/testpmd.h | 12 ++++++------
 2 files changed, 23 insertions(+), 40 deletions(-)
app/test-pmd/testpmd.c +17 -34
index 40199c1..d2ba770 100644
@@ -1459,13 +1459,15 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u\n",
+	printf("  RX-packets: %-14"PRIu64" TX-packets: %-14"PRIu64
+	       " TX-dropped: %-14"PRIu64"\n",
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
 	if (cur_fwd_eng == &csum_fwd_engine) {
-	       printf("  RX- bad IP checksum: %-14u  Rx- bad L4 checksum: "
-			"%-14u Rx- bad outer L4 checksum: %-14u\n",
+		printf("  RX- bad IP checksum: %-14"PRIu64
+		       "  Rx- bad L4 checksum: %-14"PRIu64
+		       " Rx- bad outer L4 checksum: %-14"PRIu64"\n",
 			fs->rx_bad_ip_csum, fs->rx_bad_l4_csum,
 			fs->rx_bad_outer_l4_csum);
 	}
@@ -1743,9 +1745,6 @@ struct extmem_param {
 	uint64_t total_rx_dropped;
 	uint64_t total_tx_dropped;
 	uint64_t total_rx_nombuf;
-	uint64_t tx_dropped;
-	uint64_t rx_bad_ip_csum;
-	uint64_t rx_bad_l4_csum;
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t fwd_cycles;
 #endif
@@ -1772,38 +1771,22 @@ struct extmem_param {
 	fwd_cycles = 0;
 #endif
 	for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
+		struct fwd_stream *fs = fwd_streams[sm_id];
+
 		if (cur_fwd_config.nb_fwd_streams >
 		    cur_fwd_config.nb_fwd_ports) {
 			fwd_stream_stats_display(sm_id);
-			ports[fwd_streams[sm_id]->tx_port].tx_stream = NULL;
-			ports[fwd_streams[sm_id]->rx_port].rx_stream = NULL;
+			ports[fs->tx_port].tx_stream = NULL;
+			ports[fs->rx_port].rx_stream = NULL;
 		} else {
-			ports[fwd_streams[sm_id]->tx_port].tx_stream =
-				fwd_streams[sm_id];
-			ports[fwd_streams[sm_id]->rx_port].rx_stream =
-				fwd_streams[sm_id];
-		}
-		tx_dropped = ports[fwd_streams[sm_id]->tx_port].tx_dropped;
-		tx_dropped = (uint64_t) (tx_dropped +
-					 fwd_streams[sm_id]->fwd_dropped);
-		ports[fwd_streams[sm_id]->tx_port].tx_dropped = tx_dropped;
-
-		rx_bad_ip_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum;
-		rx_bad_ip_csum = (uint64_t) (rx_bad_ip_csum +
-					 fwd_streams[sm_id]->rx_bad_ip_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum =
-							rx_bad_ip_csum;
-
-		rx_bad_l4_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum;
-		rx_bad_l4_csum = (uint64_t) (rx_bad_l4_csum +
-					 fwd_streams[sm_id]->rx_bad_l4_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum =
-							rx_bad_l4_csum;
-
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_outer_l4_csum +=
-				fwd_streams[sm_id]->rx_bad_outer_l4_csum;
+			ports[fs->tx_port].tx_stream = fs;
+			ports[fs->rx_port].rx_stream = fs;
+		}
+		ports[fs->tx_port].tx_dropped += fs->fwd_dropped;
+		ports[fs->rx_port].rx_bad_ip_csum += fs->rx_bad_ip_csum;
+		ports[fs->rx_port].rx_bad_l4_csum += fs->rx_bad_l4_csum;
+		ports[fs->rx_port].rx_bad_outer_l4_csum +=
+				fs->rx_bad_outer_l4_csum;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 		fwd_cycles = (uint64_t) (fwd_cycles +
app/test-pmd/testpmd.h +6 -6
index 85b791b..4f4a48f 100644
@@ -119,12 +119,12 @@ struct fwd_stream {
 	unsigned int retry_enabled;
 
 	/* "read-write" results */
-	unsigned int rx_packets;  /**< received packets */
-	unsigned int tx_packets;  /**< received packets transmitted */
-	unsigned int fwd_dropped; /**< received packets not forwarded */
-	unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */
-	unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
-	unsigned int rx_bad_outer_l4_csum;
+	uint64_t rx_packets;  /**< received packets */
+	uint64_t tx_packets;  /**< received packets transmitted */
+	uint64_t fwd_dropped; /**< received packets not forwarded */
+	uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
+	uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
+	uint64_t rx_bad_outer_l4_csum;
 	/**< received packets has bad outer l4 checksum */
 	unsigned int gro_times;	/**< GRO operation times */
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
Signature · 1 line
1.8.3.1
Reviewed-by on v4 2/4
#60 lore raw

Re: [PATCH v4 2/4] app/testpmd: extend fwd statistics to 64bits

Quoted 22 lines · David Marchand

fwd engine statistics are stored as unsigned int (32bits) and can wrap quite quickly.
Example: sending 7mpps for 614s gives us 4298000000 packets => 0x1002e4680 larger than 32bits.

testpmd reports forwarding stats as:
RX-packets: 3500381 TX-packets: 3500010 TX-dropped: 371

While the port and accumulated stats are reported as 64bits:
RX-packets: 4298467677 RX-dropped: 0 RX-total: 4298467677
TX-packets: 4298467306 TX-dropped: 371 TX-total: 4298467677

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- split out of the previous patch with a dedicated commitlog
- Cc'd stable

Quoted 5 lines
---
  app/test-pmd/testpmd.c | 51 +++++++++++++++++---------------------------------
  app/test-pmd/testpmd.h | 12 ++++++------
  2 files changed, 23 insertions(+), 40 deletions(-)
#61 lore raw

PATCH v4 3/4 app/testpmd: remove useless casts on statistics

In reply to David Marchand

Caught by code review while investigating the fwd stats display code.

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- focused on useless casts only
- Cc'd stable

---
 app/test-pmd/testpmd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/testpmd.c +4 -4
index d2ba770..8c3be14 100644
@@ -1376,7 +1376,7 @@ struct extmem_param {
 		printf("  RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: "
 		       "%-"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64"Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1390,13 +1390,13 @@ struct extmem_param {
 		printf("  TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: "
 		       "%-"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 	else {
 		printf("  RX-packets:             %14"PRIu64"    RX-dropped:%14"PRIu64"    RX-total:"
 		       "%14"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum:%14"PRIu64"    Bad-l4csum:%14"PRIu64"    Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1411,7 +1411,7 @@ struct extmem_param {
 		printf("  TX-packets:             %14"PRIu64"    TX-dropped:%14"PRIu64"    TX-total:"
 		       "%14"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
Signature · 1 line
1.8.3.1
Reviewed-by on v4 3/4
#62 lore raw

Re: [PATCH v4 3/4] app/testpmd: remove useless casts on statistics

Quoted 7 lines · David Marchand

Caught by code review while investigating the fwd stats display code.

Fixes af75078fece3 ("first public release")
Quoted 9 lines

---
Changelog since v2:
- focused on useless casts only
- Cc'd stable

---
  app/test-pmd/testpmd.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
#63 lore raw

PATCH v4 4/4 app/testpmd: display/clear forwarding stats on demand

In reply to David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, the (testpmd only) rte_port structure can't be used to maintain any statistics.
Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

---
Changelog since v3:
- added description in testpmd usage
- renamed cmd_fwdall as cmd_showfwdall

Changelog since v1:
- removed hunk from now deleted patch 3

---
 app/test-pmd/cmdline.c                      |  49 ++++
 app/test-pmd/testpmd.c                      | 425 +++++++++++++++-------------
 app/test-pmd/testpmd.h                      |   9 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 310 insertions(+), 209 deletions(-)
app/test-pmd/cmdline.c +49 -0
index 815e5e8..ee50e45 100644
@@ -225,6 +225,11 @@ static void cmd_help_long_parsed(void *parsed_result,
                         "show port tm node stats (port_id) (node_id) (clear)\n"
                         "       Display the port TM node stats.\n\n"
 
+			"show fwd stats all\n"
+			"    Display statistics for all fwd engines.\n\n"
+
+			"clear fwd stats all\n"
+			"    Clear statistics for all fwd engines.\n\n"
 		);
 	}
 
@@ -7386,6 +7391,49 @@ struct cmd_showqueue_result {
 	},
 };
 
+/* show/clear fwd engine statistics */
+struct fwd_result {
+	cmdline_fixed_string_t action;
+	cmdline_fixed_string_t fwd;
+	cmdline_fixed_string_t stats;
+	cmdline_fixed_string_t all;
+};
+
+cmdline_parse_token_string_t cmd_fwd_action =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
+cmdline_parse_token_string_t cmd_fwd_fwd =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
+cmdline_parse_token_string_t cmd_fwd_stats =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
+cmdline_parse_token_string_t cmd_fwd_all =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
+
+static void
+cmd_showfwdall_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct fwd_result *res = parsed_result;
+
+	if (!strcmp(res->action, "show"))
+		fwd_stats_display();
+	else
+		fwd_stats_reset();
+}
+
+static cmdline_parse_inst_t cmd_showfwdall = {
+	.f = cmd_showfwdall_parsed,
+	.data = NULL,
+	.help_str = "show|clear fwd stats all",
+	.tokens = {
+		(void *)&cmd_fwd_action,
+		(void *)&cmd_fwd_fwd,
+		(void *)&cmd_fwd_stats,
+		(void *)&cmd_fwd_all,
+		NULL,
+	},
+};
+
 /* *** READ PORT REGISTER *** */
 struct cmd_read_reg_result {
 	cmdline_fixed_string_t read;
@@ -18559,6 +18607,7 @@ struct cmd_show_tx_metadata_result {
 	(cmdline_parse_inst_t *)&cmd_showqueue,
 	(cmdline_parse_inst_t *)&cmd_showportall,
 	(cmdline_parse_inst_t *)&cmd_showcfg,
+	(cmdline_parse_inst_t *)&cmd_showfwdall,
 	(cmdline_parse_inst_t *)&cmd_start,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
app/test-pmd/testpmd.c +223 -202

469 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -7
index 4f4a48f..f43b1a7 100644
@@ -164,19 +164,12 @@ struct rte_port {
 	struct rte_eth_conf     dev_conf;   /**< Port configuration. */
 	struct ether_addr       eth_addr;   /**< Port ethernet address */
 	struct rte_eth_stats    stats;      /**< Last port statistics */
-	uint64_t                tx_dropped; /**< If no descriptor in TX ring */
-	struct fwd_stream       *rx_stream; /**< Port RX stream, if unique */
-	struct fwd_stream       *tx_stream; /**< Port TX stream, if unique */
 	unsigned int            socket_id;  /**< For NUMA support */
 	uint16_t		parse_tunnel:1; /**< Parse internal headers */
 	uint16_t                tso_segsz;  /**< Segmentation offload MSS for non-tunneled packets. */
 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
 	uint16_t                tx_vlan_id;/**< The tag ID */
 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-	uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
-	uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
-	uint64_t                rx_bad_outer_l4_csum;
-	/**< rx pkts with bad outer l4 checksum */
 	uint8_t                 tx_queue_stats_mapping_enabled;
 	uint8_t                 rx_queue_stats_mapping_enabled;
 	volatile uint16_t        port_status;    /**< port started or not */
@@ -767,6 +760,8 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 char *list_pkt_forwarding_retry_modes(void);
 void set_pkt_forwarding_mode(const char *fwd_mode);
 void start_packet_forwarding(int with_tx_first);
+void fwd_stats_display(void);
+void fwd_stats_reset(void);
 void stop_packet_forwarding(void);
 void dev_set_link_up(portid_t pid);
 void dev_set_link_down(portid_t pid);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +36 -0
index 1a12da4..06c8b2a 100644
@@ -336,6 +336,42 @@ Example::
    Set rxonly packet forwarding mode
 
 
+show fwd
+~~~~~~~~
+
+When running, forwarding engines maintain statistics from the time they have been started.
+Example for the io forwarding engine, with some packet drops on the tx side::
+
+   testpmd> show fwd stats all
+
+     ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
+     RX-packets: 274293770      TX-packets: 274293642      TX-dropped: 128
+
+     ------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
+     RX-packets: 274301850      TX-packets: 274301850      TX-dropped: 0
+
+     ---------------------- Forward statistics for port 0  ----------------------
+     RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
+     TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862
+     ----------------------------------------------------------------------------
+
+     ---------------------- Forward statistics for port 1  ----------------------
+     RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
+     TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834
+     ----------------------------------------------------------------------------
+
+     +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
+     RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
+     TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696
+     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+clear fwd
+~~~~~~~~~
+
+Clear the forwarding engines statistics::
+
+   testpmd> clear fwd stats all
+
 read rxd
 ~~~~~~~~
 
Signature · 1 line
1.8.3.1
Reviewed-by on v4 4/4
#64 lore raw

Re: [PATCH v4 4/4] app/testpmd: display/clear forwarding stats on demand

Quoted 18 lines · David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, the (testpmd only) rte_port structure can't be used to maintain any statistics.
Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

---
Changelog since v3:
- added description in testpmd usage
- renamed cmd_fwdall as cmd_showfwdall

Changelog since v1:
- removed hunk from now deleted patch 3

Quoted 7 lines
---
  app/test-pmd/cmdline.c                      |  49 ++++
  app/test-pmd/testpmd.c                      | 425 +++++++++++++++-------------
  app/test-pmd/testpmd.h                      |   9 +-
  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
  4 files changed, 310 insertions(+), 209 deletions(-)
#65 lore raw

v5 cover display testpmd forwarding engine stats on the fly

In reply to David Marchand

Here is a little series that makes it possible to display and clear testpmd fwd engines while they run without having to stop them. This is mostly handy when running stress tests and you look for packets drops without having to stop/start testpmd forwarding.

Example:

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 261977064 TX-packets: 261977064 TX-dropped: 0

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 261985142 TX-packets: 261985142 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 261977096      RX-dropped: 0             RX-total: 261977096
  TX-packets: 261985155      TX-dropped: 0             TX-total: 261985155

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 261985188      RX-dropped: 0             RX-total: 261985188
  TX-packets: 261977128      TX-dropped: 0             TX-total: 261977128

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 523962284      RX-dropped: 0             RX-total: 523962284
  TX-packets: 523962283      TX-dropped: 0             TX-total: 523962283

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 274293770 TX-packets: 274293642 TX-dropped: 128

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 274301850 TX-packets: 274301850 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
  TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
  TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
  TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Signature · 33 lines
David Marchand

---
Changelog since v4:
- take csum engine output into account in patch 1 (Andrew comment)

Changelog since v3:
- updated patch 4 following Ferruh comments

Changelog since v2:
- first patch has been merged in net-next, removed from the series
- split patch (numbered 3 in v2) in two following Andrew comment

Changelog since v1:
- Cc: stable for patch 1
- removed buggy patch 3

---

David Marchand (4):
  app/testpmd: add missing newline when showing statistics
  app/testpmd: extend fwd statistics to 64bits
  app/testpmd: remove useless casts on statistics
  app/testpmd: display/clear forwarding stats on demand

 app/test-pmd/cmdline.c                      |  49 +++
 app/test-pmd/testpmd.c                      | 452 ++++++++++++++--------------
 app/test-pmd/testpmd.h                      |  21 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 322 insertions(+), 236 deletions(-)

-- 
1.8.3.1
#66 lore raw

PATCH v5 1/4 app/testpmd: add missing newline when showing statistics

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:
iofwd engine
RX-packets: 121811360 TX-packets: 121811392 TX-dropped: 0 RX-bursts : 3806605 [100% of 32 pkts]
TX-bursts : 3806606 [100% of 32 pkts]

csum engine
RX-packets: 5467488 TX-packets: 5467520 TX-dropped: 0 RX- bad IP checksum: 0 Rx- bad L4 checksum: 0 Rx- bad outer L4 checksum: 0
RX-bursts : 170859 [100% of 32 pkts]
TX-bursts : 170860 [100% of 32 pkts]

After:
iofwd engine
RX-packets: 259770560 TX-packets: 259770592 TX-dropped: 0
RX-bursts : 8117830 [100% of 32 pkts]
TX-bursts : 8117831 [100% of 32 pkts]

csum engine
RX-packets: 7834016 TX-packets: 7834048 TX-dropped: 0 RX- bad IP checksum: 0 Rx- bad L4 checksum: 0 Rx- bad outer L4 checksum: 0
RX-bursts : 244813 [100% of 32 pkts]
TX-bursts : 244814 [100% of 32 pkts]

Fixes af75078fece3 ("first public release")

---
Changelog since v4:
- let the csum stats at the same place than before, updated commitlog

Changelog since v2:
- Cc'd stable

---
 app/test-pmd/testpmd.c | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.c +2 -0
index 216be47..7715844 100644
@@ -1468,6 +1468,8 @@ struct extmem_param {
 			"%-14u Rx- bad outer L4 checksum: %-14u\n",
 			fs->rx_bad_ip_csum, fs->rx_bad_l4_csum,
 			fs->rx_bad_outer_l4_csum);
+	} else {
+		printf("\n");
 	}
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
Signature · 1 line
1.8.3.1
Reviewed-by on v5 1/4
#67 lore raw

Re: [PATCH v5 1/4] app/testpmd: add missing newline when showing statistics

Quoted 24 lines · David Marchand

Having the standard stats and the rx burst stats on the same line gives a really long line and is not consistent with the rest.

Before:
iofwd engine
RX-packets: 121811360 TX-packets: 121811392 TX-dropped: 0 RX-bursts : 3806605 [100% of 32 pkts]
TX-bursts : 3806606 [100% of 32 pkts]

csum engine
RX-packets: 5467488 TX-packets: 5467520 TX-dropped: 0 RX- bad IP checksum: 0 Rx- bad L4 checksum: 0 Rx- bad outer L4 checksum: 0
RX-bursts : 170859 [100% of 32 pkts]
TX-bursts : 170860 [100% of 32 pkts]

After:
iofwd engine
RX-packets: 259770560 TX-packets: 259770592 TX-dropped: 0
RX-bursts : 8117830 [100% of 32 pkts]
TX-bursts : 8117831 [100% of 32 pkts]

csum engine
RX-packets: 7834016 TX-packets: 7834048 TX-dropped: 0 RX- bad IP checksum: 0 Rx- bad L4 checksum: 0 Rx- bad outer L4 checksum: 0
RX-bursts : 244813 [100% of 32 pkts]
TX-bursts : 244814 [100% of 32 pkts]

Quoted 4 lines
Fixes af75078fece3 ("first public release")
#68 lore raw

PATCH v5 2/4 app/testpmd: extend fwd statistics to 64bits

In reply to David Marchand

fwd engine statistics are stored as unsigned int (32bits) and can wrap quite quickly.
Example: sending 7mpps for 614s gives us 4298000000 packets => 0x1002e4680 larger than 32bits.

testpmd reports forwarding stats as:
RX-packets: 3500381 TX-packets: 3500010 TX-dropped: 371

While the port and accumulated stats are reported as 64bits:
RX-packets: 4298467677 RX-dropped: 0 RX-total: 4298467677
TX-packets: 4298467306 TX-dropped: 371 TX-total: 4298467677

Fixes af75078fece3 ("first public release")

---
Changelog since v4:
- rebased following patch 1 update

Changelog since v2:
- split out of the previous patch with a dedicated commitlog
- Cc'd stable

---
 app/test-pmd/testpmd.c | 51 +++++++++++++++++---------------------------------
 app/test-pmd/testpmd.h | 12 ++++++------
 2 files changed, 23 insertions(+), 40 deletions(-)
app/test-pmd/testpmd.c +17 -34
index 7715844..05a3dce 100644
@@ -1459,13 +1459,15 @@ struct extmem_param {
 	       "TX Port=%2d/Queue=%2d %s\n",
 	       fwd_top_stats_border, fs->rx_port, fs->rx_queue,
 	       fs->tx_port, fs->tx_queue, fwd_top_stats_border);
-	printf("  RX-packets: %-14u TX-packets: %-14u TX-dropped: %-14u",
+	printf("  RX-packets: %-14"PRIu64" TX-packets: %-14"PRIu64
+	       " TX-dropped: %-14"PRIu64,
 	       fs->rx_packets, fs->tx_packets, fs->fwd_dropped);
 
 	/* if checksum mode */
 	if (cur_fwd_eng == &csum_fwd_engine) {
-	       printf("  RX- bad IP checksum: %-14u  Rx- bad L4 checksum: "
-			"%-14u Rx- bad outer L4 checksum: %-14u\n",
+		printf("  RX- bad IP checksum: %-14"PRIu64
+		       "  Rx- bad L4 checksum: %-14"PRIu64
+		       " Rx- bad outer L4 checksum: %-14"PRIu64"\n",
 			fs->rx_bad_ip_csum, fs->rx_bad_l4_csum,
 			fs->rx_bad_outer_l4_csum);
 	} else {
@@ -1745,9 +1747,6 @@ struct extmem_param {
 	uint64_t total_rx_dropped;
 	uint64_t total_tx_dropped;
 	uint64_t total_rx_nombuf;
-	uint64_t tx_dropped;
-	uint64_t rx_bad_ip_csum;
-	uint64_t rx_bad_l4_csum;
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t fwd_cycles;
 #endif
@@ -1774,38 +1773,22 @@ struct extmem_param {
 	fwd_cycles = 0;
 #endif
 	for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
+		struct fwd_stream *fs = fwd_streams[sm_id];
+
 		if (cur_fwd_config.nb_fwd_streams >
 		    cur_fwd_config.nb_fwd_ports) {
 			fwd_stream_stats_display(sm_id);
-			ports[fwd_streams[sm_id]->tx_port].tx_stream = NULL;
-			ports[fwd_streams[sm_id]->rx_port].rx_stream = NULL;
+			ports[fs->tx_port].tx_stream = NULL;
+			ports[fs->rx_port].rx_stream = NULL;
 		} else {
-			ports[fwd_streams[sm_id]->tx_port].tx_stream =
-				fwd_streams[sm_id];
-			ports[fwd_streams[sm_id]->rx_port].rx_stream =
-				fwd_streams[sm_id];
-		}
-		tx_dropped = ports[fwd_streams[sm_id]->tx_port].tx_dropped;
-		tx_dropped = (uint64_t) (tx_dropped +
-					 fwd_streams[sm_id]->fwd_dropped);
-		ports[fwd_streams[sm_id]->tx_port].tx_dropped = tx_dropped;
-
-		rx_bad_ip_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum;
-		rx_bad_ip_csum = (uint64_t) (rx_bad_ip_csum +
-					 fwd_streams[sm_id]->rx_bad_ip_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum =
-							rx_bad_ip_csum;
-
-		rx_bad_l4_csum =
-			ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum;
-		rx_bad_l4_csum = (uint64_t) (rx_bad_l4_csum +
-					 fwd_streams[sm_id]->rx_bad_l4_csum);
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum =
-							rx_bad_l4_csum;
-
-		ports[fwd_streams[sm_id]->rx_port].rx_bad_outer_l4_csum +=
-				fwd_streams[sm_id]->rx_bad_outer_l4_csum;
+			ports[fs->tx_port].tx_stream = fs;
+			ports[fs->rx_port].rx_stream = fs;
+		}
+		ports[fs->tx_port].tx_dropped += fs->fwd_dropped;
+		ports[fs->rx_port].rx_bad_ip_csum += fs->rx_bad_ip_csum;
+		ports[fs->rx_port].rx_bad_l4_csum += fs->rx_bad_l4_csum;
+		ports[fs->rx_port].rx_bad_outer_l4_csum +=
+				fs->rx_bad_outer_l4_csum;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 		fwd_cycles = (uint64_t) (fwd_cycles +
app/test-pmd/testpmd.h +6 -6
index 85b791b..4f4a48f 100644
@@ -119,12 +119,12 @@ struct fwd_stream {
 	unsigned int retry_enabled;
 
 	/* "read-write" results */
-	unsigned int rx_packets;  /**< received packets */
-	unsigned int tx_packets;  /**< received packets transmitted */
-	unsigned int fwd_dropped; /**< received packets not forwarded */
-	unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */
-	unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
-	unsigned int rx_bad_outer_l4_csum;
+	uint64_t rx_packets;  /**< received packets */
+	uint64_t tx_packets;  /**< received packets transmitted */
+	uint64_t fwd_dropped; /**< received packets not forwarded */
+	uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
+	uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
+	uint64_t rx_bad_outer_l4_csum;
 	/**< received packets has bad outer l4 checksum */
 	unsigned int gro_times;	/**< GRO operation times */
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
Signature · 1 line
1.8.3.1
#69 lore raw

PATCH v5 3/4 app/testpmd: remove useless casts on statistics

In reply to David Marchand

Caught by code review while investigating the fwd stats display code.

Fixes af75078fece3 ("first public release")

---
Changelog since v2:
- focused on useless casts only
- Cc'd stable

---
 app/test-pmd/testpmd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/testpmd.c +4 -4
index 05a3dce..c78d524 100644
@@ -1376,7 +1376,7 @@ struct extmem_param {
 		printf("  RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: "
 		       "%-"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64"Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1390,13 +1390,13 @@ struct extmem_param {
 		printf("  TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: "
 		       "%-"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 	else {
 		printf("  RX-packets:             %14"PRIu64"    RX-dropped:%14"PRIu64"    RX-total:"
 		       "%14"PRIu64"\n",
 		       stats->ipackets, stats->imissed,
-		       (uint64_t) (stats->ipackets + stats->imissed));
+		       stats->ipackets + stats->imissed);
 
 		if (cur_fwd_eng == &csum_fwd_engine)
 			printf("  Bad-ipcsum:%14"PRIu64"    Bad-l4csum:%14"PRIu64"    Bad-outer-l4csum: %-14"PRIu64"\n",
@@ -1411,7 +1411,7 @@ struct extmem_param {
 		printf("  TX-packets:             %14"PRIu64"    TX-dropped:%14"PRIu64"    TX-total:"
 		       "%14"PRIu64"\n",
 		       stats->opackets, port->tx_dropped,
-		       (uint64_t) (stats->opackets + port->tx_dropped));
+		       stats->opackets + port->tx_dropped);
 	}
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
Signature · 1 line
1.8.3.1
#70 lore raw

PATCH v5 4/4 app/testpmd: display/clear forwarding stats on demand

In reply to David Marchand

Add a new "show/clear fwd stats all" command to display fwd and port statistics on the fly.

To be able to do so, the (testpmd only) rte_port structure can't be used to maintain any statistics.
Moved the stats dump parts from stop_packet_forwarding() and merge with fwd_port_stats_display() into fwd_stats_display().
fwd engine statistics are then aggregated into a local per port array.

---
Changelog since v3:
- added description in testpmd usage
- renamed cmd_fwdall as cmd_showfwdall

Changelog since v1:
- removed hunk from now deleted patch 3

---
 app/test-pmd/cmdline.c                      |  49 ++++
 app/test-pmd/testpmd.c                      | 425 +++++++++++++++-------------
 app/test-pmd/testpmd.h                      |   9 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 +++
 4 files changed, 310 insertions(+), 209 deletions(-)
app/test-pmd/cmdline.c +49 -0
index 815e5e8..ee50e45 100644
@@ -225,6 +225,11 @@ static void cmd_help_long_parsed(void *parsed_result,
                         "show port tm node stats (port_id) (node_id) (clear)\n"
                         "       Display the port TM node stats.\n\n"
 
+			"show fwd stats all\n"
+			"    Display statistics for all fwd engines.\n\n"
+
+			"clear fwd stats all\n"
+			"    Clear statistics for all fwd engines.\n\n"
 		);
 	}
 
@@ -7386,6 +7391,49 @@ struct cmd_showqueue_result {
 	},
 };
 
+/* show/clear fwd engine statistics */
+struct fwd_result {
+	cmdline_fixed_string_t action;
+	cmdline_fixed_string_t fwd;
+	cmdline_fixed_string_t stats;
+	cmdline_fixed_string_t all;
+};
+
+cmdline_parse_token_string_t cmd_fwd_action =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
+cmdline_parse_token_string_t cmd_fwd_fwd =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
+cmdline_parse_token_string_t cmd_fwd_stats =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
+cmdline_parse_token_string_t cmd_fwd_all =
+	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
+
+static void
+cmd_showfwdall_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct fwd_result *res = parsed_result;
+
+	if (!strcmp(res->action, "show"))
+		fwd_stats_display();
+	else
+		fwd_stats_reset();
+}
+
+static cmdline_parse_inst_t cmd_showfwdall = {
+	.f = cmd_showfwdall_parsed,
+	.data = NULL,
+	.help_str = "show|clear fwd stats all",
+	.tokens = {
+		(void *)&cmd_fwd_action,
+		(void *)&cmd_fwd_fwd,
+		(void *)&cmd_fwd_stats,
+		(void *)&cmd_fwd_all,
+		NULL,
+	},
+};
+
 /* *** READ PORT REGISTER *** */
 struct cmd_read_reg_result {
 	cmdline_fixed_string_t read;
@@ -18559,6 +18607,7 @@ struct cmd_show_tx_metadata_result {
 	(cmdline_parse_inst_t *)&cmd_showqueue,
 	(cmdline_parse_inst_t *)&cmd_showportall,
 	(cmdline_parse_inst_t *)&cmd_showcfg,
+	(cmdline_parse_inst_t *)&cmd_showfwdall,
 	(cmdline_parse_inst_t *)&cmd_start,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
app/test-pmd/testpmd.c +223 -202

469 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -7
index 4f4a48f..f43b1a7 100644
@@ -164,19 +164,12 @@ struct rte_port {
 	struct rte_eth_conf     dev_conf;   /**< Port configuration. */
 	struct ether_addr       eth_addr;   /**< Port ethernet address */
 	struct rte_eth_stats    stats;      /**< Last port statistics */
-	uint64_t                tx_dropped; /**< If no descriptor in TX ring */
-	struct fwd_stream       *rx_stream; /**< Port RX stream, if unique */
-	struct fwd_stream       *tx_stream; /**< Port TX stream, if unique */
 	unsigned int            socket_id;  /**< For NUMA support */
 	uint16_t		parse_tunnel:1; /**< Parse internal headers */
 	uint16_t                tso_segsz;  /**< Segmentation offload MSS for non-tunneled packets. */
 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
 	uint16_t                tx_vlan_id;/**< The tag ID */
 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
-	uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
-	uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
-	uint64_t                rx_bad_outer_l4_csum;
-	/**< rx pkts with bad outer l4 checksum */
 	uint8_t                 tx_queue_stats_mapping_enabled;
 	uint8_t                 rx_queue_stats_mapping_enabled;
 	volatile uint16_t        port_status;    /**< port started or not */
@@ -767,6 +760,8 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 char *list_pkt_forwarding_retry_modes(void);
 void set_pkt_forwarding_mode(const char *fwd_mode);
 void start_packet_forwarding(int with_tx_first);
+void fwd_stats_display(void);
+void fwd_stats_reset(void);
 void stop_packet_forwarding(void);
 void dev_set_link_up(portid_t pid);
 void dev_set_link_down(portid_t pid);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +36 -0
index 1a12da4..06c8b2a 100644
@@ -336,6 +336,42 @@ Example::
    Set rxonly packet forwarding mode
 
 
+show fwd
+~~~~~~~~
+
+When running, forwarding engines maintain statistics from the time they have been started.
+Example for the io forwarding engine, with some packet drops on the tx side::
+
+   testpmd> show fwd stats all
+
+     ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
+     RX-packets: 274293770      TX-packets: 274293642      TX-dropped: 128
+
+     ------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
+     RX-packets: 274301850      TX-packets: 274301850      TX-dropped: 0
+
+     ---------------------- Forward statistics for port 0  ----------------------
+     RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
+     TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862
+     ----------------------------------------------------------------------------
+
+     ---------------------- Forward statistics for port 1  ----------------------
+     RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
+     TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834
+     ----------------------------------------------------------------------------
+
+     +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
+     RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
+     TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696
+     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+clear fwd
+~~~~~~~~~
+
+Clear the forwarding engines statistics::
+
+   testpmd> clear fwd stats all
+
 read rxd
 ~~~~~~~~
 
Signature · 1 line
1.8.3.1
Reviewed-by on the v5 series
#71 lore raw
In reply to David Marchand
Quoted 44 lines · David Marchand

Here is a little series that makes it possible to display and clear testpmd fwd engines while they run without having to stop them. This is mostly handy when running stress tests and you look for packets drops without having to stop/start testpmd forwarding.

Example:

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 261977064 TX-packets: 261977064 TX-dropped: 0

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 261985142 TX-packets: 261985142 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 261977096      RX-dropped: 0             RX-total: 261977096
  TX-packets: 261985155      TX-dropped: 0             TX-total: 261985155

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

  RX-packets: 261985188      RX-dropped: 0             RX-total: 261985188
  TX-packets: 261977128      TX-dropped: 0             TX-total: 261977128

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 523962284      RX-dropped: 0             RX-total: 523962284
  TX-packets: 523962283      TX-dropped: 0             TX-total: 523962283

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

testpmd> show fwd stats all

------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
RX-packets: 274293770 TX-packets: 274293642 TX-dropped: 128

------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
RX-packets: 274301850 TX-packets: 274301850 TX-dropped: 0

---------------------- Forward statistics for port 0 ----------------------

  RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
  TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862

----------------------------------------------------------------------------

---------------------- Forward statistics for port 1 ----------------------

Quoted 9 lines
  RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
  TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834

----------------------------------------------------------------------------

+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++

  RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
  TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

For series,

Series applied to dpdk-next-net/master, thanks.