Lines Matching refs:flow
74 struct sw_flow *flow; in ovs_flow_alloc() local
77 flow = kmem_cache_zalloc(flow_cache, GFP_KERNEL); in ovs_flow_alloc()
78 if (!flow) in ovs_flow_alloc()
81 flow->stats_last_writer = -1; in ovs_flow_alloc()
92 RCU_INIT_POINTER(flow->stats[0], stats); in ovs_flow_alloc()
94 cpumask_set_cpu(0, &flow->cpu_used_mask); in ovs_flow_alloc()
96 return flow; in ovs_flow_alloc()
98 kmem_cache_free(flow_cache, flow); in ovs_flow_alloc()
107 static void flow_free(struct sw_flow *flow) in flow_free() argument
111 if (ovs_identifier_is_key(&flow->id)) in flow_free()
112 kfree(flow->id.unmasked_key); in flow_free()
113 if (flow->sf_acts) in flow_free()
115 flow->sf_acts); in flow_free()
118 cpu = cpumask_next(cpu, &flow->cpu_used_mask)) { in flow_free()
119 if (flow->stats[cpu]) in flow_free()
121 (struct sw_flow_stats __force *)flow->stats[cpu]); in flow_free()
124 kmem_cache_free(flow_cache, flow); in flow_free()
129 struct sw_flow *flow = container_of(rcu, struct sw_flow, rcu); in rcu_free_flow_callback() local
131 flow_free(flow); in rcu_free_flow_callback()
134 void ovs_flow_free(struct sw_flow *flow, bool deferred) in ovs_flow_free() argument
136 if (!flow) in ovs_flow_free()
140 call_rcu(&flow->rcu, rcu_free_flow_callback); in ovs_flow_free()
142 flow_free(flow); in ovs_flow_free()
464 struct sw_flow *flow) in table_instance_flow_free() argument
466 hlist_del_rcu(&flow->flow_table.node[ti->node_ver]); in table_instance_flow_free()
469 if (ovs_identifier_is_ufid(&flow->id)) { in table_instance_flow_free()
470 hlist_del_rcu(&flow->ufid_table.node[ufid_ti->node_ver]); in table_instance_flow_free()
474 flow_mask_remove(table, flow->mask); in table_instance_flow_free()
487 struct sw_flow *flow; in table_instance_flow_flush() local
489 hlist_for_each_entry_safe(flow, n, head, in table_instance_flow_flush()
493 flow); in table_instance_flow_flush()
494 ovs_flow_free(flow, true); in table_instance_flow_flush()
530 struct sw_flow *flow; in ovs_flow_tbl_dump_next() local
539 hlist_for_each_entry_rcu(flow, head, flow_table.node[ver]) { in ovs_flow_tbl_dump_next()
545 return flow; in ovs_flow_tbl_dump_next()
561 struct sw_flow *flow) in table_instance_insert() argument
565 head = find_bucket(ti, flow->flow_table.hash); in table_instance_insert()
566 hlist_add_head_rcu(&flow->flow_table.node[ti->node_ver], head); in table_instance_insert()
570 struct sw_flow *flow) in ufid_table_instance_insert() argument
574 head = find_bucket(ti, flow->ufid_table.hash); in ufid_table_instance_insert()
575 hlist_add_head_rcu(&flow->ufid_table.node[ti->node_ver], head); in ufid_table_instance_insert()
589 struct sw_flow *flow; in flow_table_copy_flows() local
593 hlist_for_each_entry_rcu(flow, head, in flow_table_copy_flows()
596 ufid_table_instance_insert(new, flow); in flow_table_copy_flows()
598 hlist_for_each_entry_rcu(flow, head, in flow_table_copy_flows()
601 table_instance_insert(new, flow); in flow_table_copy_flows()
682 static bool flow_cmp_masked_key(const struct sw_flow *flow, in flow_cmp_masked_key() argument
686 return cmp_key(&flow->key, key, range->start, range->end); in flow_cmp_masked_key()
689 static bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, in ovs_flow_cmp_unmasked_key() argument
696 BUG_ON(ovs_identifier_is_ufid(&flow->id)); in ovs_flow_cmp_unmasked_key()
697 return cmp_key(flow->id.unmasked_key, key, key_start, key_end); in ovs_flow_cmp_unmasked_key()
705 struct sw_flow *flow; in masked_flow_lookup() local
715 hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver], in masked_flow_lookup()
717 if (flow->mask == mask && flow->flow_table.hash == hash && in masked_flow_lookup()
718 flow_cmp_masked_key(flow, &masked_key, &mask->range)) in masked_flow_lookup()
719 return flow; in masked_flow_lookup()
738 struct sw_flow *flow; in flow_lookup() local
745 flow = masked_flow_lookup(ti, key, mask, n_mask_hit); in flow_lookup()
746 if (flow) { in flow_lookup()
751 return flow; in flow_lookup()
765 flow = masked_flow_lookup(ti, key, mask, n_mask_hit); in flow_lookup()
766 if (flow) { /* Found */ in flow_lookup()
771 return flow; in flow_lookup()
795 struct sw_flow *flow; in ovs_flow_tbl_lookup_stats() local
826 flow = flow_lookup(tbl, ti, ma, key, n_mask_hit, in ovs_flow_tbl_lookup_stats()
828 if (!flow) in ovs_flow_tbl_lookup_stats()
830 return flow; in ovs_flow_tbl_lookup_stats()
840 flow = flow_lookup(tbl, ti, ma, key, n_mask_hit, n_cache_hit, in ovs_flow_tbl_lookup_stats()
842 if (flow) in ovs_flow_tbl_lookup_stats()
846 return flow; in ovs_flow_tbl_lookup_stats()
856 struct sw_flow *flow; in ovs_flow_tbl_lookup() local
864 flow = flow_lookup(tbl, ti, ma, key, &n_mask_hit, &n_cache_hit, &index); in ovs_flow_tbl_lookup()
866 return flow; in ovs_flow_tbl_lookup()
880 struct sw_flow *flow; in ovs_flow_tbl_lookup_exact() local
886 flow = masked_flow_lookup(ti, match->key, mask, &n_mask_hit); in ovs_flow_tbl_lookup_exact()
887 if (flow && ovs_identifier_is_key(&flow->id) && in ovs_flow_tbl_lookup_exact()
888 ovs_flow_cmp_unmasked_key(flow, match)) { in ovs_flow_tbl_lookup_exact()
889 return flow; in ovs_flow_tbl_lookup_exact()
901 static bool ovs_flow_cmp_ufid(const struct sw_flow *flow, in ovs_flow_cmp_ufid() argument
904 if (flow->id.ufid_len != sfid->ufid_len) in ovs_flow_cmp_ufid()
907 return !memcmp(flow->id.ufid, sfid->ufid, sfid->ufid_len); in ovs_flow_cmp_ufid()
910 bool ovs_flow_cmp(const struct sw_flow *flow, in ovs_flow_cmp() argument
913 if (ovs_identifier_is_ufid(&flow->id)) in ovs_flow_cmp()
914 return flow_cmp_masked_key(flow, match->key, &match->range); in ovs_flow_cmp()
916 return ovs_flow_cmp_unmasked_key(flow, match); in ovs_flow_cmp()
923 struct sw_flow *flow; in ovs_flow_tbl_lookup_ufid() local
929 hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver], in ovs_flow_tbl_lookup_ufid()
931 if (flow->ufid_table.hash == hash && in ovs_flow_tbl_lookup_ufid()
932 ovs_flow_cmp_ufid(flow, ufid)) in ovs_flow_tbl_lookup_ufid()
933 return flow; in ovs_flow_tbl_lookup_ufid()
958 void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow) in ovs_flow_tbl_remove() argument
964 table_instance_flow_free(table, ti, ufid_ti, flow); in ovs_flow_tbl_remove()
1008 static int flow_mask_insert(struct flow_table *tbl, struct sw_flow *flow, in flow_mask_insert() argument
1032 flow->mask = mask; in flow_mask_insert()
1037 static void flow_key_insert(struct flow_table *table, struct sw_flow *flow) in flow_key_insert() argument
1042 flow->flow_table.hash = flow_hash(&flow->key, &flow->mask->range); in flow_key_insert()
1044 table_instance_insert(ti, flow); in flow_key_insert()
1061 static void flow_ufid_insert(struct flow_table *table, struct sw_flow *flow) in flow_ufid_insert() argument
1065 flow->ufid_table.hash = ufid_hash(&flow->id); in flow_ufid_insert()
1067 ufid_table_instance_insert(ti, flow); in flow_ufid_insert()
1083 int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, in ovs_flow_tbl_insert() argument
1088 err = flow_mask_insert(table, flow, mask); in ovs_flow_tbl_insert()
1091 flow_key_insert(table, flow); in ovs_flow_tbl_insert()
1092 if (ovs_identifier_is_ufid(&flow->id)) in ovs_flow_tbl_insert()
1093 flow_ufid_insert(table, flow); in ovs_flow_tbl_insert()