[dpdk-dev] [PATCH v1] examples/ethtool: fix segfault querying non-PCI devices

2016-11-30 Thread Remy Horton
Doing a device information query on a non-PCI device such as
vhost was resulting in the dereferencing of a NULL pointer
(the absent PCI data), causing a segmentation fault.

Fixes: bda68ab9d1e7 ("examples/ethtool: add user-space ethtool sample 
application")

Signed-off-by: Remy Horton 
---
 doc/guides/rel_notes/release_17_02.rst |  3 +++
 examples/ethtool/lib/rte_ethtool.c | 13 +
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 3b65038..f471e49 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -70,6 +70,9 @@ Libraries
 Examples
 

+   * **examples/ethtool Fixed crash with non-PCI devices.**
+ Querying a non-PCI device was dereferencing non-existent PCI data
+ resulting in a segmentation fault.

 Other
 ~
diff --git a/examples/ethtool/lib/rte_ethtool.c 
b/examples/ethtool/lib/rte_ethtool.c
index a1f91d4..6f0ce84 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -61,10 +61,15 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct 
ethtool_drvinfo *drvinfo)
dev_info.driver_name);
snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
rte_version());
-   snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
-   "%04x:%02x:%02x.%x",
-   dev_info.pci_dev->addr.domain, dev_info.pci_dev->addr.bus,
-   dev_info.pci_dev->addr.devid, dev_info.pci_dev->addr.function);
+   if (dev_info.pci_dev)
+   snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
+   "%04x:%02x:%02x.%x",
+   dev_info.pci_dev->addr.domain,
+   dev_info.pci_dev->addr.bus,
+   dev_info.pci_dev->addr.devid,
+   dev_info.pci_dev->addr.function);
+   else
+   snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "N/A");

memset(_info, 0, sizeof(reg_info));
rte_eth_dev_get_reg_info(port_id, _info);
-- 
2.5.5



[dpdk-dev] [PATCH v2] examples/ethtool: fix bug in drvinfo callback

2016-11-23 Thread Remy Horton
Not sure this is a problem in practice, as the same set if fields is 
updated each time...at least for now.

On 22/11/2016 09:41, Qiming Yang wrote:
> Function pcmd_drvinfo_callback uses struct info to get
> the ethtool information of each port. Struct info will
> store the information of previous port until this
> information be updated. This patch fixes this issue.
>
> Fixes: bda68ab9d1e7 ("examples/ethtool: add user-space ethtool sample 
> application")
>
> Signed-off-by: Qiming Yang 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v5 4/4] latencystats: added new library for latency stats

2016-11-18 Thread Remy Horton
Add a library designed to calculate latency statistics and report them
to the application when queried. The library measures minimum, average and
maximum latencies, and jitter in nano seconds. The 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.

Modify testpmd code to initialize/uninitialize latency statistics
calulation.

Modify the dpdk-procinfo process to display the newly added metrics.
Added new command line option "--metrics" to display metrics.

APIs:

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

Functionality:

* The library will register ethdev Rx/Tx callbacks for each active port,
  queue combinations.
* The library will register latency stats names with new metrics library.
* 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 also jitter.
* Average latency is calculated using exponential weighted moving average
  method.
* 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 are reported to the metrics library in a separate
  pthread.
* Measured stats can be retrieved via get API of the libray (or)
  by calling generic get API of the new metrics library.

Signed-off-by: Reshma Pattan 
Signed-off-by: Remy Horton 
---
 MAINTAINERS|   4 +
 app/proc_info/main.c   |  70 
 app/test-pmd/testpmd.c |  10 +
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 doc/guides/rel_notes/release_17_02.rst |   5 +
 lib/Makefile   |   1 +
 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 +
 mk/rte.app.mk  |   2 +-
 14 files changed, 703 insertions(+), 1 deletion(-)
 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 d6bbdd5..da7f9d1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -713,3 +713,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..33a4b39 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
@@ -68,6 +69,8 @@ static uint32_t enabled_port_mask;
 static uint32_t enable_stats;
 /**< Enable xstats. */
 static uint32_t enable_xstats;
+/**< Enable metrics. */
+static uint32_t enable_metrics;
 /**< Enable stats reset. */
 static uint32_t reset_stats;
 /**< Enable xstats reset. */
@@ -85,6 +88,8 @@ proc_info_usage(const char *prgname)
"  --stats: to display port statistics, enabled by default\n"
"  --xstats: to display extended port statistics, disabled by "
"default\n"
+   "  --metrics: to display derived metrics of the ports, disabled 
by "
+   "default\n"
"  --stats-reset: to reset port statistics\n"
"  --xstats-reset: to reset port extended statistics\n",
prgname);
@@ -127,6 +132,7 @@ proc_info_parse_args(int argc, char **argv)
{"stats", 0, NULL, 0},
{"stats-reset", 0, NULL, 0},
{"xstats", 0, NULL, 0},
+   {"metrics", 0, NULL, 0},
{"xstats-reset", 0, NULL, 0},
{NULL, 0, 0, 0}
};
@@ -159,6 +165,10 @@ proc_info_parse_args(int argc, char **argv)
else if (!strncmp(long_option[option_index].name, 
"xstats",
MAX_LONG_OPT_SZ))
enable_xstats = 1;
+   else if (!strncmp(long_option[option_index].name,
+  

[dpdk-dev] [PATCH v5 3/4] app/test-pmd: add support for bitrate statistics

2016-11-18 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 app/test-pmd/testpmd.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index a0332c2..60c635f 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -78,6 +78,10 @@
 #ifdef RTE_LIBRTE_PDUMP
 #include 
 #endif
+#include 
+#ifdef RTE_LIBRTE_BITRATE
+#include 
+#endif

 #include "testpmd.h"

@@ -322,6 +326,9 @@ uint16_t nb_rx_queue_stats_mappings = 0;

 unsigned max_socket = 0;

+/* Bitrate statistics */
+struct rte_stats_bitrates_s *bitrate_data;
+
 /* Forward function declarations */
 static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port 
*port);
 static void check_all_ports_link_status(uint32_t port_mask);
@@ -921,12 +928,32 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t 
pkt_fwd)
struct fwd_stream **fsm;
streamid_t nb_fs;
streamid_t sm_id;
+#ifdef RTE_LIBRTE_BITRATE
+   uint64_t tics_per_1sec;
+   uint64_t tics_datum;
+   uint64_t tics_current;
+   uint8_t idx_port, cnt_ports;
+#endif

+#ifdef RTE_LIBRTE_BITRATE
+   cnt_ports = rte_eth_dev_count();
+   tics_datum = rte_rdtsc();
+   tics_per_1sec = rte_get_timer_hz();
+#endif
fsm = _streams[fc->stream_idx];
nb_fs = fc->stream_nb;
do {
for (sm_id = 0; sm_id < nb_fs; sm_id++)
(*pkt_fwd)(fsm[sm_id]);
+#ifdef RTE_LIBRTE_BITRATE
+   tics_current = rte_rdtsc();
+   if (tics_current - tics_datum >= tics_per_1sec) {
+   /* Periodic bitrate calculation */
+   for (idx_port = 0; idx_port < cnt_ports; idx_port++)
+   rte_stats_bitrate_calc(bitrate_data, idx_port);
+   tics_datum = tics_current;
+   }
+#endif
} while (! fc->stopped);
 }

@@ -2133,6 +2160,15 @@ main(int argc, char** argv)
FOREACH_PORT(port_id, ports)
rte_eth_promiscuous_enable(port_id);

+   /* Setup bitrate stats */
+#ifdef RTE_LIBRTE_BITRATE
+   bitrate_data = rte_stats_bitrate_create();
+   if (bitrate_data == NULL)
+   rte_exit(EXIT_FAILURE, "Could not allocate bitrate data.\n");
+   rte_stats_bitrate_reg(bitrate_data);
+#endif
+
+
 #ifdef RTE_LIBRTE_CMDLINE
if (interactive == 1) {
if (auto_start) {
-- 
2.5.5



[dpdk-dev] [PATCH v5 1/4] lib: add information metrics library

2016-11-18 Thread Remy Horton
This patch adds a new information metric library that allows other
modules to register named metrics and update their values. It is
intended to be independent of ethdev, rather than mixing ethdev
and non-ethdev information in xstats.

Signed-off-by: Remy Horton 
---
 MAINTAINERS|   5 +
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 doc/guides/rel_notes/release_17_02.rst |   7 +
 lib/Makefile   |   1 +
 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  |   2 +
 11 files changed, 584 insertions(+)
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index d6bb8f8..52bd8a9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -595,6 +595,11 @@ F: lib/librte_jobstats/
 F: examples/l2fwd-jobstats/
 F: doc/guides/sample_app_ug/l2_forward_job_stats.rst

+Metrics
+M: Remy Horton 
+F: lib/librte_metrics/
+F: doc/guides/sample_app_ug/keep_alive.rst
+

 Test Applications
 -
diff --git a/config/common_base b/config/common_base
index 4bff83a..dedc4c3 100644
--- a/config/common_base
+++ b/config/common_base
@@ -589,3 +589,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n
 CONFIG_RTE_TEST_PMD=y
 CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n
 CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n
+
+#
+# Compile the device metrics library
+#
+CONFIG_RTE_LIBRTE_METRICS=y
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index 6675f96..ca50fa6 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -147,4 +147,5 @@ There are many libraries, so their headers may be grouped 
by topics:
   [common] (@ref rte_common.h),
   [ABI compat] (@ref rte_compat.h),
   [keepalive]  (@ref rte_keepalive.h),
+  [Device Metrics] (@ref rte_metrics.h),
   [version](@ref rte_version.h)
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index 9dc7ae5..fe830eb 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -57,6 +57,7 @@ INPUT   = doc/api/doxy-api-index.md \
   lib/librte_reorder \
   lib/librte_ring \
   lib/librte_sched \
+  lib/librte_metrics \
   lib/librte_table \
   lib/librte_timer \
   lib/librte_vhost
diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 3b65038..2d82dd1 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -34,6 +34,12 @@ New Features

  Refer to the previous release notes for examples.

+   * **Added information metric library.**
+
+ A library that allows information metrics to be added and update. It is
+ intended to provide a reporting mechanism that is independent of the
+ ethdev library.
+
  This section is a comment. do not overwrite or remove it.
  Also, make sure to start the actual text at the margin.
  =
@@ -152,6 +158,7 @@ The libraries prepended with a plus sign were incremented 
in this version.
  librte_mbuf.so.2
  librte_mempool.so.2
  librte_meter.so.1
+   + librte_metrics.so.1
  librte_net.so.1
  librte_pdump.so.1
  librte_pipeline.so.3
diff --git a/lib/Makefile b/lib/Makefile
index 990f23a..5d85dcf 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -58,6 +58,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TABLE) += librte_table
 DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
 DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder
 DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump
+DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics

 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
diff --git a/lib/librte_metrics/Makefile b/lib/librte_metrics/Makefile
new file mode 100644
index 000..8d6e23a
--- /dev/null
+++ b/lib/librte_metrics/Makefile
@@ -0,0 +1,51 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form

[dpdk-dev] [PATCH v5 0/4] Expanded statistics reporting

2016-11-18 Thread 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.

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

-- 
2.5.5



[dpdk-dev] [PATCH v5] latencystats: added new library for latency stats

2016-11-18 Thread Remy Horton

On 15/11/2016 21:37, Reshma Pattan wrote:
[..]
> This pacth is dependent on http://dpdk.org/dev/patchwork/patch/16927/

There are merge issues, so will combine this patch into the v6 of the 
above patchset.

..Remy


[dpdk-dev] [PATCH 5/5] ethtool: dispaly bus info and firmware version

2016-11-18 Thread Remy Horton

On 17/11/2016 17:42, Qiming Yang wrote:
> This patch enhances the ethtool-API to support to show the
> bus information and firmware version as same as kernel
> version ethtool displayed.

Suggest rewording as:

This patch enhances the ethtool example to support to show
bus information and firmware version, in the same way that
the Linux kernel ethtool does.


[dpdk-dev] [PATCH 1/5] ethdev: add firmware version get

2016-11-18 Thread Remy Horton

On 17/11/2016 17:42, Qiming Yang wrote:
> This patch added API for 'rte_eth_dev_fwver_get'
>
> void rte_eth_dev_fwver_get(uint8_t port_id,
> char *fw_version, int fw_length);

Suggest description such as:

This patch adds ethdev API for fetching firmware version.

Also see Thomas's comments. Looks like some stale patches got picked up 
by 'git send-mail *.patch'..

..Remy


[dpdk-dev] [PATCH v4 3/3] app/test-pmd: add support for bitrate statistics

2016-11-15 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 app/test-pmd/testpmd.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index a0332c2..60c635f 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -78,6 +78,10 @@
 #ifdef RTE_LIBRTE_PDUMP
 #include 
 #endif
+#include 
+#ifdef RTE_LIBRTE_BITRATE
+#include 
+#endif

 #include "testpmd.h"

@@ -322,6 +326,9 @@ uint16_t nb_rx_queue_stats_mappings = 0;

 unsigned max_socket = 0;

+/* Bitrate statistics */
+struct rte_stats_bitrates_s *bitrate_data;
+
 /* Forward function declarations */
 static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port 
*port);
 static void check_all_ports_link_status(uint32_t port_mask);
@@ -921,12 +928,32 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t 
pkt_fwd)
struct fwd_stream **fsm;
streamid_t nb_fs;
streamid_t sm_id;
+#ifdef RTE_LIBRTE_BITRATE
+   uint64_t tics_per_1sec;
+   uint64_t tics_datum;
+   uint64_t tics_current;
+   uint8_t idx_port, cnt_ports;
+#endif

+#ifdef RTE_LIBRTE_BITRATE
+   cnt_ports = rte_eth_dev_count();
+   tics_datum = rte_rdtsc();
+   tics_per_1sec = rte_get_timer_hz();
+#endif
fsm = _streams[fc->stream_idx];
nb_fs = fc->stream_nb;
do {
for (sm_id = 0; sm_id < nb_fs; sm_id++)
(*pkt_fwd)(fsm[sm_id]);
+#ifdef RTE_LIBRTE_BITRATE
+   tics_current = rte_rdtsc();
+   if (tics_current - tics_datum >= tics_per_1sec) {
+   /* Periodic bitrate calculation */
+   for (idx_port = 0; idx_port < cnt_ports; idx_port++)
+   rte_stats_bitrate_calc(bitrate_data, idx_port);
+   tics_datum = tics_current;
+   }
+#endif
} while (! fc->stopped);
 }

@@ -2133,6 +2160,15 @@ main(int argc, char** argv)
FOREACH_PORT(port_id, ports)
rte_eth_promiscuous_enable(port_id);

+   /* Setup bitrate stats */
+#ifdef RTE_LIBRTE_BITRATE
+   bitrate_data = rte_stats_bitrate_create();
+   if (bitrate_data == NULL)
+   rte_exit(EXIT_FAILURE, "Could not allocate bitrate data.\n");
+   rte_stats_bitrate_reg(bitrate_data);
+#endif
+
+
 #ifdef RTE_LIBRTE_CMDLINE
if (interactive == 1) {
if (auto_start) {
-- 
2.5.5



[dpdk-dev] [PATCH v4 2/3] lib: add bitrate statistics library

2016-11-15 Thread Remy Horton
This patch adds a library that calculates peak and average data-rate
statistics. For ethernet devices. These statistics are reported using
the metrics library.

Signed-off-by: Remy Horton 
---
 MAINTAINERS|   4 +
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 doc/guides/rel_notes/release_17_02.rst |   5 +
 lib/Makefile   |   1 +
 lib/librte_bitratestats/Makefile   |  53 +
 lib/librte_bitratestats/rte_bitrate.c  | 128 +
 lib/librte_bitratestats/rte_bitrate.h  |  80 +
 .../rte_bitratestats_version.map   |   9 ++
 mk/rte.app.mk  |   1 +
 11 files changed, 288 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

diff --git a/MAINTAINERS b/MAINTAINERS
index 52bd8a9..d6bbdd5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -600,6 +600,10 @@ M: Remy Horton 
 F: lib/librte_metrics/
 F: doc/guides/sample_app_ug/keep_alive.rst

+Bit-rate statistica
+M: Remy Horton 
+F: lib/librte_bitratestats/
+

 Test Applications
 -
diff --git a/config/common_base b/config/common_base
index dedc4c3..beca7ec 100644
--- a/config/common_base
+++ b/config/common_base
@@ -594,3 +594,8 @@ CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n
 # Compile the device metrics library
 #
 CONFIG_RTE_LIBRTE_METRICS=y
+
+#
+# Compile the bitrate statistics library
+#
+CONFIG_RTE_LIBRTE_BITRATE=y
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index ca50fa6..91e8ea6 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -148,4 +148,5 @@ There are many libraries, so their headers may be grouped 
by topics:
   [ABI compat] (@ref rte_compat.h),
   [keepalive]  (@ref rte_keepalive.h),
   [Device Metrics] (@ref rte_metrics.h),
+  [Bitrate Statistics] (@ref rte_bitrate.h),
   [version](@ref rte_version.h)
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index fe830eb..8765ddd 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -58,6 +58,7 @@ INPUT   = doc/api/doxy-api-index.md \
   lib/librte_ring \
   lib/librte_sched \
   lib/librte_metrics \
+  lib/librte_bitratestats \
   lib/librte_table \
   lib/librte_timer \
   lib/librte_vhost
diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index e1b8894..f949e88 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -40,6 +40,11 @@ New Features
  intended to provide a reporting mechanism that is independent of the
  ethdev library.

+   * **Added bit-rate calculation library.**
+
+ A library that can be used to calculate device bit-rates. Calculated
+ bitrates are reported using the metrics library.
+
  This section is a comment. do not overwrite or remove it.
  Also, make sure to start the actual text at the margin.
  =
diff --git a/lib/Makefile b/lib/Makefile
index 5d85dcf..e211bc0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -59,6 +59,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
 DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder
 DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump
 DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics
+DIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += librte_bitratestats

 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
diff --git a/lib/librte_bitratestats/Makefile b/lib/librte_bitratestats/Makefile
new file mode 100644
index 000..b725d4e
--- /dev/null
+++ b/lib/librte_bitratestats/Makefile
@@ -0,0 +1,53 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors

[dpdk-dev] [PATCH v4 1/3] lib: add information metrics library

2016-11-15 Thread Remy Horton
This patch adds a new information metric library that allows other
modules to register named metrics and update their values. It is
intended to be independent of ethdev, rather than mixing ethdev
and non-ethdev information in xstats.

Signed-off-by: Remy Horton 
---
 MAINTAINERS|   5 +
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 doc/guides/rel_notes/release_17_02.rst |   6 +
 lib/Makefile   |   1 +
 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  |   2 +
 11 files changed, 583 insertions(+)
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index d6bb8f8..52bd8a9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -595,6 +595,11 @@ F: lib/librte_jobstats/
 F: examples/l2fwd-jobstats/
 F: doc/guides/sample_app_ug/l2_forward_job_stats.rst

+Metrics
+M: Remy Horton 
+F: lib/librte_metrics/
+F: doc/guides/sample_app_ug/keep_alive.rst
+

 Test Applications
 -
diff --git a/config/common_base b/config/common_base
index 4bff83a..dedc4c3 100644
--- a/config/common_base
+++ b/config/common_base
@@ -589,3 +589,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n
 CONFIG_RTE_TEST_PMD=y
 CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n
 CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n
+
+#
+# Compile the device metrics library
+#
+CONFIG_RTE_LIBRTE_METRICS=y
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index 6675f96..ca50fa6 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -147,4 +147,5 @@ There are many libraries, so their headers may be grouped 
by topics:
   [common] (@ref rte_common.h),
   [ABI compat] (@ref rte_compat.h),
   [keepalive]  (@ref rte_keepalive.h),
+  [Device Metrics] (@ref rte_metrics.h),
   [version](@ref rte_version.h)
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index 9dc7ae5..fe830eb 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -57,6 +57,7 @@ INPUT   = doc/api/doxy-api-index.md \
   lib/librte_reorder \
   lib/librte_ring \
   lib/librte_sched \
+  lib/librte_metrics \
   lib/librte_table \
   lib/librte_timer \
   lib/librte_vhost
diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 3b65038..e1b8894 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -34,6 +34,12 @@ New Features

  Refer to the previous release notes for examples.

+   * **Added information metric library.**
+
+ A library that allows information metrics to be added and update. It is
+ intended to provide a reporting mechanism that is independent of the
+ ethdev library.
+
  This section is a comment. do not overwrite or remove it.
  Also, make sure to start the actual text at the margin.
  =
diff --git a/lib/Makefile b/lib/Makefile
index 990f23a..5d85dcf 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -58,6 +58,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TABLE) += librte_table
 DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
 DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder
 DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump
+DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics

 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
diff --git a/lib/librte_metrics/Makefile b/lib/librte_metrics/Makefile
new file mode 100644
index 000..8d6e23a
--- /dev/null
+++ b/lib/librte_metrics/Makefile
@@ -0,0 +1,51 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its

[dpdk-dev] [PATCH v4 0/3] Expanded statistics reporting

2016-11-15 Thread 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.

--

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

-- 
2.5.5



[dpdk-dev] [PATCH v1] doc: add template release notes for 17.02

2016-11-14 Thread Remy Horton

On 14/11/2016 20:31, John McNamara wrote:
> Add template release notes for DPDK 17.02 with inline
> comments and explanations of the various sections.
>
> Signed-off-by: John McNamara 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v1 2/2] net/i40e: fix spelling errors

