Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/82564/?format=api
https://patches.dpdk.org/api/patches/82564/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1603875616-272798-26-git-send-email-suanmingm@nvidia.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": "<1603875616-272798-26-git-send-email-suanmingm@nvidia.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1603875616-272798-26-git-send-email-suanmingm@nvidia.com", "date": "2020-10-28T09:00:06", "name": "[v5,25/34] net/mlx5: make port ID action cache thread safe", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "6d1560771d258504e3f68295dd113e6b1e514cd9", "submitter": { "id": 1887, "url": "https://patches.dpdk.org/api/people/1887/?format=api", "name": "Suanming Mou", "email": "suanmingm@nvidia.com" }, "delegate": { "id": 3268, "url": "https://patches.dpdk.org/api/users/3268/?format=api", "username": "rasland", "first_name": "Raslan", "last_name": "Darawsheh", "email": "rasland@nvidia.com" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1603875616-272798-26-git-send-email-suanmingm@nvidia.com/mbox/", "series": [ { "id": 13411, "url": "https://patches.dpdk.org/api/series/13411/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=13411", "date": "2020-10-28T08:59:42", "name": "net/mlx5: support multiple-thread flow operations", "version": 5, "mbox": "https://patches.dpdk.org/series/13411/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/82564/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/82564/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 51799A04DD;\n\tWed, 28 Oct 2020 10:08:54 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 7B6C3C938;\n\tWed, 28 Oct 2020 10:03:42 +0100 (CET)", "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 3FF9DC6C8\n for <dev@dpdk.org>; Wed, 28 Oct 2020 10:02:20 +0100 (CET)", "from Internal Mail-Server by MTLPINE1 (envelope-from\n suanmingm@nvidia.com) with SMTP; 28 Oct 2020 11:01:27 +0200", "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 09S90JmP024495;\n Wed, 28 Oct 2020 11:01:25 +0200" ], "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, rasland@nvidia.com, Xueming Li <xuemingl@nvidia.com>", "Date": "Wed, 28 Oct 2020 17:00:06 +0800", "Message-Id": "<1603875616-272798-26-git-send-email-suanmingm@nvidia.com>", "X-Mailer": "git-send-email 1.8.3.1", "In-Reply-To": "<1603875616-272798-1-git-send-email-suanmingm@nvidia.com>", "References": "<1601984948-313027-1-git-send-email-suanmingm@nvidia.com>\n <1603875616-272798-1-git-send-email-suanmingm@nvidia.com>", "Subject": "[dpdk-dev] [PATCH v5 25/34] net/mlx5: make port ID action cache\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 convert port id\naction cache list to thread safe cache list.\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.h | 2 +-\n drivers/net/mlx5/mlx5_flow.h | 15 ++--\n drivers/net/mlx5/mlx5_flow_dv.c | 143 +++++++++++++++++++++------------------\n 4 files changed, 94 insertions(+), 73 deletions(-)", "diff": "diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex 10fc7c5..3d2bf57 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -236,6 +236,12 @@\n \t\tgoto error;\n \t/* The resources below are only valid with DV support. */\n #ifdef HAVE_IBV_FLOW_DV_SUPPORT\n+\t/* Init port id action cache list. */\n+\tsnprintf(s, sizeof(s), \"%s_port_id_action_cache\", sh->ibdev_name);\n+\tmlx5_cache_list_init(&sh->port_id_action_list, s, 0, sh,\n+\t\t\t flow_dv_port_id_create_cb,\n+\t\t\t flow_dv_port_id_match_cb,\n+\t\t\t flow_dv_port_id_remove_cb);\n \t/* Create tags hash list table. */\n \tsnprintf(s, sizeof(s), \"%s_tags\", sh->ibdev_name);\n \tsh->tag_table = mlx5_hlist_create(s, MLX5_TAGS_HLIST_ARRAY_SIZE, 0,\n@@ -431,6 +437,7 @@\n \t\tmlx5_release_tunnel_hub(sh, priv->dev_port);\n \t\tsh->tunnel_hub = NULL;\n \t}\n+\tmlx5_cache_list_destroy(&sh->port_id_action_list);\n \tmlx5_free_table_hash_list(priv);\n }\n \ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex eadb797..1cd42eb 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -659,7 +659,7 @@ struct mlx5_dev_ctx_shared {\n \tstruct mlx5_hlist *encaps_decaps; /* Encap/decap action hash list. */\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+\tstruct mlx5_cache_list port_id_action_list; /* Port ID action cache. */\n \tuint32_t push_vlan_action_list; /* List of push VLAN actions. */\n \tuint32_t sample_action_list; /* List of sample actions. */\n \tuint32_t dest_array_list; /* List of destination array actions. */\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 6c0815a..0e4d47f 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -485,12 +485,10 @@ struct mlx5_flow_dv_jump_tbl_resource {\n \n /* Port ID resource structure. */\n struct mlx5_flow_dv_port_id_action_resource {\n-\tILIST_ENTRY(uint32_t)next;\n-\t/* Pointer to next element. */\n-\tuint32_t refcnt; /**< Reference counter. */\n-\tvoid *action;\n-\t/**< Action object. */\n+\tstruct mlx5_cache_entry entry;\n+\tvoid *action; /**< Action object. */\n \tuint32_t port_id; /**< Port ID value. */\n+\tuint32_t idx; /**< Indexed pool memory index. */\n };\n \n /* Push VLAN action resource structure */\n@@ -1437,4 +1435,11 @@ struct mlx5_cache_entry *flow_dv_matcher_create_cb(struct mlx5_cache_list *list,\n void flow_dv_matcher_remove_cb(struct mlx5_cache_list *list,\n \t\t\t struct mlx5_cache_entry *entry);\n \n+int flow_dv_port_id_match_cb(struct mlx5_cache_list *list,\n+\t\t\t struct mlx5_cache_entry *entry, void *cb_ctx);\n+struct mlx5_cache_entry *flow_dv_port_id_create_cb(struct mlx5_cache_list *list,\n+\t\tstruct mlx5_cache_entry *entry, void *cb_ctx);\n+void flow_dv_port_id_remove_cb(struct mlx5_cache_list *list,\n+\t\t\t struct mlx5_cache_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 1f82b96..e48faf0 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -2962,6 +2962,52 @@ struct mlx5_hlist_entry *\n \treturn 0;\n }\n \n+int\n+flow_dv_port_id_match_cb(struct mlx5_cache_list *list __rte_unused,\n+\t\t\t struct mlx5_cache_entry *entry, void *cb_ctx)\n+{\n+\tstruct mlx5_flow_cb_ctx *ctx = cb_ctx;\n+\tstruct mlx5_flow_dv_port_id_action_resource *ref = ctx->data;\n+\tstruct mlx5_flow_dv_port_id_action_resource *res =\n+\t\t\tcontainer_of(entry, typeof(*res), entry);\n+\n+\treturn ref->port_id != res->port_id;\n+}\n+\n+struct mlx5_cache_entry *\n+flow_dv_port_id_create_cb(struct mlx5_cache_list *list,\n+\t\t\t struct mlx5_cache_entry *entry __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 mlx5_flow_dv_port_id_action_resource *ref = ctx->data;\n+\tstruct mlx5_flow_dv_port_id_action_resource *cache;\n+\tuint32_t idx;\n+\tint ret;\n+\n+\t/* Register new port id action resource. */\n+\tcache = mlx5_ipool_zmalloc(sh->ipool[MLX5_IPOOL_PORT_ID], &idx);\n+\tif (!cache) {\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 port_id action cache memory\");\n+\t\treturn NULL;\n+\t}\n+\t*cache = *ref;\n+\tret = mlx5_flow_os_create_flow_action_dest_port(sh->fdb_domain,\n+\t\t\t\t\t\t\tref->port_id,\n+\t\t\t\t\t\t\t&cache->action);\n+\tif (ret) {\n+\t\tmlx5_ipool_free(sh->ipool[MLX5_IPOOL_PORT_ID], idx);\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 create action\");\n+\t\treturn NULL;\n+\t}\n+\treturn &cache->entry;\n+}\n+\n /**\n * Find existing table port ID resource or create and register a new one.\n *\n@@ -2985,52 +3031,19 @@ struct mlx5_hlist_entry *\n \t\t\t struct rte_flow_error *error)\n {\n \tstruct mlx5_priv *priv = dev->data->dev_private;\n-\tstruct mlx5_dev_ctx_shared *sh = priv->sh;\n-\tstruct mlx5_flow_dv_port_id_action_resource *cache_resource;\n-\tuint32_t idx = 0;\n-\tint ret;\n+\tstruct mlx5_cache_entry *entry;\n+\tstruct mlx5_flow_dv_port_id_action_resource *cache;\n+\tstruct mlx5_flow_cb_ctx ctx = {\n+\t\t.error = error,\n+\t\t.data = resource,\n+\t};\n \n-\t/* Lookup a matching resource from cache. */\n-\tILIST_FOREACH(sh->ipool[MLX5_IPOOL_PORT_ID], sh->port_id_action_list,\n-\t\t idx, cache_resource, next) {\n-\t\tif (resource->port_id == cache_resource->port_id) {\n-\t\t\tDRV_LOG(DEBUG, \"port id action resource resource %p: \"\n-\t\t\t\t\"refcnt %d++\",\n-\t\t\t\t(void *)cache_resource,\n-\t\t\t\t__atomic_load_n(&cache_resource->refcnt,\n-\t\t\t\t\t\t__ATOMIC_RELAXED));\n-\t\t\t__atomic_fetch_add(&cache_resource->refcnt, 1,\n-\t\t\t\t\t __ATOMIC_RELAXED);\n-\t\t\tdev_flow->handle->rix_port_id_action = idx;\n-\t\t\tdev_flow->dv.port_id_action = cache_resource;\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n-\t/* Register new port id action resource. */\n-\tcache_resource = mlx5_ipool_zmalloc(sh->ipool[MLX5_IPOOL_PORT_ID],\n-\t\t\t\t &dev_flow->handle->rix_port_id_action);\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-\tret = mlx5_flow_os_create_flow_action_dest_port\n-\t\t\t\t(priv->sh->fdb_domain, resource->port_id,\n-\t\t\t\t &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-\t__atomic_store_n(&cache_resource->refcnt, 1, __ATOMIC_RELAXED);\n-\tILIST_INSERT(sh->ipool[MLX5_IPOOL_PORT_ID], &sh->port_id_action_list,\n-\t\t dev_flow->handle->rix_port_id_action, cache_resource,\n-\t\t next);\n-\tdev_flow->dv.port_id_action = cache_resource;\n-\tDRV_LOG(DEBUG, \"new port id action resource %p: refcnt %d++\",\n-\t\t(void *)cache_resource,\n-\t\t__atomic_load_n(&cache_resource->refcnt, __ATOMIC_RELAXED));\n+\tentry = mlx5_cache_register(&priv->sh->port_id_action_list, &ctx);\n+\tif (!entry)\n+\t\treturn -rte_errno;\n+\tcache = container_of(entry, typeof(*cache), entry);\n+\tdev_flow->dv.port_id_action = cache;\n+\tdev_flow->handle->rix_port_id_action = cache->idx;\n \treturn 0;\n }\n \n@@ -10520,6 +10533,18 @@ struct mlx5_hlist_entry *\n \treturn mlx5_hlist_unregister(priv->sh->modify_cmds, &entry->entry);\n }\n \n+void\n+flow_dv_port_id_remove_cb(struct mlx5_cache_list *list,\n+\t\t\t struct mlx5_cache_entry *entry)\n+{\n+\tstruct mlx5_dev_ctx_shared *sh = list->ctx;\n+\tstruct mlx5_flow_dv_port_id_action_resource *cache =\n+\t\t\tcontainer_of(entry, typeof(*cache), entry);\n+\n+\tclaim_zero(mlx5_flow_os_destroy_flow_action(cache->action));\n+\tmlx5_ipool_free(sh->ipool[MLX5_IPOOL_PORT_ID], cache->idx);\n+}\n+\n /**\n * Release port ID action resource.\n *\n@@ -10536,30 +10561,14 @@ struct mlx5_hlist_entry *\n \t\t\t\t\tuint32_t port_id)\n {\n \tstruct mlx5_priv *priv = dev->data->dev_private;\n-\tstruct mlx5_flow_dv_port_id_action_resource *cache_resource;\n-\tuint32_t idx = port_id;\n+\tstruct mlx5_flow_dv_port_id_action_resource *cache;\n \n-\tcache_resource = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_PORT_ID],\n-\t\t\t\t\tidx);\n-\tif (!cache_resource)\n-\t\treturn 0;\n-\tMLX5_ASSERT(cache_resource->action);\n-\tDRV_LOG(DEBUG, \"port ID action resource %p: refcnt %d--\",\n-\t\t(void *)cache_resource,\n-\t\t__atomic_load_n(&cache_resource->refcnt, __ATOMIC_RELAXED));\n-\tif (__atomic_sub_fetch(&cache_resource->refcnt, 1,\n-\t\t\t __ATOMIC_RELAXED) == 0) {\n-\t\tclaim_zero(mlx5_flow_os_destroy_flow_action\n-\t\t\t\t\t\t(cache_resource->action));\n-\t\tILIST_REMOVE(priv->sh->ipool[MLX5_IPOOL_PORT_ID],\n-\t\t\t &priv->sh->port_id_action_list, idx,\n-\t\t\t cache_resource, next);\n-\t\tmlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_PORT_ID], idx);\n-\t\tDRV_LOG(DEBUG, \"port id action resource %p: removed\",\n-\t\t\t(void *)cache_resource);\n+\tcache = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_PORT_ID], port_id);\n+\tif (!cache)\n \t\treturn 0;\n-\t}\n-\treturn 1;\n+\tMLX5_ASSERT(cache->action);\n+\treturn mlx5_cache_unregister(&priv->sh->port_id_action_list,\n+\t\t\t\t &cache->entry);\n }\n \n /**\n", "prefixes": [ "v5", "25/34" ] }{ "id": 82564, "url": "