Lines Matching full:state
47 * State for a Deflate (de)compressor.
63 static void z_comp_free(void *state);
64 static void z_decomp_free(void *state);
65 static int z_comp_init(void *state, unsigned char *options,
68 static int z_decomp_init(void *state, unsigned char *options,
71 static int z_compress(void *state, unsigned char *rptr,
74 static void z_incomp(void *state, unsigned char *ibuf, int icnt);
75 static int z_decompress(void *state, unsigned char *ibuf,
77 static void z_comp_reset(void *state);
78 static void z_decomp_reset(void *state);
79 static void z_comp_stats(void *state, struct compstat *stats);
83 * @arg: pointer to the private state for the compressor.
87 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_comp_free() local
89 if (state) { in z_comp_free()
90 zlib_deflateEnd(&state->strm); in z_comp_free()
91 vfree(state->strm.workspace); in z_comp_free()
92 kfree(state); in z_comp_free()
107 * Returns the pointer to the private state for the compressor,
112 struct ppp_deflate_state *state; in z_comp_alloc() local
125 state = kzalloc(sizeof(*state), in z_comp_alloc()
127 if (state == NULL) in z_comp_alloc()
130 state->strm.next_in = NULL; in z_comp_alloc()
131 state->w_size = w_size; in z_comp_alloc()
132 state->strm.workspace = vmalloc(zlib_deflate_workspacesize(-w_size, 8)); in z_comp_alloc()
133 if (state->strm.workspace == NULL) in z_comp_alloc()
136 if (zlib_deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, in z_comp_alloc()
140 return (void *) state; in z_comp_alloc()
143 z_comp_free(state); in z_comp_alloc()
149 * @arg: pointer to the private state for the compressor
165 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_comp_init() local
171 DEFLATE_SIZE(options[2]) != state->w_size || in z_comp_init()
175 state->seqno = 0; in z_comp_init()
176 state->unit = unit; in z_comp_init()
177 state->debug = debug; in z_comp_init()
179 zlib_deflateReset(&state->strm); in z_comp_init()
186 * @arg: pointer to private state for the compressor.
193 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_comp_reset() local
195 state->seqno = 0; in z_comp_reset()
196 zlib_deflateReset(&state->strm); in z_comp_reset()
201 * @arg: pointer to private state for the compressor
213 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_compress() local
238 put_unaligned_be16(state->seqno, wptr); in z_compress()
241 state->strm.next_out = wptr; in z_compress()
242 state->strm.avail_out = oavail = osize - olen; in z_compress()
243 ++state->seqno; in z_compress()
247 state->strm.next_in = rptr; in z_compress()
248 state->strm.avail_in = (isize - off); in z_compress()
251 r = zlib_deflate(&state->strm, Z_PACKET_FLUSH); in z_compress()
253 if (state->debug) in z_compress()
258 if (state->strm.avail_out == 0) { in z_compress()
260 state->strm.next_out = NULL; in z_compress()
261 state->strm.avail_out = oavail = 1000000; in z_compress()
266 olen += oavail - state->strm.avail_out; in z_compress()
272 state->stats.comp_bytes += olen; in z_compress()
273 state->stats.comp_packets++; in z_compress()
275 state->stats.inc_bytes += isize; in z_compress()
276 state->stats.inc_packets++; in z_compress()
279 state->stats.unc_bytes += isize; in z_compress()
280 state->stats.unc_packets++; in z_compress()
293 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_comp_stats() local
295 *stats = state->stats; in z_comp_stats()
304 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_decomp_free() local
306 if (state) { in z_decomp_free()
307 zlib_inflateEnd(&state->strm); in z_decomp_free()
308 vfree(state->strm.workspace); in z_decomp_free()
309 kfree(state); in z_decomp_free()
324 * Returns the pointer to the private state for the decompressor,
329 struct ppp_deflate_state *state; in z_decomp_alloc() local
342 state = kzalloc(sizeof(*state), GFP_KERNEL); in z_decomp_alloc()
343 if (state == NULL) in z_decomp_alloc()
346 state->w_size = w_size; in z_decomp_alloc()
347 state->strm.next_out = NULL; in z_decomp_alloc()
348 state->strm.workspace = vmalloc(zlib_inflate_workspacesize()); in z_decomp_alloc()
349 if (state->strm.workspace == NULL) in z_decomp_alloc()
352 if (zlib_inflateInit2(&state->strm, -w_size) != Z_OK) in z_decomp_alloc()
354 return (void *) state; in z_decomp_alloc()
357 z_decomp_free(state); in z_decomp_alloc()
363 * @arg: pointer to the private state for the decompressor
380 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_decomp_init() local
386 DEFLATE_SIZE(options[2]) != state->w_size || in z_decomp_init()
390 state->seqno = 0; in z_decomp_init()
391 state->unit = unit; in z_decomp_init()
392 state->debug = debug; in z_decomp_init()
393 state->mru = mru; in z_decomp_init()
395 zlib_inflateReset(&state->strm); in z_decomp_init()
402 * @arg: pointer to private state for the decompressor.
409 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_decomp_reset() local
411 state->seqno = 0; in z_decomp_reset()
412 zlib_inflateReset(&state->strm); in z_decomp_reset()
417 * @arg: pointer to private state for the decompressor
439 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_decompress() local
445 if (state->debug) in z_decompress()
447 state->unit, isize); in z_decompress()
453 if (seq != (state->seqno & 0xffff)) { in z_decompress()
454 if (state->debug) in z_decompress()
456 state->unit, seq, state->seqno & 0xffff); in z_decompress()
459 ++state->seqno; in z_decompress()
474 state->strm.next_in = ibuf + PPP_HDRLEN + DEFLATE_OVHD; in z_decompress()
475 state->strm.avail_in = isize - (PPP_HDRLEN + DEFLATE_OVHD); in z_decompress()
476 state->strm.next_out = obuf + 3; in z_decompress()
477 state->strm.avail_out = 1; in z_decompress()
485 r = zlib_inflate(&state->strm, Z_PACKET_FLUSH); in z_decompress()
487 if (state->debug) in z_decompress()
489 state->unit, r, (state->strm.msg? state->strm.msg: "")); in z_decompress()
492 if (state->strm.avail_out != 0) in z_decompress()
495 state->strm.avail_out = osize - PPP_HDRLEN; in z_decompress()
499 --state->strm.next_out; in z_decompress()
500 ++state->strm.avail_out; in z_decompress()
509 state->strm.next_out = overflow_buf; in z_decompress()
510 state->strm.avail_out = 1; in z_decompress()
513 if (state->debug) in z_decompress()
515 state->unit); in z_decompress()
521 if (state->debug) in z_decompress()
523 state->unit); in z_decompress()
527 olen = osize + overflow - state->strm.avail_out; in z_decompress()
528 state->stats.unc_bytes += olen; in z_decompress()
529 state->stats.unc_packets++; in z_decompress()
530 state->stats.comp_bytes += isize; in z_decompress()
531 state->stats.comp_packets++; in z_decompress()
538 * @arg: pointer to private state for the decompressor
544 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg; in z_incomp() local
554 ++state->seqno; in z_incomp()
560 state->strm.next_in = ibuf + 3; in z_incomp()
561 state->strm.avail_in = icnt - 3; in z_incomp()
563 --state->strm.next_in; in z_incomp()
564 ++state->strm.avail_in; in z_incomp()
567 r = zlib_inflateIncomp(&state->strm); in z_incomp()
570 if (state->debug) { in z_incomp()
572 state->unit, r, (state->strm.msg? state->strm.msg: "")); in z_incomp()
580 state->stats.inc_bytes += icnt; in z_incomp()
581 state->stats.inc_packets++; in z_incomp()
582 state->stats.unc_bytes += icnt; in z_incomp()
583 state->stats.unc_packets++; in z_incomp()