2016-11-14 Thread Remy Horton
Fixes: da61cd084976 ("i40evf: add extended stats")
Fixes: 0eedec25ea36 ("i40e: clean log messages")

Signed-off-by: Remy Horton 
---
 drivers/net/i40e/i40e_ethdev.c| 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67778ba..f102328 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -4107,7 +4107,7 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
ret = i40e_aq_get_veb_parameters(hw, veb->seid, NULL, NULL,
>stats_idx, NULL, NULL, NULL);
if (ret != I40E_SUCCESS) {
-   PMD_DRV_LOG(ERR, "Get veb statics index failed, aq_err: %d",
+   PMD_DRV_LOG(ERR, "Get veb statistics index failed, aq_err: %d",
hw->aq.asq_last_status);
goto fail;
}
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index afae2ec..1431b6e 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -952,7 +952,7 @@ i40evf_update_stats(struct rte_eth_dev *dev, struct 
i40e_eth_stats **pstats)
 }

 static int
-i40evf_get_statics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+i40evf_get_statistics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
int ret;
struct i40e_eth_stats *pstats = NULL;
@@ -2277,8 +2277,8 @@ i40evf_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 static void
 i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
-   if (i40evf_get_statics(dev, stats))
-   PMD_DRV_LOG(ERR, "Get statics failed");
+   if (i40evf_get_statistics(dev, stats))
+   PMD_DRV_LOG(ERR, "Get statistics failed");
 }

 static void
-- 
2.5.5



[dpdk-dev] [PATCH v1 1/2] net/i40e: fix incorrect xstats value mapping

2016-11-14 Thread Remy Horton
The offsets used in rte_i40evf_stats_strings for transmission
statistics were wrong, returning the total byte count rather than
the respective (unicast, multicast, broadcast, drop, & error)
packet counts.

Fixes: da61cd084976 ("i40evf: add extended stats")

Signed-off-by: Remy Horton 
---
 drivers/net/i40e/i40e_ethdev_vf.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index aa306d6..afae2ec 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -176,11 +176,11 @@ static const struct rte_i40evf_xstats_name_off 
rte_i40evf_stats_strings[] = {
{"rx_unknown_protocol_packets", offsetof(struct i40e_eth_stats,
rx_unknown_protocol)},
{"tx_bytes", offsetof(struct i40e_eth_stats, tx_bytes)},
-   {"tx_unicast_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
-   {"tx_multicast_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
-   {"tx_broadcast_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
-   {"tx_dropped_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
-   {"tx_error_packets", offsetof(struct i40e_eth_stats, tx_bytes)},
+   {"tx_unicast_packets", offsetof(struct i40e_eth_stats, tx_unicast)},
+   {"tx_multicast_packets", offsetof(struct i40e_eth_stats, tx_multicast)},
+   {"tx_broadcast_packets", offsetof(struct i40e_eth_stats, tx_broadcast)},
+   {"tx_dropped_packets", offsetof(struct i40e_eth_stats, tx_discards)},
+   {"tx_error_packets", offsetof(struct i40e_eth_stats, tx_errors)},
 };

 #define I40EVF_NB_XSTATS (sizeof(rte_i40evf_stats_strings) / \
-- 
2.5.5



[dpdk-dev] [PATCH v1 0/2] XStats fixes

2016-11-14 Thread Remy Horton
The offsets used in rte_i40evf_stats_strings for transmission
statistics were wrong, returning the total byte count rather than
the respective (unicast, multicast, broadcast, drop, & error)
packet counts.

This patchset also fixes some spelling errors.

Fixes: da61cd084976 ("i40evf: add extended stats")
Fixes: 0eedec25ea36 ("i40e: clean log messages")

Remy Horton (2):
  net/i40e: fix incorrect xstats value mapping
  net/i40e: fix spelling errors

 drivers/net/i40e/i40e_ethdev.c|  2 +-
 drivers/net/i40e/i40e_ethdev_vf.c | 16 
 2 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.5.5



[dpdk-dev] [PATCH v4] latencystats: added new library for latency stats

2016-11-11 Thread Remy Horton

On 07/11/2016 21:14, Reshma Pattan wrote:
[..]
 > Signed-off-by: Reshma Pattan 

Reviewed-by: Remy Horton 


 > +static void
 > +metrics_display(int port_id)
 > +{
 > +struct rte_stat_value *stats;
 > +struct rte_metric_name *names;

Note that rte_stats_value is being renamed to rte_metric_value in the 
next version of the metrics library..


 > +int
 > +rte_latencystats_init(uint64_t samp_intvl,
 > +rte_latency_stats_flow_type_fn user_cb)
 > +{

Far as I can tell, user_cb is always NULL, and the two callbacks it 
eventually get passed to don't use it. There any reason the function 
signature has it at all?


 > +++ b/lib/librte_latencystats/rte_latencystats_version.map
 > @@ -0,0 +1,10 @@
 > +DPDK_16.11 {

This will need to change to 17.02 once new release cycle starts. :)

Will also need to add entry to release_17_02.rst once it becomes available..

..Remy


[dpdk-dev] [PATCH] doc: remove iomem and ioport handling in igb_uio

2016-11-11 Thread Remy Horton

On 22/09/2016 13:44, Jianfeng Tan wrote:
[..]
>
> Suggested-by: Yigit, Ferruh 
> Signed-off-by: Jianfeng Tan 

Acked-by: Remy Horton 


> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -57,3 +57,8 @@ Deprecation Notices
>  * API will change for ``rte_port_source_params`` and ``rte_port_sink_params``
>structures. The member ``file_name`` data type will be changed from
>``char *`` to ``const char *``. This change targets release 16.11.

As an aside I don't think changing a structure entry to const will 
affect its binary layout, so this ought not be an ABI break..


[dpdk-dev] [PATCH v3 1/3] lib: add information metrics library

2016-11-08 Thread Remy Horton

On 07/11/2016 23:25, Pattan, Reshma wrote:
[..]
>>> + * Initialises statistic module. This only has to be explicitly
>>> +called
>>
>> Typo < Initialises>
>
> To avoid confusion, here I mean to say "Initializes" should be used (i.e. US 
> English) .

Sorta guessed that.. :)


> Also another non-related comment, you may need to add a comment about EMWA
> near the mean bit rate calculation code.

Quite a few comments needed updating. Going to hold off the v5 until 
16.11 is out as I'll also need to change all the references to 17.02..

..Remy


[dpdk-dev] Best Practices for PMD Verification before Upstream Requests

2016-11-04 Thread Remy Horton

On 02/11/2016 20:21, Shepard Siegel wrote:
[..]
> Almost a year into our DPDK development, we have shipped an alpha version
> of our "Arkville" product. We've thankful for all the support from this
> Most everyone has suggested "get your code upstream ASAP"; but our
> team is cut from the "if it isn't tested, it doesn't work" cloth. We now
> have some solid miles on our Arkville PMD driver "ark" with 16.07. Mostly
> testpmd and a suite of user apps; dts not so much, only because our use
> case is a little different.

To me that sounds good enough for a v1 patch.


> One question that
> came up is "Should we do a thorough port and regression against 16.11 as a
> precursor to up streaming at 17.02?". Constructive feedback always welcome!

It is helpful, although bear in mind there is only so much you'll be 
able to test. Patches sent to the mailing list are picked up by 
patchwork for automated testing, so you'll find out quite quickly if 
you've broken something.

And avoid top-posting.. :)

..Remy


[dpdk-dev] [PATCH v3 3/3] app/test-pmd: add support for bitrate statistics

2016-11-04 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 app/test-pmd/testpmd.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 6185be6..3cf4795 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -78,6 +78,8 @@
 #ifdef RTE_LIBRTE_PDUMP
 #include 
 #endif
+#include 
+#include 

 #include "testpmd.h"

@@ -322,6 +324,9 @@ uint16_t nb_rx_queue_stats_mappings = 0;

 unsigned max_socket = 0;

+/* Bitrate statistics */
+struct rte_stats_bitrates_s *bitrate_data;
+
 /* Forward function declarations */
 static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port 
*port);
 static void check_all_ports_link_status(uint32_t port_mask);
@@ -921,12 +926,26 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t 
pkt_fwd)
struct fwd_stream **fsm;
streamid_t nb_fs;
streamid_t sm_id;
-
+   uint64_t tics_per_1sec;
+   uint64_t tics_datum;
+   uint64_t tics_current;
+   uint8_t idx_port, cnt_ports;
+
+   cnt_ports = rte_eth_dev_count();
+   tics_datum = rte_rdtsc();
+   tics_per_1sec = rte_get_timer_hz();
fsm = _streams[fc->stream_idx];
nb_fs = fc->stream_nb;
do {
for (sm_id = 0; sm_id < nb_fs; sm_id++)
(*pkt_fwd)(fsm[sm_id]);
+   tics_current = rte_rdtsc();
+   if (tics_current - tics_datum >= tics_per_1sec) {
+   /* Periodic bitrate calculation */
+   for (idx_port = 0; idx_port < cnt_ports; idx_port++)
+   rte_stats_bitrate_calc(bitrate_data, idx_port);
+   tics_datum = tics_current;
+   }
} while (! fc->stopped);
 }

@@ -2128,6 +2147,13 @@ main(int argc, char** argv)
FOREACH_PORT(port_id, ports)
rte_eth_promiscuous_enable(port_id);

+   /* Setup bitrate stats */
+   bitrate_data = rte_stats_bitrate_create();
+   if (bitrate_data == NULL)
+   rte_exit(EXIT_FAILURE, "Could not allocate bitrate data.\n");
+   rte_stats_bitrate_reg(bitrate_data);
+
+
 #ifdef RTE_LIBRTE_CMDLINE
if (interactive == 1) {
if (auto_start) {
-- 
2.5.5



[dpdk-dev] [PATCH v3 2/3] lib: add bitrate statistics library

2016-11-04 Thread Remy Horton
This patch adds a library that calculates peak and average data-rate
statistics. For ethernet devices. These statistics are reported using
the metrics library.

Signed-off-by: Remy Horton 
---
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 doc/guides/rel_notes/release_16_11.rst |   5 +
 lib/Makefile   |   1 +
 lib/librte_bitratestats/Makefile   |  53 +
 lib/librte_bitratestats/rte_bitrate.c  | 128 +
 lib/librte_bitratestats/rte_bitrate.h  |  80 +
 .../rte_bitratestats_version.map   |   9 ++
 mk/rte.app.mk  |   1 +
 10 files changed, 284 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

diff --git a/config/common_base b/config/common_base
index 2277727..25c3911 100644
--- a/config/common_base
+++ b/config/common_base
@@ -594,3 +594,8 @@ CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n
 # Compile the device metrics library
 #
 CONFIG_RTE_LIBRTE_METRICS=y
+
+#
+# Compile the bitrate statistics library
+#
+CONFIG_RTE_LIBRTE_BITRATE=y
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index ca50fa6..91e8ea6 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -148,4 +148,5 @@ There are many libraries, so their headers may be grouped 
by topics:
   [ABI compat] (@ref rte_compat.h),
   [keepalive]  (@ref rte_keepalive.h),
   [Device Metrics] (@ref rte_metrics.h),
+  [Bitrate Statistics] (@ref rte_bitrate.h),
   [version](@ref rte_version.h)
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index fe830eb..8765ddd 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -58,6 +58,7 @@ INPUT   = doc/api/doxy-api-index.md \
   lib/librte_ring \
   lib/librte_sched \
   lib/librte_metrics \
+  lib/librte_bitratestats \
   lib/librte_table \
   lib/librte_timer \
   lib/librte_vhost
diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index 507f715..b690b72 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -137,6 +137,11 @@ New Features
   intended to provide a reporting mechanism that is independent of the
   ethdev library.

+* **Added bit-rate calculation library.**
+
+  A library that can be used to calculate device bit-rates. Calculated
+  bitrates are reported using the metrics library.
+

 Resolved Issues
 ---
diff --git a/lib/Makefile b/lib/Makefile
index 5d85dcf..e211bc0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -59,6 +59,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
 DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder
 DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump
 DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics
+DIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += librte_bitratestats

 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
diff --git a/lib/librte_bitratestats/Makefile b/lib/librte_bitratestats/Makefile
new file mode 100644
index 000..b725d4e
--- /dev/null
+++ b/lib/librte_bitratestats/Makefile
@@ -0,0 +1,53 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTI

[dpdk-dev] [PATCH v3 1/3] lib: add information metrics library

2016-11-04 Thread Remy Horton
This patch adds a new information metric library that allows other
modules to register named metrics and update their values. It is
intended to be independent of ethdev, rather than mixing ethdev
and non-ethdev information in xstats.

Signed-off-by: Remy Horton 
---
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 doc/guides/rel_notes/release_16_11.rst |   6 +
 lib/Makefile   |   1 +
 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  |   2 +
 10 files changed, 584 insertions(+)
 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

diff --git a/config/common_base b/config/common_base
index 21d18f8..2277727 100644
--- a/config/common_base
+++ b/config/common_base
@@ -589,3 +589,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n
 CONFIG_RTE_TEST_PMD=y
 CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n
 CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n
+
+#
+# Compile the device metrics library
+#
+CONFIG_RTE_LIBRTE_METRICS=y
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index 6675f96..ca50fa6 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -147,4 +147,5 @@ There are many libraries, so their headers may be grouped 
by topics:
   [common] (@ref rte_common.h),
   [ABI compat] (@ref rte_compat.h),
   [keepalive]  (@ref rte_keepalive.h),
+  [Device Metrics] (@ref rte_metrics.h),
   [version](@ref rte_version.h)
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index 9dc7ae5..fe830eb 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -57,6 +57,7 @@ INPUT   = doc/api/doxy-api-index.md \
   lib/librte_reorder \
   lib/librte_ring \
   lib/librte_sched \
+  lib/librte_metrics \
   lib/librte_table \
   lib/librte_timer \
   lib/librte_vhost
diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index aa0c09a..507f715 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -131,6 +131,12 @@ New Features
   The GCC 4.9 ``-march`` option supports the Intel processor code names.
   The config option ``RTE_MACHINE`` can be used to pass code names to the 
compiler as ``-march`` flag.

+* **Added information metric library.**
+
+  A library that allows information metrics to be added and update. It is
+  intended to provide a reporting mechanism that is independent of the
+  ethdev library.
+

 Resolved Issues
 ---
diff --git a/lib/Makefile b/lib/Makefile
index 990f23a..5d85dcf 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -58,6 +58,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TABLE) += librte_table
 DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
 DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder
 DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump
+DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics

 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
diff --git a/lib/librte_metrics/Makefile b/lib/librte_metrics/Makefile
new file mode 100644
index 000..8d6e23a
--- /dev/null
+++ b/lib/librte_metrics/Makefile
@@ -0,0 +1,51 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

[dpdk-dev] [PATCH v3 0/3] Expanded statistics reporting

2016-11-04 Thread 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.

--

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

-- 
2.5.5



[dpdk-dev] [PATCH] ethdev: fix statistics description

2016-11-03 Thread Remy Horton

On 02/11/2016 17:07, Mcnamara, John wrote:
[..]
> Perhaps we could an API that returns a struct, or otherwise, that
> indicated what stats are returned by a PMD. An application that
> required stats could call it once to establish what stats were
> available. It would have to be done in some way that wouldn't break
> ABI every time a new stat was added.
>
> Harry, Remy, how would this fit in with the existing stats scheme or
> the new metrics library.

At the moment xstats (rte_eth_xstats_get()) pulls stuff out of 
rte_eth_stats and reports them unconditionally alongside all the 
driver-specific xstats. This could change so that it only reports the 
(legacy) stats the PMDs actually fills in.

Personally in the longer term I think xstats should get all the info it 
requires directly rather than relying on the legacy stats for some of 
its info, but that would involve pushing a lot of common code into the 
PMDs..

..Remy


[dpdk-dev] [RFC PATCH v2 2/3] lib: add bitrate statistics library

2016-11-01 Thread Remy Horton

On 28/10/2016 15:39, Morten Br?rup wrote:
> Comments below.
[..]
> When working with statistical calculations using integer arithmetic,
> you should round off the integer result by adding 0.5 to the result,
> which you do by adding half of the divisor to the dividend, like
> this:
>
> delta = (delta * alpha_percent + 50) / 100;
>
> The numbers in this particular case are probably very big, so not
> rounding off doesn't affect the result a lot; but then you should add
> a comment about why rounding down is acceptable.

A minor point, but will roll it into the next patchset.


[dpdk-dev] [RFC PATCH v2 2/3] lib: add bitrate statistics library

2016-10-28 Thread Remy Horton

On 28/10/2016 09:12, Stephen Hemminger wrote:
> On Fri, 28 Oct 2016 09:04:30 +0800
> Remy Horton  wrote:
>
>> +
>> +struct rte_stats_bitrate_s {
>> +uint64_t last_ibytes;
>> +uint64_t last_obytes;
>> +uint64_t peak_ibits;
>> +uint64_t peak_obits;
>> +uint64_t ewma_ibits;
>> +uint64_t ewma_obits;
>> +};
>> +
>
> Reader/write access of 64 bit values is not safe on 32 bit platforms.
> I think you need to add a generation counter (see Linux kernel syncp)
> to handle 32 bit architecture. If done correctly, it would be a nop
> on 64 bit platforms.

I don't see a problem since this is private persistent data that is only 
read/written from rte_stats_bitrate_calc(), and once calculated it 
pushes them into the metrics library using rte_metrics_update_metrics(). 
The idea is that downstream consumers get the values using 
rte_metrics_get_values() rather than reading rte_stats_bitrate_s directly.

Having said that, what you mention quite likley affects the metrics 
library itself.. :)


[dpdk-dev] [RFC PATCH v2 3/3] app/test-pmd: add support for bitrate statistics

2016-10-28 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 app/test-pmd/testpmd.c | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e2403c3..940dc3b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -78,6 +78,8 @@
 #ifdef RTE_LIBRTE_PDUMP
 #include 
 #endif
+#include 
+#include 

 #include "testpmd.h"

@@ -322,6 +324,9 @@ uint16_t nb_rx_queue_stats_mappings = 0;

 unsigned max_socket = 0;

+/* Bitrate statistics */
+struct rte_stats_bitrates_s *bitrate_data;
+
 /* Forward function declarations */
 static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port 
*port);
 static void check_all_ports_link_status(uint32_t port_mask);
