get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 82312,
    "url": "https://patches.dpdk.org/api/patches/82312/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1603801650-442376-27-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": "<1603801650-442376-27-git-send-email-suanmingm@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1603801650-442376-27-git-send-email-suanmingm@nvidia.com",
    "date": "2020-10-27T12:27:21",
    "name": "[v3,26/34] net/mlx5: make push VLAN action cache thread safe",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0567496b76b11b44df38310188bac009cf01afe4",
    "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/1603801650-442376-27-git-send-email-suanmingm@nvidia.com/mbox/",
    "series": [
        {
            "id": 13372,
            "url": "https://patches.dpdk.org/api/series/13372/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=13372",
            "date": "2020-10-27T12:26:55",
            "name": "net/mlx5: support multiple-thread flow operations",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/13372/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/82312/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/82312/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 3DF0CA04B5;\n\tTue, 27 Oct 2020 13:37:24 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id E0F4CACA2;\n\tTue, 27 Oct 2020 13:29:26 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id A8BD94C6B\n for <dev@dpdk.org>; Tue, 27 Oct 2020 13:28:27 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n suanmingm@nvidia.com) with SMTP; 27 Oct 2020 14:28:25 +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 09RCRZ7O024637;\n Tue, 27 Oct 2020 14:28:23 +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, Xueming Li <xuemingl@nvidia.com>",
        "Date": "Tue, 27 Oct 2020 20:27:21 +0800",
        "Message-Id": "<1603801650-442376-27-git-send-email-suanmingm@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1603801650-442376-1-git-send-email-suanmingm@nvidia.com>",
        "References": "<1601984948-313027-1-git-send-email-suanmingm@nvidia.com>\n <1603801650-442376-1-git-send-email-suanmingm@nvidia.com>",
        "Subject": "[dpdk-dev] [PATCH v3 26/34] net/mlx5: make push VLAN 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 converts push VLAN\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     |  13 +++-\n drivers/net/mlx5/mlx5_flow_dv.c  | 157 +++++++++++++++++++++------------------\n 4 files changed, 102 insertions(+), 77 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex 3d2bf57..9ab3ba9 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -242,6 +242,12 @@\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/* Init push vlan action cache list. */\n+\tsnprintf(s, sizeof(s), \"%s_push_vlan_action_cache\", sh->ibdev_name);\n+\tmlx5_cache_list_init(&sh->push_vlan_action_list, s, 0, sh,\n+\t\t\t     flow_dv_push_vlan_create_cb,\n+\t\t\t     flow_dv_push_vlan_match_cb,\n+\t\t\t     flow_dv_push_vlan_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@@ -438,6 +444,7 @@\n \t\tsh->tunnel_hub = NULL;\n \t}\n \tmlx5_cache_list_destroy(&sh->port_id_action_list);\n+\tmlx5_cache_list_destroy(&sh->push_vlan_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 ed606ee..2aa669b 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -664,7 +664,7 @@ struct mlx5_dev_ctx_shared {\n \tstruct mlx5_hlist *modify_cmds;\n \tstruct mlx5_hlist *tag_table;\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+\tstruct mlx5_cache_list push_vlan_action_list; /* Push VLAN actions. */\n \tuint32_t sample_action_list; /* List of sample actions. */\n \tuint32_t dest_array_list; /* List of destination array actions. */\n \tstruct mlx5_flow_counter_mng cmng; /* Counters management structure. */\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 1a6521f..e6e6cc4 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -494,12 +494,11 @@ struct mlx5_flow_dv_port_id_action_resource {\n \n /* Push VLAN action resource structure */\n struct mlx5_flow_dv_push_vlan_action_resource {\n-\tILIST_ENTRY(uint32_t)next;\n-\t/* Pointer to next element. */\n-\trte_atomic32_t refcnt; /**< Reference counter. */\n+\tstruct mlx5_cache_entry entry; /* Cache entry. */\n \tvoid *action; /**< Action object. */\n \tuint8_t ft_type; /**< Flow table type, Rx, Tx or FDB. */\n \trte_be32_t vlan_tag; /**< VLAN tag value. */\n+\tuint32_t idx; /**< Indexed pool memory index. */\n };\n \n /* Metadata register copy table entry. */\n@@ -1438,4 +1437,12 @@ struct mlx5_cache_entry *flow_dv_port_id_create_cb(struct mlx5_cache_list *list,\n void flow_dv_port_id_remove_cb(struct mlx5_cache_list *list,\n \t\t\t       struct mlx5_cache_entry *entry);\n \n+int flow_dv_push_vlan_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_push_vlan_create_cb\n+\t\t\t\t(struct mlx5_cache_list *list,\n+\t\t\t\t struct mlx5_cache_entry *entry, void *cb_ctx);\n+void flow_dv_push_vlan_remove_cb(struct mlx5_cache_list *list,\n+\t\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 c3c3405..fff5534 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -3046,6 +3046,58 @@ struct mlx5_cache_entry *\n \treturn 0;\n }\n \n+int\n+flow_dv_push_vlan_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_push_vlan_action_resource *ref = ctx->data;\n+\tstruct mlx5_flow_dv_push_vlan_action_resource *res =\n+\t\t\tcontainer_of(entry, typeof(*res), entry);\n+\n+\treturn ref->vlan_tag != res->vlan_tag || ref->ft_type != res->ft_type;\n+}\n+\n+struct mlx5_cache_entry *\n+flow_dv_push_vlan_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_push_vlan_action_resource *ref = ctx->data;\n+\tstruct mlx5_flow_dv_push_vlan_action_resource *cache;\n+\tstruct mlx5dv_dr_domain *domain;\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_PUSH_VLAN], &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 push_vlan action cache memory\");\n+\t\treturn NULL;\n+\t}\n+\t*cache = *ref;\n+\tif (ref->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)\n+\t\tdomain = sh->fdb_domain;\n+\telse if (ref->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_RX)\n+\t\tdomain = sh->rx_domain;\n+\telse\n+\t\tdomain = sh->tx_domain;\n+\tret = mlx5_flow_os_create_flow_action_push_vlan(domain, ref->vlan_tag,\n+\t\t\t\t\t\t\t&cache->action);\n+\tif (ret) {\n+\t\tmlx5_ipool_free(sh->ipool[MLX5_IPOOL_PUSH_VLAN], 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 push vlan action\");\n+\t\treturn NULL;\n+\t}\n+\treturn &cache->entry;\n+}\n+\n /**\n  * Find existing push vlan resource or create and register a new one.\n  *\n@@ -3069,62 +3121,23 @@ struct mlx5_cache_entry *\n \t\t\tstruct 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_push_vlan_action_resource *cache_resource;\n-\tstruct mlx5dv_dr_domain *domain;\n-\tuint32_t idx = 0;\n-\tint ret;\n+\tstruct mlx5_flow_dv_push_vlan_action_resource *cache;\n+\tstruct mlx5_cache_entry *entry;\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_PUSH_VLAN],\n-\t\t      sh->push_vlan_action_list, idx, cache_resource, next) {\n-\t\tif (resource->vlan_tag == cache_resource->vlan_tag &&\n-\t\t    resource->ft_type == cache_resource->ft_type) {\n-\t\t\tDRV_LOG(DEBUG, \"push-VLAN action resource resource %p: \"\n-\t\t\t\t\"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.rix_push_vlan = idx;\n-\t\t\tdev_flow->dv.push_vlan_res = cache_resource;\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n-\t/* Register new push_vlan action resource. */\n-\tcache_resource = mlx5_ipool_zmalloc(sh->ipool[MLX5_IPOOL_PUSH_VLAN],\n-\t\t\t\t       &dev_flow->handle->dvh.rix_push_vlan);\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-\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-\tret = mlx5_flow_os_create_flow_action_push_vlan\n-\t\t\t\t\t(domain, resource->vlan_tag,\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-\tILIST_INSERT(sh->ipool[MLX5_IPOOL_PUSH_VLAN],\n-\t\t     &sh->push_vlan_action_list,\n-\t\t     dev_flow->handle->dvh.rix_push_vlan,\n-\t\t     cache_resource, next);\n-\tdev_flow->dv.push_vlan_res = cache_resource;\n-\tDRV_LOG(DEBUG, \"new push vlan action resource %p: refcnt %d++\",\n-\t\t(void *)cache_resource,\n-\t\trte_atomic32_read(&cache_resource->refcnt));\n+\tentry = mlx5_cache_register(&priv->sh->push_vlan_action_list, &ctx);\n+\tif (!entry)\n+\t\treturn -rte_errno;\n+\tcache = container_of(entry, typeof(*cache), entry);\n+\n+\tdev_flow->handle->dvh.rix_push_vlan = cache->idx;\n+\tdev_flow->dv.push_vlan_res = cache;\n \treturn 0;\n }\n+\n /**\n  * Get the size of specific rte_flow_item_type hdr size\n  *\n@@ -10566,6 +10579,18 @@ struct mlx5_hlist_entry *\n \t\t\t\t     &cache->entry);\n }\n \n+void\n+flow_dv_push_vlan_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_push_vlan_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_PUSH_VLAN], cache->idx);\n+}\n+\n /**\n  * Release push vlan action resource.\n  *\n@@ -10582,29 +10607,15 @@ struct mlx5_hlist_entry *\n \t\t\t\t\t  struct mlx5_flow_handle *handle)\n {\n \tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_flow_dv_push_vlan_action_resource *cache;\n \tuint32_t idx = handle->dvh.rix_push_vlan;\n-\tstruct mlx5_flow_dv_push_vlan_action_resource *cache_resource;\n \n-\tcache_resource = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_PUSH_VLAN],\n-\t\t\t\t\tidx);\n-\tif (!cache_resource)\n-\t\treturn 0;\n-\tMLX5_ASSERT(cache_resource->action);\n-\tDRV_LOG(DEBUG, \"push VLAN action 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\tILIST_REMOVE(priv->sh->ipool[MLX5_IPOOL_PUSH_VLAN],\n-\t\t\t     &priv->sh->push_vlan_action_list, idx,\n-\t\t\t     cache_resource, next);\n-\t\tmlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_PUSH_VLAN], idx);\n-\t\tDRV_LOG(DEBUG, \"push vlan action resource %p: removed\",\n-\t\t\t(void *)cache_resource);\n+\tcache = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_PUSH_VLAN], idx);\n+\tif (!cache)\n \t\treturn 0;\n-\t}\n-\treturn 1;\n+\tMLX5_ASSERT(cache->action);\n+\treturn mlx5_cache_unregister(&priv->sh->push_vlan_action_list,\n+\t\t\t\t     &cache->entry);\n }\n \n /**\n",
    "prefixes": [
        "v3",
        "26/34"
    ]
}