[RFC,1/2] ethdev: move queue stats to xstats
diff mbox series

Message ID 20201012164602.1965694-1-ferruh.yigit@intel.com
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series
  • [RFC,1/2] ethdev: move queue stats to xstats
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit Oct. 12, 2020, 4:46 p.m. UTC
Queue stats are stored in 'struct rte_eth_stats' as array and array size
is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.

As a result of technical board discussion, decided to remove the queue
statistics from 'struct rte_eth_stats' in the long term.

Instead PMDs should represent the queue statistics via xstats, this
gives more flexibility on the number of the queues supported.

Currently queue stats in the xstats are filled by ethdev layer, using
the basic stats, when queue stats removed from basic stats the
responsibility to fill the relevant xstats will be pushed to the PMDs.

During the switch period, a temporary
'RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS' device flag is created. The PMDs
providing the queue stats in the xstats should set this flag to bypass
the relevant part in ethdev layer.

When all PMDs switch to the xstats for the queue stats, queue stats
related fields from 'struct rte_eth_stats' will be removed, as well as
'RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS' flag.
Later 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag also can be
removed.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_ethdev/rte_ethdev.c | 19 +++++++++++++++----
 lib/librte_ethdev/rte_ethdev.h |  2 ++
 2 files changed, 17 insertions(+), 4 deletions(-)

Comments

Thomas Monjalon Oct. 12, 2020, 9:53 p.m. UTC | #1
12/10/2020 18:46, Ferruh Yigit:
> Queue stats are stored in 'struct rte_eth_stats' as array and array size
> is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.
> 
> As a result of technical board discussion, decided to remove the queue
> statistics from 'struct rte_eth_stats' in the long term.
> 
> Instead PMDs should represent the queue statistics via xstats, this
> gives more flexibility on the number of the queues supported.

Yes

> Currently queue stats in the xstats are filled by ethdev layer, using

"some basic" queue stats

> the basic stats, when queue stats removed from basic stats the
> responsibility to fill the relevant xstats will be pushed to the PMDs.
> 
> During the switch period, a temporary
> 'RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS' device flag is created. The PMDs
> providing the queue stats in the xstats should set this flag to bypass
> the relevant part in ethdev layer.
> 
> When all PMDs switch to the xstats for the queue stats, queue stats
> related fields from 'struct rte_eth_stats' will be removed, as well as
> 'RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS' flag.
> Later 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag also can be
> removed.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> --- a/lib/librte_ethdev/rte_ethdev.h
> +++ b/lib/librte_ethdev/rte_ethdev.h
> +/** Device provides queue stats in xstats */
> +#define RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS 0x0040

Not exact wording here and in the title.
We should try to convey the idea that the basic queue stats
are not automatically converted from the array to some xstats.
Something like RTE_ETH_DEV_NO_AUTOFILL_QUEUE_XSTATS

Or we can define the opposite flag and set it by default
in all drivers which fill the basic queue stats.
I suggest RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS
Andrew Rybchenko Oct. 13, 2020, 8:31 a.m. UTC | #2
On 10/13/20 12:53 AM, Thomas Monjalon wrote:
> 12/10/2020 18:46, Ferruh Yigit:
>> Queue stats are stored in 'struct rte_eth_stats' as array and array size
>> is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.
>>
>> As a result of technical board discussion, decided to remove the queue
>> statistics from 'struct rte_eth_stats' in the long term.
>>
>> Instead PMDs should represent the queue statistics via xstats, this
>> gives more flexibility on the number of the queues supported.
> 
> Yes

I like Stephen's idea to have dedicated API to get stats per
queue. Of course it is doable via getting xstats by IDs,
but IMHO it is over-complicated. From the other hand
it sounds like a duplication to have it in xstats and
dedicated API (basically the same as we have for basic
stats and xstats).
Thomas Monjalon Oct. 13, 2020, 9:05 a.m. UTC | #3
13/10/2020 10:31, Andrew Rybchenko:
> On 10/13/20 12:53 AM, Thomas Monjalon wrote:
> > 12/10/2020 18:46, Ferruh Yigit:
> >> Queue stats are stored in 'struct rte_eth_stats' as array and array size
> >> is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.
> >>
> >> As a result of technical board discussion, decided to remove the queue
> >> statistics from 'struct rte_eth_stats' in the long term.
> >>
> >> Instead PMDs should represent the queue statistics via xstats, this
> >> gives more flexibility on the number of the queues supported.
> > 
> > Yes
> 
> I like Stephen's idea to have dedicated API to get stats per
> queue. Of course it is doable via getting xstats by IDs,
> but IMHO it is over-complicated. From the other hand
> it sounds like a duplication to have it in xstats and
> dedicated API (basically the same as we have for basic
> stats and xstats).

