1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2015-2018 Intel Corporation 3 */ 4 5 #ifndef _QAT_COMP_PMD_H_ 6 #define _QAT_COMP_PMD_H_ 7 8 #ifdef RTE_LIB_COMPRESSDEV 9 10 #include <rte_compressdev.h> 11 #include <rte_compressdev_pmd.h> 12 13 #include "qat_device.h" 14 #include "qat_comp.h" 15 16 /**< Intel(R) QAT Compression PMD name */ 17 #define COMPRESSDEV_NAME_QAT_PMD compress_qat 18 19 /* Private data structure for a QAT compression device capability. */ 20 struct qat_comp_capabilities_info { 21 const struct rte_compressdev_capabilities *data; 22 uint64_t size; 23 }; 24 25 /** 26 * Function prototypes for GENx specific compress device operations. 27 **/ 28 typedef struct qat_comp_capabilities_info (*get_comp_capabilities_info_t) 29 (struct qat_pci_device *qat_dev); 30 31 typedef uint16_t (*get_comp_ram_bank_flags_t)(void); 32 33 typedef int (*set_comp_slice_cfg_word_t)(struct qat_comp_xform *qat_xform, 34 const struct rte_comp_xform *xform, 35 enum rte_comp_op_type op_type, uint32_t *comp_slice_cfg_word); 36 37 typedef unsigned int (*get_comp_num_im_bufs_required_t)(void); 38 39 typedef uint64_t (*get_comp_feature_flags_t)(void); 40 41 struct qat_comp_gen_dev_ops { 42 struct rte_compressdev_ops *compressdev_ops; 43 get_comp_feature_flags_t qat_comp_get_feature_flags; 44 get_comp_capabilities_info_t qat_comp_get_capabilities; 45 get_comp_ram_bank_flags_t qat_comp_get_ram_bank_flags; 46 set_comp_slice_cfg_word_t qat_comp_set_slice_cfg_word; 47 get_comp_num_im_bufs_required_t qat_comp_get_num_im_bufs_required; 48 }; 49 50 extern struct qat_comp_gen_dev_ops qat_comp_gen_dev_ops[]; 51 52 /** private data structure for a QAT compression device. 53 * This QAT device is a device offering only a compression service, 54 * there can be one of these on each qat_pci_device (VF). 55 */ 56 struct qat_comp_dev_private { 57 struct qat_pci_device *qat_dev; 58 /**< The qat pci device hosting the service */ 59 struct rte_compressdev *compressdev; 60 /**< The pointer to this compression device structure */ 61 const struct rte_compressdev_capabilities *qat_dev_capabilities; 62 /* QAT device compression capabilities */ 63 const struct rte_memzone *interm_buff_mz; 64 /**< The device's memory for intermediate buffers */ 65 struct rte_mempool *xformpool; 66 /**< The device's pool for qat_comp_xforms */ 67 struct rte_mempool *streampool; 68 /**< The device's pool for qat_comp_streams */ 69 const struct rte_memzone *capa_mz; 70 /* Shared memzone for storing capabilities */ 71 uint16_t min_enq_burst_threshold; 72 }; 73 74 int 75 qat_comp_dev_config(struct rte_compressdev *dev, 76 struct rte_compressdev_config *config); 77 78 int 79 qat_comp_dev_start(struct rte_compressdev *dev __rte_unused); 80 81 void 82 qat_comp_dev_stop(struct rte_compressdev *dev __rte_unused); 83 84 int 85 qat_comp_dev_close(struct rte_compressdev *dev); 86 87 void 88 qat_comp_dev_info_get(struct rte_compressdev *dev, 89 struct rte_compressdev_info *info); 90 91 void 92 qat_comp_stats_get(struct rte_compressdev *dev, 93 struct rte_compressdev_stats *stats); 94 95 void 96 qat_comp_stats_reset(struct rte_compressdev *dev); 97 98 int 99 qat_comp_qp_release(struct rte_compressdev *dev, uint16_t queue_pair_id); 100 101 int 102 qat_comp_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, 103 uint32_t max_inflight_ops, int socket_id); 104 105 const struct rte_memzone * 106 qat_comp_setup_inter_buffers(struct qat_comp_dev_private *comp_dev, 107 uint32_t buff_size); 108 109 static __rte_always_inline unsigned int 110 qat_comp_get_num_im_bufs_required(enum qat_device_gen gen) 111 { 112 return (*qat_comp_gen_dev_ops[gen].qat_comp_get_num_im_bufs_required)(); 113 } 114 115 #endif 116 #endif /* _QAT_COMP_PMD_H_ */ 117