[dpdk-dev,RFC,v1] rte: add bit-rate metrics to xstats

Message ID 1472050682-21420-1-git-send-email-remy.horton@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Remy Horton Aug. 24, 2016, 2:58 p.m. UTC
  This patch adds peak and average data-rate metrics to the extended
statistics. The intervals used to generate the statistics are
controlled by any application wishing to make use of these metrics.

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/rel_notes/release_16_11.rst |   5 ++
 lib/librte_ether/rte_ethdev.c          | 107 ++++++++++++++++++++++++++++++++-
 lib/librte_ether/rte_ethdev.h          |  41 +++++++++++++
 lib/librte_ether/rte_ether_version.map |   6 ++
 4 files changed, 157 insertions(+), 2 deletions(-)
  

Comments

Pattan, Reshma Aug. 26, 2016, 1:28 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton
> Sent: Wednesday, August 24, 2016 3:58 PM
> To: thomas.monjalon@6wind.com
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [RFC PATCH v1] rte: add bit-rate metrics to xstats
> 
> This patch adds peak and average data-rate metrics to the extended statistics.
> The intervals used to generate the statistics are controlled by any application
> wishing to make use of these metrics.
> 
> Signed-off-by: Remy Horton <remy.horton@intel.com>
> ---
> +int
> +rte_eth_dev_stats_init(uint8_t port_id, uint32_t cnt_buckets) {
> +	struct rte_eth_dev *dev;
> +	struct rte_eth_dev_stats *stats;
> +
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
> +	dev = &rte_eth_devices[port_id];
> +	stats = &dev->data->stats;
> +
> +	memset(stats, 0, sizeof(struct rte_eth_dev_stats));
> +	stats->list_ibuckets = rte_zmalloc(
> +		NULL, sizeof(uint64_t) * cnt_buckets, 0);

We can have the sizeof(uint64_t) * cnt_buckets, calculated on top and use that in both the rte_zmallocs, Instead of performing * operation twice.

> +	stats->list_obuckets = rte_zmalloc(
> +		NULL, sizeof(uint64_t) * cnt_buckets, 0);
> +	if (stats->list_ibuckets == NULL || stats->list_obuckets == NULL)
> +		return -ENOMEM;

If  either of them has valid pointer we should free that before returning.

> +	stats->cnt_buckets = cnt_buckets;
> +	return 0;
> +}
> +

Thanks,
Reshma
  
