Lines Matching refs:dz
49 #define DZ_HASHMASK(dz) ((dz)->dz_hashmask) argument
52 #define DZ_MASK(dz) ((dz)->dz_mask) argument
86 static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz) in dn_hash() argument
88 u16 h = le16_to_cpu(key.datum)>>(16 - dz->dz_order); in dn_hash()
91 h &= DZ_HASHMASK(dz); in dn_hash()
95 static inline dn_fib_key_t dz_key(__le16 dst, struct dn_zone *dz) in dz_key() argument
98 k.datum = dst & DZ_MASK(dz); in dz_key()
102 static inline struct dn_fib_node **dn_chain_p(dn_fib_key_t key, struct dn_zone *dz) in dn_chain_p() argument
104 return &dz->dz_hash[dn_hash(key, dz).datum]; in dn_chain_p()
107 static inline struct dn_fib_node *dz_chain(dn_fib_key_t key, struct dn_zone *dz) in dz_chain() argument
109 return dz->dz_hash[dn_hash(key, dz).datum]; in dz_chain()
122 static inline void dn_rebuild_zone(struct dn_zone *dz, in dn_rebuild_zone() argument
132 for(fp = dn_chain_p(f->fn_key, dz); in dn_rebuild_zone()
142 static void dn_rehash_zone(struct dn_zone *dz) in dn_rehash_zone() argument
148 old_divisor = dz->dz_divisor; in dn_rehash_zone()
168 old_ht = dz->dz_hash; in dn_rehash_zone()
169 dz->dz_hash = ht; in dn_rehash_zone()
170 dz->dz_hashmask = new_hashmask; in dn_rehash_zone()
171 dz->dz_divisor = new_divisor; in dn_rehash_zone()
172 dn_rebuild_zone(dz, old_ht, old_divisor); in dn_rehash_zone()
187 struct dn_zone *dz = kzalloc(sizeof(struct dn_zone), GFP_KERNEL); in dn_new_zone() local
188 if (!dz) in dn_new_zone()
192 dz->dz_divisor = 16; in dn_new_zone()
193 dz->dz_hashmask = 0x0F; in dn_new_zone()
195 dz->dz_divisor = 1; in dn_new_zone()
196 dz->dz_hashmask = 0; in dn_new_zone()
199 dz->dz_hash = kcalloc(dz->dz_divisor, sizeof(struct dn_fib_node *), GFP_KERNEL); in dn_new_zone()
200 if (!dz->dz_hash) { in dn_new_zone()
201 kfree(dz); in dn_new_zone()
205 dz->dz_order = z; in dn_new_zone()
206 dz->dz_mask = dnet_make_mask(z); in dn_new_zone()
214 dz->dz_next = table->dh_zone_list; in dn_new_zone()
215 table->dh_zone_list = dz; in dn_new_zone()
217 dz->dz_next = table->dh_zones[i]->dz_next; in dn_new_zone()
218 table->dh_zones[i]->dz_next = dz; in dn_new_zone()
220 table->dh_zones[z] = dz; in dn_new_zone()
222 return dz; in dn_new_zone()
388 struct dn_zone *dz, in dn_hash_dump_bucket() argument
404 f->fn_scope, &f->fn_key, dz->dz_order, in dn_hash_dump_bucket()
417 struct dn_zone *dz) in dn_hash_dump_zone() argument
422 for(h = 0; h < dz->dz_divisor; h++) { in dn_hash_dump_zone()
427 if (dz->dz_hash == NULL || dz->dz_hash[h] == NULL) in dn_hash_dump_zone()
429 if (dn_hash_dump_bucket(skb, cb, tb, dz, dz->dz_hash[h]) < 0) { in dn_hash_dump_zone()
442 struct dn_zone *dz; in dn_fib_table_dump() local
447 for(dz = table->dh_zone_list, m = 0; dz; dz = dz->dz_next, m++) { in dn_fib_table_dump()
453 if (dn_hash_dump_zone(skb, cb, tb, dz) < 0) { in dn_fib_table_dump()
510 struct dn_zone *dz; in dn_fib_table_insert() local
520 dz = table->dh_zones[z]; in dn_fib_table_insert()
521 if (!dz && !(dz = dn_new_zone(table, z))) in dn_fib_table_insert()
528 if (dst & ~DZ_MASK(dz)) in dn_fib_table_insert()
530 key = dz_key(dst, dz); in dn_fib_table_insert()
536 if (dz->dz_nent > (dz->dz_divisor << 2) && in dn_fib_table_insert()
537 dz->dz_divisor > DN_MAX_DIVISOR && in dn_fib_table_insert()
538 (z==16 || (1<<z) > dz->dz_divisor)) in dn_fib_table_insert()
539 dn_rehash_zone(dz); in dn_fib_table_insert()
541 fp = dn_chain_p(key, dz); in dn_fib_table_insert()
616 dz->dz_nent++; in dn_fib_table_insert()
629 dz->dz_nent--; in dn_fib_table_insert()
648 struct dn_zone *dz; in dn_fib_table_delete() local
656 if ((dz = table->dh_zones[z]) == NULL) in dn_fib_table_delete()
663 if (dst & ~DZ_MASK(dz)) in dn_fib_table_delete()
665 key = dz_key(dst, dz); in dn_fib_table_delete()
668 fp = dn_chain_p(key, dz); in dn_fib_table_delete()
708 dz->dz_nent--; in dn_fib_table_delete()
751 struct dn_zone *dz; in dn_fib_table_flush() local
755 for(dz = table->dh_zone_list; dz; dz = dz->dz_next) { in dn_fib_table_flush()
758 for(i = dz->dz_divisor-1; i >= 0; i--) in dn_fib_table_flush()
759 tmp += dn_flush_list(&dz->dz_hash[i], dz->dz_order, table); in dn_fib_table_flush()
760 dz->dz_nent -= tmp; in dn_fib_table_flush()
770 struct dn_zone *dz; in dn_fib_table_lookup() local
774 for(dz = t->dh_zone_list; dz; dz = dz->dz_next) { in dn_fib_table_lookup()
776 dn_fib_key_t k = dz_key(flp->daddr, dz); in dn_fib_table_lookup()
778 for(f = dz_chain(k, dz); f; f = f->fn_next) { in dn_fib_table_lookup()
799 res->prefixlen = dz->dz_order; in dn_fib_table_lookup()