1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018 Intel Corporation 3 */ 4 #ifndef _QAT_COMMON_H_ 5 #define _QAT_COMMON_H_ 6 7 #include <stdint.h> 8 9 #include <rte_mbuf.h> 10 11 /**< Intel(R) QAT device name for PCI registration */ 12 #define QAT_PCI_NAME qat 13 #define QAT_64_BTYE_ALIGN_MASK (~0x3f) 14 15 /* Intel(R) QuickAssist Technology device generation is enumerated 16 * from one according to the generation of the device. 17 * QAT_GEN* is used as the index to find all devices 18 */ 19 20 extern const char *const *qat_cmdline_defines[]; 21 22 enum qat_device_gen { 23 QAT_GEN1, 24 QAT_GEN2, 25 QAT_GEN3, 26 QAT_GEN4, 27 QAT_GEN5, 28 QAT_GEN_LCE, 29 QAT_VQAT, 30 QAT_N_GENS 31 }; 32 33 enum qat_service_type { 34 QAT_SERVICE_ASYMMETRIC, 35 QAT_SERVICE_SYMMETRIC, 36 QAT_SERVICE_COMPRESSION, 37 QAT_MAX_SERVICES 38 }; 39 40 #define QAT_SERVICE_INVALID (QAT_MAX_SERVICES) 41 42 enum qat_svc_list { 43 QAT_SVC_UNUSED = 0, 44 QAT_SVC_CRYPTO = 1, 45 QAT_SVC_COMPRESSION = 2, 46 QAT_SVC_SYM = 3, 47 QAT_SVC_ASYM = 4, 48 }; 49 50 /**< Common struct for scatter-gather list operations */ 51 struct qat_flat_buf { 52 uint32_t len; 53 uint32_t resrvd; 54 uint64_t addr; 55 } __rte_packed; 56 57 #define qat_sgl_hdr struct { \ 58 uint64_t resrvd; \ 59 uint32_t num_bufs; \ 60 uint32_t num_mapped_bufs; \ 61 } 62 63 __extension__ 64 struct qat_sgl { 65 qat_sgl_hdr; 66 /* flexible array of flat buffers*/ 67 struct qat_flat_buf buffers[0]; 68 } __rte_packed __rte_cache_aligned; 69 70 /** Common, i.e. not service-specific, statistics */ 71 struct qat_common_stats { 72 uint64_t enqueued_count; 73 /**< Count of all operations enqueued */ 74 uint64_t dequeued_count; 75 /**< Count of all operations dequeued */ 76 77 uint64_t enqueue_err_count; 78 /**< Total error count on operations enqueued */ 79 uint64_t dequeue_err_count; 80 /**< Total error count on operations dequeued */ 81 uint64_t threshold_hit_count; 82 /**< Total number of times min qp threshold condition was fulfilled */ 83 84 }; 85 86 struct qat_pci_device; 87 88 int 89 qat_sgl_fill_array(struct rte_mbuf *buf, int64_t offset, 90 void *list_in, uint32_t data_len, 91 const uint16_t max_segs); 92 void 93 qat_stats_get(struct qat_pci_device *dev, 94 struct qat_common_stats *stats, 95 enum qat_service_type service); 96 void 97 qat_stats_reset(struct qat_pci_device *dev, 98 enum qat_service_type service); 99 100 const char * 101 qat_service_get_str(enum qat_service_type type); 102 103 #endif /* _QAT_COMMON_H_ */ 104