Pattan, Reshma Aug. 29, 2016, 10:01 a.m. UTC | #2
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton
> Sent: Wednesday, August 24, 2016 3:58 PM
> To: thomas.monjalon@6wind.com
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [RFC PATCH v1] rte: add bit-rate metrics to xstats
> 
> This patch adds peak and average data-rate metrics to the extended statistics.
> The intervals used to generate the statistics are controlled by any application
> wishing to make use of these metrics.
> 
> Signed-off-by: Remy Horton <remy.horton@intel.com>
> ---
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index
> f62a9ec..71549b4 100644
>  static const struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = {
>  	{"packets", offsetof(struct rte_eth_stats, q_ipackets)}, @@ -1499,6
> +1500,7 @@ void  rte_eth_stats_reset(uint8_t port_id)  {
>  	struct rte_eth_dev *dev;
> +	struct rte_eth_dev_stats *dev_stats;
> 
>  	RTE_ETH_VALID_PORTID_OR_RET(port_id);
>  	dev = &rte_eth_devices[port_id];
> @@ -1506,6 +1508,19 @@ rte_eth_stats_reset(uint8_t port_id)
>  	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
>  	(*dev->dev_ops->stats_reset)(dev);
>  	dev->data->rx_mbuf_alloc_failed = 0;
> +
> +	/* Clear device running stat counts */
> +	dev_stats = &dev->data->stats;
> +	memset(dev_stats->list_ibuckets, 0,
> +		sizeof(uint64_t) * dev_stats->cnt_buckets);
> +	memset(dev_stats->list_obuckets, 0,
> +		sizeof(uint64_t) * dev_stats->cnt_buckets);
> +	dev_stats->last_ibytes = 0;
> +	dev_stats->last_obytes = 0;
> +	dev_stats->peak_ibytes = 0;
> +	dev_stats->peak_obytes = 0;
> +	dev_stats->total_ibytes = 0;
> +	dev_stats->total_obytes = 0;
>  }
> 

Should the resetting has to be done inside rte_eth_xstats_reset() instead of rte_eth_stats_reset()?

Thanks,
Reshma
  
Remy Horton Aug. 29, 2016, 11:19 a.m. UTC | #3
On 29/08/2016 11:01, Pattan, Reshma wrote:
[..]
>> @@ -1506,6 +1508,19 @@ rte_eth_stats_reset(uint8_t port_id)
[..]
>> +	/* Clear device running stat counts */
>> +	dev_stats = &dev->data->stats;
>> +	memset(dev_stats->list_ibuckets, 0,
>> +		sizeof(uint64_t) * dev_stats->cnt_buckets);
>> +	memset(dev_stats->list_obuckets, 0,
>> +		sizeof(uint64_t) * dev_stats->cnt_buckets);
>> +	dev_stats->last_ibytes = 0;
>> +	dev_stats->last_obytes = 0;
>> +	dev_stats->peak_ibytes = 0;
>> +	dev_stats->peak_obytes = 0;
>> +	dev_stats->total_ibytes = 0;
>> +	dev_stats->total_obytes = 0;

> Should the resetting has to be done inside rte_eth_xstats_reset() instead of rte_eth_stats_reset()?

The bit-rate metrics are calculated from rte_eth_stats values rather 
than xstats values, which is why I put the reset here rather than in 
rte_eth_xstats_reset().

However this ought to be a moot point. I think it is a bug that 
rte_eth_xstats_reset() only calls rte_eth_stats_reset() if the driver 
doesn't implement xstats_reset, as the xstats output includes all the 
rte_eth_stats values unconditonally.
  
Remy Horton Oct. 28, 2016, 1:04 a.m. UTC | #4
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

--

v2 changes:
* Uses a new metrics library rather than being part of ethdev

Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add support for bitrate statistics

 app/test-pmd/testpmd.c                             |  30 ++-
 config/common_base                                 |  10 +
 doc/api/doxy-api-index.md                          |   2 +
 doc/api/doxy-api.conf                              |   2 +
 lib/Makefile                                       |   2 +
 lib/librte_bitratestats/Makefile                   |  53 ++++
 lib/librte_bitratestats/rte_bitrate.c              | 126 ++++++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 ++++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_metrics/Makefile                        |  51 ++++
 lib/librte_metrics/rte_metrics.c                   | 267 +++++++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 200 +++++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 14 files changed, 847 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Remy Horton Nov. 4, 2016, 3:36 a.m. UTC | #5
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

--

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add support for bitrate statistics

 app/test-pmd/testpmd.c                             |  28 +-
 config/common_base                                 |  10 +
 doc/api/doxy-api-index.md                          |   2 +
 doc/api/doxy-api.conf                              |   2 +
 doc/guides/rel_notes/release_16_11.rst             |  11 +
 lib/Makefile                                       |   2 +
 lib/librte_bitratestats/Makefile                   |  53 ++++
 lib/librte_bitratestats/rte_bitrate.c              | 128 +++++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 ++++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_metrics/Makefile                        |  51 ++++
 lib/librte_metrics/rte_metrics.c                   | 300 +++++++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 204 ++++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 15 files changed, 895 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Remy Horton Nov. 15, 2016, 7:15 a.m. UTC | #6
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

--

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add support for bitrate statistics

 MAINTAINERS                                        |   9 +
 app/test-pmd/testpmd.c                             |  36 +++
 config/common_base                                 |  10 +
 doc/api/doxy-api-index.md                          |   2 +
 doc/api/doxy-api.conf                              |   2 +
 doc/guides/rel_notes/release_17_02.rst             |  11 +
 lib/Makefile                                       |   2 +
 lib/librte_bitratestats/Makefile                   |  53 ++++
 lib/librte_bitratestats/rte_bitrate.c              | 128 +++++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 ++++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_metrics/Makefile                        |  51 ++++
 lib/librte_metrics/rte_metrics.c                   | 308 +++++++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 190 +++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 16 files changed, 907 insertions(+)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Remy Horton Nov. 18, 2016, 8 a.m. UTC | #7
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

Due to merge issues Reshma's latency statistics, which depends
on the reporting library, has been merged into this patchset.

--
v5 changes:
* Updated Shared Library Versions in release notes
* Merged in Reshma's latencystats library

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Remy Horton (4):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add support for bitrate statistics
  latencystats: added new library for latency stats

 MAINTAINERS                                        |  13 +
 app/proc_info/main.c                               |  70 ++++
 app/test-pmd/testpmd.c                             |  46 +++
 config/common_base                                 |  15 +
 doc/api/doxy-api-index.md                          |   3 +
 doc/api/doxy-api.conf                              |   3 +
 doc/guides/rel_notes/release_17_02.rst             |  18 +
 lib/Makefile                                       |   3 +
 lib/librte_bitratestats/Makefile                   |  53 +++
 lib/librte_bitratestats/rte_bitrate.c              | 128 +++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 +++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_latencystats/Makefile                   |  57 +++
 lib/librte_latencystats/rte_latencystats.c         | 389 +++++++++++++++++++++
 lib/librte_latencystats/rte_latencystats.h         | 146 ++++++++
 .../rte_latencystats_version.map                   |  10 +
 lib/librte_mbuf/rte_mbuf.h                         |   3 +
 lib/librte_metrics/Makefile                        |  51 +++
 lib/librte_metrics/rte_metrics.c                   | 308 ++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 190 ++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 22 files changed, 1611 insertions(+)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_latencystats/Makefile
 create mode 100644 lib/librte_latencystats/rte_latencystats.c
 create mode 100644 lib/librte_latencystats/rte_latencystats.h
 create mode 100644 lib/librte_latencystats/rte_latencystats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Remy Horton Jan. 11, 2017, 4:03 p.m. UTC | #8
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

Due to merge issues Reshma's latency statistics, which depends
on the reporting library, has been merged into this patchset.

--

v6 changes:
* Metrics display now has "Non port specific" rather than "port -1"
* Fixed sign issue in EWMA delta calculation
* Rebased to master

v5 changes:
* Updated Shared Library Versions in release notes
* Merged in Reshma's latencystats library

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Remy Horton (4):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add support for bitrate statistics
  latencystats: added new library for latency stats

 MAINTAINERS                                        |  13 +
 app/proc_info/main.c                               |  73 ++++
 app/test-pmd/testpmd.c                             |  46 +++
 config/common_base                                 |  15 +
 doc/api/doxy-api-index.md                          |   3 +
 doc/api/doxy-api.conf                              |   3 +
 doc/guides/rel_notes/release_17_02.rst             |  18 +
 lib/Makefile                                       |   3 +
 lib/librte_bitratestats/Makefile                   |  53 +++
 lib/librte_bitratestats/rte_bitrate.c              | 131 +++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 +++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_latencystats/Makefile                   |  57 +++
 lib/librte_latencystats/rte_latencystats.c         | 389 +++++++++++++++++++++
 lib/librte_latencystats/rte_latencystats.h         | 146 ++++++++
 .../rte_latencystats_version.map                   |  10 +
 lib/librte_mbuf/rte_mbuf.h                         |   3 +
 lib/librte_metrics/Makefile                        |  51 +++
 lib/librte_metrics/rte_metrics.c                   | 308 ++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 190 ++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 22 files changed, 1617 insertions(+)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_latencystats/Makefile
 create mode 100644 lib/librte_latencystats/rte_latencystats.c
 create mode 100644 lib/librte_latencystats/rte_latencystats.h
 create mode 100644 lib/librte_latencystats/rte_latencystats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Thomas Monjalon Jan. 11, 2017, 4:58 p.m. UTC | #9
2017-01-12 00:03, Remy Horton:
> Due to merge issues Reshma's latency statistics, which depends
> on the reporting library, has been merged into this patchset.

You losed Reshma authorship. It can be fixed with "git commit --amend --author"
  
Remy Horton Jan. 16, 2017, 4:19 p.m. UTC | #10
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

Due to merge issues Reshma's latency statistics, which depends
on the reporting library, has been merged into this patchset.

--

v7 changes:
* RTE_METRICS_NONPORT renamed to RTE_METRICS_GLOBAL
* Multiple changes to rte_metrics.h doxygen documentation
* Split apart latency patch into lib, test-pmd, & proc_info parts
* Reordered patches by functionality
* Insufficent capacity return value changed from -ERANGE to actual size
* Cache alignment in bitrate library
* Tightened up const usage to avoid STATIC_CONST_CHAR_ARRAY warning
* Reshma reinstated as author for (now split) latency patch
* Rebase to master

v6 changes:
* Metrics display now has "Non port specific" rather than "port -1"
* Fixed sign issue in EWMA delta calculation
* Rebased to master

v5 changes:
* Updated Shared Library Versions in release notes
* Merged in Reshma's latencystats library

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add bitrate statistics calculation

Reshma Pattan (3):
  app/proc_info: add metrics displaying
  lib: added new library for latency stats
  app/test-pmd: add latency statistics calculation

 MAINTAINERS                                        |  13 +
 app/proc_info/main.c                               |  73 ++++
 app/test-pmd/testpmd.c                             |  46 +++
 config/common_base                                 |  15 +
 doc/api/doxy-api-index.md                          |   3 +
 doc/api/doxy-api.conf                              |   3 +
 doc/guides/rel_notes/release_17_02.rst             |  18 +
 lib/Makefile                                       |   3 +
 lib/librte_bitratestats/Makefile                   |  53 +++
 lib/librte_bitratestats/rte_bitrate.c              | 132 +++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 +++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_latencystats/Makefile                   |  57 +++
 lib/librte_latencystats/rte_latencystats.c         | 389 +++++++++++++++++++++
 lib/librte_latencystats/rte_latencystats.h         | 146 ++++++++
 .../rte_latencystats_version.map                   |  10 +
 lib/librte_mbuf/rte_mbuf.h                         |   3 +
 lib/librte_metrics/Makefile                        |  51 +++
 lib/librte_metrics/rte_metrics.c                   | 310 ++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 223 ++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 22 files changed, 1653 insertions(+)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_latencystats/Makefile
 create mode 100644 lib/librte_latencystats/rte_latencystats.c
 create mode 100644 lib/librte_latencystats/rte_latencystats.h
 create mode 100644 lib/librte_latencystats/rte_latencystats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Remy Horton Jan. 17, 2017, 11:24 p.m. UTC | #11
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

--

v8 changes:
* Release notes correction
* Updated copyright years
* rte_metric_init() takes socket id & must be explicitly called
* rte_metrics_reg_metric renamed to rte_metrics_reg_name()
* rte_metrics_update_metric() renamed to rte_metrics_update_value()
* Doxygen updates
* Changed malloc()/free() to rte_malloc()/rte_free()
* Removed redundant memset()
* rte_stats_bitrates_s renamed to rte_stats_bitrates_s
* Split mbuf change to own patch for visibility
* CYCLES_PER_NS now a static inline function
* latency: "hidden" pthread creation now has polling API instead.
* Struct declarations and variable definitions cleaned up
* Double initialization of the latency library now returns -EEXIST
* MAINTAINERS entry for layenctstats in correct section

v7 changes:
* RTE_METRICS_NONPORT renamed to RTE_METRICS_GLOBAL
* Multiple changes to rte_metrics.h doxygen documentation
* Split apart latency patch into lib, test-pmd, & proc_info parts
* Reordered patches by functionality
* Insufficent capacity return value changed from -ERANGE to actual size
* Cache alignment in bitrate library
* Tightened up const usage to avoid STATIC_CONST_CHAR_ARRAY warning
* Reshma reinstated as author for (now split) latency patch
* Rebase to master

v6 changes:
* Metrics display now has "Non port specific" rather than "port -1"
* Fixed sign issue in EWMA delta calculation
* Rebased to master

v5 changes:
* Updated Shared Library Versions in release notes
* Merged in Reshma's latencystats library

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Harry van Haaren (3):
  mbuf: add a timestamp to the mbuf for latencystats
  lib: added new library for latency stats
  app/test-pmd: add latency statistics calculation

Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add bitrate statistics calculation

Reshma Pattan (1):
  app/proc_info: add metrics displaying

 MAINTAINERS                                        |  12 +
 app/proc_info/main.c                               |  74 ++++-
 app/test-pmd/parameters.c                          |  20 +-
 app/test-pmd/testpmd.c                             |  75 ++++-
 app/test-pmd/testpmd.h                             |   6 +-
 config/common_base                                 |  15 +
 doc/api/doxy-api-index.md                          |   3 +
 doc/api/doxy-api.conf                              |   3 +
 doc/guides/rel_notes/release_17_02.rst             |  18 +
 lib/Makefile                                       |   3 +
 lib/librte_bitratestats/Makefile                   |  53 +++
 lib/librte_bitratestats/rte_bitrate.c              | 132 ++++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 +++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_latencystats/Makefile                   |  56 ++++
 lib/librte_latencystats/rte_latencystats.c         | 366 +++++++++++++++++++++
 lib/librte_latencystats/rte_latencystats.h         | 154 +++++++++
 .../rte_latencystats_version.map                   |  10 +
 lib/librte_mbuf/rte_mbuf.h                         |   3 +
 lib/librte_metrics/Makefile                        |  51 +++
 lib/librte_metrics/rte_metrics.c                   | 308 +++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 231 +++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 24 files changed, 1694 insertions(+), 4 deletions(-)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_latencystats/Makefile
 create mode 100644 lib/librte_latencystats/rte_latencystats.c
 create mode 100644 lib/librte_latencystats/rte_latencystats.h
 create mode 100644 lib/librte_latencystats/rte_latencystats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Remy Horton Jan. 18, 2017, 3:05 p.m. UTC | #12
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

--

v9 changes:
* Updated .map files to reflect function changes in v8
* Fixed rte_malloc() of zero bytes in proc_info when no metrics exist
* Fixed rte_metrics_init not being called explicitly in testpmd

v8 changes:
* Release notes correction
* Updated copyright years
* rte_metric_init() takes socket id & must be explicitly called
* rte_metrics_reg_metric renamed to rte_metrics_reg_name()
* rte_metrics_update_metric() renamed to rte_metrics_update_value()
* Doxygen updates
* Changed malloc()/free() to rte_malloc()/rte_free()
* Removed redundant memset()
* rte_stats_bitrates_s renamed to rte_stats_bitrates_s
* Split mbuf change to own patch for visibility
* CYCLES_PER_NS now a static inline function
* latency: "hidden" pthread creation now has polling API instead.
* Struct declarations and variable definitions cleaned up
* Double initialization of the latency library now returns -EEXIST
* MAINTAINERS entry for layenctstats in correct section

v7 changes:
* RTE_METRICS_NONPORT renamed to RTE_METRICS_GLOBAL
* Multiple changes to rte_metrics.h doxygen documentation
* Split apart latency patch into lib, test-pmd, & proc_info parts
* Reordered patches by functionality
* Insufficent capacity return value changed from -ERANGE to actual size
* Cache alignment in bitrate library
* Tightened up const usage to avoid STATIC_CONST_CHAR_ARRAY warning
* Reshma reinstated as author for (now split) latency patch
* Rebase to master

v6 changes:
* Metrics display now has "Non port specific" rather than "port -1"
* Fixed sign issue in EWMA delta calculation
* Rebased to master

v5 changes:
* Updated Shared Library Versions in release notes
* Merged in Reshma's latencystats library

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Harry van Haaren (3):
  mbuf: add a timestamp to the mbuf for latencystats
  lib: added new library for latency stats
  app/test-pmd: add latency statistics calculation

Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add bitrate statistics calculation

Reshma Pattan (1):
  app/proc_info: add metrics displaying

 MAINTAINERS                                        |  12 +
 app/proc_info/main.c                               |  79 ++++-
 app/test-pmd/parameters.c                          |  20 +-
 app/test-pmd/testpmd.c                             |  78 ++++-
 app/test-pmd/testpmd.h                             |   6 +-
 config/common_base                                 |  15 +
 doc/api/doxy-api-index.md                          |   3 +
 doc/api/doxy-api.conf                              |   3 +
 doc/guides/rel_notes/release_17_02.rst             |  18 +
 lib/Makefile                                       |   3 +
 lib/librte_bitratestats/Makefile                   |  53 +++
 lib/librte_bitratestats/rte_bitrate.c              | 132 ++++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 +++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_latencystats/Makefile                   |  56 ++++
 lib/librte_latencystats/rte_latencystats.c         | 366 +++++++++++++++++++++
 lib/librte_latencystats/rte_latencystats.h         | 154 +++++++++
 .../rte_latencystats_version.map                   |  11 +
 lib/librte_mbuf/rte_mbuf.h                         |   3 +
 lib/librte_metrics/Makefile                        |  51 +++
 lib/librte_metrics/rte_metrics.c                   | 308 +++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 231 +++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 24 files changed, 1703 insertions(+), 4 deletions(-)
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_latencystats/Makefile
 create mode 100644 lib/librte_latencystats/rte_latencystats.c
 create mode 100644 lib/librte_latencystats/rte_latencystats.h
 create mode 100644 lib/librte_latencystats/rte_latencystats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Remy Horton Feb. 3, 2017, 10:33 a.m. UTC | #13
This patchset extends statistics reporting to include peak and
average data-rate metrics. It comes in two parts: a statistics
reporting library, and a bitrate calculation library that uses
it. This structure is intended to seperate statistic reporting
from ethdev and allow more flexible metric registration.

--
v10 changes:
* Rebased
* Relocated some config-related directives.
* Removed incorrect capitalisations in API docs.
* Formatting & detail corrections in release notes.
* Moved around struct member descriptions.
* Rewritten rte_metrics.h file description.
* Rewritten description of RTE_METRICS_GLOBAL.
* Used 'producers' and 'consumers' as terms.
* Removed markup (bold text) in Doxygen tags.
* Added programming guide section.

v9 changes:
* Updated .map files to reflect function changes in v8
* Fixed rte_malloc() of zero bytes in proc_info when no metrics exist
* Fixed rte_metrics_init not being called explicitly in testpmd

v8 changes:
* Release notes correction
* Updated copyright years
* rte_metric_init() takes socket id & must be explicitly called
* rte_metrics_reg_metric renamed to rte_metrics_reg_name()
* rte_metrics_update_metric() renamed to rte_metrics_update_value()
* Doxygen updates
* Changed malloc()/free() to rte_malloc()/rte_free()
* Removed redundant memset()
* rte_stats_bitrates_s renamed to rte_stats_bitrates_s
* Split mbuf change to own patch for visibility
* CYCLES_PER_NS now a static inline function
* latency: "hidden" pthread creation now has polling API instead.
* Struct declarations and variable definitions cleaned up
* Double initialization of the latency library now returns -EEXIST
* MAINTAINERS entry for layenctstats in correct section

v7 changes:
* RTE_METRICS_NONPORT renamed to RTE_METRICS_GLOBAL
* Multiple changes to rte_metrics.h doxygen documentation
* Split apart latency patch into lib, test-pmd, & proc_info parts
* Reordered patches by functionality
* Insufficent capacity return value changed from -ERANGE to actual size
* Cache alignment in bitrate library
* Tightened up const usage to avoid STATIC_CONST_CHAR_ARRAY warning
* Reshma reinstated as author for (now split) latency patch
* Rebase to master

v6 changes:
* Metrics display now has "Non port specific" rather than "port -1"
* Fixed sign issue in EWMA delta calculation
* Rebased to master

v5 changes:
* Updated Shared Library Versions in release notes
* Merged in Reshma's latencystats library

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Harry van Haaren (3):
  mbuf: add a timestamp to the mbuf for latencystats
  lib: added new library for latency stats
  app/test-pmd: add latency statistics calculation

Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add bitrate statistics calculation

Reshma Pattan (1):
  app/proc_info: add metrics displaying

 MAINTAINERS                                        |  12 +
 app/proc_info/main.c                               |  79 ++++-
 app/test-pmd/parameters.c                          |  20 +-
 app/test-pmd/testpmd.c                             |  78 ++++-
 app/test-pmd/testpmd.h                             |   6 +-
 config/common_base                                 |  15 +
 doc/api/doxy-api-index.md                          |   3 +
 doc/api/doxy-api.conf                              |   3 +
 doc/guides/prog_guide/index.rst                    |   1 +
 doc/guides/prog_guide/metrics_lib.rst              | 297 +++++++++++++++++
 doc/guides/rel_notes/release_17_02.rst             |  20 ++
 lib/Makefile                                       |   3 +
 lib/librte_bitratestats/Makefile                   |  53 +++
 lib/librte_bitratestats/rte_bitrate.c              | 132 ++++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 +++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_latencystats/Makefile                   |  56 ++++
 lib/librte_latencystats/rte_latencystats.c         | 366 +++++++++++++++++++++
 lib/librte_latencystats/rte_latencystats.h         | 154 +++++++++
 .../rte_latencystats_version.map                   |  11 +
 lib/librte_mbuf/rte_mbuf.h                         |   3 +
 lib/librte_metrics/Makefile                        |  51 +++
 lib/librte_metrics/rte_metrics.c                   | 299 +++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 240 ++++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 26 files changed, 2003 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/metrics_lib.rst
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_latencystats/Makefile
 create mode 100644 lib/librte_latencystats/rte_latencystats.c
 create mode 100644 lib/librte_latencystats/rte_latencystats.h
 create mode 100644 lib/librte_latencystats/rte_latencystats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  
Thomas Monjalon Feb. 16, 2017, 10:53 a.m. UTC | #14
2017-02-03 10:33, Remy Horton:
> This patchset extends statistics reporting to include peak and
> average data-rate metrics. It comes in two parts: a statistics
> reporting library, and a bitrate calculation library that uses
> it. This structure is intended to seperate statistic reporting
> from ethdev and allow more flexible metric registration.

Note that this series integrates a third part for latency metric.

> v10 changes:
> * Rebased
> * Relocated some config-related directives.
> * Removed incorrect capitalisations in API docs.
> * Formatting & detail corrections in release notes.
> * Moved around struct member descriptions.
> * Rewritten rte_metrics.h file description.
> * Rewritten description of RTE_METRICS_GLOBAL.
> * Used 'producers' and 'consumers' as terms.
> * Removed markup (bold text) in Doxygen tags.
> * Added programming guide section.

Thanks for adding the prog guide section. It helps.

I think there are three remaining questions:
- When the metrics computation are done? (in which thread?)
- May the few lines of computation code be done differently when tightly
integrated in an application logic?
- Could it be hosted in a separate repository on dpdk.org?
  
Remy Horton Feb. 23, 2017, 7:09 a.m. UTC | #15
On 16/02/2017 10:53, Thomas Monjalon wrote:
> 2017-02-03 10:33, Remy Horton:
[..]
> I think there are three remaining questions:
> - When the metrics computation are done? (in which thread?)

Actual calculation is not done by libmetrics itself - it only handles
distribution. Calculation is done prior to the calculated values being
passed to rte_metrics_update_value*(), so the thread that does the
calculation is a decision for the application.


> - May the few lines of computation code be done differently when tightly
> integrated in an application logic?

Yes, since it is the application itself (or in the case of bit-rate, a
separate library) that does the calculation.


> - Could it be hosted in a separate repository on dpdk.org?
>

That's part of a broader discussion on how DPDK is packaged.
  
Thomas Monjalon Feb. 23, 2017, 8:45 a.m. UTC | #16
2017-02-23 07:09, Remy Horton:
> 
> On 16/02/2017 10:53, Thomas Monjalon wrote:
> > 2017-02-03 10:33, Remy Horton:
> [..]
> > I think there are three remaining questions:
> > - When the metrics computation are done? (in which thread?)
> 
> Actual calculation is not done by libmetrics itself - it only handles
> distribution. Calculation is done prior to the calculated values being
> passed to rte_metrics_update_value*(), so the thread that does the
> calculation is a decision for the application.

Of course computation is not done in libmetrics. The question was about
its integration in the application and the perfromance impact.
Should it be in the dataplane threads or in separate threads?

> > - May the few lines of computation code be done differently when tightly
> > integrated in an application logic?
> 
> Yes, since it is the application itself (or in the case of bit-rate, a
> separate library) that does the calculation.

The question was more about the cache misses with this library.

> > - Could it be hosted in a separate repository on dpdk.org?
> 
> That's part of a broader discussion on how DPDK is packaged.

And specifically for these metrics libraries, do you agree it could
be packaged separately?
  
Remy Horton March 9, 2017, 4:25 p.m. UTC | #17
This patchset consists of three libraries: A Metrics library for
distributing device information, a library that calculates bit-rate
statistics, and a library that calculates latency statistics. The
latter two libraries make use of the first library.

Metrics Library
---------------
The Metrics library implements a mechanism by which producers can
publish numeric information for later querying by consumers.
In practice producers will typically be other libraries or
primary processes, whereas consumers will typically be applications.

Metrics themselves are statistics that are not generated by PMDs.
Metric information is populated using a push model, where producers
update the values contained within the metric library by calling an
update function on the relevant metrics. Consumers receive metric
information by querying the central metric data, which is held
in shared memory so it can also be accessed by secondary processes.

For each metric, a separate value is maintained for each port id,
and when publishing metric values the producers need to specify
which port is being updated. In addition there is a special id
RTE_METRICS_GLOBAL that is intended for global statistics that are
not associated with any individual device. Since the metrics
library is self-contained, the only restriction on port numbers is
that they are less than RTE_MAX_ETHPORTS - there is no requirement
for the ports to actually exist.

Metrics must first be registered, which is the way producers declare
the names of the metrics they will be publishing. Registration can
either be done individually, or as a group as a metric set. The
intention is for all metrics in a set to be updated in one go,
although it is also possible for metrics within a set to be updated
individually. It is up to the producers to update metrics as required.

Bit-rate statistics library
---------------------------
The bit-rate library calculates the mean, the exponentially-weighted
moving average, and peak bit-rates for each active port (i.e. network
device). These statistics are then reported via the metrics library
using the following names: mean_bits_in, mean_bits_out, ewma_bits_in,
ewma_bits_out, peak_bits_in, and peak_bits_out. The sampling window 
used for calculation is decided by the application requiring the statistics.

Latency statistics library
--------------------------
The latency statistics library calculates the port-to-port latency of
packet processing by a DPDK application, reporting the minimum, average,
and maximum nano-seconds that packet processing takes, as well as the
jitter in processing delay. These statistics are then reported via the
metrics library using the following names: min_latency_ns, avg_latency_ns,
mac_latency_ns, and jitter_ns.


For more details on the metrics library and the Bit-rate and Latency
components see the Programmer's Guide updates in the patchset.
--
v11 changes:
* Rebased
* .map references to 17.02 changed to 17.05
* Release ntoes moved to release_17_05.rst
* Bit-rate library now also gives unfiltered average

v10 changes:
* Rebased
* Relocated some config-related directives.
* Removed incorrect capitalisations in API docs.
* Formatting & detail corrections in release notes.
* Moved around struct member descriptions.
* Rewritten rte_metrics.h file description.
* Rewritten description of RTE_METRICS_GLOBAL.
* Used 'producers' and 'consumers' as terms.
* Removed markup (bold text) in Doxygen tags.
* Added programming guide section.

v9 changes:
* Updated .map files to reflect function changes in v8
* Fixed rte_malloc() of zero bytes in proc_info when no metrics exist
* Fixed rte_metrics_init not being called explicitly in testpmd

v8 changes:
* Release notes correction
* Updated copyright years
* rte_metric_init() takes socket id & must be explicitly called
* rte_metrics_reg_metric renamed to rte_metrics_reg_name()
* rte_metrics_update_metric() renamed to rte_metrics_update_value()
* Doxygen updates
* Changed malloc()/free() to rte_malloc()/rte_free()
* Removed redundant memset()
* rte_stats_bitrates_s renamed to rte_stats_bitrates_s
* Split mbuf change to own patch for visibility
* CYCLES_PER_NS now a static inline function
* latency: "hidden" pthread creation now has polling API instead.
* Struct declarations and variable definitions cleaned up
* Double initialization of the latency library now returns -EEXIST
* MAINTAINERS entry for layenctstats in correct section

v7 changes:
* RTE_METRICS_NONPORT renamed to RTE_METRICS_GLOBAL
* Multiple changes to rte_metrics.h doxygen documentation
* Split apart latency patch into lib, test-pmd, & proc_info parts
* Reordered patches by functionality
* Insufficent capacity return value changed from -ERANGE to actual size
* Cache alignment in bitrate library
* Tightened up const usage to avoid STATIC_CONST_CHAR_ARRAY warning
* Reshma reinstated as author for (now split) latency patch
* Rebase to master

v6 changes:
* Metrics display now has "Non port specific" rather than "port -1"
* Fixed sign issue in EWMA delta calculation
* Rebased to master

v5 changes:
* Updated Shared Library Versions in release notes
* Merged in Reshma's latencystats library

v4 changes:
* References to 16.11 changed to 17.02
* Fetching of non-port values was broken
* Added sanity checks to value fetching
* rte_stat_value renamed to rte_metric_value
* Corrected doxygen descriptions
* Added MAINTAINERS entries
* Added #ifdef directives to bitrate code in test-pmd

v3 changes:
* Marked rte_stats_bitrate_s as internal
* Minor integer roundoff correction
* Coding style corrections
* Removed spurious object allocation
* Changes to rte_metrics.[ch] moved from Patch 2/3 to 1/3.
* Reintroduced non-port values (RTE_METRICS_NONPORT)
* Added spinlocks to metric library
* Removed spurious test registration/update
* Added release notes entries

v2 changes:
* Uses a new metrics library rather than being part of ethdev


Harry van Haaren (3):
  mbuf: add a timestamp to the mbuf for latencystats
  lib: added new library for latency stats
  app/test-pmd: add latency statistics calculation

Remy Horton (3):
  lib: add information metrics library
  lib: add bitrate statistics library
  app/test-pmd: add bitrate statistics calculation

Reshma Pattan (1):
  app/proc_info: add metrics displaying

 MAINTAINERS                                        |  12 +
 app/proc_info/main.c                               |  79 ++++-
 app/test-pmd/parameters.c                          |  20 +-
 app/test-pmd/testpmd.c                             |  78 ++++-
 app/test-pmd/testpmd.h                             |   6 +-
 config/common_base                                 |  15 +
 doc/api/doxy-api-index.md                          |   3 +
 doc/api/doxy-api.conf                              |   3 +
 doc/guides/prog_guide/index.rst                    |   1 +
 doc/guides/prog_guide/metrics_lib.rst              | 299 +++++++++++++++++
 doc/guides/rel_notes/release_17_02.rst             |   3 +
 doc/guides/rel_notes/release_17_05.rst             |  18 +
 lib/Makefile                                       |   3 +
 lib/librte_bitratestats/Makefile                   |  53 +++
 lib/librte_bitratestats/rte_bitrate.c              | 141 ++++++++
 lib/librte_bitratestats/rte_bitrate.h              |  80 +++++
 .../rte_bitratestats_version.map                   |   9 +
 lib/librte_latencystats/Makefile                   |  56 ++++
 lib/librte_latencystats/rte_latencystats.c         | 366 +++++++++++++++++++++
 lib/librte_latencystats/rte_latencystats.h         | 154 +++++++++
 .../rte_latencystats_version.map                   |  11 +
 lib/librte_mbuf/rte_mbuf.h                         |   3 +
 lib/librte_metrics/Makefile                        |  51 +++
 lib/librte_metrics/rte_metrics.c                   | 299 +++++++++++++++++
 lib/librte_metrics/rte_metrics.h                   | 240 ++++++++++++++
 lib/librte_metrics/rte_metrics_version.map         |  13 +
 mk/rte.app.mk                                      |   3 +
 27 files changed, 2015 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/prog_guide/metrics_lib.rst
 create mode 100644 lib/librte_bitratestats/Makefile
 create mode 100644 lib/librte_bitratestats/rte_bitrate.c
 create mode 100644 lib/librte_bitratestats/rte_bitrate.h
 create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map
 create mode 100644 lib/librte_latencystats/Makefile
 create mode 100644 lib/librte_latencystats/rte_latencystats.c
 create mode 100644 lib/librte_latencystats/rte_latencystats.h
 create mode 100644 lib/librte_latencystats/rte_latencystats_version.map
 create mode 100644 lib/librte_metrics/Makefile
 create mode 100644 lib/librte_metrics/rte_metrics.c
 create mode 100644 lib/librte_metrics/rte_metrics.h
 create mode 100644 lib/librte_metrics/rte_metrics_version.map
  

Patch

diff --git a/doc/guides/rel_notes/release_16_11.rst b/doc/guides/rel_notes/release_16_11.rst
index 0b9022d..b319292 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -36,6 +36,11 @@  New Features
 
      This section is a comment. Make sure to start the actual text at the margin.
 
+   * **Added data-rate metrics to the extended statistics.**
+
+     Adds peak and average incoming and outgoing data-rate metrics to the
+     extended statistics, the calculation of which is controlled by
+     applications that wish for these to be derived.
 
 Resolved Issues
 ---------------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f62a9ec..71549b4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -101,6 +101,7 @@  static const struct rte_eth_xstats_name_off rte_stats_strings[] = {
 };
 
 #define RTE_NB_STATS (sizeof(rte_stats_strings) / sizeof(rte_stats_strings[0]))
+#define RTE_NB_DEV_STATS 4
 
 static const struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = {
 	{"packets", offsetof(struct rte_eth_stats, q_ipackets)},
@@ -1499,6 +1500,7 @@  void
 rte_eth_stats_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
+	struct rte_eth_dev_stats *dev_stats;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
@@ -1506,6 +1508,19 @@  rte_eth_stats_reset(uint8_t port_id)
 	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
 	(*dev->dev_ops->stats_reset)(dev);
 	dev->data->rx_mbuf_alloc_failed = 0;
+
+	/* Clear device running stat counts */
+	dev_stats = &dev->data->stats;
+	memset(dev_stats->list_ibuckets, 0,
+		sizeof(uint64_t) * dev_stats->cnt_buckets);
+	memset(dev_stats->list_obuckets, 0,
+		sizeof(uint64_t) * dev_stats->cnt_buckets);
+	dev_stats->last_ibytes = 0;
+	dev_stats->last_obytes = 0;
+	dev_stats->peak_ibytes = 0;
+	dev_stats->peak_obytes = 0;
+	dev_stats->total_ibytes = 0;
+	dev_stats->total_obytes = 0;
 }
 
 static int
@@ -1522,7 +1537,7 @@  get_xstats_count(uint8_t port_id)
 			return count;
 	} else
 		count = 0;
