]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/qat.h
Code improvement and bug fixes for QAT support
[mirror_zfs.git] / module / zfs / qat.h
index 4866dfe150692e1937c87d70ae6a0acd84e20c51..9014c03148bad09c3128961904a7bba6b3f8a279 100644 (file)
@@ -46,96 +46,97 @@ typedef enum qat_encrypt_dir {
 #define        QAT_TIMEOUT_MS          500
 
 /*
- * The minimal and maximal buffer size, which are not restricted
+ * The minimal and maximal buffer size which are not restricted
  * in the QAT hardware, but with the input buffer size between 4KB
- * and 128KB, the hardware can provide the optimal performance.
+ * and 128KB the hardware can provide the optimal performance.
  */
 #define        QAT_MIN_BUF_SIZE        (4*1024)
 #define        QAT_MAX_BUF_SIZE        (128*1024)
 
 /*
- * Used for qat kstat.
+ * Used for QAT kstat.
  */
 typedef struct qat_stats {
        /*
-        * Number of jobs submitted to qat compression engine.
+        * Number of jobs submitted to QAT compression engine.
         */
        kstat_named_t comp_requests;
        /*
-        * Total bytes sent to qat compression engine.
+        * Total bytes sent to QAT compression engine.
         */
        kstat_named_t comp_total_in_bytes;
        /*
-        * Total bytes output from qat compression engine.
+        * Total bytes output from QAT compression engine.
         */
        kstat_named_t comp_total_out_bytes;
        /*
-        * Number of jobs submitted to qat de-compression engine.
+        * Number of jobs submitted to QAT de-compression engine.
         */
        kstat_named_t decomp_requests;
        /*
-        * Total bytes sent to qat de-compression engine.
+        * Total bytes sent to QAT de-compression engine.
         */
        kstat_named_t decomp_total_in_bytes;
        /*
-        * Total bytes output from qat de-compression engine.
+        * Total bytes output from QAT de-compression engine.
         */
        kstat_named_t decomp_total_out_bytes;
        /*
-        * Number of fails in the qat compression / decompression engine.
-        * Note: when qat fail happens, it doesn't mean a critical hardware
-        * issue. Sometimes it is because the output buffer is not big enough.
-        * The compression job will be transfered to gzip software
-        * implementation, so the functionality of ZFS is not impacted.
+        * Number of fails in the QAT compression / decompression engine.
+        * Note: when a QAT error happens, it doesn't necessarily indicate a
+        * critical hardware issue. Sometimes it is because the output buffer
+        * is not big enough. The compression job will be transfered to the
+        * gzip software implementation so the functionality of ZFS is not
+        * impacted.
         */
        kstat_named_t dc_fails;
 
        /*
-        * Number of jobs submitted to qat encryption engine.
+        * Number of jobs submitted to QAT encryption engine.
         */
        kstat_named_t encrypt_requests;
        /*
-        * Total bytes sent to qat encryption engine.
+        * Total bytes sent to QAT encryption engine.
         */
        kstat_named_t encrypt_total_in_bytes;
        /*
-        * Total bytes output from qat encryption engine.
+        * Total bytes output from QAT encryption engine.
         */
        kstat_named_t encrypt_total_out_bytes;
        /*
-        * Number of jobs submitted to qat decryption engine.
+        * Number of jobs submitted to QAT decryption engine.
         */
        kstat_named_t decrypt_requests;
        /*
-        * Total bytes sent to qat decryption engine.
+        * Total bytes sent to QAT decryption engine.
         */
        kstat_named_t decrypt_total_in_bytes;
        /*
-        * Total bytes output from qat decryption engine.
+        * Total bytes output from QAT decryption engine.
         */
        kstat_named_t decrypt_total_out_bytes;
        /*
-        * Number of fails in the qat encryption / decryption engine.
-        * Note: when qat fail happens, it doesn't mean a critical hardware
-        * issue. Sometimes it is because the output buffer is not big enough.
-        * The encryption job will be transfered to the software implementation,
-        * so the functionality of ZFS is not impacted.
+        * Number of fails in the QAT encryption / decryption engine.
+        * Note: when a QAT error happens, it doesn't necessarily indicate a
+        * critical hardware issue. The encryption job will be transfered
+        * to the software implementation so the functionality of ZFS is
+        * not impacted.
         */
        kstat_named_t crypt_fails;
 
        /*
-        * Number of jobs submitted to qat checksum engine.
+        * Number of jobs submitted to QAT checksum engine.
         */
        kstat_named_t cksum_requests;
        /*
-        * Total bytes sent to qat checksum engine.
+        * Total bytes sent to QAT checksum engine.
         */
        kstat_named_t cksum_total_in_bytes;
        /*
-        * Number of fails in the qat checksum engine.
-        * Note: when qat fail happens, it doesn't mean a critical hardware
-        * issue. The checksum job will be transfered to the software
-        * implementation, so the functionality of ZFS is not impacted.
+        * Number of fails in the QAT checksum engine.
+        * Note: when a QAT error happens, it doesn't necessarily indicate a
+        * critical hardware issue. The checksum job will be transfered to the
+        * software implementation so the functionality of ZFS is not impacted.
         */
        kstat_named_t cksum_fails;
 } qat_stats_t;
@@ -146,6 +147,9 @@ typedef struct qat_stats {
        QAT_STAT_INCR(stat, 1)
 
 extern qat_stats_t qat_stats;
+extern int zfs_qat_compress_disable;
+extern int zfs_qat_checksum_disable;
+extern int zfs_qat_encrypt_disable;
 
 /* inlined for performance */
 static inline struct page *
@@ -166,11 +170,14 @@ void qat_mem_free_contig(void **pp_mem_addr);
 
 extern int qat_dc_init(void);
 extern void qat_dc_fini(void);
-extern int qat_crypt_init(void);
-extern void qat_crypt_fini(void);
+extern int qat_cy_init(void);
+extern void qat_cy_fini(void);
 extern int qat_init(void);
 extern void qat_fini(void);
 
+/* fake CpaStatus used to indicate data was not compressible */
+#define        CPA_STATUS_INCOMPRESSIBLE                               (-127)
+
 extern boolean_t qat_dc_use_accel(size_t s_len);
 extern boolean_t qat_crypt_use_accel(size_t s_len);
 extern boolean_t qat_checksum_use_accel(size_t s_len);
@@ -183,6 +190,7 @@ extern int qat_checksum(uint64_t cksum, uint8_t *buf, uint64_t size,
     zio_cksum_t *zcp);
 #else
 #define        CPA_STATUS_SUCCESS                                      0
+#define        CPA_STATUS_INCOMPRESSIBLE                               (-127)
 #define        qat_init()
 #define        qat_fini()
 #define        qat_dc_use_accel(s_len)                                 0