@@ -921,12 +926,26 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t 
pkt_fwd)
struct fwd_stream **fsm;
streamid_t nb_fs;
streamid_t sm_id;
-
+   uint64_t tics_per_1sec;
+   uint64_t tics_datum;
+   uint64_t tics_current;
+   uint8_t idx_port, cnt_ports;
+
+   cnt_ports = rte_eth_dev_count();
+   tics_datum = rte_rdtsc();
+   tics_per_1sec = rte_get_timer_hz();
fsm = _streams[fc->stream_idx];
nb_fs = fc->stream_nb;
do {
for (sm_id = 0; sm_id < nb_fs; sm_id++)
(*pkt_fwd)(fsm[sm_id]);
+   tics_current = rte_rdtsc();
+   if (tics_current - tics_datum >= tics_per_1sec) {
+   /* Periodic bitrate calculation */
+   for (idx_port = 0; idx_port < cnt_ports; idx_port++)
+   rte_stats_bitrate_calc(bitrate_data, idx_port);
+   tics_datum = tics_current;
+   }
} while (! fc->stopped);
 }

@@ -2119,6 +2138,15 @@ main(int argc, char** argv)
FOREACH_PORT(port_id, ports)
rte_eth_promiscuous_enable(port_id);

+   /* Setup bitrate stats */
+   bitrate_data = rte_stats_bitrate_create();
+   if (bitrate_data == NULL)
+   rte_exit(EXIT_FAILURE, "Could not allocate bitrate data.\n");
+   rte_stats_bitrate_reg(bitrate_data);
+   int id_const = rte_metrics_reg_metric("constant");
+   rte_metrics_update_metric(55, id_const, 0xdeadbeef);
+
+
 #ifdef RTE_LIBRTE_CMDLINE
if (interactive == 1) {
if (auto_start) {
-- 
2.5.5



[dpdk-dev] [RFC PATCH v2 2/3] lib: add bitrate statistics library

2016-10-28 Thread Remy Horton
This patch adds a library that calculates peak and average data-rate
statistics. For ethernet devices. These statistics are reported using
the metrics library.

Signed-off-by: Remy Horton 
---
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 lib/Makefile   |   1 +
 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/rte_metrics.c   |  22 ++--
 lib/librte_metrics/rte_metrics.h   |   4 +-
 mk/rte.app.mk  |   1 +
 11 files changed, 291 insertions(+), 12 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

diff --git a/config/common_base b/config/common_base
index c23a632..e778c00 100644
--- a/config/common_base
+++ b/config/common_base
@@ -597,3 +597,8 @@ CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n
 # Compile the device metrics library
 #
 CONFIG_RTE_LIBRTE_METRICS=y
+
+#
+# Compile the bitrate statistics library
+#
+CONFIG_RTE_LIBRTE_BITRATE=y
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index ca50fa6..91e8ea6 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -148,4 +148,5 @@ There are many libraries, so their headers may be grouped 
by topics:
   [ABI compat] (@ref rte_compat.h),
   [keepalive]  (@ref rte_keepalive.h),
   [Device Metrics] (@ref rte_metrics.h),
+  [Bitrate Statistics] (@ref rte_bitrate.h),
   [version](@ref rte_version.h)
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index fe830eb..8765ddd 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -58,6 +58,7 @@ INPUT   = doc/api/doxy-api-index.md \
   lib/librte_ring \
   lib/librte_sched \
   lib/librte_metrics \
+  lib/librte_bitratestats \
   lib/librte_table \
   lib/librte_timer \
   lib/librte_vhost
diff --git a/lib/Makefile b/lib/Makefile
index 5d85dcf..e211bc0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -59,6 +59,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
 DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder
 DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump
 DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics
+DIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += librte_bitratestats

 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
diff --git a/lib/librte_bitratestats/Makefile b/lib/librte_bitratestats/Makefile
new file mode 100644
index 000..b725d4e
--- /dev/null
+++ b/lib/librte_bitratestats/Makefile
@@ -0,0 +1,53 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library

[dpdk-dev] [RFC PATCH v2 1/3] lib: add information metrics library

2016-10-28 Thread Remy Horton
This patch adds a new information metric library that allows other
modules to register named metrics and update their values. It is
intended to be independent of ethdev, rather than mixing ethdev
and non-ethdev information in xstats.

Signed-off-by: Remy Horton 
---
 config/common_base |   5 +
 doc/api/doxy-api-index.md  |   1 +
 doc/api/doxy-api.conf  |   1 +
 lib/Makefile   |   1 +
 lib/librte_metrics/Makefile|  51 ++
 lib/librte_metrics/rte_metrics.c   | 265 +
 lib/librte_metrics/rte_metrics.h   | 200 ++
 lib/librte_metrics/rte_metrics_version.map |  13 ++
 mk/rte.app.mk  |   2 +
 9 files changed, 539 insertions(+)
 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

diff --git a/config/common_base b/config/common_base
index f5d2eff..c23a632 100644
--- a/config/common_base
+++ b/config/common_base
@@ -592,3 +592,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n
 CONFIG_RTE_TEST_PMD=y
 CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n
 CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n
+
+#
+# Compile the device metrics library
+#
+CONFIG_RTE_LIBRTE_METRICS=y
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index 6675f96..ca50fa6 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -147,4 +147,5 @@ There are many libraries, so their headers may be grouped 
by topics:
   [common] (@ref rte_common.h),
   [ABI compat] (@ref rte_compat.h),
   [keepalive]  (@ref rte_keepalive.h),
+  [Device Metrics] (@ref rte_metrics.h),
   [version](@ref rte_version.h)
diff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf
index 9dc7ae5..fe830eb 100644
--- a/doc/api/doxy-api.conf
+++ b/doc/api/doxy-api.conf
@@ -57,6 +57,7 @@ INPUT   = doc/api/doxy-api-index.md \
   lib/librte_reorder \
   lib/librte_ring \
   lib/librte_sched \
+  lib/librte_metrics \
   lib/librte_table \
   lib/librte_timer \
   lib/librte_vhost
diff --git a/lib/Makefile b/lib/Makefile
index 990f23a..5d85dcf 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -58,6 +58,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TABLE) += librte_table
 DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
 DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder
 DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump
+DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics

 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
diff --git a/lib/librte_metrics/Makefile b/lib/librte_metrics/Makefile
new file mode 100644
index 000..8d6e23a
--- /dev/null
+++ b/lib/librte_metrics/Makefile
@@ -0,0 +1,51 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# library name
+LIB = librte_metrics.a
+
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
+
+EXPORT_MAP := rte_metrics_version.map
+
+LIBABIVER := 1
+
+# all source are stored in SR

[dpdk-dev] [PATCH v2 0/3] expanded statistic reporting

2016-10-28 Thread 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.

--

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

-- 
2.5.5



[dpdk-dev] [PATCH] dpdk-procinfo: free allocated xstats memory upon failure

2016-10-12 Thread Remy Horton

On 04/10/2016 17:42, Reshma Pattan wrote:
> Some of the failures cases inside the nic_xstats_display()
> function doesn't free the allocated memory for the xstats and
> their names, memory is freed now.
>
> Fixes: e2aae1c1 ("ethdev: remove name from extended statistic fetch")
> Fixes: 22561383 ("app: replace dump_cfg by proc_info")
>
> Signed-off-by: Reshma Pattan 

Acked-by: Remy Horton 



[dpdk-dev] [PATCH] pdump: fix dir permissions value in mkdir call

2016-10-10 Thread Remy Horton

On 10/10/2016 15:35, Reshma Pattan wrote:
[..]
> Fixes: e4ffa2d3 ("pdump: fix error handlings")
> Fixes: bdd8dcc6 ("pdump: fix default socket path")
>
> Reported-by: Jianfeng Tan 
> Signed-off-by: Reshma Pattan 
> ---
>  lib/librte_pdump/rte_pdump.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Acked-by: Remy Horton 


[dpdk-dev] ixgbe: support checksum flags in sse vector Rx function

2016-10-06 Thread Remy Horton

On 07/07/2016 13:19, Olivier Matz wrote:
[..]
> Signed-off-by: Maxime Leroy 
> Signed-off-by: Olivier Matz 
> ---
>  drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  8 ++---
>  drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c   |  6 
>  drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c| 50 
> +--
>  3 files changed, 42 insertions(+), 22 deletions(-)

Acked-by: Remy Horton 


[dpdk-dev] [PATCH 2/2] kni: remove unnecessary ethtool files

2016-10-05 Thread Remy Horton


On 30/09/2016 11:10, Ferruh Yigit wrote:
> Signed-off-by: Ferruh Yigit 
> ---
>  lib/librte_eal/linuxapp/kni/Makefile   |   3 -
>  .../linuxapp/kni/ethtool/igb/igb_debugfs.c |  28 --
>  .../linuxapp/kni/ethtool/igb/igb_hwmon.c   | 260 ---
>  .../linuxapp/kni/ethtool/igb/igb_procfs.c  | 363 
> -
>  4 files changed, 654 deletions(-)
>  delete mode 100644 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_debugfs.c
>  delete mode 100644 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_hwmon.c
>  delete mode 100644 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_procfs.c

Acked-by: Remy Horton 


[dpdk-dev] [PATCH 1/2] kni: remove unused ethtool files

2016-10-05 Thread Remy Horton


On 30/09/2016 11:10, Ferruh Yigit wrote:
> Signed-off-by: Ferruh Yigit 
> ---
>  lib/librte_eal/linuxapp/kni/Makefile   |2 -
>  lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ptp.c  |  944 -
>  lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.c  | 1482 
> 
>  .../linuxapp/kni/ethtool/igb/kcompat_ethtool.c | 1171 
>  .../linuxapp/kni/ethtool/ixgbe/ixgbe_sriov.h   |   73 -
>  5 files changed, 3672 deletions(-)
>  delete mode 100644 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ptp.c
>  delete mode 100644 lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.c
>  delete mode 100644 lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat_ethtool.c
>  delete mode 100644 lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_sriov.h

Acked-by: Remy Horton 


[dpdk-dev] OpenSSL and non-BSD licenses in DPDK

2016-09-01 Thread Remy Horton
Morning,

On 31/08/2016 18:26, Bodek, Zbigniew wrote:
[..]
> I would like to ask a question regarding code licensing and importing code 
> that
> uses different license than BSD-like. Especially I'm curious about the code
> that goes with OpenSSL/SSLeay license. Is it allowed to import such sources
> (or derived work) to DPDK? I've seen some GPL stuff, mostly kernel modules 
> from
> Intel. So what with the above mentioned OpenSSL?

It is not my call to make, but my guess is the answer will almost 
certainly be "No". DPDK makes it way into commercial products, and the 
companies concerned (well, their lawyers actually..) most likley won't 
like the prospect of extra licencing conditions slipping in.

..Remy


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

2016-08-29 Thread Remy Horton

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 = >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.



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

2016-08-24 Thread Remy Horton
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 
---
 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(-)

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 = _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 = >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 = _eth_devices[port_id];
+   dev_stats = >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_

[dpdk-dev] [RFC 0/4] Use Google Test as DPDK unit test framework

2016-08-05 Thread Remy Horton

On 05/08/2016 13:59, Neil Horman wrote:
> On Fri, Aug 05, 2016 at 10:11:56AM +0100, Remy Horton wrote:
[..]
>> Cmocka's mocking relies on Gnu ld's --wrap feature, which has problems if
>> the function being mocked is defined in the same compilation unit that it is
>> used. Pity really as otherwise it looked quite good to me.
>>
> Can't you use ld's --undefined option to get the correct behavior?  I thought
> that was specifically what it was there for.

Not sure - I'll try playing around with it when I next have some spare 
time.. :)

The C-Mock extension (https://github.com/hjagodzinski/C-Mock) for GMock 
uses some dynamic linker trickery which I'm guessing is probably not C++ 
specific, and I quite like that approach as it avoids the need to 
pre-specify in makefiles which functions are to be mocked.

..Remy


[dpdk-dev] [RFC 0/4] Use Google Test as DPDK unit test framework

2016-08-05 Thread Remy Horton

On 05/08/2016 08:41, Yerden Zhumabekov wrote:
[..]
> We use cmocka.org for tests. Written in C. It has support for:
> * mocking;
> * setup/teardown;
> * asserts;
> * test groups.
>
> Output is nicely formatted.

Cmocka's mocking relies on Gnu ld's --wrap feature, which has problems 
if the function being mocked is defined in the same compilation unit 
that it is used. Pity really as otherwise it looked quite good to me.

..Remy


[dpdk-dev] [RFC 0/4] Use Google Test as DPDK unit test framework

2016-08-03 Thread Remy Horton

On 02/08/2016 22:52, Thomas Monjalon wrote:
> 2016-08-02 21:37, Declan Doherty:
[..]
> You are not advocating but the unit test must be written in C++.
> I don't think it is a good idea to force people to write and maintain the 
> tests
> in a different language than the code it tests.

In principle I agree, but in practice I don't see any alternative. All 
the purely C-based frameworks I've (independently of Declan) tried don't 
have the same flexibility as the C++ ones.


> It would be interesting to better describe in details what is missing 
> currently
> and what such a framework can bring.
> (I agree there is a huge room for improvements on unit tests)

 From my own perspective, mocking of functions is the main thing that is 
missing. When testing KeepAlive this allowed me to reroute rte_malloc() 
calls to the OS malloc() rather than having to startup/teardown the 
hugepage subsystem.

..Remy


[dpdk-dev] [PATCH v1] ether: fix overwriting driver-specific stats

2016-07-19 Thread Remy Horton
After doing a driver callout to fill in the driver specific
parts of struct rte_eth_stats, rte_eth_stats_get() overwrites
the rx_nombuf member regardless of whether the driver itself
has assigned a value. Any driver-assigned value should take
priority.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Remy Horton 
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0a6e3f1..f62a9ec 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1490,8 +1490,8 @@ rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats 
*stats)
memset(stats, 0, sizeof(*stats));

RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP);
-   (*dev->dev_ops->stats_get)(dev, stats);
stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
+   (*dev->dev_ops->stats_get)(dev, stats);
return 0;
 }

-- 
2.5.5



[dpdk-dev] rte_ether: Driver-specific stats getting overwritten

2016-07-14 Thread Remy Horton

On 14/07/2016 14:51, Igor Ryzhov wrote:
[..]
> How about deleting rx_nombuf from rte_eth_stats? Do you think this
> counter is necessary? It just shows enormous numbers in case of a
> lack of processing speed. But we already have imissed counter which
> shows real number of packets, dropped for the same reason.

Deleting it has API/ABI breakage issues. There is also lack of 
consistency between drivers as to what imissed includes, as some don't 
implement it at all whereas others include filtered packets as well.


>> 14  2016 ?., ? 16:37, Thomas Monjalon
>>  ???(?):
>>
[..]
>> Yes it is strange and has always been like that. Why not moving the
>> assignment before calling the driver callback?

Think I'll do that. Easier than updating all the drivers that don't fill 
it in..



[dpdk-dev] rte_ether: Driver-specific stats getting overwritten

2016-07-14 Thread Remy Horton
'noon,

