Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/zlib: add zlib_deflate_dfltcc_enabled() function

Add a new function to zlib.h checking if s390 Deflate-Conversion
facility is installed and enabled.

Link: http://lkml.kernel.org/r/20200103223334.20669-6-zaslonko@linux.ibm.com
Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Cc: Chris Mason <clm@fb.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Eduard Shishkin <edward6@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mikhail Zaslonko and committed by
Linus Torvalds
803521b1 c65e6815

+24 -9
+6
include/linux/zlib.h
··· 191 191 exceed those passed here. 192 192 */ 193 193 194 + extern int zlib_deflate_dfltcc_enabled (void); 195 + /* 196 + Returns 1 if Deflate-Conversion facility is installed and enabled, 197 + otherwise 0. 198 + */ 199 + 194 200 /* 195 201 extern int deflateInit (z_streamp strm, int level); 196 202
+6
lib/zlib_deflate/deflate.c
··· 59 59 #define DEFLATE_RESET_HOOK(strm) do {} while (0) 60 60 #define DEFLATE_HOOK(strm, flush, bstate) 0 61 61 #define DEFLATE_NEED_CHECKSUM(strm) 1 62 + #define DEFLATE_DFLTCC_ENABLED() 0 62 63 #endif 63 64 64 65 /* =========================================================================== ··· 1138 1137 + zlib_deflate_prev_memsize(windowBits) 1139 1138 + zlib_deflate_head_memsize(memLevel) 1140 1139 + zlib_deflate_overlay_memsize(memLevel); 1140 + } 1141 + 1142 + int zlib_deflate_dfltcc_enabled(void) 1143 + { 1144 + return DEFLATE_DFLTCC_ENABLED(); 1141 1145 }
+1
lib/zlib_deflate/deflate_syms.c
··· 12 12 #include <linux/zlib.h> 13 13 14 14 EXPORT_SYMBOL(zlib_deflate_workspacesize); 15 + EXPORT_SYMBOL(zlib_deflate_dfltcc_enabled); 15 16 EXPORT_SYMBOL(zlib_deflate); 16 17 EXPORT_SYMBOL(zlib_deflateInit2); 17 18 EXPORT_SYMBOL(zlib_deflateEnd);
+11
lib/zlib_dfltcc/dfltcc.h
··· 3 3 #define DFLTCC_H 4 4 5 5 #include "../zlib_deflate/defutil.h" 6 + #include <asm/facility.h> 7 + #include <asm/setup.h> 6 8 7 9 /* 8 10 * Tuning parameters. ··· 15 13 #define DFLTCC_FIRST_FHT_BLOCK_SIZE 4096 16 14 #define DFLTCC_DHT_MIN_SAMPLE_SIZE 4096 17 15 #define DFLTCC_RIBM 0 16 + 17 + #define DFLTCC_FACILITY 151 18 18 19 19 /* 20 20 * Parameter Block for Query Available Functions. ··· 117 113 } dfltcc_inflate_action; 118 114 dfltcc_inflate_action dfltcc_inflate(z_streamp strm, 119 115 int flush, int *ret); 116 + static inline int is_dfltcc_enabled(void) 117 + { 118 + return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED && 119 + test_facility(DFLTCC_FACILITY)); 120 + } 120 121 121 122 #define DEFLATE_RESET_HOOK(strm) \ 122 123 dfltcc_reset((strm), sizeof(deflate_state)) ··· 129 120 #define DEFLATE_HOOK dfltcc_deflate 130 121 131 122 #define DEFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_deflate((strm))) 123 + 124 + #define DEFLATE_DFLTCC_ENABLED() is_dfltcc_enabled() 132 125 133 126 #define INFLATE_RESET_HOOK(strm) \ 134 127 dfltcc_reset((strm), sizeof(struct inflate_state))
-9
lib/zlib_dfltcc/dfltcc_util.h
··· 3 3 #define DFLTCC_UTIL_H 4 4 5 5 #include <linux/zutil.h> 6 - #include <asm/facility.h> 7 - #include <asm/setup.h> 8 6 9 7 /* 10 8 * C wrapper for the DEFLATE CONVERSION CALL instruction. ··· 22 24 #define HBT_CIRCULAR (1 << 7) 23 25 #define HB_BITS 15 24 26 #define HB_SIZE (1 << HB_BITS) 25 - #define DFLTCC_FACILITY 151 26 27 27 28 static inline dfltcc_cc dfltcc( 28 29 int fn, ··· 96 99 return (level_mask & (1 << level)) != 0 && 97 100 (window_bits == HB_BITS) && 98 101 (strategy == Z_DEFAULT_STRATEGY); 99 - } 100 - 101 - static inline int is_dfltcc_enabled(void) 102 - { 103 - return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED && 104 - test_facility(DFLTCC_FACILITY)); 105 102 } 106 103 107 104 char *oesc_msg(char *buf, int oesc);