get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 75448,
    "url": "http://patches.dpdk.org/api/patches/75448/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200812063127.8687-4-vikas.gupta@broadcom.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": "<20200812063127.8687-4-vikas.gupta@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200812063127.8687-4-vikas.gupta@broadcom.com",
    "date": "2020-08-12T06:31:22",
    "name": "[v1,3/8] crypto/bcmfs: add apis for queue pair management",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d17fd8e921d0651b7f0915b3d5288b92270114cc",
    "submitter": {
        "id": 1907,
        "url": "http://patches.dpdk.org/api/people/1907/?format=api",
        "name": "Vikas Gupta",
        "email": "vikas.gupta@broadcom.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200812063127.8687-4-vikas.gupta@broadcom.com/mbox/",
    "series": [
        {
            "id": 11611,
            "url": "http://patches.dpdk.org/api/series/11611/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=11611",
            "date": "2020-08-12T06:31:19",
            "name": "Add Crypto PMD for Broadcom`s FlexSparc devices",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/11611/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/75448/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/75448/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 8F7D4A04C2;\n\tWed, 12 Aug 2020 08:32:20 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 751B21C0C9;\n\tWed, 12 Aug 2020 08:31:52 +0200 (CEST)",
            "from mail-qk1-f195.google.com (mail-qk1-f195.google.com\n [209.85.222.195]) by dpdk.org (Postfix) with ESMTP id 48C2D1C025\n for <dev@dpdk.org>; Wed, 12 Aug 2020 08:31:51 +0200 (CEST)",
            "by mail-qk1-f195.google.com with SMTP id m7so1117952qki.12\n for <dev@dpdk.org>; Tue, 11 Aug 2020 23:31:51 -0700 (PDT)",
            "from rahul_yocto_ubuntu18.ibn.broadcom.net ([192.19.234.250])\n by smtp.gmail.com with ESMTPSA id x3sm1301552qkx.3.2020.08.11.23.31.46\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 11 Aug 2020 23:31:49 -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=2XsR9cEA4NtR7q7qp3i+swYxtp7XKJGvOSiBLTGPnFE=;\n b=IlLAnzhpQl3cgx8xg4o4RMLHnP6sh51aXlKbxPPZ/dNH+gB58RCHOoFgjI+szTx5Y6\n GyOYp9zjQLdpQbTjddzfkerjliUNqmoGqbJGRYe6S0hNe5ygcDA0orudvI6oifgniy4Y\n kRlyiWIOnkfCkOOEWW2JNxtrR/jnvs7GPDMbA=",
        "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=2XsR9cEA4NtR7q7qp3i+swYxtp7XKJGvOSiBLTGPnFE=;\n b=kUj06rlVAGD6pYuf6Nj2chMF8BNw5OC+D9XaT3OcNlZszeoW00FBUeuU11q383JYLd\n GDy/BmyX564XcA42pHFcLsWsOUUv304Gi9kjmMFmz142tKob+ejJ+waIanoPipIjQ1An\n 5pb3dfCX/OI6YXgxqJlFT00h/xUp0urDtNvY0AJqVU+ZIkSVOGKuPeWclufmnO2DFqLq\n DfqsILUjA9mp44TMBaOM+iL1i1/apOXW+Ppp4qVfmDG08RnyE38z0SVnthNyKbG5oGGP\n kmNIV1uniGe7LkCbg3PkF02o+C14ZNF5Ce5GuFFRrXQSX8UJ2FZLs+jifZ7RbflnP/Oy\n ohng==",
        "X-Gm-Message-State": "AOAM5322tNf6WxzVIL10LNPywvhlsGDmyNeIAozJaBbEDDsn47p/Nw7g\n N/1vpRCFyL3OVIfFytPczqwzVLVZHI/B49Lttko/u7fYLesSqJCcucOlXHtAIv7C2kOxa+hsijY\n TGsmBRz2ugblcmx1rNBMVN6gie/AYfQUfvTukmMWPISKQ9PC0FsKuPNLMQOSV",
        "X-Google-Smtp-Source": "\n ABdhPJy0eKQWO/rK/QMV1qLVa2hLdK8A9McOV2si+0Ci3QmwH2gVvY4gnXQqxKh5qbxcoKmiCqFB0g==",
        "X-Received": "by 2002:a37:7245:: with SMTP id n66mr4646773qkc.83.1597213909610;\n Tue, 11 Aug 2020 23:31:49 -0700 (PDT)",
        "From": "Vikas Gupta <vikas.gupta@broadcom.com>",
        "To": "dev@dpdk.org,\n\takhil.goyal@nxp.com",
        "Cc": "ajit.khaparde@broadcom.com, vikram.prakash@broadcom.com,\n Vikas Gupta <vikas.gupta@broadcom.com>,\n Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>",
        "Date": "Wed, 12 Aug 2020 12:01:22 +0530",
        "Message-Id": "<20200812063127.8687-4-vikas.gupta@broadcom.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200812063127.8687-1-vikas.gupta@broadcom.com>",
        "References": "<20200811145813.44754-1-vikas.gupta@broadcom.com>\n <20200812063127.8687-1-vikas.gupta@broadcom.com>",
        "Subject": "[dpdk-dev] [PATCH v1 3/8] crypto/bcmfs: add apis for queue pair\n\tmanagement",
        "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/Makefile        |  28 ---\n drivers/crypto/bcmfs/bcmfs_device.c  |   4 +\n drivers/crypto/bcmfs/bcmfs_device.h  |   5 +\n drivers/crypto/bcmfs/bcmfs_hw_defs.h |  38 +++\n drivers/crypto/bcmfs/bcmfs_qp.c      | 345 +++++++++++++++++++++++++++\n drivers/crypto/bcmfs/bcmfs_qp.h      | 122 ++++++++++\n drivers/crypto/bcmfs/meson.build     |   3 +-\n 7 files changed, 516 insertions(+), 29 deletions(-)\n delete mode 100644 drivers/crypto/bcmfs/Makefile\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/Makefile b/drivers/crypto/bcmfs/Makefile\ndeleted file mode 100644\nindex 5f691f7ba..000000000\n--- a/drivers/crypto/bcmfs/Makefile\n+++ /dev/null\n@@ -1,28 +0,0 @@\n-# SPDX-License-Identifier: BSD-3-Clause\n-# Copyright(C) 2020 Broadcom\n-# All rights reserved.\n-#\n-\n-include $(RTE_SDK)/mk/rte.vars.mk\n-\n-#\n-# library name\n-#\n-LIB = librte_pmd_bcmfs.a\n-\n-CFLAGS += $(WERROR_FLAGS)\n-CFLAGS += -I$(RTE_SDK)/drivers/crypto/bcmfs\n-CFLAGS += -DALLOW_EXPERIMENTAL_API\n-\n-#\n-# all source are stored in SRCS-y\n-#\n-SRCS-y += bcmfs_logs.c\n-SRCS-y += bcmfs_device.c\n-SRCS-y += bcmfs_vfio.c\n-\n-LDLIBS += -lrte_eal -lrte_bus_vdev\n-\n-EXPORT_MAP := rte_pmd_bcmfs_version.map\n-\n-include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/drivers/crypto/bcmfs/bcmfs_device.c b/drivers/crypto/bcmfs/bcmfs_device.c\nindex 3b5cc9e98..b475c2933 100644\n--- a/drivers/crypto/bcmfs/bcmfs_device.c\n+++ b/drivers/crypto/bcmfs/bcmfs_device.c\n@@ -11,6 +11,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@@ -76,6 +77,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 5232bdea5..e03ce5b5b 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@@ -41,6 +42,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_DEV_H_ */\ndiff --git a/drivers/crypto/bcmfs/bcmfs_hw_defs.h b/drivers/crypto/bcmfs/bcmfs_hw_defs.h\nnew file mode 100644\nindex 000000000..ecb0c09ba\n--- /dev/null\n+++ b/drivers/crypto/bcmfs/bcmfs_hw_defs.h\n@@ -0,0 +1,38 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _BCMFS_RM_DEFS_H_\n+#define _BCMFS_RM_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+/* 32-bit MMIO register write */\n+#define FS_MMIO_WRITE32(value, addr) rte_write32_relaxed((value), (addr))\n+\n+/* 32-bit MMIO register read */\n+#define FS_MMIO_READ32(addr) rte_read32_relaxed((addr))\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\t1024\n+#define FS_RM_MIN_REQS\t\t\t32\n+\n+#endif /* BCMFS_RM_DEFS_H_ */\ndiff --git a/drivers/crypto/bcmfs/bcmfs_qp.c b/drivers/crypto/bcmfs/bcmfs_qp.c\nnew file mode 100644\nindex 000000000..864e7bb74\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 000000000..027d7a50c\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 acommodate */\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 fd39eba20..7e2bcbf14 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": [
        "v1",
        "3/8"
    ]
}