common/qat: rework queue pair per service
authorArek Kusztal <arkadiuszx.kusztal@intel.com>
Mon, 28 Jun 2021 16:34:19 +0000 (17:34 +0100)
committerAkhil Goyal <gakhil@marvell.com>
Tue, 20 Jul 2021 08:32:05 +0000 (10:32 +0200)
Different generations of Intel QuickAssist Technology devices may
differ in approach to allocate queues. Queue pair number function
therefore needs to be more generic.

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
drivers/common/qat/qat_qp.c
drivers/common/qat/qat_qp.h
drivers/compress/qat/qat_comp_pmd.c
drivers/crypto/qat/qat_asym_pmd.c
drivers/crypto/qat/qat_sym_pmd.c

index 4a80785..aa64d2e 100644 (file)
@@ -145,14 +145,19 @@ static void adf_queue_arb_disable(struct qat_queue *txq, void *base_addr,
        rte_spinlock_t *lock);
 
 
-int qat_qps_per_service(const struct qat_qp_hw_data *qp_hw_data,
+int qat_qps_per_service(struct qat_pci_device *qat_dev,
                enum qat_service_type service)
 {
-       int i, count;
-
-       for (i = 0, count = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++)
-               if (qp_hw_data[i].service_type == service)
+       int i = 0, count = 0, max_ops_per_srv = 0;
+       const struct qat_qp_hw_data*
+               sym_hw_qps = qat_gen_config[qat_dev->qat_dev_gen]
+                                               .qp_hw_data[service];
+
+       max_ops_per_srv = ADF_MAX_QPS_ON_ANY_SERVICE;
+       for (; i < max_ops_per_srv; i++)
+               if (sym_hw_qps[i].service_type == service)
                        count++;
+
        return count;
 }
 
index 74f7e7d..d353e85 100644 (file)
@@ -98,7 +98,7 @@ qat_qp_setup(struct qat_pci_device *qat_dev,
                struct qat_qp_config *qat_qp_conf);
 
 int
-qat_qps_per_service(const struct qat_qp_hw_data *qp_hw_data,
+qat_qps_per_service(struct qat_pci_device *qat_dev,
                        enum qat_service_type service);
 
 int
index 8de41f6..6eb1ae3 100644 (file)
@@ -106,6 +106,7 @@ qat_comp_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
        struct qat_qp **qp_addr =
                        (struct qat_qp **)&(dev->data->queue_pairs[qp_id]);
        struct qat_comp_dev_private *qat_private = dev->data->dev_private;
+       struct qat_pci_device *qat_dev = qat_private->qat_dev;
        const struct qat_qp_hw_data *comp_hw_qps =
                        qat_gen_config[qat_private->qat_dev->qat_dev_gen]
                                      .qp_hw_data[QAT_SERVICE_COMPRESSION];
@@ -117,7 +118,7 @@ qat_comp_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
                if (ret < 0)
                        return ret;
        }
-       if (qp_id >= qat_qps_per_service(comp_hw_qps,
+       if (qp_id >= qat_qps_per_service(qat_dev,
                                         QAT_SERVICE_COMPRESSION)) {
                QAT_LOG(ERR, "qp_id %u invalid for this device", qp_id);
                return -EINVAL;
@@ -592,13 +593,11 @@ qat_comp_dev_info_get(struct rte_compressdev *dev,
                        struct rte_compressdev_info *info)
 {
        struct qat_comp_dev_private *comp_dev = dev->data->dev_private;
-       const struct qat_qp_hw_data *comp_hw_qps =
-               qat_gen_config[comp_dev->qat_dev->qat_dev_gen]
-                             .qp_hw_data[QAT_SERVICE_COMPRESSION];
+       struct qat_pci_device *qat_dev = comp_dev->qat_dev;
 
        if (info != NULL) {
                info->max_nb_queue_pairs =
-                       qat_qps_per_service(comp_hw_qps,
+                       qat_qps_per_service(qat_dev,
                                            QAT_SERVICE_COMPRESSION);
                info->feature_flags = dev->feature_flags;
                info->capabilities = comp_dev->qat_dev_capabilities;
index a2c8aca..f0c8ed1 100644 (file)
@@ -54,12 +54,10 @@ static void qat_asym_dev_info_get(struct rte_cryptodev *dev,
                                  struct rte_cryptodev_info *info)
 {
        struct qat_asym_dev_private *internals = dev->data->dev_private;
-       const struct qat_qp_hw_data *asym_hw_qps =
-               qat_gen_config[internals->qat_dev->qat_dev_gen]
-                             .qp_hw_data[QAT_SERVICE_ASYMMETRIC];
+       struct qat_pci_device *qat_dev = internals->qat_dev;
 
        if (info != NULL) {
-               info->max_nb_queue_pairs = qat_qps_per_service(asym_hw_qps,
+               info->max_nb_queue_pairs = qat_qps_per_service(qat_dev,
                                                        QAT_SERVICE_ASYMMETRIC);
                info->feature_flags = dev->feature_flags;
                info->capabilities = internals->qat_dev_capabilities;
@@ -128,6 +126,7 @@ static int qat_asym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
        struct qat_qp **qp_addr =
                        (struct qat_qp **)&(dev->data->queue_pairs[qp_id]);
        struct qat_asym_dev_private *qat_private = dev->data->dev_private;
+       struct qat_pci_device *qat_dev = qat_private->qat_dev;
        const struct qat_qp_hw_data *asym_hw_qps =
                        qat_gen_config[qat_private->qat_dev->qat_dev_gen]
                                      .qp_hw_data[QAT_SERVICE_ASYMMETRIC];
@@ -139,7 +138,7 @@ static int qat_asym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
                if (ret < 0)
                        return ret;
        }
-       if (qp_id >= qat_qps_per_service(asym_hw_qps, QAT_SERVICE_ASYMMETRIC)) {
+       if (qp_id >= qat_qps_per_service(qat_dev, QAT_SERVICE_ASYMMETRIC)) {
                QAT_LOG(ERR, "qp_id %u invalid for this device", qp_id);
                return -EINVAL;
        }
index b9601c6..549345b 100644 (file)
@@ -90,13 +90,11 @@ static void qat_sym_dev_info_get(struct rte_cryptodev *dev,
                        struct rte_cryptodev_info *info)
 {
        struct qat_sym_dev_private *internals = dev->data->dev_private;
-       const struct qat_qp_hw_data *sym_hw_qps =
-               qat_gen_config[internals->qat_dev->qat_dev_gen]
-                             .qp_hw_data[QAT_SERVICE_SYMMETRIC];
+       struct qat_pci_device *qat_dev = internals->qat_dev;
 
        if (info != NULL) {
                info->max_nb_queue_pairs =
-                       qat_qps_per_service(sym_hw_qps, QAT_SERVICE_SYMMETRIC);
+                       qat_qps_per_service(qat_dev, QAT_SERVICE_SYMMETRIC);
                info->feature_flags = dev->feature_flags;
                info->capabilities = internals->qat_dev_capabilities;
                info->driver_id = qat_sym_driver_id;
@@ -164,6 +162,7 @@ static int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
        struct qat_qp **qp_addr =
                        (struct qat_qp **)&(dev->data->queue_pairs[qp_id]);
        struct qat_sym_dev_private *qat_private = dev->data->dev_private;
+       struct qat_pci_device *qat_dev = qat_private->qat_dev;
        const struct qat_qp_hw_data *sym_hw_qps =
                        qat_gen_config[qat_private->qat_dev->qat_dev_gen]
                                      .qp_hw_data[QAT_SERVICE_SYMMETRIC];
@@ -175,7 +174,7 @@ static int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
                if (ret < 0)
                        return ret;
        }
-       if (qp_id >= qat_qps_per_service(sym_hw_qps, QAT_SERVICE_SYMMETRIC)) {
+       if (qp_id >= qat_qps_per_service(qat_dev, QAT_SERVICE_SYMMETRIC)) {
                QAT_LOG(ERR, "qp_id %u invalid for this device", qp_id);
                return -EINVAL;
        }