Please read my proposal to have fixed ids for common stats
and fixed id ranges for stats per queue:
https://fast.dpdk.org/events/slides/DPDK-2019-09-Ethernet_Statistics.pdf
(slide 11)
Andrew Rybchenko Oct. 13, 2020, 9:16 a.m. UTC | #4
On 10/13/20 12:05 PM, Thomas Monjalon wrote:
> 13/10/2020 10:31, Andrew Rybchenko:
>> On 10/13/20 12:53 AM, Thomas Monjalon wrote:
>>> 12/10/2020 18:46, Ferruh Yigit:
>>>> Queue stats are stored in 'struct rte_eth_stats' as array and array size
>>>> is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.
>>>>
>>>> As a result of technical board discussion, decided to remove the queue
>>>> statistics from 'struct rte_eth_stats' in the long term.
>>>>
>>>> Instead PMDs should represent the queue statistics via xstats, this
>>>> gives more flexibility on the number of the queues supported.
>>>
>>> Yes
>>
>> I like Stephen's idea to have dedicated API to get stats per
>> queue. Of course it is doable via getting xstats by IDs,
>> but IMHO it is over-complicated. From the other hand
>> it sounds like a duplication to have it in xstats and
>> dedicated API (basically the same as we have for basic
>> stats and xstats).
> 
> Please read my proposal to have fixed ids for common stats
> and fixed id ranges for stats per queue:
> https://fast.dpdk.org/events/slides/DPDK-2019-09-Ethernet_Statistics.pdf
> (slide 11)
> 

Ah, yes, I forgot that point. Makes sense and LGTM.
Stephen Hemminger Oct. 13, 2020, 3:04 p.m. UTC | #5
On Tue, 13 Oct 2020 11:05:07 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> 13/10/2020 10:31, Andrew Rybchenko:
> > On 10/13/20 12:53 AM, Thomas Monjalon wrote:  
> > > 12/10/2020 18:46, Ferruh Yigit:  
> > >> Queue stats are stored in 'struct rte_eth_stats' as array and array size
> > >> is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.
> > >>
> > >> As a result of technical board discussion, decided to remove the queue
> > >> statistics from 'struct rte_eth_stats' in the long term.
> > >>
> > >> Instead PMDs should represent the queue statistics via xstats, this
> > >> gives more flexibility on the number of the queues supported.  
> > > 
> > > Yes  
> > 
> > I like Stephen's idea to have dedicated API to get stats per
> > queue. Of course it is doable via getting xstats by IDs,
> > but IMHO it is over-complicated. From the other hand
> > it sounds like a duplication to have it in xstats and
> > dedicated API (basically the same as we have for basic
> > stats and xstats).  
> 
> Please read my proposal to have fixed ids for common stats
> and fixed id ranges for stats per queue:
> https://fast.dpdk.org/events/slides/DPDK-2019-09-Ethernet_Statistics.pdf
> (slide 11)
> 
> 

Looks good. if id's are known than should be possible to go from port/queue to xstats id.

FYI - the inclusion of CRC in counters goes back to a Cisco vs Juniper fight.
Cisco has more people wasting time on standards committees so they always get
their way into the standards bodies.
Ferruh Yigit Oct. 13, 2020, 10:41 p.m. UTC | #6
On 10/13/2020 10:16 AM, Andrew Rybchenko wrote:
> On 10/13/20 12:05 PM, Thomas Monjalon wrote:
>> 13/10/2020 10:31, Andrew Rybchenko:
>>> On 10/13/20 12:53 AM, Thomas Monjalon wrote:
>>>> 12/10/2020 18:46, Ferruh Yigit:
>>>>> Queue stats are stored in 'struct rte_eth_stats' as array and array size
>>>>> is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.
>>>>>
>>>>> As a result of technical board discussion, decided to remove the queue
>>>>> statistics from 'struct rte_eth_stats' in the long term.
>>>>>
>>>>> Instead PMDs should represent the queue statistics via xstats, this
>>>>> gives more flexibility on the number of the queues supported.
>>>>
>>>> Yes
>>>
>>> I like Stephen's idea to have dedicated API to get stats per
>>> queue. Of course it is doable via getting xstats by IDs,
>>> but IMHO it is over-complicated. From the other hand
>>> it sounds like a duplication to have it in xstats and
>>> dedicated API (basically the same as we have for basic
>>> stats and xstats).
>>
>> Please read my proposal to have fixed ids for common stats
>> and fixed id ranges for stats per queue:
>> https://fast.dpdk.org/events/slides/DPDK-2019-09-Ethernet_Statistics.pdf
>> (slide 11)
>>
> 
> Ah, yes, I forgot that point. Makes sense and LGTM.
> 

