Lines Matching full:cp
282 static void tcindex_free_perfect_hash(struct tcindex_data *cp);
297 static void tcindex_free_perfect_hash(struct tcindex_data *cp) in tcindex_free_perfect_hash() argument
301 for (i = 0; i < cp->hash; i++) in tcindex_free_perfect_hash()
302 tcf_exts_destroy(&cp->perfect[i].exts); in tcindex_free_perfect_hash()
303 kfree(cp->perfect); in tcindex_free_perfect_hash()
306 static int tcindex_alloc_perfect_hash(struct net *net, struct tcindex_data *cp) in tcindex_alloc_perfect_hash() argument
310 cp->perfect = kcalloc(cp->hash, sizeof(struct tcindex_filter_result), in tcindex_alloc_perfect_hash()
312 if (!cp->perfect) in tcindex_alloc_perfect_hash()
315 for (i = 0; i < cp->hash; i++) { in tcindex_alloc_perfect_hash()
316 err = tcf_exts_init(&cp->perfect[i].exts, net, in tcindex_alloc_perfect_hash()
320 cp->perfect[i].p = cp; in tcindex_alloc_perfect_hash()
326 tcindex_free_perfect_hash(cp); in tcindex_alloc_perfect_hash()
337 struct tcindex_data *cp = NULL, *oldp; in tcindex_set_parms() local
356 cp = kzalloc(sizeof(*cp), GFP_KERNEL); in tcindex_set_parms()
357 if (!cp) in tcindex_set_parms()
360 cp->mask = p->mask; in tcindex_set_parms()
361 cp->shift = p->shift; in tcindex_set_parms()
362 cp->hash = p->hash; in tcindex_set_parms()
363 cp->alloc_hash = p->alloc_hash; in tcindex_set_parms()
364 cp->fall_through = p->fall_through; in tcindex_set_parms()
365 cp->tp = tp; in tcindex_set_parms()
366 refcount_set(&cp->refcnt, 1); /* Paired with tcindex_destroy_work() */ in tcindex_set_parms()
369 cp->hash = nla_get_u32(tb[TCA_TCINDEX_HASH]); in tcindex_set_parms()
372 cp->mask = nla_get_u16(tb[TCA_TCINDEX_MASK]); in tcindex_set_parms()
375 cp->shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]); in tcindex_set_parms()
376 if (cp->shift > 16) { in tcindex_set_parms()
381 if (!cp->hash) { in tcindex_set_parms()
385 if ((cp->mask >> cp->shift) < PERFECT_HASH_THRESHOLD) in tcindex_set_parms()
386 cp->hash = (cp->mask >> cp->shift) + 1; in tcindex_set_parms()
388 cp->hash = DEFAULT_HASH_SIZE; in tcindex_set_parms()
394 if (tcindex_alloc_perfect_hash(net, cp) < 0) in tcindex_set_parms()
396 cp->alloc_hash = cp->hash; in tcindex_set_parms()
397 for (i = 0; i < min(cp->hash, p->hash); i++) in tcindex_set_parms()
398 cp->perfect[i].res = p->perfect[i].res; in tcindex_set_parms()
401 cp->h = p->h; in tcindex_set_parms()
403 err = tcindex_filter_result_init(&new_filter_result, cp, net); in tcindex_set_parms()
414 if (cp->perfect) { in tcindex_set_parms()
415 if (!valid_perfect_hash(cp) || in tcindex_set_parms()
416 cp->hash > cp->alloc_hash) in tcindex_set_parms()
418 } else if (cp->h && cp->hash != cp->alloc_hash) { in tcindex_set_parms()
424 cp->fall_through = nla_get_u32(tb[TCA_TCINDEX_FALL_THROUGH]); in tcindex_set_parms()
426 if (!cp->perfect && !cp->h) in tcindex_set_parms()
427 cp->alloc_hash = cp->hash; in tcindex_set_parms()
434 if (cp->perfect || valid_perfect_hash(cp)) in tcindex_set_parms()
435 if (handle >= cp->alloc_hash) in tcindex_set_parms()
440 if (!cp->perfect && !cp->h) { in tcindex_set_parms()
441 if (valid_perfect_hash(cp)) { in tcindex_set_parms()
442 if (tcindex_alloc_perfect_hash(net, cp) < 0) in tcindex_set_parms()
448 hash = kcalloc(cp->hash, in tcindex_set_parms()
455 cp->h = hash; in tcindex_set_parms()
460 if (cp->perfect) { in tcindex_set_parms()
461 r = cp->perfect + handle; in tcindex_set_parms()
464 update_h = !!tcindex_lookup(cp, handle); in tcindex_set_parms()
474 err = tcindex_filter_result_init(&f->result, cp, net); in tcindex_set_parms()
487 err = tcindex_filter_result_init(old_r, cp, net); in tcindex_set_parms()
498 rcu_assign_pointer(tp->root, cp); in tcindex_set_parms()
508 fp = cp->h + (handle % cp->hash); in tcindex_set_parms()
528 fp = cp->h + (handle % cp->hash); in tcindex_set_parms()
545 tcindex_free_perfect_hash(cp); in tcindex_set_parms()
547 kfree(cp->h); in tcindex_set_parms()
550 kfree(cp); in tcindex_set_parms()