get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 49085,
    "url": "https://patches.dpdk.org/api/patches/49085/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20181218153842.10961.32000.stgit@iMac/",
    "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": "<20181218153842.10961.32000.stgit@iMac>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181218153842.10961.32000.stgit@iMac",
    "date": "2018-12-18T15:38:42",
    "name": "[v3,1/2] lib/librte_meter: add RFC4115 trTCM meter support",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "fe440827b180c10b9dac3996edb3593a7c6d04ec",
    "submitter": {
        "id": 672,
        "url": "https://patches.dpdk.org/api/people/672/?format=api",
        "name": "Eelco Chaudron",
        "email": "echaudro@redhat.com"
    },
    "delegate": {
        "id": 10018,
        "url": "https://patches.dpdk.org/api/users/10018/?format=api",
        "username": "cristian_dumitrescu",
        "first_name": "Cristian",
        "last_name": "Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20181218153842.10961.32000.stgit@iMac/mbox/",
    "series": [
        {
            "id": 2852,
            "url": "https://patches.dpdk.org/api/series/2852/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=2852",
            "date": "2018-12-18T15:38:34",
            "name": "lib/librte_meter: add RFC4115 trTCM meter support",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/2852/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/49085/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/49085/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id A106E1BB6F;\n\tTue, 18 Dec 2018 16:38:47 +0100 (CET)",
            "from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby dpdk.org (Postfix) with ESMTP id 49FD71BB42\n\tfor <dev@dpdk.org>; Tue, 18 Dec 2018 16:38:46 +0100 (CET)",
            "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 969F2637E5;\n\tTue, 18 Dec 2018 15:38:45 +0000 (UTC)",
            "from localhost.localdomain (ovpn-116-185.ams2.redhat.com\n\t[10.36.116.185])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 9C2345DD89;\n\tTue, 18 Dec 2018 15:38:44 +0000 (UTC)"
        ],
        "From": "Eelco Chaudron <echaudro@redhat.com>",
        "To": "cristian.dumitrescu@intel.com",
        "Cc": "dev@dpdk.org",
        "Date": "Tue, 18 Dec 2018 16:38:42 +0100",
        "Message-Id": "<20181218153842.10961.32000.stgit@iMac>",
        "In-Reply-To": "<20181218153551.10961.2569.stgit@iMac>",
        "References": "<20181218153551.10961.2569.stgit@iMac>",
        "User-Agent": "StGit/unknown-version",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "8bit",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.14",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.28]); Tue, 18 Dec 2018 15:38:45 +0000 (UTC)",
        "Subject": "[dpdk-dev] [PATCH v3 1/2] lib/librte_meter: add RFC4115 trTCM meter\n\tsupport",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/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 support for RFC4115 trTCM meters.\n\nSigned-off-by: Eelco Chaudron <echaudro@redhat.com>\n---\n lib/librte_meter/rte_meter.c           |   42 ++++++\n lib/librte_meter/rte_meter.h           |  235 ++++++++++++++++++++++++++++++++\n lib/librte_meter/rte_meter_version.map |    9 +\n 3 files changed, 284 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/lib/librte_meter/rte_meter.c b/lib/librte_meter/rte_meter.c\nindex 473f69aba..e55f9be65 100644\n--- a/lib/librte_meter/rte_meter.c\n+++ b/lib/librte_meter/rte_meter.c\n@@ -110,3 +110,45 @@ rte_meter_trtcm_config(struct rte_meter_trtcm *m,\n \n \treturn 0;\n }\n+\n+int __rte_experimental\n+rte_meter_trtcm_rfc4115_profile_config(\n+\tstruct rte_meter_trtcm_rfc4115_profile *p,\n+\tstruct rte_meter_trtcm_rfc4115_params *params)\n+{\n+\tuint64_t hz = rte_get_tsc_hz();\n+\n+\t/* Check input parameters */\n+\tif ((p == NULL) ||\n+\t\t(params == NULL) ||\n+\t\t(params->cir != 0 && params->cbs == 0) ||\n+\t\t(params->eir != 0 && params->ebs == 0))\n+\t\treturn -EINVAL;\n+\n+\t/* Initialize trTCM run-time structure */\n+\tp->cbs = params->cbs;\n+\tp->ebs = params->ebs;\n+\trte_meter_get_tb_params(hz, params->cir, &p->cir_period,\n+\t\t&p->cir_bytes_per_period);\n+\trte_meter_get_tb_params(hz, params->eir, &p->eir_period,\n+\t\t&p->eir_bytes_per_period);\n+\n+\treturn 0;\n+}\n+\n+int __rte_experimental\n+rte_meter_trtcm_rfc4115_config(\n+\tstruct rte_meter_trtcm_rfc4115 *m,\n+\tstruct rte_meter_trtcm_rfc4115_profile *p)\n+{\n+\t/* Check input parameters */\n+\tif ((m == NULL) || (p == NULL))\n+\t\treturn -EINVAL;\n+\n+\t/* Initialize trTCM run-time structure */\n+\tm->time_tc = m->time_te = rte_get_tsc_cycles();\n+\tm->tc = p->cbs;\n+\tm->te = p->ebs;\n+\n+\treturn 0;\n+}\ndiff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h\nindex 58a051583..e39919da0 100644\n--- a/lib/librte_meter/rte_meter.h\n+++ b/lib/librte_meter/rte_meter.h\n@@ -16,6 +16,7 @@ extern \"C\" {\n  * Traffic metering algorithms:\n  *    1. Single Rate Three Color Marker (srTCM): defined by IETF RFC 2697\n  *    2. Two Rate Three Color Marker (trTCM): defined by IETF RFC 2698\n+ *    3. Two Rate Three Color Marker (trTCM): defined by IETF RFC 4115\n  *\n  ***/\n \n@@ -49,10 +50,21 @@ be greater than or equal to CIR. Both CBS or EBS have to be greater than zero. *\n struct rte_meter_trtcm_params {\n \tuint64_t cir; /**< Committed Information Rate (CIR). Measured in bytes per second. */\n \tuint64_t pir; /**< Peak Information Rate (PIR). Measured in bytes per second. */\n-\tuint64_t cbs; /**< Committed Burst Size (CBS). Measured in byes. */\n+\tuint64_t cbs; /**< Committed Burst Size (CBS). Measured in bytes. */\n \tuint64_t pbs; /**< Peak Burst Size (PBS). Measured in bytes. */\n };\n \n+/** trTCM parameters per metered traffic flow. The CIR, EIT, CBS and EBS\n+parameters only count bytes of IP packets and do not include link specific\n+headers. The CBS and EBS need to be greater than zero if CIR and EIR are\n+none-zero respectively.*/\n+struct rte_meter_trtcm_rfc4115_params {\n+\tuint64_t cir; /**< Committed Information Rate (CIR). Measured in bytes per second. */\n+\tuint64_t eir; /**< Excess Information Rate (EIR). Measured in bytes per second. */\n+\tuint64_t cbs; /**< Committed Burst Size (CBS). Measured in bytes. */\n+\tuint64_t ebs; /**< Excess Burst Size (EBS). Measured in bytes. */\n+};\n+\n /**\n  * Internal data structure storing the srTCM configuration profile. Typically\n  * shared by multiple srTCM objects.\n@@ -65,12 +77,24 @@ struct rte_meter_srtcm_profile;\n  */\n struct rte_meter_trtcm_profile;\n \n+/**\n+ * Internal data structure storing the trTCM RFC4115 configuration profile.\n+ * Typically shared by multiple trTCM objects.\n+ */\n+struct rte_meter_trtcm_rfc4115_profile;\n+\n /** Internal data structure storing the srTCM run-time context per metered traffic flow. */\n struct rte_meter_srtcm;\n \n /** Internal data structure storing the trTCM run-time context per metered traffic flow. */\n struct rte_meter_trtcm;\n \n+/**\n+ * Internal data structure storing the trTCM RFC4115 run-time context per\n+ * metered traffic flow.\n+ */\n+struct rte_meter_trtcm_rfc4115;\n+\n /**\n  * srTCM profile configuration\n  *\n@@ -98,6 +122,23 @@ rte_meter_srtcm_profile_config(struct rte_meter_srtcm_profile *p,\n int\n rte_meter_trtcm_profile_config(struct rte_meter_trtcm_profile *p,\n \tstruct rte_meter_trtcm_params *params);\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * trTCM RFC 4115 profile configuration\n+ *\n+ * @param p\n+ *    Pointer to pre-allocated trTCM profile data structure\n+ * @param params\n+ *    trTCM profile parameters\n+ * @return\n+ *    0 upon success, error code otherwise\n+ */\n+int __rte_experimental\n+rte_meter_trtcm_rfc4115_profile_config(\n+\tstruct rte_meter_trtcm_rfc4115_profile *p,\n+\tstruct rte_meter_trtcm_rfc4115_params *params);\n \n /**\n  * srTCM configuration per metered traffic flow\n@@ -127,6 +168,23 @@ int\n rte_meter_trtcm_config(struct rte_meter_trtcm *m,\n \tstruct rte_meter_trtcm_profile *p);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * trTCM RFC 4115 configuration per metered traffic flow\n+ *\n+ * @param m\n+ *    Pointer to pre-allocated trTCM data structure\n+ * @param p\n+ *    trTCM profile. Needs to be valid.\n+ * @return\n+ *    0 upon success, error code otherwise\n+ */\n+int __rte_experimental\n+rte_meter_trtcm_rfc4115_config(struct rte_meter_trtcm_rfc4115 *m,\n+\tstruct rte_meter_trtcm_rfc4115_profile *p);\n+\n /**\n  * srTCM color blind traffic metering\n  *\n@@ -213,6 +271,57 @@ rte_meter_trtcm_color_aware_check(struct rte_meter_trtcm *m,\n \tuint32_t pkt_len,\n \tenum rte_meter_color pkt_color);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * trTCM RFC4115 color blind traffic metering\n+ *\n+ * @param m\n+ *    Handle to trTCM instance\n+ * @param p\n+ *    trTCM profile specified at trTCM object creation time\n+ * @param time\n+ *    Current CPU time stamp (measured in CPU cycles)\n+ * @param pkt_len\n+ *    Length of the current IP packet (measured in bytes)\n+ * @return\n+ *    Color assigned to the current IP packet\n+ */\n+static inline enum rte_meter_color __rte_experimental\n+rte_meter_trtcm_rfc4115_color_blind_check(\n+\tstruct rte_meter_trtcm_rfc4115 *m,\n+\tstruct rte_meter_trtcm_rfc4115_profile *p,\n+\tuint64_t time,\n+\tuint32_t pkt_len);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * trTCM RFC4115 color aware traffic metering\n+ *\n+ * @param m\n+ *    Handle to trTCM instance\n+ * @param p\n+ *    trTCM profile specified at trTCM object creation time\n+ * @param time\n+ *    Current CPU time stamp (measured in CPU cycles)\n+ * @param pkt_len\n+ *    Length of the current IP packet (measured in bytes)\n+ * @param pkt_color\n+ *    Input color of the current IP packet\n+ * @return\n+ *    Color assigned to the current IP packet\n+ */\n+static inline enum rte_meter_color __rte_experimental\n+rte_meter_trtcm_rfc4115_color_aware_check(\n+\tstruct rte_meter_trtcm_rfc4115 *m,\n+\tstruct rte_meter_trtcm_rfc4115_profile *p,\n+\tuint64_t time,\n+\tuint32_t pkt_len,\n+\tenum rte_meter_color pkt_color);\n+\n /*\n  * Inline implementation of run-time methods\n  *\n@@ -259,13 +368,43 @@ struct rte_meter_trtcm {\n \tuint64_t time_tc;\n \t/**< Time of latest update of C token bucket */\n \tuint64_t time_tp;\n-\t/**< Time of latest update of E token bucket */\n+\t/**< Time of latest update of P token bucket */\n \tuint64_t tc;\n \t/**< Number of bytes currently available in committed(C) token bucket */\n \tuint64_t tp;\n \t/**< Number of bytes currently available in the peak(P) token bucket */\n };\n \n+struct rte_meter_trtcm_rfc4115_profile {\n+\tuint64_t cbs;\n+\t/**< Upper limit for C token bucket */\n+\tuint64_t ebs;\n+\t/**< Upper limit for E token bucket */\n+\tuint64_t cir_period;\n+\t/**< Number of CPU cycles for one update of C token bucket */\n+\tuint64_t cir_bytes_per_period;\n+\t/**< Number of bytes to add to C token bucket on each update */\n+\tuint64_t eir_period;\n+\t/**< Number of CPU cycles for one update of E token bucket */\n+\tuint64_t eir_bytes_per_period;\n+\t/**< Number of bytes to add to E token bucket on each update */\n+};\n+\n+/**\n+ * Internal data structure storing the trTCM RFC4115 run-time context per\n+ * metered traffic flow.\n+ */\n+struct rte_meter_trtcm_rfc4115 {\n+\tuint64_t time_tc;\n+\t/**< Time of latest update of C token bucket */\n+\tuint64_t time_te;\n+\t/**< Time of latest update of E token bucket */\n+\tuint64_t tc;\n+\t/**< Number of bytes currently available in committed(C) token bucket */\n+\tuint64_t te;\n+\t/**< Number of bytes currently available in the excess(E) token bucket */\n+};\n+\n static inline enum rte_meter_color\n rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,\n \tstruct rte_meter_srtcm_profile *p,\n@@ -434,6 +573,98 @@ rte_meter_trtcm_color_aware_check(struct rte_meter_trtcm *m,\n \treturn e_RTE_METER_GREEN;\n }\n \n+static inline enum rte_meter_color __rte_experimental\n+rte_meter_trtcm_rfc4115_color_blind_check(\n+\tstruct rte_meter_trtcm_rfc4115 *m,\n+\tstruct rte_meter_trtcm_rfc4115_profile *p,\n+\tuint64_t time,\n+\tuint32_t pkt_len)\n+{\n+\tuint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;\n+\n+\t/* Bucket update */\n+\ttime_diff_tc = time - m->time_tc;\n+\ttime_diff_te = time - m->time_te;\n+\tn_periods_tc = time_diff_tc / p->cir_period;\n+\tn_periods_te = time_diff_te / p->eir_period;\n+\tm->time_tc += n_periods_tc * p->cir_period;\n+\tm->time_te += n_periods_te * p->eir_period;\n+\n+\ttc = m->tc + n_periods_tc * p->cir_bytes_per_period;\n+\tif (tc > p->cbs)\n+\t\ttc = p->cbs;\n+\n+\tte = m->te + n_periods_te * p->eir_bytes_per_period;\n+\tif (te > p->ebs)\n+\t\tte = p->ebs;\n+\n+\t/* Color logic */\n+\tif (tc >= pkt_len) {\n+\t\tm->tc = tc - pkt_len;\n+\t\tm->te = te;\n+\t\treturn e_RTE_METER_GREEN;\n+\t} else if (te >= pkt_len) {\n+\t\tm->tc = tc;\n+\t\tm->te = te - pkt_len;\n+\t\treturn e_RTE_METER_YELLOW;\n+\t}\n+\n+\t/* If we end up here the color is RED */\n+\tm->tc = tc;\n+\tm->te = te;\n+\treturn e_RTE_METER_RED;\n+}\n+\n+static inline enum rte_meter_color __rte_experimental\n+rte_meter_trtcm_rfc4115_color_aware_check(\n+\tstruct rte_meter_trtcm_rfc4115 *m,\n+\tstruct rte_meter_trtcm_rfc4115_profile *p,\n+\tuint64_t time,\n+\tuint32_t pkt_len,\n+\tenum rte_meter_color pkt_color)\n+{\n+\tuint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;\n+\n+\t/* Bucket update */\n+\ttime_diff_tc = time - m->time_tc;\n+\ttime_diff_te = time - m->time_te;\n+\tn_periods_tc = time_diff_tc / p->cir_period;\n+\tn_periods_te = time_diff_te / p->eir_period;\n+\tm->time_tc += n_periods_tc * p->cir_period;\n+\tm->time_te += n_periods_te * p->eir_period;\n+\n+\ttc = m->tc + n_periods_tc * p->cir_bytes_per_period;\n+\tif (tc > p->cbs)\n+\t\ttc = p->cbs;\n+\n+\tte = m->te + n_periods_te * p->eir_bytes_per_period;\n+\tif (te > p->ebs)\n+\t\tte = p->ebs;\n+\n+\t/* Color logic */\n+\tif (pkt_color == e_RTE_METER_GREEN) {\n+\t\tif (tc >= pkt_len) {\n+\t\t\tm->tc = tc - pkt_len;\n+\t\t\tm->te = te;\n+\t\t\treturn e_RTE_METER_GREEN;\n+\t\t} else if (te >= pkt_len) {\n+\t\t\tm->tc = tc;\n+\t\t\tm->te = te - pkt_len;\n+\t\t\treturn e_RTE_METER_YELLOW;\n+\t\t}\n+\t} else if (pkt_color == e_RTE_METER_YELLOW && te >= pkt_len) {\n+\t\tm->tc = tc;\n+\t\tm->te = te - pkt_len;\n+\t\treturn e_RTE_METER_YELLOW;\n+\t}\n+\n+\t/* If we end up here the color is RED */\n+\tm->tc = tc;\n+\tm->te = te;\n+\treturn e_RTE_METER_RED;\n+}\n+\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_meter/rte_meter_version.map b/lib/librte_meter/rte_meter_version.map\nindex cb79f0c2b..4b460d580 100644\n--- a/lib/librte_meter/rte_meter_version.map\n+++ b/lib/librte_meter/rte_meter_version.map\n@@ -17,3 +17,12 @@ DPDK_18.08 {\n \trte_meter_srtcm_profile_config;\n \trte_meter_trtcm_profile_config;\n };\n+\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\trte_meter_trtcm_rfc4115_color_aware_check;\n+\trte_meter_trtcm_rfc4115_color_blind_check;\n+\trte_meter_trtcm_rfc4115_config;\n+\trte_meter_trtcm_rfc4115_profile_config;\n+};\n",
    "prefixes": [
        "v3",
        "1/2"
    ]
}