Skip to contentSkip to conversation

net/i40e: fix Rx statistic inconsistent

PATCH Superseded Wei Zhao1 3 participants 8 messages Jul 29, 2016 – Aug 22, 2016 Network drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wei Zhao1

author
#0 lore raw

PATCH v2 1/1 net/i40e: fix Rx statistic inconsistent

rx_good_bytes and rx_good_packets statistic is inconsistent when port stopped,ipackets statistic is minus the discard packets but rx_bytes statistic not.Also,i40e has no statistic of discard bytes, so we have to delete discard packets item from rx_good_packets statistic.

Fixes 9aace75fc82e ("i40e: fix statistics")
---
 drivers/net/i40e/i40e_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +1 -2
index 11a5804..553dfd9 100644
@@ -2319,8 +2319,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
 	stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
 			pf->main_vsi->eth_stats.rx_multicast +
-			pf->main_vsi->eth_stats.rx_broadcast -
-			pf->main_vsi->eth_stats.rx_discards;
+			pf->main_vsi->eth_stats.rx_broadcast;
 	stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
 			pf->main_vsi->eth_stats.tx_multicast +
 			pf->main_vsi->eth_stats.tx_broadcast;
Signature · 1 line
2.5.5
#1 lore raw
Quoted 27 lines · On Fri, Jul 29, 2016 at 4:50 AM, Wei Zhao1 <[email protected]> wrote:

rx_good_bytes and rx_good_packets statistic is inconsistent when port stopped,ipackets statistic is minus the discard packets but rx_bytes statistic not.Also,i40e has no statistic of discard bytes, so we have to delete discard packets item from rx_good_packets statistic.

Fixes 9aace75fc82e ("i40e: fix statistics")
---
 drivers/net/i40e/i40e_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +1 -3
index 11a5804..553dfd9 100644
@@ -2319,8 +2319,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
        stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
                        pf->main_vsi->eth_stats.rx_multicast +
-                       pf->main_vsi->eth_stats.rx_broadcast -
-                       pf->main_vsi->eth_stats.rx_discards;
+                       pf->main_vsi->eth_stats.rx_broadcast;
        stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
                        pf->main_vsi->eth_stats.tx_multicast +
                        pf->main_vsi->eth_stats.tx_broadcast;
--
Quoted 2 lines

2.5.5

Is it not worse to report a received packet when no packet was actually received by the upper layers under normal operations than to ensure that packets and bytes are consistent when an interface is stopped? It seems like the first case is much more likely to occur than the second.

Are we just introducing a new issue to fix another?

How does this behaviour compare to other NICs? Does the ixgbe report discarded packets in its ipackets? My reading of the driver is that it does not. In fact, it does something interesting to deal with the problem:

from: http://dpdk.org/browse/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c

/*
* An errata states that gprc actually counts good + missed packets:
* Workaround to set gprc to summated queue packet receives */
hw_stats->gprc = *total_qprc;

total_gprc is equal to the sum of the qprc per queue. Can we do something similar on the i40e instead of adding unicast, mulitcast and broadcast?

author
#2 lore raw

Hi, Kyle Larose
The core problem is i40e has no statistic of discard bytes, that means even if when ports are not stopped, the
statistic rx_good_bytes is consist of discard bytes,is that reasonable? In other words, I can just minus discard bytes from rx_good_bytes if I can get discard bytes number, that is much better.

-----Original Message-----
From: Kyle Larose [mailto:[email protected]]
Sent: Saturday, July 30, 2016 1:17 AM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Quoted 27 lines · On Fri, Jul 29, 2016 at 4:50 AM, Wei Zhao1 <[email protected]> wrote:

rx_good_bytes and rx_good_packets statistic is inconsistent when port stopped,ipackets statistic is minus the discard packets but rx_bytes statistic not.Also,i40e has no statistic of discard bytes, so we have to delete discard packets item from rx_good_packets statistic.

Fixes 9aace75fc82e ("i40e: fix statistics")
---
 drivers/net/i40e/i40e_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_ethdev.c index 11a5804..553dfd9 100644