In rte_eth_stats_get() after doing the driver callout to populate struct 
rte_eth_stats, the rx_nombuf member is overwritten with 
dev->data->rx_mbuf_alloc_failed even though some drivers will have 
filled rx_nombuf with a value from elsewhere. This makes assignment of 
rx_nombuf from within the driver callout redundant. Is this intentional?

..Remy


[dpdk-dev] [PATCH v1] ethdev: fix xstats id mismatch

2016-07-08 Thread Remy Horton
When fetching xstats values the driver specific parameters are
placed after the generic ones, but when fetching xstats names
the driver specific parameter names came first. This patch fixes
the resulting id mismatch between names and values.

Fixes: bd6aa172cf35 ("ethdev: fetch extended statistics with integer ids")

Signed-off-by: Remy Horton 
---
 lib/librte_ether/rte_ethdev.c | 32 +++-
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index eac260f..80b4d90 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1536,6 +1536,7 @@ rte_eth_xstats_get_names(uint8_t port_id,
struct rte_eth_dev *dev;
int cnt_used_entries;
int cnt_expected_entries;
+   int cnt_driver_entries;
uint32_t idx, id_queue;

cnt_expected_entries = get_xstats_count(port_id);
@@ -1545,16 +1546,7 @@ rte_eth_xstats_get_names(uint8_t port_id,

/* port_id checked in get_xstats_count() */
dev = _eth_devices[port_id];
-   if (dev->dev_ops->xstats_get_names != NULL) {
-   cnt_used_entries = (*dev->dev_ops->xstats_get_names)(
-   dev, xstats_names, size);
-   if (cnt_used_entries < 0)
-   return cnt_used_entries;
-   } else
-   /* Driver itself does not support extended stats, but
-* still have basic stats.
-*/
-   cnt_used_entries = 0;
+   cnt_used_entries = 0;

for (idx = 0; idx < RTE_NB_STATS; idx++) {
snprintf(xstats_names[cnt_used_entries].name,
@@ -1581,6 +1573,20 @@ rte_eth_xstats_get_names(uint8_t port_id,
cnt_used_entries++;
}
}
+
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   /* If there are any driver-specific xstats, append them
+* to end of list.
+*/
+   cnt_driver_entries = (*dev->dev_ops->xstats_get_names)(
+   dev,
+   xstats_names + cnt_used_entries,
+   size - cnt_used_entries);
+   if (cnt_driver_entries < 0)
+   return cnt_driver_entries;
+   cnt_used_entries += cnt_driver_entries;
+   }
+
return cnt_used_entries;
 }

@@ -1628,7 +1634,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat 
*xstats,
stats_ptr = RTE_PTR_ADD(_stats,
rte_stats_strings[i].offset);
val = *stats_ptr;
-   xstats[count].id = count + xcount;
xstats[count++].value = val;
}

@@ -1639,7 +1644,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat 
*xstats,
rte_rxq_stats_strings[i].offset +
q * sizeof(uint64_t));
val = *stats_ptr;
-   xstats[count].id = count + xcount;
xstats[count++].value = val;
}
}
@@ -1651,11 +1655,13 @@ rte_eth_xstats_get(uint8_t port_id, struct 
rte_eth_xstat *xstats,
rte_txq_stats_strings[i].offset +
q * sizeof(uint64_t));
val = *stats_ptr;
-   xstats[count].id = count + xcount;
xstats[count++].value = val;
}
}

+   for (i = 0; i < count + xcount; i++)
+   xstats[i].id = i;
+
return count + xcount;
 }

-- 
2.5.5



[dpdk-dev] xstats performance

2016-07-08 Thread Remy Horton

On 07/07/2016 23:59, Rasesh Mody wrote:
[..]
> We have submitted the QEDE and BNX2X PMD xstats patches with recent
> API changes.

Seen & Acked.


> During the xstats change verification, it was observed that the order
> in which xstats names are fetched don't seem to match the order in
> which xstats values are fetched. When populating the xstats names, we
> order them as driver specific xstats names and then standard stats
> names. Whereas, while populating the xstats values, we populate the
> standard stats values and then the driver specific xstats values.

Had a look. Patch on the way..

..Remy


[dpdk-dev] [PATCH 2/2] bnx2x: add support for xstats

2016-07-08 Thread Remy Horton

On 07/07/2016 23:50, Rasesh Mody wrote:
> This patch adds support for extended statistics for BNX2X PMD.
>
> Signed-off-by: Rasesh Mody 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH 1/2] qede: add support for xstats

2016-07-08 Thread Remy Horton

On 07/07/2016 23:50, Rasesh Mody wrote:
> This patch adds support for extended statistics for QEDE PMD.
>
> Signed-off-by: Rasesh Mody 

Acked-by: Remy Horton 


[dpdk-dev] xstats performance

2016-07-06 Thread Remy Horton

On 05/07/2016 19:10, Rasesh Mody wrote:
[..]
>> For all the current drivers xstats_names[idx].id==idx so it would just
>> involve removing the references to the id field and updating the
>> documentation. Complication is coordinating with QLogic for the bnx2x &
>> qede xstats patches.
>
> We could incorporate this change in our re-submission.

The changes mentioned above have been merged in, so go ahead.. :)


[dpdk-dev] [PATCH v6 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params

2016-07-04 Thread Remy Horton

On 04/07/2016 12:36, Zyta Szpak wrote:
> From: Zyta Szpak 
>
> This change deals with hard-coded register width.
> The app was allocating too little space for 64-bit registers
> which resulted in memory corruption. This commit resolves
> this by getting the number of registers and size of register
> by rte_eth_dev_get_reg_info function called first time
> with data=NULL.
>
> Signed-off-by: Zyta Szpak 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v6 1/2] ethdev: remove get_reg_length callback

2016-07-04 Thread Remy Horton

On 04/07/2016 12:36, Zyta Szpak wrote:
> From: Zyta Szpak 
>
> Removes hard-coded assumption that device registers
> are always 32 bits wide. The rte_eth_dev_get_reg_length
> and rte_eth_dev_get_reg_info callbacks did not
> provide register size to the app in any way while is
> needed to allocate correct number of bytes before
> retrieving registers using rte_eth_dev_get_reg.
>
> This commit changes rte_eth_dev_get_reg_info so that
> it can be used to retrieve both the number of registers
> and their width, and removes the now-redundant
> rte_eth_dev_get_reg_length.
>
> Signed-off-by: Zyta Szpak 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v5 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params

2016-07-04 Thread Remy Horton

On 04/07/2016 07:51, Zyta Szpak wrote:
> From: Zyta Szpak 
>
> Version 4 of fixing the fixed register width assumption.
> The app was allocating too little space for 64-bit registers
> which resulted in memory corruption. This commit resolves
> this by getting the number of registers and size of register
> by rte_eth_dev_get_reg_info function called first time
> with data=NULL.

Comments regarding commit message on v4 1/2 also apply here..

It is also not v4.. :)


> Signed-off-by: Zyta Szpak 
> ---
>  examples/ethtool/lib/rte_ethtool.c | 19 +--
>  1 file changed, 13 insertions(+), 6 deletions(-)




[dpdk-dev] [PATCH v5 1/2] ethdev: remove get_reg_length callback

2016-07-04 Thread Remy Horton

> +++ b/drivers/net/cxgbe/cxgbe_ethdev.c
> @@ -934,7 +934,15 @@ static int cxgbe_get_regs(struct rte_eth_dev *eth_dev,
>   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
>   struct adapter *adapter = pi->adapter;
>
> - regs->length = cxgbe_get_regs_len(eth_dev);
> + if (regs->data == NULL) {
> + regs->length = cxgbe_get_regs_len(eth_dev);
> + regs->width = sizeof(uint32_t);
> + regs->version = CHELSIO_CHIP_VERSION(adapter->params.chip) |
> + (CHELSIO_CHIP_RELEASE(adapter->params.chip) << 10) |
> + (1 << 16);
> + return 0;
> + }
> +
>   regs->version = CHELSIO_CHIP_VERSION(adapter->params.chip) |
>   (CHELSIO_CHIP_RELEASE(adapter->params.chip) << 10) |
>   (1 << 16);

Code duplication..

Rest looks ok and passed a quick compile test. Might need to keep an eye 
out for other driver changes.


[dpdk-dev] [PATCH v1] eal: remove redundant id field in xstats name lookups

2016-07-01 Thread Remy Horton
For all drivers that currently implement xstats, the id field in the
rte_eth_stats_name structure equals the entry's array index. This
patch eliminates the redundant id field as a direct index lookup is
faster than a search for the matching id field.

Signed-off-by: Remy Horton 
---
 app/proc_info/main.c| 11 +++
 app/test-pmd/config.c   | 12 
 doc/guides/prog_guide/poll_mode_drv.rst | 18 +++---
 drivers/net/e1000/igb_ethdev.c  |  2 --
 drivers/net/fm10k/fm10k_ethdev.c|  3 ---
 drivers/net/i40e/i40e_ethdev.c  |  8 
 drivers/net/i40e/i40e_ethdev_vf.c   |  1 -
 drivers/net/ixgbe/ixgbe_ethdev.c|  7 ---
 drivers/net/virtio/virtio_ethdev.c  |  4 
 lib/librte_ether/rte_ethdev.c   |  3 ---
 lib/librte_ether/rte_ethdev.h   |  1 -
 11 files changed, 14 insertions(+), 56 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index f2063fa..6dc0bbb 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -246,7 +246,6 @@ nic_xstats_display(uint8_t port_id)
struct rte_eth_xstat_name *xstats_names;
struct rte_eth_xstat *xstats;
int len, ret, i;
-   int idx_name;
static const char *nic_stats_border = "";

len = rte_eth_xstats_get_names(port_id, NULL, 0);
@@ -284,13 +283,9 @@ nic_xstats_display(uint8_t port_id)
}

for (i = 0; i < len; i++)
-   for (idx_name = 0; idx_name < len; idx_name++)
-   if (xstats_names[idx_name].id == xstats[i].id) {
-   printf("%s: %"PRIu64"\n",
-   xstats_names[idx_name].name,
-   xstats[i].value);
-   break;
-   }
+   printf("%s: %"PRIu64"\n",
+   xstats_names[i].name,
+   xstats[i].value);

printf("%s\n",
   nic_stats_border);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 10f0a36..89e3f66e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -256,7 +256,7 @@ void
 nic_xstats_display(portid_t port_id)
 {
struct rte_eth_xstat *xstats;
-   int cnt_xstats, idx_xstat, idx_name;
+   int cnt_xstats, idx_xstat;
struct rte_eth_xstat_name *xstats_names;

printf("## NIC extended statistics for port %-2d\n", port_id);
@@ -298,13 +298,9 @@ nic_xstats_display(portid_t port_id)

/* Display xstats */
for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++)
-   for (idx_name = 0; idx_name < cnt_xstats; idx_name++)
-   if (xstats_names[idx_name].id == xstats[idx_xstat].id) {
-   printf("%s: %"PRIu64"\n",
-   xstats_names[idx_name].name,
-   xstats[idx_xstat].value);
-   break;
-   }
+   printf("%s: %"PRIu64"\n",
+   xstats_names[idx_xstat].name,
+   xstats[idx_xstat].value);
free(xstats_names);
free(xstats);
 }
diff --git a/doc/guides/prog_guide/poll_mode_drv.rst 
b/doc/guides/prog_guide/poll_mode_drv.rst
index 802fb8f..bf3ea9f 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -309,17 +309,13 @@ functions:
   information.

 Each ``struct rte_eth_xstat`` contains an identifier and value pair, and
-each ``struct rte_eth_xstat_name`` contains an identifier and string pair.
-Each identifier within ``struct rte_eth_xstat`` must have a corresponding
-entry in ``struct rte_eth_xstat_name`` with a matching identifier. These
-identifiers, as well as the number of extended statistic exposed, must
-remain constant during runtime.
-
-Note that extended statistic identifiers are driver-specific, and hence
-might not be the same for different ports. Although it is expected that
-drivers will make the identifiers used within ``struct rte_eth_xstat`` and
-``struct rte_eth_xstat_name`` entries match the entries' array index, this
-property should not be relied on by applications for lookups.
+each ``struct rte_eth_xstat_name`` contains a string. Each identifier
+within the ``struct rte_eth_xstat`` lookup array must have a corresponding
+entry in the ``struct rte_eth_xstat_name`` lookup array. Within the latter
+the index of the entry is the identifier the string is associated with.
+These identifiers, as well as the number of extended statistic exposed, must
+remain constant during runtime. Note that extended statistic identifiers are
+driver-specific, and hence might not be the same for diff

[dpdk-dev] [PATCH] ethdev: fix extended statistics description

2016-07-01 Thread Remy Horton

On 29/06/2016 17:59, Thomas Monjalon wrote:
> The old structure rte_eth_xstats contained names and values.
> The new structure rte_eth_xstat contains ids and values.
>
> Fixes: bd6aa172cf35 ("ethdev: fetch extended statistics with integer ids")
> Fixes: e2aae1c1ced9 ("ethdev: remove name from extended statistic fetch")
>
> Signed-off-by: Thomas Monjalon 

Acked-by: Remy Horton 


[dpdk-dev] xstats performance

2016-07-01 Thread Remy Horton

On 29/06/2016 17:40, Thomas Monjalon wrote:
[..]
> I don't think it is possible to standardize stats ids, for two reasons:
> - it is hard to maintain and avoid conflicts between drivers
> - the drivers would have to lookup the names which degrades performance

I designed it that way to keep flexibility down the line rather than 
specifically for the above use-case.


> I think the idea of Olivier would improve the performance of stats retrieval,
> which was the idea of this rework :)
> Unfortunately we need someone available to fix it quickly for RC2.

For all the current drivers xstats_names[idx].id==idx so it would just 
involve removing the references to the id field and updating the 
documentation. Complication is coordinating with QLogic for the bnx2x & 
qede xstats patches.

..Remy


[dpdk-dev] [PATCHv8 0/6] Implement pmd hardware support exports

2016-06-30 Thread Remy Horton

On 17/06/2016 19:46, Neil Horman wrote:
> Hey all-
>   So heres attempt number 2 at a method for exporting PMD hardware support
> information.  As we discussed previously, the consensus seems to be that pmd
> information should be:
[..]
> Signed-off-by: Neil Horman 
> Acked-by: Panu Matilainen 
> CC: Bruce Richardson 
> CC: Thomas Monjalon 
> CC: Stephen Hemminger 
> CC: Panu Matilainen 

Acked-by: Remy Horton 


[dpdk-dev] [PATCHv8 5/6] pmdinfo.py: Add tool to query binaries for hw and other support information

2016-06-30 Thread Remy Horton

On 29/06/2016 17:18, Neil Horman wrote:
> On Wed, Jun 29, 2016 at 04:12:21PM +0100, Remy Horton wrote:
>> 'noon,
[..]
>> No licence..?
>>
> Its BSD, same as the others, I let the README cover that.  We can include
> it if we must, though we have lots of examples where we haven't bothered

Ok. The DPDK repo has a mix of BSD and GPL licenced files, so probably 
bit more critical than in other projects.


> Nope, pep8 doesn't complain about this at all:
> [nhorman at hmsreliant tools]$ pep8 ./pmdinfo.py
> pmdinfo.py:573:80: E501 line too long (80 > 79 characters)
> [nhorman at hmsreliant tools]$

Hmm..

[remy at VM tools]$ pep8 pmdinfo.py
pmdinfo.py:19:1: E402 module level import not at top of file
pmdinfo.py:20:1: E402 module level import not at top of file
pmdinfo.py:21:1: E402 module level import not at top of file
pmdinfo.py:23:1: E402 module level import not at top of file
pmdinfo.py:24:1: E402 module level import not at top of file
pmdinfo.py:25:1: E402 module level import not at top of file
pmdinfo.py:26:1: E402 module level import not at top of file
pmdinfo.py:27:1: E402 module level import not at top of file
pmdinfo.py:28:1: E402 module level import not at top of file
pmdinfo.py:32:1: E402 module level import not at top of file
pmdinfo.py:33:1: E402 module level import not at top of file
pmdinfo.py:42:1: E402 module level import not at top of file
pmdinfo.py:43:1: E402 module level import not at top of file
pmdinfo.py:44:1: E402 module level import not at top of file
pmdinfo.py:49:1: E402 module level import not at top of file
pmdinfo.py:51:1: E402 module level import not at top of file
pmdinfo.py:573:80: E501 line too long (80 > 79 characters)
[remy at VM tools]$ pep8 --version
1.7.0

To be fair the Python lot seem to add bucketloads of extra checks to 
PEP8/PyLint with every release.


> As you note, none of these are catastrophic.  I'm willing to fix them up, but
> given, the number of iterations I've gone through for minior nits, I would
> prefer to see it incorporated before I post this series again.

I agree. Merge first and ask questions later.. :)

..Remy


[dpdk-dev] xstats performance

2016-06-29 Thread Remy Horton
'noon,

On 29/06/2016 16:38, Olivier MATZ wrote:
[..]

> And assume that the id field in rte_eth_xstat corresponds to
> the index in the rte_eth_xstat_name table?

It was an assumption I wanted to avoid setting in stone, even though at 
the moment it is actually true in implementation.

The mappings are driver-specific but I wanted to leave open, amoung 
other things, the possibility of string-id mappings being standardised 
across all drivers. For that to work drivers would have to be able to 
use a set of ids that may contain gaps.

..Remy


[dpdk-dev] [PATCHv8 5/6] pmdinfo.py: Add tool to query binaries for hw and other support information

2016-06-29 Thread Remy Horton
'noon,

The tool does not work for static PMD libraries (e.g. librte_pmd_i40e.a) 
- is this an intended limitation?

DPDK doesn't to my knowledge have any coding guidelines for Python, so 
the comments below should be considered advisory rather than 
merge-blocking issues.


On 17/06/2016 19:46, Neil Horman wrote:
[..]
> +++ b/tools/pmdinfo.py
> @@ -0,0 +1,629 @@
> +#!/usr/bin/python
> +# -
> +# scripts/pmdinfo.py
> +#
> +# Utility to dump PMD_INFO_STRING support from an object file
> +#

No licence..?


> +# -
> +import os
> +import sys
> +from optparse import OptionParser
> +import string
> +import json
> +
> +# For running from development directory. It should take precedence over the
> +# installed pyelftools.
> +sys.path.insert(0, '.')

Aside from causing all the subsequent imports to have PEP8 errors, this 
does not looks like a good way of pulling in project-specific Python 
library installs. Usual method is either using virtualenv or the 
PYTHONPATH enviornment variable.


