Lines Matching refs:ti

182 static void __table_instance_destroy(struct table_instance *ti)  in __table_instance_destroy()  argument
184 free_buckets(ti->buckets); in __table_instance_destroy()
185 kfree(ti); in __table_instance_destroy()
190 struct table_instance *ti = kmalloc(sizeof(*ti), GFP_KERNEL); in table_instance_alloc() local
192 if (!ti) in table_instance_alloc()
195 ti->buckets = alloc_buckets(new_size); in table_instance_alloc()
197 if (!ti->buckets) { in table_instance_alloc()
198 kfree(ti); in table_instance_alloc()
201 ti->n_buckets = new_size; in table_instance_alloc()
202 ti->node_ver = 0; in table_instance_alloc()
203 ti->keep_flows = false; in table_instance_alloc()
204 get_random_bytes(&ti->hash_seed, sizeof(u32)); in table_instance_alloc()
206 return ti; in table_instance_alloc()
211 struct table_instance *ti, *ufid_ti; in ovs_flow_tbl_init() local
213 ti = table_instance_alloc(TBL_MIN_BUCKETS); in ovs_flow_tbl_init()
215 if (!ti) in ovs_flow_tbl_init()
222 rcu_assign_pointer(table->ti, ti); in ovs_flow_tbl_init()
231 __table_instance_destroy(ti); in ovs_flow_tbl_init()
237 struct table_instance *ti = container_of(rcu, struct table_instance, rcu); in flow_tbl_destroy_rcu_cb() local
239 __table_instance_destroy(ti); in flow_tbl_destroy_rcu_cb()
242 static void table_instance_destroy(struct table_instance *ti, in table_instance_destroy() argument
248 if (!ti) in table_instance_destroy()
252 if (ti->keep_flows) in table_instance_destroy()
255 for (i = 0; i < ti->n_buckets; i++) { in table_instance_destroy()
257 struct hlist_head *head = flex_array_get(ti->buckets, i); in table_instance_destroy()
259 int ver = ti->node_ver; in table_instance_destroy()
272 call_rcu(&ti->rcu, flow_tbl_destroy_rcu_cb); in table_instance_destroy()
275 __table_instance_destroy(ti); in table_instance_destroy()
285 struct table_instance *ti = rcu_dereference_raw(table->ti); in ovs_flow_tbl_destroy() local
288 table_instance_destroy(ti, ufid_ti, false); in ovs_flow_tbl_destroy()
291 struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *ti, in ovs_flow_tbl_dump_next() argument
299 ver = ti->node_ver; in ovs_flow_tbl_dump_next()
300 while (*bucket < ti->n_buckets) { in ovs_flow_tbl_dump_next()
302 head = flex_array_get(ti->buckets, *bucket); in ovs_flow_tbl_dump_next()
318 static struct hlist_head *find_bucket(struct table_instance *ti, u32 hash) in find_bucket() argument
320 hash = jhash_1word(hash, ti->hash_seed); in find_bucket()
321 return flex_array_get(ti->buckets, in find_bucket()
322 (hash & (ti->n_buckets - 1))); in find_bucket()
325 static void table_instance_insert(struct table_instance *ti, in table_instance_insert() argument
330 head = find_bucket(ti, flow->flow_table.hash); in table_instance_insert()
331 hlist_add_head_rcu(&flow->flow_table.node[ti->node_ver], head); in table_instance_insert()
334 static void ufid_table_instance_insert(struct table_instance *ti, in ufid_table_instance_insert() argument
339 head = find_bucket(ti, flow->ufid_table.hash); in ufid_table_instance_insert()
340 hlist_add_head_rcu(&flow->ufid_table.node[ti->node_ver], head); in ufid_table_instance_insert()
372 static struct table_instance *table_instance_rehash(struct table_instance *ti, in table_instance_rehash() argument
381 flow_table_copy_flows(ti, new_ti, ufid); in table_instance_rehash()
398 old_ti = ovsl_dereference(flow_table->ti); in ovs_flow_tbl_flush()
401 rcu_assign_pointer(flow_table->ti, new_ti); in ovs_flow_tbl_flush()
471 static struct sw_flow *masked_flow_lookup(struct table_instance *ti, in masked_flow_lookup() argument
482 head = find_bucket(ti, hash); in masked_flow_lookup()
483 hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver]) { in masked_flow_lookup()
495 struct table_instance *ti = rcu_dereference_ovsl(tbl->ti); in ovs_flow_tbl_lookup_stats() local
502 flow = masked_flow_lookup(ti, key, mask); in ovs_flow_tbl_lookup_stats()
520 struct table_instance *ti = rcu_dereference_ovsl(tbl->ti); in ovs_flow_tbl_lookup_exact() local
526 flow = masked_flow_lookup(ti, match->key, mask); in ovs_flow_tbl_lookup_exact()
559 struct table_instance *ti = rcu_dereference_ovsl(tbl->ufid_ti); in ovs_flow_tbl_lookup_ufid() local
565 head = find_bucket(ti, hash); in ovs_flow_tbl_lookup_ufid()
566 hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver]) { in ovs_flow_tbl_lookup_ufid()
585 static struct table_instance *table_instance_expand(struct table_instance *ti, in table_instance_expand() argument
588 return table_instance_rehash(ti, ti->n_buckets * 2, ufid); in table_instance_expand()
612 struct table_instance *ti = ovsl_dereference(table->ti); in ovs_flow_tbl_remove() local
616 hlist_del_rcu(&flow->flow_table.node[ti->node_ver]); in ovs_flow_tbl_remove()
693 struct table_instance *ti; in flow_key_insert() local
696 ti = ovsl_dereference(table->ti); in flow_key_insert()
697 table_instance_insert(ti, flow); in flow_key_insert()
701 if (table->count > ti->n_buckets) in flow_key_insert()
702 new_ti = table_instance_expand(ti, false); in flow_key_insert()
704 new_ti = table_instance_rehash(ti, ti->n_buckets, false); in flow_key_insert()
707 rcu_assign_pointer(table->ti, new_ti); in flow_key_insert()
708 call_rcu(&ti->rcu, flow_tbl_destroy_rcu_cb); in flow_key_insert()
716 struct table_instance *ti; in flow_ufid_insert() local
719 ti = ovsl_dereference(table->ufid_ti); in flow_ufid_insert()
720 ufid_table_instance_insert(ti, flow); in flow_ufid_insert()
724 if (table->ufid_count > ti->n_buckets) { in flow_ufid_insert()
727 new_ti = table_instance_expand(ti, true); in flow_ufid_insert()
730 call_rcu(&ti->rcu, flow_tbl_destroy_rcu_cb); in flow_ufid_insert()