Lines Matching refs:cp

224 	struct tcindex_data *cp, *oldp;  in tcindex_set_parms()  local
238 cp = kzalloc(sizeof(*cp), GFP_KERNEL); in tcindex_set_parms()
239 if (!cp) in tcindex_set_parms()
242 cp->mask = p->mask; in tcindex_set_parms()
243 cp->shift = p->shift; in tcindex_set_parms()
244 cp->hash = p->hash; in tcindex_set_parms()
245 cp->alloc_hash = p->alloc_hash; in tcindex_set_parms()
246 cp->fall_through = p->fall_through; in tcindex_set_parms()
247 cp->tp = tp; in tcindex_set_parms()
252 cp->perfect = kmemdup(p->perfect, in tcindex_set_parms()
253 sizeof(*r) * cp->hash, GFP_KERNEL); in tcindex_set_parms()
254 if (!cp->perfect) in tcindex_set_parms()
256 for (i = 0; i < cp->hash; i++) in tcindex_set_parms()
257 tcf_exts_init(&cp->perfect[i].exts, in tcindex_set_parms()
261 cp->h = p->h; in tcindex_set_parms()
269 cp->hash = nla_get_u32(tb[TCA_TCINDEX_HASH]); in tcindex_set_parms()
272 cp->mask = nla_get_u16(tb[TCA_TCINDEX_MASK]); in tcindex_set_parms()
275 cp->shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]); in tcindex_set_parms()
282 if (cp->perfect) { in tcindex_set_parms()
283 if (!valid_perfect_hash(cp) || in tcindex_set_parms()
284 cp->hash > cp->alloc_hash) in tcindex_set_parms()
286 } else if (cp->h && cp->hash != cp->alloc_hash) { in tcindex_set_parms()
292 cp->fall_through = nla_get_u32(tb[TCA_TCINDEX_FALL_THROUGH]); in tcindex_set_parms()
294 if (!cp->hash) { in tcindex_set_parms()
298 if ((cp->mask >> cp->shift) < PERFECT_HASH_THRESHOLD) in tcindex_set_parms()
299 cp->hash = (cp->mask >> cp->shift) + 1; in tcindex_set_parms()
301 cp->hash = DEFAULT_HASH_SIZE; in tcindex_set_parms()
304 if (!cp->perfect && !cp->h) in tcindex_set_parms()
305 cp->alloc_hash = cp->hash; in tcindex_set_parms()
312 if (cp->perfect || valid_perfect_hash(cp)) in tcindex_set_parms()
313 if (handle >= cp->alloc_hash) in tcindex_set_parms()
318 if (!cp->perfect && !cp->h) { in tcindex_set_parms()
319 if (valid_perfect_hash(cp)) { in tcindex_set_parms()
322 cp->perfect = kcalloc(cp->hash, sizeof(*r), GFP_KERNEL); in tcindex_set_parms()
323 if (!cp->perfect) in tcindex_set_parms()
325 for (i = 0; i < cp->hash; i++) in tcindex_set_parms()
326 tcf_exts_init(&cp->perfect[i].exts, in tcindex_set_parms()
333 hash = kcalloc(cp->hash, in tcindex_set_parms()
340 cp->h = hash; in tcindex_set_parms()
345 if (cp->perfect) in tcindex_set_parms()
346 r = cp->perfect + handle; in tcindex_set_parms()
348 r = tcindex_lookup(cp, handle) ? : &new_filter_result; in tcindex_set_parms()
374 rcu_assign_pointer(tp->root, cp); in tcindex_set_parms()
382 fp = cp->h + (handle % cp->hash); in tcindex_set_parms()
397 kfree(cp->perfect); in tcindex_set_parms()
399 kfree(cp->h); in tcindex_set_parms()
401 kfree(cp); in tcindex_set_parms()