Lines Matching refs:fz
93 #define FZ_HASHMASK(fz) ((fz)->fz_hashmask) argument
97 #define FZ_MASK(fz) ((fz)->fz_mask) argument
110 static __inline__ fn_hash_idx_t fn_hash(fn_key_t key, struct fn_zone *fz) in fn_hash() argument
112 u32 h = ntohl(key.datum)>>(32 - fz->fz_order); in fn_hash()
116 h &= FZ_HASHMASK(fz); in fn_hash()
121 #define fz_prefix(key,fz) ((key).datum) argument
123 static __inline__ fn_key_t fz_key(u32 dst, struct fn_zone *fz) in fz_key() argument
126 k.datum = dst & FZ_MASK(fz); in fz_key()
130 static __inline__ struct fib_node ** fz_chain_p(fn_key_t key, struct fn_zone *fz) in fz_chain_p() argument
132 return &fz->fz_hash[fn_hash(key, fz).datum]; in fz_chain_p()
135 static __inline__ struct fib_node * fz_chain(fn_key_t key, struct fn_zone *fz) in fz_chain() argument
137 return fz->fz_hash[fn_hash(key, fz).datum]; in fz_chain()
167 static __inline__ void fn_rebuild_zone(struct fn_zone *fz, in fn_rebuild_zone() argument
177 for (fp = fz_chain_p(f->fn_key, fz); in fn_rebuild_zone()
196 static void fn_rehash_zone(struct fn_zone *fz) in fn_rehash_zone() argument
202 old_divisor = fz->fz_divisor; in fn_rehash_zone()
223 printk("fn_rehash_zone: hash for zone %d grows from %d\n", fz->fz_order, old_divisor); in fn_rehash_zone()
232 old_ht = fz->fz_hash; in fn_rehash_zone()
233 fz->fz_hash = ht; in fn_rehash_zone()
234 fz->fz_hashmask = new_hashmask; in fn_rehash_zone()
235 fz->fz_divisor = new_divisor; in fn_rehash_zone()
236 fn_rebuild_zone(fz, old_ht, old_divisor); in fn_rehash_zone()
254 struct fn_zone *fz = kmalloc(sizeof(struct fn_zone), GFP_KERNEL); in fn_new_zone() local
255 if (!fz) in fn_new_zone()
258 memset(fz, 0, sizeof(struct fn_zone)); in fn_new_zone()
260 fz->fz_divisor = 16; in fn_new_zone()
262 fz->fz_divisor = 1; in fn_new_zone()
264 fz->fz_hashmask = (fz->fz_divisor - 1); in fn_new_zone()
265 fz->fz_hash = fz_hash_alloc(fz->fz_divisor); in fn_new_zone()
266 if (!fz->fz_hash) { in fn_new_zone()
267 kfree(fz); in fn_new_zone()
270 memset(fz->fz_hash, 0, fz->fz_divisor*sizeof(struct fib_node*)); in fn_new_zone()
271 fz->fz_order = z; in fn_new_zone()
272 fz->fz_mask = inet_make_mask(z); in fn_new_zone()
281 fz->fz_next = table->fn_zone_list; in fn_new_zone()
282 table->fn_zone_list = fz; in fn_new_zone()
284 fz->fz_next = table->fn_zones[i]->fz_next; in fn_new_zone()
285 table->fn_zones[i]->fz_next = fz; in fn_new_zone()
287 table->fn_zones[z] = fz; in fn_new_zone()
289 return fz; in fn_new_zone()
296 struct fn_zone *fz; in fn_hash_lookup() local
300 for (fz = t->fn_zone_list; fz; fz = fz->fz_next) { in fn_hash_lookup()
302 fn_key_t k = fz_key(key->dst, fz); in fn_hash_lookup()
304 for (f = fz_chain(k, fz); f; f = f->fn_next) { in fn_hash_lookup()
326 res->prefixlen = fz->fz_order; in fn_hash_lookup()
372 struct fn_zone *fz = t->fn_zones[0]; in fn_hash_select_default() local
374 if (fz == NULL) in fn_hash_select_default()
382 for (f = fz->fz_hash[0]; f; f = f->fn_next) { in fn_hash_select_default()
462 struct fn_zone *fz; in fn_hash_insert() local
478 fz = table->fn_zones[z]; in fn_hash_insert()
479 if (!fz && !(fz = fn_new_zone(table, z))) in fn_hash_insert()
486 if (dst & ~FZ_MASK(fz)) in fn_hash_insert()
488 key = fz_key(dst, fz); in fn_hash_insert()
494 if (fz->fz_nent > (fz->fz_divisor<<1) && in fn_hash_insert()
495 fz->fz_divisor < FZ_MAX_DIVISOR && in fn_hash_insert()
496 (z==32 || (1<<z) > fz->fz_divisor)) in fn_hash_insert()
497 fn_rehash_zone(fz); in fn_hash_insert()
499 fp = fz_chain_p(key, fz); in fn_hash_insert()
608 fz->fz_nent++; in fn_hash_insert()
622 fz->fz_nent--; in fn_hash_insert()
642 struct fn_zone *fz; in fn_hash_delete() local
653 if ((fz = table->fn_zones[z]) == NULL) in fn_hash_delete()
660 if (dst & ~FZ_MASK(fz)) in fn_hash_delete()
662 key = fz_key(dst, fz); in fn_hash_delete()
665 fp = fz_chain_p(key, fz); in fn_hash_delete()
712 fz->fz_nent--; in fn_hash_delete()
754 struct fn_zone *fz; in fn_hash_flush() local
758 for (fz = table->fn_zone_list; fz; fz = fz->fz_next) { in fn_hash_flush()
761 for (i=fz->fz_divisor-1; i>=0; i--) in fn_hash_flush()
762 tmp += fn_flush_list(&fz->fz_hash[i], fz->fz_order, table); in fn_hash_flush()
763 fz->fz_nent -= tmp; in fn_hash_flush()
775 struct fn_zone *fz; in fn_hash_get_info() local
780 for (fz=table->fn_zone_list; fz; fz = fz->fz_next) { in fn_hash_get_info()
783 int maxslot = fz->fz_divisor; in fn_hash_get_info()
784 struct fib_node **fp = fz->fz_hash; in fn_hash_get_info()
786 if (fz->fz_nent == 0) in fn_hash_get_info()
789 if (pos + fz->fz_nent <= first) { in fn_hash_get_info()
790 pos += fz->fz_nent; in fn_hash_get_info()
801 fz_prefix(f->fn_key, fz), in fn_hash_get_info()
802 FZ_MASK(fz), buffer); in fn_hash_get_info()
819 struct fn_zone *fz, in fn_hash_dump_bucket() argument
831 &f->fn_key, fz->fz_order, f->fn_tos, in fn_hash_dump_bucket()
844 struct fn_zone *fz) in fn_hash_dump_zone() argument
849 for (h=0; h < fz->fz_divisor; h++) { in fn_hash_dump_zone()
853 if (fz->fz_hash == NULL || fz->fz_hash[h] == NULL) in fn_hash_dump_zone()
855 if (fn_hash_dump_bucket(skb, cb, tb, fz, fz->fz_hash[h]) < 0) { in fn_hash_dump_zone()
867 struct fn_zone *fz; in fn_hash_dump() local
872 for (fz = table->fn_zone_list, m=0; fz; fz = fz->fz_next, m++) { in fn_hash_dump()
876 if (fn_hash_dump_zone(skb, cb, tb, fz) < 0) { in fn_hash_dump()