-	count += RTE_NB_STATS;
+	count += RTE_NB_STATS + RTE_NB_DEV_STATS;
 	count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
 	count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
 	return count;
@@ -1574,6 +1589,19 @@  rte_eth_xstats_get_names(uint8_t port_id,
 		}
 	}
 
+	snprintf(xstats_names[cnt_used_entries++].name,
+		sizeof(xstats_names[0].name),
+		"tx_peak_bytes");
+	snprintf(xstats_names[cnt_used_entries++].name,
+		sizeof(xstats_names[0].name),
+		"tx_mean_bytes");
+	snprintf(xstats_names[cnt_used_entries++].name,
+		sizeof(xstats_names[0].name),
+		"rx_peak_bytes");
+	snprintf(xstats_names[cnt_used_entries++].name,
+		sizeof(xstats_names[0].name),
+		"rx_mean_bytes");
+
 	if (dev->dev_ops->xstats_get_names != NULL) {
 		/* If there are any driver-specific xstats, append them
 		 * to end of list.
@@ -1600,14 +1628,16 @@  rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
 	unsigned count = 0, i, q;
 	signed xcount = 0;
 	uint64_t val, *stats_ptr;
+	struct rte_eth_dev_stats *dev_stats;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
+	dev_stats = &dev->data->stats;
 
 	/* Return generic statistics */
 	count = RTE_NB_STATS + (dev->data->nb_rx_queues * RTE_NB_RXQ_STATS) +
-		(dev->data->nb_tx_queues * RTE_NB_TXQ_STATS);
+		(dev->data->nb_tx_queues * RTE_NB_TXQ_STATS) + RTE_NB_DEV_STATS;
 
 	/* implemented by the driver */
 	if (dev->dev_ops->xstats_get != NULL) {
@@ -1659,12 +1689,85 @@  rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
 		}
 	}
 
