get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 79766,
    "url": "http://patches.dpdk.org/api/patches/79766/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1601984948-313027-14-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": "<1601984948-313027-14-git-send-email-suanmingm@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1601984948-313027-14-git-send-email-suanmingm@nvidia.com",
    "date": "2020-10-06T11:48:56",
    "name": "[13/25] net/mlx5: make header reformat action thread safe",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a6edf45fd1320c94db4035cf4fe01ef71d189fcf",
    "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/1601984948-313027-14-git-send-email-suanmingm@nvidia.com/mbox/",
    "series": [
        {
            "id": 12718,
            "url": "http://patches.dpdk.org/api/series/12718/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12718",
            "date": "2020-10-06T11:48:45",
            "name": "net/mlx5: support multiple-thread flow operations",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/12718/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/79766/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/79766/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 9BF9FA04BB;\n\tTue,  6 Oct 2020 13:53:40 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 366A01B96B;\n\tTue,  6 Oct 2020 13:49:43 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 090EB1B872\n for <dev@dpdk.org>; Tue,  6 Oct 2020 13:49:39 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n suanmingm@nvidia.com) with SMTP; 6 Oct 2020 14:49:37 +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 096BnC0X028553;\n Tue, 6 Oct 2020 14:49:36 +0300"
        ],
        "From": "Suanming Mou <suanmingm@nvidia.com>",
        "To": "viacheslavo@nvidia.com, matan@nvidia.com",
        "Cc": "rasland@nvidia.com, dev@dpdk.org",
        "Date": "Tue,  6 Oct 2020 19:48:56 +0800",
        "Message-Id": "<1601984948-313027-14-git-send-email-suanmingm@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1601984948-313027-1-git-send-email-suanmingm@nvidia.com>",
        "References": "<1601984948-313027-1-git-send-email-suanmingm@nvidia.com>",
        "Subject": "[dpdk-dev] [PATCH 13/25] net/mlx5: make header reformat action\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": "This commit applies the thread safe hash list to the header reformat\naction. That makes the theader reformat action to be thread safe.\n\nSigned-off-by: Suanming Mou <suanmingm@nvidia.com>\n---\n drivers/net/mlx5/linux/mlx5_os.c |   6 +-\n drivers/net/mlx5/mlx5_flow.h     |   6 ++\n drivers/net/mlx5/mlx5_flow_dv.c  | 181 +++++++++++++++++++++------------------\n 3 files changed, 111 insertions(+), 82 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex 50d3d99..24cf348 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -262,12 +262,16 @@\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,\n-\t\t\t\t\t      0, false, NULL, NULL, NULL);\n+\t\t\t\t\t      0, true,\n+\t\t\t\t\t      flow_dv_encap_decap_create_cb,\n+\t\t\t\t\t      flow_dv_encap_decap_match_cb,\n+\t\t\t\t\t      flow_dv_encap_decap_remove_cb);\n \tif (!sh->encaps_decaps) {\n \t\tDRV_LOG(ERR, \"encap decap hash creation failed\");\n \t\terr = ENOMEM;\n \t\tgoto error;\n \t}\n+\tsh->encaps_decaps->ctx = sh;\n #endif\n #ifdef HAVE_MLX5DV_DR\n \tvoid *domain;\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 41969c2..1fe0b30 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -1105,4 +1105,10 @@ struct mlx5_hlist_entry *flow_dv_mreg_create_cb(struct mlx5_hlist *list,\n void flow_dv_mreg_remove_cb(struct mlx5_hlist *list,\n \t\t\t    struct mlx5_hlist_entry *entry);\n \n+int flow_dv_encap_decap_match_cb(struct mlx5_hlist *list,\n+\t\t\t\t struct mlx5_hlist_entry *entry, void *cb_ctx);\n+struct mlx5_hlist_entry *flow_dv_encap_decap_create_cb(struct mlx5_hlist *list,\n+\t\t\t\tuint64_t key, void *cb_ctx);\n+void flow_dv_encap_decap_remove_cb(struct mlx5_hlist *list,\n+\t\t\t\t   struct mlx5_hlist_entry *entry);\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 d19f697..b884d8c 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -2548,21 +2548,24 @@ struct field_modify_info modify_tcp[] = {\n /**\n  * Match encap_decap resource.\n  *\n+ * @param list\n+ *   Pointer to the hash list.\n  * @param entry\n  *   Pointer to exist resource entry object.\n- * @param ctx\n+ * @param ctx_cb\n  *   Pointer to new encap_decap resource.\n  *\n  * @return\n- *   0 on matching, -1 otherwise.\n+ *   0 on matching, none-zero otherwise.\n  */\n-static int\n-flow_dv_encap_decap_resource_match(struct mlx5_hlist_entry *entry, void *ctx)\n+int\n+flow_dv_encap_decap_match_cb(struct mlx5_hlist *list __rte_unused,\n+\t\t\t     struct mlx5_hlist_entry *entry, void *cb_ctx)\n {\n-\tstruct mlx5_flow_dv_encap_decap_resource *resource;\n+\tstruct mlx5_flow_cb_ctx *ctx = cb_ctx;\n+\tstruct mlx5_flow_dv_encap_decap_resource *resource = ctx->data;\n \tstruct mlx5_flow_dv_encap_decap_resource *cache_resource;\n \n-\tresource = (struct mlx5_flow_dv_encap_decap_resource *)ctx;\n \tcache_resource = container_of(entry,\n \t\t\t\t      struct mlx5_flow_dv_encap_decap_resource,\n \t\t\t\t      entry);\n@@ -2579,6 +2582,63 @@ struct field_modify_info modify_tcp[] = {\n }\n \n /**\n+ * Allocate encap_decap resource.\n+ *\n+ * @param list\n+ *   Pointer to the hash list.\n+ * @param entry\n+ *   Pointer to exist resource entry object.\n+ * @param ctx_cb\n+ *   Pointer to new encap_decap resource.\n+ *\n+ * @return\n+ *   0 on matching, none-zero otherwise.\n+ */\n+struct mlx5_hlist_entry *\n+flow_dv_encap_decap_create_cb(struct mlx5_hlist *list,\n+\t\t\t      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 *domain;\n+\tstruct mlx5_flow_dv_encap_decap_resource *resource = ctx->data;\n+\tstruct mlx5_flow_dv_encap_decap_resource *cache_resource;\n+\tuint32_t idx;\n+\tint ret;\n+\n+\tif (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)\n+\t\tdomain = sh->fdb_domain;\n+\telse if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_RX)\n+\t\tdomain = sh->rx_domain;\n+\telse\n+\t\tdomain = sh->tx_domain;\n+\t/* Register new encap/decap resource. */\n+\tcache_resource = mlx5_ipool_zmalloc(sh->ipool[MLX5_IPOOL_DECAP_ENCAP],\n+\t\t\t\t       &idx);\n+\tif (!cache_resource) {\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+\t*cache_resource = *resource;\n+\tcache_resource->idx = idx;\n+\tret = mlx5_flow_os_create_flow_action_packet_reformat\n+\t\t\t\t\t(sh->ctx, domain, cache_resource,\n+\t\t\t\t\t &cache_resource->action);\n+\tif (ret) {\n+\t\tmlx5_ipool_free(sh->ipool[MLX5_IPOOL_DECAP_ENCAP], idx);\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 action\");\n+\t\treturn NULL;\n+\t}\n+\n+\treturn &cache_resource->entry;\n+}\n+\n+/**\n  * Find existing encap/decap resource or create and register a new one.\n  *\n  * @param[in, out] dev\n@@ -2602,8 +2662,6 @@ 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_encap_decap_resource *cache_resource;\n-\tstruct mlx5dv_dr_domain *domain;\n \tstruct mlx5_hlist_entry *entry;\n \tunion mlx5_flow_encap_decap_key encap_decap_key = {\n \t\t{\n@@ -2614,68 +2672,22 @@ struct field_modify_info modify_tcp[] = {\n \t\t\t.cksum = 0,\n \t\t}\n \t};\n-\tint ret;\n+\tstruct mlx5_flow_cb_ctx ctx = {\n+\t\t.error = error,\n+\t\t.data = resource,\n+\t};\n \n \tresource->flags = dev_flow->dv.group ? 0 : 1;\n-\tif (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)\n-\t\tdomain = sh->fdb_domain;\n-\telse if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_RX)\n-\t\tdomain = sh->rx_domain;\n-\telse\n-\t\tdomain = sh->tx_domain;\n \tencap_decap_key.cksum = __rte_raw_cksum(resource->buf,\n \t\t\t\t\t\tresource->size, 0);\n \tresource->entry.key = encap_decap_key.v64;\n-\t/* Lookup a matching resource from cache. */\n-\tentry = mlx5_hlist_lookup_ex(sh->encaps_decaps, resource->entry.key,\n-\t\t\t\t     flow_dv_encap_decap_resource_match,\n-\t\t\t\t     (void *)resource);\n-\tif (entry) {\n-\t\tcache_resource = container_of(entry,\n-\t\t\tstruct mlx5_flow_dv_encap_decap_resource, entry);\n-\t\tDRV_LOG(DEBUG, \"encap/decap 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.rix_encap_decap = cache_resource->idx;\n-\t\tdev_flow->dv.encap_decap = cache_resource;\n-\t\treturn 0;\n-\t}\n-\t/* Register new encap/decap resource. */\n-\tcache_resource = mlx5_ipool_zmalloc(sh->ipool[MLX5_IPOOL_DECAP_ENCAP],\n-\t\t\t\t       &dev_flow->handle->dvh.rix_encap_decap);\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-\tcache_resource->idx = dev_flow->handle->dvh.rix_encap_decap;\n-\tret = mlx5_flow_os_create_flow_action_packet_reformat\n-\t\t\t\t\t(sh->ctx, domain, cache_resource,\n-\t\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-\trte_atomic32_init(&cache_resource->refcnt);\n-\trte_atomic32_inc(&cache_resource->refcnt);\n-\tif (mlx5_hlist_insert_ex(sh->encaps_decaps, &cache_resource->entry,\n-\t\t\t\t flow_dv_encap_decap_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_ipool_free(priv->sh->ipool[MLX5_IPOOL_DECAP_ENCAP],\n-\t\t\t\tcache_resource->idx);\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->dv.encap_decap = cache_resource;\n-\tDRV_LOG(DEBUG, \"new encap/decap resource %p: refcnt %d++\",\n-\t\t(void *)cache_resource,\n-\t\trte_atomic32_read(&cache_resource->refcnt));\n+\tentry = mlx5_hlist_register(sh->encaps_decaps, resource->entry.key,\n+\t\t\t\t    &ctx);\n+\tif (!entry)\n+\t\treturn -rte_errno;\n+\tresource = container_of(entry, typeof(*resource), entry);\n+\tdev_flow->dv.encap_decap = resource;\n+\tdev_flow->handle->dvh.rix_encap_decap = resource->idx;\n \treturn 0;\n }\n \n@@ -9089,6 +9101,26 @@ struct mlx5_hlist_entry *\n }\n \n /**\n+ * Release encap_decap resource.\n+ *\n+ * @param list\n+ *   Pointer to the hash list.\n+ * @param entry\n+ *   Pointer to exist resource entry object.\n+ */\n+void\n+flow_dv_encap_decap_remove_cb(struct mlx5_hlist *list,\n+\t\t\t      struct mlx5_hlist_entry *entry)\n+{\n+\tstruct mlx5_dev_ctx_shared *sh = list->ctx;\n+\tstruct mlx5_flow_dv_encap_decap_resource *res =\n+\t\tcontainer_of(entry, typeof(*res), entry);\n+\n+\tclaim_zero(mlx5_flow_os_destroy_flow_action(res->action));\n+\tmlx5_ipool_free(sh->ipool[MLX5_IPOOL_DECAP_ENCAP], res->idx);\n+}\n+\n+/**\n  * Release an encap/decap resource.\n  *\n  * @param dev\n@@ -9104,28 +9136,15 @@ 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-\tuint32_t idx = handle->dvh.rix_encap_decap;\n \tstruct mlx5_flow_dv_encap_decap_resource *cache_resource;\n \n \tcache_resource = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_DECAP_ENCAP],\n-\t\t\t idx);\n+\t\t\t\t\thandle->dvh.rix_encap_decap);\n \tif (!cache_resource)\n \t\treturn 0;\n \tMLX5_ASSERT(cache_resource->action);\n-\tDRV_LOG(DEBUG, \"encap/decap 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->encaps_decaps,\n-\t\t\t\t  &cache_resource->entry);\n-\t\tmlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_DECAP_ENCAP], idx);\n-\t\tDRV_LOG(DEBUG, \"encap/decap resource %p: removed\",\n-\t\t\t(void *)cache_resource);\n-\t\treturn 0;\n-\t}\n-\treturn 1;\n+\treturn mlx5_hlist_unregister(priv->sh->encaps_decaps,\n+\t\t\t\t     &cache_resource->entry);\n }\n \n /**\n",
    "prefixes": [
        "13/25"
    ]
}