get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 71718,
    "url": "http://patches.dpdk.org/api/patches/71718/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1592465084-140601-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": "<1592465084-140601-3-git-send-email-suanmingm@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1592465084-140601-3-git-send-email-suanmingm@mellanox.com",
    "date": "2020-06-18T07:24:43",
    "name": "[2/3] net/mlx5: manage shared counters in Three-Level table",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "b9b09934ac2ac18ab7cad6953b4db57978bc5348",
    "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/1592465084-140601-3-git-send-email-suanmingm@mellanox.com/mbox/",
    "series": [
        {
            "id": 10496,
            "url": "http://patches.dpdk.org/api/series/10496/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=10496",
            "date": "2020-06-18T07:24:41",
            "name": "net/mlx5: optimize single counter allocate",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/10496/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/71718/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/71718/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 D3A0EA04A5;\n\tThu, 18 Jun 2020 09:25:09 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 84A8B1BE99;\n\tThu, 18 Jun 2020 09:24:56 +0200 (CEST)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])\n by dpdk.org (Postfix) with ESMTP id A58141BDFD\n for <dev@dpdk.org>; Thu, 18 Jun 2020 09:24:53 +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": "Thu, 18 Jun 2020 15:24:43 +0800",
        "Message-Id": "<1592465084-140601-3-git-send-email-suanmingm@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1592465084-140601-1-git-send-email-suanmingm@mellanox.com>",
        "References": "<1592465084-140601-1-git-send-email-suanmingm@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH 2/3] net/mlx5: manage shared counters in\n\tThree-Level table",
        "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": "Currently, to check if any shared counter with same ID existing, it will\nhave to loop the counter pools to search for the counter. Even add the\ncounter to the list will also not so helpful while there are thousands\nof shared counters in the list.\n\nChange Three-Level table to look up the counter index saved in the\nrelevant table entry will be more efficient.\n\nThis patch introduces the Three-level table to save the ID relevant\ncounter index in the table. Then the next while the same ID comes, just\ncheck the table entry of this ID will get the counter index directly.\nNo search will be needed.\n\nSigned-off-by: Suanming Mou <suanmingm@mellanox.com>\nAcked-by: Matan Azrad <matan@mellanox.com>\n---\n drivers/net/mlx5/mlx5.c         | 13 ++++++++++\n drivers/net/mlx5/mlx5.h         |  1 +\n drivers/net/mlx5/mlx5_flow_dv.c | 53 ++++++++++++++++++++++++-----------------\n 3 files changed, 45 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 5c86f6f..4c0c26e 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -716,6 +716,11 @@ struct mlx5_dev_ctx_shared *\n \tmlx5_os_set_reg_mr_cb(&sh->share_cache.reg_mr_cb,\n \t\t\t      &sh->share_cache.dereg_mr_cb);\n \tmlx5_os_dev_shared_handler_install(sh);\n+\tsh->cnt_id_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_DWORD);\n+\tif (!sh->cnt_id_tbl) {\n+\t\terr = rte_errno;\n+\t\tgoto error;\n+\t}\n \tmlx5_flow_aging_init(sh);\n \tmlx5_flow_counters_mng_init(sh);\n \tmlx5_flow_ipool_create(sh, config);\n@@ -732,6 +737,10 @@ struct mlx5_dev_ctx_shared *\n error:\n \tpthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);\n \tMLX5_ASSERT(sh);\n+\tif (sh->cnt_id_tbl) {\n+\t\tmlx5_l3t_destroy(sh->cnt_id_tbl);\n+\t\tsh->cnt_id_tbl = NULL;\n+\t}\n \tif (sh->tis)\n \t\tclaim_zero(mlx5_devx_cmd_destroy(sh->tis));\n \tif (sh->td)\n@@ -793,6 +802,10 @@ struct mlx5_dev_ctx_shared *\n \tmlx5_flow_counters_mng_close(sh);\n \tmlx5_flow_ipool_destroy(sh);\n \tmlx5_os_dev_shared_handler_uninstall(sh);\n+\tif (sh->cnt_id_tbl) {\n+\t\tmlx5_l3t_destroy(sh->cnt_id_tbl);\n+\t\tsh->cnt_id_tbl = NULL;\n+\t}\n \tif (sh->pd)\n \t\tclaim_zero(mlx5_glue->dealloc_pd(sh->pd));\n \tif (sh->tis)\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 5bd5acd..1ee9da7 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -565,6 +565,7 @@ struct mlx5_dev_ctx_shared {\n \tstruct mlx5_flow_counter_mng cmng; /* Counters management structure. */\n \tstruct mlx5_indexed_pool *ipool[MLX5_IPOOL_MAX];\n \t/* Memory Pool for mlx5 flow resources. */\n+\tstruct mlx5_l3t_tbl *cnt_id_tbl; /* Shared counter lookup table. */\n \t/* Shared interrupt handler section. */\n \tstruct rte_intr_handle intr_handle; /* Interrupt handler for device. */\n \tstruct rte_intr_handle intr_handle_devx; /* DEVX interrupt handler. */\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex 5bb252e..6e4e10c 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -4453,8 +4453,8 @@ struct field_modify_info modify_tcp[] = {\n /**\n  * Search for existed shared counter.\n  *\n- * @param[in] cont\n- *   Pointer to the relevant counter pool container.\n+ * @param[in] dev\n+ *   Pointer to the Ethernet device structure.\n  * @param[in] id\n  *   The shared counter ID to search.\n  * @param[out] ppool\n@@ -4464,26 +4464,22 @@ struct field_modify_info modify_tcp[] = {\n  *   NULL if not existed, otherwise pointer to the shared extend counter.\n  */\n static struct mlx5_flow_counter_ext *\n-flow_dv_counter_shared_search(struct mlx5_pools_container *cont, uint32_t id,\n+flow_dv_counter_shared_search(struct rte_eth_dev *dev, uint32_t id,\n \t\t\t      struct mlx5_flow_counter_pool **ppool)\n {\n-\tstruct mlx5_flow_counter_ext *cnt;\n-\tstruct mlx5_flow_counter_pool *pool;\n-\tuint32_t i, j;\n-\tuint32_t n_valid = rte_atomic16_read(&cont->n_valid);\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tunion mlx5_l3t_data data;\n+\tuint32_t cnt_idx;\n \n-\tfor (i = 0; i < n_valid; i++) {\n-\t\tpool = cont->pools[i];\n-\t\tfor (j = 0; j < MLX5_COUNTERS_PER_POOL; ++j) {\n-\t\t\tcnt = MLX5_GET_POOL_CNT_EXT(pool, j);\n-\t\t\tif (cnt->ref_cnt && cnt->shared && cnt->id == id) {\n-\t\t\t\tif (ppool)\n-\t\t\t\t\t*ppool = cont->pools[i];\n-\t\t\t\treturn cnt;\n-\t\t\t}\n-\t\t}\n-\t}\n-\treturn NULL;\n+\tif (mlx5_l3t_get_entry(priv->sh->cnt_id_tbl, id, &data) || !data.dword)\n+\t\treturn NULL;\n+\tcnt_idx = data.dword;\n+\t/*\n+\t * Shared counters don't have age info. The counter extend is after\n+\t * the counter datat structure.\n+\t */\n+\treturn (struct mlx5_flow_counter_ext *)\n+\t       ((flow_dv_counter_get_by_idx(dev, cnt_idx, ppool)) + 1);\n }\n \n /**\n@@ -4529,7 +4525,7 @@ struct field_modify_info modify_tcp[] = {\n \t\treturn 0;\n \t}\n \tif (shared) {\n-\t\tcnt_ext = flow_dv_counter_shared_search(cont, id, &pool);\n+\t\tcnt_ext = flow_dv_counter_shared_search(dev, id, &pool);\n \t\tif (cnt_ext) {\n \t\t\tif (cnt_ext->ref_cnt + 1 == 0) {\n \t\t\t\trte_errno = E2BIG;\n@@ -4597,6 +4593,13 @@ struct field_modify_info modify_tcp[] = {\n \t\tcnt_ext->shared = shared;\n \t\tcnt_ext->ref_cnt = 1;\n \t\tcnt_ext->id = id;\n+\t\tif (shared) {\n+\t\t\tunion mlx5_l3t_data data;\n+\n+\t\t\tdata.dword = cnt_idx;\n+\t\t\tif (mlx5_l3t_set_entry(priv->sh->cnt_id_tbl, id, &data))\n+\t\t\t\treturn 0;\n+\t\t}\n \t}\n \tif (!priv->counter_fallback && !priv->sh->cmng.query_thread_on)\n \t\t/* Start the asynchronous batch query by the host thread. */\n@@ -4679,6 +4682,7 @@ struct field_modify_info modify_tcp[] = {\n static void\n flow_dv_counter_release(struct rte_eth_dev *dev, uint32_t counter)\n {\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n \tstruct mlx5_flow_counter_pool *pool = NULL;\n \tstruct mlx5_flow_counter *cnt;\n \tstruct mlx5_flow_counter_ext *cnt_ext = NULL;\n@@ -4689,8 +4693,13 @@ struct field_modify_info modify_tcp[] = {\n \tMLX5_ASSERT(pool);\n \tif (counter < MLX5_CNT_BATCH_OFFSET) {\n \t\tcnt_ext = MLX5_CNT_TO_CNT_EXT(pool, cnt);\n-\t\tif (cnt_ext && --cnt_ext->ref_cnt)\n-\t\t\treturn;\n+\t\tif (cnt_ext) {\n+\t\t\tif (--cnt_ext->ref_cnt)\n+\t\t\t\treturn;\n+\t\t\tif (cnt_ext->shared)\n+\t\t\t\tmlx5_l3t_clear_entry(priv->sh->cnt_id_tbl,\n+\t\t\t\t\t\t     cnt_ext->id);\n+\t\t}\n \t}\n \tif (IS_AGE_POOL(pool))\n \t\tflow_dv_counter_remove_from_age(dev, counter, cnt);\n",
    "prefixes": [
        "2/3"
    ]
}