drivers/net/i40e/i40e_ethdev.c +1 -2
@@ -2319,8 +2319,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, 
 struct rte_eth_stats *stats)
 
        stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
                        pf->main_vsi->eth_stats.rx_multicast +
-                       pf->main_vsi->eth_stats.rx_broadcast -
-                       pf->main_vsi->eth_stats.rx_discards;
+                       pf->main_vsi->eth_stats.rx_broadcast;
        stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
                        pf->main_vsi->eth_stats.tx_multicast +
                        pf->main_vsi->eth_stats.tx_broadcast;
Quoted 3 lines

--
2.5.5

Is it not worse to report a received packet when no packet was actually received by the upper layers under normal operations than to ensure that packets and bytes are consistent when an interface is stopped? It seems like the first case is much more likely to occur than the second.

Are we just introducing a new issue to fix another?

How does this behaviour compare to other NICs? Does the ixgbe report discarded packets in its ipackets? My reading of the driver is that it does not. In fact, it does something interesting to deal with the problem:

from: http://dpdk.org/browse/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c

/*
* An errata states that gprc actually counts good + missed packets:
* Workaround to set gprc to summated queue packet receives */ hw_stats->gprc = *total_qprc;

total_gprc is equal to the sum of the qprc per queue. Can we do something similar on the i40e instead of adding unicast, mulitcast and broadcast?

author
#3 lore raw
In reply to Kyle Larose

Hi,Wu jingjing and wenzhuo

Quoted 66 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Monday, August 1, 2016 4:58 PM
To: 'Kyle Larose' <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Hi, Kyle Larose
The core problem is i40e has no statistic of discard bytes, that means even if
when ports are not stopped, the statistic rx_good_bytes is consist of discard bytes,is that reasonable? In other words, I can just minus discard bytes from rx_good_bytes if I can get discard bytes number, that is much better.

-----Original Message-----
From: Kyle Larose [mailto:[email protected]]
Sent: Saturday, July 30, 2016 1:17 AM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Quoted 27 lines · On Fri, Jul 29, 2016 at 4:50 AM, Wei Zhao1 <[email protected]> wrote:

rx_good_bytes and rx_good_packets statistic is inconsistent when port stopped,ipackets statistic is minus the discard packets but rx_bytes statistic not.Also,i40e has no statistic of discard bytes, so we have to delete discard packets item from rx_good_packets statistic.

Fixes 9aace75fc82e ("i40e: fix statistics")
---
 drivers/net/i40e/i40e_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_ethdev.c index 11a5804..553dfd9 100644

drivers/net/i40e/i40e_ethdev.c +1 -2
@@ -2319,8 +2319,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev,
 struct rte_eth_stats *stats)
 
        stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
                        pf->main_vsi->eth_stats.rx_multicast +
-                       pf->main_vsi->eth_stats.rx_broadcast -
-                       pf->main_vsi->eth_stats.rx_discards;
+                       pf->main_vsi->eth_stats.rx_broadcast;
        stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
                        pf->main_vsi->eth_stats.tx_multicast +
                        pf->main_vsi->eth_stats.tx_broadcast;
Quoted 3 lines

--
2.5.5

Is it not worse to report a received packet when no packet was actually received by the upper layers under normal operations than to ensure that packets and bytes are consistent when an interface is stopped? It seems like the first case is much more likely to occur than the second.

Are we just introducing a new issue to fix another?

How does this behaviour compare to other NICs? Does the ixgbe report discarded packets in its ipackets? My reading of the driver is that it does not. In fact, it does something interesting to deal with the
problem:

from: http://dpdk.org/browse/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c

Quoted 7 lines

/*
* An errata states that gprc actually counts good + missed packets:
* Workaround to set gprc to summated queue packet receives */ hw_stats-

Quoted 1 line

gprc = *total_qprc;

total_gprc is equal to the sum of the qprc per queue. Can we do something similar on the i40e instead of adding unicast, mulitcast and broadcast?