> +from elftools import __version__
> +from elftools.common.exceptions import ELFError
[..]
> +from elftools.dwarf.constants import (
> +DW_LNS_copy, DW_LNS_set_file, DW_LNE_define_file)
> +from elftools.dwarf.callframe import CIE, FDE

According to PyLint, most of these imports are unused.


> +
> +
> +class Vendor:

Old style class definition. Using modern notation it is:

class Vendor(object):


> +def report(self):
> +print "\t%s\t%s" % (self.ID, self.name)
> +for subID, subdev in self.subdevices.items():
> +subdev.report()

subID unused. An underscore can be used as a placeholder for these types 
of loops.


> +optparser.add_option("-t", "--table", dest="tblout",
> + help="output information on hw support as a hex 
> table",

PEP8: pmdinfo.py:573:80: E501 line too long (80 > 79 characters)




[dpdk-dev] [PATCHv8 0/6] Implement pmd hardware support exports

2016-06-29 Thread Remy Horton
Morning,

Compile error with virtio_user_ethdev.c - looks like a new addition 
(commit ce2eabdd43ec) that also needs to be converted.

Regards,

..Remy


On 17/06/2016 19:46, Neil Horman wrote:
> Hey all-
>   So heres attempt number 2 at a method for exporting PMD hardware support
> information.  As we discussed previously, the consensus seems to be that pmd
> information should be:
[..]
> Signed-off-by: Neil Horman 
> Acked-by: Panu Matilainen 
> CC: Bruce Richardson 
> CC: Thomas Monjalon 
> CC: Stephen Hemminger 
> CC: Panu Matilainen 



[dpdk-dev] [PATCH v4 2/2] examples/ethtool: use rte_eth_dev_get_reg_info for reg params

2016-06-27 Thread Remy Horton

On 23/06/2016 14:26, zr at semihalf.com wrote:
> From: Zyta Szpak 
>
> Version 4 of fixing the fixed register width assumption.
> The app was allocating too little space for 64-bit registers
> which resulted in memory corruption. This commit resolves
> this by getting the number of registers and size of register
> by rte_eth_dev_get_reg_info function called first time
> with data=NULL.
>
> Signed-off-by: Zyta Szpak 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v4 1/2] ethdev: remove get_reg_length callback

2016-06-27 Thread Remy Horton
Morning,


On 23/06/2016 14:26, zr at semihalf.com wrote:
> From: Zyta Szpak 
>
> Version 4 of fixing the assumption of that device registers
> are always 32 bits long. rte_eth_dev_get_reg_length and
> rte_eth_dev_get_reg_info callbacks did not provide register size
> to the app in any way. It is needed to allocate proper number
> of bytes before retrieving registers content with
> rte_eth_dev_get_reg. This commit remove rte_eth_dev_get_reg_length
> callback and adds width parameter to reg_info struct which makes
> it possible to call rte_eth_dev_get_reg_info to get attributes
> first. The drivers using this callback fill width and length
> when call to function made with data=NULL.

I think this would read better as a commit message:

Removes hard-coded assumption that device registers are always 32 bits 
wide. The rte_eth_dev_get_reg_length and rte_eth_dev_get_reg_info 
callbacks did not provide register size to the app in any way, which is 
needed to allocate correct number of bytes before retrieving registers 
using rte_eth_dev_get_reg.

This commit changes rte_eth_dev_get_reg_info so that it can be used to 
retrieve both the number of registers and their width, and removes the 
now-redundant rte_eth_dev_get_reg_length.


> -/**
> - * Retrieve device registers and register attributes
> + * Retrieve device registers and register attributes (nb of regs and reg 
> size)
>   *
>   * @param port_id
>   *   The port identifier of the Ethernet device.

Need detail regarding how *info->data affects function behaviour. 
Something along the lines of:

/**
  * Retrieve device registers and register attributes (number of
  * registers and register size)
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
  * @param info
  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
  *   NULL the function fills in the width and length fields. If non-NULL
  *   the registers are put into the buffer pointed at by the data field.

Program code itself looks good to me.

..Remy


[dpdk-dev] [PATCH v4 2/3] bnx2x: enhance stats get

2016-06-21 Thread Remy Horton
Morning,

On 11/05/2016 01:58, Rasesh Mody wrote:
[..]
>>> We shall split this patch into an enhancement and a bug fix.
>>
>> Keep in mind that the xstats API is changing so that stats_get() no
>> longer includes strings:
>>
>> http://thread.gmane.org/gmane.comp.networking.dpdk.devel/37079
>> http://thread.gmane.org/gmane.comp.networking.dpdk.devel/37571
>>
>> ..Remy
>
> Sure, made a note of it. Do we know when will these changes be picked
> up? We can incorporate the related changes into our patches if the
> patches are about to be accepted.
>

Quick heads-up - the XStats changes were merged into master a few days ago.

Regards,

..Remy


[dpdk-dev] [PATCH v2 2/2] examples/l2fwd-keepalive: fix Coverity issues

2016-06-20 Thread Remy Horton
Fixes memory leaks detected by Coverity. These are due to ephemeral
memory allocations not being freed when errors occur.

Coverity issue 127349: Resource leak

Fixes: e2aae1c1ced9 ("ethdev: remove name from extended statistic fetch")

Signed-off-by: Remy Horton 
---
 examples/l2fwd-keepalive/shm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c
index 66fc433..177aa5b 100644
--- a/examples/l2fwd-keepalive/shm.c
+++ b/examples/l2fwd-keepalive/shm.c
@@ -80,6 +80,8 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void)
RTE_LOG(INFO, EAL,
"Failed to setup SHM semaphore (%s)\n",
strerror(errno));
+   munmap(ka_shm,
+   sizeof(struct rte_keepalive_shm));
return NULL;
}

-- 
2.5.5



[dpdk-dev] [PATCH v2 1/2] app/test-pmd: fix Coverity issues

2016-06-20 Thread Remy Horton
Fixes memory leaks detected by Coverity. These are due to ephemeral
memory allocations not being freed when errors occur.

Coverity issue 127348: Resource leak

Fixes: e2aae1c1ced9 ("ethdev: remove name from extended statistic fetch")

Signed-off-by: Remy Horton 
---
 app/test-pmd/config.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 10f0a36..cb71c09 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -281,6 +281,7 @@ nic_xstats_display(portid_t port_id)
if (cnt_xstats != rte_eth_xstats_get_names(
port_id, xstats_names, cnt_xstats)) {
printf("Error: Cannot get xstats lookup\n");
+   free(xstats_names);
return;
}

@@ -293,6 +294,8 @@ nic_xstats_display(portid_t port_id)
}
if (cnt_xstats != rte_eth_xstats_get(port_id, xstats, cnt_xstats)) {
printf("Error: Unable to get xstats\n");
+   free(xstats_names);
+   free(xstats);
return;
}

-- 
2.5.5



[dpdk-dev] [PATCH v2 0/2] fix Coverity issues

2016-06-20 Thread Remy Horton
Fixes memory leaks detected by Coverity. These are due to ephemeral
memory allocations not being freed when errors occur.

--
v2 changes:
* Split patch into two

Remy Horton (2):
  app/test-pmd: fix Coverity issues
  examples/l2fwd-keepalive: fix Coverity issues

 app/test-pmd/config.c  | 3 +++
 examples/l2fwd-keepalive/shm.c | 2 ++
 2 files changed, 5 insertions(+)

-- 
2.5.5



[dpdk-dev] [PATCH v1] app: fix Coverity issues

2016-06-20 Thread Remy Horton

On 20/06/2016 14:56, Thomas Monjalon wrote:
[..]
> It looks to be 2 patches: one for xstats and the other for keepalive.
>

Ok, will seperate. I combined them since they were the same small fix in 
multiple places.


[dpdk-dev] [PATCH v1] app: fix Coverity issues

2016-06-20 Thread Remy Horton
Fixes memory leaks detected by Coverity. These are due to ephemeral
memory allocations not being freed when errors occur.

Coverity issue 127348: Resource leak
Coverity issue 127349: Resource leak

Fixes: e2aae1c1ced9 ("ethdev: remove name from extended statistic fetch")

Signed-off-by: Remy Horton 
---
 app/test-pmd/config.c  | 3 +++
 examples/l2fwd-keepalive/shm.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 10f0a36..cb71c09 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -281,6 +281,7 @@ nic_xstats_display(portid_t port_id)
if (cnt_xstats != rte_eth_xstats_get_names(
port_id, xstats_names, cnt_xstats)) {
printf("Error: Cannot get xstats lookup\n");
+   free(xstats_names);
return;
}

@@ -293,6 +294,8 @@ nic_xstats_display(portid_t port_id)
}
if (cnt_xstats != rte_eth_xstats_get(port_id, xstats, cnt_xstats)) {
printf("Error: Unable to get xstats\n");
+   free(xstats_names);
+   free(xstats);
return;
}

diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c
index 66fc433..177aa5b 100644
--- a/examples/l2fwd-keepalive/shm.c
+++ b/examples/l2fwd-keepalive/shm.c
@@ -80,6 +80,8 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void)
RTE_LOG(INFO, EAL,
"Failed to setup SHM semaphore (%s)\n",
strerror(errno));
+   munmap(ka_shm,
+   sizeof(struct rte_keepalive_shm));
return NULL;
}

-- 
2.5.5



[dpdk-dev] [PATCH] virtio: fix crash on querying xstats

2016-06-20 Thread Remy Horton

On 20/06/2016 11:50, Yuanhan Liu wrote:
> Trying to access xstats_names after "if (stats_names == NULL)" is
> obviously wrong, which would result to a crash while running "show
> port xstats 0" in testpmd with virtio PMD.
>
> The fix is also straightforward: just revese the check.
>
> Fixes: baf91c395b18 ("net/virtio: fetch extended statistics with integer ids")
>
> Cc: Remy Horton 
> Signed-off-by: Yuanhan Liu 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v1] eal: fix missing symbol exports

2016-06-20 Thread Remy Horton
The KeepAlive rte_keepalive_mark_sleep function was not being exported.

Fixes: 90c622f35679 ("keepalive: add liveness callback")

Signed-off-by: Remy Horton 
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   | 1 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 3b4dd3b..1852c4a 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -156,6 +156,7 @@ DPDK_16.07 {
global:

pci_get_sysfs_path;
+   rte_keepalive_mark_sleep;
rte_keepalive_register_relay_callback;
rte_thread_setname;

diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 7330a46..0513467 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -159,6 +159,7 @@ DPDK_16.07 {
global:

pci_get_sysfs_path;
+   rte_keepalive_mark_sleep;
rte_keepalive_register_relay_callback;
rte_thread_setname;

-- 
2.5.5



[dpdk-dev] [PATCH] keepalive: fix exported symbols

2016-06-17 Thread Remy Horton
rte_keepalive_mark_sleep is also missing from both.

On 17/06/2016 16:02, Thomas Monjalon wrote:
> The function rte_keepalive_register_alive_callback do not exist.
> The function rte_keepalive_register_relay_callback was missing for BSD.
>
> Fixes: 90c622f35679 ("keepalive: add liveness callback")
>
> Signed-off-by: Thomas Monjalon 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH v4 3/3] examples/l2fwd-keepalive: add IPC liveness reporting

2016-06-15 Thread Remy Horton
Changes the l2fwd keepalive example to show how the new keepalive
enhancements can be used to relay core state to an external process.

Signed-off-by: Remy Horton 
---
 examples/Makefile  |   1 +
 examples/l2fwd-keepalive/Makefile  |   5 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  49 ++
 examples/l2fwd-keepalive/ka-agent/main.c   | 150 +
 examples/l2fwd-keepalive/main.c|  22 -
 examples/l2fwd-keepalive/shm.c | 129 +
 examples/l2fwd-keepalive/shm.h |  89 +
 7 files changed, 441 insertions(+), 4 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h

diff --git a/examples/Makefile b/examples/Makefile
index 3bc635a..f650d3e 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -64,6 +64,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += l2fwd-ivshmem
 DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats
 DIRS-y += l2fwd-keepalive
+DIRS-y += l2fwd-keepalive/ka-agent
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += l3fwd
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += l3fwd-acl
 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
diff --git a/examples/l2fwd-keepalive/Makefile 
b/examples/l2fwd-keepalive/Makefile
index 568edcb..ca45a79 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,9 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l2fwd-keepalive

 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c shm.c

 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+LDFLAGS += -lrt

 include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/l2fwd-keepalive/ka-agent/Makefile 
b/examples/l2fwd-keepalive/ka-agent/Makefile
new file mode 100644
index 000..fd0c38b
--- /dev/null
+++ b/examples/l2fwd-keepalive/ka-agent/Makefile
@@ -0,0 +1,49 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ifeq ($(RTE_SDK),)
+$(error "Please define RTE_SDK environment variable")
+endif
+
+# Default target, can be overridden by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# binary name
+APP = ka-agent
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)/../
+LDFLAGS += -lrt
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/l2fwd-keepalive/ka-agent/main.c 
b/examples/l2fwd-keepalive/ka-agent/main.c
new file mode 100644
index 000..be1c7f4
--- /dev/null
+++ b/examples/l2fwd-keepalive/ka-agent/main.c
@@ -0,0 +1,150 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code m

[dpdk-dev] [PATCH v4 2/3] eal: add additional keepalive callbacks

2016-06-15 Thread Remy Horton
Adds and documents new callbacks that allow transitions to core
states other than dead to be reported to applications.

Signed-off-by: Remy Horton 
---
 doc/guides/rel_notes/release_16_07.rst  |  6 +++
 examples/Makefile   |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_keepalive.h   | 51 +
 lib/librte_eal/common/rte_keepalive.c   | 30 +++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 +
 6 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index c0f6b02..df95321 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -66,6 +66,12 @@ New Features
   * Enable RSS per network interface through the configuration file.
   * Streamline the CLI code.

+* **Added keepalive enhancements.**
+
+  Adds support for reporting of core states other than dead to
+  monitoring applications, enabling the support of broader liveness
+  reporting to external processes.
+

 Resolved Issues
 ---
diff --git a/examples/Makefile b/examples/Makefile
index b28b30e..3bc635a 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2014 6WIND S.A.
+#   Copyright(c) 2016 6WIND S.A.
 #
 #   Redistribution and use in source and binary forms, with or without
 #   modification, are permitted provided that the following conditions
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index f8c3dea..0fb1cf2 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -156,5 +156,6 @@ DPDK_16.07 {
global:

pci_get_sysfs_path;
+   rte_keepalive_register_alive_callback;

 } DPDK_16.04;
diff --git a/lib/librte_eal/common/include/rte_keepalive.h 
b/lib/librte_eal/common/include/rte_keepalive.h
index d01a654..88ad8e4 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -63,12 +63,32 @@ enum rte_keepalive_state {
  *
  *  Receives a data pointer passed to rte_keepalive_create() and the id of the
  *  failed core.
+ *  @param data Data pointer passed to rte_keepalive_create()
+ *  @param id_core ID of the core that has failed
  */
 typedef void (*rte_keepalive_failure_callback_t)(
void *data,
const int id_core);

 /**
+ * Keepalive relay callback.
+ *
+ *  Receives a data pointer passed to rte_keepalive_register_relay_callback(),
+ *  the id of the core for which state is to be forwarded, and details of the
+ *  current core state.
+ *  @param data Data pointer passed to rte_keepalive_register_relay_callback()
+ *  @param id_core ID of the core for which state is being reported
+ *  @param core_state The current state of the core
+ *  @param Timestamp of when core was last seen alive
+ */
+typedef void (*rte_keepalive_relay_callback_t)(
+   void *data,
+   const int id_core,
+   enum rte_keepalive_state core_state,
+   uint64_t last_seen
+   );
+
+/**
  * Keepalive state structure.
  * @internal
  */
@@ -115,4 +135,35 @@ void rte_keepalive_register_core(struct rte_keepalive 
*keepcfg,
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);

+/**
+ * Per-core sleep-time indication.
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ *
+ * If CPU idling is enabled, this function needs to be called from within
+ * the main process loop of the LCore going to sleep, in order to avoid
+ * the LCore being mis-detected as dead.
+ */
+void
+rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg);
+
+/**
+ * Registers a 'live core' callback.
+ *
+ * The complement of the 'dead core' callback. This is called when a
+ * core is known to be alive, and is intended for cases when an app
+ * needs to know 'liveness' beyond just knowing when a core has died.
+ *
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ * @param callback
+ *   Function called upon detection of a dead core.
+ * @param data
+ *   Data pointer to be passed to function callback.
+ */
+void
+rte_keepalive_register_relay_callback(struct rte_keepalive *keepcfg,
+   rte_keepalive_relay_callback_t callback,
+   void *data);
+
 #endif /* _KEEPALIVE_H_ */
