Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/41053/?format=api
http://patchwork.dpdk.org/api/patches/41053/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1528892062-4997-19-git-send-email-tomaszx.jozwiak@intel.com/", "project": { "id": 1, "url": "http://patchwork.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": "<1528892062-4997-19-git-send-email-tomaszx.jozwiak@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1528892062-4997-19-git-send-email-tomaszx.jozwiak@intel.com", "date": "2018-06-13T12:14:02", "name": "[v3,18/38] crypto/qat: add QAT PCI device struct", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "a600b1927cb94ff7c0fcfb66a0f7d1cf11d9b2e7", "submitter": { "id": 949, "url": "http://patchwork.dpdk.org/api/people/949/?format=api", "name": "Tomasz Jozwiak", "email": "tomaszx.jozwiak@intel.com" }, "delegate": { "id": 22, "url": "http://patchwork.dpdk.org/api/users/22/?format=api", "username": "pdelarag", "first_name": "Pablo", "last_name": "de Lara Guarch", "email": "pablo.de.lara.guarch@intel.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1528892062-4997-19-git-send-email-tomaszx.jozwiak@intel.com/mbox/", "series": [ { "id": 111, "url": "http://patchwork.dpdk.org/api/series/111/?format=api", "web_url": "http://patchwork.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://patchwork.dpdk.org/series/111/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/41053/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/41053/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 607351EFAD;\n\tWed, 13 Jun 2018 14:15:17 +0200 (CEST)", "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 2FF351EF8B\n\tfor <dev@dpdk.org>; Wed, 13 Jun 2018 14:15:02 +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:59 -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:49 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.51,218,1526367600\"; d=\"scan'208\";a=\"63727729\"", "From": "Tomasz Jozwiak <tomaszx.jozwiak@intel.com>", "To": "fiona.trahe@intel.com,\n\ttomaszx.jozwiak@intel.com,\n\tdev@dpdk.org", "Date": "Wed, 13 Jun 2018 14:14:02 +0200", "Message-Id": "<1528892062-4997-19-git-send-email-tomaszx.jozwiak@intel.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1528892062-4997-1-git-send-email-tomaszx.jozwiak@intel.com>", "References": "<1523040732-3290-1-git-send-email-fiona.trahe@intel.com>\n\t<1528892062-4997-1-git-send-email-tomaszx.jozwiak@intel.com>", "Subject": "[dpdk-dev] [PATCH v3 18/38] crypto/qat: add QAT PCI device struct", "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://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Fiona Trahe <fiona.trahe@intel.com>\n\n- Added struct qat_pci_device to use internally in QAT PMD\n to avoid dependencies on rte_cryptodev or rte_compressdev\n - Added a global array of these\n - Restructured probe/release to separate QAT common init/clear\n from crypto pmd create/destroy.\n - In QAT common part allocated a qat_pci_device and populated it\n - Removed meaningless check in probe for RTE_PROC_PRIMARY\n\nSigned-off-by: Fiona Trahe <fiona.trahe@intel.com>\n---\n drivers/crypto/qat/qat_device.c | 127 ++++++++++++++++++++++\n drivers/crypto/qat/qat_device.h | 60 ++++++++++-\n drivers/crypto/qat/rte_qat_cryptodev.c | 140 ++++++++++++++++++-------\n 3 files changed, 286 insertions(+), 41 deletions(-)", "diff": "diff --git a/drivers/crypto/qat/qat_device.c b/drivers/crypto/qat/qat_device.c\nindex cdf4f7058..75af1e8bc 100644\n--- a/drivers/crypto/qat/qat_device.c\n+++ b/drivers/crypto/qat/qat_device.c\n@@ -20,6 +20,10 @@ struct qat_gen_hw_data qp_gen_config[] = {\n \t},\n };\n \n+\n+static struct qat_pci_device qat_pci_devices[QAT_MAX_PCI_DEVICES];\n+static int qat_nb_pci_devices;\n+\n int qat_dev_config(__rte_unused struct rte_cryptodev *dev,\n \t\t__rte_unused struct rte_cryptodev_config *config)\n {\n@@ -72,3 +76,126 @@ void qat_dev_info_get(struct rte_cryptodev *dev,\n \t\tinfo->pci_dev = RTE_DEV_TO_PCI(dev->device);\n \t}\n }\n+\n+\n+static struct qat_pci_device *\n+qat_pci_get_dev(uint8_t dev_id)\n+{\n+\treturn &qat_pci_devices[dev_id];\n+}\n+static struct qat_pci_device *\n+qat_pci_get_named_dev(const char *name)\n+{\n+\tstruct qat_pci_device *dev;\n+\tunsigned int i;\n+\n+\tif (name == NULL)\n+\t\treturn NULL;\n+\n+\tfor (i = 0; i < QAT_MAX_PCI_DEVICES; i++) {\n+\t\tdev = &qat_pci_devices[i];\n+\n+\t\tif ((dev->attached == QAT_ATTACHED) &&\n+\t\t\t\t(strcmp(dev->name, name) == 0))\n+\t\t\treturn dev;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+static uint8_t\n+qat_pci_find_free_device_index(void)\n+{\n+\tuint8_t dev_id;\n+\n+\tfor (dev_id = 0; dev_id < QAT_MAX_PCI_DEVICES; dev_id++) {\n+\t\tif (qat_pci_devices[dev_id].attached == QAT_DETACHED)\n+\t\t\tbreak;\n+\t}\n+\treturn dev_id;\n+}\n+\n+struct qat_pci_device *\n+qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev)\n+{\n+\tchar name[QAT_DEV_NAME_MAX_LEN];\n+\n+\trte_pci_device_name(&pci_dev->addr, name, sizeof(name));\n+\n+\treturn qat_pci_get_named_dev(name);\n+}\n+\n+struct qat_pci_device *\n+qat_pci_device_allocate(struct rte_pci_device *pci_dev)\n+{\n+\tstruct qat_pci_device *qat_dev;\n+\tuint8_t qat_dev_id;\n+\tchar name[QAT_DEV_NAME_MAX_LEN];\n+\n+\trte_pci_device_name(&pci_dev->addr, name, sizeof(name));\n+\n+\tif (qat_pci_get_named_dev(name) != NULL) {\n+\t\tPMD_DRV_LOG(ERR, \"QAT device with name %s already allocated!\",\n+\t\t\t\tname);\n+\t\treturn NULL;\n+\t}\n+\n+\tqat_dev_id = qat_pci_find_free_device_index();\n+\tif (qat_dev_id == QAT_MAX_PCI_DEVICES) {\n+\t\tPMD_DRV_LOG(ERR, \"Reached maximum number of QAT devices\");\n+\t\treturn NULL;\n+\t}\n+\n+\tqat_dev = qat_pci_get_dev(qat_dev_id);\n+\tsnprintf(qat_dev->name, QAT_DEV_NAME_MAX_LEN, \"%s\", name);\n+\tqat_dev->pci_dev = pci_dev;\n+\tswitch (qat_dev->pci_dev->id.device_id) {\n+\tcase 0x0443:\n+\t\tqat_dev->qat_dev_gen = QAT_GEN1;\n+\t\tbreak;\n+\tcase 0x37c9:\n+\tcase 0x19e3:\n+\tcase 0x6f55:\n+\t\tqat_dev->qat_dev_gen = QAT_GEN2;\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(ERR, \"Invalid dev_id, can't determine generation\");\n+\t\treturn NULL;\n+\t}\n+\n+\trte_spinlock_init(&qat_dev->arb_csr_lock);\n+\n+\tqat_dev->attached = QAT_ATTACHED;\n+\n+\tqat_nb_pci_devices++;\n+\n+\tPMD_DRV_LOG(DEBUG, \"QAT device %d allocated, total QATs %d\",\n+\t\t\t\tqat_dev_id, qat_nb_pci_devices);\n+\n+\treturn qat_dev;\n+}\n+\n+int\n+qat_pci_device_release(struct rte_pci_device *pci_dev)\n+{\n+\tstruct qat_pci_device *qat_dev;\n+\tchar name[QAT_DEV_NAME_MAX_LEN];\n+\n+\tif (pci_dev == NULL)\n+\t\treturn -EINVAL;\n+\n+\trte_pci_device_name(&pci_dev->addr, name, sizeof(name));\n+\tqat_dev = qat_pci_get_named_dev(name);\n+\tif (qat_dev != NULL) {\n+\n+\t\t/* Check that there are no service devs still on pci device */\n+\t\tif (qat_dev->sym_dev != NULL)\n+\t\t\treturn -EBUSY;\n+\n+\t\tqat_dev->attached = QAT_DETACHED;\n+\t\tqat_nb_pci_devices--;\n+\t}\n+\tPMD_DRV_LOG(DEBUG, \"QAT device %s released, total QATs %d\",\n+\t\t\t\tname, qat_nb_pci_devices);\n+\treturn 0;\n+}\ndiff --git a/drivers/crypto/qat/qat_device.h b/drivers/crypto/qat/qat_device.h\nindex 0983e3c2e..d83ad632c 100644\n--- a/drivers/crypto/qat/qat_device.h\n+++ b/drivers/crypto/qat/qat_device.h\n@@ -11,15 +11,58 @@\n #include \"adf_transport_access_macros.h\"\n #include \"qat_qp.h\"\n \n+\n+#define QAT_DETACHED (0)\n+#define QAT_ATTACHED (1)\n+\n+#define QAT_MAX_PCI_DEVICES\t48\n+#define QAT_DEV_NAME_MAX_LEN\t64\n+\n+\n extern uint8_t cryptodev_qat_driver_id;\n \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- * 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+ * This struct holds all the data about a QAT pci device\n+ * including data about all services it supports.\n+ * It contains\n+ * - hw_data\n+ * - config data\n+ * - runtime data\n+ */\n+struct qat_pci_device {\n+\n+\t/* data used by all services */\n+\tchar name[QAT_DEV_NAME_MAX_LEN];\n+\t/**< Name of qat pci device */\n+\tstruct rte_pci_device *pci_dev;\n+\t/**< PCI information. */\n+\tenum qat_device_gen qat_dev_gen;\n+\t/**< QAT device generation */\n+\trte_spinlock_t arb_csr_lock;\n+\t/* protects accesses to the arbiter CSR */\n+\t__extension__\n+\tuint8_t attached : 1;\n+\t/**< Flag indicating the device is attached */\n+\n+\t/* data relating to symmetric crypto service */\n+\tstruct qat_pmd_private *sym_dev;\n+\t/**< link back to cryptodev private data */\n+\tunsigned int max_nb_sym_queue_pairs;\n+\t/**< Max number of queue pairs supported by device */\n+\n+\t/* data relating to compression service */\n+\n+\t/* data relating to asymmetric crypto service */\n+\n+};\n+\n+/** private data structure for a QAT device.\n+ * This QAT device is a device offering only symmetric crypto service,\n+ * there can be one of these on each qat_pci_device (VF),\n+ * in future there may also be private data structures for other services.\n */\n struct qat_pmd_private {\n \tunsigned int max_nb_queue_pairs;\n@@ -34,6 +77,8 @@ struct qat_pmd_private {\n \t/**< PCI information. */\n \tuint8_t dev_id;\n \t/**< Device ID for this instance */\n+\tstruct qat_pci_device *qat_dev;\n+\t/**< The qat pci device hosting the service */\n };\n \n struct qat_gen_hw_data {\n@@ -51,4 +96,11 @@ int qat_dev_close(struct rte_cryptodev *dev);\n void qat_dev_info_get(struct rte_cryptodev *dev,\n \tstruct rte_cryptodev_info *info);\n \n+struct qat_pci_device *\n+qat_pci_device_allocate(struct rte_pci_device *pci_dev);\n+int\n+qat_pci_device_release(struct rte_pci_device *pci_dev);\n+struct qat_pci_device *\n+qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev);\n+\n #endif /* _QAT_DEVICE_H_ */\ndiff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c\nindex fe19b18b6..6ab870cad 100644\n--- a/drivers/crypto/qat/rte_qat_cryptodev.c\n+++ b/drivers/crypto/qat/rte_qat_cryptodev.c\n@@ -69,17 +69,28 @@ static const struct rte_pci_id pci_id_qat_map[] = {\n \t\t{.device_id = 0},\n };\n \n+\n+\n static int\n-crypto_qat_create(const char *name, struct rte_pci_device *pci_dev,\n-\t\tstruct rte_cryptodev_pmd_init_params *init_params)\n+qat_sym_dev_create(struct qat_pci_device *qat_pci_dev)\n {\n+\tstruct rte_cryptodev_pmd_init_params init_params = {\n+\t\t\t.name = \"\",\n+\t\t\t.socket_id = qat_pci_dev->pci_dev->device.numa_node,\n+\t\t\t.private_data_size = sizeof(struct qat_pmd_private),\n+\t\t\t.max_nb_sessions = RTE_QAT_PMD_MAX_NB_SESSIONS\n+\t};\n+\tchar name[RTE_CRYPTODEV_NAME_MAX_LEN];\n \tstruct rte_cryptodev *cryptodev;\n \tstruct qat_pmd_private *internals;\n \n-\tPMD_INIT_FUNC_TRACE();\n+\tsnprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN, \"%s_%s\",\n+\t\t\tqat_pci_dev->name, \"sym\");\n+\tPMD_DRV_LOG(DEBUG, \"Creating QAT SYM device %s\", name);\n+\n+\tcryptodev = rte_cryptodev_pmd_create(name,\n+\t\t\t&qat_pci_dev->pci_dev->device, &init_params);\n \n-\tcryptodev = rte_cryptodev_pmd_create(name, &pci_dev->device,\n-\t\t\tinit_params);\n \tif (cryptodev == NULL)\n \t\treturn -ENODEV;\n \n@@ -95,7 +106,10 @@ crypto_qat_create(const char *name, struct rte_pci_device *pci_dev,\n \t\t\tRTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;\n \n \tinternals = cryptodev->data->dev_private;\n-\tinternals->max_nb_sessions = init_params->max_nb_sessions;\n+\tinternals->qat_dev = qat_pci_dev;\n+\tqat_pci_dev->sym_dev = internals;\n+\n+\tinternals->max_nb_sessions = init_params.max_nb_sessions;\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@@ -111,68 +125,120 @@ crypto_qat_create(const char *name, struct rte_pci_device *pci_dev,\n \t\tbreak;\n \tdefault:\n \t\tPMD_DRV_LOG(ERR,\n-\t\t\t\"Invalid dev_id, can't determine capabilities\");\n+\t\t\t\t\"Invalid dev_id, can't determine capabilities\");\n \t\tbreak;\n \t}\n \n-\t/*\n-\t * For secondary processes, we don't initialise any further as primary\n-\t * has already done this work. Only check we don't need a different\n-\t * RX function\n-\t */\n-\tif (rte_eal_process_type() != RTE_PROC_PRIMARY) {\n-\t\tPMD_DRV_LOG(DEBUG, \"Device already initialised by primary process\");\n \t\treturn 0;\n-\t}\n+}\n+\n+static int\n+qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev)\n+{\n+\tstruct rte_cryptodev *cryptodev;\n+\n+\tif (qat_pci_dev == NULL)\n+\t\treturn -ENODEV;\n+\tif (qat_pci_dev->sym_dev == NULL)\n+\t\treturn 0;\n+\n+\t/* free crypto device */\n+\tcryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->dev_id);\n+\trte_cryptodev_pmd_destroy(cryptodev);\n+\tqat_pci_dev->sym_dev = NULL;\n+\n+\treturn 0;\n+}\n+\n+static int\n+qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused)\n+{\n+\treturn 0;\n+}\n \n+static int\n+qat_asym_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused)\n+{\n \treturn 0;\n }\n \n-static int crypto_qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n+static int\n+qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+qat_pci_dev_destroy(struct qat_pci_device *qat_pci_dev,\n \t\tstruct rte_pci_device *pci_dev)\n {\n-\tstruct rte_cryptodev_pmd_init_params init_params = {\n-\t\t.name = \"\",\n-\t\t.socket_id = pci_dev->device.numa_node,\n-\t\t.private_data_size = sizeof(struct qat_pmd_private),\n-\t\t.max_nb_sessions = RTE_QAT_PMD_MAX_NB_SESSIONS\n-\t};\n-\tchar name[RTE_CRYPTODEV_NAME_MAX_LEN];\n+\tqat_sym_dev_destroy(qat_pci_dev);\n+\tqat_comp_dev_destroy(qat_pci_dev);\n+\tqat_asym_dev_destroy(qat_pci_dev);\n+\treturn qat_pci_device_release(pci_dev);\n+}\n+\n+static int qat_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n+\t\tstruct rte_pci_device *pci_dev)\n+{\n+\tint ret = 0;\n+\tstruct qat_pci_device *qat_pci_dev;\n \n \tPMD_DRV_LOG(DEBUG, \"Found QAT device at %02x:%02x.%x\",\n \t\t\tpci_dev->addr.bus,\n \t\t\tpci_dev->addr.devid,\n \t\t\tpci_dev->addr.function);\n \n-\trte_pci_device_name(&pci_dev->addr, name, sizeof(name));\n+\tqat_pci_dev = qat_pci_device_allocate(pci_dev);\n+\tif (qat_pci_dev == NULL)\n+\t\treturn -ENODEV;\n+\n+\tret = qat_sym_dev_create(qat_pci_dev);\n+\tif (ret != 0)\n+\t\tgoto error_out;\n+\n+\tret = qat_comp_dev_create(qat_pci_dev);\n+\tif (ret != 0)\n+\t\tgoto error_out;\n+\n+\tret = qat_asym_dev_create(qat_pci_dev);\n+\tif (ret != 0)\n+\t\tgoto error_out;\n+\n+\treturn 0;\n+\n+error_out:\n+\tqat_pci_dev_destroy(qat_pci_dev, pci_dev);\n+\treturn ret;\n \n-\treturn crypto_qat_create(name, pci_dev, &init_params);\n }\n \n-static int crypto_qat_pci_remove(struct rte_pci_device *pci_dev)\n+static int qat_pci_remove(struct rte_pci_device *pci_dev)\n {\n-\tstruct rte_cryptodev *cryptodev;\n-\tchar cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];\n+\tstruct qat_pci_device *qat_pci_dev;\n \n \tif (pci_dev == NULL)\n \t\treturn -EINVAL;\n \n-\trte_pci_device_name(&pci_dev->addr, cryptodev_name,\n-\t\t\tsizeof(cryptodev_name));\n+\tqat_pci_dev = qat_get_qat_dev_from_pci_dev(pci_dev);\n+\tif (qat_pci_dev == NULL)\n+\t\treturn 0;\n \n-\tcryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);\n-\tif (cryptodev == NULL)\n-\t\treturn -ENODEV;\n+\treturn qat_pci_dev_destroy(qat_pci_dev, pci_dev);\n \n-\t/* free crypto device */\n-\treturn rte_cryptodev_pmd_destroy(cryptodev);\n }\n \n static struct rte_pci_driver rte_qat_pmd = {\n \t.id_table = pci_id_qat_map,\n \t.drv_flags = RTE_PCI_DRV_NEED_MAPPING,\n-\t.probe = crypto_qat_pci_probe,\n-\t.remove = crypto_qat_pci_remove\n+\t.probe = qat_pci_probe,\n+\t.remove = qat_pci_remove\n };\n \n static struct cryptodev_driver qat_crypto_drv;\n", "prefixes": [ "v3", "18/38" ] }{ "id": 41053, "url": "