From: Fiona Trahe Date: Wed, 13 Jun 2018 12:14:05 +0000 (+0200) Subject: crypto/qat: use common stats structures X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e1c6aa1f776f845db2c27172b289a25864ec6243;p=dpdk.git crypto/qat: use common stats structures 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 --- diff --git a/drivers/crypto/qat/qat_common.h b/drivers/crypto/qat/qat_common.h index 63e5569ea8..fcf5c4c095 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 8ad3162e1b..4dfbc84c8c 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 855bf6c1c1..d1615e2a7e 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 d482d5732c..49d9f29d33 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 e77fbe4c40..8007e25d6a 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++) {