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()
462 struct sw_flow *flow) in table_instance_flow_free() argument
464 hlist_del_rcu(&flow->flow_table.node[ti->node_ver]); in table_instance_flow_free()
467 if (ovs_identifier_is_ufid(&flow->id)) { in table_instance_flow_free()
468 hlist_del_rcu(&flow->ufid_table.node[ufid_ti->node_ver]); in table_instance_flow_free()
472 flow_mask_remove(table, flow->mask); in table_instance_flow_free()
485 struct sw_flow *flow; in table_instance_flow_flush() local
487 hlist_for_each_entry_safe(flow, n, head, in table_instance_flow_flush()
491 flow); in table_instance_flow_flush()
492 ovs_flow_free(flow, true); in table_instance_flow_flush()
528 struct sw_flow *flow; in ovs_flow_tbl_dump_next() local
537 hlist_for_each_entry_rcu(flow, head, flow_table.node[ver]) { in ovs_flow_tbl_dump_next()
543 return flow; in ovs_flow_tbl_dump_next()
559 struct sw_flow *flow) in table_instance_insert() argument
563 head = find_bucket(ti, flow->flow_table.hash); in table_instance_insert()
564 hlist_add_head_rcu(&flow->flow_table.node[ti->node_ver], head); in table_instance_insert()
568 struct sw_flow *flow) in ufid_table_instance_insert() argument
572 head = find_bucket(ti, flow->ufid_table.hash); in ufid_table_instance_insert()
573 hlist_add_head_rcu(&flow->ufid_table.node[ti->node_ver], head); in ufid_table_instance_insert()
587 struct sw_flow *flow; in flow_table_copy_flows() local
591 hlist_for_each_entry_rcu(flow, head, in flow_table_copy_flows()
594 ufid_table_instance_insert(new, flow); in flow_table_copy_flows()
596 hlist_for_each_entry_rcu(flow, head, in flow_table_copy_flows()
599 table_instance_insert(new, flow); in flow_table_copy_flows()
680 static bool flow_cmp_masked_key(const struct sw_flow *flow, in flow_cmp_masked_key() argument
684 return cmp_key(&flow->key, key, range->start, range->end); in flow_cmp_masked_key()
687 static bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, in ovs_flow_cmp_unmasked_key() argument
694 BUG_ON(ovs_identifier_is_ufid(&flow->id)); in ovs_flow_cmp_unmasked_key()
695 return cmp_key(flow->id.unmasked_key, key, key_start, key_end); in ovs_flow_cmp_unmasked_key()
703 struct sw_flow *flow; in masked_flow_lookup() local
713 hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver], in masked_flow_lookup()
715 if (flow->mask == mask && flow->flow_table.hash == hash && in masked_flow_lookup()
716 flow_cmp_masked_key(flow, &masked_key, &mask->range)) in masked_flow_lookup()
717 return flow; in masked_flow_lookup()
722 /* Flow lookup does full lookup on flow table. It starts with
736 struct sw_flow *flow; in flow_lookup() local
743 flow = masked_flow_lookup(ti, key, mask, n_mask_hit); in flow_lookup()
744 if (flow) { in flow_lookup()
749 return flow; in flow_lookup()
763 flow = masked_flow_lookup(ti, key, mask, n_mask_hit); in flow_lookup()
764 if (flow) { /* Found */ in flow_lookup()
769 return flow; in flow_lookup()
777 * mask_cache maps flow to probable mask. This cache is not tightly
793 struct sw_flow *flow; in ovs_flow_tbl_lookup_stats() local
824 flow = flow_lookup(tbl, ti, ma, key, n_mask_hit, in ovs_flow_tbl_lookup_stats()
826 if (!flow) in ovs_flow_tbl_lookup_stats()
828 return flow; in ovs_flow_tbl_lookup_stats()
838 flow = flow_lookup(tbl, ti, ma, key, n_mask_hit, n_cache_hit, in ovs_flow_tbl_lookup_stats()
840 if (flow) in ovs_flow_tbl_lookup_stats()
844 return flow; in ovs_flow_tbl_lookup_stats()
854 struct sw_flow *flow; in ovs_flow_tbl_lookup() local
862 flow = flow_lookup(tbl, ti, ma, key, &n_mask_hit, &n_cache_hit, &index); in ovs_flow_tbl_lookup()
864 return flow; in ovs_flow_tbl_lookup()
878 struct sw_flow *flow; in ovs_flow_tbl_lookup_exact() local
884 flow = masked_flow_lookup(ti, match->key, mask, &n_mask_hit); in ovs_flow_tbl_lookup_exact()
885 if (flow && ovs_identifier_is_key(&flow->id) && in ovs_flow_tbl_lookup_exact()
886 ovs_flow_cmp_unmasked_key(flow, match)) { in ovs_flow_tbl_lookup_exact()
887 return flow; in ovs_flow_tbl_lookup_exact()
899 static bool ovs_flow_cmp_ufid(const struct sw_flow *flow, in ovs_flow_cmp_ufid() argument
902 if (flow->id.ufid_len != sfid->ufid_len) in ovs_flow_cmp_ufid()
905 return !memcmp(flow->id.ufid, sfid->ufid, sfid->ufid_len); in ovs_flow_cmp_ufid()
908 bool ovs_flow_cmp(const struct sw_flow *flow, in ovs_flow_cmp() argument
911 if (ovs_identifier_is_ufid(&flow->id)) in ovs_flow_cmp()
912 return flow_cmp_masked_key(flow, match->key, &match->range); in ovs_flow_cmp()
914 return ovs_flow_cmp_unmasked_key(flow, match); in ovs_flow_cmp()
921 struct sw_flow *flow; in ovs_flow_tbl_lookup_ufid() local
927 hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver], in ovs_flow_tbl_lookup_ufid()
929 if (flow->ufid_table.hash == hash && in ovs_flow_tbl_lookup_ufid()
930 ovs_flow_cmp_ufid(flow, ufid)) in ovs_flow_tbl_lookup_ufid()
931 return flow; in ovs_flow_tbl_lookup_ufid()
956 void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow) in ovs_flow_tbl_remove() argument
962 table_instance_flow_free(table, ti, ufid_ti, flow); in ovs_flow_tbl_remove()
1006 static int flow_mask_insert(struct flow_table *tbl, struct sw_flow *flow, in flow_mask_insert() argument
1030 flow->mask = mask; in flow_mask_insert()
1035 static void flow_key_insert(struct flow_table *table, struct sw_flow *flow) in flow_key_insert() argument
1040 flow->flow_table.hash = flow_hash(&flow->key, &flow->mask->range); in flow_key_insert()
1042 table_instance_insert(ti, flow); in flow_key_insert()
1059 static void flow_ufid_insert(struct flow_table *table, struct sw_flow *flow) in flow_ufid_insert() argument
1063 flow->ufid_table.hash = ufid_hash(&flow->id); in flow_ufid_insert()
1065 ufid_table_instance_insert(ti, flow); in flow_ufid_insert()
1081 int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow, in ovs_flow_tbl_insert() argument
1086 err = flow_mask_insert(table, flow, mask); in ovs_flow_tbl_insert()
1089 flow_key_insert(table, flow); in ovs_flow_tbl_insert()
1090 if (ovs_identifier_is_ufid(&flow->id)) in ovs_flow_tbl_insert()
1091 flow_ufid_insert(table, flow); in ovs_flow_tbl_insert()
1188 /* Initializes the flow module.
1215 /* Uninitializes the flow module. */