I have checked ixgbe code about Rx statistic, in function ixgbe_read_stats_registers() we can find the rx_good_bytes and rx_good_packets statistic. It is listed below, we can see rx_good_packets is also just addition of Queue Packets Received Count and not minused discard packet number. Is there some wrong of understanding?

for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++)
{
......

                                 *total_qprc += hw_stats->qprc[i];
		*total_qbrc += hw_stats->qbrc[i];

......
}

author
#4 lore raw

Hi, Wujingjing and Kyle Larose

Quoted 100 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Tuesday, August 2, 2016 11:27 AM
To: Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Hi,Wu jingjing and wenzhuo

Quoted 8 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Monday, August 1, 2016 4:58 PM
To: 'Kyle Larose' <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Quoted 6 lines

Hi, Kyle Larose
The core problem is i40e has no statistic of discard bytes, that
means even if when ports are not stopped, the statistic rx_good_bytes is consist of discard
bytes,is that reasonable? In other words, I can just minus discard bytes from rx_good_bytes if I can get discard bytes number, that is much

better.

Quoted 29 lines

-----Original Message-----
From: Kyle Larose [mailto:[email protected]]
Sent: Saturday, July 30, 2016 1:17 AM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Quoted 19 lines · On Fri, Jul 29, 2016 at 4:50 AM, Wei Zhao1 <[email protected]> wrote:

rx_good_bytes and rx_good_packets statistic is inconsistent when port stopped,ipackets statistic is minus the discard packets but rx_bytes statistic not.Also,i40e has no statistic of discard bytes, so we have to delete discard packets item from rx_good_packets statistic.

Fixes 9aace75fc82e ("i40e: fix statistics")
---
 drivers/net/i40e/i40e_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_ethdev.c index 11a5804..553dfd9 100644

drivers/net/i40e/i40e_ethdev.c +0 -0
@@ -2319,8 +2319,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev,
 struct rte_eth_stats *stats)
 
Quoted 16 lines
Quoted 11 lines
drivers/net/i40e/i40e_ethdev.c +1 -2
        stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
                        pf->main_vsi->eth_stats.rx_multicast +
-                       pf->main_vsi->eth_stats.rx_broadcast -
-                       pf->main_vsi->eth_stats.rx_discards;
+                       pf->main_vsi->eth_stats.rx_broadcast;
        stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
                        pf->main_vsi->eth_stats.tx_multicast +
                        pf->main_vsi->eth_stats.tx_broadcast;

--
2.5.5

Is it not worse to report a received packet when no packet was actually received by the upper layers under normal operations than to ensure that packets and bytes are consistent when an interface is stopped? It seems like the first case is much more likely to occur than the

second.

Quoted 11 lines

Are we just introducing a new issue to fix another?

How does this behaviour compare to other NICs? Does the ixgbe report discarded packets in its ipackets? My reading of the driver is that it does not. In fact, it does something interesting to deal with the
problem:

from:
http://dpdk.org/browse/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c

Quoted 8 lines

/*
* An errata states that gprc actually counts good + missed packets:
* Workaround to set gprc to summated queue packet receives */ hw_stats-

Quoted 1 line

gprc = *total_qprc;

total_gprc is equal to the sum of the qprc per queue. Can we do something similar on the i40e instead of adding unicast, mulitcast and

broadcast?

I have checked ixgbe code about Rx statistic, in function ixgbe_read_stats_registers() we can find the rx_good_bytes and rx_good_packets statistic.
It is listed below, we can see rx_good_packets is also just addition of Queue Packets Received Count and not minused discard packet number. Is there some wrong of understanding?

Quoted 6 lines

for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
......

                                 *total_qprc += hw_stats->qprc[i];
		*total_qbrc += hw_stats->qbrc[i];

......
}

The problem is i40e has no statistic of discard bytes, so it is impossible to minus discard bytes from rx_good_bytes . If you think it's not reasonable to
Delete rx_discards iterm from rx_good_packets statistic, this patch will be superseded. Because I didn't find other way to correct this problem at present.

