1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
7 #include <rte_cryptodev_pmd.h>
8 #include <rte_bus_pci.h>
9 #include "qat_common.h"
11 #include "adf_transport_access_macros.h"
15 #define QAT_DETACHED (0)
16 #define QAT_ATTACHED (1)
18 #define QAT_MAX_PCI_DEVICES 48
19 #define QAT_DEV_NAME_MAX_LEN 64
22 extern uint8_t cryptodev_qat_driver_id;
24 extern int qat_sym_qp_release(struct rte_cryptodev *dev,
25 uint16_t queue_pair_id);
28 * This struct holds all the data about a QAT pci device
29 * including data about all services it supports.
35 struct qat_sym_dev_private;
36 struct qat_pci_device {
38 /* Data used by all services */
39 char name[QAT_DEV_NAME_MAX_LEN];
40 /**< Name of qat pci device */
42 /**< Device instance for this qat pci device */
43 struct rte_pci_device *pci_dev;
44 /**< PCI information. */
45 enum qat_device_gen qat_dev_gen;
46 /**< QAT device generation */
47 rte_spinlock_t arb_csr_lock;
48 /**< lock to protect accesses to the arbiter CSR */
51 /**< Flag indicating the device is attached */
53 struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_PER_BUNDLE];
54 /**< links to qps set up for each service, index same as on API */
56 /* Data relating to symmetric crypto service */
57 struct qat_sym_dev_private *sym_dev;
58 /**< link back to cryptodev private data */
60 /* Data relating to compression service */
62 /* Data relating to asymmetric crypto service */
66 /** private data structure for a QAT device.
67 * This QAT device is a device offering only symmetric crypto service,
68 * there can be one of these on each qat_pci_device (VF),
69 * in future there may also be private data structures for other services.
71 struct qat_sym_dev_private {
72 struct qat_pci_device *qat_dev;
73 /**< The qat pci device hosting the service */
75 /**< Device instance for this rte_cryptodev */
76 const struct rte_cryptodev_capabilities *qat_dev_capabilities;
77 /* QAT device symmetric crypto capabilities */
80 struct qat_gen_hw_data {
81 enum qat_device_gen dev_gen;
82 const struct qat_qp_hw_data (*qp_hw_data)[ADF_MAX_QPS_PER_BUNDLE];
85 extern struct qat_gen_hw_data qp_gen_config[];
87 int qat_dev_config(struct rte_cryptodev *dev,
88 struct rte_cryptodev_config *config);
89 int qat_dev_start(struct rte_cryptodev *dev);
90 void qat_dev_stop(struct rte_cryptodev *dev);
91 int qat_dev_close(struct rte_cryptodev *dev);
92 void qat_sym_dev_info_get(struct rte_cryptodev *dev,
93 struct rte_cryptodev_info *info);
95 struct qat_pci_device *
96 qat_pci_device_allocate(struct rte_pci_device *pci_dev);
98 qat_pci_device_release(struct rte_pci_device *pci_dev);
99 struct qat_pci_device *
100 qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev);
102 #endif /* _QAT_DEVICE_H_ */