Lines Matching refs:cp

245 	struct tcindex_data *cp, *oldp;  in tcindex_set_parms()  local
259 cp = kzalloc(sizeof(*cp), GFP_KERNEL); in tcindex_set_parms()
260 if (!cp) in tcindex_set_parms()
263 cp->mask = p->mask; in tcindex_set_parms()
264 cp->shift = p->shift; in tcindex_set_parms()
265 cp->hash = p->hash; in tcindex_set_parms()
266 cp->alloc_hash = p->alloc_hash; in tcindex_set_parms()
267 cp->fall_through = p->fall_through; in tcindex_set_parms()
268 cp->tp = tp; in tcindex_set_parms()
273 cp->perfect = kmemdup(p->perfect, in tcindex_set_parms()
274 sizeof(*r) * cp->hash, GFP_KERNEL); in tcindex_set_parms()
275 if (!cp->perfect) in tcindex_set_parms()
277 for (i = 0; i < cp->hash; i++) in tcindex_set_parms()
278 tcf_exts_init(&cp->perfect[i].exts, in tcindex_set_parms()
282 cp->h = p->h; in tcindex_set_parms()
290 cp->hash = nla_get_u32(tb[TCA_TCINDEX_HASH]); in tcindex_set_parms()
293 cp->mask = nla_get_u16(tb[TCA_TCINDEX_MASK]); in tcindex_set_parms()
296 cp->shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]); in tcindex_set_parms()
303 if (cp->perfect) { in tcindex_set_parms()
304 if (!valid_perfect_hash(cp) || in tcindex_set_parms()
305 cp->hash > cp->alloc_hash) in tcindex_set_parms()
307 } else if (cp->h && cp->hash != cp->alloc_hash) { in tcindex_set_parms()
313 cp->fall_through = nla_get_u32(tb[TCA_TCINDEX_FALL_THROUGH]); in tcindex_set_parms()
315 if (!cp->hash) { in tcindex_set_parms()
319 if ((cp->mask >> cp->shift) < PERFECT_HASH_THRESHOLD) in tcindex_set_parms()
320 cp->hash = (cp->mask >> cp->shift) + 1; in tcindex_set_parms()
322 cp->hash = DEFAULT_HASH_SIZE; in tcindex_set_parms()
325 if (!cp->perfect && !cp->h) in tcindex_set_parms()
326 cp->alloc_hash = cp->hash; in tcindex_set_parms()
333 if (cp->perfect || valid_perfect_hash(cp)) in tcindex_set_parms()
334 if (handle >= cp->alloc_hash) in tcindex_set_parms()
339 if (!cp->perfect && !cp->h) { in tcindex_set_parms()
340 if (valid_perfect_hash(cp)) { in tcindex_set_parms()
343 cp->perfect = kcalloc(cp->hash, sizeof(*r), GFP_KERNEL); in tcindex_set_parms()
344 if (!cp->perfect) in tcindex_set_parms()
346 for (i = 0; i < cp->hash; i++) in tcindex_set_parms()
347 tcf_exts_init(&cp->perfect[i].exts, in tcindex_set_parms()
354 hash = kcalloc(cp->hash, in tcindex_set_parms()
361 cp->h = hash; in tcindex_set_parms()
366 if (cp->perfect) in tcindex_set_parms()
367 r = cp->perfect + handle; in tcindex_set_parms()
369 r = tcindex_lookup(cp, handle) ? : &new_filter_result; in tcindex_set_parms()
395 rcu_assign_pointer(tp->root, cp); in tcindex_set_parms()
403 fp = cp->h + (handle % cp->hash); in tcindex_set_parms()
418 kfree(cp->perfect); in tcindex_set_parms()
420 kfree(cp->h); in tcindex_set_parms()
422 kfree(cp); in tcindex_set_parms()