diff --git a/lib/librte_eal/common/rte_keepalive.c 
b/lib/librte_eal/common/rte_keepalive.c
index 8b14370..9765d1b 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -64,6 +64,15 @@ struct rte_keepalive {
void *callback_data;
uint64_t tsc_initial;
uint64_t tsc_mhz;
+
+   /** Core state relay handler. */
+   rte_keepalive_relay_callback_t relay_callback;
+
+   /**
+* Core state relay handler app data.
+* Pointer is passed to live core handler.
+*/
+   void

[dpdk-dev] [PATCH v4 1/3] eal: export keepalive state enumerations

2016-06-15 Thread Remy Horton
Changes the keepalive state from an anonymous enum to a declared one
which is externally visible, so that keepalive enum values can be
used by applications.

Signed-off-by: Remy Horton 
---
 lib/librte_eal/common/include/rte_keepalive.h | 12 +-
 lib/librte_eal/common/rte_keepalive.c | 34 +++
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_keepalive.h 
b/lib/librte_eal/common/include/rte_keepalive.h
index 10dac2e..d01a654 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,16 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif

+enum rte_keepalive_state {
+   RTE_KA_STATE_UNUSED = 0,
+   RTE_KA_STATE_ALIVE = 1,
+   RTE_KA_STATE_MISSING = 4,
+   RTE_KA_STATE_DEAD = 2,
+   RTE_KA_STATE_GONE = 3,
+   RTE_KA_STATE_DOZING = 5,
+   RTE_KA_STATE_SLEEP = 6
+};
+
 /**
  * Keepalive failure callback.
  *
diff --git a/lib/librte_eal/common/rte_keepalive.c 
b/lib/librte_eal/common/rte_keepalive.c
index 23363ec..8b14370 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -42,12 +42,8 @@

 struct rte_keepalive {
/** Core Liveness. */
-   enum rte_keepalive_state {
-   ALIVE = 1,
-   MISSING = 0,
-   DEAD = 2,
-   GONE = 3
-   } __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
+   enum rte_keepalive_state __rte_cache_aligned state_flags[
+   RTE_KEEPALIVE_MAXCORES];

/** Last-seen-alive timestamps */
uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
@@ -92,16 +88,18 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
continue;

switch (keepcfg->state_flags[idx_core]) {
-   case ALIVE: /* Alive */
-   keepcfg->state_flags[idx_core] = MISSING;
+   case RTE_KA_STATE_UNUSED:
+   break;
+   case RTE_KA_STATE_ALIVE: /* Alive */
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_MISSING;
keepcfg->last_alive[idx_core] = rte_rdtsc();
break;
-   case MISSING: /* MIA */
+   case RTE_KA_STATE_MISSING: /* MIA */
print_trace("Core MIA. ", keepcfg, idx_core);
-   keepcfg->state_flags[idx_core] = DEAD;
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_DEAD;
break;
-   case DEAD: /* Dead */
-   keepcfg->state_flags[idx_core] = GONE;
+   case RTE_KA_STATE_DEAD: /* Dead */
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_GONE;
print_trace("Core died. ", keepcfg, idx_core);
if (keepcfg->callback)
keepcfg->callback(
@@ -109,7 +107,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
idx_core
);
break;
-   case GONE: /* Buried */
+   case RTE_KA_STATE_GONE: /* Buried */
+   break;
+   case RTE_KA_STATE_DOZING: /* Core going idle */
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_SLEEP;
+   keepcfg->last_alive[idx_core] = rte_rdtsc();
+   break;
+   case RTE_KA_STATE_SLEEP: /* Idled core */
break;
}
}
@@ -137,7 +141,7 @@ void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
if (id_core < RTE_KEEPALIVE_MAXCORES) {
-   keepcfg->active_cores[id_core] = 1;
+   keepcfg->active_cores[id_core] = RTE_KA_STATE_ALIVE;
keepcfg->last_alive[id_core] = rte_rdtsc();
}
 }
@@ -145,5 +149,5 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, 
const int id_core)
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
-   keepcfg->state_flags[rte_lcore_id()] = ALIVE;
+   keepcfg->state_flags[rte_lcore_id()] = RTE_KA_STATE_ALIVE;
 }
-- 
2.5.5



[dpdk-dev] [PATCH v4 0/3] Keep-alive enhancements

2016-06-15 Thread Remy Horton
This patchset adds enhancements to the keepalive core monitoring and
reporting sub-system. The first is support for idled (sleeping and
frequency-stepped) CPU cores, and the second is support for applications
to be notified of active as well as faulted cores. The latter is to allow
core state to be relayed to external (secondary) processes, which is
demonstrated by changes to the l2fwd-keepalive example.

--

v4 changes
* Use RTE_KA_STATE_ prefix instead of RTE_ (namespace issues)

v3 changes
* Rebased to master
* Exposed keepalive state enumerations
* Changed keepalive state enumerations to use RTE_ prefix
* Added missing parameter documentation
* Doc changes squashed

v2 changes:
* Some date & typos fixups
* State enum made public and extended with new states
* Generalised 'alive' callback to all states
* Last-alive shows gone-to-sleep time for idle cores
* Removed some redundant sanity checks
* Last-alive time exposed to application
* #define'd semaphore timeout
* Agent checks for dead keepalive

Remy Horton (3):
  eal: export keepalive state enumerations
  eal: add additional keepalive callbacks
  examples/l2fwd-keepalive: add IPC liveness reporting

 doc/guides/rel_notes/release_16_07.rst  |   6 +
 examples/Makefile   |   3 +-
 examples/l2fwd-keepalive/Makefile   |   5 +-
 examples/l2fwd-keepalive/ka-agent/Makefile  |  49 
 examples/l2fwd-keepalive/ka-agent/main.c| 150 
 examples/l2fwd-keepalive/main.c |  22 +++-
 examples/l2fwd-keepalive/shm.c  | 129 
 examples/l2fwd-keepalive/shm.h  |  89 ++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   1 +
 lib/librte_eal/common/include/rte_keepalive.h   |  63 +-
 lib/librte_eal/common/rte_keepalive.c   |  64 +++---
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   2 +
 12 files changed, 562 insertions(+), 21 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h

-- 
2.5.5



[dpdk-dev] [PATCH v5 7/7] rte: change xstats usage to new API

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the test-pmd
and proc_info applications to use the new xstats API, and removes
deprecated code associated with the old API.

Signed-off-by: Remy Horton 
---
 app/proc_info/main.c   | 29 +---
 app/test-pmd/config.c  | 54 +-
 drivers/net/e1000/igb_ethdev.c | 10 +++
 drivers/net/fm10k/fm10k_ethdev.c   |  5 +---
 drivers/net/i40e/i40e_ethdev.c |  8 ++
 drivers/net/i40e/i40e_ethdev_vf.c  |  5 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c   | 11 +++-
 drivers/net/virtio/virtio_ethdev.c |  6 ++---
 lib/librte_ether/rte_ethdev.c  |  5 +---
 lib/librte_ether/rte_ethdev.h  |  7 +++--
 10 files changed, 85 insertions(+), 55 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 5f83092..f2063fa 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -1,7 +1,7 @@
 /*
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -243,11 +243,13 @@ nic_stats_clear(uint8_t port_id)
 static void
 nic_xstats_display(uint8_t port_id)
 {
-   struct rte_eth_xstats *xstats;
+   struct rte_eth_xstat_name *xstats_names;
+   struct rte_eth_xstat *xstats;
int len, ret, i;
+   int idx_name;
static const char *nic_stats_border = "";

-   len = rte_eth_xstats_get(port_id, NULL, 0);
+   len = rte_eth_xstats_get_names(port_id, NULL, 0);
if (len < 0) {
printf("Cannot get xstats count\n");
return;
@@ -258,6 +260,18 @@ nic_xstats_display(uint8_t port_id)
return;
}

+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
+   if (xstats_names == NULL) {
+   printf("Cannot allocate memory for xstat names\n");
+   free(xstats);
+   return;
+   }
+   if (len != rte_eth_xstats_get_names(
+   port_id, xstats_names, len)) {
+   printf("Cannot get xstat names\n");
+   return;
+   }
+
printf("## NIC extended statistics for port %-2d #\n",
   port_id);
printf("%s\n",
@@ -270,11 +284,18 @@ nic_xstats_display(uint8_t port_id)
}

for (i = 0; i < len; i++)
-   printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value);
+   for (idx_name = 0; idx_name < len; idx_name++)
+   if (xstats_names[idx_name].id == xstats[i].id) {
+   printf("%s: %"PRIu64"\n",
+   xstats_names[idx_name].name,
+   xstats[i].value);
+   break;
+   }

printf("%s\n",
   nic_stats_border);
free(xstats);
+   free(xstats_names);
 }

 static void
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1c552e4..8ddec07 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -232,29 +232,57 @@ nic_stats_clear(portid_t port_id)
 void
 nic_xstats_display(portid_t port_id)
 {
-   struct rte_eth_xstats *xstats;
-   int len, ret, i;
+   struct rte_eth_xstat *xstats;
+   int cnt_xstats, idx_xstat, idx_name;
+   struct rte_eth_xstat_name *xstats_names;

printf("## NIC extended statistics for port %-2d\n", port_id);
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   printf("Error: Invalid port number %i\n", port_id);
+   return;
+   }
+
+   /* Get count */
+   cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0);
+   if (cnt_xstats  < 0) {
+   printf("Error: Cannot get count of xstats\n");
+   return;
+   }

-   len = rte_eth_xstats_get(port_id, NULL, 0);
-   if (len < 0) {
-   printf("Cannot get xstats count\n");
+   /* Get id-name lookup table */
+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * cnt_xstats);
+   if (xstats_names == NULL) {
+  

[dpdk-dev] [PATCH v5 6/7] drivers/net/virtio: change xstats to use integer ids

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the virtio driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/virtio/virtio_ethdev.c | 62 +-
 1 file changed, 55 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index c3fb628..83df025 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -80,6 +80,9 @@ static void virtio_dev_stats_get(struct rte_eth_dev *dev,
 struct rte_eth_stats *stats);
 static int virtio_dev_xstats_get(struct rte_eth_dev *dev,
 struct rte_eth_xstats *xstats, unsigned n);
+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  unsigned limit);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
 static int virtio_vlan_filter_set(struct rte_eth_dev *dev,
@@ -615,6 +618,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
.dev_infos_get   = virtio_dev_info_get,
.stats_get   = virtio_dev_stats_get,
.xstats_get  = virtio_dev_xstats_get,
+   .xstats_get_names= virtio_dev_xstats_get_names,
.stats_reset = virtio_dev_stats_reset,
.xstats_reset= virtio_dev_stats_reset,
.link_update = virtio_dev_link_update,
@@ -708,6 +712,52 @@ virtio_update_stats(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 }

+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  __rte_unused unsigned limit)
+{
+   unsigned i;
+   unsigned count = 0;
+   unsigned t;
+
+   unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_Q_XSTATS +
+   dev->data->nb_rx_queues * VIRTIO_NB_Q_XSTATS;
+
+   if (xstats_names == NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct virtqueue *rxvq = dev->data->rx_queues[i];
+   if (rxvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct virtqueue *txvq = dev->data->tx_queues[i];
+   if (txvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+   }
+   return nstats;
+}
+
 static int
 virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
  unsigned n)
@@ -730,9 +780,8 @@ virtio_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
unsigned t;

for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", i,
-rte_virtio_q_stat_strings[t].name);
+   xstats[count].name[0] = '\0';
+   xstats[co

[dpdk-dev] [PATCH v5 5/7] drivers/net/i40e: change xstats to use integer ids

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the i40e driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/i40e/i40e_ethdev.c| 82 ---
 drivers/net/i40e/i40e_ethdev_vf.c | 26 +++--
 2 files changed, 91 insertions(+), 17 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..d712bbe 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -306,6 +306,9 @@ static void i40e_dev_stats_get(struct rte_eth_dev *dev,
   struct rte_eth_stats *stats);
 static int i40e_dev_xstats_get(struct rte_eth_dev *dev,
   struct rte_eth_xstats *xstats, unsigned n);
+static int i40e_dev_xstats_get_names(struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+unsigned limit);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
 static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
uint16_t queue_id,
@@ -467,6 +470,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.link_update  = i40e_dev_link_update,
.stats_get= i40e_dev_stats_get,
.xstats_get   = i40e_dev_xstats_get,
+   .xstats_get_names = i40e_dev_xstats_get_names,
.stats_reset  = i40e_dev_stats_reset,
.xstats_reset = i40e_dev_stats_reset,
.queue_stats_mapping_set  = i40e_dev_queue_stats_mapping_set,
@@ -2205,6 +2209,60 @@ i40e_xstats_calc_num(void)
(I40E_NB_TXQ_PRIO_XSTATS * 8);
 }

+static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned count = 0;
+   unsigned i, prio;
+
+   if (xstats_names == NULL)
+   return i40e_xstats_calc_num();
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Get stats from i40e_eth_stats struct */
+   for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"%s", rte_i40e_stats_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* Get individiual stats from i40e_hw_port struct */
+   for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+"%s", rte_i40e_hw_port_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"rx_priority%u_%s", prio,
+rte_i40e_rxq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"tx_priority%u_%s", prio,
+rte_i40e_txq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+}
+
 static int
 i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
unsigned n)
@@ -2227,8 +2285,8 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Get stats from i40e_eth_stats struct */
for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", rte_i40e_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+   xst

[dpdk-dev] [PATCH v5 4/7] drivers/net/fm10k: change xstats to use integer ids

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the fm10k driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/fm10k/fm10k_ethdev.c | 55 +---
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c2d377f..e07c1ec 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -1256,6 +1256,47 @@ fm10k_link_update(struct rte_eth_dev *dev,
return 0;
 }

+static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   unsigned i, q;
+   unsigned count = 0;
+
+   if (xstats_names != NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Global stats */
+   for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s", fm10k_hw_stats_strings[count].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* PF queue stats */
+   for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
+   for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", q,
+   fm10k_hw_stats_rx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", q,
+   fm10k_hw_stats_tx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   }
+   return FM10K_NB_XSTATS;
+}
+
 static int
 fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 unsigned n)
@@ -1269,8 +1310,7 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Global stats */
for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", fm10k_hw_stats_strings[count].name);
+   xstats[count].name[0] = '\0';
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
fm10k_hw_stats_strings[count].offset);
count++;
@@ -1279,18 +1319,14 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
/* PF queue stats */
for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", q,
-fm10k_hw_stats_rx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_rx_q_strings[i].offset);
count++;
}
for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"tx_q%u_%s", q,
-fm10k_hw_stats_tx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_tx_q_strings[i].offset);
@@ -2629,6 +2665,7 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.allmulticast_disable   = fm10k_dev_allmulticast_disable,
.stats_get  = fm10

[dpdk-dev] [PATCH v5 3/7] drivers/net/e1000: change xstats to use integer ids

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the e1000 driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/e1000/igb_ethdev.c | 52 ++
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f0921ee..dffa04f 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -100,6 +100,9 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igb_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
@@ -165,6 +168,9 @@ static void eth_igbvf_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igbvf_xstats_get(struct rte_eth_dev *dev,
struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igbvf_xstats_get_names(struct rte_eth_dev *dev,
+ struct rte_eth_xstat_name *xstats_names,
+ unsigned limit);
 static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
 static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
@@ -324,6 +330,7 @@ static const struct eth_dev_ops eth_igb_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igb_stats_get,
.xstats_get   = eth_igb_xstats_get,
+   .xstats_get_names = eth_igb_xstats_get_names,
.stats_reset  = eth_igb_stats_reset,
.xstats_reset = eth_igb_xstats_reset,
.dev_infos_get= eth_igb_infos_get,
@@ -385,6 +392,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igbvf_stats_get,
.xstats_get   = eth_igbvf_xstats_get,
+   .xstats_get_names = eth_igbvf_xstats_get_names,
.stats_reset  = eth_igbvf_stats_reset,
.xstats_reset = eth_igbvf_stats_reset,
.vlan_filter_set  = igbvf_vlan_filter_set,
@@ -1691,6 +1699,26 @@ eth_igb_xstats_reset(struct rte_eth_dev *dev)
memset(stats, 0, sizeof(*stats));
 }

+static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   __rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names == NULL)
+   return IGB_NB_XSTATS;
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < IGB_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
+"%s", rte_igb_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+
+   return IGB_NB_XSTATS;
+}
+
 static int
 eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
   unsigned n)
@@ -1713,8 +1741,8 @@ eth_igb_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Extended stats */
for (i = 0; i < IGB_NB_XSTATS; i++) {
-   snprintf(xstats[i].name, sizeof(xstats[i].name),
-"%s", rte_igb_stats_strings[i].name);
+   xstats[i].name[0] = '\0';
+   xstats[i].id = i;
xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
rte_igb_stats_strings[i].offset);
}
@@ -1762,6 +1790,22 @@ igbvf_read_stats_registers(struct e1000_hw *hw, struct 
e1000_vf_stats *hw_stats)
hw_stats->last_gotlbc, hw_stats->gotlbc);
 }

+static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names != NULL)
+   for (i = 0; i < IGBVF_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name,
+   sizeof(xstats_names[i].name), "%s",
+   rte_igbvf_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+   return IGBVF_NB_XSTATS;
+}
+
 static int

[dpdk-dev] [PATCH v5 2/7] drivers/net/ixgbe: change xstats to use integer ids

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the ixgbe driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 101 +--
 1 file changed, 86 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a2b170b..9e73492 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -179,6 +179,10 @@ static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
+static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 uint16_t queue_id,
 uint8_t stat_idx,
@@ -466,6 +470,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.xstats_get   = ixgbe_dev_xstats_get,
.stats_reset  = ixgbe_dev_stats_reset,
.xstats_reset = ixgbe_dev_xstats_reset,
+   .xstats_get_names = ixgbe_dev_xstats_get_names,
.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
.dev_infos_get= ixgbe_dev_info_get,
.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
@@ -555,6 +560,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.xstats_get   = ixgbevf_dev_xstats_get,
.stats_reset  = ixgbevf_dev_stats_reset,
.xstats_reset = ixgbevf_dev_stats_reset,
+   .xstats_get_names = ixgbevf_dev_xstats_get_names,
.dev_close= ixgbevf_dev_close,
.allmulticast_enable  = ixgbevf_dev_allmulticast_enable,
.allmulticast_disable = ixgbevf_dev_allmulticast_disable,
@@ -685,6 +691,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_rxq_strings[] = {

 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
   sizeof(rte_ixgbe_rxq_strings[0]))
