get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 24882,
    "url": "https://patches.dpdk.org/api/patches/24882/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1496162653-137817-3-git-send-email-cristian.dumitrescu@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": "<1496162653-137817-3-git-send-email-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1496162653-137817-3-git-send-email-cristian.dumitrescu@intel.com",
    "date": "2017-05-30T16:44:12",
    "name": "[dpdk-dev,RFC,2/3] ethdev: add new rte_mtr API for traffic metering and policing",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "dc42dac8cbe7064f91ea866f5ca458f78e888a2b",
    "submitter": {
        "id": 19,
        "url": "https://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1496162653-137817-3-git-send-email-cristian.dumitrescu@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/24882/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/24882/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 ED23E7D3B;\n\tTue, 30 May 2017 18:46:27 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id B2C3B7CAE\n\tfor <dev@dpdk.org>; Tue, 30 May 2017 18:46:19 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t30 May 2017 09:46:16 -0700",
            "from silpixa00382658.ir.intel.com ([10.237.223.29])\n\tby orsmga003.jf.intel.com with ESMTP; 30 May 2017 09:44:34 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.38,418,1491289200\"; d=\"scan'208\";a=\"974720585\"",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net, adrien.mazarguil@6wind.com,\n\tjerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com,\n\tdeclan.doherty@intel.com, keith.wiles@intel.com",
        "Date": "Tue, 30 May 2017 17:44:12 +0100",
        "Message-Id": "<1496162653-137817-3-git-send-email-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1496162653-137817-1-git-send-email-cristian.dumitrescu@intel.com>",
        "References": "<1496162653-137817-1-git-send-email-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [RFC 2/3] ethdev: add new rte_mtr API for traffic\n\tmetering and policing",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <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": "Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n MAINTAINERS                            |   4 +\n lib/librte_ether/Makefile              |   7 +-\n lib/librte_ether/rte_ether_version.map |   8 +\n lib/librte_ether/rte_mtr.c             | 184 +++++++++++++\n lib/librte_ether/rte_mtr.h             | 465 +++++++++++++++++++++++++++++++++\n lib/librte_ether/rte_mtr_driver.h      | 188 +++++++++++++\n 6 files changed, 854 insertions(+), 2 deletions(-)\n create mode 100644 lib/librte_ether/rte_mtr.c\n create mode 100644 lib/librte_ether/rte_mtr.h\n create mode 100644 lib/librte_ether/rte_mtr_driver.h",
    "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex afb4cab..b025a7b 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -240,6 +240,10 @@ Flow API\n M: Adrien Mazarguil <adrien.mazarguil@6wind.com>\n F: lib/librte_ether/rte_flow*\n \n+Traffic metering and policing API\n+M: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n+F: lib/librte_ether/rte_mtr*\n+\n Crypto API\n M: Declan Doherty <declan.doherty@intel.com>\n F: lib/librte_cryptodev/\ndiff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile\nindex 93fdde1..48f1098 100644\n--- a/lib/librte_ether/Makefile\n+++ b/lib/librte_ether/Makefile\n@@ -1,6 +1,6 @@\n #   BSD LICENSE\n #\n-#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.\n+#   Copyright(c) 2010-2017 Intel Corporation. All rights reserved.\n #   All rights reserved.\n #\n #   Redistribution and use in source and binary forms, with or without\n@@ -41,10 +41,11 @@ CFLAGS += $(WERROR_FLAGS)\n \n EXPORT_MAP := rte_ether_version.map\n \n-LIBABIVER := 6\n+LIBABIVER := 7\n \n SRCS-y += rte_ethdev.c\n SRCS-y += rte_flow.c\n+SRCS-y += rte_mtr.c\n \n #\n # Export include files\n@@ -56,5 +57,7 @@ SYMLINK-y-include += rte_eth_ctrl.h\n SYMLINK-y-include += rte_dev_info.h\n SYMLINK-y-include += rte_flow.h\n SYMLINK-y-include += rte_flow_driver.h\n+SYMLINK-y-include += rte_mtr.h\n+SYMLINK-y-include += rte_mtr_driver.h\n \n include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map\nindex 9783aa1..89ea2ed 100644\n--- a/lib/librte_ether/rte_ether_version.map\n+++ b/lib/librte_ether/rte_ether_version.map\n@@ -161,4 +161,12 @@ DPDK_17.08 {\n     global:\n \n \trte_eth_dev_mtr_ops_get;\n+\trte_mtr_meter_profile_add;\n+\trte_mtr_meter_profile_delete;\n+\trte_mtr_create;\n+\trte_mtr_destroy;\n+\trte_mtr_meter_profile_update;\n+\trte_mtr_policer_action_update;\n+\trte_mtr_stats_update;\n+\trte_mtr_stats_read;\n } DPDK_17.05;\ndiff --git a/lib/librte_ether/rte_mtr.c b/lib/librte_ether/rte_mtr.c\nnew file mode 100644\nindex 0000000..efbe7fb\n--- /dev/null\n+++ b/lib/librte_ether/rte_mtr.c\n@@ -0,0 +1,184 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 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 <stdint.h>\n+\n+#include <rte_errno.h>\n+#include \"rte_ethdev.h\"\n+#include \"rte_mtr_driver.h\"\n+#include \"rte_mtr.h\"\n+\n+/* Get generic traffic metering and policing operations structure from a port. */\n+const struct rte_mtr_ops *\n+rte_mtr_ops_get(uint8_t port_id, struct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\tconst struct rte_mtr_ops *ops;\n+\n+\tif (!rte_eth_dev_is_valid_port(port_id)) {\n+\t\trte_mtr_error_set(error,\n+\t\t\tENODEV,\n+\t\t\tRTE_MTR_ERROR_TYPE_UNSPECIFIED,\n+\t\t\tNULL,\n+\t\t\trte_strerror(ENODEV));\n+\t\treturn NULL;\n+\t}\n+\n+\tif ((dev->dev_ops->mtr_ops_get == NULL) ||\n+\t\t(dev->dev_ops->mtr_ops_get(dev, &ops) != 0) ||\n+\t\t(ops == NULL)) {\n+\t\trte_mtr_error_set(error,\n+\t\t\tENOSYS,\n+\t\t\tRTE_MTR_ERROR_TYPE_UNSPECIFIED,\n+\t\t\tNULL,\n+\t\t\trte_strerror(ENOSYS));\n+\t\treturn NULL;\n+\t}\n+\n+\treturn ops;\n+}\n+\n+#define RTE_MTR_FUNC(port_id, func)\t\t\t\\\n+({\t\t\t\t\t\t\t\\\n+\tconst struct rte_mtr_ops *ops =\t\t\t\\\n+\t\trte_mtr_ops_get(port_id, error);\t\t\\\n+\tif (ops == NULL)\t\t\t\t\t\\\n+\t\treturn -rte_errno;\t\t\t\\\n+\t\t\t\t\t\t\t\\\n+\tif (ops->func == NULL)\t\t\t\t\\\n+\t\treturn -rte_mtr_error_set(error,\t\t\\\n+\t\t\tENOSYS,\t\t\t\t\\\n+\t\t\tRTE_MTR_ERROR_TYPE_UNSPECIFIED,\t\\\n+\t\t\tNULL,\t\t\t\t\\\n+\t\t\trte_strerror(ENOSYS));\t\t\\\n+\t\t\t\t\t\t\t\\\n+\tops->func;\t\t\t\t\t\\\n+})\n+\n+/* MTR meter profile add */\n+int\n+rte_mtr_meter_profile_add(uint8_t port_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_meter_profile *profile,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, meter_profile_add)(dev,\n+\t\tmeter_profile_id, profile, error);\n+}\n+\n+/** MTR meter profile delete */\n+int\n+rte_mtr_meter_profile_delete(uint8_t port_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, meter_profile_delete)(dev,\n+\t\tmeter_profile_id, error);\n+}\n+\n+/** MTR object create */\n+int\n+rte_mtr_create(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_params *params,\n+\tint shared,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, create)(dev,\n+\t\tmtr_id, params, shared, error);\n+}\n+\n+/** MTR object destroy */\n+int\n+rte_mtr_destroy(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, destroy)(dev,\n+\t\tmtr_id, error);\n+}\n+\n+/** MTR object meter profile update */\n+int\n+rte_mtr_meter_profile_update(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, meter_profile_update)(dev,\n+\t\tmtr_id, meter_profile_id, error);\n+}\n+\n+/** MTR object policer action update */\n+int\n+rte_mtr_policer_action_update(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tenum rte_mtr_color color,\n+\tenum rte_mtr_policer_action action,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, policer_action_update)(dev,\n+\t\tmtr_id, color, action, error);\n+}\n+\n+/** MTR object enabled stats update */\n+int\n+rte_mtr_stats_update(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tuint64_t stats_mask,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, stats_update)(dev,\n+\t\tmtr_id, stats_mask, error);\n+}\n+\n+/** MTR object stats read */\n+int\n+rte_mtr_stats_read(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_stats *stats,\n+\tuint64_t *stats_mask,\n+\tint clear,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\treturn RTE_MTR_FUNC(port_id, stats_read)(dev,\n+\t\tmtr_id, stats, stats_mask, clear, error);\n+}\ndiff --git a/lib/librte_ether/rte_mtr.h b/lib/librte_ether/rte_mtr.h\nnew file mode 100644\nindex 0000000..63179d1\n--- /dev/null\n+++ b/lib/librte_ether/rte_mtr.h\n@@ -0,0 +1,465 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 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+#ifndef __INCLUDE_RTE_MTR_H__\n+#define __INCLUDE_RTE_MTR_H__\n+\n+/**\n+ * @file\n+ * RTE Generic Traffic Metering and Policing API\n+ *\n+ * This interface provides the ability to configure the traffic metering and\n+ * policing (MTR) in a generic way.\n+ *\n+ * The processing done for each input packet hitting a MTR object is:\n+ *    A) Traffic metering: The packet is assigned a color (the meter output\n+ *       color), based on the previous history of the flow reflected in the\n+ *       current state of the MTR object, according to the specific traffic\n+ *       metering algorithm. The traffic metering algorithm can typically work\n+ *       in color aware mode, in which case the input packet already has an\n+ *       initial color (the input color), or in color blind mode, which is\n+ *       equivalent to considering all input packets initially colored as green.\n+ *    B) Policing: There is a separate policer action configured for each meter\n+ *       output color, which can:\n+ *          a) Drop the packet.\n+ *          b) Keep the same packet color: the policer output color matches the\n+ *             meter output color (essentially a no-op action).\n+ *          c) Recolor the packet: the policer output color is different than\n+ *             the meter output color.\n+ *       The policer output color is the output color of the packet, which is\n+ *       set in the packet meta-data (i.e. struct rte_mbuf::sched::color).\n+ *    C) Statistics: The set of counters maintained for each MTR object is\n+ *       configurable and subject to the implementation support. This set\n+ *       includes the number of packets and bytes dropped or passed for each\n+ *       output color.\n+ *\n+ * Once successfully created, an MTR object is linked to one or several flows\n+ * through the meter action of the flow API.\n+ *    A) Whether an MTR object is private to a flow or potentially shared by\n+ *       several flows has to be specified at creation time.\n+ *    B) Several meter actions can be potentially registered for the same flow.\n+ */\n+#include <stdint.h>\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * Color\n+ */\n+enum rte_mtr_color {\n+\tRTE_MTR_GREEN = 0, /**< Green */\n+\tRTE_MTR_YELLOW, /**< Yellow */\n+\tRTE_MTR_RED, /**< Red */\n+\tRTE_MTR_COLORS /**< Number of colors */\n+};\n+\n+/**\n+ * Statistics counter type\n+ */\n+enum rte_mtr_stats_type {\n+\t/**< Number of packets passed as green by the policer.  */\n+\tRTE_MTR_STATS_N_PKTS_GREEN = 1 << 0,\n+\n+\t/**< Number of bytes passed as green by the policer.  */\n+\tRTE_MTR_STATS_N_BYTES_GREEN = 1 << 1,\n+\n+\t/**< Number of packets passed as yellow by the policer.  */\n+\tRTE_MTR_STATS_N_PKTS_YELLOW = 1 << 2,\n+\n+\t/**< Number of bytes passed as yellow by the policer.  */\n+\tRTE_MTR_STATS_N_BYTES_YELLOW = 1 << 3,\n+\n+\t/**< Number of packets passed as red by the policer.  */\n+\tRTE_MTR_STATS_N_PKTS_RED = 1 << 4,\n+\n+\t/**< Number of bytes passed as red by the policer.  */\n+\tRTE_MTR_STATS_N_BYTES_RED = 1 << 5,\n+\n+\t/**< Number of packets dropped by the policer.  */\n+\tRTE_MTR_STATS_N_PKTS_DROPPED = 1 << 6,\n+\n+\t/**< Number of bytes dropped by the policer.  */\n+\tRTE_MTR_STATS_N_BYTES_DROPPED = 1 << 7,\n+};\n+\n+/**\n+ * Statistics counters\n+ */\n+struct rte_mtr_stats {\n+\t/**< Number of packets passed by the policer (per color). */\n+\tuint64_t n_pkts[RTE_MTR_COLORS];\n+\n+\t/**< Number of bytes passed by the policer (per color). */\n+\tuint64_t n_bytes[RTE_MTR_COLORS];\n+\n+\t/**< Number of packets dropped by the policer. */\n+\tuint64_t n_pkts_dropped;\n+\n+\t/**< Number of bytes passed by the policer. */\n+\tuint64_t n_bytes_dropped;\n+};\n+\n+/**\n+ * Traffic metering algorithms\n+ */\n+enum rte_mtr_algorithm {\n+\t/**< Single Rate Three Color Marker (srTCM) - IETF RFC 2697. */\n+\tRTE_MTR_SRTCM_RFC2697 = 0,\n+\n+\t/**< Two Rate Three Color Marker (trTCM) - IETF RFC 2698. */\n+\tRTE_MTR_TRTCM_RFC2698,\n+};\n+\n+/**\n+ * Meter profile\n+ */\n+struct rte_mtr_meter_profile {\n+\t/**<  Traffic metering algorithm. */\n+\tenum rte_mtr_algorithm alg;\n+\n+\tunion {\n+\t\t/**< Items only valid when *alg* is set to srTCM - RFC2697. */\n+\t\tstruct {\n+\t\t\t/**< Committed Information Rate (CIR) (bytes/second). */\n+\t\t\tuint64_t cir;\n+\n+\t\t\t/**< Committed Burst Size (CBS) (bytes). */\n+\t\t\tuint64_t cbs;\n+\n+\t\t\t/**< Excess Burst Size (EBS) (bytes). */\n+\t\t\tuint64_t ebs;\n+\n+\t\t\t/**< Non-zero for color aware mode, zero for color blind\n+\t\t\t * mode. In color aware mode, the packet input color is\n+\t\t\t * read from the IPv4/IPv6 DSCP field, as defined by\n+\t\t\t * IETF RFC 2597 (low/medium/high drop precedence\n+\t\t\t * translates to green/yellow/red color respectively).\n+\t\t\t */\n+\t\t\tint color_aware;\n+\t\t} srtcm_rfc2697;\n+\n+\t\t/**< Items only valid when *alg* is set to trTCM - RFC2698. */\n+\t\tstruct {\n+\t\t\t/**< Committed Information Rate (CIR) (bytes/second). */\n+\t\t\tuint64_t cir;\n+\n+\t\t\t/**< Peak Information Rate (PIR) (bytes/second). */\n+\t\t\tuint64_t pir;\n+\n+\t\t\t/**< Committed Burst Size (CBS) (byes). */\n+\t\t\tuint64_t cbs;\n+\n+\t\t\t/**< Peak Burst Size (PBS) (bytes). */\n+\t\t\tuint64_t pbs;\n+\n+\t\t\t/**< Non-zero for color aware mode, zero for color blind\n+\t\t\t * mode. In color aware mode, the packet input color is\n+\t\t\t * read from the IPv4/IPv6 DSCP field, as defined by\n+\t\t\t * IETF RFC 2597 (low/medium/high drop precedence\n+\t\t\t * translates to green/yellow/red color respectively).\n+\t\t\t */\n+\t\t\tint color_aware;\n+\t\t} trtcm_rfc2698;\n+\t};\n+};\n+\n+/**\n+ * Policer actions\n+ */\n+enum rte_mtr_policer_action {\n+\t/**< Recolor the packet as green. */\n+\te_MTR_POLICER_ACTION_COLOR_GREEN = 0,\n+\n+\t/**< Recolor the packet as yellow. */\n+\te_MTR_POLICER_ACTION_COLOR_YELLOW,\n+\n+\t/**< Recolor the packet as red. */\n+\te_MTR_POLICER_ACTION_COLOR_RED,\n+\n+\t/**< Drop the packet. */\n+\te_MTR_POLICER_ACTION_DROP,\n+};\n+\n+/**\n+ * Parameters for each traffic metering & policing object\n+ *\n+ * @see enum rte_mtr_stats_type\n+ */\n+struct rte_mtr_params {\n+\t/**< Meter profile ID. */\n+\tuint32_t meter_profile_id;\n+\n+\t/**< Policer actions (per meter output color). */\n+\tenum rte_mtr_policer_action action[RTE_MTR_COLORS];\n+\n+\t/**< Set of stats counters to be enabled. */\n+\tuint64_t stats_mask;\n+};\n+\n+/**\n+ * Verbose error types.\n+ *\n+ * Most of them provide the type of the object referenced by struct\n+ * rte_mtr_error::cause.\n+ */\n+enum rte_mtr_error_type {\n+\tRTE_MTR_ERROR_TYPE_NONE, /**< No error. */\n+\tRTE_MTR_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */\n+\tRTE_MTR_ERROR_TYPE_METER_PROFILE_ID,\n+\tRTE_MTR_ERROR_TYPE_METER_PROFILE,\n+\tRTE_MTR_ERROR_TYPE_MTR_ID,\n+\tRTE_MTR_ERROR_TYPE_MTR_PARAMS,\n+\tRTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,\n+\tRTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,\n+\tRTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,\n+\tRTE_MTR_ERROR_TYPE_STATS_MASK,\n+\tRTE_MTR_ERROR_TYPE_STATS,\n+\tRTE_MTR_ERROR_TYPE_SHARED,\n+};\n+\n+/**\n+ * Verbose error structure definition.\n+ *\n+ * This object is normally allocated by applications and set by PMDs, the\n+ * message points to a constant string which does not need to be freed by\n+ * the application, however its pointer can be considered valid only as long\n+ * as its associated DPDK port remains configured. Closing the underlying\n+ * device or unloading the PMD invalidates it.\n+ *\n+ * Both cause and message may be NULL regardless of the error type.\n+ */\n+struct rte_mtr_error {\n+\tenum rte_mtr_error_type type; /**< Cause field and error type. */\n+\tconst void *cause; /**< Object responsible for the error. */\n+\tconst char *message; /**< Human-readable error message. */\n+};\n+\n+/**\n+ * Meter profile add\n+ *\n+ * Create a new meter profile with ID set to *meter_profile_id*. The new profile\n+ * is used to create one or several MTR objects.\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] meter_profile_id\n+ *   ID for the new meter profile. Needs to be unused by any of the existing\n+ *   meter profiles added for the current port.\n+ * @param[in] profile\n+ *   Meter profile parameters. Needs to be pre-allocated and valid.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ */\n+int\n+rte_mtr_meter_profile_add(uint8_t port_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_meter_profile *profile,\n+\tstruct rte_mtr_error *error);\n+\n+/**\n+ * Meter profile delete\n+ *\n+ * Delete an existing meter profile. This operation fails when there is\n+ * currently at least one user (i.e. MTR object) of this profile.\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] meter_profile_id\n+ *   Meter profile ID. Needs to be the valid.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ */\n+int\n+rte_mtr_meter_profile_delete(uint8_t port_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_error *error);\n+\n+/**\n+ * MTR object create\n+ *\n+ * Create a new MTR object for the current port.\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] mtr_id\n+ *   MTR object ID. Needs to be unused by any of the existing MTR objects\n+ *   created for the current port.\n+ * @param[in] params\n+ *   MTR object params. Needs to be pre-allocated and valid.\n+ * @param[in] shared\n+ *   Non-zero when this MTR object can be shared by multiple flows, zero when\n+ *   this MTR object can be used by a single flow.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ */\n+int\n+rte_mtr_create(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_params *params,\n+\tint shared,\n+\tstruct rte_mtr_error *error);\n+\n+/**\n+ * MTR object destroy\n+ *\n+ * Delete an existing MTR object. This operation fails when there is currently\n+ * at least one user (i.e. flow) of this MTR object.\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] mtr_id\n+ *   MTR object ID. Needs to be unused by any of the existing MTR objects\n+ *   created for the current port.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ */\n+int\n+rte_mtr_destroy(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_error *error);\n+\n+/**\n+ * MTR object meter profile update\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] mtr_id\n+ *   MTR object ID. Needs to be valid.\n+ * @param[in] meter_profile_id\n+ *   Meter profile ID for the current MTR object. Needs to be valid.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ */\n+int\n+rte_mtr_meter_profile_update(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_error *error);\n+\n+/**\n+ * MTR object policer action update for given color\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] mtr_id\n+ *   MTR object ID. Needs to be valid.\n+ * @param[in] color\n+ *   Color for which the policer action is updated.\n+ * @param[in] action\n+ *   Policer action for specified color.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ */\n+int\n+rte_mtr_policer_action_update(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tenum rte_mtr_color color,\n+\tenum rte_mtr_policer_action action,\n+\tstruct rte_mtr_error *error);\n+\n+/**\n+ * MTR object enabled statistics counters update\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] mtr_id\n+ *   MTR object ID. Needs to be valid.\n+ * @param[in] stats_mask\n+ *   Mask of statistics counter types to be enabled for the current MTR object.\n+ *   Any statistics counter type not included in this set is to be disabled for\n+ *   the current MTR object.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ *\n+ * @see enum rte_mtr_stats_type\n+ */\n+int\n+rte_mtr_stats_update(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tuint64_t stats_mask,\n+\tstruct rte_mtr_error *error);\n+\n+/**\n+ * MTR object statistics counters read\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[in] mtr_id\n+ *   MTR object ID. Needs to be valid.\n+ * @param[out] stats\n+ *   When non-NULL, it contains the current value for the statistics counters\n+ *   enabled for the current MTR object.\n+ * @param[out] stats_mask\n+ *   When non-NULL, it contains the mask of statistics counter types that are\n+ *   currently enabled for this MTR object, indicating which of the counters\n+ *   retrieved with the *stats* structure are valid.\n+ * @param[in] clear\n+ *   When this parameter has a non-zero value, the statistics counters are\n+ *   cleared (i.e. set to zero) immediately after they have been read,\n+ *   otherwise the statistics counters are left untouched.\n+ * @param[out] error\n+ *   Error details. Filled in only on error, when not NULL.\n+ * @return\n+ *   0 on success, non-zero error code otherwise.\n+ *\n+ * @see enum rte_mtr_stats_type\n+ */\n+int\n+rte_mtr_stats_read(uint8_t port_id,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_stats *stats,\n+\tuint64_t *stats_mask,\n+\tint clear,\n+\tstruct rte_mtr_error *error);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* __INCLUDE_RTE_MTR_H__ */\ndiff --git a/lib/librte_ether/rte_mtr_driver.h b/lib/librte_ether/rte_mtr_driver.h\nnew file mode 100644\nindex 0000000..3798cf6\n--- /dev/null\n+++ b/lib/librte_ether/rte_mtr_driver.h\n@@ -0,0 +1,188 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 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+#ifndef __INCLUDE_RTE_MTR_DRIVER_H__\n+#define __INCLUDE_RTE_MTR_DRIVER_H__\n+\n+/**\n+ * @file\n+ * RTE Generic Traffic Metering and Policing API (Driver Side)\n+ *\n+ * This file provides implementation helpers for internal use by PMDs, they\n+ * are not intended to be exposed to applications and are not subject to ABI\n+ * versioning.\n+ */\n+\n+#include <stdint.h>\n+\n+#include <rte_errno.h>\n+#include \"rte_ethdev.h\"\n+#include \"rte_mtr.h\"\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+typedef int (*rte_mtr_meter_profile_add_t)(struct rte_eth_dev *dev,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_meter_profile *profile,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR meter profile add */\n+\n+typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR meter profile delete */\n+\n+typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_params *params,\n+\tint shared,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR object create */\n+\n+typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR object destroy */\n+\n+typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,\n+\tuint32_t mtr_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR object meter profile update */\n+\n+typedef int (*rte_mtr_policer_action_update_t)(struct rte_eth_dev *dev,\n+\tuint32_t mtr_id,\n+\tenum rte_mtr_color color,\n+\tenum rte_mtr_policer_action action,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR object policer action update*/\n+\n+typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,\n+\tuint32_t mtr_id,\n+\tuint64_t stats_mask,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR object enabled stats update */\n+\n+typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,\n+\tuint32_t mtr_id,\n+\tstruct rte_mtr_stats *stats,\n+\tuint64_t *stats_mask,\n+\tint clear,\n+\tstruct rte_mtr_error *error);\n+/**< @internal MTR object stats read */\n+\n+struct rte_mtr_ops {\n+\t/** MTR meter profile add */\n+\trte_mtr_meter_profile_add_t meter_profile_add;\n+\n+\t/** MTR meter profile delete */\n+\trte_mtr_meter_profile_delete_t meter_profile_delete;\n+\n+\t/** MTR object create */\n+\trte_mtr_create_t create;\n+\n+\t/** MTR object destroy */\n+\trte_mtr_destroy_t destroy;\n+\n+\t/** MTR object meter profile update */\n+\trte_mtr_meter_profile_update_t meter_profile_update;\n+\n+\t/** MTR object policer action update */\n+\trte_mtr_policer_action_update_t policer_action_update;\n+\n+\t/** MTR object enabled stats update */\n+\trte_mtr_stats_update_t stats_update;\n+\n+\t/** MTR object stats read */\n+\trte_mtr_stats_read_t stats_read;\n+};\n+\n+/**\n+ * Initialize generic error structure.\n+ *\n+ * This function also sets rte_errno to a given value.\n+ *\n+ * @param[out] error\n+ *   Pointer to error structure (may be NULL).\n+ * @param[in] code\n+ *   Related error code (rte_errno).\n+ * @param[in] type\n+ *   Cause field and error type.\n+ * @param[in] cause\n+ *   Object responsible for the error.\n+ * @param[in] message\n+ *   Human-readable error message.\n+ *\n+ * @return\n+ *   Error code.\n+ */\n+static inline int\n+rte_mtr_error_set(struct rte_mtr_error *error,\n+\t\t   int code,\n+\t\t   enum rte_mtr_error_type type,\n+\t\t   const void *cause,\n+\t\t   const char *message)\n+{\n+\tif (error) {\n+\t\t*error = (struct rte_mtr_error){\n+\t\t\t.type = type,\n+\t\t\t.cause = cause,\n+\t\t\t.message = message,\n+\t\t};\n+\t}\n+\trte_errno = code;\n+\treturn code;\n+}\n+\n+/**\n+ * Get generic traffic metering and policing operations structure from a port\n+ *\n+ * @param[in] port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param[out] error\n+ *   Error details\n+ *\n+ * @return\n+ *   The traffic metering and policing operations structure associated with\n+ *   port_id on success, NULL otherwise.\n+ */\n+const struct rte_mtr_ops *\n+rte_mtr_ops_get(uint8_t port_id, struct rte_mtr_error *error);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */\n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "2/3"
    ]
}