Lines Matching full:flow
6 #include "flow.h"
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()
82 flow->cpu_used_mask = (struct cpumask *)&flow->stats[nr_cpu_ids]; in ovs_flow_alloc()
93 RCU_INIT_POINTER(flow->stats[0], stats); in ovs_flow_alloc()
95 cpumask_set_cpu(0, flow->cpu_used_mask); in ovs_flow_alloc()
97 return flow; in ovs_flow_alloc()
99 kmem_cache_free(flow_cache, flow); in ovs_flow_alloc()
108 static void flow_free(struct sw_flow *flow) in flow_free() argument
112 if (ovs_identifier_is_key(&flow->id)) in flow_free()
113 kfree(flow->id.unmasked_key); in flow_free()
114 if (flow->sf_acts) in flow_free()
116 flow->sf_acts); in flow_free()
119 cpu = cpumask_next(cpu, flow->cpu_used_mask)) { in flow_free()
120 if (flow->stats[cpu]) in flow_free()
122 (struct sw_flow_stats __force *)flow->stats[cpu]); in flow_free()
125 kmem_cache_free(flow_cache, flow); in flow_free()
130 struct sw_flow *flow = container_of(rcu, struct sw_flow, rcu); in rcu_free_flow_callback() local
132 flow_free(flow); in rcu_free_flow_callback()
135 void ovs_flow_free(struct sw_flow *flow, bool deferred) in ovs_flow_free() argument
137 if (!flow) in ovs_flow_free()
141 call_rcu(&flow->rcu, rcu_free_flow_callback); in ovs_flow_free()
143 flow_free(flow); in ovs_flow_free()
465 struct sw_flow *flow) in table_instance_flow_free() argument
467 hlist_del_rcu(&flow->flow_table.node[ti->node_ver]); in table_instance_flow_free()
470 if (ovs_identifier_is_ufid(&flow->id)) { in table_instance_flow_free()
471 hlist_del_rcu(&flow->ufid_table.node[ufid_ti->node_ver]); in table_instance_flow_free()
475 flow_mask_remove(table, flow->mask); in table_instance_flow_free()
488 struct sw_flow *flow; in table_instance_flow_flush() local
490 hlist_for_each_entry_safe(flow, n, head, in table_instance_flow_flush()
494 flow); in table_instance_flow_flush()
495 ovs_flow_free(flow, true); in table_instance_flow_flush()
531 struct sw_flow *flow; in ovs_flow_tbl_dump_next() local
540 hlist_for_each_entry_rcu(flow, head, flow_table.node[ver]) { in ovs_flow_tbl_dump_next()
546 return flow; in ovs_flow_tbl_dump_next()
562 struct sw_flow *flow) in table_instance_insert() argument
566 head = find_bucket(ti, flow->flow_table.hash); in table_instance_insert()
567 hlist_add_head_rcu(&flow->flow_table.node[ti->node_ver], head); in table_instance_insert()
571 struct sw_flow *flow) in ufid_table_instance_insert() argument
575 head = find_bucket(ti, flow->ufid_table.hash); in ufid_table_instance_insert()
576 hlist_add_head_rcu(&flow->ufid_table.node[ti->node_ver], head); in ufid_table_instance_insert()
590 struct sw_flow *flow; in flow_table_copy_flows() local
594 hlist_for_each_entry_rcu(flow, head, in flow_table_copy_flows()
597 ufid_table_instance_insert(new, flow); in flow_table_copy_flows()
599 hlist_for_each_entry_rcu(flow, head, in flow_table_copy_flows()
602 table_instance_insert(new, flow); in flow_table_copy_flows()
683 static bool flow_cmp_masked_key(const struct sw_flow *flow, in flow_cmp_masked_key() argument
687 return cmp_key(&flow->key, key, range->start, range->end); in flow_cmp_masked_key()
690 static bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, in ovs_flow_cmp_unmasked_key() argument
697 BUG_ON(ovs_identifier_is_ufid(&flow->id)); in ovs_flow_cmp_unmasked_key()
698 return cmp_key(flow->id.unmasked_key, key, key_start, key_end); in ovs_flow_cmp_unmasked_key()
706 struct sw_flow *flow; in masked_flow_lookup() local
716 hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver], in masked_flow_lookup()
718 if (flow->mask == mask && flow->flow_table.hash == hash && in masked_flow_lookup()
719 flow_cmp_masked_key(flow, &masked_key, &mask->range)) in masked_flow_lookup()
720 return flow; in masked_flow_lookup()
725 /* Flow lookup does full lookup on flow table. It starts with
739 struct sw_flow *flow; in flow_lookup() local
746 flow = masked_flow_lookup(ti, key, mask, n_mask_hit); in flow_lookup()
747 if (flow) { in flow_lookup()
752 return flow; in flow_lookup()
766 flow = masked_flow_lookup(ti, key, mask, n_mask_hit); in flow_lookup()
767 if (flow) { /* Found */ in flow_lookup()
772 return flow; in flow_lookup()
780 * mask_cache maps flow to probable mask. This cache is not tightly
796 struct sw_flow *flow; in ovs_flow_tbl_lookup_stats() local
827 flow = flow_lookup(tbl, ti, ma, key, n_mask_hit, in ovs_flow_tbl_lookup_stats()
829 if (!flow) in ovs_flow_tbl_lookup_stats()
831 return flow; in ovs_flow_tbl_lookup_stats()
841 flow = flow_lookup(tbl, ti, ma, key, n_mask_hit, n_cache_hit, in ovs_flow_tbl_lookup_stats()
843 if (flow) in ovs_flow_tbl_lookup_stats()
847 return flow; in ovs_flow_tbl_lookup_stats()
857 struct sw_flow *flow; in ovs_flow_tbl_lookup() local
865 flow = flow_lookup(tbl, ti, ma, key, &n_mask_hit, &n_cache_hit, &index); in ovs_flow_tbl_lookup()
867 return flow; in ovs_flow_tbl_lookup()
881 struct sw_flow *flow; in ovs_flow_tbl_lookup_exact() local
887 flow = masked_flow_lookup(ti, match->key, mask, &n_mask_hit); in ovs_flow_tbl_lookup_exact()
888 if (flow && ovs_identifier_is_key(&flow->id) && in ovs_flow_tbl_lookup_exact()
889 ovs_flow_cmp_unmasked_key(flow, match)) { in ovs_flow_tbl_lookup_exact()
890 return flow; in ovs_flow_tbl_lookup_exact()
902 static bool ovs_flow_cmp_ufid(const struct sw_flow *flow, in ovs_flow_cmp_ufid() argument
905 if (flow->id.ufid_len != sfid->ufid_len) in ovs_flow_cmp_ufid()
908 return !memcmp(flow->id.ufid, sfid->ufid, sfid->ufid_len); in ovs_flow_cmp_ufid()
911 bool ovs_flow_cmp(const struct sw_flow *flow, in ovs_flow_cmp() argument
914 if (ovs_identifier_is_ufid(&flow->id)) in ovs_flow_cmp()
915 return flow_cmp_masked_key(flow, match->key, &match->range); in ovs_flow_cmp()
917 return ovs_flow_cmp_unmasked_key(flow, match); in ovs_flow_cmp()
924 struct sw_flow *flow; in ovs_flow_tbl_lookup_ufid() local
930 hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver], in ovs_flow_tbl_lookup_ufid()
932 if (flow->ufid_table.hash == hash && in ovs_flow_tbl_lookup_ufid()
933 ovs_flow_cmp_ufid(flow, ufid)) in ovs_flow_tbl_lookup_ufid()
934 return flow; in ovs_flow_tbl_lookup_ufid()
959 void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow) in ovs_flow_tbl_remove() argument
965 table_instance_flow_free(table, ti, ufid_ti, flow); in ovs_flow_tbl_remove()
1009 static int flow_mask_insert(struct flow_table *tbl, struct sw_flow *flow, in flow_mask_insert() argument
1033 flow->mask = mask; in flow_mask_insert()
1038 static void flow_key_insert(struct flow_table *table, struct sw_flow *flow) in flow_key_insert() argument
1043 flow->flow_table.hash = flow_hash(&flow->key, &flow->mask->range); in flow_key_insert()
1045 table_instance_insert(ti, flow); in flow_key_insert()
1062 static void flow_ufid_insert(struct flow_table *table, struct sw_flow *flow) in flow_ufid_insert() argument
1066 flow->ufid_table.hash = ufid_hash(&flow->id); in flow_ufid_insert()
1068 ufid_table_instance_insert(ti, flow); in flow_ufid_insert()
1084 int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, in ovs_flow_tbl_insert() argument
1089 err = flow_mask_insert(table, flow, mask); in ovs_flow_tbl_insert()
1092 flow_key_insert(table, flow); in ovs_flow_tbl_insert()
1093 if (ovs_identifier_is_ufid(&flow->id)) in ovs_flow_tbl_insert()
1094 flow_ufid_insert(table, flow); in ovs_flow_tbl_insert()
1191 /* Initializes the flow module.
1218 /* Uninitializes the flow module. */