get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 61244,
    "url": "http://patches.dpdk.org/api/patches/61244/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1571130263-120863-12-git-send-email-orika@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": "<1571130263-120863-12-git-send-email-orika@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1571130263-120863-12-git-send-email-orika@mellanox.com",
    "date": "2019-10-15T09:04:19",
    "name": "[v3,11/14] net/mlx5: add id generation function",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2c9f7d0d1a316ff8806e88f2495e4a598039195a",
    "submitter": {
        "id": 795,
        "url": "http://patches.dpdk.org/api/people/795/?format=api",
        "name": "Ori Kam",
        "email": "orika@mellanox.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1571130263-120863-12-git-send-email-orika@mellanox.com/mbox/",
    "series": [
        {
            "id": 6855,
            "url": "http://patches.dpdk.org/api/series/6855/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=6855",
            "date": "2019-10-15T09:04:08",
            "name": "add hairpin feature",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/6855/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/61244/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/61244/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6DB571EA5A;\n\tTue, 15 Oct 2019 11:06:57 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n\tby dpdk.org (Postfix) with ESMTP id 002031EA4E\n\tfor <dev@dpdk.org>; Tue, 15 Oct 2019 11:06:55 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n\torika@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 15 Oct 2019 11:06:55 +0200",
            "from pegasus04.mtr.labs.mlnx. (pegasus04.mtr.labs.mlnx\n\t[10.210.16.126])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x9F94hcm029891;\n\tTue, 15 Oct 2019 12:06:55 +0300"
        ],
        "From": "Ori Kam <orika@mellanox.com>",
        "To": "Matan Azrad <matan@mellanox.com>, Shahaf Shuler <shahafs@mellanox.com>, \n\tViacheslav Ovsiienko <viacheslavo@mellanox.com>",
        "Cc": "dev@dpdk.org, orika@mellanox.com, jingjing.wu@intel.com,\n\tstephen@networkplumber.org",
        "Date": "Tue, 15 Oct 2019 09:04:19 +0000",
        "Message-Id": "<1571130263-120863-12-git-send-email-orika@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1571130263-120863-1-git-send-email-orika@mellanox.com>",
        "References": "<1569479349-36962-1-git-send-email-orika@mellanox.com>\n\t<1571130263-120863-1-git-send-email-orika@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH v3 11/14] net/mlx5: add id generation function",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "When splitting flows for example in hairpin / metering, there is a need\nto combine the flows. This is done using ID.\nThis commit introduce a simple way to generate such IDs.\n\nThe reason why bitmap was not used is due to fact that the release and\nallocation are O(n) while in the chosen approch the allocation and\nrelease are O(1)\n\nSigned-off-by: Ori Kam <orika@mellanox.com>\nAcked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>\n\n---\n drivers/net/mlx5/mlx5.c      | 120 ++++++++++++++++++++++++++++++++++++++++++-\n drivers/net/mlx5/mlx5_flow.h |  14 +++++\n 2 files changed, 133 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 7962936..0c3239c 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -179,6 +179,124 @@ struct mlx5_dev_spawn_data {\n static LIST_HEAD(, mlx5_ibv_shared) mlx5_ibv_list = LIST_HEAD_INITIALIZER();\n static pthread_mutex_t mlx5_ibv_list_mutex = PTHREAD_MUTEX_INITIALIZER;\n \n+#define MLX5_FLOW_MIN_ID_POOL_SIZE 512\n+#define MLX5_ID_GENERATION_ARRAY_FACTOR 16\n+\n+/**\n+ * Allocate ID pool structure.\n+ *\n+ * @return\n+ *   Pointer to pool object, NULL value otherwise.\n+ */\n+struct mlx5_flow_id_pool *\n+mlx5_flow_id_pool_alloc(void)\n+{\n+\tstruct mlx5_flow_id_pool *pool;\n+\tvoid *mem;\n+\n+\tpool = rte_zmalloc(\"id pool allocation\", sizeof(*pool),\n+\t\t\t   RTE_CACHE_LINE_SIZE);\n+\tif (!pool) {\n+\t\tDRV_LOG(ERR, \"can't allocate id pool\");\n+\t\trte_errno  = ENOMEM;\n+\t\treturn NULL;\n+\t}\n+\tmem = rte_zmalloc(\"\", MLX5_FLOW_MIN_ID_POOL_SIZE * sizeof(uint32_t),\n+\t\t\t  RTE_CACHE_LINE_SIZE);\n+\tif (!mem) {\n+\t\tDRV_LOG(ERR, \"can't allocate mem for id pool\");\n+\t\trte_errno  = ENOMEM;\n+\t\tgoto error;\n+\t}\n+\tpool->free_arr = mem;\n+\tpool->curr = pool->free_arr;\n+\tpool->last = pool->free_arr + MLX5_FLOW_MIN_ID_POOL_SIZE;\n+\tpool->base_index = 0;\n+\treturn pool;\n+error:\n+\trte_free(pool);\n+\treturn NULL;\n+}\n+\n+/**\n+ * Release ID pool structure.\n+ *\n+ * @param[in] pool\n+ *   Pointer to flow id pool object to free.\n+ */\n+void\n+mlx5_flow_id_pool_release(struct mlx5_flow_id_pool *pool)\n+{\n+\trte_free(pool->free_arr);\n+\trte_free(pool);\n+}\n+\n+/**\n+ * Generate ID.\n+ *\n+ * @param[in] pool\n+ *   Pointer to flow id pool.\n+ * @param[out] id\n+ *   The generated ID.\n+ *\n+ * @return\n+ *   0 on success, error value otherwise.\n+ */\n+uint32_t\n+mlx5_flow_id_get(struct mlx5_flow_id_pool *pool, uint32_t *id)\n+{\n+\tif (pool->curr == pool->free_arr) {\n+\t\tif (pool->base_index == UINT32_MAX) {\n+\t\t\trte_errno  = ENOMEM;\n+\t\t\tDRV_LOG(ERR, \"no free id\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\t*id = ++pool->base_index;\n+\t\treturn 0;\n+\t}\n+\t*id = *(--pool->curr);\n+\treturn 0;\n+}\n+\n+/**\n+ * Release ID.\n+ *\n+ * @param[in] pool\n+ *   Pointer to flow id pool.\n+ * @param[out] id\n+ *   The generated ID.\n+ *\n+ * @return\n+ *   0 on success, error value otherwise.\n+ */\n+uint32_t\n+mlx5_flow_id_release(struct mlx5_flow_id_pool *pool, uint32_t id)\n+{\n+\tuint32_t size;\n+\tuint32_t size2;\n+\tvoid *mem;\n+\n+\tif (pool->curr == pool->last) {\n+\t\tsize = pool->curr - pool->free_arr;\n+\t\tsize2 = size * MLX5_ID_GENERATION_ARRAY_FACTOR;\n+\t\tassert(size2 > size);\n+\t\tmem = rte_malloc(\"\", size2 * sizeof(uint32_t), 0);\n+\t\tif (!mem) {\n+\t\t\tDRV_LOG(ERR, \"can't allocate mem for id pool\");\n+\t\t\trte_errno  = ENOMEM;\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\tmemcpy(mem, pool->free_arr, size * sizeof(uint32_t));\n+\t\trte_free(pool->free_arr);\n+\t\tpool->free_arr = mem;\n+\t\tpool->curr = pool->free_arr + size;\n+\t\tpool->last = pool->free_arr + size2;\n+\t}\n+\t*pool->curr = id;\n+\tpool->curr++;\n+\treturn 0;\n+}\n+\n /**\n  * Initialize the counters management structure.\n  *\n@@ -329,7 +447,7 @@ struct mlx5_dev_spawn_data {\n \tstruct mlx5_devx_tis_attr tis_attr = { 0 };\n #endif\n \n-\tassert(spawn);\n+assert(spawn);\n \t/* Secondary process should not create the shared context. */\n \tassert(rte_eal_process_type() == RTE_PROC_PRIMARY);\n \tpthread_mutex_lock(&mlx5_ibv_list_mutex);\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 0148c1b..1b14fb7 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -495,8 +495,22 @@ struct mlx5_flow_driver_ops {\n #define MLX5_CNT_CONTAINER_UNUSED(sh, batch, thread) (&(sh)->cmng.ccont \\\n \t[(~((sh)->cmng.mhi[batch] >> (thread)) & 0x1) * 2 + (batch)])\n \n+/* ID generation structure. */\n+struct mlx5_flow_id_pool {\n+\tuint32_t *free_arr; /**< Pointer to the a array of free values. */\n+\tuint32_t base_index;\n+\t/**< The next index that can be used without any free elements. */\n+\tuint32_t *curr; /**< Pointer to the index to pop. */\n+\tuint32_t *last; /**< Pointer to the last element in the empty arrray. */\n+};\n+\n /* mlx5_flow.c */\n \n+struct mlx5_flow_id_pool *mlx5_flow_id_pool_alloc(void);\n+void mlx5_flow_id_pool_release(struct mlx5_flow_id_pool *pool);\n+uint32_t mlx5_flow_id_get(struct mlx5_flow_id_pool *pool, uint32_t *id);\n+uint32_t mlx5_flow_id_release(struct mlx5_flow_id_pool *pool,\n+\t\t\t      uint32_t id);\n int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes,\n \t\t\t     bool external, uint32_t group, uint32_t *table,\n \t\t\t     struct rte_flow_error *error);\n",
    "prefixes": [
        "v3",
        "11/14"
    ]
}