But we don't have (and not planned for) the fixed id ranges in the xstats yes, 
and agree it will be complicated to parse the queue stats from xstats without it.

Should we wait for the fixed id ranges change before we continue with this patch?
Ferruh Yigit Oct. 13, 2020, 10:53 p.m. UTC | #7
On 10/12/2020 10:53 PM, Thomas Monjalon wrote:
> 12/10/2020 18:46, Ferruh Yigit:
>> Queue stats are stored in 'struct rte_eth_stats' as array and array size
>> is defined by 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag.
>>
>> As a result of technical board discussion, decided to remove the queue
>> statistics from 'struct rte_eth_stats' in the long term.
>>
>> Instead PMDs should represent the queue statistics via xstats, this
>> gives more flexibility on the number of the queues supported.
> 
> Yes
> 
>> Currently queue stats in the xstats are filled by ethdev layer, using
> 
> "some basic" queue stats
> 
>> the basic stats, when queue stats removed from basic stats the
>> responsibility to fill the relevant xstats will be pushed to the PMDs.
>>
>> During the switch period, a temporary
>> 'RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS' device flag is created. The PMDs
>> providing the queue stats in the xstats should set this flag to bypass
>> the relevant part in ethdev layer.
>>
>> When all PMDs switch to the xstats for the queue stats, queue stats
>> related fields from 'struct rte_eth_stats' will be removed, as well as
>> 'RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS' flag.
>> Later 'RTE_ETHDEV_QUEUE_STAT_CNTRS' compile time flag also can be
>> removed.
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>> --- a/lib/librte_ethdev/rte_ethdev.h
>> +++ b/lib/librte_ethdev/rte_ethdev.h
>> +/** Device provides queue stats in xstats */
>> +#define RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS 0x0040
> 
> Not exact wording here and in the title.
> We should try to convey the idea that the basic queue stats
> are not automatically converted from the array to some xstats.
> Something like RTE_ETH_DEV_NO_AUTOFILL_QUEUE_XSTATS
> 
> Or we can define the opposite flag and set it by default
> in all drivers which fill the basic queue stats.
> I suggest RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS
> 

Agree that opposite flag makes it easier to traces the PMDs missing 
implementation, will send another RFC with it.

Patch
diff mbox series

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 892c246a53..66665ad4ee 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -2446,8 +2446,10 @@  get_xstats_basic_count(struct rte_eth_dev *dev)
 	nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
 
 	count = RTE_NB_STATS;
-	count += nb_rxqs * RTE_NB_RXQ_STATS;
-	count += nb_txqs * RTE_NB_TXQ_STATS;
+	if ((dev->data->dev_flags & RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS) == 0) {
+		count += nb_rxqs * RTE_NB_RXQ_STATS;
+		count += nb_txqs * RTE_NB_TXQ_STATS;
+	}
 
 	return count;
 }
@@ -2538,6 +2540,10 @@  rte_eth_basic_stats_get_names(struct rte_eth_dev *dev,
 			sizeof(xstats_names[0].name));
 		cnt_used_entries++;
 	}
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS)
+		return cnt_used_entries;
+
 	num_q = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
 	for (id_queue = 0; id_queue < num_q; id_queue++) {
 		for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
@@ -2736,6 +2742,9 @@  rte_eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats)
 		xstats[count++].value = val;
 	}
 
+	if (dev->data->dev_flags & RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS)
+		return count;
+
 	/* per-rxq stats */
 	for (q = 0; q < nb_rxqs; q++) {
 		for (i = 0; i < RTE_NB_RXQ_STATS; i++) {
@@ -2871,8 +2880,10 @@  rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
 	nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
 
 	/* Return generic statistics */
-	count = RTE_NB_STATS + (nb_rxqs * RTE_NB_RXQ_STATS) +
-		(nb_txqs * RTE_NB_TXQ_STATS);
+	count = RTE_NB_STATS;
+	if ((dev->data->dev_flags & RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS) == 0)
+		count += (nb_rxqs * RTE_NB_RXQ_STATS) +
+			(nb_txqs * RTE_NB_TXQ_STATS);
 
 	/* implemented by the driver */
 	if (dev->dev_ops->xstats_get != NULL) {
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 5bcfbb8b04..42c83303e1 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -1694,6 +1694,8 @@  struct rte_eth_dev_owner {
 #define RTE_ETH_DEV_REPRESENTOR  0x0010
 /** Device does not support MAC change after started */
 #define RTE_ETH_DEV_NOLIVE_MAC_ADDR  0x0020
+/** Device provides queue stats in xstats */
+#define RTE_ETH_DEV_QUEUE_STATS_IN_XSTATS 0x0040
 
 /**
  * Iterates over valid ethdev ports owned by a specific owner.