get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 130941,
    "url": "https://patches.dpdk.org/api/patches/130941/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230831095650.219964-9-wanry@3snic.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": "<20230831095650.219964-9-wanry@3snic.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230831095650.219964-9-wanry@3snic.com",
    "date": "2023-08-31T09:56:26",
    "name": "[v2,08/32] net/sssnic/base: add work queue",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d448145e7288191f006c258b6651285b741a85a9",
    "submitter": {
        "id": 3119,
        "url": "https://patches.dpdk.org/api/people/3119/?format=api",
        "name": "Renyong Wan",
        "email": "wanry@3snic.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230831095650.219964-9-wanry@3snic.com/mbox/",
    "series": [
        {
            "id": 29383,
            "url": "https://patches.dpdk.org/api/series/29383/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=29383",
            "date": "2023-08-31T09:56:18",
            "name": "Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/29383/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/130941/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/130941/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id EEF4941FDA;\n\tThu, 31 Aug 2023 11:58:52 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7CE1D402C2;\n\tThu, 31 Aug 2023 11:58:09 +0200 (CEST)",
            "from VLXDG1SPAM1.ramaxel.com (email.unionmem.com [221.4.138.186])\n by mails.dpdk.org (Postfix) with ESMTP id A81C7402A6\n for <dev@dpdk.org>; Thu, 31 Aug 2023 11:58:06 +0200 (CEST)",
            "from V12DG1MBS03.ramaxel.local ([172.26.18.33])\n by VLXDG1SPAM1.ramaxel.com with ESMTP id 37V9vfHG064333;\n Thu, 31 Aug 2023 17:57:41 +0800 (GMT-8)\n (envelope-from wanry@3snic.com)",
            "from localhost.localdomain (10.64.136.151) by\n V12DG1MBS03.ramaxel.local (172.26.18.33) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id\n 15.1.2375.17; Thu, 31 Aug 2023 17:57:40 +0800"
        ],
        "From": "<wanry@3snic.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@amd.com>, Renyong Wan <wanry@3snic.com>, Steven Song\n <steven.song@3snic.com>",
        "Subject": "[PATCH v2 08/32] net/sssnic/base: add work queue",
        "Date": "Thu, 31 Aug 2023 17:56:26 +0800",
        "Message-ID": "<20230831095650.219964-9-wanry@3snic.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20230831095650.219964-1-wanry@3snic.com>",
        "References": "<20230831095650.219964-1-wanry@3snic.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "7bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.64.136.151]",
        "X-ClientProxiedBy": "V12DG1MBS03.ramaxel.local (172.26.18.33) To\n V12DG1MBS03.ramaxel.local (172.26.18.33)",
        "X-DNSRBL": "",
        "X-SPAM-SOURCE-CHECK": "pass",
        "X-MAIL": "VLXDG1SPAM1.ramaxel.com 37V9vfHG064333",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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"
    },
    "content": "From: Renyong Wan <wanry@3snic.com>\n\nWork queue is used to maintain hardware queue information by\ndriver, it is usually used in control queue, rx queue\nand tx queue.\n\nSigned-off-by: Steven Song <steven.song@3snic.com>\nSigned-off-by: Renyong Wan <wanry@3snic.com>\n---\nv2:\n* Removed error.h from including files.\n---\n drivers/net/sssnic/base/meson.build    |   1 +\n drivers/net/sssnic/base/sssnic_workq.c | 141 +++++++++++++++++++++++++\n drivers/net/sssnic/base/sssnic_workq.h | 108 +++++++++++++++++++\n 3 files changed, 250 insertions(+)\n create mode 100644 drivers/net/sssnic/base/sssnic_workq.c\n create mode 100644 drivers/net/sssnic/base/sssnic_workq.h",
    "diff": "diff --git a/drivers/net/sssnic/base/meson.build b/drivers/net/sssnic/base/meson.build\nindex 4abd1a0daf..7c23a82ff3 100644\n--- a/drivers/net/sssnic/base/meson.build\n+++ b/drivers/net/sssnic/base/meson.build\n@@ -6,6 +6,7 @@ sources = [\n         'sssnic_eventq.c',\n         'sssnic_msg.c',\n         'sssnic_mbox.c',\n+        'sssnic_workq.c',\n ]\n \n c_args = cflags\ndiff --git a/drivers/net/sssnic/base/sssnic_workq.c b/drivers/net/sssnic/base/sssnic_workq.c\nnew file mode 100644\nindex 0000000000..25b7585246\n--- /dev/null\n+++ b/drivers/net/sssnic/base/sssnic_workq.c\n@@ -0,0 +1,141 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018-2022 Shenzhen 3SNIC Information Technology Co., Ltd.\n+ */\n+\n+#include <rte_common.h>\n+#include <rte_malloc.h>\n+#include <rte_memcpy.h>\n+#include <rte_memzone.h>\n+\n+#include \"../sssnic_log.h\"\n+#include \"sssnic_workq.h\"\n+\n+/* Consume num_entries and increase CI\n+ * Return the first entry address of previous CI position\n+ */\n+void *\n+sssnic_workq_consume(struct sssnic_workq *workq, uint16_t num_entries,\n+\tuint16_t *ci)\n+{\n+\tvoid *e;\n+\tuint16_t current_ci;\n+\n+\tif (workq->idle_entries + num_entries > workq->num_entries)\n+\t\treturn NULL;\n+\n+\tcurrent_ci = sssnic_workq_ci_get(workq);\n+\te = (void *)sssnic_workq_entry_get(workq, current_ci);\n+\tworkq->idle_entries += num_entries;\n+\tworkq->ci += num_entries;\n+\tif (ci != NULL)\n+\t\t*ci = current_ci;\n+\n+\treturn e;\n+}\n+\n+/* Produce num_entries and increase pi.\n+ * Return the first entry address of previous PI position\n+ */\n+void *\n+sssnic_workq_produce(struct sssnic_workq *workq, uint16_t num_entries,\n+\tuint16_t *pi)\n+{\n+\tvoid *e;\n+\tuint16_t current_pi;\n+\n+\tif (workq->idle_entries < num_entries)\n+\t\treturn NULL;\n+\n+\tcurrent_pi = sssnic_workq_pi_get(workq);\n+\te = (void *)sssnic_workq_entry_get(workq, current_pi);\n+\tworkq->idle_entries -= num_entries;\n+\tworkq->pi += num_entries;\n+\tif (pi != NULL)\n+\t\t*pi = current_pi;\n+\n+\treturn e;\n+}\n+\n+static int\n+sssnic_workq_init(struct sssnic_workq *workq, const char *name, int socket_id,\n+\tuint32_t entry_size, uint32_t depth)\n+{\n+\tchar zname[RTE_MEMZONE_NAMESIZE];\n+\n+\tif (!rte_is_power_of_2(entry_size)) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t\"The entry size(%u) of workq(%s) is not power of 2\",\n+\t\t\tentry_size, name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (!rte_is_power_of_2(depth)) {\n+\t\tPMD_DRV_LOG(ERR, \"The depth(%u) of workq(%s) is not power of 2\",\n+\t\t\tdepth, name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tworkq->buf_size = entry_size * depth;\n+\tworkq->entry_size = entry_size;\n+\tworkq->entry_shift = rte_log2_u32(entry_size);\n+\tworkq->num_entries = depth;\n+\tworkq->idle_entries = depth;\n+\tworkq->index_mask = depth - 1;\n+\n+\tsnprintf(zname, sizeof(zname), \"%s_mz\", name);\n+\tworkq->buf_mz = rte_memzone_reserve_aligned(zname, workq->buf_size,\n+\t\tsocket_id, RTE_MEMZONE_IOVA_CONTIG, RTE_PGSIZE_256K);\n+\tif (workq->buf_mz == NULL) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to alloc DMA memory for %s\", name);\n+\t\treturn -ENOMEM;\n+\t}\n+\tworkq->buf_addr = workq->buf_mz->addr;\n+\tworkq->buf_phyaddr = workq->buf_mz->iova;\n+\n+\treturn 0;\n+}\n+\n+static void\n+sssnic_workq_cleanup(struct sssnic_workq *workq)\n+{\n+\tif (workq != NULL && workq->buf_mz != NULL)\n+\t\trte_memzone_free(workq->buf_mz);\n+}\n+\n+/* Cleanup a work queue and free it*/\n+void\n+sssnic_workq_destroy(struct sssnic_workq *workq)\n+{\n+\tif (workq != NULL) {\n+\t\tsssnic_workq_cleanup(workq);\n+\t\trte_free(workq);\n+\t}\n+}\n+\n+/*Create a work queue and initialize*/\n+struct sssnic_workq *\n+sssnic_workq_new(const char *name, int socket_id, uint32_t entry_size,\n+\tuint32_t depth)\n+{\n+\tint ret;\n+\tstruct sssnic_workq *workq;\n+\n+\tif (name == NULL) {\n+\t\tPMD_DRV_LOG(ERR, \"Bad parameter, workq name is NULL\");\n+\t\treturn NULL;\n+\t}\n+\n+\tworkq = rte_zmalloc(name, sizeof(struct sssnic_workq), 0);\n+\tif (workq == NULL) {\n+\t\tPMD_DRV_LOG(ERR, \"Could not alloc memory for  %s\", name);\n+\t\treturn NULL;\n+\t}\n+\tret = sssnic_workq_init(workq, name, socket_id, entry_size, depth);\n+\tif (ret) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to initialize %s\", name);\n+\t\trte_free(workq);\n+\t\treturn NULL;\n+\t}\n+\n+\treturn workq;\n+}\ndiff --git a/drivers/net/sssnic/base/sssnic_workq.h b/drivers/net/sssnic/base/sssnic_workq.h\nnew file mode 100644\nindex 0000000000..470aef6409\n--- /dev/null\n+++ b/drivers/net/sssnic/base/sssnic_workq.h\n@@ -0,0 +1,108 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018-2022 Shenzhen 3SNIC Information Technology Co., Ltd.\n+ */\n+\n+#ifndef _SSSNIC_WORKQ_H_\n+#define _SSSNIC_WORKQ_H_\n+\n+struct sssnic_workq {\n+\t/* DMA buffer of entries*/\n+\tconst struct rte_memzone *buf_mz;\n+\t/* Virtual address of DMA buffer */\n+\tuint8_t *buf_addr;\n+\t/* Physic address of DMA buffer */\n+\tuint64_t buf_phyaddr;\n+\t/* DMA buffer size */\n+\tuint32_t buf_size;\n+\t/* element size */\n+\tuint32_t entry_size;\n+\t/* number of bits of entry size */\n+\tuint16_t entry_shift;\n+\t/* Max number of entries in buf */\n+\tuint16_t num_entries;\n+\t/* Number of entries not be used */\n+\tuint16_t idle_entries;\n+\t/* Consumer index */\n+\tuint16_t ci;\n+\t/* Producer index */\n+\tuint16_t pi;\n+\t/* CI and PI mask */\n+\tuint16_t index_mask;\n+} __rte_cache_aligned;\n+\n+#define SSSNIC_WORKQ_ENTRY_CAST(workq, idx, type)                              \\\n+\t(((type *)((workq)->buf_addr)) + (idx))\n+#define SSSNIC_WORKQ_BUF_PHYADDR(workq) ((workq)->buf_phyaddr)\n+\n+static inline void *\n+sssnic_workq_entry_get(struct sssnic_workq *workq, uint32_t index)\n+{\n+\treturn (void *)(workq->buf_addr + (index << workq->entry_shift));\n+}\n+\n+/* Return the entry address of current CI position. */\n+static inline void *\n+sssnic_workq_peek(struct sssnic_workq *workq)\n+{\n+\tif ((workq->idle_entries + 1) > workq->num_entries)\n+\t\treturn NULL;\n+\n+\treturn sssnic_workq_entry_get(workq, workq->ci & workq->index_mask);\n+}\n+\n+static inline uint16_t\n+sssnic_workq_num_used_entries(struct sssnic_workq *workq)\n+{\n+\treturn workq->num_entries - workq->idle_entries;\n+}\n+\n+static inline uint16_t\n+sssnic_workq_num_idle_entries(struct sssnic_workq *workq)\n+{\n+\treturn workq->idle_entries;\n+}\n+\n+static inline uint16_t\n+sssnic_workq_ci_get(struct sssnic_workq *workq)\n+{\n+\treturn workq->ci & workq->index_mask;\n+}\n+\n+static inline uint16_t\n+sssnic_workq_pi_get(struct sssnic_workq *workq)\n+{\n+\treturn workq->pi & workq->index_mask;\n+}\n+\n+static inline void\n+sssnic_workq_consume_fast(struct sssnic_workq *workq, uint16_t num_entries)\n+{\n+\tworkq->idle_entries += num_entries;\n+\tworkq->ci += num_entries;\n+}\n+\n+static inline void\n+sssnic_workq_produce_fast(struct sssnic_workq *workq, uint16_t num_entries)\n+{\n+\tworkq->idle_entries -= num_entries;\n+\tworkq->pi += num_entries;\n+}\n+\n+static inline void\n+sssnic_workq_reset(struct sssnic_workq *workq)\n+{\n+\tworkq->ci = 0;\n+\tworkq->pi = 0;\n+\tworkq->idle_entries = workq->num_entries;\n+}\n+\n+void *sssnic_workq_consume(struct sssnic_workq *workq, uint16_t num_entries,\n+\tuint16_t *ci);\n+void *sssnic_workq_produce(struct sssnic_workq *workq, uint16_t num_entries,\n+\tuint16_t *pi);\n+\n+struct sssnic_workq *sssnic_workq_new(const char *name, int socket_id,\n+\tuint32_t entry_size, uint32_t depth);\n+void sssnic_workq_destroy(struct sssnic_workq *workq);\n+\n+#endif /* _SSSNIC_WORKQ_H_ */\n",
    "prefixes": [
        "v2",
        "08/32"
    ]
}