common/qat: add service discovery
authorArek Kusztal <arkadiuszx.kusztal@intel.com>
Mon, 28 Jun 2021 16:34:31 +0000 (17:34 +0100)
committerAkhil Goyal <gakhil@marvell.com>
Tue, 20 Jul 2021 08:32:05 +0000 (10:32 +0200)
This commit adds service discovery to generation four
of Intel QuickAssist Technology devices.

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_common.h
drivers/common/qat/qat_device.c
drivers/common/qat/qat_device.h
drivers/common/qat/qat_qp.c
drivers/common/qat/qat_qp.h

index 845c8d9..2371508 100644 (file)
@@ -29,6 +29,14 @@ enum qat_service_type {
        QAT_SERVICE_INVALID
 };
 
+enum qat_svc_list {
+       QAT_SVC_UNUSED = 0,
+       QAT_SVC_CRYPTO = 1,
+       QAT_SVC_COMPRESSION = 2,
+       QAT_SVC_SYM = 3,
+       QAT_SVC_ASYM = 4,
+};
+
 #define QAT_MAX_SERVICES               (QAT_SERVICE_INVALID)
 
 /**< Common struct for scatter-gather list operations */
index e52d90f..1b967cb 100644 (file)
@@ -148,6 +148,22 @@ qat_gen4_reset_ring_pair(struct qat_pci_device *qat_pci_dev)
        return 0;
 }
 
+int qat_query_svc(struct qat_pci_device *qat_dev, uint8_t *val)
+{
+       int ret = -(EINVAL);
+       struct qat_pf2vf_msg pf2vf_msg;
+
+       if (qat_dev->qat_dev_gen == QAT_GEN4) {
+               pf2vf_msg.msg_type = ADF_VF2PF_MSGTYPE_GET_SMALL_BLOCK_REQ;
+               pf2vf_msg.block_hdr = ADF_VF2PF_BLOCK_MSG_GET_RING_TO_SVC_REQ;
+               pf2vf_msg.msg_data = 2;
+               ret = qat_pf2vf_exch_msg(qat_dev, pf2vf_msg, 2, val);
+       }
+
+       return ret;
+}
+
+
 static void qat_dev_parse_cmd(const char *str, struct qat_dev_cmd_param
                *qat_dev_cmd_param)
 {
@@ -296,9 +312,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev,
                qat_dev_parse_cmd(devargs->drv_str, qat_dev_cmd_param);
 
        if (qat_dev->qat_dev_gen >= QAT_GEN4) {
-               int ret = qat_read_qp_config(qat_dev, qat_dev->qat_dev_gen);
-
-               if (ret) {
+               if (qat_read_qp_config(qat_dev)) {
                        QAT_LOG(ERR,
                                "Cannot acquire ring configuration for QAT_%d",
                                qat_dev_id);
index 05e164b..228c057 100644 (file)
@@ -159,4 +159,7 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev __rte_unused,
 int
 qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev __rte_unused);
 
+int
+qat_query_svc(struct qat_pci_device *qat_pci_dev, uint8_t *ret);
+
 #endif /* _QAT_DEVICE_H_ */
index 8be5977..026ea5e 100644 (file)
@@ -504,20 +504,43 @@ qat_select_valid_queue(struct qat_pci_device *qat_dev, int qp_id,
 }
 
 int
-qat_read_qp_config(struct qat_pci_device *qat_dev,
-                       enum qat_device_gen qat_dev_gen)
+qat_read_qp_config(struct qat_pci_device *qat_dev)
 {
+       int i = 0;
+       enum qat_device_gen qat_dev_gen = qat_dev->qat_dev_gen;
+
        if (qat_dev_gen == QAT_GEN4) {
-               /* Read default configuration,
-                * until some probe of it can be done
-                */
-               int i = 0;
+               uint16_t svc = 0;
 
+               if (qat_query_svc(qat_dev, (uint8_t *)&svc))
+                       return -(EFAULT);
                for (; i < QAT_GEN4_BUNDLE_NUM; i++) {
                        struct qat_qp_hw_data *hw_data =
                                &qat_dev->qp_gen4_data[i][0];
-                       enum qat_service_type service_type =
-                               (QAT_GEN4_QP_DEFCON >> (8 * i)) & 0xFF;
+                       uint8_t svc1 = (svc >> (3 * i)) & 0x7;
+                       enum qat_service_type service_type = QAT_SERVICE_INVALID;
+
+                       if (svc1 == QAT_SVC_SYM) {
+                               service_type = QAT_SERVICE_SYMMETRIC;
+                               QAT_LOG(DEBUG,
+                                       "Discovered SYMMETRIC service on bundle %d",
+                                       i);
+                       } else if (svc1 == QAT_SVC_COMPRESSION) {
+                               service_type = QAT_SERVICE_COMPRESSION;
+                               QAT_LOG(DEBUG,
+                                       "Discovered COPRESSION service on bundle %d",
+                                       i);
+                       } else if (svc1 == QAT_SVC_ASYM) {
+                               service_type = QAT_SERVICE_ASYMMETRIC;
+                               QAT_LOG(DEBUG,
+                                       "Discovered ASYMMETRIC service on bundle %d",
+                                       i);
+                       } else {
+                               QAT_LOG(ERR,
+                                       "Unrecognized service on bundle %d",
+                                       i);
+                               return -(EFAULT);
+                       }
 
                        memset(hw_data, 0, sizeof(*hw_data));
                        hw_data->service_type = service_type;
@@ -534,9 +557,9 @@ qat_read_qp_config(struct qat_pci_device *qat_dev,
                        hw_data->rx_ring_num = 1;
                        hw_data->hw_bundle_num = i;
                }
+               return 0;
        }
-       /* With default config will always return success */
-       return 0;
+       return -(EINVAL);
 }
 
 static int qat_qp_check_queue_alignment(uint64_t phys_addr,
index 3d9a757..e162719 100644 (file)
@@ -134,7 +134,6 @@ qat_select_valid_queue(struct qat_pci_device *qat_dev, int qp_id,
                        enum qat_service_type service_type);
 
 int
-qat_read_qp_config(struct qat_pci_device *qat_dev,
-                       enum qat_device_gen qat_dev_gen);
+qat_read_qp_config(struct qat_pci_device *qat_dev);
 
 #endif /* _QAT_QP_H_ */