156cf2635SRahul Lakkireddy /*
256cf2635SRahul Lakkireddy  *  Copyright (C) 2018 Chelsio Communications.  All rights reserved.
356cf2635SRahul Lakkireddy  *
456cf2635SRahul Lakkireddy  *  This program is free software; you can redistribute it and/or modify it
556cf2635SRahul Lakkireddy  *  under the terms and conditions of the GNU General Public License,
656cf2635SRahul Lakkireddy  *  version 2, as published by the Free Software Foundation.
756cf2635SRahul Lakkireddy  *
856cf2635SRahul Lakkireddy  *  This program is distributed in the hope it will be useful, but WITHOUT
956cf2635SRahul Lakkireddy  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1056cf2635SRahul Lakkireddy  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
1156cf2635SRahul Lakkireddy  *  more details.
1256cf2635SRahul Lakkireddy  *
1356cf2635SRahul Lakkireddy  *  The full GNU General Public License is included in this distribution in
1456cf2635SRahul Lakkireddy  *  the file called "COPYING".
1556cf2635SRahul Lakkireddy  *
1656cf2635SRahul Lakkireddy  */
1756cf2635SRahul Lakkireddy 
1856cf2635SRahul Lakkireddy #ifndef __CUDBG_ZLIB_H__
1956cf2635SRahul Lakkireddy #define __CUDBG_ZLIB_H__
2056cf2635SRahul Lakkireddy 
2191c1953dSRahul Lakkireddy #include <linux/zlib.h>
2291c1953dSRahul Lakkireddy 
2391c1953dSRahul Lakkireddy #define CUDBG_ZLIB_COMPRESS_ID 17
2491c1953dSRahul Lakkireddy #define CUDBG_ZLIB_WIN_BITS 12
2591c1953dSRahul Lakkireddy #define CUDBG_ZLIB_MEM_LVL 4
2691c1953dSRahul Lakkireddy 
2791c1953dSRahul Lakkireddy struct cudbg_compress_hdr {
2891c1953dSRahul Lakkireddy 	u32 compress_id;
2991c1953dSRahul Lakkireddy 	u64 decompress_size;
3091c1953dSRahul Lakkireddy 	u64 compress_size;
3191c1953dSRahul Lakkireddy 	u64 rsvd[32];
3291c1953dSRahul Lakkireddy };
3391c1953dSRahul Lakkireddy 
3491c1953dSRahul Lakkireddy static inline int cudbg_get_workspace_size(void)
3591c1953dSRahul Lakkireddy {
3691c1953dSRahul Lakkireddy #ifdef CONFIG_ZLIB_DEFLATE
3791c1953dSRahul Lakkireddy 	return zlib_deflate_workspacesize(CUDBG_ZLIB_WIN_BITS,
3891c1953dSRahul Lakkireddy 					  CUDBG_ZLIB_MEM_LVL);
3991c1953dSRahul Lakkireddy #else
4091c1953dSRahul Lakkireddy 	return 0;
4191c1953dSRahul Lakkireddy #endif /* CONFIG_ZLIB_DEFLATE */
4291c1953dSRahul Lakkireddy }
4391c1953dSRahul Lakkireddy 
4491c1953dSRahul Lakkireddy #ifndef CONFIG_ZLIB_DEFLATE
4556cf2635SRahul Lakkireddy static inline int cudbg_compress_buff(struct cudbg_init *pdbg_init,
4656cf2635SRahul Lakkireddy 				      struct cudbg_buffer *pin_buff,
4756cf2635SRahul Lakkireddy 				      struct cudbg_buffer *pout_buff)
4856cf2635SRahul Lakkireddy {
4956cf2635SRahul Lakkireddy 	return 0;
5056cf2635SRahul Lakkireddy }
5191c1953dSRahul Lakkireddy #else
5291c1953dSRahul Lakkireddy int cudbg_compress_buff(struct cudbg_init *pdbg_init,
5391c1953dSRahul Lakkireddy 			struct cudbg_buffer *pin_buff,
5491c1953dSRahul Lakkireddy 			struct cudbg_buffer *pout_buff);
5591c1953dSRahul Lakkireddy #endif /* CONFIG_ZLIB_DEFLATE */
5656cf2635SRahul Lakkireddy #endif /* __CUDBG_ZLIB_H__ */
57