From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 416235F65 for ; Fri, 13 Jul 2018 12:34:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 03:34:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,347,1526367600"; d="scan'208";a="215718236" Received: from silpixa00399466.ir.intel.com (HELO silpixa00399466.ger.corp.intel.com) ([10.237.223.220]) by orsmga004.jf.intel.com with ESMTP; 13 Jul 2018 03:34:24 -0700 From: Pablo de Lara To: fiona.trahe@intel.com, tomaszx.jozwiak@intel.com, john.griffin@intel.com, deepak.k.jain@intel.com Cc: dev@dpdk.org Date: Fri, 13 Jul 2018 03:28:23 +0100 Message-Id: <20180713022825.33106-15-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180713022825.33106-1-pablo.de.lara.guarch@intel.com> References: <1531411499-13156-1-git-send-email-fiona.trahe@intel.com> <20180713022825.33106-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v7 14/16] compress/qat: add fns to create and destroy the PMD X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2018 10:34:27 -0000 From: Fiona Trahe Now that all the device operations are available, add the functions to create and destroy the pmd. Called on probe and remove of the qat pci device, these register the device with the compressdev API and plug in all the device functionality. Signed-off-by: Fiona Trahe Signed-off-by: Tomasz Jozwiak --- drivers/common/qat/qat_device.h | 4 ++ drivers/common/qat/qat_qp.c | 11 ++++- drivers/common/qat/qat_qp.h | 5 ++ drivers/compress/qat/qat_comp_pmd.c | 98 +++++++++++++++++++++++++++++++++++-- drivers/compress/qat/qat_comp_pmd.h | 11 ++--- 5 files changed, 117 insertions(+), 12 deletions(-) diff --git a/drivers/common/qat/qat_device.h b/drivers/common/qat/qat_device.h index 0cb370c72..9599fc596 100644 --- a/drivers/common/qat/qat_device.h +++ b/drivers/common/qat/qat_device.h @@ -25,6 +25,8 @@ * - runtime data */ struct qat_sym_dev_private; +struct qat_comp_dev_private; + struct qat_pci_device { /* Data used by all services */ @@ -55,6 +57,8 @@ struct qat_pci_device { */ /* Data relating to compression service */ + struct qat_comp_dev_private *comp_dev; + /**< link back to compressdev private data */ /* Data relating to asymmetric crypto service */ diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c index 32c17596b..7ca7a45eb 100644 --- a/drivers/common/qat/qat_qp.c +++ b/drivers/common/qat/qat_qp.c @@ -15,6 +15,7 @@ #include "qat_device.h" #include "qat_qp.h" #include "qat_sym.h" +#include "qat_comp.h" #include "adf_transport_access_macros.h" @@ -606,8 +607,8 @@ qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops) if (tmp_qp->service_type == QAT_SERVICE_SYMMETRIC) qat_sym_process_response(ops, resp_msg); - /* add qat_asym_process_response here */ - /* add qat_comp_process_response here */ + else if (tmp_qp->service_type == QAT_SERVICE_COMPRESSION) + qat_comp_process_response(ops, resp_msg); head = adf_modulo(head + rx_queue->msg_size, rx_queue->modulo_mask); @@ -633,3 +634,9 @@ qat_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops) } return resp_counter; } + +__attribute__((weak)) int +qat_comp_process_response(void **op __rte_unused, uint8_t *resp __rte_unused) +{ + return 0; +} diff --git a/drivers/common/qat/qat_qp.h b/drivers/common/qat/qat_qp.h index 59db945e7..69f8a6131 100644 --- a/drivers/common/qat/qat_qp.h +++ b/drivers/common/qat/qat_qp.h @@ -103,4 +103,9 @@ qat_qp_setup(struct qat_pci_device *qat_dev, int qat_qps_per_service(const struct qat_qp_hw_data *qp_hw_data, enum qat_service_type service); + +/* Needed for weak function*/ +int +qat_comp_process_response(void **op __rte_unused, uint8_t *resp __rte_unused); + #endif /* _QAT_QP_H_ */ diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c index 013ff6e8d..9bb98974c 100644 --- a/drivers/compress/qat/qat_comp_pmd.c +++ b/drivers/compress/qat/qat_comp_pmd.c @@ -5,6 +5,18 @@ #include "qat_comp.h" #include "qat_comp_pmd.h" +static const struct rte_compressdev_capabilities qat_comp_gen_capabilities[] = { + {/* COMPRESSION - deflate */ + .algo = RTE_COMP_ALGO_DEFLATE, + .comp_feature_flags = RTE_COMP_FF_MULTI_PKT_CHECKSUM | + RTE_COMP_FF_CRC32_CHECKSUM | + RTE_COMP_FF_ADLER32_CHECKSUM | + RTE_COMP_FF_CRC32_ADLER32_CHECKSUM | + RTE_COMP_FF_SHAREABLE_PRIV_XFORM | + RTE_COMP_FF_HUFFMAN_FIXED, + .window_size = {.min = 15, .max = 15, .increment = 0} }, + {RTE_COMP_ALGO_LIST_END, 0, {0, 0, 0} } }; + static void qat_comp_stats_get(struct rte_compressdev *dev, struct rte_compressdev_stats *stats) @@ -225,14 +237,14 @@ qat_comp_dev_info_get(struct rte_compressdev *dev, } } -uint16_t +static uint16_t qat_comp_pmd_enqueue_op_burst(void *qp, struct rte_comp_op **ops, uint16_t nb_ops) { return qat_enqueue_op_burst(qp, (void **)ops, nb_ops); } -uint16_t +static uint16_t qat_comp_pmd_dequeue_op_burst(void *qp, struct rte_comp_op **ops, uint16_t nb_ops) { @@ -240,7 +252,7 @@ qat_comp_pmd_dequeue_op_burst(void *qp, struct rte_comp_op **ops, } -struct rte_compressdev_ops compress_qat_ops = { +static struct rte_compressdev_ops compress_qat_ops = { /* Device related operations */ .dev_configure = qat_comp_dev_config, @@ -258,3 +270,83 @@ struct rte_compressdev_ops compress_qat_ops = { .private_xform_create = qat_comp_private_xform_create, .private_xform_free = qat_comp_private_xform_free }; + +int +qat_comp_dev_create(struct qat_pci_device *qat_pci_dev) +{ + if (qat_pci_dev->qat_dev_gen == QAT_GEN1) { + QAT_LOG(ERR, "Compression PMD not supported on QAT dh895xcc"); + return 0; + } + + struct rte_compressdev_pmd_init_params init_params = { + .name = "", + .socket_id = qat_pci_dev->pci_dev->device.numa_node, + }; + char name[RTE_COMPRESSDEV_NAME_MAX_LEN]; + struct rte_compressdev *compressdev; + struct qat_comp_dev_private *comp_dev; + + snprintf(name, RTE_COMPRESSDEV_NAME_MAX_LEN, "%s_%s", + qat_pci_dev->name, "comp"); + QAT_LOG(DEBUG, "Creating QAT COMP device %s", name); + + compressdev = rte_compressdev_pmd_create(name, + &qat_pci_dev->pci_dev->device, + sizeof(struct qat_comp_dev_private), + &init_params); + + if (compressdev == NULL) + return -ENODEV; + + compressdev->dev_ops = &compress_qat_ops; + + compressdev->enqueue_burst = qat_comp_pmd_enqueue_op_burst; + compressdev->dequeue_burst = qat_comp_pmd_dequeue_op_burst; + + compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; + + comp_dev = compressdev->data->dev_private; + comp_dev->qat_dev = qat_pci_dev; + comp_dev->compressdev = compressdev; + qat_pci_dev->comp_dev = comp_dev; + + switch (qat_pci_dev->qat_dev_gen) { + case QAT_GEN1: + case QAT_GEN2: + comp_dev->qat_dev_capabilities = qat_comp_gen_capabilities; + break; + default: + comp_dev->qat_dev_capabilities = qat_comp_gen_capabilities; + QAT_LOG(DEBUG, + "QAT gen %d capabilities unknown, default to GEN1", + qat_pci_dev->qat_dev_gen); + break; + } + + QAT_LOG(DEBUG, + "Created QAT COMP device %s as compressdev instance %d", + name, compressdev->data->dev_id); + return 0; +} + +int +qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev) +{ + struct qat_comp_dev_private *comp_dev; + + if (qat_pci_dev == NULL) + return -ENODEV; + + comp_dev = qat_pci_dev->comp_dev; + if (comp_dev == NULL) + return 0; + + /* clean up any resources used by the device */ + qat_comp_dev_close(comp_dev->compressdev); + + rte_compressdev_pmd_destroy(comp_dev->compressdev); + qat_pci_dev->comp_dev = NULL; + + return 0; +} diff --git a/drivers/compress/qat/qat_comp_pmd.h b/drivers/compress/qat/qat_comp_pmd.h index 7ba1b8dc6..9ad2a2836 100644 --- a/drivers/compress/qat/qat_comp_pmd.h +++ b/drivers/compress/qat/qat_comp_pmd.h @@ -27,16 +27,13 @@ struct qat_comp_dev_private { /**< The device's memory for intermediate buffers */ struct rte_mempool *xformpool; /**< The device's pool for qat_comp_xforms */ - }; -uint16_t -qat_comp_pmd_enqueue_op_burst(void *qp, struct rte_comp_op **ops, - uint16_t nb_ops); +int +qat_comp_dev_create(struct qat_pci_device *qat_pci_dev); -uint16_t -qat_comp_pmd_dequeue_op_burst(void *qp, struct rte_comp_op **ops, - uint16_t nb_ops); +int +qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev); #endif #endif /* _QAT_COMP_PMD_H_ */ -- 2.14.4