Show a patch.

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

{
    "id": 41046,
    "url": "http://patches.dpdk.org/api/patches/41046/",
    "web_url": "http://patches.dpdk.org/patch/41046/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<1528892062-4997-14-git-send-email-tomaszx.jozwiak@intel.com>",
    "date": "2018-06-13T12:13:57",
    "name": "[v3,13/38] crypto/qat: remove dependencies on cryptodev from common",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "9e297da5085d60601850af4e3c172845ae08bae3",
    "submitter": {
        "id": 949,
        "url": "http://patches.dpdk.org/api/people/949/",
        "name": "Tomasz Jozwiak",
        "email": "tomaszx.jozwiak@intel.com"
    },
    "delegate": {
        "id": 22,
        "url": "http://patches.dpdk.org/api/users/22/",
        "username": "pdelarag",
        "first_name": "Pablo",
        "last_name": "de Lara Guarch",
        "email": "pablo.de.lara.guarch@intel.com"
    },
    "mbox": "http://patches.dpdk.org/patch/41046/mbox/",
    "series": [
        {
            "id": 111,
            "url": "http://patches.dpdk.org/api/series/111/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=111",
            "date": "2018-06-13T12:13:44",
            "name": "crypto/qat: refactor to support multiple services",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/111/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/41046/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/41046/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Mailer": "git-send-email 2.7.4",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 609A01EF8A;\n\tWed, 13 Jun 2018 14:15:01 +0200 (CEST)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 812371EF26\n\tfor <dev@dpdk.org>; Wed, 13 Jun 2018 14:14:59 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t13 Jun 2018 05:14:58 -0700",
            "from tjozwiax-mobl.ger.corp.intel.com (HELO localhost.localdomain)\n\t([10.103.104.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 13 Jun 2018 05:14:43 -0700"
        ],
        "References": "<1523040732-3290-1-git-send-email-fiona.trahe@intel.com>\n\t<1528892062-4997-1-git-send-email-tomaszx.jozwiak@intel.com>",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<1528892062-4997-14-git-send-email-tomaszx.jozwiak@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,218,1526367600\"; d=\"scan'208\";a=\"63727703\"",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Precedence": "list",
        "From": "Tomasz Jozwiak <tomaszx.jozwiak@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": "<1528892062-4997-1-git-send-email-tomaszx.jozwiak@intel.com>",
        "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "fiona.trahe@intel.com,\n\ttomaszx.jozwiak@intel.com,\n\tdev@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Unsubscribe": "<https://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Wed, 13 Jun 2018 14:13:57 +0200",
        "X-Amp-File-Uploaded": "False",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v3 13/38] crypto/qat: remove dependencies on\n\tcryptodev from common"
    },
    "content": "From: Fiona Trahe <fiona.trahe@intel.com>\n\nRemove dependence on rte_cryptodev from common qp code\nto facilitate being used by other device types in future.\nTransferred required data into qat-specific structures.\n\nSigned-off-by: Fiona Trahe <fiona.trahe@intel.com>\n---\n drivers/crypto/qat/qat_device.h        | 11 ++++-\n drivers/crypto/qat/qat_qp.c            | 67 ++++++++++++++------------\n drivers/crypto/qat/qat_qp.h            |  8 ++-\n drivers/crypto/qat/qat_sym.c           | 15 ++++--\n drivers/crypto/qat/rte_qat_cryptodev.c |  4 +-\n 5 files changed, 66 insertions(+), 39 deletions(-)",
    "diff": "diff --git a/drivers/crypto/qat/qat_device.h b/drivers/crypto/qat/qat_device.h\nindex 2cb8e7612..64706abae 100644\n--- a/drivers/crypto/qat/qat_device.h\n+++ b/drivers/crypto/qat/qat_device.h\n@@ -14,7 +14,11 @@ extern uint8_t cryptodev_qat_driver_id;\n extern int qat_sym_qp_release(struct rte_cryptodev *dev,\n \tuint16_t queue_pair_id);\n \n-/** private data structure for each QAT device */\n+/** private data structure for each QAT device.\n+ * In this context a QAT device is a device offering only one service,\n+ * so there can be more than 1 device on a pci_dev (VF),\n+ * one for symmetric crypto, one for compression\n+ */\n struct qat_pmd_private {\n \tunsigned int max_nb_queue_pairs;\n \t/**< Max number of queue pairs supported by device */\n@@ -23,6 +27,11 @@ struct qat_pmd_private {\n \tenum qat_device_gen qat_dev_gen;\n \t/**< QAT device generation */\n \tconst struct rte_cryptodev_capabilities *qat_dev_capabilities;\n+\t/* QAT device capabilities */\n+\tstruct rte_pci_device *pci_dev;\n+\t/**< PCI information. */\n+\tuint8_t dev_id;\n+\t/**< Device ID for this instance */\n };\n \n int qat_dev_config(struct rte_cryptodev *dev,\ndiff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c\nindex d1d2be34f..b831ab420 100644\n--- a/drivers/crypto/qat/qat_qp.c\n+++ b/drivers/crypto/qat/qat_qp.c\n@@ -6,7 +6,6 @@\n #include <rte_dev.h>\n #include <rte_malloc.h>\n #include <rte_memzone.h>\n-#include <rte_cryptodev_pmd.h>\n #include <rte_pci.h>\n #include <rte_bus_pci.h>\n #include <rte_atomic.h>\n@@ -31,7 +30,7 @@\n static int qat_qp_check_queue_alignment(uint64_t phys_addr,\n \tuint32_t queue_size_bytes);\n static void qat_queue_delete(struct qat_queue *queue);\n-static int qat_queue_create(struct rte_cryptodev *dev,\n+static int qat_queue_create(struct qat_pmd_private *qat_dev,\n \tstruct qat_queue *queue, struct qat_qp_config *, uint8_t dir);\n static int adf_verify_queue_size(uint32_t msg_size, uint32_t msg_num,\n \tuint32_t *queue_size_for_csr);\n@@ -70,14 +69,19 @@ queue_dma_zone_reserve(const char *queue_name, uint32_t queue_size,\n \t\tsocket_id, RTE_MEMZONE_IOVA_CONTIG, queue_size);\n }\n \n-int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,\n+int qat_qp_setup(struct qat_pmd_private *qat_dev,\n+\t\tstruct qat_qp **qp_addr,\n+\t\tuint16_t queue_pair_id,\n \t\tstruct qat_qp_config *qat_qp_conf)\n+\n {\n \tstruct qat_qp *qp;\n-\tstruct rte_pci_device *pci_dev;\n+\tstruct rte_pci_device *pci_dev = qat_dev->pci_dev;\n \tchar op_cookie_pool_name[RTE_RING_NAMESIZE];\n \tuint32_t i;\n \n+\tPMD_DRV_LOG(DEBUG, \"Setup qp %u on device %d gen %d\",\n+\t\t\tqueue_pair_id, qat_dev->dev_id, qat_dev->qat_dev_gen);\n \n \tif ((qat_qp_conf->nb_descriptors > ADF_MAX_DESC) ||\n \t\t(qat_qp_conf->nb_descriptors < ADF_MIN_DESC)) {\n@@ -86,8 +90,6 @@ int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,\n \t\treturn -EINVAL;\n \t}\n \n-\tpci_dev = RTE_DEV_TO_PCI(dev->device);\n-\n \tif (pci_dev->mem_resource[0].addr == NULL) {\n \t\tPMD_DRV_LOG(ERR, \"Could not find VF config space \"\n \t\t\t\t\"(UIO driver attached?).\");\n@@ -114,14 +116,14 @@ int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,\n \tqp->mmap_bar_addr = pci_dev->mem_resource[0].addr;\n \tqp->inflights16 = 0;\n \n-\tif (qat_queue_create(dev, &(qp->tx_q), qat_qp_conf,\n+\tif (qat_queue_create(qat_dev, &(qp->tx_q), qat_qp_conf,\n \t\t\t\t\tADF_RING_DIR_TX) != 0) {\n \t\tPMD_INIT_LOG(ERR, \"Tx queue create failed \"\n \t\t\t\t\"queue_pair_id=%u\", queue_pair_id);\n \t\tgoto create_err;\n \t}\n \n-\tif (qat_queue_create(dev, &(qp->rx_q), qat_qp_conf,\n+\tif (qat_queue_create(qat_dev, &(qp->rx_q), qat_qp_conf,\n \t\t\t\t\tADF_RING_DIR_RX) != 0) {\n \t\tPMD_DRV_LOG(ERR, \"Rx queue create failed \"\n \t\t\t\t\"queue_pair_id=%hu\", queue_pair_id);\n@@ -134,7 +136,7 @@ int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,\n \n \tsnprintf(op_cookie_pool_name, RTE_RING_NAMESIZE, \"%s_%s_qp_op_%d_%hu\",\n \t\tpci_dev->driver->driver.name, qat_qp_conf->service_str,\n-\t\tdev->data->dev_id, queue_pair_id);\n+\t\tqat_dev->dev_id, queue_pair_id);\n \n \tqp->op_cookie_pool = rte_mempool_lookup(op_cookie_pool_name);\n \tif (qp->op_cookie_pool == NULL)\n@@ -156,13 +158,15 @@ int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,\n \t\t}\n \t}\n \n-\tstruct qat_pmd_private *internals\n-\t\t= dev->data->dev_private;\n-\tqp->qat_dev_gen = internals->qat_dev_gen;\n+\tqp->qat_dev_gen = qat_dev->qat_dev_gen;\n \tqp->build_request = qat_qp_conf->build_request;\n \tqp->process_response = qat_qp_conf->process_response;\n+\tqp->qat_dev = qat_dev;\n+\n+\tPMD_DRV_LOG(DEBUG, \"QP setup complete: id: %d, cookiepool: %s\",\n+\t\t\tqueue_pair_id, op_cookie_pool_name);\n \n-\tdev->data->queue_pairs[queue_pair_id] = qp;\n+\t*qp_addr = qp;\n \treturn 0;\n \n create_err:\n@@ -170,10 +174,9 @@ int qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,\n \treturn -EFAULT;\n }\n \n-int qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id)\n+int qat_qp_release(struct qat_qp **qp_addr)\n {\n-\tstruct qat_qp *qp =\n-\t\t\t(struct qat_qp *)dev->data->queue_pairs[queue_pair_id];\n+\tstruct qat_qp *qp = *qp_addr;\n \tuint32_t i;\n \n \tPMD_INIT_FUNC_TRACE();\n@@ -182,6 +185,9 @@ int qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id)\n \t\treturn 0;\n \t}\n \n+\tPMD_DRV_LOG(DEBUG, \"Free qp on qat_pci device %d\",\n+\t\t\tqp->qat_dev->dev_id);\n+\n \t/* Don't free memory if there are still responses to be processed */\n \tif (qp->inflights16 == 0) {\n \t\tqat_queue_delete(&(qp->tx_q));\n@@ -200,13 +206,11 @@ int qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id)\n \n \trte_free(qp->op_cookies);\n \trte_free(qp);\n-\tdev->data->queue_pairs[queue_pair_id] = NULL;\n+\t*qp_addr = NULL;\n \treturn 0;\n }\n \n \n-\n-\n static void qat_queue_delete(struct qat_queue *queue)\n {\n \tconst struct rte_memzone *mz;\n@@ -216,6 +220,9 @@ static void qat_queue_delete(struct qat_queue *queue)\n \t\tPMD_DRV_LOG(DEBUG, \"Invalid queue\");\n \t\treturn;\n \t}\n+\tPMD_DRV_LOG(DEBUG, \"Free ring %d, memzone: %s\",\n+\t\t\tqueue->hw_queue_number, 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@@ -231,13 +238,13 @@ static void qat_queue_delete(struct qat_queue *queue)\n }\n \n static int\n-qat_queue_create(struct rte_cryptodev *dev, struct qat_queue *queue,\n+qat_queue_create(struct qat_pmd_private *qat_dev, struct qat_queue *queue,\n \t\tstruct qat_qp_config *qp_conf, uint8_t dir)\n {\n \tuint64_t queue_base;\n \tvoid *io_addr;\n \tconst struct rte_memzone *qp_mz;\n-\tstruct rte_pci_device *pci_dev;\n+\tstruct rte_pci_device *pci_dev = qat_dev->pci_dev;\n \tint ret = 0;\n \tuint16_t desc_size = (dir == ADF_RING_DIR_TX ?\n \t\t\t\tqp_conf->tx_msg_size : qp_conf->rx_msg_size);\n@@ -252,15 +259,13 @@ qat_queue_create(struct rte_cryptodev *dev, struct qat_queue *queue,\n \t\treturn -EINVAL;\n \t}\n \n-\tpci_dev = RTE_DEV_TO_PCI(dev->device);\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_%s_%s_%d_%d_%d\",\n \t\tpci_dev->driver->driver.name, qp_conf->service_str,\n-\t\t\"qp_mem\", dev->data->dev_id,\n+\t\t\"qp_mem\", qat_dev->dev_id,\n \t\tqueue->hw_bundle_number, queue->hw_queue_number);\n \tqp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes,\n \t\t\tqp_conf->socket_id);\n@@ -290,12 +295,6 @@ qat_queue_create(struct rte_cryptodev *dev, struct qat_queue *queue,\n \tqueue->max_inflights = ADF_MAX_INFLIGHTS(queue->queue_size,\n \t\t\t\t\tADF_BYTES_TO_MSG_SIZE(desc_size));\n \tqueue->modulo = ADF_RING_SIZE_MODULO(queue->queue_size);\n-\tPMD_DRV_LOG(DEBUG, \"RING: Name:%s, size in CSR: %u, in bytes %u,\"\n-\t\t\t\" nb msgs %u, msg_size %u, max_inflights %u modulo %u\",\n-\t\t\tqueue->memz_name,\n-\t\t\tqueue->queue_size, queue_size_bytes,\n-\t\t\tqp_conf->nb_descriptors, desc_size,\n-\t\t\tqueue->max_inflights, queue->modulo);\n \n \tif (queue->max_inflights < 2) {\n \t\tPMD_DRV_LOG(ERR, \"Invalid num inflights\");\n@@ -318,6 +317,14 @@ qat_queue_create(struct rte_cryptodev *dev, struct qat_queue *queue,\n \n \tWRITE_CSR_RING_BASE(io_addr, queue->hw_bundle_number,\n \t\t\tqueue->hw_queue_number, queue_base);\n+\n+\tPMD_DRV_LOG(DEBUG, \"RING: Name:%s, size in CSR: %u, in bytes %u,\"\n+\t\t\t\" nb msgs %u, msg_size %u, max_inflights %u modulo %u\",\n+\t\t\tqueue->memz_name,\n+\t\t\tqueue->queue_size, queue_size_bytes,\n+\t\t\tqp_conf->nb_descriptors, desc_size,\n+\t\t\tqueue->max_inflights, queue->modulo);\n+\n \treturn 0;\n \n queue_create_err:\ndiff --git a/drivers/crypto/qat/qat_qp.h b/drivers/crypto/qat/qat_qp.h\nindex 0cdf37f61..7bd8fdcec 100644\n--- a/drivers/crypto/qat/qat_qp.h\n+++ b/drivers/crypto/qat/qat_qp.h\n@@ -5,6 +5,7 @@\n #define _QAT_QP_H_\n \n #include \"qat_common.h\"\n+#include \"qat_device.h\"\n \n typedef int (*build_request_t)(void *op,\n \t\tuint8_t *req, void *op_cookie,\n@@ -69,6 +70,8 @@ struct qat_qp {\n \tenum qat_device_gen qat_dev_gen;\n \tbuild_request_t build_request;\n \tprocess_response_t process_response;\n+\tstruct qat_pmd_private *qat_dev;\n+\t/**< qat device this qp is on */\n } __rte_cache_aligned;\n \n uint16_t\n@@ -78,9 +81,10 @@ uint16_t\n qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops);\n \n int\n-qat_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id);\n+qat_qp_release(struct qat_qp **qp_addr);\n \n int\n-qat_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,\n+qat_qp_setup(struct qat_pmd_private *qat_dev,\n+\t\tstruct qat_qp **qp_addr, uint16_t queue_pair_id,\n \t\tstruct qat_qp_config *qat_qp_conf);\n #endif /* _QAT_QP_H_ */\ndiff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c\nindex 4f86f2258..8ab95ac43 100644\n--- a/drivers/crypto/qat/qat_sym.c\n+++ b/drivers/crypto/qat/qat_sym.c\n@@ -809,7 +809,10 @@ void qat_sym_stats_reset(struct rte_cryptodev *dev)\n \n int qat_sym_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id)\n {\n-\treturn qat_qp_release(dev, queue_pair_id);\n+\tPMD_DRV_LOG(DEBUG, \"Release sym qp %u on device %d\",\n+\t\t\t\tqueue_pair_id, dev->data->dev_id);\n+\treturn qat_qp_release((struct qat_qp **)\n+\t\t\t&(dev->data->queue_pairs[queue_pair_id]));\n }\n \n int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,\n@@ -820,9 +823,12 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,\n \tint ret = 0;\n \tuint32_t i;\n \tstruct qat_qp_config qat_qp_conf;\n+\tstruct qat_qp **qp_addr =\n+\t\t\t(struct qat_qp **)&(dev->data->queue_pairs[qp_id]);\n+\tstruct qat_pmd_private *qat_private = dev->data->dev_private;\n \n \t/* If qp is already in use free ring memory and qp metadata. */\n-\tif (dev->data->queue_pairs[qp_id] != NULL) {\n+\tif (*qp_addr != NULL) {\n \t\tret = qat_sym_qp_release(dev, qp_id);\n \t\tif (ret < 0)\n \t\t\treturn ret;\n@@ -833,7 +839,6 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,\n \t\treturn -EINVAL;\n \t}\n \n-\n \tqat_qp_conf.hw_bundle_num = (qp_id/ADF_NUM_SYM_QPS_PER_BUNDLE);\n \tqat_qp_conf.tx_ring_num = (qp_id%ADF_NUM_SYM_QPS_PER_BUNDLE) +\n \t\t\tADF_SYM_TX_QUEUE_STARTOFF;\n@@ -848,11 +853,11 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,\n \tqat_qp_conf.socket_id = socket_id;\n \tqat_qp_conf.service_str = \"sym\";\n \n-\tret = qat_qp_setup(dev, qp_id, &qat_qp_conf);\n+\tret = qat_qp_setup(qat_private, qp_addr, qp_id, &qat_qp_conf);\n \tif (ret != 0)\n \t\treturn ret;\n \n-\tqp = (struct qat_qp *)dev->data->queue_pairs[qp_id];\n+\tqp = (struct qat_qp *)*qp_addr;\n \n \tfor (i = 0; i < qp->nb_descriptors; i++) {\n \ndiff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c\nindex 05cb5ef40..fe19b18b6 100644\n--- a/drivers/crypto/qat/rte_qat_cryptodev.c\n+++ b/drivers/crypto/qat/rte_qat_cryptodev.c\n@@ -96,7 +96,9 @@ crypto_qat_create(const char *name, struct rte_pci_device *pci_dev,\n \n \tinternals = cryptodev->data->dev_private;\n \tinternals->max_nb_sessions = init_params->max_nb_sessions;\n-\tswitch (pci_dev->id.device_id) {\n+\tinternals->pci_dev = RTE_DEV_TO_PCI(cryptodev->device);\n+\tinternals->dev_id = cryptodev->data->dev_id;\n+\tswitch (internals->pci_dev->id.device_id) {\n \tcase 0x0443:\n \t\tinternals->qat_dev_gen = QAT_GEN1;\n \t\tinternals->qat_dev_capabilities = qat_gen1_sym_capabilities;\n",
    "prefixes": [
        "v3",
        "13/38"
    ]
}