tag | line | file | source code |
db | 196 | drivers/net/bsd_comp.c | static int bsd_init (void *db, unsigned char *options, |
db | 245 | drivers/net/bsd_comp.c | bsd_clear(struct bsd_db *db) |
db | 247 | drivers/net/bsd_comp.c | db->clear_count++; |
db | 248 | drivers/net/bsd_comp.c | db->max_ent = FIRST-1; |
db | 249 | drivers/net/bsd_comp.c | db->n_bits = BSD_INIT_BITS; |
db | 250 | drivers/net/bsd_comp.c | db->bytes_out = 0; |
db | 251 | drivers/net/bsd_comp.c | db->in_count = 0; |
db | 252 | drivers/net/bsd_comp.c | db->incomp_count = 0; |
db | 253 | drivers/net/bsd_comp.c | db->ratio = 0; |
db | 254 | drivers/net/bsd_comp.c | db->checkpoint = CHECK_GAP; |
db | 271 | drivers/net/bsd_comp.c | static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */ |
db | 275 | drivers/net/bsd_comp.c | if (db->in_count >= db->checkpoint) |
db | 278 | drivers/net/bsd_comp.c | if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX) |
db | 280 | drivers/net/bsd_comp.c | db->in_count -= (db->in_count >> 2); |
db | 281 | drivers/net/bsd_comp.c | db->bytes_out -= (db->bytes_out >> 2); |
db | 284 | drivers/net/bsd_comp.c | db->checkpoint = db->in_count + CHECK_GAP; |
db | 286 | drivers/net/bsd_comp.c | if (db->max_ent >= db->maxmaxcode) |
db | 296 | drivers/net/bsd_comp.c | new_ratio = db->in_count << RATIO_SCALE_LOG; |
db | 297 | drivers/net/bsd_comp.c | if (db->bytes_out != 0) |
db | 299 | drivers/net/bsd_comp.c | new_ratio /= db->bytes_out; |
db | 302 | drivers/net/bsd_comp.c | if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) |
db | 304 | drivers/net/bsd_comp.c | bsd_clear (db); |
db | 307 | drivers/net/bsd_comp.c | db->ratio = new_ratio; |
db | 319 | drivers/net/bsd_comp.c | struct bsd_db *db = (struct bsd_db *) state; |
db | 321 | drivers/net/bsd_comp.c | stats->unc_bytes = db->uncomp_bytes; |
db | 322 | drivers/net/bsd_comp.c | stats->unc_packets = db->uncomp_count; |
db | 323 | drivers/net/bsd_comp.c | stats->comp_bytes = db->comp_bytes; |
db | 324 | drivers/net/bsd_comp.c | stats->comp_packets = db->comp_count; |
db | 325 | drivers/net/bsd_comp.c | stats->inc_bytes = db->incomp_bytes; |
db | 326 | drivers/net/bsd_comp.c | stats->inc_packets = db->incomp_count; |
db | 327 | drivers/net/bsd_comp.c | stats->in_count = db->in_count; |
db | 328 | drivers/net/bsd_comp.c | stats->bytes_out = db->bytes_out; |
db | 337 | drivers/net/bsd_comp.c | struct bsd_db *db = (struct bsd_db *) state; |
db | 339 | drivers/net/bsd_comp.c | bsd_clear(db); |
db | 341 | drivers/net/bsd_comp.c | db->seqno = 0; |
db | 342 | drivers/net/bsd_comp.c | db->clear_count = 0; |
db | 351 | drivers/net/bsd_comp.c | struct bsd_db *db = (struct bsd_db *) state; |
db | 353 | drivers/net/bsd_comp.c | if (db) |
db | 358 | drivers/net/bsd_comp.c | if (db->dict) |
db | 360 | drivers/net/bsd_comp.c | vfree (db->dict); |
db | 361 | drivers/net/bsd_comp.c | db->dict = NULL; |
db | 366 | drivers/net/bsd_comp.c | if (db->lens) |
db | 368 | drivers/net/bsd_comp.c | vfree (db->lens); |
db | 369 | drivers/net/bsd_comp.c | db->lens = NULL; |
db | 374 | drivers/net/bsd_comp.c | kfree (db); |
db | 387 | drivers/net/bsd_comp.c | struct bsd_db *db; |
db | 429 | drivers/net/bsd_comp.c | db = (struct bsd_db *) kmalloc (sizeof (struct bsd_db), |
db | 431 | drivers/net/bsd_comp.c | if (!db) |
db | 436 | drivers/net/bsd_comp.c | memset (db, 0, sizeof(struct bsd_db)); |
db | 441 | drivers/net/bsd_comp.c | db->dict = (struct bsd_dict *) vmalloc (hsize * |
db | 443 | drivers/net/bsd_comp.c | if (!db->dict) |
db | 445 | drivers/net/bsd_comp.c | bsd_free (db); |
db | 455 | drivers/net/bsd_comp.c | db->lens = NULL; |
db | 462 | drivers/net/bsd_comp.c | db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) * |
db | 463 | drivers/net/bsd_comp.c | sizeof (db->lens[0])); |
db | 464 | drivers/net/bsd_comp.c | if (!db->lens) |
db | 466 | drivers/net/bsd_comp.c | bsd_free (db); |
db | 473 | drivers/net/bsd_comp.c | db->totlen = sizeof (struct bsd_db) + |
db | 476 | drivers/net/bsd_comp.c | db->hsize = hsize; |
db | 477 | drivers/net/bsd_comp.c | db->hshift = hshift; |
db | 478 | drivers/net/bsd_comp.c | db->maxmaxcode = maxmaxcode; |
db | 479 | drivers/net/bsd_comp.c | db->maxbits = bits; |
db | 481 | drivers/net/bsd_comp.c | return (void *) db; |
db | 501 | drivers/net/bsd_comp.c | struct bsd_db *db = state; |
db | 506 | drivers/net/bsd_comp.c | || (BSD_NBITS(options[2]) != db->maxbits) |
db | 507 | drivers/net/bsd_comp.c | || (decomp && db->lens == NULL)) |
db | 517 | drivers/net/bsd_comp.c | db->lens[indx] = 1; |
db | 522 | drivers/net/bsd_comp.c | indx = db->hsize; |
db | 525 | drivers/net/bsd_comp.c | db->dict[indx].codem1 = BADCODEM1; |
db | 526 | drivers/net/bsd_comp.c | db->dict[indx].cptr = 0; |
db | 529 | drivers/net/bsd_comp.c | db->unit = unit; |
db | 530 | drivers/net/bsd_comp.c | db->mru = 0; |
db | 534 | drivers/net/bsd_comp.c | db->debug = 1; |
db | 536 | drivers/net/bsd_comp.c | bsd_reset(db); |
db | 562 | drivers/net/bsd_comp.c | static unsigned short *lens_ptr(struct bsd_db *db, int idx) |
db | 564 | drivers/net/bsd_comp.c | if ((unsigned int) idx > (unsigned int) db->maxmaxcode) |
db | 569 | drivers/net/bsd_comp.c | return lens_ptrx (db, idx); |
db | 572 | drivers/net/bsd_comp.c | static struct bsd_dict *dict_ptr(struct bsd_db *db, int idx) |
db | 574 | drivers/net/bsd_comp.c | if ((unsigned int) idx >= (unsigned int) db->hsize) |
db | 579 | drivers/net/bsd_comp.c | return dict_ptrx (db, idx); |
db | 583 | drivers/net/bsd_comp.c | #define lens_ptr(db,idx) lens_ptrx(db,idx) |
db | 584 | drivers/net/bsd_comp.c | #define dict_ptr(db,idx) dict_ptrx(db,idx) |
db | 601 | drivers/net/bsd_comp.c | struct bsd_db *db; |
db | 656 | drivers/net/bsd_comp.c | db = (struct bsd_db *) state; |
db | 657 | drivers/net/bsd_comp.c | hshift = db->hshift; |
db | 658 | drivers/net/bsd_comp.c | max_ent = db->max_ent; |
db | 659 | drivers/net/bsd_comp.c | n_bits = db->n_bits; |
db | 680 | drivers/net/bsd_comp.c | *wptr++ = db->seqno >> 8; |
db | 681 | drivers/net/bsd_comp.c | *wptr++ = db->seqno; |
db | 694 | drivers/net/bsd_comp.c | dictp = dict_ptr (db, hval); |
db | 714 | drivers/net/bsd_comp.c | if (hval >= db->hsize) |
db | 716 | drivers/net/bsd_comp.c | hval -= db->hsize; |
db | 718 | drivers/net/bsd_comp.c | dictp = dict_ptr (db, hval); |
db | 733 | drivers/net/bsd_comp.c | if (max_ent < db->maxmaxcode) |
db | 742 | drivers/net/bsd_comp.c | db->n_bits = ++n_bits; |
db | 750 | drivers/net/bsd_comp.c | dictp2 = dict_ptr (db, max_ent + 1); |
db | 752 | drivers/net/bsd_comp.c | dictp3 = dict_ptr (db, indx); |
db | 762 | drivers/net/bsd_comp.c | db->max_ent = ++max_ent; |
db | 764 | drivers/net/bsd_comp.c | if (db->lens) |
db | 766 | drivers/net/bsd_comp.c | unsigned short *len1 = lens_ptr (db, max_ent); |
db | 767 | drivers/net/bsd_comp.c | unsigned short *len2 = lens_ptr (db, ent); |
db | 776 | drivers/net/bsd_comp.c | db->bytes_out += olen; /* Do not count bytes from here */ |
db | 777 | drivers/net/bsd_comp.c | db->uncomp_bytes += isize; |
db | 778 | drivers/net/bsd_comp.c | db->in_count += isize; |
db | 779 | drivers/net/bsd_comp.c | ++db->uncomp_count; |
db | 780 | drivers/net/bsd_comp.c | ++db->seqno; |
db | 784 | drivers/net/bsd_comp.c | ++db->bytes_out; /* must be set before calling bsd_check */ |
db | 791 | drivers/net/bsd_comp.c | if (bsd_check(db)) |
db | 811 | drivers/net/bsd_comp.c | if (max_ent >= mxcode && max_ent < db->maxmaxcode) |
db | 813 | drivers/net/bsd_comp.c | db->n_bits++; |
db | 819 | drivers/net/bsd_comp.c | ++db->incomp_count; |
db | 820 | drivers/net/bsd_comp.c | db->incomp_bytes += isize; |
db | 825 | drivers/net/bsd_comp.c | ++db->comp_count; |
db | 826 | drivers/net/bsd_comp.c | db->comp_bytes += olen; |
db | 865 | drivers/net/bsd_comp.c | struct bsd_db *db; |
db | 885 | drivers/net/bsd_comp.c | db = (struct bsd_db *) state; |
db | 886 | drivers/net/bsd_comp.c | max_ent = db->max_ent; |
db | 889 | drivers/net/bsd_comp.c | n_bits = db->n_bits; |
db | 910 | drivers/net/bsd_comp.c | if (seq != db->seqno) |
db | 912 | drivers/net/bsd_comp.c | if (db->debug) |
db | 915 | drivers/net/bsd_comp.c | db->unit, seq, db->seqno - 1); |
db | 920 | drivers/net/bsd_comp.c | ++db->seqno; |
db | 921 | drivers/net/bsd_comp.c | db->bytes_out += ilen; |
db | 945 | drivers/net/bsd_comp.c | db->in_count += (explen - 3); /* don't count the header */ |
db | 974 | drivers/net/bsd_comp.c | if (db->debug) |
db | 976 | drivers/net/bsd_comp.c | printk("bsd_decomp%d: bad CLEAR\n", db->unit); |
db | 981 | drivers/net/bsd_comp.c | bsd_clear(db); |
db | 985 | drivers/net/bsd_comp.c | if ((incode > max_ent + 2) || (incode > db->maxmaxcode) |
db | 988 | drivers/net/bsd_comp.c | if (db->debug) |
db | 991 | drivers/net/bsd_comp.c | db->unit, incode, oldcode); |
db | 993 | drivers/net/bsd_comp.c | max_ent, explen, db->seqno); |
db | 1010 | drivers/net/bsd_comp.c | codelen = *(lens_ptr (db, finchar)); |
db | 1014 | drivers/net/bsd_comp.c | if (db->debug) |
db | 1016 | drivers/net/bsd_comp.c | printk("bsd_decomp%d: ran out of mru\n", db->unit); |
db | 1033 | drivers/net/bsd_comp.c | struct bsd_dict *dictp2 = dict_ptr (db, finchar); |
db | 1035 | drivers/net/bsd_comp.c | dictp = dict_ptr (db, dictp2->cptr); |
db | 1041 | drivers/net/bsd_comp.c | printk("bsd_decomp%d: fell off end of chain ", db->unit); |
db | 1051 | drivers/net/bsd_comp.c | db->unit, incode, finchar); |
db | 1069 | drivers/net/bsd_comp.c | db->unit, codelen, incode, max_ent); |
db | 1086 | drivers/net/bsd_comp.c | if (oldcode != CLEAR && max_ent < db->maxmaxcode) |
db | 1094 | drivers/net/bsd_comp.c | hval = BSD_HASH(oldcode,finchar,db->hshift); |
db | 1095 | drivers/net/bsd_comp.c | dictp = dict_ptr (db, hval); |
db | 1104 | drivers/net/bsd_comp.c | if (hval >= db->hsize) |
db | 1106 | drivers/net/bsd_comp.c | hval -= db->hsize; |
db | 1108 | drivers/net/bsd_comp.c | dictp = dict_ptr (db, hval); |
db | 1118 | drivers/net/bsd_comp.c | dictp2 = dict_ptr (db, max_ent + 1); |
db | 1120 | drivers/net/bsd_comp.c | dictp3 = dict_ptr (db, indx); |
db | 1130 | drivers/net/bsd_comp.c | db->max_ent = ++max_ent; |
db | 1133 | drivers/net/bsd_comp.c | lens1 = lens_ptr (db, max_ent); |
db | 1134 | drivers/net/bsd_comp.c | lens2 = lens_ptr (db, oldcode); |
db | 1138 | drivers/net/bsd_comp.c | if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) |
db | 1140 | drivers/net/bsd_comp.c | db->n_bits = ++n_bits; |
db | 1147 | drivers/net/bsd_comp.c | ++db->comp_count; |
db | 1148 | drivers/net/bsd_comp.c | ++db->uncomp_count; |
db | 1149 | drivers/net/bsd_comp.c | db->comp_bytes += isize - BSD_OVHD - PPP_HDRLEN; |
db | 1150 | drivers/net/bsd_comp.c | db->uncomp_bytes += explen; |
db | 1152 | drivers/net/bsd_comp.c | if (bsd_check(db)) |
db | 1154 | drivers/net/bsd_comp.c | if (db->debug) |
db | 1157 | drivers/net/bsd_comp.c | db->unit, db->seqno - 1); |