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_pci_device {
37 /* data used by all services */
38 char name[QAT_DEV_NAME_MAX_LEN];
39 /**< Name of qat pci device */
40 struct rte_pci_device *pci_dev;
41 /**< PCI information. */
42 enum qat_device_gen qat_dev_gen;
43 /**< QAT device generation */
44 rte_spinlock_t arb_csr_lock;
45 /* protects accesses to the arbiter CSR */
48 /**< Flag indicating the device is attached */
50 /* data relating to symmetric crypto service */
51 struct qat_pmd_private *sym_dev;
52 /**< link back to cryptodev private data */
53 unsigned int max_nb_sym_queue_pairs;
54 /**< Max number of queue pairs supported by device */
56 /* data relating to compression service */
58 /* data relating to asymmetric crypto service */
62 /** private data structure for a QAT device.
63 * This QAT device is a device offering only symmetric crypto service,
64 * there can be one of these on each qat_pci_device (VF),
65 * in future there may also be private data structures for other services.
67 struct qat_pmd_private {
68 unsigned int max_nb_queue_pairs;
69 /**< Max number of queue pairs supported by device */
70 unsigned int max_nb_sessions;
71 /**< Max number of sessions supported by device */
72 enum qat_device_gen qat_dev_gen;
73 /**< QAT device generation */
74 const struct rte_cryptodev_capabilities *qat_dev_capabilities;
75 /* QAT device capabilities */
76 struct rte_pci_device *pci_dev;
77 /**< PCI information. */
79 /**< Device ID for this instance */
80 struct qat_pci_device *qat_dev;
81 /**< The qat pci device hosting the service */
84 struct qat_gen_hw_data {
85 enum qat_device_gen dev_gen;
86 const struct qat_qp_hw_data (*qp_hw_data)[ADF_MAX_QPS_PER_BUNDLE];
89 extern struct qat_gen_hw_data qp_gen_config[];
91 int qat_dev_config(struct rte_cryptodev *dev,
92 struct rte_cryptodev_config *config);
93 int qat_dev_start(struct rte_cryptodev *dev);
94 void qat_dev_stop(struct rte_cryptodev *dev);
95 int qat_dev_close(struct rte_cryptodev *dev);
96 void qat_dev_info_get(struct rte_cryptodev *dev,
97 struct rte_cryptodev_info *info);
99 struct qat_pci_device *
100 qat_pci_device_allocate(struct rte_pci_device *pci_dev);
102 qat_pci_device_release(struct rte_pci_device *pci_dev);
103 struct qat_pci_device *
104 qat_get_qat_dev_from_pci_dev(struct rte_pci_device *pci_dev);
106 #endif /* _QAT_DEVICE_H_ */