Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/81884/?format=api
http://patches.dpdk.org/api/patches/81884/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1603437295-119083-17-git-send-email-suanmingm@nvidia.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": "<1603437295-119083-17-git-send-email-suanmingm@nvidia.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1603437295-119083-17-git-send-email-suanmingm@nvidia.com", "date": "2020-10-23T07:14:46", "name": "[v2,16/25] net/mlx5: make flow modify action list thread safe", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "9ff97375dc217a94d6dcb3ce4f90160cc05c0d94", "submitter": { "id": 1887, "url": "http://patches.dpdk.org/api/people/1887/?format=api", "name": "Suanming Mou", "email": "suanmingm@nvidia.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/1603437295-119083-17-git-send-email-suanmingm@nvidia.com/mbox/", "series": [ { "id": 13250, "url": "http://patches.dpdk.org/api/series/13250/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=13250", "date": "2020-10-23T07:14:30", "name": "*net/mlx5: support multiple-thread flow operations", "version": 2, "mbox": "http://patches.dpdk.org/series/13250/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/81884/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/81884/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 663C5A04DE;\n\tFri, 23 Oct 2020 09:21:26 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 0EB6C5AA7;\n\tFri, 23 Oct 2020 09:17:05 +0200 (CEST)", "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 73C8372F4\n for <dev@dpdk.org>; Fri, 23 Oct 2020 09:15:39 +0200 (CEST)", "from Internal Mail-Server by MTLPINE1 (envelope-from\n suanmingm@nvidia.com) with SMTP; 23 Oct 2020 10:15:33 +0300", "from nvidia.com (mtbc-r640-04.mtbc.labs.mlnx [10.75.70.9])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09N7F2LZ026736;\n Fri, 23 Oct 2020 10:15:31 +0300" ], "From": "Suanming Mou <suanmingm@nvidia.com>", "To": "Matan Azrad <matan@nvidia.com>, Shahaf Shuler <shahafs@nvidia.com>,\n Viacheslav Ovsiienko <viacheslavo@nvidia.com>", "Cc": "dev@dpdk.org, Xueming Li <xuemingl@nvidia.com>", "Date": "Fri, 23 Oct 2020 15:14:46 +0800", "Message-Id": "<1603437295-119083-17-git-send-email-suanmingm@nvidia.com>", "X-Mailer": "git-send-email 1.8.3.1", "In-Reply-To": "<1603437295-119083-1-git-send-email-suanmingm@nvidia.com>", "References": "<1601984948-313027-1-git-send-email-suanmingm@nvidia.com>\n <1603437295-119083-1-git-send-email-suanmingm@nvidia.com>", "Subject": "[dpdk-dev] [PATCH v2 16/25] net/mlx5: make flow modify action list\n\tthread safe", "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": "From: Xueming Li <xuemingl@nvidia.com>\n\nTo support multi-thread flow insertion, this patch updates flow modify\naction list to use thread safe hash list with write-most mode.\n\nSigned-off-by: Xueming Li <xuemingl@nvidia.com>\nAcked-by: Matan Azrad <matan@nvidia.com>\n---\n drivers/net/mlx5/linux/mlx5_os.c | 7 +-\n drivers/net/mlx5/mlx5_flow.h | 14 ++-\n drivers/net/mlx5/mlx5_flow_dv.c | 194 +++++++++++++++++----------------------\n 3 files changed, 102 insertions(+), 113 deletions(-)", "diff": "diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex 21a9db6..822edd3 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -250,12 +250,17 @@\n \tsh->tag_table->ctx = sh;\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-\t\t\t\t\t 0, 0, NULL, NULL, NULL);\n+\t\t\t\t\t 0, MLX5_HLIST_WRITE_MOST |\n+\t\t\t\t\t MLX5_HLIST_DIRECT_KEY,\n+\t\t\t\t\t flow_dv_modify_create_cb,\n+\t\t\t\t\t flow_dv_modify_match_cb,\n+\t\t\t\t\t flow_dv_modify_remove_cb);\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+\tsh->modify_cmds->ctx = sh;\n \tsnprintf(s, sizeof(s), \"%s_encaps_decaps\", sh->ibdev_name);\n \tsh->encaps_decaps = mlx5_hlist_create(s,\n \t\t\t\t\t MLX5_FLOW_ENCAP_DECAP_HTABLE_SZ,\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 87d7fe7..45b9b05 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -464,10 +464,8 @@ struct mlx5_flow_dv_tag_resource {\n /* Modify resource structure */\n struct mlx5_flow_dv_modify_hdr_resource {\n \tstruct mlx5_hlist_entry entry;\n-\t/* Pointer to next element. */\n-\trte_atomic32_t refcnt; /**< Reference counter. */\n-\tvoid *action;\n-\t/**< Modify header action object. */\n+\tvoid *action; /**< Modify header action object. */\n+\t/* Key area for hash list matching: */\n \tuint8_t ft_type; /**< Flow table type, Rx or Tx. */\n \tuint32_t actions_num; /**< Number of modification actions. */\n \tuint64_t flags; /**< Flags for RDMA API. */\n@@ -1171,4 +1169,12 @@ struct mlx5_hlist_entry *flow_dv_tag_create_cb(struct mlx5_hlist *list,\n void flow_dv_tag_remove_cb(struct mlx5_hlist *list,\n \t\t\t struct mlx5_hlist_entry *entry);\n \n+int flow_dv_modify_match_cb(struct mlx5_hlist *list,\n+\t\t\t struct mlx5_hlist_entry *entry,\n+\t\t\t uint64_t key, void *cb_ctx);\n+struct mlx5_hlist_entry *flow_dv_modify_create_cb(struct mlx5_hlist *list,\n+\t\t\t\t\t\t uint64_t key, void *ctx);\n+void flow_dv_modify_remove_cb(struct mlx5_hlist *list,\n+\t\t\t struct mlx5_hlist_entry *entry);\n+\n #endif /* RTE_PMD_MLX5_FLOW_H_ */\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex 2d4c8dd..7e9f9f9 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -4204,35 +4204,75 @@ struct field_modify_info modify_tcp[] = {\n /**\n * Match modify-header resource.\n *\n+ * @param list\n+ * Pointer to the hash list.\n * @param entry\n * Pointer to exist resource entry object.\n+ * @param key\n+ * Key of the new entry.\n * @param ctx\n * Pointer to new modify-header resource.\n *\n * @return\n- * 0 on matching, -1 otherwise.\n+ * 0 on matching, non-zero otherwise.\n */\n-static int\n-flow_dv_modify_hdr_resource_match(struct mlx5_hlist_entry *entry, void *ctx)\n+int\n+flow_dv_modify_match_cb(struct mlx5_hlist *list __rte_unused,\n+\t\t\tstruct mlx5_hlist_entry *entry,\n+\t\t\tuint64_t key __rte_unused, void *cb_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+\tstruct mlx5_flow_cb_ctx *ctx = cb_ctx;\n+\tstruct mlx5_flow_dv_modify_hdr_resource *ref = ctx->data;\n+\tstruct mlx5_flow_dv_modify_hdr_resource *resource =\n+\t\t\tcontainer_of(entry, typeof(*resource), entry);\n+\tuint32_t key_len = sizeof(*ref) - offsetof(typeof(*ref), ft_type);\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+\tkey_len += ref->actions_num * sizeof(ref->actions[0]);\n+\treturn ref->actions_num != resource->actions_num ||\n+\t memcmp(&ref->ft_type, &resource->ft_type, key_len);\n+}\n+\n+struct mlx5_hlist_entry *\n+flow_dv_modify_create_cb(struct mlx5_hlist *list, uint64_t key __rte_unused,\n+\t\t\t void *cb_ctx)\n+{\n+\tstruct mlx5_dev_ctx_shared *sh = list->ctx;\n+\tstruct mlx5_flow_cb_ctx *ctx = cb_ctx;\n+\tstruct mlx5dv_dr_domain *ns;\n+\tstruct mlx5_flow_dv_modify_hdr_resource *entry;\n+\tstruct mlx5_flow_dv_modify_hdr_resource *ref = ctx->data;\n+\tint ret;\n+\tuint32_t data_len = ref->actions_num * sizeof(ref->actions[0]);\n+\tuint32_t key_len = sizeof(*ref) - offsetof(typeof(*ref), ft_type);\n+\n+\tentry = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*entry) + data_len, 0,\n+\t\t\t SOCKET_ID_ANY);\n+\tif (!entry) {\n+\t\trte_flow_error_set(ctx->error, ENOMEM,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t \"cannot allocate resource memory\");\n+\t\treturn NULL;\n+\t}\n+\trte_memcpy(&entry->ft_type,\n+\t\t RTE_PTR_ADD(ref, offsetof(typeof(*ref), ft_type)),\n+\t\t key_len + data_len);\n+\tif (entry->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)\n+\t\tns = sh->fdb_domain;\n+\telse if (entry->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_TX)\n+\t\tns = sh->tx_domain;\n+\telse\n+\t\tns = sh->rx_domain;\n+\tret = mlx5_flow_os_create_flow_action_modify_header\n+\t\t\t\t\t(sh->ctx, ns, entry,\n+\t\t\t\t\t data_len, &entry->action);\n+\tif (ret) {\n+\t\tmlx5_free(entry);\n+\t\trte_flow_error_set(ctx->error, ENOMEM,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t NULL, \"cannot create modification action\");\n+\t\treturn NULL;\n+\t}\n+\treturn &entry->entry;\n }\n \n /**\n@@ -4443,19 +4483,14 @@ struct field_modify_info modify_tcp[] = {\n {\n \tstruct mlx5_priv *priv = dev->data->dev_private;\n \tstruct mlx5_dev_ctx_shared *sh = priv->sh;\n-\tstruct mlx5_flow_dv_modify_hdr_resource *cache_resource;\n-\tstruct mlx5dv_dr_domain *ns;\n-\tuint32_t actions_len;\n+\tuint32_t key_len = sizeof(*resource) -\n+\t\t\t offsetof(typeof(*resource), ft_type) +\n+\t\t\t resource->actions_num * sizeof(resource->actions[0]);\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+\tstruct mlx5_flow_cb_ctx ctx = {\n+\t\t.error = error,\n+\t\t.data = resource,\n \t};\n-\tint ret;\n \n \tresource->flags = dev_flow->dv.group ? 0 :\n \t\t\t MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL;\n@@ -4464,66 +4499,12 @@ struct field_modify_info modify_tcp[] = {\n \t\treturn rte_flow_error_set(error, EOVERFLOW,\n \t\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n \t\t\t\t\t \"too many modify header items\");\n-\tif (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)\n-\t\tns = sh->fdb_domain;\n-\telse if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_TX)\n-\t\tns = sh->tx_domain;\n-\telse\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-\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-\t\t\t\t sizeof(*cache_resource) + actions_len, 0,\n-\t\t\t\t SOCKET_ID_ANY);\n-\tif (!cache_resource)\n-\t\treturn rte_flow_error_set(error, ENOMEM,\n-\t\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n-\t\t\t\t\t \"cannot allocate resource memory\");\n-\t*cache_resource = *resource;\n-\trte_memcpy(cache_resource->actions, resource->actions, actions_len);\n-\tret = mlx5_flow_os_create_flow_action_modify_header\n-\t\t\t\t\t(sh->ctx, ns, cache_resource,\n-\t\t\t\t\t actions_len, &cache_resource->action);\n-\tif (ret) {\n-\t\tmlx5_free(cache_resource);\n-\t\treturn rte_flow_error_set(error, ENOMEM,\n-\t\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n-\t\t\t\t\t NULL, \"cannot create action\");\n-\t}\n-\trte_atomic32_init(&cache_resource->refcnt);\n-\trte_atomic32_inc(&cache_resource->refcnt);\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-\t\trte_atomic32_read(&cache_resource->refcnt));\n+\tresource->entry.key = __rte_raw_cksum(&resource->ft_type, key_len, 0);\n+\tentry = mlx5_hlist_register(sh->modify_cmds, resource->entry.key, &ctx);\n+\tif (!entry)\n+\t\treturn -rte_errno;\n+\tresource = container_of(entry, typeof(*resource), entry);\n+\tdev_flow->handle->dvh.modify_hdr = resource;\n \treturn 0;\n }\n \n@@ -10130,6 +10111,17 @@ struct mlx5_hlist_entry *\n \treturn flow_dv_tbl_resource_release(dev, &tbl_data->tbl);\n }\n \n+void\n+flow_dv_modify_remove_cb(struct mlx5_hlist *list __rte_unused,\n+\t\t\t struct mlx5_hlist_entry *entry)\n+{\n+\tstruct mlx5_flow_dv_modify_hdr_resource *res =\n+\t\tcontainer_of(entry, typeof(*res), entry);\n+\n+\tclaim_zero(mlx5_flow_os_destroy_flow_action(res->action));\n+\tmlx5_free(entry);\n+}\n+\n /**\n * Release a modify-header resource.\n *\n@@ -10146,24 +10138,10 @@ struct mlx5_hlist_entry *\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+\tstruct mlx5_flow_dv_modify_hdr_resource *entry = handle->dvh.modify_hdr;\n \n-\tMLX5_ASSERT(cache_resource->action);\n-\tDRV_LOG(DEBUG, \"modify-header resource %p: refcnt %d--\",\n-\t\t(void *)cache_resource,\n-\t\trte_atomic32_read(&cache_resource->refcnt));\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\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-\t\treturn 0;\n-\t}\n-\treturn 1;\n+\tMLX5_ASSERT(entry->action);\n+\treturn mlx5_hlist_unregister(priv->sh->modify_cmds, &entry->entry);\n }\n \n /**\n", "prefixes": [ "v2", "16/25" ] }{ "id": 81884, "url": "