+	xstats[count++].value = dev_stats->peak_obytes;
+	xstats[count++].value =
+		dev_stats->total_obytes / dev_stats->cnt_buckets;
+	xstats[count++].value = dev_stats->peak_ibytes;
+	xstats[count++].value =
+		dev_stats->total_ibytes / dev_stats->cnt_buckets;
+
 	for (i = 0; i < count + xcount; i++)
 		xstats[i].id = i;
 
 	return count + xcount;
 }
 
+int
+rte_eth_dev_stats_init(uint8_t port_id, uint32_t cnt_buckets)
+{
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_stats *stats;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	dev = &rte_eth_devices[port_id];
+	stats = &dev->data->stats;
+
+	memset(stats, 0, sizeof(struct rte_eth_dev_stats));
+	stats->list_ibuckets = rte_zmalloc(
+		NULL, sizeof(uint64_t) * cnt_buckets, 0);
+	stats->list_obuckets = rte_zmalloc(
+		NULL, sizeof(uint64_t) * cnt_buckets, 0);
+	if (stats->list_ibuckets == NULL || stats->list_obuckets == NULL)
+		return -ENOMEM;
+	stats->cnt_buckets = cnt_buckets;
+	return 0;
+}
+
+int
+rte_eth_dev_stats_calc(uint8_t port_id)
+{
+	struct rte_eth_dev *dev;
+	uint64_t *metric;
+	uint64_t cnt_bytes_in_bucket;
+	struct rte_eth_dev_stats *stats;
+	struct rte_eth_stats eth_stats;
+	unsigned ret_code;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	dev = &rte_eth_devices[port_id];
+	stats = &dev->data->stats;
+
+	ret_code = rte_eth_stats_get(port_id, &eth_stats);
+	if (ret_code != 0)
+		return ret_code;
+
+	/* tx_good_bytes */
+	metric = RTE_PTR_ADD(&eth_stats, rte_stats_strings[3].offset);
+	cnt_bytes_in_bucket = *metric - stats->last_obytes;
+	stats->last_obytes = *metric;
+	if (cnt_bytes_in_bucket > stats->peak_obytes)
+		stats->peak_obytes = cnt_bytes_in_bucket;
+	stats->total_obytes -= stats->list_obuckets[stats->next_bucket];
+	stats->total_obytes += cnt_bytes_in_bucket;
+	stats->list_obuckets[stats->next_bucket] = cnt_bytes_in_bucket;
+
+	/* rx_good_bytes */
+	metric = RTE_PTR_ADD(&eth_stats, rte_stats_strings[2].offset);
+	cnt_bytes_in_bucket = *metric - stats->last_ibytes;
+	stats->last_ibytes = *metric;
+	if (cnt_bytes_in_bucket > stats->peak_ibytes)
+		stats->peak_ibytes = cnt_bytes_in_bucket;
+	stats->total_ibytes -= stats->list_ibuckets[stats->next_bucket];
+	stats->total_ibytes += cnt_bytes_in_bucket;
+	stats->list_ibuckets[stats->next_bucket] = cnt_bytes_in_bucket;
+
+	/* index wraparound */
+	if (++stats->next_bucket == stats->cnt_buckets)
+		stats->next_bucket = 0;
+
+	return 0;
+}
+
 /* reset ethdev extended statistics */
 void
 rte_eth_xstats_reset(uint8_t port_id)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b0fe033..4b1b47b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1656,6 +1656,19 @@  struct rte_eth_dev_sriov {
 
 #define RTE_ETH_NAME_MAX_LEN (32)
 
+struct rte_eth_dev_stats {
+	uint64_t *list_ibuckets;
+	uint64_t *list_obuckets;
+	uint32_t cnt_buckets;
+	uint32_t next_bucket;
+	uint64_t last_ibytes;
+	uint64_t last_obytes;
+	uint64_t peak_ibytes;
+	uint64_t peak_obytes;
+	uint64_t total_ibytes;
+	uint64_t total_obytes;
+};
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet device.
@@ -1670,6 +1683,7 @@  struct rte_eth_dev_data {
 	void **tx_queues; /**< Array of pointers to TX queues. */
 	uint16_t nb_rx_queues; /**< Number of RX queues. */
 	uint16_t nb_tx_queues; /**< Number of TX queues. */
+	struct rte_eth_dev_stats stats; /**< Device stats metrics */
 
 	struct rte_eth_dev_sriov sriov;    /**< SRIOV data */
 
@@ -2328,6 +2342,33 @@  int rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
 		unsigned n);
 
 /**
+ *  Initialise device statistics.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device
+ * @param cnt_buckets
+ *   Number of sampling buckets within sampling window.
+ * @return
+ *   - Zero on success.
+ *   - Negative value on error.
+ */
+int rte_eth_dev_stats_init(uint8_t port_id, uint32_t cnt_buckets);
+
+/**
+ *  Calculate device statistics.
+ *  This function need to be called periodically. The time between each
+ *  invocation is the sampling period of an individual time bucket within
+ *  the sampling window.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device
+ * @return
+ *   - Zero on success.
+ *   - Negative value on error.
+ */
+int rte_eth_dev_stats_calc(uint8_t port_id);
+
+/**
  * Reset extended statistics of an Ethernet device.
  *
  * @param port_id
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 45ddf44..bb7d1cf 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -139,3 +139,9 @@  DPDK_16.07 {
 	rte_eth_dev_get_port_by_name;
 	rte_eth_xstats_get_names;
 } DPDK_16.04;
+
+DPDK_16.11 {
+	global:
+
+	rte_eth_dev_stats_calc;
+} DPDK_16.07;