get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 87957,
    "url": "https://patches.dpdk.org/api/patches/87957/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210216204646.24196-3-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": "<20210216204646.24196-3-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210216204646.24196-3-cristian.dumitrescu@intel.com",
    "date": "2021-02-16T20:46:44",
    "name": "[v3,3/5] pipeline: support non-incremental table updates",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "be122970933b2f627b42efb9e9259a4816134701",
    "submitter": {
        "id": 19,
        "url": "https://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210216204646.24196-3-cristian.dumitrescu@intel.com/mbox/",
    "series": [
        {
            "id": 15273,
            "url": "https://patches.dpdk.org/api/series/15273/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=15273",
            "date": "2021-02-16T20:46:42",
            "name": "[v3,1/5] pipeline: improve table entry helpers",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/15273/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/87957/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/87957/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 7A8A9A054D;\n\tTue, 16 Feb 2021 21:47:02 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id A8E47160800;\n\tTue, 16 Feb 2021 21:46:53 +0100 (CET)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n by mails.dpdk.org (Postfix) with ESMTP id 58CD51607E5\n for <dev@dpdk.org>; Tue, 16 Feb 2021 21:46:51 +0100 (CET)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 16 Feb 2021 12:46:49 -0800",
            "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com) ([10.237.223.107])\n by fmsmga001.fm.intel.com with ESMTP; 16 Feb 2021 12:46:49 -0800"
        ],
        "IronPort-SDR": [
            "\n w1GUMxN9905RknSrkRxJCnKzzQwOjxJGD5s5XLat1A+mcLUCtKzdJdqa4PJnB0ZImBnjfgSmBZ\n UKUR7D3hM7rQ==",
            "\n xhPpuUFepMvLY2zNQDqSyXEVEoWSkTy6WOPlCEl8/VNgsiyiGsSyiWempI/fUYCnqPeRip4OEr\n yOZ05nsbJrjA=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9897\"; a=\"247078502\"",
            "E=Sophos;i=\"5.81,184,1610438400\"; d=\"scan'208\";a=\"247078502\"",
            "E=Sophos;i=\"5.81,184,1610438400\"; d=\"scan'208\";a=\"493443108\""
        ],
        "X-ExtLoop1": "1",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 16 Feb 2021 20:46:44 +0000",
        "Message-Id": "<20210216204646.24196-3-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20210216204646.24196-1-cristian.dumitrescu@intel.com>",
        "References": "<20210216202127.22803-1-cristian.dumitrescu@intel.com>\n <20210216204646.24196-1-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 3/5] pipeline: support non-incremental table\n updates",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Some table types (e.g. exact match/hash) allow for incremental table\nupdates, while others (e.g. wildcard match/ACL) do not. The former is\nalready supported, the latter is enabled by this patch.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_pipeline/rte_swx_ctl.c | 315 ++++++++++++++++++++++++------\n 1 file changed, 258 insertions(+), 57 deletions(-)",
    "diff": "diff --git a/lib/librte_pipeline/rte_swx_ctl.c b/lib/librte_pipeline/rte_swx_ctl.c\nindex 4a416bc71..6bef9c311 100644\n--- a/lib/librte_pipeline/rte_swx_ctl.c\n+++ b/lib/librte_pipeline/rte_swx_ctl.c\n@@ -42,11 +42,38 @@ struct table {\n \tstruct rte_swx_table_ops ops;\n \tstruct rte_swx_table_params params;\n \n+\t/* Set of \"stable\" keys: these keys are currently part of the table;\n+\t * these keys will be preserved with no action data changes after the\n+\t * next commit.\n+\t */\n \tstruct rte_swx_table_entry_list entries;\n+\n+\t/* Set of new keys: these keys are currently NOT part of the table;\n+\t * these keys will be added to the table on the next commit, if\n+\t * the commit operation is successful.\n+\t */\n \tstruct rte_swx_table_entry_list pending_add;\n+\n+\t/* Set of keys to be modified: these keys are currently part of the\n+\t * table; these keys are still going to be part of the table after the\n+\t * next commit, but their action data will be modified if the commit\n+\t * operation is successful. The modify0 list contains the keys with the\n+\t * current action data, the modify1 list contains the keys with the\n+\t * modified action data.\n+\t */\n \tstruct rte_swx_table_entry_list pending_modify0;\n \tstruct rte_swx_table_entry_list pending_modify1;\n+\n+\t/* Set of keys to be deleted: these keys are currently part of the\n+\t * table; these keys are to be deleted from the table on the next\n+\t * commit, if the commit operation is successful.\n+\t */\n \tstruct rte_swx_table_entry_list pending_delete;\n+\n+\t/* The pending default action: this is NOT the current default action;\n+\t * this will be the new default action after the next commit, if the\n+\t * next commit operation is successful.\n+\t */\n \tstruct rte_swx_table_entry *pending_default;\n \n \tint is_stub;\n@@ -609,6 +636,31 @@ table_pending_default_free(struct table *table)\n \ttable->pending_default = NULL;\n }\n \n+static int\n+table_is_update_pending(struct table *table, int consider_pending_default)\n+{\n+\tstruct rte_swx_table_entry *e;\n+\tuint32_t n = 0;\n+\n+\t/* Pending add. */\n+\tTAILQ_FOREACH(e, &table->pending_add, node)\n+\t\tn++;\n+\n+\t/* Pending modify. */\n+\tTAILQ_FOREACH(e, &table->pending_modify1, node)\n+\t\tn++;\n+\n+\t/* Pending delete. */\n+\tTAILQ_FOREACH(e, &table->pending_delete, node)\n+\t\tn++;\n+\n+\t/* Pending default. */\n+\tif (consider_pending_default && table->pending_default)\n+\t\tn++;\n+\n+\treturn n;\n+}\n+\n static void\n table_free(struct rte_swx_ctl_pipeline *ctl)\n {\n@@ -680,7 +732,7 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl)\n \t\tstruct rte_swx_table_state *ts_next = &ctl->ts_next[i];\n \n \t\t/* Table object. */\n-\t\tif (!table->is_stub) {\n+\t\tif (!table->is_stub && table->ops.add) {\n \t\t\tts_next->obj = table->ops.create(&table->params,\n \t\t\t\t\t\t\t &table->entries,\n \t\t\t\t\t\t\t table->info.args,\n@@ -691,6 +743,9 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl)\n \t\t\t}\n \t\t}\n \n+\t\tif (!table->is_stub && !table->ops.add)\n+\t\t\tts_next->obj = ts->obj;\n+\n \t\t/* Default action data: duplicate from current table state. */\n \t\tts_next->default_action_data =\n \t\t\tmalloc(table->params.action_data_size);\n@@ -1114,54 +1169,173 @@ rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,\n \treturn 0;\n }\n \n+\n+static void\n+table_entry_list_free(struct rte_swx_table_entry_list *list)\n+{\n+\tfor ( ; ; ) {\n+\t\tstruct rte_swx_table_entry *entry;\n+\n+\t\tentry = TAILQ_FIRST(list);\n+\t\tif (!entry)\n+\t\t\tbreak;\n+\n+\t\tTAILQ_REMOVE(list, entry, node);\n+\t\ttable_entry_free(entry);\n+\t}\n+}\n+\n+static int\n+table_entry_list_duplicate(struct rte_swx_ctl_pipeline *ctl,\n+\t\t\t   uint32_t table_id,\n+\t\t\t   struct rte_swx_table_entry_list *dst,\n+\t\t\t   struct rte_swx_table_entry_list *src)\n+{\n+\tstruct rte_swx_table_entry *src_entry;\n+\n+\tTAILQ_FOREACH(src_entry, src, node) {\n+\t\tstruct rte_swx_table_entry *dst_entry;\n+\n+\t\tdst_entry = table_entry_duplicate(ctl, table_id, src_entry, 1, 1);\n+\t\tif (!dst_entry)\n+\t\t\tgoto error;\n+\n+\t\tTAILQ_INSERT_TAIL(dst, dst_entry, node);\n+\t}\n+\n+\treturn 0;\n+\n+error:\n+\ttable_entry_list_free(dst);\n+\treturn -ENOMEM;\n+}\n+\n+/* This commit stage contains all the operations that can fail; in case ANY of\n+ * them fails for ANY table, ALL of them are rolled back for ALL the tables.\n+ */\n static int\n-table_rollfwd0(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n+table_rollfwd0(struct rte_swx_ctl_pipeline *ctl,\n+\t       uint32_t table_id,\n+\t       uint32_t after_swap)\n {\n \tstruct table *table = &ctl->tables[table_id];\n+\tstruct rte_swx_table_state *ts = &ctl->ts[table_id];\n \tstruct rte_swx_table_state *ts_next = &ctl->ts_next[table_id];\n-\tstruct rte_swx_table_entry *entry;\n \n-\t/* Reset counters. */\n-\ttable->n_add = 0;\n-\ttable->n_modify = 0;\n-\ttable->n_delete = 0;\n+\tif (table->is_stub || !table_is_update_pending(table, 0))\n+\t\treturn 0;\n \n-\t/* Add pending rules. */\n-\tTAILQ_FOREACH(entry, &table->pending_add, node) {\n-\t\tint status;\n+\t/*\n+\t * Current table supports incremental update.\n+\t */\n+\tif (table->ops.add) {\n+\t\t/* Reset counters. */\n+\t\ttable->n_add = 0;\n+\t\ttable->n_modify = 0;\n+\t\ttable->n_delete = 0;\n \n-\t\tstatus = table->ops.add(ts_next->obj, entry);\n-\t\tif (status)\n-\t\t\treturn status;\n+\t\t/* Add pending rules. */\n+\t\tstruct rte_swx_table_entry *entry;\n \n-\t\ttable->n_add++;\n-\t}\n+\t\tTAILQ_FOREACH(entry, &table->pending_add, node) {\n+\t\t\tint status;\n \n-\t/* Modify pending rules. */\n-\tTAILQ_FOREACH(entry, &table->pending_modify1, node) {\n-\t\tint status;\n+\t\t\tstatus = table->ops.add(ts_next->obj, entry);\n+\t\t\tif (status)\n+\t\t\t\treturn status;\n \n-\t\tstatus = table->ops.add(ts_next->obj, entry);\n-\t\tif (status)\n-\t\t\treturn status;\n+\t\t\ttable->n_add++;\n+\t\t}\n+\n+\t\t/* Modify pending rules. */\n+\t\tTAILQ_FOREACH(entry, &table->pending_modify1, node) {\n+\t\t\tint status;\n+\n+\t\t\tstatus = table->ops.add(ts_next->obj, entry);\n+\t\t\tif (status)\n+\t\t\t\treturn status;\n+\n+\t\t\ttable->n_modify++;\n+\t\t}\n+\n+\t\t/* Delete pending rules. */\n+\t\tTAILQ_FOREACH(entry, &table->pending_delete, node) {\n+\t\t\tint status;\n \n-\t\ttable->n_modify++;\n+\t\t\tstatus = table->ops.del(ts_next->obj, entry);\n+\t\t\tif (status)\n+\t\t\t\treturn status;\n+\n+\t\t\ttable->n_delete++;\n+\t\t}\n+\n+\t\treturn 0;\n \t}\n \n-\t/* Delete pending rules. */\n-\tTAILQ_FOREACH(entry, &table->pending_delete, node) {\n+\t/*\n+\t * Current table does NOT support incremental update.\n+\t */\n+\tif (!after_swap) {\n+\t\tstruct rte_swx_table_entry_list list;\n \t\tint status;\n \n-\t\tstatus = table->ops.del(ts_next->obj, entry);\n+\t\t/* Create updated list of entries included. */\n+\t\tTAILQ_INIT(&list);\n+\n+\t\tstatus = table_entry_list_duplicate(ctl,\n+\t\t\t\t\t\t    table_id,\n+\t\t\t\t\t\t    &list,\n+\t\t\t\t\t\t    &table->entries);\n+\t\tif (status)\n+\t\t\tgoto error;\n+\n+\t\tstatus = table_entry_list_duplicate(ctl,\n+\t\t\t\t\t\t    table_id,\n+\t\t\t\t\t\t    &list,\n+\t\t\t\t\t\t    &table->pending_add);\n+\t\tif (status)\n+\t\t\tgoto error;\n+\n+\t\tstatus = table_entry_list_duplicate(ctl,\n+\t\t\t\t\t\t    table_id,\n+\t\t\t\t\t\t    &list,\n+\t\t\t\t\t\t    &table->pending_modify1);\n \t\tif (status)\n-\t\t\treturn status;\n+\t\t\tgoto error;\n+\n+\t\t/* Create new table object with the updates included. */\n+\t\tts_next->obj = table->ops.create(&table->params,\n+\t\t\t\t\t\t &list,\n+\t\t\t\t\t\t table->info.args,\n+\t\t\t\t\t\t ctl->numa_node);\n+\t\tif (!ts_next->obj) {\n+\t\t\tstatus = -ENODEV;\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\ttable_entry_list_free(&list);\n+\n+\t\treturn 0;\n \n-\t\ttable->n_delete++;\n+error:\n+\t\ttable_entry_list_free(&list);\n+\t\treturn status;\n \t}\n \n+\t/* Free the old table object. */\n+\tif (ts_next->obj && table->ops.free)\n+\t\ttable->ops.free(ts_next->obj);\n+\n+\t/* Copy over the new table object. */\n+\tts_next->obj = ts->obj;\n+\n \treturn 0;\n }\n \n+/* This commit stage contains all the operations that cannot fail. They are\n+ * executed only if the previous stage was successful for ALL the tables. Hence,\n+ * none of these operations has to be rolled back for ANY table.\n+ */\n static void\n table_rollfwd1(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n {\n@@ -1186,6 +1360,10 @@ table_rollfwd1(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n \tts_next->default_action_id = action_id;\n }\n \n+/* This last commit stage is simply finalizing a successful commit operation.\n+ * This stage is only executed if all the previous stages were successful. This\n+ * stage cannot fail.\n+ */\n static void\n table_rollfwd2(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n {\n@@ -1212,43 +1390,66 @@ table_rollfwd2(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n \ttable_pending_default_free(table);\n }\n \n+/* The rollback stage is only executed when the commit failed, i.e. ANY of the\n+ * commit operations that can fail did fail for ANY table. It reverts ALL the\n+ * tables to their state before the commit started, as if the commit never\n+ * happened.\n+ */\n static void\n table_rollback(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n {\n \tstruct table *table = &ctl->tables[table_id];\n \tstruct rte_swx_table_state *ts_next = &ctl->ts_next[table_id];\n-\tstruct rte_swx_table_entry *entry;\n \n-\t/* Add back all the entries that were just deleted. */\n-\tTAILQ_FOREACH(entry, &table->pending_delete, node) {\n-\t\tif (!table->n_delete)\n-\t\t\tbreak;\n+\tif (table->is_stub || !table_is_update_pending(table, 0))\n+\t\treturn;\n \n-\t\ttable->ops.add(ts_next->obj, entry);\n-\t\ttable->n_delete--;\n-\t}\n+\tif (table->ops.add) {\n+\t\tstruct rte_swx_table_entry *entry;\n \n-\t/* Add back the old copy for all the entries that were just\n-\t * modified.\n-\t */\n-\tTAILQ_FOREACH(entry, &table->pending_modify0, node) {\n-\t\tif (!table->n_modify)\n-\t\t\tbreak;\n+\t\t/* Add back all the entries that were just deleted. */\n+\t\tTAILQ_FOREACH(entry, &table->pending_delete, node) {\n+\t\t\tif (!table->n_delete)\n+\t\t\t\tbreak;\n \n-\t\ttable->ops.add(ts_next->obj, entry);\n-\t\ttable->n_modify--;\n-\t}\n+\t\t\ttable->ops.add(ts_next->obj, entry);\n+\t\t\ttable->n_delete--;\n+\t\t}\n \n-\t/* Delete all the entries that were just added. */\n-\tTAILQ_FOREACH(entry, &table->pending_add, node) {\n-\t\tif (!table->n_add)\n-\t\t\tbreak;\n+\t\t/* Add back the old copy for all the entries that were just\n+\t\t * modified.\n+\t\t */\n+\t\tTAILQ_FOREACH(entry, &table->pending_modify0, node) {\n+\t\t\tif (!table->n_modify)\n+\t\t\t\tbreak;\n+\n+\t\t\ttable->ops.add(ts_next->obj, entry);\n+\t\t\ttable->n_modify--;\n+\t\t}\n \n-\t\ttable->ops.del(ts_next->obj, entry);\n-\t\ttable->n_add--;\n+\t\t/* Delete all the entries that were just added. */\n+\t\tTAILQ_FOREACH(entry, &table->pending_add, node) {\n+\t\t\tif (!table->n_add)\n+\t\t\t\tbreak;\n+\n+\t\t\ttable->ops.del(ts_next->obj, entry);\n+\t\t\ttable->n_add--;\n+\t\t}\n+\t} else {\n+\t\tstruct rte_swx_table_state *ts = &ctl->ts[table_id];\n+\n+\t\t/* Free the new table object, as update was cancelled. */\n+\t\tif (ts_next->obj && table->ops.free)\n+\t\t\ttable->ops.free(ts_next->obj);\n+\n+\t\t/* Reinstate the old table object. */\n+\t\tts_next->obj = ts->obj;\n \t}\n }\n \n+/* This stage is conditionally executed (as instructed by the user) after a\n+ * failed commit operation to remove ALL the pending work for ALL the tables.\n+ */\n static void\n table_abort(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n {\n@@ -1290,7 +1491,7 @@ rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl, int abort_on_fail)\n \t * ts.\n \t */\n \tfor (i = 0; i < ctl->info.n_tables; i++) {\n-\t\tstatus = table_rollfwd0(ctl, i);\n+\t\tstatus = table_rollfwd0(ctl, i, 0);\n \t\tif (status)\n \t\t\tgoto rollback;\n \t}\n@@ -1310,7 +1511,7 @@ rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl, int abort_on_fail)\n \t/* Operate the changes on the current ts_next, which is the previous ts.\n \t */\n \tfor (i = 0; i < ctl->info.n_tables; i++) {\n-\t\ttable_rollfwd0(ctl, i);\n+\t\ttable_rollfwd0(ctl, i, 1);\n \t\ttable_rollfwd1(ctl, i);\n \t\ttable_rollfwd2(ctl, i);\n \t}\n@@ -1444,11 +1645,11 @@ rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,\n \t\t\t\tmask = field_hton(mask, mf->n_bits);\n \t\t}\n \n-\t\t\t/* Copy to entry. */\n-\t\t\tif (entry->key_mask)\n-\t\t\t\tmemcpy(&entry->key_mask[offset],\n-\t\t\t\t       (uint8_t *)&mask,\n-\t\t\t\t       mf->n_bits / 8);\n+\t\t/* Copy to entry. */\n+\t\tif (entry->key_mask)\n+\t\t\tmemcpy(&entry->key_mask[offset],\n+\t\t\t       (uint8_t *)&mask,\n+\t\t\t       mf->n_bits / 8);\n \n \t\t/*\n \t\t * Value.\n",
    "prefixes": [
        "v3",
        "3/5"
    ]
}