get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 79942,
    "url": "https://patches.dpdk.org/api/patches/79942/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20201007164539.45097-4-vikas.gupta@broadcom.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": "<20201007164539.45097-4-vikas.gupta@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20201007164539.45097-4-vikas.gupta@broadcom.com",
    "date": "2020-10-07T16:45:34",
    "name": "[v4,3/8] crypto/bcmfs: add queue pair management API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "915c16988adf7942fec501b264a2fb283fb6cc06",
    "submitter": {
        "id": 1907,
        "url": "https://patches.dpdk.org/api/people/1907/?format=api",
        "name": "Vikas Gupta",
        "email": "vikas.gupta@broadcom.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20201007164539.45097-4-vikas.gupta@broadcom.com/mbox/",
    "series": [
        {
            "id": 12761,
            "url": "https://patches.dpdk.org/api/series/12761/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=12761",
            "date": "2020-10-07T16:45:31",
            "name": "Add Crypto PMD for Broadcom`s FlexSparc devices",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/12761/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/79942/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/79942/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 EAE84A04BA;\n\tWed,  7 Oct 2020 18:47:33 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id EF2731BEA2;\n\tWed,  7 Oct 2020 18:46:03 +0200 (CEST)",
            "from mail-pl1-f196.google.com (mail-pl1-f196.google.com\n [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 65D5E1BEA0\n for <dev@dpdk.org>; Wed,  7 Oct 2020 18:46:02 +0200 (CEST)",
            "by mail-pl1-f196.google.com with SMTP id x5so1280228plo.6\n for <dev@dpdk.org>; Wed, 07 Oct 2020 09:46:02 -0700 (PDT)",
            "from rahul_yocto_ubuntu18.ibn.broadcom.net ([192.19.234.250])\n by smtp.gmail.com with ESMTPSA id g126sm3858647pfb.32.2020.10.07.09.45.57\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 07 Oct 2020 09:45:58 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com;\n s=google;\n h=from:to:cc:subject:date:message-id:in-reply-to:references;\n bh=9VkoQC8sPeU8t/vHU2s8TnxmRriD/GfJtk0R2Ic9XOo=;\n b=Ay6X9nTMTLNGVgZ9a0UKO4XfjiAPu/GH895vuIyd1sehSJ+L1e0IxAAFl0c98RvTFu\n IxmrjEs3JHWpoAfcTAyjLNj7XpmjbCPcyZvvb1GMlj/JwgDFHlH44LBGcnRbxMFRmzWV\n GRlkP3ERbAxiVf0R9rluKQ6OjGwz0RlpuEZJ4=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references;\n bh=9VkoQC8sPeU8t/vHU2s8TnxmRriD/GfJtk0R2Ic9XOo=;\n b=Jv+7WiZvVPzVsC+cCpc703WaijmJYAExJckYf62CzCahTh2dlQ0oDIzVKac7KIDJcQ\n tTkpsK4gQ2wkWiAQTTqoAbmMEbrq46EH2Xlpap19bk5O6ISMTg2hwT5MCJUoYAb52aJH\n EGPsHGPbvejfv2ndumGZyB4VmpqpXVzYtejKTRpiywq9uHvxINXBc708Z4H0phrh1UQR\n 1z9xkfL/i6QXBXbf3rN9tK+lvo4KstIMh70n33Qq3ywe00qFHtrGP4ydRp04GOEK8Pok\n jyPrxy5/ooGm+1HvqwgVMeC4SU2geMYVhvbpIpYwz8R5aMc8SubF9KCeqKmH1HpySDpE\n 2J4A==",
        "X-Gm-Message-State": "AOAM532sLfK6+jH0U/2fUO0I+XAhJxPmQx8gEH53CUv+XrAoBRtIbxP2\n UZYk7Ryt5bbCdcL0XJDJ8Hp7xeST5oPrruYVFsM62vlnl4mI19v5xrtbMKc5D3eEfuLRplRw1O9\n OIN8v+9I3SGNylqhOJLAfAhLRJZSGxj//x/WzglMtH6b86a+AhBQcESajON4a",
        "X-Google-Smtp-Source": "\n ABdhPJzKEsHg3hJfmqjD2ikTTRXz9tzm1ttyrVHGxKoyZ8w7dze6HAhw7CT31b76Um/vn4wUTPpFpw==",
        "X-Received": "by 2002:a17:902:b70a:b029:d2:6391:a80f with SMTP id\n d10-20020a170902b70ab02900d26391a80fmr3654376pls.0.1602089159751;\n Wed, 07 Oct 2020 09:45:59 -0700 (PDT)",
        "From": "Vikas Gupta <vikas.gupta@broadcom.com>",
        "To": "dev@dpdk.org,\n\takhil.goyal@nxp.com",
        "Cc": "vikram.prakash@broadcom.com, Vikas Gupta <vikas.gupta@broadcom.com>,\n Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>",
        "Date": "Wed,  7 Oct 2020 22:15:34 +0530",
        "Message-Id": "<20201007164539.45097-4-vikas.gupta@broadcom.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20201007164539.45097-1-vikas.gupta@broadcom.com>",
        "References": "<20201005162658.12416-1-vikas.gupta@broadcom.com>\n <20201007164539.45097-1-vikas.gupta@broadcom.com>",
        "Content-Type": "text/plain",
        "X-Content-Filtered-By": "Mailman/MimeDel 2.1.15",
        "Subject": "[dpdk-dev] [PATCH v4 3/8] crypto/bcmfs: add queue pair management\n\tAPI",
        "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": "Add queue pair management APIs which will be used by Crypto device to\nmanage h/w queues. A bcmfs device structure owns multiple queue-pairs\nbased on the mapped address allocated to it.\n\nSigned-off-by: Vikas Gupta <vikas.gupta@broadcom.com>\nSigned-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>\nReviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>\n---\n drivers/crypto/bcmfs/bcmfs_device.c  |   4 +\n drivers/crypto/bcmfs/bcmfs_device.h  |   5 +\n drivers/crypto/bcmfs/bcmfs_hw_defs.h |  32 +++\n drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++\n drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++\n drivers/crypto/bcmfs/meson.build     |   3 +-\n 6 files changed, 510 insertions(+), 1 deletion(-)\n create mode 100644 drivers/crypto/bcmfs/bcmfs_hw_defs.h\n create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.c\n create mode 100644 drivers/crypto/bcmfs/bcmfs_qp.h",
    "diff": "diff --git a/drivers/crypto/bcmfs/bcmfs_device.c b/drivers/crypto/bcmfs/bcmfs_device.c\nindex 0ccddea202..a01a5c79d5 100644\n--- a/drivers/crypto/bcmfs/bcmfs_device.c\n+++ b/drivers/crypto/bcmfs/bcmfs_device.c\n@@ -12,6 +12,7 @@\n \n #include \"bcmfs_device.h\"\n #include \"bcmfs_logs.h\"\n+#include \"bcmfs_qp.h\"\n #include \"bcmfs_vfio.h\"\n \n struct bcmfs_device_attr {\n@@ -77,6 +78,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,\n \tif (bcmfs_attach_vfio(fsdev))\n \t\tgoto cleanup;\n \n+\t/* Maximum number of QPs supported */\n+\tfsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN;\n+\n \tTAILQ_INSERT_TAIL(&fsdev_list, fsdev, next);\n \n \treturn fsdev;\ndiff --git a/drivers/crypto/bcmfs/bcmfs_device.h b/drivers/crypto/bcmfs/bcmfs_device.h\nindex f99d57d4bd..dede5b82dc 100644\n--- a/drivers/crypto/bcmfs/bcmfs_device.h\n+++ b/drivers/crypto/bcmfs/bcmfs_device.h\n@@ -11,6 +11,7 @@\n #include <rte_bus_vdev.h>\n \n #include \"bcmfs_logs.h\"\n+#include \"bcmfs_qp.h\"\n \n /* max number of dev nodes */\n #define BCMFS_MAX_NODES\t\t4\n@@ -44,6 +45,10 @@ struct bcmfs_device {\n \tuint8_t *mmap_addr;\n \t/* mapped size */\n \tuint32_t mmap_size;\n+\t/* max number of h/w queue pairs detected */\n+\tuint16_t max_hw_qps;\n+\t/* current qpairs in use */\n+\tstruct bcmfs_qp *qps_in_use[BCMFS_MAX_HW_QUEUES];\n };\n \n #endif /* _BCMFS_DEVICE_H_ */\ndiff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h b/drivers/crypto/bcmfs/bcmfs_hw_defs.h\nnew file mode 100644\nindex 0000000000..7d5bb5d8fe\n--- /dev/null\n+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h\n@@ -0,0 +1,32 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _BCMFS_HW_DEFS_H_\n+#define _BCMFS_HW_DEFS_H_\n+\n+#include <rte_atomic.h>\n+#include <rte_byteorder.h>\n+#include <rte_common.h>\n+#include <rte_io.h>\n+\n+#ifndef BIT\n+#define BIT(nr)         (1UL << (nr))\n+#endif\n+\n+#define FS_RING_REGS_SIZE\t\t0x10000\n+#define FS_RING_DESC_SIZE\t\t8\n+#define FS_RING_BD_ALIGN_ORDER\t\t12\n+#define FS_RING_BD_DESC_PER_REQ\t\t32\n+#define FS_RING_CMPL_ALIGN_ORDER\t13\n+#define FS_RING_CMPL_SIZE\t\t(1024 * FS_RING_DESC_SIZE)\n+#define FS_RING_MAX_REQ_COUNT\t\t1024\n+#define FS_RING_PAGE_SHFT\t\t12\n+#define FS_RING_PAGE_SIZE\t\tBIT(FS_RING_PAGE_SHFT)\n+\n+/* Minimum and maximum number of requests supported */\n+#define FS_RM_MAX_REQS\t\t\t4096\n+#define FS_RM_MIN_REQS\t\t\t32\n+\n+#endif /* BCMFS_HW_DEFS_H_ */\ndiff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c\nnew file mode 100644\nindex 0000000000..864e7bb746\n--- /dev/null\n+++ b/drivers/crypto/bcmfs/bcmfs_qp.c\n@@ -0,0 +1,345 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2020 Broadcom.\n+ * All rights reserved.\n+ */\n+\n+#include <inttypes.h>\n+\n+#include <rte_atomic.h>\n+#include <rte_bitmap.h>\n+#include <rte_common.h>\n+#include <rte_dev.h>\n+#include <rte_malloc.h>\n+#include <rte_memzone.h>\n+#include <rte_prefetch.h>\n+#include <rte_string_fns.h>\n+\n+#include \"bcmfs_logs.h\"\n+#include \"bcmfs_qp.h\"\n+#include \"bcmfs_hw_defs.h\"\n+\n+/* TX or submission queue name */\n+static const char *txq_name = \"tx\";\n+/* Completion or receive queue name */\n+static const char *cmplq_name = \"cmpl\";\n+\n+/* Helper function */\n+static int\n+bcmfs_qp_check_queue_alignment(uint64_t phys_addr,\n+\t\t\t       uint32_t align)\n+{\n+\tif (((align - 1) & phys_addr) != 0)\n+\t\treturn -EINVAL;\n+\treturn 0;\n+}\n+\n+static void\n+bcmfs_queue_delete(struct bcmfs_queue *queue,\n+\t\t   uint16_t queue_pair_id)\n+{\n+\tconst struct rte_memzone *mz;\n+\tint status = 0;\n+\n+\tif (queue == NULL) {\n+\t\tBCMFS_LOG(DEBUG, \"Invalid queue\");\n+\t\treturn;\n+\t}\n+\tBCMFS_LOG(DEBUG, \"Free ring %d type %d, memzone: %s\",\n+\t\t  queue_pair_id, queue->q_type, queue->memz_name);\n+\n+\tmz = rte_memzone_lookup(queue->memz_name);\n+\tif (mz != NULL)\t{\n+\t\t/* Write an unused pattern to the queue memory. */\n+\t\tmemset(queue->base_addr, 0x9B, queue->queue_size);\n+\t\tstatus = rte_memzone_free(mz);\n+\t\tif (status != 0)\n+\t\t\tBCMFS_LOG(ERR, \"Error %d on freeing queue %s\",\n+\t\t\t\t\tstatus, queue->memz_name);\n+\t} else {\n+\t\tBCMFS_LOG(DEBUG, \"queue %s doesn't exist\",\n+\t\t\t\tqueue->memz_name);\n+\t}\n+}\n+\n+static const struct rte_memzone *\n+queue_dma_zone_reserve(const char *queue_name, uint32_t queue_size,\n+\t\t       int socket_id, unsigned int align)\n+{\n+\tconst struct rte_memzone *mz;\n+\n+\tmz = rte_memzone_lookup(queue_name);\n+\tif (mz != NULL) {\n+\t\tif (((size_t)queue_size <= mz->len) &&\n+\t\t    (socket_id == SOCKET_ID_ANY ||\n+\t\t     socket_id == mz->socket_id)) {\n+\t\t\tBCMFS_LOG(DEBUG, \"re-use memzone already \"\n+\t\t\t\t\t\"allocated for %s\", queue_name);\n+\t\t\treturn mz;\n+\t\t}\n+\n+\t\tBCMFS_LOG(ERR, \"Incompatible memzone already \"\n+\t\t\t\t\"allocated %s, size %u, socket %d. \"\n+\t\t\t\t\"Requested size %u, socket %u\",\n+\t\t\t\tqueue_name, (uint32_t)mz->len,\n+\t\t\t\tmz->socket_id, queue_size, socket_id);\n+\t\treturn NULL;\n+\t}\n+\n+\tBCMFS_LOG(DEBUG, \"Allocate memzone for %s, size %u on socket %u\",\n+\t\t  queue_name, queue_size, socket_id);\n+\treturn rte_memzone_reserve_aligned(queue_name, queue_size,\n+\t\tsocket_id, RTE_MEMZONE_IOVA_CONTIG, align);\n+}\n+\n+static int\n+bcmfs_queue_create(struct bcmfs_queue *queue,\n+\t\t   struct bcmfs_qp_config *qp_conf,\n+\t\t   uint16_t queue_pair_id,\n+\t\t   enum bcmfs_queue_type qtype)\n+{\n+\tconst struct rte_memzone *qp_mz;\n+\tchar q_name[16];\n+\tunsigned int align;\n+\tuint32_t queue_size_bytes;\n+\tint ret;\n+\n+\tif (qtype == BCMFS_RM_TXQ) {\n+\t\tstrlcpy(q_name, txq_name, sizeof(q_name));\n+\t\talign = 1U << FS_RING_BD_ALIGN_ORDER;\n+\t\tqueue_size_bytes = qp_conf->nb_descriptors *\n+\t\t\t\t   qp_conf->max_descs_req * FS_RING_DESC_SIZE;\n+\t\tqueue_size_bytes = RTE_ALIGN_MUL_CEIL(queue_size_bytes,\n+\t\t\t\t\t\t      FS_RING_PAGE_SIZE);\n+\t\t/* make queue size to multiple for 4K pages */\n+\t} else if (qtype == BCMFS_RM_CPLQ) {\n+\t\tstrlcpy(q_name, cmplq_name, sizeof(q_name));\n+\t\talign = 1U << FS_RING_CMPL_ALIGN_ORDER;\n+\n+\t\t/*\n+\t\t * Memory size for cmpl + MSI\n+\t\t * For MSI allocate here itself and so we allocate twice\n+\t\t */\n+\t\tqueue_size_bytes = 2 * FS_RING_CMPL_SIZE;\n+\t} else {\n+\t\tBCMFS_LOG(ERR, \"Invalid queue selection\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tqueue->q_type = qtype;\n+\n+\t/*\n+\t * Allocate a memzone for the queue - create a unique name.\n+\t */\n+\tsnprintf(queue->memz_name, sizeof(queue->memz_name),\n+\t\t \"%s_%d_%s_%d_%s\", \"bcmfs\", qtype, \"qp_mem\",\n+\t\t queue_pair_id, q_name);\n+\tqp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes,\n+\t\t\t\t       0, align);\n+\tif (qp_mz == NULL) {\n+\t\tBCMFS_LOG(ERR, \"Failed to allocate ring memzone\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tif (bcmfs_qp_check_queue_alignment(qp_mz->iova, align)) {\n+\t\tBCMFS_LOG(ERR, \"Invalid alignment on queue create \"\n+\t\t\t\t\t\" 0x%\" PRIx64 \"\\n\",\n+\t\t\t\t\tqueue->base_phys_addr);\n+\t\tret = -EFAULT;\n+\t\tgoto queue_create_err;\n+\t}\n+\n+\tqueue->base_addr = (char *)qp_mz->addr;\n+\tqueue->base_phys_addr = qp_mz->iova;\n+\tqueue->queue_size = queue_size_bytes;\n+\n+\treturn 0;\n+\n+queue_create_err:\n+\trte_memzone_free(qp_mz);\n+\n+\treturn ret;\n+}\n+\n+int\n+bcmfs_qp_release(struct bcmfs_qp **qp_addr)\n+{\n+\tstruct bcmfs_qp *qp = *qp_addr;\n+\n+\tif (qp == NULL) {\n+\t\tBCMFS_LOG(DEBUG, \"qp already freed\");\n+\t\treturn 0;\n+\t}\n+\n+\t/* Don't free memory if there are still responses to be processed */\n+\tif ((qp->stats.enqueued_count - qp->stats.dequeued_count) == 0) {\n+\t\t/* Stop the h/w ring */\n+\t\tqp->ops->stopq(qp);\n+\t\t/* Delete the queue pairs */\n+\t\tbcmfs_queue_delete(&qp->tx_q, qp->qpair_id);\n+\t\tbcmfs_queue_delete(&qp->cmpl_q, qp->qpair_id);\n+\t} else {\n+\t\treturn -EAGAIN;\n+\t}\n+\n+\trte_bitmap_reset(qp->ctx_bmp);\n+\trte_free(qp->ctx_bmp_mem);\n+\trte_free(qp->ctx_pool);\n+\n+\trte_free(qp);\n+\t*qp_addr = NULL;\n+\n+\treturn 0;\n+}\n+\n+int\n+bcmfs_qp_setup(struct bcmfs_qp **qp_addr,\n+\t       uint16_t queue_pair_id,\n+\t       struct bcmfs_qp_config *qp_conf)\n+{\n+\tstruct bcmfs_qp *qp;\n+\tuint32_t bmp_size;\n+\tuint32_t nb_descriptors = qp_conf->nb_descriptors;\n+\tuint16_t i;\n+\tint rc;\n+\n+\tif (nb_descriptors < FS_RM_MIN_REQS) {\n+\t\tBCMFS_LOG(ERR, \"Can't create qp for %u descriptors\",\n+\t\t\t  nb_descriptors);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (nb_descriptors > FS_RM_MAX_REQS)\n+\t\tnb_descriptors = FS_RM_MAX_REQS;\n+\n+\tif (qp_conf->iobase == NULL) {\n+\t\tBCMFS_LOG(ERR, \"IO onfig space null\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tqp = rte_zmalloc_socket(\"BCM FS PMD qp metadata\",\n+\t\t\t\tsizeof(*qp), RTE_CACHE_LINE_SIZE,\n+\t\t\t\tqp_conf->socket_id);\n+\tif (qp == NULL) {\n+\t\tBCMFS_LOG(ERR, \"Failed to alloc mem for qp struct\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tqp->qpair_id = queue_pair_id;\n+\tqp->ioreg = qp_conf->iobase;\n+\tqp->nb_descriptors = nb_descriptors;\n+\n+\tqp->stats.enqueued_count = 0;\n+\tqp->stats.dequeued_count = 0;\n+\n+\trc = bcmfs_queue_create(&qp->tx_q, qp_conf, qp->qpair_id,\n+\t\t\t\tBCMFS_RM_TXQ);\n+\tif (rc) {\n+\t\tBCMFS_LOG(ERR, \"Tx queue create failed queue_pair_id %u\",\n+\t\t\t  queue_pair_id);\n+\t\tgoto create_err;\n+\t}\n+\n+\trc = bcmfs_queue_create(&qp->cmpl_q, qp_conf, qp->qpair_id,\n+\t\t\t\tBCMFS_RM_CPLQ);\n+\tif (rc) {\n+\t\tBCMFS_LOG(ERR, \"Cmpl queue create failed queue_pair_id= %u\",\n+\t\t\t  queue_pair_id);\n+\t\tgoto q_create_err;\n+\t}\n+\n+\t/* ctx saving bitmap */\n+\tbmp_size = rte_bitmap_get_memory_footprint(nb_descriptors);\n+\n+\t/* Allocate memory for bitmap */\n+\tqp->ctx_bmp_mem = rte_zmalloc(\"ctx_bmp_mem\", bmp_size,\n+\t\t\t\t      RTE_CACHE_LINE_SIZE);\n+\tif (qp->ctx_bmp_mem == NULL) {\n+\t\trc = -ENOMEM;\n+\t\tgoto qp_create_err;\n+\t}\n+\n+\t/* Initialize pool resource bitmap array */\n+\tqp->ctx_bmp = rte_bitmap_init(nb_descriptors, qp->ctx_bmp_mem,\n+\t\t\t\t      bmp_size);\n+\tif (qp->ctx_bmp == NULL) {\n+\t\trc = -EINVAL;\n+\t\tgoto bmap_mem_free;\n+\t}\n+\n+\t/* Mark all pools available */\n+\tfor (i = 0; i < nb_descriptors; i++)\n+\t\trte_bitmap_set(qp->ctx_bmp, i);\n+\n+\t/* Allocate memory for context */\n+\tqp->ctx_pool = rte_zmalloc(\"qp_ctx_pool\",\n+\t\t\t\t   sizeof(unsigned long) *\n+\t\t\t\t   nb_descriptors, 0);\n+\tif (qp->ctx_pool == NULL) {\n+\t\tBCMFS_LOG(ERR, \"ctx allocation pool fails\");\n+\t\trc = -ENOMEM;\n+\t\tgoto bmap_free;\n+\t}\n+\n+\t/* Start h/w ring */\n+\tqp->ops->startq(qp);\n+\n+\t*qp_addr = qp;\n+\n+\treturn 0;\n+\n+bmap_free:\n+\trte_bitmap_reset(qp->ctx_bmp);\n+bmap_mem_free:\n+\trte_free(qp->ctx_bmp_mem);\n+qp_create_err:\n+\tbcmfs_queue_delete(&qp->cmpl_q, queue_pair_id);\n+q_create_err:\n+\tbcmfs_queue_delete(&qp->tx_q, queue_pair_id);\n+create_err:\n+\trte_free(qp);\n+\n+\treturn rc;\n+}\n+\n+uint16_t\n+bcmfs_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops)\n+{\n+\tstruct bcmfs_qp *tmp_qp = (struct bcmfs_qp *)qp;\n+\tregister uint32_t nb_ops_sent = 0;\n+\tuint16_t nb_ops_possible = nb_ops;\n+\tint ret;\n+\n+\tif (unlikely(nb_ops == 0))\n+\t\treturn 0;\n+\n+\twhile (nb_ops_sent != nb_ops_possible) {\n+\t\tret = tmp_qp->ops->enq_one_req(qp, *ops);\n+\t\tif (ret != 0) {\n+\t\t\ttmp_qp->stats.enqueue_err_count++;\n+\t\t\t/* This message cannot be enqueued */\n+\t\t\tif (nb_ops_sent == 0)\n+\t\t\t\treturn 0;\n+\t\t\tgoto ring_db;\n+\t\t}\n+\n+\t\tops++;\n+\t\tnb_ops_sent++;\n+\t}\n+\n+ring_db:\n+\ttmp_qp->stats.enqueued_count += nb_ops_sent;\n+\ttmp_qp->ops->ring_db(tmp_qp);\n+\n+\treturn nb_ops_sent;\n+}\n+\n+uint16_t\n+bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops)\n+{\n+\tstruct bcmfs_qp *tmp_qp = (struct bcmfs_qp *)qp;\n+\tuint32_t deq = tmp_qp->ops->dequeue(tmp_qp, ops, nb_ops);\n+\n+\ttmp_qp->stats.dequeued_count += deq;\n+\n+\treturn deq;\n+}\ndiff --git a/drivers/crypto/bcmfs/bcmfs_qp.h b/drivers/crypto/bcmfs/bcmfs_qp.h\nnew file mode 100644\nindex 0000000000..52c487956e\n--- /dev/null\n+++ b/drivers/crypto/bcmfs/bcmfs_qp.h\n@@ -0,0 +1,122 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _BCMFS_QP_H_\n+#define _BCMFS_QP_H_\n+\n+#include <rte_memzone.h>\n+\n+/* Maximum number of h/w queues supported by device */\n+#define BCMFS_MAX_HW_QUEUES\t\t32\n+\n+/* H/W queue IO address space len */\n+#define BCMFS_HW_QUEUE_IO_ADDR_LEN\t(64 * 1024)\n+\n+/* Maximum size of device ops name */\n+#define BCMFS_HW_OPS_NAMESIZE\t\t32\n+\n+enum bcmfs_queue_type {\n+\t/* TX or submission queue */\n+\tBCMFS_RM_TXQ,\n+\t /* Completion or receive queue */\n+\tBCMFS_RM_CPLQ\n+};\n+\n+struct bcmfs_qp_stats {\n+\t/* Count of all operations enqueued */\n+\tuint64_t enqueued_count;\n+\t/* Count of all operations dequeued */\n+\tuint64_t dequeued_count;\n+\t/* Total error count on operations enqueued */\n+\tuint64_t enqueue_err_count;\n+\t/* Total error count on operations dequeued */\n+\tuint64_t dequeue_err_count;\n+};\n+\n+struct bcmfs_qp_config {\n+\t/* Socket to allocate memory on */\n+\tint socket_id;\n+\t/* Mapped iobase for qp */\n+\tvoid *iobase;\n+\t/* nb_descriptors or requests a h/w queue can accommodate */\n+\tuint16_t nb_descriptors;\n+\t/* Maximum number of h/w descriptors needed by a request */\n+\tuint16_t max_descs_req;\n+};\n+\n+struct bcmfs_queue {\n+\t/* Base virt address */\n+\tvoid *base_addr;\n+\t/* Base iova */\n+\trte_iova_t base_phys_addr;\n+\t/* Queue type */\n+\tenum bcmfs_queue_type q_type;\n+\t/* Queue size based on nb_descriptors and max_descs_reqs */\n+\tuint32_t queue_size;\n+\tunion {\n+\t\t/* s/w pointer for tx h/w queue*/\n+\t\tuint32_t tx_write_ptr;\n+\t\t/* s/w pointer for completion h/w queue*/\n+\t\tuint32_t cmpl_read_ptr;\n+\t};\n+\t/* Memzone name */\n+\tchar memz_name[RTE_MEMZONE_NAMESIZE];\n+};\n+\n+struct bcmfs_qp {\n+\t/* Queue-pair ID */\n+\tuint16_t qpair_id;\n+\t/* Mapped IO address */\n+\tvoid *ioreg;\n+\t/* A TX queue */\n+\tstruct bcmfs_queue tx_q;\n+\t/* A Completion queue */\n+\tstruct bcmfs_queue cmpl_q;\n+\t/* Number of requests queue can accommodate */\n+\tuint32_t nb_descriptors;\n+\t/* Number of pending requests and enqueued to h/w queue */\n+\tuint16_t nb_pending_requests;\n+\t/* A pool which act as a hash for <request-ID and virt address> pair */\n+\tunsigned long *ctx_pool;\n+\t/* virt address for mem allocated for bitmap */\n+\tvoid *ctx_bmp_mem;\n+\t/* Bitmap */\n+\tstruct rte_bitmap *ctx_bmp;\n+\t/* Associated stats */\n+\tstruct bcmfs_qp_stats stats;\n+\t/* h/w ops associated with qp */\n+\tstruct bcmfs_hw_queue_pair_ops *ops;\n+\n+} __rte_cache_aligned;\n+\n+/* Structure defining h/w queue pair operations */\n+struct bcmfs_hw_queue_pair_ops {\n+\t/* ops name */\n+\tchar name[BCMFS_HW_OPS_NAMESIZE];\n+\t/* Enqueue an object */\n+\tint (*enq_one_req)(struct bcmfs_qp *qp, void *obj);\n+\t/* Ring doorbell */\n+\tvoid (*ring_db)(struct bcmfs_qp *qp);\n+\t/* Dequeue objects */\n+\tuint16_t (*dequeue)(struct bcmfs_qp *qp, void **obj,\n+\t\t\t    uint16_t nb_ops);\n+\t/* Start the h/w queue */\n+\tint (*startq)(struct bcmfs_qp *qp);\n+\t/* Stop the h/w queue */\n+\tvoid (*stopq)(struct bcmfs_qp *qp);\n+};\n+\n+uint16_t\n+bcmfs_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops);\n+uint16_t\n+bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops);\n+int\n+bcmfs_qp_release(struct bcmfs_qp **qp_addr);\n+int\n+bcmfs_qp_setup(struct bcmfs_qp **qp_addr,\n+\t       uint16_t queue_pair_id,\n+\t       struct bcmfs_qp_config *bcmfs_conf);\n+\n+#endif /* _BCMFS_QP_H_ */\ndiff --git a/drivers/crypto/bcmfs/meson.build b/drivers/crypto/bcmfs/meson.build\nindex fd39eba20e..7e2bcbf14b 100644\n--- a/drivers/crypto/bcmfs/meson.build\n+++ b/drivers/crypto/bcmfs/meson.build\n@@ -7,5 +7,6 @@ deps += ['eal', 'bus_vdev']\n sources = files(\n \t\t'bcmfs_logs.c',\n \t\t'bcmfs_device.c',\n-\t\t'bcmfs_vfio.c'\n+\t\t'bcmfs_vfio.c',\n+\t\t'bcmfs_qp.c'\n \t\t)\n",
    "prefixes": [
        "v4",
        "3/8"
    ]
}