#5 lore raw

Hello Wei,

Quoted 103 lines · Wei

Hi, Wujingjing and Kyle Larose

Quoted 99 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Tuesday, August 2, 2016 11:27 AM
To: Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Hi,Wu jingjing and wenzhuo

Quoted 8 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Monday, August 1, 2016 4:58 PM
To: 'Kyle Larose' <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Quoted 6 lines

Hi, Kyle Larose
The core problem is i40e has no statistic of discard bytes, that
means even if when ports are not stopped, the statistic rx_good_bytes is consist of discard
bytes,is that reasonable? In other words, I can just minus discard bytes from rx_good_bytes if I can get discard bytes number, that is much

better.

Quoted 29 lines

-----Original Message-----
From: Kyle Larose [mailto:[email protected]]
Sent: Saturday, July 30, 2016 1:17 AM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Quoted 19 lines · On Fri, Jul 29, 2016 at 4:50 AM, Wei Zhao1 <[email protected]> wrote:

rx_good_bytes and rx_good_packets statistic is inconsistent when port stopped,ipackets statistic is minus the discard packets but rx_bytes statistic not.Also,i40e has no statistic of discard bytes, so we have to delete discard packets item from rx_good_packets statistic.

Fixes 9aace75fc82e ("i40e: fix statistics")
---
 drivers/net/i40e/i40e_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_ethdev.c index 11a5804..553dfd9 100644

drivers/net/i40e/i40e_ethdev.c +0 -0
@@ -2319,8 +2319,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev,
 struct rte_eth_stats *stats)
 
Quoted 16 lines
Quoted 11 lines
drivers/net/i40e/i40e_ethdev.c +1 -2
        stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
                        pf->main_vsi->eth_stats.rx_multicast +
-                       pf->main_vsi->eth_stats.rx_broadcast -
-                       pf->main_vsi->eth_stats.rx_discards;
+                       pf->main_vsi->eth_stats.rx_broadcast;
        stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
                        pf->main_vsi->eth_stats.tx_multicast +
                        pf->main_vsi->eth_stats.tx_broadcast;

--
2.5.5

Is it not worse to report a received packet when no packet was actually received by the upper layers under normal operations than to ensure that packets and bytes are consistent when an interface is stopped? It seems like the first case is much more likely to occur than the

second.

Quoted 11 lines

Are we just introducing a new issue to fix another?

How does this behaviour compare to other NICs? Does the ixgbe report discarded packets in its ipackets? My reading of the driver is that it does not. In fact, it does something interesting to deal with the
problem:

from:
http://dpdk.org/browse/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c

Quoted 8 lines

/*
* An errata states that gprc actually counts good + missed packets:
* Workaround to set gprc to summated queue packet receives */ hw_stats-

Quoted 1 line

gprc = *total_qprc;

total_gprc is equal to the sum of the qprc per queue. Can we do something similar on the i40e instead of adding unicast, mulitcast and

broadcast?

I have checked ixgbe code about Rx statistic, in function ixgbe_read_stats_registers() we can find the rx_good_bytes and rx_good_packets statistic.
It is listed below, we can see rx_good_packets is also just addition of Queue Packets Received Count and not minused discard packet number. Is there some wrong of understanding?

My understanding of the problem can be broken into three parts:
1) In Unicast/Multicast/Broadcast packet counters are counting
packets which were discarded
2) The corresponding byte counters count packets which were discarded.
3) There are no discarded byte counters.

Our in bytes counter consists of the sum of in unicast, in multicast, and in broadcast. This sum includes discarded bytes, which we do not want, for two reasons. First, it would lead to misleading bitrate
reports: people expect to see the amount of traffic actually handled. Second, it conflicts with the current packet counters (the counters without your change).

Obviously if we could count the discarded bytes, we could subtract them. Alternatively, if we could count only received bytes which were not discarded, then we would not need to subtract discarded bytes from the received bytes counter. The ixgbe had a similar problem for packets, but presumably not bytes. So, I looked to it for inspiration.

