get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 35994,
    "url": "https://patches.dpdk.org/api/patches/35994/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20180312172615.6621-8-jasvinder.singh@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": "<20180312172615.6621-8-jasvinder.singh@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180312172615.6621-8-jasvinder.singh@intel.com",
    "date": "2018-03-12T17:25:38",
    "name": "[dpdk-dev,v2,07/44] pipeline: add ttl update action",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "29bee5b17206519d9de86c2ccaf50c0738ae2567",
    "submitter": {
        "id": 285,
        "url": "https://patches.dpdk.org/api/people/285/?format=api",
        "name": "Jasvinder Singh",
        "email": "jasvinder.singh@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20180312172615.6621-8-jasvinder.singh@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/35994/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/35994/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 EA5355B34;\n\tMon, 12 Mar 2018 18:52:11 +0100 (CET)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id BCBA72C58\n\tfor <dev@dpdk.org>; Mon, 12 Mar 2018 18:52:06 +0100 (CET)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t12 Mar 2018 10:26:25 -0700",
            "from silpixa00381635.ir.intel.com (HELO\n\tsilpixa00381635.ger.corp.intel.com) ([10.237.222.149])\n\tby orsmga004.jf.intel.com with ESMTP; 12 Mar 2018 10:26:25 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.47,462,1515484800\"; d=\"scan'208\";a=\"182012833\"",
        "From": "Jasvinder Singh <jasvinder.singh@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "cristian.dumitrescu@intel.com",
        "Date": "Mon, 12 Mar 2018 17:25:38 +0000",
        "Message-Id": "<20180312172615.6621-8-jasvinder.singh@intel.com>",
        "X-Mailer": "git-send-email 2.9.3",
        "In-Reply-To": "<20180312172615.6621-1-jasvinder.singh@intel.com>",
        "References": "<20180309182426.135278-2-jasvinder.singh@intel.com>\n\t<20180312172615.6621-1-jasvinder.singh@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 07/44] pipeline: add ttl update action",
        "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://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": "<https://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": "Add implementation of ttl update action.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_pipeline/rte_pipeline_version.map |   1 +\n lib/librte_pipeline/rte_table_action.c       | 155 +++++++++++++++++++++++++++\n lib/librte_pipeline/rte_table_action.h       |  66 ++++++++++++\n 3 files changed, 222 insertions(+)",
    "diff": "diff --git a/lib/librte_pipeline/rte_pipeline_version.map b/lib/librte_pipeline/rte_pipeline_version.map\nindex c7106dc..9388585 100644\n--- a/lib/librte_pipeline/rte_pipeline_version.map\n+++ b/lib/librte_pipeline/rte_pipeline_version.map\n@@ -61,5 +61,6 @@ EXPERIMENTAL {\n \trte_table_action_profile_free;\n \trte_table_action_profile_freeze;\n \trte_table_action_table_params_get;\n+\trte_table_action_ttl_read;\n \n } DPDK_16.04;\ndiff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c\nindex ddffe18..f26bec3 100644\n--- a/lib/librte_pipeline/rte_table_action.c\n+++ b/lib/librte_pipeline/rte_table_action.c\n@@ -842,6 +842,82 @@ pkt_ipv6_work_nat(struct ipv6_hdr *ip,\n }\n \n /**\n+ * RTE_TABLE_ACTION_TTL\n+ */\n+static int\n+ttl_cfg_check(struct rte_table_action_ttl_config *ttl)\n+{\n+\tif (ttl->drop == 0)\n+\t\treturn -ENOTSUP;\n+\n+\treturn 0;\n+}\n+\n+struct ttl_data {\n+\tuint32_t n_packets;\n+} __attribute__((__packed__));\n+\n+#define TTL_INIT(data, decrement)                         \\\n+\t((data)->n_packets = (decrement) ? 1 : 0)\n+\n+#define TTL_DEC_GET(data)                                  \\\n+\t((uint8_t)((data)->n_packets & 1))\n+\n+#define TTL_STATS_RESET(data)                             \\\n+\t((data)->n_packets = ((data)->n_packets & 1))\n+\n+#define TTL_STATS_READ(data)                               \\\n+\t((data)->n_packets >> 1)\n+\n+#define TTL_STATS_ADD(data, value)                        \\\n+\t((data)->n_packets =                                  \\\n+\t\t(((((data)->n_packets >> 1) + (value)) << 1) |    \\\n+\t\t((data)->n_packets & 1)))\n+\n+static int\n+ttl_apply(void *data,\n+\tstruct rte_table_action_ttl_params *p)\n+{\n+\tstruct ttl_data *d = data;\n+\n+\tTTL_INIT(d, p->decrement);\n+\n+\treturn 0;\n+}\n+\n+static __rte_always_inline uint64_t\n+pkt_ipv4_work_ttl(struct ipv4_hdr *ip,\n+\tstruct ttl_data *data)\n+{\n+\tuint32_t drop;\n+\tuint8_t ttl = ip->time_to_live;\n+\n+\tttl -= TTL_DEC_GET(data);\n+\tip->time_to_live = ttl;\n+\n+\tdrop = (ttl == 0) ? 1 : 0;\n+\tTTL_STATS_ADD(data, drop);\n+\n+\treturn drop;\n+}\n+\n+static __rte_always_inline uint64_t\n+pkt_ipv6_work_ttl(struct ipv6_hdr *ip,\n+\tstruct ttl_data *data)\n+{\n+\tuint32_t drop;\n+\tuint8_t ttl = ip->hop_limits;\n+\n+\tttl -= TTL_DEC_GET(data);\n+\tip->hop_limits = ttl;\n+\n+\tdrop = (ttl == 0) ? 1 : 0;\n+\tTTL_STATS_ADD(data, drop);\n+\n+\treturn drop;\n+}\n+\n+/**\n  * Action profile\n  */\n static int\n@@ -853,6 +929,7 @@ action_valid(enum rte_table_action_type action)\n \tcase RTE_TABLE_ACTION_TM:\n \tcase RTE_TABLE_ACTION_ENCAP:\n \tcase RTE_TABLE_ACTION_NAT:\n+\tcase RTE_TABLE_ACTION_TTL:\n \t\treturn 1;\n \tdefault:\n \t\treturn 0;\n@@ -869,6 +946,7 @@ struct ap_config {\n \tstruct rte_table_action_tm_config tm;\n \tstruct rte_table_action_encap_config encap;\n \tstruct rte_table_action_nat_config nat;\n+\tstruct rte_table_action_ttl_config ttl;\n };\n \n static size_t\n@@ -883,6 +961,8 @@ action_cfg_size(enum rte_table_action_type action)\n \t\treturn sizeof(struct rte_table_action_encap_config);\n \tcase RTE_TABLE_ACTION_NAT:\n \t\treturn sizeof(struct rte_table_action_nat_config);\n+\tcase RTE_TABLE_ACTION_TTL:\n+\t\treturn sizeof(struct rte_table_action_ttl_config);\n \tdefault:\n \t\treturn 0;\n \t}\n@@ -905,6 +985,9 @@ action_cfg_get(struct ap_config *ap_config,\n \tcase RTE_TABLE_ACTION_NAT:\n \t\treturn &ap_config->nat;\n \n+\tcase RTE_TABLE_ACTION_TTL:\n+\t\treturn &ap_config->ttl;\n+\n \tdefault:\n \t\treturn NULL;\n \t}\n@@ -949,6 +1032,9 @@ action_data_size(enum rte_table_action_type action,\n \t\treturn nat_data_size(&ap_config->nat,\n \t\t\t&ap_config->common);\n \n+\tcase RTE_TABLE_ACTION_TTL:\n+\t\treturn sizeof(struct ttl_data);\n+\n \tdefault:\n \t\treturn 0;\n \t}\n@@ -1035,6 +1121,10 @@ rte_table_action_profile_action_register(struct rte_table_action_profile *profil\n \t\tstatus = nat_cfg_check(action_config);\n \t\tbreak;\n \n+\tcase RTE_TABLE_ACTION_TTL:\n+\t\tstatus = ttl_cfg_check(action_config);\n+\t\tbreak;\n+\n \tdefault:\n \t\tstatus = 0;\n \t\tbreak;\n@@ -1168,6 +1258,10 @@ rte_table_action_apply(struct rte_table_action *action,\n \t\t\taction_params,\n \t\t\t&action->cfg.common);\n \n+\tcase RTE_TABLE_ACTION_TTL:\n+\t\treturn ttl_apply(action_data,\n+\t\t\taction_params);\n+\n \tdefault:\n \t\treturn -EINVAL;\n \t}\n@@ -1334,6 +1428,34 @@ rte_table_action_meter_read(struct rte_table_action *action,\n \treturn 0;\n }\n \n+int\n+rte_table_action_ttl_read(struct rte_table_action *action,\n+\tvoid *data,\n+\tstruct rte_table_action_ttl_counters *stats,\n+\tint clear)\n+{\n+\tstruct ttl_data *ttl_data;\n+\n+\t/* Check input arguments */\n+\tif ((action == NULL) ||\n+\t\t((action->cfg.action_mask &\n+\t\t(1LLU << RTE_TABLE_ACTION_TTL)) == 0) ||\n+\t\t(data == NULL))\n+\t\treturn -EINVAL;\n+\n+\tttl_data = action_data_get(data, action, RTE_TABLE_ACTION_TTL);\n+\n+\t/* Read */\n+\tif (stats)\n+\t\tstats->n_packets = TTL_STATS_READ(ttl_data);\n+\n+\t/* Clear */\n+\tif (clear)\n+\t\tTTL_STATS_RESET(ttl_data);\n+\n+\treturn 0;\n+}\n+\n static __rte_always_inline uint64_t\n pkt_work(struct rte_mbuf *mbuf,\n \tstruct rte_pipeline_table_entry *table_entry,\n@@ -1407,6 +1529,16 @@ pkt_work(struct rte_mbuf *mbuf,\n \t\t\tpkt_ipv6_work_nat(ip, data, &cfg->nat);\n \t}\n \n+\tif (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TTL)) {\n+\t\tvoid *data =\n+\t\t\taction_data_get(table_entry, action, RTE_TABLE_ACTION_TTL);\n+\n+\t\tif (cfg->common.ip_version)\n+\t\t\tdrop_mask |= pkt_ipv4_work_ttl(ip, data);\n+\t\telse\n+\t\t\tdrop_mask |= pkt_ipv6_work_ttl(ip, data);\n+\t}\n+\n \treturn drop_mask;\n }\n \n@@ -1613,6 +1745,29 @@ pkt4_work(struct rte_mbuf **mbufs,\n \t\t}\n \t}\n \n+\tif (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TTL)) {\n+\t\tvoid *data0 =\n+\t\t\t\taction_data_get(table_entry0, action, RTE_TABLE_ACTION_TTL);\n+\t\tvoid *data1 =\n+\t\t\t\taction_data_get(table_entry1, action, RTE_TABLE_ACTION_TTL);\n+\t\tvoid *data2 =\n+\t\t\t\taction_data_get(table_entry2, action, RTE_TABLE_ACTION_TTL);\n+\t\tvoid *data3 =\n+\t\t\t\taction_data_get(table_entry3, action, RTE_TABLE_ACTION_TTL);\n+\n+\t\tif (cfg->common.ip_version) {\n+\t\t\tdrop_mask0 |= pkt_ipv4_work_ttl(ip0, data0);\n+\t\t\tdrop_mask1 |= pkt_ipv4_work_ttl(ip1, data1);\n+\t\t\tdrop_mask2 |= pkt_ipv4_work_ttl(ip2, data2);\n+\t\t\tdrop_mask3 |= pkt_ipv4_work_ttl(ip3, data3);\n+\t\t} else {\n+\t\t\tdrop_mask0 |= pkt_ipv6_work_ttl(ip0, data0);\n+\t\t\tdrop_mask1 |= pkt_ipv6_work_ttl(ip1, data1);\n+\t\t\tdrop_mask2 |= pkt_ipv6_work_ttl(ip2, data2);\n+\t\t\tdrop_mask3 |= pkt_ipv6_work_ttl(ip3, data3);\n+\t\t}\n+\t}\n+\n \treturn drop_mask0 |\n \t\t(drop_mask1 << 1) |\n \t\t(drop_mask2 << 2) |\ndiff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h\nindex 5204511..57ac4f9 100644\n--- a/lib/librte_pipeline/rte_table_action.h\n+++ b/lib/librte_pipeline/rte_table_action.h\n@@ -80,6 +80,9 @@ enum rte_table_action_type {\n \n \t/** Network Address Translation (NAT). */\n \tRTE_TABLE_ACTION_NAT,\n+\n+\t/** Time to Live (TTL) update. */\n+\tRTE_TABLE_ACTION_TTL,\n };\n \n /** Common action configuration (per table action profile). */\n@@ -448,6 +451,44 @@ struct rte_table_action_nat_params {\n };\n \n /**\n+ * RTE_TABLE_ACTION_TTL\n+ */\n+/** TTL action configuration (per table action profile). */\n+struct rte_table_action_ttl_config {\n+\t/** When non-zero, the input packets whose updated IPv4 Time to Live\n+\t * (TTL) field or IPv6 Hop Limit (HL) field is zero are dropped.\n+\t * When zero, the input packets whose updated IPv4 TTL field or IPv6 HL\n+\t * field is zero are forwarded as usual (typically for debugging\n+\t * purpose).\n+\t */\n+\tint drop;\n+\n+\t/** When non-zero, the *n_packets* stats counter for TTL action is\n+\t * enabled, otherwise disabled.\n+\t *\n+\t * @see struct rte_table_action_ttl_counters\n+\t */\n+\tint n_packets_enabled;\n+};\n+\n+/** TTL action parameters (per table rule). */\n+struct rte_table_action_ttl_params {\n+\t/** When non-zero, decrement the IPv4 TTL field and update the checksum\n+\t * field, or decrement the IPv6 HL field. When zero, the IPv4 TTL field\n+\t * or the IPv6 HL field is not changed.\n+\t */\n+\tint decrement;\n+};\n+\n+/** TTL action statistics packets (per table rule). */\n+struct rte_table_action_ttl_counters {\n+\t/** Number of IPv4 packets whose updated TTL field is zero or IPv6\n+\t * packets whose updated HL field is zero.\n+\t */\n+\tuint64_t n_packets;\n+};\n+\n+/**\n  * Table action profile.\n  */\n struct rte_table_action_profile;\n@@ -671,6 +712,31 @@ rte_table_action_meter_read(struct rte_table_action *action,\n \tstruct rte_table_action_mtr_counters *stats,\n \tint clear);\n \n+/**\n+ * Table action TTL read.\n+ *\n+ * @param[in] action\n+ *   Handle to table action object (needs to be valid).\n+ * @param[in] data\n+ *   Data byte array (typically table rule data) with TTL action previously\n+ *   applied on it.\n+ * @param[inout] stats\n+ *   When non-NULL, it points to the area where the TTL stats counters read from\n+ *   *data* are saved.\n+ * @param[in] clear\n+ *   When non-zero, the TTL stats counters are cleared (i.e. set to zero),\n+ *   otherwise the counters are not modified. When the read operation is enabled\n+ *   (*stats* is non-NULL), the clear operation is performed after the read\n+ *   operation is completed.\n+ * @return\n+ *   Zero on success, non-zero error code otherwise.\n+ */\n+int __rte_experimental\n+rte_table_action_ttl_read(struct rte_table_action *action,\n+\tvoid *data,\n+\tstruct rte_table_action_ttl_counters *stats,\n+\tint clear);\n+\n #ifdef __cplusplus\n }\n #endif\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "07/44"
    ]
}