Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/95518/?format=api
https://patches.dpdk.org/api/patches/95518/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210707204804.16848-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": "<20210707204804.16848-1-cristian.dumitrescu@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20210707204804.16848-1-cristian.dumitrescu@intel.com", "date": "2021-07-07T20:48:04", "name": "pipeline: add support for LPM lookup", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "0ce1d20a654b472d787a4774991e2607aff9abda", "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/20210707204804.16848-1-cristian.dumitrescu@intel.com/mbox/", "series": [ { "id": 17707, "url": "https://patches.dpdk.org/api/series/17707/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17707", "date": "2021-07-07T20:48:04", "name": "pipeline: add support for LPM lookup", "version": 1, "mbox": "https://patches.dpdk.org/series/17707/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/95518/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/95518/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 69EF7A0C49;\n\tWed, 7 Jul 2021 22:48:09 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1B768413DB;\n\tWed, 7 Jul 2021 22:48:09 +0200 (CEST)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n by mails.dpdk.org (Postfix) with ESMTP id 443F3413B6\n for <dev@dpdk.org>; Wed, 7 Jul 2021 22:48:07 +0200 (CEST)", "from orsmga001.jf.intel.com ([10.7.209.18])\n by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 07 Jul 2021 13:48:06 -0700", "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com) ([10.237.223.107])\n by orsmga001.jf.intel.com with ESMTP; 07 Jul 2021 13:48:05 -0700" ], "X-IronPort-AV": [ "E=McAfee;i=\"6200,9189,10037\"; a=\"209202000\"", "E=Sophos;i=\"5.84,221,1620716400\"; d=\"scan'208\";a=\"209202000\"", "E=Sophos;i=\"5.84,221,1620716400\"; d=\"scan'208\";a=\"491845515\"" ], "X-ExtLoop1": "1", "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>", "To": "dev@dpdk.org", "Cc": "Churchill Khangar <churchill.khangar@intel.com>", "Date": "Wed, 7 Jul 2021 21:48:04 +0100", "Message-Id": "<20210707204804.16848-1-cristian.dumitrescu@intel.com>", "X-Mailer": "git-send-email 2.17.1", "Subject": "[dpdk-dev] [PATCH] pipeline: add support for LPM lookup", "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": "Add support for the Longest Prefix Match (LPM) lookup to the SWX\npipeline.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\nSigned-off-by: Churchill Khangar <churchill.khangar@intel.com>\n---\n lib/pipeline/rte_swx_ctl.c | 99 ++++++++++++++++++++++-----------\n lib/pipeline/rte_swx_pipeline.c | 78 +++++++++-----------------\n 2 files changed, 93 insertions(+), 84 deletions(-)", "diff": "diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c\nindex 4ee47df10..f1480bc27 100644\n--- a/lib/pipeline/rte_swx_ctl.c\n+++ b/lib/pipeline/rte_swx_ctl.c\n@@ -218,9 +218,6 @@ table_params_get(struct rte_swx_ctl_pipeline *ctl, uint32_t table_id)\n \n \t\tif (n_match_fields_em == table->info.n_match_fields)\n \t\t\tmatch_type = RTE_SWX_TABLE_MATCH_EXACT;\n-\t\telse if ((n_match_fields_em == table->info.n_match_fields - 1) &&\n-\t\t\t (last->match_type == RTE_SWX_TABLE_MATCH_LPM))\n-\t\t\tmatch_type = RTE_SWX_TABLE_MATCH_LPM;\n \n \t\t/* key_offset. */\n \t\tkey_offset = first->offset / 8;\n@@ -347,35 +344,15 @@ table_entry_check(struct rte_swx_ctl_pipeline *ctl,\n \n \tCHECK(entry, EINVAL);\n \n-\tif (key_check) {\n-\t\tif (table->is_stub) {\n-\t\t\t/* key. */\n-\t\t\tCHECK(!entry->key, EINVAL);\n-\n-\t\t\t/* key_mask. */\n-\t\t\tCHECK(!entry->key_mask, EINVAL);\n-\t\t} else {\n-\t\t\t/* key. */\n-\t\t\tCHECK(entry->key, EINVAL);\n-\n-\t\t\t/* key_mask. */\n-\t\t\tswitch (table->params.match_type) {\n-\t\t\tcase RTE_SWX_TABLE_MATCH_WILDCARD:\n-\t\t\t\tbreak;\n-\n-\t\t\tcase RTE_SWX_TABLE_MATCH_LPM:\n-\t\t\t\t/* TBD Check that key mask is prefix. */\n-\t\t\t\tbreak;\n-\n-\t\t\tcase RTE_SWX_TABLE_MATCH_EXACT:\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+\tif (key_check && !table->is_stub) {\n+\t\t/* key. */\n+\t\tCHECK(entry->key, EINVAL);\n \n-\t\t\tdefault:\n-\t\t\t\tCHECK(0, EINVAL);\n-\t\t\t}\n+\t\t/* key_mask. */\n+\t\tif (table->params.match_type == RTE_SWX_TABLE_MATCH_EXACT) {\n+\t\t\tstatus = table_entry_key_check_em(table, entry);\n+\t\t\tif (status)\n+\t\t\t\treturn status;\n \t\t}\n \t}\n \n@@ -2207,6 +2184,45 @@ rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl)\n \t\tselector_abort(ctl, i);\n }\n \n+static int\n+mask_to_prefix(uint64_t mask, uint32_t mask_length, uint32_t *prefix_length)\n+{\n+\tuint32_t n_trailing_zeros = 0, n_ones = 0, i;\n+\n+\tif (!mask) {\n+\t\t*prefix_length = 0;\n+\t\treturn 0;\n+\t}\n+\n+\t/* Count trailing zero bits. */\n+\tfor (i = 0; i < 64; i++) {\n+\t\tif (mask & (1LLU << i))\n+\t\t\tbreak;\n+\n+\t\tn_trailing_zeros++;\n+\t}\n+\n+\t/* Count the one bits that follow. */\n+\tfor ( ; i < 64; i++) {\n+\t\tif (!(mask & (1LLU << i)))\n+\t\t\tbreak;\n+\n+\t\tn_ones++;\n+\t}\n+\n+\t/* Check that no more one bits are present */\n+\tfor ( ; i < 64; i++)\n+\t\tif (mask & (1LLU << i))\n+\t\t\treturn -EINVAL;\n+\n+\t/* Check that the input mask is a prefix or the right length. */\n+\tif (n_ones + n_trailing_zeros != mask_length)\n+\t\treturn -EINVAL;\n+\n+\t*prefix_length = n_ones;\n+\treturn 0;\n+}\n+\n static int\n token_is_comment(const char *token)\n {\n@@ -2231,8 +2247,8 @@ rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,\n \tstruct action *action;\n \tstruct rte_swx_table_entry *entry = NULL;\n \tchar *s0 = NULL, *s;\n-\tuint32_t n_tokens = 0, arg_offset = 0, i;\n-\tint blank_or_comment = 0;\n+\tuint32_t n_tokens = 0, arg_offset = 0, lpm_prefix_length_max = 0, lpm_prefix_length = 0, i;\n+\tint lpm = 0, blank_or_comment = 0;\n \n \t/* Check input arguments. */\n \tif (!ctl)\n@@ -2307,6 +2323,19 @@ rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,\n \t\t\tif (mf_mask[0])\n \t\t\t\tgoto error;\n \n+\t\t\t/* LPM. */\n+\t\t\tif (mf->match_type == RTE_SWX_TABLE_MATCH_LPM) {\n+\t\t\t\tint status;\n+\n+\t\t\t\tlpm = 1;\n+\n+\t\t\t\tlpm_prefix_length_max = mf->n_bits;\n+\n+\t\t\t\tstatus = mask_to_prefix(mask, mf->n_bits, &lpm_prefix_length);\n+\t\t\t\tif (status)\n+\t\t\t\t\tgoto error;\n+\t\t\t}\n+\n \t\t\t/* Endianness conversion. */\n \t\t\tif (mf->is_header)\n \t\t\t\tmask = field_hton(mask, mf->n_bits);\n@@ -2361,6 +2390,10 @@ rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,\n \t\tn_tokens -= 2;\n \t}\n \n+\t/* LPM. */\n+\tif (lpm)\n+\t\tentry->key_priority = lpm_prefix_length_max - lpm_prefix_length;\n+\n \t/*\n \t * Action.\n \t */\ndiff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c\nindex 22c860f28..85db45d48 100644\n--- a/lib/pipeline/rte_swx_pipeline.c\n+++ b/lib/pipeline/rte_swx_pipeline.c\n@@ -9199,37 +9199,42 @@ rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p,\n \treturn 0;\n }\n \n-static enum rte_swx_table_match_type\n+static int\n table_match_type_resolve(struct rte_swx_match_field_params *fields,\n \t\t\t uint32_t n_fields,\n-\t\t\t uint32_t max_offset_field_id)\n+\t\t\t enum rte_swx_table_match_type *match_type)\n {\n-\tuint32_t n_fields_em = 0, i;\n+\tuint32_t n_fields_em = 0, n_fields_lpm = 0, i;\n+\n+\tfor (i = 0; i < n_fields; i++) {\n+\t\tstruct rte_swx_match_field_params *f = &fields[i];\n \n-\tfor (i = 0; i < n_fields; i++)\n-\t\tif (fields[i].match_type == RTE_SWX_TABLE_MATCH_EXACT)\n+\t\tif (f->match_type == RTE_SWX_TABLE_MATCH_EXACT)\n \t\t\tn_fields_em++;\n \n-\tif (n_fields_em == n_fields)\n-\t\treturn RTE_SWX_TABLE_MATCH_EXACT;\n+\t\tif (f->match_type == RTE_SWX_TABLE_MATCH_LPM)\n+\t\t\tn_fields_lpm++;\n+\t}\n+\n+\tif ((n_fields_lpm > 1) ||\n+\t (n_fields_lpm && (n_fields_em != n_fields - 1)))\n+\t\treturn -EINVAL;\n \n-\tif ((n_fields_em == n_fields - 1) &&\n-\t (fields[max_offset_field_id].match_type == RTE_SWX_TABLE_MATCH_LPM))\n-\t\treturn RTE_SWX_TABLE_MATCH_LPM;\n+\t*match_type = (n_fields_em == n_fields) ?\n+\t\t RTE_SWX_TABLE_MATCH_EXACT :\n+\t\t RTE_SWX_TABLE_MATCH_WILDCARD;\n \n-\treturn RTE_SWX_TABLE_MATCH_WILDCARD;\n+\treturn 0;\n }\n \n static int\n table_match_fields_check(struct rte_swx_pipeline *p,\n \t\t\t struct rte_swx_pipeline_table_params *params,\n-\t\t\t struct header **header,\n-\t\t\t uint32_t *min_offset_field_id,\n-\t\t\t uint32_t *max_offset_field_id)\n+\t\t\t struct header **header)\n {\n \tstruct header *h0 = NULL;\n \tstruct field *hf, *mf;\n-\tuint32_t *offset = NULL, min_offset, max_offset, min_offset_pos, max_offset_pos, i;\n+\tuint32_t *offset = NULL, i;\n \tint status = 0;\n \n \t/* Return if no match fields. */\n@@ -9293,34 +9298,10 @@ table_match_fields_check(struct rte_swx_pipeline *p,\n \t\t\t}\n \t}\n \n-\t/* Find the min and max offset fields. */\n-\tmin_offset = offset[0];\n-\tmax_offset = offset[0];\n-\tmin_offset_pos = 0;\n-\tmax_offset_pos = 0;\n-\n-\tfor (i = 1; i < params->n_fields; i++) {\n-\t\tif (offset[i] < min_offset) {\n-\t\t\tmin_offset = offset[i];\n-\t\t\tmin_offset_pos = i;\n-\t\t}\n-\n-\t\tif (offset[i] > max_offset) {\n-\t\t\tmax_offset = offset[i];\n-\t\t\tmax_offset_pos = i;\n-\t\t}\n-\t}\n-\n \t/* Return. */\n \tif (header)\n \t\t*header = h0;\n \n-\tif (min_offset_field_id)\n-\t\t*min_offset_field_id = min_offset_pos;\n-\n-\tif (max_offset_field_id)\n-\t\t*max_offset_field_id = max_offset_pos;\n-\n end:\n \tfree(offset);\n \treturn status;\n@@ -9338,7 +9319,7 @@ rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,\n \tstruct table *t;\n \tstruct action *default_action;\n \tstruct header *header = NULL;\n-\tuint32_t action_data_size_max = 0, min_offset_field_id = 0, max_offset_field_id = 0, i;\n+\tuint32_t action_data_size_max = 0, i;\n \tint status = 0;\n \n \tCHECK(p, EINVAL);\n@@ -9350,11 +9331,7 @@ rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,\n \tCHECK(params, EINVAL);\n \n \t/* Match checks. */\n-\tstatus = table_match_fields_check(p,\n-\t\t\t\t\t params,\n-\t\t\t\t\t &header,\n-\t\t\t\t\t &min_offset_field_id,\n-\t\t\t\t\t &max_offset_field_id);\n+\tstatus = table_match_fields_check(p, params, &header);\n \tif (status)\n \t\treturn status;\n \n@@ -9393,12 +9370,11 @@ rte_swx_pipeline_table_config(struct rte_swx_pipeline *p,\n \tif (params->n_fields) {\n \t\tenum rte_swx_table_match_type match_type;\n \n-\t\tmatch_type = table_match_type_resolve(params->fields,\n-\t\t\t\t\t\t params->n_fields,\n-\t\t\t\t\t\t max_offset_field_id);\n-\t\ttype = table_type_resolve(p,\n-\t\t\t\t\t recommended_table_type_name,\n-\t\t\t\t\t match_type);\n+\t\tstatus = table_match_type_resolve(params->fields, params->n_fields, &match_type);\n+\t\tif (status)\n+\t\t\treturn status;\n+\n+\t\ttype = table_type_resolve(p, recommended_table_type_name, match_type);\n \t\tCHECK(type, EINVAL);\n \t} else {\n \t\ttype = NULL;\n", "prefixes": [] }{ "id": 95518, "url": "