xref: /dpdk/drivers/compress/qat/qat_comp_pmd.h (revision 477d7d0512113126dea32a6279ea7578fa9f4f12)
17a34c215SFiona Trahe /* SPDX-License-Identifier: BSD-3-Clause
27a34c215SFiona Trahe  * Copyright(c) 2015-2018 Intel Corporation
37a34c215SFiona Trahe  */
47a34c215SFiona Trahe 
57a34c215SFiona Trahe #ifndef _QAT_COMP_PMD_H_
67a34c215SFiona Trahe #define _QAT_COMP_PMD_H_
77a34c215SFiona Trahe 
8a8d0d473SBruce Richardson #ifdef RTE_LIB_COMPRESSDEV
97a34c215SFiona Trahe 
107a34c215SFiona Trahe #include <rte_compressdev.h>
117a34c215SFiona Trahe #include <rte_compressdev_pmd.h>
127a34c215SFiona Trahe 
1332842f2aSFiona Trahe #include "qat_device.h"
144c6912d3SFan Zhang #include "qat_comp.h"
1532842f2aSFiona Trahe 
16*f8dbaebbSSean Morrissey /**< Intel(R) QAT Compression PMD name */
17df8cca46SFiona Trahe #define COMPRESSDEV_NAME_QAT_PMD	compress_qat
18df8cca46SFiona Trahe 
194c6912d3SFan Zhang /* Private data structure for a QAT compression device capability. */
204c6912d3SFan Zhang struct qat_comp_capabilities_info {
214c6912d3SFan Zhang 	const struct rte_compressdev_capabilities *data;
224c6912d3SFan Zhang 	uint64_t size;
234c6912d3SFan Zhang };
244c6912d3SFan Zhang 
254c6912d3SFan Zhang /**
264c6912d3SFan Zhang  * Function prototypes for GENx specific compress device operations.
274c6912d3SFan Zhang  **/
284c6912d3SFan Zhang typedef struct qat_comp_capabilities_info (*get_comp_capabilities_info_t)
294c6912d3SFan Zhang 		(struct qat_pci_device *qat_dev);
304c6912d3SFan Zhang 
314c6912d3SFan Zhang typedef uint16_t (*get_comp_ram_bank_flags_t)(void);
324c6912d3SFan Zhang 
334c6912d3SFan Zhang typedef int (*set_comp_slice_cfg_word_t)(struct qat_comp_xform *qat_xform,
344c6912d3SFan Zhang 		const struct rte_comp_xform *xform,
354c6912d3SFan Zhang 		enum rte_comp_op_type op_type, uint32_t *comp_slice_cfg_word);
364c6912d3SFan Zhang 
374c6912d3SFan Zhang typedef unsigned int (*get_comp_num_im_bufs_required_t)(void);
384c6912d3SFan Zhang 
394c6912d3SFan Zhang typedef uint64_t (*get_comp_feature_flags_t)(void);
404c6912d3SFan Zhang 
414c6912d3SFan Zhang struct qat_comp_gen_dev_ops {
424c6912d3SFan Zhang 	struct rte_compressdev_ops *compressdev_ops;
434c6912d3SFan Zhang 	get_comp_feature_flags_t qat_comp_get_feature_flags;
444c6912d3SFan Zhang 	get_comp_capabilities_info_t qat_comp_get_capabilities;
454c6912d3SFan Zhang 	get_comp_ram_bank_flags_t qat_comp_get_ram_bank_flags;
464c6912d3SFan Zhang 	set_comp_slice_cfg_word_t qat_comp_set_slice_cfg_word;
474c6912d3SFan Zhang 	get_comp_num_im_bufs_required_t qat_comp_get_num_im_bufs_required;
484c6912d3SFan Zhang };
494c6912d3SFan Zhang 
504c6912d3SFan Zhang extern struct qat_comp_gen_dev_ops qat_comp_gen_dev_ops[];
514c6912d3SFan Zhang 
526a7ea148SFiona Trahe /** private data structure for a QAT compression device.
536a7ea148SFiona Trahe  * This QAT device is a device offering only a compression service,
546a7ea148SFiona Trahe  * there can be one of these on each qat_pci_device (VF).
556a7ea148SFiona Trahe  */
566a7ea148SFiona Trahe struct qat_comp_dev_private {
576a7ea148SFiona Trahe 	struct qat_pci_device *qat_dev;
586a7ea148SFiona Trahe 	/**< The qat pci device hosting the service */
596a7ea148SFiona Trahe 	struct rte_compressdev *compressdev;
606a7ea148SFiona Trahe 	/**< The pointer to this compression device structure */
6184aaaf8eSFiona Trahe 	const struct rte_compressdev_capabilities *qat_dev_capabilities;
6284aaaf8eSFiona Trahe 	/* QAT device compression capabilities */
636a7ea148SFiona Trahe 	const struct rte_memzone *interm_buff_mz;
646a7ea148SFiona Trahe 	/**< The device's memory for intermediate buffers */
656a7ea148SFiona Trahe 	struct rte_mempool *xformpool;
666a7ea148SFiona Trahe 	/**< The device's pool for qat_comp_xforms */
6782822753SAdam Dybkowski 	struct rte_mempool *streampool;
6882822753SAdam Dybkowski 	/**< The device's pool for qat_comp_streams */
697788dcecSArek Kusztal 	const struct rte_memzone *capa_mz;
707788dcecSArek Kusztal 	/* Shared memzone for storing capabilities */
7147c3f7a4SArek Kusztal 	uint16_t min_enq_burst_threshold;
726a7ea148SFiona Trahe };
736a7ea148SFiona Trahe 
74c0c90bc4SFiona Trahe int
754c6912d3SFan Zhang qat_comp_dev_config(struct rte_compressdev *dev,
764c6912d3SFan Zhang 		struct rte_compressdev_config *config);
774c6912d3SFan Zhang 
784c6912d3SFan Zhang int
794c6912d3SFan Zhang qat_comp_dev_start(struct rte_compressdev *dev __rte_unused);
804c6912d3SFan Zhang 
814c6912d3SFan Zhang void
824c6912d3SFan Zhang qat_comp_dev_stop(struct rte_compressdev *dev __rte_unused);
834c6912d3SFan Zhang 
844c6912d3SFan Zhang int
854c6912d3SFan Zhang qat_comp_dev_close(struct rte_compressdev *dev);
864c6912d3SFan Zhang 
874c6912d3SFan Zhang void
884c6912d3SFan Zhang qat_comp_dev_info_get(struct rte_compressdev *dev,
894c6912d3SFan Zhang 		struct rte_compressdev_info *info);
904c6912d3SFan Zhang 
914c6912d3SFan Zhang void
924c6912d3SFan Zhang qat_comp_stats_get(struct rte_compressdev *dev,
934c6912d3SFan Zhang 		struct rte_compressdev_stats *stats);
944c6912d3SFan Zhang 
954c6912d3SFan Zhang void
964c6912d3SFan Zhang qat_comp_stats_reset(struct rte_compressdev *dev);
974c6912d3SFan Zhang 
984c6912d3SFan Zhang int
994c6912d3SFan Zhang qat_comp_qp_release(struct rte_compressdev *dev, uint16_t queue_pair_id);
1004c6912d3SFan Zhang 
1014c6912d3SFan Zhang int
1024c6912d3SFan Zhang qat_comp_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
1034c6912d3SFan Zhang 		uint32_t max_inflight_ops, int socket_id);
1044c6912d3SFan Zhang 
1054c6912d3SFan Zhang const struct rte_memzone *
1064c6912d3SFan Zhang qat_comp_setup_inter_buffers(struct qat_comp_dev_private *comp_dev,
1074c6912d3SFan Zhang 		uint32_t buff_size);
1084c6912d3SFan Zhang 
1094c6912d3SFan Zhang static __rte_always_inline unsigned int
qat_comp_get_num_im_bufs_required(enum qat_device_gen gen)1104c6912d3SFan Zhang qat_comp_get_num_im_bufs_required(enum qat_device_gen gen)
1114c6912d3SFan Zhang {
1124c6912d3SFan Zhang 	return (*qat_comp_gen_dev_ops[gen].qat_comp_get_num_im_bufs_required)();
1134c6912d3SFan Zhang }
1144c6912d3SFan Zhang 
1157a34c215SFiona Trahe #endif
1167a34c215SFiona Trahe #endif /* _QAT_COMP_PMD_H_ */
117