+#define IXGBE_NB_RXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
{"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
@@ -695,6 +702,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_txq_strings[] = {

 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
   sizeof(rte_ixgbe_txq_strings[0]))
+#define IXGBE_NB_TXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
{"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
@@ -2695,8 +2703,75 @@ ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
 /* This function calculates the number of xstats based on the current config */
 static unsigned
 ixgbe_xstats_calc_num(void) {
-   return IXGBE_NB_HW_STATS + (IXGBE_NB_RXQ_PRIO_STATS * 8) +
-   (IXGBE_NB_TXQ_PRIO_STATS * 8);
+   return IXGBE_NB_HW_STATS +
+   (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
+   (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
+}
+
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   const unsigned cnt_stats = ixgbe_xstats_calc_num();
+   unsigned stat, i, count;
+
+   if (xstats_names != NULL) {
+   count = 0;
+
+   /* Note: limit >= cnt_stats checked upstream
+* in rte_eth_xstats_names()
+*/
+
+   /* Extended stats from ixgbe_hw_stats */
+   for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s",
+   rte_ixgbe_stats_strings[i].name);
+   count++;
+   }
+
+   /* RX Priority Stats */
+   for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
+   for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   

[dpdk-dev] [PATCH v5 1/7] rte: change xstats to use integer ids

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the xstats
functions to instead use a numeric identifier rather than a string, and
adds the ability to retrieve identifier-to-string mappings.

Signed-off-by: Remy Horton 
---
 doc/guides/prog_guide/poll_mode_drv.rst | 25 +++--
 lib/librte_ether/rte_ethdev.c   | 93 ++---
 lib/librte_ether/rte_ethdev.h   | 41 +++
 lib/librte_ether/rte_ether_version.map  |  6 +++
 4 files changed, 153 insertions(+), 12 deletions(-)

diff --git a/doc/guides/prog_guide/poll_mode_drv.rst 
b/doc/guides/prog_guide/poll_mode_drv.rst
index 7698692..802fb8f 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -299,10 +299,27 @@ Extended Statistics API
 ~~~

 The extended statistics API allows each individual PMD to expose a unique set
-of statistics. The client of the API provides an array of
-``struct rte_eth_xstats`` type. Each ``struct rte_eth_xstats`` contains a
-string and value pair. The amount of xstats exposed, and position of the
-statistic in the array must remain constant during runtime.
+of statistics. Accessing these from application programs is done via two
+functions:
+
+* ``rte_eth_xstats_get``: Fills in an array of ``struct rte_eth_xstat``
+  with extended statistics.
+* ``rte_eth_xstats_get_names``: Fills in an array of
+  ``struct rte_eth_xstat_name`` with extended statistic name lookup
+  information.
+
+Each ``struct rte_eth_xstat`` contains an identifier and value pair, and
+each ``struct rte_eth_xstat_name`` contains an identifier and string pair.
+Each identifier within ``struct rte_eth_xstat`` must have a corresponding
+entry in ``struct rte_eth_xstat_name`` with a matching identifier. These
+identifiers, as well as the number of extended statistic exposed, must
+remain constant during runtime.
+
+Note that extended statistic identifiers are driver-specific, and hence
+might not be the same for different ports. Although it is expected that
+drivers will make the identifiers used within ``struct rte_eth_xstat`` and
+``struct rte_eth_xstat_name`` entries match the entries' array index, this
+property should not be relied on by applications for lookups.

 A naming scheme exists for the strings exposed to clients of the API. This is
 to allow scraping of the API for statistics of interest. The naming scheme uses
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..98e5efb 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1502,6 +1502,85 @@ rte_eth_stats_reset(uint8_t port_id)
dev->data->rx_mbuf_alloc_failed = 0;
 }

+static int
+get_xstats_count(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int count;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   count = (*dev->dev_ops->xstats_get_names)(dev, NULL, 0);
+   if (count < 0)
+   return count;
+   } else
+   count = 0;
+   count += RTE_NB_STATS;
+   count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
+   count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
+   return count;
+}
+
+int
+rte_eth_xstats_get_names(uint8_t port_id,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned size)
+{
+   struct rte_eth_dev *dev;
+   int cnt_used_entries;
+   int cnt_expected_entries;
+   uint32_t idx, id_queue;
+
+   cnt_expected_entries = get_xstats_count(port_id);
+   if (xstats_names == NULL || cnt_expected_entries < 0 ||
+   (int)size < cnt_expected_entries)
+   return cnt_expected_entries;
+
+   /* port_id checked in get_xstats_count() */
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   cnt_used_entries = (*dev->dev_ops->xstats_get_names)(
+   dev, xstats_names, size);
+   if (cnt_used_entries < 0)
+   return cnt_used_entries;
+   } else
+   /* Driver itself does not support extended stats, but
+* still have basic stats.
+*/
+   cnt_used_entries = 0;
+
+   for (idx = 0; idx < RTE_NB_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "%s", rte_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+   for (id_queue = 0; id_queue < dev->data->nb_rx_que

[dpdk-dev] [PATCH v5 0/7] Remove string operations from xstats

2016-06-15 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patchset changes the API for
xstats to use integer identifiers instead of strings and implements
this new API for the ixgbe, i40e, e1000, fm10k, and virtio drivers.

--

v5 changes:
* Missing .map file change added (broke shared builds)
* rte_eth_xstats_get_names(): Changed buffer-too-small return value
* Missing commit description added
* Documentation patch squashed (had been ACK'd)

v4 changes:
* rte_eth_xstats_count() removed
* rte_eth_xstats_names() changed to rte_eth_xstats_get_names()
* struct rte_eth_xstats_name renamed to rte_eth_xstat_name
* struct rte_eth_xstats renamed to rte_eth_xstat
* struct rte_eth_dev: .xstats_names renamed to .xstats_get_names
* Other minor local variable name changes
* Documentation updates due to renames
* API changeover patches squashed

v3 changes:
* Corrected ixgbe vf xstats fetching
* Added xstats changes to e1000, f10k, and virtio drivers
* Added cleanup patch that removes now-redundant name field
* Removed ethtool xstats command 
* Removed unused .xstats_count from eth-dev_ops
* Changed test-pmd & proc_info to use new API
* Added documentation update
* Added missing changes to .map file (affected shared lib builds)

v2 changes:
* Fetching xstats count now seperate API function
* Added #define constants for some magic numbers
* Fixed bug with virtual function count fetching
* For non-xstats-supporting drivers, queue stats returned
* Some refactoring/cleanups
* Removed index assumption from example

Remy Horton (7):
  rte: change xstats to use integer ids
  drivers/net/ixgbe: change xstats to use integer ids
  drivers/net/e1000: change xstats to use integer ids
  drivers/net/fm10k: change xstats to use integer ids
  drivers/net/i40e: change xstats to use integer ids
  drivers/net/virtio: change xstats to use integer ids
  rte: change xstats usage to new API

 app/proc_info/main.c|  29 +++--
 app/test-pmd/config.c   |  54 
 doc/guides/prog_guide/poll_mode_drv.rst |  25 ++--
 drivers/net/e1000/igb_ethdev.c  |  58 ++---
 drivers/net/fm10k/fm10k_ethdev.c|  54 +---
 drivers/net/i40e/i40e_ethdev.c  |  82 +++-
 drivers/net/i40e/i40e_ethdev_vf.c   |  29 +++--
 drivers/net/ixgbe/ixgbe_ethdev.c| 106 ++--
 drivers/net/virtio/virtio_ethdev.c  |  64 ---
 lib/librte_ether/rte_ethdev.c   |  92 ---
 lib/librte_ether/rte_ethdev.h   |  48 +--
 lib/librte_ether/rte_ether_version.map  |   6 ++
 12 files changed, 546 insertions(+), 101 deletions(-)

-- 
2.5.5



[dpdk-dev] [PATCH v3 1/3] eal: export keepalive state enumerations

2016-06-15 Thread Remy Horton

On 15/06/2016 10:27, Thomas Monjalon wrote:
[..]
> I'm concerned about the namespace here.
> RTE_UNUSED and others have a chance to not be unique enough.
> Is it possible to have a longer prefix like RTE_KA_ or RTE_STATE_
> or RTE_KA_STATE_?
>

Good point - I'll go with RTE_KA_STATE_ as it is most descriptive.

..Remy


[dpdk-dev] [PATCH v3 3/3] examples/l2fwd-keepalive: add IPC liveness reporting

2016-06-15 Thread Remy Horton
Changes the l2fwd keepalive example to show how the new keepalive
enhancements can be used to relay core state to an external process.

Signed-off-by: Remy Horton 
---
 examples/Makefile  |   1 +
 examples/l2fwd-keepalive/Makefile  |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  48 +
 examples/l2fwd-keepalive/ka-agent/main.c   | 150 +
 examples/l2fwd-keepalive/main.c|  22 -
 examples/l2fwd-keepalive/shm.c | 128 
 examples/l2fwd-keepalive/shm.h |  89 +
 7 files changed, 438 insertions(+), 4 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h

diff --git a/examples/Makefile b/examples/Makefile
index 3bc635a..f650d3e 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -64,6 +64,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += l2fwd-ivshmem
 DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats
 DIRS-y += l2fwd-keepalive
+DIRS-y += l2fwd-keepalive/ka-agent
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += l3fwd
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += l3fwd-acl
 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
diff --git a/examples/l2fwd-keepalive/Makefile 
b/examples/l2fwd-keepalive/Makefile
index 568edcb..3fcf513 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l2fwd-keepalive

 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c shm.c

 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
diff --git a/examples/l2fwd-keepalive/ka-agent/Makefile 
b/examples/l2fwd-keepalive/ka-agent/Makefile
new file mode 100644
index 000..f008428
--- /dev/null
+++ b/examples/l2fwd-keepalive/ka-agent/Makefile
@@ -0,0 +1,48 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ifeq ($(RTE_SDK),)
+$(error "Please define RTE_SDK environment variable")
+endif
+
+# Default target, can be overridden by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# binary name
+APP = ka-agent
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)/../
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/l2fwd-keepalive/ka-agent/main.c 
b/examples/l2fwd-keepalive/ka-agent/main.c
new file mode 100644
index 000..d1f5e6d
--- /dev/null
+++ b/examples/l2fwd-keepalive/ka-agent/main.c
@@ -0,0 +1,150 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditio

[dpdk-dev] [PATCH v3 2/3] eal: add additional keepalive callbacks

2016-06-15 Thread Remy Horton
Adds and documents new callbacks that allow transitions to core
states other than dead to be reported to applications.

Signed-off-by: Remy Horton 
---
 doc/guides/rel_notes/release_16_07.rst  |  6 +++
 examples/Makefile   |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_keepalive.h   | 51 +
 lib/librte_eal/common/rte_keepalive.c   | 30 +++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 6 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index c0f6b02..df95321 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -66,6 +66,12 @@ New Features
   * Enable RSS per network interface through the configuration file.
   * Streamline the CLI code.

+* **Added keepalive enhancements.**
+
+  Adds support for reporting of core states other than dead to
+  monitoring applications, enabling the support of broader liveness
+  reporting to external processes.
+

 Resolved Issues
 ---
diff --git a/examples/Makefile b/examples/Makefile
index b28b30e..3bc635a 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2014 6WIND S.A.
+#   Copyright(c) 2016 6WIND S.A.
 #
 #   Redistribution and use in source and binary forms, with or without
 #   modification, are permitted provided that the following conditions
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index f8c3dea..0fb1cf2 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -156,5 +156,6 @@ DPDK_16.07 {
global:

pci_get_sysfs_path;
+   rte_keepalive_register_alive_callback;

 } DPDK_16.04;
diff --git a/lib/librte_eal/common/include/rte_keepalive.h 
b/lib/librte_eal/common/include/rte_keepalive.h
index 2f856c3..e04ea1c 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -63,12 +63,32 @@ enum rte_keepalive_state {
  *
  *  Receives a data pointer passed to rte_keepalive_create() and the id of the
  *  failed core.
+ *  @param data Data pointer passed to rte_keepalive_create()
+ *  @param id_core ID of the core that has failed
  */
 typedef void (*rte_keepalive_failure_callback_t)(
void *data,
const int id_core);

 /**
+ * Keepalive relay callback.
+ *
+ *  Receives a data pointer passed to rte_keepalive_register_relay_callback(),
+ *  the id of the core for which state is to be forwarded, and details of the
+ *  current core state.
+ *  @param data Data pointer passed to rte_keepalive_register_relay_callback()
+ *  @param id_core ID of the core for which state is being reported
+ *  @param core_state The current state of the core
+ *  @param Timestamp of when core was last seen alive
+ */
+typedef void (*rte_keepalive_relay_callback_t)(
+   void *data,
+   const int id_core,
+   enum rte_keepalive_state core_state,
+   uint64_t last_seen
+   );
+
+/**
  * Keepalive state structure.
  * @internal
  */
@@ -115,4 +135,35 @@ void rte_keepalive_register_core(struct rte_keepalive 
*keepcfg,
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);

+/**
+ * Per-core sleep-time indication.
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ *
+ * If CPU idling is enabled, this function needs to be called from within
+ * the main process loop of the LCore going to sleep, in order to avoid
+ * the LCore being mis-detected as dead.
+ */
+void
+rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg);
+
+/**
+ * Registers a 'live core' callback.
+ *
+ * The complement of the 'dead core' callback. This is called when a
+ * core is known to be alive, and is intended for cases when an app
+ * needs to know 'liveness' beyond just knowing when a core has died.
+ *
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ * @param callback
+ *   Function called upon detection of a dead core.
+ * @param data
+ *   Data pointer to be passed to function callback.
+ */
+void
+rte_keepalive_register_relay_callback(struct rte_keepalive *keepcfg,
+   rte_keepalive_relay_callback_t callback,
+   void *data);
+
 #endif /* _KEEPALIVE_H_ */
diff --git a/lib/librte_eal/common/rte_keepalive.c 
b/lib/librte_eal/common/rte_keepalive.c
index dd18e9f..0aeee46 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -64,6 +64,15 @@ struct rte_keepalive {
void *callback_data;
uint64_t tsc_initial;
uint64_t tsc_mhz;
+
+   /** Core state relay handler. */
+   rte_keepalive_relay_callback_t relay_callback;
+
+   /**
+* Core state relay handler app data.
+* Pointer is passed to live core handler.
+*/
+   void

[dpdk-dev] [PATCH v3 1/3] eal: export keepalive state enumerations

2016-06-15 Thread Remy Horton
Changes the keepalive state from an anonymous enum to a declared one
which is externally visible, so that keepalive enum values can be
used by applications.

Signed-off-by: Remy Horton 
---
 lib/librte_eal/common/include/rte_keepalive.h | 12 +-
 lib/librte_eal/common/rte_keepalive.c | 34 +++
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_keepalive.h 
b/lib/librte_eal/common/include/rte_keepalive.h
index 10dac2e..2f856c3 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,16 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif

+enum rte_keepalive_state {
+   RTE_UNUSED = 0,
+   RTE_ALIVE = 1,
+   RTE_MISSING = 4,
+   RTE_DEAD = 2,
+   RTE_GONE = 3,
+   RTE_DOZING = 5,
+   RTE_SLEEP = 6
+};
+
 /**
  * Keepalive failure callback.
  *
diff --git a/lib/librte_eal/common/rte_keepalive.c 
b/lib/librte_eal/common/rte_keepalive.c
index 23363ec..dd18e9f 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -42,12 +42,8 @@

 struct rte_keepalive {
/** Core Liveness. */
-   enum rte_keepalive_state {
-   ALIVE = 1,
-   MISSING = 0,
-   DEAD = 2,
-   GONE = 3
-   } __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
+   enum rte_keepalive_state __rte_cache_aligned state_flags[
+   RTE_KEEPALIVE_MAXCORES];

/** Last-seen-alive timestamps */
uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
@@ -92,16 +88,18 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
continue;

switch (keepcfg->state_flags[idx_core]) {
-   case ALIVE: /* Alive */
-   keepcfg->state_flags[idx_core] = MISSING;
+   case RTE_UNUSED:
+   break;
+   case RTE_ALIVE: /* Alive */
+   keepcfg->state_flags[idx_core] = RTE_MISSING;
keepcfg->last_alive[idx_core] = rte_rdtsc();
break;
-   case MISSING: /* MIA */
+   case RTE_MISSING: /* MIA */
print_trace("Core MIA. ", keepcfg, idx_core);
-   keepcfg->state_flags[idx_core] = DEAD;
+   keepcfg->state_flags[idx_core] = RTE_DEAD;
break;
-   case DEAD: /* Dead */
-   keepcfg->state_flags[idx_core] = GONE;
+   case RTE_DEAD: /* Dead */
+   keepcfg->state_flags[idx_core] = RTE_GONE;
print_trace("Core died. ", keepcfg, idx_core);
if (keepcfg->callback)
keepcfg->callback(
@@ -109,7 +107,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
idx_core
);
break;
-   case GONE: /* Buried */
+   case RTE_GONE: /* Buried */
+   break;
+   case RTE_DOZING: /* Core going idle */
+   keepcfg->state_flags[idx_core] = RTE_SLEEP;
+   keepcfg->last_alive[idx_core] = rte_rdtsc();
+   break;
+   case RTE_SLEEP: /* Idled core */
break;
}
}
@@ -137,7 +141,7 @@ void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
if (id_core < RTE_KEEPALIVE_MAXCORES) {
-   keepcfg->active_cores[id_core] = 1;
+   keepcfg->active_cores[id_core] = RTE_ALIVE;
keepcfg->last_alive[id_core] = rte_rdtsc();
}
 }
@@ -145,5 +149,5 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, 
const int id_core)
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
-   keepcfg->state_flags[rte_lcore_id()] = ALIVE;
+   keepcfg->state_flags[rte_lcore_id()] = RTE_ALIVE;
 }
-- 
2.5.5



[dpdk-dev] [PATCH v3 0/3] Keep-alive enhancements

2016-06-15 Thread Remy Horton
This patchset adds enhancements to the keepalive core monitoring and
reporting sub-system. The first is support for idled (sleeping and
frequency-stepped) CPU cores, and the second is support for applications
to be notified of active as well as faulted cores. The latter is to allow
core state to be relayed to external (secondary) processes, which is
demonstrated by changes to the l2fed-keepalive example.

--

v3 changes
* Rebased to master
* Changed keepalive state enumerations to use RTE_ prefix
* Added missing parameter documentation
* Doc changes squashed

v2 changes:
* Some date & typos fixups
* State enum made public and extended with new states
* Generalised 'alive' callback to all states
* Last-alive shows gone-to-sleep time for idle cores
* Removed some redundant sanity checks
* Last-alive time exposed to application
* #define'd semaphore timeout
* Agent checks for dead keepalive

Remy Horton (3):
  eal: export keepalive state enumerations
  eal: add additional keepalive callbacks
  examples/l2fwd-keepalive: add IPC liveness reporting

 doc/guides/rel_notes/release_16_07.rst  |   6 +
 examples/Makefile   |   3 +-
 examples/l2fwd-keepalive/Makefile   |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile  |  48 
 examples/l2fwd-keepalive/ka-agent/main.c| 150 
 examples/l2fwd-keepalive/main.c |  22 +++-
 examples/l2fwd-keepalive/shm.c  | 128 
 examples/l2fwd-keepalive/shm.h  |  89 ++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   1 +
 lib/librte_eal/common/include/rte_keepalive.h   |  63 +-
 lib/librte_eal/common/rte_keepalive.c   |  64 +++---
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   1 +
 12 files changed, 558 insertions(+), 21 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h

-- 
2.5.5



[dpdk-dev] [PATCH v2 3/3] doc: add keepalive enhancement documentation

2016-06-14 Thread Remy Horton