Presumably, the ixgbe per-queue counters count all received packets, per queue, and do not count discarded packets.Thus, is you take the sum of received packets across all queues, you can find the total number of received packets without discards included.

Can we not do the same thing on the i40e, but for bytes? I just took a quick look at the datasheet, and I cannot see anything offhand that is equivalent to qbrc, which is what I would have used here. That said, I'm not an i40e expert, so I may have missed something. That's why I'm asking if it's possible. :)

Quoted 11 lines
Quoted 7 lines

for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
......

                                 *total_qprc += hw_stats->qprc[i];
              *total_qbrc += hw_stats->qbrc[i];

......
}

The problem is i40e has no statistic of discard bytes, so it is impossible to minus discard bytes from rx_good_bytes . If you think it's not reasonable to
Delete rx_discards iterm from rx_good_packets statistic, this patch will be superseded. Because I didn't find other way to correct this problem at present.

I understand that there is no discard byte counter. Are there per-queue byte counters on the i40e, which do not count discarded byte, with which we could do a similar thing as the packet counters on the ixgbe?

My concern is that both solutions aside from that are not good: either we count less packets received than bytes received, or we count discarded packets as received packets. Is there any chance that a firmware update in the future could fix this? This sort of inconsistency, or inability to provide *good* stats, really sucks for a NIC.

Thanks,

Kyle

author
#6 lore raw

Hi ,Kyle Larose&Jingjing

Quoted 180 lines

-----Original Message-----
From: Kyle Larose [mailto:[email protected]]
Sent: Wednesday, August 3, 2016 12:22 AM
To: Zhao1, Wei <[email protected]>
Cc: Wu, Jingjing <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Hello Wei,

Quoted 41 lines · Wei

Hi, Wujingjing and Kyle Larose

Quoted 37 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Tuesday, August 2, 2016 11:27 AM
To: Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Hi,Wu jingjing and wenzhuo

Quoted 8 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Monday, August 1, 2016 4:58 PM
To: 'Kyle Larose' <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

Quoted 7 lines

Hi, Kyle Larose
The core problem is i40e has no statistic of discard bytes, that
means even if when ports are not stopped, the statistic rx_good_bytes is consist of discard
bytes,is that reasonable? In other words, I can just minus discard bytes from rx_good_bytes if I can get discard bytes number, that is much

better.

Quoted 10 lines

-----Original Message-----
From: Kyle Larose [mailto:[email protected]]
Sent: Saturday, July 30, 2016 1:17 AM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix Rx statistic inconsistent

On Fri, Jul 29, 2016 at 4:50 AM, Wei Zhao1 <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

rx_good_bytes and rx_good_packets statistic is inconsistent when port stopped,ipackets statistic is minus the discard packets but rx_bytes statistic not.Also,i40e has no statistic of discard bytes, so we have to delete discard packets item from

