get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 87924,
    "url": "http://patches.dpdk.org/api/patches/87924/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210215162151.5655-3-cristian.dumitrescu@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<20210215162151.5655-3-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210215162151.5655-3-cristian.dumitrescu@intel.com",
    "date": "2021-02-15T16:21:49",
    "name": "[3/5] pipeline: support non-incremental table updates",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b75a8127c39bb164fbd59f9770159d8959bd57e8",
    "submitter": {
        "id": 19,
        "url": "http://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20210215162151.5655-3-cristian.dumitrescu@intel.com/mbox/",
    "series": [
        {
            "id": 15263,
            "url": "http://patches.dpdk.org/api/series/15263/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=15263",
            "date": "2021-02-15T16:21:47",
            "name": "[1/5] pipeline: improve table entry helpers",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/15263/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/87924/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/87924/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 0418BA054F;\n\tMon, 15 Feb 2021 17:22:14 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6B08E1606DC;\n\tMon, 15 Feb 2021 17:22:00 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by mails.dpdk.org (Postfix) with ESMTP id 8A17C406FF\n for <dev@dpdk.org>; Mon, 15 Feb 2021 17:21:56 +0100 (CET)",
            "from fmsmga008.fm.intel.com ([10.253.24.58])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 Feb 2021 08:21:55 -0800",
            "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com) ([10.237.223.107])\n by fmsmga008.fm.intel.com with ESMTP; 15 Feb 2021 08:21:54 -0800"
        ],
        "IronPort-SDR": [
            "\n 5FumE9qNdI4cySNqq5vVprTVcxslrYnJXrT+59HZryOJiy7SqxbTvgh9pPIvlIZ0ygzOvT2wtC\n 2WM8txHRwEWQ==",
            "\n LXvpY19GTeKfmzssovl1JiT10tKIsy/91UUtuOu3HAEJ+tzWX8BY9gp9zv2mMrWg39L4CK4IRI\n TKrIvIPASdoQ=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9896\"; a=\"201892848\"",
            "E=Sophos;i=\"5.81,181,1610438400\"; d=\"scan'208\";a=\"201892848\"",
            "E=Sophos;i=\"5.81,181,1610438400\"; d=\"scan'208\";a=\"383421603\""
        ],
        "X-ExtLoop1": "1",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 15 Feb 2021 16:21:49 +0000",
        "Message-Id": "<20210215162151.5655-3-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20210215162151.5655-1-cristian.dumitrescu@intel.com>",
        "References": "<20210215162151.5655-1-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 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 | 258 +++++++++++++++++++++++-------\n 1 file changed, 197 insertions(+), 61 deletions(-)",
    "diff": "diff --git a/lib/librte_pipeline/rte_swx_ctl.c b/lib/librte_pipeline/rte_swx_ctl.c\nindex 480e34238..20e2ac067 100644\n--- a/lib/librte_pipeline/rte_swx_ctl.c\n+++ b/lib/librte_pipeline/rte_swx_ctl.c\n@@ -603,6 +603,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_peding_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_peding_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@@ -674,7 +699,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@@ -685,6 +710,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@@ -1108,52 +1136,145 @@ 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_rollfwd0(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\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+static int\n+table_rollfwd0(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id, uint32_t after_swap)\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/* 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+\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\ttable->n_modify++;\n-\t}\n+\t\t/* Modify pending rules. */\n+\t\tTAILQ_FOREACH(entry, &table->pending_modify1, node) {\n+\t\t\tint status;\n \n-\t/* Delete pending rules. */\n-\tTAILQ_FOREACH(entry, &table->pending_delete, 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.del(ts_next->obj, entry);\n-\t\tif (status)\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\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} else {\n+\t\tif (!after_swap) {\n+\t\t\tstruct rte_swx_table_entry_list list;\n+\t\t\tint status;\n+\n+\t\t\t/* Create updated list of entries included. */\n+\t\t\tTAILQ_INIT(&list);\n+\n+\t\t\tstatus = table_entry_list_duplicate(ctl, table_id, &list, &table->entries);\n+\t\t\tif (status)\n+\t\t\t\tgoto error;\n+\n+\t\t\tstatus = table_entry_list_duplicate(ctl, table_id, &list, &table->pending_add);\n+\t\t\tif (status)\n+\t\t\t\tgoto error;\n+\n+\t\t\tstatus = table_entry_list_duplicate(ctl, table_id, &list, &table->pending_modify1);\n+\t\t\tif (status)\n+\t\t\t\tgoto error;\n+\n+\t\t\t/* Create new table object with the updates included. */\n+\t\t\tts_next->obj = table->ops.create(&table->params, &list, table->info.args, ctl->numa_node);\n+\t\t\tif (!ts_next->obj) {\n+\t\t\t\tstatus = -ENODEV;\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\n+\t\t\ttable_entry_list_free(&list);\n+\n+\t\t\treturn 0;\n+\n+error:\n+\t\t\ttable_entry_list_free(&list);\n \t\t\treturn status;\n+\t\t} else {\n+\t\t\tstruct rte_swx_table_state *ts = &ctl->ts[table_id];\n \n-\t\ttable->n_delete++;\n-\t}\n+\t\t\t/* Free the old table object. */\n+\t\t\tif (ts_next->obj && table->ops.free)\n+\t\t\t\ttable->ops.free(ts_next->obj);\n \n-\treturn 0;\n+\t\t\t/* Copy over the new table object. */\n+\t\t\tts_next->obj = ts->obj;\n+\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n }\n \n static void\n@@ -1211,35 +1332,50 @@ 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@@ -1284,7 +1420,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@@ -1304,7 +1440,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@@ -1438,11 +1574,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": [
        "3/5"
    ]
}