On 08/06/2016 10:52, Thomas Monjalon wrote:
> 2016-05-18 10:30, Remy Horton:
>
> There is no explanation and it is totally normal, because this patch
> must be squashed with the code change.
>
>> Signed-off-by: Remy Horton 
>> ---
>>   doc/guides/rel_notes/release_16_07.rst | 5 +
>>   1 file changed, 5 insertions(+)

Done for v3. I tend to keep documentation changes in a seperate commit
as from my experience they cause the most problems when rebasing.

..Remy


[dpdk-dev] [PATCH v4 8/8] doc: update xstats documentation

2016-06-13 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 doc/guides/prog_guide/poll_mode_drv.rst | 25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/doc/guides/prog_guide/poll_mode_drv.rst 
b/doc/guides/prog_guide/poll_mode_drv.rst
index 7698692..802fb8f 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -299,10 +299,27 @@ Extended Statistics API
 ~~~

 The extended statistics API allows each individual PMD to expose a unique set
-of statistics. The client of the API provides an array of
-``struct rte_eth_xstats`` type. Each ``struct rte_eth_xstats`` contains a
-string and value pair. The amount of xstats exposed, and position of the
-statistic in the array must remain constant during runtime.
+of statistics. Accessing these from application programs is done via two
+functions:
+
+* ``rte_eth_xstats_get``: Fills in an array of ``struct rte_eth_xstat``
+  with extended statistics.
+* ``rte_eth_xstats_get_names``: Fills in an array of
+  ``struct rte_eth_xstat_name`` with extended statistic name lookup
+  information.
+
+Each ``struct rte_eth_xstat`` contains an identifier and value pair, and
+each ``struct rte_eth_xstat_name`` contains an identifier and string pair.
+Each identifier within ``struct rte_eth_xstat`` must have a corresponding
+entry in ``struct rte_eth_xstat_name`` with a matching identifier. These
+identifiers, as well as the number of extended statistic exposed, must
+remain constant during runtime.
+
+Note that extended statistic identifiers are driver-specific, and hence
+might not be the same for different ports. Although it is expected that
+drivers will make the identifiers used within ``struct rte_eth_xstat`` and
+``struct rte_eth_xstat_name`` entries match the entries' array index, this
+property should not be relied on by applications for lookups.

 A naming scheme exists for the strings exposed to clients of the API. This is
 to allow scraping of the API for statistics of interest. The naming scheme uses
-- 
2.5.5



[dpdk-dev] [PATCH v4 7/8] rte: change xstats usage to new API

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the test-pmd
and proc_info applications to use the new xstats API, and removes
deprecated code associated with the old API.

Signed-off-by: Remy Horton 
---
 app/proc_info/main.c   | 29 +---
 app/test-pmd/config.c  | 54 +-
 drivers/net/e1000/igb_ethdev.c | 10 +++
 drivers/net/fm10k/fm10k_ethdev.c   |  5 +---
 drivers/net/i40e/i40e_ethdev.c |  8 ++
 drivers/net/i40e/i40e_ethdev_vf.c  |  5 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c   | 11 +++-
 drivers/net/virtio/virtio_ethdev.c |  6 ++---
 lib/librte_ether/rte_ethdev.c  |  5 +---
 lib/librte_ether/rte_ethdev.h  |  7 +++--
 10 files changed, 85 insertions(+), 55 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 5f83092..f2063fa 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -1,7 +1,7 @@
 /*
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -243,11 +243,13 @@ nic_stats_clear(uint8_t port_id)
 static void
 nic_xstats_display(uint8_t port_id)
 {
-   struct rte_eth_xstats *xstats;
+   struct rte_eth_xstat_name *xstats_names;
+   struct rte_eth_xstat *xstats;
int len, ret, i;
+   int idx_name;
static const char *nic_stats_border = "";

-   len = rte_eth_xstats_get(port_id, NULL, 0);
+   len = rte_eth_xstats_get_names(port_id, NULL, 0);
if (len < 0) {
printf("Cannot get xstats count\n");
return;
@@ -258,6 +260,18 @@ nic_xstats_display(uint8_t port_id)
return;
}

+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
+   if (xstats_names == NULL) {
+   printf("Cannot allocate memory for xstat names\n");
+   free(xstats);
+   return;
+   }
+   if (len != rte_eth_xstats_get_names(
+   port_id, xstats_names, len)) {
+   printf("Cannot get xstat names\n");
+   return;
+   }
+
printf("## NIC extended statistics for port %-2d #\n",
   port_id);
printf("%s\n",
@@ -270,11 +284,18 @@ nic_xstats_display(uint8_t port_id)
}

for (i = 0; i < len; i++)
-   printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value);
+   for (idx_name = 0; idx_name < len; idx_name++)
+   if (xstats_names[idx_name].id == xstats[i].id) {
+   printf("%s: %"PRIu64"\n",
+   xstats_names[idx_name].name,
+   xstats[i].value);
+   break;
+   }

printf("%s\n",
   nic_stats_border);
free(xstats);
+   free(xstats_names);
 }

 static void
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1c552e4..8ddec07 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -232,29 +232,57 @@ nic_stats_clear(portid_t port_id)
 void
 nic_xstats_display(portid_t port_id)
 {
-   struct rte_eth_xstats *xstats;
-   int len, ret, i;
+   struct rte_eth_xstat *xstats;
+   int cnt_xstats, idx_xstat, idx_name;
+   struct rte_eth_xstat_name *xstats_names;

printf("## NIC extended statistics for port %-2d\n", port_id);
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   printf("Error: Invalid port number %i\n", port_id);
+   return;
+   }
+
+   /* Get count */
+   cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0);
+   if (cnt_xstats  < 0) {
+   printf("Error: Cannot get count of xstats\n");
+   return;
+   }

-   len = rte_eth_xstats_get(port_id, NULL, 0);
-   if (len < 0) {
-   printf("Cannot get xstats count\n");
+   /* Get id-name lookup table */
+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * cnt_xstats);
+   if (xstats_names == NULL) {
+  

[dpdk-dev] [PATCH v4 6/8] drivers/net/virtio: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the virtio driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/virtio/virtio_ethdev.c | 62 +-
 1 file changed, 55 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index c3fb628..83df025 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -80,6 +80,9 @@ static void virtio_dev_stats_get(struct rte_eth_dev *dev,
 struct rte_eth_stats *stats);
 static int virtio_dev_xstats_get(struct rte_eth_dev *dev,
 struct rte_eth_xstats *xstats, unsigned n);
+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  unsigned limit);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
 static int virtio_vlan_filter_set(struct rte_eth_dev *dev,
@@ -615,6 +618,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
.dev_infos_get   = virtio_dev_info_get,
.stats_get   = virtio_dev_stats_get,
.xstats_get  = virtio_dev_xstats_get,
+   .xstats_get_names= virtio_dev_xstats_get_names,
.stats_reset = virtio_dev_stats_reset,
.xstats_reset= virtio_dev_stats_reset,
.link_update = virtio_dev_link_update,
@@ -708,6 +712,52 @@ virtio_update_stats(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 }

+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  __rte_unused unsigned limit)
+{
+   unsigned i;
+   unsigned count = 0;
+   unsigned t;
+
+   unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_Q_XSTATS +
+   dev->data->nb_rx_queues * VIRTIO_NB_Q_XSTATS;
+
+   if (xstats_names == NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct virtqueue *rxvq = dev->data->rx_queues[i];
+   if (rxvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct virtqueue *txvq = dev->data->tx_queues[i];
+   if (txvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+   }
+   return nstats;
+}
+
 static int
 virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
  unsigned n)
@@ -730,9 +780,8 @@ virtio_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
unsigned t;

for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", i,
-rte_virtio_q_stat_strings[t].name);
+   xstats[count].name[0] = '\0';
+   xstats[co

[dpdk-dev] [PATCH v4 5/8] drivers/net/i40e: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the i40e driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/i40e/i40e_ethdev.c| 82 ---
 drivers/net/i40e/i40e_ethdev_vf.c | 26 +++--
 2 files changed, 91 insertions(+), 17 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..d712bbe 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -306,6 +306,9 @@ static void i40e_dev_stats_get(struct rte_eth_dev *dev,
   struct rte_eth_stats *stats);
 static int i40e_dev_xstats_get(struct rte_eth_dev *dev,
   struct rte_eth_xstats *xstats, unsigned n);
+static int i40e_dev_xstats_get_names(struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+unsigned limit);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
 static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
uint16_t queue_id,
@@ -467,6 +470,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.link_update  = i40e_dev_link_update,
.stats_get= i40e_dev_stats_get,
.xstats_get   = i40e_dev_xstats_get,
+   .xstats_get_names = i40e_dev_xstats_get_names,
.stats_reset  = i40e_dev_stats_reset,
.xstats_reset = i40e_dev_stats_reset,
.queue_stats_mapping_set  = i40e_dev_queue_stats_mapping_set,
@@ -2205,6 +2209,60 @@ i40e_xstats_calc_num(void)
(I40E_NB_TXQ_PRIO_XSTATS * 8);
 }

+static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned count = 0;
+   unsigned i, prio;
+
+   if (xstats_names == NULL)
+   return i40e_xstats_calc_num();
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Get stats from i40e_eth_stats struct */
+   for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"%s", rte_i40e_stats_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* Get individiual stats from i40e_hw_port struct */
+   for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+"%s", rte_i40e_hw_port_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"rx_priority%u_%s", prio,
+rte_i40e_rxq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"tx_priority%u_%s", prio,
+rte_i40e_txq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+}
+
 static int
 i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
unsigned n)
@@ -2227,8 +2285,8 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Get stats from i40e_eth_stats struct */
for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", rte_i40e_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+   xst

[dpdk-dev] [PATCH v4 4/8] drivers/net/fm10k: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the fm10k driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/fm10k/fm10k_ethdev.c | 55 +---
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c2d377f..e07c1ec 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -1256,6 +1256,47 @@ fm10k_link_update(struct rte_eth_dev *dev,
return 0;
 }

+static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   unsigned i, q;
+   unsigned count = 0;
+
+   if (xstats_names != NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Global stats */
+   for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s", fm10k_hw_stats_strings[count].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* PF queue stats */
+   for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
+   for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", q,
+   fm10k_hw_stats_rx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", q,
+   fm10k_hw_stats_tx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   }
+   return FM10K_NB_XSTATS;
+}
+
 static int
 fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 unsigned n)
@@ -1269,8 +1310,7 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Global stats */
for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", fm10k_hw_stats_strings[count].name);
+   xstats[count].name[0] = '\0';
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
fm10k_hw_stats_strings[count].offset);
count++;
@@ -1279,18 +1319,14 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
/* PF queue stats */
for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", q,
-fm10k_hw_stats_rx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_rx_q_strings[i].offset);
count++;
}
for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"tx_q%u_%s", q,
-fm10k_hw_stats_tx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_tx_q_strings[i].offset);
@@ -2629,6 +2665,7 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.allmulticast_disable   = fm10k_dev_allmulticast_disable,
.stats_get  = fm10

[dpdk-dev] [PATCH v4 3/8] drivers/net/e1000: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the e1000 driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/e1000/igb_ethdev.c | 52 ++
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f0921ee..dffa04f 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -100,6 +100,9 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igb_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
@@ -165,6 +168,9 @@ static void eth_igbvf_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igbvf_xstats_get(struct rte_eth_dev *dev,
struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igbvf_xstats_get_names(struct rte_eth_dev *dev,
+ struct rte_eth_xstat_name *xstats_names,
+ unsigned limit);
 static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
 static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
@@ -324,6 +330,7 @@ static const struct eth_dev_ops eth_igb_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igb_stats_get,
.xstats_get   = eth_igb_xstats_get,
+   .xstats_get_names = eth_igb_xstats_get_names,
.stats_reset  = eth_igb_stats_reset,
.xstats_reset = eth_igb_xstats_reset,
.dev_infos_get= eth_igb_infos_get,
@@ -385,6 +392,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igbvf_stats_get,
.xstats_get   = eth_igbvf_xstats_get,
+   .xstats_get_names = eth_igbvf_xstats_get_names,
.stats_reset  = eth_igbvf_stats_reset,
.xstats_reset = eth_igbvf_stats_reset,
.vlan_filter_set  = igbvf_vlan_filter_set,
@@ -1691,6 +1699,26 @@ eth_igb_xstats_reset(struct rte_eth_dev *dev)
memset(stats, 0, sizeof(*stats));
 }

+static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   __rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names == NULL)
+   return IGB_NB_XSTATS;
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < IGB_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
+"%s", rte_igb_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+
+   return IGB_NB_XSTATS;
+}
+
 static int
 eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
   unsigned n)
@@ -1713,8 +1741,8 @@ eth_igb_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Extended stats */
for (i = 0; i < IGB_NB_XSTATS; i++) {
-   snprintf(xstats[i].name, sizeof(xstats[i].name),
-"%s", rte_igb_stats_strings[i].name);
+   xstats[i].name[0] = '\0';
+   xstats[i].id = i;
xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
rte_igb_stats_strings[i].offset);
}
@@ -1762,6 +1790,22 @@ igbvf_read_stats_registers(struct e1000_hw *hw, struct 
e1000_vf_stats *hw_stats)
hw_stats->last_gotlbc, hw_stats->gotlbc);
 }

+static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names != NULL)
+   for (i = 0; i < IGBVF_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name,
+   sizeof(xstats_names[i].name), "%s",
+   rte_igbvf_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+   return IGBVF_NB_XSTATS;
+}
+
 static int

[dpdk-dev] [PATCH v4 2/8] drivers/net/ixgbe: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the ixgbe driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 101 +--
 1 file changed, 86 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a2b170b..9e73492 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -179,6 +179,10 @@ static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
+static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 uint16_t queue_id,
 uint8_t stat_idx,
@@ -466,6 +470,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.xstats_get   = ixgbe_dev_xstats_get,
.stats_reset  = ixgbe_dev_stats_reset,
.xstats_reset = ixgbe_dev_xstats_reset,
+   .xstats_get_names = ixgbe_dev_xstats_get_names,
.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
.dev_infos_get= ixgbe_dev_info_get,
.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
@@ -555,6 +560,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.xstats_get   = ixgbevf_dev_xstats_get,
.stats_reset  = ixgbevf_dev_stats_reset,
.xstats_reset = ixgbevf_dev_stats_reset,
+   .xstats_get_names = ixgbevf_dev_xstats_get_names,
.dev_close= ixgbevf_dev_close,
.allmulticast_enable  = ixgbevf_dev_allmulticast_enable,
.allmulticast_disable = ixgbevf_dev_allmulticast_disable,
@@ -685,6 +691,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_rxq_strings[] = {

 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
   sizeof(rte_ixgbe_rxq_strings[0]))
+#define IXGBE_NB_RXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
{"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
@@ -695,6 +702,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_txq_strings[] = {

 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
   sizeof(rte_ixgbe_txq_strings[0]))
+#define IXGBE_NB_TXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
{"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
@@ -2695,8 +2703,75 @@ ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
 /* This function calculates the number of xstats based on the current config */
 static unsigned
 ixgbe_xstats_calc_num(void) {
-   return IXGBE_NB_HW_STATS + (IXGBE_NB_RXQ_PRIO_STATS * 8) +
-   (IXGBE_NB_TXQ_PRIO_STATS * 8);
+   return IXGBE_NB_HW_STATS +
+   (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
+   (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
+}
+
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   const unsigned cnt_stats = ixgbe_xstats_calc_num();
+   unsigned stat, i, count;
+
+   if (xstats_names != NULL) {
+   count = 0;
+
+   /* Note: limit >= cnt_stats checked upstream
+* in rte_eth_xstats_names()
+*/
+
+   /* Extended stats from ixgbe_hw_stats */
+   for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s",
+   rte_ixgbe_stats_strings[i].name);
+   count++;
+   }
+
+   /* RX Priority Stats */
+   for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
+   for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   

[dpdk-dev] [PATCH v4 1/8] rte: change xstats to use integer ids

2016-06-13 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 lib/librte_ether/rte_ethdev.c  | 94 +++---
 lib/librte_ether/rte_ethdev.h  | 35 +
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 128 insertions(+), 8 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..79a01cc 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1502,6 +1502,86 @@ rte_eth_stats_reset(uint8_t port_id)
dev->data->rx_mbuf_alloc_failed = 0;
 }

+static int
+get_xstats_count(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int count;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   count = (*dev->dev_ops->xstats_get_names)(dev, NULL, 0);
+   if (count < 0)
+   return count;
+   } else
+   count = 0;
+   count += RTE_NB_STATS;
+   count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
+   count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
+   return count;
+}
+
+int
+rte_eth_xstats_get_names(uint8_t port_id,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned size)
+{
+   struct rte_eth_dev *dev;
+   int cnt_used_entries;
+   int cnt_expected_entries;
+   uint32_t idx, id_queue;
+
+   cnt_expected_entries = get_xstats_count(port_id);
+   if (xstats_names == NULL || cnt_expected_entries < 0)
+   return cnt_expected_entries;
+   if ((int)size < cnt_expected_entries)
+   return -ERANGE;
+
+   /* port_id checked in get_xstats_count() */
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   cnt_used_entries = (*dev->dev_ops->xstats_get_names)(
+   dev, xstats_names, size);
+   if (cnt_used_entries < 0)
+   return cnt_used_entries;
+   } else
+   /* Driver itself does not support extended stats, but
+* still have basic stats.
+*/
+   cnt_used_entries = 0;
+
+   for (idx = 0; idx < RTE_NB_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "%s", rte_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+   for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) {
+   for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "rx_q%u%s",
+   id_queue, rte_rxq_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+
+   }
+   for (id_queue = 0; id_queue < dev->data->nb_tx_queues; id_queue++) {
+   for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "tx_q%u%s",
+   id_queue, rte_txq_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+   }
+   return cnt_used_entries;
+}
+
 /* retrieve ethdev extended statistics */
 int
 rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
@@ -1546,8 +1626,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats 
*xstats,
stats_ptr = RTE_PTR_ADD(_stats,
rte_stats_strings[i].offset);
val = *stats_ptr;
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-   "%s", rte_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+   xstats[count].id = count + xcount;
xstats[count++].value = val;
}

@@ -1558,9 +1638,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats 
*xstats,
rte_rxq_stats_strings[i].offset +
q * sizeof(uint64_t));
val = *stats_ptr;
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-   "rx_q%u_%s", q,
-   rte_rxq_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+  

  1   2   3   >