get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/17014/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 17014,
    "url": "https://patches.dpdk.org/api/patches/17014/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1479194120-6917-2-git-send-email-remy.horton@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1479194120-6917-2-git-send-email-remy.horton@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1479194120-6917-2-git-send-email-remy.horton@intel.com",
    "date": "2016-11-15T07:15:18",
    "name": "[dpdk-dev,v4,1/3] lib: add information metrics library",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2a89309ffc801c2259d4f99d9ef74af84c2c3f93",
    "submitter": {
        "id": 326,
        "url": "https://patches.dpdk.org/api/people/326/?format=api",
        "name": "Remy Horton",
        "email": "remy.horton@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1479194120-6917-2-git-send-email-remy.horton@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/17014/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/17014/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 4D73937A8;\n\tTue, 15 Nov 2016 08:15:44 +0100 (CET)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 0DBF82BE4\n\tfor <dev@dpdk.org>; Tue, 15 Nov 2016 08:15:23 +0100 (CET)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga104.jf.intel.com with ESMTP; 14 Nov 2016 23:15:23 -0800",
            "from rhorton-mobl.ger.corp.intel.com (HELO VM.sh.intel.com)\n\t([10.239.205.185])\n\tby orsmga003.jf.intel.com with ESMTP; 14 Nov 2016 23:15:22 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.31,641,1473145200\"; d=\"scan'208\";a=\"901497633\"",
        "From": "Remy Horton <remy.horton@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas.monjalon@6wind.com",
        "Date": "Tue, 15 Nov 2016 15:15:18 +0800",
        "Message-Id": "<1479194120-6917-2-git-send-email-remy.horton@intel.com>",
        "X-Mailer": "git-send-email 2.5.5",
        "In-Reply-To": "<1479194120-6917-1-git-send-email-remy.horton@intel.com>",
        "References": "<1479194120-6917-1-git-send-email-remy.horton@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4 1/3] lib: add information metrics library",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch adds a new information metric library that allows other\nmodules to register named metrics and update their values. It is\nintended to be independent of ethdev, rather than mixing ethdev\nand non-ethdev information in xstats.\n\nSigned-off-by: Remy Horton <remy.horton@intel.com>\n---\n MAINTAINERS                                |   5 +\n config/common_base                         |   5 +\n doc/api/doxy-api-index.md                  |   1 +\n doc/api/doxy-api.conf                      |   1 +\n doc/guides/rel_notes/release_17_02.rst     |   6 +\n lib/Makefile                               |   1 +\n lib/librte_metrics/Makefile                |  51 +++++\n lib/librte_metrics/rte_metrics.c           | 308 +++++++++++++++++++++++++++++\n lib/librte_metrics/rte_metrics.h           | 190 ++++++++++++++++++\n lib/librte_metrics/rte_metrics_version.map |  13 ++\n mk/rte.app.mk                              |   2 +\n 11 files changed, 583 insertions(+)\n create mode 100644 lib/librte_metrics/Makefile\n create mode 100644 lib/librte_metrics/rte_metrics.c\n create mode 100644 lib/librte_metrics/rte_metrics.h\n create mode 100644 lib/librte_metrics/rte_metrics_version.map",
    "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex d6bb8f8..52bd8a9 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -595,6 +595,11 @@ F: lib/librte_jobstats/\n F: examples/l2fwd-jobstats/\n F: doc/guides/sample_app_ug/l2_forward_job_stats.rst\n \n+Metrics\n+M: Remy Horton <remy.horton@intel.com>\n+F: lib/librte_metrics/\n+F: doc/guides/sample_app_ug/keep_alive.rst\n+\n \n Test Applications\n -----------------\ndiff --git a/config/common_base b/config/common_base\nindex 4bff83a..dedc4c3 100644\n--- a/config/common_base\n+++ b/config/common_base\n@@ -589,3 +589,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n\n CONFIG_RTE_TEST_PMD=y\n CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n\n CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n\n+\n+#\n+# Compile the device metrics library\n+#\n+CONFIG_RTE_LIBRTE_METRICS=y\ndiff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md\nindex 6675f96..ca50fa6 100644\n--- a/doc/api/doxy-api-index.md\n+++ b/doc/api/doxy-api-index.md\n@@ -147,4 +147,5 @@ There are many libraries, so their headers may be grouped by topics:\n   [common]             (@ref rte_common.h),\n   [ABI compat]         (@ref rte_compat.h),\n   [keepalive]          (@ref rte_keepalive.h),\n+  [Device Metrics]     (@ref rte_metrics.h),\n   [version]            (@ref rte_version.h)\ndiff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf\nindex 9dc7ae5..fe830eb 100644\n--- a/doc/api/doxy-api.conf\n+++ b/doc/api/doxy-api.conf\n@@ -57,6 +57,7 @@ INPUT                   = doc/api/doxy-api-index.md \\\n                           lib/librte_reorder \\\n                           lib/librte_ring \\\n                           lib/librte_sched \\\n+                          lib/librte_metrics \\\n                           lib/librte_table \\\n                           lib/librte_timer \\\n                           lib/librte_vhost\ndiff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst\nindex 3b65038..e1b8894 100644\n--- a/doc/guides/rel_notes/release_17_02.rst\n+++ b/doc/guides/rel_notes/release_17_02.rst\n@@ -34,6 +34,12 @@ New Features\n \n      Refer to the previous release notes for examples.\n \n+   * **Added information metric library.**\n+\n+     A library that allows information metrics to be added and update. It is\n+     intended to provide a reporting mechanism that is independent of the\n+     ethdev library.\n+\n      This section is a comment. do not overwrite or remove it.\n      Also, make sure to start the actual text at the margin.\n      =========================================================\ndiff --git a/lib/Makefile b/lib/Makefile\nindex 990f23a..5d85dcf 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -58,6 +58,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TABLE) += librte_table\n DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline\n DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder\n DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump\n+DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics\n \n ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)\n DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni\ndiff --git a/lib/librte_metrics/Makefile b/lib/librte_metrics/Makefile\nnew file mode 100644\nindex 0000000..8d6e23a\n--- /dev/null\n+++ b/lib/librte_metrics/Makefile\n@@ -0,0 +1,51 @@\n+#   BSD LICENSE\n+#\n+#   Copyright(c) 2016 Intel Corporation. All rights reserved.\n+#   All rights reserved.\n+#\n+#   Redistribution and use in source and binary forms, with or without\n+#   modification, are permitted provided that the following conditions\n+#   are met:\n+#\n+#     * Redistributions of source code must retain the above copyright\n+#       notice, this list of conditions and the following disclaimer.\n+#     * Redistributions in binary form must reproduce the above copyright\n+#       notice, this list of conditions and the following disclaimer in\n+#       the documentation and/or other materials provided with the\n+#       distribution.\n+#     * Neither the name of Intel Corporation nor the names of its\n+#       contributors may be used to endorse or promote products derived\n+#       from this software without specific prior written permission.\n+#\n+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+#   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+\n+include $(RTE_SDK)/mk/rte.vars.mk\n+\n+# library name\n+LIB = librte_metrics.a\n+\n+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)\n+\n+EXPORT_MAP := rte_metrics_version.map\n+\n+LIBABIVER := 1\n+\n+# all source are stored in SRCS-y\n+SRCS-$(CONFIG_RTE_LIBRTE_METRICS) := rte_metrics.c\n+\n+# Install header file\n+SYMLINK-$(CONFIG_RTE_LIBRTE_METRICS)-include += rte_metrics.h\n+\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_METRICS) += lib/librte_eal\n+\n+include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c\nnew file mode 100644\nindex 0000000..5edacc6\n--- /dev/null\n+++ b/lib/librte_metrics/rte_metrics.c\n@@ -0,0 +1,308 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2016 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <string.h>\n+#include <sys/queue.h>\n+\n+#include <rte_common.h>\n+#include <rte_malloc.h>\n+#include <rte_metrics.h>\n+#include <rte_lcore.h>\n+#include <rte_memzone.h>\n+#include <rte_spinlock.h>\n+\n+#define RTE_METRICS_MAX_METRICS 256\n+#define RTE_METRICS_MEMZONE_NAME \"RTE_METRICS\"\n+\n+/**\n+ * Internal stats metadata and value entry.\n+ *\n+ * @internal\n+ * @param name\n+ *   Name of metric\n+ * @param value\n+ *   Current value for metric\n+ * @param idx_next_set\n+ *   Index of next root element (zero for none)\n+ * @param idx_next_metric\n+ *   Index of next metric in set (zero for none)\n+ *\n+ * Only the root of each set needs idx_next_set but since it has to be\n+ * assumed that number of sets could equal total number of metrics,\n+ * having a separate set metadata table doesn't save any memory.\n+ */\n+struct rte_metrics_meta_s {\n+\tchar name[RTE_METRICS_MAX_NAME_LEN];\n+\tuint64_t value[RTE_MAX_ETHPORTS];\n+\tuint64_t nonport_value;\n+\tuint16_t idx_next_set;\n+\tuint16_t idx_next_stat;\n+};\n+\n+/**\n+ * Internal stats info structure.\n+ *\n+ * @internal\n+ * @param idx_last_set\n+ *   Index of last metadata entry with valid data. This value is\n+ *   not valid if cnt_stats is zero.\n+ * @param cnt_stats\n+ *   Number of metrics.\n+ * @param metadata\n+ *   Stat data memory block.\n+ *\n+ * Offsets into metadata are used instead of pointers because ASLR\n+ * means that having the same physical addresses in different\n+ * processes is not guaranteed.\n+ */\n+struct rte_metrics_data_s {\n+\tuint16_t idx_last_set;\n+\tuint16_t cnt_stats;\n+\tstruct rte_metrics_meta_s metadata[RTE_METRICS_MAX_METRICS];\n+\trte_spinlock_t lock;\n+};\n+\n+void\n+rte_metrics_init(void)\n+{\n+\tstruct rte_metrics_data_s *stats;\n+\tconst struct rte_memzone *memzone;\n+\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n+\t\treturn;\n+\n+\tmemzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);\n+\tif (memzone != NULL)\n+\t\treturn;\n+\tmemzone = rte_memzone_reserve(RTE_METRICS_MEMZONE_NAME,\n+\t\tsizeof(struct rte_metrics_data_s), rte_socket_id(), 0);\n+\tif (memzone == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Unable to allocate stats memzone\\n\");\n+\tstats = memzone->addr;\n+\tmemset(stats, 0, sizeof(struct rte_metrics_data_s));\n+\trte_spinlock_init(&stats->lock);\n+}\n+\n+int\n+rte_metrics_reg_metric(const char *name)\n+{\n+\tconst char *list_names[] = {name};\n+\n+\treturn rte_metrics_reg_metrics(list_names, 1);\n+}\n+\n+int\n+rte_metrics_reg_metrics(const char **names, uint16_t cnt_names)\n+{\n+\tstruct rte_metrics_meta_s *entry;\n+\tstruct rte_metrics_data_s *stats;\n+\tconst struct rte_memzone *memzone;\n+\tuint16_t idx_name;\n+\tuint16_t idx_base;\n+\n+\t/* Some sanity checks */\n+\tif (cnt_names < 1 || names == NULL)\n+\t\treturn -EINVAL;\n+\n+\trte_metrics_init();\n+\tmemzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);\n+\tif (memzone == NULL)\n+\t\treturn -EIO;\n+\tstats = memzone->addr;\n+\n+\tif (stats->cnt_stats + cnt_names >= RTE_METRICS_MAX_METRICS)\n+\t\treturn -ENOMEM;\n+\n+\trte_spinlock_lock(&stats->lock);\n+\n+\t/* Overwritten later if this is actually first set.. */\n+\tstats->metadata[stats->idx_last_set].idx_next_set = stats->cnt_stats;\n+\n+\tstats->idx_last_set = idx_base = stats->cnt_stats;\n+\n+\tfor (idx_name = 0; idx_name < cnt_names; idx_name++) {\n+\t\tentry = &stats->metadata[idx_name + stats->cnt_stats];\n+\t\tstrncpy(entry->name, names[idx_name],\n+\t\t\tRTE_METRICS_MAX_NAME_LEN);\n+\t\tmemset(entry->value, 0, sizeof(entry->value));\n+\t\tentry->idx_next_stat = idx_name + stats->cnt_stats + 1;\n+\t}\n+\tentry->idx_next_stat = 0;\n+\tentry->idx_next_set = 0;\n+\tstats->cnt_stats += cnt_names;\n+\n+\trte_spinlock_unlock(&stats->lock);\n+\n+\treturn idx_base;\n+}\n+\n+int\n+rte_metrics_update_metric(int port_id, uint16_t key, const uint64_t value)\n+{\n+\treturn rte_metrics_update_metrics(port_id, key, &value, 1);\n+}\n+\n+int\n+rte_metrics_update_metrics(int port_id,\n+\tuint16_t key,\n+\tconst uint64_t *values,\n+\tuint32_t count)\n+{\n+\tstruct rte_metrics_meta_s *entry;\n+\tstruct rte_metrics_data_s *stats;\n+\tconst struct rte_memzone *memzone;\n+\tuint16_t idx_metric;\n+\tuint16_t idx_value;\n+\tuint16_t cnt_setsize;\n+\n+\tif (port_id != RTE_METRICS_NONPORT &&\n+\t\t\t(port_id < 0 || port_id > RTE_MAX_ETHPORTS))\n+\t\treturn -EINVAL;\n+\n+\trte_metrics_init();\n+\tmemzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);\n+\tif (memzone == NULL)\n+\t\treturn -EIO;\n+\tstats = memzone->addr;\n+\n+\trte_spinlock_lock(&stats->lock);\n+\tidx_metric = key;\n+\tcnt_setsize = 1;\n+\twhile (idx_metric < stats->cnt_stats) {\n+\t\tentry = &stats->metadata[idx_metric];\n+\t\tif (entry->idx_next_stat == 0)\n+\t\t\tbreak;\n+\t\tcnt_setsize++;\n+\t\tidx_metric++;\n+\t}\n+\t/* Check update does not cross set border */\n+\tif (count > cnt_setsize) {\n+\t\trte_spinlock_unlock(&stats->lock);\n+\t\treturn -ERANGE;\n+\t}\n+\n+\tif (port_id == RTE_METRICS_NONPORT)\n+\t\tfor (idx_value = 0; idx_value < count; idx_value++) {\n+\t\t\tidx_metric = key + idx_value;\n+\t\t\tstats->metadata[idx_metric].nonport_value =\n+\t\t\t\tvalues[idx_value];\n+\t\t}\n+\telse\n+\t\tfor (idx_value = 0; idx_value < count; idx_value++) {\n+\t\t\tidx_metric = key + idx_value;\n+\t\t\tstats->metadata[idx_metric].value[port_id] =\n+\t\t\t\tvalues[idx_value];\n+\t\t}\n+\trte_spinlock_unlock(&stats->lock);\n+\treturn 0;\n+}\n+\n+int\n+rte_metrics_get_names(struct rte_metric_name *names,\n+\tuint16_t capacity)\n+{\n+\tstruct rte_metrics_data_s *stats;\n+\tconst struct rte_memzone *memzone;\n+\tuint16_t idx_name;\n+\tint return_value;\n+\n+\tmemzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);\n+\t/* If not allocated, fail silently */\n+\tif (memzone == NULL)\n+\t\treturn 0;\n+\n+\tstats = memzone->addr;\n+\trte_spinlock_lock(&stats->lock);\n+\tif (names != NULL) {\n+\t\tif (capacity < stats->cnt_stats) {\n+\t\t\trte_spinlock_unlock(&stats->lock);\n+\t\t\treturn -ERANGE;\n+\t\t}\n+\t\tfor (idx_name = 0; idx_name < stats->cnt_stats; idx_name++)\n+\t\t\tstrncpy(names[idx_name].name,\n+\t\t\t\tstats->metadata[idx_name].name,\n+\t\t\t\tRTE_METRICS_MAX_NAME_LEN);\n+\t}\n+\treturn_value = stats->cnt_stats;\n+\trte_spinlock_unlock(&stats->lock);\n+\treturn return_value;\n+}\n+\n+int\n+rte_metrics_get_values(int port_id,\n+\tstruct rte_metric_value *values,\n+\tuint16_t capacity)\n+{\n+\tstruct rte_metrics_meta_s *entry;\n+\tstruct rte_metrics_data_s *stats;\n+\tconst struct rte_memzone *memzone;\n+\tuint16_t idx_name;\n+\tint return_value;\n+\n+\tif (port_id != RTE_METRICS_NONPORT &&\n+\t\t\t(port_id < 0 || port_id > RTE_MAX_ETHPORTS))\n+\t\treturn -EINVAL;\n+\n+\tmemzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);\n+\t/* If not allocated, fail silently */\n+\tif (memzone == NULL)\n+\t\treturn 0;\n+\tstats = memzone->addr;\n+\trte_spinlock_lock(&stats->lock);\n+\n+\tif (values != NULL) {\n+\t\tif (capacity < stats->cnt_stats) {\n+\t\t\trte_spinlock_unlock(&stats->lock);\n+\t\t\treturn -ERANGE;\n+\t\t}\n+\t\tif (port_id == RTE_METRICS_NONPORT)\n+\t\t\tfor (idx_name = 0;\n+\t\t\t\t\tidx_name < stats->cnt_stats;\n+\t\t\t\t\tidx_name++) {\n+\t\t\t\tentry = &stats->metadata[idx_name];\n+\t\t\t\tvalues[idx_name].key = idx_name;\n+\t\t\t\tvalues[idx_name].value = entry->nonport_value;\n+\t\t\t}\n+\t\telse\n+\t\t\tfor (idx_name = 0;\n+\t\t\t\t\tidx_name < stats->cnt_stats;\n+\t\t\t\t\tidx_name++) {\n+\t\t\t\tentry = &stats->metadata[idx_name];\n+\t\t\t\tvalues[idx_name].key = idx_name;\n+\t\t\t\tvalues[idx_name].value = entry->value[port_id];\n+\t\t\t}\n+\t}\n+\treturn_value = stats->cnt_stats;\n+\trte_spinlock_unlock(&stats->lock);\n+\treturn return_value;\n+}\ndiff --git a/lib/librte_metrics/rte_metrics.h b/lib/librte_metrics/rte_metrics.h\nnew file mode 100644\nindex 0000000..c58b366\n--- /dev/null\n+++ b/lib/librte_metrics/rte_metrics.h\n@@ -0,0 +1,190 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2016 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+/**\n+ * @file\n+ *\n+ * RTE Metrics module\n+ *\n+ * Metric information is populated using a push model, where the\n+ * information provider calls an update function on the relevant\n+ * metrics. Currently only bulk querying of metrics is supported.\n+ */\n+\n+#ifndef _RTE_METRICS_H_\n+#define _RTE_METRICS_H_\n+\n+/** Maximum length of metric name (including null-terminator) */\n+#define RTE_METRICS_MAX_NAME_LEN 64\n+\n+/** Used to indicate port-independent information */\n+#define RTE_METRICS_NONPORT -1\n+\n+\n+/**\n+ * Metric name\n+ */\n+struct rte_metric_name {\n+\t/** String describing metric */\n+\tchar name[RTE_METRICS_MAX_NAME_LEN];\n+};\n+\n+\n+/**\n+ * Metric name.\n+ */\n+struct rte_metric_value {\n+\t/** Numeric identifier of metric */\n+\tuint16_t key;\n+\t/** Value for metric */\n+\tuint64_t value;\n+};\n+\n+\n+/**\n+ * Initializes metric module. This only has to be explicitly called if you\n+ * intend to use rte_metrics_reg_metric() or rte_metrics_reg_metrics() from a\n+ * secondary process. This function must be called from a primary process.\n+ */\n+void rte_metrics_init(void);\n+\n+\n+/**\n+ * Register a metric\n+ *\n+ * @param name\n+ *   Metric name\n+ *\n+ * @return\n+ *  - Zero or positive: Success\n+ *  - Negative: Failure\n+ */\n+int rte_metrics_reg_metric(const char *name);\n+\n+/**\n+ * Register a set of metrics\n+ *\n+ * @param names\n+ *   List of metric names\n+ *\n+ * @param cnt_names\n+ *   Number of metrics in set\n+ *\n+ * @return\n+ *  - Zero or positive: Success\n+ *  - Negative: Failure\n+ */\n+int rte_metrics_reg_metrics(const char **names, uint16_t cnt_names);\n+\n+/**\n+ * Get metric name-key lookup table.\n+ *\n+ * @param names\n+ *   Array of names to receive key names\n+ *\n+ * @param capacity\n+ *   Space available in names\n+ *\n+ * @return\n+ *   - Non-negative: Success (number of names)\n+ *   - Negative: Failure\n+ */\n+int rte_metrics_get_names(\n+\tstruct rte_metric_name *names,\n+\tuint16_t capacity);\n+\n+/**\n+ * Fetch metrics.\n+ *\n+ * @param port_id\n+ *   Port id to query\n+ *\n+ * @param values\n+ *   Array to receive values and their keys\n+ *\n+ * @param capacity\n+ *   Space available in values\n+ *\n+ * @return\n+ *   - Non-negative: Success (number of names)\n+ *   - Negative: Failure\n+ */\n+int rte_metrics_get_values(\n+\tint port_id,\n+\tstruct rte_metric_value *values,\n+\tuint16_t capacity);\n+\n+/**\n+ * Updates a metric\n+ *\n+ * @param port_id\n+ *   Port to update metrics for\n+ * @param key\n+ *   Id of metric to update\n+ * @param value\n+ *   New value\n+ *\n+ * @return\n+ *   - -EIO if unable to access shared metrics memory\n+ *   - Zero on success\n+ */\n+int rte_metrics_update_metric(\n+\tint port_id,\n+\tuint16_t key,\n+\tconst uint64_t value);\n+\n+/**\n+ * Updates a metric set. Note that it is an error to try to\n+ * update across a set boundary.\n+ *\n+ * @param port_id\n+ *   Port to update metrics for\n+ * @param key\n+ *   Base id of metrics set to update\n+ * @param values\n+ *   Set of new values\n+ * @param count\n+ *   Number of new values\n+ *\n+ * @return\n+ *   - -ERANGE if count exceeds metric set size\n+ *   - -EIO if upable to access shared metrics memory\n+ *   - Zero on success\n+ */\n+int rte_metrics_update_metrics(\n+\tint port_id,\n+\tuint16_t key,\n+\tconst uint64_t *values,\n+\tuint32_t count);\n+\n+#endif\ndiff --git a/lib/librte_metrics/rte_metrics_version.map b/lib/librte_metrics/rte_metrics_version.map\nnew file mode 100644\nindex 0000000..f904814\n--- /dev/null\n+++ b/lib/librte_metrics/rte_metrics_version.map\n@@ -0,0 +1,13 @@\n+DPDK_17.02 {\n+\tglobal:\n+\n+\trte_metrics_get_names;\n+\trte_metrics_get_values;\n+\trte_metrics_init;\n+\trte_metrics_reg_metric;\n+\trte_metrics_reg_metrics;\n+\trte_metrics_update_metric;\n+\trte_metrics_update_metrics;\n+\n+\tlocal: *;\n+};\ndiff --git a/mk/rte.app.mk b/mk/rte.app.mk\nindex f75f0e2..40fcf33 100644\n--- a/mk/rte.app.mk\n+++ b/mk/rte.app.mk\n@@ -98,6 +98,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring\n _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal\n _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline\n _LDLIBS-$(CONFIG_RTE_LIBRTE_CFGFILE)        += -lrte_cfgfile\n+_LDLIBS-$(CONFIG_RTE_LIBRTE_METRICS)        += -lrte_metrics\n+\n \n _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BOND)       += -lrte_pmd_bond\n _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT)    += -lrte_pmd_xenvirt -lxenstore\n",
    "prefixes": [
        "dpdk-dev",
        "v4",
        "1/3"
    ]
}