Skip to content

Commit

Permalink
lib/zlib: add zlib_deflate_dfltcc_enabled() function
Browse files Browse the repository at this point in the history
Add a new function to zlib.h checking if s390 Deflate-Conversion
facility is installed and enabled.

Link: http:https://lkml.kernel.org/r/[email protected]
Signed-off-by: Mikhail Zaslonko <[email protected]>
Cc: Chris Mason <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: David Sterba <[email protected]>
Cc: Eduard Shishkin <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Ilya Leoshkevich <[email protected]>
Cc: Josef Bacik <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mzaslonk authored and torvalds committed Jan 31, 2020
1 parent c65e681 commit 803521b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions include/linux/zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
exceed those passed here.
*/

extern int zlib_deflate_dfltcc_enabled (void);
/*
Returns 1 if Deflate-Conversion facility is installed and enabled,
otherwise 0.
*/

/*
extern int deflateInit (z_streamp strm, int level);
Expand Down
6 changes: 6 additions & 0 deletions lib/zlib_deflate/deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#define DEFLATE_RESET_HOOK(strm) do {} while (0)
#define DEFLATE_HOOK(strm, flush, bstate) 0
#define DEFLATE_NEED_CHECKSUM(strm) 1
#define DEFLATE_DFLTCC_ENABLED() 0
#endif

/* ===========================================================================
Expand Down Expand Up @@ -1138,3 +1139,8 @@ int zlib_deflate_workspacesize(int windowBits, int memLevel)
+ zlib_deflate_head_memsize(memLevel)
+ zlib_deflate_overlay_memsize(memLevel);
}

int zlib_deflate_dfltcc_enabled(void)
{
return DEFLATE_DFLTCC_ENABLED();
}
1 change: 1 addition & 0 deletions lib/zlib_deflate/deflate_syms.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/zlib.h>

EXPORT_SYMBOL(zlib_deflate_workspacesize);
EXPORT_SYMBOL(zlib_deflate_dfltcc_enabled);
EXPORT_SYMBOL(zlib_deflate);
EXPORT_SYMBOL(zlib_deflateInit2);
EXPORT_SYMBOL(zlib_deflateEnd);
Expand Down
11 changes: 11 additions & 0 deletions lib/zlib_dfltcc/dfltcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#define DFLTCC_H

#include "../zlib_deflate/defutil.h"
#include <asm/facility.h>
#include <asm/setup.h>

/*
* Tuning parameters.
Expand All @@ -14,6 +16,8 @@
#define DFLTCC_DHT_MIN_SAMPLE_SIZE 4096
#define DFLTCC_RIBM 0

#define DFLTCC_FACILITY 151

/*
* Parameter Block for Query Available Functions.
*/
Expand Down Expand Up @@ -113,6 +117,11 @@ typedef enum {
} dfltcc_inflate_action;
dfltcc_inflate_action dfltcc_inflate(z_streamp strm,
int flush, int *ret);
static inline int is_dfltcc_enabled(void)
{
return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED &&
test_facility(DFLTCC_FACILITY));
}

#define DEFLATE_RESET_HOOK(strm) \
dfltcc_reset((strm), sizeof(deflate_state))
Expand All @@ -121,6 +130,8 @@ dfltcc_inflate_action dfltcc_inflate(z_streamp strm,

#define DEFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_deflate((strm)))

#define DEFLATE_DFLTCC_ENABLED() is_dfltcc_enabled()

#define INFLATE_RESET_HOOK(strm) \
dfltcc_reset((strm), sizeof(struct inflate_state))

Expand Down
9 changes: 0 additions & 9 deletions lib/zlib_dfltcc/dfltcc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#define DFLTCC_UTIL_H

#include <linux/zutil.h>
#include <asm/facility.h>
#include <asm/setup.h>

/*
* C wrapper for the DEFLATE CONVERSION CALL instruction.
Expand All @@ -24,7 +22,6 @@ typedef enum {
#define HBT_CIRCULAR (1 << 7)
#define HB_BITS 15
#define HB_SIZE (1 << HB_BITS)
#define DFLTCC_FACILITY 151

static inline dfltcc_cc dfltcc(
int fn,
Expand Down Expand Up @@ -101,12 +98,6 @@ static inline int dfltcc_are_params_ok(
(strategy == Z_DEFAULT_STRATEGY);
}

static inline int is_dfltcc_enabled(void)
{
return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED &&
test_facility(DFLTCC_FACILITY));
}

char *oesc_msg(char *buf, int oesc);

#endif /* DFLTCC_UTIL_H */

0 comments on commit 803521b

Please sign in to comment.