rx_good_packets statistic.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Fixes 9aace75fc82e ("i40e: fix statistics")
---
 drivers/net/i40e/i40e_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/net/i40e/i40e_ethdev.c i40e_dev_stats_get(struct rte_eth_dev

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_ethdev.c index 11a5804..553dfd9 100644

drivers/net/i40e/i40e_ethdev.c +0 -0
@@ -2319,8 +2319,7 @@ i40e_dev_stats_get(struct rte_eth_dev

*dev,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +1 -2
 struct rte_eth_stats *stats)
 
        stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
                        pf->main_vsi->eth_stats.rx_multicast +
-                       pf->main_vsi->eth_stats.rx_broadcast -
-                       pf->main_vsi->eth_stats.rx_discards;
+                       pf->main_vsi->eth_stats.rx_broadcast;
        stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
                        pf->main_vsi->eth_stats.tx_multicast +
                        pf->main_vsi->eth_stats.tx_broadcast;
Quoted 3 lines

--
2.5.5

Is it not worse to report a received packet when no packet was actually received by the upper layers under normal operations than to ensure that packets and bytes are consistent when an interface is stopped? It seems like the first case is much more likely to occur than the

Quoted 6 lines
Quoted 6 lines

second.

Quoted 5 lines

Are we just introducing a new issue to fix another?

How does this behaviour compare to other NICs? Does the ixgbe report discarded packets in its ipackets? My reading of the driver is that

it does not.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

In fact, it does something interesting to deal with the problem:

from:
http://dpdk.org/browse/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c

/*
* An errata states that gprc actually counts good + missed packets:
* Workaround to set gprc to summated queue packet receives */ hw_stats-

Quoted 1 line

gprc = *total_qprc;

total_gprc is equal to the sum of the qprc per queue. Can we do something similar on the i40e instead of adding unicast, mulitcast and

Quoted 8 lines
Quoted 8 lines

broadcast?

I have checked ixgbe code about Rx statistic, in function ixgbe_read_stats_registers() we can find the rx_good_bytes and rx_good_packets statistic.
It is listed below, we can see rx_good_packets is also just addition of Queue Packets Received Count and not minused discard packet

number.

Quoted 1 line
Quoted 1 line

Is there some wrong of understanding?

My understanding of the problem can be broken into three parts:
1) In Unicast/Multicast/Broadcast packet counters are counting packets
which were discarded
2) The corresponding byte counters count packets which were discarded.
3) There are no discarded byte counters.

Our in bytes counter consists of the sum of in unicast, in multicast, and in broadcast. This sum includes discarded bytes, which we do not want, for two reasons. First, it would lead to misleading bitrate
reports: people expect to see the amount of traffic actually handled. Second, it conflicts with the current packet counters (the counters without your change).

Obviously if we could count the discarded bytes, we could subtract them. Alternatively, if we could count only received bytes which were not discarded, then we would not need to subtract discarded bytes from the received bytes counter. The ixgbe had a similar problem for packets, but presumably not bytes. So, I looked to it for inspiration.

Presumably, the ixgbe per-queue counters count all received packets, per queue, and do not count discarded packets.Thus, is you take the sum of received packets across all queues, you can find the total number of received packets without discards included.

Can we not do the same thing on the i40e, but for bytes? I just took a quick look at the datasheet, and I cannot see anything offhand that is equivalent to qbrc, which is what I would have used here. That said, I'm not an i40e expert, so I may have missed something. That's why I'm asking if it's possible. :)

Quoted 8 lines
Quoted 5 lines

for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) { ......

                                 *total_qprc += hw_stats->qprc[i];
              *total_qbrc += hw_stats->qbrc[i]; ......
}

The problem is i40e has no statistic of discard bytes, so it is
impossible to minus discard bytes from rx_good_bytes . If you think it's not

reasonable to Delete rx_discards iterm from rx_good_packets statistic, this patch will be superseded. Because I didn't find other way to correct this problem at present.

Quoted 1 line

I understand that there is no discard byte counter. Are there per-queue byte counters on the i40e, which do not count discarded byte, with which we could do a similar thing as the packet counters on the ixgbe?

My concern is that both solutions aside from that are not good: either we count less packets received than bytes received, or we count discarded packets as received packets. Is there any chance that a firmware update in the future could fix this? This sort of inconsistency, or inability to provide *good* stats, really sucks for a NIC.

Quoted 3 lines

Thanks,

Kyle

According to your suggestion and meeting last week with harry ,I have supply a v3 patch for this problem. [dpdk-dev,v3] net/i40e: fix Rx statistic inconsistent , Permalink :/dev/patchwork/patch/15161/. This fix is avoiding statistic work when port is stopped.

#7 lore raw

Hi,

2016-08-09 02:18, Zhao1, Wei:

Quoted 2 lines

According to your suggestion and meeting last week with harry ,I have supply a v3 patch for this problem. [dpdk-dev,v3] net/i40e: fix Rx statistic inconsistent , Permalink :/dev/patchwork/patch/15161/.

Please use --in-reply-to to send new version of a patch. Thanks