[dpdk-dev] [RFC v3] latencystats: added new library for latency stats

2016-10-18 Thread Pattan, Reshma
Hi,

The below latency stats RFC adds new field to second cache line of mbuf. This 
is not an ABI break.
But I would like to emphasize on this  point so you can have a look into the 
changes and provide comments.

Thanks,
Reshma

> -Original Message-
> From: Pattan, Reshma
> Sent: Monday, October 17, 2016 2:40 PM
> To: dev at dpdk.org
> Cc: Pattan, Reshma 
> Subject: [RFC v3] latencystats: added new library for latency stats
> 
> Library is designed to calculate latency stats and report them to the 
> application
> when queried. Library measures minimum, average, maximum latencies and
> jitter in nano seconds.
> Current implementation supports global latency stats, i.e. per application 
> stats.
> 
> Added new field to mbuf struct to mark the packet arrival time on Rx and use 
> the
> times tamp to measure the latency on Tx.
> 
> Modified dpdk-procinfo process to display the new stats.
> 
> APIs:
> 
> Added APIs to initialize and un initialize latency stats calculation.
> Added API to retrieve latency stats names and values.
> 
> Functionality:
> 
> *Library will register ethdev Rx/Tx callbacks for each active port, queue
> combinations.
> *Library will register latency stats names with new stats library, which is 
> under
> design for now.
> *Rx packets will be marked with time stamp on each sampling interval.
> *On Tx side, packets with time stamp will be considered for calculating the
> minimum, maximum, average latencies and jitter.
> *Average latency is calculated by summing all the latencies measured for each
> time stamped packet and dividing that by total time stamped packets.
> *Minimum and maximum latencies will be low and high latency values observed
> so far.
> *Jitter calculation is done based on inter packet delay variation.
> *Measured stats can be retrieved via get API of the libray (or) by calling 
> generic
> get API of the new stats library, in this case callback is provided to update 
> the
> stats  into new stats library.
> 
> Signed-off-by: Reshma Pattan 


[dpdk-dev] [RFC v3] latencystats: added new library for latency stats

2016-10-17 Thread Reshma Pattan
Library is designed to calculate latency stats and report them to the
application when queried. Library measures minimum, average, maximum
latencies and jitter in nano seconds.
Current implementation supports global latency stats, i.e. per application
stats.

Added new field to mbuf struct to mark the packet arrival time on Rx and
use the times tamp to measure the latency on Tx.

Modified dpdk-procinfo process to display the new stats.

APIs:

Added APIs to initialize and un initialize latency stats
calculation.
Added API to retrieve latency stats names and values.

Functionality:

*Library will register ethdev Rx/Tx callbacks for each active port,
queue combinations.
*Library will register latency stats names with new stats library, which is 
under
design for now.
*Rx packets will be marked with time stamp on each sampling interval.
*On Tx side, packets with time stamp will be considered for calculating
the minimum, maximum, average latencies and jitter.
*Average latency is calculated by summing all the latencies measured for each
time stamped packet and dividing that by total time stamped packets.
*Minimum and maximum latencies will be low and high latency values observed
so far.
*Jitter calculation is done based on inter packet delay variation.
*Measured stats can be retrieved via get API of the libray (or)
by calling generic get API of the new stats library, in this case
callback is provided to update the stats  into new stats library.

Signed-off-by: Reshma Pattan 
---
 MAINTAINERS|   4 +
 app/proc_info/main.c   |  60 
 app/test-pmd/testpmd.c |   9 +
 config/common_base |  10 +
 lib/Makefile   |   1 +
 lib/librte_latencystats/Makefile   |  57 
 lib/librte_latencystats/rte_latencystats.c | 378 +
 lib/librte_latencystats/rte_latencystats.h | 141 
 .../rte_latencystats_version.map   |  10 +
 lib/librte_mbuf/rte_mbuf.h |   3 +
 mk/rte.app.mk  |   1 +
 11 files changed, 674 insertions(+)
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index 8f5fa82..2db3365 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -698,3 +698,7 @@ F: examples/tep_termination/
 F: examples/vmdq/
 F: examples/vmdq_dcb/
 F: doc/guides/sample_app_ug/vmdq_dcb_forwarding.rst
+
+Latency Stats
+M: Reshma Pattan 
+F: lib/librte_latencystats/
diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 2c56d10..56c9509 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 

 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
@@ -75,6 +76,8 @@ static uint32_t reset_xstats;
 /**< Enable memory info. */
 static uint32_t mem_info;

+static uint32_t enable_latnbit_stats = 1;
+
 /**< display usage */
 static void
 proc_info_usage(const char *prgname)
@@ -301,6 +304,60 @@ nic_xstats_clear(uint8_t port_id)
printf("\n  NIC extended statistics for port %d cleared\n", port_id);
 }

+static void
+latnbit_stats_display(void)
+{
+   struct rte_stat_value *lat_stats;
+   struct rte_stat_name *names;
+   int len, ret;
+   static const char *nic_stats_border = "";
+
+   memset(_stats, 0, sizeof(struct rte_stat_value));
+   len = rte_stats_get_names(NULL, 0);
+   if (len < 0) {
+   printf("Cannot get latency and bitrate stats count\n");
+   return;
+   }
+
+   lat_stats = malloc(sizeof(struct rte_stat_value) * len);
+   if (lat_stats == NULL) {
+   printf("Cannot allocate memory for latency and bitrate 
stats\n");
+   return;
+   }
+
+   names =  malloc(sizeof(struct rte_stat_name) * len);
+   if (names == NULL) {
+   printf("Cannot allocate memory for latency and bitrate stats 
names\n");
+   free(lat_stats);
+   return;
+   }
+
+   if (len != rte_stats_get_names(names, len)) {
+   printf("Cannot get latency and bitrate stats names\n");
+   free(lat_stats);
+   free(names);
+   return;
+   }
+
+   printf("## Latency and bitrate statistics #\n");
+   printf("%s\n", nic_stats_border);
+   ret = rte_stats_get_values(RTE_STATS_NONPORT, lat_stats, len);
+   if (ret < 0 || ret > len) {
+   printf("Cannot get latency and bitrate stats\n");
+   free(lat_stats);
+   free(names);
+   return;
+   }
+
+