get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 87955,
    "url": "https://patches.dpdk.org/api/patches/87955/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210216204646.24196-1-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-1-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210216204646.24196-1-cristian.dumitrescu@intel.com",
    "date": "2021-02-16T20:46:42",
    "name": "[v3,1/5] pipeline: improve table entry helpers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "a030d3472dcd404f4f52e56fc0a21df2d0866065",
    "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-1-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/87955/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/87955/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 62F49A054D;\n\tTue, 16 Feb 2021 21:46:51 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 421261607D4;\n\tTue, 16 Feb 2021 21:46:51 +0100 (CET)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n by mails.dpdk.org (Postfix) with ESMTP id 965311607C0\n for <dev@dpdk.org>; Tue, 16 Feb 2021 21:46:49 +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:47 -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:46 -0800"
        ],
        "IronPort-SDR": [
            "\n o2S3ToXS1mTqbG7lVEoCCspgGXAavRwl2fTYf4iUpbABtnFRTrGi3FcMrffAYYJ/T/kv5/xUSf\n GLG+GuXxKlig==",
            "\n p3Ck9TqPWs1c0t1QczKF6aZiEXlGlCdSLagKu/5FWIDh+hlwSiJt5j+XiRIWd93x5QTXktNHXL\n ya/NtgdwQ3+w=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9897\"; a=\"247078495\"",
            "E=Sophos;i=\"5.81,184,1610438400\"; d=\"scan'208\";a=\"247078495\"",
            "E=Sophos;i=\"5.81,184,1610438400\"; d=\"scan'208\";a=\"493443097\""
        ],
        "X-ExtLoop1": "1",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 16 Feb 2021 20:46:42 +0000",
        "Message-Id": "<20210216204646.24196-1-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20210216202127.22803-1-cristian.dumitrescu@intel.com>",
        "References": "<20210216202127.22803-1-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 1/5] pipeline: improve table entry helpers",
        "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": "Improve the internal table entry helper routines for key comparison,\nentry duplication and checks.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_pipeline/rte_swx_ctl.c | 120 ++++++++++++++++--------------\n 1 file changed, 65 insertions(+), 55 deletions(-)",
    "diff": "diff --git a/lib/librte_pipeline/rte_swx_ctl.c b/lib/librte_pipeline/rte_swx_ctl.c\nindex ee6df4544..af653d7f4 100644\n--- a/lib/librte_pipeline/rte_swx_ctl.c\n+++ b/lib/librte_pipeline/rte_swx_ctl.c\n@@ -234,6 +234,26 @@ table_entry_alloc(struct table *table)\n \treturn NULL;\n }\n \n+static int\n+table_entry_key_check_em(struct table *table, struct rte_swx_table_entry *entry)\n+{\n+\tuint8_t *key_mask0 = table->params.key_mask0;\n+\tuint32_t key_size = table->params.key_size, i;\n+\n+\tif (!entry->key_mask)\n+\t\treturn 0;\n+\n+\tfor (i = 0; i < key_size; i++) {\n+\t\tuint8_t km0 = key_mask0[i];\n+\t\tuint8_t km = entry->key_mask[i];\n+\n+\t\tif ((km & km0) != km0)\n+\t\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int\n table_entry_check(struct rte_swx_ctl_pipeline *ctl,\n \t\t  uint32_t table_id,\n@@ -242,6 +262,7 @@ table_entry_check(struct rte_swx_ctl_pipeline *ctl,\n \t\t  int data_check)\n {\n \tstruct table *table = &ctl->tables[table_id];\n+\tint status;\n \n \tCHECK(entry, EINVAL);\n \n@@ -266,7 +287,9 @@ table_entry_check(struct rte_swx_ctl_pipeline *ctl,\n \t\t\t\tbreak;\n \n \t\t\tcase RTE_SWX_TABLE_MATCH_EXACT:\n-\t\t\t\tCHECK(!entry->key_mask, EINVAL);\n+\t\t\t\tstatus = table_entry_key_check_em(table, entry);\n+\t\t\t\tif (status)\n+\t\t\t\t\treturn status;\n \t\t\t\tbreak;\n \n \t\t\tdefault:\n@@ -327,10 +350,7 @@ table_entry_duplicate(struct rte_swx_ctl_pipeline *ctl,\n \t\tnew_entry->key_signature = entry->key_signature;\n \n \t\t/* key_mask. */\n-\t\tif (table->params.match_type != RTE_SWX_TABLE_MATCH_EXACT) {\n-\t\t\tif (!entry->key_mask)\n-\t\t\t\tgoto error;\n-\n+\t\tif (entry->key_mask) {\n \t\t\tnew_entry->key_mask = malloc(table->params.key_size);\n \t\t\tif (!new_entry->key_mask)\n \t\t\t\tgoto error;\n@@ -357,18 +377,24 @@ table_entry_duplicate(struct rte_swx_ctl_pipeline *ctl,\n \n \t\t/* action_data. */\n \t\ta = &ctl->actions[entry->action_id];\n-\t\tif (a->data_size) {\n-\t\t\tif (!entry->action_data)\n-\t\t\t\tgoto error;\n+\t\tif (a->data_size && !entry->action_data)\n+\t\t\tgoto error;\n \n-\t\t\tnew_entry->action_data = malloc(a->data_size);\n-\t\t\tif (!new_entry->action_data)\n-\t\t\t\tgoto error;\n+\t\t/* The table layer provisions a constant action data size per\n+\t\t * entry, which should be the largest data size for all the\n+\t\t * actions enabled for the current table, and attempts to copy\n+\t\t * this many bytes each time a table entry is added, even if the\n+\t\t * specific action requires less data or even no data at all,\n+\t\t * hence we always have to allocate the max.\n+\t\t */\n+\t\tnew_entry->action_data = calloc(1, table->params.action_data_size);\n+\t\tif (!new_entry->action_data)\n+\t\t\tgoto error;\n \n+\t\tif (a->data_size)\n \t\t\tmemcpy(new_entry->action_data,\n \t\t\t       entry->action_data,\n \t\t\t       a->data_size);\n-\t\t}\n \t}\n \n \treturn new_entry;\n@@ -378,58 +404,36 @@ table_entry_duplicate(struct rte_swx_ctl_pipeline *ctl,\n \treturn NULL;\n }\n \n-static int\n-entry_keycmp_em(struct rte_swx_table_entry *e0,\n-\t\tstruct rte_swx_table_entry *e1,\n-\t\tuint32_t key_size)\n-{\n-\tif (e0->key_signature != e1->key_signature)\n-\t\treturn 1; /* Not equal. */\n-\n-\tif (memcmp(e0->key, e1->key, key_size))\n-\t\treturn 1; /* Not equal. */\n-\n-\treturn 0; /* Equal */\n-}\n-\n-static int\n-entry_keycmp_wm(struct rte_swx_table_entry *e0 __rte_unused,\n-\t\tstruct rte_swx_table_entry *e1 __rte_unused,\n-\t\tuint32_t key_size __rte_unused)\n-{\n-\t/* TBD */\n-\n-\treturn 1; /* Not equal */\n-}\n-\n-static int\n-entry_keycmp_lpm(struct rte_swx_table_entry *e0 __rte_unused,\n-\t\t struct rte_swx_table_entry *e1 __rte_unused,\n-\t\t uint32_t key_size __rte_unused)\n-{\n-\t/* TBD */\n-\n-\treturn 1; /* Not equal */\n-}\n-\n static int\n table_entry_keycmp(struct table *table,\n \t\t   struct rte_swx_table_entry *e0,\n \t\t   struct rte_swx_table_entry *e1)\n {\n-\tswitch (table->params.match_type) {\n-\tcase RTE_SWX_TABLE_MATCH_EXACT:\n-\t\treturn entry_keycmp_em(e0, e1, table->params.key_size);\n+\tuint32_t key_size = table->params.key_size;\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < key_size; i++) {\n+\t\tuint8_t *key_mask0 = table->params.key_mask0;\n+\t\tuint8_t km0, km[2], k[2];\n+\n+\t\tkm0 = key_mask0 ? key_mask0[i] : 0xFF;\n+\n+\t\tkm[0] = e0->key_mask ? e0->key_mask[i] : 0xFF;\n+\t\tkm[1] = e1->key_mask ? e1->key_mask[i] : 0xFF;\n \n-\tcase RTE_SWX_TABLE_MATCH_WILDCARD:\n-\t\treturn entry_keycmp_wm(e0, e1, table->params.key_size);\n+\t\tk[0] = e0->key[i];\n+\t\tk[1] = e1->key[i];\n \n-\tcase RTE_SWX_TABLE_MATCH_LPM:\n-\t\treturn entry_keycmp_lpm(e0, e1, table->params.key_size);\n+\t\t/* Mask comparison. */\n+\t\tif ((km[0] & km0) != (km[1] & km0))\n+\t\t\treturn 1; /* Not equal. */\n \n-\tdefault:\n-\t\treturn 1; /* Not equal. */\n+\t\t/* Value comparison. */\n+\t\tif ((k[0] & km[0] & km0) != (k[1] & km[1] & km0))\n+\t\t\treturn 1; /* Not equal. */\n \t}\n+\n+\treturn 0; /* Equal. */\n }\n \n static struct rte_swx_table_entry *\n@@ -893,6 +897,9 @@ rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,\n \tCHECK(table, EINVAL);\n \ttable_id = table - ctl->tables;\n \n+\tCHECK(entry, EINVAL);\n+\tCHECK(!table_entry_check(ctl, table_id, entry, 1, 1), EINVAL);\n+\n \tnew_entry = table_entry_duplicate(ctl, table_id, entry, 1, 1);\n \tCHECK(new_entry, ENOMEM);\n \n@@ -1095,6 +1102,9 @@ rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,\n \ttable_id = table - ctl->tables;\n \tCHECK(!table->info.default_action_is_const, EINVAL);\n \n+\tCHECK(entry, EINVAL);\n+\tCHECK(!table_entry_check(ctl, table_id, entry, 0, 1), EINVAL);\n+\n \tnew_entry = table_entry_duplicate(ctl, table_id, entry, 0, 1);\n \tCHECK(new_entry, ENOMEM);\n \n",
    "prefixes": [
        "v3",
        "1/5"
    ]
}