Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/17015/?format=api
https://patches.dpdk.org/api/patches/17015/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1479194120-6917-3-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-3-git-send-email-remy.horton@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1479194120-6917-3-git-send-email-remy.horton@intel.com", "date": "2016-11-15T07:15:19", "name": "[dpdk-dev,v4,2/3] lib: add bitrate statistics library", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "923743e3e946c567a43259b4ba79948be6665948", "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-3-git-send-email-remy.horton@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/17015/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/17015/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 CABAD388F;\n\tTue, 15 Nov 2016 08:15:51 +0100 (CET)", "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 51479376D\n\tfor <dev@dpdk.org>; Tue, 15 Nov 2016 08:15:25 +0100 (CET)", "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga104.jf.intel.com with ESMTP; 14 Nov 2016 23:15:24 -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:23 -0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.31,641,1473145200\"; d=\"scan'208\";a=\"901497636\"", "From": "Remy Horton <remy.horton@intel.com>", "To": "dev@dpdk.org", "Cc": "thomas.monjalon@6wind.com", "Date": "Tue, 15 Nov 2016 15:15:19 +0800", "Message-Id": "<1479194120-6917-3-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 2/3] lib: add bitrate statistics 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 library that calculates peak and average data-rate\nstatistics. For ethernet devices. These statistics are reported using\nthe metrics library.\n\nSigned-off-by: Remy Horton <remy.horton@intel.com>\n---\n MAINTAINERS | 4 +\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 | 5 +\n lib/Makefile | 1 +\n lib/librte_bitratestats/Makefile | 53 +++++++++\n lib/librte_bitratestats/rte_bitrate.c | 128 +++++++++++++++++++++\n lib/librte_bitratestats/rte_bitrate.h | 80 +++++++++++++\n .../rte_bitratestats_version.map | 9 ++\n mk/rte.app.mk | 1 +\n 11 files changed, 288 insertions(+)\n create mode 100644 lib/librte_bitratestats/Makefile\n create mode 100644 lib/librte_bitratestats/rte_bitrate.c\n create mode 100644 lib/librte_bitratestats/rte_bitrate.h\n create mode 100644 lib/librte_bitratestats/rte_bitratestats_version.map", "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex 52bd8a9..d6bbdd5 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -600,6 +600,10 @@ M: Remy Horton <remy.horton@intel.com>\n F: lib/librte_metrics/\n F: doc/guides/sample_app_ug/keep_alive.rst\n \n+Bit-rate statistica\n+M: Remy Horton <remy.horton@intel.com>\n+F: lib/librte_bitratestats/\n+\n \n Test Applications\n -----------------\ndiff --git a/config/common_base b/config/common_base\nindex dedc4c3..beca7ec 100644\n--- a/config/common_base\n+++ b/config/common_base\n@@ -594,3 +594,8 @@ CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n\n # Compile the device metrics library\n #\n CONFIG_RTE_LIBRTE_METRICS=y\n+\n+#\n+# Compile the bitrate statistics library\n+#\n+CONFIG_RTE_LIBRTE_BITRATE=y\ndiff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md\nindex ca50fa6..91e8ea6 100644\n--- a/doc/api/doxy-api-index.md\n+++ b/doc/api/doxy-api-index.md\n@@ -148,4 +148,5 @@ There are many libraries, so their headers may be grouped by topics:\n [ABI compat] (@ref rte_compat.h),\n [keepalive] (@ref rte_keepalive.h),\n [Device Metrics] (@ref rte_metrics.h),\n+ [Bitrate Statistics] (@ref rte_bitrate.h),\n [version] (@ref rte_version.h)\ndiff --git a/doc/api/doxy-api.conf b/doc/api/doxy-api.conf\nindex fe830eb..8765ddd 100644\n--- a/doc/api/doxy-api.conf\n+++ b/doc/api/doxy-api.conf\n@@ -58,6 +58,7 @@ INPUT = doc/api/doxy-api-index.md \\\n lib/librte_ring \\\n lib/librte_sched \\\n lib/librte_metrics \\\n+ lib/librte_bitratestats \\\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 e1b8894..f949e88 100644\n--- a/doc/guides/rel_notes/release_17_02.rst\n+++ b/doc/guides/rel_notes/release_17_02.rst\n@@ -40,6 +40,11 @@ New Features\n intended to provide a reporting mechanism that is independent of the\n ethdev library.\n \n+ * **Added bit-rate calculation library.**\n+\n+ A library that can be used to calculate device bit-rates. Calculated\n+ bitrates are reported using the metrics 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 5d85dcf..e211bc0 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -59,6 +59,7 @@ 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+DIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += librte_bitratestats\n \n ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)\n DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni\ndiff --git a/lib/librte_bitratestats/Makefile b/lib/librte_bitratestats/Makefile\nnew file mode 100644\nindex 0000000..b725d4e\n--- /dev/null\n+++ b/lib/librte_bitratestats/Makefile\n@@ -0,0 +1,53 @@\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_bitratestats.a\n+\n+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)\n+\n+EXPORT_MAP := rte_bitratestats_version.map\n+\n+LIBABIVER := 1\n+\n+# all source are stored in SRCS-y\n+SRCS-$(CONFIG_RTE_LIBRTE_BITRATE) := rte_bitrate.c\n+\n+# Install header file\n+SYMLINK-$(CONFIG_RTE_LIBRTE_BITRATE)-include += rte_bitrate.h\n+\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += lib/librte_eal\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += lib/librte_ether\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += lib/librte_metrics\n+\n+include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c\nnew file mode 100644\nindex 0000000..6346bb1\n--- /dev/null\n+++ b/lib/librte_bitratestats/rte_bitrate.c\n@@ -0,0 +1,128 @@\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 <rte_common.h>\n+#include <rte_ethdev.h>\n+#include <rte_malloc.h>\n+#include <rte_metrics.h>\n+#include <rte_bitrate.h>\n+\n+/*\n+ * Persistent bit-rate data.\n+ * @internal\n+ */\n+struct rte_stats_bitrate_s {\n+\tuint64_t last_ibytes;\n+\tuint64_t last_obytes;\n+\tuint64_t peak_ibits;\n+\tuint64_t peak_obits;\n+\tuint64_t ewma_ibits;\n+\tuint64_t ewma_obits;\n+};\n+\n+struct rte_stats_bitrates_s {\n+\tstruct rte_stats_bitrate_s port_stats[RTE_MAX_ETHPORTS];\n+\tuint16_t id_stats_set;\n+};\n+\n+struct rte_stats_bitrates_s *\n+rte_stats_bitrate_create(void)\n+{\n+\treturn rte_zmalloc(NULL, sizeof(struct rte_stats_bitrates_s), 0);\n+}\n+\n+int\n+rte_stats_bitrate_reg(struct rte_stats_bitrates_s *bitrate_data)\n+{\n+\tconst char *names[] = {\n+\t\t\"mean_bits_in\", \"mean_bits_out\",\n+\t\t\"peak_bits_in\", \"peak_bits_out\",\n+\t};\n+\tint return_value;\n+\n+\treturn_value = rte_metrics_reg_metrics(&names[0], 4);\n+\tif (return_value >= 0)\n+\t\tbitrate_data->id_stats_set = return_value;\n+\treturn return_value;\n+}\n+\n+int\n+rte_stats_bitrate_calc(struct rte_stats_bitrates_s *bitrate_data,\n+\tuint8_t port_id)\n+{\n+\tstruct rte_stats_bitrate_s *port_data;\n+\tstruct rte_eth_stats eth_stats;\n+\tint ret_code;\n+\tuint64_t cnt_bits;\n+\tint64_t delta;\n+\tconst int64_t alpha_percent = 20;\n+\tuint64_t values[4];\n+\n+\tret_code = rte_eth_stats_get(port_id, ð_stats);\n+\tif (ret_code != 0)\n+\t\treturn ret_code;\n+\n+\tport_data = &bitrate_data->port_stats[port_id];\n+\n+\t/* Incoming bitrate. This is an iteratively calculated EWMA\n+\t * (Expomentially Weighted Moving Average) that uses a\n+\t * weighting factor of alpha_percent.\n+\t */\n+\tcnt_bits = (eth_stats.ibytes - port_data->last_ibytes) << 3;\n+\tport_data->last_ibytes = eth_stats.ibytes;\n+\tif (cnt_bits > port_data->peak_ibits)\n+\t\tport_data->peak_ibits = cnt_bits;\n+\tdelta = cnt_bits;\n+\tdelta -= port_data->ewma_ibits;\n+\t/* The +50 fixes integer rounding during divison */\n+\tdelta = (delta * alpha_percent + 50) / 100;\n+\tport_data->ewma_ibits += delta;\n+\n+\t/* Outgoing bitrate (also EWMA) */\n+\tcnt_bits = (eth_stats.obytes - port_data->last_obytes) << 3;\n+\tport_data->last_obytes = eth_stats.obytes;\n+\tif (cnt_bits > port_data->peak_obits)\n+\t\tport_data->peak_obits = cnt_bits;\n+\tdelta = cnt_bits;\n+\tdelta -= port_data->ewma_obits;\n+\tdelta = (delta * alpha_percent + 50) / 100;\n+\tport_data->ewma_obits += delta;\n+\n+\tvalues[0] = port_data->ewma_ibits;\n+\tvalues[1] = port_data->ewma_obits;\n+\tvalues[2] = port_data->peak_ibits;\n+\tvalues[3] = port_data->peak_obits;\n+\trte_metrics_update_metrics(port_id, bitrate_data->id_stats_set,\n+\t\tvalues, 4);\n+\treturn 0;\n+}\ndiff --git a/lib/librte_bitratestats/rte_bitrate.h b/lib/librte_bitratestats/rte_bitrate.h\nnew file mode 100644\nindex 0000000..bc87c5e\n--- /dev/null\n+++ b/lib/librte_bitratestats/rte_bitrate.h\n@@ -0,0 +1,80 @@\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+/**\n+ * Bitrate statistics data structure.\n+ * This data structure is intentionally opaque.\n+ */\n+struct rte_stats_bitrates_s;\n+\n+\n+/**\n+ * Allocate a bitrate statistics structure\n+ *\n+ * @return\n+ * - Pointer to structure on success\n+ * - NULL on error (zmalloc failure)\n+ */\n+struct rte_stats_bitrates_s *rte_stats_bitrate_create(void);\n+\n+\n+/**\n+ * Register bitrate statistics with the metric library.\n+ *\n+ * @param bitrate_data\n+ * Pointer allocated by rte_stats_create()\n+ *\n+ * @return\n+ * Zero on success\n+ * Negative on error\n+ */\n+int rte_stats_bitrate_reg(struct rte_stats_bitrates_s *bitrate_data);\n+\n+\n+/**\n+ * Calculate statistics for current time window. The period with which\n+ * this function is called should be the intended sampling window width.\n+ *\n+ * @param bitrate_data\n+ * Bitrate statistics data pointer\n+ *\n+ * @param port_id\n+ * Port id to calculate statistics for\n+ *\n+ * @return\n+ * - Zero on success\n+ * - Negative value on error\n+ */\n+int rte_stats_bitrate_calc(struct rte_stats_bitrates_s *bitrate_data,\n+\tuint8_t port_id);\ndiff --git a/lib/librte_bitratestats/rte_bitratestats_version.map b/lib/librte_bitratestats/rte_bitratestats_version.map\nnew file mode 100644\nindex 0000000..66f232f\n--- /dev/null\n+++ b/lib/librte_bitratestats/rte_bitratestats_version.map\n@@ -0,0 +1,9 @@\n+DPDK_17.02 {\n+\tglobal:\n+\n+\trte_stats_bitrate_calc;\n+\trte_stats_bitrate_create;\n+\trte_stats_bitrate_reg;\n+\n+\tlocal: *;\n+};\ndiff --git a/mk/rte.app.mk b/mk/rte.app.mk\nindex 40fcf33..6aac5ac 100644\n--- a/mk/rte.app.mk\n+++ b/mk/rte.app.mk\n@@ -99,6 +99,7 @@ _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+_LDLIBS-$(CONFIG_RTE_LIBRTE_BITRATE) += -lrte_bitratestats\n \n \n _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += -lrte_pmd_bond\n", "prefixes": [ "dpdk-dev", "v4", "2/3" ] }{ "id": 17015, "url": "