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 CFD7D1CF3A for ; Fri, 6 Apr 2018 20:52:50 +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; 06 Apr 2018 11:52:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,416,1517904000"; d="scan'208";a="189275808" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga004.jf.intel.com with ESMTP; 06 Apr 2018 11:52:48 -0700 From: Fiona Trahe To: dev@dpdk.org, pablo.de.lara.guarch@intel.com Cc: fiona.trahe@intel.com, tomaszx.jozwiak@intel.com Date: Fri, 6 Apr 2018 19:52:04 +0100 Message-Id: <1523040732-3290-23-git-send-email-fiona.trahe@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> References: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> Subject: [dpdk-dev] [PATCH 22/30] crypto/qat: use common stats structures 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, 06 Apr 2018 18:52:51 -0000 Split qat_sym_stats_get/reset into 2 functions, a wrapper function calling a new qat_stats_get/reset function which can be called per service. Remove cryptodev stats struct from qat_qp, replace with qat_common_stats. Add links for qat_qp into qat_pci_device using an array per service to avoid need for a lock and so qp_id for the service can be used as index. Signed-off-by: Fiona Trahe --- drivers/crypto/qat/qat_common.h | 13 +++++++ drivers/crypto/qat/qat_device.c | 1 + drivers/crypto/qat/qat_device.h | 3 ++ drivers/crypto/qat/qat_qp.h | 2 +- drivers/crypto/qat/qat_sym.c | 86 ++++++++++++++++++++++++++++++++++------- 5 files changed, 91 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/qat/qat_common.h b/drivers/crypto/qat/qat_common.h index 63e5569ea..fcf5c4c09 100644 --- a/drivers/crypto/qat/qat_common.h +++ b/drivers/crypto/qat/qat_common.h @@ -49,6 +49,19 @@ struct qat_sgl { struct qat_flat_buf buffers[QAT_SGL_MAX_NUMBER]; } __rte_packed __rte_cache_aligned; +/** Common, i.e. not service-specific, statistics */ +struct qat_common_stats { + uint64_t enqueued_count; + /**< Count of all operations enqueued */ + uint64_t dequeued_count; + /**< Count of all operations dequeued */ + + uint64_t enqueue_err_count; + /**< Total error count on operations enqueued */ + uint64_t dequeue_err_count; + /**< Total error count on operations dequeued */ +}; + int qat_sgl_fill_array(struct rte_mbuf *buf, uint64_t buf_start, struct qat_sgl *list, uint32_t data_len); diff --git a/drivers/crypto/qat/qat_device.c b/drivers/crypto/qat/qat_device.c index 8ad3162e1..4dfbc84c8 100644 --- a/drivers/crypto/qat/qat_device.c +++ b/drivers/crypto/qat/qat_device.c @@ -148,6 +148,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev) } qat_dev = qat_pci_get_dev(qat_dev_id); + memset(qat_dev, 0, sizeof(*qat_dev)); snprintf(qat_dev->name, QAT_DEV_NAME_MAX_LEN, "%s", name); qat_dev->qat_dev_id = qat_dev_id; qat_dev->pci_dev = pci_dev; diff --git a/drivers/crypto/qat/qat_device.h b/drivers/crypto/qat/qat_device.h index 855bf6c1c..d1615e2a7 100644 --- a/drivers/crypto/qat/qat_device.h +++ b/drivers/crypto/qat/qat_device.h @@ -50,6 +50,9 @@ struct qat_pci_device { uint8_t attached : 1; /**< Flag indicating the device is attached */ + struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_PER_BUNDLE]; + /**< links to qps set up for each service, index same as on API */ + /* Data relating to symmetric crypto service */ struct qat_sym_dev_private *sym_dev; /**< link back to cryptodev private data */ diff --git a/drivers/crypto/qat/qat_qp.h b/drivers/crypto/qat/qat_qp.h index d482d5732..49d9f29d3 100644 --- a/drivers/crypto/qat/qat_qp.h +++ b/drivers/crypto/qat/qat_qp.h @@ -78,7 +78,7 @@ struct qat_qp { uint16_t inflights16; struct qat_queue tx_q; struct qat_queue rx_q; - struct rte_cryptodev_stats stats; + struct qat_common_stats stats; struct rte_mempool *op_cookie_pool; void **op_cookies; uint32_t nb_descriptors; diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index e77fbe4c4..8007e25d6 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -717,20 +717,24 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, } -void qat_sym_stats_get(struct rte_cryptodev *dev, - struct rte_cryptodev_stats *stats) +static void qat_stats_get(struct qat_pci_device *dev, + struct qat_common_stats *stats, + enum qat_service_type service) { int i; - struct qat_qp **qp = (struct qat_qp **)(dev->data->queue_pairs); + struct qat_qp **qp; - PMD_INIT_FUNC_TRACE(); - if (stats == NULL) { - PMD_DRV_LOG(ERR, "invalid stats ptr NULL"); + if (stats == NULL || dev == NULL || service >= QAT_SERVICE_INVALID) { + PMD_DRV_LOG(ERR, "invalid param: stats %p, dev %p, service %d", + stats, dev, service); return; } - for (i = 0; i < dev->data->nb_queue_pairs; i++) { + + qp = dev->qps_in_use[service]; + for (i = 0; i < ADF_MAX_QPS_PER_BUNDLE; i++) { if (qp[i] == NULL) { - PMD_DRV_LOG(DEBUG, "Uninitialised queue pair"); + PMD_DRV_LOG(DEBUG, "Service %d Uninitialised qp %d", + service, i); continue; } @@ -741,22 +745,74 @@ void qat_sym_stats_get(struct rte_cryptodev *dev, } } -void qat_sym_stats_reset(struct rte_cryptodev *dev) +void qat_sym_stats_get(struct rte_cryptodev *dev, + struct rte_cryptodev_stats *stats) +{ + struct qat_common_stats qat_stats = {0}; + struct qat_sym_dev_private *qat_priv; + + if (stats == NULL || dev == NULL) { + PMD_DRV_LOG(ERR, "invalid ptr: stats %p, dev %p", stats, dev); + return; + } + qat_priv = dev->data->dev_private; + + qat_stats_get(qat_priv->qat_dev, &qat_stats, QAT_SERVICE_SYMMETRIC); + stats->enqueued_count = qat_stats.enqueued_count; + stats->dequeued_count = qat_stats.dequeued_count; + stats->enqueue_err_count = qat_stats.enqueue_err_count; + stats->dequeue_err_count = qat_stats.dequeue_err_count; +} + +static void qat_stats_reset(struct qat_pci_device *dev, + enum qat_service_type service) { int i; - struct qat_qp **qp = (struct qat_qp **)(dev->data->queue_pairs); + struct qat_qp **qp; - PMD_INIT_FUNC_TRACE(); - for (i = 0; i < dev->data->nb_queue_pairs; i++) + if (dev == NULL || service >= QAT_SERVICE_INVALID) { + PMD_DRV_LOG(ERR, "invalid param: dev %p, service %d", + dev, service); + return; + } + + qp = dev->qps_in_use[service]; + for (i = 0; i < ADF_MAX_QPS_PER_BUNDLE; i++) { + if (qp[i] == NULL) { + PMD_DRV_LOG(DEBUG, "Service %d Uninitialised qp %d", + service, i); + continue; + } memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats)); - PMD_DRV_LOG(DEBUG, "QAT crypto: stats cleared"); + } + + PMD_DRV_LOG(DEBUG, "QAT crypto: %d stats cleared", service); +} + +void qat_sym_stats_reset(struct rte_cryptodev *dev) +{ + struct qat_sym_dev_private *qat_priv; + + if (dev == NULL) { + PMD_DRV_LOG(ERR, "invalid cryptodev ptr %p", dev); + return; + } + qat_priv = dev->data->dev_private; + + qat_stats_reset(qat_priv->qat_dev, QAT_SERVICE_SYMMETRIC); + } int qat_sym_qp_release(struct rte_cryptodev *dev, uint16_t queue_pair_id) { + struct qat_sym_dev_private *qat_private = dev->data->dev_private; + PMD_DRV_LOG(DEBUG, "Release sym qp %u on device %d", queue_pair_id, dev->data->dev_id); + qat_private->qat_dev->qps_in_use[QAT_SERVICE_SYMMETRIC][queue_pair_id] + = NULL; + return qat_qp_release((struct qat_qp **) &(dev->data->queue_pairs[queue_pair_id])); } @@ -801,6 +857,10 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, if (ret != 0) return ret; + /* store a link to the qp in the qat_pci_device */ + qat_private->qat_dev->qps_in_use[QAT_SERVICE_SYMMETRIC][qp_id] + = *qp_addr; + qp = (struct qat_qp *)*qp_addr; for (i = 0; i < qp->nb_descriptors; i++) { -- 2.13.6