get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 75090,
    "url": "http://patches.dpdk.org/api/patches/75090/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1596166458-150683-3-git-send-email-suanmingm@mellanox.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": "<1596166458-150683-3-git-send-email-suanmingm@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1596166458-150683-3-git-send-email-suanmingm@mellanox.com",
    "date": "2020-07-31T03:34:18",
    "name": "[2/2] net/mlx5: manage modify actions with hashed list",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "7cc3b048d12e39aa882db0967f1cb2fe86d6faa4",
    "submitter": {
        "id": 1358,
        "url": "http://patches.dpdk.org/api/people/1358/?format=api",
        "name": "Suanming Mou",
        "email": "suanmingm@mellanox.com"
    },
    "delegate": {
        "id": 3268,
        "url": "http://patches.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1596166458-150683-3-git-send-email-suanmingm@mellanox.com/mbox/",
    "series": [
        {
            "id": 11428,
            "url": "http://patches.dpdk.org/api/series/11428/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=11428",
            "date": "2020-07-31T03:34:16",
            "name": "net/mlx5: manage modify actions with hashed list",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/11428/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/75090/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/75090/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 36750A052B;\n\tFri, 31 Jul 2020 05:34:45 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 144A01C030;\n\tFri, 31 Jul 2020 05:34:33 +0200 (CEST)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [94.188.199.2])\n by dpdk.org (Postfix) with ESMTP id 22CDF1BFFD\n for <dev@dpdk.org>; Fri, 31 Jul 2020 05:34:27 +0200 (CEST)"
        ],
        "From": "Suanming Mou <suanmingm@mellanox.com>",
        "To": "viacheslavo@mellanox.com,\n\tmatan@mellanox.com",
        "Cc": "rasland@mellanox.com,\n\tdev@dpdk.org",
        "Date": "Fri, 31 Jul 2020 11:34:18 +0800",
        "Message-Id": "<1596166458-150683-3-git-send-email-suanmingm@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1596166458-150683-1-git-send-email-suanmingm@mellanox.com>",
        "References": "<1596166458-150683-1-git-send-email-suanmingm@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH 2/2] net/mlx5: manage modify actions with hashed\n\tlist",
        "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://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": "To manage header modify actions mlx5 PMD used the single linked list and\nlookup and insertion operations took too long times if there were millions\nof objects and this impacted the flow insertion/deletion rate.\n\nIn order to optimize the performance the hashed list is engaged. The list\nimplementation is updated to support non-unique keys with few collisions.\n\nSigned-off-by: Suanming Mou <suanmingm@mellanox.com>\nAcked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>\n---\n drivers/net/mlx5/linux/mlx5_os.c | 15 +++++++\n drivers/net/mlx5/mlx5.h          |  2 +-\n drivers/net/mlx5/mlx5_defs.h     |  3 ++\n drivers/net/mlx5/mlx5_flow.h     | 13 +++++-\n drivers/net/mlx5/mlx5_flow_dv.c  | 95 ++++++++++++++++++++++++++++++++--------\n 5 files changed, 108 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex 69123e1..db955ae 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -241,6 +241,13 @@\n \t\terr = ENOMEM;\n \t\tgoto error;\n \t}\n+\tsnprintf(s, sizeof(s), \"%s_hdr_modify\", sh->ibdev_name);\n+\tsh->modify_cmds = mlx5_hlist_create(s, MLX5_FLOW_HDR_MODIFY_HTABLE_SZ);\n+\tif (!sh->modify_cmds) {\n+\t\tDRV_LOG(ERR, \"hdr modify hash creation failed\");\n+\t\terr = ENOMEM;\n+\t\tgoto error;\n+\t}\n #ifdef HAVE_MLX5DV_DR\n \tvoid *domain;\n \n@@ -314,6 +321,10 @@\n \t\tmlx5_glue->destroy_flow_action(sh->pop_vlan_action);\n \t\tsh->pop_vlan_action = NULL;\n \t}\n+\tif (sh->modify_cmds) {\n+\t\tmlx5_hlist_destroy(sh->modify_cmds, NULL, NULL);\n+\t\tsh->modify_cmds = NULL;\n+\t}\n \tif (sh->tag_table) {\n \t\t/* tags should be destroyed with flow before. */\n \t\tmlx5_hlist_destroy(sh->tag_table, NULL, NULL);\n@@ -367,6 +378,10 @@\n \t}\n \tpthread_mutex_destroy(&sh->dv_mutex);\n #endif /* HAVE_MLX5DV_DR */\n+\tif (sh->modify_cmds) {\n+\t\tmlx5_hlist_destroy(sh->modify_cmds, NULL, NULL);\n+\t\tsh->modify_cmds = NULL;\n+\t}\n \tif (sh->tag_table) {\n \t\t/* tags should be destroyed with flow before. */\n \t\tmlx5_hlist_destroy(sh->tag_table, NULL, NULL);\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 78d6eb7..1880a82 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -638,7 +638,7 @@ struct mlx5_dev_ctx_shared {\n \tvoid *esw_drop_action; /* Pointer to DR E-Switch drop action. */\n \tvoid *pop_vlan_action; /* Pointer to DR pop VLAN action. */\n \tuint32_t encaps_decaps; /* Encap/decap action indexed memory list. */\n-\tLIST_HEAD(modify_cmd, mlx5_flow_dv_modify_hdr_resource) modify_cmds;\n+\tstruct mlx5_hlist *modify_cmds;\n \tstruct mlx5_hlist *tag_table;\n \tuint32_t port_id_action_list; /* List of port ID actions. */\n \tuint32_t push_vlan_action_list; /* List of push VLAN actions. */\ndiff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h\nindex e5f7acc..4be33d6 100644\n--- a/drivers/net/mlx5/mlx5_defs.h\n+++ b/drivers/net/mlx5/mlx5_defs.h\n@@ -187,6 +187,9 @@\n #define MLX5_FLOW_MREG_HNAME \"MARK_COPY_TABLE\"\n #define MLX5_DEFAULT_COPY_ID UINT32_MAX\n \n+/* Size of the simple hash table for header modify table. */\n+#define MLX5_FLOW_HDR_MODIFY_HTABLE_SZ (1 << 16)\n+\n /* Hairpin TX/RX queue configuration parameters. */\n #define MLX5_HAIRPIN_QUEUE_STRIDE 6\n #define MLX5_HAIRPIN_JUMBO_LOG_SIZE (14 + 2)\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 66caefc..92301e4 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -427,7 +427,7 @@ struct mlx5_flow_dv_tag_resource {\n \n /* Modify resource structure */\n struct mlx5_flow_dv_modify_hdr_resource {\n-\tLIST_ENTRY(mlx5_flow_dv_modify_hdr_resource) next;\n+\tstruct mlx5_hlist_entry entry;\n \t/* Pointer to next element. */\n \trte_atomic32_t refcnt; /**< Reference counter. */\n \tvoid *action;\n@@ -439,6 +439,17 @@ struct mlx5_flow_dv_modify_hdr_resource {\n \t/**< Modification actions. */\n };\n \n+/* Modify resource key of the hash organization. */\n+union mlx5_flow_modify_hdr_key {\n+\tstruct {\n+\t\tuint32_t ft_type:8;\t/**< Flow table type, Rx or Tx. */\n+\t\tuint32_t actions_num:5;\t/**< Number of modification actions. */\n+\t\tuint32_t group:19;\t/**< Flow group id. */\n+\t\tuint32_t cksum;\t\t/**< Actions check sum. */\n+\t};\n+\tuint64_t v64;\t\t\t/**< full 64bits value of key */\n+};\n+\n /* Jump action resource structure. */\n struct mlx5_flow_dv_jump_tbl_resource {\n \trte_atomic32_t refcnt; /**< Reference counter. */\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex 5339980..dd35959 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -3958,6 +3958,40 @@ struct field_modify_info modify_tcp[] = {\n }\n \n /**\n+ * Match modify-header resource.\n+ *\n+ * @param entry\n+ *   Pointer to exist resource entry object.\n+ * @param ctx\n+ *   Pointer to new modify-header resource.\n+ *\n+ * @return\n+ *   0 on matching, -1 otherwise.\n+ */\n+static int\n+flow_dv_modify_hdr_resource_match(struct mlx5_hlist_entry *entry, void *ctx)\n+{\n+\tstruct mlx5_flow_dv_modify_hdr_resource *resource;\n+\tstruct mlx5_flow_dv_modify_hdr_resource *cache_resource;\n+\tuint32_t actions_len;\n+\n+\tresource = (struct mlx5_flow_dv_modify_hdr_resource *)ctx;\n+\tcache_resource = container_of(entry,\n+\t\t\t\t      struct mlx5_flow_dv_modify_hdr_resource,\n+\t\t\t\t      entry);\n+\tactions_len = resource->actions_num * sizeof(resource->actions[0]);\n+\tif (resource->entry.key == cache_resource->entry.key &&\n+\t    resource->ft_type == cache_resource->ft_type &&\n+\t    resource->actions_num == cache_resource->actions_num &&\n+\t    resource->flags == cache_resource->flags &&\n+\t    !memcmp((const void *)resource->actions,\n+\t\t    (const void *)cache_resource->actions,\n+\t\t    actions_len))\n+\t\treturn 0;\n+\treturn -1;\n+}\n+\n+/**\n  * Find existing modify-header resource or create and register a new one.\n  *\n  * @param dev[in, out]\n@@ -3984,6 +4018,15 @@ struct field_modify_info modify_tcp[] = {\n \tstruct mlx5_flow_dv_modify_hdr_resource *cache_resource;\n \tstruct mlx5dv_dr_domain *ns;\n \tuint32_t actions_len;\n+\tstruct mlx5_hlist_entry *entry;\n+\tunion mlx5_flow_modify_hdr_key hdr_mod_key = {\n+\t\t{\n+\t\t\t.ft_type = resource->ft_type,\n+\t\t\t.actions_num = resource->actions_num,\n+\t\t\t.group = dev_flow->dv.group,\n+\t\t\t.cksum = 0,\n+\t\t}\n+\t};\n \tint ret;\n \n \tresource->flags = dev_flow->dv.group ? 0 :\n@@ -4001,20 +4044,22 @@ struct field_modify_info modify_tcp[] = {\n \t\tns = sh->rx_domain;\n \t/* Lookup a matching resource from cache. */\n \tactions_len = resource->actions_num * sizeof(resource->actions[0]);\n-\tLIST_FOREACH(cache_resource, &sh->modify_cmds, next) {\n-\t\tif (resource->ft_type == cache_resource->ft_type &&\n-\t\t    resource->actions_num == cache_resource->actions_num &&\n-\t\t    resource->flags == cache_resource->flags &&\n-\t\t    !memcmp((const void *)resource->actions,\n-\t\t\t    (const void *)cache_resource->actions,\n-\t\t\t    actions_len)) {\n-\t\t\tDRV_LOG(DEBUG, \"modify-header resource %p: refcnt %d++\",\n-\t\t\t\t(void *)cache_resource,\n-\t\t\t\trte_atomic32_read(&cache_resource->refcnt));\n-\t\t\trte_atomic32_inc(&cache_resource->refcnt);\n-\t\t\tdev_flow->handle->dvh.modify_hdr = cache_resource;\n-\t\t\treturn 0;\n-\t\t}\n+\thdr_mod_key.cksum = __rte_raw_cksum(resource->actions, actions_len, 0);\n+\tresource->entry.key = hdr_mod_key.v64;\n+\tentry = mlx5_hlist_lookup_ex(sh->modify_cmds, resource->entry.key,\n+\t\t\t\t     flow_dv_modify_hdr_resource_match,\n+\t\t\t\t     (void *)resource);\n+\tif (entry) {\n+\t\tcache_resource = container_of(entry,\n+\t\t\t\t\tstruct mlx5_flow_dv_modify_hdr_resource,\n+\t\t\t\t\tentry);\n+\t\tDRV_LOG(DEBUG, \"modify-header resource %p: refcnt %d++\",\n+\t\t\t(void *)cache_resource,\n+\t\t\trte_atomic32_read(&cache_resource->refcnt));\n+\t\trte_atomic32_inc(&cache_resource->refcnt);\n+\t\tdev_flow->handle->dvh.modify_hdr = cache_resource;\n+\t\treturn 0;\n+\n \t}\n \t/* Register new modify-header resource. */\n \tcache_resource = mlx5_malloc(MLX5_MEM_ZERO,\n@@ -4037,7 +4082,16 @@ struct field_modify_info modify_tcp[] = {\n \t}\n \trte_atomic32_init(&cache_resource->refcnt);\n \trte_atomic32_inc(&cache_resource->refcnt);\n-\tLIST_INSERT_HEAD(&sh->modify_cmds, cache_resource, next);\n+\tif (mlx5_hlist_insert_ex(sh->modify_cmds, &cache_resource->entry,\n+\t\t\t\t flow_dv_modify_hdr_resource_match,\n+\t\t\t\t (void *)cache_resource)) {\n+\t\tclaim_zero(mlx5_flow_os_destroy_flow_action\n+\t\t\t\t\t\t(cache_resource->action));\n+\t\tmlx5_free(cache_resource);\n+\t\treturn rte_flow_error_set(error, EEXIST,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t  NULL, \"action exist\");\n+\t}\n \tdev_flow->handle->dvh.modify_hdr = cache_resource;\n \tDRV_LOG(DEBUG, \"new modify-header resource %p: refcnt %d++\",\n \t\t(void *)cache_resource,\n@@ -9122,6 +9176,8 @@ struct field_modify_info modify_tcp[] = {\n /**\n  * Release a modify-header resource.\n  *\n+ * @param dev\n+ *   Pointer to Ethernet device.\n  * @param handle\n  *   Pointer to mlx5_flow_handle.\n  *\n@@ -9129,8 +9185,10 @@ struct field_modify_info modify_tcp[] = {\n  *   1 while a reference on it exists, 0 when freed.\n  */\n static int\n-flow_dv_modify_hdr_resource_release(struct mlx5_flow_handle *handle)\n+flow_dv_modify_hdr_resource_release(struct rte_eth_dev *dev,\n+\t\t\t\t    struct mlx5_flow_handle *handle)\n {\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n \tstruct mlx5_flow_dv_modify_hdr_resource *cache_resource =\n \t\t\t\t\t\t\thandle->dvh.modify_hdr;\n \n@@ -9141,7 +9199,8 @@ struct field_modify_info modify_tcp[] = {\n \tif (rte_atomic32_dec_and_test(&cache_resource->refcnt)) {\n \t\tclaim_zero(mlx5_flow_os_destroy_flow_action\n \t\t\t\t\t\t(cache_resource->action));\n-\t\tLIST_REMOVE(cache_resource, next);\n+\t\tmlx5_hlist_remove(priv->sh->modify_cmds,\n+\t\t\t\t  &cache_resource->entry);\n \t\tmlx5_free(cache_resource);\n \t\tDRV_LOG(DEBUG, \"modify-header resource %p: removed\",\n \t\t\t(void *)cache_resource);\n@@ -9351,7 +9410,7 @@ struct field_modify_info modify_tcp[] = {\n \t\tif (dev_handle->dvh.rix_encap_decap)\n \t\t\tflow_dv_encap_decap_resource_release(dev, dev_handle);\n \t\tif (dev_handle->dvh.modify_hdr)\n-\t\t\tflow_dv_modify_hdr_resource_release(dev_handle);\n+\t\t\tflow_dv_modify_hdr_resource_release(dev, dev_handle);\n \t\tif (dev_handle->dvh.rix_push_vlan)\n \t\t\tflow_dv_push_vlan_action_resource_release(dev,\n \t\t\t\t\t\t\t\t  dev_handle);\n",
    "prefixes": [
        "2/2"
    ]
}