Lines Matching refs:state

80 static void	z_comp_free(void *state);
81 static void z_decomp_free(void *state);
82 static int z_comp_init(void *state, uchar_t *options, int opt_len,
84 static int z_decomp_init(void *state, uchar_t *options, int opt_len,
86 static int z_compress(void *state, mblk_t **mret,
88 static int z_incomp(void *state, mblk_t *dmsg);
89 static int z_decompress(void *state, mblk_t **dmpp);
90 static void z_comp_reset(void *state);
91 static void z_decomp_reset(void *state);
92 static void z_comp_stats(void *state, struct compstat *stats);
196 struct deflate_state *state; in z_comp_alloc() local
217 state = (struct deflate_state *)kmem_zalloc(sizeof (*state), KM_SLEEP); in z_comp_alloc()
218 ASSERT(state != NULL); in z_comp_alloc()
220 state->strm.zalloc = (alloc_func)z_alloc; in z_comp_alloc()
221 state->strm.zfree = (free_func)z_free; in z_comp_alloc()
223 if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, in z_comp_alloc()
226 kmem_free(state, sizeof (*state)); in z_comp_alloc()
231 state->w_size = w_size; in z_comp_alloc()
233 bzero(&state->stats, sizeof (state->stats)); in z_comp_alloc()
235 return ((void *)state); in z_comp_alloc()
244 struct deflate_state *state = (struct deflate_state *)arg; in z_comp_free() local
246 (void) deflateEnd(&state->strm); in z_comp_free()
248 kmem_free(state, sizeof (*state)); in z_comp_free()
258 struct deflate_state *state = (struct deflate_state *)arg; in z_comp_init() local
264 DEFLATE_SIZE(options[2]) != state->w_size || in z_comp_init()
270 state->seqno = 0; in z_comp_init()
271 state->unit = unit; in z_comp_init()
272 state->hdrlen = hdrlen; in z_comp_init()
274 state->flags |= DS_DEBUG; in z_comp_init()
276 state->flags &= ~DS_DEBUG; in z_comp_init()
278 (void) deflateReset(&state->strm); in z_comp_init()
289 struct deflate_state *state = (struct deflate_state *)arg; in z_comp_reset() local
291 state->seqno = 0; in z_comp_reset()
293 (void) deflateReset(&state->strm); in z_comp_reset()
302 struct deflate_state *state = (struct deflate_state *)arg; in z_compress() local
377 wspace = maxolen + state->hdrlen; in z_compress()
391 if (state->hdrlen + PPP_HDRLEN + 2 < wspace) { in z_compress()
392 m->b_rptr += state->hdrlen; in z_compress()
394 wspace -= state->hdrlen; in z_compress()
410 wptr[0] = state->seqno >> 8; in z_compress()
411 wptr[1] = state->seqno; in z_compress()
419 if ((state->flags & DS_TESTOUT) && (state->seqno % 100) == 50) in z_compress()
423 state->strm.next_out = wptr; in z_compress()
424 state->strm.avail_out = wspace - (PPP_HDRLEN + 2); in z_compress()
426 state->strm.next_out = NULL; in z_compress()
427 state->strm.avail_out = 1000000; in z_compress()
430 ++state->seqno; in z_compress()
432 state->strm.next_in = rptr; in z_compress()
433 state->strm.avail_in = mp->b_wptr - rptr; in z_compress()
440 r = deflate(&state->strm, flush); in z_compress()
445 state->unit, r, in z_compress()
446 (state->strm.msg? state->strm.msg: "")); in z_compress()
451 if (state->strm.avail_in == 0) { in z_compress()
455 if (state->strm.avail_out != 0) in z_compress()
458 state->strm.next_in = mp->b_rptr; in z_compress()
459 state->strm.avail_in = mp->b_wptr - mp->b_rptr; in z_compress()
463 if (state->strm.avail_out == 0) { in z_compress()
485 state->strm.next_out = m->b_wptr; in z_compress()
488 state->strm.avail_out = wspace; in z_compress()
493 state->strm.next_out = NULL; in z_compress()
494 state->strm.avail_out = 1000000; in z_compress()
500 m->b_wptr += wspace - state->strm.avail_out; in z_compress()
501 olen += wspace - state->strm.avail_out; in z_compress()
508 state->stats.comp_bytes += olen; in z_compress()
509 state->stats.comp_packets++; in z_compress()
516 state->stats.inc_bytes += orig_len; in z_compress()
517 state->stats.inc_packets++; in z_compress()
522 state->stats.unc_bytes += orig_len; in z_compress()
523 state->stats.unc_packets++; in z_compress()
536 struct deflate_state *state = (struct deflate_state *)arg; in z_incomp() local
571 ++state->seqno; in z_incomp()
579 state->strm.next_in = rptr; in z_incomp()
580 state->strm.avail_in = rlen; in z_incomp()
583 r = inflateIncomp(&state->strm); in z_incomp()
586 if (state->flags & DS_DEBUG) { in z_incomp()
589 "%d (%s)\n", state->unit, r, in z_incomp()
590 (state->strm.msg? state->strm.msg: "")); in z_incomp()
601 state->strm.next_in = mp->b_rptr; in z_incomp()
602 state->strm.avail_in = mp->b_wptr - mp->b_rptr; in z_incomp()
604 rlen += state->strm.avail_in; in z_incomp()
610 state->stats.inc_bytes += rlen; in z_incomp()
611 state->stats.inc_packets++; in z_incomp()
612 state->stats.unc_bytes += rlen; in z_incomp()
613 state->stats.unc_packets++; in z_incomp()
624 struct deflate_state *state = (struct deflate_state *)arg; in z_comp_stats() local
627 *stats = state->stats; in z_comp_stats()
650 struct deflate_state *state; in z_decomp_alloc() local
671 state = (struct deflate_state *)kmem_zalloc(sizeof (*state), KM_SLEEP); in z_decomp_alloc()
672 ASSERT(state != NULL); in z_decomp_alloc()
674 state->strm.zalloc = (alloc_func)z_alloc; in z_decomp_alloc()
675 state->strm.zfree = (free_func)z_free; in z_decomp_alloc()
677 if (inflateInit2(&state->strm, -w_size) != Z_OK) { in z_decomp_alloc()
678 kmem_free(state, sizeof (*state)); in z_decomp_alloc()
682 state->w_size = w_size; in z_decomp_alloc()
684 bzero(&state->stats, sizeof (state->stats)); in z_decomp_alloc()
686 return ((void *)state); in z_decomp_alloc()
695 struct deflate_state *state = (struct deflate_state *)arg; in z_decomp_free() local
697 (void) inflateEnd(&state->strm); in z_decomp_free()
699 kmem_free(state, sizeof (*state)); in z_decomp_free()
709 struct deflate_state *state = (struct deflate_state *)arg; in z_decomp_init() local
715 DEFLATE_SIZE(options[2]) != state->w_size || in z_decomp_init()
721 state->seqno = 0; in z_decomp_init()
722 state->unit = unit; in z_decomp_init()
723 state->hdrlen = hdrlen; in z_decomp_init()
725 state->flags |= DS_DEBUG; in z_decomp_init()
727 state->flags &= ~DS_DEBUG; in z_decomp_init()
728 state->mru = mru; in z_decomp_init()
730 (void) inflateReset(&state->strm); in z_decomp_init()
741 struct deflate_state *state = (struct deflate_state *)arg; in z_decomp_reset() local
743 state->seqno = 0; in z_decomp_reset()
745 (void) inflateReset(&state->strm); in z_decomp_reset()
769 struct deflate_state *state = (struct deflate_state *)arg; in z_decompress() local
793 if (state->flags & DS_DEBUG) { in z_decompress()
795 state->unit); in z_decompress()
830 if (state->flags & DS_DEBUG) { in z_decompress()
832 state->unit); in z_decompress()
844 if ((state->flags & DS_TESTIN) && (state->seqno % 300) == 101) in z_decompress()
847 if (seq != state->seqno++) { in z_decompress()
849 if (state->flags & DS_DEBUG) { in z_decompress()
852 state->unit, seq, state->seqno - 1); in z_decompress()
860 mo = allocb(DECOMP_CHUNK + state->hdrlen, BPRI_MED); in z_decompress()
868 mo->b_rptr += state->hdrlen; in z_decompress()
887 state->strm.next_in = rptr; in z_decompress()
888 state->strm.avail_in = mi->b_wptr - rptr; in z_decompress()
890 rlen = state->strm.avail_in + PPP_HDRLEN + DEFLATE_OVHD; in z_decompress()
892 state->strm.next_out = wptr; in z_decompress()
893 state->strm.avail_out = 1; in z_decompress()
904 r = inflate(&state->strm, flush); in z_decompress()
908 if (state->flags & DS_DEBUG) { in z_decompress()
911 "(%s)\n", state->unit, r, in z_decompress()
912 (state->strm.msg? state->strm.msg: "")); in z_decompress()
922 if (state->strm.avail_in == 0) { in z_decompress()
929 if (state->strm.avail_out != 0) in z_decompress()
932 state->strm.next_in = mi->b_rptr; in z_decompress()
933 state->strm.avail_in = mi->b_wptr - mi->b_rptr; in z_decompress()
935 rlen += state->strm.avail_in; in z_decompress()
939 if (state->strm.avail_out == 0) { in z_decompress()
941 state->strm.avail_out = ospace - PPP_HDRLEN; in z_decompress()
949 --state->strm.next_out; in z_decompress()
950 ++state->strm.avail_out; in z_decompress()
968 state->strm.next_out = mo->b_rptr; in z_decompress()
969 state->strm.avail_out = ospace = DECOMP_CHUNK; in z_decompress()
979 mo->b_wptr += ospace - state->strm.avail_out; in z_decompress()
980 olen += ospace - state->strm.avail_out; in z_decompress()
982 if ((olen > state->mru + PPP_HDRLEN) && (state->flags & DS_DEBUG)) { in z_decompress()
984 state->unit, olen, state->mru + PPP_HDRLEN); in z_decompress()
987 state->stats.unc_bytes += olen; in z_decompress()
988 state->stats.unc_packets++; in z_decompress()
989 state->stats.comp_bytes += rlen; in z_decompress()
990 state->stats.comp_packets++; in z_decompress()